@phala/cloud 0.1.2 → 0.2.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/dist/actions/cvms/get_available_os_images.d.ts +217 -0
- package/dist/actions/cvms/get_cvm_state.d.ts +93 -0
- package/dist/actions/cvms/update_os_image.d.ts +61 -0
- package/dist/actions/cvms/watch_cvm_state.d.ts +157 -0
- package/dist/actions/get_available_nodes.d.ts +11 -11
- package/dist/actions/get_current_user.d.ts +11 -11
- package/dist/actions/index.d.ts +5 -0
- package/dist/actions/kms/next_app_ids.d.ts +73 -0
- package/dist/create-client.d.ts +60 -0
- package/dist/index.js +486 -171
- package/dist/index.mjs +466 -171
- package/dist/utils/define-action.d.ts +8 -8
- package/package.json +1 -1
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type CvmIdInput } from "../../types/cvm_id";
|
|
3
|
+
/**
|
|
4
|
+
* OS image variant (prod or dev)
|
|
5
|
+
*/
|
|
6
|
+
export declare const OSImageVariantSchema: z.ZodObject<{
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
os_image_hash: z.ZodNullable<z.ZodString>;
|
|
9
|
+
is_current: z.ZodBoolean;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
name: string;
|
|
12
|
+
os_image_hash: string | null;
|
|
13
|
+
is_current: boolean;
|
|
14
|
+
}, {
|
|
15
|
+
name: string;
|
|
16
|
+
os_image_hash: string | null;
|
|
17
|
+
is_current: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
export type OSImageVariant = z.infer<typeof OSImageVariantSchema>;
|
|
20
|
+
/**
|
|
21
|
+
* Available OS image information with prod/dev variants
|
|
22
|
+
*/
|
|
23
|
+
export declare const AvailableOSImageSchema: z.ZodObject<{
|
|
24
|
+
version: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>]>;
|
|
25
|
+
prod: z.ZodNullable<z.ZodObject<{
|
|
26
|
+
name: z.ZodString;
|
|
27
|
+
os_image_hash: z.ZodNullable<z.ZodString>;
|
|
28
|
+
is_current: z.ZodBoolean;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
name: string;
|
|
31
|
+
os_image_hash: string | null;
|
|
32
|
+
is_current: boolean;
|
|
33
|
+
}, {
|
|
34
|
+
name: string;
|
|
35
|
+
os_image_hash: string | null;
|
|
36
|
+
is_current: boolean;
|
|
37
|
+
}>>;
|
|
38
|
+
dev: z.ZodNullable<z.ZodObject<{
|
|
39
|
+
name: z.ZodString;
|
|
40
|
+
os_image_hash: z.ZodNullable<z.ZodString>;
|
|
41
|
+
is_current: z.ZodBoolean;
|
|
42
|
+
}, "strip", z.ZodTypeAny, {
|
|
43
|
+
name: string;
|
|
44
|
+
os_image_hash: string | null;
|
|
45
|
+
is_current: boolean;
|
|
46
|
+
}, {
|
|
47
|
+
name: string;
|
|
48
|
+
os_image_hash: string | null;
|
|
49
|
+
is_current: boolean;
|
|
50
|
+
}>>;
|
|
51
|
+
}, "strip", z.ZodTypeAny, {
|
|
52
|
+
version: [number, number, number] | [number, number, number, number];
|
|
53
|
+
prod: {
|
|
54
|
+
name: string;
|
|
55
|
+
os_image_hash: string | null;
|
|
56
|
+
is_current: boolean;
|
|
57
|
+
} | null;
|
|
58
|
+
dev: {
|
|
59
|
+
name: string;
|
|
60
|
+
os_image_hash: string | null;
|
|
61
|
+
is_current: boolean;
|
|
62
|
+
} | null;
|
|
63
|
+
}, {
|
|
64
|
+
version: [number, number, number] | [number, number, number, number];
|
|
65
|
+
prod: {
|
|
66
|
+
name: string;
|
|
67
|
+
os_image_hash: string | null;
|
|
68
|
+
is_current: boolean;
|
|
69
|
+
} | null;
|
|
70
|
+
dev: {
|
|
71
|
+
name: string;
|
|
72
|
+
os_image_hash: string | null;
|
|
73
|
+
is_current: boolean;
|
|
74
|
+
} | null;
|
|
75
|
+
}>;
|
|
76
|
+
export type AvailableOSImage = z.infer<typeof AvailableOSImageSchema>;
|
|
77
|
+
/**
|
|
78
|
+
* Response schema for available OS images
|
|
79
|
+
*/
|
|
80
|
+
export declare const GetAvailableOSImagesResponseSchema: z.ZodArray<z.ZodObject<{
|
|
81
|
+
version: z.ZodUnion<[z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>, z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>]>;
|
|
82
|
+
prod: z.ZodNullable<z.ZodObject<{
|
|
83
|
+
name: z.ZodString;
|
|
84
|
+
os_image_hash: z.ZodNullable<z.ZodString>;
|
|
85
|
+
is_current: z.ZodBoolean;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
name: string;
|
|
88
|
+
os_image_hash: string | null;
|
|
89
|
+
is_current: boolean;
|
|
90
|
+
}, {
|
|
91
|
+
name: string;
|
|
92
|
+
os_image_hash: string | null;
|
|
93
|
+
is_current: boolean;
|
|
94
|
+
}>>;
|
|
95
|
+
dev: z.ZodNullable<z.ZodObject<{
|
|
96
|
+
name: z.ZodString;
|
|
97
|
+
os_image_hash: z.ZodNullable<z.ZodString>;
|
|
98
|
+
is_current: z.ZodBoolean;
|
|
99
|
+
}, "strip", z.ZodTypeAny, {
|
|
100
|
+
name: string;
|
|
101
|
+
os_image_hash: string | null;
|
|
102
|
+
is_current: boolean;
|
|
103
|
+
}, {
|
|
104
|
+
name: string;
|
|
105
|
+
os_image_hash: string | null;
|
|
106
|
+
is_current: boolean;
|
|
107
|
+
}>>;
|
|
108
|
+
}, "strip", z.ZodTypeAny, {
|
|
109
|
+
version: [number, number, number] | [number, number, number, number];
|
|
110
|
+
prod: {
|
|
111
|
+
name: string;
|
|
112
|
+
os_image_hash: string | null;
|
|
113
|
+
is_current: boolean;
|
|
114
|
+
} | null;
|
|
115
|
+
dev: {
|
|
116
|
+
name: string;
|
|
117
|
+
os_image_hash: string | null;
|
|
118
|
+
is_current: boolean;
|
|
119
|
+
} | null;
|
|
120
|
+
}, {
|
|
121
|
+
version: [number, number, number] | [number, number, number, number];
|
|
122
|
+
prod: {
|
|
123
|
+
name: string;
|
|
124
|
+
os_image_hash: string | null;
|
|
125
|
+
is_current: boolean;
|
|
126
|
+
} | null;
|
|
127
|
+
dev: {
|
|
128
|
+
name: string;
|
|
129
|
+
os_image_hash: string | null;
|
|
130
|
+
is_current: boolean;
|
|
131
|
+
} | null;
|
|
132
|
+
}>, "many">;
|
|
133
|
+
export type GetAvailableOSImagesResponse = z.infer<typeof GetAvailableOSImagesResponseSchema>;
|
|
134
|
+
export declare const GetAvailableOSImagesRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
135
|
+
id: z.ZodOptional<z.ZodString>;
|
|
136
|
+
uuid: z.ZodOptional<z.ZodString>;
|
|
137
|
+
app_id: z.ZodOptional<z.ZodString>;
|
|
138
|
+
instance_id: z.ZodOptional<z.ZodString>;
|
|
139
|
+
}, "strip", z.ZodTypeAny, {
|
|
140
|
+
id?: string | undefined;
|
|
141
|
+
app_id?: string | undefined;
|
|
142
|
+
instance_id?: string | undefined;
|
|
143
|
+
uuid?: string | undefined;
|
|
144
|
+
}, {
|
|
145
|
+
id?: string | undefined;
|
|
146
|
+
app_id?: string | undefined;
|
|
147
|
+
instance_id?: string | undefined;
|
|
148
|
+
uuid?: string | undefined;
|
|
149
|
+
}>, any, any>, {
|
|
150
|
+
cvmId: string;
|
|
151
|
+
}, any>;
|
|
152
|
+
export type GetAvailableOSImagesRequest = CvmIdInput;
|
|
153
|
+
/**
|
|
154
|
+
* Get available OS images for CVM upgrade
|
|
155
|
+
*
|
|
156
|
+
* Returns list of OS images that this CVM can upgrade to.
|
|
157
|
+
* The response includes only images that:
|
|
158
|
+
* 1. Are deployed on the CVM's teepod
|
|
159
|
+
* 2. Are allowed by the CVM's KMS if applicable
|
|
160
|
+
* 3. Follow dev/non-dev upgrade rules
|
|
161
|
+
* 4. Match GPU requirements
|
|
162
|
+
*
|
|
163
|
+
* @param client - The API client
|
|
164
|
+
* @param request - Request parameters
|
|
165
|
+
* @param request.cvmId - ID of the CVM
|
|
166
|
+
* @returns Array of available OS images grouped by version
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* const images = await getAvailableOsImages(client, { cvmId: "cvm-123" })
|
|
171
|
+
* console.log(images[0].version) // [0, 3, 5]
|
|
172
|
+
* console.log(images[0].prod?.name) // "prod-0.3.5"
|
|
173
|
+
* console.log(images[0].dev?.name) // "dev-0.3.5"
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
declare const getAvailableOsImages: {
|
|
177
|
+
(client: import("../..").BaseClient, params: CvmIdInput): Promise<{
|
|
178
|
+
version: [number, number, number] | [number, number, number, number];
|
|
179
|
+
prod: {
|
|
180
|
+
name: string;
|
|
181
|
+
os_image_hash: string | null;
|
|
182
|
+
is_current: boolean;
|
|
183
|
+
} | null;
|
|
184
|
+
dev: {
|
|
185
|
+
name: string;
|
|
186
|
+
os_image_hash: string | null;
|
|
187
|
+
is_current: boolean;
|
|
188
|
+
} | null;
|
|
189
|
+
}[]>;
|
|
190
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient, params: CvmIdInput, parameters: {
|
|
191
|
+
schema: T;
|
|
192
|
+
}): Promise<z.TypeOf<T>>;
|
|
193
|
+
(client: import("../..").BaseClient, params: CvmIdInput, parameters: {
|
|
194
|
+
schema: false;
|
|
195
|
+
}): Promise<unknown>;
|
|
196
|
+
}, safeGetAvailableOsImages: {
|
|
197
|
+
(client: import("../..").BaseClient, params: CvmIdInput): Promise<import("../..").SafeResult<{
|
|
198
|
+
version: [number, number, number] | [number, number, number, number];
|
|
199
|
+
prod: {
|
|
200
|
+
name: string;
|
|
201
|
+
os_image_hash: string | null;
|
|
202
|
+
is_current: boolean;
|
|
203
|
+
} | null;
|
|
204
|
+
dev: {
|
|
205
|
+
name: string;
|
|
206
|
+
os_image_hash: string | null;
|
|
207
|
+
is_current: boolean;
|
|
208
|
+
} | null;
|
|
209
|
+
}[]>>;
|
|
210
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient, params: CvmIdInput, parameters: {
|
|
211
|
+
schema: T;
|
|
212
|
+
}): Promise<import("../..").SafeResult<z.TypeOf<T>>>;
|
|
213
|
+
(client: import("../..").BaseClient, params: CvmIdInput, parameters: {
|
|
214
|
+
schema: false;
|
|
215
|
+
}): Promise<import("../..").SafeResult<unknown>>;
|
|
216
|
+
};
|
|
217
|
+
export { getAvailableOsImages, safeGetAvailableOsImages };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type Client } from "../../client";
|
|
3
|
+
import { type CvmIdInput } from "../../types/cvm_id";
|
|
4
|
+
/**
|
|
5
|
+
* CVM state response schema
|
|
6
|
+
*/
|
|
7
|
+
export declare const CvmStateSchema: z.ZodObject<{
|
|
8
|
+
status: z.ZodString;
|
|
9
|
+
derived_status: z.ZodOptional<z.ZodString>;
|
|
10
|
+
vm_uuid: z.ZodOptional<z.ZodString>;
|
|
11
|
+
instance_id: z.ZodOptional<z.ZodString>;
|
|
12
|
+
uptime: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
status: string;
|
|
15
|
+
uptime?: string | undefined;
|
|
16
|
+
instance_id?: string | undefined;
|
|
17
|
+
vm_uuid?: string | undefined;
|
|
18
|
+
derived_status?: string | undefined;
|
|
19
|
+
}, {
|
|
20
|
+
status: string;
|
|
21
|
+
uptime?: string | undefined;
|
|
22
|
+
instance_id?: string | undefined;
|
|
23
|
+
vm_uuid?: string | undefined;
|
|
24
|
+
derived_status?: string | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
export type CvmState = z.infer<typeof CvmStateSchema>;
|
|
27
|
+
export declare const GetCvmStateRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
28
|
+
id: z.ZodOptional<z.ZodString>;
|
|
29
|
+
uuid: z.ZodOptional<z.ZodString>;
|
|
30
|
+
app_id: z.ZodOptional<z.ZodString>;
|
|
31
|
+
instance_id: z.ZodOptional<z.ZodString>;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
id?: string | undefined;
|
|
34
|
+
app_id?: string | undefined;
|
|
35
|
+
instance_id?: string | undefined;
|
|
36
|
+
uuid?: string | undefined;
|
|
37
|
+
}, {
|
|
38
|
+
id?: string | undefined;
|
|
39
|
+
app_id?: string | undefined;
|
|
40
|
+
instance_id?: string | undefined;
|
|
41
|
+
uuid?: string | undefined;
|
|
42
|
+
}>, any, any>, {
|
|
43
|
+
cvmId: string;
|
|
44
|
+
}, any>;
|
|
45
|
+
export type GetCvmStateRequest = CvmIdInput;
|
|
46
|
+
/**
|
|
47
|
+
* Get current state of a CVM (one-shot, immediate return)
|
|
48
|
+
*
|
|
49
|
+
* This action retrieves the current state of a CVM without waiting or streaming.
|
|
50
|
+
* For monitoring state changes until a target status is reached, use `watchCvmState` instead.
|
|
51
|
+
*
|
|
52
|
+
* @param client - The API client
|
|
53
|
+
* @param request - Request parameters
|
|
54
|
+
* @param request.cvmId - ID of the CVM to get state for
|
|
55
|
+
* @param parameters - Optional behavior parameters
|
|
56
|
+
* @returns Current CVM state
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const state = await getCvmState(client, { cvmId: "cvm-123" })
|
|
61
|
+
* console.log(state.status) // "running", "stopped", etc.
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
declare const getCvmState: {
|
|
65
|
+
(client: Client, params: CvmIdInput): Promise<{
|
|
66
|
+
status: string;
|
|
67
|
+
uptime?: string | undefined;
|
|
68
|
+
instance_id?: string | undefined;
|
|
69
|
+
vm_uuid?: string | undefined;
|
|
70
|
+
derived_status?: string | undefined;
|
|
71
|
+
}>;
|
|
72
|
+
<T extends z.ZodTypeAny>(client: Client, params: CvmIdInput, parameters: {
|
|
73
|
+
schema: T;
|
|
74
|
+
}): Promise<z.TypeOf<T>>;
|
|
75
|
+
(client: Client, params: CvmIdInput, parameters: {
|
|
76
|
+
schema: false;
|
|
77
|
+
}): Promise<unknown>;
|
|
78
|
+
}, safeGetCvmState: {
|
|
79
|
+
(client: Client, params: CvmIdInput): Promise<import("../..").SafeResult<{
|
|
80
|
+
status: string;
|
|
81
|
+
uptime?: string | undefined;
|
|
82
|
+
instance_id?: string | undefined;
|
|
83
|
+
vm_uuid?: string | undefined;
|
|
84
|
+
derived_status?: string | undefined;
|
|
85
|
+
}>>;
|
|
86
|
+
<T extends z.ZodTypeAny>(client: Client, params: CvmIdInput, parameters: {
|
|
87
|
+
schema: T;
|
|
88
|
+
}): Promise<import("../..").SafeResult<z.TypeOf<T>>>;
|
|
89
|
+
(client: Client, params: CvmIdInput, parameters: {
|
|
90
|
+
schema: false;
|
|
91
|
+
}): Promise<import("../..").SafeResult<unknown>>;
|
|
92
|
+
};
|
|
93
|
+
export { getCvmState, safeGetCvmState };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Update CVM OS image
|
|
4
|
+
*
|
|
5
|
+
* This action initiates an asynchronous OS image update operation.
|
|
6
|
+
* The CVM will be shut down, the OS image updated, and then restarted.
|
|
7
|
+
* This operation may take several minutes to complete.
|
|
8
|
+
*
|
|
9
|
+
* Returns 202 Accepted as the operation runs asynchronously.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { createClient, updateOsImage } from '@phala/cloud'
|
|
14
|
+
*
|
|
15
|
+
* const client = createClient();
|
|
16
|
+
* await updateOsImage(client, {
|
|
17
|
+
* id: 'my-cvm-id',
|
|
18
|
+
* os_image_name: 'prod-0.3.5'
|
|
19
|
+
* });
|
|
20
|
+
* console.log('OS image update initiated');
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare const UpdateOsImageRequestSchema: z.ZodEffects<z.ZodObject<{
|
|
24
|
+
id: z.ZodOptional<z.ZodString>;
|
|
25
|
+
uuid: z.ZodOptional<z.ZodString>;
|
|
26
|
+
app_id: z.ZodOptional<z.ZodString>;
|
|
27
|
+
instance_id: z.ZodOptional<z.ZodString>;
|
|
28
|
+
} & {
|
|
29
|
+
os_image_name: z.ZodString;
|
|
30
|
+
}, "strip", z.ZodTypeAny, {
|
|
31
|
+
os_image_name: string;
|
|
32
|
+
id?: string | undefined;
|
|
33
|
+
app_id?: string | undefined;
|
|
34
|
+
instance_id?: string | undefined;
|
|
35
|
+
uuid?: string | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
os_image_name: string;
|
|
38
|
+
id?: string | undefined;
|
|
39
|
+
app_id?: string | undefined;
|
|
40
|
+
instance_id?: string | undefined;
|
|
41
|
+
uuid?: string | undefined;
|
|
42
|
+
}>, any, any>;
|
|
43
|
+
export type UpdateOsImageRequest = z.infer<typeof UpdateOsImageRequestSchema>;
|
|
44
|
+
declare const updateOsImage: {
|
|
45
|
+
(client: import("../..").BaseClient, params?: any): Promise<void>;
|
|
46
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient, params?: any, parameters?: {
|
|
47
|
+
schema: T;
|
|
48
|
+
} | undefined): Promise<z.TypeOf<T>>;
|
|
49
|
+
(client: import("../..").BaseClient, params?: any, parameters?: {
|
|
50
|
+
schema: false;
|
|
51
|
+
} | undefined): Promise<unknown>;
|
|
52
|
+
}, safeUpdateOsImage: {
|
|
53
|
+
(client: import("../..").BaseClient, params?: any): Promise<import("../..").SafeResult<void>>;
|
|
54
|
+
<T extends z.ZodTypeAny>(client: import("../..").BaseClient, params?: any, parameters?: {
|
|
55
|
+
schema: T;
|
|
56
|
+
} | undefined): Promise<import("../..").SafeResult<z.TypeOf<T>>>;
|
|
57
|
+
(client: import("../..").BaseClient, params?: any, parameters?: {
|
|
58
|
+
schema: false;
|
|
59
|
+
} | undefined): Promise<import("../..").SafeResult<unknown>>;
|
|
60
|
+
};
|
|
61
|
+
export { updateOsImage, safeUpdateOsImage };
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { type Client } from "../../client";
|
|
3
|
+
import { type CvmIdInput } from "../../types/cvm_id";
|
|
4
|
+
import { type CvmState } from "./get_cvm_state";
|
|
5
|
+
/**
|
|
6
|
+
* SSE event data structures
|
|
7
|
+
*/
|
|
8
|
+
type SSEStateEvent = {
|
|
9
|
+
type: "state";
|
|
10
|
+
data: CvmState;
|
|
11
|
+
};
|
|
12
|
+
type SSECompleteEvent = {
|
|
13
|
+
type: "complete";
|
|
14
|
+
data: {
|
|
15
|
+
status: string;
|
|
16
|
+
elapsed: number;
|
|
17
|
+
target: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
type SSETimeoutEvent = {
|
|
21
|
+
type: "timeout";
|
|
22
|
+
data: {
|
|
23
|
+
error: string;
|
|
24
|
+
elapsed: number;
|
|
25
|
+
target: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
type SSEErrorEvent = {
|
|
29
|
+
type: "error";
|
|
30
|
+
data: {
|
|
31
|
+
error: string;
|
|
32
|
+
elapsed?: number;
|
|
33
|
+
message?: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export type SSEEvent = SSEStateEvent | SSECompleteEvent | SSETimeoutEvent | SSEErrorEvent;
|
|
37
|
+
/**
|
|
38
|
+
* Watch CVM state request input (before transformation)
|
|
39
|
+
*/
|
|
40
|
+
export type WatchCvmStateRequest = CvmIdInput & {
|
|
41
|
+
target: string;
|
|
42
|
+
interval?: number;
|
|
43
|
+
timeout?: number;
|
|
44
|
+
maxRetries?: number;
|
|
45
|
+
retryDelay?: number;
|
|
46
|
+
};
|
|
47
|
+
export declare const WatchCvmStateRequestSchema: z.ZodObject<{
|
|
48
|
+
target: z.ZodString;
|
|
49
|
+
interval: z.ZodDefault<z.ZodNumber>;
|
|
50
|
+
timeout: z.ZodDefault<z.ZodNumber>;
|
|
51
|
+
maxRetries: z.ZodDefault<z.ZodNumber>;
|
|
52
|
+
retryDelay: z.ZodDefault<z.ZodNumber>;
|
|
53
|
+
}, "strip", z.ZodTypeAny, {
|
|
54
|
+
timeout: number;
|
|
55
|
+
retryDelay: number;
|
|
56
|
+
maxRetries: number;
|
|
57
|
+
target: string;
|
|
58
|
+
interval: number;
|
|
59
|
+
}, {
|
|
60
|
+
target: string;
|
|
61
|
+
timeout?: number | undefined;
|
|
62
|
+
retryDelay?: number | undefined;
|
|
63
|
+
maxRetries?: number | undefined;
|
|
64
|
+
interval?: number | undefined;
|
|
65
|
+
}>;
|
|
66
|
+
/**
|
|
67
|
+
* Options for watch operation
|
|
68
|
+
*/
|
|
69
|
+
export interface WatchCvmStateOptions {
|
|
70
|
+
signal?: AbortSignal;
|
|
71
|
+
onEvent?: (event: SSEEvent) => void;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Error thrown when watch operation is aborted
|
|
75
|
+
*/
|
|
76
|
+
export declare class WatchAbortedError extends Error {
|
|
77
|
+
constructor();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Error thrown when max retries exceeded
|
|
81
|
+
*/
|
|
82
|
+
export declare class MaxRetriesExceededError extends Error {
|
|
83
|
+
readonly attempts: number;
|
|
84
|
+
constructor(attempts: number);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Watch CVM state changes using Server-Sent Events (SSE)
|
|
88
|
+
*
|
|
89
|
+
* This action streams state updates from the backend until the target status is reached,
|
|
90
|
+
* timeout occurs, or an error happens. It automatically retries on timeout/error up to
|
|
91
|
+
* maxRetries times, providing unlimited watch capability.
|
|
92
|
+
*
|
|
93
|
+
* Key features:
|
|
94
|
+
* - Streams real-time state updates via SSE
|
|
95
|
+
* - Automatic retry on timeout (backend max 600s, but SDK can retry infinitely)
|
|
96
|
+
* - AbortController support for cancellation
|
|
97
|
+
* - Callback for each SSE event
|
|
98
|
+
* - Resolves with final state when target reached
|
|
99
|
+
*
|
|
100
|
+
* @param client - The API client
|
|
101
|
+
* @param request - Request parameters
|
|
102
|
+
* @param request.id - CVM ID (or use uuid, app_id, instance_id)
|
|
103
|
+
* @param request.target - Target status to wait for (e.g., "running")
|
|
104
|
+
* @param request.interval - Polling interval in seconds (5-30, default: 5)
|
|
105
|
+
* @param request.timeout - Timeout per attempt in seconds (10-600, default: 300)
|
|
106
|
+
* @param request.maxRetries - Max retry attempts (default: Infinity)
|
|
107
|
+
* @param request.retryDelay - Delay between retries in ms (default: 5000)
|
|
108
|
+
* @param options - Optional behavior parameters
|
|
109
|
+
* @param options.signal - AbortSignal for cancellation
|
|
110
|
+
* @param options.onEvent - Callback invoked for each SSE event
|
|
111
|
+
* @returns Promise that resolves with final CVM state when target is reached
|
|
112
|
+
*
|
|
113
|
+
* @throws {WatchAbortedError} If operation is aborted via signal
|
|
114
|
+
* @throws {MaxRetriesExceededError} If max retries exceeded without reaching target
|
|
115
|
+
* @throws {Error} For other unexpected errors
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* // Basic usage: wait for CVM to reach "running" status
|
|
120
|
+
* const state = await watchCvmState(client, {
|
|
121
|
+
* id: "cvm-123",
|
|
122
|
+
* target: "running"
|
|
123
|
+
* })
|
|
124
|
+
* console.log("CVM is now running!")
|
|
125
|
+
*
|
|
126
|
+
* // With event callback and abort controller
|
|
127
|
+
* const controller = new AbortController()
|
|
128
|
+
* try {
|
|
129
|
+
* const state = await watchCvmState(
|
|
130
|
+
* client,
|
|
131
|
+
* {
|
|
132
|
+
* id: "cvm-123",
|
|
133
|
+
* target: "running",
|
|
134
|
+
* interval: 10,
|
|
135
|
+
* maxRetries: 5
|
|
136
|
+
* },
|
|
137
|
+
* {
|
|
138
|
+
* signal: controller.signal,
|
|
139
|
+
* onEvent: (event) => {
|
|
140
|
+
* if (event.type === "state") {
|
|
141
|
+
* console.log("Current status:", event.data.status)
|
|
142
|
+
* }
|
|
143
|
+
* }
|
|
144
|
+
* }
|
|
145
|
+
* )
|
|
146
|
+
* } catch (error) {
|
|
147
|
+
* if (error instanceof WatchAbortedError) {
|
|
148
|
+
* console.log("Watch cancelled")
|
|
149
|
+
* }
|
|
150
|
+
* }
|
|
151
|
+
*
|
|
152
|
+
* // Cancel after 30 seconds
|
|
153
|
+
* setTimeout(() => controller.abort(), 30000)
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export declare function watchCvmState(client: Client, request: WatchCvmStateRequest, options?: WatchCvmStateOptions): Promise<CvmState>;
|
|
157
|
+
export {};
|
|
@@ -637,6 +637,12 @@ export type TeepodCapacity = z.infer<typeof TeepodCapacitySchema>;
|
|
|
637
637
|
export type ResourceThreshold = z.infer<typeof ResourceThresholdSchema>;
|
|
638
638
|
export type AvailableNodes = z.infer<typeof AvailableNodesSchema>;
|
|
639
639
|
declare const getAvailableNodes: {
|
|
640
|
+
(client: Client, parameters: {
|
|
641
|
+
schema: false;
|
|
642
|
+
}): Promise<unknown>;
|
|
643
|
+
<T extends z.ZodTypeAny>(client: Client, parameters: {
|
|
644
|
+
schema: T;
|
|
645
|
+
}): Promise<z.TypeOf<T>>;
|
|
640
646
|
(client: Client): Promise<z.objectOutputType<{
|
|
641
647
|
tier: z.ZodString;
|
|
642
648
|
capacity: z.ZodObject<{
|
|
@@ -788,13 +794,13 @@ declare const getAvailableNodes: {
|
|
|
788
794
|
gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
|
|
789
795
|
}, z.ZodTypeAny, "passthrough">>, "many">;
|
|
790
796
|
}, z.ZodTypeAny, "passthrough">>;
|
|
791
|
-
|
|
792
|
-
schema: T;
|
|
793
|
-
}): Promise<z.TypeOf<T>>;
|
|
797
|
+
}, safeGetAvailableNodes: {
|
|
794
798
|
(client: Client, parameters: {
|
|
795
799
|
schema: false;
|
|
796
|
-
}): Promise<unknown
|
|
797
|
-
|
|
800
|
+
}): Promise<import("..").SafeResult<unknown>>;
|
|
801
|
+
<T extends z.ZodTypeAny>(client: Client, parameters: {
|
|
802
|
+
schema: T;
|
|
803
|
+
}): Promise<import("..").SafeResult<z.TypeOf<T>>>;
|
|
798
804
|
(client: Client): Promise<import("..").SafeResult<z.objectOutputType<{
|
|
799
805
|
tier: z.ZodString;
|
|
800
806
|
capacity: z.ZodObject<{
|
|
@@ -946,11 +952,5 @@ declare const getAvailableNodes: {
|
|
|
946
952
|
gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
|
|
947
953
|
}, z.ZodTypeAny, "passthrough">>, "many">;
|
|
948
954
|
}, z.ZodTypeAny, "passthrough">>>;
|
|
949
|
-
<T extends z.ZodTypeAny>(client: Client, parameters: {
|
|
950
|
-
schema: T;
|
|
951
|
-
}): Promise<import("..").SafeResult<z.TypeOf<T>>>;
|
|
952
|
-
(client: Client, parameters: {
|
|
953
|
-
schema: false;
|
|
954
|
-
}): Promise<import("..").SafeResult<unknown>>;
|
|
955
955
|
};
|
|
956
956
|
export { getAvailableNodes, safeGetAvailableNodes };
|
|
@@ -85,6 +85,12 @@ export declare const CurrentUserSchema: z.ZodObject<{
|
|
|
85
85
|
}, z.ZodTypeAny, "passthrough">>;
|
|
86
86
|
export type CurrentUser = z.infer<typeof CurrentUserSchema>;
|
|
87
87
|
declare const getCurrentUser: {
|
|
88
|
+
(client: Client, parameters: {
|
|
89
|
+
schema: false;
|
|
90
|
+
}): Promise<unknown>;
|
|
91
|
+
<T extends z.ZodTypeAny>(client: Client, parameters: {
|
|
92
|
+
schema: T;
|
|
93
|
+
}): Promise<z.TypeOf<T>>;
|
|
88
94
|
(client: Client): Promise<z.objectOutputType<{
|
|
89
95
|
username: z.ZodString;
|
|
90
96
|
email: z.ZodString;
|
|
@@ -94,13 +100,13 @@ declare const getCurrentUser: {
|
|
|
94
100
|
team_name: z.ZodString;
|
|
95
101
|
team_tier: z.ZodString;
|
|
96
102
|
}, z.ZodTypeAny, "passthrough">>;
|
|
97
|
-
|
|
98
|
-
schema: T;
|
|
99
|
-
}): Promise<z.TypeOf<T>>;
|
|
103
|
+
}, safeGetCurrentUser: {
|
|
100
104
|
(client: Client, parameters: {
|
|
101
105
|
schema: false;
|
|
102
|
-
}): Promise<unknown
|
|
103
|
-
|
|
106
|
+
}): Promise<import("..").SafeResult<unknown>>;
|
|
107
|
+
<T extends z.ZodTypeAny>(client: Client, parameters: {
|
|
108
|
+
schema: T;
|
|
109
|
+
}): Promise<import("..").SafeResult<z.TypeOf<T>>>;
|
|
104
110
|
(client: Client): Promise<import("..").SafeResult<z.objectOutputType<{
|
|
105
111
|
username: z.ZodString;
|
|
106
112
|
email: z.ZodString;
|
|
@@ -110,11 +116,5 @@ declare const getCurrentUser: {
|
|
|
110
116
|
team_name: z.ZodString;
|
|
111
117
|
team_tier: z.ZodString;
|
|
112
118
|
}, z.ZodTypeAny, "passthrough">>>;
|
|
113
|
-
<T extends z.ZodTypeAny>(client: Client, parameters: {
|
|
114
|
-
schema: T;
|
|
115
|
-
}): Promise<import("..").SafeResult<z.TypeOf<T>>>;
|
|
116
|
-
(client: Client, parameters: {
|
|
117
|
-
schema: false;
|
|
118
|
-
}): Promise<import("..").SafeResult<unknown>>;
|
|
119
119
|
};
|
|
120
120
|
export { getCurrentUser, safeGetCurrentUser };
|
package/dist/actions/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export { getCvmInfo, safeGetCvmInfo, CvmLegacyDetailSchema, GetCvmInfoRequestSch
|
|
|
12
12
|
export { getCvmList, safeGetCvmList, GetCvmListSchema, GetCvmListRequestSchema, type GetCvmListRequest, type GetCvmListResponse, } from "./cvms/get_cvm_list";
|
|
13
13
|
export { getKmsInfo, safeGetKmsInfo, GetKmsInfoRequestSchema, type GetKmsInfoRequest, } from "./kms/get_kms_info";
|
|
14
14
|
export { getKmsList, safeGetKmsList, GetKmsListSchema, GetKmsListRequestSchema, type GetKmsListRequest, type GetKmsListResponse, } from "./kms/get_kms_list";
|
|
15
|
+
export { nextAppIds, safeNextAppIds, NextAppIdsSchema, NextAppIdsRequestSchema, type NextAppIdsRequest, type NextAppIds, } from "./kms/next_app_ids";
|
|
15
16
|
export { listWorkspaces, safeListWorkspaces, WorkspaceResponseSchema, ListWorkspacesSchema, PaginationMetadataSchema, type WorkspaceResponse, type ListWorkspaces, type PaginationMetadata, type ListWorkspacesRequest, } from "./workspaces/list_workspaces";
|
|
16
17
|
export { getWorkspace, safeGetWorkspace, } from "./workspaces/get_workspace";
|
|
17
18
|
export { listInstanceTypes, safeListInstanceTypes, PaginatedInstanceTypesSchema, InstanceTypeSchema, type PaginatedInstanceTypes, type InstanceType, type ListInstanceTypesRequest, ListInstanceTypesRequestSchema, } from "./list-instance-types";
|
|
@@ -23,7 +24,11 @@ export { deleteCvm, safeDeleteCvm, DeleteCvmRequestSchema, type DeleteCvmRequest
|
|
|
23
24
|
export { getCvmStats, safeGetCvmStats, CvmSystemInfoSchema, GetCvmStatsRequestSchema, type GetCvmStatsRequest, type CvmSystemInfo, } from "./cvms/get_cvm_stats";
|
|
24
25
|
export { getCvmContainersStats, safeGetCvmContainersStats, CvmContainersStatsSchema, GetCvmContainersStatsRequestSchema, type GetCvmContainersStatsRequest, type CvmContainersStats, } from "./cvms/get_cvm_containers_stats";
|
|
25
26
|
export { getCvmNetwork, safeGetCvmNetwork, CvmNetworkSchema, GetCvmNetworkRequestSchema, type GetCvmNetworkRequest, type CvmNetwork, } from "./cvms/get_cvm_network";
|
|
27
|
+
export { getCvmState, safeGetCvmState, CvmStateSchema, GetCvmStateRequestSchema, type GetCvmStateRequest, type CvmState, } from "./cvms/get_cvm_state";
|
|
28
|
+
export { watchCvmState, WatchCvmStateRequestSchema, type WatchCvmStateRequest, type WatchCvmStateOptions, type SSEEvent, WatchAbortedError, MaxRetriesExceededError, } from "./cvms/watch_cvm_state";
|
|
26
29
|
export { getCvmAttestation, safeGetCvmAttestation, CvmAttestationSchema, GetCvmAttestationRequestSchema, type GetCvmAttestationRequest, type CvmAttestation, } from "./cvms/get_cvm_attestation";
|
|
27
30
|
export { getCvmDockerCompose, safeGetCvmDockerCompose, GetCvmDockerComposeRequestSchema, type GetCvmDockerComposeRequest, } from "./cvms/get_cvm_docker_compose";
|
|
28
31
|
export { updateCvmResources, safeUpdateCvmResources, UpdateCvmResourcesRequestSchema, type UpdateCvmResourcesRequest, } from "./cvms/update_cvm_resources";
|
|
29
32
|
export { updateCvmVisibility, safeUpdateCvmVisibility, UpdateCvmVisibilityRequestSchema, type UpdateCvmVisibilityRequest, } from "./cvms/update_cvm_visibility";
|
|
33
|
+
export { getAvailableOsImages, safeGetAvailableOsImages, OSImageVariantSchema, GetAvailableOSImagesResponseSchema, GetAvailableOSImagesRequestSchema, type OSImageVariant, type GetAvailableOSImagesResponse, type GetAvailableOSImagesRequest, } from "./cvms/get_available_os_images";
|
|
34
|
+
export { updateOsImage, safeUpdateOsImage, UpdateOsImageRequestSchema, type UpdateOsImageRequest, } from "./cvms/update_os_image";
|