askui 0.13.1 → 0.15.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 (87) hide show
  1. package/README.md +1 -2
  2. package/dist/cjs/execution/read-credentials.d.ts +3 -0
  3. package/dist/cjs/execution/read-credentials.js +24 -0
  4. package/dist/cjs/execution/read-environment-credentials.js +1 -1
  5. package/dist/cjs/execution/ui-control-client-dependency-builder.js +3 -3
  6. package/dist/cjs/execution/ui-control-client.d.ts +70 -5
  7. package/dist/cjs/execution/ui-control-client.js +117 -0
  8. package/dist/cjs/lib/interactive_cli/{add-script-package-json.d.ts → add-remove-script-package-json.d.ts} +1 -0
  9. package/dist/cjs/lib/interactive_cli/{add-script-package-json.js → add-remove-script-package-json.js} +21 -2
  10. package/dist/cjs/lib/interactive_cli/cli-options-interface.d.ts +2 -2
  11. package/dist/cjs/lib/interactive_cli/cli.js +35 -38
  12. package/dist/cjs/lib/interactive_cli/create-example-project.d.ts +3 -6
  13. package/dist/cjs/lib/interactive_cli/create-example-project.js +53 -80
  14. package/dist/cjs/lib/logger.d.ts +1 -7
  15. package/dist/esm/execution/read-credentials.d.ts +3 -0
  16. package/dist/esm/execution/read-credentials.js +20 -0
  17. package/dist/esm/execution/read-environment-credentials.js +1 -1
  18. package/dist/esm/execution/ui-control-client-dependency-builder.js +3 -3
  19. package/dist/esm/execution/ui-control-client.d.ts +70 -5
  20. package/dist/esm/execution/ui-control-client.js +117 -0
  21. package/dist/esm/lib/interactive_cli/{add-script-package-json.d.ts → add-remove-script-package-json.d.ts} +1 -0
  22. package/dist/esm/lib/interactive_cli/{add-script-package-json.js → add-remove-script-package-json.js} +19 -1
  23. package/dist/esm/lib/interactive_cli/cli-options-interface.d.ts +2 -2
  24. package/dist/esm/lib/interactive_cli/cli.js +35 -38
  25. package/dist/esm/lib/interactive_cli/create-example-project.d.ts +3 -6
  26. package/dist/esm/lib/interactive_cli/create-example-project.js +52 -79
  27. package/dist/esm/lib/logger.d.ts +1 -7
  28. package/dist/example_projects_templates/templates/askui-helper-windows.nj +1 -4
  29. package/dist/example_projects_templates/templates/askui-helper.nj +1 -4
  30. package/package.json +13 -14
  31. package/dist/cjs/core/model/test-case-dto/custom-element-json.d.ts +0 -75
  32. package/dist/cjs/core/model/test-case-dto/custom-element-json.js +0 -2
  33. package/dist/cjs/core/model/test-case-dto/custom-element.d.ts +0 -21
  34. package/dist/cjs/core/model/test-case-dto/custom-element.js +0 -54
  35. package/dist/cjs/core/model/test-case-dto/index.d.ts +0 -3
  36. package/dist/cjs/core/model/test-case-dto/index.js +0 -5
  37. package/dist/cjs/core/model/test-case-dto/test-step.d.ts +0 -6
  38. package/dist/cjs/core/model/test-case-dto/test-step.js +0 -2
  39. package/dist/cjs/core/model/test-case-result-dto/index.d.ts +0 -2
  40. package/dist/cjs/core/model/test-case-result-dto/index.js +0 -7
  41. package/dist/cjs/core/model/test-case-result-dto/test-step-result-dto.d.ts +0 -9
  42. package/dist/cjs/core/model/test-case-result-dto/test-step-result-dto.js +0 -16
  43. package/dist/cjs/core/model/test-case-result-dto/test-step-state.d.ts +0 -4
  44. package/dist/cjs/core/model/test-case-result-dto/test-step-state.js +0 -8
  45. package/dist/cjs/core/reporting/default-reporter.d.ts +0 -10
  46. package/dist/cjs/core/reporting/default-reporter.js +0 -12
  47. package/dist/cjs/execution/annotation-level.d.ts +0 -5
  48. package/dist/cjs/execution/annotation-level.js +0 -9
  49. package/dist/cjs/execution/ui-control-client-error.d.ts +0 -2
  50. package/dist/cjs/execution/ui-control-client-error.js +0 -6
  51. package/dist/cjs/lib/copy-example-project.d.ts +0 -2
  52. package/dist/cjs/lib/copy-example-project.js +0 -65
  53. package/dist/cjs/lib/interactive_cli/replace-string-in-file.d.ts +0 -1
  54. package/dist/cjs/lib/interactive_cli/replace-string-in-file.js +0 -31
  55. package/dist/esm/core/model/test-case-dto/custom-element-json.d.ts +0 -75
  56. package/dist/esm/core/model/test-case-dto/custom-element-json.js +0 -1
  57. package/dist/esm/core/model/test-case-dto/custom-element.d.ts +0 -21
  58. package/dist/esm/core/model/test-case-dto/custom-element.js +0 -50
  59. package/dist/esm/core/model/test-case-dto/index.d.ts +0 -3
  60. package/dist/esm/core/model/test-case-dto/index.js +0 -1
  61. package/dist/esm/core/model/test-case-dto/test-step.d.ts +0 -6
  62. package/dist/esm/core/model/test-case-dto/test-step.js +0 -1
  63. package/dist/esm/core/model/test-case-result-dto/index.d.ts +0 -2
  64. package/dist/esm/core/model/test-case-result-dto/index.js +0 -2
  65. package/dist/esm/core/model/test-case-result-dto/test-step-result-dto.d.ts +0 -9
  66. package/dist/esm/core/model/test-case-result-dto/test-step-result-dto.js +0 -12
  67. package/dist/esm/core/model/test-case-result-dto/test-step-state.d.ts +0 -4
  68. package/dist/esm/core/model/test-case-result-dto/test-step-state.js +0 -5
  69. package/dist/esm/core/reporting/default-reporter.d.ts +0 -10
  70. package/dist/esm/core/reporting/default-reporter.js +0 -9
  71. package/dist/esm/execution/annotation-level.d.ts +0 -5
  72. package/dist/esm/execution/annotation-level.js +0 -6
  73. package/dist/esm/execution/ui-control-client-error.d.ts +0 -2
  74. package/dist/esm/execution/ui-control-client-error.js +0 -2
  75. package/dist/esm/lib/copy-example-project.d.ts +0 -2
  76. package/dist/esm/lib/copy-example-project.js +0 -58
  77. package/dist/esm/lib/interactive_cli/replace-string-in-file.d.ts +0 -1
  78. package/dist/esm/lib/interactive_cli/replace-string-in-file.js +0 -24
  79. package/dist/example_projects_templates/configs/jasmine.config.json +0 -12
  80. package/dist/example_projects_templates/typescript/.eslintignore +0 -1
  81. package/dist/example_projects_templates/typescript/.eslintrc.json +0 -20
  82. package/dist/example_projects_templates/typescript/askui_example/helpers/askui-helper.ts +0 -39
  83. package/dist/example_projects_templates/typescript_jest/test/README.md +0 -21
  84. package/dist/example_projects_templates/typescript_jest/test/helper/jest.setup.ts +0 -51
  85. package/dist/example_projects_templates/typescript_jest/test/jest.config.ts +0 -13
  86. package/dist/example_projects_templates/typescript_jest/test/my-first-askui-test-suite.test.ts +0 -21
  87. package/dist/example_projects_templates/typescript_jest/tsconfig.json +0 -7
