@phala/cloud 0.2.1-beta.4 → 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.
Files changed (69) hide show
  1. package/LICENSE +201 -0
  2. package/dist/actions/apps/get_app_cvms.d.ts +30 -0
  3. package/dist/actions/apps/get_app_info.d.ts +30 -0
  4. package/dist/actions/apps/get_app_list.d.ts +74 -0
  5. package/dist/actions/apps/get_app_revision_detail.d.ts +48 -0
  6. package/dist/actions/apps/get_app_revisions.d.ts +42 -0
  7. package/dist/actions/cvms/commit_cvm_compose_file_update.d.ts +7 -7
  8. package/dist/actions/cvms/commit_cvm_provision.d.ts +31 -31
  9. package/dist/actions/cvms/delete_cvm.d.ts +10 -7
  10. package/dist/actions/cvms/get_available_os_images.d.ts +10 -7
  11. package/dist/actions/cvms/get_cvm_attestation.d.ts +10 -7
  12. package/dist/actions/cvms/get_cvm_compose_file.d.ts +18 -15
  13. package/dist/actions/cvms/get_cvm_containers_stats.d.ts +14 -11
  14. package/dist/actions/cvms/get_cvm_docker_compose.d.ts +10 -7
  15. package/dist/actions/cvms/get_cvm_info.d.ts +19 -35
  16. package/dist/actions/cvms/get_cvm_list.d.ts +11 -537
  17. package/dist/actions/cvms/get_cvm_network.d.ts +10 -7
  18. package/dist/actions/cvms/get_cvm_prelaunch_script.d.ts +42 -0
  19. package/dist/actions/cvms/get_cvm_state.d.ts +10 -7
  20. package/dist/actions/cvms/get_cvm_stats.d.ts +10 -7
  21. package/dist/actions/cvms/get_cvm_status_batch.d.ts +167 -0
  22. package/dist/actions/cvms/provision_cvm.d.ts +404 -21
  23. package/dist/actions/cvms/provision_cvm_compose_file_update.d.ts +32 -32
  24. package/dist/actions/cvms/restart_cvm.d.ts +17 -14
  25. package/dist/actions/cvms/shutdown_cvm.d.ts +18 -15
  26. package/dist/actions/cvms/start_cvm.d.ts +18 -15
  27. package/dist/actions/cvms/stop_cvm.d.ts +18 -15
  28. package/dist/actions/cvms/update_cvm_envs.d.ts +32 -118
  29. package/dist/actions/cvms/update_cvm_resources.d.ts +13 -10
  30. package/dist/actions/cvms/update_cvm_visibility.d.ts +33 -14
  31. package/dist/actions/cvms/update_docker_compose.d.ts +420 -0
  32. package/dist/actions/cvms/update_os_image.d.ts +9 -6
  33. package/dist/actions/cvms/update_prelaunch_script.d.ts +417 -0
  34. package/dist/actions/cvms/watch_cvm_state.d.ts +1 -1
  35. package/dist/actions/get_available_nodes.d.ts +6 -6
  36. package/dist/actions/get_current_user.d.ts +36 -89
  37. package/dist/actions/index.d.ts +13 -2
  38. package/dist/actions/kms/get_app_env_encrypt_pubkey.d.ts +6 -6
  39. package/dist/actions/kms/get_kms_info.d.ts +6 -6
  40. package/dist/actions/kms/get_kms_list.d.ts +6 -6
  41. package/dist/actions/kms/next_app_ids.d.ts +6 -6
  42. package/dist/actions/list-instance-types.d.ts +16 -16
  43. package/dist/actions/workspaces/get_workspace.d.ts +6 -6
  44. package/dist/actions/workspaces/get_workspace_nodes.d.ts +266 -0
  45. package/dist/actions/workspaces/get_workspace_quotas.d.ts +1169 -0
  46. package/dist/actions/workspaces/list_workspaces.d.ts +6 -6
  47. package/dist/client.d.ts +49 -9
  48. package/dist/create-client.d.ts +72 -36
  49. package/dist/credentials/current_user_v20251028.d.ts +30 -0
  50. package/dist/credentials/current_user_v20260121.d.ts +276 -0
  51. package/dist/credentials/index.d.ts +4 -0
  52. package/dist/index.d.ts +1 -0
  53. package/dist/index.js +1714 -664
  54. package/dist/index.mjs +1629 -657
  55. package/dist/types/app_info_v20251028.d.ts +1266 -0
  56. package/dist/types/app_info_v20260121.d.ts +3293 -0
  57. package/dist/types/app_revision.d.ts +453 -0
  58. package/dist/types/client.d.ts +40 -2
  59. package/dist/types/cvm_id.d.ts +29 -11
  60. package/dist/types/cvm_info.d.ts +16 -502
  61. package/dist/types/cvm_info_v20251028.d.ts +988 -0
  62. package/dist/types/cvm_info_v20260121.d.ts +1264 -0
  63. package/dist/types/index.d.ts +6 -0
  64. package/dist/types/version-mappings.d.ts +38 -0
  65. package/dist/utils/define-action.d.ts +15 -14
  66. package/dist/utils/errors.d.ts +2 -2
  67. package/dist/utils/hostname.d.ts +77 -0
  68. package/dist/utils/index.d.ts +1 -0
  69. package/package.json +2 -2
