askui 0.1.4 → 0.2.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.
Files changed (188) hide show
  1. package/README.md +6 -0
  2. package/dist/cjs/core/model/test-case-dto/custom-element.d.ts +2 -2
  3. package/dist/cjs/core/model/test-case-dto/custom-element.js +2 -2
  4. package/dist/cjs/core/model/test-case-dto/custom-element.spec.js +7 -6
  5. package/dist/cjs/execution/dsl.d.ts +6 -17
  6. package/dist/cjs/execution/dsl.js +4 -21
  7. package/dist/cjs/execution/execution-runtime.d.ts +5 -5
  8. package/dist/cjs/execution/execution-runtime.js +14 -14
  9. package/dist/cjs/execution/index.d.ts +2 -1
  10. package/dist/cjs/execution/index.js +5 -3
  11. package/dist/cjs/execution/{control-your-ui-api.d.ts → inference-client.d.ts} +3 -3
  12. package/dist/cjs/execution/{control-your-ui-api.js → inference-client.js} +8 -8
  13. package/dist/cjs/execution/ui-control-client-error.d.ts +2 -0
  14. package/dist/cjs/execution/ui-control-client-error.js +6 -0
  15. package/dist/cjs/execution/ui-control-client.d.ts +34 -0
  16. package/dist/cjs/execution/{client.js → ui-control-client.js} +48 -29
  17. package/dist/cjs/execution/{client-connection-state.d.ts → ui-controller-client-connection-state.d.ts} +1 -1
  18. package/dist/cjs/execution/ui-controller-client-connection-state.js +10 -0
  19. package/dist/cjs/execution/ui-controller-client-interface.d.ts +27 -0
  20. package/dist/cjs/execution/{client-interface.js → ui-controller-client-interface.js} +0 -0
  21. package/dist/cjs/execution/{control-your-ui-client.d.ts → ui-controller-client.d.ts} +6 -6
  22. package/dist/cjs/execution/{control-your-ui-client.js → ui-controller-client.js} +28 -28
  23. package/dist/cjs/lib/download-binaries.js +8 -8
  24. package/dist/cjs/lib/index.d.ts +1 -1
  25. package/dist/cjs/lib/index.js +3 -3
  26. package/dist/cjs/lib/libfuse-error.d.ts +2 -0
  27. package/dist/cjs/lib/libfuse-error.js +6 -0
  28. package/dist/cjs/lib/logger.js +1 -1
  29. package/dist/cjs/lib/timeout-error.d.ts +0 -2
  30. package/dist/cjs/lib/timeout-error.js +0 -5
  31. package/dist/cjs/lib/ui-controller-args.d.ts +47 -0
  32. package/dist/cjs/lib/{control-ui-server-args.js → ui-controller-args.js} +0 -0
  33. package/dist/cjs/lib/{control-ui-server-args.spec.d.ts → ui-controller-args.spec.d.ts} +0 -0
  34. package/dist/cjs/lib/{control-ui-server-args.spec.js → ui-controller-args.spec.js} +7 -7
  35. package/dist/cjs/lib/ui-controller-darwin.d.ts +6 -0
  36. package/dist/cjs/lib/{control-ui-server-darwin.js → ui-controller-darwin.js} +8 -8
  37. package/dist/cjs/lib/ui-controller-facade.d.ts +17 -0
  38. package/dist/cjs/lib/{control-ui-server-facade.js → ui-controller-facade.js} +22 -16
  39. package/dist/cjs/lib/ui-controller-linux.d.ts +5 -0
  40. package/dist/cjs/lib/ui-controller-linux.js +52 -0
  41. package/dist/cjs/lib/ui-controller-win32.d.ts +3 -0
  42. package/dist/cjs/lib/ui-controller-win32.js +7 -0
  43. package/dist/cjs/lib/ui-controller.d.ts +8 -0
  44. package/dist/cjs/lib/{askui-control-server.js → ui-controller.js} +9 -9
  45. package/dist/cjs/lib/unkown-error.d.ts +0 -2
  46. package/dist/cjs/lib/unkown-error.js +0 -5
  47. package/dist/cjs/lib/wayland-error.d.ts +2 -0
  48. package/dist/cjs/lib/wayland-error.js +6 -0
  49. package/dist/cjs/main.d.ts +3 -2
  50. package/dist/cjs/main.js +6 -3
  51. package/dist/cjs/shared/index.d.ts +1 -0
  52. package/dist/cjs/shared/index.js +5 -0
  53. package/dist/cjs/utils/analytics/analytics-interface.d.ts +3 -0
  54. package/dist/cjs/utils/analytics/analytics-interface.js +2 -0
  55. package/dist/cjs/utils/analytics/analytics.d.ts +5 -0
  56. package/dist/cjs/utils/analytics/analytics.js +32 -0
  57. package/dist/cjs/utils/analytics/index.d.ts +1 -0
  58. package/dist/cjs/utils/analytics/index.js +5 -0
  59. package/dist/cjs/utils/analytics/user-identifier-interface.d.ts +3 -0
  60. package/dist/cjs/utils/analytics/user-identifier-interface.js +2 -0
  61. package/dist/cjs/utils/analytics/user-identifier.d.ts +4 -0
  62. package/dist/cjs/utils/analytics/user-identifier.js +22 -0
  63. package/dist/cjs/utils/base_64_image/base-64-image-error.d.ts +2 -0
  64. package/dist/cjs/utils/base_64_image/base-64-image-error.js +6 -0
  65. package/dist/cjs/utils/base_64_image/base-64-image-path-error.d.ts +4 -0
  66. package/dist/cjs/utils/base_64_image/base-64-image-path-error.js +11 -0
  67. package/dist/cjs/utils/base_64_image/base-64-image-string-error.d.ts +4 -0
  68. package/dist/cjs/utils/base_64_image/base-64-image-string-error.js +11 -0
  69. package/dist/cjs/utils/base_64_image/base-64-image.d.ts +18 -0
  70. package/dist/cjs/utils/base_64_image/base-64-image.js +86 -0
  71. package/dist/cjs/utils/http/custom-errors/http-client-error.d.ts +0 -2
  72. package/dist/cjs/utils/http/custom-errors/http-client-error.js +0 -5
  73. package/dist/cjs/utils/http/http-client-got.d.ts +6 -5
  74. package/dist/cjs/utils/http/http-client-got.js +11 -11
  75. package/dist/cjs/utils/image-resize-errors/image-resizing-base-error.d.ts +0 -2
  76. package/dist/cjs/utils/image-resize-errors/image-resizing-base-error.js +0 -5
  77. package/dist/cjs/utils/image-resize-errors/index.d.ts +0 -1
  78. package/dist/cjs/utils/image-resize-errors/index.js +1 -3
  79. package/dist/cjs/utils/transformations.d.ts +0 -2
  80. package/dist/cjs/utils/transformations.js +11 -44
  81. package/dist/esm/core/model/test-case-dto/custom-element.d.ts +2 -2
  82. package/dist/esm/core/model/test-case-dto/custom-element.js +2 -2
  83. package/dist/esm/core/model/test-case-dto/custom-element.spec.js +7 -6
  84. package/dist/esm/execution/dsl.d.ts +6 -17
  85. package/dist/esm/execution/dsl.js +3 -21
  86. package/dist/esm/execution/execution-runtime.d.ts +5 -5
  87. package/dist/esm/execution/execution-runtime.js +14 -14
  88. package/dist/esm/execution/index.d.ts +2 -1
  89. package/dist/esm/execution/index.js +2 -1
  90. package/dist/esm/execution/{control-your-ui-api.d.ts → inference-client.d.ts} +3 -3
  91. package/dist/esm/execution/{control-your-ui-api.js → inference-client.js} +6 -6
  92. package/dist/esm/execution/ui-control-client-error.d.ts +2 -0
  93. package/dist/esm/execution/ui-control-client-error.js +2 -0
  94. package/dist/esm/execution/ui-control-client.d.ts +34 -0
  95. package/dist/esm/execution/{client.js → ui-control-client.js} +46 -27
  96. package/dist/esm/execution/{client-connection-state.d.ts → ui-controller-client-connection-state.d.ts} +1 -1
  97. package/dist/esm/execution/ui-controller-client-connection-state.js +7 -0
  98. package/dist/esm/execution/ui-controller-client-interface.d.ts +27 -0
  99. package/dist/esm/execution/{client-interface.js → ui-controller-client-interface.js} +0 -0
  100. package/dist/esm/execution/{control-your-ui-client.d.ts → ui-controller-client.d.ts} +6 -6
  101. package/dist/esm/execution/{control-your-ui-client.js → ui-controller-client.js} +26 -26
  102. package/dist/esm/lib/download-binaries.js +8 -8
  103. package/dist/esm/lib/index.d.ts +1 -1
  104. package/dist/esm/lib/index.js +1 -1
  105. package/dist/esm/lib/libfuse-error.d.ts +2 -0
  106. package/dist/esm/lib/libfuse-error.js +2 -0
  107. package/dist/esm/lib/logger.js +1 -1
  108. package/dist/esm/lib/timeout-error.d.ts +0 -2
  109. package/dist/esm/lib/timeout-error.js +0 -5
  110. package/dist/esm/lib/ui-controller-args.d.ts +47 -0
  111. package/dist/esm/lib/{control-ui-server-args.js → ui-controller-args.js} +0 -0
  112. package/dist/esm/lib/{control-ui-server-args.spec.d.ts → ui-controller-args.spec.d.ts} +0 -0
  113. package/dist/esm/lib/{control-ui-server-args.spec.js → ui-controller-args.spec.js} +1 -1
  114. package/dist/esm/lib/ui-controller-darwin.d.ts +6 -0
  115. package/dist/esm/lib/{control-ui-server-darwin.js → ui-controller-darwin.js} +6 -6
  116. package/dist/esm/lib/ui-controller-facade.d.ts +17 -0
  117. package/dist/esm/lib/{control-ui-server-facade.js → ui-controller-facade.js} +17 -11
  118. package/dist/esm/lib/ui-controller-linux.d.ts +5 -0
  119. package/dist/esm/lib/ui-controller-linux.js +48 -0
  120. package/dist/esm/lib/ui-controller-win32.d.ts +3 -0
  121. package/dist/esm/lib/ui-controller-win32.js +3 -0
  122. package/dist/esm/lib/ui-controller.d.ts +8 -0
  123. package/dist/esm/lib/{askui-control-server.js → ui-controller.js} +7 -7
  124. package/dist/esm/lib/unkown-error.d.ts +0 -2
  125. package/dist/esm/lib/unkown-error.js +0 -5
  126. package/dist/esm/lib/wayland-error.d.ts +2 -0
  127. package/dist/esm/lib/wayland-error.js +2 -0
  128. package/dist/esm/main.d.ts +3 -2
  129. package/dist/esm/main.js +3 -2
  130. package/dist/esm/shared/index.d.ts +1 -0
  131. package/dist/esm/shared/index.js +1 -0
  132. package/dist/esm/utils/analytics/analytics-interface.d.ts +3 -0
  133. package/dist/esm/utils/analytics/analytics-interface.js +1 -0
  134. package/dist/esm/utils/analytics/analytics.d.ts +5 -0
  135. package/dist/esm/utils/analytics/analytics.js +25 -0
  136. package/dist/esm/utils/analytics/index.d.ts +1 -0
  137. package/dist/esm/utils/analytics/index.js +1 -0
  138. package/dist/esm/utils/analytics/user-identifier-interface.d.ts +3 -0
  139. package/dist/esm/utils/analytics/user-identifier-interface.js +1 -0
  140. package/dist/esm/utils/analytics/user-identifier.d.ts +4 -0
  141. package/dist/esm/utils/analytics/user-identifier.js +18 -0
  142. package/dist/esm/utils/base_64_image/base-64-image-error.d.ts +2 -0
  143. package/dist/esm/utils/base_64_image/base-64-image-error.js +2 -0
  144. package/dist/esm/utils/base_64_image/base-64-image-path-error.d.ts +4 -0
  145. package/dist/esm/utils/base_64_image/base-64-image-path-error.js +7 -0
  146. package/dist/esm/utils/base_64_image/base-64-image-string-error.d.ts +4 -0
  147. package/dist/esm/utils/base_64_image/base-64-image-string-error.js +7 -0
  148. package/dist/esm/utils/base_64_image/base-64-image.d.ts +18 -0
  149. package/dist/esm/utils/base_64_image/base-64-image.js +79 -0
  150. package/dist/esm/utils/http/custom-errors/http-client-error.d.ts +0 -2
  151. package/dist/esm/utils/http/custom-errors/http-client-error.js +0 -5
  152. package/dist/esm/utils/http/http-client-got.d.ts +6 -5
  153. package/dist/esm/utils/http/http-client-got.js +11 -11
  154. package/dist/esm/utils/image-resize-errors/image-resizing-base-error.d.ts +0 -2
  155. package/dist/esm/utils/image-resize-errors/image-resizing-base-error.js +0 -5
  156. package/dist/esm/utils/image-resize-errors/index.d.ts +0 -1
  157. package/dist/esm/utils/image-resize-errors/index.js +0 -1
  158. package/dist/esm/utils/transformations.d.ts +0 -2
  159. package/dist/esm/utils/transformations.js +11 -39
  160. package/dist/example_projects_templates/typescript_jest/test/helper/jest.setup.ts +7 -7
  161. package/dist/example_projects_templates/typescript_jest/test/jest.config.ts +3 -0
  162. package/package.json +9 -6
  163. package/dist/cjs/execution/client-connection-state.js +0 -10
  164. package/dist/cjs/execution/client-error.d.ts +0 -2
  165. package/dist/cjs/execution/client-error.js +0 -6
  166. package/dist/cjs/execution/client-interface.d.ts +0 -13
  167. package/dist/cjs/execution/client.d.ts +0 -25
  168. package/dist/cjs/lib/askui-control-server.d.ts +0 -8
  169. package/dist/cjs/lib/control-ui-server-args.d.ts +0 -21
  170. package/dist/cjs/lib/control-ui-server-darwin.d.ts +0 -6
  171. package/dist/cjs/lib/control-ui-server-facade.d.ts +0 -16
  172. package/dist/cjs/lib/control-ui-server-linux.d.ts +0 -4
  173. package/dist/cjs/lib/control-ui-server-linux.js +0 -13
  174. package/dist/cjs/lib/control-ui-server-win32.d.ts +0 -3
  175. package/dist/cjs/lib/control-ui-server-win32.js +0 -7
  176. package/dist/esm/execution/client-connection-state.js +0 -7
  177. package/dist/esm/execution/client-error.d.ts +0 -2
  178. package/dist/esm/execution/client-error.js +0 -2
  179. package/dist/esm/execution/client-interface.d.ts +0 -13
  180. package/dist/esm/execution/client.d.ts +0 -25
  181. package/dist/esm/lib/askui-control-server.d.ts +0 -8
  182. package/dist/esm/lib/control-ui-server-args.d.ts +0 -21
  183. package/dist/esm/lib/control-ui-server-darwin.d.ts +0 -6
  184. package/dist/esm/lib/control-ui-server-facade.d.ts +0 -16
  185. package/dist/esm/lib/control-ui-server-linux.d.ts +0 -4
  186. package/dist/esm/lib/control-ui-server-linux.js +0 -9
  187. package/dist/esm/lib/control-ui-server-win32.d.ts +0 -3
  188. package/dist/esm/lib/control-ui-server-win32.js +0 -3
