@phala/cloud 0.2.1-beta.3 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +426 -0
  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 +14 -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 +87 -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 +1782 -633
  54. package/dist/index.mjs +1693 -626
  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 +45 -10
  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,453 @@
1
+ import { z } from "zod";
2
+ export declare const CvmRefSchema: z.ZodObject<{
3
+ object_type: z.ZodLiteral<"cvm">;
4
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
5
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
6
+ app_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
7
+ vm_uuid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8
+ }, "strip", z.ZodTypeAny, {
9
+ object_type: "cvm";
10
+ name?: string | null | undefined;
11
+ id?: string | null | undefined;
12
+ app_id?: string | null | undefined;
13
+ vm_uuid?: string | null | undefined;
14
+ }, {
15
+ object_type: "cvm";
16
+ name?: string | null | undefined;
17
+ id?: string | null | undefined;
18
+ app_id?: string | null | undefined;
19
+ vm_uuid?: string | null | undefined;
20
+ }>;
21
+ export type CvmRef = z.infer<typeof CvmRefSchema>;
22
+ export declare const AppRevisionResponseSchema: z.ZodObject<{
23
+ app_id: z.ZodString;
24
+ vm_uuid: z.ZodString;
25
+ compose_hash: z.ZodString;
26
+ created_at: z.ZodString;
27
+ trace_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
28
+ operation_type: z.ZodString;
29
+ triggered_by: z.ZodOptional<z.ZodNullable<z.ZodObject<{
30
+ object_type: z.ZodLiteral<"user">;
31
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
32
+ username: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
+ avatar_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
34
+ }, "strip", z.ZodTypeAny, {
35
+ object_type: "user";
36
+ username?: string | null | undefined;
37
+ id?: string | null | undefined;
38
+ avatar_url?: string | null | undefined;
39
+ }, {
40
+ object_type: "user";
41
+ username?: string | null | undefined;
42
+ id?: string | null | undefined;
43
+ avatar_url?: string | null | undefined;
44
+ }>>>;
45
+ cvm: z.ZodOptional<z.ZodNullable<z.ZodObject<{
46
+ object_type: z.ZodLiteral<"cvm">;
47
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
49
+ app_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
50
+ vm_uuid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
51
+ }, "strip", z.ZodTypeAny, {
52
+ object_type: "cvm";
53
+ name?: string | null | undefined;
54
+ id?: string | null | undefined;
55
+ app_id?: string | null | undefined;
56
+ vm_uuid?: string | null | undefined;
57
+ }, {
58
+ object_type: "cvm";
59
+ name?: string | null | undefined;
60
+ id?: string | null | undefined;
61
+ app_id?: string | null | undefined;
62
+ vm_uuid?: string | null | undefined;
63
+ }>>>;
64
+ workspace: z.ZodOptional<z.ZodNullable<z.ZodObject<{
65
+ object_type: z.ZodLiteral<"workspace">;
66
+ id: z.ZodString;
67
+ name: z.ZodString;
68
+ slug: z.ZodOptional<z.ZodNullable<z.ZodString>>;
69
+ avatar_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
70
+ }, "strip", z.ZodTypeAny, {
71
+ name: string;
72
+ id: string;
73
+ object_type: "workspace";
74
+ slug?: string | null | undefined;
75
+ avatar_url?: string | null | undefined;
76
+ }, {
77
+ name: string;
78
+ id: string;
79
+ object_type: "workspace";
80
+ slug?: string | null | undefined;
81
+ avatar_url?: string | null | undefined;
82
+ }>>>;
83
+ }, "strip", z.ZodTypeAny, {
84
+ app_id: string;
85
+ vm_uuid: string;
86
+ created_at: string;
87
+ compose_hash: string;
88
+ operation_type: string;
89
+ workspace?: {
90
+ name: string;
91
+ id: string;
92
+ object_type: "workspace";
93
+ slug?: string | null | undefined;
94
+ avatar_url?: string | null | undefined;
95
+ } | null | undefined;
96
+ cvm?: {
97
+ object_type: "cvm";
98
+ name?: string | null | undefined;
99
+ id?: string | null | undefined;
100
+ app_id?: string | null | undefined;
101
+ vm_uuid?: string | null | undefined;
102
+ } | null | undefined;
103
+ trace_id?: string | null | undefined;
104
+ triggered_by?: {
105
+ object_type: "user";
106
+ username?: string | null | undefined;
107
+ id?: string | null | undefined;
108
+ avatar_url?: string | null | undefined;
109
+ } | null | undefined;
110
+ }, {
111
+ app_id: string;
112
+ vm_uuid: string;
113
+ created_at: string;
114
+ compose_hash: string;
115
+ operation_type: string;
116
+ workspace?: {
117
+ name: string;
118
+ id: string;
119
+ object_type: "workspace";
120
+ slug?: string | null | undefined;
121
+ avatar_url?: string | null | undefined;
122
+ } | null | undefined;
123
+ cvm?: {
124
+ object_type: "cvm";
125
+ name?: string | null | undefined;
126
+ id?: string | null | undefined;
127
+ app_id?: string | null | undefined;
128
+ vm_uuid?: string | null | undefined;
129
+ } | null | undefined;
130
+ trace_id?: string | null | undefined;
131
+ triggered_by?: {
132
+ object_type: "user";
133
+ username?: string | null | undefined;
134
+ id?: string | null | undefined;
135
+ avatar_url?: string | null | undefined;
136
+ } | null | undefined;
137
+ }>;
138
+ export type AppRevisionResponse = z.infer<typeof AppRevisionResponseSchema>;
139
+ export declare const AppRevisionDetailResponseSchema: z.ZodObject<{
140
+ app_id: z.ZodString;
141
+ vm_uuid: z.ZodString;
142
+ compose_hash: z.ZodString;
143
+ compose_file: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodAny>, z.ZodString]>>>;
144
+ encrypted_env: z.ZodString;
145
+ user_config: z.ZodString;
146
+ created_at: z.ZodString;
147
+ trace_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
148
+ operation_type: z.ZodString;
149
+ triggered_by: z.ZodOptional<z.ZodNullable<z.ZodObject<{
150
+ object_type: z.ZodLiteral<"user">;
151
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
152
+ username: z.ZodOptional<z.ZodNullable<z.ZodString>>;
153
+ avatar_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
154
+ }, "strip", z.ZodTypeAny, {
155
+ object_type: "user";
156
+ username?: string | null | undefined;
157
+ id?: string | null | undefined;
158
+ avatar_url?: string | null | undefined;
159
+ }, {
160
+ object_type: "user";
161
+ username?: string | null | undefined;
162
+ id?: string | null | undefined;
163
+ avatar_url?: string | null | undefined;
164
+ }>>>;
165
+ cvm: z.ZodOptional<z.ZodNullable<z.ZodObject<{
166
+ object_type: z.ZodLiteral<"cvm">;
167
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
168
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
169
+ app_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
170
+ vm_uuid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
171
+ }, "strip", z.ZodTypeAny, {
172
+ object_type: "cvm";
173
+ name?: string | null | undefined;
174
+ id?: string | null | undefined;
175
+ app_id?: string | null | undefined;
176
+ vm_uuid?: string | null | undefined;
177
+ }, {
178
+ object_type: "cvm";
179
+ name?: string | null | undefined;
180
+ id?: string | null | undefined;
181
+ app_id?: string | null | undefined;
182
+ vm_uuid?: string | null | undefined;
183
+ }>>>;
184
+ workspace: z.ZodOptional<z.ZodNullable<z.ZodObject<{
185
+ object_type: z.ZodLiteral<"workspace">;
186
+ id: z.ZodString;
187
+ name: z.ZodString;
188
+ slug: z.ZodOptional<z.ZodNullable<z.ZodString>>;
189
+ avatar_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
190
+ }, "strip", z.ZodTypeAny, {
191
+ name: string;
192
+ id: string;
193
+ object_type: "workspace";
194
+ slug?: string | null | undefined;
195
+ avatar_url?: string | null | undefined;
196
+ }, {
197
+ name: string;
198
+ id: string;
199
+ object_type: "workspace";
200
+ slug?: string | null | undefined;
201
+ avatar_url?: string | null | undefined;
202
+ }>>>;
203
+ }, "strip", z.ZodTypeAny, {
204
+ app_id: string;
205
+ vm_uuid: string;
206
+ created_at: string;
207
+ compose_hash: string;
208
+ encrypted_env: string;
209
+ operation_type: string;
210
+ user_config: string;
211
+ workspace?: {
212
+ name: string;
213
+ id: string;
214
+ object_type: "workspace";
215
+ slug?: string | null | undefined;
216
+ avatar_url?: string | null | undefined;
217
+ } | null | undefined;
218
+ compose_file?: string | Record<string, any> | null | undefined;
219
+ cvm?: {
220
+ object_type: "cvm";
221
+ name?: string | null | undefined;
222
+ id?: string | null | undefined;
223
+ app_id?: string | null | undefined;
224
+ vm_uuid?: string | null | undefined;
225
+ } | null | undefined;
226
+ trace_id?: string | null | undefined;
227
+ triggered_by?: {
228
+ object_type: "user";
229
+ username?: string | null | undefined;
230
+ id?: string | null | undefined;
231
+ avatar_url?: string | null | undefined;
232
+ } | null | undefined;
233
+ }, {
234
+ app_id: string;
235
+ vm_uuid: string;
236
+ created_at: string;
237
+ compose_hash: string;
238
+ encrypted_env: string;
239
+ operation_type: string;
240
+ user_config: string;
241
+ workspace?: {
242
+ name: string;
243
+ id: string;
244
+ object_type: "workspace";
245
+ slug?: string | null | undefined;
246
+ avatar_url?: string | null | undefined;
247
+ } | null | undefined;
248
+ compose_file?: string | Record<string, any> | null | undefined;
249
+ cvm?: {
250
+ object_type: "cvm";
251
+ name?: string | null | undefined;
252
+ id?: string | null | undefined;
253
+ app_id?: string | null | undefined;
254
+ vm_uuid?: string | null | undefined;
255
+ } | null | undefined;
256
+ trace_id?: string | null | undefined;
257
+ triggered_by?: {
258
+ object_type: "user";
259
+ username?: string | null | undefined;
260
+ id?: string | null | undefined;
261
+ avatar_url?: string | null | undefined;
262
+ } | null | undefined;
263
+ }>;
264
+ export type AppRevisionDetailResponse = z.infer<typeof AppRevisionDetailResponseSchema>;
265
+ export declare const AppRevisionsResponseSchema: z.ZodObject<{
266
+ revisions: z.ZodArray<z.ZodObject<{
267
+ app_id: z.ZodString;
268
+ vm_uuid: z.ZodString;
269
+ compose_hash: z.ZodString;
270
+ created_at: z.ZodString;
271
+ trace_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
272
+ operation_type: z.ZodString;
273
+ triggered_by: z.ZodOptional<z.ZodNullable<z.ZodObject<{
274
+ object_type: z.ZodLiteral<"user">;
275
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
276
+ username: z.ZodOptional<z.ZodNullable<z.ZodString>>;
277
+ avatar_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
278
+ }, "strip", z.ZodTypeAny, {
279
+ object_type: "user";
280
+ username?: string | null | undefined;
281
+ id?: string | null | undefined;
282
+ avatar_url?: string | null | undefined;
283
+ }, {
284
+ object_type: "user";
285
+ username?: string | null | undefined;
286
+ id?: string | null | undefined;
287
+ avatar_url?: string | null | undefined;
288
+ }>>>;
289
+ cvm: z.ZodOptional<z.ZodNullable<z.ZodObject<{
290
+ object_type: z.ZodLiteral<"cvm">;
291
+ id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
292
+ name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
293
+ app_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
294
+ vm_uuid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
295
+ }, "strip", z.ZodTypeAny, {
296
+ object_type: "cvm";
297
+ name?: string | null | undefined;
298
+ id?: string | null | undefined;
299
+ app_id?: string | null | undefined;
300
+ vm_uuid?: string | null | undefined;
301
+ }, {
302
+ object_type: "cvm";
303
+ name?: string | null | undefined;
304
+ id?: string | null | undefined;
305
+ app_id?: string | null | undefined;
306
+ vm_uuid?: string | null | undefined;
307
+ }>>>;
308
+ workspace: z.ZodOptional<z.ZodNullable<z.ZodObject<{
309
+ object_type: z.ZodLiteral<"workspace">;
310
+ id: z.ZodString;
311
+ name: z.ZodString;
312
+ slug: z.ZodOptional<z.ZodNullable<z.ZodString>>;
313
+ avatar_url: z.ZodOptional<z.ZodNullable<z.ZodString>>;
314
+ }, "strip", z.ZodTypeAny, {
315
+ name: string;
316
+ id: string;
317
+ object_type: "workspace";
318
+ slug?: string | null | undefined;
319
+ avatar_url?: string | null | undefined;
320
+ }, {
321
+ name: string;
322
+ id: string;
323
+ object_type: "workspace";
324
+ slug?: string | null | undefined;
325
+ avatar_url?: string | null | undefined;
326
+ }>>>;
327
+ }, "strip", z.ZodTypeAny, {
328
+ app_id: string;
329
+ vm_uuid: string;
330
+ created_at: string;
331
+ compose_hash: string;
332
+ operation_type: string;
333
+ workspace?: {
334
+ name: string;
335
+ id: string;
336
+ object_type: "workspace";
337
+ slug?: string | null | undefined;
338
+ avatar_url?: string | null | undefined;
339
+ } | null | undefined;
340
+ cvm?: {
341
+ object_type: "cvm";
342
+ name?: string | null | undefined;
343
+ id?: string | null | undefined;
344
+ app_id?: string | null | undefined;
345
+ vm_uuid?: string | null | undefined;
346
+ } | null | undefined;
347
+ trace_id?: string | null | undefined;
348
+ triggered_by?: {
349
+ object_type: "user";
350
+ username?: string | null | undefined;
351
+ id?: string | null | undefined;
352
+ avatar_url?: string | null | undefined;
353
+ } | null | undefined;
354
+ }, {
355
+ app_id: string;
356
+ vm_uuid: string;
357
+ created_at: string;
358
+ compose_hash: string;
359
+ operation_type: string;
360
+ workspace?: {
361
+ name: string;
362
+ id: string;
363
+ object_type: "workspace";
364
+ slug?: string | null | undefined;
365
+ avatar_url?: string | null | undefined;
366
+ } | null | undefined;
367
+ cvm?: {
368
+ object_type: "cvm";
369
+ name?: string | null | undefined;
370
+ id?: string | null | undefined;
371
+ app_id?: string | null | undefined;
372
+ vm_uuid?: string | null | undefined;
373
+ } | null | undefined;
374
+ trace_id?: string | null | undefined;
375
+ triggered_by?: {
376
+ object_type: "user";
377
+ username?: string | null | undefined;
378
+ id?: string | null | undefined;
379
+ avatar_url?: string | null | undefined;
380
+ } | null | undefined;
381
+ }>, "many">;
382
+ total: z.ZodNumber;
383
+ page: z.ZodNumber;
384
+ page_size: z.ZodNumber;
385
+ total_pages: z.ZodNumber;
386
+ }, "strip", z.ZodTypeAny, {
387
+ total: number;
388
+ page: number;
389
+ page_size: number;
390
+ total_pages: number;
391
+ revisions: {
392
+ app_id: string;
393
+ vm_uuid: string;
394
+ created_at: string;
395
+ compose_hash: string;
396
+ operation_type: string;
397
+ workspace?: {
398
+ name: string;
399
+ id: string;
400
+ object_type: "workspace";
401
+ slug?: string | null | undefined;
402
+ avatar_url?: string | null | undefined;
403
+ } | null | undefined;
404
+ cvm?: {
405
+ object_type: "cvm";
406
+ name?: string | null | undefined;
407
+ id?: string | null | undefined;
408
+ app_id?: string | null | undefined;
409
+ vm_uuid?: string | null | undefined;
410
+ } | null | undefined;
411
+ trace_id?: string | null | undefined;
412
+ triggered_by?: {
413
+ object_type: "user";
414
+ username?: string | null | undefined;
415
+ id?: string | null | undefined;
416
+ avatar_url?: string | null | undefined;
417
+ } | null | undefined;
418
+ }[];
419
+ }, {
420
+ total: number;
421
+ page: number;
422
+ page_size: number;
423
+ total_pages: number;
424
+ revisions: {
425
+ app_id: string;
426
+ vm_uuid: string;
427
+ created_at: string;
428
+ compose_hash: string;
429
+ operation_type: string;
430
+ workspace?: {
431
+ name: string;
432
+ id: string;
433
+ object_type: "workspace";
434
+ slug?: string | null | undefined;
435
+ avatar_url?: string | null | undefined;
436
+ } | null | undefined;
437
+ cvm?: {
438
+ object_type: "cvm";
439
+ name?: string | null | undefined;
440
+ id?: string | null | undefined;
441
+ app_id?: string | null | undefined;
442
+ vm_uuid?: string | null | undefined;
443
+ } | null | undefined;
444
+ trace_id?: string | null | undefined;
445
+ triggered_by?: {
446
+ object_type: "user";
447
+ username?: string | null | undefined;
448
+ id?: string | null | undefined;
449
+ avatar_url?: string | null | undefined;
450
+ } | null | undefined;
451
+ }[];
452
+ }>;
453
+ export type AppRevisionsResponse = z.infer<typeof AppRevisionsResponseSchema>;
@@ -1,6 +1,38 @@
1
1
  import { z } from "zod";
