@autohq/cli 0.1.83 → 0.1.84

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.
@@ -19605,7 +19605,6 @@ var AuthScopeSchema = external_exports.enum([
19605
19605
  "environments:write",
19606
19606
  "profiles:read",
19607
19607
  "profiles:write",
19608
- "resources:apply_dry_run",
19609
19608
  "runs:read",
19610
19609
  "runs:write",
19611
19610
  "events:write",
@@ -19696,6 +19695,24 @@ var AuthWhoamiResponseSchema = external_exports.object({
19696
19695
  })
19697
19696
  }).optional()
19698
19697
  });
19698
+ var SERVICE_ACCOUNT_READ_ONLY_SCOPES = [
19699
+ "environments:read",
19700
+ "profiles:read",
19701
+ "tools:read",
19702
+ "sessions:read",
19703
+ "runs:read"
19704
+ ];
19705
+ var SERVICE_ACCOUNT_SCOPE_PRESETS = {
19706
+ "read-only": SERVICE_ACCOUNT_READ_ONLY_SCOPES,
19707
+ applier: [
19708
+ ...SERVICE_ACCOUNT_READ_ONLY_SCOPES,
19709
+ "environments:write",
19710
+ "profiles:write",
19711
+ "tools:write",
19712
+ "sessions:write"
19713
+ ]
19714
+ };
19715
+ var ServiceAccountScopePresetSchema = external_exports.enum(["read-only", "applier"]);
19699
19716
 
19700
19717
  // ../../packages/schemas/src/primitives.ts