package/README.md CHANGED
@@ -42,6 +42,12 @@ npx askui init
42
42
 
43
43
  Visit our [documentation](https://docs.askui.com) for examples and a full list of supported commands.
44
44
 
45
+ ### Notes
46
+
47
+ Important note for Linux users: Currently, Wayland is not supported.
48
+ You can read more in our [troubleshooting chapter](https://docs.askui.com/docs/general/Troubleshooting/askui-ui-controller-starting-problems#wayland).
49
+ If you want to use the askui library libfuse2 is needed ([libfuse2 installation](https://docs.askui.com/docs/general/Troubleshooting/askui-ui-controller-starting-problems#libfuse2)).
50
+
45
51
  ## Example
46
52
 
47
53
  The following example shows the use of **askui** for testing a desktop application.
@@ -4,13 +4,13 @@ export declare class CustomElement implements CustomElementJson {
4
4
  name?: string | undefined;
5
5
  threshold?: number | undefined;
6
6
  rotationDegreePerStep?: number | undefined;
7
- imageCompareFormat?: "grayscale" | "RGB" | undefined;
7
+ imageCompareFormat?: "RGB" | "grayscale" | undefined;
8
8
  mask?: {
9
9
  x: number;
10
10
  y: number;
11
11
  }[] | undefined;
12
12
  private static schema;
13
- constructor(customImage: string, name?: string | undefined, threshold?: number | undefined, rotationDegreePerStep?: number | undefined, imageCompareFormat?: "grayscale" | "RGB" | undefined, mask?: {
13
+ constructor(customImage: string, name?: string | undefined, threshold?: number | undefined, rotationDegreePerStep?: number | undefined, imageCompareFormat?: "RGB" | "grayscale" | undefined, mask?: {
14
14
  x: number;
15
15
  y: number;
16
16
  }[] | undefined);
@@ -11,7 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.CustomElement = void 0;
13
13
  const yup_1 = require("yup");
14
- const transformations_1 = require("../../../utils/transformations");
14
+ const base_64_image_1 = require("../../../utils/base_64_image/base-64-image");
15
15
  class CustomElement {
16
16
  constructor(customImage, name, threshold, rotationDegreePerStep, imageCompareFormat, mask) {
17
17
  this.customImage = customImage;
@@ -28,7 +28,7 @@ class CustomElement {
28
28
  }
29
29
  static fromJsonWithImagePathOrImage(ceJson) {
30
30
  return __awaiter(this, void 0, void 0, function* () {
31
- const customImage = yield (0, transformations_1.toBase64ImageIfNeeded)(ceJson.customImage);
31
+ const customImage = (yield base_64_image_1.Base64Image.fromPathOrString(ceJson.customImage)).toString();
32
32
  const customElement = CustomElement.fromJson(Object.assign(Object.assign({}, ceJson), { customImage }));
33
33
  customElement.validate();
34
34
  return customElement;
@@ -10,12 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const custom_element_1 = require("./custom-element");
13
+ 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/zmrhv3OP9BWvZciF1QvxwO9339xNPlvF+cX4+h2E/fe3bJf7GZxj2MMfiPrn4s84LJ9wu4bwwBosOJ6dN6Rhcm8+OxedBp69BgG08ImBxwB4G5qccEvbhui2ih+jy4jKAjokHnL73jzO9HOf/qRv/mEfj7wfuEWioB8O4QNGjIljO+k8hxc4nCuHQOF/RC4eEEyayLHCJQDoLqILzfvaP89884AA4vh1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RH1QAAAABJRU5ErkJggg==';
13
14
  describe('CustomElement', () => {
14
15
  describe('fromJsonWithImagePathOrImage', () => {
15
16
  test('should return CustomElement if CustomElement created from JSON is valid', () => __awaiter(void 0, void 0, void 0, function* () {
16
- const expected = new custom_element_1.CustomElement('data:image', 'Dummy_element', 0.7, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 3, y: 4 }]);
17
+ const expected = new custom_element_1.CustomElement(base64ImageString, 'Dummy_element', 0.7, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 3, y: 4 }]);
17
18
  const actual = yield custom_element_1.CustomElement.fromJsonWithImagePathOrImage({
18
- customImage: 'data:image',
19
+ customImage: base64ImageString,
19
20
  name: 'Dummy_element',
20
21
  threshold: 0.7,
21
22
  rotationDegreePerStep: 10,
@@ -26,25 +27,25 @@ describe('CustomElement', () => {
26
27
  }));
27
28
  test('should throw ValidationError if threshold is invalid', () => {
28
29
  expect(() => {
29
- const customElement = new custom_element_1.CustomElement('data:image', 'Dummy_element', 1.1, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 3, y: 4 }]);
30
+ const customElement = new custom_element_1.CustomElement(base64ImageString, 'Dummy_element', 1.1, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 3, y: 4 }]);
30
31
  customElement.validate();
31
32
  }).toThrow('threshold must be less than or equal to 1');
32
33
  });
33
34
  test('should throw ValidationError if rotationDegreePerStep is invalid', () => {
34
35
  expect(() => {
35
- const customElement = new custom_element_1.CustomElement('data:image', 'Dummy_element', 0.9, -90, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 3, y: 4 }]);
36
+ const customElement = new custom_element_1.CustomElement(base64ImageString, 'Dummy_element', 0.9, -90, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 3, y: 4 }]);
36
37
  customElement.validate();
37
38
  }).toThrow('rotationDegreePerStep must be greater than or equal to 0');
38
39
  });
39
40
  test('should throw ValidationError if mask is invalid', () => {
40
41
  expect(() => {
41
- const customElement = new custom_element_1.CustomElement('data:image', 'Dummy_element', 0.9, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }]);
42
+ const customElement = new custom_element_1.CustomElement(base64ImageString, 'Dummy_element', 0.9, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }]);
42
43
  customElement.validate();
43
44
  }).toThrow('mask must contain at least 3 points');
44
45
  });
45
46
  test('should throw ValidationError if mask and threshold are both invalid', () => {
46
47
  expect(() => {
47
- const customElement = new custom_element_1.CustomElement('data:image', 'Dummy_element', 90, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }]);
48
+ const customElement = new custom_element_1.CustomElement(base64ImageString, 'Dummy_element', 90, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }]);
48
49
  customElement.validate();
49
50
  }).toThrow('threshold must be less than or equal to 1, mask must contain at least 3 points');
50
51
  });
