@phala/cloud 0.2.1-beta.4 → 0.2.2
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/LICENSE +201 -0
- package/dist/actions/apps/get_app_cvms.d.ts +30 -0
- package/dist/actions/apps/get_app_info.d.ts +30 -0
- package/dist/actions/apps/get_app_list.d.ts +74 -0
- package/dist/actions/apps/get_app_revision_detail.d.ts +48 -0
- package/dist/actions/apps/get_app_revisions.d.ts +42 -0
- package/dist/actions/cvms/commit_cvm_compose_file_update.d.ts +7 -7
- package/dist/actions/cvms/commit_cvm_provision.d.ts +31 -31
- package/dist/actions/cvms/delete_cvm.d.ts +10 -7
- package/dist/actions/cvms/get_available_os_images.d.ts +10 -7
- package/dist/actions/cvms/get_cvm_attestation.d.ts +10 -7
- package/dist/actions/cvms/get_cvm_compose_file.d.ts +18 -15
- package/dist/actions/cvms/get_cvm_containers_stats.d.ts +14 -11
- package/dist/actions/cvms/get_cvm_docker_compose.d.ts +10 -7
- package/dist/actions/cvms/get_cvm_info.d.ts +19 -35
- package/dist/actions/cvms/get_cvm_list.d.ts +11 -537
- package/dist/actions/cvms/get_cvm_network.d.ts +10 -7
- package/dist/actions/cvms/get_cvm_prelaunch_script.d.ts +42 -0
- package/dist/actions/cvms/get_cvm_state.d.ts +10 -7
- package/dist/actions/cvms/get_cvm_stats.d.ts +10 -7
- package/dist/actions/cvms/get_cvm_status_batch.d.ts +167 -0
- package/dist/actions/cvms/provision_cvm.d.ts +404 -21
- package/dist/actions/cvms/provision_cvm_compose_file_update.d.ts +32 -32
- package/dist/actions/cvms/restart_cvm.d.ts +17 -14
- package/dist/actions/cvms/shutdown_cvm.d.ts +18 -15
- package/dist/actions/cvms/start_cvm.d.ts +18 -15
- package/dist/actions/cvms/stop_cvm.d.ts +18 -15
- package/dist/actions/cvms/update_cvm_envs.d.ts +32 -118
- package/dist/actions/cvms/update_cvm_resources.d.ts +13 -10
- package/dist/actions/cvms/update_cvm_visibility.d.ts +33 -14
- package/dist/actions/cvms/update_docker_compose.d.ts +420 -0
- package/dist/actions/cvms/update_os_image.d.ts +9 -6
- package/dist/actions/cvms/update_prelaunch_script.d.ts +417 -0
- package/dist/actions/cvms/watch_cvm_state.d.ts +1 -1
- package/dist/actions/get_available_nodes.d.ts +6 -6
- package/dist/actions/get_current_user.d.ts +36 -89
- package/dist/actions/index.d.ts +13 -2
- package/dist/actions/kms/get_app_env_encrypt_pubkey.d.ts +6 -6
- package/dist/actions/kms/get_kms_info.d.ts +6 -6
- package/dist/actions/kms/get_kms_list.d.ts +6 -6
- package/dist/actions/kms/next_app_ids.d.ts +6 -6
- package/dist/actions/list-instance-types.d.ts +16 -16
- package/dist/actions/workspaces/get_workspace.d.ts +8 -6
- package/dist/actions/workspaces/get_workspace_nodes.d.ts +313 -0
- package/dist/actions/workspaces/get_workspace_quotas.d.ts +1169 -0
- package/dist/actions/workspaces/list_workspaces.d.ts +24 -6
- package/dist/client.d.ts +49 -9
- package/dist/create-client.d.ts +72 -36
- package/dist/credentials/current_user_v20251028.d.ts +30 -0
- package/dist/credentials/current_user_v20260121.d.ts +276 -0
- package/dist/credentials/index.d.ts +4 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1713 -664
- package/dist/index.mjs +1627 -657
- package/dist/types/app_info_v20251028.d.ts +1266 -0
- package/dist/types/app_info_v20260121.d.ts +3385 -0
- package/dist/types/app_revision.d.ts +453 -0
- package/dist/types/client.d.ts +41 -3
- package/dist/types/cvm_id.d.ts +29 -11
- package/dist/types/cvm_info.d.ts +16 -502
- package/dist/types/cvm_info_v20251028.d.ts +988 -0
- package/dist/types/cvm_info_v20260121.d.ts +1333 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/version-mappings.d.ts +38 -0
- package/dist/utils/define-action.d.ts +15 -14
- package/dist/utils/errors.d.ts +2 -2
- package/dist/utils/hostname.d.ts +77 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +2 -2
|
@@ -67,6 +67,7 @@ export declare const WorkspaceResponseSchema: z.ZodObject<{
|
|
|
67
67
|
slug: z.ZodNullable<z.ZodString>;
|
|
68
68
|
tier: z.ZodString;
|
|
69
69
|
role: z.ZodString;
|
|
70
|
+
is_default: z.ZodBoolean;
|
|
70
71
|
created_at: z.ZodString;
|
|
71
72
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
72
73
|
id: z.ZodString;
|
|
@@ -74,6 +75,7 @@ export declare const WorkspaceResponseSchema: z.ZodObject<{
|
|
|
74
75
|
slug: z.ZodNullable<z.ZodString>;
|
|
75
76
|
tier: z.ZodString;
|
|
76
77
|
role: z.ZodString;
|
|
78
|
+
is_default: z.ZodBoolean;
|
|
77
79
|
created_at: z.ZodString;
|
|
78
80
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
79
81
|
id: z.ZodString;
|
|
@@ -81,6 +83,7 @@ export declare const WorkspaceResponseSchema: z.ZodObject<{
|
|
|
81
83
|
slug: z.ZodNullable<z.ZodString>;
|
|
82
84
|
tier: z.ZodString;
|
|
83
85
|
role: z.ZodString;
|
|
86
|
+
is_default: z.ZodBoolean;
|
|
84
87
|
created_at: z.ZodString;
|
|
85
88
|
}, z.ZodTypeAny, "passthrough">>;
|
|
86
89
|
export declare const PaginationMetadataSchema: z.ZodObject<{
|
|
@@ -103,6 +106,7 @@ export declare const ListWorkspacesSchema: z.ZodObject<{
|
|
|
103
106
|
slug: z.ZodNullable<z.ZodString>;
|
|
104
107
|
tier: z.ZodString;
|
|
105
108
|
role: z.ZodString;
|
|
109
|
+
is_default: z.ZodBoolean;
|
|
106
110
|
created_at: z.ZodString;
|
|
107
111
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
108
112
|
id: z.ZodString;
|
|
@@ -110,6 +114,7 @@ export declare const ListWorkspacesSchema: z.ZodObject<{
|
|
|
110
114
|
slug: z.ZodNullable<z.ZodString>;
|
|
111
115
|
tier: z.ZodString;
|
|
112
116
|
role: z.ZodString;
|
|
117
|
+
is_default: z.ZodBoolean;
|
|
113
118
|
created_at: z.ZodString;
|
|
114
119
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
115
120
|
id: z.ZodString;
|
|
@@ -117,6 +122,7 @@ export declare const ListWorkspacesSchema: z.ZodObject<{
|
|
|
117
122
|
slug: z.ZodNullable<z.ZodString>;
|
|
118
123
|
tier: z.ZodString;
|
|
119
124
|
role: z.ZodString;
|
|
125
|
+
is_default: z.ZodBoolean;
|
|
120
126
|
created_at: z.ZodString;
|
|
121
127
|
}, z.ZodTypeAny, "passthrough">>, "many">;
|
|
122
128
|
pagination: z.ZodObject<{
|
|
@@ -139,6 +145,7 @@ export declare const ListWorkspacesSchema: z.ZodObject<{
|
|
|
139
145
|
slug: z.ZodNullable<z.ZodString>;
|
|
140
146
|
tier: z.ZodString;
|
|
141
147
|
role: z.ZodString;
|
|
148
|
+
is_default: z.ZodBoolean;
|
|
142
149
|
created_at: z.ZodString;
|
|
143
150
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
144
151
|
id: z.ZodString;
|
|
@@ -146,6 +153,7 @@ export declare const ListWorkspacesSchema: z.ZodObject<{
|
|
|
146
153
|
slug: z.ZodNullable<z.ZodString>;
|
|
147
154
|
tier: z.ZodString;
|
|
148
155
|
role: z.ZodString;
|
|
156
|
+
is_default: z.ZodBoolean;
|
|
149
157
|
created_at: z.ZodString;
|
|
150
158
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
151
159
|
id: z.ZodString;
|
|
@@ -153,6 +161,7 @@ export declare const ListWorkspacesSchema: z.ZodObject<{
|
|
|
153
161
|
slug: z.ZodNullable<z.ZodString>;
|
|
154
162
|
tier: z.ZodString;
|
|
155
163
|
role: z.ZodString;
|
|
164
|
+
is_default: z.ZodBoolean;
|
|
156
165
|
created_at: z.ZodString;
|
|
157
166
|
}, z.ZodTypeAny, "passthrough">>, "many">;
|
|
158
167
|
pagination: z.ZodObject<{
|
|
@@ -175,6 +184,7 @@ export declare const ListWorkspacesSchema: z.ZodObject<{
|
|
|
175
184
|
slug: z.ZodNullable<z.ZodString>;
|
|
176
185
|
tier: z.ZodString;
|
|
177
186
|
role: z.ZodString;
|
|
187
|
+
is_default: z.ZodBoolean;
|
|
178
188
|
created_at: z.ZodString;
|
|
179
189
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
180
190
|
id: z.ZodString;
|
|
@@ -182,6 +192,7 @@ export declare const ListWorkspacesSchema: z.ZodObject<{
|
|
|
182
192
|
slug: z.ZodNullable<z.ZodString>;
|
|
183
193
|
tier: z.ZodString;
|
|
184
194
|
role: z.ZodString;
|
|
195
|
+
is_default: z.ZodBoolean;
|
|
185
196
|
created_at: z.ZodString;
|
|
186
197
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
187
198
|
id: z.ZodString;
|
|
@@ -189,6 +200,7 @@ export declare const ListWorkspacesSchema: z.ZodObject<{
|
|
|
189
200
|
slug: z.ZodNullable<z.ZodString>;
|
|
190
201
|
tier: z.ZodString;
|
|
191
202
|
role: z.ZodString;
|
|
203
|
+
is_default: z.ZodBoolean;
|
|
192
204
|
created_at: z.ZodString;
|
|
193
205
|
}, z.ZodTypeAny, "passthrough">>, "many">;
|
|
194
206
|
pagination: z.ZodObject<{
|
|
@@ -213,13 +225,14 @@ export type ListWorkspacesRequest = {
|
|
|
213
225
|
limit?: number;
|
|
214
226
|
};
|
|
215
227
|
declare const listWorkspaces: {
|
|
216
|
-
(client: Client
|
|
228
|
+
(client: Client<import("../..").ApiVersion>, params?: ListWorkspacesRequest | undefined): Promise<z.objectOutputType<{
|
|
217
229
|
data: z.ZodArray<z.ZodObject<{
|
|
218
230
|
id: z.ZodString;
|
|
219
231
|
name: z.ZodString;
|
|
220
232
|
slug: z.ZodNullable<z.ZodString>;
|
|
221
233
|
tier: z.ZodString;
|
|
222
234
|
role: z.ZodString;
|
|
235
|
+
is_default: z.ZodBoolean;
|
|
223
236
|
created_at: z.ZodString;
|
|
224
237
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
225
238
|
id: z.ZodString;
|
|
@@ -227,6 +240,7 @@ declare const listWorkspaces: {
|
|
|
227
240
|
slug: z.ZodNullable<z.ZodString>;
|
|
228
241
|
tier: z.ZodString;
|
|
229
242
|
role: z.ZodString;
|
|
243
|
+
is_default: z.ZodBoolean;
|
|
230
244
|
created_at: z.ZodString;
|
|
231
245
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
232
246
|
id: z.ZodString;
|
|
@@ -234,6 +248,7 @@ declare const listWorkspaces: {
|
|
|
234
248
|
slug: z.ZodNullable<z.ZodString>;
|
|
235
249
|
tier: z.ZodString;
|
|
236
250
|
role: z.ZodString;
|
|
251
|
+
is_default: z.ZodBoolean;
|
|
237
252
|
created_at: z.ZodString;
|
|
238
253
|
}, z.ZodTypeAny, "passthrough">>, "many">;
|
|
239
254
|
pagination: z.ZodObject<{
|
|
@@ -250,20 +265,21 @@ declare const listWorkspaces: {
|
|
|
250
265
|
total: z.ZodNullable<z.ZodNumber>;
|
|
251
266
|
}, z.ZodTypeAny, "passthrough">>;
|
|
252
267
|
}, z.ZodTypeAny, "passthrough">>;
|
|
253
|
-
<T extends z.ZodTypeAny>(client: Client
|
|
268
|
+
<T extends z.ZodTypeAny>(client: Client<import("../..").ApiVersion>, params?: ListWorkspacesRequest | undefined, parameters?: {
|
|
254
269
|
schema: T;
|
|
255
270
|
} | undefined): Promise<z.TypeOf<T>>;
|
|
256
|
-
(client: Client
|
|
271
|
+
(client: Client<import("../..").ApiVersion>, params?: ListWorkspacesRequest | undefined, parameters?: {
|
|
257
272
|
schema: false;
|
|
258
273
|
} | undefined): Promise<unknown>;
|
|
259
274
|
}, safeListWorkspaces: {
|
|
260
|
-
(client: Client
|
|
275
|
+
(client: Client<import("../..").ApiVersion>, params?: ListWorkspacesRequest | undefined): Promise<import("../..").SafeResult<z.objectOutputType<{
|
|
261
276
|
data: z.ZodArray<z.ZodObject<{
|
|
262
277
|
id: z.ZodString;
|
|
263
278
|
name: z.ZodString;
|
|
264
279
|
slug: z.ZodNullable<z.ZodString>;
|
|
265
280
|
tier: z.ZodString;
|
|
266
281
|
role: z.ZodString;
|
|
282
|
+
is_default: z.ZodBoolean;
|
|
267
283
|
created_at: z.ZodString;
|
|
268
284
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
269
285
|
id: z.ZodString;
|
|
@@ -271,6 +287,7 @@ declare const listWorkspaces: {
|
|
|
271
287
|
slug: z.ZodNullable<z.ZodString>;
|
|
272
288
|
tier: z.ZodString;
|
|
273
289
|
role: z.ZodString;
|
|
290
|
+
is_default: z.ZodBoolean;
|
|
274
291
|
created_at: z.ZodString;
|
|
275
292
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
276
293
|
id: z.ZodString;
|
|
@@ -278,6 +295,7 @@ declare const listWorkspaces: {
|
|
|
278
295
|
slug: z.ZodNullable<z.ZodString>;
|
|
279
296
|
tier: z.ZodString;
|
|
280
297
|
role: z.ZodString;
|
|
298
|
+
is_default: z.ZodBoolean;
|
|
281
299
|
created_at: z.ZodString;
|
|
282
300
|
}, z.ZodTypeAny, "passthrough">>, "many">;
|
|
283
301
|
pagination: z.ZodObject<{
|
|
@@ -294,10 +312,10 @@ declare const listWorkspaces: {
|
|
|
294
312
|
total: z.ZodNullable<z.ZodNumber>;
|
|
295
313
|
}, z.ZodTypeAny, "passthrough">>;
|
|
296
314
|
}, z.ZodTypeAny, "passthrough">>>;
|
|
297
|
-
<T extends z.ZodTypeAny>(client: Client
|
|
315
|
+
<T extends z.ZodTypeAny>(client: Client<import("../..").ApiVersion>, params?: ListWorkspacesRequest | undefined, parameters?: {
|
|
298
316
|
schema: T;
|
|
299
317
|
} | undefined): Promise<import("../..").SafeResult<z.TypeOf<T>>>;
|
|
300
|
-
(client: Client
|
|
318
|
+
(client: Client<import("../..").ApiVersion>, params?: ListWorkspacesRequest | undefined, parameters?: {
|
|
301
319
|
schema: false;
|
|
302
320
|
} | undefined): Promise<import("../..").SafeResult<unknown>>;
|
|
303
321
|
};
|
package/dist/client.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ofetch, type FetchOptions, type FetchRequest } from "ofetch";
|
|
2
2
|
import { type Handler } from "mitt";
|
|
3
|
-
import { type SafeResult, type ClientConfig } from "./types/client";
|
|
3
|
+
import { type SafeResult, type ClientConfig, type ResolvedClientConfig, type FullResponse, type RequestOptions, type ApiVersion, type DefaultApiVersion } from "./types/client";
|
|
4
4
|
import type { Prettify } from "./types/common";
|
|
5
5
|
import { PhalaCloudError } from "./utils/errors";
|
|
6
|
-
export type { SafeResult } from "./types/client";
|
|
7
|
-
export declare const SUPPORTED_API_VERSIONS: readonly ["2025-
|
|
6
|
+
export type { SafeResult, FullResponse, RequestOptions, ApiVersion, DefaultApiVersion, } from "./types/client";
|
|
7
|
+
export declare const SUPPORTED_API_VERSIONS: readonly ["2025-10-28", "2026-01-21"];
|
|
8
|
+
export declare const DEFAULT_API_VERSION: DefaultApiVersion;
|
|
8
9
|
/**
|
|
9
10
|
* Client event types
|
|
10
11
|
*/
|
|
@@ -14,11 +15,11 @@ type ClientEvents = {
|
|
|
14
15
|
/**
|
|
15
16
|
* HTTP Client class with ofetch compatibility
|
|
16
17
|
*/
|
|
17
|
-
export declare class Client {
|
|
18
|
+
export declare class Client<V extends ApiVersion = DefaultApiVersion> {
|
|
18
19
|
protected fetchInstance: typeof ofetch;
|
|
19
|
-
readonly config:
|
|
20
|
+
readonly config: ResolvedClientConfig<V>;
|
|
20
21
|
private emitter;
|
|
21
|
-
constructor(config?: ClientConfig);
|
|
22
|
+
constructor(config?: ClientConfig<V>);
|
|
22
23
|
/**
|
|
23
24
|
* Get the underlying ofetch instance for advanced usage
|
|
24
25
|
*/
|
|
@@ -71,6 +72,17 @@ export declare class Client {
|
|
|
71
72
|
*/
|
|
72
73
|
once<K extends keyof ClientEvents>(type: K, handler: Handler<ClientEvents[K]>): void;
|
|
73
74
|
once(type: "*", handler: Handler): void;
|
|
75
|
+
/**
|
|
76
|
+
* Generic request method (throws PhalaCloudError on error)
|
|
77
|
+
*/
|
|
78
|
+
request<T = unknown>(url: string, options?: RequestOptions): Promise<T>;
|
|
79
|
+
/**
|
|
80
|
+
* Generic request method that returns the full response (status + headers + data)
|
|
81
|
+
*
|
|
82
|
+
* Unlike other direct methods, this does NOT throw for non-2xx HTTP statuses.
|
|
83
|
+
* It only throws for network/transport/unexpected errors.
|
|
84
|
+
*/
|
|
85
|
+
requestFull<T = unknown>(url: string, options?: RequestOptions): Promise<FullResponse<T>>;
|
|
74
86
|
/**
|
|
75
87
|
* Perform GET request (throws PhalaCloudError on error)
|
|
76
88
|
*/
|
|
@@ -126,6 +138,25 @@ export declare class Client {
|
|
|
126
138
|
* Safe DELETE request (returns SafeResult)
|
|
127
139
|
*/
|
|
128
140
|
safeDelete<T = unknown>(request: FetchRequest, options?: Omit<FetchOptions, "method">): Promise<SafeResult<T, PhalaCloudError>>;
|
|
141
|
+
/**
|
|
142
|
+
* Safe wrapper around the generic request method (returns SafeResult)
|
|
143
|
+
*/
|
|
144
|
+
safeRequestMethod<T = unknown>(url: string, options?: RequestOptions): Promise<SafeResult<T, PhalaCloudError>>;
|
|
145
|
+
/**
|
|
146
|
+
* Safe wrapper around requestFull (returns SafeResult)
|
|
147
|
+
*/
|
|
148
|
+
safeRequestFull<T = unknown>(url: string, options?: RequestOptions): Promise<SafeResult<FullResponse<T>, PhalaCloudError>>;
|
|
149
|
+
/**
|
|
150
|
+
* Create a new client with a different API version
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* const client = createClient(); // defaults to 2026-01-21
|
|
155
|
+
* const legacyClient = client.withVersion("2025-10-28");
|
|
156
|
+
* const data = await getCvmInfo(legacyClient, { id: "xxx" });
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
withVersion<NewV extends ApiVersion>(version: NewV): Client<NewV>;
|
|
129
160
|
/**
|
|
130
161
|
* Extend client with additional actions
|
|
131
162
|
*
|
|
@@ -138,8 +169,8 @@ export declare class Client {
|
|
|
138
169
|
* await client.getCurrentUser() // Method call instead of function call
|
|
139
170
|
* ```
|
|
140
171
|
*/
|
|
141
|
-
extend<TActions extends Record<string, unknown>>(actions: TActions | ((client: Client) => TActions)): Prettify<this & {
|
|
142
|
-
[K in keyof TActions]: TActions[K] extends (client: Client) => infer R ? () => R : TActions[K] extends (client: Client
|
|
172
|
+
extend<TActions extends Record<string, unknown>>(actions: TActions | ((client: Client<V>) => TActions)): Prettify<this & {
|
|
173
|
+
[K in keyof TActions]: TActions[K] extends (client: Client<V>) => infer R ? () => R : TActions[K] extends (client: Client<V>, ...args: infer P) => infer R ? (...args: P) => R : never;
|
|
143
174
|
}>;
|
|
144
175
|
}
|
|
145
176
|
/**
|
|
@@ -164,8 +195,17 @@ export declare class Client {
|
|
|
164
195
|
* // Using environment variables (set PHALA_CLOUD_API_KEY)
|
|
165
196
|
* const client = createClient()
|
|
166
197
|
*
|
|
198
|
+
* // Using a specific API version
|
|
199
|
+
* const client = createClient({ version: '2025-10-28' })
|
|
200
|
+
*
|
|
167
201
|
* // To enable debug logging:
|
|
168
202
|
* // DEBUG=phala::api-client node your-script.js
|
|
169
203
|
* ```
|
|
170
204
|
*/
|
|
171
|
-
export declare function createClient(config
|
|
205
|
+
export declare function createClient(config: ClientConfig<"2026-01-21"> & {
|
|
206
|
+
version: "2026-01-21";
|
|
207
|
+
}): Client<"2026-01-21">;
|
|
208
|
+
export declare function createClient(config: ClientConfig<"2025-10-28"> & {
|
|
209
|
+
version: "2025-10-28";
|
|
210
|
+
}): Client<"2025-10-28">;
|
|
211
|
+
export declare function createClient(config?: ClientConfig): Client<DefaultApiVersion>;
|
package/dist/create-client.d.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { Client as BaseClient } from "./client";
|
|
2
|
-
import type { ClientConfig } from "./types/client";
|
|
2
|
+
import type { ClientConfig, ApiVersion, DefaultApiVersion } from "./types/client";
|
|
3
3
|
import type { z } from "zod";
|
|
4
|
-
import {
|
|
4
|
+
import type { GetCurrentUserResponse, GetCvmListResponse, GetCvmInfoResponse } from "./types/version-mappings";
|
|
5
5
|
import { type AvailableNodes } from "./actions/get_available_nodes";
|
|
6
6
|
import { type AllFamiliesResponse, type FamilyInstanceTypesResponse, type ListFamilyInstanceTypesRequest } from "./actions/list-instance-types";
|
|
7
7
|
import { type ListWorkspacesRequest, type ListWorkspaces, type WorkspaceResponse } from "./actions/workspaces/list_workspaces";
|
|
8
|
-
import { type GetCvmInfoRequest
|
|
9
|
-
import { type GetCvmListRequest
|
|
8
|
+
import { type GetCvmInfoRequest } from "./actions/cvms/get_cvm_info";
|
|
9
|
+
import { type GetCvmListRequest } from "./actions/cvms/get_cvm_list";
|
|
10
10
|
import { type ProvisionCvmRequest, type ProvisionCvm } from "./actions/cvms/provision_cvm";
|
|
11
11
|
import { type CommitCvmProvisionRequest, type CommitCvmProvision } from "./actions/cvms/commit_cvm_provision";
|
|
12
12
|
import { type GetCvmComposeFileRequest, type GetCvmComposeFileResult } from "./actions/cvms/get_cvm_compose_file";
|
|
13
13
|
import { type ProvisionCvmComposeFileUpdateRequest, type ProvisionCvmComposeFileUpdateResult } from "./actions/cvms/provision_cvm_compose_file_update";
|
|
14
14
|
import { type CommitCvmComposeFileUpdateRequest, type CommitCvmComposeFileUpdate } from "./actions/cvms/commit_cvm_compose_file_update";
|
|
15
15
|
import { type UpdateCvmEnvsRequest, type UpdateCvmEnvsResult } from "./actions/cvms/update_cvm_envs";
|
|
16
|
+
import { type UpdateDockerComposeRequest, type UpdateDockerComposeResult } from "./actions/cvms/update_docker_compose";
|
|
17
|
+
import { type UpdatePreLaunchScriptRequest, type UpdatePreLaunchScriptResult } from "./actions/cvms/update_prelaunch_script";
|
|
18
|
+
import { type GetCvmPreLaunchScriptRequest } from "./actions/cvms/get_cvm_prelaunch_script";
|
|
16
19
|
import { type GetKmsInfoRequest } from "./actions/kms/get_kms_info";
|
|
17
20
|
import { type GetKmsListRequest, type GetKmsListResponse } from "./actions/kms/get_kms_list";
|
|
18
21
|
import { type GetAppEnvEncryptPubKeyRequest, type GetAppEnvEncryptPubKey as GetAppEnvEncryptPubKeyResult } from "./actions/kms/get_app_env_encrypt_pubkey";
|
|
@@ -51,6 +54,10 @@ import type { SafeResult } from "./types/client";
|
|
|
51
54
|
* const user = await client.getCurrentUser()
|
|
52
55
|
* const cvms = await client.getCvmList()
|
|
53
56
|
* const result = await client.provisionCvm({...})
|
|
57
|
+
*
|
|
58
|
+
* // With specific API version
|
|
59
|
+
* const clientV20251028 = createClient({ apiKey: 'your-api-key', version: '2025-10-28' })
|
|
60
|
+
* const cvms = await clientV20251028.getCvmList() // Returns PaginatedCvmInfosV20251028
|
|
54
61
|
* ```
|
|
55
62
|
*
|
|
56
63
|
* For tree-shaking optimization, use `createBaseClient` with individual action imports:
|
|
@@ -64,22 +71,33 @@ import type { SafeResult } from "./types/client";
|
|
|
64
71
|
* @param config - Client configuration
|
|
65
72
|
* @returns Client extended with all available actions
|
|
66
73
|
*/
|
|
67
|
-
export declare function createClient(config
|
|
74
|
+
export declare function createClient(config: ClientConfig<"2026-01-21"> & {
|
|
75
|
+
version: "2026-01-21";
|
|
76
|
+
}): Client<"2026-01-21">;
|
|
77
|
+
export declare function createClient(config: ClientConfig<"2025-10-28"> & {
|
|
78
|
+
version: "2025-10-28";
|
|
79
|
+
}): Client<"2025-10-28">;
|
|
80
|
+
export declare function createClient(config?: ClientConfig): Client<DefaultApiVersion>;
|
|
68
81
|
/**
|
|
69
82
|
* Extended client type with all action methods
|
|
70
83
|
*
|
|
71
84
|
* This type definition ensures proper type inference for all action methods,
|
|
72
85
|
* including their overload signatures for schema parameters.
|
|
73
86
|
*/
|
|
74
|
-
export interface Client extends BaseClient {
|
|
75
|
-
|
|
87
|
+
export interface Client<V extends ApiVersion = DefaultApiVersion> extends BaseClient<V> {
|
|
88
|
+
withVersion<NewV extends ApiVersion>(version: NewV): Client<NewV>;
|
|
89
|
+
request<T = unknown>(url: string, options?: import("./types/client").RequestOptions): Promise<T>;
|
|
90
|
+
requestFull<T = unknown>(url: string, options?: import("./types/client").RequestOptions): Promise<import("./types/client").FullResponse<T>>;
|
|
91
|
+
safeRequestMethod<T = unknown>(url: string, options?: import("./types/client").RequestOptions): Promise<SafeResult<T, import("./utils/errors").PhalaCloudError>>;
|
|
92
|
+
safeRequestFull<T = unknown>(url: string, options?: import("./types/client").RequestOptions): Promise<SafeResult<import("./types/client").FullResponse<T>, import("./utils/errors").PhalaCloudError>>;
|
|
93
|
+
getCurrentUser(): Promise<GetCurrentUserResponse<V>>;
|
|
76
94
|
getCurrentUser<T extends z.ZodTypeAny>(parameters: {
|
|
77
95
|
schema: T;
|
|
78
96
|
}): Promise<z.infer<T>>;
|
|
79
97
|
getCurrentUser(parameters: {
|
|
80
98
|
schema: false;
|
|
81
99
|
}): Promise<unknown>;
|
|
82
|
-
safeGetCurrentUser(): Promise<SafeResult<
|
|
100
|
+
safeGetCurrentUser(): Promise<SafeResult<GetCurrentUserResponse<V>>>;
|
|
83
101
|
safeGetCurrentUser<T extends z.ZodTypeAny>(parameters: {
|
|
84
102
|
schema: T;
|
|
85
103
|
}): Promise<SafeResult<z.infer<T>>>;
|
|
@@ -142,20 +160,8 @@ export interface Client extends BaseClient {
|
|
|
142
160
|
safeListWorkspaces(request: ListWorkspacesRequest | undefined, parameters: {
|
|
143
161
|
schema: false;
|
|
144
162
|
}): Promise<SafeResult<unknown>>;
|
|
145
|
-
getCvmList(request?: GetCvmListRequest): Promise<GetCvmListResponse
|
|
146
|
-
|
|
147
|
-
schema: T;
|
|
148
|
-
}): Promise<z.infer<T>>;
|
|
149
|
-
getCvmList(request: GetCvmListRequest | undefined, parameters: {
|
|
150
|
-
schema: false;
|
|
151
|
-
}): Promise<unknown>;
|
|
152
|
-
safeGetCvmList(request?: GetCvmListRequest): Promise<SafeResult<GetCvmListResponse>>;
|
|
153
|
-
safeGetCvmList<T extends z.ZodTypeAny>(request: GetCvmListRequest | undefined, parameters: {
|
|
154
|
-
schema: T;
|
|
155
|
-
}): Promise<SafeResult<z.infer<T>>>;
|
|
156
|
-
safeGetCvmList(request: GetCvmListRequest | undefined, parameters: {
|
|
157
|
-
schema: false;
|
|
158
|
-
}): Promise<SafeResult<unknown>>;
|
|
163
|
+
getCvmList(request?: GetCvmListRequest): Promise<GetCvmListResponse<V>>;
|
|
164
|
+
safeGetCvmList(request?: GetCvmListRequest): Promise<SafeResult<GetCvmListResponse<V>>>;
|
|
159
165
|
getKmsList(request?: GetKmsListRequest): Promise<GetKmsListResponse>;
|
|
160
166
|
getKmsList<T extends z.ZodTypeAny>(request: GetKmsListRequest | undefined, parameters: {
|
|
161
167
|
schema: T;
|
|
@@ -184,20 +190,8 @@ export interface Client extends BaseClient {
|
|
|
184
190
|
safeGetWorkspace(teamSlug: string, parameters: {
|
|
185
191
|
schema: false;
|
|
186
192
|
}): Promise<SafeResult<unknown>>;
|
|
187
|
-
getCvmInfo(request: GetCvmInfoRequest): Promise<GetCvmInfoResponse
|
|
188
|
-
|
|
189
|
-
schema: T;
|
|
190
|
-
}): Promise<z.infer<T>>;
|
|
191
|
-
getCvmInfo(request: GetCvmInfoRequest, parameters: {
|
|
192
|
-
schema: false;
|
|
193
|
-
}): Promise<unknown>;
|
|
194
|
-
safeGetCvmInfo(request: GetCvmInfoRequest): Promise<SafeResult<GetCvmInfoResponse>>;
|
|
195
|
-
safeGetCvmInfo<T extends z.ZodTypeAny>(request: GetCvmInfoRequest, parameters: {
|
|
196
|
-
schema: T;
|
|
197
|
-
}): Promise<SafeResult<z.infer<T>>>;
|
|
198
|
-
safeGetCvmInfo(request: GetCvmInfoRequest, parameters: {
|
|
199
|
-
schema: false;
|
|
200
|
-
}): Promise<SafeResult<unknown>>;
|
|
193
|
+
getCvmInfo(request: GetCvmInfoRequest): Promise<GetCvmInfoResponse<V>>;
|
|
194
|
+
safeGetCvmInfo(request: GetCvmInfoRequest): Promise<SafeResult<GetCvmInfoResponse<V>>>;
|
|
201
195
|
getCvmComposeFile(request: GetCvmComposeFileRequest): Promise<GetCvmComposeFileResult>;
|
|
202
196
|
getCvmComposeFile<T extends z.ZodTypeAny>(request: GetCvmComposeFileRequest, parameters: {
|
|
203
197
|
schema: T;
|
|
@@ -282,6 +276,48 @@ export interface Client extends BaseClient {
|
|
|
282
276
|
safeUpdateCvmEnvs(request: UpdateCvmEnvsRequest, parameters: {
|
|
283
277
|
schema: false;
|
|
284
278
|
}): Promise<SafeResult<unknown>>;
|
|
279
|
+
updateDockerCompose(request: UpdateDockerComposeRequest): Promise<UpdateDockerComposeResult>;
|
|
280
|
+
updateDockerCompose<T extends z.ZodTypeAny>(request: UpdateDockerComposeRequest, parameters: {
|
|
281
|
+
schema: T;
|
|
282
|
+
}): Promise<z.infer<T>>;
|
|
283
|
+
updateDockerCompose(request: UpdateDockerComposeRequest, parameters: {
|
|
284
|
+
schema: false;
|
|
285
|
+
}): Promise<unknown>;
|
|
286
|
+
safeUpdateDockerCompose(request: UpdateDockerComposeRequest): Promise<SafeResult<UpdateDockerComposeResult>>;
|
|
287
|
+
safeUpdateDockerCompose<T extends z.ZodTypeAny>(request: UpdateDockerComposeRequest, parameters: {
|
|
288
|
+
schema: T;
|
|
289
|
+
}): Promise<SafeResult<z.infer<T>>>;
|
|
290
|
+
safeUpdateDockerCompose(request: UpdateDockerComposeRequest, parameters: {
|
|
291
|
+
schema: false;
|
|
292
|
+
}): Promise<SafeResult<unknown>>;
|
|
293
|
+
updatePreLaunchScript(request: UpdatePreLaunchScriptRequest): Promise<UpdatePreLaunchScriptResult>;
|
|
294
|
+
updatePreLaunchScript<T extends z.ZodTypeAny>(request: UpdatePreLaunchScriptRequest, parameters: {
|
|
295
|
+
schema: T;
|
|
296
|
+
}): Promise<z.infer<T>>;
|
|
297
|
+
updatePreLaunchScript(request: UpdatePreLaunchScriptRequest, parameters: {
|
|
298
|
+
schema: false;
|
|
299
|
+
}): Promise<unknown>;
|
|
300
|
+
safeUpdatePreLaunchScript(request: UpdatePreLaunchScriptRequest): Promise<SafeResult<UpdatePreLaunchScriptResult>>;
|
|
301
|
+
safeUpdatePreLaunchScript<T extends z.ZodTypeAny>(request: UpdatePreLaunchScriptRequest, parameters: {
|
|
302
|
+
schema: T;
|
|
303
|
+
}): Promise<SafeResult<z.infer<T>>>;
|
|
304
|
+
safeUpdatePreLaunchScript(request: UpdatePreLaunchScriptRequest, parameters: {
|
|
305
|
+
schema: false;
|
|
306
|
+
}): Promise<SafeResult<unknown>>;
|
|
307
|
+
getCvmPreLaunchScript(request: GetCvmPreLaunchScriptRequest): Promise<string>;
|
|
308
|
+
getCvmPreLaunchScript<T extends z.ZodTypeAny>(request: GetCvmPreLaunchScriptRequest, parameters: {
|
|
309
|
+
schema: T;
|
|
310
|
+
}): Promise<z.infer<T>>;
|
|
311
|
+
getCvmPreLaunchScript(request: GetCvmPreLaunchScriptRequest, parameters: {
|
|
312
|
+
schema: false;
|
|
313
|
+
}): Promise<unknown>;
|
|
314
|
+
safeGetCvmPreLaunchScript(request: GetCvmPreLaunchScriptRequest): Promise<SafeResult<string>>;
|
|
315
|
+
safeGetCvmPreLaunchScript<T extends z.ZodTypeAny>(request: GetCvmPreLaunchScriptRequest, parameters: {
|
|
316
|
+
schema: T;
|
|
317
|
+
}): Promise<SafeResult<z.infer<T>>>;
|
|
318
|
+
safeGetCvmPreLaunchScript(request: GetCvmPreLaunchScriptRequest, parameters: {
|
|
319
|
+
schema: false;
|
|
320
|
+
}): Promise<SafeResult<unknown>>;
|
|
285
321
|
getKmsInfo(request: GetKmsInfoRequest): Promise<KmsInfo>;
|
|
286
322
|
getKmsInfo<T extends z.ZodTypeAny>(request: GetKmsInfoRequest, parameters: {
|
|
287
323
|
schema: T;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Current user schema for API version 2025-10-28 (legacy flat format)
|
|
4
|
+
*/
|
|
5
|
+
export declare const CurrentUserV20251028Schema: z.ZodObject<{
|
|
6
|
+
username: z.ZodString;
|
|
7
|
+
email: z.ZodString;
|
|
8
|
+
credits: z.ZodNumber;
|
|
9
|
+
granted_credits: z.ZodNumber;
|
|
10
|
+
avatar: z.ZodString;
|
|
11
|
+
team_name: z.ZodString;
|
|
12
|
+
team_tier: z.ZodString;
|
|
13
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
14
|
+
username: z.ZodString;
|
|
15
|
+
email: z.ZodString;
|
|
16
|
+
credits: z.ZodNumber;
|
|
17
|
+
granted_credits: z.ZodNumber;
|
|
18
|
+
avatar: z.ZodString;
|
|
19
|
+
team_name: z.ZodString;
|
|
20
|
+
team_tier: z.ZodString;
|
|
21
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
22
|
+
username: z.ZodString;
|
|
23
|
+
email: z.ZodString;
|
|
24
|
+
credits: z.ZodNumber;
|
|
25
|
+
granted_credits: z.ZodNumber;
|
|
26
|
+
avatar: z.ZodString;
|
|
27
|
+
team_name: z.ZodString;
|
|
28
|
+
team_tier: z.ZodString;
|
|
29
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
30
|
+
export type CurrentUserV20251028 = z.infer<typeof CurrentUserV20251028Schema>;
|