askui 0.2.0 → 0.2.3

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 (79) hide show
  1. package/README.md +2 -2
  2. package/bin/askui-postinstall +35 -0
  3. package/dist/cjs/core/model/test-case-dto/index.js +1 -3
  4. package/dist/cjs/core/model/test-case-dto/test-step.d.ts +3 -7
  5. package/dist/cjs/core/model/test-case-dto/test-step.js +0 -12
  6. package/dist/cjs/core/ui-control-commands/control-command.d.ts +1 -0
  7. package/dist/cjs/core/ui-control-commands/control-command.js +5 -0
  8. package/dist/cjs/core/ui-control-commands/input-event.d.ts +1 -2
  9. package/dist/cjs/core/ui-control-commands/input-event.js +0 -1
  10. package/dist/cjs/execution/dsl.d.ts +51 -1
  11. package/dist/cjs/execution/dsl.js +67 -10
  12. package/dist/cjs/execution/execution-runtime.d.ts +2 -0
  13. package/dist/cjs/execution/execution-runtime.js +27 -15
  14. package/dist/cjs/execution/inference-client.d.ts +1 -1
  15. package/dist/cjs/execution/inference-client.js +1 -1
  16. package/dist/cjs/execution/read-environment-credentials.js +4 -4
  17. package/dist/cjs/execution/read-environment-credentials.spec.js +2 -2
  18. package/dist/cjs/execution/ui-control-client.d.ts +46 -1
  19. package/dist/cjs/execution/ui-control-client.js +56 -6
  20. package/dist/cjs/execution/ui-controller-client-interface.d.ts +1 -1
  21. package/dist/cjs/lib/copy-example-project.js +2 -1
  22. package/dist/cjs/lib/download-binaries.js +2 -1
  23. package/dist/cjs/lib/ui-controller-facade.js +1 -1
  24. package/dist/cjs/lib/ui-controller-linux.js +2 -2
  25. package/dist/cjs/utils/analytics/analytics.js +7 -1
  26. package/dist/cjs/utils/analytics/installation-timestamp-create-error.d.ts +4 -0
  27. package/dist/cjs/utils/analytics/installation-timestamp-create-error.js +9 -0
  28. package/dist/cjs/utils/analytics/installation-timestamp-get-error.d.ts +4 -0
  29. package/dist/cjs/utils/analytics/installation-timestamp-get-error.js +9 -0
  30. package/dist/cjs/utils/analytics/installation-timestamp.d.ts +7 -0
  31. package/dist/cjs/utils/analytics/installation-timestamp.js +68 -0
  32. package/dist/cjs/utils/http/credentials.d.ts +1 -1
  33. package/dist/cjs/utils/http/credentials.js +1 -1
  34. package/dist/cjs/utils/http/credentials.spec.js +2 -2
  35. package/dist/cjs/utils/path.d.ts +1 -0
  36. package/dist/cjs/utils/path.js +11 -0
  37. package/dist/esm/core/model/test-case-dto/index.js +0 -1
  38. package/dist/esm/core/model/test-case-dto/test-step.d.ts +3 -7
  39. package/dist/esm/core/model/test-case-dto/test-step.js +1 -10
  40. package/dist/esm/core/ui-control-commands/control-command.d.ts +1 -0
  41. package/dist/esm/core/ui-control-commands/control-command.js +5 -0
  42. package/dist/esm/core/ui-control-commands/input-event.d.ts +1 -2
  43. package/dist/esm/core/ui-control-commands/input-event.js +0 -1
  44. package/dist/esm/execution/dsl.d.ts +51 -1
  45. package/dist/esm/execution/dsl.js +67 -10
  46. package/dist/esm/execution/execution-runtime.d.ts +2 -0
  47. package/dist/esm/execution/execution-runtime.js +27 -15
  48. package/dist/esm/execution/inference-client.d.ts +1 -1
  49. package/dist/esm/execution/inference-client.js +1 -1
  50. package/dist/esm/execution/read-environment-credentials.js +4 -4
  51. package/dist/esm/execution/read-environment-credentials.spec.js +2 -2
  52. package/dist/esm/execution/ui-control-client.d.ts +46 -1
  53. package/dist/esm/execution/ui-control-client.js +57 -7
  54. package/dist/esm/execution/ui-controller-client-interface.d.ts +1 -1
  55. package/dist/esm/lib/copy-example-project.js +2 -1
  56. package/dist/esm/lib/download-binaries.js +2 -1
  57. package/dist/esm/lib/ui-controller-facade.js +1 -1
  58. package/dist/esm/lib/ui-controller-linux.js +2 -2
  59. package/dist/esm/utils/analytics/analytics.js +7 -1
  60. package/dist/esm/utils/analytics/installation-timestamp-create-error.d.ts +4 -0
  61. package/dist/esm/utils/analytics/installation-timestamp-create-error.js +5 -0
  62. package/dist/esm/utils/analytics/installation-timestamp-get-error.d.ts +4 -0
  63. package/dist/esm/utils/analytics/installation-timestamp-get-error.js +5 -0
  64. package/dist/esm/utils/analytics/installation-timestamp.d.ts +7 -0
  65. package/dist/esm/utils/analytics/installation-timestamp.js +61 -0
  66. package/dist/esm/utils/http/credentials.d.ts +1 -1
  67. package/dist/esm/utils/http/credentials.js +1 -1
  68. package/dist/esm/utils/http/credentials.spec.js +2 -2
  69. package/dist/esm/utils/path.d.ts +1 -0
  70. package/dist/esm/utils/path.js +4 -0
  71. package/package.json +12 -4
  72. package/dist/cjs/utils/base_64_image/base-64-image-path-error.d.ts +0 -4
  73. package/dist/cjs/utils/base_64_image/base-64-image-path-error.js +0 -11
  74. package/dist/cjs/utils/image-resize-errors/invalid-base64-image-error.d.ts +0 -3
  75. package/dist/cjs/utils/image-resize-errors/invalid-base64-image-error.js +0 -7
  76. package/dist/esm/utils/base_64_image/base-64-image-path-error.d.ts +0 -4
  77. package/dist/esm/utils/base_64_image/base-64-image-path-error.js +0 -7
  78. package/dist/esm/utils/image-resize-errors/invalid-base64-image-error.d.ts +0 -3
  79. package/dist/esm/utils/image-resize-errors/invalid-base64-image-error.js +0 -3
