@phala/cloud 0.0.7 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,116 @@
1
+ # Phala Cloud JavaScript SDK
2
+
3
+ TypeScript SDK for Phala Cloud API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Using npm
9
+ npm install @phala/cloud
10
+
11
+ # Using yarn
12
+ yarn add @phala/cloud
13
+
14
+ # Using pnpm
15
+ pnpm add @phala/cloud
16
+
17
+ # Using bun
18
+ bun add @phala/cloud
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ### Basic Usage
24
+
25
+ ```typescript
26
+ import { createClient } from '@phala/cloud';
27
+
28
+ // Create client with API key
29
+ const client = createClient({
30
+ apiKey: 'your-api-key',
31
+ // Optional: override base URL
32
+ // baseURL: 'https://custom-api.example.com'
33
+ });
34
+
35
+ // Make API requests
36
+ const result = await client.get('/kms');
37
+ console.log(result);
38
+
39
+ // Using safe methods that return a SafeResult
40
+ const safeResult = await client.safeGet('/kms');
41
+ if (safeResult.success) {
42
+ console.log('Success:', safeResult.data);
43
+ } else {
44
+ console.error('Error:', safeResult.error);
45
+ }
46
+ ```
47
+
48
+ ### Environment Variables
49
+
50
+ You can configure the client using environment variables:
51
+
52
+ - `PHALA_CLOUD_API_KEY`: API key for authentication
53
+ - `PHALA_CLOUD_API_PREFIX`: Base URL prefix for the API
54
+
55
+ ```typescript
56
+ // Using environment variables (set PHALA_CLOUD_API_KEY)
57
+ const client = createClient();
58
+ ```
59
+
60
+ ### Debug Logging
61
+
62
+ The SDK includes built-in debug logging that can display cURL-like request and response information. To enable it, set the `DEBUG` environment variable to `phala::api-client`:
63
+
64
+ ```bash
65
+ # Enable debug logging
66
+ DEBUG=phala::api-client node your-script.js
67
+
68
+ # Or with bun
69
+ DEBUG=phala::api-client bun run your-script.ts
70
+ ```
71
+
72
+ This will print detailed information about each API call in a format similar to cURL:
73
+
74
+ ```
75
+ === REQUEST ===
76
+ > curl -X GET "https://cloud-api.phala.network/api/v1/kms"
77
+ -H "X-API-Key: your-api-key"
78
+ -H "X-Phala-Version: 2025-05-31"
79
+ -H "Content-Type: application/json"
80
+
81
+ === RESPONSE [GET /kms] (123ms) ===
82
+ < HTTP/1.1 200 OK
83
+ < content-type: application/json
84
+ < x-response-time: 123
85
+
86
+ {
87
+ "data": [
88
+ {
89
+ "id": "example-id",
90
+ "name": "Example Key"
91
+ }
92
+ ]
93
+ }
94
+ ```
95
+
96
+ ## Available Methods
97
+
98
+ ### Direct Methods (throw on error)
99
+
100
+ - `client.get<T>(request, options?): Promise<T>`
101
+ - `client.post<T>(request, body?, options?): Promise<T>`
102
+ - `client.put<T>(request, body?, options?): Promise<T>`
103
+ - `client.patch<T>(request, body?, options?): Promise<T>`
104
+ - `client.delete<T>(request, options?): Promise<T>`
105
+
106
+ ### Safe Methods (return SafeResult)
107
+
108
+ - `client.safeGet<T>(request, options?): Promise<SafeResult<T>>`
109
+ - `client.safePost<T>(request, body?, options?): Promise<SafeResult<T>>`
110
+ - `client.safePut<T>(request, body?, options?): Promise<SafeResult<T>>`
111
+ - `client.safePatch<T>(request, body?, options?): Promise<SafeResult<T>>`
112
+ - `client.safeDelete<T>(request, options?): Promise<SafeResult<T>>`
113
+
114
+ ## License
115
+
116
+ Apache-2.0
@@ -92,31 +92,47 @@ export declare const GetCvmListSchema: z.ZodObject<{
92
92
  project_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
93
93
  project_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
94
94
  billing_period: z.ZodOptional<z.ZodNullable<z.ZodString>>;
95
- kms_info: z.ZodOptional<z.ZodNullable<z.ZodObject<{
95
+ kms_info: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodObject<{
96
96
  id: z.ZodString;
97
- slug: z.ZodString;
97
+ slug: z.ZodNullable<z.ZodString>;
98
98
  url: z.ZodString;
99
99
  version: z.ZodString;
100
- chain_id: z.ZodOptional<z.ZodNumber>;
101
- kms_contract_address: z.ZodOptional<z.ZodString>;
102
- gateway_app_id: z.ZodOptional<z.ZodString>;
103
- }, "strip", z.ZodTypeAny, {
104
- version: string;
105
- id: string;
106
- slug: string;
107
- url: string;
108
- chain_id?: number | undefined;
109
- kms_contract_address?: string | undefined;
110
- gateway_app_id?: string | undefined;
111
- }, {
112
- version: string;
113
- id: string;
114
- slug: string;
115
- url: string;
116
- chain_id?: number | undefined;
117
- kms_contract_address?: string | undefined;
118
- gateway_app_id?: string | undefined;
119
- }>>>;
100
+ chain_id: z.ZodNullable<z.ZodNumber>;
101
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
102
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
103
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
104
+ id: z.ZodString;
105
+ slug: z.ZodNullable<z.ZodString>;
106
+ url: z.ZodString;
107
+ version: z.ZodString;
108
+ chain_id: z.ZodNullable<z.ZodNumber>;
109
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
110
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
111
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
112
+ id: z.ZodString;
113
+ slug: z.ZodNullable<z.ZodString>;
114
+ url: z.ZodString;
115
+ version: z.ZodString;
116
+ chain_id: z.ZodNullable<z.ZodNumber>;
117
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
118
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
119
+ }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
120
+ id: z.ZodString;
121
+ slug: z.ZodNullable<z.ZodString>;
122
+ url: z.ZodString;
123
+ version: z.ZodString;
124
+ chain_id: z.ZodNullable<z.ZodNumber>;
125
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
126
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
127
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
128
+ id: z.ZodString;
129
+ slug: z.ZodNullable<z.ZodString>;
130
+ url: z.ZodString;
131
+ version: z.ZodString;
132
+ chain_id: z.ZodNullable<z.ZodNumber>;
133
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
134
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
135
+ }, z.ZodTypeAny, "passthrough">>>>;
120
136
  vcpu: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
