askui 0.30.0 → 0.32.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 (79) hide show
  1. package/dist/cjs/core/cache/cache-config.d.ts +5 -0
  2. package/dist/cjs/core/cache/cache-config.js +2 -0
  3. package/dist/cjs/core/cache/cache-entry-reference.d.ts +7 -0
  4. package/dist/cjs/core/cache/cache-entry-reference.js +20 -0
  5. package/dist/cjs/core/cache/cache-entry.d.ts +11 -0
  6. package/dist/cjs/core/cache/cache-entry.js +47 -0
  7. package/dist/cjs/core/cache/cache-interface.d.ts +11 -0
  8. package/dist/cjs/core/cache/cache-interface.js +2 -0
  9. package/dist/cjs/core/cache/cache-manager.d.ts +24 -0
  10. package/dist/cjs/core/cache/cache-manager.js +145 -0
  11. package/dist/cjs/core/cache/cahe-file.d.ts +19 -0
  12. package/dist/cjs/core/cache/cahe-file.js +128 -0
  13. package/dist/cjs/core/cache/dummy-cache-manager.d.ts +12 -0
  14. package/dist/cjs/core/cache/dummy-cache-manager.js +27 -0
  15. package/dist/cjs/core/cache/image-reference.d.ts +10 -0
  16. package/dist/cjs/core/cache/image-reference.js +40 -0
  17. package/dist/cjs/core/cache/index.d.ts +7 -0
  18. package/dist/cjs/core/cache/index.js +13 -0
  19. package/dist/cjs/core/model/annotation-result/boundary-box.js +1 -1
  20. package/dist/cjs/core/model/custom-element.d.ts +1 -0
  21. package/dist/cjs/core/model/custom-element.js +3 -0
  22. package/dist/cjs/core/ui-control-commands/action.d.ts +1 -0
  23. package/dist/cjs/core/ui-control-commands/action.js +10 -2
  24. package/dist/cjs/core/ui-control-commands/control-command.d.ts +1 -0
  25. package/dist/cjs/core/ui-control-commands/control-command.js +7 -0
  26. package/dist/cjs/execution/dsl.d.ts +12 -5
  27. package/dist/cjs/execution/dsl.js +30 -15
  28. package/dist/cjs/execution/execution-runtime.d.ts +1 -1
  29. package/dist/cjs/execution/execution-runtime.js +21 -17
  30. package/dist/cjs/execution/inference-client.d.ts +5 -3
  31. package/dist/cjs/execution/inference-client.js +22 -3
  32. package/dist/cjs/execution/ui-control-client-dependency-builder.js +6 -1
  33. package/dist/cjs/execution/ui-control-client.d.ts +2 -1
  34. package/dist/cjs/execution/ui-control-client.js +28 -11
  35. package/dist/cjs/execution/ui-controller-client-interface.d.ts +2 -0
  36. package/dist/cjs/utils/base_64_image/base-64-image.d.ts +2 -0
  37. package/dist/cjs/utils/base_64_image/base-64-image.js +27 -4
  38. package/dist/cjs/utils/http/http-client-got.d.ts +15 -0
  39. package/dist/cjs/utils/http/http-client-got.js +59 -11
  40. package/dist/esm/core/cache/cache-config.d.ts +5 -0
  41. package/dist/esm/core/cache/cache-config.js +1 -0
  42. package/dist/esm/core/cache/cache-entry-reference.d.ts +7 -0
  43. package/dist/esm/core/cache/cache-entry-reference.js +16 -0
  44. package/dist/esm/core/cache/cache-entry.d.ts +11 -0
  45. package/dist/esm/core/cache/cache-entry.js +43 -0
  46. package/dist/esm/core/cache/cache-interface.d.ts +11 -0
  47. package/dist/esm/core/cache/cache-interface.js +1 -0
  48. package/dist/esm/core/cache/cache-manager.d.ts +24 -0
  49. package/dist/esm/core/cache/cache-manager.js +141 -0
  50. package/dist/esm/core/cache/cahe-file.d.ts +19 -0
  51. package/dist/esm/core/cache/cahe-file.js +121 -0
  52. package/dist/esm/core/cache/dummy-cache-manager.d.ts +12 -0
  53. package/dist/esm/core/cache/dummy-cache-manager.js +23 -0
  54. package/dist/esm/core/cache/image-reference.d.ts +10 -0
  55. package/dist/esm/core/cache/image-reference.js +36 -0
  56. package/dist/esm/core/cache/index.d.ts +7 -0
  57. package/dist/esm/core/cache/index.js +5 -0
  58. package/dist/esm/core/model/annotation-result/boundary-box.js +1 -1
  59. package/dist/esm/core/model/custom-element.d.ts +1 -0
  60. package/dist/esm/core/model/custom-element.js +3 -0
  61. package/dist/esm/core/ui-control-commands/action.d.ts +1 -0
  62. package/dist/esm/core/ui-control-commands/action.js +10 -2
  63. package/dist/esm/core/ui-control-commands/control-command.d.ts +1 -0
  64. package/dist/esm/core/ui-control-commands/control-command.js +7 -0
  65. package/dist/esm/execution/dsl.d.ts +12 -5
  66. package/dist/esm/execution/dsl.js +30 -15
  67. package/dist/esm/execution/execution-runtime.d.ts +1 -1
  68. package/dist/esm/execution/execution-runtime.js +21 -17
  69. package/dist/esm/execution/inference-client.d.ts +5 -3
  70. package/dist/esm/execution/inference-client.js +22 -3
  71. package/dist/esm/execution/ui-control-client-dependency-builder.js +6 -1
  72. package/dist/esm/execution/ui-control-client.d.ts +2 -1
  73. package/dist/esm/execution/ui-control-client.js +28 -11
  74. package/dist/esm/execution/ui-controller-client-interface.d.ts +2 -0
  75. package/dist/esm/utils/base_64_image/base-64-image.d.ts +2 -0
  76. package/dist/esm/utils/base_64_image/base-64-image.js +27 -4
  77. package/dist/esm/utils/http/http-client-got.d.ts +15 -0
  78. package/dist/esm/utils/http/http-client-got.js +36 -8
  79. package/package.json +4 -2
