@agentuity/server 0.0.42 → 0.0.44
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/api/api.d.ts +28 -12
- package/dist/api/api.d.ts.map +1 -1
- package/dist/api/api.js +208 -84
- package/dist/api/api.js.map +1 -1
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.d.ts.map +1 -1
- package/dist/api/index.js +2 -0
- package/dist/api/index.js.map +1 -1
- package/dist/api/org/list.d.ts +14 -8
- package/dist/api/org/list.d.ts.map +1 -1
- package/dist/api/org/list.js +8 -3
- package/dist/api/org/list.js.map +1 -1
- package/dist/api/project/create.d.ts +15 -7
- package/dist/api/project/create.d.ts.map +1 -1
- package/dist/api/project/create.js +8 -3
- package/dist/api/project/create.js.map +1 -1
- package/dist/api/project/delete.d.ts.map +1 -1
- package/dist/api/project/delete.js +1 -1
- package/dist/api/project/delete.js.map +1 -1
- package/dist/api/project/deploy.d.ts +184 -0
- package/dist/api/project/deploy.d.ts.map +1 -0
- package/dist/api/project/deploy.js +160 -0
- package/dist/api/project/deploy.js.map +1 -0
- package/dist/api/project/env-delete.d.ts +15 -0
- package/dist/api/project/env-delete.d.ts.map +1 -0
- package/dist/api/project/env-delete.js +24 -0
- package/dist/api/project/env-delete.js.map +1 -0
- package/dist/api/project/env-update.d.ts +17 -0
- package/dist/api/project/env-update.d.ts.map +1 -0
- package/dist/api/project/env-update.js +39 -0
- package/dist/api/project/env-update.js.map +1 -0
- package/dist/api/project/exists.d.ts +7 -5
- package/dist/api/project/exists.d.ts.map +1 -1
- package/dist/api/project/exists.js +1 -1
- package/dist/api/project/exists.js.map +1 -1
- package/dist/api/project/get.d.ts +7 -12
- package/dist/api/project/get.d.ts.map +1 -1
- package/dist/api/project/get.js +5 -4
- package/dist/api/project/get.js.map +1 -1
- package/dist/api/project/index.d.ts +3 -0
- package/dist/api/project/index.d.ts.map +1 -1
- package/dist/api/project/index.js +3 -0
- package/dist/api/project/index.js.map +1 -1
- package/dist/api/project/list.d.ts +20 -8
- package/dist/api/project/list.d.ts.map +1 -1
- package/dist/api/project/list.js +9 -6
- package/dist/api/project/list.js.map +1 -1
- package/dist/api/region/create.d.ts +46 -0
- package/dist/api/region/create.d.ts.map +1 -0
- package/dist/api/region/create.js +35 -0
- package/dist/api/region/create.js.map +1 -0
- package/dist/api/region/delete.d.ts +38 -0
- package/dist/api/region/delete.d.ts.map +1 -0
- package/dist/api/region/delete.js +31 -0
- package/dist/api/region/delete.js.map +1 -0
- package/dist/api/region/index.d.ts +5 -0
- package/dist/api/region/index.d.ts.map +1 -0
- package/dist/api/region/index.js +5 -0
- package/dist/api/region/index.js.map +1 -0
- package/dist/api/region/list.d.ts +27 -0
- package/dist/api/region/list.d.ts.map +1 -0
- package/dist/api/region/list.js +21 -0
- package/dist/api/region/list.js.map +1 -0
- package/dist/api/region/resources.d.ts +53 -0
- package/dist/api/region/resources.d.ts.map +1 -0
- package/dist/api/region/resources.js +35 -0
- package/dist/api/region/resources.js.map +1 -0
- package/dist/api/user/index.d.ts +2 -0
- package/dist/api/user/index.d.ts.map +1 -0
- package/dist/api/user/index.js +2 -0
- package/dist/api/user/index.js.map +1 -0
- package/dist/api/user/whoami.d.ts +35 -0
- package/dist/api/user/whoami.d.ts.map +1 -0
- package/dist/api/user/whoami.js +26 -0
- package/dist/api/user/whoami.js.map +1 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -0
- package/dist/config.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +39 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +241 -0
- package/dist/logger.js.map +1 -0
- package/dist/server.js +2 -2
- package/dist/server.js.map +1 -1
- package/package.json +4 -2
- package/src/api/api-example.md +16 -11
- package/src/api/api.ts +254 -93
- package/src/api/index.ts +2 -0
- package/src/api/org/list.ts +13 -10
- package/src/api/project/create.ts +14 -9
- package/src/api/project/delete.ts +2 -2
- package/src/api/project/deploy.ts +224 -0
- package/src/api/project/env-delete.ts +40 -0
- package/src/api/project/env-update.ts +59 -0
- package/src/api/project/exists.ts +1 -1
- package/src/api/project/get.ts +12 -12
- package/src/api/project/index.ts +3 -0
- package/src/api/project/list.ts +20 -15
- package/src/api/region/create.ts +55 -0
- package/src/api/region/delete.ts +49 -0
- package/src/api/region/index.ts +4 -0
- package/src/api/region/list.ts +31 -0
- package/src/api/region/resources.ts +51 -0
- package/src/api/user/index.ts +1 -0
- package/src/api/user/whoami.ts +31 -0
- package/src/config.ts +2 -0
- package/src/index.ts +1 -0
- package/src/logger.ts +291 -0
- package/src/server.ts +2 -2
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { type APIClient, APIResponseSchema } from '../api';
|
|
3
|
+
|
|
4
|
+
export const Resources = z.object({
|
|
5
|
+
memory: z.string().default('500Mi').describe('The memory requirements'),
|
|
6
|
+
cpu: z.string().default('500m').describe('The CPU requirements'),
|
|
7
|
+
disk: z.string().default('500Mi').describe('The disk requirements'),
|
|
8
|
+
db: z.string().optional().describe('the name of the database to use'),
|
|
9
|
+
storage: z.string().optional().describe('the name of the storage bucket to use'),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export const Mode = z.object({
|
|
13
|
+
type: z
|
|
14
|
+
.enum(['on-demand', 'provisioned'])
|
|
15
|
+
.default('on-demand')
|
|
16
|
+
.describe('on-demand or provisioned'),
|
|
17
|
+
idle: z.string().optional().describe('duration in seconds if on-demand'),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export const Deployment = z.object({
|
|
21
|
+
resources: Resources.optional().describe('the resource requirements for your deployed project'),
|
|
22
|
+
mode: Mode.optional().describe('the provisioning mode for the project'),
|
|
23
|
+
dependencies: z
|
|
24
|
+
.array(z.string().describe('APT dependencies to install prior to launching your project'))
|
|
25
|
+
.optional(),
|
|
26
|
+
domains: z.array(z.string().describe('the custom domain')).optional(),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const BaseFileFields = {
|
|
30
|
+
filename: z.string().describe('the relative path for the file'),
|
|
31
|
+
version: z.string().describe('the SHA256 content of the file'),
|
|
32
|
+
identifier: z.string().describe('the folder for the file'),
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const EvalSchema = z.object({
|
|
36
|
+
...BaseFileFields,
|
|
37
|
+
id: z.string().describe('the unique calculated id for the eval'),
|
|
38
|
+
name: z.string().describe('the name of the eval'),
|
|
39
|
+
description: z.string().optional().describe('the eval description'),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
const BaseAgentFields = {
|
|
43
|
+
...BaseFileFields,
|
|
44
|
+
id: z.string().describe('the unique calculated id for the agent'),
|
|
45
|
+
name: z.string().describe('the name of the agent'),
|
|
46
|
+
description: z.string().optional().describe('the agent description'),
|
|
47
|
+
evals: z.array(EvalSchema).optional().describe('the evals for the agent'),
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const AgentSchema = z.object({
|
|
51
|
+
...BaseAgentFields,
|
|
52
|
+
subagents: z.array(z.object(BaseAgentFields)).optional().describe('subagents of this agent'),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export const BuildMetadataSchema = z.object({
|
|
56
|
+
routes: z.array(
|
|
57
|
+
z.object({
|
|
58
|
+
id: z.string().describe('the unique calculated id for the route'),
|
|
59
|
+
filename: z.string().describe('the relative path for the file'),
|
|
60
|
+
path: z.string().describe('the route path'),
|
|
61
|
+
method: z.enum(['get', 'post', 'put', 'delete', 'patch']).describe('the HTTP method'),
|
|
62
|
+
version: z.string().describe('the SHA256 content of the file'),
|
|
63
|
+
type: z.enum(['api', 'sms', 'email', 'cron', 'websocket', 'sse', 'stream']),
|
|
64
|
+
config: z
|
|
65
|
+
.record(z.string(), z.unknown())
|
|
66
|
+
.optional()
|
|
67
|
+
.describe('type specific configuration'),
|
|
68
|
+
})
|
|
69
|
+
),
|
|
70
|
+
agents: z.array(AgentSchema),
|
|
71
|
+
assets: z.array(
|
|
72
|
+
z.object({
|
|
73
|
+
filename: z.string().describe('the relative path for the file'),
|
|
74
|
+
kind: z.string().describe('the type of asset'),
|
|
75
|
+
contentType: z.string().describe('the content-type for the file'),
|
|
76
|
+
size: z.number().describe('the size in bytes for the file'),
|
|
77
|
+
})
|
|
78
|
+
),
|
|
79
|
+
project: z.object({
|
|
80
|
+
id: z.string().describe('the project id'),
|
|
81
|
+
name: z.string().describe('the name of the project (from package.json)'),
|
|
82
|
+
version: z.string().optional().describe('the version of the project (from package.json)'),
|
|
83
|
+
orgId: z.string().describe('the organization id for the project'),
|
|
84
|
+
}),
|
|
85
|
+
deployment: z.intersection(
|
|
86
|
+
Deployment,
|
|
87
|
+
z.object({
|
|
88
|
+
id: z.string().describe('the deployment id'),
|
|
89
|
+
date: z.string().describe('the date the deployment was created in UTC format'),
|
|
90
|
+
git: z
|
|
91
|
+
.object({
|
|
92
|
+
repo: z.string().optional().describe('the repository name'),
|
|
93
|
+
commit: z.string().optional().describe('the git commit sha'),
|
|
94
|
+
message: z.string().optional().describe('the git commit message'),
|
|
95
|
+
branch: z.string().optional().describe('the git branch'),
|
|
96
|
+
tags: z.array(z.string()).optional().describe('the tags for the current branch'),
|
|
97
|
+
pr: z.string().optional().describe('the pull request number'),
|
|
98
|
+
})
|
|
99
|
+
.optional()
|
|
100
|
+
.describe('git commit information'),
|
|
101
|
+
build: z.object({
|
|
102
|
+
bun: z.string().describe('the version of bun that was used to build the deployment'),
|
|
103
|
+
agentuity: z.string().describe('the version of the agentuity runtime'),
|
|
104
|
+
arch: z.string().describe('the machine architecture'),
|
|
105
|
+
platform: z.string().describe('the machine os platform'),
|
|
106
|
+
}),
|
|
107
|
+
})
|
|
108
|
+
),
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
export type BuildMetadata = z.infer<typeof BuildMetadataSchema>;
|
|
112
|
+
|
|
113
|
+
const CreateProjectDeployment = z.object({
|
|
114
|
+
id: z.string().describe('the unique id for the deployment'),
|
|
115
|
+
orgId: z.string().describe('the organization id'),
|
|
116
|
+
publicKey: z.string().describe('the public key to use for encrypting the deployment'),
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const CreateProjectDeploymentSchema = APIResponseSchema(CreateProjectDeployment);
|
|
120
|
+
|
|
121
|
+
type CreateProjectDeploymentPayload = z.infer<typeof CreateProjectDeploymentSchema>;
|
|
122
|
+
|
|
123
|
+
export type Deployment = z.infer<typeof CreateProjectDeployment>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Create a new project deployment
|
|
127
|
+
*
|
|
128
|
+
* @param client
|
|
129
|
+
* @param projectId
|
|
130
|
+
* @returns
|
|
131
|
+
*/
|
|
132
|
+
export async function projectDeploymentCreate(
|
|
133
|
+
client: APIClient,
|
|
134
|
+
projectId: string,
|
|
135
|
+
deploymentConfig?: z.infer<typeof Deployment>
|
|
136
|
+
): Promise<Deployment> {
|
|
137
|
+
const resp = await client.request<CreateProjectDeploymentPayload>(
|
|
138
|
+
'POST',
|
|
139
|
+
`/cli/deploy/1/start/${projectId}`,
|
|
140
|
+
CreateProjectDeploymentSchema,
|
|
141
|
+
deploymentConfig
|
|
142
|
+
);
|
|
143
|
+
if (resp.success) {
|
|
144
|
+
return resp.data;
|
|
145
|
+
}
|
|
146
|
+
throw new Error(resp.message);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const DeploymentInstructionsObject = z.object({
|
|
150
|
+
deployment: z.string().describe('the url for uploading the encrypted deployment archive'),
|
|
151
|
+
assets: z
|
|
152
|
+
.record(
|
|
153
|
+
z.string().describe('the asset id'),
|
|
154
|
+
z.string().describe('the url for the asset upload')
|
|
155
|
+
)
|
|
156
|
+
.describe('the upload metadata for public assets'),
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
const DeploymentInstructionsSchema = APIResponseSchema(DeploymentInstructionsObject);
|
|
160
|
+
|
|
161
|
+
type DeploymentInstructionsResponse = z.infer<typeof DeploymentInstructionsSchema>;
|
|
162
|
+
export type DeploymentInstructions = z.infer<typeof DeploymentInstructionsObject>;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Update the deployment with the build metadata
|
|
166
|
+
*
|
|
167
|
+
* @param client
|
|
168
|
+
* @param deploymentId
|
|
169
|
+
* @returns
|
|
170
|
+
*/
|
|
171
|
+
export async function projectDeploymentUpdate(
|
|
172
|
+
client: APIClient,
|
|
173
|
+
deploymentId: string,
|
|
174
|
+
deployment: BuildMetadata
|
|
175
|
+
): Promise<DeploymentInstructions> {
|
|
176
|
+
const resp = await client.request<DeploymentInstructionsResponse, BuildMetadata>(
|
|
177
|
+
'PUT',
|
|
178
|
+
`/cli/deploy/1/start/${deploymentId}`,
|
|
179
|
+
DeploymentInstructionsSchema,
|
|
180
|
+
deployment,
|
|
181
|
+
BuildMetadataSchema
|
|
182
|
+
);
|
|
183
|
+
if (resp.success) {
|
|
184
|
+
return resp.data;
|
|
185
|
+
}
|
|
186
|
+
throw new Error(resp.message);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const DeploymentCompleteObject = z.object({
|
|
190
|
+
publicUrls: z
|
|
191
|
+
.object({
|
|
192
|
+
latest: z.url().describe('the public url for the latest deployment'),
|
|
193
|
+
deployment: z.url().describe('the public url for this deployment'),
|
|
194
|
+
custom: z.array(z.string().describe('the custom domain')),
|
|
195
|
+
})
|
|
196
|
+
.describe('the map of public urls'),
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
const DeploymentCompleteObjectSchema = APIResponseSchema(DeploymentCompleteObject);
|
|
200
|
+
|
|
201
|
+
type DeploymentCompleteResponse = z.infer<typeof DeploymentCompleteObjectSchema>;
|
|
202
|
+
export type DeploymentComplete = z.infer<typeof DeploymentCompleteObject>;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Complete the deployment once build is uploaded
|
|
206
|
+
*
|
|
207
|
+
* @param client
|
|
208
|
+
* @param deploymentId
|
|
209
|
+
* @returns
|
|
210
|
+
*/
|
|
211
|
+
export async function projectDeploymentComplete(
|
|
212
|
+
client: APIClient,
|
|
213
|
+
deploymentId: string
|
|
214
|
+
): Promise<DeploymentComplete> {
|
|
215
|
+
const resp = await client.request<DeploymentCompleteResponse>(
|
|
216
|
+
'POST',
|
|
217
|
+
`/cli/deploy/1/complete/${deploymentId}`,
|
|
218
|
+
DeploymentCompleteObjectSchema
|
|
219
|
+
);
|
|
220
|
+
if (resp.success) {
|
|
221
|
+
return resp.data;
|
|
222
|
+
}
|
|
223
|
+
throw new Error(resp.message);
|
|
224
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIClient, APIResponseSchemaNoData } from '../api';
|
|
3
|
+
|
|
4
|
+
const _ProjectEnvDeleteRequestSchema = z.object({
|
|
5
|
+
id: z.string().describe('the project id'),
|
|
6
|
+
env: z.array(z.string()).optional().describe('environment variable keys to delete'),
|
|
7
|
+
secrets: z.array(z.string()).optional().describe('secret keys to delete'),
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const ProjectEnvDeleteResponseSchema = APIResponseSchemaNoData();
|
|
11
|
+
|
|
12
|
+
type ProjectEnvDeleteRequest = z.infer<typeof _ProjectEnvDeleteRequestSchema>;
|
|
13
|
+
type ProjectEnvDeleteResponse = z.infer<typeof ProjectEnvDeleteResponseSchema>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Delete environment variables and/or secrets from a project.
|
|
17
|
+
* Provide arrays of keys to delete.
|
|
18
|
+
*/
|
|
19
|
+
export async function projectEnvDelete(
|
|
20
|
+
client: APIClient,
|
|
21
|
+
request: ProjectEnvDeleteRequest
|
|
22
|
+
): Promise<void> {
|
|
23
|
+
const { id, env, secrets } = request;
|
|
24
|
+
|
|
25
|
+
const resp = await client.request<ProjectEnvDeleteResponse, Omit<ProjectEnvDeleteRequest, 'id'>>(
|
|
26
|
+
'DELETE',
|
|
27
|
+
`/cli/project/${id}/env`,
|
|
28
|
+
ProjectEnvDeleteResponseSchema,
|
|
29
|
+
{
|
|
30
|
+
env,
|
|
31
|
+
secrets,
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
if (!resp.success) {
|
|
36
|
+
throw new Error(resp.message ?? 'failed to delete project env');
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Delete operations don't return data, success is sufficient
|
|
40
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIClient, APIResponseSchema } from '../api';
|
|
3
|
+
import type { Project } from './get';
|
|
4
|
+
import { projectGet } from './get';
|
|
5
|
+
|
|
6
|
+
const _ProjectEnvUpdateRequestSchema = z.object({
|
|
7
|
+
id: z.string().describe('the project id'),
|
|
8
|
+
env: z.record(z.string(), z.string()).optional().describe('environment variables to set/update'),
|
|
9
|
+
secrets: z.record(z.string(), z.string()).optional().describe('secrets to set/update'),
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const ProjectEnvUpdateResponseSchema = APIResponseSchema(
|
|
13
|
+
z
|
|
14
|
+
.object({
|
|
15
|
+
id: z.string().describe('the project id'),
|
|
16
|
+
orgId: z.string().describe('the organization id'),
|
|
17
|
+
api_key: z.string().optional().describe('the SDK api key for the project'),
|
|
18
|
+
env: z.record(z.string(), z.string()).optional().describe('the environment key/values'),
|
|
19
|
+
secrets: z.record(z.string(), z.string()).optional().describe('the secrets key/values'),
|
|
20
|
+
})
|
|
21
|
+
.optional()
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
type ProjectEnvUpdateRequest = z.infer<typeof _ProjectEnvUpdateRequestSchema>;
|
|
25
|
+
type ProjectEnvUpdateResponse = z.infer<typeof ProjectEnvUpdateResponseSchema>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Update environment variables and/or secrets for a project.
|
|
29
|
+
* This will merge the provided env/secrets with existing values.
|
|
30
|
+
* Keys starting with 'AGENTUITY_' should be filtered out before calling this function.
|
|
31
|
+
*/
|
|
32
|
+
export async function projectEnvUpdate(
|
|
33
|
+
client: APIClient,
|
|
34
|
+
request: ProjectEnvUpdateRequest
|
|
35
|
+
): Promise<Project> {
|
|
36
|
+
const { id, env, secrets } = request;
|
|
37
|
+
|
|
38
|
+
const resp = await client.request<ProjectEnvUpdateResponse, Omit<ProjectEnvUpdateRequest, 'id'>>(
|
|
39
|
+
'PUT',
|
|
40
|
+
`/cli/project/${id}/env`,
|
|
41
|
+
ProjectEnvUpdateResponseSchema,
|
|
42
|
+
{
|
|
43
|
+
env,
|
|
44
|
+
secrets,
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
if (!resp.success) {
|
|
49
|
+
throw new Error(resp.message ?? 'failed to update project env');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (resp.data) {
|
|
53
|
+
return resp.data;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// If the API didn't return data, fetch the updated project
|
|
57
|
+
// This handles backends that return success without the full project data
|
|
58
|
+
return projectGet(client, { id, mask: false });
|
|
59
|
+
}
|
package/src/api/project/get.ts
CHANGED
|
@@ -6,20 +6,20 @@ const _ProjectGetRequestSchema = z.object({
|
|
|
6
6
|
mask: z.boolean().default(true).describe('if the secrets should be returned masked'),
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
z.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
);
|
|
9
|
+
const ProjectSchema = z.object({
|
|
10
|
+
id: z.string().describe('the project id'),
|
|
11
|
+
orgId: z.string().describe('the organization id'),
|
|
12
|
+
api_key: z.string().optional().describe('the SDK api key for the project'),
|
|
13
|
+
env: z.record(z.string(), z.string()).optional().describe('the environment key/values'),
|
|
14
|
+
secrets: z.record(z.string(), z.string()).optional().describe('the secrets key/values'),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const ProjectGetResponseSchema = APIResponseSchema(ProjectSchema);
|
|
18
18
|
|
|
19
19
|
type ProjectGetRequest = z.infer<typeof _ProjectGetRequestSchema>;
|
|
20
20
|
type ProjectGetResponse = z.infer<typeof ProjectGetResponseSchema>;
|
|
21
21
|
|
|
22
|
-
export type Project =
|
|
22
|
+
export type Project = z.infer<typeof ProjectSchema>;
|
|
23
23
|
|
|
24
24
|
export async function projectGet(client: APIClient, request: ProjectGetRequest): Promise<Project> {
|
|
25
25
|
const resp = await client.request<ProjectGetResponse, ProjectGetRequest>(
|
|
@@ -28,9 +28,9 @@ export async function projectGet(client: APIClient, request: ProjectGetRequest):
|
|
|
28
28
|
ProjectGetResponseSchema
|
|
29
29
|
);
|
|
30
30
|
|
|
31
|
-
if (resp.
|
|
31
|
+
if (resp.success) {
|
|
32
32
|
return resp.data;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
throw new Error(resp.message
|
|
35
|
+
throw new Error(resp.message);
|
|
36
36
|
}
|
package/src/api/project/index.ts
CHANGED
package/src/api/project/list.ts
CHANGED
|
@@ -1,37 +1,42 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { APIClient, APIResponseSchema } from '../api';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
z.
|
|
6
|
-
z.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
)
|
|
4
|
+
const ProjectListResponse = z.array(
|
|
5
|
+
z.object({
|
|
6
|
+
id: z.string().describe('the project id'),
|
|
7
|
+
name: z.string().describe('the project name'),
|
|
8
|
+
description: z.string().optional().describe('the project description'),
|
|
9
|
+
orgId: z.string().describe('the organization id that this project is registered with'),
|
|
10
|
+
orgName: z.string().describe('the organization name'),
|
|
11
|
+
latestDeploymentId: z.string().nullable().describe('the latest deployment id'),
|
|
12
|
+
})
|
|
14
13
|
);
|
|
15
14
|
|
|
15
|
+
const ProjectListResponseSchema = APIResponseSchema(ProjectListResponse);
|
|
16
|
+
|
|
16
17
|
export type ProjectListResponse = z.infer<typeof ProjectListResponseSchema>;
|
|
17
|
-
export type ProjectList =
|
|
18
|
+
export type ProjectList = z.infer<typeof ProjectListResponse>;
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* List all projects
|
|
21
22
|
*
|
|
22
23
|
* @param client
|
|
24
|
+
* @param hasDeployment if true, filter by projects with at least one deployment
|
|
23
25
|
* @returns
|
|
24
26
|
*/
|
|
25
|
-
export async function projectList(
|
|
27
|
+
export async function projectList(
|
|
28
|
+
client: APIClient,
|
|
29
|
+
hasDeployment?: boolean
|
|
30
|
+
): Promise<ProjectList> {
|
|
26
31
|
const resp = await client.request<ProjectListResponse>(
|
|
27
32
|
'GET',
|
|
28
|
-
|
|
33
|
+
`/cli/project${hasDeployment ? '?hasDeployment=true' : ''}`,
|
|
29
34
|
ProjectListResponseSchema
|
|
30
35
|
);
|
|
31
36
|
|
|
32
|
-
if (resp.
|
|
37
|
+
if (resp.success) {
|
|
33
38
|
return resp.data;
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
throw new Error(resp.message
|
|
41
|
+
throw new Error(resp.message);
|
|
37
42
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIResponseSchema, APIClient } from '../api';
|
|
3
|
+
|
|
4
|
+
const ResourceSpec = z.object({
|
|
5
|
+
type: z.enum(['db', 's3']).describe('the resource type'),
|
|
6
|
+
name: z.string().optional().describe('optional custom name for db'),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const CreateResourcesRequest = z.object({
|
|
10
|
+
resources: z.array(ResourceSpec).describe('list of resources to create'),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const CreatedResource = z.object({
|
|
14
|
+
type: z.string().describe('the resource type'),
|
|
15
|
+
name: z.string().describe('the resource name'),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const CreateResourcesResponse = z.object({
|
|
19
|
+
created: z.array(CreatedResource),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const CreateResourcesResponseSchema = APIResponseSchema(CreateResourcesResponse);
|
|
23
|
+
|
|
24
|
+
export type CreateResourcesRequest = z.infer<typeof CreateResourcesRequest>;
|
|
25
|
+
export type CreateResourcesResponse = z.infer<typeof CreateResourcesResponseSchema>;
|
|
26
|
+
export type CreatedResource = z.infer<typeof CreatedResource>;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Create one or more resources (DB or S3) for an organization in a specific region
|
|
30
|
+
* Requires CLI authentication
|
|
31
|
+
*
|
|
32
|
+
* @param client - Catalyst API client
|
|
33
|
+
* @param orgId - Organization ID
|
|
34
|
+
* @param region - Cloud region
|
|
35
|
+
* @param resources - Array of resources to create
|
|
36
|
+
* @returns
|
|
37
|
+
*/
|
|
38
|
+
export async function createResources(
|
|
39
|
+
client: APIClient,
|
|
40
|
+
orgId: string,
|
|
41
|
+
region: string,
|
|
42
|
+
resources: Array<{ type: 'db' | 's3'; name?: string }>
|
|
43
|
+
): Promise<CreatedResource[]> {
|
|
44
|
+
const resp = await client.request<CreateResourcesResponse, CreateResourcesRequest>(
|
|
45
|
+
'POST',
|
|
46
|
+
`/resource/2025-11-16/${orgId}/${region}`,
|
|
47
|
+
CreateResourcesResponseSchema,
|
|
48
|
+
{ resources },
|
|
49
|
+
CreateResourcesRequest
|
|
50
|
+
);
|
|
51
|
+
if (resp.success) {
|
|
52
|
+
return resp.data.created;
|
|
53
|
+
}
|
|
54
|
+
throw new Error('message' in resp ? resp.message : 'Failed to create resources');
|
|
55
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIResponseSchema, APIClient } from '../api';
|
|
3
|
+
|
|
4
|
+
const DeleteResourceSpec = z.object({
|
|
5
|
+
type: z.enum(['db', 's3']).describe('the resource type'),
|
|
6
|
+
name: z.string().describe('the resource name (bucket_name for S3, db_name for DB)'),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const DeleteResourcesRequest = z.object({
|
|
10
|
+
resources: z.array(DeleteResourceSpec).describe('list of resources to delete'),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const DeleteResourcesResponse = z.object({
|
|
14
|
+
deleted: z.array(z.string()).describe('list of deleted resource names'),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const DeleteResourcesResponseSchema = APIResponseSchema(DeleteResourcesResponse);
|
|
18
|
+
|
|
19
|
+
export type DeleteResourcesRequest = z.infer<typeof DeleteResourcesRequest>;
|
|
20
|
+
export type DeleteResourcesResponse = z.infer<typeof DeleteResourcesResponseSchema>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Delete one or more resources (DB or S3) for an organization in a specific region
|
|
24
|
+
* Requires CLI authentication
|
|
25
|
+
*
|
|
26
|
+
* @param client - Catalyst API client
|
|
27
|
+
* @param orgId - Organization ID
|
|
28
|
+
* @param region - Cloud region
|
|
29
|
+
* @param resources - Array of resources to delete
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
export async function deleteResources(
|
|
33
|
+
client: APIClient,
|
|
34
|
+
orgId: string,
|
|
35
|
+
region: string,
|
|
36
|
+
resources: Array<{ type: 'db' | 's3'; name: string }>
|
|
37
|
+
): Promise<string[]> {
|
|
38
|
+
const resp = await client.request<DeleteResourcesResponse, DeleteResourcesRequest>(
|
|
39
|
+
'DELETE',
|
|
40
|
+
`/resource/2025-11-16/${orgId}/${region}`,
|
|
41
|
+
DeleteResourcesResponseSchema,
|
|
42
|
+
{ resources },
|
|
43
|
+
DeleteResourcesRequest
|
|
44
|
+
);
|
|
45
|
+
if (resp.success) {
|
|
46
|
+
return resp.data.deleted;
|
|
47
|
+
}
|
|
48
|
+
throw new Error('message' in resp ? resp.message : 'Failed to delete resources');
|
|
49
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIResponseSchema, APIClient } from '../api';
|
|
3
|
+
|
|
4
|
+
const ListRegionsResponse = z.array(
|
|
5
|
+
z.object({
|
|
6
|
+
region: z.string().describe('the region identifier'),
|
|
7
|
+
description: z.string().describe('the human-readable description of the region'),
|
|
8
|
+
})
|
|
9
|
+
);
|
|
10
|
+
const ListRegionsResponseSchema = APIResponseSchema(ListRegionsResponse);
|
|
11
|
+
|
|
12
|
+
export type ListRegionsResponse = z.infer<typeof ListRegionsResponseSchema>;
|
|
13
|
+
export type RegionList = z.infer<typeof ListRegionsResponse>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* List all available cloud regions
|
|
17
|
+
*
|
|
18
|
+
* @param client
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
export async function listRegions(client: APIClient): Promise<RegionList> {
|
|
22
|
+
const resp = await client.request<ListRegionsResponse>(
|
|
23
|
+
'GET',
|
|
24
|
+
'/cli/region',
|
|
25
|
+
ListRegionsResponseSchema
|
|
26
|
+
);
|
|
27
|
+
if (resp.success) {
|
|
28
|
+
return resp.data;
|
|
29
|
+
}
|
|
30
|
+
throw new Error(resp.message);
|
|
31
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIResponseSchema, APIClient } from '../api';
|
|
3
|
+
|
|
4
|
+
const ResourceListResponse = z.object({
|
|
5
|
+
s3: z.array(
|
|
6
|
+
z.object({
|
|
7
|
+
bucket_name: z.string().describe('the S3 bucket name'),
|
|
8
|
+
access_key: z.string().nullable().optional().describe('the S3 access key'),
|
|
9
|
+
secret_key: z.string().nullable().optional().describe('the S3 secret key'),
|
|
10
|
+
region: z.string().nullable().optional().describe('the S3 region'),
|
|
11
|
+
endpoint: z.string().nullable().optional().describe('the S3 endpoint'),
|
|
12
|
+
cname: z.string().nullable().optional().describe('the S3 CNAME'),
|
|
13
|
+
})
|
|
14
|
+
),
|
|
15
|
+
db: z.array(
|
|
16
|
+
z.object({
|
|
17
|
+
name: z.string().describe('the database name'),
|
|
18
|
+
username: z.string().nullable().optional().describe('the database username'),
|
|
19
|
+
password: z.string().nullable().optional().describe('the database password'),
|
|
20
|
+
url: z.string().nullable().optional().describe('the full database connection URL'),
|
|
21
|
+
})
|
|
22
|
+
),
|
|
23
|
+
});
|
|
24
|
+
const ResourceListResponseSchema = APIResponseSchema(ResourceListResponse);
|
|
25
|
+
|
|
26
|
+
export type ResourceListResponse = z.infer<typeof ResourceListResponseSchema>;
|
|
27
|
+
export type ResourceList = z.infer<typeof ResourceListResponse>;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* List all resources for a given organization and region
|
|
31
|
+
*
|
|
32
|
+
* @param client
|
|
33
|
+
* @param orgId
|
|
34
|
+
* @param region
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
export async function listResources(
|
|
38
|
+
client: APIClient,
|
|
39
|
+
orgId: string,
|
|
40
|
+
region: string
|
|
41
|
+
): Promise<ResourceList> {
|
|
42
|
+
const resp = await client.request<ResourceListResponse>(
|
|
43
|
+
'GET',
|
|
44
|
+
`/resource/2025-03-17/${orgId}/${region}`,
|
|
45
|
+
ResourceListResponseSchema
|
|
46
|
+
);
|
|
47
|
+
if (resp.success) {
|
|
48
|
+
return resp.data;
|
|
49
|
+
}
|
|
50
|
+
throw new Error(resp.message);
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './whoami';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { APIResponseSchema, APIClient } from '../api';
|
|
3
|
+
|
|
4
|
+
const OrganizationSchema = z.object({
|
|
5
|
+
id: z.string().describe('the unique id for the organization'),
|
|
6
|
+
name: z.string().describe('the name of the organization'),
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const WhoamiResponse = z.object({
|
|
10
|
+
firstName: z.string().describe('the first name of the user'),
|
|
11
|
+
lastName: z.string().describe('the last name of the user'),
|
|
12
|
+
organizations: z.array(OrganizationSchema).describe('the organizations the user is a member of'),
|
|
13
|
+
});
|
|
14
|
+
const WhoamiResponseSchema = APIResponseSchema(WhoamiResponse);
|
|
15
|
+
|
|
16
|
+
export type WhoamiResponse = z.infer<typeof WhoamiResponseSchema>;
|
|
17
|
+
export type User = z.infer<typeof WhoamiResponse>;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Get the current authenticated user information
|
|
21
|
+
*
|
|
22
|
+
* @param client
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
export async function whoami(client: APIClient): Promise<User> {
|
|
26
|
+
const resp = await client.request<WhoamiResponse>('GET', '/cli/auth/user', WhoamiResponseSchema);
|
|
27
|
+
if (resp.success) {
|
|
28
|
+
return resp.data;
|
|
29
|
+
}
|
|
30
|
+
throw new Error(resp.message);
|
|
31
|
+
}
|