2
2
  import type { FetchOptions, FetchRequest } from "ofetch";
3
3
  import type { PhalaCloudError } from "../utils/errors";
4
+ /**
5
+ * Supported API versions
6
+ */
7
+ export type ApiVersion = "2025-10-28" | "2026-01-21";
8
+ /**
9
+ * Default API version (latest stable)
10
+ */
11
+ export type DefaultApiVersion = "2026-01-21";
12
+ /**
13
+ * Full HTTP response including status, headers, and parsed body
14
+ */
15
+ export interface FullResponse<T = unknown> {
16
+ /** HTTP status code */
17
+ status: number;
18
+ /** HTTP status text */
19
+ statusText: string;
20
+ /** Response headers */
21
+ headers: Headers;
22
+ /** Parsed response body */
23
+ data: T;
24
+ /** Whether the response status is 2xx */
25
+ ok: boolean;
26
+ }
27
+ /**
28
+ * Options for the generic request method
29
+ */
30
+ export interface RequestOptions extends Omit<FetchOptions, "method"> {
31
+ /** HTTP method (GET, POST, PUT, PATCH, DELETE, HEAD, OPTIONS, etc.) */
32
+ method?: string;
33
+ /** Request body (for POST, PUT, PATCH) */
34
+ body?: RequestInit["body"] | Record<string, unknown>;
35
+ }
4
36
  /**
5
37
  * Enhanced error type that includes both HTTP and validation errors
6
38
  */
