askui 0.3.1 → 0.4.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.
- package/README.md +6 -12
- package/dist/cjs/core/annotation/annotation-writer.js +2 -4
- package/dist/cjs/core/annotation/annotation.d.ts +3 -4
- package/dist/cjs/core/annotation/annotation.js +5 -4
- package/dist/cjs/core/inference-response/inference-response.d.ts +15 -0
- package/dist/cjs/core/inference-response/inference-response.js +25 -0
- package/dist/cjs/core/model/annotation-result/boundary-box.d.ts +23 -0
- package/dist/cjs/core/model/annotation-result/boundary-box.js +27 -0
- package/dist/cjs/core/model/annotation-result/detected-element.d.ts +9 -3
- package/dist/cjs/core/model/annotation-result/detected-element.js +10 -4
- package/dist/cjs/core/ui-control-commands/control-command.d.ts +1 -1
- package/dist/cjs/core/ui-control-commands/control-command.js +2 -1
- package/dist/cjs/core/ui-control-commands/index.d.ts +1 -0
- package/dist/cjs/core/ui-control-commands/index.js +3 -1
- package/dist/cjs/execution/dsl.d.ts +691 -2
- package/dist/cjs/execution/dsl.js +968 -7
- package/dist/cjs/execution/dsl.spec.js +4 -4
- package/dist/cjs/execution/execution-runtime.d.ts +2 -0
- package/dist/cjs/execution/execution-runtime.js +11 -1
- package/dist/cjs/execution/inference-client.d.ts +3 -0
- package/dist/cjs/execution/inference-client.js +28 -12
- package/dist/cjs/execution/inference-response-error.d.ts +2 -0
- package/dist/cjs/execution/inference-response-error.js +6 -0
- package/dist/cjs/execution/ui-control-client.d.ts +5 -3
- package/dist/cjs/execution/ui-control-client.js +12 -3
- package/dist/cjs/utils/analytics/analytics.d.ts +1 -0
- package/dist/cjs/utils/analytics/analytics.js +8 -0
- package/dist/cjs/utils/http/http-client-got.d.ts +3 -2
- package/dist/cjs/utils/http/http-client-got.js +16 -6
- package/dist/esm/core/annotation/annotation-writer.js +2 -4
- package/dist/esm/core/annotation/annotation.d.ts +3 -4
- package/dist/esm/core/annotation/annotation.js +5 -4
- package/dist/esm/core/inference-response/inference-response.d.ts +15 -0
- package/dist/esm/core/inference-response/inference-response.js +21 -0
- package/dist/esm/core/model/annotation-result/boundary-box.d.ts +23 -0
- package/dist/esm/core/model/annotation-result/boundary-box.js +27 -0
- package/dist/esm/core/model/annotation-result/detected-element.d.ts +9 -3
- package/dist/esm/core/model/annotation-result/detected-element.js +10 -4
- package/dist/esm/core/ui-control-commands/control-command.d.ts +1 -1
- package/dist/esm/core/ui-control-commands/control-command.js +2 -1
- package/dist/esm/core/ui-control-commands/index.d.ts +1 -0
- package/dist/esm/core/ui-control-commands/index.js +1 -0
- package/dist/esm/execution/dsl.d.ts +691 -2
- package/dist/esm/execution/dsl.js +962 -6
- package/dist/esm/execution/dsl.spec.js +4 -4
- package/dist/esm/execution/execution-runtime.d.ts +2 -0
- package/dist/esm/execution/execution-runtime.js +11 -1
- package/dist/esm/execution/inference-client.d.ts +3 -0
- package/dist/esm/execution/inference-client.js +29 -13
- package/dist/esm/execution/inference-response-error.d.ts +2 -0
- package/dist/esm/execution/inference-response-error.js +2 -0
- package/dist/esm/execution/ui-control-client.d.ts +5 -3
- package/dist/esm/execution/ui-control-client.js +13 -4
- package/dist/esm/utils/analytics/analytics.d.ts +1 -0
- package/dist/esm/utils/analytics/analytics.js +8 -0
- package/dist/esm/utils/http/http-client-got.d.ts +3 -2
- package/dist/esm/utils/http/http-client-got.js +16 -6
- package/package.json +2 -1
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { FluentCommand } from './dsl';
|
|
11
11
|
class TestCommand extends FluentCommand {
|
|
12
12
|
// eslint-disable-next-line class-methods-use-this
|
|
13
|
-
|
|
13
|
+
fluentCommandExecutor(instruction, customElements) {
|
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
// eslint-disable-next-line no-console
|
|
16
16
|
console.log(`${instruction} ${customElements}`);
|
|
@@ -22,14 +22,14 @@ describe('DSL', () => {
|
|
|
22
22
|
describe('custom element', () => {
|
|
23
23
|
test('should call exec function with zero custom element', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
24
|
const underTest = new TestCommand();
|
|
25
|
-
const testCommandSpy = jest.spyOn(underTest, '
|
|
25
|
+
const testCommandSpy = jest.spyOn(underTest, 'fluentCommandExecutor');
|
|
26
26
|
yield underTest.click().button()
|
|
27
27
|
.exec();
|
|
28
28
|
expect(testCommandSpy).toHaveBeenCalledWith('Click on button', []);
|
|
29
29
|
}));
|
|
30
30
|
test('should call exec function with one custom element', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
31
|
const underTest = new TestCommand();
|
|
32
|
-
const testCommandSpy = jest.spyOn(underTest, '
|
|
32
|
+
const testCommandSpy = jest.spyOn(underTest, 'fluentCommandExecutor');
|
|
33
33
|
yield underTest.click().customElement({
|
|
34
34
|
customImage: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==',
|
|
35
35
|
imageCompareFormat: 'grayscale',
|
|
@@ -44,7 +44,7 @@ describe('DSL', () => {
|
|
|
44
44
|
}));
|
|
45
45
|
test('should call exec function with two custom element', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
46
|
const underTest = new TestCommand();
|
|
47
|
-
const testCommandSpy = jest.spyOn(underTest, '
|
|
47
|
+
const testCommandSpy = jest.spyOn(underTest, 'fluentCommandExecutor');
|
|
48
48
|
yield underTest.click().customElement({
|
|
49
49
|
customImage: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z/C/HgAGgwJ/lK3Q6wAAAABJRU5ErkJggg==',
|
|
50
50
|
imageCompareFormat: 'grayscale',
|
|
@@ -3,6 +3,7 @@ import { UiControllerClient } from './ui-controller-client';
|
|
|
3
3
|
import { InferenceClient } from './inference-client';
|
|
4
4
|
import { Annotation } from '../core/annotation/annotation';
|
|
5
5
|
import { CustomElementJson } from '../core/model/test-case-dto/custom-element-json';
|
|
6
|
+
import { DetectedElement } from '../core/model/annotation-result/detected-element';
|
|
6
7
|
export declare class ExecutionRuntime {
|
|
7
8
|
private uiControllerClient;
|
|
8
9
|
private inferenceClient;
|
|
@@ -25,5 +26,6 @@ export declare class ExecutionRuntime {
|
|
|
25
26
|
private predictCommand;
|
|
26
27
|
annotateInteractively(): Promise<void>;
|
|
27
28
|
takeScreenshotIfImageisNotProvided(imagePath?: string): Promise<string>;
|
|
29
|
+
getDetectedElements(instruction: string, customElementJson?: CustomElementJson[]): Promise<DetectedElement[]>;
|
|
28
30
|
annotateImage(imagePath?: string, customElementJson?: CustomElementJson[]): Promise<Annotation>;
|
|
29
31
|
}
|
|
@@ -116,7 +116,7 @@ export class ExecutionRuntime {
|
|
|
116
116
|
annotateInteractively() {
|
|
117
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
118
118
|
const annotationResponse = yield this.annotateImage();
|
|
119
|
-
yield this.uiControllerClient.annotateInteractively(annotationResponse.
|
|
119
|
+
yield this.uiControllerClient.annotateInteractively(annotationResponse.detected_elements, annotationResponse.image);
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
122
|
takeScreenshotIfImageisNotProvided(imagePath) {
|
|
@@ -132,6 +132,16 @@ export class ExecutionRuntime {
|
|
|
132
132
|
return base64Image;
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
|
+
getDetectedElements(instruction, customElementJson) {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
let customElements = [];
|
|
138
|
+
const base64Image = yield this.takeScreenshotIfImageisNotProvided();
|
|
139
|
+
if (customElementJson !== undefined) {
|
|
140
|
+
customElements = yield CustomElement.fromJsonListWithImagePathOrImage(customElementJson);
|
|
141
|
+
}
|
|
142
|
+
return this.inferenceClient.getDetectedElements(instruction, base64Image, customElements);
|
|
143
|
+
});
|
|
144
|
+
}
|
|
135
145
|
annotateImage(imagePath, customElementJson) {
|
|
136
146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
137
147
|
let customElements = [];
|
|
@@ -2,6 +2,7 @@ import { HttpClientGot } from '../utils/http/http-client-got';
|
|
|
2
2
|
import { ControlCommand } from '../core/ui-control-commands';
|
|
3
3
|
import { CustomElement } from '../core/model/test-case-dto';
|
|
4
4
|
import { Annotation } from '../core/annotation/annotation';
|
|
5
|
+
import { DetectedElement } from '../core/model/annotation-result/detected-element';
|
|
5
6
|
export declare class InferenceClient {
|
|
6
7
|
baseUrl: string;
|
|
7
8
|
httpClient: HttpClientGot;
|
|
@@ -11,6 +12,8 @@ export declare class InferenceClient {
|
|
|
11
12
|
constructor(baseUrl: string, httpClient: HttpClientGot, workspaceId?: string | undefined, apiVersion?: string);
|
|
12
13
|
isImageRequired(instruction: string): Promise<boolean>;
|
|
13
14
|
private resizeIfNeeded;
|
|
15
|
+
inference(customElements?: CustomElement[], image?: string, instruction?: string): Promise<ControlCommand | Annotation>;
|
|
14
16
|
predictControlCommand(instruction: string, customElements?: CustomElement[], image?: string): Promise<ControlCommand>;
|
|
17
|
+
getDetectedElements(instruction: string, image: string, customElements?: CustomElement[]): Promise<DetectedElement[]>;
|
|
15
18
|
predictImageAnnotation(image: string, customElements?: CustomElement[]): Promise<Annotation>;
|
|
16
19
|
}
|
|
@@ -8,11 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import urljoin from 'url-join';
|
|
11
|
-
import { ControlCommand } from '../core/ui-control-commands';
|
|
11
|
+
import { ControlCommand, InferenceResponse } from '../core/ui-control-commands';
|
|
12
12
|
import { Annotation } from '../core/annotation/annotation';
|
|
13
13
|
import { resizeBase64ImageWithSameRatio } from '../utils/transformations';
|
|
14
|
+
import { InferenceResponseError } from './inference-response-error';
|
|
14
15
|
export class InferenceClient {
|
|
15
|
-
constructor(baseUrl, httpClient, workspaceId, apiVersion = '
|
|
16
|
+
constructor(baseUrl, httpClient, workspaceId, apiVersion = 'v3') {
|
|
16
17
|
this.baseUrl = baseUrl;
|
|
17
18
|
this.httpClient = httpClient;
|
|
18
19
|
this.workspaceId = workspaceId;
|
|
@@ -39,7 +40,7 @@ export class InferenceClient {
|
|
|
39
40
|
return resizeBase64ImageWithSameRatio(image);
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
|
-
|
|
43
|
+
inference(customElements = [], image, instruction) {
|
|
43
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
45
|
const resizedImage = yield this.resizeIfNeeded(customElements, image);
|
|
45
46
|
const httpBody = {
|
|
@@ -47,21 +48,36 @@ export class InferenceClient {
|
|
|
47
48
|
instruction,
|
|
48
49
|
customElements,
|
|
49
50
|
};
|
|
50
|
-
const url = urljoin(this.url, '
|
|
51
|
+
const url = urljoin(this.url, 'inference');
|
|
51
52
|
const httpResponse = yield this.httpClient.post(url, httpBody);
|
|
52
|
-
return
|
|
53
|
+
return InferenceResponse.fromJson(httpResponse, resizedImage.resizeRatio, image);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
predictControlCommand(instruction, customElements = [], image) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const inferenceResponse = yield this.inference(customElements, image, instruction);
|
|
59
|
+
if (!(inferenceResponse instanceof ControlCommand)) {
|
|
60
|
+
throw new InferenceResponseError('Internal Error. Can not execute command');
|
|
61
|
+
}
|
|
62
|
+
return inferenceResponse;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
getDetectedElements(instruction, image, customElements = []) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
const inferenceResponse = yield this.inference(customElements, image, instruction);
|
|
68
|
+
if (!(inferenceResponse instanceof Annotation)) {
|
|
69
|
+
throw new InferenceResponseError('Internal Error. Unable to get the detected elements');
|
|
70
|
+
}
|
|
71
|
+
return inferenceResponse.detected_elements;
|
|
53
72
|
});
|
|
54
73
|
}
|
|
55
74
|
predictImageAnnotation(image, customElements = []) {
|
|
56
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const url = urljoin(this.url, 'annotate', '?format=json');
|
|
63
|
-
const httpResponse = yield this.httpClient.post(url, httpBody);
|
|
64
|
-
return Annotation.fromJson(Object.assign(Object.assign({}, httpResponse), { image }), resizedImage.resizeRatio);
|
|
76
|
+
const inferenceResponse = yield this.inference(customElements, image);
|
|
77
|
+
if (!(inferenceResponse instanceof Annotation)) {
|
|
78
|
+
throw new InferenceResponseError('Internal Error. Can not execute annotation');
|
|
79
|
+
}
|
|
80
|
+
return inferenceResponse;
|
|
65
81
|
});
|
|
66
82
|
}
|
|
67
83
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { CustomElementJson } from '../core/model/test-case-dto';
|
|
2
|
-
import { Exec, Executable,
|
|
2
|
+
import { Exec, Executable, FluentFilters, ApiCommands } 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';
|
|
6
6
|
import { ClientArgs } from './ui-controller-client-interface';
|
|
7
|
-
|
|
7
|
+
import { DetectedElement } from '../core/model/annotation-result/detected-element';
|
|
8
|
+
export declare class UiControlClient extends ApiCommands {
|
|
8
9
|
private httpClient;
|
|
9
10
|
private clientArgs;
|
|
10
11
|
private workspaceId?;
|
|
@@ -19,7 +20,8 @@ export declare class UiControlClient extends FluentCommand {
|
|
|
19
20
|
annotate(annotationRequest?: AnnotationRequest): Promise<Annotation>;
|
|
20
21
|
annotateInteractively(): Promise<void>;
|
|
21
22
|
private escapeSeparatorString;
|
|
22
|
-
|
|
23
|
+
fluentCommandExecutor(instruction: string, customElementJson?: CustomElementJson[]): Promise<void>;
|
|
24
|
+
getterExecutor(instruction: string, customElementJson?: CustomElementJson[]): Promise<DetectedElement[]>;
|
|
23
25
|
private secretText;
|
|
24
26
|
/**
|
|
25
27
|
* Types a text inside the filtered element.
|
|
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { CustomElement } from '../core/model/test-case-dto';
|
|
11
|
-
import {
|
|
11
|
+
import { ApiCommands, Separators, } from './dsl';
|
|
12
12
|
import { HttpClientGot } from '../utils/http/http-client-got';
|
|
13
13
|
import { UiControllerClient } from './ui-controller-client';
|
|
14
14
|
import { ExecutionRuntime } from './execution-runtime';
|
|
@@ -21,7 +21,7 @@ import { UiControlClientError } from './ui-control-client-error';
|
|
|
21
21
|
import { envCredentials } from './read-environment-credentials';
|
|
22
22
|
import { Analytics } from '../utils/analytics';
|
|
23
23
|
const getClientArgsWithDefaults = (clientArgs = {}) => (Object.assign({ uiControllerUrl: 'http://127.0.0.1:6769', inferenceServerUrl: 'https://inference.askui.com', annotationLevel: AnnotationLevel.DISABLED }, clientArgs));
|
|
24
|
-
export class UiControlClient extends
|
|
24
|
+
export class UiControlClient extends ApiCommands {
|
|
25
25
|
constructor(httpClient, clientArgs, workspaceId) {
|
|
26
26
|
super();
|
|
27
27
|
this.httpClient = httpClient;
|
|
@@ -33,9 +33,10 @@ export class UiControlClient extends FluentCommand {
|
|
|
33
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
34
|
const analytics = new Analytics();
|
|
35
35
|
const analyticsHeaders = yield analytics.getAnalyticsHeaders();
|
|
36
|
+
const analyticsCookies = yield analytics.getAnalyticsCookies();
|
|
36
37
|
const cas = getClientArgsWithDefaults(clientArgs);
|
|
37
38
|
const credentialArgs = cas.credentials || envCredentials();
|
|
38
|
-
const httpClient = new HttpClientGot(credentialArgs === null || credentialArgs === void 0 ? void 0 : credentialArgs.token, analyticsHeaders);
|
|
39
|
+
const httpClient = new HttpClientGot(credentialArgs === null || credentialArgs === void 0 ? void 0 : credentialArgs.token, analyticsHeaders, analyticsCookies);
|
|
39
40
|
return new UiControlClient(httpClient, cas, credentialArgs === null || credentialArgs === void 0 ? void 0 : credentialArgs.workspaceId);
|
|
40
41
|
});
|
|
41
42
|
}
|
|
@@ -92,7 +93,7 @@ export class UiControlClient extends FluentCommand {
|
|
|
92
93
|
escapeSeparatorString(instruction) {
|
|
93
94
|
return instruction.split(Separators.STRING).join('"');
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
+
fluentCommandExecutor(instruction, customElementJson = []) {
|
|
96
97
|
return __awaiter(this, void 0, void 0, function* () {
|
|
97
98
|
const { secretText } = this;
|
|
98
99
|
const customElements = yield CustomElement.fromJsonListWithImagePathOrImage(customElementJson);
|
|
@@ -113,6 +114,14 @@ export class UiControlClient extends FluentCommand {
|
|
|
113
114
|
}
|
|
114
115
|
});
|
|
115
116
|
}
|
|
117
|
+
getterExecutor(instruction, customElementJson = []) {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
const customElements = yield CustomElement.fromJsonListWithImagePathOrImage(customElementJson);
|
|
120
|
+
const stringWithoutSeparators = this.escapeSeparatorString(instruction);
|
|
121
|
+
logger.debug(stringWithoutSeparators);
|
|
122
|
+
return this.executionRuntime.getDetectedElements(instruction, customElements);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
116
125
|
/**
|
|
117
126
|
* Types a text inside the filtered element.
|
|
118
127
|
*
|
|
@@ -28,4 +28,12 @@ export class Analytics {
|
|
|
28
28
|
return headers;
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
+
getAnalyticsCookies() {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const userID = yield this.userIdentifier.userId();
|
|
34
|
+
return {
|
|
35
|
+
'askui-user-id': userID,
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
}
|
|
31
39
|
}
|
|
@@ -2,10 +2,11 @@ import { OptionsOfJSONResponseBody } from 'got';
|
|
|
2
2
|
export declare class HttpClientGot {
|
|
3
3
|
readonly token?: string | undefined;
|
|
4
4
|
readonly customHeaders?: Record<string, string> | undefined;
|
|
5
|
+
private readonly cookies;
|
|
5
6
|
private headers;
|
|
6
|
-
constructor(token?: string | undefined, customHeaders?: Record<string, string> | undefined);
|
|
7
|
+
constructor(token?: string | undefined, customHeaders?: Record<string, string> | undefined, cookies?: Record<string, string>);
|
|
7
8
|
private initHeaders;
|
|
8
|
-
private
|
|
9
|
+
private injectHeadersAndCookies;
|
|
9
10
|
post<T>(url: string, data: Record<string | number | symbol, unknown>): Promise<T>;
|
|
10
11
|
get<T>(url: string, options?: OptionsOfJSONResponseBody): Promise<T>;
|
|
11
12
|
}
|
|
@@ -8,12 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import got from 'got';
|
|
11
|
+
import { CookieJar } from 'tough-cookie';
|
|
12
|
+
import { logger } from '../../lib';
|
|
11
13
|
import { Credentials } from './credentials';
|
|
12
14
|
import { httpClientErrorHandler } from './custom-errors';
|
|
13
15
|
export class HttpClientGot {
|
|
14
|
-
constructor(token, customHeaders) {
|
|
16
|
+
constructor(token, customHeaders, cookies = {}) {
|
|
15
17
|
this.token = token;
|
|
16
18
|
this.customHeaders = customHeaders;
|
|
19
|
+
this.cookies = cookies;
|
|
17
20
|
this.headers = {};
|
|
18
21
|
this.initHeaders(token, customHeaders);
|
|
19
22
|
}
|
|
@@ -21,13 +24,20 @@ export class HttpClientGot {
|
|
|
21
24
|
const credentials = token ? new Credentials(token) : undefined;
|
|
22
25
|
this.headers = Object.assign(Object.assign({}, (credentials ? { Authorization: `Basic ${credentials === null || credentials === void 0 ? void 0 : credentials.base64Encoded}` } : {})), customHeaders);
|
|
23
26
|
}
|
|
24
|
-
|
|
25
|
-
|
|
27
|
+
injectHeadersAndCookies(url, options) {
|
|
28
|
+
const cookieJar = new CookieJar();
|
|
29
|
+
Object.keys(this.cookies).map((key) => `${key}=${this.cookies[key]}`).forEach((cookie) => {
|
|
30
|
+
cookieJar.setCookieSync(cookie, url);
|
|
31
|
+
});
|
|
32
|
+
return Object.assign(Object.assign({}, options), { headers: this.headers, cookieJar });
|
|
26
33
|
}
|
|
27
34
|
post(url, data) {
|
|
28
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
-
const options = this.
|
|
30
|
-
const { body, statusCode } = yield got.post(url, options);
|
|
36
|
+
const options = this.injectHeadersAndCookies(url, { json: data, responseType: 'json', throwHttpErrors: false });
|
|
37
|
+
const { body, statusCode, headers } = yield got.post(url, options);
|
|
38
|
+
if (headers['deprecation'] !== undefined) {
|
|
39
|
+
logger.warn(headers['deprecation']);
|
|
40
|
+
}
|
|
31
41
|
if (statusCode !== 200) {
|
|
32
42
|
throw httpClientErrorHandler(statusCode, JSON.stringify(body));
|
|
33
43
|
}
|
|
@@ -36,7 +46,7 @@ export class HttpClientGot {
|
|
|
36
46
|
}
|
|
37
47
|
get(url, options = { responseType: 'json' }) {
|
|
38
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const response = yield got.get(url, this.
|
|
49
|
+
const response = yield got.get(url, this.injectHeadersAndCookies(url, options));
|
|
40
50
|
return response.body;
|
|
41
51
|
});
|
|
42
52
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "askui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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",
|
|
@@ -58,6 +58,7 @@
|
|
|
58
58
|
"pino": "7.8.1",
|
|
59
59
|
"pino-pretty": "7.5.3",
|
|
60
60
|
"sharp": "0.30.6",
|
|
61
|
+
"tough-cookie": "4.1.2",
|
|
61
62
|
"url-join": "4.0.1",
|
|
62
63
|
"wait-port": "0.2.9",
|
|
63
64
|
"ws": "7.4.4",
|