@keystrokehq/cli 0.0.128 → 0.0.130
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/index.mjs +110 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2099,10 +2099,22 @@ const CreateOrganizationRequestSchema = object({
|
|
|
2099
2099
|
const UpdateOrganizationRequestSchema = object({ slug: ClaimableOrganizationSlugSchema });
|
|
2100
2100
|
const CreateOrganizationResponseSchema = object({ organization: UserOrganizationSchema });
|
|
2101
2101
|
const ListProjectsResponseSchema = object({ projects: array(ProjectSchema) });
|
|
2102
|
+
const ProjectListMetricsSchema = object({
|
|
2103
|
+
agentCount: number$1(),
|
|
2104
|
+
workflowCount: number$1(),
|
|
2105
|
+
skillCount: number$1(),
|
|
2106
|
+
credentialCount: number$1(),
|
|
2107
|
+
lastDeploymentAt: isoDateTime$3.nullable()
|
|
2108
|
+
});
|
|
2109
|
+
const ListProjectMetricsResponseSchema = object({ metrics: record(string(), ProjectListMetricsSchema) });
|
|
2102
2110
|
const CreateProjectRequestSchema = object({
|
|
2103
2111
|
name: string().trim().min(1),
|
|
2104
2112
|
description: string().trim().min(1).optional()
|
|
2105
2113
|
});
|
|
2114
|
+
const UpdateProjectRequestSchema = object({
|
|
2115
|
+
name: string().trim().min(1).optional(),
|
|
2116
|
+
description: string().trim().optional()
|
|
2117
|
+
}).refine((data) => data.name !== void 0 || data.description !== void 0, { message: "At least one field is required" });
|
|
2106
2118
|
const CreateProjectResponseSchema = object({ project: ProjectSchema });
|
|
2107
2119
|
const ProjectResponseSchema = object({ project: ProjectSchema });
|
|
2108
2120
|
const ProjectReachabilityResponseSchema = object({ reachable: boolean() });
|
|
@@ -5115,16 +5127,22 @@ function createProjectsResource(http) {
|
|
|
5115
5127
|
throw await toPlatformError(error);
|
|
5116
5128
|
}
|
|
5117
5129
|
},
|
|
5118
|
-
update
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5130
|
+
async update(projectId, patch) {
|
|
5131
|
+
const body = UpdateProjectRequestSchema.parse(patch);
|
|
5132
|
+
try {
|
|
5133
|
+
const data = await http.patch(`/api/projects/${encodeURIComponent(projectId)}`, { json: body }).json();
|
|
5134
|
+
return ProjectResponseSchema.parse(data).project;
|
|
5135
|
+
} catch (error) {
|
|
5136
|
+
throw await toPlatformError(error);
|
|
5137
|
+
}
|
|
5138
|
+
},
|
|
5139
|
+
async delete(projectId) {
|
|
5140
|
+
try {
|
|
5141
|
+
await http.delete(`/api/projects/${encodeURIComponent(projectId)}`);
|
|
5142
|
+
} catch (error) {
|
|
5143
|
+
throw await toPlatformError(error);
|
|
5144
|
+
}
|
|
5145
|
+
},
|
|
5128
5146
|
async checkReachability(projectId) {
|
|
5129
5147
|
try {
|
|
5130
5148
|
const data = await http.get(`/api/projects/${encodeURIComponent(projectId)}/reachability`, { timeout: PROJECT_REACHABILITY_REQUEST_TIMEOUT_MS }).json();
|
|
@@ -5135,6 +5153,16 @@ function createProjectsResource(http) {
|
|
|
5135
5153
|
}
|
|
5136
5154
|
};
|
|
5137
5155
|
}
|
|
5156
|
+
function createProjectMetricsResource(http) {
|
|
5157
|
+
return { async list() {
|
|
5158
|
+
try {
|
|
5159
|
+
const data = await http.get("/api/projects/metrics").json();
|
|
5160
|
+
return ListProjectMetricsResponseSchema.parse(data).metrics;
|
|
5161
|
+
} catch (error) {
|
|
5162
|
+
throw await toPlatformError(error);
|
|
5163
|
+
}
|
|
5164
|
+
} };
|
|
5165
|
+
}
|
|
5138
5166
|
function createAgentsResource(http) {
|
|
5139
5167
|
return {
|
|
5140
5168
|
async list() {
|
|
@@ -6954,13 +6982,6 @@ function createDeploymentsResource() {
|
|
|
6954
6982
|
}));
|
|
6955
6983
|
}) };
|
|
6956
6984
|
}
|
|
6957
|
-
function createProjectMetricsResource() {
|
|
6958
|
-
return { list: mock({
|
|
6959
|
-
domain: "projectMetrics",
|
|
6960
|
-
method: "list",
|
|
6961
|
-
plannedEndpoint: "GET /api/projects/metrics"
|
|
6962
|
-
}, async () => ({})) };
|
|
6963
|
-
}
|
|
6964
6985
|
const projectMembersStore = /* @__PURE__ */ new Map();
|
|
6965
6986
|
function getProjectMembers(projectId) {
|
|
6966
6987
|
let members = projectMembersStore.get(projectId);
|
|
@@ -8565,7 +8586,7 @@ function createPlatformClient(options) {
|
|
|
8565
8586
|
history: createHistoryResource(),
|
|
8566
8587
|
deployments: createDeploymentsResource(),
|
|
8567
8588
|
gatewayAttachments: createGatewayAttachmentsResource(http),
|
|
8568
|
-
projectMetrics: createProjectMetricsResource(),
|
|
8589
|
+
projectMetrics: createProjectMetricsResource(http),
|
|
8569
8590
|
projectFiles: createProjectFilesResource(http),
|
|
8570
8591
|
channels: createChannelsResource(),
|
|
8571
8592
|
members: createMembersResource(http),
|
|
@@ -8771,6 +8792,9 @@ function setCliTargetOptions(options) {
|
|
|
8771
8792
|
function getCliTargetOptions() {
|
|
8772
8793
|
return targetOptions;
|
|
8773
8794
|
}
|
|
8795
|
+
function resolveActiveProjectId(config) {
|
|
8796
|
+
return getCliTargetOptions().projectId ?? config.get("activeProjectId");
|
|
8797
|
+
}
|
|
8774
8798
|
//#endregion
|
|
8775
8799
|
//#region src/errors/example-input.ts
|
|
8776
8800
|
function exampleValueFromValidationMessage(message) {
|
|
@@ -9570,8 +9594,7 @@ async function runDeploy(options) {
|
|
|
9570
9594
|
function registerDeployCommand(program) {
|
|
9571
9595
|
program.command("deploy").description("Build, upload, and deploy the project to the platform").option("--dir <path>", "Project directory", process.cwd()).option("--skip-build", "Upload the existing dist/ without rebuilding").action(async (options) => {
|
|
9572
9596
|
try {
|
|
9573
|
-
const
|
|
9574
|
-
const projectId = getCliTargetOptions().projectId ?? config.get("activeProjectId");
|
|
9597
|
+
const projectId = resolveActiveProjectId(createCliConfig());
|
|
9575
9598
|
if (!projectId) throw new Error("Usage: keystroke deploy --project <id>");
|
|
9576
9599
|
await runDeploy({
|
|
9577
9600
|
dir: options.dir,
|
|
@@ -10147,6 +10170,13 @@ async function runProjectList(config) {
|
|
|
10147
10170
|
writeInactiveDeployHints(projects);
|
|
10148
10171
|
});
|
|
10149
10172
|
}
|
|
10173
|
+
async function runProjectMetrics(config, options) {
|
|
10174
|
+
await withActivePlatformClient(config, async (platform) => {
|
|
10175
|
+
const metrics = await platform.projectMetrics.list();
|
|
10176
|
+
const output = options.projectId === void 0 ? metrics : Object.fromEntries(Object.entries(metrics).filter(([projectId]) => projectId === options.projectId));
|
|
10177
|
+
process.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
|
|
10178
|
+
});
|
|
10179
|
+
}
|
|
10150
10180
|
async function runProjectCreate(config, input) {
|
|
10151
10181
|
await withActivePlatformClient(config, async (platform) => {
|
|
10152
10182
|
const project = await platform.projects.create(input);
|
|
@@ -10154,10 +10184,23 @@ async function runProjectCreate(config, input) {
|
|
|
10154
10184
|
writeInactiveDeployHints([project]);
|
|
10155
10185
|
});
|
|
10156
10186
|
}
|
|
10187
|
+
async function runProjectUpdate(config, input) {
|
|
10188
|
+
await withActivePlatformClient(config, async (platform) => {
|
|
10189
|
+
const { projectId, ...patch } = input;
|
|
10190
|
+
const project = await platform.projects.update(projectId, patch);
|
|
10191
|
+
process.stdout.write(`${JSON.stringify({ project }, null, 2)}\n`);
|
|
10192
|
+
});
|
|
10193
|
+
}
|
|
10194
|
+
async function runProjectDelete(config, projectId) {
|
|
10195
|
+
await withActivePlatformClient(config, async (platform) => {
|
|
10196
|
+
await platform.projects.delete(projectId);
|
|
10197
|
+
process.stdout.write(`${JSON.stringify({ deleted: projectId }, null, 2)}\n`);
|
|
10198
|
+
});
|
|
10199
|
+
}
|
|
10157
10200
|
//#endregion
|
|
10158
10201
|
//#region src/commands/project/index.ts
|
|
10159
10202
|
function registerProjectCommand(program) {
|
|
10160
|
-
const project = program.command("project").description("List and
|
|
10203
|
+
const project = program.command("project").description("List, create, update, and delete platform projects");
|
|
10161
10204
|
project.command("list").description("List projects in the active organization").action(async () => {
|
|
10162
10205
|
const config = createCliConfig();
|
|
10163
10206
|
try {
|
|
@@ -10170,6 +10213,18 @@ function registerProjectCommand(program) {
|
|
|
10170
10213
|
process.exitCode = 1;
|
|
10171
10214
|
}
|
|
10172
10215
|
});
|
|
10216
|
+
project.command("metrics").description("List rollup metrics for projects in the active organization").option("--project <id>", "Return metrics for a single project").action(async (options) => {
|
|
10217
|
+
const config = createCliConfig();
|
|
10218
|
+
try {
|
|
10219
|
+
await runProjectMetrics(config, { ...options.project ? { projectId: options.project } : {} });
|
|
10220
|
+
} catch (error) {
|
|
10221
|
+
process.stderr.write(`${formatCliError(error, "List project metrics failed", {
|
|
10222
|
+
serverUrl: getPlatformUrl(config),
|
|
10223
|
+
webUrl: getWebUrl(config)
|
|
10224
|
+
})}\n`);
|
|
10225
|
+
process.exitCode = 1;
|
|
10226
|
+
}
|
|
10227
|
+
});
|
|
10173
10228
|
project.command("create").description("Create a platform project in the active organization").requiredOption("--name <name>", "Project name").option("--description <description>", "Project description").action(async (options) => {
|
|
10174
10229
|
const config = createCliConfig();
|
|
10175
10230
|
try {
|
|
@@ -10185,6 +10240,40 @@ function registerProjectCommand(program) {
|
|
|
10185
10240
|
process.exitCode = 1;
|
|
10186
10241
|
}
|
|
10187
10242
|
});
|
|
10243
|
+
project.command("update").description("Update a platform project's name and/or description").option("--name <name>", "Project name").option("--description <description>", "Project description").action(async (options) => {
|
|
10244
|
+
const config = createCliConfig();
|
|
10245
|
+
try {
|
|
10246
|
+
const projectId = resolveActiveProjectId(config);
|
|
10247
|
+
if (!projectId) throw new Error("Usage: keystroke --project <id> project update --name <name>");
|
|
10248
|
+
if (!options.name && options.description === void 0) throw new Error("At least one of --name or --description is required");
|
|
10249
|
+
await runProjectUpdate(config, {
|
|
10250
|
+
projectId,
|
|
10251
|
+
...options.name ? { name: options.name } : {},
|
|
10252
|
+
...options.description !== void 0 ? { description: options.description } : {}
|
|
10253
|
+
});
|
|
10254
|
+
} catch (error) {
|
|
10255
|
+
process.stderr.write(`${formatCliError(error, "Update project failed", {
|
|
10256
|
+
serverUrl: getPlatformUrl(config),
|
|
10257
|
+
webUrl: getWebUrl(config)
|
|
10258
|
+
})}\n`);
|
|
10259
|
+
process.exitCode = 1;
|
|
10260
|
+
}
|
|
10261
|
+
});
|
|
10262
|
+
project.command("delete").description("Delete a platform project").option("-y, --yes", "Skip confirmation prompt").action(async (options) => {
|
|
10263
|
+
const config = createCliConfig();
|
|
10264
|
+
try {
|
|
10265
|
+
const projectId = resolveActiveProjectId(config);
|
|
10266
|
+
if (!projectId) throw new Error("Usage: keystroke --project <id> project delete");
|
|
10267
|
+
if (!options.yes) throw new Error("Pass --yes to confirm project deletion");
|
|
10268
|
+
await runProjectDelete(config, projectId);
|
|
10269
|
+
} catch (error) {
|
|
10270
|
+
process.stderr.write(`${formatCliError(error, "Delete project failed", {
|
|
10271
|
+
serverUrl: getPlatformUrl(config),
|
|
10272
|
+
webUrl: getWebUrl(config)
|
|
10273
|
+
})}\n`);
|
|
10274
|
+
process.exitCode = 1;
|
|
10275
|
+
}
|
|
10276
|
+
});
|
|
10188
10277
|
}
|
|
10189
10278
|
//#endregion
|
|
10190
10279
|
//#region src/commands/start.ts
|