@@ -21,15 +21,14 @@ const listr_1 = __importDefault(require("listr"));
21
21
  const chalk_1 = __importDefault(require("chalk"));
22
22
  const nunjucks_1 = __importDefault(require("nunjucks"));
23
23
  const path_2 = require("../../utils/path");
24
- const add_script_package_json_1 = require("./add-script-package-json");
24
+ const add_remove_script_package_json_1 = require("./add-remove-script-package-json");
25
25
  class CreateExampleProject {
26
26
  constructor(cliOptions) {
27
27
  this.cliOptions = cliOptions;
28
28
  this.baseDirPath = process.cwd();
29
29
  this.exampleFolderName = 'askui_example';
30
30
  this.distexampleFolderPath = path_1.default.join(this.baseDirPath, this.exampleFolderName);
31
- this.proxyDocUrl = 'https://docs.askui.com/docs/general/Troubleshooting/proxy';
32
- this.remoteDeviceControllerUrl = 'https://docs.askui.com/docs/api/Remote-Device-Controller';
31
+ this.askUIControllerUrl = 'https://docs.askui.com/docs/general/Components/AskUI-Controller';
33
32
  this.helperTemplateConfig = {};
34
33
  }
35
34
  copyTemplateProject() {
@@ -64,7 +63,11 @@ class CreateExampleProject {
64
63
  },
65
64
  {
66
65
  title: 'Install askui dependency',
67
- task: () => __awaiter(this, void 0, void 0, function* () { return runCommand('npm i -D askui '); }),
66
+ task: () => __awaiter(this, void 0, void 0, function* () {
67
+ yield runCommand('npm init -y');
68
+ yield (0, add_remove_script_package_json_1.removeScript)(`${this.baseDirPath}/package.json`, 'test');
69
+ yield runCommand('npm i -D askui ');
70
+ }),
68
71
  },
69
72
  ];
70
73
  });
