@keystrokehq/cli 0.0.148 → 0.0.149
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/{dist-B61CtbIr.mjs → dist-BKyJS66Y.mjs} +8 -14
- package/dist/dist-BKyJS66Y.mjs.map +1 -0
- package/dist/{dist-CcJj87Po.mjs → dist-CzQkL7nN.mjs} +2 -2
- package/dist/{dist-CcJj87Po.mjs.map → dist-CzQkL7nN.mjs.map} +1 -1
- package/dist/{dist-k21gN6FR.mjs → dist-DN4tiUnu.mjs} +2 -2
- package/dist/{dist-k21gN6FR.mjs.map → dist-DN4tiUnu.mjs.map} +1 -1
- package/dist/index.mjs +196 -171
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/dist-B61CtbIr.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as ProjectSlugAvailabilityResponseSchema, A as InviteOrganizationMembersRequestSchema, At as WorkflowSummaryDetailResponseSchema, B as ListProjectsResponseSchema, C as GatewayAttachmentRecordSchema, Ct as UpsertGatewayAttachmentBodySchema, D as HistoryRunDetailResponseSchema, Dt as UserPreferencesSchema, E as HistoryRunCancelResponseSchema, Et as UserPreferencesPatchSchema, F as ListOrganizationMembersResponseSchema, Ft as parseErrorResponse, G as PresignOrgLogoRequestSchema, H as OrganizationSidebarBrandingSchema, I as ListOrganizationsResponseSchema, J as PresignProjectSourceResponseSchema, K as PresignOrgLogoResponseSchema, L as ListProjectDeploymentsResponseSchema, M as ListAppsResponseSchema, Mt as listenPortFromPublicUrl, N as ListCredentialsResponseSchema, O as HistoryRunListQuerySchema, Ot as WorkflowRunDetailResponseSchema, P as ListOrganizationInvitationsResponseSchema, Pt as originFromPublicUrl, Q as ProjectResponseSchema, R as ListProjectFilesResponseSchema, S as ErrorResponseSchema, St as UploadProjectSourceResponseSchema, T as HealthResponseSchema, Tt as UserAvatarSchema, U as PROJECT_REACHABILITY_REQUEST_TIMEOUT_MS, V as OrganizationSidebarBrandingPatchSchema, W as PollRunResponseSchema, X as PresignUserAvatarResponseSchema, Y as PresignUserAvatarRequestSchema, Z as ProjectReachabilityResponseSchema, _ as CreateProjectRequestSchema, _t as UpdateOrganizationMemberRequestSchema, a as AgentSessionListResponseSchema, at as RecentResourceListResponseSchema, b as CredentialInstanceRecordSchema, bt as UpdateProjectRequestSchema, c as CompleteProjectArtifactResponseSchema, ct as SlugAvailabilityResponseSchema, d as CreateCredentialInstanceBodySchema, dt as TriggerDetailResponseSchema, et as PromptInputSchema, f as CreateCredentialsRequestSchema, ft as TriggerListResponseSchema, g as CreateProjectArtifactResponseSchema, gt as UpdateCredentialRequestSchema, h as CreateOrganizationResponseSchema, ht as UpdateCredentialInstanceBodySchema, i as AgentSessionDetailResponseSchema, it as ROUTE_MANIFEST_REL_PATH, j as InviteOrganizationMembersResponseSchema, jt as WorkflowSummaryListResponseSchema, k as HistoryRunListResponseSchema, kt as WorkflowRunListResponseSchema, l as ConnectAuthorizeUrlResponseSchema, lt as StartOAuthConnectionInputSchema, m as CreateOrganizationRequestSchema, mt as TriggerRunListResponseSchema, n as AcceptOrganizationInvitationResponseSchema, nt as QueuedAgentPromptResponseSchema, o as AgentSummaryDetailResponseSchema, ot as SkillSummaryDetailResponseSchema, p as CreateCredentialsResponseSchema, pt as TriggerRunDetailResponseSchema, q as PresignProjectSourceRequestSchema, r as ActiveOrganizationResponseSchema, rt as QueuedRunResponseSchema, s as AgentSummaryListResponseSchema, st as SkillSummaryListResponseSchema, t as ACTIVE_ORG_HEADER, tt as PromptResponseSchema, u as ConnectProvidersResponseSchema, ut as StartOAuthConnectionResultSchema, v as CreateProjectResponseSchema, vt as UpdateOrganizationMemberResponseSchema, w as GetCredentialResponseSchema, wt as UserAvatarPatchSchema, x as DeclineOrganizationInvitationResponseSchema, xt as UploadProjectSourceManifestRequestSchema, y as CredentialInstanceListResponseSchema, yt as UpdateOrganizationRequestSchema, z as ListProjectMetricsResponseSchema } from "./dist-
|
|
2
|
+
import { $ as ProjectSlugAvailabilityResponseSchema, A as InviteOrganizationMembersRequestSchema, At as WorkflowSummaryDetailResponseSchema, B as ListProjectsResponseSchema, C as GatewayAttachmentRecordSchema, Ct as UpsertGatewayAttachmentBodySchema, D as HistoryRunDetailResponseSchema, Dt as UserPreferencesSchema, E as HistoryRunCancelResponseSchema, Et as UserPreferencesPatchSchema, F as ListOrganizationMembersResponseSchema, Ft as parseErrorResponse, G as PresignOrgLogoRequestSchema, H as OrganizationSidebarBrandingSchema, I as ListOrganizationsResponseSchema, J as PresignProjectSourceResponseSchema, K as PresignOrgLogoResponseSchema, L as ListProjectDeploymentsResponseSchema, M as ListAppsResponseSchema, Mt as listenPortFromPublicUrl, N as ListCredentialsResponseSchema, O as HistoryRunListQuerySchema, Ot as WorkflowRunDetailResponseSchema, P as ListOrganizationInvitationsResponseSchema, Pt as originFromPublicUrl, Q as ProjectResponseSchema, R as ListProjectFilesResponseSchema, S as ErrorResponseSchema, St as UploadProjectSourceResponseSchema, T as HealthResponseSchema, Tt as UserAvatarSchema, U as PROJECT_REACHABILITY_REQUEST_TIMEOUT_MS, V as OrganizationSidebarBrandingPatchSchema, W as PollRunResponseSchema, X as PresignUserAvatarResponseSchema, Y as PresignUserAvatarRequestSchema, Z as ProjectReachabilityResponseSchema, _ as CreateProjectRequestSchema, _t as UpdateOrganizationMemberRequestSchema, a as AgentSessionListResponseSchema, at as RecentResourceListResponseSchema, b as CredentialInstanceRecordSchema, bt as UpdateProjectRequestSchema, c as CompleteProjectArtifactResponseSchema, ct as SlugAvailabilityResponseSchema, d as CreateCredentialInstanceBodySchema, dt as TriggerDetailResponseSchema, et as PromptInputSchema, f as CreateCredentialsRequestSchema, ft as TriggerListResponseSchema, g as CreateProjectArtifactResponseSchema, gt as UpdateCredentialRequestSchema, h as CreateOrganizationResponseSchema, ht as UpdateCredentialInstanceBodySchema, i as AgentSessionDetailResponseSchema, it as ROUTE_MANIFEST_REL_PATH, j as InviteOrganizationMembersResponseSchema, jt as WorkflowSummaryListResponseSchema, k as HistoryRunListResponseSchema, kt as WorkflowRunListResponseSchema, l as ConnectAuthorizeUrlResponseSchema, lt as StartOAuthConnectionInputSchema, m as CreateOrganizationRequestSchema, mt as TriggerRunListResponseSchema, n as AcceptOrganizationInvitationResponseSchema, nt as QueuedAgentPromptResponseSchema, o as AgentSummaryDetailResponseSchema, ot as SkillSummaryDetailResponseSchema, p as CreateCredentialsResponseSchema, pt as TriggerRunDetailResponseSchema, q as PresignProjectSourceRequestSchema, r as ActiveOrganizationResponseSchema, rt as QueuedRunResponseSchema, s as AgentSummaryListResponseSchema, st as SkillSummaryListResponseSchema, t as ACTIVE_ORG_HEADER, tt as PromptResponseSchema, u as ConnectProvidersResponseSchema, ut as StartOAuthConnectionResultSchema, v as CreateProjectResponseSchema, vt as UpdateOrganizationMemberResponseSchema, w as GetCredentialResponseSchema, wt as UserAvatarPatchSchema, x as DeclineOrganizationInvitationResponseSchema, xt as UploadProjectSourceManifestRequestSchema, y as CredentialInstanceListResponseSchema, yt as UpdateOrganizationRequestSchema, z as ListProjectMetricsResponseSchema } from "./dist-BKyJS66Y.mjs";
|
|
3
3
|
import { t as walkProject } from "./walk-project-171B4cvO-DJy3qZKd.mjs";
|
|
4
4
|
import { a as installPlaygroundDependencies, i as installDependencies, n as buildPlaygroundWorkspace, o as resolvePackageManager, s as resolveCliRoot, t as readCliVersion } from "./version-DESgLEkE.mjs";
|
|
5
5
|
import { createRequire } from "node:module";
|
|
@@ -3883,8 +3883,8 @@ function buildOAuthAuthorizeSearchParams(input) {
|
|
|
3883
3883
|
const params = {};
|
|
3884
3884
|
const scopes = input.scopes ?? [];
|
|
3885
3885
|
if (scopes.length > 0) params.scopes = scopes.join(",");
|
|
3886
|
-
const projectIds = input.
|
|
3887
|
-
if (projectIds.length > 0) params.
|
|
3886
|
+
const projectIds = input.projects ?? [];
|
|
3887
|
+
if (projectIds.length > 0) params.projects = projectIds.join(",");
|
|
3888
3888
|
if (input.createOrganizationCredential) params.org = "true";
|
|
3889
3889
|
if (input.createUserProvidedCredential) params.user = "true";
|
|
3890
3890
|
return params;
|
|
@@ -5382,19 +5382,19 @@ function registerAppCommand(program) {
|
|
|
5382
5382
|
}
|
|
5383
5383
|
//#endregion
|
|
5384
5384
|
//#region src/commands/connect/parse-connect-scopes.ts
|
|
5385
|
-
function parseConnectScopes(scopes,
|
|
5385
|
+
function parseConnectScopes(scopes, projectSlugs) {
|
|
5386
5386
|
const normalized = scopes.length > 0 ? scopes : ["org"];
|
|
5387
5387
|
for (const scope of normalized) if (scope !== "org" && scope !== "user" && scope !== "project") throw new Error(`Unknown scope "${scope}". Expected org, user, or project.`);
|
|
5388
5388
|
const createOrganizationCredential = normalized.includes("org");
|
|
5389
5389
|
const createUserProvidedCredential = normalized.includes("user");
|
|
5390
5390
|
const includesProject = normalized.includes("project");
|
|
5391
|
-
const
|
|
5392
|
-
if (includesProject &&
|
|
5393
|
-
if (!createOrganizationCredential && !createUserProvidedCredential &&
|
|
5391
|
+
const selectedProjects = includesProject ? projectSlugs : [];
|
|
5392
|
+
if (includesProject && selectedProjects.length === 0) throw new Error("--project-slug is required when scope includes project");
|
|
5393
|
+
if (!createOrganizationCredential && !createUserProvidedCredential && selectedProjects.length === 0) throw new Error("At least one scope is required via --scope and/or --project-slug");
|
|
5394
5394
|
return {
|
|
5395
5395
|
createOrganizationCredential,
|
|
5396
5396
|
createUserProvidedCredential,
|
|
5397
|
-
|
|
5397
|
+
projects: selectedProjects
|
|
5398
5398
|
};
|
|
5399
5399
|
}
|
|
5400
5400
|
//#endregion
|
|
@@ -5430,7 +5430,7 @@ async function runConnect(options) {
|
|
|
5430
5430
|
appId: provider.key,
|
|
5431
5431
|
scopes: oauthScopes,
|
|
5432
5432
|
permissionMode: "default",
|
|
5433
|
-
|
|
5433
|
+
projects: scopes.projects,
|
|
5434
5434
|
createOrganizationCredential: scopes.createOrganizationCredential,
|
|
5435
5435
|
createUserProvidedCredential: scopes.createUserProvidedCredential
|
|
5436
5436
|
});
|
|
@@ -5469,11 +5469,11 @@ function resolveConnectTargetOptions() {
|
|
|
5469
5469
|
if (local) return { local: true };
|
|
5470
5470
|
return { orgScoped: true };
|
|
5471
5471
|
}
|
|
5472
|
-
function collectValues(value, previous) {
|
|
5472
|
+
function collectValues$1(value, previous) {
|
|
5473
5473
|
return previous.concat([value]);
|
|
5474
5474
|
}
|
|
5475
5475
|
function registerConnectCommand(program) {
|
|
5476
|
-
program.command("connect [provider]").description("Connect third-party accounts (uses apiTarget; --local for local server)").option("--oauth-scope <scope>", "OAuth permission scope to request (repeatable)", collectValues, []).option("--scope <scope>", "Credential scope: org, user, or project (repeatable)", collectValues, []).option("--project-
|
|
5476
|
+
program.command("connect [provider]").description("Connect third-party accounts (uses apiTarget; --local for local server)").option("--oauth-scope <scope>", "OAuth permission scope to request (repeatable)", collectValues$1, []).option("--scope <scope>", "Credential scope: org, user, or project (repeatable)", collectValues$1, []).option("--project-slug <slug>", "Project slug when scope includes project (repeatable)", collectValues$1, []).option("--print-url", "Print the authorize URL and exit without opening the browser").action((provider, options) => runCliCommand("Could not fetch connect providers", async (ctx) => {
|
|
5477
5477
|
const providers = await ctx.client.connect.listProviders();
|
|
5478
5478
|
if (!provider) {
|
|
5479
5479
|
if (providers.length === 0) {
|
|
@@ -5489,9 +5489,9 @@ function registerConnectCommand(program) {
|
|
|
5489
5489
|
const available = providers.map((entry) => entry.key).join(", ") || "(none)";
|
|
5490
5490
|
throw new Error(`Unknown provider "${provider}". Available: ${available}`);
|
|
5491
5491
|
}
|
|
5492
|
-
const hasScopeFlags = options.scope.length > 0 || options.
|
|
5493
|
-
if (ctx.apiTarget.mode === "local" && hasScopeFlags) throw new Error("--scope and --project-
|
|
5494
|
-
const credentialScopes = ctx.apiTarget.mode === "platform" ? parseConnectScopes(options.scope, options.
|
|
5492
|
+
const hasScopeFlags = options.scope.length > 0 || options.projectSlug.length > 0;
|
|
5493
|
+
if (ctx.apiTarget.mode === "local" && hasScopeFlags) throw new Error("--scope and --project-slug are only supported against the platform API (omit --local)");
|
|
5494
|
+
const credentialScopes = ctx.apiTarget.mode === "platform" ? parseConnectScopes(options.scope, options.projectSlug) : void 0;
|
|
5495
5495
|
const platform = ctx.apiTarget.mode === "platform" ? createCliPlatformClient(createCliConfig()) : void 0;
|
|
5496
5496
|
await runConnect({
|
|
5497
5497
|
client: ctx.client,
|
|
@@ -5505,6 +5505,73 @@ function registerConnectCommand(program) {
|
|
|
5505
5505
|
}, void 0, resolveConnectTargetOptions()));
|
|
5506
5506
|
}
|
|
5507
5507
|
//#endregion
|
|
5508
|
+
//#region src/commands/project/run-project.ts
|
|
5509
|
+
async function withActivePlatformClient(config, fn) {
|
|
5510
|
+
const platform = createCliPlatformClient(config);
|
|
5511
|
+
let active = await platform.organizations.getActive();
|
|
5512
|
+
if (!active) active = await selectActiveOrganization(config);
|
|
5513
|
+
platform.setActiveOrganizationId(active.organization.id);
|
|
5514
|
+
await fn(platform);
|
|
5515
|
+
}
|
|
5516
|
+
function writeInactiveDeployHints(projects) {
|
|
5517
|
+
const bin = cliBinaryName();
|
|
5518
|
+
for (const project of projects) {
|
|
5519
|
+
if (project.status !== "inactive") continue;
|
|
5520
|
+
process.stderr.write(`Project ${formatProjectLabel(project)} is inactive. Deploy with: ${bin} deploy --project ${formatProjectLabel(project)}\n`);
|
|
5521
|
+
}
|
|
5522
|
+
}
|
|
5523
|
+
async function runProjectList(config) {
|
|
5524
|
+
await withActivePlatformClient(config, async (platform) => {
|
|
5525
|
+
const projects = await platform.projects.list();
|
|
5526
|
+
process.stdout.write(`${JSON.stringify({ projects }, null, 2)}\n`);
|
|
5527
|
+
if (projects.length === 0) {
|
|
5528
|
+
const bin = cliBinaryName();
|
|
5529
|
+
process.stderr.write(`No projects yet. Create one with: ${bin} project create --name "My project"\n`);
|
|
5530
|
+
return;
|
|
5531
|
+
}
|
|
5532
|
+
writeInactiveDeployHints(projects);
|
|
5533
|
+
});
|
|
5534
|
+
}
|
|
5535
|
+
async function runProjectMetrics(config, options) {
|
|
5536
|
+
await withActivePlatformClient(config, async (platform) => {
|
|
5537
|
+
const metrics = await platform.projectMetrics.list();
|
|
5538
|
+
if (options.projectRef === void 0) {
|
|
5539
|
+
process.stdout.write(`${JSON.stringify(metrics, null, 2)}\n`);
|
|
5540
|
+
return;
|
|
5541
|
+
}
|
|
5542
|
+
const project = await resolveProjectRef(platform, options.projectRef);
|
|
5543
|
+
const output = Object.fromEntries(Object.entries(metrics).filter(([projectId]) => projectId === project.id));
|
|
5544
|
+
process.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
|
|
5545
|
+
});
|
|
5546
|
+
}
|
|
5547
|
+
async function runProjectDeploymentsList(config, options) {
|
|
5548
|
+
await withActivePlatformClient(config, async (platform) => {
|
|
5549
|
+
const project = await resolveProjectRef(platform, options.projectRef);
|
|
5550
|
+
const deployments = await platform.deployments.listForProject(project.id);
|
|
5551
|
+
process.stdout.write(`${JSON.stringify({ deployments }, null, 2)}\n`);
|
|
5552
|
+
});
|
|
5553
|
+
}
|
|
5554
|
+
async function runProjectCreate(config, input) {
|
|
5555
|
+
await withActivePlatformClient(config, async (platform) => {
|
|
5556
|
+
const project = await platform.projects.create(input);
|
|
5557
|
+
process.stdout.write(`${JSON.stringify({ project }, null, 2)}\n`);
|
|
5558
|
+
writeInactiveDeployHints([project]);
|
|
5559
|
+
});
|
|
5560
|
+
}
|
|
5561
|
+
async function runProjectUpdate(config, input) {
|
|
5562
|
+
await withActivePlatformClient(config, async (platform) => {
|
|
5563
|
+
const { projectId, ...patch } = input;
|
|
5564
|
+
const project = await platform.projects.update(projectId, patch);
|
|
5565
|
+
process.stdout.write(`${JSON.stringify({ project }, null, 2)}\n`);
|
|
5566
|
+
});
|
|
5567
|
+
}
|
|
5568
|
+
async function runProjectDelete(config, projectId) {
|
|
5569
|
+
await withActivePlatformClient(config, async (platform) => {
|
|
5570
|
+
await platform.projects.delete(projectId);
|
|
5571
|
+
process.stdout.write(`${JSON.stringify({ deleted: projectId }, null, 2)}\n`);
|
|
5572
|
+
});
|
|
5573
|
+
}
|
|
5574
|
+
//#endregion
|
|
5508
5575
|
//#region src/commands/credentials/target-options.ts
|
|
5509
5576
|
function resolveCredentialsTargetOptions(options = {}) {
|
|
5510
5577
|
if (options.scopeType === "project") return {
|
|
@@ -5515,10 +5582,21 @@ function resolveCredentialsTargetOptions(options = {}) {
|
|
|
5515
5582
|
}
|
|
5516
5583
|
//#endregion
|
|
5517
5584
|
//#region src/commands/credentials/run-credentials.ts
|
|
5518
|
-
async function
|
|
5519
|
-
const
|
|
5520
|
-
await
|
|
5521
|
-
|
|
5585
|
+
async function createLocalCredentialsClient(targetOptions) {
|
|
5586
|
+
const config = createCliConfig();
|
|
5587
|
+
const target = await resolveApiTarget(config, {
|
|
5588
|
+
...getCliTargetOptions(),
|
|
5589
|
+
...resolveCredentialsTargetOptions(),
|
|
5590
|
+
...targetOptions
|
|
5591
|
+
});
|
|
5592
|
+
return {
|
|
5593
|
+
config,
|
|
5594
|
+
client: createCliClient(config, {
|
|
5595
|
+
baseUrl: target.baseUrl,
|
|
5596
|
+
platform: target.mode === "platform"
|
|
5597
|
+
}),
|
|
5598
|
+
target
|
|
5599
|
+
};
|
|
5522
5600
|
}
|
|
5523
5601
|
function isLocalCredentialsTarget() {
|
|
5524
5602
|
return Boolean(getCliTargetOptions().local);
|
|
@@ -5534,7 +5612,7 @@ async function runCredentialsCommand(fallback, fn) {
|
|
|
5534
5612
|
});
|
|
5535
5613
|
return;
|
|
5536
5614
|
}
|
|
5537
|
-
await withActivePlatformClient
|
|
5615
|
+
await withActivePlatformClient(config, async (platform) => {
|
|
5538
5616
|
await fn({
|
|
5539
5617
|
config,
|
|
5540
5618
|
platform,
|
|
@@ -5550,15 +5628,14 @@ async function runCredentialsCommand(fallback, fn) {
|
|
|
5550
5628
|
}
|
|
5551
5629
|
}
|
|
5552
5630
|
function buildPlatformCreateRequest(args) {
|
|
5553
|
-
|
|
5554
|
-
if (!apiKey) throw new Error("At least one --set field is required");
|
|
5631
|
+
if (Object.keys(args.value).length === 0) throw new Error("At least one --set field is required");
|
|
5555
5632
|
return {
|
|
5556
5633
|
appId: args.appId,
|
|
5557
5634
|
connectionKind: "manual",
|
|
5558
|
-
|
|
5559
|
-
|
|
5560
|
-
createOrganizationCredential: args.
|
|
5561
|
-
createUserProvidedCredential: args.
|
|
5635
|
+
value: args.value,
|
|
5636
|
+
projects: args.targets.projects,
|
|
5637
|
+
createOrganizationCredential: args.targets.createOrganizationCredential,
|
|
5638
|
+
createUserProvidedCredential: args.targets.createUserProvidedCredential
|
|
5562
5639
|
};
|
|
5563
5640
|
}
|
|
5564
5641
|
function buildPlatformUpdatePatch(args) {
|
|
@@ -5573,15 +5650,8 @@ function buildPlatformUpdatePatch(args) {
|
|
|
5573
5650
|
function registerCredentialsDeleteCommand(credentials) {
|
|
5574
5651
|
credentials.command("delete").description("Delete a credential instance").argument("<id>", "Credential instance id").action((id) => runCredentialsCommand("Delete credential failed", async ({ platform, local }) => {
|
|
5575
5652
|
if (local) {
|
|
5576
|
-
const
|
|
5577
|
-
|
|
5578
|
-
...getCliTargetOptions(),
|
|
5579
|
-
...resolveCredentialsTargetOptions()
|
|
5580
|
-
});
|
|
5581
|
-
await createCliClient(config, {
|
|
5582
|
-
baseUrl: target.baseUrl,
|
|
5583
|
-
platform: target.mode === "platform"
|
|
5584
|
-
}).credentials.deleteInstance(id);
|
|
5653
|
+
const { client } = await createLocalCredentialsClient();
|
|
5654
|
+
await client.credentials.deleteInstance(id);
|
|
5585
5655
|
return;
|
|
5586
5656
|
}
|
|
5587
5657
|
await platform.credentials.delete(id);
|
|
@@ -5592,15 +5662,8 @@ function registerCredentialsDeleteCommand(credentials) {
|
|
|
5592
5662
|
function registerCredentialsGetCommand(credentials) {
|
|
5593
5663
|
credentials.command("get").description("Get a credential instance by id").argument("<id>", "Credential instance id").action((id) => runCredentialsCommand("Get credential failed", async ({ platform, local }) => {
|
|
5594
5664
|
if (local) {
|
|
5595
|
-
const
|
|
5596
|
-
const
|
|
5597
|
-
...getCliTargetOptions(),
|
|
5598
|
-
...resolveCredentialsTargetOptions()
|
|
5599
|
-
});
|
|
5600
|
-
const match = (await createCliClient(config, {
|
|
5601
|
-
baseUrl: target.baseUrl,
|
|
5602
|
-
platform: target.mode === "platform"
|
|
5603
|
-
}).credentials.listInstances()).instances.find((instance) => instance.id === id);
|
|
5665
|
+
const { client } = await createLocalCredentialsClient();
|
|
5666
|
+
const match = (await client.credentials.listInstances()).instances.find((instance) => instance.id === id);
|
|
5604
5667
|
if (!match) throw new Error(`Credential ${id} not found`);
|
|
5605
5668
|
process.stdout.write(`${JSON.stringify(match, null, 2)}\n`);
|
|
5606
5669
|
return;
|
|
@@ -5614,15 +5677,8 @@ function registerCredentialsGetCommand(credentials) {
|
|
|
5614
5677
|
function registerCredentialsListCommand(credentials) {
|
|
5615
5678
|
credentials.command("list").description("List stored credential instances").option("--key <key>", "Filter by credential key (local server only)").action((options) => runCredentialsCommand("List credential instances failed", async ({ platform, local }) => {
|
|
5616
5679
|
if (local) {
|
|
5617
|
-
const
|
|
5618
|
-
const
|
|
5619
|
-
...getCliTargetOptions(),
|
|
5620
|
-
...resolveCredentialsTargetOptions()
|
|
5621
|
-
});
|
|
5622
|
-
const result = await createCliClient(config, {
|
|
5623
|
-
baseUrl: target.baseUrl,
|
|
5624
|
-
platform: target.mode === "platform"
|
|
5625
|
-
}).credentials.listInstances(options.key ? { key: options.key } : void 0);
|
|
5680
|
+
const { client } = await createLocalCredentialsClient();
|
|
5681
|
+
const result = await client.credentials.listInstances(options.key ? { key: options.key } : void 0);
|
|
5626
5682
|
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
5627
5683
|
return;
|
|
5628
5684
|
}
|
|
@@ -5775,83 +5831,119 @@ async function assertNoSetConflict(client, args) {
|
|
|
5775
5831
|
}));
|
|
5776
5832
|
}
|
|
5777
5833
|
//#endregion
|
|
5834
|
+
//#region src/commands/credentials/parse-set-scopes.ts
|
|
5835
|
+
function parseCredentialSetScopes(scopes, projectSlugs) {
|
|
5836
|
+
if (scopes.includes("global")) {
|
|
5837
|
+
if (scopes.length > 1) throw new Error("global scope cannot be combined with org, user, or project");
|
|
5838
|
+
if (projectSlugs.length > 0) throw new Error("global scope cannot be combined with --project-slug");
|
|
5839
|
+
return { global: true };
|
|
5840
|
+
}
|
|
5841
|
+
return parseConnectScopes(scopes, projectSlugs);
|
|
5842
|
+
}
|
|
5843
|
+
//#endregion
|
|
5778
5844
|
//#region src/commands/credentials/set.ts
|
|
5779
5845
|
function registerCredentialsSetCommand(credentials) {
|
|
5780
|
-
credentials.command("set").description("Create a new api_key credential instance").argument("<key>", "Credential key or app id, e.g. exa").
|
|
5846
|
+
credentials.command("set").description("Create a new api_key credential instance").argument("<key>", "Credential key or app id, e.g. exa").option("--scope <scope>", "org, user, project, or global (repeatable)", collectValues, []).option("--project-slug <slug>", "Project slug when scope includes project (repeatable)", collectValues, []).option("--label <label>", "Human-readable label within the scope").option("--default", "Mark as default for this scope").option("--set <field>", "Credential field as key=value or key=@env:VAR (falls back to project .env when unset in shell)", collectSetValues$1, []).action((key, options) => runCredentialsCommand("Set credential failed", async ({ platform, local }) => {
|
|
5781
5847
|
const value = parseCredentialValueFields(options.set);
|
|
5782
|
-
const
|
|
5783
|
-
if (scopeType === "project" && !options.projectId) throw new Error("--project-id is required when scope is project");
|
|
5848
|
+
const parsedScopes = parseCredentialSetScopes(options.scope, options.projectSlug);
|
|
5784
5849
|
if (local) {
|
|
5785
|
-
const
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5850
|
+
const { client } = await createLocalCredentialsClient();
|
|
5851
|
+
if ("global" in parsedScopes) {
|
|
5852
|
+
const scopeType = scopeTypeFromCli("global");
|
|
5853
|
+
await assertNoSetConflict(client, {
|
|
5854
|
+
key,
|
|
5855
|
+
scope: "global",
|
|
5789
5856
|
scopeType,
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
const
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5857
|
+
label: options.label,
|
|
5858
|
+
setFields: options.set
|
|
5859
|
+
});
|
|
5860
|
+
const result = await client.credentials.createInstance({
|
|
5861
|
+
key,
|
|
5862
|
+
scopeType,
|
|
5863
|
+
label: options.label,
|
|
5864
|
+
isDefault: options.default,
|
|
5865
|
+
value
|
|
5866
|
+
});
|
|
5867
|
+
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`);
|
|
5868
|
+
return;
|
|
5869
|
+
}
|
|
5870
|
+
const targets = expandLocalCredentialTargets(parsedScopes);
|
|
5871
|
+
const instances = [];
|
|
5872
|
+
for (const target of targets) {
|
|
5873
|
+
await assertNoSetConflict(client, {
|
|
5874
|
+
key,
|
|
5875
|
+
scope: target.scope,
|
|
5876
|
+
scopeType: target.scopeType,
|
|
5877
|
+
projectId: target.projectSlug,
|
|
5878
|
+
label: options.label,
|
|
5879
|
+
setFields: options.set
|
|
5880
|
+
});
|
|
5881
|
+
instances.push(await client.credentials.createInstance({
|
|
5882
|
+
key,
|
|
5883
|
+
scopeType: target.scopeType,
|
|
5884
|
+
scopeId: target.projectSlug,
|
|
5885
|
+
label: options.label,
|
|
5886
|
+
isDefault: options.default,
|
|
5887
|
+
value
|
|
5888
|
+
}));
|
|
5889
|
+
}
|
|
5890
|
+
if (instances.length === 1) {
|
|
5891
|
+
process.stdout.write(`${JSON.stringify(instances[0], null, 2)}\n`);
|
|
5892
|
+
return;
|
|
5893
|
+
}
|
|
5894
|
+
process.stdout.write(`${JSON.stringify({ instances }, null, 2)}\n`);
|
|
5814
5895
|
return;
|
|
5815
5896
|
}
|
|
5816
|
-
if (options.scope
|
|
5897
|
+
if (options.scope.includes("global") || "global" in parsedScopes) throw new Error("global scope is only supported against a local keystroke server");
|
|
5817
5898
|
const created = await platform.credentials.create(buildPlatformCreateRequest({
|
|
5818
5899
|
appId: key,
|
|
5819
5900
|
value,
|
|
5820
|
-
|
|
5821
|
-
projectId: options.projectId
|
|
5901
|
+
targets: parsedScopes
|
|
5822
5902
|
}));
|
|
5823
5903
|
if (options.label !== void 0 || options.default !== void 0) {
|
|
5824
5904
|
const patch = buildPlatformUpdatePatch({
|
|
5825
5905
|
...options.label !== void 0 ? { label: options.label } : {},
|
|
5826
5906
|
...options.default !== void 0 ? { isDefault: options.default } : {}
|
|
5827
5907
|
});
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
}
|
|
5908
|
+
const credentials = [];
|
|
5909
|
+
for (const credential of created) credentials.push(await platform.credentials.update(credential.id, patch));
|
|
5910
|
+
process.stdout.write(`${JSON.stringify({ credentials }, null, 2)}\n`);
|
|
5832
5911
|
return;
|
|
5833
5912
|
}
|
|
5834
5913
|
process.stdout.write(`${JSON.stringify({ credentials: created }, null, 2)}\n`);
|
|
5835
5914
|
}));
|
|
5836
5915
|
}
|
|
5916
|
+
function collectValues(value, previous) {
|
|
5917
|
+
return previous.concat([value]);
|
|
5918
|
+
}
|
|
5837
5919
|
function collectSetValues$1(value, previous) {
|
|
5838
5920
|
return previous.concat([value]);
|
|
5839
5921
|
}
|
|
5922
|
+
function expandLocalCredentialTargets(targets) {
|
|
5923
|
+
const expanded = [];
|
|
5924
|
+
if (targets.createOrganizationCredential) expanded.push({
|
|
5925
|
+
scope: "org",
|
|
5926
|
+
scopeType: scopeTypeFromCli("org")
|
|
5927
|
+
});
|
|
5928
|
+
if (targets.createUserProvidedCredential) expanded.push({
|
|
5929
|
+
scope: "user",
|
|
5930
|
+
scopeType: scopeTypeFromCli("user")
|
|
5931
|
+
});
|
|
5932
|
+
for (const projectSlug of targets.projects) expanded.push({
|
|
5933
|
+
scope: "project",
|
|
5934
|
+
scopeType: scopeTypeFromCli("project"),
|
|
5935
|
+
projectSlug
|
|
5936
|
+
});
|
|
5937
|
+
return expanded;
|
|
5938
|
+
}
|
|
5840
5939
|
//#endregion
|
|
5841
5940
|
//#region src/commands/credentials/update.ts
|
|
5842
5941
|
function registerCredentialsUpdateCommand(credentials) {
|
|
5843
5942
|
credentials.command("update").description("Update a credential instance").argument("<id>", "Credential instance id").option("--label <label>", "Human-readable label within the scope").option("--default", "Mark as default for this scope").option("--set <field>", "Credential field as key=value or key=@env:VAR", collectSetValues, []).action((id, options) => runCredentialsCommand("Update credential failed", async ({ platform, local }) => {
|
|
5844
5943
|
const value = options.set.length > 0 ? parseCredentialValueFields(options.set) : void 0;
|
|
5845
5944
|
if (local) {
|
|
5846
|
-
const
|
|
5847
|
-
const
|
|
5848
|
-
...getCliTargetOptions(),
|
|
5849
|
-
...resolveCredentialsTargetOptions()
|
|
5850
|
-
});
|
|
5851
|
-
const result = await createCliClient(config, {
|
|
5852
|
-
baseUrl: target.baseUrl,
|
|
5853
|
-
platform: target.mode === "platform"
|
|
5854
|
-
}).credentials.updateInstance(id, {
|
|
5945
|
+
const { client } = await createLocalCredentialsClient();
|
|
5946
|
+
const result = await client.credentials.updateInstance(id, {
|
|
5855
5947
|
...options.label !== void 0 ? { label: options.label } : {},
|
|
5856
5948
|
...options.default !== void 0 ? { isDefault: options.default } : {},
|
|
5857
5949
|
...value ? { value } : {}
|
|
@@ -5992,7 +6084,7 @@ function registerBuildCommand(program) {
|
|
|
5992
6084
|
program.command("build").description("Build the keystroke project for production").option("--dir <path>", "Project directory", process.cwd()).action(async (options) => {
|
|
5993
6085
|
try {
|
|
5994
6086
|
const root = resolveProjectRoot(options.dir);
|
|
5995
|
-
const { buildApp } = await import("./dist-
|
|
6087
|
+
const { buildApp } = await import("./dist-CzQkL7nN.mjs");
|
|
5996
6088
|
await buildApp({ root });
|
|
5997
6089
|
process.stdout.write(`Built ${root}\n`);
|
|
5998
6090
|
} catch (error) {
|
|
@@ -6089,7 +6181,7 @@ async function runDeploy(options) {
|
|
|
6089
6181
|
const client = createCliPlatformClient(config);
|
|
6090
6182
|
let source;
|
|
6091
6183
|
if (!options.skipBuild) {
|
|
6092
|
-
const { buildApp } = await import("./dist-
|
|
6184
|
+
const { buildApp } = await import("./dist-CzQkL7nN.mjs");
|
|
6093
6185
|
source = { files: (await buildApp({
|
|
6094
6186
|
root,
|
|
6095
6187
|
collectSources: true,
|
|
@@ -6189,7 +6281,7 @@ function runtimeChildEnv(parentEnv, overrides) {
|
|
|
6189
6281
|
//#region src/project/bootstrap-run.ts
|
|
6190
6282
|
/** Node args + env for `@keystrokehq/build` bootstrap (shared by start + dev). */
|
|
6191
6283
|
async function resolveBootstrapRun(options) {
|
|
6192
|
-
const { resolveRuntimeBuildArtifact } = await import("./dist-
|
|
6284
|
+
const { resolveRuntimeBuildArtifact } = await import("./dist-CzQkL7nN.mjs");
|
|
6193
6285
|
const loader = pathToFileURL(resolveRuntimeBuildArtifact(options.runtimeNodeModules, "dist/runtime-loader.mjs")).href;
|
|
6194
6286
|
const bootstrap = resolveRuntimeBuildArtifact(options.runtimeNodeModules, "dist/bootstrap.mjs");
|
|
6195
6287
|
const args = [`--import=${loader}`];
|
|
@@ -6339,7 +6431,7 @@ async function runDev(options) {
|
|
|
6339
6431
|
process.on("SIGINT", shutdown);
|
|
6340
6432
|
process.on("SIGTERM", shutdown);
|
|
6341
6433
|
try {
|
|
6342
|
-
const { watchApp } = await import("./dist-
|
|
6434
|
+
const { watchApp } = await import("./dist-CzQkL7nN.mjs");
|
|
6343
6435
|
await watchApp({
|
|
6344
6436
|
root,
|
|
6345
6437
|
clean: false,
|
|
@@ -6367,73 +6459,6 @@ function registerDevCommand(program) {
|
|
|
6367
6459
|
});
|
|
6368
6460
|
}
|
|
6369
6461
|
//#endregion
|
|
6370
|
-
//#region src/commands/project/run-project.ts
|
|
6371
|
-
async function withActivePlatformClient(config, fn) {
|
|
6372
|
-
const platform = createCliPlatformClient(config);
|
|
6373
|
-
let active = await platform.organizations.getActive();
|
|
6374
|
-
if (!active) active = await selectActiveOrganization(config);
|
|
6375
|
-
platform.setActiveOrganizationId(active.organization.id);
|
|
6376
|
-
await fn(platform);
|
|
6377
|
-
}
|
|
6378
|
-
function writeInactiveDeployHints(projects) {
|
|
6379
|
-
const bin = cliBinaryName();
|
|
6380
|
-
for (const project of projects) {
|
|
6381
|
-
if (project.status !== "inactive") continue;
|
|
6382
|
-
process.stderr.write(`Project ${formatProjectLabel(project)} is inactive. Deploy with: ${bin} deploy --project ${formatProjectLabel(project)}\n`);
|
|
6383
|
-
}
|
|
6384
|
-
}
|
|
6385
|
-
async function runProjectList(config) {
|
|
6386
|
-
await withActivePlatformClient(config, async (platform) => {
|
|
6387
|
-
const projects = await platform.projects.list();
|
|
6388
|
-
process.stdout.write(`${JSON.stringify({ projects }, null, 2)}\n`);
|
|
6389
|
-
if (projects.length === 0) {
|
|
6390
|
-
const bin = cliBinaryName();
|
|
6391
|
-
process.stderr.write(`No projects yet. Create one with: ${bin} project create --name "My project"\n`);
|
|
6392
|
-
return;
|
|
6393
|
-
}
|
|
6394
|
-
writeInactiveDeployHints(projects);
|
|
6395
|
-
});
|
|
6396
|
-
}
|
|
6397
|
-
async function runProjectMetrics(config, options) {
|
|
6398
|
-
await withActivePlatformClient(config, async (platform) => {
|
|
6399
|
-
const metrics = await platform.projectMetrics.list();
|
|
6400
|
-
if (options.projectRef === void 0) {
|
|
6401
|
-
process.stdout.write(`${JSON.stringify(metrics, null, 2)}\n`);
|
|
6402
|
-
return;
|
|
6403
|
-
}
|
|
6404
|
-
const project = await resolveProjectRef(platform, options.projectRef);
|
|
6405
|
-
const output = Object.fromEntries(Object.entries(metrics).filter(([projectId]) => projectId === project.id));
|
|
6406
|
-
process.stdout.write(`${JSON.stringify(output, null, 2)}\n`);
|
|
6407
|
-
});
|
|
6408
|
-
}
|
|
6409
|
-
async function runProjectDeploymentsList(config, options) {
|
|
6410
|
-
await withActivePlatformClient(config, async (platform) => {
|
|
6411
|
-
const project = await resolveProjectRef(platform, options.projectRef);
|
|
6412
|
-
const deployments = await platform.deployments.listForProject(project.id);
|
|
6413
|
-
process.stdout.write(`${JSON.stringify({ deployments }, null, 2)}\n`);
|
|
6414
|
-
});
|
|
6415
|
-
}
|
|
6416
|
-
async function runProjectCreate(config, input) {
|
|
6417
|
-
await withActivePlatformClient(config, async (platform) => {
|
|
6418
|
-
const project = await platform.projects.create(input);
|
|
6419
|
-
process.stdout.write(`${JSON.stringify({ project }, null, 2)}\n`);
|
|
6420
|
-
writeInactiveDeployHints([project]);
|
|
6421
|
-
});
|
|
6422
|
-
}
|
|
6423
|
-
async function runProjectUpdate(config, input) {
|
|
6424
|
-
await withActivePlatformClient(config, async (platform) => {
|
|
6425
|
-
const { projectId, ...patch } = input;
|
|
6426
|
-
const project = await platform.projects.update(projectId, patch);
|
|
6427
|
-
process.stdout.write(`${JSON.stringify({ project }, null, 2)}\n`);
|
|
6428
|
-
});
|
|
6429
|
-
}
|
|
6430
|
-
async function runProjectDelete(config, projectId) {
|
|
6431
|
-
await withActivePlatformClient(config, async (platform) => {
|
|
6432
|
-
await platform.projects.delete(projectId);
|
|
6433
|
-
process.stdout.write(`${JSON.stringify({ deleted: projectId }, null, 2)}\n`);
|
|
6434
|
-
});
|
|
6435
|
-
}
|
|
6436
|
-
//#endregion
|
|
6437
6462
|
//#region src/commands/history/run-history.ts
|
|
6438
6463
|
async function runHistoryList(config, filters) {
|
|
6439
6464
|
await withActivePlatformClient(config, async (platform) => {
|
|
@@ -6954,7 +6979,7 @@ async function runStart(options) {
|
|
|
6954
6979
|
const apiPort = Number(new URL(serverUrl).port || 80);
|
|
6955
6980
|
const runtimeNodeModules = resolveCliRuntimeNodeModules(resolveCliRoot(import.meta.url));
|
|
6956
6981
|
ensureNativeDeps(runtimeNodeModules);
|
|
6957
|
-
const { buildApp } = await import("./dist-
|
|
6982
|
+
const { buildApp } = await import("./dist-CzQkL7nN.mjs");
|
|
6958
6983
|
await buildApp({
|
|
6959
6984
|
root,
|
|
6960
6985
|
clean: false
|