askui 0.11.2 → 0.11.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,8 @@
1
1
  import { CustomElementJson } from '../custom-element-json';
2
+ import { DetectedElement } from './detected-element';
2
3
  export interface AnnotationRequest {
3
4
  imagePath?: string;
5
+ elements?: DetectedElement[];
4
6
  outputPath?: string;
5
7
  fileNamePrefix?: string;
6
8
  customElements?: CustomElementJson[];
@@ -1,3 +1,7 @@
1
1
  export declare class ControlCommandError extends Error {
2
+ matcherResult: {
3
+ pass: boolean;
4
+ message: string;
5
+ };
2
6
  constructor(message: string);
3
7
  }
@@ -2,5 +2,9 @@ export class ControlCommandError extends Error {
2
2
  constructor(message) {
3
3
  super(message);
4
4
  this.name = 'ControlCommandError';
5
+ this.matcherResult = {
6
+ pass: false,
7
+ message,
8
+ };
5
9
  }
6
10
  }
@@ -34,5 +34,5 @@ export declare class ExecutionRuntime {
34
34
  annotateInteractively(): Promise<void>;
35
35
  takeScreenshotIfImageisNotProvided(imagePath?: string): Promise<string>;
36
36
  getDetectedElements(instruction: string, customElementJson?: CustomElementJson[]): Promise<DetectedElement[]>;
37
- annotateImage(imagePath?: string, customElementJson?: CustomElementJson[]): Promise<Annotation>;
37
+ annotateImage(imagePath?: string, customElementJson?: CustomElementJson[], elements?: DetectedElement[]): Promise<Annotation>;
38
38
  }
@@ -12,6 +12,7 @@ import { CustomElement } from '../core/model/custom-element';
12
12
  import { RepeatError } from './repeat-error';
13
13
  import { delay } from './misc';
14
14
  import { ControlCommandError } from './control-command-error';
15
+ import { Annotation } from '../core/annotation/annotation';
15
16
  import { logger } from '../lib/logger';
16
17
  import { Base64Image } from '../utils/base_64_image/base-64-image';
17
18
  export class ExecutionRuntime {
@@ -188,10 +189,16 @@ export class ExecutionRuntime {
188
189
  return this.inferenceClient.getDetectedElements(instruction, base64Image, customElements);
189
190
  });
190
191
  }
191
- annotateImage(imagePath, customElementJson) {
192
+ annotateImage(imagePath, customElementJson, elements) {
192
193
  return __awaiter(this, void 0, void 0, function* () {
193
194
  let customElements = [];
194
195
  const base64Image = yield this.takeScreenshotIfImageisNotProvided(imagePath);
196
+ if (elements !== undefined) {
197
+ if (elements.length === 0) {
198
+ logger.warn("Parameter 'elements' is an empty list.");
199
+ }
200
+ return new Annotation(base64Image, elements);
201
+ }
195
202
  if (customElementJson !== undefined) {
196
203
  customElements = yield CustomElement.fromJsonListWithImagePathOrImage(customElementJson);
197
204
  }
@@ -89,7 +89,7 @@ export class UiControlClient extends ApiCommands {
89
89
  }
90
90
  annotate(annotationRequest = {}) {
91
91
  return __awaiter(this, void 0, void 0, function* () {
92
- const annotation = yield this.executionRuntime.annotateImage(annotationRequest.imagePath, annotationRequest.customElements);
92
+ const annotation = yield this.executionRuntime.annotateImage(annotationRequest.imagePath, annotationRequest.customElements, annotationRequest.elements);
93
93
  AnnotationWriter.write(annotation.toHtml(), annotationRequest.outputPath, annotationRequest.fileNamePrefix);
94
94
  return annotation;
95
95
  });
@@ -8,11 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { machineId } from 'node-machine-id';
11
+ import { logger } from '../../lib';
11
12
  export class UserIdentifier {
12
13
  // eslint-disable-next-line class-methods-use-this
13
14
  userId() {
14
15
  return __awaiter(this, void 0, void 0, function* () {
15
- return machineId();
16
+ try {
17
+ return yield machineId();
18
+ }
19
+ catch (error) {
20
+ logger.debug("Can't retrieve user id!", error);
21
+ return Promise.resolve('undefined');
22
+ }
16
23
  });
17
24
  }
18
25
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "askui",
3
- "version": "0.11.2",
3
+ "version": "0.11.4",
4
4
  "license": "MIT",
5
5
  "author": "askui GmbH <info@askui.com> (http://www.askui.com/)",
6
6
  "description": "Reliable, automated end-to-end-testing that depends on what is shown on your screen instead of the technology you are running on",