cyberdesk 0.1.3 → 0.2.1
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 +70 -56
- package/dist/client/sdk.gen.d.ts +9 -9
- package/dist/client/sdk.gen.js +13 -13
- package/dist/client/types.gen.d.ts +24 -24
- package/dist/index.d.ts +15 -12
- package/dist/index.js +7 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,74 +16,88 @@ pnpm add cyberdesk
|
|
|
16
16
|
|
|
17
17
|
## Usage
|
|
18
18
|
|
|
19
|
-
First,
|
|
19
|
+
First, create a Cyberdesk client instance with your API key:
|
|
20
20
|
|
|
21
21
|
```typescript
|
|
22
|
-
import {
|
|
22
|
+
import { createCyberdeskClient } from 'cyberdesk';
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const cyberdesk = createCyberdeskClient({
|
|
25
|
+
apiKey: 'YOUR_API_KEY',
|
|
26
|
+
// Optionally, you can override the baseUrl or provide a custom fetch implementation
|
|
27
|
+
});
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Launch a Desktop
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
const launchResult = await cyberdesk.launchDesktop({
|
|
34
|
+
body: { timeout_ms: 10000 } // Optional: set a timeout for the desktop session
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
if (launchResult.error) {
|
|
38
|
+
throw new Error('Failed to launch desktop: ' + launchResult.error.error);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const desktopId = launchResult.id;
|
|
42
|
+
console.log('Launched desktop with ID:', desktopId);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Get Desktop Info
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
const info = await cyberdesk.getDesktop({
|
|
49
|
+
path: { id: desktopId }
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if ('error' in info) {
|
|
53
|
+
throw new Error('Failed to get desktop info: ' + info.error);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
console.log('Desktop info:', info);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Perform a Computer Action (e.g., Mouse Click)
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
const actionResult = await cyberdesk.executeComputerAction({
|
|
63
|
+
path: { id: desktopId },
|
|
64
|
+
body: {
|
|
65
|
+
type: 'click_mouse',
|
|
66
|
+
x: 100,
|
|
67
|
+
y: 150
|
|
29
68
|
}
|
|
30
69
|
});
|
|
70
|
+
|
|
71
|
+
if (actionResult.error) {
|
|
72
|
+
throw new Error('Action failed: ' + actionResult.error);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
console.log('Action result:', actionResult);
|
|
31
76
|
```
|
|
32
77
|
|
|
33
|
-
|
|
78
|
+
### Run a Bash Command
|
|
34
79
|
|
|
35
80
|
```typescript
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
type PostV1DesktopIdComputerActionData
|
|
41
|
-
} from 'cyberdesk';
|
|
42
|
-
|
|
43
|
-
async function createAndInteract() {
|
|
44
|
-
try {
|
|
45
|
-
// 1. Create a new desktop
|
|
46
|
-
console.log('Creating desktop...');
|
|
47
|
-
const createResponse = await postV1Desktop({
|
|
48
|
-
// Pass request body parameters inside the 'data' object
|
|
49
|
-
data: {
|
|
50
|
-
timeoutMs: 10000
|
|
51
|
-
}
|
|
52
|
-
// Headers like Authorization should be set globally via setConfig (see above)
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
if (!createResponse.data) {
|
|
56
|
-
throw new Error('Failed to create desktop: ' + (createResponse.error?.message || 'Unknown error'));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const desktopId = createResponse.data.id; // Assuming the response has an ID
|
|
60
|
-
console.log(`Desktop created with ID: ${desktopId}`);
|
|
61
|
-
|
|
62
|
-
// 2. Perform an action (e.g., a mouse click)
|
|
63
|
-
console.log(`Performing action on desktop ${desktopId}...`);
|
|
64
|
-
const actionData: PostV1DesktopIdComputerActionData['data'] = {
|
|
65
|
-
type: 'click_mouse', // Example action type
|
|
66
|
-
x: 100,
|
|
67
|
-
y: 150
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const actionResponse = await postV1DesktopIdComputerAction({
|
|
71
|
-
path: { id: desktopId }, // Provide path parameters
|
|
72
|
-
data: actionData // Provide request body data
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
if (actionResponse.error) {
|
|
76
|
-
throw new Error(`Action failed: ${actionResponse.error.message}`);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
console.log('Action successful:', actionResponse.data);
|
|
80
|
-
|
|
81
|
-
} catch (error) {
|
|
82
|
-
console.error('Error using Cyberdesk SDK:', error);
|
|
81
|
+
const bashResult = await cyberdesk.executeBashAction({
|
|
82
|
+
path: { id: desktopId },
|
|
83
|
+
body: {
|
|
84
|
+
command: 'echo Hello, world!'
|
|
83
85
|
}
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
if (bashResult.error) {
|
|
89
|
+
throw new Error('Bash command failed: ' + bashResult.error);
|
|
84
90
|
}
|
|
85
91
|
|
|
86
|
-
|
|
92
|
+
console.log('Bash output:', bashResult.output);
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## TypeScript Support
|
|
96
|
+
|
|
97
|
+
All request parameter types and the `CyberdeskSDK` type are exported for convenience:
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
import type { LaunchDesktopParams, CyberdeskSDK } from 'cyberdesk';
|
|
87
101
|
```
|
|
88
102
|
|
|
89
103
|
## License
|
package/dist/client/sdk.gen.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Options as ClientOptions, TDataShape, Client } from '@hey-api/client-fetch';
|
|
2
|
-
import type {
|
|
2
|
+
import type { GetV1DesktopByIdData, GetV1DesktopByIdError, PostV1DesktopData, PostV1DesktopError, PostV1DesktopByIdStopData, PostV1DesktopByIdStopError, PostV1DesktopByIdComputerActionData, PostV1DesktopByIdComputerActionError, PostV1DesktopByIdBashActionData, PostV1DesktopByIdBashActionError } from './types.gen';
|
|
3
3
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean> = ClientOptions<TData, ThrowOnError> & {
|
|
4
4
|
/**
|
|
5
5
|
* You can provide a client instance returned by `createClient()` instead of
|
|
@@ -17,13 +17,13 @@ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends
|
|
|
17
17
|
* Get details of a specific desktop instance
|
|
18
18
|
* Returns the ID, status, creation timestamp, and timeout timestamp for a given desktop instance.
|
|
19
19
|
*/
|
|
20
|
-
export declare const
|
|
20
|
+
export declare const getV1DesktopById: <ThrowOnError extends boolean = false>(options: Options<GetV1DesktopByIdData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<{
|
|
21
21
|
id: string;
|
|
22
22
|
status: "pending" | "running" | "terminated" | "error";
|
|
23
23
|
stream_url: string;
|
|
24
24
|
created_at: string;
|
|
25
25
|
timeout_at: string;
|
|
26
|
-
},
|
|
26
|
+
}, GetV1DesktopByIdError, ThrowOnError>;
|
|
27
27
|
/**
|
|
28
28
|
* Create a new virtual desktop instance
|
|
29
29
|
* Creates a new virtual desktop instance and returns its ID and stream URL
|
|
@@ -36,24 +36,24 @@ export declare const postV1Desktop: <ThrowOnError extends boolean = false>(optio
|
|
|
36
36
|
* Stop a running desktop instance
|
|
37
37
|
* Stops a running desktop instance and cleans up resources
|
|
38
38
|
*/
|
|
39
|
-
export declare const
|
|
39
|
+
export declare const postV1DesktopByIdStop: <ThrowOnError extends boolean = false>(options: Options<PostV1DesktopByIdStopData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<{
|
|
40
40
|
status: "pending" | "running" | "terminated" | "error";
|
|
41
|
-
},
|
|
41
|
+
}, PostV1DesktopByIdStopError, ThrowOnError>;
|
|
42
42
|
/**
|
|
43
43
|
* Perform an action on the desktop
|
|
44
44
|
* Executes a computer action such as mouse clicks, keyboard input, or screenshots on the desktop
|
|
45
45
|
*/
|
|
46
|
-
export declare const
|
|
46
|
+
export declare const postV1DesktopByIdComputerAction: <ThrowOnError extends boolean = false>(options: Options<PostV1DesktopByIdComputerActionData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<{
|
|
47
47
|
output?: string;
|
|
48
48
|
error?: string;
|
|
49
49
|
base64_image?: string;
|
|
50
|
-
},
|
|
50
|
+
}, PostV1DesktopByIdComputerActionError, ThrowOnError>;
|
|
51
51
|
/**
|
|
52
52
|
* Execute a bash command on the desktop
|
|
53
53
|
* Runs a bash command on the desktop and returns the command output
|
|
54
54
|
*/
|
|
55
|
-
export declare const
|
|
55
|
+
export declare const postV1DesktopByIdBashAction: <ThrowOnError extends boolean = false>(options: Options<PostV1DesktopByIdBashActionData, ThrowOnError>) => import("@hey-api/client-fetch").RequestResult<{
|
|
56
56
|
output?: string;
|
|
57
57
|
error?: string;
|
|
58
58
|
base64_image?: string;
|
|
59
|
-
},
|
|
59
|
+
}, PostV1DesktopByIdBashActionError, ThrowOnError>;
|
package/dist/client/sdk.gen.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.
|
|
4
|
+
exports.postV1DesktopByIdBashAction = exports.postV1DesktopByIdComputerAction = exports.postV1DesktopByIdStop = exports.postV1Desktop = exports.getV1DesktopById = void 0;
|
|
5
5
|
const client_gen_1 = require("./client.gen");
|
|
6
6
|
/**
|
|
7
7
|
* Get details of a specific desktop instance
|
|
8
8
|
* Returns the ID, status, creation timestamp, and timeout timestamp for a given desktop instance.
|
|
9
9
|
*/
|
|
10
|
-
const
|
|
10
|
+
const getV1DesktopById = (options) => {
|
|
11
11
|
var _a;
|
|
12
|
-
return ((_a = options.client) !== null && _a !== void 0 ? _a : client_gen_1.client).get(Object.assign({ url: '/v1/desktop
|
|
12
|
+
return ((_a = options.client) !== null && _a !== void 0 ? _a : client_gen_1.client).get(Object.assign({ url: '/v1/desktop/{id}' }, options));
|
|
13
13
|
};
|
|
14
|
-
exports.
|
|
14
|
+
exports.getV1DesktopById = getV1DesktopById;
|
|
15
15
|
/**
|
|
16
16
|
* Create a new virtual desktop instance
|
|
17
17
|
* Creates a new virtual desktop instance and returns its ID and stream URL
|
|
@@ -25,26 +25,26 @@ exports.postV1Desktop = postV1Desktop;
|
|
|
25
25
|
* Stop a running desktop instance
|
|
26
26
|
* Stops a running desktop instance and cleans up resources
|
|
27
27
|
*/
|
|
28
|
-
const
|
|
28
|
+
const postV1DesktopByIdStop = (options) => {
|
|
29
29
|
var _a;
|
|
30
|
-
return ((_a = options.client) !== null && _a !== void 0 ? _a : client_gen_1.client).post(Object.assign({ url: '/v1/desktop
|
|
30
|
+
return ((_a = options.client) !== null && _a !== void 0 ? _a : client_gen_1.client).post(Object.assign({ url: '/v1/desktop/{id}/stop' }, options));
|
|
31
31
|
};
|
|
32
|
-
exports.
|
|
32
|
+
exports.postV1DesktopByIdStop = postV1DesktopByIdStop;
|
|
33
33
|
/**
|
|
34
34
|
* Perform an action on the desktop
|
|
35
35
|
* Executes a computer action such as mouse clicks, keyboard input, or screenshots on the desktop
|
|
36
36
|
*/
|
|
37
|
-
const
|
|
37
|
+
const postV1DesktopByIdComputerAction = (options) => {
|
|
38
38
|
var _a;
|
|
39
|
-
return ((_a = options.client) !== null && _a !== void 0 ? _a : client_gen_1.client).post(Object.assign(Object.assign({ url: '/v1/desktop
|
|
39
|
+
return ((_a = options.client) !== null && _a !== void 0 ? _a : client_gen_1.client).post(Object.assign(Object.assign({ url: '/v1/desktop/{id}/computer-action' }, options), { headers: Object.assign({ 'Content-Type': 'application/json' }, options === null || options === void 0 ? void 0 : options.headers) }));
|
|
40
40
|
};
|
|
41
|
-
exports.
|
|
41
|
+
exports.postV1DesktopByIdComputerAction = postV1DesktopByIdComputerAction;
|
|
42
42
|
/**
|
|
43
43
|
* Execute a bash command on the desktop
|
|
44
44
|
* Runs a bash command on the desktop and returns the command output
|
|
45
45
|
*/
|
|
46
|
-
const
|
|
46
|
+
const postV1DesktopByIdBashAction = (options) => {
|
|
47
47
|
var _a;
|
|
48
|
-
return ((_a = options.client) !== null && _a !== void 0 ? _a : client_gen_1.client).post(Object.assign(Object.assign({ url: '/v1/desktop
|
|
48
|
+
return ((_a = options.client) !== null && _a !== void 0 ? _a : client_gen_1.client).post(Object.assign(Object.assign({ url: '/v1/desktop/{id}/bash-action' }, options), { headers: Object.assign({ 'Content-Type': 'application/json' }, options === null || options === void 0 ? void 0 : options.headers) }));
|
|
49
49
|
};
|
|
50
|
-
exports.
|
|
50
|
+
exports.postV1DesktopByIdBashAction = postV1DesktopByIdBashAction;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type GetV1DesktopByIdData = {
|
|
2
2
|
body?: never;
|
|
3
3
|
headers: {
|
|
4
4
|
/**
|
|
@@ -13,9 +13,9 @@ export type GetV1DesktopIdData = {
|
|
|
13
13
|
id: string;
|
|
14
14
|
};
|
|
15
15
|
query?: never;
|
|
16
|
-
url: '/v1/desktop
|
|
16
|
+
url: '/v1/desktop/{id}';
|
|
17
17
|
};
|
|
18
|
-
export type
|
|
18
|
+
export type GetV1DesktopByIdErrors = {
|
|
19
19
|
/**
|
|
20
20
|
* The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
|
|
21
21
|
*/
|
|
@@ -97,8 +97,8 @@ export type GetV1DesktopIdErrors = {
|
|
|
97
97
|
error: string;
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
|
-
export type
|
|
101
|
-
export type
|
|
100
|
+
export type GetV1DesktopByIdError = GetV1DesktopByIdErrors[keyof GetV1DesktopByIdErrors];
|
|
101
|
+
export type GetV1DesktopByIdResponses = {
|
|
102
102
|
/**
|
|
103
103
|
* Desktop instance details retrieved successfully
|
|
104
104
|
*/
|
|
@@ -125,7 +125,7 @@ export type GetV1DesktopIdResponses = {
|
|
|
125
125
|
timeout_at: string;
|
|
126
126
|
};
|
|
127
127
|
};
|
|
128
|
-
export type
|
|
128
|
+
export type GetV1DesktopByIdResponse = GetV1DesktopByIdResponses[keyof GetV1DesktopByIdResponses];
|
|
129
129
|
export type PostV1DesktopData = {
|
|
130
130
|
body?: {
|
|
131
131
|
/**
|
|
@@ -242,7 +242,7 @@ export type PostV1DesktopResponses = {
|
|
|
242
242
|
};
|
|
243
243
|
};
|
|
244
244
|
export type PostV1DesktopResponse = PostV1DesktopResponses[keyof PostV1DesktopResponses];
|
|
245
|
-
export type
|
|
245
|
+
export type PostV1DesktopByIdStopData = {
|
|
246
246
|
body?: never;
|
|
247
247
|
headers: {
|
|
248
248
|
/**
|
|
@@ -257,9 +257,9 @@ export type PostV1DesktopIdStopData = {
|
|
|
257
257
|
id: string;
|
|
258
258
|
};
|
|
259
259
|
query?: never;
|
|
260
|
-
url: '/v1/desktop
|
|
260
|
+
url: '/v1/desktop/{id}/stop';
|
|
261
261
|
};
|
|
262
|
-
export type
|
|
262
|
+
export type PostV1DesktopByIdStopErrors = {
|
|
263
263
|
/**
|
|
264
264
|
* The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
|
|
265
265
|
*/
|
|
@@ -341,8 +341,8 @@ export type PostV1DesktopIdStopErrors = {
|
|
|
341
341
|
error: string;
|
|
342
342
|
};
|
|
343
343
|
};
|
|
344
|
-
export type
|
|
345
|
-
export type
|
|
344
|
+
export type PostV1DesktopByIdStopError = PostV1DesktopByIdStopErrors[keyof PostV1DesktopByIdStopErrors];
|
|
345
|
+
export type PostV1DesktopByIdStopResponses = {
|
|
346
346
|
/**
|
|
347
347
|
* Desktop stopped successfully
|
|
348
348
|
*/
|
|
@@ -353,8 +353,8 @@ export type PostV1DesktopIdStopResponses = {
|
|
|
353
353
|
status: 'pending' | 'running' | 'terminated' | 'error';
|
|
354
354
|
};
|
|
355
355
|
};
|
|
356
|
-
export type
|
|
357
|
-
export type
|
|
356
|
+
export type PostV1DesktopByIdStopResponse = PostV1DesktopByIdStopResponses[keyof PostV1DesktopByIdStopResponses];
|
|
357
|
+
export type PostV1DesktopByIdComputerActionData = {
|
|
358
358
|
body?: {
|
|
359
359
|
/**
|
|
360
360
|
* Perform a mouse action: click, press (down), or release (up). Defaults to a single left click at the current position.
|
|
@@ -489,9 +489,9 @@ export type PostV1DesktopIdComputerActionData = {
|
|
|
489
489
|
id: string;
|
|
490
490
|
};
|
|
491
491
|
query?: never;
|
|
492
|
-
url: '/v1/desktop
|
|
492
|
+
url: '/v1/desktop/{id}/computer-action';
|
|
493
493
|
};
|
|
494
|
-
export type
|
|
494
|
+
export type PostV1DesktopByIdComputerActionErrors = {
|
|
495
495
|
/**
|
|
496
496
|
* The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
|
|
497
497
|
*/
|
|
@@ -573,8 +573,8 @@ export type PostV1DesktopIdComputerActionErrors = {
|
|
|
573
573
|
error: string;
|
|
574
574
|
};
|
|
575
575
|
};
|
|
576
|
-
export type
|
|
577
|
-
export type
|
|
576
|
+
export type PostV1DesktopByIdComputerActionError = PostV1DesktopByIdComputerActionErrors[keyof PostV1DesktopByIdComputerActionErrors];
|
|
577
|
+
export type PostV1DesktopByIdComputerActionResponses = {
|
|
578
578
|
/**
|
|
579
579
|
* Action executed successfully. Response may contain output or image data depending on the action.
|
|
580
580
|
*/
|
|
@@ -593,8 +593,8 @@ export type PostV1DesktopIdComputerActionResponses = {
|
|
|
593
593
|
base64_image?: string;
|
|
594
594
|
};
|
|
595
595
|
};
|
|
596
|
-
export type
|
|
597
|
-
export type
|
|
596
|
+
export type PostV1DesktopByIdComputerActionResponse = PostV1DesktopByIdComputerActionResponses[keyof PostV1DesktopByIdComputerActionResponses];
|
|
597
|
+
export type PostV1DesktopByIdBashActionData = {
|
|
598
598
|
body?: {
|
|
599
599
|
/**
|
|
600
600
|
* Bash command to execute
|
|
@@ -614,9 +614,9 @@ export type PostV1DesktopIdBashActionData = {
|
|
|
614
614
|
id: string;
|
|
615
615
|
};
|
|
616
616
|
query?: never;
|
|
617
|
-
url: '/v1/desktop
|
|
617
|
+
url: '/v1/desktop/{id}/bash-action';
|
|
618
618
|
};
|
|
619
|
-
export type
|
|
619
|
+
export type PostV1DesktopByIdBashActionErrors = {
|
|
620
620
|
/**
|
|
621
621
|
* The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
|
|
622
622
|
*/
|
|
@@ -698,8 +698,8 @@ export type PostV1DesktopIdBashActionErrors = {
|
|
|
698
698
|
error: string;
|
|
699
699
|
};
|
|
700
700
|
};
|
|
701
|
-
export type
|
|
702
|
-
export type
|
|
701
|
+
export type PostV1DesktopByIdBashActionError = PostV1DesktopByIdBashActionErrors[keyof PostV1DesktopByIdBashActionErrors];
|
|
702
|
+
export type PostV1DesktopByIdBashActionResponses = {
|
|
703
703
|
/**
|
|
704
704
|
* Command executed successfully. Response contains command output.
|
|
705
705
|
*/
|
|
@@ -718,7 +718,7 @@ export type PostV1DesktopIdBashActionResponses = {
|
|
|
718
718
|
base64_image?: string;
|
|
719
719
|
};
|
|
720
720
|
};
|
|
721
|
-
export type
|
|
721
|
+
export type PostV1DesktopByIdBashActionResponse = PostV1DesktopByIdBashActionResponses[keyof PostV1DesktopByIdBashActionResponses];
|
|
722
722
|
export type ClientOptions = {
|
|
723
723
|
baseUrl: 'https://api.cyberdesk.io' | (string & {});
|
|
724
724
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Options as ClientOptions } from '@hey-api/client-fetch';
|
|
2
2
|
import * as apiMethods from './client/sdk.gen';
|
|
3
|
-
|
|
4
|
-
import { type GetV1DesktopIdData, type PostV1DesktopData, type PostV1DesktopIdStopData, type PostV1DesktopIdComputerActionData, type PostV1DesktopIdBashActionData } from './client/types.gen';
|
|
3
|
+
import { GetV1DesktopByIdData, PostV1DesktopData, PostV1DesktopByIdStopData, PostV1DesktopByIdComputerActionData, PostV1DesktopByIdBashActionData } from './client/types.gen';
|
|
5
4
|
type FetchFn = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
6
5
|
/**
|
|
7
6
|
* Configuration options for the Cyberdesk SDK client.
|
|
@@ -16,12 +15,17 @@ export interface CyberdeskClientOptions {
|
|
|
16
15
|
/** Optional: Provide additional default options for the underlying client (e.g., timeout, keepalive). */
|
|
17
16
|
clientOptions?: Partial<ClientOptions>;
|
|
18
17
|
}
|
|
19
|
-
export type
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
export type GetDesktopParams = Omit<GetV1DesktopByIdData, 'headers' | 'url'>;
|
|
19
|
+
export type LaunchDesktopParams = Omit<PostV1DesktopData, 'headers' | 'url'>;
|
|
20
|
+
export type TerminateDesktopParams = Omit<PostV1DesktopByIdStopData, 'headers' | 'url'>;
|
|
21
|
+
export type ExecuteComputerActionParams = Omit<PostV1DesktopByIdComputerActionData, 'headers' | 'url'>;
|
|
22
|
+
export type ExecuteBashActionParams = Omit<PostV1DesktopByIdBashActionData, 'headers' | 'url'>;
|
|
23
|
+
export type CyberdeskSDK = {
|
|
24
|
+
getDesktop: (opts: GetDesktopParams) => ReturnType<typeof apiMethods.getV1DesktopById>;
|
|
25
|
+
launchDesktop: (opts: LaunchDesktopParams) => ReturnType<typeof apiMethods.postV1Desktop>;
|
|
26
|
+
terminateDesktop: (opts: TerminateDesktopParams) => ReturnType<typeof apiMethods.postV1DesktopByIdStop>;
|
|
27
|
+
executeComputerAction: (opts: ExecuteComputerActionParams) => ReturnType<typeof apiMethods.postV1DesktopByIdComputerAction>;
|
|
28
|
+
executeBashAction: (opts: ExecuteBashActionParams) => ReturnType<typeof apiMethods.postV1DesktopByIdBashAction>;
|
|
25
29
|
};
|
|
26
30
|
/**
|
|
27
31
|
* Creates a Cyberdesk SDK instance configured with your API key.
|
|
@@ -29,6 +33,5 @@ export type CyberdeskSdk = {
|
|
|
29
33
|
* @param options - Configuration options including the API key.
|
|
30
34
|
* @returns An SDK instance with methods ready to be called.
|
|
31
35
|
*/
|
|
32
|
-
export declare function createCyberdeskClient(options: CyberdeskClientOptions):
|
|
33
|
-
export {
|
|
34
|
-
export * as rawApiMethods from './client/sdk.gen';
|
|
36
|
+
export declare function createCyberdeskClient(options: CyberdeskClientOptions): CyberdeskSDK;
|
|
37
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -33,18 +33,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
return result;
|
|
34
34
|
};
|
|
35
35
|
})();
|
|
36
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
37
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
38
|
-
};
|
|
39
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
-
exports.rawApiMethods = exports.createClient = void 0;
|
|
41
37
|
exports.createCyberdeskClient = createCyberdeskClient;
|
|
42
38
|
const client_fetch_1 = require("@hey-api/client-fetch");
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
// Re-export all types from types.gen for user convenience
|
|
46
|
-
__exportStar(require("./client/types.gen"), exports);
|
|
47
|
-
const DEFAULT_BASE_URL = 'https://api.cyberdesk.io'; // Replace if needed
|
|
39
|
+
const apiMethods = __importStar(require("./client/sdk.gen"));
|
|
40
|
+
const DEFAULT_BASE_URL = 'https://api.cyberdesk.io';
|
|
48
41
|
/**
|
|
49
42
|
* Creates a Cyberdesk SDK instance configured with your API key.
|
|
50
43
|
*
|
|
@@ -56,29 +49,16 @@ function createCyberdeskClient(options) {
|
|
|
56
49
|
if (!apiKey) {
|
|
57
50
|
throw new Error('Cyberdesk SDK requires an `apiKey` to be provided.');
|
|
58
51
|
}
|
|
59
|
-
// Ensure baseUrl is string | undefined before use
|
|
60
52
|
const finalBaseUrl = baseUrl;
|
|
61
|
-
// Prepare headers, merging defaults with any provided in clientOptions
|
|
62
53
|
const mergedHeaders = Object.assign({ 'x-api-key': apiKey, 'Content-Type': 'application/json' }, (clientOptions.headers || {}));
|
|
63
|
-
|
|
64
|
-
const finalClientOptions = Object.assign({
|
|
65
|
-
// Set base URL
|
|
66
|
-
baseUrl: finalBaseUrl,
|
|
67
|
-
// Set merged headers
|
|
68
|
-
headers: mergedHeaders }, (customFetch && { fetch: customFetch }));
|
|
69
|
-
// Pass the inferred options object directly
|
|
54
|
+
const finalClientOptions = Object.assign({ baseUrl: finalBaseUrl, headers: mergedHeaders }, (customFetch && { fetch: customFetch }));
|
|
70
55
|
const configuredClient = (0, client_fetch_1.createClient)(finalClientOptions);
|
|
71
56
|
// Return an object where each method is pre-configured with the client instance
|
|
72
57
|
return {
|
|
73
|
-
|
|
74
|
-
// Merge client headers with potentially provided headers from opts
|
|
75
|
-
headers: Object.assign(Object.assign({}, mergedHeaders), opts.headers) })),
|
|
58
|
+
getDesktop: (opts) => apiMethods.getV1DesktopById(Object.assign(Object.assign({}, opts), { client: configuredClient, headers: Object.assign(Object.assign({}, mergedHeaders), opts.headers) })),
|
|
76
59
|
launchDesktop: (opts) => apiMethods.postV1Desktop(Object.assign(Object.assign({}, opts), { client: configuredClient, headers: Object.assign(Object.assign({}, mergedHeaders), opts.headers) })),
|
|
77
|
-
terminateDesktop: (opts) => apiMethods.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// Add bindings for other generated methods here following the same pattern
|
|
60
|
+
terminateDesktop: (opts) => apiMethods.postV1DesktopByIdStop(Object.assign(Object.assign({}, opts), { path: Object.assign(Object.assign({}, opts.path), { id: opts.path.id }), client: configuredClient, headers: Object.assign(Object.assign({}, mergedHeaders), opts.headers) })),
|
|
61
|
+
executeComputerAction: (opts) => apiMethods.postV1DesktopByIdComputerAction(Object.assign(Object.assign({}, opts), { client: configuredClient, headers: Object.assign(Object.assign({}, mergedHeaders), opts.headers) })),
|
|
62
|
+
executeBashAction: (opts) => apiMethods.postV1DesktopByIdBashAction(Object.assign(Object.assign({}, opts), { client: configuredClient, headers: Object.assign(Object.assign({}, mergedHeaders), opts.headers) })),
|
|
81
63
|
};
|
|
82
64
|
}
|
|
83
|
-
// Optional: Export the underlying api methods if needed, though usually accessed via the sdk instance
|
|
84
|
-
exports.rawApiMethods = __importStar(require("./client/sdk.gen"));
|