@@ -0,0 +1,417 @@
1
+ import { z } from "zod";
2
+ import { type Client } from "../../client";
3
+ /**
4
+ * Update CVM pre-launch script
5
+ *
6
+ * Updates the pre-launch script for a CVM. The pre-launch script runs before the main containers start.
7
+ * Supports two scenarios:
8
+ * 1. Legacy/offchain KMS: Direct update without compose hash verification
9
+ * 2. Contract-owned KMS (ETHEREUM/BASE): Requires compose hash verification (two-phase)
10
+ *
11
+ * When using contract-owned KMS and compose_hash/transaction_hash are not provided,
12
+ * the API returns HTTP 465 with the compose hash to sign.
13
+ * The client should then register the compose hash on-chain and retry the request
14
+ * with both compose_hash and transaction_hash.
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import { createClient, updatePreLaunchScript } from '@phala/cloud'
19
+ *
20
+ * const client = createClient({ apiKey: 'your-api-key' })
21
+ *
22
+ * const script = `#!/bin/bash
23
+ * echo "Initializing..."
24
+ * # Your pre-launch commands here
25
+ * `
26
+ *
27
+ * // Phase 1: Initial update (may return precondition_required for contract-owned KMS)
28
+ * const result = await updatePreLaunchScript(client, {
29
+ * id: 'cvm-123',
30
+ * pre_launch_script: script
31
+ * })
32
+ *
33
+ * if (result.status === 'precondition_required') {
34
+ * // Register compose hash on-chain and get transaction hash
35
+ * const txHash = await registerComposeHashOnChain(
36
+ * result.compose_hash,
37
+ * result.kms_info
38
+ * )
39
+ *
40
+ * // Phase 2: Retry with compose hash and transaction hash
41
+ * const finalResult = await updatePreLaunchScript(client, {
42
+ * id: 'cvm-123',
43
+ * pre_launch_script: script,
44
+ * compose_hash: result.compose_hash,
45
+ * transaction_hash: txHash
46
+ * })
47
+ *
48
+ * if (finalResult.status === 'in_progress') {
49
+ * console.log(`Update started: ${finalResult.correlation_id}`)
50
+ * }
51
+ * }
52
+ * ```
53
+ *
54
+ * ## Returns
55
+ *
56
+ * `UpdatePreLaunchScriptResult | unknown`
57
+ *
58
+ * Returns either:
59
+ * - `{ status: "in_progress", ... }` - Update initiated successfully
60
+ * - `{ status: "precondition_required", compose_hash: "...", ... }` - Compose hash verification required
61
+ *
62
+ * Return type depends on schema parameter.
63
+ *
64
+ * ## Parameters
65
+ *
66
+ * ### request (required)
67
+ * - **Type:** `UpdatePreLaunchScriptRequest`
68
+ *
69
+ * Request parameters containing CVM ID, pre_launch_script content, and optional compose_hash/transaction_hash.
70
+ *
71
+ * ### parameters (optional)
72
+ * - **Type:** `UpdatePreLaunchScriptParameters`
73
+ *
74
+ * Optional behavior parameters for schema validation.
75
+ *
76
+ * ```typescript
77
+ * // Use default schema
78
+ * const result = await updatePreLaunchScript(client, {
79
+ * id: 'cvm-123',
80
+ * pre_launch_script: script
81
+ * })
82
+ *
83
+ * // Return raw data without validation
84
+ * const raw = await updatePreLaunchScript(client, request, { schema: false })
85
+ *
86
+ * // Use custom schema
87
+ * const customSchema = z.object({ status: z.string() })
88
+ * const custom = await updatePreLaunchScript(client, request, { schema: customSchema })
89
+ * ```
90
+ *
91
+ * ## Safe Version
92
+ *
93
+ * Use `safeUpdatePreLaunchScript` for error handling without exceptions:
94
+ *
95
+ * ```typescript
96
+ * import { safeUpdatePreLaunchScript } from '@phala/cloud'
97
+ *
98
+ * const result = await safeUpdatePreLaunchScript(client, {
99
+ * id: 'cvm-123',
100
+ * pre_launch_script: script
101
+ * })
102
+ *
103
+ * if (result.success) {
104
+ * if (result.data.status === 'precondition_required') {
105
+ * console.log(`Compose hash: ${result.data.compose_hash}`)
106
+ * console.log(`App ID: ${result.data.app_id}`)
107
+ * // Register on-chain and retry with transaction_hash
108
+ * } else {
109
+ * console.log(`Update started: ${result.data.correlation_id}`)
110
+ * }
111
+ * } else {
112
+ * if ("isRequestError" in result.error) {
113
+ * console.error(`HTTP ${result.error.status}: ${result.error.message}`)
114
+ * } else {
115
+ * console.error(`Validation error: ${result.error.issues}`)
116
+ * }
117
+ * }
118
+ * ```
119
+ */
120
+ export declare const UpdatePreLaunchScriptRequestSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
121
+ id: z.ZodOptional<z.ZodString>;
122
+ uuid: z.ZodOptional<z.ZodString>;
123
+ app_id: z.ZodOptional<z.ZodString>;
124
+ instance_id: z.ZodOptional<z.ZodString>;
125
+ name: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
126
+ } & {
127
+ pre_launch_script: z.ZodString;
128
+ compose_hash: z.ZodOptional<z.ZodString>;
129
+ transaction_hash: z.ZodOptional<z.ZodString>;
130
+ }, "strip", z.ZodTypeAny, {
131
+ pre_launch_script: string;
132
+ name?: string | undefined;
133
+ id?: string | undefined;
134
+ app_id?: string | undefined;
135
+ instance_id?: string | undefined;
136
+ compose_hash?: string | undefined;
137
+ uuid?: string | undefined;
138
+ transaction_hash?: string | undefined;
139
+ }, {
140
+ pre_launch_script: string;
141
+ name?: string | undefined;
142
+ id?: string | undefined;
143
+ app_id?: string | undefined;
144
+ instance_id?: string | undefined;
145
+ compose_hash?: string | undefined;
146
+ uuid?: string | undefined;
147
+ transaction_hash?: string | undefined;
148
+ }>, any, any>, {
149
+ cvmId: any;
150
+ request: {
151
+ pre_launch_script: any;
152
+ compose_hash: any;
153
+ transaction_hash: any;
154
+ };
155
+ _raw: any;
156
+ }, any>;
157
+ declare const UpdatePreLaunchScriptInProgressSchema: z.ZodObject<{
158
+ status: z.ZodLiteral<"in_progress">;
159
+ message: z.ZodString;
160
+ correlation_id: z.ZodString;
161
+ }, "strip", z.ZodTypeAny, {
162
+ status: "in_progress";
163
+ message: string;
164
+ correlation_id: string;
165
+ }, {
166
+ status: "in_progress";
167
+ message: string;
168
+ correlation_id: string;
169
+ }>;
170
+ declare const UpdatePreLaunchScriptPreconditionRequiredSchema: z.ZodObject<{
171
+ status: z.ZodLiteral<"precondition_required">;
172
+ message: z.ZodString;
173
+ compose_hash: z.ZodString;
174
+ app_id: z.ZodString;
175
+ device_id: z.ZodString;
176
+ kms_info: z.ZodEffects<z.ZodObject<{
177
+ id: z.ZodString;
178
+ slug: z.ZodNullable<z.ZodString>;
179
+ url: z.ZodString;
180
+ version: z.ZodString;
181
+ chain_id: z.ZodNullable<z.ZodNumber>;
182
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
183
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
184
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
185
+ id: z.ZodString;
186
+ slug: z.ZodNullable<z.ZodString>;
187
+ url: z.ZodString;
188
+ version: z.ZodString;
189
+ chain_id: z.ZodNullable<z.ZodNumber>;
190
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
191
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
192
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
193
+ id: z.ZodString;
194
+ slug: z.ZodNullable<z.ZodString>;
195
+ url: z.ZodString;
196
+ version: z.ZodString;
197
+ chain_id: z.ZodNullable<z.ZodNumber>;
198
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
199
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
200
+ }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
201
+ id: z.ZodString;
202
+ slug: z.ZodNullable<z.ZodString>;
203
+ url: z.ZodString;
204
+ version: z.ZodString;
205
+ chain_id: z.ZodNullable<z.ZodNumber>;
206
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
207
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
208
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
209
+ id: z.ZodString;
210
+ slug: z.ZodNullable<z.ZodString>;
211
+ url: z.ZodString;
212
+ version: z.ZodString;
213
+ chain_id: z.ZodNullable<z.ZodNumber>;
214
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
215
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
216
+ }, z.ZodTypeAny, "passthrough">>;
217
+ }, "strip", z.ZodTypeAny, {
218
+ status: "precondition_required";
219
+ message: string;
220
+ app_id: string;
221
+ kms_info: {
222
+ version: string;
223
+ id: string;
224
+ slug: string | null;
225
+ url: string;
226
+ chain_id: number | null;
227
+ kms_contract_address: `0x${string}`;
228
+ gateway_app_id: `0x${string}`;
229
+ } & {
230
+ [k: string]: unknown;
231
+ };
232
+ device_id: string;
233
+ compose_hash: string;
234
+ }, {
235
+ status: "precondition_required";
236
+ message: string;
237
+ app_id: string;
238
+ kms_info: {
239
+ version: string;
240
+ id: string;
241
+ slug: string | null;
242
+ url: string;
243
+ chain_id: number | null;
244
+ kms_contract_address: string | null;
245
+ gateway_app_id: string | null;
246
+ } & {
247
+ [k: string]: unknown;
248
+ };
249
+ device_id: string;
250
+ compose_hash: string;
251
+ }>;
252
+ export declare const UpdatePreLaunchScriptResultSchema: z.ZodUnion<[z.ZodObject<{
253
+ status: z.ZodLiteral<"in_progress">;
254
+ message: z.ZodString;
255
+ correlation_id: z.ZodString;
256
+ }, "strip", z.ZodTypeAny, {
257
+ status: "in_progress";
258
+ message: string;
259
+ correlation_id: string;
260
+ }, {
261
+ status: "in_progress";
262
+ message: string;
263
+ correlation_id: string;
264
+ }>, z.ZodObject<{
265
+ status: z.ZodLiteral<"precondition_required">;
266
+ message: z.ZodString;
267
+ compose_hash: z.ZodString;
268
+ app_id: z.ZodString;
269
+ device_id: z.ZodString;
270
+ kms_info: z.ZodEffects<z.ZodObject<{
271
+ id: z.ZodString;
272
+ slug: z.ZodNullable<z.ZodString>;
273
+ url: z.ZodString;
274
+ version: z.ZodString;
275
+ chain_id: z.ZodNullable<z.ZodNumber>;
276
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
277
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
278
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
279
+ id: z.ZodString;
280
+ slug: z.ZodNullable<z.ZodString>;
281
+ url: z.ZodString;
282
+ version: z.ZodString;
283
+ chain_id: z.ZodNullable<z.ZodNumber>;
284
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
285
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
286
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
287
+ id: z.ZodString;
288
+ slug: z.ZodNullable<z.ZodString>;
289
+ url: z.ZodString;
290
+ version: z.ZodString;
291
+ chain_id: z.ZodNullable<z.ZodNumber>;
292
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
293
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
294
+ }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
295
+ id: z.ZodString;
296
+ slug: z.ZodNullable<z.ZodString>;
297
+ url: z.ZodString;
298
+ version: z.ZodString;
299
+ chain_id: z.ZodNullable<z.ZodNumber>;
300
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
301
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
302
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
303
+ id: z.ZodString;
304
+ slug: z.ZodNullable<z.ZodString>;
305
+ url: z.ZodString;
306
+ version: z.ZodString;
307
+ chain_id: z.ZodNullable<z.ZodNumber>;
308
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
309
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
310
+ }, z.ZodTypeAny, "passthrough">>;
311
+ }, "strip", z.ZodTypeAny, {
312
+ status: "precondition_required";
313
+ message: string;
314
+ app_id: string;
315
+ kms_info: {
316
+ version: string;
317
+ id: string;
318
+ slug: string | null;
319
+ url: string;
320
+ chain_id: number | null;
321
+ kms_contract_address: `0x${string}`;
322
+ gateway_app_id: `0x${string}`;
323
+ } & {
324
+ [k: string]: unknown;
325
+ };
326
+ device_id: string;
327
+ compose_hash: string;
328
+ }, {
329
+ status: "precondition_required";
330
+ message: string;
331
+ app_id: string;
332
+ kms_info: {
333
+ version: string;
334
+ id: string;
335
+ slug: string | null;
336
+ url: string;
337
+ chain_id: number | null;
338
+ kms_contract_address: string | null;
339
+ gateway_app_id: string | null;
340
+ } & {
341
+ [k: string]: unknown;
342
+ };
343
+ device_id: string;
344
+ compose_hash: string;
345
+ }>]>;
346
+ export type UpdatePreLaunchScriptRequest = z.input<typeof UpdatePreLaunchScriptRequestSchema>;
347
+ export type UpdatePreLaunchScriptResult = z.infer<typeof UpdatePreLaunchScriptResultSchema>;
348
+ export type UpdatePreLaunchScriptInProgress = z.infer<typeof UpdatePreLaunchScriptInProgressSchema>;
349
+ export type UpdatePreLaunchScriptPreconditionRequired = z.infer<typeof UpdatePreLaunchScriptPreconditionRequiredSchema>;
350
+ /**
351
+ * Update CVM pre-launch script
352
+ *
353
+ * @param client - The API client
354
+ * @param request - Request parameters containing CVM ID and pre-launch script content
355
+ * @param parameters - Optional behavior parameters
356
+ * @returns Update result (either in_progress or precondition_required)
357
+ */
358
+ declare const updatePreLaunchScript: {
359
+ (client: Client<import("../..").ApiVersion>, params?: any): Promise<{
360
+ status: "in_progress";
361
+ message: string;
362
+ correlation_id: string;
363
+ } | {
364
+ status: "precondition_required";
365
+ message: string;
366
+ app_id: string;
367
+ kms_info: {
368
+ version: string;
369
+ id: string;
370
+ slug: string | null;
371
+ url: string;
372
+ chain_id: number | null;
373
+ kms_contract_address: `0x${string}`;
374
+ gateway_app_id: `0x${string}`;
375
+ } & {
376
+ [k: string]: unknown;
377
+ };
378
+ device_id: string;
379
+ compose_hash: string;
380
+ }>;
381
+ <T extends z.ZodTypeAny>(client: Client<import("../..").ApiVersion>, params?: any, parameters?: {
382
+ schema: T;
383
+ } | undefined): Promise<z.TypeOf<T>>;
384
+ (client: Client<import("../..").ApiVersion>, params?: any, parameters?: {
385
+ schema: false;
386
+ } | undefined): Promise<unknown>;
387
+ }, safeUpdatePreLaunchScript: {
388
+ (client: Client<import("../..").ApiVersion>, params?: any): Promise<import("../..").SafeResult<{
389
+ status: "in_progress";
390
+ message: string;
391
+ correlation_id: string;
392
+ } | {
393
+ status: "precondition_required";
394
+ message: string;
395
+ app_id: string;
396
+ kms_info: {
397
+ version: string;
398
+ id: string;
399
+ slug: string | null;
400
+ url: string;
401
+ chain_id: number | null;
402
+ kms_contract_address: `0x${string}`;
403
+ gateway_app_id: `0x${string}`;
404
+ } & {
405
+ [k: string]: unknown;
406
+ };
407
+ device_id: string;
408
+ compose_hash: string;
409
+ }>>;
410
+ <T extends z.ZodTypeAny>(client: Client<import("../..").ApiVersion>, params?: any, parameters?: {
411
+ schema: T;
412
+ } | undefined): Promise<import("../..").SafeResult<z.TypeOf<T>>>;
413
+ (client: Client<import("../..").ApiVersion>, params?: any, parameters?: {
414
+ schema: false;
415
+ } | undefined): Promise<import("../..").SafeResult<unknown>>;
416
+ };
417
+ export { updatePreLaunchScript, safeUpdatePreLaunchScript };
@@ -53,8 +53,8 @@ export declare const WatchCvmStateRequestSchema: z.ZodObject<{
53
53
  }, "strip", z.ZodTypeAny, {
54
54
  timeout: number;
55
55
  retryDelay: number;
56
- maxRetries: number;
57
56
  target: string;
57
+ maxRetries: number;
58
58
  interval: number;
59
59
  }, {
60
60
  target: string;
@@ -637,13 +637,13 @@ 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: {
640
+ (client: Client<import("..").ApiVersion>, parameters: {
641
641
  schema: false;
642
642
  }): Promise<unknown>;
643
- <T extends z.ZodTypeAny>(client: Client, parameters: {
643
+ <T extends z.ZodTypeAny>(client: Client<import("..").ApiVersion>, parameters: {
644
644
  schema: T;
645
645
  }): Promise<z.TypeOf<T>>;
646
- (client: Client): Promise<z.objectOutputType<{
646
+ (client: Client<import("..").ApiVersion>): Promise<z.objectOutputType<{
647
647
  tier: z.ZodString;
648
648
  capacity: z.ZodObject<{
649
649
  max_instances: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
@@ -795,13 +795,13 @@ declare const getAvailableNodes: {
795
795
  }, z.ZodTypeAny, "passthrough">>, "many">;
796
796
  }, z.ZodTypeAny, "passthrough">>;
797
797
  }, safeGetAvailableNodes: {
798
- (client: Client, parameters: {
798
+ (client: Client<import("..").ApiVersion>, parameters: {
799
799
  schema: false;
800
800
  }): Promise<import("..").SafeResult<unknown>>;
801
- <T extends z.ZodTypeAny>(client: Client, parameters: {
801
+ <T extends z.ZodTypeAny>(client: Client<import("..").ApiVersion>, parameters: {
802
802
  schema: T;
803
803
  }): Promise<import("..").SafeResult<z.TypeOf<T>>>;
804
- (client: Client): Promise<import("..").SafeResult<z.objectOutputType<{
804
+ (client: Client<import("..").ApiVersion>): Promise<import("..").SafeResult<z.objectOutputType<{
805
805
  tier: z.ZodString;
806
806
  capacity: z.ZodObject<{
807
807
  max_instances: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
@@ -1,42 +1,32 @@
1
1
  import { z } from "zod";
2
- import { type Client } from "../client";
2
+ import { type Client, type SafeResult } from "../client";
3
+ import type { ApiVersion } from "../types/client";
4
+ import type { GetCurrentUserResponse } from "../types/version-mappings";
3
5
  /**
4
6
  * Get current user information and validate API token
5
7
  *
6
8
  * Returns information about the current authenticated user.
9
+ * The response format depends on the API version:
10
+ * - v20260121 (default): Three-layer structure with `user`, `workspace`, and `credits`
11
+ * - v20251028 (legacy): Flat structure with all fields at top level
7
12
  *
8
13
  * @example
9
14
  * ```typescript
10
15
  * import { createClient, getCurrentUser } from '@phala/cloud'
11
16
  *
17
+ * // Default (v20260121) - three-layer response
12
18
  * const client = createClient({ apiKey: 'your-api-key' })
13
- * const user = await getCurrentUser(client)
14
- * // Output: { username: 'alice', email: 'alice@example.com', credits: 1000, ... }
15
- * ```
16
- *
17
- * ## Returns
18
- *
19
- * `CurrentUser | unknown`
20
- *
21
- * Information about the current user. Return type depends on schema parameter.
22
- *
23
- * ## Parameters
24
- *
25
- * ### parameters (optional)
26
- * - **Type:** `GetCurrentUserParameters`
27
- *
28
- * Optional behavior parameters for schema validation.
29
- *
30
- * ```typescript
31
- * // Use default schema
32
- * const user = await getCurrentUser(client)
33
- *
34
- * // Return raw data without validation
35
- * const raw = await getCurrentUser(client, { schema: false })
36
- *
37
- * // Use custom schema
38
- * const customSchema = z.object({ id: z.number(), name: z.string() })
39
- * const custom = await getCurrentUser(client, { schema: customSchema })
19
+ * const auth = await getCurrentUser(client)
20
+ * console.log(auth.user.username)
21
+ * console.log(auth.workspace.name)
22
+ * console.log(auth.credits.balance)
23
+ *
24
+ * // Legacy (v20251028) - flat response
25
+ * const legacyClient = createClient({ apiKey: 'your-api-key', version: '2025-10-28' })
26
+ * const user = await getCurrentUser(legacyClient)
27
+ * console.log(user.username)
28
+ * console.log(user.team_name)
29
+ * console.log(user.credits) // number
40
30
  * ```
41
31
  *
42
32
  * ## Safe Version
@@ -48,7 +38,7 @@ import { type Client } from "../client";
48
38
  *
49
39
  * const result = await safeGetCurrentUser(client)
50
40
  * if (result.success) {
51
- * console.log(result.data.username)
41
+ * console.log(result.data.user.username)
52
42
  * } else {
53
43
  * if ("isRequestError" in result.error) {
54
44
  * console.error(`HTTP ${result.error.status}: ${result.error.message}`)
@@ -58,63 +48,20 @@ import { type Client } from "../client";
58
48
  * }
59
49
  * ```
60
50
  */
61
- export declare const CurrentUserSchema: z.ZodObject<{
62
- username: z.ZodString;
63
- email: z.ZodString;
64
- credits: z.ZodNumber;
65
- granted_credits: z.ZodNumber;
66
- avatar: z.ZodString;
67
- team_name: z.ZodString;
68
- team_tier: z.ZodString;
69
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
70
- username: z.ZodString;
71
- email: z.ZodString;
72
- credits: z.ZodNumber;
73
- granted_credits: z.ZodNumber;
74
- avatar: z.ZodString;
75
- team_name: z.ZodString;
76
- team_tier: z.ZodString;
77
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
78
- username: z.ZodString;
79
- email: z.ZodString;
80
- credits: z.ZodNumber;
81
- granted_credits: z.ZodNumber;
82
- avatar: z.ZodString;
83
- team_name: z.ZodString;
84
- team_tier: z.ZodString;
85
- }, z.ZodTypeAny, "passthrough">>;
86
- export type CurrentUser = z.infer<typeof CurrentUserSchema>;
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>>;
94
- (client: Client): Promise<z.objectOutputType<{
95
- username: z.ZodString;
96
- email: z.ZodString;
97
- credits: z.ZodNumber;
98
- granted_credits: z.ZodNumber;
99
- avatar: z.ZodString;
100
- team_name: z.ZodString;
101
- team_tier: z.ZodString;
102
- }, z.ZodTypeAny, "passthrough">>;
103
- }, safeGetCurrentUser: {
104
- (client: Client, parameters: {
105
- schema: false;
106
- }): Promise<import("..").SafeResult<unknown>>;
107
- <T extends z.ZodTypeAny>(client: Client, parameters: {
108
- schema: T;
109
- }): Promise<import("..").SafeResult<z.TypeOf<T>>>;
110
- (client: Client): Promise<import("..").SafeResult<z.objectOutputType<{
111
- username: z.ZodString;
112
- email: z.ZodString;
113
- credits: z.ZodNumber;
114
- granted_credits: z.ZodNumber;
115
- avatar: z.ZodString;
116
- team_name: z.ZodString;
117
- team_tier: z.ZodString;
118
- }, z.ZodTypeAny, "passthrough">>>;
119
- };
120
- export { getCurrentUser, safeGetCurrentUser };
51
+ export { UserInfoSchema, WorkspaceInfoSchema, CreditsInfoSchema, type UserInfo, type WorkspaceInfo, type CreditsInfo, } from "../credentials/current_user_v20260121";
52
+ export { CurrentUserV20260121Schema as AuthResponseSchema, type CurrentUserV20260121 as AuthResponse, } from "../credentials/current_user_v20260121";
53
+ export { CurrentUserV20251028Schema as CurrentUserSchema, type CurrentUserV20251028 as CurrentUser, } from "../credentials/current_user_v20251028";
54
+ export declare function getCurrentUser<V extends ApiVersion>(client: Client<V>): Promise<GetCurrentUserResponse<V>>;
55
+ export declare function getCurrentUser<V extends ApiVersion>(client: Client<V>, parameters: {
56
+ schema: false;
57
+ }): Promise<unknown>;
58
+ export declare function getCurrentUser<V extends ApiVersion, T extends z.ZodTypeAny>(client: Client<V>, parameters: {
59
+ schema: T;
60
+ }): Promise<z.infer<T>>;
61
+ export declare function safeGetCurrentUser<V extends ApiVersion>(client: Client<V>): Promise<SafeResult<GetCurrentUserResponse<V>>>;
62
+ export declare function safeGetCurrentUser<V extends ApiVersion>(client: Client<V>, parameters: {
63
+ schema: false;
64
+ }): Promise<SafeResult<unknown>>;
65
+ export declare function safeGetCurrentUser<V extends ApiVersion, T extends z.ZodTypeAny>(client: Client<V>, parameters: {
66
+ schema: T;
67
+ }): Promise<SafeResult<z.infer<T>>>;
@@ -9,13 +9,15 @@ export { provisionCvmComposeFileUpdate, safeProvisionCvmComposeFileUpdate, Provi
9
9
  export { commitCvmComposeFileUpdate, safeCommitCvmComposeFileUpdate, CommitCvmComposeFileUpdateRequestSchema, type CommitCvmComposeFileUpdateRequest, CommitCvmComposeFileUpdateSchema, type CommitCvmComposeFileUpdate, } from "./cvms/commit_cvm_compose_file_update";
10
10
  export { updateCvmEnvs, safeUpdateCvmEnvs, UpdateCvmEnvsRequestSchema, type UpdateCvmEnvsRequest, UpdateCvmEnvsResultSchema, type UpdateCvmEnvsResult, type UpdateCvmEnvsInProgress, type UpdateCvmEnvsPreconditionRequired, } from "./cvms/update_cvm_envs";
11
11
  export { getAppEnvEncryptPubKey, safeGetAppEnvEncryptPubKey, GetAppEnvEncryptPubKeySchema, type GetAppEnvEncryptPubKeyRequest, type GetAppEnvEncryptPubKey, GetAppEnvEncryptPubKeyRequestSchema, } from "./kms/get_app_env_encrypt_pubkey";
12
- export { getCvmInfo, safeGetCvmInfo, CvmLegacyDetailSchema, GetCvmInfoRequestSchema, type GetCvmInfoRequest, type GetCvmInfoResponse, } from "./cvms/get_cvm_info";
13
- export { getCvmList, safeGetCvmList, GetCvmListSchema, GetCvmListRequestSchema, type GetCvmListRequest, type GetCvmListResponse, } from "./cvms/get_cvm_list";
12
+ export { getCvmInfo, safeGetCvmInfo, GetCvmInfoRequestSchema, type GetCvmInfoRequest, } from "./cvms/get_cvm_info";
13
+ export { getCvmList, safeGetCvmList, GetCvmListRequestSchema, type GetCvmListRequest, } from "./cvms/get_cvm_list";
14
14
  export { getKmsInfo, safeGetKmsInfo, GetKmsInfoRequestSchema, type GetKmsInfoRequest, } from "./kms/get_kms_info";
15
15
  export { getKmsList, safeGetKmsList, GetKmsListSchema, GetKmsListRequestSchema, type GetKmsListRequest, type GetKmsListResponse, } from "./kms/get_kms_list";
16
16
  export { nextAppIds, safeNextAppIds, NextAppIdsSchema, NextAppIdsRequestSchema, type NextAppIdsRequest, type NextAppIds, } from "./kms/next_app_ids";
17
17
  export { listWorkspaces, safeListWorkspaces, WorkspaceResponseSchema, ListWorkspacesSchema, PaginationMetadataSchema, type WorkspaceResponse, type ListWorkspaces, type PaginationMetadata, type ListWorkspacesRequest, } from "./workspaces/list_workspaces";
18
18
  export { getWorkspace, safeGetWorkspace, } from "./workspaces/get_workspace";
19
+ export { getWorkspaceNodes, safeGetWorkspaceNodes, NodeInfoSchema, GetWorkspaceNodesSchema, type NodeInfo, type GetWorkspaceNodes, type GetWorkspaceNodesRequest, } from "./workspaces/get_workspace_nodes";
20
+ export { getWorkspaceQuotas, safeGetWorkspaceQuotas, QuotaMetricSchema, WorkspaceQuotasSchema, WorkspaceReservedGpuQuotaSchema, GetWorkspaceQuotasSchema, type QuotaMetric, type WorkspaceQuotas, type WorkspaceReservedGpuQuota, type GetWorkspaceQuotas, type GetWorkspaceQuotasRequest, } from "./workspaces/get_workspace_quotas";
19
21
  export { listAllInstanceTypeFamilies, safeListAllInstanceTypeFamilies, listFamilyInstanceTypes, safeListFamilyInstanceTypes, AllFamiliesResponseSchema, FamilyInstanceTypesResponseSchema, FamilyGroupSchema, InstanceTypeSchema, ListFamilyInstanceTypesRequestSchema, type AllFamiliesResponse, type FamilyInstanceTypesResponse, type FamilyGroup, type InstanceType, type ListFamilyInstanceTypesRequest, } from "./list-instance-types";
20
22
  export { startCvm, safeStartCvm, StartCvmRequestSchema, type StartCvmRequest, } from "./cvms/start_cvm";
21
23
  export { shutdownCvm, safeShutdownCvm, ShutdownCvmRequestSchema, type ShutdownCvmRequest, } from "./cvms/shutdown_cvm";
@@ -33,3 +35,12 @@ export { updateCvmResources, safeUpdateCvmResources, UpdateCvmResourcesRequestSc
33
35
  export { updateCvmVisibility, safeUpdateCvmVisibility, UpdateCvmVisibilityRequestSchema, type UpdateCvmVisibilityRequest, } from "./cvms/update_cvm_visibility";
34
36
  export { getAvailableOsImages, safeGetAvailableOsImages, OSImageVariantSchema, GetAvailableOSImagesResponseSchema, GetAvailableOSImagesRequestSchema, type OSImageVariant, type GetAvailableOSImagesResponse, type GetAvailableOSImagesRequest, } from "./cvms/get_available_os_images";
35
37
  export { updateOsImage, safeUpdateOsImage, UpdateOsImageRequestSchema, type UpdateOsImageRequest, } from "./cvms/update_os_image";
38
+ export { updateDockerCompose, safeUpdateDockerCompose, UpdateDockerComposeRequestSchema, type UpdateDockerComposeRequest, UpdateDockerComposeResultSchema, type UpdateDockerComposeResult, type UpdateDockerComposeInProgress, type UpdateDockerComposePreconditionRequired, } from "./cvms/update_docker_compose";
39
+ export { updatePreLaunchScript, safeUpdatePreLaunchScript, UpdatePreLaunchScriptRequestSchema, type UpdatePreLaunchScriptRequest, UpdatePreLaunchScriptResultSchema, type UpdatePreLaunchScriptResult, type UpdatePreLaunchScriptInProgress, type UpdatePreLaunchScriptPreconditionRequired, } from "./cvms/update_prelaunch_script";
40
+ export { getCvmPreLaunchScript, safeGetCvmPreLaunchScript, GetCvmPreLaunchScriptRequestSchema, type GetCvmPreLaunchScriptRequest, } from "./cvms/get_cvm_prelaunch_script";
41
+ export { getCvmStatusBatch, safeGetCvmStatusBatch, CvmStatusSchema, GetCvmStatusBatchResponseSchema, GetCvmStatusBatchRequestSchema, type CvmStatus, type GetCvmStatusBatchResponse, type GetCvmStatusBatchRequest, } from "./cvms/get_cvm_status_batch";
42
+ export { getAppList, safeGetAppList, GetAppListRequestSchema, type GetAppListRequest, } from "./apps/get_app_list";
43
+ export { getAppInfo, safeGetAppInfo, GetAppInfoRequestSchema, type GetAppInfoRequest, } from "./apps/get_app_info";
44
+ export { getAppCvms, safeGetAppCvms, GetAppCvmsRequestSchema, type GetAppCvmsRequest, } from "./apps/get_app_cvms";
45
+ export { getAppRevisions, safeGetAppRevisions, GetAppRevisionsRequestSchema, type GetAppRevisionsRequest, } from "./apps/get_app_revisions";
46
+ export { getAppRevisionDetail, safeGetAppRevisionDetail, GetAppRevisionDetailRequestSchema, type GetAppRevisionDetailRequest, } from "./apps/get_app_revision_detail";