@@ -73,43 +76,38 @@ class CreateExampleProject {
73
76
  return __awaiter(this, void 0, void 0, function* () {
74
77
  const frameworkConfigs = {
75
78
  jest: 'jest.config.ts',
76
- jasmine: 'jasmine.config.json',
77
79
  };
78
- const configFilePath = path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), 'example_projects_templates', 'configs', frameworkConfigs[this.cliOptions.testFramework]);
79
- yield fs_extra_1.default.copyFile(configFilePath, path_1.default.join(this.distexampleFolderPath, frameworkConfigs[this.cliOptions.testFramework]));
80
+ const configFilePath = path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), 'example_projects_templates', 'configs', frameworkConfigs.jest);
81
+ yield fs_extra_1.default.copyFile(configFilePath, path_1.default.join(this.distexampleFolderPath, frameworkConfigs.jest));
80
82
  });
81
83
  }
82
84
  addTestFrameWorkTimeout() {
83
85
  return __awaiter(this, void 0, void 0, function* () {
84
86
  const frameworkTimeoutstring = {
85
87
  jest: 'jest.setTimeout(60 * 1000 * 60);',
86
- jasmine: 'jasmine.DEFAULT_TIMEOUT_INTERVAL = 60 * 1000 * 60;',
87
88
  };
88
- this.helperTemplateConfig['timeout_placeholder'] = frameworkTimeoutstring[this.cliOptions.testFramework];
89
+ this.helperTemplateConfig['timeout_placeholder'] = frameworkTimeoutstring.jest;
89
90
  });
90
91
  }
