askui 0.2.5 → 0.2.7
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/dist/cjs/execution/credentials-args.d.ts +4 -0
- package/dist/cjs/execution/credentials-args.js +2 -0
- package/dist/cjs/execution/inference-client.d.ts +5 -2
- package/dist/cjs/execution/inference-client.js +7 -3
- package/dist/cjs/execution/read-environment-credentials.d.ts +1 -1
- package/dist/cjs/execution/read-environment-credentials.js +2 -4
- package/dist/cjs/execution/read-environment-credentials.spec.js +1 -2
- package/dist/cjs/execution/ui-control-client.d.ts +2 -1
- package/dist/cjs/execution/ui-control-client.js +7 -5
- package/dist/cjs/execution/ui-controller-client-interface.d.ts +1 -1
- package/dist/cjs/lib/ui-controller-darwin.js +3 -3
- package/dist/cjs/utils/http/credentials.d.ts +2 -8
- package/dist/cjs/utils/http/credentials.js +3 -6
- package/dist/cjs/utils/http/credentials.spec.js +2 -2
- package/dist/cjs/utils/http/http-client-got.d.ts +2 -3
- package/dist/cjs/utils/http/http-client-got.js +5 -5
- package/dist/esm/execution/credentials-args.d.ts +4 -0
- package/dist/esm/execution/credentials-args.js +1 -0
- package/dist/esm/execution/inference-client.d.ts +5 -2
- package/dist/esm/execution/inference-client.js +7 -3
- package/dist/esm/execution/read-environment-credentials.d.ts +1 -1
- package/dist/esm/execution/read-environment-credentials.js +2 -4
- package/dist/esm/execution/read-environment-credentials.spec.js +1 -2
- package/dist/esm/execution/ui-control-client.d.ts +2 -1
- package/dist/esm/execution/ui-control-client.js +7 -5
- package/dist/esm/execution/ui-controller-client-interface.d.ts +1 -1
- package/dist/esm/lib/ui-controller-darwin.js +3 -3
- package/dist/esm/utils/http/credentials.d.ts +2 -8
- package/dist/esm/utils/http/credentials.js +3 -6
- package/dist/esm/utils/http/credentials.spec.js +2 -2
- package/dist/esm/utils/http/http-client-got.d.ts +2 -3
- package/dist/esm/utils/http/http-client-got.js +5 -5
- package/package.json +1 -1
|
@@ -3,9 +3,12 @@ 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
5
|
export declare class InferenceClient {
|
|
6
|
-
|
|
6
|
+
baseUrl: string;
|
|
7
7
|
httpClient: HttpClientGot;
|
|
8
|
-
|
|
8
|
+
readonly workspaceId?: string | undefined;
|
|
9
|
+
apiVersion: string;
|
|
10
|
+
url: string;
|
|
11
|
+
constructor(baseUrl: string, httpClient: HttpClientGot, workspaceId?: string | undefined, apiVersion?: string);
|
|
9
12
|
isImageRequired(instruction: string): Promise<boolean>;
|
|
10
13
|
private resizeIfNeeded;
|
|
11
14
|
predictControlCommand(instruction: string, customElements?: CustomElement[], image?: string): Promise<ControlCommand>;
|
|
@@ -18,9 +18,13 @@ const ui_control_commands_1 = require("../core/ui-control-commands");
|
|
|
18
18
|
const annotation_1 = require("../core/annotation/annotation");
|
|
19
19
|
const transformations_1 = require("../utils/transformations");
|
|
20
20
|
class InferenceClient {
|
|
21
|
-
constructor(
|
|
22
|
-
this.
|
|
21
|
+
constructor(baseUrl, httpClient, workspaceId, apiVersion = 'v2') {
|
|
22
|
+
this.baseUrl = baseUrl;
|
|
23
23
|
this.httpClient = httpClient;
|
|
24
|
+
this.workspaceId = workspaceId;
|
|
25
|
+
this.apiVersion = apiVersion;
|
|
26
|
+
const versionedBaseUrl = (0, url_join_1.default)(this.baseUrl, 'api', this.apiVersion);
|
|
27
|
+
this.url = workspaceId ? (0, url_join_1.default)(versionedBaseUrl, 'workspaces', workspaceId) : versionedBaseUrl;
|
|
24
28
|
}
|
|
25
29
|
isImageRequired(instruction) {
|
|
26
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -49,7 +53,7 @@ class InferenceClient {
|
|
|
49
53
|
instruction,
|
|
50
54
|
customElements,
|
|
51
55
|
};
|
|
52
|
-
const url = (0, url_join_1.default)(this.url, '
|
|
56
|
+
const url = (0, url_join_1.default)(this.url, 'predict-command');
|
|
53
57
|
const httpResponse = yield this.httpClient.post(url, httpBody);
|
|
54
58
|
return ui_control_commands_1.ControlCommand.fromJson(httpResponse, resizedImage.resizeRatio);
|
|
55
59
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CredentialArgs } from '
|
|
1
|
+
import { CredentialArgs } from './credentials-args';
|
|
2
2
|
export declare function envCredentials(): CredentialArgs | undefined;
|
|
@@ -5,12 +5,10 @@ const lib_1 = require("../lib");
|
|
|
5
5
|
function envCredentials() {
|
|
6
6
|
const envToken = process.env['ASKUI_TOKEN'];
|
|
7
7
|
const envWorkspaceId = process.env['ASKUI_WORKSPACE_ID'];
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
lib_1.logger.info('Credentials are used from ENV variables: ASKUI_TOKEN, ASKUI_WORKSPACE_ID and ASKUI_EMAIL');
|
|
8
|
+
if (envToken && envWorkspaceId) {
|
|
9
|
+
lib_1.logger.info('Credentials are used from ENV variables: ASKUI_TOKEN and ASKUI_WORKSPACE_ID');
|
|
11
10
|
return {
|
|
12
11
|
workspaceId: envWorkspaceId,
|
|
13
|
-
email: envEmail,
|
|
14
12
|
token: envToken,
|
|
15
13
|
};
|
|
16
14
|
}
|
|
@@ -5,8 +5,7 @@ describe('envCredentials()', () => {
|
|
|
5
5
|
test('should read the credentials from the environment variables', () => {
|
|
6
6
|
process.env['ASKUI_TOKEN'] = 'token';
|
|
7
7
|
process.env['ASKUI_WORKSPACE_ID'] = 'id123';
|
|
8
|
-
process.env['ASKUI_EMAIL'] = 'name@tenant.com';
|
|
9
8
|
const credentialsFromTheEnv = (0, read_environment_credentials_1.envCredentials)();
|
|
10
|
-
expect(credentialsFromTheEnv).toStrictEqual({ workspaceId: 'id123',
|
|
9
|
+
expect(credentialsFromTheEnv).toStrictEqual({ workspaceId: 'id123', token: 'token' });
|
|
11
10
|
});
|
|
12
11
|
});
|
|
@@ -7,6 +7,7 @@ import { ClientArgs } from './ui-controller-client-interface';
|
|
|
7
7
|
export declare class UiControlClient extends FluentCommand {
|
|
8
8
|
private httpClient;
|
|
9
9
|
private clientArgs;
|
|
10
|
+
private workspaceId?;
|
|
10
11
|
private _uiControllerClient?;
|
|
11
12
|
private constructor();
|
|
12
13
|
static build(clientArgs?: ClientArgs): Promise<UiControlClient>;
|
|
@@ -74,7 +75,7 @@ export declare class UiControlClient extends FluentCommand {
|
|
|
74
75
|
*/
|
|
75
76
|
waitFor(delayInMs: number): Executable;
|
|
76
77
|
/**
|
|
77
|
-
*
|
|
78
|
+
* Closes the connection to the askui UI Controller
|
|
78
79
|
*/
|
|
79
80
|
close(): void;
|
|
80
81
|
}
|
|
@@ -25,10 +25,11 @@ const read_environment_credentials_1 = require("./read-environment-credentials")
|
|
|
25
25
|
const analytics_1 = require("../utils/analytics");
|
|
26
26
|
const getClientArgsWithDefaults = (clientArgs = {}) => (Object.assign({ uiControllerUrl: 'http://127.0.0.1:6769', inferenceServerUrl: 'https://inference.askui.com', annotationLevel: annotation_level_1.AnnotationLevel.DISABLED }, clientArgs));
|
|
27
27
|
class UiControlClient extends dsl_1.FluentCommand {
|
|
28
|
-
constructor(httpClient, clientArgs) {
|
|
28
|
+
constructor(httpClient, clientArgs, workspaceId) {
|
|
29
29
|
super();
|
|
30
30
|
this.httpClient = httpClient;
|
|
31
31
|
this.clientArgs = clientArgs;
|
|
32
|
+
this.workspaceId = workspaceId;
|
|
32
33
|
this.secretText = undefined;
|
|
33
34
|
}
|
|
34
35
|
static build(clientArgs) {
|
|
@@ -36,8 +37,9 @@ class UiControlClient extends dsl_1.FluentCommand {
|
|
|
36
37
|
const analytics = new analytics_1.Analytics();
|
|
37
38
|
const analyticsHeaders = yield analytics.getAnalyticsHeaders();
|
|
38
39
|
const cas = getClientArgsWithDefaults(clientArgs);
|
|
39
|
-
const
|
|
40
|
-
|
|
40
|
+
const credentialArgs = cas.credentials || (0, read_environment_credentials_1.envCredentials)();
|
|
41
|
+
const httpClient = new http_client_got_1.HttpClientGot(credentialArgs === null || credentialArgs === void 0 ? void 0 : credentialArgs.token, analyticsHeaders);
|
|
42
|
+
return new UiControlClient(httpClient, cas, credentialArgs === null || credentialArgs === void 0 ? void 0 : credentialArgs.workspaceId);
|
|
41
43
|
});
|
|
42
44
|
}
|
|
43
45
|
get uiControllerClient() {
|
|
@@ -47,7 +49,7 @@ class UiControlClient extends dsl_1.FluentCommand {
|
|
|
47
49
|
return this._uiControllerClient;
|
|
48
50
|
}
|
|
49
51
|
get inferenceClient() {
|
|
50
|
-
return new inference_client_1.InferenceClient(this.clientArgs.inferenceServerUrl, this.httpClient);
|
|
52
|
+
return new inference_client_1.InferenceClient(this.clientArgs.inferenceServerUrl, this.httpClient, this.workspaceId);
|
|
51
53
|
}
|
|
52
54
|
get executionRuntime() {
|
|
53
55
|
return new execution_runtime_1.ExecutionRuntime(this.uiControllerClient, this.inferenceClient);
|
|
@@ -182,7 +184,7 @@ class UiControlClient extends dsl_1.FluentCommand {
|
|
|
182
184
|
};
|
|
183
185
|
}
|
|
184
186
|
/**
|
|
185
|
-
*
|
|
187
|
+
* Closes the connection to the askui UI Controller
|
|
186
188
|
*/
|
|
187
189
|
close() {
|
|
188
190
|
this.uiControllerClient.close();
|
|
@@ -14,10 +14,10 @@ class UiControllerDarwin extends ui_controller_facade_1.UiControllerFacade {
|
|
|
14
14
|
this.makeDiskImageExecutable();
|
|
15
15
|
}
|
|
16
16
|
getStartingCommand() {
|
|
17
|
-
return `"${path_1.default.dirname(this.binaryPath)}/
|
|
17
|
+
return `"${path_1.default.dirname(this.binaryPath)}/askui-ui-controller.app/Contents/MacOS/askui-ui-controller"`;
|
|
18
18
|
}
|
|
19
19
|
makeDiskImageExecutable() {
|
|
20
|
-
const mountPoint = '/Volumes/
|
|
20
|
+
const mountPoint = '/Volumes/askui-ui-controller.dmg';
|
|
21
21
|
(0, child_process_1.execSync)([
|
|
22
22
|
'hdiutil attach',
|
|
23
23
|
'-nobrowse',
|
|
@@ -27,7 +27,7 @@ class UiControllerDarwin extends ui_controller_facade_1.UiControllerFacade {
|
|
|
27
27
|
`-mountpoint "${mountPoint}"`,
|
|
28
28
|
`"${this.binaryPath}"`,
|
|
29
29
|
].join(' '));
|
|
30
|
-
const appBaseName = '
|
|
30
|
+
const appBaseName = 'askui-ui-controller.app';
|
|
31
31
|
const appSrcPath = `${mountPoint}/${appBaseName}`;
|
|
32
32
|
const appDestPath = `${path_1.default.dirname(this.binaryPath)}/${appBaseName}`;
|
|
33
33
|
fs_extra_1.default.removeSync(appDestPath);
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
export interface CredentialArgs {
|
|
2
|
-
workspaceId: string;
|
|
3
|
-
email: string;
|
|
4
|
-
token: string;
|
|
5
|
-
}
|
|
6
1
|
export declare class Credentials {
|
|
7
|
-
private
|
|
8
|
-
constructor(
|
|
2
|
+
private token;
|
|
3
|
+
constructor(token: string);
|
|
9
4
|
get base64Encoded(): string;
|
|
10
5
|
private get buffered();
|
|
11
|
-
private get userName();
|
|
12
6
|
}
|
|
@@ -2,17 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Credentials = void 0;
|
|
4
4
|
class Credentials {
|
|
5
|
-
constructor(
|
|
6
|
-
this.
|
|
5
|
+
constructor(token) {
|
|
6
|
+
this.token = token;
|
|
7
7
|
}
|
|
8
8
|
get base64Encoded() {
|
|
9
9
|
return this.buffered.toString('base64');
|
|
10
10
|
}
|
|
11
11
|
get buffered() {
|
|
12
|
-
return Buffer.from(`${this.
|
|
13
|
-
}
|
|
14
|
-
get userName() {
|
|
15
|
-
return `${this.credentials.workspaceId}|${this.credentials.email}`;
|
|
12
|
+
return Buffer.from(`${this.token}`);
|
|
16
13
|
}
|
|
17
14
|
}
|
|
18
15
|
exports.Credentials = Credentials;
|
|
@@ -4,8 +4,8 @@ const credentials_1 = require("./credentials");
|
|
|
4
4
|
describe('Credentials', () => {
|
|
5
5
|
describe('base64Encoded()', () => {
|
|
6
6
|
test('should return base64-encoded credentials', () => {
|
|
7
|
-
const credentials = new credentials_1.Credentials(
|
|
8
|
-
expect(credentials.base64Encoded).toBe('
|
|
7
|
+
const credentials = new credentials_1.Credentials('password');
|
|
8
|
+
expect(credentials.base64Encoded).toBe('cGFzc3dvcmQ=');
|
|
9
9
|
});
|
|
10
10
|
});
|
|
11
11
|
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { OptionsOfJSONResponseBody } from 'got';
|
|
2
|
-
import { CredentialArgs } from './credentials';
|
|
3
2
|
export declare class HttpClientGot {
|
|
4
|
-
readonly
|
|
3
|
+
readonly token?: string | undefined;
|
|
5
4
|
readonly customHeaders?: Record<string, string> | undefined;
|
|
6
5
|
private headers;
|
|
7
|
-
constructor(
|
|
6
|
+
constructor(token?: string | undefined, customHeaders?: Record<string, string> | undefined);
|
|
8
7
|
private initHeaders;
|
|
9
8
|
private injectHeaders;
|
|
10
9
|
post<T>(url: string, data: Record<string | number | symbol, unknown>): Promise<T>;
|
|
@@ -17,14 +17,14 @@ const got_1 = __importDefault(require("got"));
|
|
|
17
17
|
const credentials_1 = require("./credentials");
|
|
18
18
|
const custom_errors_1 = require("./custom-errors");
|
|
19
19
|
class HttpClientGot {
|
|
20
|
-
constructor(
|
|
21
|
-
this.
|
|
20
|
+
constructor(token, customHeaders) {
|
|
21
|
+
this.token = token;
|
|
22
22
|
this.customHeaders = customHeaders;
|
|
23
23
|
this.headers = {};
|
|
24
|
-
this.initHeaders(
|
|
24
|
+
this.initHeaders(token, customHeaders);
|
|
25
25
|
}
|
|
26
|
-
initHeaders(
|
|
27
|
-
const credentials =
|
|
26
|
+
initHeaders(token, customHeaders = {}) {
|
|
27
|
+
const credentials = token ? new credentials_1.Credentials(token) : undefined;
|
|
28
28
|
this.headers = Object.assign(Object.assign({}, (credentials ? { Authorization: `Basic ${credentials === null || credentials === void 0 ? void 0 : credentials.base64Encoded}` } : {})), customHeaders);
|
|
29
29
|
}
|
|
30
30
|
injectHeaders(options) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -3,9 +3,12 @@ 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
5
|
export declare class InferenceClient {
|
|
6
|
-
|
|
6
|
+
baseUrl: string;
|
|
7
7
|
httpClient: HttpClientGot;
|
|
8
|
-
|
|
8
|
+
readonly workspaceId?: string | undefined;
|
|
9
|
+
apiVersion: string;
|
|
10
|
+
url: string;
|
|
11
|
+
constructor(baseUrl: string, httpClient: HttpClientGot, workspaceId?: string | undefined, apiVersion?: string);
|
|
9
12
|
isImageRequired(instruction: string): Promise<boolean>;
|
|
10
13
|
private resizeIfNeeded;
|
|
11
14
|
predictControlCommand(instruction: string, customElements?: CustomElement[], image?: string): Promise<ControlCommand>;
|
|
@@ -12,9 +12,13 @@ import { ControlCommand } from '../core/ui-control-commands';
|
|
|
12
12
|
import { Annotation } from '../core/annotation/annotation';
|
|
13
13
|
import { resizeBase64ImageWithSameRatio } from '../utils/transformations';
|
|
14
14
|
export class InferenceClient {
|
|
15
|
-
constructor(
|
|
16
|
-
this.
|
|
15
|
+
constructor(baseUrl, httpClient, workspaceId, apiVersion = 'v2') {
|
|
16
|
+
this.baseUrl = baseUrl;
|
|
17
17
|
this.httpClient = httpClient;
|
|
18
|
+
this.workspaceId = workspaceId;
|
|
19
|
+
this.apiVersion = apiVersion;
|
|
20
|
+
const versionedBaseUrl = urljoin(this.baseUrl, 'api', this.apiVersion);
|
|
21
|
+
this.url = workspaceId ? urljoin(versionedBaseUrl, 'workspaces', workspaceId) : versionedBaseUrl;
|
|
18
22
|
}
|
|
19
23
|
isImageRequired(instruction) {
|
|
20
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -43,7 +47,7 @@ export class InferenceClient {
|
|
|
43
47
|
instruction,
|
|
44
48
|
customElements,
|
|
45
49
|
};
|
|
46
|
-
const url = urljoin(this.url, '
|
|
50
|
+
const url = urljoin(this.url, 'predict-command');
|
|
47
51
|
const httpResponse = yield this.httpClient.post(url, httpBody);
|
|
48
52
|
return ControlCommand.fromJson(httpResponse, resizedImage.resizeRatio);
|
|
49
53
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CredentialArgs } from '
|
|
1
|
+
import { CredentialArgs } from './credentials-args';
|
|
2
2
|
export declare function envCredentials(): CredentialArgs | undefined;
|
|
@@ -2,12 +2,10 @@ import { logger } from '../lib';
|
|
|
2
2
|
export function envCredentials() {
|
|
3
3
|
const envToken = process.env['ASKUI_TOKEN'];
|
|
4
4
|
const envWorkspaceId = process.env['ASKUI_WORKSPACE_ID'];
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
logger.info('Credentials are used from ENV variables: ASKUI_TOKEN, ASKUI_WORKSPACE_ID and ASKUI_EMAIL');
|
|
5
|
+
if (envToken && envWorkspaceId) {
|
|
6
|
+
logger.info('Credentials are used from ENV variables: ASKUI_TOKEN and ASKUI_WORKSPACE_ID');
|
|
8
7
|
return {
|
|
9
8
|
workspaceId: envWorkspaceId,
|
|
10
|
-
email: envEmail,
|
|
11
9
|
token: envToken,
|
|
12
10
|
};
|
|
13
11
|
}
|
|
@@ -3,8 +3,7 @@ describe('envCredentials()', () => {
|
|
|
3
3
|
test('should read the credentials from the environment variables', () => {
|
|
4
4
|
process.env['ASKUI_TOKEN'] = 'token';
|
|
5
5
|
process.env['ASKUI_WORKSPACE_ID'] = 'id123';
|
|
6
|
-
process.env['ASKUI_EMAIL'] = 'name@tenant.com';
|
|
7
6
|
const credentialsFromTheEnv = envCredentials();
|
|
8
|
-
expect(credentialsFromTheEnv).toStrictEqual({ workspaceId: 'id123',
|
|
7
|
+
expect(credentialsFromTheEnv).toStrictEqual({ workspaceId: 'id123', token: 'token' });
|
|
9
8
|
});
|
|
10
9
|
});
|
|
@@ -7,6 +7,7 @@ import { ClientArgs } from './ui-controller-client-interface';
|
|
|
7
7
|
export declare class UiControlClient extends FluentCommand {
|
|
8
8
|
private httpClient;
|
|
9
9
|
private clientArgs;
|
|
10
|
+
private workspaceId?;
|
|
10
11
|
private _uiControllerClient?;
|
|
11
12
|
private constructor();
|
|
12
13
|
static build(clientArgs?: ClientArgs): Promise<UiControlClient>;
|
|
@@ -74,7 +75,7 @@ export declare class UiControlClient extends FluentCommand {
|
|
|
74
75
|
*/
|
|
75
76
|
waitFor(delayInMs: number): Executable;
|
|
76
77
|
/**
|
|
77
|
-
*
|
|
78
|
+
* Closes the connection to the askui UI Controller
|
|
78
79
|
*/
|
|
79
80
|
close(): void;
|
|
80
81
|
}
|
|
@@ -22,10 +22,11 @@ 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
24
|
export class UiControlClient extends FluentCommand {
|
|
25
|
-
constructor(httpClient, clientArgs) {
|
|
25
|
+
constructor(httpClient, clientArgs, workspaceId) {
|
|
26
26
|
super();
|
|
27
27
|
this.httpClient = httpClient;
|
|
28
28
|
this.clientArgs = clientArgs;
|
|
29
|
+
this.workspaceId = workspaceId;
|
|
29
30
|
this.secretText = undefined;
|
|
30
31
|
}
|
|
31
32
|
static build(clientArgs) {
|
|
@@ -33,8 +34,9 @@ export class UiControlClient extends FluentCommand {
|
|
|
33
34
|
const analytics = new Analytics();
|
|
34
35
|
const analyticsHeaders = yield analytics.getAnalyticsHeaders();
|
|
35
36
|
const cas = getClientArgsWithDefaults(clientArgs);
|
|
36
|
-
const
|
|
37
|
-
|
|
37
|
+
const credentialArgs = cas.credentials || envCredentials();
|
|
38
|
+
const httpClient = new HttpClientGot(credentialArgs === null || credentialArgs === void 0 ? void 0 : credentialArgs.token, analyticsHeaders);
|
|
39
|
+
return new UiControlClient(httpClient, cas, credentialArgs === null || credentialArgs === void 0 ? void 0 : credentialArgs.workspaceId);
|
|
38
40
|
});
|
|
39
41
|
}
|
|
40
42
|
get uiControllerClient() {
|
|
@@ -44,7 +46,7 @@ export class UiControlClient extends FluentCommand {
|
|
|
44
46
|
return this._uiControllerClient;
|
|
45
47
|
}
|
|
46
48
|
get inferenceClient() {
|
|
47
|
-
return new InferenceClient(this.clientArgs.inferenceServerUrl, this.httpClient);
|
|
49
|
+
return new InferenceClient(this.clientArgs.inferenceServerUrl, this.httpClient, this.workspaceId);
|
|
48
50
|
}
|
|
49
51
|
get executionRuntime() {
|
|
50
52
|
return new ExecutionRuntime(this.uiControllerClient, this.inferenceClient);
|
|
@@ -179,7 +181,7 @@ export class UiControlClient extends FluentCommand {
|
|
|
179
181
|
};
|
|
180
182
|
}
|
|
181
183
|
/**
|
|
182
|
-
*
|
|
184
|
+
* Closes the connection to the askui UI Controller
|
|
183
185
|
*/
|
|
184
186
|
close() {
|
|
185
187
|
this.uiControllerClient.close();
|
|
@@ -8,10 +8,10 @@ export class UiControllerDarwin extends UiControllerFacade {
|
|
|
8
8
|
this.makeDiskImageExecutable();
|
|
9
9
|
}
|
|
10
10
|
getStartingCommand() {
|
|
11
|
-
return `"${path.dirname(this.binaryPath)}/
|
|
11
|
+
return `"${path.dirname(this.binaryPath)}/askui-ui-controller.app/Contents/MacOS/askui-ui-controller"`;
|
|
12
12
|
}
|
|
13
13
|
makeDiskImageExecutable() {
|
|
14
|
-
const mountPoint = '/Volumes/
|
|
14
|
+
const mountPoint = '/Volumes/askui-ui-controller.dmg';
|
|
15
15
|
execSync([
|
|
16
16
|
'hdiutil attach',
|
|
17
17
|
'-nobrowse',
|
|
@@ -21,7 +21,7 @@ export class UiControllerDarwin extends UiControllerFacade {
|
|
|
21
21
|
`-mountpoint "${mountPoint}"`,
|
|
22
22
|
`"${this.binaryPath}"`,
|
|
23
23
|
].join(' '));
|
|
24
|
-
const appBaseName = '
|
|
24
|
+
const appBaseName = 'askui-ui-controller.app';
|
|
25
25
|
const appSrcPath = `${mountPoint}/${appBaseName}`;
|
|
26
26
|
const appDestPath = `${path.dirname(this.binaryPath)}/${appBaseName}`;
|
|
27
27
|
fs.removeSync(appDestPath);
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
export interface CredentialArgs {
|
|
2
|
-
workspaceId: string;
|
|
3
|
-
email: string;
|
|
4
|
-
token: string;
|
|
5
|
-
}
|
|
6
1
|
export declare class Credentials {
|
|
7
|
-
private
|
|
8
|
-
constructor(
|
|
2
|
+
private token;
|
|
3
|
+
constructor(token: string);
|
|
9
4
|
get base64Encoded(): string;
|
|
10
5
|
private get buffered();
|
|
11
|
-
private get userName();
|
|
12
6
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
export class Credentials {
|
|
2
|
-
constructor(
|
|
3
|
-
this.
|
|
2
|
+
constructor(token) {
|
|
3
|
+
this.token = token;
|
|
4
4
|
}
|
|
5
5
|
get base64Encoded() {
|
|
6
6
|
return this.buffered.toString('base64');
|
|
7
7
|
}
|
|
8
8
|
get buffered() {
|
|
9
|
-
return Buffer.from(`${this.
|
|
10
|
-
}
|
|
11
|
-
get userName() {
|
|
12
|
-
return `${this.credentials.workspaceId}|${this.credentials.email}`;
|
|
9
|
+
return Buffer.from(`${this.token}`);
|
|
13
10
|
}
|
|
14
11
|
}
|
|
@@ -2,8 +2,8 @@ import { Credentials } from './credentials';
|
|
|
2
2
|
describe('Credentials', () => {
|
|
3
3
|
describe('base64Encoded()', () => {
|
|
4
4
|
test('should return base64-encoded credentials', () => {
|
|
5
|
-
const credentials = new Credentials(
|
|
6
|
-
expect(credentials.base64Encoded).toBe('
|
|
5
|
+
const credentials = new Credentials('password');
|
|
6
|
+
expect(credentials.base64Encoded).toBe('cGFzc3dvcmQ=');
|
|
7
7
|
});
|
|
8
8
|
});
|
|
9
9
|
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { OptionsOfJSONResponseBody } from 'got';
|
|
2
|
-
import { CredentialArgs } from './credentials';
|
|
3
2
|
export declare class HttpClientGot {
|
|
4
|
-
readonly
|
|
3
|
+
readonly token?: string | undefined;
|
|
5
4
|
readonly customHeaders?: Record<string, string> | undefined;
|
|
6
5
|
private headers;
|
|
7
|
-
constructor(
|
|
6
|
+
constructor(token?: string | undefined, customHeaders?: Record<string, string> | undefined);
|
|
8
7
|
private initHeaders;
|
|
9
8
|
private injectHeaders;
|
|
10
9
|
post<T>(url: string, data: Record<string | number | symbol, unknown>): Promise<T>;
|
|
@@ -11,14 +11,14 @@ import got from 'got';
|
|
|
11
11
|
import { Credentials } from './credentials';
|
|
12
12
|
import { httpClientErrorHandler } from './custom-errors';
|
|
13
13
|
export class HttpClientGot {
|
|
14
|
-
constructor(
|
|
15
|
-
this.
|
|
14
|
+
constructor(token, customHeaders) {
|
|
15
|
+
this.token = token;
|
|
16
16
|
this.customHeaders = customHeaders;
|
|
17
17
|
this.headers = {};
|
|
18
|
-
this.initHeaders(
|
|
18
|
+
this.initHeaders(token, customHeaders);
|
|
19
19
|
}
|
|
20
|
-
initHeaders(
|
|
21
|
-
const credentials =
|
|
20
|
+
initHeaders(token, customHeaders = {}) {
|
|
21
|
+
const credentials = token ? new Credentials(token) : undefined;
|
|
22
22
|
this.headers = Object.assign(Object.assign({}, (credentials ? { Authorization: `Basic ${credentials === null || credentials === void 0 ? void 0 : credentials.base64Encoded}` } : {})), customHeaders);
|
|
23
23
|
}
|
|
24
24
|
injectHeaders(options) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "askui",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.7",
|
|
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",
|