@@ -1,9 +1,4 @@
1
1
  import { CustomElementJson } from '../core/model/test-case-dto';
2
- export declare enum TimeUnit {
3
- MS = "millisecond",
4
- S = "seconds",
5
- MIN = "minutes"
6
- }
7
2
  export declare type PC_KEY = 'backspace' | 'delete' | 'enter' | 'tab' | 'escape' | 'up' | 'down' | 'right' | 'left' | 'home' | 'end' | 'pageup' | 'pagedown' | 'f1' | 'f2' | 'f3' | 'f4' | 'f5' | 'f6' | 'f7' | 'f8' | 'f9' | 'f10' | 'f11' | 'f12' | 'space' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | '!' | '"' | '#' | '$' | '%' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | '-' | '.' | '/' | ':' | ';' | '<' | '=' | '>' | '?' | '@' | '[' | '\\' | ']' | '^' | '_' | '`' | '{' | '|' | '}' | '~ ';
8
3
  export declare type ANDROID_KEY = 'home' | 'back' | 'call' | 'endcall' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'star' | 'pound' | 'dpad_up' | 'dpad_down' | 'dpad_left' | 'dpad_right' | 'dpad_center' | 'volume_up' | 'volume_down' | 'power' | 'camera' | 'clear' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | 'comma' | 'period' | 'alt_left' | 'alt_right' | 'shift_left' | 'shift_right' | 'tab' | 'space' | 'sym' | 'explorer' | 'envelope' | 'enter' | 'del' | 'grave' | 'minus' | 'equals' | 'left_bracket' | 'right_bracket' | 'backslash' | 'semicolon' | 'apostrophe' | 'slash' | 'at' | 'num' | 'headsethook' | 'focus' | 'plus' | 'menu' | 'notification' | 'search' | 'media_play_pause' | 'media_stop' | 'media_next' | 'media_previous' | 'media_rewind' | 'media_fast_forward' | 'mute' | 'page_up' | 'page_down' | 'switch_charset' | 'escape' | 'forward_del' | 'ctrl_left' | 'ctrl_right' | 'caps_lock' | 'scroll_lock' | 'function' | 'break' | 'move_home' | 'move_end' | 'insert' | 'forward' | 'media_play' | 'media_pause' | 'media_close' | 'media_eject' | 'media_record' | 'f1' | 'f2' | 'f3' | 'f4' | 'f5' | 'f6' | 'f7' | 'f8' | 'f9' | 'f10' | 'f11' | 'f12' | 'num_lock' | 'numpad_0' | 'numpad_1' | 'numpad_2' | 'numpad_3' | 'numpad_4' | 'numpad_5' | 'numpad_6' | 'numpad_7' | 'numpad_8' | 'numpad_9' | 'numpad_divide' | 'numpad_multiply' | 'numpad_subtract' | 'numpad_add' | 'numpad_dot' | 'numpad_comma' | 'numpad_enter' | 'numpad_equals' | 'numpad_left_paren' | 'numpad_right_paren' | 'volume_mute' | 'info' | 'channel_up' | 'channel_down' | 'zoom_in' | 'zoom_out' | 'window' | 'guide' | 'bookmark' | 'captions' | 'settings' | 'app_switch' | 'language_switch' | 'contacts' | 'calendar' | 'music' | 'calculator' | 'assist' | 'brightness_down' | 'brightness_up' | 'media_audio_track' | 'sleep' | 'wakeup' | 'pairing' | 'media_top_menu' | 'last_channel' | 'tv_data_service' | 'voice_assist' | 'help' | 'navigate_previous' | 'navigate_next' | 'navigate_in' | 'navigate_out' | 'dpad_up_left' | 'dpad_down_left' | 'dpad_up_right' | 'dpad_down_right' | 'media_skip_forward' | 'media_skip_backward' | 'media_step_forward' | 'media_step_backward' | 'soft_sleep' | 'cut' | 'copy' | 'paste' | 'all_apps' | 'refresh';