91
92
  addReporterConfig() {
92
93
  return __awaiter(this, void 0, void 0, function* () {
93
- if (this.cliOptions.testFramework === 'jest') {
94
- this.helperTemplateConfig['allure_stepreporter_import'] = "import { AskUIAllureStepReporter } from '@askui/askui-reporters';";
95
- this.helperTemplateConfig['reporter_placeholder'] = 'reporter: new AskUIAllureStepReporter(),';
96
- this.helperTemplateConfig['allure_stepreporter_attach_video'] = `const video = await aui.readVideoRecording();
94
+ this.helperTemplateConfig['allure_stepreporter_import'] = "import { AskUIAllureStepReporter } from '@askui/askui-reporters';";
95
+ this.helperTemplateConfig['reporter_placeholder'] = 'reporter: new AskUIAllureStepReporter(),';
96
+ this.helperTemplateConfig['allure_stepreporter_attach_video'] = `const video = await aui.readVideoRecording();
97
97
  await AskUIAllureStepReporter.attachVideo(video);`;
98
- }
99
98
  });
100
99
  }
101
100
  addAskuiRunCommand() {
102
101
  return __awaiter(this, void 0, void 0, function* () {
103
102
  const frameworkExecutionCommand = {
104
103
  jest: `jest --config ./${this.exampleFolderName}/jest.config.ts --runInBand`,
105
- jasmine: `jasmine --config=${this.exampleFolderName}/jasmine.config.json`,
106
104
  };
107
- yield (0, add_script_package_json_1.addScript)(`${this.baseDirPath}/package.json`, 'askui', frameworkExecutionCommand[this.cliOptions.testFramework]);
105
+ yield (0, add_remove_script_package_json_1.addScript)(`${this.baseDirPath}/package.json`, 'askui', frameworkExecutionCommand.jest);
108
106
  });
109
107
  }
110
108
  addESLintRunCommand() {
111
109
  return __awaiter(this, void 0, void 0, function* () {
112
- yield (0, add_script_package_json_1.addScript)(`${this.baseDirPath}/package.json`, 'lint', 'eslint . --ext .ts');
110
+ yield (0, add_remove_script_package_json_1.addScript)(`${this.baseDirPath}/package.json`, 'lint', 'eslint . --ext .ts');
113
111
  });
114
112
  }
115
113
  createAskUIHelperFromTemplate() {
@@ -147,8 +145,8 @@ class CreateExampleProject {
147
145
  task: () => __awaiter(this, void 0, void 0, function* () {
148
146
  return new listr_1.default([
149
147
  {
150
- title: `Install ${this.cliOptions.testFramework}`,
151
- task: () => __awaiter(this, void 0, void 0, function* () { return this.installTestFrameworkPackages(); }),
148
+ title: 'Install jest',
149
+ task: () => __awaiter(this, void 0, void 0, function* () { return CreateExampleProject.installTestFrameworkPackages(); }),
152
150
  },
153
151
  {
154
152
  title: 'Copy config file',
@@ -159,7 +157,7 @@ class CreateExampleProject {
159
157
  task: () => __awaiter(this, void 0, void 0, function* () { return this.addTestFrameWorkTimeout(); }),
160
158
  },
161
159
  {
162
- title: 'Add reporter (only Jest)',
160
+ title: 'Add reporter',
163
161
  task: () => __awaiter(this, void 0, void 0, function* () { return this.addReporterConfig(); }),
164
162
  },
165
163
  {
@@ -175,33 +173,29 @@ class CreateExampleProject {
175
173
  }];
176
174
  });
177
175
  }
178
- installTestFrameworkPackages() {
176
+ static installTestFrameworkPackages() {
179
177
  return __awaiter(this, void 0, void 0, function* () {
180
178
  const runCommand = (0, util_1.promisify)(child_process_1.exec);
181
- const frameworkDepencies = {
182
- jest: 'npm i -D @askui/askui-reporters typescript ts-node @types/jest ts-jest jest @askui/jest-allure-circus eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-import eslint-plugin-askui',
183
- jasmine: 'npm i -D @askui/askui-reporters typescript ts-node @types/jasmine jasmine @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-import eslint-plugin-askui',
179
+ const frameworkDependencies = {
180
+ jest: 'npm i -D @askui/askui-reporters typescript ts-node @types/jest ts-jest jest @askui/jest-allure-circus eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin eslint-plugin-import eslint-plugin-askui hpagent',
184
181
  };
185
- yield runCommand(frameworkDepencies[this.cliOptions.testFramework]);
182
+ yield runCommand(frameworkDependencies.jest);
186
183
  });
187
184
  }
188
- addUserCredentails() {
185
+ addUserCredentials() {
189
186
  return __awaiter(this, void 0, void 0, function* () {
190
- return [{
191
- title: 'Add user credentails',
187
+ return [
188
+ {
189
+ title: 'Add user credentials',
190
+ enabled: () => !this.cliOptions.skipCredentials,
192
191
  task: () => __awaiter(this, void 0, void 0, function* () {
193
- return new listr_1.default([
194
- {
195
- title: 'Add workspace id ',
196
- task: () => __awaiter(this, void 0, void 0, function* () { this.helperTemplateConfig['workspace_id'] = this.cliOptions.workspaceId; }),
197
- },
198
- {
199
- title: 'Add access token',
200
- task: () => __awaiter(this, void 0, void 0, function* () { this.helperTemplateConfig['access_token'] = this.cliOptions.accessToken; }),
201
- },
202
- ]);
192
+ this.helperTemplateConfig['credentials'] = ` credentials: {
193
+ workspaceId: '${this.cliOptions.workspaceId}',
194
+ token: '${this.cliOptions.accessToken}',
195
+ },`;
203
196
  }),
204
- }];
197
+ },
198
+ ];
205
199
  });
206
200
  }
207
201
  copyESLintConfigFiles() {
@@ -226,68 +220,47 @@ class CreateExampleProject {
226
220
  },
227
221
  ]);
228
222
  }),
229
- }];
223
+ },
224
+ ];
230
225
  });
231
226
  }
232
227
  copyTsConfigFile() {
233
228
  return __awaiter(this, void 0, void 0, function* () {
234
229
  const tsConfigFilePath = path_1.default.join('example_projects_templates', 'typescript', 'tsconfig.json');
235
- return [{
230
+ const tsConfigTargetFilePath = path_1.default.join(this.baseDirPath, 'tsconfig.json');
231
+ return [
232
+ {
236
233
  title: 'Copy ts config file',
237
- enabled: () => this.cliOptions.typescriptConfig,
234
+ enabled: () => this.cliOptions.typescriptConfig || !fs_extra_1.default.existsSync(tsConfigTargetFilePath),
238
235
  task: () => __awaiter(this, void 0, void 0, function* () {
239
- return fs_extra_1.default.copyFile(path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), tsConfigFilePath), path_1.default.join(this.baseDirPath, 'tsconfig.json'));
236
+ return fs_extra_1.default.copyFile(path_1.default.join((0, path_2.getPathToNodeModulesRoot)(), tsConfigFilePath), tsConfigTargetFilePath);
240
237
  }),
241
- }];
242
- });
243
- }
244
- installProxy() {
245
- return __awaiter(this, void 0, void 0, function* () {
246
- const runCommand = (0, util_1.promisify)(child_process_1.exec);
247
- return [{
248
- title: 'Install Proxy',
249
- enabled: () => this.cliOptions.usingProxy,
250
- task: () => __awaiter(this, void 0, void 0, function* () { return runCommand('npm install --save-dev hpagent '); }),
251
- }];
238
+ },
239
+ ];
252
240
  });
253
241
  }
254
- normalizeCliOptions() {
255
- let useProxy = this.cliOptions.usingProxy;
256
- if (typeof useProxy !== 'boolean') {
257
- useProxy = (useProxy === 'true');
258
- }
259
- this.cliOptions.usingProxy = useProxy;
260
- let { typescriptConfig } = this.cliOptions;
261
- if (typeof typescriptConfig !== 'boolean') {
262
- typescriptConfig = (typescriptConfig === 'true');
263
- }
264
- this.cliOptions.typescriptConfig = typescriptConfig;
265
- }
266
242
  createExampleProject() {
267
243
  return __awaiter(this, void 0, void 0, function* () {
268
244
  const tasks = new listr_1.default();
269
- this.normalizeCliOptions();
270
245
  tasks.add([
271
- ...yield this.copyTemplateProject(),
272
- ...yield this.setupTestFrameWork(),
273
- ...yield this.copyESLintConfigFiles(),
274
- ...yield this.copyTsConfigFile(),
275
- ...yield this.addUserCredentails(),
276
- ...yield this.createAskUIHelperFromTemplate(),
277
- ...yield this.installProxy(),
246
+ ...(yield this.copyTemplateProject()),
247
+ ...(yield this.setupTestFrameWork()),
248
+ ...(yield this.copyESLintConfigFiles()),
249
+ ...(yield this.copyTsConfigFile()),
250
+ ...(yield this.addUserCredentials()),
251
+ ...(yield this.createAskUIHelperFromTemplate()),
278
252
  ]);
279
253
  yield tasks.run();
280
254
  /* eslint-disable no-console */
281
- if (this.cliOptions.usingProxy) {
282
- console.log(chalk_1.default.redBright('Since you are using a Proxy. Please don\'t forget to configure it!'));
283
- console.log(chalk_1.default.gray(`You can find more information under ${this.proxyDocUrl}`));
284
- }
285
255
  console.log(chalk_1.default.greenBright('\nCongratulations!'));
286
256
  console.log(`askui example was created under ${chalk_1.default.gray(this.distexampleFolderPath)}`);
287
257
  if (this.cliOptions.operatingSystem === 'windows') {
288
- console.log(chalk_1.default.redBright(`\nPlease install and start the Remote Device Controller: ${this.remoteDeviceControllerUrl}\n`));
258
+ console.log(chalk_1.default.redBright(`\nPlease make sure the AskUI Controller is running: ${this.askUIControllerUrl}\n`));
259
+ console.log(`You can start your automation with this command ${chalk_1.default.green('AskUI-RunProject')}`);
260
+ }
261
+ else {
262
+ console.log(`You can start your automation with this command ${chalk_1.default.green('npm run askui')}`);
289
263
  }
290
- console.log(`You can start your automation with this command ${chalk_1.default.green('npm run askui')}`);
291
264
  /* eslint-enable no-console */
292
265
  });
293
266
  }
@@ -1,8 +1,2 @@
1
- declare const logger: import("pino").Logger<{
2
- name: string;
3
- level: string;
4
- customLevels: {
5
- verbose: number;
6
- };
7
- }>;
1
+ declare const logger: import("pino").Logger<"verbose">;
8
2
  export { logger };
@@ -0,0 +1,3 @@
1
+ import { CredentialArgs } from './credentials-args';
2
+ import { ClientArgs } from './ui-controller-client-interface';
3
+ export declare function readCredentials(clientArgs: ClientArgs): CredentialArgs;
@@ -0,0 +1,20 @@
1
+ import { logger } from '../lib';
2
+ import { envCredentials } from './read-environment-credentials';
3
+ export function readCredentials(clientArgs) {
4
+ const environmentCredentials = envCredentials();
5
+ const inCodeCredentials = clientArgs.credentials;
6
+ const credentials = inCodeCredentials !== null && inCodeCredentials !== void 0 ? inCodeCredentials : environmentCredentials;
7
+ if (!credentials) {
8
+ throw new Error('No credentials are defined! Please define a token and a Workspace ID in the environment variables ASKUI_TOKEN and ASKUI_WORKSPACE_ID or define them in the UiControlClient.build.');
9
+ }
10
+ if (!(credentials === null || credentials === void 0 ? void 0 : credentials.token)) {
11
+ throw new Error('No Token is defined! Please define a token in the environment variable ASKUI_TOKEN or define a token in the UiControlClient.');
12
+ }
13
+ if (!(credentials === null || credentials === void 0 ? void 0 : credentials.workspaceId)) {
14
+ throw new Error('No Workspace ID is defined! Please define a workspace ID in the environment variable ASKUI_WORKSPACE_ID or define a workspace ID in the UiControlClient.');
15
+ }
16
+ if (environmentCredentials && inCodeCredentials) {
17
+ logger.warn('In-code credentials in UiControlClient.build and ENV variables(ASKUI_WORKSPACE_ID und ASKUI_TOKEN) are defined! We recommend to remove the in-code credentials for security reason! In-code credentials will be used for this execution.');
18
+ }
19
+ return credentials;
20
+ }
@@ -3,7 +3,7 @@ export function envCredentials() {
3
3
  const envToken = process.env['ASKUI_TOKEN'];
4
4
  const envWorkspaceId = process.env['ASKUI_WORKSPACE_ID'];
5
5
  if (envToken && envWorkspaceId) {
6
- logger.info('Credentials are used from ENV variables: ASKUI_TOKEN and ASKUI_WORKSPACE_ID');
6
+ logger.debug('AskUI credentials are being read from ENV variables: ASKUI_TOKEN and ASKUI_WORKSPACE_ID');
7
7
  return {
8
8
  workspaceId: envWorkspaceId,
9
9
  token: envToken,
@@ -10,11 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  import { HttpClientGot } from '../utils/http/http-client-got';
11
11
  import { UiControllerClient } from './ui-controller-client';
12
12
  import { InferenceClient } from './inference-client';
13
- import { envCredentials } from './read-environment-credentials';
14
13
  import { Analytics } from '../utils/analytics';
15
14
  import { envProxyAgents } from '../utils/proxy/proxy-builder';
16
15
  import { ExecutionRuntime } from './execution-runtime';
17
16
  import { StepReporter } from '../core/reporting';
17
+ import { readCredentials } from './read-credentials';
18
18
  export class UiControlClientDependencyBuilder {
19
19
  static buildHttpClient(clientArgs) {
20
20
  var _a;
@@ -47,9 +47,9 @@ export class UiControlClientDependencyBuilder {
47
47
  });
48
48
  }
49
49
  static getClientArgsWithDefaults(clientArgs) {
50
- var _a, _b, _c, _d;
50
+ var _a, _b, _c;
51
51
  return __awaiter(this, void 0, void 0, function* () {
52
- return Object.assign(Object.assign({}, clientArgs), { uiControllerUrl: (_a = clientArgs.uiControllerUrl) !== null && _a !== void 0 ? _a : 'http://127.0.0.1:6769', inferenceServerUrl: (_b = clientArgs.inferenceServerUrl) !== null && _b !== void 0 ? _b : 'https://inference.askui.com', credentials: (_c = clientArgs.credentials) !== null && _c !== void 0 ? _c : envCredentials(), proxyAgents: (_d = clientArgs.proxyAgents) !== null && _d !== void 0 ? _d : yield envProxyAgents() });
52
+ return Object.assign(Object.assign({}, clientArgs), { uiControllerUrl: (_a = clientArgs.uiControllerUrl) !== null && _a !== void 0 ? _a : 'http://127.0.0.1:6769', inferenceServerUrl: (_b = clientArgs.inferenceServerUrl) !== null && _b !== void 0 ? _b : 'https://inference.askui.com', credentials: readCredentials(clientArgs), proxyAgents: (_c = clientArgs.proxyAgents) !== null && _c !== void 0 ? _c : (yield envProxyAgents()) });
53
53
  });
54
54
  }
55
55
  }
@@ -1,5 +1,5 @@
1
1
  import { CustomElementJson } from '../core/model/custom-element-json';
2
- import { Exec, Executable, FluentFilters, ApiCommands } from './dsl';
2
+ import { Exec, Executable, FluentFilters, ApiCommands, PC_AND_MODIFIER_KEY } 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';
@@ -56,8 +56,8 @@ export declare class UiControlClient extends ApiCommands {
56
56
  * @return {FluentFilters}
57
57
  */
58
58
  typeIn(text: string, { isSecret, secretMask }?: {
59
- isSecret?: boolean | undefined;
60
- secretMask?: string | undefined;
59
+ isSecret?: boolean;
60
+ secretMask?: string;
61
61
  }): FluentFilters;
62
62
  /**
63
63
  * Types a text at the current position.
@@ -78,8 +78,8 @@ export declare class UiControlClient extends ApiCommands {
78
78
  * @return {Exec}
79
79
  */
80
80
  type(text: string, { isSecret, secretMask }?: {
81
- isSecret?: boolean | undefined;
82
- secretMask?: string | undefined;
81
+ isSecret?: boolean;
82
+ secretMask?: string;
83
83
  }): Exec;
84
84
  /**
85
85
  * Waits for `<delayInMs>` ms, e.g., 1000 ms. The exact delay may be a little longer
@@ -90,4 +90,69 @@ export declare class UiControlClient extends ApiCommands {
90
90
  * @return {Executable}
91
91
  */
92
92
  waitFor(delayInMs: number): Executable;
93
+ /**
94
+ * Press a key multiple times. At least two times.
95
+ *
96
+ * @param {PC_AND_MODIFIER_KEY} key
97
+ *
98
+ * @param {number} times
99
+ */
100
+ pressKeyNTimes(key: PC_AND_MODIFIER_KEY, times?: number): Promise<void>;
101
+ /**
102
+ * Press an array of keys one after another.
103
+ *
104
+ * For example press the following keys: right, left, enter.
105
+ *
106
+ * pressKeys(['right', 'left', 'enter'])
107
+ *
108
+ * @param {PC_AND_MODIFIER_KEY[]} keys
109
+ */
110
+ pressKeys(keys: PC_AND_MODIFIER_KEY[]): Promise<void>;
111
+ /**
112
+ * Searches for a text element and clicks it when found.
113
+ *
114
+ * @param {string} text - A text to be searched.
115
+ */
116
+ clickText(text: string): Promise<void>;
117
+ /**
118
+ * Searches for text elements and clicks them
119
+ * one after another when found.
120
+ *
121
+ * @param {string[]} texts - An array of texts to be searched.
122
+ */
123
+ clickTexts(texts: string[]): Promise<void>;
124
+ /**
125
+ * Searches for an element of type button
126
+ * with a label and clicks it when found.
127
+ *
128
+ * @param {string} label - The buttons label.
129
+ */
130
+ clickButton(label: string): Promise<void>;
131
+ /**
132
+ * Searches for an element of type textfield with a specific placeholder text.
133
+ * If found, clicks it.
134
+ *
135
+ * @param {string} placeholder - The textfields placeholder text.
136
+ */
137
+ clickTextfield(placeholder: string): Promise<void>;
138
+ /**
139
+ * Clicks an icon based on a description.
140
+ *
141
+ * @param {string} description
142
+ */
143
+ clickIcon(description: string): Promise<void>;
144
+ /**
145
+ * Wait until an AskUICommand does not fail.
146
+ *
147
+ * Use it to wait for an element to appear like this:
148
+ *
149
+ * await waitUntil(
150
+ * aui.expect().text('Github').exists()
151
+ * );
152
+ *
153
+ * @param {Executable} AskUICommand - For example: aui.moveMouse(0, 0)
154
+ * @param {number} maxTry - Number of maximum retries
155
+ * @param {number} waitTime - Time in milliseconds
156
+ */
157
+ waitUntil(AskUICommand: Executable, maxTry?: number, waitTime?: number): Promise<void>;
93
158
  }
@@ -214,4 +214,121 @@ export class UiControlClient extends ApiCommands {
214
214
  },
215
215
  };
216
216
  }
217
+ /**
218
+ * Press a key multiple times. At least two times.
219
+ *
220
+ * @param {PC_AND_MODIFIER_KEY} key
221
+ *
222
+ * @param {number} times
223
+ */
224
+ pressKeyNTimes(key, times = 2) {
225
+ return __awaiter(this, void 0, void 0, function* () {
226
+ /* eslint-disable no-await-in-loop */
227
+ for (let i = 0; i < times; i += 1) {
228
+ yield this.pressKey(key).exec();
229
+ }
230
+ });
231
+ }
232
+ /**
233
+ * Press an array of keys one after another.
234
+ *
235
+ * For example press the following keys: right, left, enter.
236
+ *
237
+ * pressKeys(['right', 'left', 'enter'])
238
+ *
239
+ * @param {PC_AND_MODIFIER_KEY[]} keys
240
+ */
241
+ pressKeys(keys) {
242
+ return __awaiter(this, void 0, void 0, function* () {
243
+ /* eslint-disable no-await-in-loop */
244
+ for (let i = 0; i < keys.length; i += 1) {
245
+ yield this.pressKey(keys[i]).exec();
246
+ }
247
+ });
248
+ }
249
+ /**
250
+ * Searches for a text element and clicks it when found.
251
+ *
252
+ * @param {string} text - A text to be searched.
253
+ */
254
+ clickText(text) {
255
+ return __awaiter(this, void 0, void 0, function* () {
256
+ yield this.click().text(text).exec();
257
+ });
258
+ }
259
+ /**
260
+ * Searches for text elements and clicks them
261
+ * one after another when found.
262
+ *
263
+ * @param {string[]} texts - An array of texts to be searched.
264
+ */
265
+ clickTexts(texts) {
266
+ return __awaiter(this, void 0, void 0, function* () {
267
+ /* eslint-disable no-await-in-loop */
268
+ for (let i = 0; i < texts.length; i += 1) {
269
+ yield this.click().text(texts[i]).exec();
270
+ }
271
+ });
272
+ }
273
+ /**
274
+ * Searches for an element of type button
275
+ * with a label and clicks it when found.
276
+ *
277
+ * @param {string} label - The buttons label.
278
+ */
279
+ clickButton(label) {
280
+ return __awaiter(this, void 0, void 0, function* () {
281
+ yield this.click().button().withText(label).exec();
282
+ });
283
+ }
284
+ /**
285
+ * Searches for an element of type textfield with a specific placeholder text.
286
+ * If found, clicks it.
287
+ *
288
+ * @param {string} placeholder - The textfields placeholder text.
289
+ */
290
+ clickTextfield(placeholder) {
291
+ return __awaiter(this, void 0, void 0, function* () {
292
+ yield this.click().textfield().contains().text()
293
+ .withText(placeholder)
294
+ .exec();
295
+ });
296
+ }
297
+ /**
298
+ * Clicks an icon based on a description.
299
+ *
300
+ * @param {string} description
301
+ */
302
+ clickIcon(description) {
303
+ return __awaiter(this, void 0, void 0, function* () {
304
+ yield this.click().icon().matching(description).exec();
305
+ });
306
+ }
307
+ /**
308
+ * Wait until an AskUICommand does not fail.
309
+ *
310
+ * Use it to wait for an element to appear like this:
311
+ *
312
+ * await waitUntil(
313
+ * aui.expect().text('Github').exists()
314
+ * );
315
+ *
316
+ * @param {Executable} AskUICommand - For example: aui.moveMouse(0, 0)
317
+ * @param {number} maxTry - Number of maximum retries
318
+ * @param {number} waitTime - Time in milliseconds
319
+ */
320
+ waitUntil(AskUICommand, maxTry = 5, waitTime = 2000) {
321
+ return __awaiter(this, void 0, void 0, function* () {
322
+ try {
323
+ yield AskUICommand.exec();
324
+ }
325
+ catch (error) {
326
+ if (maxTry === 0) {
327
+ throw error;
328
+ }
329
+ yield this.waitFor(waitTime).exec();
330
+ yield this.waitUntil(AskUICommand, maxTry - 1);
331
+ }
332
+ });
333
+ }
217
334
  }
@@ -1 +1,2 @@
1
1
  export declare function addScript(filePath: string, name: string, command: string): Promise<void>;
2
+ export declare function removeScript(filePath: string, name: string): Promise<void>;
@@ -24,7 +24,25 @@ export function addScript(filePath, name, command) {
24
24
  yield fs.writeFile(filePath, jsonString, 'utf8');
25
25
  }
26
26
  catch (error) {
27
- logger.error(`Could write script '${command}' in file '${filePath}'`);
27
+ logger.error(`Could not write script '${command}' in file '${filePath}'`);
28
+ logger.error(error.message);
29
+ }
30
+ });
31
+ }
32
+ export function removeScript(filePath, name) {
33
+ return __awaiter(this, void 0, void 0, function* () {
34
+ try {
35
+ const data = yield fs.readFile(filePath, 'utf8');
36
+ const jsonData = JSON.parse(data);
37
+ if (jsonData.scripts === undefined) {
38
+ return;
39
+ }
40
+ delete jsonData.scripts[name];
41
+ const jsonString = JSON.stringify(jsonData, null, 2);
42
+ yield fs.writeFile(filePath, jsonString, 'utf8');
43
+ }
44
+ catch (error) {
45
+ logger.error(`Could not remove script '${name}' in file '${filePath}'`);
28
46
  logger.error(error.message);
29
47
  }
30
48
  });
@@ -1,8 +1,8 @@
1
1
  export interface CliOptions {
2
+ skipCredentials: boolean;
2
3
  operatingSystem: 'windows' | 'linux' | 'macos';
3
4
  workspaceId: string;
4
5
  accessToken: string;
5
- testFramework: 'jasmine' | 'jest';
6
- usingProxy: boolean;
6
+ testFramework: 'jest';
7
7
  typescriptConfig: boolean;
8
8
  }