askui 0.7.0 → 0.7.2
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/annotation/annotation-json.d.ts +5 -0
- package/dist/cjs/core/annotation/annotation-json.js +2 -0
- package/dist/cjs/core/inference-response/inference-response.d.ts +7 -11
- package/dist/cjs/core/inference-response/inference-response.js +8 -13
- package/dist/cjs/core/inference-response/invalid-model-type-error.d.ts +4 -0
- package/dist/cjs/core/inference-response/invalid-model-type-error.js +9 -0
- package/dist/cjs/core/inference-response/model-type.d.ts +1 -0
- package/dist/cjs/core/inference-response/model-type.js +2 -0
- package/dist/cjs/core/model/test-case-dto/custom-element.spec.d.ts +1 -0
- package/dist/cjs/core/model/test-case-dto/custom-element.spec.js +53 -0
- package/dist/cjs/execution/dsl.d.ts +48 -0
- package/dist/cjs/execution/dsl.js +72 -0
- package/dist/cjs/execution/dsl.spec.d.ts +1 -0
- package/dist/cjs/execution/dsl.spec.js +75 -0
- package/dist/cjs/execution/inference-client.d.ts +1 -0
- package/dist/cjs/execution/inference-client.js +17 -8
- package/dist/cjs/execution/read-environment-credentials.spec.d.ts +1 -0
- package/dist/cjs/execution/read-environment-credentials.spec.js +11 -0
- package/dist/cjs/lib/download-binaries.d.ts +1 -1
- package/dist/cjs/lib/download-binaries.js +42 -29
- package/dist/cjs/lib/ui-controller-args.spec.d.ts +1 -0
- package/dist/cjs/lib/ui-controller-args.spec.js +23 -0
- package/dist/cjs/lib/ui-controller-darwin.js +3 -3
- package/dist/cjs/lib/ui-controller-facade.d.ts +1 -2
- package/dist/cjs/lib/ui-controller-facade.js +6 -11
- package/dist/cjs/lib/ui-controller-linux.js +1 -1
- package/dist/cjs/utils/http/credentials.spec.d.ts +1 -0
- package/dist/cjs/utils/http/credentials.spec.js +11 -0
- package/dist/cjs/utils/http/http-client-got.d.ts +5 -1
- package/dist/cjs/utils/http/http-client-got.js +12 -4
- package/dist/esm/core/annotation/annotation-json.d.ts +5 -0
- package/dist/esm/core/annotation/annotation-json.js +1 -0
- package/dist/esm/core/inference-response/inference-response.d.ts +7 -11
- package/dist/esm/core/inference-response/inference-response.js +8 -13
- package/dist/esm/core/inference-response/invalid-model-type-error.d.ts +4 -0
- package/dist/esm/core/inference-response/invalid-model-type-error.js +5 -0
- package/dist/esm/core/inference-response/model-type.d.ts +1 -0
- package/dist/esm/core/inference-response/model-type.js +1 -0
- package/dist/esm/core/model/test-case-dto/custom-element.spec.d.ts +1 -0
- package/dist/esm/core/model/test-case-dto/custom-element.spec.js +51 -0
- package/dist/esm/execution/dsl.d.ts +48 -0
- package/dist/esm/execution/dsl.js +72 -0
- package/dist/esm/execution/dsl.spec.d.ts +1 -0
- package/dist/esm/execution/dsl.spec.js +73 -0
- package/dist/esm/execution/inference-client.d.ts +1 -0
- package/dist/esm/execution/inference-client.js +17 -8
- package/dist/esm/execution/read-environment-credentials.spec.d.ts +1 -0
- package/dist/esm/execution/read-environment-credentials.spec.js +9 -0
- package/dist/esm/lib/download-binaries.d.ts +1 -1
- package/dist/esm/lib/download-binaries.js +40 -27
- package/dist/esm/lib/ui-controller-args.spec.d.ts +1 -0
- package/dist/esm/lib/ui-controller-args.spec.js +21 -0
- package/dist/esm/lib/ui-controller-darwin.js +3 -3
- package/dist/esm/lib/ui-controller-facade.d.ts +1 -2
- package/dist/esm/lib/ui-controller-facade.js +7 -12
- package/dist/esm/lib/ui-controller-linux.js +1 -1
- package/dist/esm/utils/http/credentials.spec.d.ts +1 -0
- package/dist/esm/utils/http/credentials.spec.js +9 -0
- package/dist/esm/utils/http/http-client-got.d.ts +5 -1
- package/dist/esm/utils/http/http-client-got.js +12 -4
- package/dist/example_projects_templates/typescript_jest/test/my-first-askui-test-suite.test.ts +5 -6
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UiControllerArgs, UiControllerArgsWithDefaults } from './ui-controller-args';
|
|
2
2
|
export declare abstract class UiControllerFacade {
|
|
3
|
-
protected
|
|
3
|
+
protected binaryFilePath: string;
|
|
4
4
|
protected serverLogFile: string;
|
|
5
5
|
protected readonly DefaultmaxWaitingForStartingInMs: number;
|
|
6
6
|
start(args?: UiControllerArgs, maxWaitingForStartingInSeconds?: number): Promise<void>;
|
|
@@ -11,7 +11,6 @@ export declare abstract class UiControllerFacade {
|
|
|
11
11
|
protected makeBinaryExecutable(): void;
|
|
12
12
|
protected runPreStartChecks(): Promise<void>;
|
|
13
13
|
protected waitUntilStarted(args: UiControllerArgsWithDefaults, maxWaitingForStartingInSeconds?: number): Promise<void>;
|
|
14
|
-
private isBinaryValid;
|
|
15
14
|
private getBinary;
|
|
16
15
|
private startWithDefaults;
|
|
17
16
|
}
|
|
@@ -27,7 +27,7 @@ const unkown_error_1 = require("./unkown-error");
|
|
|
27
27
|
const proxy_builder_1 = require("../utils/proxy/proxy-builder");
|
|
28
28
|
class UiControllerFacade {
|
|
29
29
|
constructor() {
|
|
30
|
-
this.
|
|
30
|
+
this.binaryFilePath = (0, download_binaries_1.getBinaryFilePath)('latest');
|
|
31
31
|
this.DefaultmaxWaitingForStartingInMs = 30 * 1000;
|
|
32
32
|
}
|
|
33
33
|
start(args, maxWaitingForStartingInSeconds) {
|
|
@@ -35,7 +35,7 @@ class UiControllerFacade {
|
|
|
35
35
|
yield this.runPreStartChecks();
|
|
36
36
|
const argsWithDefaults = (0, ui_controller_args_1.createArgsWithDefaults)(args);
|
|
37
37
|
const argsWithLogPath = this.serverLogFilePath(argsWithDefaults);
|
|
38
|
-
this.
|
|
38
|
+
this.binaryFilePath = (0, download_binaries_1.getBinaryFilePath)(argsWithLogPath.binaryVersion);
|
|
39
39
|
yield this.getBinary(argsWithLogPath.binaryVersion, argsWithLogPath.overWriteBinary, argsWithLogPath.proxyAgents || (yield (0, proxy_builder_1.buildProxyAgentArgsFromEnvironment)()));
|
|
40
40
|
this.makeBinaryExecutable();
|
|
41
41
|
logger_1.logger.debug(`UI Controller log path "${this.serverLogFile}"`);
|
|
@@ -71,7 +71,7 @@ class UiControllerFacade {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
getStartingCommand() {
|
|
74
|
-
return `"${this.
|
|
74
|
+
return `"${this.binaryFilePath}"`;
|
|
75
75
|
}
|
|
76
76
|
// eslint-disable-next-line class-methods-use-this
|
|
77
77
|
makeBinaryExecutable() {
|
|
@@ -105,19 +105,14 @@ class UiControllerFacade {
|
|
|
105
105
|
}
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
|
-
isBinaryValid() {
|
|
109
|
-
const sizeThresholdInMB = 100;
|
|
110
|
-
const binarysizeInMB = fs_extra_1.default.statSync(this.binaryPath).size / (1024 * 1024);
|
|
111
|
-
return binarysizeInMB > sizeThresholdInMB;
|
|
112
|
-
}
|
|
113
108
|
getBinary(binaryVersion, overWriteBinary = false, proxyAgent) {
|
|
114
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
-
if (!fs_extra_1.default.existsSync(this.
|
|
116
|
-
logger_1.logger.debug(`Currently, no binary of the UI Controller is available at "${this.
|
|
110
|
+
if (!fs_extra_1.default.existsSync(this.binaryFilePath) || overWriteBinary) {
|
|
111
|
+
logger_1.logger.debug(`Currently, no binary of the UI Controller is available at "${this.binaryFilePath}"`);
|
|
117
112
|
yield (0, download_binaries_1.downloadServerBinaries)(binaryVersion, proxyAgent);
|
|
118
113
|
}
|
|
119
114
|
else {
|
|
120
|
-
logger_1.logger.debug(`Binary of UI Controller is already present at "${this.
|
|
115
|
+
logger_1.logger.debug(`Binary of UI Controller is already present at "${this.binaryFilePath}".`);
|
|
121
116
|
}
|
|
122
117
|
});
|
|
123
118
|
}
|
|
@@ -19,7 +19,7 @@ const libfuse_error_1 = require("./libfuse-error");
|
|
|
19
19
|
class UiControllerLinux extends ui_controller_facade_1.UiControllerFacade {
|
|
20
20
|
// eslint-disable-next-line class-methods-use-this
|
|
21
21
|
makeBinaryExecutable() {
|
|
22
|
-
(0, child_process_1.exec)(`chmod +x "${this.
|
|
22
|
+
(0, child_process_1.exec)(`chmod +x "${this.binaryFilePath}"`, (_exception, stdout) => logger_1.logger.debug(stdout));
|
|
23
23
|
}
|
|
24
24
|
// eslint-disable-next-line class-methods-use-this
|
|
25
25
|
runPreStartChecks() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const credentials_1 = require("./credentials");
|
|
4
|
+
describe('Credentials', () => {
|
|
5
|
+
describe('base64Encoded()', () => {
|
|
6
|
+
test('should return base64-encoded credentials', () => {
|
|
7
|
+
const credentials = new credentials_1.Credentials('password');
|
|
8
|
+
expect(credentials.base64Encoded).toBe('cGFzc3dvcmQ=');
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { OptionsOfJSONResponseBody } from 'got';
|
|
2
3
|
import http from 'http';
|
|
3
4
|
import https from 'https';
|
|
@@ -17,6 +18,9 @@ export declare class HttpClientGot {
|
|
|
17
18
|
} | undefined);
|
|
18
19
|
private initHeaders;
|
|
19
20
|
private injectHeadersAndCookies;
|
|
20
|
-
post<T>(url: string, data: Record<string | number | symbol, unknown>): Promise<
|
|
21
|
+
post<T>(url: string, data: Record<string | number | symbol, unknown>): Promise<{
|
|
22
|
+
headers: http.IncomingHttpHeaders;
|
|
23
|
+
body: T;
|
|
24
|
+
}>;
|
|
21
25
|
get<T>(url: string, options?: OptionsOfJSONResponseBody): Promise<T>;
|
|
22
26
|
}
|
|
@@ -30,18 +30,26 @@ class HttpClientGot {
|
|
|
30
30
|
}
|
|
31
31
|
initHeaders(token, customHeaders = {}) {
|
|
32
32
|
const credentials = token ? new credentials_1.Credentials(token) : undefined;
|
|
33
|
-
this.headers = Object.assign(Object.assign({}, (credentials
|
|
33
|
+
this.headers = Object.assign(Object.assign({}, (credentials
|
|
34
|
+
? { Authorization: `Basic ${credentials === null || credentials === void 0 ? void 0 : credentials.base64Encoded}` }
|
|
35
|
+
: {})), customHeaders);
|
|
34
36
|
}
|
|
35
37
|
injectHeadersAndCookies(url, options) {
|
|
36
38
|
const cookieJar = new tough_cookie_1.CookieJar();
|
|
37
|
-
Object.keys(this.cookies)
|
|
39
|
+
Object.keys(this.cookies)
|
|
40
|
+
.map((key) => `${key}=${this.cookies[key]}`)
|
|
41
|
+
.forEach((cookie) => {
|
|
38
42
|
cookieJar.setCookieSync(cookie, url);
|
|
39
43
|
});
|
|
40
44
|
return Object.assign(Object.assign({}, options), { headers: this.headers, cookieJar });
|
|
41
45
|
}
|
|
42
46
|
post(url, data) {
|
|
43
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
const options = this.injectHeadersAndCookies(url, {
|
|
48
|
+
const options = this.injectHeadersAndCookies(url, {
|
|
49
|
+
json: data,
|
|
50
|
+
responseType: 'json',
|
|
51
|
+
throwHttpErrors: false,
|
|
52
|
+
});
|
|
45
53
|
const { body, statusCode, headers } = yield this.askuiGot.post(url, options);
|
|
46
54
|
if (headers['deprecation'] !== undefined) {
|
|
47
55
|
lib_1.logger.warn(headers['deprecation']);
|
|
@@ -49,7 +57,7 @@ class HttpClientGot {
|
|
|
49
57
|
if (statusCode !== 200) {
|
|
50
58
|
throw (0, custom_errors_1.httpClientErrorHandler)(statusCode, JSON.stringify(body));
|
|
51
59
|
}
|
|
52
|
-
return body;
|
|
60
|
+
return { headers, body };
|
|
53
61
|
});
|
|
54
62
|
}
|
|
55
63
|
get(url, options = { responseType: 'json' }) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { ControlCommand } from '../ui-control-commands/control-command';
|
|
2
2
|
import { Annotation } from '../annotation/annotation';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
static fromJson(json: unknown, resizeRatio?: number, image?: string): ControlCommand | Annotation;
|
|
8
|
-
static createModels(type: string, data: ControlCommand | Annotation, resizeRatio: number, image?: string): ControlCommand | Annotation;
|
|
9
|
-
static models: Models;
|
|
3
|
+
import { ModelType } from './model-type';
|
|
4
|
+
export interface InferenceResponseBody {
|
|
5
|
+
type: ModelType;
|
|
6
|
+
data: ModelType extends 'COMMANDS' ? ControlCommand : Annotation;
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
COMMANDS:
|
|
8
|
+
export declare class InferenceResponse {
|
|
9
|
+
static fromJson(json: InferenceResponseBody, resizeRatio?: number, image?: string): ControlCommand | Annotation;
|
|
10
|
+
static createModels(type: ModelType, data: ModelType extends 'COMMANDS' ? ControlCommand : Annotation, resizeRatio: number, image?: string): ControlCommand | Annotation;
|
|
14
11
|
}
|
|
15
|
-
export {};
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import { ControlCommand } from '../ui-control-commands/control-command';
|
|
2
2
|
import { Annotation } from '../annotation/annotation';
|
|
3
|
+
import { InvalidModelTypeError } from './invalid-model-type-error';
|
|
3
4
|
export class InferenceResponse {
|
|
4
|
-
constructor(type, data) {
|
|
5
|
-
this.type = type;
|
|
6
|
-
this.data = data;
|
|
7
|
-
}
|
|
8
5
|
static fromJson(json, resizeRatio = 1, image) {
|
|
9
|
-
|
|
10
|
-
return this.createModels(inferenceResponse.type, inferenceResponse.data, resizeRatio, image);
|
|
6
|
+
return this.createModels(json.type, json.data, resizeRatio, image);
|
|
11
7
|
}
|
|
12
8
|
static createModels(type, data, resizeRatio, image) {
|
|
13
|
-
|
|
9
|
+
if (type === 'COMMANDS')
|
|
10
|
+
return ControlCommand.fromJson(data, resizeRatio);
|
|
11
|
+
if (type === 'DETECTED_ELEMENTS') {
|
|
12
|
+
return Annotation.fromJson({ image, detected_elements: data.detected_elements }, resizeRatio);
|
|
13
|
+
}
|
|
14
|
+
throw new InvalidModelTypeError(type);
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
|
-
InferenceResponse.models = {
|
|
17
|
-
DETECTED_ELEMENTS: (data, resizeRatio, image) => Annotation
|
|
18
|
-
.fromJson({ image, detected_elements: data.detected_elements }, resizeRatio),
|
|
19
|
-
COMMANDS: (data, resizeRatio) => ControlCommand
|
|
20
|
-
.fromJson(data, resizeRatio),
|
|
21
|
-
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare type ModelType = 'DETECTED_ELEMENTS' | 'COMMANDS';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { CustomElement } from './custom-element';
|
|
11
|
+
const base64ImageString = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAA8CAYAAADWibxkAAAACXBIWXMAABYlAAAWJQFJUiTwAAAN20lEQVRogXVa3XrbSg7T7XHsfZyNneSJtm2cOH1/7UeCIMCRz4Xa2NYPhwRBkKPtdv7e306P/e3le7+dP+v43t9eHvt7HOfH/nb53q/12/vLdx5vL/f97RT/x/G53y73/e1S19Q5ccS9buc7zrt87+/nL1x/wvW3Sxz3/f3lnr/p/Pgu7HrUb/c8j/fC/XHdR9rJa2F7rieeV3/zmrhv3OP9BWvZciF1QvxwO9339xNP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Iaiaz4ufcDoID/36z/6ngq0ecPIVAGaQxF33NxWW6T82gD16/64bnvW3a2sj0X+6irhg9SuHN5EWat8lK84Mt9NPrv66+bniV2H/ckDaZqSbVu0FpIie57NGRs8MAcSLFVeruQAzQ7YJQ4uaX6Z7xtN5TZl8GEy1LZIq/jmzUDL4ZUaG4baMNcD/H8hlYADpzRH1QAAAABJRU5ErkJggg==';
|
|
12
|
+
describe('CustomElement', () => {
|
|
13
|
+
describe('fromJsonWithImagePathOrImage', () => {
|
|
14
|
+
test('should return CustomElement if CustomElement created from JSON is valid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const expected = new CustomElement(base64ImageString, 'Dummy_element', 0.7, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 3, y: 4 }]);
|
|
16
|
+
const actual = yield CustomElement.fromJsonWithImagePathOrImage({
|
|
17
|
+
customImage: base64ImageString,
|
|
18
|
+
name: 'Dummy_element',
|
|
19
|
+
threshold: 0.7,
|
|
20
|
+
rotationDegreePerStep: 10,
|
|
21
|
+
imageCompareFormat: 'RGB',
|
|
22
|
+
mask: [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 3, y: 4 }],
|
|
23
|
+
});
|
|
24
|
+
expect(actual).toStrictEqual(expected);
|
|
25
|
+
}));
|
|
26
|
+
test('should throw ValidationError if threshold is invalid', () => {
|
|
27
|
+
expect(() => {
|
|
28
|
+
const customElement = new CustomElement(base64ImageString, 'Dummy_element', 1.1, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 3, y: 4 }]);
|
|
29
|
+
customElement.validate();
|
|
30
|
+
}).toThrow('threshold must be less than or equal to 1');
|
|
31
|
+
});
|
|
32
|
+
test('should throw ValidationError if rotationDegreePerStep is invalid', () => {
|
|
33
|
+
expect(() => {
|
|
34
|
+
const customElement = new CustomElement(base64ImageString, 'Dummy_element', 0.9, -90, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 3, y: 4 }]);
|
|
35
|
+
customElement.validate();
|
|
36
|
+
}).toThrow('rotationDegreePerStep must be greater than or equal to 0');
|
|
37
|
+
});
|
|
38
|
+
test('should throw ValidationError if mask is invalid', () => {
|
|
39
|
+
expect(() => {
|
|
40
|
+
const customElement = new CustomElement(base64ImageString, 'Dummy_element', 0.9, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }]);
|
|
41
|
+
customElement.validate();
|
|
42
|
+
}).toThrow('mask must contain at least 3 points');
|
|
43
|
+
});
|
|
44
|
+
test('should throw ValidationError if mask and threshold are both invalid', () => {
|
|
45
|
+
expect(() => {
|
|
46
|
+
const customElement = new CustomElement(base64ImageString, 'Dummy_element', 90, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }]);
|
|
47
|
+
customElement.validate();
|
|
48
|
+
}).toThrow('threshold must be less than or equal to 1, mask must contain at least 3 points');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -1779,6 +1779,54 @@ export declare abstract class FluentCommand extends FluentBase {
|
|
|
1779
1779
|
* @return {Exec}
|
|
1780
1780
|
*/
|
|
1781
1781
|
execOnShell(shell_command: string): Exec;
|
|
1782
|
+
/**
|
|
1783
|
+
* Clicks with left mouse key.
|
|
1784
|
+
*
|
|
1785
|
+
* @return {Exec}
|
|
1786
|
+
*/
|
|
1787
|
+
mouseLeftClick(): Exec;
|
|
1788
|
+
/**
|
|
1789
|
+
* Clicks with right mouse key.
|
|
1790
|
+
*
|
|
1791
|
+
* @return {Exec}
|
|
1792
|
+
*/
|
|
1793
|
+
mouseRightClick(): Exec;
|
|
1794
|
+
/**
|
|
1795
|
+
* Clicks with middle mouse key.
|
|
1796
|
+
*
|
|
1797
|
+
* @return {Exec}
|
|
1798
|
+
*/
|
|
1799
|
+
mouseMiddleClick(): Exec;
|
|
1800
|
+
/**
|
|
1801
|
+
* Double-clicks with left mouse key.
|
|
1802
|
+
*
|
|
1803
|
+
* @return {Exec}
|
|
1804
|
+
*/
|
|
1805
|
+
mouseDoubleLeftClick(): Exec;
|
|
1806
|
+
/**
|
|
1807
|
+
* Double-clicks with right mouse key.
|
|
1808
|
+
*
|
|
1809
|
+
* @return {Exec}
|
|
1810
|
+
*/
|
|
1811
|
+
mouseDoubleRightClick(): Exec;
|
|
1812
|
+
/**
|
|
1813
|
+
* Double-clicks with middle mouse key.
|
|
1814
|
+
*
|
|
1815
|
+
* @return {Exec}
|
|
1816
|
+
*/
|
|
1817
|
+
mouseDoubleMiddleClick(): Exec;
|
|
1818
|
+
/**
|
|
1819
|
+
* Toggles mouse down (Left mouse key).
|
|
1820
|
+
*
|
|
1821
|
+
* @return {Exec}
|
|
1822
|
+
*/
|
|
1823
|
+
mouseToggleDown(): Exec;
|
|
1824
|
+
/**
|
|
1825
|
+
* Toggles mouse up (Left mouse key).
|
|
1826
|
+
*
|
|
1827
|
+
* @return {Exec}
|
|
1828
|
+
*/
|
|
1829
|
+
mouseToggleUp(): Exec;
|
|
1782
1830
|
/**
|
|
1783
1831
|
* Press three keys like `CTRL+ALT+DEL`
|
|
1784
1832
|
*
|
|
@@ -2361,6 +2361,78 @@ export class FluentCommand extends FluentBase {
|
|
|
2361
2361
|
this._textStr = `Execute shell command ${Separators.STRING}${shell_command}${Separators.STRING}`;
|
|
2362
2362
|
return new Exec(this);
|
|
2363
2363
|
}
|
|
2364
|
+
/**
|
|
2365
|
+
* Clicks with left mouse key.
|
|
2366
|
+
*
|
|
2367
|
+
* @return {Exec}
|
|
2368
|
+
*/
|
|
2369
|
+
mouseLeftClick() {
|
|
2370
|
+
this._textStr = 'Mouse left click';
|
|
2371
|
+
return new Exec(this);
|
|
2372
|
+
}
|
|
2373
|
+
/**
|
|
2374
|
+
* Clicks with right mouse key.
|
|
2375
|
+
*
|
|
2376
|
+
* @return {Exec}
|
|
2377
|
+
*/
|
|
2378
|
+
mouseRightClick() {
|
|
2379
|
+
this._textStr = 'Mouse right click';
|
|
2380
|
+
return new Exec(this);
|
|
2381
|
+
}
|
|
2382
|
+
/**
|
|
2383
|
+
* Clicks with middle mouse key.
|
|
2384
|
+
*
|
|
2385
|
+
* @return {Exec}
|
|
2386
|
+
*/
|
|
2387
|
+
mouseMiddleClick() {
|
|
2388
|
+
this._textStr = 'Mouse middle click';
|
|
2389
|
+
return new Exec(this);
|
|
2390
|
+
}
|
|
2391
|
+
/**
|
|
2392
|
+
* Double-clicks with left mouse key.
|
|
2393
|
+
*
|
|
2394
|
+
* @return {Exec}
|
|
2395
|
+
*/
|
|
2396
|
+
mouseDoubleLeftClick() {
|
|
2397
|
+
this._textStr = 'Mouse double left click';
|
|
2398
|
+
return new Exec(this);
|
|
2399
|
+
}
|
|
2400
|
+
/**
|
|
2401
|
+
* Double-clicks with right mouse key.
|
|
2402
|
+
*
|
|
2403
|
+
* @return {Exec}
|
|
2404
|
+
*/
|
|
2405
|
+
mouseDoubleRightClick() {
|
|
2406
|
+
this._textStr = 'Mouse double right click';
|
|
2407
|
+
return new Exec(this);
|
|
2408
|
+
}
|
|
2409
|
+
/**
|
|
2410
|
+
* Double-clicks with middle mouse key.
|
|
2411
|
+
*
|
|
2412
|
+
* @return {Exec}
|
|
2413
|
+
*/
|
|
2414
|
+
mouseDoubleMiddleClick() {
|
|
2415
|
+
this._textStr = 'Mouse double middle click';
|
|
2416
|
+
return new Exec(this);
|
|
2417
|
+
}
|
|
2418
|
+
/**
|
|
2419
|
+
* Toggles mouse down (Left mouse key).
|
|
2420
|
+
*
|
|
2421
|
+
* @return {Exec}
|
|
2422
|
+
*/
|
|
2423
|
+
mouseToggleDown() {
|
|
2424
|
+
this._textStr = 'Mouse toggle down';
|
|
2425
|
+
return new Exec(this);
|
|
2426
|
+
}
|
|
2427
|
+
/**
|
|
2428
|
+
* Toggles mouse up (Left mouse key).
|
|
2429
|
+
*
|
|
2430
|
+
* @return {Exec}
|
|
2431
|
+
*/
|
|
2432
|
+
mouseToggleUp() {
|
|
2433
|
+
this._textStr = 'Mouse toggle up';
|
|
2434
|
+
return new Exec(this);
|
|
2435
|
+
}
|
|
2364
2436
|
/**
|
|
2365
2437
|
* Press three keys like `CTRL+ALT+DEL`
|
|
2366
2438
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { FluentCommand } from './dsl';
|
|
11
|
+
class TestCommand extends FluentCommand {
|
|
12
|
+
// eslint-disable-next-line class-methods-use-this
|
|
13
|
+
fluentCommandExecutor(instruction, customElements) {
|
|
14
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
15
|
+
// eslint-disable-next-line no-console
|
|
16
|
+
console.log(`${instruction} ${customElements}`);
|
|
17
|
+
return Promise.resolve();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
describe('DSL', () => {
|
|
22
|
+
describe('custom element', () => {
|
|
23
|
+
test('should call exec function with zero custom element', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
const underTest = new TestCommand();
|
|
25
|
+
const testCommandSpy = jest.spyOn(underTest, 'fluentCommandExecutor');
|
|
26
|
+
yield underTest.click().button()
|
|
27
|
+
.exec();
|
|
28
|
+
expect(testCommandSpy).toHaveBeenCalledWith('Click on button', []);
|
|
29
|
+
}));
|
|
30
|
+
test('should call exec function with one custom element', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
const underTest = new TestCommand();
|
|
32
|
+
const testCommandSpy = jest.spyOn(underTest, 'fluentCommandExecutor');
|
|
33
|
+
yield underTest.click().customElement({
|
|
34
|
+
customImage: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==',
|
|
35
|
+
imageCompareFormat: 'grayscale',
|
|
36
|
+
name: 'custom element 1',
|
|
37
|
+
}).button()
|
|
38
|
+
.exec();
|
|
39
|
+
expect(testCommandSpy).toHaveBeenCalledWith('Click on custom element button', [{
|
|
40
|
+
customImage: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==',
|
|
41
|
+
imageCompareFormat: 'grayscale',
|
|
42
|
+
name: 'custom element 1',
|
|
43
|
+
}]);
|
|
44
|
+
}));
|
|
45
|
+
test('should call exec function with two custom element', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
const underTest = new TestCommand();
|
|
47
|
+
const testCommandSpy = jest.spyOn(underTest, 'fluentCommandExecutor');
|
|
48
|
+
yield underTest.click().customElement({
|
|
49
|
+
customImage: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==',
|
|
50
|
+
imageCompareFormat: 'grayscale',
|
|
51
|
+
name: 'custom element 1',
|
|
52
|
+
})
|
|
53
|
+
.button()
|
|
54
|
+
.customElement({
|
|
55
|
+
customImage: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==',
|
|
56
|
+
imageCompareFormat: 'grayscale',
|
|
57
|
+
name: 'custom element 2',
|
|
58
|
+
})
|
|
59
|
+
.exec();
|
|
60
|
+
expect(testCommandSpy).toHaveBeenCalledWith('Click on custom element button custom element', [{
|
|
61
|
+
customImage: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==',
|
|
62
|
+
imageCompareFormat: 'grayscale',
|
|
63
|
+
name: 'custom element 1',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
customImage: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==',
|
|
67
|
+
imageCompareFormat: 'grayscale',
|
|
68
|
+
name: 'custom element 2',
|
|
69
|
+
},
|
|
70
|
+
]);
|
|
71
|
+
}));
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -14,6 +14,7 @@ export declare class InferenceClient {
|
|
|
14
14
|
isImageRequired(instruction: string): Promise<boolean>;
|
|
15
15
|
private resizeIfNeeded;
|
|
16
16
|
inference(customElements?: CustomElement[], image?: string, instruction?: string): Promise<ControlCommand | Annotation>;
|
|
17
|
+
private static logMetaInformation;
|
|
17
18
|
predictControlCommand(instruction: string, customElements?: CustomElement[], image?: string): Promise<ControlCommand>;
|
|
18
19
|
getDetectedElements(instruction: string, image: string, customElements?: CustomElement[]): Promise<DetectedElement[]>;
|
|
19
20
|
predictImageAnnotation(image: string, customElements?: CustomElement[]): Promise<Annotation>;
|
|
@@ -13,6 +13,7 @@ import { Annotation } from '../core/annotation/annotation';
|
|
|
13
13
|
import { resizeBase64ImageWithSameRatio } from '../utils/transformations';
|
|
14
14
|
import { InferenceResponseError } from './inference-response-error';
|
|
15
15
|
import { ConfigurationError } from './config-error';
|
|
16
|
+
import { logger } from '../lib/logger';
|
|
16
17
|
export class InferenceClient {
|
|
17
18
|
constructor(baseUrl, httpClient, resize, workspaceId, apiVersion = 'v3') {
|
|
18
19
|
this.baseUrl = baseUrl;
|
|
@@ -21,7 +22,9 @@ export class InferenceClient {
|
|
|
21
22
|
this.workspaceId = workspaceId;
|
|
22
23
|
this.apiVersion = apiVersion;
|
|
23
24
|
const versionedBaseUrl = urljoin(this.baseUrl, 'api', this.apiVersion);
|
|
24
|
-
this.url = workspaceId
|
|
25
|
+
this.url = workspaceId
|
|
26
|
+
? urljoin(versionedBaseUrl, 'workspaces', workspaceId)
|
|
27
|
+
: versionedBaseUrl;
|
|
25
28
|
if (this.resize !== undefined && this.resize <= 0) {
|
|
26
29
|
throw new ConfigurationError(`Resize must be a positive number. The current resize value "${this.resize}" is not valid.`);
|
|
27
30
|
}
|
|
@@ -30,17 +33,17 @@ export class InferenceClient {
|
|
|
30
33
|
isImageRequired(instruction) {
|
|
31
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
32
35
|
const url = urljoin(this.url, 'instruction', 'is-image-required');
|
|
33
|
-
const
|
|
36
|
+
const requestBody = {
|
|
34
37
|
instruction,
|
|
35
38
|
};
|
|
36
|
-
const
|
|
37
|
-
return
|
|
39
|
+
const response = yield this.httpClient.post(url, requestBody);
|
|
40
|
+
return response.body.isImageRequired;
|
|
38
41
|
});
|
|
39
42
|
}
|
|
40
43
|
// eslint-disable-next-line class-methods-use-this
|
|
41
44
|
resizeIfNeeded(customElements, image) {
|
|
42
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
if (!
|
|
46
|
+
if (!image || customElements.length > 0 || this.resize === undefined) {
|
|
44
47
|
return { base64Image: image, resizeRatio: 1 };
|
|
45
48
|
}
|
|
46
49
|
return resizeBase64ImageWithSameRatio(image, this.resize);
|
|
@@ -49,16 +52,22 @@ export class InferenceClient {
|
|
|
49
52
|
inference(customElements = [], image, instruction) {
|
|
50
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
54
|
const resizedImage = yield this.resizeIfNeeded(customElements, image);
|
|
52
|
-
const
|
|
55
|
+
const requestBody = {
|
|
53
56
|
image: resizedImage.base64Image,
|
|
54
57
|
instruction,
|
|
55
58
|
customElements,
|
|
56
59
|
};
|
|
57
60
|
const url = urljoin(this.url, 'inference');
|
|
58
|
-
const
|
|
59
|
-
|
|
61
|
+
const response = yield this.httpClient.post(url, requestBody);
|
|
62
|
+
InferenceClient.logMetaInformation(response);
|
|
63
|
+
return InferenceResponse.fromJson(response.body, resizedImage.resizeRatio, image);
|
|
60
64
|
});
|
|
61
65
|
}
|
|
66
|
+
static logMetaInformation(response) {
|
|
67
|
+
if (response.headers['askui-usage-warnings'] !== undefined) {
|
|
68
|
+
logger.warn(response.headers['askui-usage-warnings']);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
62
71
|
predictControlCommand(instruction, customElements = [], image) {
|
|
63
72
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
73
|
const inferenceResponse = yield this.inference(customElements, image, instruction);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { envCredentials } from './read-environment-credentials';
|
|
2
|
+
describe('envCredentials()', () => {
|
|
3
|
+
test('should read the credentials from the environment variables', () => {
|
|
4
|
+
process.env['ASKUI_TOKEN'] = 'token';
|
|
5
|
+
process.env['ASKUI_WORKSPACE_ID'] = 'id123';
|
|
6
|
+
const credentialsFromTheEnv = envCredentials();
|
|
7
|
+
expect(credentialsFromTheEnv).toStrictEqual({ workspaceId: 'id123', token: 'token' });
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -7,7 +7,7 @@ declare enum SupportedPlatform {
|
|
|
7
7
|
WIN32 = "win32"
|
|
8
8
|
}
|
|
9
9
|
export declare function platform(): SupportedPlatform;
|
|
10
|
-
export declare function
|
|
10
|
+
export declare function getBinaryFilePath(version: string): string;
|
|
11
11
|
export declare function downloadServerBinaries(binaryVersion: string, proxyAgent?: {
|
|
12
12
|
http: http.Agent;
|
|
13
13
|
https: https.Agent;
|