9
4
  export declare type MODIFIER_KEY = 'command' | 'alt' | 'control' | 'shift' | 'right_shift';
@@ -19,7 +14,10 @@ declare abstract class FluentBase {
19
14
  protected get textStr(): string;
20
15
  protected get params(): Map<string, unknown>;
21
16
  }
22
- declare class Exec extends FluentBase {
17
+ export interface Executable {
18
+ exec(): Promise<void>;
19
+ }
20
+ export declare class Exec extends FluentBase implements Executable {
23
21
  exec(): Promise<void>;
24
22
  }
25
23
  export declare class FluentFilters extends FluentBase {
@@ -1333,14 +1331,14 @@ export declare abstract class FluentCommand extends FluentBase {
1333
1331
  */
1334
1332
  typeIn(text: string): FluentFilters;
1335
1333
  /**
1336
- * Scrolls in the x and y direction, e.g., until an element is visible.
1334
+ * Moves mouse to the filtered element and scrolls in the x and y direction
1337
1335
  *
1338
1336
  * @param {number} x_offset - A (positive/negative) x direction.
1339
1337
  * @param {number} y_offset - A (positive/negative) y direction.
1340
1338
  *
1341
1339
  * @return {FluentFilters}
1342
1340
  */
1343
- scrollUntil(x_offset: number, y_offset: number): FluentFilters;
1341
+ scrollInside(x_offset: number, y_offset: number): FluentFilters;
1344
1342
  /**
1345
1343
  * Moves the mouse relatively to an element in the direction.
1346
1344
  * This can be used when the mouse should not hover over on an element anymore.
@@ -1368,15 +1366,6 @@ export declare abstract class FluentCommand extends FluentBase {
1368
1366
  * @return {Exec}
1369
1367
  */
1370
1368
  type(text: string): Exec;
1371
- /**
1372
- * Waits for `<timeValue> <timeUnit>`, e.g., 10 seconds.
1373
- *
1374
- * @param {number} timeValue - A number of time unit, e.g., ms or min, to wait for.
1375
- * @param {TimeUnit} timeUnit - A time unit, e.g., ms, s or min.
1376
- *
1377
- * @return {Exec}
1378
- */
1379
- waitFor(timeValue: number, timeUnit: TimeUnit): Exec;
1380
1369
  /**
1381
1370
  * Moves the mouse from the current position (relative) in x and y direction.
1382
1371
  *
@@ -4,13 +4,7 @@
4
4
  /* eslint-disable max-classes-per-file */
5
5
  // Autogenerated from typescript.template file
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.FluentCommand = exports.FluentFiltersOrRelationsCondition = exports.FluentFiltersCondition = exports.FluentFiltersOrRelations = exports.FluentFilters = exports.TimeUnit = void 0;
8
- var TimeUnit;
9
- (function (TimeUnit) {
10
- TimeUnit["MS"] = "millisecond";
11
- TimeUnit["S"] = "seconds";
12
- TimeUnit["MIN"] = "minutes";
13
- })(TimeUnit = exports.TimeUnit || (exports.TimeUnit = {}));
7
+ exports.FluentCommand = exports.FluentFiltersOrRelationsCondition = exports.FluentFiltersCondition = exports.FluentFiltersOrRelations = exports.FluentFilters = exports.Exec = void 0;
14
8
  class FluentBase {
15
9
  constructor(prev) {
16
10
  this.prev = prev;
@@ -47,6 +41,7 @@ class Exec extends FluentBase {
47
41
  return this.commandStringBuilder();
48
42
  }
49
43
  }
44
+ exports.Exec = Exec;
50
45
  // Filters
51
46
  class FluentFilters extends FluentBase {
52
47
  /**
@@ -1877,14 +1872,14 @@ class FluentCommand extends FluentBase {
1877
1872
  return new FluentFilters(this);
1878
1873
  }
1879
1874
  /**
1880
- * Scrolls in the x and y direction, e.g., until an element is visible.
1875
+ * Moves mouse to the filtered element and scrolls in the x and y direction
1881
1876
  *
1882
1877
  * @param {number} x_offset - A (positive/negative) x direction.
1883
1878
  * @param {number} y_offset - A (positive/negative) y direction.
1884
1879
  *
1885
1880
  * @return {FluentFilters}
1886
1881
  */
1887
- scrollUntil(x_offset, y_offset) {
1882
+ scrollInside(x_offset, y_offset) {
1888
1883
  this._textStr = `Scroll x ${x_offset} y ${y_offset} in`;
1889
1884
  return new FluentFilters(this);
1890
1885
  }
@@ -1924,18 +1919,6 @@ class FluentCommand extends FluentBase {
1924
1919
  this._textStr = `Type "${text}"`;
1925
1920
  return new Exec(this);
1926
1921
  }
1927
- /**
1928
- * Waits for `<timeValue> <timeUnit>`, e.g., 10 seconds.
1929
- *
1930
- * @param {number} timeValue - A number of time unit, e.g., ms or min, to wait for.
1931
- * @param {TimeUnit} timeUnit - A time unit, e.g., ms, s or min.
1932
- *
1933
- * @return {Exec}
1934
- */
1935
- waitFor(timeValue, timeUnit) {
1936
- this._textStr = `Wait for ${timeValue} ${timeUnit}`;
1937
- return new Exec(this);
1938
- }
1939
1922
  /**
1940
1923
  * Moves the mouse from the current position (relative) in x and y direction.
1941
1924
  *
@@ -1,12 +1,12 @@
1
1
  import { TestStep } from '../core/model/test-case-dto';
2
- import { ControlYourUiClient } from './control-your-ui-client';
3
- import { ControlYourUiApi } from './control-your-ui-api';
2
+ import { UiControllerClient } from './ui-controller-client';
3
+ import { InferenceClient } from './inference-client';
4
4
  import { Annotation } from '../core/annotation/annotation';
5
5
  import { CustomElementJson } from '../core/model/test-case-dto/custom-element-json';
6
6
  export declare class ExecutionRuntime {
7
- private client;
8
- private api;
9
- constructor(client: ControlYourUiClient, api: ControlYourUiApi);
7
+ private uiControllerClient;
8
+ private inferenceClient;
9
+ constructor(uiControllerClient: UiControllerClient, inferenceClient: InferenceClient);
10
10
  executeTestStep(step: TestStep): Promise<void>;
11
11
  /**
12
12
  * @param {TestStep} step - Test step used for predicting command.
@@ -15,12 +15,12 @@ const test_case_dto_1 = require("../core/model/test-case-dto");
15
15
  const repeat_error_1 = require("./repeat-error");
16
16
  const misc_1 = require("./misc");
17
17
  const control_command_error_1 = require("./control-command-error");
18
- const transformations_1 = require("../utils/transformations");
19
18
  const logger_1 = require("../lib/logger");
19
+ const base_64_image_1 = require("../utils/base_64_image/base-64-image");
20
20
  class ExecutionRuntime {
21
- constructor(client, api) {
22
- this.client = client;
23
- this.api = api;
21
+ constructor(uiControllerClient, inferenceClient) {
22
+ this.uiControllerClient = uiControllerClient;
23
+ this.inferenceClient = inferenceClient;
24
24
  this.EXEC_REPETITION_COUNT = 25;
25
25
  this.PREDICT_COMMAND_RETRY_COUNT = 2;
26
26
  }
@@ -38,10 +38,10 @@ class ExecutionRuntime {
38
38
  return __awaiter(this, void 0, void 0, function* () {
39
39
  const controlCommand = yield this.predictCommandWithRetry(step);
40
40
  if (controlCommand.code === ui_control_commands_1.ControlCommandCode.OK) {
41
- yield this.client.requestControl(controlCommand);
41
+ yield this.uiControllerClient.requestControl(controlCommand);
42
42
  }
43
43
  else if (controlCommand.tryToRepeat) {
44
- yield this.client.requestControl(controlCommand);
44
+ yield this.uiControllerClient.requestControl(controlCommand);
45
45
  this.executeCommandRepeatedly(step);
46
46
  }
47
47
  else {
@@ -64,7 +64,7 @@ class ExecutionRuntime {
64
64
  break;
65
65
  }
66
66
  else if (controlCommand.tryToRepeat) {
67
- yield this.client.requestControl(controlCommand);
67
+ yield this.uiControllerClient.requestControl(controlCommand);
68
68
  }
69
69
  else {
70
70
  throw new control_command_error_1.ControlCommandError(((_a = controlCommand.actions[0]) === null || _a === void 0 ? void 0 : _a.text) || '');
@@ -96,29 +96,29 @@ class ExecutionRuntime {
96
96
  }
97
97
  predictCommand(step) {
98
98
  return __awaiter(this, void 0, void 0, function* () {
99
- const isImageRequired = yield this.api.isImageRequired(step.instruction);
99
+ const isImageRequired = yield this.inferenceClient.isImageRequired(step.instruction);
100
100
  let image;
101
101
  if (isImageRequired) {
102
- const screenshotResponse = yield this.client.requestScreenshot();
102
+ const screenshotResponse = yield this.uiControllerClient.requestScreenshot();
103
103
  image = screenshotResponse.data.image;
104
104
  }
105
- return this.api.predictControlCommand(step.instruction, step.customElements, image);
105
+ return this.inferenceClient.predictControlCommand(step.instruction, step.customElements, image);
106
106
  });
107
107
  }
108
108
  annotateInteractively() {
109
109
  return __awaiter(this, void 0, void 0, function* () {
110
110
  const annotationResponse = yield this.annotateImage();
111
- yield this.client.annotateInteractively(annotationResponse.objects, annotationResponse.image);
111
+ yield this.uiControllerClient.annotateInteractively(annotationResponse.objects, annotationResponse.image);
112
112
  });
113
113
  }
114
114
  takeScreenshotIfImageisNotProvided(imagePath) {
115
115
  return __awaiter(this, void 0, void 0, function* () {
116
116
  let base64Image = '';
117
117
  if (imagePath !== undefined) {
118
- base64Image = yield (0, transformations_1.toBase64Image)(imagePath);
118
+ base64Image = (yield base_64_image_1.Base64Image.fromPath(imagePath)).toString();
119
119
  }
120
120
  if (imagePath === undefined) {
121
- const screenshotResponse = yield this.client.requestScreenshot();
121
+ const screenshotResponse = yield this.uiControllerClient.requestScreenshot();
122
122
  base64Image = screenshotResponse.data.image;
123
123
  }
124
124
  return base64Image;
@@ -131,7 +131,7 @@ class ExecutionRuntime {
131
131
  if (customElementJson !== undefined) {
132
132
  customElements = yield test_case_dto_1.CustomElement.fromJsonListWithImagePathOrImage(customElementJson);
133
133
  }
134
- return this.api.predictImageAnnotation(base64Image, customElements);
134
+ return this.inferenceClient.predictImageAnnotation(base64Image, customElements);
135
135
  });
136
136
  }
137
137
  }
@@ -1 +1,2 @@
1
- export { AskuiClient } from './client';
1
+ export { AnnotationLevel } from './annotation-level';
2
+ export { UiControlClient } from './ui-control-client';
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AskuiClient = void 0;
4
- var client_1 = require("./client");
5
- Object.defineProperty(exports, "AskuiClient", { enumerable: true, get: function () { return client_1.AskuiClient; } });
3
+ exports.UiControlClient = exports.AnnotationLevel = void 0;
4
+ var annotation_level_1 = require("./annotation-level");
5
+ Object.defineProperty(exports, "AnnotationLevel", { enumerable: true, get: function () { return annotation_level_1.AnnotationLevel; } });
6
+ var ui_control_client_1 = require("./ui-control-client");
7
+ Object.defineProperty(exports, "UiControlClient", { enumerable: true, get: function () { return ui_control_client_1.UiControlClient; } });
@@ -2,10 +2,10 @@ import { HttpClientGot } from '../utils/http/http-client-got';
2
2
  import { ControlCommand } from '../core/ui-control-commands';
3
3
  import { CustomElement } from '../core/model/test-case-dto';
4
4
  import { Annotation } from '../core/annotation/annotation';
5
- export declare class ControlYourUiApi {
6
- apiEndpointUrl: string;
5
+ export declare class InferenceClient {
6
+ url: string;
7
7
  httpClient: HttpClientGot;
8
- constructor(apiEndpointUrl: string, httpClient: HttpClientGot);
8
+ constructor(url: string, httpClient: HttpClientGot);
9
9
  isImageRequired(instruction: string): Promise<boolean>;
10
10
  private resizeIfNeeded;
11
11
  predictControlCommand(instruction: string, customElements: CustomElement[], image?: string): Promise<ControlCommand>;
@@ -12,19 +12,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.ControlYourUiApi = void 0;
15
+ exports.InferenceClient = void 0;
16
16
  const url_join_1 = __importDefault(require("url-join"));
17
17
  const ui_control_commands_1 = require("../core/ui-control-commands");
18
18
  const annotation_1 = require("../core/annotation/annotation");
19
19
  const transformations_1 = require("../utils/transformations");
20
- class ControlYourUiApi {
21
- constructor(apiEndpointUrl, httpClient) {
22
- this.apiEndpointUrl = apiEndpointUrl;
20
+ class InferenceClient {
21
+ constructor(url, httpClient) {
22
+ this.url = url;
23
23
  this.httpClient = httpClient;
24
24
  }
25
25
  isImageRequired(instruction) {
26
26
  return __awaiter(this, void 0, void 0, function* () {
27
- const url = (0, url_join_1.default)(this.apiEndpointUrl, 'instruction', 'is-image-required');
27
+ const url = (0, url_join_1.default)(this.url, 'instruction', 'is-image-required');
28
28
  const httpBody = {
29
29
  instruction,
30
30
  };
@@ -49,7 +49,7 @@ class ControlYourUiApi {
49
49
  instruction,
50
50
  customElements,
51
51
  };
52
- const url = (0, url_join_1.default)(this.apiEndpointUrl, 'api', 'v1', 'predict-command');
52
+ const url = (0, url_join_1.default)(this.url, 'api', 'v1', 'predict-command');
53
53
  const httpResponse = yield this.httpClient.post(url, httpBody);
54
54
  return ui_control_commands_1.ControlCommand.fromJson(httpResponse, resizedImage.resizeRatio);
55
55
  });
@@ -61,10 +61,10 @@ class ControlYourUiApi {
61
61
  image: resizedImage.base64Image,
62
62
  customElements,
63
63
  };
64
- const url = (0, url_join_1.default)(this.apiEndpointUrl, 'annotate', '?format=json');
64
+ const url = (0, url_join_1.default)(this.url, 'annotate', '?format=json');
65
65
  const httpResponse = yield this.httpClient.post(url, httpBody);
66
66
  return annotation_1.Annotation.fromJson(Object.assign(Object.assign({}, httpResponse), { image }), resizedImage.resizeRatio);
67
67
  });
68
68
  }
69
69
  }
70
- exports.ControlYourUiApi = ControlYourUiApi;
70
+ exports.InferenceClient = InferenceClient;
@@ -0,0 +1,2 @@
1
+ export declare class UiControlClientError extends Error {
2
+ }
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UiControlClientError = void 0;
4
+ class UiControlClientError extends Error {
5
+ }
6
+ exports.UiControlClientError = UiControlClientError;
@@ -0,0 +1,34 @@
1
+ import { CustomElementJson } from '../core/model/test-case-dto';
2
+ import { Executable, FluentCommand } from './dsl';
3
+ import { UiControllerClientConnectionState } from './ui-controller-client-connection-state';
4
+ import { Annotation } from '../core/annotation/annotation';
5
+ import { AnnotationRequest } from '../core/model/annotation-result/annotation-interface';
6
+ import { ClientArgs } from './ui-controller-client-interface';
7
+ export declare class UiControlClient extends FluentCommand {
8
+ private httpClient;
9
+ private clientArgs;
10
+ private _uiControllerClient?;
11
+ private constructor();
12
+ static build(clientArgs?: ClientArgs): Promise<UiControlClient>;
13
+ private get uiControllerClient();
14
+ private get inferenceClient();
15
+ private get executionRuntime();
16
+ private annotateByDefault;
17
+ connect(): Promise<UiControllerClientConnectionState>;
18
+ annotate(annotationRequest?: AnnotationRequest): Promise<Annotation>;
19
+ annotateInteractively(): Promise<void>;
20
+ exec(instruction: string, customElementJson?: CustomElementJson[]): Promise<void>;
21
+ /**
22
+ * Waits for `<delayInMs>` ms, e.g., 1000 ms. The exact delay may be a little longer
23
+ * than `<delayInMs>` but never shorter than that.
24
+ *
25
+ * @param {number} delayInMs - The delay in ms to wait for.
26
+ *
27
+ * @return {Executable}
28
+ */
29
+ waitFor(delayInMs: number): Executable;
30
+ /**
31
+ * closes the connection to the controlui-server`.
32
+ */
33
+ close(): void;
34
+ }
@@ -9,52 +9,54 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AskuiClient = void 0;
12
+ exports.UiControlClient = void 0;
13
13
  const test_case_dto_1 = require("../core/model/test-case-dto");
14
14
  const dsl_1 = require("./dsl");
15
15
  const http_client_got_1 = require("../utils/http/http-client-got");
16
- const control_your_ui_client_1 = require("./control-your-ui-client");
16
+ const ui_controller_client_1 = require("./ui-controller-client");
17
17
  const execution_runtime_1 = require("./execution-runtime");
18
- const control_your_ui_api_1 = require("./control-your-ui-api");
18
+ const inference_client_1 = require("./inference-client");
19
19
  const annotation_writer_1 = require("../core/annotation/annotation-writer");
20
20
  const logger_1 = require("../lib/logger");
21
21
  const test_case_result_dto_1 = require("../core/model/test-case-result-dto");
22
22
  const annotation_level_1 = require("./annotation-level");
23
- const client_error_1 = require("./client-error");
23
+ const ui_control_client_error_1 = require("./ui-control-client-error");
24
24
  const read_environment_credentials_1 = require("./read-environment-credentials");
25
- class AskuiClient extends dsl_1.FluentCommand {
26
- constructor(clientArgs) {
27
- var _a;
25
+ const analytics_1 = require("../utils/analytics");
26
+ const getClientArgsWithDefaults = (clientArgs = {}) => (Object.assign({ uiControllerUrl: 'http://localhost:6769', inferenceServerUrl: 'https://inference.askui.com', annotationLevel: annotation_level_1.AnnotationLevel.DISABLED }, clientArgs));
27
+ class UiControlClient extends dsl_1.FluentCommand {
28
+ constructor(httpClient, clientArgs) {
28
29
  super();
30
+ this.httpClient = httpClient;
29
31
  this.clientArgs = clientArgs;
30
- this.httpClient = new http_client_got_1.HttpClientGot(((_a = this.clientArgs) === null || _a === void 0 ? void 0 : _a.credentials) ? this.clientArgs.credentials : (0, read_environment_credentials_1.envCredentials)());
31
32
  }
32
- get controlYourUiClient() {
33
- if (!this._controlYourUiClient) {
34
- this._controlYourUiClient = new control_your_ui_client_1.ControlYourUiClient(this.clientArgsWithDefaults.controlServerUrl);
35
- }
36
- return this._controlYourUiClient;
33
+ static build(clientArgs) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const analytics = new analytics_1.Analytics();
36
+ const analyticsHeaders = yield analytics.getAnalyticsHeaders();
37
+ const cas = getClientArgsWithDefaults(clientArgs);
38
+ const httpClient = new http_client_got_1.HttpClientGot(cas.credentials || (0, read_environment_credentials_1.envCredentials)(), analyticsHeaders);
39
+ return new UiControlClient(httpClient, cas);
40
+ });
37
41
  }
38
- get clientArgsWithDefaults() {
39
- const defaults = {
40
- controlServerUrl: 'http://localhost:6769',
41
- controlYourUiApi: 'https://inference.askui.com',
42
- annotationLevel: annotation_level_1.AnnotationLevel.DISABLED,
43
- };
44
- return Object.assign(defaults, this.clientArgs);
42
+ get uiControllerClient() {
43
+ if (!this._uiControllerClient) {
44
+ this._uiControllerClient = new ui_controller_client_1.UiControllerClient(this.clientArgs.uiControllerUrl);
45
+ }
46
+ return this._uiControllerClient;
45
47
  }
46
- get api() {
47
- return new control_your_ui_api_1.ControlYourUiApi(this.clientArgsWithDefaults.controlYourUiApi, this.httpClient);
48
+ get inferenceClient() {
49
+ return new inference_client_1.InferenceClient(this.clientArgs.inferenceServerUrl, this.httpClient);
48
50
  }
49
51
  get executionRuntime() {
50
- return new execution_runtime_1.ExecutionRuntime(this.controlYourUiClient, this.api);
52
+ return new execution_runtime_1.ExecutionRuntime(this.uiControllerClient, this.inferenceClient);
51
53
  }
52
54
  annotateByDefault(testStepState, customElements = []) {
53
55
  return __awaiter(this, void 0, void 0, function* () {
54
56
  if ((testStepState === test_case_result_dto_1.TestStepState.FAILED
55
- && this.clientArgsWithDefaults.annotationLevel === annotation_level_1.AnnotationLevel.DISABLED)
57
+ && this.clientArgs.annotationLevel === annotation_level_1.AnnotationLevel.DISABLED)
56
58
  || (testStepState === test_case_result_dto_1.TestStepState.PASSED
57
- && this.clientArgsWithDefaults.annotationLevel !== annotation_level_1.AnnotationLevel.ALL)) {
59
+ && this.clientArgs.annotationLevel !== annotation_level_1.AnnotationLevel.ALL)) {
58
60
  return;
59
61
  }
60
62
  yield this.annotate({
@@ -65,7 +67,7 @@ class AskuiClient extends dsl_1.FluentCommand {
65
67
  }
66
68
  connect() {
67
69
  return __awaiter(this, void 0, void 0, function* () {
68
- const connectionState = yield this.controlYourUiClient.connect();
70
+ const connectionState = yield this.uiControllerClient.connect();
69
71
  return connectionState;
70
72
  });
71
73
  }
@@ -102,15 +104,32 @@ class AskuiClient extends dsl_1.FluentCommand {
102
104
  }
103
105
  catch (error) {
104
106
  yield this.annotateByDefault(test_case_result_dto_1.TestStepState.FAILED, customElements);
105
- return Promise.reject(new client_error_1.ControlUiClientError(`A problem occures while executing the instruction: ${instruction}. Reason ${error}`));
107
+ return Promise.reject(new ui_control_client_error_1.UiControlClientError(`A problem occures while executing the instruction: ${instruction}. Reason ${error}`));
106
108
  }
107
109
  });
108
110
  }
111
+ /**
112
+ * Waits for `<delayInMs>` ms, e.g., 1000 ms. The exact delay may be a little longer
113
+ * than `<delayInMs>` but never shorter than that.
114
+ *
115
+ * @param {number} delayInMs - The delay in ms to wait for.
116
+ *
117
+ * @return {Executable}
118
+ */
119
+ // eslint-disable-next-line class-methods-use-this
120
+ waitFor(delayInMs) {
121
+ return {
122
+ exec() {
123
+ logger_1.logger.debug(`Wait for ${delayInMs} ms`);
124
+ return new Promise((resolve) => { setTimeout(() => resolve(), delayInMs); });
125
+ },
126
+ };
127
+ }
109
128
  /**
110
129
  * closes the connection to the controlui-server`.
111
130
  */
112
131
  close() {
113
- this.controlYourUiClient.close();
132
+ this.uiControllerClient.close();
114
133
  }
115
134
  }
116
- exports.AskuiClient = AskuiClient;
135
+ exports.UiControlClient = UiControlClient;
@@ -1,4 +1,4 @@
1
- export declare enum ClientConnectionState {
1
+ export declare enum UiControllerClientConnectionState {
2
2
  NOT_CONNECTED = 0,
3
3
  CONNECTING = 1,
4
4
  CONNECTED = 2,
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UiControllerClientConnectionState = void 0;
4
+ var UiControllerClientConnectionState;
5
+ (function (UiControllerClientConnectionState) {
6
+ UiControllerClientConnectionState[UiControllerClientConnectionState["NOT_CONNECTED"] = 0] = "NOT_CONNECTED";
7
+ UiControllerClientConnectionState[UiControllerClientConnectionState["CONNECTING"] = 1] = "CONNECTING";
8
+ UiControllerClientConnectionState[UiControllerClientConnectionState["CONNECTED"] = 2] = "CONNECTED";
9
+ UiControllerClientConnectionState[UiControllerClientConnectionState["ERROR"] = 3] = "ERROR";
10
+ })(UiControllerClientConnectionState = exports.UiControllerClientConnectionState || (exports.UiControllerClientConnectionState = {}));
@@ -0,0 +1,27 @@
1
+ import { CredentialArgs } from '../utils/http/credentials';
2
+ import { AnnotationLevel } from './annotation-level';
3
+ /**
4
+ * Configuration options for the askui UI Control Client
5
+ *
6
+ * @param {string} uiControllerUrl - Default: http://localhost:6769
7
+ * The adress of the askui UI Controller server.
8
+ * @param {string} inferenceClientUrl - Default: https://inference.askui.com`
9
+ * Address of the askui Inference server.
10
+ * @param {AnnotationLevel} annotationLevel - Default: AnnotationLevel.DISABLED
11
+ * Usage of annotate command
12
+ * after execution of test steps.
13
+ * You have three options: `DISABLED`, `ON_FAILURE`, `ALL`.
14
+ * @param {CredentialArgs} credentials - We need to provide credentials for
15
+ * the authentication of the askui Inference Server.
16
+ */
17
+ export interface ClientArgs {
18
+ readonly uiControllerUrl?: string;
19
+ readonly inferenceServerUrl?: string;
20
+ readonly annotationLevel?: AnnotationLevel;
21
+ readonly credentials?: CredentialArgs;
22
+ }
23
+ export interface ClientArgsWithDefaults extends ClientArgs {
24
+ readonly uiControllerUrl: string;
25
+ readonly inferenceServerUrl: string;
26
+ readonly annotationLevel: AnnotationLevel;
27
+ }