package/README.md CHANGED
@@ -45,8 +45,8 @@ Visit our [documentation](https://docs.askui.com) for examples and a full list o
45
45
  ### Notes
46
46
 
47
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)).
48
+ You can read more in our [troubleshooting chapter](https://docs.askui.com/docs/general/Troubleshooting/linux#wayland).
49
+ If you want to use the askui library libfuse2 is needed ([libfuse2 installation](https://docs.askui.com/docs/general/Troubleshooting/linux#libfuse2)).
50
50
 
51
51
  ## Example
52
52
 
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { access } = require('fs/promises');
4
+ const { join } = require('path');
5
+
6
+ async function shouldBeExecuted() {
7
+ try {
8
+ await access(join(__dirname, '../.no-askui-postinstall'));
9
+ } catch (err) {
10
+ if (err.code === 'ENOENT') {
11
+ return true;
12
+ }
13
+ // eslint-disable-next-line no-console
14
+ console.error(err);
15
+ }
16
+ return false;
17
+ }
18
+
19
+ async function createInstallationTimestamp() {
20
+ try {
21
+ const { InstallationTimestamp } = require('../dist/cjs/utils/analytics/installation-timestamp');
22
+ InstallationTimestamp.create();
23
+ } catch (err) {
24
+ // eslint-disable-next-line no-console
25
+ console.error(err);
26
+ }
27
+ }
28
+
29
+ async function main() {
30
+ if (await shouldBeExecuted()) {
31
+ await createInstallationTimestamp();
32
+ }
33
+ }
34
+
35
+ main();
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TestStep = exports.CustomElement = void 0;
3
+ exports.CustomElement = void 0;
4
4
  var custom_element_1 = require("./custom-element");
5
5
  Object.defineProperty(exports, "CustomElement", { enumerable: true, get: function () { return custom_element_1.CustomElement; } });
6
- var test_step_1 = require("./test-step");
7
- Object.defineProperty(exports, "TestStep", { enumerable: true, get: function () { return test_step_1.TestStep; } });
@@ -1,10 +1,6 @@
1
1
  import { CustomElement } from './custom-element';
2
- import { CustomElementJson } from './custom-element-json';
3
- export declare class TestStep {
2
+ export interface TestStep {
4
3
  instruction: string;
5
- customElements: CustomElement[];
6
- constructor(instruction: string, customElements?: CustomElement[]);
7
- static fromJson(step: TestStep & {
8
- customElements: CustomElementJson[];
9
- }): TestStep;
4
+ customElements?: CustomElement[];
5
+ secretText?: string | undefined;
10
6
  }
@@ -1,14 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TestStep = void 0;
4
- const custom_element_1 = require("./custom-element");
5
- class TestStep {
6
- constructor(instruction, customElements = []) {
7
- this.instruction = instruction;
8
- this.customElements = customElements;
9
- }
10
- static fromJson(step) {
11
- return new TestStep(step.instruction, (step.customElements || []).map((customELement) => custom_element_1.CustomElement.fromJson(customELement)));
12
- }
13
- }
14
- exports.TestStep = TestStep;
@@ -6,4 +6,5 @@ export declare class ControlCommand {
6
6
  tryToRepeat: boolean;
7
7
  constructor(code: ControlCommandCode, actions: Action[], tryToRepeat?: boolean);
8
8
  static fromJson(json: ControlCommand, resizeRatio?: number): ControlCommand;
9
+ setTextToBeTyped(text: string): void;
9
10
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ControlCommand = void 0;
4
4
  const action_1 = require("./action");
5
5
  const control_command_code_1 = require("./control-command-code");
6
+ const input_event_1 = require("./input-event");
6
7
  class ControlCommand {
7
8
  constructor(code, actions, tryToRepeat = false) {
8
9
  this.code = code;
@@ -12,5 +13,9 @@ class ControlCommand {
12
13
  static fromJson(json, resizeRatio = 1) {
13
14
  return new ControlCommand(control_command_code_1.ControlCommandCode[json.code], json.actions.map((action) => action_1.Action.fromJson(action, resizeRatio)), json.tryToRepeat);
14
15
  }
16
+ setTextToBeTyped(text) {
17
+ this.actions = this.actions.map((action) => ([input_event_1.InputEvent.TYPE, input_event_1.InputEvent.TYPE_TEXT].includes(action.inputEvent)
18
+ ? new action_1.Action(action.inputEvent, action.position, text) : action));
19
+ }
15
20
  }
16
21
  exports.ControlCommand = ControlCommand;
@@ -16,6 +16,5 @@ export declare enum InputEvent {
16
16
  MOUSE_MOVE = "MOUSE_MOVE",
17
17
  MOUSE_DOWN = "MOUSE_DOWN",
18
18
  MOUSE_UP = "MOUSE_UP",
19
- EXECUTE_COMMAND = "EXECUTE_COMMAND",
20
- WAIT = "WAIT"
19
+ EXECUTE_COMMAND = "EXECUTE_COMMAND"
21
20
  }
@@ -21,5 +21,4 @@ var InputEvent;
21
21
  InputEvent["MOUSE_DOWN"] = "MOUSE_DOWN";
22
22
  InputEvent["MOUSE_UP"] = "MOUSE_UP";
23
23
  InputEvent["EXECUTE_COMMAND"] = "EXECUTE_COMMAND";
24
- InputEvent["WAIT"] = "WAIT";
25
24
  })(InputEvent = exports.InputEvent || (exports.InputEvent = {}));
@@ -426,6 +426,15 @@ export declare class FluentFilters extends FluentBase {
426
426
  /**
427
427
  * Filters for an UI element 'icon'.
428
428
  *
429
+ * You can combine it with the 'withText' command to look for a specific icon.
430
+ *
431
+ * **Examples:**
432
+ * ```typescript
433
+ * icon().withText('plus')
434
+ * ```
435
+ *
436
+ * Note: This is an alpha feature. The prediction of the icon name is sometimes unstable. Use custom elements as an alternative.
437
+ *
429
438
  * @return {FluentFiltersOrRelations}
430
439
  */
431
440
  icon(): FluentFiltersOrRelations;
@@ -461,6 +470,22 @@ export declare class FluentFilters extends FluentBase {
461
470
  * @return {FluentFiltersOrRelations}
462
471
  */
463
472
  withText(text: string): FluentFiltersOrRelations;
473
+ /**
474
+ * Filters for texts, which match the regex pattern.
475
+ *
476
+ * **Examples:**
477
+ *
478
+ * ```typescript
479
+ * 'The rain in Spain' === withTextRegex('\b[Ss]\w+') => true
480
+ * 'The rain in Portugal' === withTextRegex('\b[Ss]\w+') => false
481
+ * 'The rain in switzerland' === withTextRegex('\b[Ss]\w+') => true
482
+ * ```
483
+ *
484
+ * @param {string} regex_pattern - An regex pattern
485
+ *
486
+ * @return {FluentFiltersOrRelations}
487
+ */
488
+ withTextRegex(regex_pattern: string): FluentFiltersOrRelations;
464
489
  /**
465
490
  * Filters for equal text.
466
491
  *
@@ -1060,6 +1085,15 @@ export declare class FluentFiltersCondition extends FluentBase {
1060
1085
  /**
1061
1086
  * Filters for an UI element 'icon'.
1062
1087
  *
1088
+ * You can combine it with the 'withText' command to look for a specific icon.
1089
+ *
1090
+ * **Examples:**
1091
+ * ```typescript
1092
+ * icon().withText('plus')
1093
+ * ```
1094
+ *
1095
+ * Note: This is an alpha feature. The prediction of the icon name is sometimes unstable. Use custom elements as an alternative.
1096
+ *
1063
1097
  * @return {FluentFiltersOrRelationsCondition}
1064
1098
  */
1065
1099
  icon(): FluentFiltersOrRelationsCondition;
@@ -1095,6 +1129,22 @@ export declare class FluentFiltersCondition extends FluentBase {
1095
1129
  * @return {FluentFiltersOrRelationsCondition}
1096
1130
  */
1097
1131
  withText(text: string): FluentFiltersOrRelationsCondition;
1132
+ /**
1133
+ * Filters for texts, which match the regex pattern.
1134
+ *
1135
+ * **Examples:**
1136
+ *
1137
+ * ```typescript
1138
+ * 'The rain in Spain' === withTextRegex('\b[Ss]\w+') => true
1139
+ * 'The rain in Portugal' === withTextRegex('\b[Ss]\w+') => false
1140
+ * 'The rain in switzerland' === withTextRegex('\b[Ss]\w+') => true
1141
+ * ```
1142
+ *
1143
+ * @param {string} regex_pattern - An regex pattern
1144
+ *
1145
+ * @return {FluentFiltersOrRelationsCondition}
1146
+ */
1147
+ withTextRegex(regex_pattern: string): FluentFiltersOrRelationsCondition;
1098
1148
  /**
1099
1149
  * Filters for equal text.
1100
1150
  *
@@ -1331,7 +1381,7 @@ export declare abstract class FluentCommand extends FluentBase {
1331
1381
  */
1332
1382
  typeIn(text: string): FluentFilters;
1333
1383
  /**
1334
- * Moves mouse to the filtered element and scrolls in the x and y direction
1384
+ * Moves mouse to the filtered element and scrolls in the x and y direction.
1335
1385
  *
1336
1386
  * @param {number} x_offset - A (positive/negative) x direction.
1337
1387
  * @param {number} y_offset - A (positive/negative) y direction.
@@ -2,6 +2,7 @@
2
2
  /* eslint-disable @typescript-eslint/no-use-before-define */
3
3
  /* eslint-disable @typescript-eslint/naming-convention */
4
4
  /* eslint-disable max-classes-per-file */
5
+ /* eslint-disable max-len */
5
6
  // Autogenerated from typescript.template file
6
7
  Object.defineProperty(exports, "__esModule", { value: true });
7
8
  exports.FluentCommand = exports.FluentFiltersOrRelationsCondition = exports.FluentFiltersCondition = exports.FluentFiltersOrRelations = exports.FluentFilters = exports.Exec = void 0;
@@ -650,6 +651,15 @@ class FluentFilters extends FluentBase {
650
651
  /**
651
652
  * Filters for an UI element 'icon'.
652
653
  *
654
+ * You can combine it with the 'withText' command to look for a specific icon.
655
+ *
656
+ * **Examples:**
657
+ * ```typescript
658
+ * icon().withText('plus')
659
+ * ```
660
+ *
661
+ * Note: This is an alpha feature. The prediction of the icon name is sometimes unstable. Use custom elements as an alternative.
662
+ *
653
663
  * @return {FluentFiltersOrRelations}
654
664
  */
655
665
  icon() {
@@ -695,7 +705,26 @@ class FluentFilters extends FluentBase {
695
705
  * @return {FluentFiltersOrRelations}
696
706
  */
697
707
  withText(text) {
698
- this._textStr = `with text "${text}"`;
708
+ this._textStr = `with text <|string|>${text}<|string|>`;
709
+ return new FluentFiltersOrRelations(this);
710
+ }
711
+ /**
712
+ * Filters for texts, which match the regex pattern.
713
+ *
714
+ * **Examples:**
715
+ *
716
+ * ```typescript
717
+ * 'The rain in Spain' === withTextRegex('\b[Ss]\w+') => true
718
+ * 'The rain in Portugal' === withTextRegex('\b[Ss]\w+') => false
719
+ * 'The rain in switzerland' === withTextRegex('\b[Ss]\w+') => true
720
+ * ```
721
+ *
722
+ * @param {string} regex_pattern - An regex pattern
723
+ *
724
+ * @return {FluentFiltersOrRelations}
725
+ */
726
+ withTextRegex(regex_pattern) {
727
+ this._textStr = `match regex pattern <|string|>${regex_pattern}<|string|>`;
699
728
  return new FluentFiltersOrRelations(this);
700
729
  }
701
730
  /**
@@ -717,7 +746,7 @@ class FluentFilters extends FluentBase {
717
746
  * @return {FluentFiltersOrRelations}
718
747
  */
719
748
  withExactText(text) {
720
- this._textStr = `equals text "${text}"`;
749
+ this._textStr = `equals text <|string|>${text}<|string|>`;
721
750
  return new FluentFiltersOrRelations(this);
722
751
  }
723
752
  /**
@@ -735,7 +764,7 @@ class FluentFilters extends FluentBase {
735
764
  * @return {FluentFiltersOrRelations}
736
765
  */
737
766
  containsText(text) {
738
- this._textStr = `contain text "${text}"`;
767
+ this._textStr = `contain text <|string|>${text}<|string|>`;
739
768
  return new FluentFiltersOrRelations(this);
740
769
  }
741
770
  /**
@@ -1534,6 +1563,15 @@ class FluentFiltersCondition extends FluentBase {
1534
1563
  /**
1535
1564
  * Filters for an UI element 'icon'.
1536
1565
  *
1566
+ * You can combine it with the 'withText' command to look for a specific icon.
1567
+ *
1568
+ * **Examples:**
1569
+ * ```typescript
1570
+ * icon().withText('plus')
1571
+ * ```
1572
+ *
1573
+ * Note: This is an alpha feature. The prediction of the icon name is sometimes unstable. Use custom elements as an alternative.
1574
+ *
1537
1575
  * @return {FluentFiltersOrRelationsCondition}
1538
1576
  */
1539
1577
  icon() {
@@ -1579,7 +1617,26 @@ class FluentFiltersCondition extends FluentBase {
1579
1617
  * @return {FluentFiltersOrRelationsCondition}
1580
1618
  */
1581
1619
  withText(text) {
1582
- this._textStr = `with text "${text}"`;
1620
+ this._textStr = `with text <|string|>${text}<|string|>`;
1621
+ return new FluentFiltersOrRelationsCondition(this);
1622
+ }
1623
+ /**
1624
+ * Filters for texts, which match the regex pattern.
1625
+ *
1626
+ * **Examples:**
1627
+ *
1628
+ * ```typescript
1629
+ * 'The rain in Spain' === withTextRegex('\b[Ss]\w+') => true
1630
+ * 'The rain in Portugal' === withTextRegex('\b[Ss]\w+') => false
1631
+ * 'The rain in switzerland' === withTextRegex('\b[Ss]\w+') => true
1632
+ * ```
1633
+ *
1634
+ * @param {string} regex_pattern - An regex pattern
1635
+ *
1636
+ * @return {FluentFiltersOrRelationsCondition}
1637
+ */
1638
+ withTextRegex(regex_pattern) {
1639
+ this._textStr = `match regex pattern <|string|>${regex_pattern}<|string|>`;
1583
1640
  return new FluentFiltersOrRelationsCondition(this);
1584
1641
  }
1585
1642
  /**
@@ -1601,7 +1658,7 @@ class FluentFiltersCondition extends FluentBase {
1601
1658
  * @return {FluentFiltersOrRelationsCondition}
1602
1659
  */
1603
1660
  withExactText(text) {
1604
- this._textStr = `equals text "${text}"`;
1661
+ this._textStr = `equals text <|string|>${text}<|string|>`;
1605
1662
  return new FluentFiltersOrRelationsCondition(this);
1606
1663
  }
1607
1664
  /**
@@ -1619,7 +1676,7 @@ class FluentFiltersCondition extends FluentBase {
1619
1676
  * @return {FluentFiltersOrRelationsCondition}
1620
1677
  */
1621
1678
  containsText(text) {
1622
- this._textStr = `contain text "${text}"`;
1679
+ this._textStr = `contain text <|string|>${text}<|string|>`;
1623
1680
  return new FluentFiltersOrRelationsCondition(this);
1624
1681
  }
1625
1682
  /**
@@ -1868,11 +1925,11 @@ class FluentCommand extends FluentBase {
1868
1925
  * @return {FluentFilters}
1869
1926
  */
1870
1927
  typeIn(text) {
1871
- this._textStr = `Type "${text}" in`;
1928
+ this._textStr = `Type <|string|>${text}<|string|> in`;
1872
1929
  return new FluentFilters(this);
1873
1930
  }
1874
1931
  /**
1875
- * Moves mouse to the filtered element and scrolls in the x and y direction
1932
+ * Moves mouse to the filtered element and scrolls in the x and y direction.
1876
1933
  *
1877
1934
  * @param {number} x_offset - A (positive/negative) x direction.
1878
1935
  * @param {number} y_offset - A (positive/negative) y direction.
@@ -1916,7 +1973,7 @@ class FluentCommand extends FluentBase {
1916
1973
  * @return {Exec}
1917
1974
  */
1918
1975
  type(text) {
1919
- this._textStr = `Type "${text}"`;
1976
+ this._textStr = `Type <|string|>${text}<|string|>`;
1920
1977
  return new Exec(this);
1921
1978
  }
1922
1979
  /**
@@ -1965,7 +2022,7 @@ class FluentCommand extends FluentBase {
1965
2022
  * @return {Exec}
1966
2023
  */
1967
2024
  execOnShell(shell_command) {
1968
- this._textStr = `Execute shell command "${shell_command}"`;
2025
+ this._textStr = `Execute shell command <|string|>${shell_command}<|string|>`;
1969
2026
  return new Exec(this);
1970
2027
  }
1971
2028
  /**
@@ -8,6 +8,7 @@ export declare class ExecutionRuntime {
8
8
  private inferenceClient;
9
9
  constructor(uiControllerClient: UiControllerClient, inferenceClient: InferenceClient);
10
10
  executeTestStep(step: TestStep): Promise<void>;
11
+ private requestControl;
11
12
  /**
12
13
  * @param {TestStep} step - Test step used for predicting command.
13
14
  */
@@ -20,6 +21,7 @@ export declare class ExecutionRuntime {
20
21
  * --> retry with linear back-off
21
22
  */
22
23
  private predictCommandWithRetry;
24
+ private getImageIfRequired;
23
25
  private predictCommand;
24
26
  annotateInteractively(): Promise<void>;
25
27
  takeScreenshotIfImageisNotProvided(imagePath?: string): Promise<string>;
@@ -30,6 +30,11 @@ class ExecutionRuntime {
30
30
  yield this.executeCommand(step);
31
31
  });
32
32
  }
33
+ requestControl(controlCommand) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ yield this.uiControllerClient.requestControl(controlCommand);
36
+ });
37
+ }
33
38
  /**
34
39
  * @param {TestStep} step - Test step used for predicting command.
35
40
  */
@@ -38,15 +43,13 @@ class ExecutionRuntime {
38
43
  return __awaiter(this, void 0, void 0, function* () {
39
44
  const controlCommand = yield this.predictCommandWithRetry(step);
40
45
  if (controlCommand.code === ui_control_commands_1.ControlCommandCode.OK) {
41
- yield this.uiControllerClient.requestControl(controlCommand);
46
+ return this.requestControl(controlCommand);
42
47
  }
43
- else if (controlCommand.tryToRepeat) {
44
- yield this.uiControllerClient.requestControl(controlCommand);
45
- this.executeCommandRepeatedly(step);
46
- }
47
- else {
48
- throw new control_command_error_1.ControlCommandError(((_a = controlCommand.actions[0]) === null || _a === void 0 ? void 0 : _a.text) || '');
48
+ if (controlCommand.tryToRepeat) {
49
+ yield this.requestControl(controlCommand);
50
+ return this.executeCommandRepeatedly(step);
49
51
  }
52
+ throw new control_command_error_1.ControlCommandError(((_a = controlCommand.actions[0]) === null || _a === void 0 ? void 0 : _a.text) || '');
50
53
  });
51
54
  }
52
55
  executeCommandRepeatedly(step) {
@@ -63,8 +66,8 @@ class ExecutionRuntime {
63
66
  if (controlCommand.code === ui_control_commands_1.ControlCommandCode.OK) {
64
67
  break;
65
68
  }
66
- else if (controlCommand.tryToRepeat) {
67
- yield this.uiControllerClient.requestControl(controlCommand);
69
+ if (controlCommand.tryToRepeat) {
70
+ yield this.requestControl(controlCommand);
68
71
  }
69
72
  else {
70
73
  throw new control_command_error_1.ControlCommandError(((_a = controlCommand.actions[0]) === null || _a === void 0 ? void 0 : _a.text) || '');
@@ -94,15 +97,24 @@ class ExecutionRuntime {
94
97
  return command;
95
98
  });
96
99
  }
100
+ getImageIfRequired(instruction) {
101
+ return __awaiter(this, void 0, void 0, function* () {
102
+ const isImageRequired = yield this.inferenceClient.isImageRequired(instruction);
103
+ if (!isImageRequired) {
104
+ return undefined;
105
+ }
106
+ const screenshotResponse = yield this.uiControllerClient.requestScreenshot();
107
+ return screenshotResponse.data.image;
108
+ });
109
+ }
97
110
  predictCommand(step) {
98
111
  return __awaiter(this, void 0, void 0, function* () {
99
- const isImageRequired = yield this.inferenceClient.isImageRequired(step.instruction);
100
- let image;
101
- if (isImageRequired) {
102
- const screenshotResponse = yield this.uiControllerClient.requestScreenshot();
103
- image = screenshotResponse.data.image;
112
+ const image = yield this.getImageIfRequired(step.instruction);
113
+ const controlCommand = yield this.inferenceClient.predictControlCommand(step.instruction, step.customElements, image);
114
+ if (step.secretText !== undefined) {
115
+ controlCommand.setTextToBeTyped(step.secretText);
104
116
  }
105
- return this.inferenceClient.predictControlCommand(step.instruction, step.customElements, image);
117
+ return controlCommand;
106
118
  });
107
119
  }
108
120
  annotateInteractively() {
@@ -8,6 +8,6 @@ export declare class InferenceClient {
8
8
  constructor(url: string, httpClient: HttpClientGot);
9
9
  isImageRequired(instruction: string): Promise<boolean>;
10
10
  private resizeIfNeeded;
11
- predictControlCommand(instruction: string, customElements: CustomElement[], image?: string): Promise<ControlCommand>;
11
+ predictControlCommand(instruction: string, customElements?: CustomElement[], image?: string): Promise<ControlCommand>;
12
12
  predictImageAnnotation(image: string, customElements?: CustomElement[]): Promise<Annotation>;
13
13
  }
@@ -41,7 +41,7 @@ class InferenceClient {
41
41
  return (0, transformations_1.resizeBase64ImageWithSameRatio)(image);
42
42
  });
43
43
  }
44
- predictControlCommand(instruction, customElements, image) {
44
+ predictControlCommand(instruction, customElements = [], image) {
45
45
  return __awaiter(this, void 0, void 0, function* () {
46
46
  const resizedImage = yield this.resizeIfNeeded(customElements, image);
47
47
  const httpBody = {
@@ -4,12 +4,12 @@ exports.envCredentials = void 0;
4
4
  const lib_1 = require("../lib");
5
5
  function envCredentials() {
6
6
  const envToken = process.env['ASKUI_TOKEN'];
7
- const envTenant = process.env['ASKUI_TENANT'];
7
+ const envWorkspaceId = process.env['ASKUI_WORKSPACE_ID'];
8
8
  const envEmail = process.env['ASKUI_EMAIL'];
9
- if (envToken && envTenant && envEmail) {
10
- lib_1.logger.info('Credentials are used from ENV variables: ASKUI_TOKEN, ASKUI_TENANT and ASKUI_EMAIL');
9
+ if (envToken && envWorkspaceId && envEmail) {
10
+ lib_1.logger.info('Credentials are used from ENV variables: ASKUI_TOKEN, ASKUI_WORKSPACE_ID and ASKUI_EMAIL');
11
11
  return {
12
- tenant: envTenant,
12
+ workspaceId: envWorkspaceId,
13
13
  email: envEmail,
14
14
  token: envToken,
15
15
  };
@@ -4,9 +4,9 @@ const read_environment_credentials_1 = require("./read-environment-credentials")
4
4
  describe('envCredentials()', () => {
5
5
  test('should read the credentials from the environment variables', () => {
6
6
  process.env['ASKUI_TOKEN'] = 'token';
7
- process.env['ASKUI_TENANT'] = 'tenant';
7
+ process.env['ASKUI_WORKSPACE_ID'] = 'id123';
8
8
  process.env['ASKUI_EMAIL'] = 'name@tenant.com';
9
9
  const credentialsFromTheEnv = (0, read_environment_credentials_1.envCredentials)();
10
- expect(credentialsFromTheEnv).toStrictEqual({ tenant: 'tenant', email: 'name@tenant.com', token: 'token' });
10
+ expect(credentialsFromTheEnv).toStrictEqual({ workspaceId: 'id123', email: 'name@tenant.com', token: 'token' });
11
11
  });
12
12
  });
@@ -1,5 +1,5 @@
1
1
  import { CustomElementJson } from '../core/model/test-case-dto';
2
- import { Executable, FluentCommand } from './dsl';
2
+ import { Exec, Executable, FluentCommand, FluentFilters } from './dsl';
3
3
  import { UiControllerClientConnectionState } from './ui-controller-client-connection-state';
4
4
  import { Annotation } from '../core/annotation/annotation';
5
5
  import { AnnotationRequest } from '../core/model/annotation-result/annotation-interface';
@@ -18,6 +18,51 @@ export declare class UiControlClient extends FluentCommand {
18
18
  annotate(annotationRequest?: AnnotationRequest): Promise<Annotation>;
19
19
  annotateInteractively(): Promise<void>;
20
20
  exec(instruction: string, customElementJson?: CustomElementJson[]): Promise<void>;
21
+ private secretText;
22
+ /**
23
+ * Types a text inside the filtered element.
24
+ *
25
+ * By default, the `text` is included in the logs and sent over to the askui Inference server to
26
+ * predict in which context the typing has to occur. You can exclude the `text` from the logs
27
+ * and the request to the askui Inference server setting `options.isSecret` to `true`.
28
+ * This should not change the quality of the prediction of the askui Inference server. In this
29
+ * case, `options.secretMask` is included in logs and sent over instead of the `text`.
30
+ *
31
+ * @param {string} text - A text to type.
32
+ * @param {Object} [options]
33
+ * @param {boolean} [options.isSecret = false] - If set to `true`, `text` is neither included in
34
+ * logs of askui nor sent over to askui Inference for prediction.
35
+ * @param {string} [options.secretMask = '****'] - If `options.isSecret` is set to `true`, this
36
+ * is included in logs and sent over to askui Inference for prediction instead of the `text`.
37
+ *
38
+ * @return {FluentFilters}
39
+ */
40
+ typeIn(text: string, { isSecret, secretMask }?: {
41
+ isSecret?: boolean | undefined;
42
+ secretMask?: string | undefined;
43
+ }): FluentFilters;
44
+ /**
45
+ * Types a text at the current position.
46
+ *
47
+ * By default, the `text` is included in the logs and sent over to the askui Inference server to
48
+ * predict in which context the typing has to occur. You can exclude the `text` from the logs
49
+ * and the request to the askui Inference server setting `options.isSecret` to `true`.
50
+ * This should not change the quality of the prediction of the askui Inference server. In this
51
+ * case, `options.secretMask` is included in logs and sent over instead of the `text`.
52
+ *
53
+ * @param {string} text - A text to type.
54
+ * @param {Object} options
55
+ * @param {boolean} [options.isSecret = false] - If set to `true`, `text` is neither included in
56
+ * logs of askui nor sent over to askui Inference for prediction.
57
+ * @param {string} [options.secretMask = '****'] - If `options.isSecret` is set to `true`, this
58
+ * is included in logs and sent over to askui Inference for prediction instead of the `text`.
59
+ *
60
+ * @return {Exec}
61
+ */
62
+ type(text: string, { isSecret, secretMask }?: {
63
+ isSecret?: boolean | undefined;
64
+ secretMask?: string | undefined;
65
+ }): Exec;
21
66
  /**
22
67
  * Waits for `<delayInMs>` ms, e.g., 1000 ms. The exact delay may be a little longer
23
68
  * than `<delayInMs>` but never shorter than that.