askui 0.1.6 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/README.md +6 -0
  2. package/bin/askui-postinstall +35 -0
  3. package/dist/cjs/core/model/test-case-dto/custom-element.d.ts +2 -2
  4. package/dist/cjs/core/model/test-case-dto/custom-element.js +2 -2
  5. package/dist/cjs/core/model/test-case-dto/custom-element.spec.js +7 -6
  6. package/dist/cjs/core/model/test-case-dto/index.js +1 -3
  7. package/dist/cjs/core/model/test-case-dto/test-step.d.ts +3 -7
  8. package/dist/cjs/core/model/test-case-dto/test-step.js +0 -12
  9. package/dist/cjs/core/ui-control-commands/control-command.d.ts +1 -0
  10. package/dist/cjs/core/ui-control-commands/control-command.js +5 -0
  11. package/dist/cjs/core/ui-control-commands/input-event.d.ts +1 -2
  12. package/dist/cjs/core/ui-control-commands/input-event.js +0 -1
  13. package/dist/cjs/execution/dsl.d.ts +6 -17
  14. package/dist/cjs/execution/dsl.js +4 -21
  15. package/dist/cjs/execution/execution-runtime.d.ts +7 -5
  16. package/dist/cjs/execution/execution-runtime.js +35 -23
  17. package/dist/cjs/execution/index.d.ts +2 -1
  18. package/dist/cjs/execution/index.js +5 -3
  19. package/dist/cjs/execution/{control-your-ui-api.d.ts → inference-client.d.ts} +4 -4
  20. package/dist/cjs/execution/{control-your-ui-api.js → inference-client.js} +9 -9
  21. package/dist/cjs/execution/ui-control-client-error.d.ts +2 -0
  22. package/dist/cjs/execution/ui-control-client-error.js +6 -0
  23. package/dist/cjs/execution/ui-control-client.d.ts +79 -0
  24. package/dist/cjs/execution/ui-control-client.js +185 -0
  25. package/dist/cjs/execution/{client-connection-state.d.ts → ui-controller-client-connection-state.d.ts} +1 -1
  26. package/dist/cjs/execution/ui-controller-client-connection-state.js +10 -0
  27. package/dist/cjs/execution/ui-controller-client-interface.d.ts +27 -0
  28. package/dist/cjs/execution/{client-interface.js → ui-controller-client-interface.js} +0 -0
  29. package/dist/cjs/execution/{control-your-ui-client.d.ts → ui-controller-client.d.ts} +6 -6
  30. package/dist/cjs/execution/{control-your-ui-client.js → ui-controller-client.js} +28 -28
  31. package/dist/cjs/lib/copy-example-project.js +2 -1
  32. package/dist/cjs/lib/download-binaries.js +10 -9
  33. package/dist/cjs/lib/index.d.ts +1 -1
  34. package/dist/cjs/lib/index.js +3 -3
  35. package/dist/cjs/lib/libfuse-error.d.ts +2 -0
  36. package/dist/cjs/lib/libfuse-error.js +6 -0
  37. package/dist/cjs/lib/logger.js +1 -1
  38. package/dist/cjs/lib/timeout-error.d.ts +0 -2
  39. package/dist/cjs/lib/timeout-error.js +0 -5
  40. package/dist/cjs/lib/ui-controller-args.d.ts +47 -0
  41. package/dist/cjs/lib/{control-ui-server-args.js → ui-controller-args.js} +0 -0
  42. package/dist/cjs/lib/{control-ui-server-args.spec.d.ts → ui-controller-args.spec.d.ts} +0 -0
  43. package/dist/cjs/lib/{control-ui-server-args.spec.js → ui-controller-args.spec.js} +7 -7
  44. package/dist/cjs/lib/ui-controller-darwin.d.ts +6 -0
  45. package/dist/cjs/lib/{control-ui-server-darwin.js → ui-controller-darwin.js} +8 -8
  46. package/dist/cjs/lib/ui-controller-facade.d.ts +17 -0
  47. package/dist/cjs/lib/{control-ui-server-facade.js → ui-controller-facade.js} +22 -16
  48. package/dist/cjs/lib/ui-controller-linux.d.ts +5 -0
  49. package/dist/cjs/lib/ui-controller-linux.js +52 -0
  50. package/dist/cjs/lib/ui-controller-win32.d.ts +3 -0
  51. package/dist/cjs/lib/ui-controller-win32.js +7 -0
  52. package/dist/cjs/lib/ui-controller.d.ts +8 -0
  53. package/dist/cjs/lib/{askui-control-server.js → ui-controller.js} +9 -9
  54. package/dist/cjs/lib/unkown-error.d.ts +0 -2
  55. package/dist/cjs/lib/unkown-error.js +0 -5
  56. package/dist/cjs/lib/wayland-error.d.ts +2 -0
  57. package/dist/cjs/lib/wayland-error.js +6 -0
  58. package/dist/cjs/main.d.ts +3 -2
  59. package/dist/cjs/main.js +6 -3
  60. package/dist/cjs/shared/index.d.ts +1 -0
  61. package/dist/cjs/shared/index.js +5 -0
  62. package/dist/cjs/utils/analytics/analytics-interface.d.ts +3 -0
  63. package/dist/cjs/utils/analytics/analytics-interface.js +2 -0
  64. package/dist/cjs/utils/analytics/analytics.d.ts +5 -0
  65. package/dist/cjs/utils/analytics/analytics.js +38 -0
  66. package/dist/cjs/utils/analytics/index.d.ts +1 -0
  67. package/dist/cjs/utils/analytics/index.js +5 -0
  68. package/dist/cjs/utils/analytics/installation-timestamp-create-error.d.ts +4 -0
  69. package/dist/cjs/utils/analytics/installation-timestamp-create-error.js +9 -0
  70. package/dist/cjs/utils/analytics/installation-timestamp-get-error.d.ts +4 -0
  71. package/dist/cjs/utils/analytics/installation-timestamp-get-error.js +9 -0
  72. package/dist/cjs/utils/analytics/installation-timestamp.d.ts +7 -0
  73. package/dist/cjs/utils/analytics/installation-timestamp.js +68 -0
  74. package/dist/cjs/utils/analytics/user-identifier-interface.d.ts +3 -0
  75. package/dist/cjs/utils/analytics/user-identifier-interface.js +2 -0
  76. package/dist/cjs/utils/analytics/user-identifier.d.ts +4 -0
  77. package/dist/cjs/utils/analytics/user-identifier.js +22 -0
  78. package/dist/cjs/utils/base_64_image/base-64-image-error.d.ts +2 -0
  79. package/dist/cjs/utils/base_64_image/base-64-image-error.js +6 -0
  80. package/dist/cjs/utils/base_64_image/base-64-image-string-error.d.ts +4 -0
  81. package/dist/cjs/utils/base_64_image/base-64-image-string-error.js +11 -0
  82. package/dist/cjs/utils/base_64_image/base-64-image.d.ts +18 -0
  83. package/dist/cjs/utils/base_64_image/base-64-image.js +86 -0
  84. package/dist/cjs/utils/http/custom-errors/http-client-error.d.ts +0 -2
  85. package/dist/cjs/utils/http/custom-errors/http-client-error.js +0 -5
  86. package/dist/cjs/utils/http/http-client-got.d.ts +6 -5
  87. package/dist/cjs/utils/http/http-client-got.js +11 -11
  88. package/dist/cjs/utils/image-resize-errors/image-resizing-base-error.d.ts +0 -2
  89. package/dist/cjs/utils/image-resize-errors/image-resizing-base-error.js +0 -5
  90. package/dist/cjs/utils/image-resize-errors/index.d.ts +0 -1
  91. package/dist/cjs/utils/image-resize-errors/index.js +1 -3
  92. package/dist/cjs/utils/path.d.ts +1 -0
  93. package/dist/cjs/utils/path.js +11 -0
  94. package/dist/cjs/utils/transformations.d.ts +0 -2
  95. package/dist/cjs/utils/transformations.js +11 -44
  96. package/dist/esm/core/model/test-case-dto/custom-element.d.ts +2 -2
  97. package/dist/esm/core/model/test-case-dto/custom-element.js +2 -2
  98. package/dist/esm/core/model/test-case-dto/custom-element.spec.js +7 -6
  99. package/dist/esm/core/model/test-case-dto/index.js +0 -1
  100. package/dist/esm/core/model/test-case-dto/test-step.d.ts +3 -7
  101. package/dist/esm/core/model/test-case-dto/test-step.js +1 -10
  102. package/dist/esm/core/ui-control-commands/control-command.d.ts +1 -0
  103. package/dist/esm/core/ui-control-commands/control-command.js +5 -0
  104. package/dist/esm/core/ui-control-commands/input-event.d.ts +1 -2
  105. package/dist/esm/core/ui-control-commands/input-event.js +0 -1
  106. package/dist/esm/execution/dsl.d.ts +6 -17
  107. package/dist/esm/execution/dsl.js +3 -21
  108. package/dist/esm/execution/execution-runtime.d.ts +7 -5
  109. package/dist/esm/execution/execution-runtime.js +35 -23
  110. package/dist/esm/execution/index.d.ts +2 -1
  111. package/dist/esm/execution/index.js +2 -1
  112. package/dist/esm/execution/{control-your-ui-api.d.ts → inference-client.d.ts} +4 -4
  113. package/dist/esm/execution/{control-your-ui-api.js → inference-client.js} +7 -7
  114. package/dist/esm/execution/ui-control-client-error.d.ts +2 -0
  115. package/dist/esm/execution/ui-control-client-error.js +2 -0
  116. package/dist/esm/execution/ui-control-client.d.ts +79 -0
  117. package/dist/esm/execution/ui-control-client.js +181 -0
  118. package/dist/esm/execution/{client-connection-state.d.ts → ui-controller-client-connection-state.d.ts} +1 -1
  119. package/dist/esm/execution/ui-controller-client-connection-state.js +7 -0
  120. package/dist/esm/execution/ui-controller-client-interface.d.ts +27 -0
  121. package/dist/esm/execution/{client-interface.js → ui-controller-client-interface.js} +0 -0
  122. package/dist/esm/execution/{control-your-ui-client.d.ts → ui-controller-client.d.ts} +6 -6
  123. package/dist/esm/execution/{control-your-ui-client.js → ui-controller-client.js} +26 -26
  124. package/dist/esm/lib/copy-example-project.js +2 -1
  125. package/dist/esm/lib/download-binaries.js +10 -9
  126. package/dist/esm/lib/index.d.ts +1 -1
  127. package/dist/esm/lib/index.js +1 -1
  128. package/dist/esm/lib/libfuse-error.d.ts +2 -0
  129. package/dist/esm/lib/libfuse-error.js +2 -0
  130. package/dist/esm/lib/logger.js +1 -1
  131. package/dist/esm/lib/timeout-error.d.ts +0 -2
  132. package/dist/esm/lib/timeout-error.js +0 -5
  133. package/dist/esm/lib/ui-controller-args.d.ts +47 -0
  134. package/dist/esm/lib/{control-ui-server-args.js → ui-controller-args.js} +0 -0
  135. package/dist/esm/lib/{control-ui-server-args.spec.d.ts → ui-controller-args.spec.d.ts} +0 -0
  136. package/dist/esm/lib/{control-ui-server-args.spec.js → ui-controller-args.spec.js} +1 -1
  137. package/dist/esm/lib/ui-controller-darwin.d.ts +6 -0
  138. package/dist/esm/lib/{control-ui-server-darwin.js → ui-controller-darwin.js} +6 -6
  139. package/dist/esm/lib/ui-controller-facade.d.ts +17 -0
  140. package/dist/esm/lib/{control-ui-server-facade.js → ui-controller-facade.js} +17 -11
  141. package/dist/esm/lib/ui-controller-linux.d.ts +5 -0
  142. package/dist/esm/lib/ui-controller-linux.js +48 -0
  143. package/dist/esm/lib/ui-controller-win32.d.ts +3 -0
  144. package/dist/esm/lib/ui-controller-win32.js +3 -0
  145. package/dist/esm/lib/ui-controller.d.ts +8 -0
  146. package/dist/esm/lib/{askui-control-server.js → ui-controller.js} +7 -7
  147. package/dist/esm/lib/unkown-error.d.ts +0 -2
  148. package/dist/esm/lib/unkown-error.js +0 -5
  149. package/dist/esm/lib/wayland-error.d.ts +2 -0
  150. package/dist/esm/lib/wayland-error.js +2 -0
  151. package/dist/esm/main.d.ts +3 -2
  152. package/dist/esm/main.js +3 -2
  153. package/dist/esm/shared/index.d.ts +1 -0
  154. package/dist/esm/shared/index.js +1 -0
  155. package/dist/esm/utils/analytics/analytics-interface.d.ts +3 -0
  156. package/dist/esm/utils/analytics/analytics-interface.js +1 -0
  157. package/dist/esm/utils/analytics/analytics.d.ts +5 -0
  158. package/dist/esm/utils/analytics/analytics.js +31 -0
  159. package/dist/esm/utils/analytics/index.d.ts +1 -0
  160. package/dist/esm/utils/analytics/index.js +1 -0
  161. package/dist/esm/utils/analytics/installation-timestamp-create-error.d.ts +4 -0
  162. package/dist/esm/utils/analytics/installation-timestamp-create-error.js +5 -0
  163. package/dist/esm/utils/analytics/installation-timestamp-get-error.d.ts +4 -0
  164. package/dist/esm/utils/analytics/installation-timestamp-get-error.js +5 -0
  165. package/dist/esm/utils/analytics/installation-timestamp.d.ts +7 -0
  166. package/dist/esm/utils/analytics/installation-timestamp.js +61 -0
  167. package/dist/esm/utils/analytics/user-identifier-interface.d.ts +3 -0
  168. package/dist/esm/utils/analytics/user-identifier-interface.js +1 -0
  169. package/dist/esm/utils/analytics/user-identifier.d.ts +4 -0
  170. package/dist/esm/utils/analytics/user-identifier.js +18 -0
  171. package/dist/esm/utils/base_64_image/base-64-image-error.d.ts +2 -0
  172. package/dist/esm/utils/base_64_image/base-64-image-error.js +2 -0
  173. package/dist/esm/utils/base_64_image/base-64-image-string-error.d.ts +4 -0
  174. package/dist/esm/utils/base_64_image/base-64-image-string-error.js +7 -0
  175. package/dist/esm/utils/base_64_image/base-64-image.d.ts +18 -0
  176. package/dist/esm/utils/base_64_image/base-64-image.js +79 -0
  177. package/dist/esm/utils/http/custom-errors/http-client-error.d.ts +0 -2
  178. package/dist/esm/utils/http/custom-errors/http-client-error.js +0 -5
  179. package/dist/esm/utils/http/http-client-got.d.ts +6 -5
  180. package/dist/esm/utils/http/http-client-got.js +11 -11
  181. package/dist/esm/utils/image-resize-errors/image-resizing-base-error.d.ts +0 -2
  182. package/dist/esm/utils/image-resize-errors/image-resizing-base-error.js +0 -5
  183. package/dist/esm/utils/image-resize-errors/index.d.ts +0 -1
  184. package/dist/esm/utils/image-resize-errors/index.js +0 -1
  185. package/dist/esm/utils/path.d.ts +1 -0
  186. package/dist/esm/utils/path.js +4 -0
  187. package/dist/esm/utils/transformations.d.ts +0 -2
  188. package/dist/esm/utils/transformations.js +11 -39
  189. package/dist/example_projects_templates/typescript_jest/test/helper/jest.setup.ts +7 -7
  190. package/dist/example_projects_templates/typescript_jest/test/jest.config.ts +3 -0
  191. package/package.json +15 -8
  192. package/dist/cjs/execution/client-connection-state.js +0 -10
  193. package/dist/cjs/execution/client-error.d.ts +0 -2
  194. package/dist/cjs/execution/client-error.js +0 -6
  195. package/dist/cjs/execution/client-interface.d.ts +0 -13
  196. package/dist/cjs/execution/client.d.ts +0 -25
  197. package/dist/cjs/execution/client.js +0 -116
  198. package/dist/cjs/lib/askui-control-server.d.ts +0 -8
  199. package/dist/cjs/lib/control-ui-server-args.d.ts +0 -21
  200. package/dist/cjs/lib/control-ui-server-darwin.d.ts +0 -6
  201. package/dist/cjs/lib/control-ui-server-facade.d.ts +0 -16
  202. package/dist/cjs/lib/control-ui-server-linux.d.ts +0 -4
  203. package/dist/cjs/lib/control-ui-server-linux.js +0 -13
  204. package/dist/cjs/lib/control-ui-server-win32.d.ts +0 -3
  205. package/dist/cjs/lib/control-ui-server-win32.js +0 -7
  206. package/dist/cjs/utils/image-resize-errors/invalid-base64-image-error.d.ts +0 -3
  207. package/dist/cjs/utils/image-resize-errors/invalid-base64-image-error.js +0 -7
  208. package/dist/esm/execution/client-connection-state.js +0 -7
  209. package/dist/esm/execution/client-error.d.ts +0 -2
  210. package/dist/esm/execution/client-error.js +0 -2
  211. package/dist/esm/execution/client-interface.d.ts +0 -13
  212. package/dist/esm/execution/client.d.ts +0 -25
  213. package/dist/esm/execution/client.js +0 -112
  214. package/dist/esm/lib/askui-control-server.d.ts +0 -8
  215. package/dist/esm/lib/control-ui-server-args.d.ts +0 -21
  216. package/dist/esm/lib/control-ui-server-darwin.d.ts +0 -6
  217. package/dist/esm/lib/control-ui-server-facade.d.ts +0 -16
  218. package/dist/esm/lib/control-ui-server-linux.d.ts +0 -4
  219. package/dist/esm/lib/control-ui-server-linux.js +0 -9
  220. package/dist/esm/lib/control-ui-server-win32.d.ts +0 -3
  221. package/dist/esm/lib/control-ui-server-win32.js +0 -3
  222. package/dist/esm/utils/image-resize-errors/invalid-base64-image-error.d.ts +0 -3
  223. package/dist/esm/utils/image-resize-errors/invalid-base64-image-error.js +0 -3