121
137
  memory: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
122
138
  disk_size: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
@@ -166,15 +182,15 @@ export declare const GetCvmListSchema: z.ZodObject<{
166
182
  project_id?: string | null | undefined;
167
183
  project_type?: string | null | undefined;
168
184
  billing_period?: string | null | undefined;
169
- kms_info?: {
170
- version: string;
171
- id: string;
172
- slug: string;
173
- url: string;
174
- chain_id?: number | undefined;
175
- kms_contract_address?: string | undefined;
176
- gateway_app_id?: string | undefined;
177
- } | null | undefined;
185
+ kms_info?: z.objectOutputType<{
186
+ id: z.ZodString;
187
+ slug: z.ZodNullable<z.ZodString>;
188
+ url: z.ZodString;
189
+ version: z.ZodString;
190
+ chain_id: z.ZodNullable<z.ZodNumber>;
191
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
192
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
193
+ }, z.ZodTypeAny, "passthrough"> | null | undefined;
178
194
  vcpu?: number | null | undefined;
179
195
  memory?: number | null | undefined;
180
196
  disk_size?: number | null | undefined;
@@ -218,15 +234,15 @@ export declare const GetCvmListSchema: z.ZodObject<{
218
234
  project_id?: string | null | undefined;
219
235
  project_type?: string | null | undefined;
220
236
  billing_period?: string | null | undefined;
221
- kms_info?: {
222
- version: string;
223
- id: string;
224
- slug: string;
225
- url: string;
226
- chain_id?: number | undefined;
227
- kms_contract_address?: string | undefined;
228
- gateway_app_id?: string | undefined;
229
- } | null | undefined;
237
+ kms_info?: z.objectInputType<{
238
+ id: z.ZodString;
239
+ slug: z.ZodNullable<z.ZodString>;
240
+ url: z.ZodString;
241
+ version: z.ZodString;
242
+ chain_id: z.ZodNullable<z.ZodNumber>;
243
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
244
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
245
+ }, z.ZodTypeAny, "passthrough"> | null | undefined;
230
246
  vcpu?: number | null | undefined;
231
247
  memory?: number | null | undefined;
232
248
  disk_size?: number | null | undefined;
@@ -278,15 +294,15 @@ export declare const GetCvmListSchema: z.ZodObject<{
278
294
  project_id?: string | null | undefined;
279
295
  project_type?: string | null | undefined;
280
296
  billing_period?: string | null | undefined;
281
- kms_info?: {
282
- version: string;
283
- id: string;
284
- slug: string;
285
- url: string;
286
- chain_id?: number | undefined;
287
- kms_contract_address?: string | undefined;
288
- gateway_app_id?: string | undefined;
289
- } | null | undefined;
297
+ kms_info?: z.objectOutputType<{
298
+ id: z.ZodString;
299
+ slug: z.ZodNullable<z.ZodString>;
300
+ url: z.ZodString;
301
+ version: z.ZodString;
302
+ chain_id: z.ZodNullable<z.ZodNumber>;
303
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
304
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
305
+ }, z.ZodTypeAny, "passthrough"> | null | undefined;
290
306
  vcpu?: number | null | undefined;
291
307
  memory?: number | null | undefined;
292
308
  disk_size?: number | null | undefined;
@@ -336,15 +352,15 @@ export declare const GetCvmListSchema: z.ZodObject<{
336
352
  project_id?: string | null | undefined;
337
353
  project_type?: string | null | undefined;
338
354
  billing_period?: string | null | undefined;
339
- kms_info?: {
340
- version: string;
341
- id: string;
342
- slug: string;
343
- url: string;
344
- chain_id?: number | undefined;
345
- kms_contract_address?: string | undefined;
346
- gateway_app_id?: string | undefined;
347
- } | null | undefined;
355
+ kms_info?: z.objectInputType<{
356
+ id: z.ZodString;
357
+ slug: z.ZodNullable<z.ZodString>;
358
+ url: z.ZodString;
359
+ version: z.ZodString;
360
+ chain_id: z.ZodNullable<z.ZodNumber>;
361
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
362
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
363
+ }, z.ZodTypeAny, "passthrough"> | null | undefined;
348
364
  vcpu?: number | null | undefined;
349
365
  memory?: number | null | undefined;
350
366
  disk_size?: number | null | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"get_cvm_list.d.ts","sourceRoot":"","sources":["../../src/actions/get_cvm_list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAC;AAEzD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAGrE,eAAO,MAAM,uBAAuB;;;;;;;;;;;;EAMzB,CAAC;AAEZ,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B,EAC3B,UAAU,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,GACnC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAalC;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC,SAAS,GAAG,KAAK,GAAG,SAAS,GAAG,SAAS,EACxF,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,iBAAiB,EAC3B,UAAU,CAAC,EAAE,oBAAoB,CAAC,CAAC,CAAC,GACnC,OAAO,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CA0B9C"}
package/dist/client.d.ts CHANGED
@@ -64,6 +64,10 @@ export declare class Client {
64
64
  * - PHALA_CLOUD_API_KEY: API key for authentication
65
65
  * - PHALA_CLOUD_API_PREFIX: Base URL prefix for the API
66
66
  *
67
+ * Debug Logging:
68
+ * - Set DEBUG=phala::api-client to enable cURL-like request/response logging
69
+ * - This will print detailed information about each API call in a format similar to cURL
70
+ *
67
71
  * @example
68
72
  * ```typescript
69
73
  * // Using explicit configuration
@@ -74,6 +78,9 @@ export declare class Client {
74
78
  *
75
79
  * // Using environment variables (set PHALA_CLOUD_API_KEY)
76
80
  * const client = createClient()
81
+ *
82
+ * // To enable debug logging:
83
+ * // DEBUG=phala::api-client node your-script.js
77
84
  * ```
78
85
  */
79
86
  export declare function createClient(config?: ClientConfig): Client;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAc,MAAM,QAAQ,CAAC;AAClF,OAAO,EAAE,KAAK,UAAU,EAAE,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAClF,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAIjD;;GAEG;AACH,qBAAa,MAAM;IACjB,SAAS,CAAC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,CAAC,MAAM,EAAE,OAAO,CAAC,EACpD,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,GAAG,MAAM,CAAC,GAC9C,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAIvC;;OAEG;IACG,SAAS,CAAC,CAAC,GAAG,OAAO,EACzB,OAAO,EAAE,YAAY,EACrB,IAAI,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACpD,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,GAAG,MAAM,CAAC,GAC9C,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;IAIvC;;OAEG;IACG,UAAU,CAAC,CAAC,GAAG,OAAO,EAC1B,OAAO,EAAE,YAAY,EACrB,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,GACrC,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;CAGxC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAAC,MAAM,GAAE,YAAiB,GAAG,MAAM,CAE9D"}
package/dist/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
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
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
@@ -38,7 +48,6 @@ __export(index_exports, {
38
48
  GetCvmComposeFileResultSchema: () => GetCvmComposeFileResultSchema,
39
49
  GetCvmListSchema: () => GetCvmListSchema,
40
50
  GetKmsListSchema: () => GetKmsListSchema,
41
- KMSInfoSchema: () => KMSInfoSchema,
42
51
  KmsInfoSchema: () => KmsInfoSchema,
43
52
  ManagedUserSchema: () => ManagedUserSchema,
44
53
  NetworkError: () => NetworkError,
@@ -110,6 +119,7 @@ module.exports = __toCommonJS(index_exports);
110
119
 
111
120
  // src/client.ts
112
121
  var import_ofetch = require("ofetch");
122
+ var import_debug = __toESM(require("debug"));
113
123
 
114
124
  // src/types/client.ts
115
125
  var import_zod = require("zod");
@@ -182,6 +192,29 @@ var RequestError = class _RequestError extends Error {
182
192
 
183
193
  // src/client.ts
184
194
  var SUPPORTED_API_VERSIONS = ["2025-05-31"];
195
+ var logger = (0, import_debug.default)("phala::api-client");
196
+ function formatHeaders(headers) {
197
+ return Object.entries(headers).map(([key, value]) => ` -H "${key}: ${value}"`).join("\n");
198
+ }
199
+ function formatBody(body) {
200
+ if (!body) return "";
201
+ const bodyStr = typeof body === "string" ? body : JSON.stringify(body, null, 2);
202
+ return ` -d '${bodyStr.replace(/'/g, "\\'")}'`;
203
+ }
204
+ function formatResponse(status, statusText, headers, body) {
205
+ const headerEntries = [];
206
+ headers.forEach((value, key) => {
207
+ headerEntries.push(`${key}: ${value}`);
208
+ });
209
+ const headerStr = headerEntries.join("\n");
210
+ const bodyStr = typeof body === "string" ? body : JSON.stringify(body, null, 2);
211
+ return [
212
+ `< HTTP/1.1 ${status} ${statusText}`,
213
+ headerStr ? `< ${headerStr.replace(/\n/g, "\n< ")}` : "",
214
+ "",
215
+ bodyStr
216
+ ].filter(Boolean).join("\n");
217
+ }
185
218
  var Client = class {
186
219
  constructor(config = {}) {
187
220
  const resolvedConfig = {
@@ -197,19 +230,66 @@ var Client = class {
197
230
  );
198
231
  }
199
232
  const { apiKey, baseURL, timeout, headers, ...fetchOptions } = resolvedConfig;
233
+ const requestHeaders = {
234
+ "X-API-Key": apiKey,
235
+ "X-Phala-Version": version,
236
+ "Content-Type": "application/json",
237
+ ...headers || {}
238
+ };
200
239
  this.fetchInstance = import_ofetch.ofetch.create({
201
240
  baseURL,
202
241
  timeout: timeout || 3e4,
203
- headers: {
204
- "X-API-Key": apiKey,
205
- "X-Phala-Version": version,
206
- "Content-Type": "application/json",
207
- ...headers || {}
208
- },
242
+ headers: requestHeaders,
209
243
  ...fetchOptions,
244
+ // Log request in cURL format
245
+ onRequest({ request, options }) {
246
+ if (logger.enabled) {
247
+ const method = options.method || "GET";
248
+ const url = typeof request === "string" ? request : request.url;
249
+ const fullUrl = url.startsWith("http") ? url : `${baseURL}${url}`;
250
+ const headerObj = {};
251
+ if (options.headers && typeof options.headers === "object") {
252
+ Object.entries(options.headers).forEach(([key, value]) => {
253
+ if (typeof value === "string") {
254
+ headerObj[key] = value;
255
+ }
256
+ });
257
+ }
258
+ const curlCommand = [
259
+ `> curl -X ${method} "${fullUrl}"`,
260
+ formatHeaders(headerObj),
261
+ options.body ? formatBody(options.body) : ""
262
+ ].filter(Boolean).join("\n");
263
+ logger("\n=== REQUEST ===\n%s\n", curlCommand);
264
+ }
265
+ },
266
+ // Log response in cURL format
267
+ onResponse({ request, response, options }) {
268
+ if (logger.enabled) {
269
+ const method = options.method || "GET";
270
+ const url = typeof request === "string" ? request : request.url;
271
+ logger(
272
+ "\n=== RESPONSE [%s %s] (%dms) ===\n%s\n",
273
+ method,
274
+ url,
275
+ response.headers.get("x-response-time") || "?",
276
+ formatResponse(response.status, response.statusText, response.headers, response._data)
277
+ );
278
+ }
279
+ },
210
280
  // Generic handlers for response error (similar to request.ts)
211
- onResponseError: ({ response }) => {
281
+ onResponseError: ({ request, response, options }) => {
212
282
  console.warn(`HTTP ${response.status}: ${response.url}`);
283
+ if (logger.enabled) {
284
+ const method = options.method || "GET";
285
+ const url = typeof request === "string" ? request : request.url;
286
+ logger(
287
+ "\n=== ERROR RESPONSE [%s %s] ===\n%s\n",
288
+ method,
289
+ url,
290
+ formatResponse(response.status, response.statusText, response.headers, response._data)
291
+ );
292
+ }
213
293
  }
214
294
  });
215
295
  }
@@ -388,16 +468,6 @@ var CvmNetworkUrlsSchema = import_zod3.z.object({
388
468
  app: import_zod3.z.string(),
389
469
  instance: import_zod3.z.string()
390
470
  });
391
- var KMSInfoSchema = import_zod3.z.object({
392
- id: import_zod3.z.string(),
393
- // HashedId is represented as string in JS
394
- slug: import_zod3.z.string(),
395
- url: import_zod3.z.string(),
396
- version: import_zod3.z.string(),
397
- chain_id: import_zod3.z.number().optional(),
398
- kms_contract_address: import_zod3.z.string().optional(),
399
- gateway_app_id: import_zod3.z.string().optional()
400
- });
401
471
  var CvmInfoSchema = import_zod3.z.object({
402
472
  hosted: VmInfoSchema,
403
473
  name: import_zod3.z.string(),
@@ -413,7 +483,7 @@ var CvmInfoSchema = import_zod3.z.object({
413
483
  // HashedId is represented as string in JS
414
484
  project_type: import_zod3.z.string().nullable(),
415
485
  billing_period: import_zod3.z.string().nullable(),
416
- kms_info: KMSInfoSchema.nullable(),
486
+ kms_info: KmsInfoSchema.nullable(),
417
487
  vcpu: import_zod3.z.number().nullable(),
418
488
  memory: import_zod3.z.number().nullable(),
419
489
  disk_size: import_zod3.z.number().nullable(),
@@ -442,7 +512,7 @@ var CvmLegacyDetailSchema = import_zod3.z.object({
442
512
  public_logs: import_zod3.z.boolean(),
443
513
  dapp_dashboard_url: import_zod3.z.string().nullable(),
444
514
  syslog_endpoint: import_zod3.z.string().nullable(),
445
- kms_info: KMSInfoSchema.nullable(),
515
+ kms_info: KmsInfoSchema.nullable(),
446
516
  contract_address: import_zod3.z.string().nullable(),
447
517
  deployer_address: import_zod3.z.string().nullable(),
448
518
  scheduled_delete_at: import_zod3.z.string().nullable(),
@@ -2468,7 +2538,6 @@ var import_verify_env_encrypt_public_key = require("@phala/dstack-sdk/verify-env
2468
2538
  GetCvmComposeFileResultSchema,
2469
2539
  GetCvmListSchema,
2470
2540
  GetKmsListSchema,
2471
- KMSInfoSchema,
2472
2541
  KmsInfoSchema,
2473
2542
  ManagedUserSchema,
2474
2543
  NetworkError,
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  // src/client.ts
2
2
  import { ofetch } from "ofetch";
3
+ import debug from "debug";
3
4
 
4
5
  // src/types/client.ts
5
6
  import { z } from "zod";
@@ -72,6 +73,29 @@ var RequestError = class _RequestError extends Error {
72
73
 
73
74
  // src/client.ts
74
75
  var SUPPORTED_API_VERSIONS = ["2025-05-31"];
76
+ var logger = debug("phala::api-client");
77
+ function formatHeaders(headers) {
78
+ return Object.entries(headers).map(([key, value]) => ` -H "${key}: ${value}"`).join("\n");
79
+ }
80
+ function formatBody(body) {
81
+ if (!body) return "";
82
+ const bodyStr = typeof body === "string" ? body : JSON.stringify(body, null, 2);
83
+ return ` -d '${bodyStr.replace(/'/g, "\\'")}'`;
84
+ }
85
+ function formatResponse(status, statusText, headers, body) {
86
+ const headerEntries = [];
87
+ headers.forEach((value, key) => {
88
+ headerEntries.push(`${key}: ${value}`);
89
+ });
90
+ const headerStr = headerEntries.join("\n");
91
+ const bodyStr = typeof body === "string" ? body : JSON.stringify(body, null, 2);
92
+ return [
93
+ `< HTTP/1.1 ${status} ${statusText}`,
94
+ headerStr ? `< ${headerStr.replace(/\n/g, "\n< ")}` : "",
95
+ "",
96
+ bodyStr
97
+ ].filter(Boolean).join("\n");
98
+ }
75
99
  var Client = class {
76
100
  constructor(config = {}) {
77
101
  const resolvedConfig = {
@@ -87,19 +111,66 @@ var Client = class {
87
111
  );
88
112
  }
89
113
  const { apiKey, baseURL, timeout, headers, ...fetchOptions } = resolvedConfig;
114
+ const requestHeaders = {
115
+ "X-API-Key": apiKey,
116
+ "X-Phala-Version": version,
117
+ "Content-Type": "application/json",
118
+ ...headers || {}
119
+ };
90
120
  this.fetchInstance = ofetch.create({
91
121
  baseURL,
92
122
  timeout: timeout || 3e4,
93
- headers: {
94
- "X-API-Key": apiKey,
95
- "X-Phala-Version": version,
96
- "Content-Type": "application/json",
97
- ...headers || {}
98
- },
123
+ headers: requestHeaders,
99
124
  ...fetchOptions,
125
+ // Log request in cURL format
126
+ onRequest({ request, options }) {
127
+ if (logger.enabled) {
128
+ const method = options.method || "GET";
129
+ const url = typeof request === "string" ? request : request.url;
130
+ const fullUrl = url.startsWith("http") ? url : `${baseURL}${url}`;
131
+ const headerObj = {};
132
+ if (options.headers && typeof options.headers === "object") {
133
+ Object.entries(options.headers).forEach(([key, value]) => {
134
+ if (typeof value === "string") {
135
+ headerObj[key] = value;
136
+ }
137
+ });
138
+ }
139
+ const curlCommand = [
140
+ `> curl -X ${method} "${fullUrl}"`,
141
+ formatHeaders(headerObj),
142
+ options.body ? formatBody(options.body) : ""
143
+ ].filter(Boolean).join("\n");
144
+ logger("\n=== REQUEST ===\n%s\n", curlCommand);
145
+ }
146
+ },
147
+ // Log response in cURL format
148
+ onResponse({ request, response, options }) {
149
+ if (logger.enabled) {
150
+ const method = options.method || "GET";
151
+ const url = typeof request === "string" ? request : request.url;
152
+ logger(
153
+ "\n=== RESPONSE [%s %s] (%dms) ===\n%s\n",
154
+ method,
155
+ url,
156
+ response.headers.get("x-response-time") || "?",
157
+ formatResponse(response.status, response.statusText, response.headers, response._data)
158
+ );
159
+ }
160
+ },
100
161
  // Generic handlers for response error (similar to request.ts)
101
- onResponseError: ({ response }) => {
162
+ onResponseError: ({ request, response, options }) => {
102
163
  console.warn(`HTTP ${response.status}: ${response.url}`);
164
+ if (logger.enabled) {
165
+ const method = options.method || "GET";
166
+ const url = typeof request === "string" ? request : request.url;
167
+ logger(
168
+ "\n=== ERROR RESPONSE [%s %s] ===\n%s\n",
169
+ method,
170
+ url,
171
+ formatResponse(response.status, response.statusText, response.headers, response._data)
172
+ );
173
+ }
103
174
  }
104
175
  });
105
176
  }
@@ -278,16 +349,6 @@ var CvmNetworkUrlsSchema = z3.object({
278
349
  app: z3.string(),
279
350
  instance: z3.string()
280
351
  });
281
- var KMSInfoSchema = z3.object({
282
- id: z3.string(),
283
- // HashedId is represented as string in JS
284
- slug: z3.string(),
285
- url: z3.string(),
286
- version: z3.string(),
287
- chain_id: z3.number().optional(),
288
- kms_contract_address: z3.string().optional(),
289
- gateway_app_id: z3.string().optional()
290
- });
291
352
  var CvmInfoSchema = z3.object({
292
353
  hosted: VmInfoSchema,
293
354
  name: z3.string(),
@@ -303,7 +364,7 @@ var CvmInfoSchema = z3.object({
303
364
  // HashedId is represented as string in JS
304
365
  project_type: z3.string().nullable(),
305
366
  billing_period: z3.string().nullable(),
306
- kms_info: KMSInfoSchema.nullable(),
367
+ kms_info: KmsInfoSchema.nullable(),
307
368
  vcpu: z3.number().nullable(),
308
369
  memory: z3.number().nullable(),
309
370
  disk_size: z3.number().nullable(),
@@ -332,7 +393,7 @@ var CvmLegacyDetailSchema = z3.object({
332
393
  public_logs: z3.boolean(),
333
394
  dapp_dashboard_url: z3.string().nullable(),
334
395
  syslog_endpoint: z3.string().nullable(),
335
- kms_info: KMSInfoSchema.nullable(),
396
+ kms_info: KmsInfoSchema.nullable(),
336
397
  contract_address: z3.string().nullable(),
337
398
  deployer_address: z3.string().nullable(),
338
399
  scheduled_delete_at: z3.string().nullable(),
@@ -2376,7 +2437,6 @@ export {
2376
2437
  GetCvmComposeFileResultSchema,
2377
2438
  GetCvmListSchema,
2378
2439
  GetKmsListSchema,
2379
- KMSInfoSchema,
2380
2440
  KmsInfoSchema,
2381
2441
  ManagedUserSchema,
2382
2442
  NetworkError,
@@ -76,31 +76,6 @@ export declare const CvmNetworkUrlsSchema: z.ZodObject<{
76
76
  app: string;
77
77
  instance: string;
78
78
  }>;
79
- export declare const KMSInfoSchema: z.ZodObject<{
80
- id: z.ZodString;
81
- slug: z.ZodString;
82
- url: z.ZodString;
83
- version: z.ZodString;
84
- chain_id: z.ZodOptional<z.ZodNumber>;
85
- kms_contract_address: z.ZodOptional<z.ZodString>;
86
- gateway_app_id: z.ZodOptional<z.ZodString>;
87
- }, "strip", z.ZodTypeAny, {
88
- version: string;
89
- id: string;
90
- slug: string;
91
- url: string;
92
- chain_id?: number | undefined;
93
- kms_contract_address?: string | undefined;
94
- gateway_app_id?: string | undefined;
95
- }, {
96
- version: string;
97
- id: string;
98
- slug: string;
99
- url: string;
100
- chain_id?: number | undefined;
101
- kms_contract_address?: string | undefined;
102
- gateway_app_id?: string | undefined;
103
- }>;
104
79
  export declare const CvmInfoSchema: z.ZodObject<{
105
80
  hosted: z.ZodOptional<z.ZodObject<{
106
81
  id: z.ZodString;
@@ -178,31 +153,47 @@ export declare const CvmInfoSchema: z.ZodObject<{
178
153
  project_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
179
154
  project_type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
180
155
  billing_period: z.ZodOptional<z.ZodNullable<z.ZodString>>;
181
- kms_info: z.ZodOptional<z.ZodNullable<z.ZodObject<{
156
+ kms_info: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodObject<{
182
157
  id: z.ZodString;
183
- slug: z.ZodString;
158
+ slug: z.ZodNullable<z.ZodString>;
184
159
  url: z.ZodString;
185
160
  version: z.ZodString;
186
- chain_id: z.ZodOptional<z.ZodNumber>;
187
- kms_contract_address: z.ZodOptional<z.ZodString>;
188
- gateway_app_id: z.ZodOptional<z.ZodString>;
189
- }, "strip", z.ZodTypeAny, {
190
- version: string;
191
- id: string;
192
- slug: string;
193
- url: string;
194
- chain_id?: number | undefined;
195
- kms_contract_address?: string | undefined;
196
- gateway_app_id?: string | undefined;
197
- }, {
198
- version: string;
199
- id: string;
200
- slug: string;
201
- url: string;
202
- chain_id?: number | undefined;
203
- kms_contract_address?: string | undefined;
204
- gateway_app_id?: string | undefined;
205
- }>>>;
161
+ chain_id: z.ZodNullable<z.ZodNumber>;
162
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
163
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
164
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
165
+ id: z.ZodString;
166
+ slug: z.ZodNullable<z.ZodString>;
167
+ url: z.ZodString;
168
+ version: z.ZodString;
169
+ chain_id: z.ZodNullable<z.ZodNumber>;
170
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
171
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
172
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
173
+ id: z.ZodString;
174
+ slug: z.ZodNullable<z.ZodString>;
175
+ url: z.ZodString;
176
+ version: z.ZodString;
177
+ chain_id: z.ZodNullable<z.ZodNumber>;
178
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
179
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
180
+ }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
181
+ id: z.ZodString;
182
+ slug: z.ZodNullable<z.ZodString>;
183
+ url: z.ZodString;
184
+ version: z.ZodString;
185
+ chain_id: z.ZodNullable<z.ZodNumber>;
186
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
187
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
188
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
189
+ id: z.ZodString;
190
+ slug: z.ZodNullable<z.ZodString>;
191
+ url: z.ZodString;
192
+ version: z.ZodString;
193
+ chain_id: z.ZodNullable<z.ZodNumber>;
194
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
195
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
196
+ }, z.ZodTypeAny, "passthrough">>>>;
206
197
  vcpu: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
207
198
  memory: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
208
199
  disk_size: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
@@ -252,15 +243,15 @@ export declare const CvmInfoSchema: z.ZodObject<{
252
243
  project_id?: string | null | undefined;
253
244
  project_type?: string | null | undefined;
254
245
  billing_period?: string | null | undefined;
255
- kms_info?: {
256
- version: string;
257
- id: string;
258
- slug: string;
259
- url: string;
260
- chain_id?: number | undefined;
261
- kms_contract_address?: string | undefined;
262
- gateway_app_id?: string | undefined;
263
- } | null | undefined;
246
+ kms_info?: z.objectOutputType<{
247
+ id: z.ZodString;
248
+ slug: z.ZodNullable<z.ZodString>;
249
+ url: z.ZodString;
250
+ version: z.ZodString;
251
+ chain_id: z.ZodNullable<z.ZodNumber>;
252
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
253
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
254
+ }, z.ZodTypeAny, "passthrough"> | null | undefined;
264
255
  vcpu?: number | null | undefined;
265
256
  memory?: number | null | undefined;
266
257
  disk_size?: number | null | undefined;
@@ -304,15 +295,15 @@ export declare const CvmInfoSchema: z.ZodObject<{
304
295
  project_id?: string | null | undefined;
305
296
  project_type?: string | null | undefined;
306
297
  billing_period?: string | null | undefined;
307
- kms_info?: {
308
- version: string;
309
- id: string;
310
- slug: string;
311
- url: string;
312
- chain_id?: number | undefined;
313
- kms_contract_address?: string | undefined;
314
- gateway_app_id?: string | undefined;
315
- } | null | undefined;
298
+ kms_info?: z.objectInputType<{
299
+ id: z.ZodString;
300
+ slug: z.ZodNullable<z.ZodString>;
301
+ url: z.ZodString;
302
+ version: z.ZodString;
303
+ chain_id: z.ZodNullable<z.ZodNumber>;
304
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
305
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
306
+ }, z.ZodTypeAny, "passthrough"> | null | undefined;
316
307
  vcpu?: number | null | undefined;
317
308
  memory?: number | null | undefined;
318
309
  disk_size?: number | null | undefined;
@@ -357,31 +348,47 @@ export declare const CvmLegacyDetailSchema: z.ZodObject<{
357
348
  public_logs: z.ZodBoolean;
358
349
  dapp_dashboard_url: z.ZodNullable<z.ZodString>;
359
350
  syslog_endpoint: z.ZodNullable<z.ZodString>;
360
- kms_info: z.ZodNullable<z.ZodObject<{
351
+ kms_info: z.ZodNullable<z.ZodEffects<z.ZodObject<{
361
352
  id: z.ZodString;
362
- slug: z.ZodString;
353
+ slug: z.ZodNullable<z.ZodString>;
363
354
  url: z.ZodString;
364
355
  version: z.ZodString;
365
- chain_id: z.ZodOptional<z.ZodNumber>;
366
- kms_contract_address: z.ZodOptional<z.ZodString>;
367
- gateway_app_id: z.ZodOptional<z.ZodString>;
368
- }, "strip", z.ZodTypeAny, {
369
- version: string;
370
- id: string;
371
- slug: string;
372
- url: string;
373
- chain_id?: number | undefined;
374
- kms_contract_address?: string | undefined;
375
- gateway_app_id?: string | undefined;
376
- }, {
377
- version: string;
378
- id: string;
379
- slug: string;
380
- url: string;
381
- chain_id?: number | undefined;
382
- kms_contract_address?: string | undefined;
383
- gateway_app_id?: string | undefined;
384
- }>>;
356
+ chain_id: z.ZodNullable<z.ZodNumber>;
357
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
358
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
359
+ }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
360
+ id: z.ZodString;
361
+ slug: z.ZodNullable<z.ZodString>;
362
+ url: z.ZodString;
363
+ version: z.ZodString;
364
+ chain_id: z.ZodNullable<z.ZodNumber>;
365
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
366
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
367
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
368
+ id: z.ZodString;
369
+ slug: z.ZodNullable<z.ZodString>;
370
+ url: z.ZodString;
371
+ version: z.ZodString;
372
+ chain_id: z.ZodNullable<z.ZodNumber>;
373
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
374
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
375
+ }, z.ZodTypeAny, "passthrough">>, z.objectOutputType<{
376
+ id: z.ZodString;
377
+ slug: z.ZodNullable<z.ZodString>;
378
+ url: z.ZodString;
379
+ version: z.ZodString;
380
+ chain_id: z.ZodNullable<z.ZodNumber>;
381
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
382
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
383
+ }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
384
+ id: z.ZodString;
385
+ slug: z.ZodNullable<z.ZodString>;
386
+ url: z.ZodString;
387
+ version: z.ZodString;
388
+ chain_id: z.ZodNullable<z.ZodNumber>;
389
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
390
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
391
+ }, z.ZodTypeAny, "passthrough">>>;
385
392
  contract_address: z.ZodNullable<z.ZodString>;
386
393
  deployer_address: z.ZodNullable<z.ZodString>;
387
394
  scheduled_delete_at: z.ZodNullable<z.ZodString>;
@@ -408,15 +415,15 @@ export declare const CvmLegacyDetailSchema: z.ZodObject<{
408
415
  syslog_endpoint: string | null;
409
416
  project_id: string | null;
410
417
  project_type: string | null;
411
- kms_info: {
412
- version: string;
413
- id: string;
414
- slug: string;
415
- url: string;
416
- chain_id?: number | undefined;
417
- kms_contract_address?: string | undefined;
418
- gateway_app_id?: string | undefined;
419
- } | null;
418
+ kms_info: z.objectOutputType<{
419
+ id: z.ZodString;
420
+ slug: z.ZodNullable<z.ZodString>;
421
+ url: z.ZodString;
422
+ version: z.ZodString;
423
+ chain_id: z.ZodNullable<z.ZodNumber>;
424
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
425
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
426
+ }, z.ZodTypeAny, "passthrough"> | null;
420
427
  vcpu: number | null;
421
428
  memory: number | null;
422
429
  disk_size: number | null;
@@ -451,15 +458,15 @@ export declare const CvmLegacyDetailSchema: z.ZodObject<{
451
458
  syslog_endpoint: string | null;
452
459
  project_id: string | null;
453
460
  project_type: string | null;
454
- kms_info: {
455
- version: string;
456
- id: string;
457
- slug: string;
458
- url: string;
459
- chain_id?: number | undefined;
460
- kms_contract_address?: string | undefined;
461
- gateway_app_id?: string | undefined;
462
- } | null;
461
+ kms_info: z.objectInputType<{
462
+ id: z.ZodString;
463
+ slug: z.ZodNullable<z.ZodString>;
464
+ url: z.ZodString;
465
+ version: z.ZodString;
466
+ chain_id: z.ZodNullable<z.ZodNumber>;
467
+ kms_contract_address: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
468
+ gateway_app_id: z.ZodEffects<z.ZodNullable<z.ZodString>, `0x${string}`, string | null>;
469
+ }, z.ZodTypeAny, "passthrough"> | null;
463
470
  vcpu: number | null;
464
471
  memory: number | null;
465
472
  disk_size: number | null;
@@ -1 +1 @@
1
- {"version":3,"file":"cvm_info.d.ts","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3
+ "version": "0.0.9",
4
4
  "description": "TypeScript SDK for Phala Cloud API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -30,12 +30,14 @@
30
30
  "license": "Apache-2.0",
31
31
  "dependencies": {
32
32
  "@phala/dstack-sdk": "0.5.4-beta.6",
33
+ "debug": "^4.4.1",
33
34
  "ofetch": "^1.3.3",
34
35
  "viem": "^2.7.0",
35
36
  "zod": "^3.22.4"
36
37
  },
37
38
  "devDependencies": {
38
39
  "@biomejs/biome": "^1.9.4",
40
+ "@types/debug": "^4.1.12",
39
41
  "@types/node": "^20.10.0",
40
42
  "dotenv": "^16.5.0",
41
43
  "tsup": "^8.0.0",