19701
19718
  var JsonValueSchema2 = external_exports.lazy(
@@ -20867,16 +20884,12 @@ var ProjectServiceAccountSchema = external_exports.object({
20867
20884
  scopes: external_exports.array(AuthScopeSchema),
20868
20885
  createdAt: external_exports.string().datetime()
20869
20886
  });
20870
- var ProjectServiceAccountScopeInputSchema = external_exports.union([
20871
- AuthScopeSchema,
20872
- external_exports.literal("members:none")
20873
- ]);
20874
20887
  var ProjectServiceAccountCreateRequestSchema = external_exports.object({
20875
20888
  name: ResourceNameSchema,
20876
- scopes: external_exports.array(ProjectServiceAccountScopeInputSchema).optional()
20889
+ scopes: external_exports.array(AuthScopeSchema).min(1)
20877
20890
  });
20878
20891
  var ProjectServiceAccountUpdateRequestSchema = external_exports.object({
20879
- scopes: external_exports.array(ProjectServiceAccountScopeInputSchema)
20892
+ scopes: external_exports.array(AuthScopeSchema).min(1)
20880
20893
  });
20881
20894
  var ProjectServiceAccountTokenResponseSchema = external_exports.object({
20882
20895
  serviceAccount: ProjectServiceAccountSchema,
package/dist/index.js CHANGED
@@ -15196,7 +15196,7 @@ var init_ids = __esm({
15196
15196
  });
15197
15197
 
15198
15198
  // ../../packages/schemas/src/auth.ts
15199
- var AuthRoleSchema, AuthIdentityProviderSchema, AuthScopeSchema, AUTH_SCOPES, PrincipalSchema, AuthClientSchema, AuthActorSchema, AuthContextSchema, AuthWhoamiResponseSchema;
15199
+ var AuthRoleSchema, AuthIdentityProviderSchema, AuthScopeSchema, AUTH_SCOPES, PrincipalSchema, AuthClientSchema, AuthActorSchema, AuthContextSchema, AuthWhoamiResponseSchema, SERVICE_ACCOUNT_READ_ONLY_SCOPES, SERVICE_ACCOUNT_SCOPE_PRESETS, ServiceAccountScopePresetSchema;
15200
15200
  var init_auth = __esm({
15201
15201
  "../../packages/schemas/src/auth.ts"() {
15202
15202
  "use strict";
@@ -15213,7 +15213,6 @@ var init_auth = __esm({
15213
15213
  "environments:write",
15214
15214
  "profiles:read",
15215
15215
  "profiles:write",
15216
- "resources:apply_dry_run",
15217
15216
  "runs:read",
15218
15217
  "runs:write",
15219
15218
  "events:write",
@@ -15304,6 +15303,24 @@ var init_auth = __esm({
15304
15303
  })
15305
15304
  }).optional()
15306
15305
  });
15306
+ SERVICE_ACCOUNT_READ_ONLY_SCOPES = [
15307
+ "environments:read",
15308
+ "profiles:read",
15309
+ "tools:read",
15310
+ "sessions:read",
15311
+ "runs:read"
15312
+ ];
15313
+ SERVICE_ACCOUNT_SCOPE_PRESETS = {
15314
+ "read-only": SERVICE_ACCOUNT_READ_ONLY_SCOPES,
15315
+ applier: [
15316
+ ...SERVICE_ACCOUNT_READ_ONLY_SCOPES,
15317
+ "environments:write",
15318
+ "profiles:write",
15319
+ "tools:write",
15320
+ "sessions:write"
15321
+ ]
15322
+ };
15323
+ ServiceAccountScopePresetSchema = external_exports.enum(["read-only", "applier"]);
15307
15324
  }
15308
15325
  });
15309
15326
 
@@ -16646,7 +16663,7 @@ var init_mounts = __esm({
16646
16663
  });
16647
16664
 
16648
16665
  // ../../packages/schemas/src/project-service-accounts.ts
16649
- var ProjectServiceAccountSchema, ProjectServiceAccountScopeInputSchema, ProjectServiceAccountCreateRequestSchema, ProjectServiceAccountUpdateRequestSchema, ProjectServiceAccountTokenResponseSchema, ProjectServiceAccountUpdateResponseSchema, ProjectServiceAccountRemoveResponseSchema, ProjectServiceAccountListResponseSchema;
16666
+ var ProjectServiceAccountSchema, ProjectServiceAccountCreateRequestSchema, ProjectServiceAccountUpdateRequestSchema, ProjectServiceAccountTokenResponseSchema, ProjectServiceAccountUpdateResponseSchema, ProjectServiceAccountRemoveResponseSchema, ProjectServiceAccountListResponseSchema;
16650
16667
  var init_project_service_accounts = __esm({
16651
16668
  "../../packages/schemas/src/project-service-accounts.ts"() {
16652
16669
  "use strict";
@@ -16662,16 +16679,12 @@ var init_project_service_accounts = __esm({
16662
16679
  scopes: external_exports.array(AuthScopeSchema),
16663
16680
  createdAt: external_exports.string().datetime()
16664
16681
  });
16665
- ProjectServiceAccountScopeInputSchema = external_exports.union([
16666
- AuthScopeSchema,
16667
- external_exports.literal("members:none")
16668
- ]);
16669
16682
  ProjectServiceAccountCreateRequestSchema = external_exports.object({
16670
16683
  name: ResourceNameSchema,
16671
- scopes: external_exports.array(ProjectServiceAccountScopeInputSchema).optional()
16684
+ scopes: external_exports.array(AuthScopeSchema).min(1)
16672
16685
  });
16673
16686
  ProjectServiceAccountUpdateRequestSchema = external_exports.object({
16674
- scopes: external_exports.array(ProjectServiceAccountScopeInputSchema)
16687
+ scopes: external_exports.array(AuthScopeSchema).min(1)
16675
16688
  });
16676
16689
  ProjectServiceAccountTokenResponseSchema = external_exports.object({
16677
16690
  serviceAccount: ProjectServiceAccountSchema,
@@ -21114,7 +21127,7 @@ var init_package = __esm({
21114
21127
  "package.json"() {
21115
21128
  package_default = {
21116
21129
  name: "@autohq/cli",
21117
- version: "0.1.83",
21130
+ version: "0.1.84",
21118
21131
  license: "SEE LICENSE IN README.md",
21119
21132
  publishConfig: {
21120
21133
  access: "public"
@@ -23628,7 +23641,11 @@ function useCreateServiceAccount(apiUrl) {
23628
23641
  const client = useApiClient();
23629
23642
  const queryClient = useQueryClient();
23630
23643
  return useMutation({
23631
- mutationFn: (name) => client.createProjectServiceAccount({ name }, { apiBaseUrl: apiUrl }),
23644
+ mutationFn: (name) => client.createProjectServiceAccount(
23645
+ // The TUI has no scope picker yet; mint with the applier preset.
23646
+ { name, scopes: [...SERVICE_ACCOUNT_SCOPE_PRESETS.applier] },
23647
+ { apiBaseUrl: apiUrl }
23648
+ ),
23632
23649
  onSuccess: () => queryClient.invalidateQueries({
23633
23650
  queryKey: queryKeys.serviceAccounts(apiUrl)
23634
23651
  })
@@ -23927,6 +23944,7 @@ var queryKeys, RUNS_REFETCH_INTERVAL_MS;
23927
23944
  var init_queries = __esm({
23928
23945
  "src/tui/hooks/queries.ts"() {
23929
23946
  "use strict";
23947
+ init_src();
23930
23948
  init_ApiClientContext();
23931
23949
  queryKeys = {
23932
23950
  environments: (apiUrl) => ["environments", apiUrl],
@@ -30436,16 +30454,17 @@ function withApiBaseUrl(context, commandOptions) {
30436
30454
  }
30437
30455
 
30438
30456
  // src/commands/service-accounts/actions.ts
30457
+ init_src();
30439
30458
  async function createServiceAccount(input) {
30440
30459
  const response = await input.client.createProjectServiceAccount(
30441
- { name: input.name, scopes: input.commandOptions.scope },
30460
+ { name: input.name, scopes: requestedScopes(input.commandOptions) },
30442
30461
  { apiBaseUrl: input.commandOptions.apiBaseUrl }
30443
30462
  );
30444
30463
  writeServiceAccountTokenResponse(response, input);
30445
30464
  }
30446
30465
  async function updateServiceAccount(input) {
30447
30466
  const response = await input.client.updateProjectServiceAccount(
30448
- { name: input.name, scopes: input.commandOptions.scope ?? [] },
30467
+ { name: input.name, scopes: requestedScopes(input.commandOptions) },
30449
30468
  { apiBaseUrl: input.commandOptions.apiBaseUrl }
30450
30469
  );
30451
30470
  if (input.commandOptions.json) {
@@ -30472,6 +30491,33 @@ async function removeServiceAccount(input) {
30472
30491
  }
30473
30492
  input.writeOutput(`removed service-account ${response.serviceAccount.name}`);
30474
30493
  }
30494
+ function requestedScopes(options) {
30495
+ const presetNames = Object.keys(SERVICE_ACCOUNT_SCOPE_PRESETS).join(", ");
30496
+ const scopes = [];
30497
+ if (options.preset !== void 0) {
30498
+ const preset = ServiceAccountScopePresetSchema.safeParse(options.preset);
30499
+ if (!preset.success) {
30500
+ throw new Error(
30501
+ `Unknown preset "${options.preset}". Available presets: ${presetNames}.`
30502
+ );
30503
+ }
30504
+ scopes.push(...SERVICE_ACCOUNT_SCOPE_PRESETS[preset.data]);
30505
+ }
30506
+ for (const scope of options.scope ?? []) {
30507
+ if (!AuthScopeSchema.safeParse(scope).success) {
30508
+ throw new Error(
30509
+ `Unknown scope "${scope}". Valid scopes: ${AUTH_SCOPES.join(", ")}.`
30510
+ );
30511
+ }
30512
+ scopes.push(scope);
30513
+ }
30514
+ if (scopes.length === 0) {
30515
+ throw new Error(
30516
+ `Provide --preset <preset> (${presetNames}) or at least one --scope.`
30517
+ );
30518
+ }
30519
+ return [...new Set(scopes)];
30520
+ }
30475
30521
  function writeServiceAccountTokenResponse(response, input) {
30476
30522
  if (input.commandOptions.json) {
30477
30523
  input.writeOutput(JSON.stringify(response));
@@ -30494,6 +30540,9 @@ function writeServiceAccountScopesResponse(response, writeOutput) {
30494
30540
  function registerServiceAccountCommands(program, context) {
30495
30541
  const serviceAccount = program.command("service-account").description("Manage Auto project service accounts.");
30496
30542
  serviceAccount.command("create").description("Create a project service account and print its token.").argument("<name>", "service account name").option(
30543
+ "--preset <preset>",
30544
+ "grant a named scope bundle (read-only, applier)"
30545
+ ).option(
30497
30546
  "--scope <scope>",
30498
30547
  "grant a scope; repeat to grant multiple scopes",
30499
30548
  collectScopes
@@ -30507,11 +30556,13 @@ function registerServiceAccountCommands(program, context) {
30507
30556
  });
30508
30557
  }
30509
30558
  );
30510
- serviceAccount.command("update").description("Update project service account scopes.").argument("<name>", "service account name").requiredOption(
30559
+ serviceAccount.command("update").description("Update project service account scopes.").argument("<name>", "service account name").option(
30560
+ "--preset <preset>",
30561
+ "grant a named scope bundle (read-only, applier)"
30562
+ ).option(
30511
30563
  "--scope <scope>",
30512
30564
  "grant a scope; repeat to grant multiple scopes",
30513
- collectScopes,
30514
- []
30565
+ collectScopes
30515
30566
  ).option("--json", "print the updated service account as JSON").option("--api-url <url>", "Auto API base URL").option("--api-base-url <url>", "Auto API base URL").action(
30516
30567
  async (name, commandOptions) => {
30517
30568
  await updateServiceAccount({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.83",
3
+ "version": "0.1.84",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"