@@ -1,25 +0,0 @@
1
- import { CustomElementJson } from '../core/model/test-case-dto';
2
- import { FluentCommand } from './dsl';
3
- import { ClientConnectionState } from './client-connection-state';
4
- import { Annotation } from '../core/annotation/annotation';
5
- import { AnnotationRequest } from '../core/model/annotation-result/annotation-interface';
6
- import { ClientArgs } from './client-interface';
7
- export declare class AskuiClient extends FluentCommand {
8
- private clientArgs?;
9
- private _controlYourUiClient?;
10
- private httpClient;
11
- constructor(clientArgs?: ClientArgs | undefined);
12
- private get controlYourUiClient();
13
- private get clientArgsWithDefaults();
14
- private get api();
15
- private get executionRuntime();
16
- private annotateByDefault;
17
- connect(): Promise<ClientConnectionState>;
18
- annotate(annotationRequest?: AnnotationRequest): Promise<Annotation>;
19
- annotateInteractively(): Promise<void>;
20
- exec(instruction: string, customElementJson?: CustomElementJson[]): Promise<void>;
21
- /**
22
- * closes the connection to the controlui-server`.
23
- */
24
- close(): void;
25
- }
@@ -1,116 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AskuiClient = void 0;
13
- const test_case_dto_1 = require("../core/model/test-case-dto");
14
- const dsl_1 = require("./dsl");
15
- const http_client_got_1 = require("../utils/http/http-client-got");
16
- const control_your_ui_client_1 = require("./control-your-ui-client");
17
- const execution_runtime_1 = require("./execution-runtime");
18
- const control_your_ui_api_1 = require("./control-your-ui-api");
19
- const annotation_writer_1 = require("../core/annotation/annotation-writer");
20
- const logger_1 = require("../lib/logger");
21
- const test_case_result_dto_1 = require("../core/model/test-case-result-dto");
22
- const annotation_level_1 = require("./annotation-level");
23
- const client_error_1 = require("./client-error");
24
- const read_environment_credentials_1 = require("./read-environment-credentials");
25
- class AskuiClient extends dsl_1.FluentCommand {
26
- constructor(clientArgs) {
27
- var _a;
28
- super();
29
- 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
- get controlYourUiClient() {
33
- if (!this._controlYourUiClient) {
34
- this._controlYourUiClient = new control_your_ui_client_1.ControlYourUiClient(this.clientArgsWithDefaults.controlServerUrl);
35
- }
36
- return this._controlYourUiClient;
37
- }
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);
45
- }
46
- get api() {
47
- return new control_your_ui_api_1.ControlYourUiApi(this.clientArgsWithDefaults.controlYourUiApi, this.httpClient);
48
- }
49
- get executionRuntime() {
50
- return new execution_runtime_1.ExecutionRuntime(this.controlYourUiClient, this.api);
51
- }
52
- annotateByDefault(testStepState, customElements = []) {
53
- return __awaiter(this, void 0, void 0, function* () {
54
- if ((testStepState === test_case_result_dto_1.TestStepState.FAILED
55
- && this.clientArgsWithDefaults.annotationLevel === annotation_level_1.AnnotationLevel.DISABLED)
56
- || (testStepState === test_case_result_dto_1.TestStepState.PASSED
57
- && this.clientArgsWithDefaults.annotationLevel !== annotation_level_1.AnnotationLevel.ALL)) {
58
- return;
59
- }
60
- yield this.annotate({
61
- customElements,
62
- fileNamePrefix: `${testStepState.toLowerCase()}_testStep_annotation`,
63
- });
64
- });
65
- }
66
- connect() {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- const connectionState = yield this.controlYourUiClient.connect();
69
- return connectionState;
70
- });
71
- }
72
- annotate(annotationRequest = {}) {
73
- return __awaiter(this, void 0, void 0, function* () {
74
- const annotation = yield this.executionRuntime.annotateImage(annotationRequest.imagePath, annotationRequest.customElements);
75
- annotation_writer_1.AnnotationWriter.write(annotation.toHtml(), annotationRequest.outputPath, annotationRequest.fileNamePrefix);
76
- return annotation;
77
- });
78
- }
79
- annotateInteractively() {
80
- return __awaiter(this, void 0, void 0, function* () {
81
- try {
82
- yield this.executionRuntime.annotateInteractively();
83
- }
84
- catch (err) {
85
- logger_1.logger.error(err);
86
- }
87
- });
88
- }
89
- exec(instruction, customElementJson) {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- let customElements = [];
92
- if (customElementJson !== undefined) {
93
- customElements = yield test_case_dto_1.CustomElement.fromJsonListWithImagePathOrImage(customElementJson);
94
- }
95
- try {
96
- yield this.executionRuntime.executeTestStep({
97
- instruction,
98
- customElements,
99
- });
100
- yield this.annotateByDefault(test_case_result_dto_1.TestStepState.PASSED, customElements);
101
- return yield Promise.resolve();
102
- }
103
- catch (error) {
104
- 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}`));
106
- }
107
- });
108
- }
109
- /**
110
- * closes the connection to the controlui-server`.
111
- */
112
- close() {
113
- this.controlYourUiClient.close();
114
- }
115
- }
116
- exports.AskuiClient = AskuiClient;
@@ -1,8 +0,0 @@
1
- import { ControlUiServerArgs } from './control-ui-server-args';
2
- export declare class AskuiControlServer {
3
- private args?;
4
- private server;
5
- constructor(args?: ControlUiServerArgs | undefined);
6
- start(timeoutInSeconds?: number): Promise<void>;
7
- stop(forceStop?: boolean): Promise<void>;
8
- }
@@ -1,21 +0,0 @@
1
- import { LogLevels } from '../shared/log-levels';
2
- export interface ControlUiServerArgs {
3
- readonly display?: number;
4
- readonly binaryVersion?: string;
5
- readonly port?: number;
6
- readonly host?: string;
7
- readonly minimize?: boolean;
8
- readonly overWriteBinary?: boolean;
9
- readonly logLevel?: LogLevels;
10
- readonly logFilePath?: string;
11
- }
12
- export interface ControlUiServerArgsWithDefaults extends ControlUiServerArgs {
13
- readonly display: number;
14
- readonly binaryVersion: string;
15
- readonly overWriteBinary: boolean;
16
- readonly port: number;
17
- readonly host: string;
18
- readonly logLevel?: LogLevels;
19
- }
20
- export declare function createArgsWithDefaults(args?: ControlUiServerArgs): ControlUiServerArgsWithDefaults;
21
- export declare function createCliFlagsFromArgs(args: ControlUiServerArgsWithDefaults): string[];
@@ -1,6 +0,0 @@
1
- import { ControlUiServerFacade } from './control-ui-server-facade';
2
- export declare class ControlUiServerDarwin extends ControlUiServerFacade {
3
- protected makeBinaryExecutable(): void;
4
- protected getStartingCommand(): string;
5
- private makeDiskImageExecutable;
6
- }
@@ -1,16 +0,0 @@
1
- import { ControlUiServerArgs, ControlUiServerArgsWithDefaults } from './control-ui-server-args';
2
- export declare abstract class ControlUiServerFacade {
3
- protected binaryPath: string;
4
- protected serverLogFile: string;
5
- protected readonly DefaultmaxWaitingForStartingInMs: number;
6
- start(args?: ControlUiServerArgs, maxWaitingForStartingInSeconds?: number): Promise<void>;
7
- stop(args?: ControlUiServerArgs, forceStop?: boolean): Promise<void>;
8
- protected serverLogFilePath(args?: ControlUiServerArgsWithDefaults): ControlUiServerArgsWithDefaults;
9
- protected killPort(port: number, forceStop?: boolean): Promise<void>;
10
- protected getStartingCommand(): string;
11
- protected makeBinaryExecutable(): void;
12
- protected waitUntilStarted(args: ControlUiServerArgsWithDefaults, maxWaitingForStartingInSeconds?: number): Promise<void>;
13
- private isBinaryValid;
14
- private getBinary;
15
- private startWithDefaults;
16
- }
@@ -1,4 +0,0 @@
1
- import { ControlUiServerFacade } from './control-ui-server-facade';
2
- export declare class ControlUiServerLinux extends ControlUiServerFacade {
3
- protected makeBinaryExecutable(): void;
4
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ControlUiServerLinux = void 0;
4
- const child_process_1 = require("child_process");
5
- const control_ui_server_facade_1 = require("./control-ui-server-facade");
6
- const logger_1 = require("./logger");
7
- class ControlUiServerLinux extends control_ui_server_facade_1.ControlUiServerFacade {
8
- // eslint-disable-next-line class-methods-use-this
9
- makeBinaryExecutable() {
10
- (0, child_process_1.exec)(`chmod +x ${this.binaryPath}`, (_exception, stdout) => logger_1.logger.debug(stdout));
11
- }
12
- }
13
- exports.ControlUiServerLinux = ControlUiServerLinux;
@@ -1,3 +0,0 @@
1
- import { ControlUiServerFacade } from './control-ui-server-facade';
2
- export declare class ControlUiServerWin32 extends ControlUiServerFacade {
3
- }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ControlUiServerWin32 = void 0;
4
- const control_ui_server_facade_1 = require("./control-ui-server-facade");
5
- class ControlUiServerWin32 extends control_ui_server_facade_1.ControlUiServerFacade {
6
- }
7
- exports.ControlUiServerWin32 = ControlUiServerWin32;
@@ -1,3 +0,0 @@
1
- import { ImageResizingError } from './image-resizing-base-error';
2
- export declare class InvalidBase64Image extends ImageResizingError {
3
- }
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidBase64Image = void 0;
4
- const image_resizing_base_error_1 = require("./image-resizing-base-error");
5
- class InvalidBase64Image extends image_resizing_base_error_1.ImageResizingError {
6
- }
7
- exports.InvalidBase64Image = InvalidBase64Image;
@@ -1,7 +0,0 @@
1
- export var ClientConnectionState;
2
- (function (ClientConnectionState) {
3
- ClientConnectionState[ClientConnectionState["NOT_CONNECTED"] = 0] = "NOT_CONNECTED";
4
- ClientConnectionState[ClientConnectionState["CONNECTING"] = 1] = "CONNECTING";
5
- ClientConnectionState[ClientConnectionState["CONNECTED"] = 2] = "CONNECTED";
6
- ClientConnectionState[ClientConnectionState["ERROR"] = 3] = "ERROR";
7
- })(ClientConnectionState || (ClientConnectionState = {}));
@@ -1,2 +0,0 @@
1
- export declare class ControlUiClientError extends Error {
2
- }
@@ -1,2 +0,0 @@
1
- export class ControlUiClientError extends Error {
2
- }
@@ -1,13 +0,0 @@
1
- import { CredentialArgs } from '../utils/http/credentials';
2
- import { AnnotationLevel } from './annotation-level';
3
- export interface ClientArgs {
4
- readonly controlServerUrl?: string;
5
- readonly controlYourUiApi?: string;
6
- readonly annotationLevel?: AnnotationLevel;
7
- readonly credentials?: CredentialArgs;
8
- }
9
- export interface ClientArgsWithDefaults extends ClientArgs {
10
- readonly controlServerUrl: string;
11
- readonly controlYourUiApi: string;
12
- readonly annotationLevel: AnnotationLevel;
13
- }
@@ -1,25 +0,0 @@
1
- import { CustomElementJson } from '../core/model/test-case-dto';
2
- import { FluentCommand } from './dsl';
3
- import { ClientConnectionState } from './client-connection-state';
4
- import { Annotation } from '../core/annotation/annotation';
5
- import { AnnotationRequest } from '../core/model/annotation-result/annotation-interface';
6
- import { ClientArgs } from './client-interface';
7
- export declare class AskuiClient extends FluentCommand {
8
- private clientArgs?;
9
- private _controlYourUiClient?;
10
- private httpClient;
11
- constructor(clientArgs?: ClientArgs | undefined);
12
- private get controlYourUiClient();
13
- private get clientArgsWithDefaults();
14
- private get api();
15
- private get executionRuntime();
16
- private annotateByDefault;
17
- connect(): Promise<ClientConnectionState>;
18
- annotate(annotationRequest?: AnnotationRequest): Promise<Annotation>;
19
- annotateInteractively(): Promise<void>;
20
- exec(instruction: string, customElementJson?: CustomElementJson[]): Promise<void>;
21
- /**
22
- * closes the connection to the controlui-server`.
23
- */
24
- close(): void;
25
- }
@@ -1,112 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import { CustomElement } from '../core/model/test-case-dto';
11
- import { FluentCommand } from './dsl';
12
- import { HttpClientGot } from '../utils/http/http-client-got';
13
- import { ControlYourUiClient } from './control-your-ui-client';
14
- import { ExecutionRuntime } from './execution-runtime';
15
- import { ControlYourUiApi } from './control-your-ui-api';
16
- import { AnnotationWriter } from '../core/annotation/annotation-writer';
17
- import { logger } from '../lib/logger';
18
- import { TestStepState } from '../core/model/test-case-result-dto';
19
- import { AnnotationLevel } from './annotation-level';
20
- import { ControlUiClientError } from './client-error';
21
- import { envCredentials } from './read-environment-credentials';
22
- export class AskuiClient extends FluentCommand {
23
- constructor(clientArgs) {
24
- var _a;
25
- super();
26
- this.clientArgs = clientArgs;
27
- this.httpClient = new HttpClientGot(((_a = this.clientArgs) === null || _a === void 0 ? void 0 : _a.credentials) ? this.clientArgs.credentials : envCredentials());
28
- }
29
- get controlYourUiClient() {
30
- if (!this._controlYourUiClient) {
31
- this._controlYourUiClient = new ControlYourUiClient(this.clientArgsWithDefaults.controlServerUrl);
32
- }
33
- return this._controlYourUiClient;
34
- }
35
- get clientArgsWithDefaults() {
36
- const defaults = {
37
- controlServerUrl: 'http://localhost:6769',
38
- controlYourUiApi: 'https://inference.askui.com',
39
- annotationLevel: AnnotationLevel.DISABLED,
40
- };
41
- return Object.assign(defaults, this.clientArgs);
42
- }
43
- get api() {
44
- return new ControlYourUiApi(this.clientArgsWithDefaults.controlYourUiApi, this.httpClient);
45
- }
46
- get executionRuntime() {
47
- return new ExecutionRuntime(this.controlYourUiClient, this.api);
48
- }
49
- annotateByDefault(testStepState, customElements = []) {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- if ((testStepState === TestStepState.FAILED
52
- && this.clientArgsWithDefaults.annotationLevel === AnnotationLevel.DISABLED)
53
- || (testStepState === TestStepState.PASSED
54
- && this.clientArgsWithDefaults.annotationLevel !== AnnotationLevel.ALL)) {
55
- return;
56
- }
57
- yield this.annotate({
58
- customElements,
59
- fileNamePrefix: `${testStepState.toLowerCase()}_testStep_annotation`,
60
- });
61
- });
62
- }
63
- connect() {
64
- return __awaiter(this, void 0, void 0, function* () {
65
- const connectionState = yield this.controlYourUiClient.connect();
66
- return connectionState;
67
- });
68
- }
69
- annotate(annotationRequest = {}) {
70
- return __awaiter(this, void 0, void 0, function* () {
71
- const annotation = yield this.executionRuntime.annotateImage(annotationRequest.imagePath, annotationRequest.customElements);
72
- AnnotationWriter.write(annotation.toHtml(), annotationRequest.outputPath, annotationRequest.fileNamePrefix);
73
- return annotation;
74
- });
75
- }
76
- annotateInteractively() {
77
- return __awaiter(this, void 0, void 0, function* () {
78
- try {
79
- yield this.executionRuntime.annotateInteractively();
80
- }
81
- catch (err) {
82
- logger.error(err);
83
- }
84
- });
85
- }
86
- exec(instruction, customElementJson) {
87
- return __awaiter(this, void 0, void 0, function* () {
88
- let customElements = [];
89
- if (customElementJson !== undefined) {
90
- customElements = yield CustomElement.fromJsonListWithImagePathOrImage(customElementJson);
91
- }
92
- try {
93
- yield this.executionRuntime.executeTestStep({
94
- instruction,
95
- customElements,
96
- });
97
- yield this.annotateByDefault(TestStepState.PASSED, customElements);
98
- return yield Promise.resolve();
99
- }
100
- catch (error) {
101
- yield this.annotateByDefault(TestStepState.FAILED, customElements);
102
- return Promise.reject(new ControlUiClientError(`A problem occures while executing the instruction: ${instruction}. Reason ${error}`));
103
- }
104
- });
105
- }
106
- /**
107
- * closes the connection to the controlui-server`.
108
- */
109
- close() {
110
- this.controlYourUiClient.close();
111
- }
112
- }
@@ -1,8 +0,0 @@
1
- import { ControlUiServerArgs } from './control-ui-server-args';
2
- export declare class AskuiControlServer {
3
- private args?;
4
- private server;
5
- constructor(args?: ControlUiServerArgs | undefined);
6
- start(timeoutInSeconds?: number): Promise<void>;
7
- stop(forceStop?: boolean): Promise<void>;
8
- }
@@ -1,21 +0,0 @@
1
- import { LogLevels } from '../shared/log-levels';
2
- export interface ControlUiServerArgs {
3
- readonly display?: number;
4
- readonly binaryVersion?: string;
5
- readonly port?: number;
6
- readonly host?: string;
7
- readonly minimize?: boolean;
8
- readonly overWriteBinary?: boolean;
9
- readonly logLevel?: LogLevels;
10
- readonly logFilePath?: string;
11
- }
12
- export interface ControlUiServerArgsWithDefaults extends ControlUiServerArgs {
13
- readonly display: number;
14
- readonly binaryVersion: string;
15
- readonly overWriteBinary: boolean;
16
- readonly port: number;
17
- readonly host: string;
18
- readonly logLevel?: LogLevels;
19
- }
20
- export declare function createArgsWithDefaults(args?: ControlUiServerArgs): ControlUiServerArgsWithDefaults;
21
- export declare function createCliFlagsFromArgs(args: ControlUiServerArgsWithDefaults): string[];
@@ -1,6 +0,0 @@
1
- import { ControlUiServerFacade } from './control-ui-server-facade';
2
- export declare class ControlUiServerDarwin extends ControlUiServerFacade {
3
- protected makeBinaryExecutable(): void;
4
- protected getStartingCommand(): string;
5
- private makeDiskImageExecutable;
6
- }
@@ -1,16 +0,0 @@
1
- import { ControlUiServerArgs, ControlUiServerArgsWithDefaults } from './control-ui-server-args';
2
- export declare abstract class ControlUiServerFacade {
3
- protected binaryPath: string;
4
- protected serverLogFile: string;
5
- protected readonly DefaultmaxWaitingForStartingInMs: number;
6
- start(args?: ControlUiServerArgs, maxWaitingForStartingInSeconds?: number): Promise<void>;
7
- stop(args?: ControlUiServerArgs, forceStop?: boolean): Promise<void>;
8
- protected serverLogFilePath(args?: ControlUiServerArgsWithDefaults): ControlUiServerArgsWithDefaults;
9
- protected killPort(port: number, forceStop?: boolean): Promise<void>;
10
- protected getStartingCommand(): string;
11
- protected makeBinaryExecutable(): void;
12
- protected waitUntilStarted(args: ControlUiServerArgsWithDefaults, maxWaitingForStartingInSeconds?: number): Promise<void>;
13
- private isBinaryValid;
14
- private getBinary;
15
- private startWithDefaults;
16
- }
@@ -1,4 +0,0 @@
1
- import { ControlUiServerFacade } from './control-ui-server-facade';
2
- export declare class ControlUiServerLinux extends ControlUiServerFacade {
3
- protected makeBinaryExecutable(): void;
4
- }
@@ -1,9 +0,0 @@
1
- import { exec } from 'child_process';
2
- import { ControlUiServerFacade } from './control-ui-server-facade';
3
- import { logger } from './logger';
4
- export class ControlUiServerLinux extends ControlUiServerFacade {
5
- // eslint-disable-next-line class-methods-use-this
6
- makeBinaryExecutable() {
7
- exec(`chmod +x ${this.binaryPath}`, (_exception, stdout) => logger.debug(stdout));
8
- }
9
- }
@@ -1,3 +0,0 @@
1
- import { ControlUiServerFacade } from './control-ui-server-facade';
2
- export declare class ControlUiServerWin32 extends ControlUiServerFacade {
3
- }
@@ -1,3 +0,0 @@
1
- import { ControlUiServerFacade } from './control-ui-server-facade';
2
- export class ControlUiServerWin32 extends ControlUiServerFacade {
3
- }
@@ -1,3 +0,0 @@
1
- import { ImageResizingError } from './image-resizing-base-error';
2
- export declare class InvalidBase64Image extends ImageResizingError {
3
- }
@@ -1,3 +0,0 @@
1
- import { ImageResizingError } from './image-resizing-base-error';
2
- export class InvalidBase64Image extends ImageResizingError {
3
- }