@@ -7,11 +7,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import got from 'got';
10
+ import got, { HTTPError, } from 'got';
11
11
  import { CookieJar } from 'tough-cookie';
12
12
  import { logger } from '../../lib';
13
13
  import { Credentials } from './credentials';
14
14
  import { httpClientErrorHandler } from './custom-errors';
15
+ import { UnkownHttpClientError } from './custom-errors/unkown-http-client-error';
15
16
  function buildRetryLog(requestUrl, errorCode, statusCode, errorMessage, delayInMs, delayReason, attemptCount) {
16
17
  const failureReasons = [];
17
18
  if (statusCode !== undefined && statusCode >= 400) {
@@ -40,6 +41,16 @@ export class HttpClientGot {
40
41
  const gotExtendOptions = this.buildGotExtendOptions(proxyAgents);
41
42
  this.askuiGot = got.extend(gotExtendOptions);
42
43
  }
44
+ /**
45
+ * Configures got with retry behavior for transient server errors.
46
+ *
47
+ * Got retries requests that fail with retryable status codes
48
+ * (500, 502, 503, 504, etc.) up to `limit` times using exponential backoff.
49
+ *
50
+ * POST requests are only retried if their URL is registered in `urlsToRetry`
51
+ * (see `shouldRetryOnError`), to avoid retrying non-idempotent calls
52
+ * to unknown endpoints.
53
+ */
43
54
  buildGotExtendOptions(proxyAgents) {
44
55
  const gotExtendOptions = {
45
56
  retry: {
@@ -87,6 +98,11 @@ export class HttpClientGot {
87
98
  }
88
99
  return gotExtendOptions;
89
100
  }
101
+ /**
102
+ * Only retry POST requests if the URL is explicitly registered in `urlsToRetry`
103
+ * (populated by InferenceClient with inference endpoint URLs).
104
+ * Non-POST requests (GET, PUT, etc.) are always retried.
105
+ */
90
106
  shouldRetryOnError(error) {
91
107
  var _a;
92
108
  return (((_a = error.request) === null || _a === void 0 ? void 0 : _a.options.method) !== 'POST'
@@ -112,19 +128,31 @@ export class HttpClientGot {
112
128
  }
113
129
  post(url, data) {
114
130
  return __awaiter(this, void 0, void 0, function* () {
131
+ // Note: We intentionally do NOT set `throwHttpErrors: false` here.
132
+ // Got must throw on non-2xx responses so that its built-in retry mechanism
133
+ // (configured in buildGotExtendOptions) can kick in for transient server errors
134
+ // (500, 502, 503, 504). After all retries are exhausted, got throws an HTTPError
135
+ // which we catch below and convert into our custom error hierarchy.
115
136
  const options = this.injectHeadersAndCookies(url, {
116
137
  json: data,
117
138
  responseType: 'json',
118
- throwHttpErrors: false,
119
139
  });
120
- const { body, statusCode, headers } = yield this.askuiGot.post(url, options);
121
- if (headers['deprecation'] !== undefined) {
122
- logger.warn(headers['deprecation']);
140
+ try {
141
+ const { body, headers } = yield this.askuiGot.post(url, options);
142
+ if (headers['deprecation'] !== undefined) {
143
+ logger.warn(headers['deprecation']);
144
+ }
145
+ return { body, headers };
123
146
  }
124
- if (statusCode !== 200) {
125
- throw httpClientErrorHandler(statusCode, JSON.stringify(body));
147
+ catch (error) {
148
+ // After got exhausts all retries, it throws HTTPError.
149
+ // Convert it to our custom error types (ServerHttpClientError,
150
+ // AuthenticationHttpClientError, etc.) for consistent error handling.
151
+ if (error instanceof HTTPError) {
152
+ throw httpClientErrorHandler(error.response.statusCode, error.response.body);
153
+ }
154
+ throw new UnkownHttpClientError(error instanceof Error ? error.message : String(error));
126
155
  }
127
- return { body, headers };
128
156
  });
129
157
  }
130
158
  get(url_1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "askui",
3
- "version": "0.30.0",
3
+ "version": "0.32.0",
4
4
  "license": "MIT",
5
5
  "author": "askui GmbH <info@askui.com> (http://www.askui.com/)",
6
6
  "description": "Reliable, automated end-to-end-testing that depends on what is shown on your screen instead of the technology you are running on",
@@ -42,7 +42,8 @@
42
42
  "test": "cross-env NODE_EXTRA_CA_CERTS='test/proxy/certs/unit_test.pem' jest '/src'",
43
43
  "postinstall": "node -e \"require('./bin/askui-postinstall')\"",
44
44
  "release:prerelease": "cross-env HUSKY=0 release-it --preRelease=next",
45
- "release": "cross-env HUSKY=0 release-it"
45
+ "release": "cross-env HUSKY=0 release-it",
46
+ "generate:SBOM": "cyclonedx-npm package.json --omit dev --gather-license-texts --output-file bom.json --output-format JSON"
46
47
  },
47
48
  "files": [
48
49
  "dist/cjs/",
@@ -73,6 +74,7 @@
73
74
  "yup": "1.4.0"
74
75
  },
75
76
  "devDependencies": {
77
+ "@cyclonedx/cyclonedx-npm": "^4.1.2",
76
78
  "@release-it/bumper": "6.0.1",
77
79
  "@release-it/conventional-changelog": "8.0.2",
78
80
  "@types/fs-extra": "11.0.4",