@phala/cloud 0.0.10 → 0.0.12
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/dist/actions/commit_cvm_compose_file_update.d.ts +15 -1
- package/dist/actions/commit_cvm_compose_file_update.d.ts.map +1 -1
- package/dist/actions/get_cvm_compose_file.d.ts +2 -70
- package/dist/actions/get_cvm_compose_file.d.ts.map +1 -1
- package/dist/actions/index.d.ts +4 -1
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/list-instance-types.d.ts +146 -0
- package/dist/actions/list-instance-types.d.ts.map +1 -0
- package/dist/actions/provision_cvm_compose_file_update.d.ts +77 -25
- package/dist/actions/provision_cvm_compose_file_update.d.ts.map +1 -1
- package/dist/actions/workspaces/get_workspace.d.ts +72 -0
- package/dist/actions/workspaces/get_workspace.d.ts.map +1 -0
- package/dist/actions/workspaces/list_workspaces.d.ts +219 -0
- package/dist/actions/workspaces/list_workspaces.d.ts.map +1 -0
- package/dist/index.js +240 -77
- package/dist/index.mjs +229 -76
- package/dist/types/app_compose.d.ts +37 -0
- package/dist/types/app_compose.d.ts.map +1 -0
- package/package.json +66 -56
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1980,8 +1980,11 @@ async function safeAddComposeHash(request, parameters) {
|
|
|
1980
1980
|
}
|
|
1981
1981
|
|
|
1982
1982
|
// src/actions/get_cvm_compose_file.ts
|
|
1983
|
+
import { z as z11 } from "zod";
|
|
1984
|
+
|
|
1985
|
+
// src/types/app_compose.ts
|
|
1983
1986
|
import { z as z10 } from "zod";
|
|
1984
|
-
var
|
|
1987
|
+
var LooseAppComposeSchema = z10.object({
|
|
1985
1988
|
allowed_envs: z10.array(z10.string()).optional(),
|
|
1986
1989
|
docker_compose_file: z10.string(),
|
|
1987
1990
|
features: z10.array(z10.string()).optional(),
|
|
@@ -1993,14 +1996,16 @@ var GetCvmComposeFileResultSchema = z10.object({
|
|
|
1993
1996
|
tproxy_enabled: z10.boolean().optional(),
|
|
1994
1997
|
pre_launch_script: z10.string().optional()
|
|
1995
1998
|
}).passthrough();
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
1999
|
+
|
|
2000
|
+
// src/actions/get_cvm_compose_file.ts
|
|
2001
|
+
var GetCvmComposeFileRequestSchema = z11.object({
|
|
2002
|
+
id: z11.string().optional(),
|
|
2003
|
+
uuid: z11.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(),
|
|
2004
|
+
app_id: z11.string().refine(
|
|
2000
2005
|
(val) => !val.startsWith("app_") && val.length === 40,
|
|
2001
2006
|
"app_id should be 40 characters without prefix"
|
|
2002
2007
|
).transform((val) => val.startsWith("app_") ? val : `app_${val}`).optional(),
|
|
2003
|
-
instance_id:
|
|
2008
|
+
instance_id: z11.string().refine(
|
|
2004
2009
|
(val) => !val.startsWith("instance_") && val.length === 40,
|
|
2005
2010
|
"instance_id should be 40 characters without prefix"
|
|
2006
2011
|
).transform((val) => val.startsWith("instance_") ? val : `instance_${val}`).optional()
|
|
@@ -2017,7 +2022,7 @@ async function getCvmComposeFile(client, request, parameters) {
|
|
|
2017
2022
|
if (parameters?.schema === false) {
|
|
2018
2023
|
return response;
|
|
2019
2024
|
}
|
|
2020
|
-
const schema = parameters?.schema ||
|
|
2025
|
+
const schema = parameters?.schema || LooseAppComposeSchema;
|
|
2021
2026
|
return schema.parse(response);
|
|
2022
2027
|
}
|
|
2023
2028
|
async function safeGetCvmComposeFile(client, request, parameters) {
|
|
@@ -2032,44 +2037,38 @@ async function safeGetCvmComposeFile(client, request, parameters) {
|
|
|
2032
2037
|
if (parameters?.schema === false) {
|
|
2033
2038
|
return { success: true, data: httpResult.data };
|
|
2034
2039
|
}
|
|
2035
|
-
const schema = parameters?.schema ||
|
|
2040
|
+
const schema = parameters?.schema || LooseAppComposeSchema;
|
|
2036
2041
|
return schema.safeParse(httpResult.data);
|
|
2037
2042
|
}
|
|
2038
2043
|
|
|
2039
2044
|
// src/actions/provision_cvm_compose_file_update.ts
|
|
2040
|
-
import { z as
|
|
2041
|
-
var ProvisionCvmComposeFileUpdateRequestSchema =
|
|
2042
|
-
id:
|
|
2043
|
-
uuid:
|
|
2044
|
-
app_id:
|
|
2045
|
+
import { z as z12 } from "zod";
|
|
2046
|
+
var ProvisionCvmComposeFileUpdateRequestSchema = z12.object({
|
|
2047
|
+
id: z12.string().optional(),
|
|
2048
|
+
uuid: z12.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(),
|
|
2049
|
+
app_id: z12.string().refine(
|
|
2045
2050
|
(val) => !val.startsWith("app_") && val.length === 40,
|
|
2046
2051
|
"app_id should be 40 characters without prefix"
|
|
2047
2052
|
).transform((val) => val.startsWith("app_") ? val : `app_${val}`).optional(),
|
|
2048
|
-
instance_id:
|
|
2053
|
+
instance_id: z12.string().refine(
|
|
2049
2054
|
(val) => !val.startsWith("instance_") && val.length === 40,
|
|
2050
2055
|
"instance_id should be 40 characters without prefix"
|
|
2051
2056
|
).transform((val) => val.startsWith("instance_") ? val : `instance_${val}`).optional(),
|
|
2052
|
-
app_compose:
|
|
2053
|
-
|
|
2054
|
-
docker_compose_file: z11.string().min(1, "Docker compose file is required"),
|
|
2055
|
-
name: z11.string(),
|
|
2056
|
-
kms_enabled: z11.boolean().optional(),
|
|
2057
|
-
public_logs: z11.boolean().optional(),
|
|
2058
|
-
public_sysinfo: z11.boolean().optional(),
|
|
2059
|
-
pre_launch_script: z11.string().optional()
|
|
2060
|
-
})
|
|
2057
|
+
app_compose: LooseAppComposeSchema,
|
|
2058
|
+
update_env_vars: z12.boolean().optional().nullable()
|
|
2061
2059
|
}).refine(
|
|
2062
2060
|
(data) => !!(data.id || data.uuid || data.app_id || data.instance_id),
|
|
2063
2061
|
"One of id, uuid, app_id, or instance_id must be provided"
|
|
2064
2062
|
).transform((data) => ({
|
|
2065
2063
|
cvmId: data.id || data.uuid || data.app_id || data.instance_id,
|
|
2066
2064
|
request: data.app_compose,
|
|
2065
|
+
update_env_vars: data.update_env_vars,
|
|
2067
2066
|
_raw: data
|
|
2068
2067
|
}));
|
|
2069
|
-
var ProvisionCvmComposeFileUpdateResultSchema =
|
|
2070
|
-
app_id:
|
|
2071
|
-
device_id:
|
|
2072
|
-
compose_hash:
|
|
2068
|
+
var ProvisionCvmComposeFileUpdateResultSchema = z12.object({
|
|
2069
|
+
app_id: z12.string().nullable(),
|
|
2070
|
+
device_id: z12.string().nullable(),
|
|
2071
|
+
compose_hash: z12.string(),
|
|
2073
2072
|
kms_info: KmsInfoSchema.nullable().optional()
|
|
2074
2073
|
}).passthrough();
|
|
2075
2074
|
async function provisionCvmComposeFileUpdate(client, request, parameters) {
|
|
@@ -2104,21 +2103,22 @@ async function safeProvisionCvmComposeFileUpdate(client, request, parameters) {
|
|
|
2104
2103
|
}
|
|
2105
2104
|
|
|
2106
2105
|
// src/actions/commit_cvm_compose_file_update.ts
|
|
2107
|
-
import { z as
|
|
2108
|
-
var CommitCvmComposeFileUpdateRequestSchema =
|
|
2109
|
-
id:
|
|
2110
|
-
uuid:
|
|
2111
|
-
app_id:
|
|
2106
|
+
import { z as z13 } from "zod";
|
|
2107
|
+
var CommitCvmComposeFileUpdateRequestSchema = z13.object({
|
|
2108
|
+
id: z13.string().optional(),
|
|
2109
|
+
uuid: z13.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(),
|
|
2110
|
+
app_id: z13.string().refine(
|
|
2112
2111
|
(val) => !val.startsWith("app_") && val.length === 40,
|
|
2113
2112
|
"app_id should be 40 characters without prefix"
|
|
2114
2113
|
).transform((val) => val.startsWith("app_") ? val : `app_${val}`).optional(),
|
|
2115
|
-
instance_id:
|
|
2114
|
+
instance_id: z13.string().refine(
|
|
2116
2115
|
(val) => !val.startsWith("instance_") && val.length === 40,
|
|
2117
2116
|
"instance_id should be 40 characters without prefix"
|
|
2118
2117
|
).transform((val) => val.startsWith("instance_") ? val : `instance_${val}`).optional(),
|
|
2119
|
-
compose_hash:
|
|
2120
|
-
encrypted_env:
|
|
2121
|
-
env_keys:
|
|
2118
|
+
compose_hash: z13.string().min(1, "Compose hash is required"),
|
|
2119
|
+
encrypted_env: z13.string().optional(),
|
|
2120
|
+
env_keys: z13.array(z13.string()).optional(),
|
|
2121
|
+
update_env_vars: z13.boolean().optional().nullable()
|
|
2122
2122
|
}).refine(
|
|
2123
2123
|
(data) => !!(data.id || data.uuid || data.app_id || data.instance_id),
|
|
2124
2124
|
"One of id, uuid, app_id, or instance_id must be provided"
|
|
@@ -2127,9 +2127,10 @@ var CommitCvmComposeFileUpdateRequestSchema = z12.object({
|
|
|
2127
2127
|
compose_hash: data.compose_hash,
|
|
2128
2128
|
encrypted_env: data.encrypted_env,
|
|
2129
2129
|
env_keys: data.env_keys,
|
|
2130
|
+
update_env_vars: !!data.update_env_vars,
|
|
2130
2131
|
_raw: data
|
|
2131
2132
|
}));
|
|
2132
|
-
var CommitCvmComposeFileUpdateSchema =
|
|
2133
|
+
var CommitCvmComposeFileUpdateSchema = z13.any().transform(() => void 0);
|
|
2133
2134
|
async function commitCvmComposeFileUpdate(client, request, parameters) {
|
|
2134
2135
|
const validatedRequest = CommitCvmComposeFileUpdateRequestSchema.parse(request);
|
|
2135
2136
|
const response = await client.patch(`/cvms/${validatedRequest.cvmId}/compose_file`, {
|
|
@@ -2164,17 +2165,17 @@ async function safeCommitCvmComposeFileUpdate(client, request, parameters) {
|
|
|
2164
2165
|
}
|
|
2165
2166
|
|
|
2166
2167
|
// src/actions/get_app_env_encrypt_pubkey.ts
|
|
2167
|
-
import { z as
|
|
2168
|
-
var GetAppEnvEncryptPubKeyRequestSchema =
|
|
2169
|
-
kms:
|
|
2170
|
-
app_id:
|
|
2168
|
+
import { z as z14 } from "zod";
|
|
2169
|
+
var GetAppEnvEncryptPubKeyRequestSchema = z14.object({
|
|
2170
|
+
kms: z14.string().min(1, "KMS ID or slug is required"),
|
|
2171
|
+
app_id: z14.string().refine(
|
|
2171
2172
|
(val) => val.length === 40 || val.startsWith("0x") && val.length === 42,
|
|
2172
2173
|
"App ID must be exactly 40 characters or 42 characters with 0x prefix"
|
|
2173
2174
|
)
|
|
2174
2175
|
}).strict();
|
|
2175
|
-
var GetAppEnvEncryptPubKeySchema =
|
|
2176
|
-
public_key:
|
|
2177
|
-
signature:
|
|
2176
|
+
var GetAppEnvEncryptPubKeySchema = z14.object({
|
|
2177
|
+
public_key: z14.string(),
|
|
2178
|
+
signature: z14.string()
|
|
2178
2179
|
}).strict();
|
|
2179
2180
|
var getAppEnvEncryptPubKey = async (client, payload, parameters) => {
|
|
2180
2181
|
const validatedRequest = GetAppEnvEncryptPubKeyRequestSchema.parse(payload);
|
|
@@ -2211,15 +2212,15 @@ var safeGetAppEnvEncryptPubKey = async (client, payload, parameters) => {
|
|
|
2211
2212
|
};
|
|
2212
2213
|
|
|
2213
2214
|
// src/actions/get_cvm_info.ts
|
|
2214
|
-
import { z as
|
|
2215
|
-
var GetCvmInfoRequestSchema =
|
|
2216
|
-
id:
|
|
2217
|
-
uuid:
|
|
2218
|
-
app_id:
|
|
2215
|
+
import { z as z15 } from "zod";
|
|
2216
|
+
var GetCvmInfoRequestSchema = z15.object({
|
|
2217
|
+
id: z15.string().optional(),
|
|
2218
|
+
uuid: z15.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(),
|
|
2219
|
+
app_id: z15.string().refine(
|
|
2219
2220
|
(val) => !val.startsWith("app_") && val.length === 40,
|
|
2220
2221
|
"app_id should be 40 characters without prefix"
|
|
2221
2222
|
).transform((val) => val.startsWith("app_") ? val : `app_${val}`).optional(),
|
|
2222
|
-
instance_id:
|
|
2223
|
+
instance_id: z15.string().refine(
|
|
2223
2224
|
(val) => !val.startsWith("instance_") && val.length === 40,
|
|
2224
2225
|
"instance_id should be 40 characters without prefix"
|
|
2225
2226
|
).transform((val) => val.startsWith("instance_") ? val : `instance_${val}`).optional()
|
|
@@ -2265,18 +2266,18 @@ async function safeGetCvmInfo(client, request, parameters) {
|
|
|
2265
2266
|
}
|
|
2266
2267
|
|
|
2267
2268
|
// src/actions/get_cvm_list.ts
|
|
2268
|
-
import { z as
|
|
2269
|
-
var GetCvmListRequestSchema =
|
|
2270
|
-
page:
|
|
2271
|
-
page_size:
|
|
2272
|
-
node_id:
|
|
2269
|
+
import { z as z16 } from "zod";
|
|
2270
|
+
var GetCvmListRequestSchema = z16.object({
|
|
2271
|
+
page: z16.number().int().min(1).optional(),
|
|
2272
|
+
page_size: z16.number().int().min(1).optional(),
|
|
2273
|
+
node_id: z16.number().int().min(1).optional()
|
|
2273
2274
|
}).strict();
|
|
2274
|
-
var GetCvmListSchema =
|
|
2275
|
-
items:
|
|
2276
|
-
total:
|
|
2277
|
-
page:
|
|
2278
|
-
page_size:
|
|
2279
|
-
pages:
|
|
2275
|
+
var GetCvmListSchema = z16.object({
|
|
2276
|
+
items: z16.array(CvmInfoSchema),
|
|
2277
|
+
total: z16.number(),
|
|
2278
|
+
page: z16.number(),
|
|
2279
|
+
page_size: z16.number(),
|
|
2280
|
+
pages: z16.number()
|
|
2280
2281
|
}).strict();
|
|
2281
2282
|
async function getCvmList(client, request, parameters) {
|
|
2282
2283
|
const validatedRequest = GetCvmListRequestSchema.parse(request ?? {});
|
|
@@ -2313,9 +2314,9 @@ async function safeGetCvmList(client, request, parameters) {
|
|
|
2313
2314
|
}
|
|
2314
2315
|
|
|
2315
2316
|
// src/actions/get_kms_info.ts
|
|
2316
|
-
import { z as
|
|
2317
|
-
var GetKmsInfoRequestSchema =
|
|
2318
|
-
kms_id:
|
|
2317
|
+
import { z as z17 } from "zod";
|
|
2318
|
+
var GetKmsInfoRequestSchema = z17.object({
|
|
2319
|
+
kms_id: z17.string().min(1, "KMS ID is required")
|
|
2319
2320
|
});
|
|
2320
2321
|
async function getKmsInfo(client, request, parameters) {
|
|
2321
2322
|
const validatedRequest = GetKmsInfoRequestSchema.parse(request);
|
|
@@ -2349,18 +2350,18 @@ async function safeGetKmsInfo(client, request, parameters) {
|
|
|
2349
2350
|
}
|
|
2350
2351
|
|
|
2351
2352
|
// src/actions/get_kms_list.ts
|
|
2352
|
-
import { z as
|
|
2353
|
-
var GetKmsListRequestSchema =
|
|
2354
|
-
page:
|
|
2355
|
-
page_size:
|
|
2356
|
-
is_onchain:
|
|
2353
|
+
import { z as z18 } from "zod";
|
|
2354
|
+
var GetKmsListRequestSchema = z18.object({
|
|
2355
|
+
page: z18.number().int().min(1).optional(),
|
|
2356
|
+
page_size: z18.number().int().min(1).optional(),
|
|
2357
|
+
is_onchain: z18.boolean().optional()
|
|
2357
2358
|
}).strict();
|
|
2358
|
-
var GetKmsListSchema =
|
|
2359
|
-
items:
|
|
2360
|
-
total:
|
|
2361
|
-
page:
|
|
2362
|
-
page_size:
|
|
2363
|
-
pages:
|
|
2359
|
+
var GetKmsListSchema = z18.object({
|
|
2360
|
+
items: z18.array(KmsInfoSchema),
|
|
2361
|
+
total: z18.number(),
|
|
2362
|
+
page: z18.number(),
|
|
2363
|
+
page_size: z18.number(),
|
|
2364
|
+
pages: z18.number()
|
|
2364
2365
|
}).strict();
|
|
2365
2366
|
async function getKmsList(client, request, parameters) {
|
|
2366
2367
|
const validatedRequest = GetKmsListRequestSchema.parse(request ?? {});
|
|
@@ -2396,6 +2397,148 @@ async function safeGetKmsList(client, request, parameters) {
|
|
|
2396
2397
|
return validationResult;
|
|
2397
2398
|
}
|
|
2398
2399
|
|
|
2400
|
+
// src/actions/workspaces/list_workspaces.ts
|
|
2401
|
+
import { z as z19 } from "zod";
|
|
2402
|
+
var WorkspaceResponseSchema = z19.object({
|
|
2403
|
+
id: z19.string(),
|
|
2404
|
+
name: z19.string(),
|
|
2405
|
+
slug: z19.string().nullable(),
|
|
2406
|
+
tier: z19.string(),
|
|
2407
|
+
role: z19.string(),
|
|
2408
|
+
created_at: z19.string()
|
|
2409
|
+
}).passthrough();
|
|
2410
|
+
var PaginationMetadataSchema = z19.object({
|
|
2411
|
+
has_more: z19.boolean(),
|
|
2412
|
+
next_cursor: z19.string().nullable(),
|
|
2413
|
+
total: z19.number().nullable()
|
|
2414
|
+
}).passthrough();
|
|
2415
|
+
var ListWorkspacesSchema = z19.object({
|
|
2416
|
+
data: z19.array(WorkspaceResponseSchema),
|
|
2417
|
+
pagination: PaginationMetadataSchema
|
|
2418
|
+
}).passthrough();
|
|
2419
|
+
async function listWorkspaces(client, parameters) {
|
|
2420
|
+
validateActionParameters(parameters);
|
|
2421
|
+
const queryParams = new URLSearchParams();
|
|
2422
|
+
if (parameters?.cursor) queryParams.append("cursor", parameters.cursor);
|
|
2423
|
+
if (parameters?.limit) queryParams.append("limit", parameters.limit.toString());
|
|
2424
|
+
const url = queryParams.toString() ? `/workspaces?${queryParams.toString()}` : "/workspaces";
|
|
2425
|
+
const response = await client.get(url);
|
|
2426
|
+
if (parameters?.schema === false) {
|
|
2427
|
+
return response;
|
|
2428
|
+
}
|
|
2429
|
+
const schema = parameters?.schema || ListWorkspacesSchema;
|
|
2430
|
+
return schema.parse(response);
|
|
2431
|
+
}
|
|
2432
|
+
async function safeListWorkspaces(client, parameters) {
|
|
2433
|
+
const parameterValidationError = safeValidateActionParameters(parameters);
|
|
2434
|
+
if (parameterValidationError) {
|
|
2435
|
+
return parameterValidationError;
|
|
2436
|
+
}
|
|
2437
|
+
const queryParams = new URLSearchParams();
|
|
2438
|
+
if (parameters?.cursor) queryParams.append("cursor", parameters.cursor);
|
|
2439
|
+
if (parameters?.limit) queryParams.append("limit", parameters.limit.toString());
|
|
2440
|
+
const url = queryParams.toString() ? `/workspaces?${queryParams.toString()}` : "/workspaces";
|
|
2441
|
+
const httpResult = await client.safeGet(url);
|
|
2442
|
+
if (!httpResult.success) {
|
|
2443
|
+
return httpResult;
|
|
2444
|
+
}
|
|
2445
|
+
if (parameters?.schema === false) {
|
|
2446
|
+
return { success: true, data: httpResult.data };
|
|
2447
|
+
}
|
|
2448
|
+
const schema = parameters?.schema || ListWorkspacesSchema;
|
|
2449
|
+
return schema.safeParse(httpResult.data);
|
|
2450
|
+
}
|
|
2451
|
+
|
|
2452
|
+
// src/actions/workspaces/get_workspace.ts
|
|
2453
|
+
async function getWorkspace(client, teamSlug, parameters) {
|
|
2454
|
+
validateActionParameters(parameters);
|
|
2455
|
+
const response = await client.get(`/workspaces/${teamSlug}`);
|
|
2456
|
+
if (parameters?.schema === false) {
|
|
2457
|
+
return response;
|
|
2458
|
+
}
|
|
2459
|
+
const schema = parameters?.schema || WorkspaceResponseSchema;
|
|
2460
|
+
return schema.parse(response);
|
|
2461
|
+
}
|
|
2462
|
+
async function safeGetWorkspace(client, teamSlug, parameters) {
|
|
2463
|
+
const parameterValidationError = safeValidateActionParameters(parameters);
|
|
2464
|
+
if (parameterValidationError) {
|
|
2465
|
+
return parameterValidationError;
|
|
2466
|
+
}
|
|
2467
|
+
const httpResult = await client.safeGet(`/workspaces/${teamSlug}`);
|
|
2468
|
+
if (!httpResult.success) {
|
|
2469
|
+
return httpResult;
|
|
2470
|
+
}
|
|
2471
|
+
if (parameters?.schema === false) {
|
|
2472
|
+
return { success: true, data: httpResult.data };
|
|
2473
|
+
}
|
|
2474
|
+
const schema = parameters?.schema || WorkspaceResponseSchema;
|
|
2475
|
+
return schema.safeParse(httpResult.data);
|
|
2476
|
+
}
|
|
2477
|
+
|
|
2478
|
+
// src/actions/list-instance-types.ts
|
|
2479
|
+
import { z as z20 } from "zod";
|
|
2480
|
+
var ListInstanceTypesRequestSchema = z20.object({
|
|
2481
|
+
page: z20.number().int().min(1).optional().default(1),
|
|
2482
|
+
page_size: z20.number().int().min(1).max(1e3).optional().default(100)
|
|
2483
|
+
}).strict();
|
|
2484
|
+
var InstanceTypeSchema = z20.object({
|
|
2485
|
+
id: z20.string(),
|
|
2486
|
+
name: z20.string(),
|
|
2487
|
+
description: z20.string(),
|
|
2488
|
+
vcpu: z20.number(),
|
|
2489
|
+
memory_mb: z20.number(),
|
|
2490
|
+
hourly_rate: z20.string(),
|
|
2491
|
+
requires_gpu: z20.boolean(),
|
|
2492
|
+
public: z20.boolean(),
|
|
2493
|
+
enabled: z20.boolean()
|
|
2494
|
+
}).passthrough();
|
|
2495
|
+
var PaginatedInstanceTypesSchema = z20.object({
|
|
2496
|
+
items: z20.array(InstanceTypeSchema),
|
|
2497
|
+
total: z20.number(),
|
|
2498
|
+
page: z20.number(),
|
|
2499
|
+
page_size: z20.number(),
|
|
2500
|
+
pages: z20.number()
|
|
2501
|
+
}).strict();
|
|
2502
|
+
async function listInstanceTypes(client, request, parameters) {
|
|
2503
|
+
const validatedRequest = ListInstanceTypesRequestSchema.parse(request ?? {});
|
|
2504
|
+
validateActionParameters(parameters);
|
|
2505
|
+
const queryParams = new URLSearchParams();
|
|
2506
|
+
queryParams.append("page", validatedRequest.page.toString());
|
|
2507
|
+
queryParams.append("page_size", validatedRequest.page_size.toString());
|
|
2508
|
+
const response = await client.get(`/api/instance-types?${queryParams.toString()}`);
|
|
2509
|
+
if (parameters?.schema === false) {
|
|
2510
|
+
return response;
|
|
2511
|
+
}
|
|
2512
|
+
const schema = parameters?.schema || PaginatedInstanceTypesSchema;
|
|
2513
|
+
return schema.parse(response);
|
|
2514
|
+
}
|
|
2515
|
+
async function safeListInstanceTypes(client, request, parameters) {
|
|
2516
|
+
const requestValidation = ListInstanceTypesRequestSchema.safeParse(request ?? {});
|
|
2517
|
+
if (!requestValidation.success) {
|
|
2518
|
+
return requestValidation;
|
|
2519
|
+
}
|
|
2520
|
+
const parameterValidationError = safeValidateActionParameters(parameters);
|
|
2521
|
+
if (parameterValidationError) {
|
|
2522
|
+
return parameterValidationError;
|
|
2523
|
+
}
|
|
2524
|
+
const queryParams = new URLSearchParams();
|
|
2525
|
+
queryParams.append("page", requestValidation.data.page.toString());
|
|
2526
|
+
queryParams.append("page_size", requestValidation.data.page_size.toString());
|
|
2527
|
+
const httpResult = await client.safeGet(`/api/instance-types?${queryParams.toString()}`);
|
|
2528
|
+
if (!httpResult.success) {
|
|
2529
|
+
return httpResult;
|
|
2530
|
+
}
|
|
2531
|
+
if (parameters?.schema === false) {
|
|
2532
|
+
return {
|
|
2533
|
+
success: true,
|
|
2534
|
+
data: httpResult.data
|
|
2535
|
+
};
|
|
2536
|
+
}
|
|
2537
|
+
const schema = parameters?.schema || PaginatedInstanceTypesSchema;
|
|
2538
|
+
const validationResult = schema.safeParse(httpResult.data);
|
|
2539
|
+
return validationResult;
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2399
2542
|
// src/parse_dotenv.ts
|
|
2400
2543
|
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
2401
2544
|
function parseEnv(input) {
|
|
@@ -2449,12 +2592,15 @@ export {
|
|
|
2449
2592
|
DeployAppAuthRequestSchema,
|
|
2450
2593
|
DeployAppAuthSchema,
|
|
2451
2594
|
GetAppEnvEncryptPubKeySchema,
|
|
2452
|
-
GetCvmComposeFileResultSchema,
|
|
2453
2595
|
GetCvmListSchema,
|
|
2454
2596
|
GetKmsListSchema,
|
|
2597
|
+
InstanceTypeSchema,
|
|
2455
2598
|
KmsInfoSchema,
|
|
2599
|
+
ListWorkspacesSchema,
|
|
2456
2600
|
ManagedUserSchema,
|
|
2457
2601
|
NetworkError,
|
|
2602
|
+
PaginatedInstanceTypesSchema,
|
|
2603
|
+
PaginationMetadataSchema,
|
|
2458
2604
|
ProvisionCvmComposeFileUpdateRequestSchema,
|
|
2459
2605
|
ProvisionCvmComposeFileUpdateResultSchema,
|
|
2460
2606
|
ProvisionCvmRequestSchema,
|
|
@@ -2464,6 +2610,7 @@ export {
|
|
|
2464
2610
|
TransactionError,
|
|
2465
2611
|
VmInfoSchema,
|
|
2466
2612
|
WalletError,
|
|
2613
|
+
WorkspaceResponseSchema,
|
|
2467
2614
|
addComposeHash,
|
|
2468
2615
|
addNetwork,
|
|
2469
2616
|
asHex,
|
|
@@ -2494,6 +2641,9 @@ export {
|
|
|
2494
2641
|
getErrorMessage,
|
|
2495
2642
|
getKmsInfo,
|
|
2496
2643
|
getKmsList,
|
|
2644
|
+
getWorkspace,
|
|
2645
|
+
listInstanceTypes,
|
|
2646
|
+
listWorkspaces,
|
|
2497
2647
|
parseEnv,
|
|
2498
2648
|
parseEnvVars,
|
|
2499
2649
|
provisionCvm,
|
|
@@ -2510,6 +2660,9 @@ export {
|
|
|
2510
2660
|
safeGetCvmList,
|
|
2511
2661
|
safeGetKmsInfo,
|
|
2512
2662
|
safeGetKmsList,
|
|
2663
|
+
safeGetWorkspace,
|
|
2664
|
+
safeListInstanceTypes,
|
|
2665
|
+
safeListWorkspaces,
|
|
2513
2666
|
safeProvisionCvm,
|
|
2514
2667
|
safeProvisionCvmComposeFileUpdate,
|
|
2515
2668
|
safeValidateActionParameters,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const LooseAppComposeSchema: z.ZodObject<{
|
|
3
|
+
allowed_envs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
4
|
+
docker_compose_file: z.ZodString;
|
|
5
|
+
features: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
6
|
+
name: z.ZodOptional<z.ZodString>;
|
|
7
|
+
manifest_version: z.ZodOptional<z.ZodNumber>;
|
|
8
|
+
kms_enabled: z.ZodOptional<z.ZodBoolean>;
|
|
9
|
+
public_logs: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
public_sysinfo: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
tproxy_enabled: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
+
pre_launch_script: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
14
|
+
allowed_envs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
15
|
+
docker_compose_file: z.ZodString;
|
|
16
|
+
features: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
17
|
+
name: z.ZodOptional<z.ZodString>;
|
|
18
|
+
manifest_version: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
kms_enabled: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
public_logs: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
+
public_sysinfo: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
tproxy_enabled: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
pre_launch_script: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
25
|
+
allowed_envs: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
26
|
+
docker_compose_file: z.ZodString;
|
|
27
|
+
features: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
28
|
+
name: z.ZodOptional<z.ZodString>;
|
|
29
|
+
manifest_version: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
kms_enabled: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
public_logs: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
public_sysinfo: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
tproxy_enabled: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
pre_launch_script: z.ZodOptional<z.ZodString>;
|
|
35
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
36
|
+
export type LooseAppCompose = z.infer<typeof LooseAppComposeSchema>;
|
|
37
|
+
//# sourceMappingURL=app_compose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app_compose.d.ts","sourceRoot":"","sources":["../../src/types/app_compose.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAalB,CAAC;AAEjB,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,58 +1,68 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
2
|
+
"name": "@phala/cloud",
|
|
3
|
+
"version": "0.0.12",
|
|
4
|
+
"description": "TypeScript SDK for Phala Cloud API",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/**/*",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsup src/index.ts --format cjs,esm && tsc --emitDeclarationOnly --declaration --outDir dist",
|
|
13
|
+
"dev": "tsup src/index.ts --format cjs,esm --dts --watch",
|
|
14
|
+
"fmt": "biome format --write",
|
|
15
|
+
"test": "vitest --run --exclude '**/*.e2e.test.ts'",
|
|
16
|
+
"test:e2e": "vitest --run src/**/*.e2e.test.ts",
|
|
17
|
+
"test:watch": "vitest",
|
|
18
|
+
"lint": "biome lint .",
|
|
19
|
+
"lint:fix": "biome lint --write .",
|
|
20
|
+
"check": "npm run lint && npm run test",
|
|
21
|
+
"type-check": "tsc --noEmit",
|
|
22
|
+
"typecheck": "tsc --noEmit",
|
|
23
|
+
"version:patch": "npm version patch",
|
|
24
|
+
"version:minor": "npm version minor",
|
|
25
|
+
"version:major": "npm version major",
|
|
26
|
+
"prepublish-stable": "npm run build && npm run check",
|
|
27
|
+
"publish-stable": "npm run prepublish-stable && npm publish --access public",
|
|
28
|
+
"prepublish-beta": "npm run build && npm run check",
|
|
29
|
+
"publish-beta": "npm run prepublish-beta && npm publish --access public --tag beta"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"phala",
|
|
33
|
+
"cloud",
|
|
34
|
+
"cvm",
|
|
35
|
+
"tee",
|
|
36
|
+
"blockchain",
|
|
37
|
+
"deployment"
|
|
38
|
+
],
|
|
39
|
+
"author": "Leechael Yim",
|
|
40
|
+
"license": "Apache-2.0",
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@phala/dstack-sdk": "0.5.4-beta.6",
|
|
43
|
+
"debug": "^4.4.1",
|
|
44
|
+
"ofetch": "^1.3.3",
|
|
45
|
+
"viem": "^2.7.0",
|
|
46
|
+
"zod": "^3.22.4"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@biomejs/biome": "^1.9.4",
|
|
50
|
+
"@types/debug": "^4.1.12",
|
|
51
|
+
"@types/node": "^20.10.0",
|
|
52
|
+
"dotenv": "^16.5.0",
|
|
53
|
+
"tsup": "^8.0.0",
|
|
54
|
+
"typescript": "^5.3.0",
|
|
55
|
+
"vitest": "^1.0.0"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"typescript": ">=4.5.0"
|
|
59
|
+
},
|
|
60
|
+
"repository": {
|
|
61
|
+
"type": "git",
|
|
62
|
+
"url": "https://github.com/Phala-Network/phala-cloud-sdks",
|
|
63
|
+
"directory": "js"
|
|
64
|
+
},
|
|
65
|
+
"engines": {
|
|
66
|
+
"node": ">=18"
|
|
67
|
+
}
|
|
58
68
|
}
|