@@ -25,7 +57,7 @@ export type SafeResult<T, E = SafeError> = {
25
57
  * - PHALA_CLOUD_API_KEY: API key for authentication
26
58
  * - PHALA_CLOUD_API_PREFIX: Base URL prefix for the API
27
59
  */
28
- export interface ClientConfig extends FetchOptions {
60
+ export interface ClientConfig<V extends ApiVersion = ApiVersion> extends FetchOptions {
29
61
  /**
30
62
  * API key for authentication
31
63
  * If not provided, will read from PHALA_CLOUD_API_KEY environment variable
@@ -43,7 +75,7 @@ export interface ClientConfig extends FetchOptions {
43
75
  /**
44
76
  * API version to use
45
77
  */
46
- version?: string;
78
+ version?: V;
47
79
  /**
48
80
  * Use cookie-based authentication instead of API key
49
81
  * When true, API key is not required and credentials: "include" is set
@@ -59,3 +91,9 @@ export interface ClientConfig extends FetchOptions {
59
91
  options: FetchOptions;
60
92
  }) => void | Promise<void>;
61
93
  }
94
+ /**
95
+ * Resolved client configuration with version guaranteed
96
+ */
97
+ export interface ResolvedClientConfig<V extends ApiVersion = ApiVersion> extends Omit<ClientConfig<V>, "version"> {
98
+ version: V;
99
+ }
@@ -6,15 +6,15 @@ import { z } from "zod";
6
6
  * @example
7
7
  * ```typescript
8
8
  * const MySchema = CvmIdObjectSchema.extend({
9
- * name: z.string()
9
+ * custom_field: z.string()
10
10
  * }).refine(
11
- * (data) => !!(data.id || data.uuid || data.app_id || data.instance_id),
12
- * "One of id, uuid, app_id, or instance_id must be provided"
11
+ * (data) => !!(data.id || data.uuid || data.app_id || data.instance_id || data.name),
12
+ * "One of id, uuid, app_id, instance_id, or name must be provided"
13
13
  * );
14
14
  * ```
15
15
  */
16
16
  export declare const CvmIdObjectSchema: z.ZodObject<{
17
- /** Direct CVM ID (any format) */
17
+ /** Direct CVM ID (any format) - accepts any string including names */
18
18
  id: z.ZodOptional<z.ZodString>;
19
19
  /** UUID format (with or without dashes) */
20
20
  uuid: z.ZodOptional<z.ZodString>;
@@ -22,12 +22,16 @@ export declare const CvmIdObjectSchema: z.ZodObject<{
22
22
  app_id: z.ZodOptional<z.ZodString>;
23
23
  /** Instance ID (40 characters, optionally prefixed with 'instance_') */
24
24
  instance_id: z.ZodOptional<z.ZodString>;
25
+ /** CVM name (RFC 1123 hostname format: 5-63 chars, starts with letter, alphanumeric + hyphens) */
26
+ name: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
25
27
  }, "strip", z.ZodTypeAny, {
28
+ name?: string | undefined;
26
29
  id?: string | undefined;
27
30
  app_id?: string | undefined;
28
31
  instance_id?: string | undefined;
29
32
  uuid?: string | undefined;
30
33
  }, {
34
+ name?: string | undefined;
31
35
  id?: string | undefined;
32
36
  app_id?: string | undefined;
33
37
  instance_id?: string | undefined;
@@ -42,7 +46,7 @@ export declare const refineCvmId: <T extends z.ZodTypeAny>(schema: T) => z.ZodEf
42
46
  * For extending with additional fields, use CvmIdObjectSchema.extend() then call refineCvmId()
43
47
  */
44
48
  export declare const CvmIdBaseSchema: z.ZodEffects<z.ZodObject<{
45
- /** Direct CVM ID (any format) */
49
+ /** Direct CVM ID (any format) - accepts any string including names */
46
50
  id: z.ZodOptional<z.ZodString>;
47
51
  /** UUID format (with or without dashes) */
48
52
  uuid: z.ZodOptional<z.ZodString>;
@@ -50,12 +54,16 @@ export declare const CvmIdBaseSchema: z.ZodEffects<z.ZodObject<{
50
54
  app_id: z.ZodOptional<z.ZodString>;
51
55
  /** Instance ID (40 characters, optionally prefixed with 'instance_') */
52
56
  instance_id: z.ZodOptional<z.ZodString>;
57
+ /** CVM name (RFC 1123 hostname format: 5-63 chars, starts with letter, alphanumeric + hyphens) */
58
+ name: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
53
59
  }, "strip", z.ZodTypeAny, {
60
+ name?: string | undefined;
54
61
  id?: string | undefined;
55
62
  app_id?: string | undefined;
56
63
  instance_id?: string | undefined;
57
64
  uuid?: string | undefined;
58
65
  }, {
66
+ name?: string | undefined;
59
67
  id?: string | undefined;
60
68
  app_id?: string | undefined;
61
69
  instance_id?: string | undefined;
@@ -63,16 +71,37 @@ export declare const CvmIdBaseSchema: z.ZodEffects<z.ZodObject<{
63
71
  }>, any, any>;
64
72
  /**
65
73
  * CVM ID Schema - supports multiple identifier formats
66
- * Automatically transforms to the correct format for API calls
74
+ * Automatically detects and normalizes any CVM ID format
75
+ *
76
+ * Process:
77
+ * 1. Extract raw value from any field (priority: id > uuid > app_id > instance_id > name)
78
+ * 2. Auto-detect format using regex patterns
79
+ * 3. Apply appropriate normalization:
80
+ * - UUID (with or without dashes) → remove dashes
81
+ * - 40-char hex string → add 'app_' prefix
82
+ * - Name field → use as-is (validated by RFC 1123)
83
+ * - Already prefixed or custom → use as-is
67
84
  *
68
85
  * @example
69
86
  * ```typescript
70
- * const result1 = CvmIdSchema.parse({ id: "cvm-123" });
71
- * const result2 = CvmIdSchema.parse({ uuid: "550e8400-e29b-41d4-a716-446655440000" });
87
+ * // UUID formats
88
+ * CvmIdSchema.parse({ id: "550e8400-e29b-41d4-a716-446655440000" });
89
+ * CvmIdSchema.parse({ uuid: "550e8400-e29b-41d4-a716-446655440000" });
90
+ * // → { cvmId: "550e8400e29b41d4a716446655440000" }
91
+ *
92
+ * // App ID formats
93
+ * CvmIdSchema.parse({ id: "50b0e827cc6c53f4010b57e588a18c5ef9388cc1" });
94
+ * CvmIdSchema.parse({ app_id: "50b0e827cc6c53f4010b57e588a18c5ef9388cc1" });
95
+ * // → { cvmId: "app_50b0e827cc6c53f4010b57e588a18c5ef9388cc1" }
96
+ *
97
+ * // Name formats (RFC 1123)
98
+ * CvmIdSchema.parse({ name: "my-app" });
99
+ * CvmIdSchema.parse({ id: "my-app" }); // also works via id field
100
+ * // → { cvmId: "my-app" }
72
101
  * ```
73
102
  */
74
103
  export declare const CvmIdSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
75
- /** Direct CVM ID (any format) */
104
+ /** Direct CVM ID (any format) - accepts any string including names */
76
105
  id: z.ZodOptional<z.ZodString>;
77
106
  /** UUID format (with or without dashes) */
78
107
  uuid: z.ZodOptional<z.ZodString>;
@@ -80,18 +109,22 @@ export declare const CvmIdSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
80
109
  app_id: z.ZodOptional<z.ZodString>;
81
110
  /** Instance ID (40 characters, optionally prefixed with 'instance_') */
82
111
  instance_id: z.ZodOptional<z.ZodString>;
112
+ /** CVM name (RFC 1123 hostname format: 5-63 chars, starts with letter, alphanumeric + hyphens) */
113
+ name: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
83
114
  }, "strip", z.ZodTypeAny, {
115
+ name?: string | undefined;
84
116
  id?: string | undefined;
85
117
  app_id?: string | undefined;
86
118
  instance_id?: string | undefined;
87
119
  uuid?: string | undefined;
88
120
  }, {
121
+ name?: string | undefined;
89
122
  id?: string | undefined;
90
123
  app_id?: string | undefined;
91
124
  instance_id?: string | undefined;
92
125
  uuid?: string | undefined;
93
126
  }>, any, any>, {
94
- cvmId: string;
127
+ cvmId: any;
95
128
  }, any>;
96
129
  /**
97
130
  * Input type for CVM ID
@@ -100,6 +133,7 @@ export declare const CvmIdSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
100
133
  * ```typescript
101
134
  * const identifier: CvmIdInput = { id: "cvm-123" };
102
135
  * const identifier2: CvmIdInput = { uuid: "550e8400-e29b-41d4-a716-446655440000" };
136
+ * const identifier3: CvmIdInput = { name: "my-app" };
103
137
  * ```
104
138
  */
105
139
  export type CvmIdInput = {
@@ -107,4 +141,5 @@ export type CvmIdInput = {
107
141
  uuid?: string;
108
142
  app_id?: string;
109
143
  instance_id?: string;
144
+ name?: string;
110
145
  };