askui 0.18.1 → 0.20.0
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/ai-element/ai-element-collection.d.ts +10 -0
- package/dist/cjs/core/ai-element/ai-element-collection.js +78 -0
- package/dist/cjs/core/ai-element/ai-element-error.d.ts +2 -0
- package/dist/cjs/core/ai-element/ai-element-error.js +6 -0
- package/dist/cjs/core/ai-element/ai-element.d.ts +27 -0
- package/dist/cjs/core/ai-element/ai-element.js +31 -0
- package/dist/cjs/execution/dsl.d.ts +127 -17
- package/dist/cjs/execution/dsl.js +158 -17
- package/dist/cjs/execution/index.d.ts +1 -1
- package/dist/cjs/execution/index.js +11 -3
- package/dist/cjs/execution/ui-control-client-dependency-builder.d.ts +1 -0
- package/dist/cjs/execution/ui-control-client-dependency-builder.js +3 -0
- package/dist/cjs/execution/ui-control-client.d.ts +101 -16
- package/dist/cjs/execution/ui-control-client.js +145 -52
- package/dist/cjs/main.d.ts +1 -1
- package/dist/cjs/main.js +12 -3
- package/dist/cjs/utils/analytics/analytics.d.ts +1 -1
- package/dist/esm/core/ai-element/ai-element-collection.d.ts +10 -0
- package/dist/esm/core/ai-element/ai-element-collection.js +71 -0
- package/dist/esm/core/ai-element/ai-element-error.d.ts +2 -0
- package/dist/esm/core/ai-element/ai-element-error.js +2 -0
- package/dist/esm/core/ai-element/ai-element.d.ts +27 -0
- package/dist/esm/core/ai-element/ai-element.js +28 -0
- package/dist/esm/execution/dsl.d.ts +127 -17
- package/dist/esm/execution/dsl.js +158 -17
- package/dist/esm/execution/index.d.ts +1 -1
- package/dist/esm/execution/index.js +1 -1
- package/dist/esm/execution/ui-control-client-dependency-builder.d.ts +1 -0
- package/dist/esm/execution/ui-control-client-dependency-builder.js +3 -0
- package/dist/esm/execution/ui-control-client.d.ts +101 -16
- package/dist/esm/execution/ui-control-client.js +145 -49
- package/dist/esm/main.d.ts +1 -1
- package/dist/esm/main.js +1 -1
- package/dist/esm/utils/analytics/analytics.d.ts +1 -1
- package/package.json +1 -1
- package/dist/cjs/core/annotation/annotation-writer.js.map +0 -1
- package/dist/cjs/core/annotation/annotation.js.map +0 -1
- package/dist/cjs/core/inference-response/inference-response.js.map +0 -1
- package/dist/cjs/core/inference-response/invalid-model-type-error.js.map +0 -1
- package/dist/cjs/core/inference-response/model-type.js.map +0 -1
- package/dist/cjs/core/model/annotation-result/annotation-interface.js.map +0 -1
- package/dist/cjs/core/model/annotation-result/boundary-box.js.map +0 -1
- package/dist/cjs/core/model/annotation-result/detected-element.js.map +0 -1
- package/dist/cjs/core/model/custom-element-json.js.map +0 -1
- package/dist/cjs/core/model/custom-element.js.map +0 -1
- package/dist/cjs/core/reporting/default-step.js.map +0 -1
- package/dist/cjs/core/reporting/index.js.map +0 -1
- package/dist/cjs/core/reporting/instruction.js.map +0 -1
- package/dist/cjs/core/reporting/reporter-config.js.map +0 -1
- package/dist/cjs/core/reporting/reporter.js.map +0 -1
- package/dist/cjs/core/reporting/snapshot-detail-level.js.map +0 -1
- package/dist/cjs/core/reporting/snapshot.js.map +0 -1
- package/dist/cjs/core/reporting/step-reporter.js.map +0 -1
- package/dist/cjs/core/reporting/step-run.js.map +0 -1
- package/dist/cjs/core/reporting/step-status-end.js.map +0 -1
- package/dist/cjs/core/reporting/step-status.js.map +0 -1
- package/dist/cjs/core/reporting/step.js.map +0 -1
- package/dist/cjs/core/runner-protocol/index.js.map +0 -1
- package/dist/cjs/core/runner-protocol/request/capture-screenshot-request.js.map +0 -1
- package/dist/cjs/core/runner-protocol/request/control-request.js.map +0 -1
- package/dist/cjs/core/runner-protocol/request/get-server-process-pid.js.map +0 -1
- package/dist/cjs/core/runner-protocol/request/index.js.map +0 -1
- package/dist/cjs/core/runner-protocol/request/interactive-annotation-request.js.map +0 -1
- package/dist/cjs/core/runner-protocol/request/read-recording-request.js.map +0 -1
- package/dist/cjs/core/runner-protocol/request/runner-protocol-request.js.map +0 -1
- package/dist/cjs/core/runner-protocol/request/start-recording-request.js.map +0 -1
- package/dist/cjs/core/runner-protocol/request/stop-recording-request.js.map +0 -1
- package/dist/cjs/core/runner-protocol/response/index.js.map +0 -1
- package/dist/cjs/core/ui-control-commands/action.js.map +0 -1
- package/dist/cjs/core/ui-control-commands/control-command-code.js.map +0 -1
- package/dist/cjs/core/ui-control-commands/control-command.js.map +0 -1
- package/dist/cjs/core/ui-control-commands/index.js.map +0 -1
- package/dist/cjs/core/ui-control-commands/input-event.js.map +0 -1
- package/dist/cjs/execution/config-error.js.map +0 -1
- package/dist/cjs/execution/control-command-error.js.map +0 -1
- package/dist/cjs/execution/credentials-args.js.map +0 -1
- package/dist/cjs/execution/dsl.js.map +0 -1
- package/dist/cjs/execution/execution-runtime.js.map +0 -1
- package/dist/cjs/execution/index.js.map +0 -1
- package/dist/cjs/execution/inference-client.js.map +0 -1
- package/dist/cjs/execution/inference-response-error.js.map +0 -1
- package/dist/cjs/execution/is-image-required-interface.js.map +0 -1
- package/dist/cjs/execution/misc.js.map +0 -1
- package/dist/cjs/execution/model-composition-branch.js.map +0 -1
- package/dist/cjs/execution/read-environment-credentials.js.map +0 -1
- package/dist/cjs/execution/read-recording-response-stream-handler.js.map +0 -1
- package/dist/cjs/execution/repeat-error.js.map +0 -1
- package/dist/cjs/execution/ui-control-client-dependency-builder.js.map +0 -1
- package/dist/cjs/execution/ui-control-client.js.map +0 -1
- package/dist/cjs/execution/ui-controller-client-connection-state.js.map +0 -1
- package/dist/cjs/execution/ui-controller-client-error.js.map +0 -1
- package/dist/cjs/execution/ui-controller-client-interface.js.map +0 -1
- package/dist/cjs/execution/ui-controller-client.js.map +0 -1
- package/dist/cjs/lib/download-binaries.js.map +0 -1
- package/dist/cjs/lib/index.js.map +0 -1
- package/dist/cjs/lib/interactive_cli/add-script-package-json.d.ts +0 -1
- package/dist/cjs/lib/interactive_cli/add-script-package-json.js +0 -39
- package/dist/cjs/lib/interactive_cli/add-script-package-json.js.map +0 -1
- package/dist/cjs/lib/interactive_cli/cli-options-interface.js.map +0 -1
- package/dist/cjs/lib/interactive_cli/cli.js.map +0 -1
- package/dist/cjs/lib/interactive_cli/create-example-project.js.map +0 -1
- package/dist/cjs/lib/interactive_cli/index.js.map +0 -1
- package/dist/cjs/lib/libfuse-error.js.map +0 -1
- package/dist/cjs/lib/logger.js.map +0 -1
- package/dist/cjs/lib/timeout-error.js.map +0 -1
- package/dist/cjs/lib/ui-controller-args.js.map +0 -1
- package/dist/cjs/lib/ui-controller-darwin.js.map +0 -1
- package/dist/cjs/lib/ui-controller-facade.js.map +0 -1
- package/dist/cjs/lib/ui-controller-linux.js.map +0 -1
- package/dist/cjs/lib/ui-controller-win32.js.map +0 -1
- package/dist/cjs/lib/ui-controller.js.map +0 -1
- package/dist/cjs/lib/unkown-error.js.map +0 -1
- package/dist/cjs/lib/wayland-error.js.map +0 -1
- package/dist/cjs/main.js.map +0 -1
- package/dist/cjs/shared/index.js.map +0 -1
- package/dist/cjs/shared/log-levels.js.map +0 -1
- package/dist/cjs/shared/proxy-agent-args.js.map +0 -1
- package/dist/cjs/utils/analytics/analytics-interface.js.map +0 -1
- package/dist/cjs/utils/analytics/analytics.js.map +0 -1
- package/dist/cjs/utils/analytics/index.js.map +0 -1
- package/dist/cjs/utils/analytics/installation-timestamp-create-error.js.map +0 -1
- package/dist/cjs/utils/analytics/installation-timestamp-get-error.js.map +0 -1
- package/dist/cjs/utils/analytics/installation-timestamp.js.map +0 -1
- package/dist/cjs/utils/analytics/user-identifier-interface.js.map +0 -1
- package/dist/cjs/utils/analytics/user-identifier.js.map +0 -1
- package/dist/cjs/utils/base_64_image/base-64-image-error.js.map +0 -1
- package/dist/cjs/utils/base_64_image/base-64-image-string-error.js.map +0 -1
- package/dist/cjs/utils/base_64_image/base-64-image.js.map +0 -1
- package/dist/cjs/utils/base_64_image/sharp.js.map +0 -1
- package/dist/cjs/utils/http/credentials.js.map +0 -1
- package/dist/cjs/utils/http/custom-errors/authentication-http-client-error.js.map +0 -1
- package/dist/cjs/utils/http/custom-errors/client-http-client-error.js.map +0 -1
- package/dist/cjs/utils/http/custom-errors/general-http-client-error.js.map +0 -1
- package/dist/cjs/utils/http/custom-errors/http-client-error.js.map +0 -1
- package/dist/cjs/utils/http/custom-errors/index.js.map +0 -1
- package/dist/cjs/utils/http/custom-errors/server-http-client-error.js.map +0 -1
- package/dist/cjs/utils/http/custom-errors/unkown-http-client-error.js.map +0 -1
- package/dist/cjs/utils/http/http-client-got.js.map +0 -1
- package/dist/cjs/utils/http/index.js.map +0 -1
- package/dist/cjs/utils/image-resize-errors/image-resizing-base-error.js.map +0 -1
- package/dist/cjs/utils/image-resize-errors/index.js.map +0 -1
- package/dist/cjs/utils/path.js.map +0 -1
- package/dist/cjs/utils/proxy/proxy-builder.js.map +0 -1
- package/dist/cjs/utils/resized-image-interface.js.map +0 -1
- package/dist/cjs/utils/transformations.js.map +0 -1
- package/dist/esm/core/annotation/annotation-writer.js.map +0 -1
- package/dist/esm/core/annotation/annotation.js.map +0 -1
- package/dist/esm/core/inference-response/inference-response.js.map +0 -1
- package/dist/esm/core/inference-response/invalid-model-type-error.js.map +0 -1
- package/dist/esm/core/inference-response/model-type.js.map +0 -1
- package/dist/esm/core/model/annotation-result/annotation-interface.js.map +0 -1
- package/dist/esm/core/model/annotation-result/boundary-box.js.map +0 -1
- package/dist/esm/core/model/annotation-result/detected-element.js.map +0 -1
- package/dist/esm/core/model/custom-element-json.js.map +0 -1
- package/dist/esm/core/model/custom-element.js.map +0 -1
- package/dist/esm/core/reporting/default-step.js.map +0 -1
- package/dist/esm/core/reporting/index.js.map +0 -1
- package/dist/esm/core/reporting/instruction.js.map +0 -1
- package/dist/esm/core/reporting/reporter-config.js.map +0 -1
- package/dist/esm/core/reporting/reporter.js.map +0 -1
- package/dist/esm/core/reporting/snapshot-detail-level.js.map +0 -1
- package/dist/esm/core/reporting/snapshot.js.map +0 -1
- package/dist/esm/core/reporting/step-reporter.js.map +0 -1
- package/dist/esm/core/reporting/step-run.js.map +0 -1
- package/dist/esm/core/reporting/step-status-end.js.map +0 -1
- package/dist/esm/core/reporting/step-status.js.map +0 -1
- package/dist/esm/core/reporting/step.js.map +0 -1
- package/dist/esm/core/runner-protocol/index.js.map +0 -1
- package/dist/esm/core/runner-protocol/request/capture-screenshot-request.js.map +0 -1
- package/dist/esm/core/runner-protocol/request/control-request.js.map +0 -1
- package/dist/esm/core/runner-protocol/request/get-server-process-pid.js.map +0 -1
- package/dist/esm/core/runner-protocol/request/index.js.map +0 -1
- package/dist/esm/core/runner-protocol/request/interactive-annotation-request.js.map +0 -1
- package/dist/esm/core/runner-protocol/request/read-recording-request.js.map +0 -1
- package/dist/esm/core/runner-protocol/request/runner-protocol-request.js.map +0 -1
- package/dist/esm/core/runner-protocol/request/start-recording-request.js.map +0 -1
- package/dist/esm/core/runner-protocol/request/stop-recording-request.js.map +0 -1
- package/dist/esm/core/runner-protocol/response/index.js.map +0 -1
- package/dist/esm/core/ui-control-commands/action.js.map +0 -1
- package/dist/esm/core/ui-control-commands/control-command-code.js.map +0 -1
- package/dist/esm/core/ui-control-commands/control-command.js.map +0 -1
- package/dist/esm/core/ui-control-commands/index.js.map +0 -1
- package/dist/esm/core/ui-control-commands/input-event.js.map +0 -1
- package/dist/esm/execution/config-error.js.map +0 -1
- package/dist/esm/execution/control-command-error.js.map +0 -1
- package/dist/esm/execution/credentials-args.js.map +0 -1
- package/dist/esm/execution/dsl.js.map +0 -1
- package/dist/esm/execution/execution-runtime.js.map +0 -1
- package/dist/esm/execution/index.js.map +0 -1
- package/dist/esm/execution/inference-client.js.map +0 -1
- package/dist/esm/execution/inference-response-error.js.map +0 -1
- package/dist/esm/execution/is-image-required-interface.js.map +0 -1
- package/dist/esm/execution/misc.js.map +0 -1
- package/dist/esm/execution/model-composition-branch.js.map +0 -1
- package/dist/esm/execution/read-environment-credentials.js.map +0 -1
- package/dist/esm/execution/read-recording-response-stream-handler.js.map +0 -1
- package/dist/esm/execution/repeat-error.js.map +0 -1
- package/dist/esm/execution/ui-control-client-dependency-builder.js.map +0 -1
- package/dist/esm/execution/ui-control-client.js.map +0 -1
- package/dist/esm/execution/ui-controller-client-connection-state.js.map +0 -1
- package/dist/esm/execution/ui-controller-client-error.js.map +0 -1
- package/dist/esm/execution/ui-controller-client-interface.js.map +0 -1
- package/dist/esm/execution/ui-controller-client.js.map +0 -1
- package/dist/esm/lib/download-binaries.js.map +0 -1
- package/dist/esm/lib/index.js.map +0 -1
- package/dist/esm/lib/interactive_cli/add-script-package-json.d.ts +0 -1
- package/dist/esm/lib/interactive_cli/add-script-package-json.js +0 -32
- package/dist/esm/lib/interactive_cli/add-script-package-json.js.map +0 -1
- package/dist/esm/lib/interactive_cli/cli-options-interface.js.map +0 -1
- package/dist/esm/lib/interactive_cli/cli.js.map +0 -1
- package/dist/esm/lib/interactive_cli/create-example-project.js.map +0 -1
- package/dist/esm/lib/interactive_cli/index.js.map +0 -1
- package/dist/esm/lib/libfuse-error.js.map +0 -1
- package/dist/esm/lib/logger.js.map +0 -1
- package/dist/esm/lib/timeout-error.js.map +0 -1
- package/dist/esm/lib/ui-controller-args.js.map +0 -1
- package/dist/esm/lib/ui-controller-darwin.js.map +0 -1
- package/dist/esm/lib/ui-controller-facade.js.map +0 -1
- package/dist/esm/lib/ui-controller-linux.js.map +0 -1
- package/dist/esm/lib/ui-controller-win32.js.map +0 -1
- package/dist/esm/lib/ui-controller.js.map +0 -1
- package/dist/esm/lib/unkown-error.js.map +0 -1
- package/dist/esm/lib/wayland-error.js.map +0 -1
- package/dist/esm/main.js.map +0 -1
- package/dist/esm/shared/index.js.map +0 -1
- package/dist/esm/shared/log-levels.js.map +0 -1
- package/dist/esm/shared/proxy-agent-args.js.map +0 -1
- package/dist/esm/utils/analytics/analytics-interface.js.map +0 -1
- package/dist/esm/utils/analytics/analytics.js.map +0 -1
- package/dist/esm/utils/analytics/index.js.map +0 -1
- package/dist/esm/utils/analytics/installation-timestamp-create-error.js.map +0 -1
- package/dist/esm/utils/analytics/installation-timestamp-get-error.js.map +0 -1
- package/dist/esm/utils/analytics/installation-timestamp.js.map +0 -1
- package/dist/esm/utils/analytics/user-identifier-interface.js.map +0 -1
- package/dist/esm/utils/analytics/user-identifier.js.map +0 -1
- package/dist/esm/utils/base_64_image/base-64-image-error.js.map +0 -1
- package/dist/esm/utils/base_64_image/base-64-image-string-error.js.map +0 -1
- package/dist/esm/utils/base_64_image/base-64-image.js.map +0 -1
- package/dist/esm/utils/base_64_image/sharp.js.map +0 -1
- package/dist/esm/utils/http/credentials.js.map +0 -1
- package/dist/esm/utils/http/custom-errors/authentication-http-client-error.js.map +0 -1
- package/dist/esm/utils/http/custom-errors/client-http-client-error.js.map +0 -1
- package/dist/esm/utils/http/custom-errors/general-http-client-error.js.map +0 -1
- package/dist/esm/utils/http/custom-errors/http-client-error.js.map +0 -1
- package/dist/esm/utils/http/custom-errors/index.js.map +0 -1
- package/dist/esm/utils/http/custom-errors/server-http-client-error.js.map +0 -1
- package/dist/esm/utils/http/custom-errors/unkown-http-client-error.js.map +0 -1
- package/dist/esm/utils/http/http-client-got.js.map +0 -1
- package/dist/esm/utils/http/index.js.map +0 -1
- package/dist/esm/utils/image-resize-errors/image-resizing-base-error.js.map +0 -1
- package/dist/esm/utils/image-resize-errors/index.js.map +0 -1
- package/dist/esm/utils/path.js.map +0 -1
- package/dist/esm/utils/proxy/proxy-builder.js.map +0 -1
- package/dist/esm/utils/resized-image-interface.js.map +0 -1
- package/dist/esm/utils/transformations.js.map +0 -1
- package/dist/example_projects_templates/configs/jasmine.config.json +0 -12
|
@@ -1,12 +1,34 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Exec, Executable, FluentFilters, ApiCommands, PC_AND_MODIFIER_KEY } from './dsl';
|
|
1
|
+
import { Exec, Executable, FluentFilters, ApiCommands, PC_AND_MODIFIER_KEY, CommandExecutorContext } from './dsl';
|
|
3
2
|
import { UiControllerClientConnectionState } from './ui-controller-client-connection-state';
|
|
4
3
|
import { Annotation } from '../core/annotation/annotation';
|
|
5
4
|
import { AnnotationRequest } from '../core/model/annotation-result/annotation-interface';
|
|
6
5
|
import { DetectedElement } from '../core/model/annotation-result/detected-element';
|
|
7
6
|
import { ClientArgs } from './ui-controller-client-interface';
|
|
8
7
|
export declare type RelationsForConvenienceMethods = 'nearestTo' | 'leftOf' | 'above' | 'rightOf' | 'below' | 'contains';
|
|
8
|
+
export declare type TextMatchingOption = 'similar' | 'exact' | 'regex';
|
|
9
|
+
export declare type ElementExistsQueryType = 'otherElement' | 'switch' | 'element' | 'container' | 'checkbox' | 'element' | 'button' | 'table' | 'text' | 'icon' | 'image' | 'textfield';
|
|
10
|
+
export interface ElementExistsQueryText {
|
|
11
|
+
value: string;
|
|
12
|
+
matching?: TextMatchingOption;
|
|
13
|
+
}
|
|
14
|
+
export interface ElementExistsQueryRelation {
|
|
15
|
+
type: RelationsForConvenienceMethods;
|
|
16
|
+
text: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ElementExistsQuery {
|
|
19
|
+
type: keyof Pick<FluentFilters, ElementExistsQueryType>;
|
|
20
|
+
text?: ElementExistsQueryText;
|
|
21
|
+
relation?: ElementExistsQueryRelation;
|
|
22
|
+
}
|
|
23
|
+
export interface ExpectExistenceElement extends ElementExistsQuery {
|
|
24
|
+
exists: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface ExpectAllExistResult {
|
|
27
|
+
allExist: boolean;
|
|
28
|
+
elements: ExpectExistenceElement[];
|
|
29
|
+
}
|
|
9
30
|
export declare class UiControlClient extends ApiCommands {
|
|
31
|
+
private workspaceId;
|
|
10
32
|
private executionRuntime;
|
|
11
33
|
private stepReporter;
|
|
12
34
|
private constructor();
|
|
@@ -34,8 +56,9 @@ export declare class UiControlClient extends ApiCommands {
|
|
|
34
56
|
annotateInteractively(): Promise<void>;
|
|
35
57
|
private escapeSeparatorString;
|
|
36
58
|
private buildInstruction;
|
|
37
|
-
|
|
38
|
-
|
|
59
|
+
private getAIElementsByNames;
|
|
60
|
+
fluentCommandExecutor(instructionString: string, context?: CommandExecutorContext): Promise<void>;
|
|
61
|
+
getterExecutor(instruction: string, context?: CommandExecutorContext): Promise<DetectedElement[]>;
|
|
39
62
|
private secretText;
|
|
40
63
|
private getAndResetSecretText;
|
|
41
64
|
/**
|
|
@@ -190,8 +213,8 @@ export declare class UiControlClient extends ApiCommands {
|
|
|
190
213
|
* @param {Object} params - Object containing required `label` property and
|
|
191
214
|
* optional `relation` property.
|
|
192
215
|
* @property {string} params.label - The label for the checkbox.
|
|
193
|
-
* @property {Object} params.relation - Object describing the relationship between
|
|
194
|
-
*
|
|
216
|
+
* @property {Object} [params.relation] - Object describing the relationship between
|
|
217
|
+
* the clicked checkbox and another element.
|
|
195
218
|
* @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
|
|
196
219
|
*/
|
|
197
220
|
clickCheckbox(params: {
|
|
@@ -213,7 +236,7 @@ export declare class UiControlClient extends ApiCommands {
|
|
|
213
236
|
* @param {Object} params - Object containing required `label` property and
|
|
214
237
|
* optional `relation` property.
|
|
215
238
|
* @property {string} params.label - The label for the checkbox.
|
|
216
|
-
* @property {Object} params.relation - Object describing the relationship between
|
|
239
|
+
* @property {Object} [params.relation] - Object describing the relationship between
|
|
217
240
|
* the clicked checkbox and another element.
|
|
218
241
|
* @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
|
|
219
242
|
*/
|
|
@@ -266,41 +289,103 @@ export declare class UiControlClient extends ApiCommands {
|
|
|
266
289
|
}): Promise<void>;
|
|
267
290
|
/**
|
|
268
291
|
* Click on a specific text.
|
|
269
|
-
* You can also use a RegEx or match the text exactly by
|
|
292
|
+
* You can also use a RegEx or match the text exactly by specifying the specific flag.
|
|
270
293
|
* Use a relation to find the text in relation to a specific text.
|
|
271
294
|
*
|
|
272
295
|
* **Examples:**
|
|
273
296
|
* ```typescript
|
|
274
297
|
* // Click text that matches exactly
|
|
275
|
-
* await aui.clickText({text: 'askui',
|
|
298
|
+
* await aui.clickText({text: 'askui', matching: 'similar'})
|
|
276
299
|
*
|
|
277
300
|
* // Click text that contains 'pie' or 'cake' or 'Pie' or 'Cake'
|
|
278
|
-
* await aui.clickText({text: '.*([Pp]ie|[Cc]ake).*',
|
|
301
|
+
* await aui.clickText({text: '.*([Pp]ie|[Cc]ake).*', matching: 'regex'})
|
|
279
302
|
*
|
|
280
303
|
* // Click the text 'TERMINAL' that is left of the text 'Ports'
|
|
281
304
|
* await aui.clickText({
|
|
282
305
|
* text: 'TERMINAL',
|
|
283
|
-
*
|
|
306
|
+
* matching: "exact",
|
|
284
307
|
* relation: { type: 'leftOf', text: 'PORTS' }
|
|
285
308
|
* })
|
|
286
309
|
* ```
|
|
310
|
+
*
|
|
287
311
|
* @param {Object} params - Object containing required `text` property and optional properties
|
|
288
312
|
* for regular expression matching and relation.
|
|
289
313
|
* @property {string} params.text - The text to be clicked.
|
|
290
|
-
* @property {string} params.
|
|
291
|
-
*
|
|
292
|
-
* @property {Object} params.relation - Object describing the relationship between the
|
|
293
|
-
*
|
|
314
|
+
* @property {string} params.matching - Whether the text is matched using similarity,
|
|
315
|
+
* exact match or a regular expression.
|
|
316
|
+
* @property {Object} [params.relation] - Object describing the relationship between the
|
|
317
|
+
* clicked text and another element.
|
|
294
318
|
* @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
|
|
295
319
|
* @property {string} params.relation.text - The label or text associated with the
|
|
296
320
|
* related element or state.
|
|
297
321
|
*/
|
|
298
322
|
clickText(params: {
|
|
299
323
|
text: string;
|
|
300
|
-
|
|
324
|
+
matching: TextMatchingOption;
|
|
301
325
|
relation?: {
|
|
302
326
|
type: RelationsForConvenienceMethods;
|
|
303
327
|
text: string;
|
|
304
328
|
};
|
|
305
329
|
}): Promise<void>;
|
|
330
|
+
private evaluateMatchingProperty;
|
|
331
|
+
/**
|
|
332
|
+
* Check if one or multiple elements are detected.
|
|
333
|
+
*
|
|
334
|
+
* **Examples:**
|
|
335
|
+
* ```typescript
|
|
336
|
+
* await aui.expectAllExist([
|
|
337
|
+
* {
|
|
338
|
+
* type: 'text',
|
|
339
|
+
* text: {
|
|
340
|
+
* value: 'Switch to Dark',
|
|
341
|
+
* matching: 'similar'
|
|
342
|
+
* }
|
|
343
|
+
* },
|
|
344
|
+
* ]);
|
|
345
|
+
*
|
|
346
|
+
* // Check for existence of multiple elements
|
|
347
|
+
* await aui.expectAllExist([
|
|
348
|
+
* {
|
|
349
|
+
* type: 'textfield',
|
|
350
|
+
* relation: {
|
|
351
|
+
* type: 'rightOf',
|
|
352
|
+
* text: 'Email:'
|
|
353
|
+
* }
|
|
354
|
+
* },
|
|
355
|
+
* {
|
|
356
|
+
* type: 'element',
|
|
357
|
+
* text: {
|
|
358
|
+
* value: 'Switch to Dark'
|
|
359
|
+
* }
|
|
360
|
+
* },
|
|
361
|
+
* ]);
|
|
362
|
+
*
|
|
363
|
+
* // Validate existence
|
|
364
|
+
* const exists = await aui.expectAllExist([...]);
|
|
365
|
+
* exists.allExist // true when every element exists
|
|
366
|
+
*
|
|
367
|
+
* // Check which elements do not exist
|
|
368
|
+
* // with the elements property
|
|
369
|
+
* const nonExistentElements = exists.elements.filter((e) => e.exists===false)
|
|
370
|
+
* ```
|
|
371
|
+
*
|
|
372
|
+
* @param {ElementExistsQuery[]} query - Objects containing the required property
|
|
373
|
+
* 'type' and the optional properties
|
|
374
|
+
* 'text' and 'relation'.
|
|
375
|
+
* @property {string} query.type - The type of the element: 'otherElement' | 'switch' |
|
|
376
|
+
* 'element' | 'container' | 'checkbox' | 'element' |
|
|
377
|
+
* 'button' | 'table' | 'text' | 'icon' | 'image' | 'textfield'
|
|
378
|
+
* @property {Object} [query.text] - Object containing value and matching strategy.
|
|
379
|
+
* @property {string} query.text.value - The text to match for.
|
|
380
|
+
* @property {string} [query.text.matching] - Whether the text is matched using similarity,
|
|
381
|
+
* exact match or a regular expression.
|
|
382
|
+
* @property {Object} [query.relation] - Object describing the relationship between the
|
|
383
|
+
* clicked text and another element.
|
|
384
|
+
* @property {RelationsForConvenienceMethods} query.relation.type - The type of relation.
|
|
385
|
+
* @property {string} query.relation.text - The label or text associated with the
|
|
386
|
+
* related element or state.
|
|
387
|
+
* @returns {ExpectAllExistResult.allExist} - If every element exists.
|
|
388
|
+
* @returns {ExpectAllExistResult.elements} - ExpectExistenceElement[].
|
|
389
|
+
*/
|
|
390
|
+
expectAllExist(query: ElementExistsQuery[]): Promise<ExpectAllExistResult>;
|
|
306
391
|
}
|
|
@@ -8,20 +8,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
12
|
exports.UiControlClient = void 0;
|
|
16
|
-
const
|
|
13
|
+
const yup_1 = require("yup");
|
|
17
14
|
const custom_element_1 = require("../core/model/custom-element");
|
|
18
15
|
const dsl_1 = require("./dsl");
|
|
19
16
|
const annotation_writer_1 = require("../core/annotation/annotation-writer");
|
|
20
17
|
const logger_1 = require("../lib/logger");
|
|
21
18
|
const ui_control_client_dependency_builder_1 = require("./ui-control-client-dependency-builder");
|
|
19
|
+
const ai_element_collection_1 = require("../core/ai-element/ai-element-collection");
|
|
22
20
|
class UiControlClient extends dsl_1.ApiCommands {
|
|
23
|
-
constructor(executionRuntime, stepReporter) {
|
|
21
|
+
constructor(workspaceId, executionRuntime, stepReporter) {
|
|
24
22
|
super();
|
|
23
|
+
this.workspaceId = workspaceId;
|
|
25
24
|
this.executionRuntime = executionRuntime;
|
|
26
25
|
this.stepReporter = stepReporter;
|
|
27
26
|
this.secretText = undefined;
|
|
@@ -30,8 +29,8 @@ class UiControlClient extends dsl_1.ApiCommands {
|
|
|
30
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
31
30
|
const builder = ui_control_client_dependency_builder_1.UiControlClientDependencyBuilder;
|
|
32
31
|
const clientArgsWithDefaults = yield builder.getClientArgsWithDefaults(clientArgs);
|
|
33
|
-
const { executionRuntime, stepReporter } = yield builder.build(clientArgsWithDefaults);
|
|
34
|
-
return new UiControlClient(executionRuntime, stepReporter);
|
|
32
|
+
const { workspaceId, executionRuntime, stepReporter, } = yield builder.build(clientArgsWithDefaults);
|
|
33
|
+
return new UiControlClient(workspaceId, executionRuntime, stepReporter);
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
36
|
/**
|
|
@@ -125,9 +124,23 @@ class UiControlClient extends dsl_1.ApiCommands {
|
|
|
125
124
|
};
|
|
126
125
|
});
|
|
127
126
|
}
|
|
128
|
-
|
|
127
|
+
getAIElementsByNames(names) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
if (names.length === 0) {
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
// eslint-disable-next-line max-len
|
|
133
|
+
const workspaceAIElementCollection = yield ai_element_collection_1.AIElementCollection.collectForWorkspaceId(this.workspaceId);
|
|
134
|
+
return workspaceAIElementCollection.getByNames(names);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
fluentCommandExecutor(instructionString, context = { customElementsJson: [], aiElementNames: [] }) {
|
|
129
138
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
-
const
|
|
139
|
+
const aiElements = yield this.getAIElementsByNames(context.aiElementNames);
|
|
140
|
+
const instruction = yield this.buildInstruction(instructionString, [
|
|
141
|
+
...context.customElementsJson,
|
|
142
|
+
...aiElements,
|
|
143
|
+
]);
|
|
131
144
|
logger_1.logger.debug(instruction);
|
|
132
145
|
try {
|
|
133
146
|
yield this.stepReporter.resetStep(instruction);
|
|
@@ -141,12 +154,16 @@ class UiControlClient extends dsl_1.ApiCommands {
|
|
|
141
154
|
}
|
|
142
155
|
});
|
|
143
156
|
}
|
|
144
|
-
getterExecutor(instruction,
|
|
157
|
+
getterExecutor(instruction, context = { customElementsJson: [], aiElementNames: [] }) {
|
|
145
158
|
return __awaiter(this, void 0, void 0, function* () {
|
|
146
|
-
const
|
|
159
|
+
const aiElements = yield this.getAIElementsByNames(context.aiElementNames);
|
|
160
|
+
const customElements = yield custom_element_1.CustomElement.fromJsonListWithImagePathOrImage(context.customElementsJson);
|
|
147
161
|
const stringWithoutSeparators = this.escapeSeparatorString(instruction);
|
|
148
162
|
logger_1.logger.debug(stringWithoutSeparators);
|
|
149
|
-
return this.executionRuntime.getDetectedElements(instruction,
|
|
163
|
+
return this.executionRuntime.getDetectedElements(instruction, [
|
|
164
|
+
...customElements,
|
|
165
|
+
...aiElements,
|
|
166
|
+
]);
|
|
150
167
|
});
|
|
151
168
|
}
|
|
152
169
|
getAndResetSecretText() {
|
|
@@ -331,30 +348,22 @@ class UiControlClient extends dsl_1.ApiCommands {
|
|
|
331
348
|
}
|
|
332
349
|
// eslint-disable-next-line class-methods-use-this
|
|
333
350
|
evaluateRelation(command, relation, text) {
|
|
334
|
-
let commando = command;
|
|
335
351
|
switch (relation) {
|
|
336
|
-
case 'nearestTo':
|
|
337
|
-
commando = command.nearestTo().text(text);
|
|
338
|
-
break;
|
|
339
352
|
case 'leftOf':
|
|
340
|
-
|
|
341
|
-
break;
|
|
353
|
+
return command.leftOf().text(text);
|
|
342
354
|
case 'above':
|
|
343
|
-
|
|
344
|
-
break;
|
|
355
|
+
return command.above().text(text);
|
|
345
356
|
case 'rightOf':
|
|
346
|
-
|
|
347
|
-
break;
|
|
357
|
+
return command.rightOf().text(text);
|
|
348
358
|
case 'below':
|
|
349
|
-
|
|
350
|
-
break;
|
|
359
|
+
return command.below().text(text);
|
|
351
360
|
case 'contains':
|
|
352
|
-
|
|
353
|
-
|
|
361
|
+
return command.contains().text(text);
|
|
362
|
+
case 'nearestTo':
|
|
363
|
+
return command.nearestTo().text(text);
|
|
354
364
|
default:
|
|
355
|
-
throw new
|
|
365
|
+
throw new yup_1.ValidationError(`'relation' has to be 'nearestTo', 'leftOf', 'above', 'rightOf', 'below' or 'contains' but was '${relation}'`);
|
|
356
366
|
}
|
|
357
|
-
return commando;
|
|
358
367
|
}
|
|
359
368
|
/**
|
|
360
369
|
* Click a button with a specific label.
|
|
@@ -400,8 +409,8 @@ class UiControlClient extends dsl_1.ApiCommands {
|
|
|
400
409
|
* @param {Object} params - Object containing required `label` property and
|
|
401
410
|
* optional `relation` property.
|
|
402
411
|
* @property {string} params.label - The label for the checkbox.
|
|
403
|
-
* @property {Object} params.relation - Object describing the relationship between
|
|
404
|
-
*
|
|
412
|
+
* @property {Object} [params.relation] - Object describing the relationship between
|
|
413
|
+
* the clicked checkbox and another element.
|
|
405
414
|
* @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
|
|
406
415
|
*/
|
|
407
416
|
clickCheckbox(params) {
|
|
@@ -429,7 +438,7 @@ class UiControlClient extends dsl_1.ApiCommands {
|
|
|
429
438
|
* @param {Object} params - Object containing required `label` property and
|
|
430
439
|
* optional `relation` property.
|
|
431
440
|
* @property {string} params.label - The label for the checkbox.
|
|
432
|
-
* @property {Object} params.relation - Object describing the relationship between
|
|
441
|
+
* @property {Object} [params.relation] - Object describing the relationship between
|
|
433
442
|
* the clicked checkbox and another element.
|
|
434
443
|
* @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
|
|
435
444
|
*/
|
|
@@ -493,31 +502,32 @@ class UiControlClient extends dsl_1.ApiCommands {
|
|
|
493
502
|
}
|
|
494
503
|
/**
|
|
495
504
|
* Click on a specific text.
|
|
496
|
-
* You can also use a RegEx or match the text exactly by
|
|
505
|
+
* You can also use a RegEx or match the text exactly by specifying the specific flag.
|
|
497
506
|
* Use a relation to find the text in relation to a specific text.
|
|
498
507
|
*
|
|
499
508
|
* **Examples:**
|
|
500
509
|
* ```typescript
|
|
501
510
|
* // Click text that matches exactly
|
|
502
|
-
* await aui.clickText({text: 'askui',
|
|
511
|
+
* await aui.clickText({text: 'askui', matching: 'similar'})
|
|
503
512
|
*
|
|
504
513
|
* // Click text that contains 'pie' or 'cake' or 'Pie' or 'Cake'
|
|
505
|
-
* await aui.clickText({text: '.*([Pp]ie|[Cc]ake).*',
|
|
514
|
+
* await aui.clickText({text: '.*([Pp]ie|[Cc]ake).*', matching: 'regex'})
|
|
506
515
|
*
|
|
507
516
|
* // Click the text 'TERMINAL' that is left of the text 'Ports'
|
|
508
517
|
* await aui.clickText({
|
|
509
518
|
* text: 'TERMINAL',
|
|
510
|
-
*
|
|
519
|
+
* matching: "exact",
|
|
511
520
|
* relation: { type: 'leftOf', text: 'PORTS' }
|
|
512
521
|
* })
|
|
513
522
|
* ```
|
|
523
|
+
*
|
|
514
524
|
* @param {Object} params - Object containing required `text` property and optional properties
|
|
515
525
|
* for regular expression matching and relation.
|
|
516
526
|
* @property {string} params.text - The text to be clicked.
|
|
517
|
-
* @property {string} params.
|
|
518
|
-
*
|
|
519
|
-
* @property {Object} params.relation - Object describing the relationship between the
|
|
520
|
-
*
|
|
527
|
+
* @property {string} params.matching - Whether the text is matched using similarity,
|
|
528
|
+
* exact match or a regular expression.
|
|
529
|
+
* @property {Object} [params.relation] - Object describing the relationship between the
|
|
530
|
+
* clicked text and another element.
|
|
521
531
|
* @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
|
|
522
532
|
* @property {string} params.relation.text - The label or text associated with the
|
|
523
533
|
* related element or state.
|
|
@@ -525,24 +535,107 @@ class UiControlClient extends dsl_1.ApiCommands {
|
|
|
525
535
|
clickText(params) {
|
|
526
536
|
return __awaiter(this, void 0, void 0, function* () {
|
|
527
537
|
let command = this.click().text();
|
|
528
|
-
|
|
529
|
-
case 'similar':
|
|
530
|
-
command = command.withText(params.text);
|
|
531
|
-
break;
|
|
532
|
-
case 'exact':
|
|
533
|
-
command = command.withExactText(params.text);
|
|
534
|
-
break;
|
|
535
|
-
case 'regex':
|
|
536
|
-
command = command.withTextRegex(params.text);
|
|
537
|
-
break;
|
|
538
|
-
default:
|
|
539
|
-
throw new ValidationError_1.default('"type" must be "similar", "exact" or "regex"');
|
|
540
|
-
}
|
|
538
|
+
command = this.evaluateMatchingProperty(command, { value: params.text, matching: params.matching });
|
|
541
539
|
if (params.relation) {
|
|
542
540
|
command = this.evaluateRelation(command, params.relation.type, params.relation.text);
|
|
543
541
|
}
|
|
544
542
|
yield command.exec();
|
|
545
543
|
});
|
|
546
544
|
}
|
|
545
|
+
// eslint-disable-next-line class-methods-use-this
|
|
546
|
+
evaluateMatchingProperty(command, text) {
|
|
547
|
+
var _a;
|
|
548
|
+
switch ((_a = text.matching) !== null && _a !== void 0 ? _a : 'similar') {
|
|
549
|
+
case 'exact':
|
|
550
|
+
return command.withExactText(text.value);
|
|
551
|
+
case 'regex':
|
|
552
|
+
return command.withTextRegex(text.value);
|
|
553
|
+
case 'similar':
|
|
554
|
+
return command.withText(text.value);
|
|
555
|
+
default:
|
|
556
|
+
throw new yup_1.ValidationError(`'text.matching' property has to be 'similar', 'exact' or 'regex' but was '${text.matching}'`);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Check if one or multiple elements are detected.
|
|
561
|
+
*
|
|
562
|
+
* **Examples:**
|
|
563
|
+
* ```typescript
|
|
564
|
+
* await aui.expectAllExist([
|
|
565
|
+
* {
|
|
566
|
+
* type: 'text',
|
|
567
|
+
* text: {
|
|
568
|
+
* value: 'Switch to Dark',
|
|
569
|
+
* matching: 'similar'
|
|
570
|
+
* }
|
|
571
|
+
* },
|
|
572
|
+
* ]);
|
|
573
|
+
*
|
|
574
|
+
* // Check for existence of multiple elements
|
|
575
|
+
* await aui.expectAllExist([
|
|
576
|
+
* {
|
|
577
|
+
* type: 'textfield',
|
|
578
|
+
* relation: {
|
|
579
|
+
* type: 'rightOf',
|
|
580
|
+
* text: 'Email:'
|
|
581
|
+
* }
|
|
582
|
+
* },
|
|
583
|
+
* {
|
|
584
|
+
* type: 'element',
|
|
585
|
+
* text: {
|
|
586
|
+
* value: 'Switch to Dark'
|
|
587
|
+
* }
|
|
588
|
+
* },
|
|
589
|
+
* ]);
|
|
590
|
+
*
|
|
591
|
+
* // Validate existence
|
|
592
|
+
* const exists = await aui.expectAllExist([...]);
|
|
593
|
+
* exists.allExist // true when every element exists
|
|
594
|
+
*
|
|
595
|
+
* // Check which elements do not exist
|
|
596
|
+
* // with the elements property
|
|
597
|
+
* const nonExistentElements = exists.elements.filter((e) => e.exists===false)
|
|
598
|
+
* ```
|
|
599
|
+
*
|
|
600
|
+
* @param {ElementExistsQuery[]} query - Objects containing the required property
|
|
601
|
+
* 'type' and the optional properties
|
|
602
|
+
* 'text' and 'relation'.
|
|
603
|
+
* @property {string} query.type - The type of the element: 'otherElement' | 'switch' |
|
|
604
|
+
* 'element' | 'container' | 'checkbox' | 'element' |
|
|
605
|
+
* 'button' | 'table' | 'text' | 'icon' | 'image' | 'textfield'
|
|
606
|
+
* @property {Object} [query.text] - Object containing value and matching strategy.
|
|
607
|
+
* @property {string} query.text.value - The text to match for.
|
|
608
|
+
* @property {string} [query.text.matching] - Whether the text is matched using similarity,
|
|
609
|
+
* exact match or a regular expression.
|
|
610
|
+
* @property {Object} [query.relation] - Object describing the relationship between the
|
|
611
|
+
* clicked text and another element.
|
|
612
|
+
* @property {RelationsForConvenienceMethods} query.relation.type - The type of relation.
|
|
613
|
+
* @property {string} query.relation.text - The label or text associated with the
|
|
614
|
+
* related element or state.
|
|
615
|
+
* @returns {ExpectAllExistResult.allExist} - If every element exists.
|
|
616
|
+
* @returns {ExpectAllExistResult.elements} - ExpectExistenceElement[].
|
|
617
|
+
*/
|
|
618
|
+
expectAllExist(query) {
|
|
619
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
620
|
+
const elements = yield query.reduce((accumulatorPromise, subquery) => __awaiter(this, void 0, void 0, function* () {
|
|
621
|
+
const acc = yield accumulatorPromise;
|
|
622
|
+
const command = this.get()[subquery.type]();
|
|
623
|
+
let finalCommand = subquery.text !== undefined
|
|
624
|
+
? this.evaluateMatchingProperty(command, subquery.text)
|
|
625
|
+
: command;
|
|
626
|
+
if (subquery.relation) {
|
|
627
|
+
finalCommand = this.evaluateRelation(finalCommand, subquery.relation.type, subquery.relation.text);
|
|
628
|
+
}
|
|
629
|
+
return [
|
|
630
|
+
...acc,
|
|
631
|
+
Object.assign(Object.assign({}, subquery), { exists: (yield finalCommand.exec()).length > 0 }),
|
|
632
|
+
];
|
|
633
|
+
}), Promise.resolve([]));
|
|
634
|
+
return {
|
|
635
|
+
elements,
|
|
636
|
+
allExist: elements.every((el) => el.exists),
|
|
637
|
+
};
|
|
638
|
+
});
|
|
639
|
+
}
|
|
547
640
|
}
|
|
548
641
|
exports.UiControlClient = UiControlClient;
|
package/dist/cjs/main.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { UiController } from './lib';
|
|
2
|
-
export
|
|
2
|
+
export * from './execution';
|
|
3
3
|
export { Instruction, Reporter, ReporterConfig, Snapshot, SnapshotDetailLevel, Step, StepStatus, StepStatusEnd, } from './core/reporting';
|
|
4
4
|
export { Annotation } from './core/annotation/annotation';
|
|
5
5
|
export { DetectedElement } from './core/model/annotation-result/detected-element';
|
package/dist/cjs/main.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
2
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LogLevels = exports.DetectedElement = exports.Annotation = exports.
|
|
13
|
+
exports.LogLevels = exports.DetectedElement = exports.Annotation = exports.UiController = void 0;
|
|
4
14
|
var lib_1 = require("./lib");
|
|
5
15
|
Object.defineProperty(exports, "UiController", { enumerable: true, get: function () { return lib_1.UiController; } });
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "UiControlClient", { enumerable: true, get: function () { return execution_1.UiControlClient; } });
|
|
16
|
+
__exportStar(require("./execution"), exports);
|
|
8
17
|
var annotation_1 = require("./core/annotation/annotation");
|
|
9
18
|
Object.defineProperty(exports, "Annotation", { enumerable: true, get: function () { return annotation_1.Annotation; } });
|
|
10
19
|
var detected_element_1 = require("./core/model/annotation-result/detected-element");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AnalyticsInterface } from './analytics-interface';
|
|
2
|
-
import { Context } from '
|
|
2
|
+
import { Context } from '../../execution/context';
|
|
3
3
|
export declare class Analytics implements AnalyticsInterface {
|
|
4
4
|
private static clientSessionId;
|
|
5
5
|
private clientId;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AIElement } from './ai-element';
|
|
2
|
+
import { CustomElementJson } from '../model/custom-element-json';
|
|
3
|
+
export declare class AIElementCollection {
|
|
4
|
+
private elements;
|
|
5
|
+
static AI_ELEMENT_FOLDER: string;
|
|
6
|
+
constructor(elements: AIElement[]);
|
|
7
|
+
static collectForWorkspaceId(workspaceId: string | undefined): Promise<AIElementCollection>;
|
|
8
|
+
getByName(name: string): CustomElementJson[];
|
|
9
|
+
getByNames(names: string[]): CustomElementJson[];
|
|
10
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
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 os from 'os';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import fs from 'fs-extra';
|
|
13
|
+
import { AIElement } from './ai-element';
|
|
14
|
+
import { logger } from '../../lib';
|
|
15
|
+
import { AIElementError } from './ai-element-error';
|
|
16
|
+
export class AIElementCollection {
|
|
17
|
+
constructor(elements) {
|
|
18
|
+
this.elements = elements;
|
|
19
|
+
}
|
|
20
|
+
static collectForWorkspaceId(workspaceId) {
|
|
21
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
logger.debug(`Collecting AIElements for workspace '${workspaceId}' ...`);
|
|
23
|
+
if (workspaceId === undefined) {
|
|
24
|
+
throw new AIElementError("Value of 'workspaceId' must be defined.");
|
|
25
|
+
}
|
|
26
|
+
const workspaceAIElementFolder = path.join(AIElementCollection.AI_ELEMENT_FOLDER, workspaceId);
|
|
27
|
+
if (!(yield fs.pathExists(workspaceAIElementFolder))) {
|
|
28
|
+
throw new AIElementError(`Missing AIElement folder for workspace '${workspaceId}' at '${workspaceAIElementFolder}'.`);
|
|
29
|
+
}
|
|
30
|
+
const files = yield fs.readdir(workspaceAIElementFolder);
|
|
31
|
+
if (files.length === 0) {
|
|
32
|
+
throw new AIElementError(`'${workspaceAIElementFolder}' is empty. No AIElement files found for workspace '${workspaceId}'.`);
|
|
33
|
+
}
|
|
34
|
+
const aiElements = yield Promise.all(files
|
|
35
|
+
.filter((file) => path.extname(file) === '.json')
|
|
36
|
+
.map((file) => __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const jsonFile = path.join(workspaceAIElementFolder, file);
|
|
38
|
+
const baseName = path.basename(jsonFile, '.json');
|
|
39
|
+
const pngFile = path.join(workspaceAIElementFolder, `${baseName}.png`);
|
|
40
|
+
if (yield fs.pathExists(pngFile)) {
|
|
41
|
+
const metadata = JSON.parse(yield fs.readFile(jsonFile, 'utf-8'));
|
|
42
|
+
return AIElement.fromJson(metadata, pngFile);
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
})));
|
|
46
|
+
const validAIElements = aiElements.filter((element) => element !== null);
|
|
47
|
+
if (validAIElements.length === 0) {
|
|
48
|
+
throw new AIElementError(`No AIElement files found for workspace '${workspaceId}' at '${workspaceAIElementFolder}'.`);
|
|
49
|
+
}
|
|
50
|
+
return new AIElementCollection(validAIElements);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
getByName(name) {
|
|
54
|
+
if (name === '') {
|
|
55
|
+
throw new AIElementError("Parameter 'name' must be non-empty. This might be due to corrupted metadata.");
|
|
56
|
+
}
|
|
57
|
+
logger.debug(`Getting all CustomElementJson with the name '${name}' ...`);
|
|
58
|
+
const elements = this.elements.filter((element) => element.hasName(name));
|
|
59
|
+
if (elements.length === 0) {
|
|
60
|
+
throw new AIElementError(`No AIElement with the name '${name}' was found.`);
|
|
61
|
+
}
|
|
62
|
+
return elements.map((element) => element.toCustomElement());
|
|
63
|
+
}
|
|
64
|
+
getByNames(names) {
|
|
65
|
+
if (names.length === 0) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
return names.flatMap((name) => this.getByName(name));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
AIElementCollection.AI_ELEMENT_FOLDER = path.join(os.homedir(), '.askui', 'SnippingTool', 'AIElement');
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { CustomElementJson } from '../model/custom-element-json';
|
|
2
|
+
interface AIElementJson {
|
|
3
|
+
version: number;
|
|
4
|
+
name: string;
|
|
5
|
+
image?: {
|
|
6
|
+
mask?: {
|
|
7
|
+
x: number;
|
|
8
|
+
y: number;
|
|
9
|
+
}[];
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
declare class AIElement {
|
|
13
|
+
name: string;
|
|
14
|
+
imagePath: string;
|
|
15
|
+
mask?: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
}[] | undefined;
|
|
19
|
+
constructor(name: string, imagePath: string, mask?: {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
}[] | undefined);
|
|
23
|
+
static fromJson(json: AIElementJson, imagePath: string): AIElement;
|
|
24
|
+
toCustomElement(): CustomElementJson;
|
|
25
|
+
hasName(name: string): boolean;
|
|
26
|
+
}
|
|
27
|
+
export { AIElement, AIElementJson };
|