@phala/cloud 0.1.1-beta.1 → 0.1.1-beta.3

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.
@@ -1,1143 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // src/create-client.ts
31
- var create_client_exports = {};
32
- __export(create_client_exports, {
33
- createClient: () => createClient2
34
- });
35
- module.exports = __toCommonJS(create_client_exports);
36
-
37
- // src/client.ts
38
- var import_ofetch = require("ofetch");
39
- var import_debug = __toESM(require("debug"));
40
-
41
- // src/types/client.ts
42
- var import_zod = require("zod");
43
- var ApiErrorSchema = import_zod.z.object({
44
- detail: import_zod.z.union([
45
- import_zod.z.string(),
46
- import_zod.z.array(
47
- import_zod.z.object({
48
- msg: import_zod.z.string(),
49
- type: import_zod.z.string().optional(),
50
- ctx: import_zod.z.record(import_zod.z.unknown()).optional()
51
- })
52
- ),
53
- import_zod.z.record(import_zod.z.unknown())
54
- ]),
55
- type: import_zod.z.string().optional(),
56
- code: import_zod.z.string().optional()
57
- });
58
- var RequestError = class _RequestError extends Error {
59
- constructor(message, options) {
60
- super(message);
61
- this.name = "RequestError";
62
- this.isRequestError = true;
63
- this.status = options?.status;
64
- this.statusText = options?.statusText;
65
- this.data = options?.data;
66
- this.request = options?.request;
67
- this.response = options?.response;
68
- this.detail = options?.detail || message;
69
- this.code = options?.code;
70
- this.type = options?.type;
71
- }
72
- /**
73
- * Create RequestError from FetchError
74
- */
75
- static fromFetchError(error) {
76
- const parseResult = ApiErrorSchema.safeParse(error.data);
77
- if (parseResult.success) {
78
- return new _RequestError(error.message, {
79
- status: error.status ?? void 0,
80
- statusText: error.statusText ?? void 0,
81
- data: error.data,
82
- request: error.request ?? void 0,
83
- response: error.response ?? void 0,
84
- detail: parseResult.data.detail,
85
- code: parseResult.data.code ?? void 0,
86
- type: parseResult.data.type ?? void 0
87
- });
88
- }
89
- return new _RequestError(error.message, {
90
- status: error.status ?? void 0,
91
- statusText: error.statusText ?? void 0,
92
- data: error.data,
93
- request: error.request ?? void 0,
94
- response: error.response ?? void 0,
95
- detail: error.data?.detail || "Unknown API error",
96
- code: error.status?.toString() ?? void 0
97
- });
98
- }
99
- /**
100
- * Create RequestError from generic Error
101
- */
102
- static fromError(error, request) {
103
- return new _RequestError(error.message, {
104
- request: request ?? void 0,
105
- detail: error.message
106
- });
107
- }
108
- };
109
-
110
- // src/client.ts
111
- var SUPPORTED_API_VERSIONS = ["2025-05-31"];
112
- var logger = (0, import_debug.default)("phala::api-client");
113
- function formatHeaders(headers) {
114
- return Object.entries(headers).map(([key, value]) => ` -H "${key}: ${value}"`).join("\n");
115
- }
116
- function formatBody(body) {
117
- if (!body) return "";
118
- const bodyStr = typeof body === "string" ? body : JSON.stringify(body, null, 2);
119
- return ` -d '${bodyStr.replace(/'/g, "\\'")}'`;
120
- }
121
- function formatResponse(status, statusText, headers, body) {
122
- const headerEntries = [];
123
- headers.forEach((value, key) => {
124
- headerEntries.push(`${key}: ${value}`);
125
- });
126
- const headerStr = headerEntries.join("\n");
127
- const bodyStr = typeof body === "string" ? body : JSON.stringify(body, null, 2);
128
- return [
129
- `< HTTP/1.1 ${status} ${statusText}`,
130
- headerStr ? `< ${headerStr.replace(/\n/g, "\n< ")}` : "",
131
- "",
132
- bodyStr
133
- ].filter(Boolean).join("\n");
134
- }
135
- var Client = class {
136
- constructor(config = {}) {
137
- const resolvedConfig = {
138
- ...config,
139
- apiKey: config.apiKey || process?.env?.PHALA_CLOUD_API_KEY,
140
- baseURL: config.baseURL || process?.env?.PHALA_CLOUD_API_PREFIX || "https://cloud-api.phala.network/api/v1"
141
- };
142
- const version = resolvedConfig.version && SUPPORTED_API_VERSIONS.includes(resolvedConfig.version) ? resolvedConfig.version : SUPPORTED_API_VERSIONS[0];
143
- this.config = resolvedConfig;
144
- if (!resolvedConfig.useCookieAuth && !resolvedConfig.apiKey) {
145
- throw new Error(
146
- "API key is required. Provide it via config.apiKey or set PHALA_CLOUD_API_KEY environment variable."
147
- );
148
- }
149
- const { apiKey, baseURL, timeout, headers, useCookieAuth, onResponseError, ...fetchOptions } = resolvedConfig;
150
- const requestHeaders = {
151
- "X-Phala-Version": version,
152
- "Content-Type": "application/json"
153
- };
154
- if (headers && typeof headers === "object") {
155
- Object.entries(headers).forEach(([key, value]) => {
156
- if (typeof value === "string") {
157
- requestHeaders[key] = value;
158
- }
159
- });
160
- }
161
- if (!useCookieAuth && apiKey) {
162
- requestHeaders["X-API-Key"] = apiKey;
163
- }
164
- this.fetchInstance = import_ofetch.ofetch.create({
165
- baseURL,
166
- timeout: timeout || 3e4,
167
- headers: requestHeaders,
168
- ...useCookieAuth ? { credentials: "include" } : {},
169
- ...fetchOptions,
170
- // Log request in cURL format
171
- onRequest({ request, options }) {
172
- if (logger.enabled) {
173
- const method = options.method || "GET";
174
- const url = typeof request === "string" ? request : request.url;
175
- const fullUrl = url.startsWith("http") ? url : `${baseURL}${url}`;
176
- const headerObj = {};
177
- if (options.headers && typeof options.headers === "object") {
178
- Object.entries(options.headers).forEach(([key, value]) => {
179
- if (typeof value === "string") {
180
- headerObj[key] = value;
181
- }
182
- });
183
- }
184
- const curlCommand = [
185
- `> curl -X ${method} "${fullUrl}"`,
186
- formatHeaders(headerObj),
187
- options.body ? formatBody(options.body) : ""
188
- ].filter(Boolean).join("\n");
189
- logger("\n=== REQUEST ===\n%s\n", curlCommand);
190
- }
191
- },
192
- // Log response in cURL format
193
- onResponse({ request, response, options }) {
194
- if (logger.enabled) {
195
- const method = options.method || "GET";
196
- const url = typeof request === "string" ? request : request.url;
197
- logger(
198
- "\n=== RESPONSE [%s %s] (%dms) ===\n%s\n",
199
- method,
200
- url,
201
- response.headers.get("x-response-time") || "?",
202
- formatResponse(response.status, response.statusText, response.headers, response._data)
203
- );
204
- }
205
- },
206
- // Generic handlers for response error (similar to request.ts)
207
- onResponseError: ({ request, response, options }) => {
208
- console.warn(`HTTP ${response.status}: ${response.url}`);
209
- if (logger.enabled) {
210
- const method = options.method || "GET";
211
- const url = typeof request === "string" ? request : request.url;
212
- logger(
213
- "\n=== ERROR RESPONSE [%s %s] ===\n%s\n",
214
- method,
215
- url,
216
- formatResponse(response.status, response.statusText, response.headers, response._data)
217
- );
218
- }
219
- if (onResponseError) {
220
- onResponseError({ request, response, options });
221
- }
222
- }
223
- });
224
- }
225
- /**
226
- * Get the underlying ofetch instance for advanced usage
227
- */
228
- get raw() {
229
- return this.fetchInstance;
230
- }
231
- // ===== Direct methods (throw on error) =====
232
- /**
233
- * Perform GET request (throws on error)
234
- */
235
- async get(request, options) {
236
- return this.fetchInstance(request, {
237
- ...options,
238
- method: "GET"
239
- });
240
- }
241
- /**
242
- * Perform POST request (throws on error)
243
- */
244
- async post(request, body, options) {
245
- return this.fetchInstance(request, {
246
- ...options,
247
- method: "POST",
248
- body
249
- });
250
- }
251
- /**
252
- * Perform PUT request (throws on error)
253
- */
254
- async put(request, body, options) {
255
- return this.fetchInstance(request, {
256
- ...options,
257
- method: "PUT",
258
- body
259
- });
260
- }
261
- /**
262
- * Perform PATCH request (throws on error)
263
- */
264
- async patch(request, body, options) {
265
- return this.fetchInstance(request, {
266
- ...options,
267
- method: "PATCH",
268
- body
269
- });
270
- }
271
- /**
272
- * Perform DELETE request (throws on error)
273
- */
274
- async delete(request, options) {
275
- return this.fetchInstance(request, {
276
- ...options,
277
- method: "DELETE"
278
- });
279
- }
280
- // ===== Safe methods (return SafeResult) =====
281
- /**
282
- * Safe wrapper for any request method (zod-style result)
283
- */
284
- async safeRequest(fn) {
285
- try {
286
- const data = await fn();
287
- return { success: true, data };
288
- } catch (error) {
289
- if (error && typeof error === "object" && "data" in error) {
290
- const requestError2 = RequestError.fromFetchError(error);
291
- return { success: false, error: requestError2 };
292
- }
293
- if (error instanceof Error) {
294
- const requestError2 = RequestError.fromError(error);
295
- return { success: false, error: requestError2 };
296
- }
297
- const requestError = new RequestError("Unknown error occurred", {
298
- detail: "Unknown error occurred"
299
- });
300
- return { success: false, error: requestError };
301
- }
302
- }
303
- /**
304
- * Safe GET request (returns SafeResult)
305
- */
306
- async safeGet(request, options) {
307
- return this.safeRequest(() => this.get(request, options));
308
- }
309
- /**
310
- * Safe POST request (returns SafeResult)
311
- */
312
- async safePost(request, body, options) {
313
- return this.safeRequest(() => this.post(request, body, options));
314
- }
315
- /**
316
- * Safe PUT request (returns SafeResult)
317
- */
318
- async safePut(request, body, options) {
319
- return this.safeRequest(() => this.put(request, body, options));
320
- }
321
- /**
322
- * Safe PATCH request (returns SafeResult)
323
- */
324
- async safePatch(request, body, options) {
325
- return this.safeRequest(() => this.patch(request, body, options));
326
- }
327
- /**
328
- * Safe DELETE request (returns SafeResult)
329
- */
330
- async safeDelete(request, options) {
331
- return this.safeRequest(() => this.delete(request, options));
332
- }
333
- /**
334
- * Extend client with additional actions
335
- *
336
- * @example
337
- * ```typescript
338
- * const client = createClient({ apiKey: 'xxx' })
339
- * .extend(publicActions)
340
- * .extend(cvmActions)
341
- *
342
- * await client.getCurrentUser() // Method call instead of function call
343
- * ```
344
- */
345
- extend(actions) {
346
- const actionsObj = typeof actions === "function" ? actions(this) : actions;
347
- const extended = Object.create(this);
348
- for (const [key, action] of Object.entries(actionsObj)) {
349
- if (typeof action === "function") {
350
- extended[key] = (...args) => action(this, ...args);
351
- }
352
- }
353
- return extended;
354
- }
355
- };
356
- function createClient(config = {}) {
357
- return new Client(config);
358
- }
359
-
360
- // src/actions/get_current_user.ts
361
- var import_zod2 = require("zod");
362
-
363
- // src/utils/validate-parameters.ts
364
- function validateActionParameters(parameters) {
365
- if (parameters?.schema !== void 0 && parameters?.schema !== false) {
366
- if (typeof parameters.schema !== "object" || parameters.schema === null || !("parse" in parameters.schema) || typeof parameters.schema.parse !== "function") {
367
- throw new Error("Invalid schema: must be a Zod schema object, false, or undefined");
368
- }
369
- }
370
- }
371
- function safeValidateActionParameters(parameters) {
372
- if (parameters?.schema !== void 0 && parameters?.schema !== false) {
373
- if (typeof parameters.schema !== "object" || parameters.schema === null || !("parse" in parameters.schema) || typeof parameters.schema.parse !== "function") {
374
- return {
375
- success: false,
376
- error: {
377
- name: "ZodError",
378
- message: "Invalid schema: must be a Zod schema object, false, or undefined",
379
- issues: [
380
- {
381
- code: "invalid_type",
382
- expected: "object",
383
- received: typeof parameters.schema,
384
- path: ["schema"],
385
- message: "Invalid schema: must be a Zod schema object, false, or undefined"
386
- }
387
- ]
388
- }
389
- };
390
- }
391
- }
392
- return void 0;
393
- }
394
-
395
- // src/utils/define-action.ts
396
- function defineSimpleAction(schema, fn) {
397
- function action(client, parameters) {
398
- return _actionImpl(client, parameters);
399
- }
400
- async function _actionImpl(client, parameters) {
401
- validateActionParameters(parameters);
402
- const response = await fn(client);
403
- if (parameters?.schema === false) {
404
- return response;
405
- }
406
- const actualSchema = parameters?.schema || schema;
407
- return actualSchema.parse(response);
408
- }
409
- function safeAction(client, parameters) {
410
- return _safeActionImpl(client, parameters);
411
- }
412
- async function _safeActionImpl(client, parameters) {
413
- const parameterValidationError = safeValidateActionParameters(parameters);
414
- if (parameterValidationError) {
415
- return parameterValidationError;
416
- }
417
- const httpResult = await (async () => {
418
- try {
419
- const data = await fn(client);
420
- return { success: true, data };
421
- } catch (error) {
422
- if (error && typeof error === "object" && "isRequestError" in error) {
423
- return { success: false, error };
424
- }
425
- if (error && typeof error === "object" && "issues" in error) {
426
- return { success: false, error };
427
- }
428
- return {
429
- success: false,
430
- error: {
431
- name: "Error",
432
- message: error instanceof Error ? error.message : String(error)
433
- }
434
- };
435
- }
436
- })();
437
- if (!httpResult.success) {
438
- return httpResult;
439
- }
440
- if (parameters?.schema === false) {
441
- return { success: true, data: httpResult.data };
442
- }
443
- const actualSchema = parameters?.schema || schema;
444
- return actualSchema.safeParse(httpResult.data);
445
- }
446
- return {
447
- action,
448
- safeAction
449
- };
450
- }
451
- function defineAction(schema, fn) {
452
- function action(client, ...args) {
453
- const [params, parameters] = args;
454
- return _actionImpl(client, params, parameters);
455
- }
456
- async function _actionImpl(client, params, parameters) {
457
- validateActionParameters(parameters);
458
- const response = await fn(client, params);
459
- if (parameters?.schema === false) {
460
- return response;
461
- }
462
- const actualSchema = parameters?.schema || schema;
463
- return actualSchema.parse(response);
464
- }
465
- function safeAction(client, ...args) {
466
- const [params, parameters] = args;
467
- return _safeActionImpl(client, params, parameters);
468
- }
469
- async function _safeActionImpl(client, params, parameters) {
470
- const parameterValidationError = safeValidateActionParameters(parameters);
471
- if (parameterValidationError) {
472
- return parameterValidationError;
473
- }
474
- const httpResult = await (async () => {
475
- try {
476
- const data = await fn(client, params);
477
- return { success: true, data };
478
- } catch (error) {
479
- if (error && typeof error === "object" && "isRequestError" in error) {
480
- return { success: false, error };
481
- }
482
- if (error && typeof error === "object" && "issues" in error) {
483
- return { success: false, error };
484
- }
485
- return {
486
- success: false,
487
- error: {
488
- name: "Error",
489
- message: error instanceof Error ? error.message : String(error)
490
- }
491
- };
492
- }
493
- })();
494
- if (!httpResult.success) {
495
- return httpResult;
496
- }
497
- if (parameters?.schema === false) {
498
- return { success: true, data: httpResult.data };
499
- }
500
- const actualSchema = parameters?.schema || schema;
501
- return actualSchema.safeParse(httpResult.data);
502
- }
503
- return {
504
- action,
505
- safeAction
506
- };
507
- }
508
-
509
- // src/actions/get_current_user.ts
510
- var CurrentUserSchema = import_zod2.z.object({
511
- username: import_zod2.z.string(),
512
- email: import_zod2.z.string(),
513
- credits: import_zod2.z.number(),
514
- granted_credits: import_zod2.z.number(),
515
- avatar: import_zod2.z.string(),
516
- team_name: import_zod2.z.string(),
517
- team_tier: import_zod2.z.string()
518
- }).passthrough();
519
- var { action: getCurrentUser, safeAction: safeGetCurrentUser } = defineSimpleAction(
520
- CurrentUserSchema,
521
- async (client) => {
522
- return await client.get("/auth/me");
523
- }
524
- );
525
-
526
- // src/actions/get_available_nodes.ts
527
- var import_zod4 = require("zod");
528
-
529
- // src/types/kms_info.ts
530
- var import_zod3 = require("zod");
531
-
532
- // src/types/supported_chains.ts
533
- var import_chains = require("viem/chains");
534
- var SUPPORTED_CHAINS = {
535
- [import_chains.mainnet.id]: import_chains.mainnet,
536
- [import_chains.base.id]: import_chains.base,
537
- [import_chains.anvil.id]: import_chains.anvil
538
- };
539
-
540
- // src/types/kms_info.ts
541
- var KmsInfoBaseSchema = import_zod3.z.object({
542
- id: import_zod3.z.string(),
543
- slug: import_zod3.z.string().nullable(),
544
- url: import_zod3.z.string(),
545
- version: import_zod3.z.string(),
546
- chain_id: import_zod3.z.number().nullable(),
547
- kms_contract_address: import_zod3.z.string().nullable().transform((val) => val),
548
- gateway_app_id: import_zod3.z.string().nullable().transform((val) => val)
549
- }).passthrough();
550
- var KmsInfoSchema = KmsInfoBaseSchema.transform((data) => {
551
- if (data.chain_id != null) {
552
- const chain = SUPPORTED_CHAINS[data.chain_id];
553
- if (chain) {
554
- return { ...data, chain };
555
- }
556
- }
557
- return data;
558
- });
559
-
560
- // src/actions/get_available_nodes.ts
561
- var AvailableOSImageSchema = import_zod4.z.object({
562
- name: import_zod4.z.string(),
563
- is_dev: import_zod4.z.boolean(),
564
- version: import_zod4.z.union([
565
- import_zod4.z.tuple([import_zod4.z.number(), import_zod4.z.number(), import_zod4.z.number()]),
566
- import_zod4.z.tuple([import_zod4.z.number(), import_zod4.z.number(), import_zod4.z.number(), import_zod4.z.number()])
567
- ]),
568
- os_image_hash: import_zod4.z.string().nullable().optional()
569
- }).passthrough();
570
- var TeepodCapacitySchema = import_zod4.z.object({
571
- teepod_id: import_zod4.z.number(),
572
- name: import_zod4.z.string(),
573
- listed: import_zod4.z.boolean(),
574
- resource_score: import_zod4.z.number(),
575
- remaining_vcpu: import_zod4.z.number(),
576
- remaining_memory: import_zod4.z.number(),
577
- remaining_cvm_slots: import_zod4.z.number(),
578
- images: import_zod4.z.array(AvailableOSImageSchema),
579
- support_onchain_kms: import_zod4.z.boolean().optional(),
580
- fmspc: import_zod4.z.string().nullable().optional(),
581
- device_id: import_zod4.z.string().nullable().optional(),
582
- region_identifier: import_zod4.z.string().nullable().optional(),
583
- default_kms: import_zod4.z.string().nullable().optional(),
584
- kms_list: import_zod4.z.array(import_zod4.z.string()).default([])
585
- }).passthrough();
586
- var ResourceThresholdSchema = import_zod4.z.object({
587
- max_instances: import_zod4.z.number().nullable().optional(),
588
- max_vcpu: import_zod4.z.number().nullable().optional(),
589
- max_memory: import_zod4.z.number().nullable().optional(),
590
- max_disk: import_zod4.z.number().nullable().optional()
591
- }).passthrough();
592
- var AvailableNodesSchema = import_zod4.z.object({
593
- tier: import_zod4.z.string(),
594
- // TeamTier is string enum
595
- capacity: ResourceThresholdSchema,
596
- nodes: import_zod4.z.array(TeepodCapacitySchema),
597
- kms_list: import_zod4.z.array(KmsInfoSchema)
598
- }).passthrough();
599
- var { action: getAvailableNodes, safeAction: safeGetAvailableNodes } = defineSimpleAction(
600
- AvailableNodesSchema,
601
- async (client) => {
602
- return await client.get("/teepods/available");
603
- }
604
- );
605
-
606
- // src/actions/list-instance-types.ts
607
- var import_zod5 = require("zod");
608
- var ListInstanceTypesRequestSchema = import_zod5.z.object({
609
- page: import_zod5.z.number().int().min(1).optional().default(1),
610
- page_size: import_zod5.z.number().int().min(1).max(1e3).optional().default(100)
611
- }).strict();
612
- var InstanceTypeSchema = import_zod5.z.object({
613
- id: import_zod5.z.string(),
614
- name: import_zod5.z.string(),
615
- description: import_zod5.z.string(),
616
- vcpu: import_zod5.z.number(),
617
- memory_mb: import_zod5.z.number(),
618
- hourly_rate: import_zod5.z.string(),
619
- requires_gpu: import_zod5.z.boolean(),
620
- public: import_zod5.z.boolean(),
621
- enabled: import_zod5.z.boolean()
622
- }).passthrough();
623
- var PaginatedInstanceTypesSchema = import_zod5.z.object({
624
- items: import_zod5.z.array(InstanceTypeSchema),
625
- total: import_zod5.z.number(),
626
- page: import_zod5.z.number(),
627
- page_size: import_zod5.z.number(),
628
- pages: import_zod5.z.number()
629
- }).strict();
630
- var { action: listInstanceTypes, safeAction: safeListInstanceTypes } = defineAction(PaginatedInstanceTypesSchema, async (client, request) => {
631
- const validatedRequest = ListInstanceTypesRequestSchema.parse(request ?? {});
632
- const queryParams = new URLSearchParams();
633
- queryParams.append("page", validatedRequest.page.toString());
634
- queryParams.append("page_size", validatedRequest.page_size.toString());
635
- return await client.get(`/api/instance-types?${queryParams.toString()}`);
636
- });
637
-
638
- // src/actions/workspaces/list_workspaces.ts
639
- var import_zod6 = require("zod");
640
- var WorkspaceResponseSchema = import_zod6.z.object({
641
- id: import_zod6.z.string(),
642
- name: import_zod6.z.string(),
643
- slug: import_zod6.z.string().nullable(),
644
- tier: import_zod6.z.string(),
645
- role: import_zod6.z.string(),
646
- created_at: import_zod6.z.string()
647
- }).passthrough();
648
- var PaginationMetadataSchema = import_zod6.z.object({
649
- has_more: import_zod6.z.boolean(),
650
- next_cursor: import_zod6.z.string().nullable(),
651
- total: import_zod6.z.number().nullable()
652
- }).passthrough();
653
- var ListWorkspacesSchema = import_zod6.z.object({
654
- data: import_zod6.z.array(WorkspaceResponseSchema),
655
- pagination: PaginationMetadataSchema
656
- }).passthrough();
657
- var { action: listWorkspaces, safeAction: safeListWorkspaces } = defineAction(ListWorkspacesSchema, async (client, request) => {
658
- const queryParams = new URLSearchParams();
659
- if (request?.cursor) queryParams.append("cursor", request.cursor);
660
- if (request?.limit) queryParams.append("limit", request.limit.toString());
661
- const url = queryParams.toString() ? `/workspaces?${queryParams.toString()}` : "/workspaces";
662
- return await client.get(url);
663
- });
664
-
665
- // src/actions/workspaces/get_workspace.ts
666
- var { action: getWorkspace, safeAction: safeGetWorkspace } = defineAction(WorkspaceResponseSchema, async (client, teamSlug) => {
667
- return await client.get(`/workspaces/${teamSlug}`);
668
- });
669
-
670
- // src/actions/cvms/get_cvm_info.ts
671
- var import_zod8 = require("zod");
672
-
673
- // src/types/cvm_info.ts
674
- var import_zod7 = require("zod");
675
- var VmInfoSchema = import_zod7.z.object({
676
- id: import_zod7.z.string(),
677
- name: import_zod7.z.string(),
678
- status: import_zod7.z.string(),
679
- uptime: import_zod7.z.string(),
680
- app_url: import_zod7.z.string().nullable(),
681
- app_id: import_zod7.z.string(),
682
- instance_id: import_zod7.z.string().nullable(),
683
- configuration: import_zod7.z.any().optional(),
684
- // TODO: add VmConfiguration schema if needed
685
- exited_at: import_zod7.z.string().nullable(),
686
- boot_progress: import_zod7.z.string().nullable(),
687
- boot_error: import_zod7.z.string().nullable(),
688
- shutdown_progress: import_zod7.z.string().nullable(),
689
- image_version: import_zod7.z.string().nullable()
690
- });
691
- var ManagedUserSchema = import_zod7.z.object({
692
- id: import_zod7.z.number(),
693
- username: import_zod7.z.string()
694
- });
695
- var CvmNodeSchema = import_zod7.z.object({
696
- id: import_zod7.z.number(),
697
- name: import_zod7.z.string(),
698
- region_identifier: import_zod7.z.string().optional()
699
- });
700
- var CvmNetworkUrlsSchema = import_zod7.z.object({
701
- app: import_zod7.z.string(),
702
- instance: import_zod7.z.string()
703
- });
704
- var CvmInfoSchema = import_zod7.z.object({
705
- hosted: VmInfoSchema,
706
- name: import_zod7.z.string(),
707
- managed_user: ManagedUserSchema.optional().nullable(),
708
- node: CvmNodeSchema.optional().nullable(),
709
- listed: import_zod7.z.boolean().default(false),
710
- status: import_zod7.z.string(),
711
- in_progress: import_zod7.z.boolean().default(false),
712
- dapp_dashboard_url: import_zod7.z.string().nullable(),
713
- syslog_endpoint: import_zod7.z.string().nullable(),
714
- allow_upgrade: import_zod7.z.boolean().default(false),
715
- project_id: import_zod7.z.string().nullable(),
716
- // HashedId is represented as string in JS
717
- project_type: import_zod7.z.string().nullable(),
718
- billing_period: import_zod7.z.string().nullable(),
719
- kms_info: KmsInfoSchema.nullable(),
720
- vcpu: import_zod7.z.number().nullable(),
721
- memory: import_zod7.z.number().nullable(),
722
- disk_size: import_zod7.z.number().nullable(),
723
- gateway_domain: import_zod7.z.string().nullable(),
724
- public_urls: import_zod7.z.array(CvmNetworkUrlsSchema)
725
- }).partial();
726
- var CvmLegacyDetailSchema = import_zod7.z.object({
727
- id: import_zod7.z.number(),
728
- name: import_zod7.z.string(),
729
- status: import_zod7.z.string(),
730
- in_progress: import_zod7.z.boolean(),
731
- teepod_id: import_zod7.z.number().nullable(),
732
- teepod: CvmNodeSchema,
733
- app_id: import_zod7.z.string(),
734
- vm_uuid: import_zod7.z.string().nullable(),
735
- instance_id: import_zod7.z.string().nullable(),
736
- vcpu: import_zod7.z.number().nullable(),
737
- memory: import_zod7.z.number().nullable(),
738
- disk_size: import_zod7.z.number().nullable(),
739
- base_image: import_zod7.z.string(),
740
- encrypted_env_pubkey: import_zod7.z.string().nullable(),
741
- listed: import_zod7.z.boolean(),
742
- project_id: import_zod7.z.string().nullable(),
743
- project_type: import_zod7.z.string().nullable(),
744
- public_sysinfo: import_zod7.z.boolean(),
745
- public_logs: import_zod7.z.boolean(),
746
- dapp_dashboard_url: import_zod7.z.string().nullable(),
747
- syslog_endpoint: import_zod7.z.string().nullable(),
748
- kms_info: KmsInfoSchema.nullable(),
749
- contract_address: import_zod7.z.string().nullable(),
750
- deployer_address: import_zod7.z.string().nullable(),
751
- scheduled_delete_at: import_zod7.z.string().nullable(),
752
- public_urls: import_zod7.z.array(CvmNetworkUrlsSchema),
753
- gateway_domain: import_zod7.z.string().nullable()
754
- });
755
-
756
- // src/actions/cvms/get_cvm_info.ts
757
- var GetCvmInfoRequestSchema = import_zod8.z.object({
758
- id: import_zod8.z.string().optional(),
759
- uuid: import_zod8.z.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),
760
- app_id: import_zod8.z.string().refine(
761
- (val) => !val.startsWith("app_") && val.length === 40,
762
- "app_id should be 40 characters without prefix"
763
- ).transform((val) => val.startsWith("app_") ? val : `app_${val}`).optional(),
764
- instance_id: import_zod8.z.string().refine(
765
- (val) => !val.startsWith("instance_") && val.length === 40,
766
- "instance_id should be 40 characters without prefix"
767
- ).transform((val) => val.startsWith("instance_") ? val : `instance_${val}`).optional()
768
- }).refine(
769
- (data) => !!(data.id || data.uuid || data.app_id || data.instance_id),
770
- "One of id, uuid, app_id, or instance_id must be provided"
771
- ).transform((data) => ({
772
- cvmId: data.id || data.uuid || data.app_id || data.instance_id,
773
- _raw: data
774
- }));
775
- var { action: getCvmInfo, safeAction: safeGetCvmInfo } = defineAction(CvmLegacyDetailSchema, async (client, request) => {
776
- const validatedRequest = GetCvmInfoRequestSchema.parse(request);
777
- return await client.get(`/cvms/${validatedRequest.cvmId}`);
778
- });
779
-
780
- // src/actions/cvms/get_cvm_list.ts
781
- var import_zod9 = require("zod");
782
- var GetCvmListRequestSchema = import_zod9.z.object({
783
- page: import_zod9.z.number().int().min(1).optional(),
784
- page_size: import_zod9.z.number().int().min(1).optional(),
785
- node_id: import_zod9.z.number().int().min(1).optional()
786
- }).strict();
787
- var GetCvmListSchema = import_zod9.z.object({
788
- items: import_zod9.z.array(CvmInfoSchema),
789
- total: import_zod9.z.number(),
790
- page: import_zod9.z.number(),
791
- page_size: import_zod9.z.number(),
792
- pages: import_zod9.z.number()
793
- }).strict();
794
- var { action: getCvmList, safeAction: safeGetCvmList } = defineAction(GetCvmListSchema, async (client, request) => {
795
- const validatedRequest = GetCvmListRequestSchema.parse(request ?? {});
796
- return await client.get("/cvms/paginated", { params: validatedRequest });
797
- });
798
-
799
- // src/actions/cvms/provision_cvm.ts
800
- var import_zod10 = require("zod");
801
- var ProvisionCvmSchema = import_zod10.z.object({
802
- app_id: import_zod10.z.string().nullable().optional(),
803
- app_env_encrypt_pubkey: import_zod10.z.string().nullable().optional(),
804
- compose_hash: import_zod10.z.string(),
805
- fmspc: import_zod10.z.string().nullable().optional(),
806
- device_id: import_zod10.z.string().nullable().optional(),
807
- os_image_hash: import_zod10.z.string().nullable().optional(),
808
- teepod_id: import_zod10.z.number().nullable().optional(),
809
- // Will be transformed to node_id
810
- node_id: import_zod10.z.number().nullable().optional(),
811
- kms_id: import_zod10.z.string().nullable().optional()
812
- }).passthrough().transform((data) => {
813
- if ("teepod_id" in data && data.teepod_id !== void 0) {
814
- const { teepod_id, ...rest } = data;
815
- return { ...rest, node_id: teepod_id };
816
- }
817
- return data;
818
- });
819
- var ProvisionCvmRequestSchema = import_zod10.z.object({
820
- node_id: import_zod10.z.number().optional(),
821
- // recommended
822
- teepod_id: import_zod10.z.number().optional(),
823
- // deprecated, for compatibility
824
- name: import_zod10.z.string(),
825
- image: import_zod10.z.string(),
826
- vcpu: import_zod10.z.number(),
827
- memory: import_zod10.z.number(),
828
- disk_size: import_zod10.z.number(),
829
- compose_file: import_zod10.z.object({
830
- allowed_envs: import_zod10.z.array(import_zod10.z.string()).optional(),
831
- pre_launch_script: import_zod10.z.string().optional(),
832
- docker_compose_file: import_zod10.z.string().optional(),
833
- name: import_zod10.z.string().optional(),
834
- kms_enabled: import_zod10.z.boolean().optional(),
835
- public_logs: import_zod10.z.boolean().optional(),
836
- public_sysinfo: import_zod10.z.boolean().optional(),
837
- gateway_enabled: import_zod10.z.boolean().optional(),
838
- // recommended
839
- tproxy_enabled: import_zod10.z.boolean().optional()
840
- // deprecated, for compatibility
841
- }),
842
- listed: import_zod10.z.boolean().optional(),
843
- instance_type: import_zod10.z.string().nullable().optional(),
844
- kms_id: import_zod10.z.string().optional(),
845
- env_keys: import_zod10.z.array(import_zod10.z.string()).optional()
846
- }).passthrough();
847
- function autofillComposeFileName(appCompose) {
848
- if (appCompose.compose_file && !appCompose.compose_file.name) {
849
- return {
850
- ...appCompose,
851
- compose_file: {
852
- ...appCompose.compose_file,
853
- name: appCompose.name
854
- }
855
- };
856
- }
857
- return appCompose;
858
- }
859
- function handleGatewayCompatibility(appCompose) {
860
- if (!appCompose.compose_file) {
861
- return appCompose;
862
- }
863
- const composeFile = { ...appCompose.compose_file };
864
- if (typeof composeFile.gateway_enabled === "boolean" && typeof composeFile.tproxy_enabled === "boolean") {
865
- delete composeFile.tproxy_enabled;
866
- } else if (typeof composeFile.tproxy_enabled === "boolean" && typeof composeFile.gateway_enabled === "undefined") {
867
- composeFile.gateway_enabled = composeFile.tproxy_enabled;
868
- delete composeFile.tproxy_enabled;
869
- if (typeof window !== "undefined" ? window.console : globalThis.console) {
870
- console.warn(
871
- "[phala/cloud] tproxy_enabled is deprecated, please use gateway_enabled instead. See docs for migration."
872
- );
873
- }
874
- }
875
- return {
876
- ...appCompose,
877
- compose_file: composeFile
878
- };
879
- }
880
- var { action: provisionCvm, safeAction: safeProvisionCvm } = defineAction(ProvisionCvmSchema, async (client, appCompose) => {
881
- const body = handleGatewayCompatibility(autofillComposeFileName(appCompose));
882
- let requestBody = { ...body };
883
- if (typeof body.node_id === "number") {
884
- requestBody = { ...body, teepod_id: body.node_id };
885
- delete requestBody.node_id;
886
- } else if (typeof body.teepod_id === "number") {
887
- console.warn("[phala/cloud] teepod_id is deprecated, please use node_id instead.");
888
- }
889
- return await client.post("/cvms/provision", requestBody);
890
- });
891
-
892
- // src/actions/cvms/commit_cvm_provision.ts
893
- var import_zod11 = require("zod");
894
- var CommitCvmProvisionSchema = import_zod11.z.object({
895
- id: import_zod11.z.number(),
896
- name: import_zod11.z.string(),
897
- status: import_zod11.z.string(),
898
- teepod_id: import_zod11.z.number(),
899
- teepod: import_zod11.z.object({
900
- id: import_zod11.z.number(),
901
- name: import_zod11.z.string()
902
- }).nullable(),
903
- user_id: import_zod11.z.number().nullable(),
904
- app_id: import_zod11.z.string().nullable(),
905
- vm_uuid: import_zod11.z.string().nullable(),
906
- instance_id: import_zod11.z.string().nullable(),
907
- app_url: import_zod11.z.string().nullable(),
908
- base_image: import_zod11.z.string().nullable(),
909
- vcpu: import_zod11.z.number(),
910
- memory: import_zod11.z.number(),
911
- disk_size: import_zod11.z.number(),
912
- manifest_version: import_zod11.z.number().nullable(),
913
- version: import_zod11.z.string().nullable(),
914
- runner: import_zod11.z.string().nullable(),
915
- docker_compose_file: import_zod11.z.string().nullable(),
916
- features: import_zod11.z.array(import_zod11.z.string()).nullable(),
917
- created_at: import_zod11.z.string(),
918
- encrypted_env_pubkey: import_zod11.z.string().nullable().optional(),
919
- app_auth_contract_address: import_zod11.z.string().nullable().optional(),
920
- deployer_address: import_zod11.z.string().nullable().optional()
921
- }).passthrough();
922
- var CommitCvmProvisionRequestSchema = import_zod11.z.object({
923
- encrypted_env: import_zod11.z.string().optional().nullable(),
924
- app_id: import_zod11.z.string(),
925
- compose_hash: import_zod11.z.string().optional(),
926
- kms_id: import_zod11.z.string().optional(),
927
- contract_address: import_zod11.z.string().optional(),
928
- deployer_address: import_zod11.z.string().optional(),
929
- env_keys: import_zod11.z.array(import_zod11.z.string()).optional().nullable()
930
- }).passthrough();
931
- var { action: commitCvmProvision, safeAction: safeCommitCvmProvision } = defineAction(CommitCvmProvisionSchema, async (client, payload) => {
932
- return await client.post("/cvms", payload);
933
- });
934
-
935
- // src/actions/cvms/get_cvm_compose_file.ts
936
- var import_zod13 = require("zod");
937
-
938
- // src/types/app_compose.ts
939
- var import_zod12 = require("zod");
940
- var LooseAppComposeSchema = import_zod12.z.object({
941
- allowed_envs: import_zod12.z.array(import_zod12.z.string()).optional(),
942
- docker_compose_file: import_zod12.z.string(),
943
- features: import_zod12.z.array(import_zod12.z.string()).optional(),
944
- name: import_zod12.z.string().optional(),
945
- manifest_version: import_zod12.z.number().optional(),
946
- kms_enabled: import_zod12.z.boolean().optional(),
947
- public_logs: import_zod12.z.boolean().optional(),
948
- public_sysinfo: import_zod12.z.boolean().optional(),
949
- tproxy_enabled: import_zod12.z.boolean().optional(),
950
- pre_launch_script: import_zod12.z.string().optional()
951
- }).passthrough();
952
-
953
- // src/actions/cvms/get_cvm_compose_file.ts
954
- var GetCvmComposeFileRequestSchema = import_zod13.z.object({
955
- id: import_zod13.z.string().optional(),
956
- uuid: import_zod13.z.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),
957
- app_id: import_zod13.z.string().refine(
958
- (val) => !val.startsWith("app_") && val.length === 40,
959
- "app_id should be 40 characters without prefix"
960
- ).transform((val) => val.startsWith("app_") ? val : `app_${val}`).optional(),
961
- instance_id: import_zod13.z.string().refine(
962
- (val) => !val.startsWith("instance_") && val.length === 40,
963
- "instance_id should be 40 characters without prefix"
964
- ).transform((val) => val.startsWith("instance_") ? val : `instance_${val}`).optional()
965
- }).refine(
966
- (data) => !!(data.id || data.uuid || data.app_id || data.instance_id),
967
- "One of id, uuid, app_id, or instance_id must be provided"
968
- ).transform((data) => ({
969
- cvmId: data.id || data.uuid || data.app_id || data.instance_id,
970
- _raw: data
971
- }));
972
- var { action: getCvmComposeFile, safeAction: safeGetCvmComposeFile } = defineAction(LooseAppComposeSchema, async (client, request) => {
973
- const validatedRequest = GetCvmComposeFileRequestSchema.parse(request);
974
- return await client.get(`/cvms/${validatedRequest.cvmId}/compose_file`);
975
- });
976
-
977
- // src/actions/cvms/provision_cvm_compose_file_update.ts
978
- var import_zod14 = require("zod");
979
- var ProvisionCvmComposeFileUpdateRequestSchema = import_zod14.z.object({
980
- id: import_zod14.z.string().optional(),
981
- uuid: import_zod14.z.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),
982
- app_id: import_zod14.z.string().refine(
983
- (val) => !val.startsWith("app_") && val.length === 40,
984
- "app_id should be 40 characters without prefix"
985
- ).transform((val) => val.startsWith("app_") ? val : `app_${val}`).optional(),
986
- instance_id: import_zod14.z.string().refine(
987
- (val) => !val.startsWith("instance_") && val.length === 40,
988
- "instance_id should be 40 characters without prefix"
989
- ).transform((val) => val.startsWith("instance_") ? val : `instance_${val}`).optional(),
990
- app_compose: LooseAppComposeSchema,
991
- update_env_vars: import_zod14.z.boolean().optional().nullable()
992
- }).refine(
993
- (data) => !!(data.id || data.uuid || data.app_id || data.instance_id),
994
- "One of id, uuid, app_id, or instance_id must be provided"
995
- ).transform((data) => ({
996
- cvmId: data.id || data.uuid || data.app_id || data.instance_id,
997
- request: data.app_compose,
998
- update_env_vars: data.update_env_vars,
999
- _raw: data
1000
- }));
1001
- var ProvisionCvmComposeFileUpdateResultSchema = import_zod14.z.object({
1002
- app_id: import_zod14.z.string().nullable(),
1003
- device_id: import_zod14.z.string().nullable(),
1004
- compose_hash: import_zod14.z.string(),
1005
- kms_info: KmsInfoSchema.nullable().optional()
1006
- }).passthrough();
1007
- var { action: provisionCvmComposeFileUpdate, safeAction: safeProvisionCvmComposeFileUpdate } = defineAction(ProvisionCvmComposeFileUpdateResultSchema, async (client, request) => {
1008
- const validatedRequest = ProvisionCvmComposeFileUpdateRequestSchema.parse(request);
1009
- return await client.post(
1010
- `/cvms/${validatedRequest.cvmId}/compose_file/provision`,
1011
- validatedRequest.request
1012
- );
1013
- });
1014
-
1015
- // src/actions/cvms/commit_cvm_compose_file_update.ts
1016
- var import_zod15 = require("zod");
1017
- var CommitCvmComposeFileUpdateRequestSchema = import_zod15.z.object({
1018
- id: import_zod15.z.string().optional(),
1019
- uuid: import_zod15.z.string().regex(/^[0-9a-f]{8}[-]?[0-9a-f]{4}[-]?4[0-9a-f]{3}[-]?[89ab][0-9a-f]{3}[-]?[0-9a-f]{12}$/i).optional(),
1020
- app_id: import_zod15.z.string().refine(
1021
- (val) => !val.startsWith("app_") && val.length === 40,
1022
- "app_id should be 40 characters without prefix"
1023
- ).transform((val) => val.startsWith("app_") ? val : `app_${val}`).optional(),
1024
- instance_id: import_zod15.z.string().refine(
1025
- (val) => !val.startsWith("instance_") && val.length === 40,
1026
- "instance_id should be 40 characters without prefix"
1027
- ).transform((val) => val.startsWith("instance_") ? val : `instance_${val}`).optional(),
1028
- compose_hash: import_zod15.z.string().min(1, "Compose hash is required"),
1029
- encrypted_env: import_zod15.z.string().optional(),
1030
- env_keys: import_zod15.z.array(import_zod15.z.string()).optional(),
1031
- update_env_vars: import_zod15.z.boolean().optional().nullable()
1032
- }).refine(
1033
- (data) => !!(data.id || data.uuid || data.app_id || data.instance_id),
1034
- "One of id, uuid, app_id, or instance_id must be provided"
1035
- ).transform((data) => ({
1036
- cvmId: data.id || data.uuid || data.app_id || data.instance_id,
1037
- compose_hash: data.compose_hash,
1038
- encrypted_env: data.encrypted_env,
1039
- env_keys: data.env_keys,
1040
- update_env_vars: !!data.update_env_vars,
1041
- _raw: data
1042
- }));
1043
- var CommitCvmComposeFileUpdateSchema = import_zod15.z.any().transform(() => void 0);
1044
- var { action: commitCvmComposeFileUpdate, safeAction: safeCommitCvmComposeFileUpdate } = defineAction(
1045
- CommitCvmComposeFileUpdateSchema,
1046
- async (client, request) => {
1047
- const validatedRequest = CommitCvmComposeFileUpdateRequestSchema.parse(request);
1048
- return await client.patch(`/cvms/${validatedRequest.cvmId}/compose_file`, {
1049
- compose_hash: validatedRequest.compose_hash,
1050
- encrypted_env: validatedRequest.encrypted_env,
1051
- env_keys: validatedRequest.env_keys
1052
- });
1053
- }
1054
- );
1055
-
1056
- // src/actions/kms/get_kms_info.ts
1057
- var import_zod16 = require("zod");
1058
- var GetKmsInfoRequestSchema = import_zod16.z.object({
1059
- kms_id: import_zod16.z.string().min(1, "KMS ID is required")
1060
- });
1061
- var { action: getKmsInfo, safeAction: safeGetKmsInfo } = defineAction(KmsInfoSchema, async (client, request) => {
1062
- const validatedRequest = GetKmsInfoRequestSchema.parse(request);
1063
- return await client.get(`/kms/${validatedRequest.kms_id}`);
1064
- });
1065
-
1066
- // src/actions/kms/get_kms_list.ts
1067
- var import_zod17 = require("zod");
1068
- var GetKmsListRequestSchema = import_zod17.z.object({
1069
- page: import_zod17.z.number().int().min(1).optional(),
1070
- page_size: import_zod17.z.number().int().min(1).optional(),
1071
- is_onchain: import_zod17.z.boolean().optional()
1072
- }).strict();
1073
- var GetKmsListSchema = import_zod17.z.object({
1074
- items: import_zod17.z.array(KmsInfoSchema),
1075
- total: import_zod17.z.number(),
1076
- page: import_zod17.z.number(),
1077
- page_size: import_zod17.z.number(),
1078
- pages: import_zod17.z.number()
1079
- }).strict();
1080
- var { action: getKmsList, safeAction: safeGetKmsList } = defineAction(GetKmsListSchema, async (client, request) => {
1081
- const validatedRequest = GetKmsListRequestSchema.parse(request ?? {});
1082
- return await client.get("/kms", { params: validatedRequest });
1083
- });
1084
-
1085
- // src/actions/kms/get_app_env_encrypt_pubkey.ts
1086
- var import_zod18 = require("zod");
1087
- var GetAppEnvEncryptPubKeyRequestSchema = import_zod18.z.object({
1088
- kms: import_zod18.z.string().min(1, "KMS ID or slug is required"),
1089
- app_id: import_zod18.z.string().refine(
1090
- (val) => val.length === 40 || val.startsWith("0x") && val.length === 42,
1091
- "App ID must be exactly 40 characters or 42 characters with 0x prefix"
1092
- )
1093
- }).strict();
1094
- var GetAppEnvEncryptPubKeySchema = import_zod18.z.object({
1095
- public_key: import_zod18.z.string(),
1096
- signature: import_zod18.z.string()
1097
- }).strict();
1098
- var { action: getAppEnvEncryptPubKey, safeAction: safeGetAppEnvEncryptPubKey } = defineAction(GetAppEnvEncryptPubKeySchema, async (client, payload) => {
1099
- const validatedRequest = GetAppEnvEncryptPubKeyRequestSchema.parse(payload);
1100
- return await client.get(`/kms/${validatedRequest.kms}/pubkey/${validatedRequest.app_id}`);
1101
- });
1102
-
1103
- // src/create-client.ts
1104
- function createClient2(config = {}) {
1105
- const client = createClient(config);
1106
- const allActions = {
1107
- getCurrentUser,
1108
- safeGetCurrentUser,
1109
- getAvailableNodes,
1110
- safeGetAvailableNodes,
1111
- listInstanceTypes,
1112
- safeListInstanceTypes,
1113
- listWorkspaces,
1114
- safeListWorkspaces,
1115
- getWorkspace,
1116
- safeGetWorkspace,
1117
- getCvmInfo,
1118
- safeGetCvmInfo,
1119
- getCvmList,
1120
- safeGetCvmList,
1121
- provisionCvm,
1122
- safeProvisionCvm,
1123
- commitCvmProvision,
1124
- safeCommitCvmProvision,
1125
- getCvmComposeFile,
1126
- safeGetCvmComposeFile,
1127
- provisionCvmComposeFileUpdate,
1128
- safeProvisionCvmComposeFileUpdate,
1129
- commitCvmComposeFileUpdate,
1130
- safeCommitCvmComposeFileUpdate,
1131
- getKmsInfo,
1132
- safeGetKmsInfo,
1133
- getKmsList,
1134
- safeGetKmsList,
1135
- getAppEnvEncryptPubKey,
1136
- safeGetAppEnvEncryptPubKey
1137
- };
1138
- return client.extend(allActions);
1139
- }
1140
- // Annotate the CommonJS export names for ESM import in node:
1141
- 0 && (module.exports = {
1142
- createClient
1143
- });