@altertable/cli 1.6.2 → 1.7.0

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.
Files changed (2) hide show
  1. package/dist/cli.js +1060 -231
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -7035,7 +7035,7 @@ var require_public_api = __commonJS(function(exports) {
7035
7035
  });
7036
7036
 
7037
7037
  // src/version.ts
7038
- var VERSION = "1.6.2";
7038
+ var VERSION = "1.7.0";
7039
7039
  var USER_AGENT = `altertable-cli/${VERSION}`;
7040
7040
 
7041
7041
  // src/lib/transport-defaults.ts
@@ -7097,6 +7097,12 @@ class CliError extends Error {
7097
7097
  }
7098
7098
  }
7099
7099
  }
7100
+ function assertRetrieved(value, operation, path) {
7101
+ if (value === undefined || value === null || value === "") {
7102
+ throw new CliError(`${operation} failed: assertion failed retrieving ${path}`);
7103
+ }
7104
+ return value;
7105
+ }
7100
7106
 
7101
7107
  class ConfigurationError extends CliError {
7102
7108
  constructor(message, options = {}) {
@@ -7142,7 +7148,7 @@ class HttpError extends CliError {
7142
7148
  constructor(options) {
7143
7149
  super(`Request failed with status ${options.status}.`, {
7144
7150
  exitCode: options.exitCode ?? httpStatusExitCode(options.status),
7145
- details: options.parsedDetail
7151
+ details: options.detailsOverride ?? options.parsedDetail
7146
7152
  });
7147
7153
  this.name = "HttpError";
7148
7154
  this.status = options.status;
@@ -7151,7 +7157,7 @@ class HttpError extends CliError {
7151
7157
  this.url = options.url;
7152
7158
  this.parsedDetail = options.parsedDetail;
7153
7159
  this.retryAfterHeader = options.retryAfterHeader;
7154
- this.message = httpStatusMessage(options.status, options.authPlane);
7160
+ this.message = options.messageOverride ?? httpStatusMessage(options.status, options.authPlane);
7155
7161
  }
7156
7162
  }
7157
7163
 
@@ -10192,13 +10198,11 @@ async function runLoginFlow(sink, oauthBase) {
10192
10198
  const server = await startLoopbackServer(state);
10193
10199
  try {
10194
10200
  const authorizeUrl = buildAuthorizeUrl({ redirectUri: server.redirectUri, challenge, state }, oauthBase);
10195
- sink.writeMetadata([renderDisplayText([span("Opening your browser to sign in\u2026", "subtle")])]);
10196
- sink.writeMetadata([
10197
- renderDisplayText([
10198
- span("If it doesn't open, visit: ", "subtle"),
10199
- span(authorizeUrl, "accent", authorizeUrl)
10200
- ])
10201
- ]);
10201
+ sink.writeHuman(renderDisplayText([span("Opening your browser to sign in\u2026", "subtle")]));
10202
+ sink.writeHuman(renderDisplayText([
10203
+ span("If it doesn't open, visit: ", "subtle"),
10204
+ span(authorizeUrl, "accent", authorizeUrl)
10205
+ ]));
10202
10206
  openBrowser(authorizeUrl);
10203
10207
  const code = await server.waitForCode();
10204
10208
  return await exchangeCode({ code, redirectUri: server.redirectUri, verifier }, oauthBase);
@@ -10775,6 +10779,17 @@ function deriveProfileName(org, env) {
10775
10779
  assertSafeProfileName(profileName);
10776
10780
  return profileName;
10777
10781
  }
10782
+ function deriveServiceAccountProfileName(org, env, serviceAccountSlug) {
10783
+ const orgPart = normalizeProfileNamePart(org);
10784
+ const envPart = normalizeProfileNamePart(env);
10785
+ const slugPart = normalizeProfileNamePart(serviceAccountSlug);
10786
+ if (!orgPart || !envPart || !slugPart) {
10787
+ throw new ConfigurationError("Profile auto-naming requires non-empty organization, environment, and service account values.");
10788
+ }
10789
+ const profileName = `${orgPart}_${envPart}_${slugPart}`;
10790
+ assertSafeProfileName(profileName);
10791
+ return profileName;
10792
+ }
10778
10793
  function nowIso() {
10779
10794
  return new Date().toISOString();
10780
10795
  }
@@ -11280,13 +11295,131 @@ function lakehousePlaneStatusDetail(profileName) {
11280
11295
  return configGet("user", profileName) || "unknown";
11281
11296
  }
11282
11297
 
11298
+ // src/lib/parse-api-json.ts
11299
+ function parseApiJson(body) {
11300
+ try {
11301
+ return JSON.parse(body);
11302
+ } catch {
11303
+ throw new ParseError("Response body is not valid JSON.", {
11304
+ details: truncateBodySnippet(body)
11305
+ });
11306
+ }
11307
+ }
11308
+
11309
+ // src/lib/service-account-provision.ts
11310
+ function parseServiceAccountScope(value) {
11311
+ const bareMode = value.trim().toLowerCase();
11312
+ if (bareMode === "ro" || bareMode === "rw") {
11313
+ return bareMode;
11314
+ }
11315
+ const scope = {};
11316
+ for (const rawEntry of value.split(",")) {
11317
+ const entry = rawEntry.trim();
11318
+ const separatorIndex = entry.lastIndexOf(":");
11319
+ if (separatorIndex === -1) {
11320
+ throw new ConfigurationError(`Invalid --scope entry "${entry}": expected ro, rw, catalog:ro or catalog:rw.`);
11321
+ }
11322
+ const catalog = entry.slice(0, separatorIndex).trim();
11323
+ const mode = entry.slice(separatorIndex + 1).trim().toLowerCase();
11324
+ if (!catalog) {
11325
+ throw new ConfigurationError(`Invalid --scope entry "${entry}": catalog name is required.`);
11326
+ }
11327
+ if (mode !== "ro" && mode !== "rw") {
11328
+ throw new ConfigurationError(`Invalid --scope entry "${entry}": mode must be ro or rw.`);
11329
+ }
11330
+ if (scope[catalog] !== undefined) {
11331
+ throw new ConfigurationError(`Invalid --scope entry "${entry}": catalog "${catalog}" is duplicated.`);
11332
+ }
11333
+ scope[catalog] = mode;
11334
+ }
11335
+ return scope;
11336
+ }
11337
+ function withServiceAccountRequestContext(error) {
11338
+ if (!(error instanceof HttpError)) {
11339
+ return error;
11340
+ }
11341
+ const request = `${error.method} ${error.url}`;
11342
+ return new HttpError({
11343
+ status: error.status,
11344
+ body: error.body,
11345
+ method: error.method,
11346
+ url: error.url,
11347
+ parsedDetail: error.parsedDetail ?? request,
11348
+ detailsOverride: error.details ? `${error.details}
11349
+ ${request}` : request,
11350
+ messageOverride: `Failed to create environment service account: ${error.message}`,
11351
+ exitCode: error.exitCode,
11352
+ retryAfterHeader: error.retryAfterHeader
11353
+ });
11354
+ }
11355
+ async function provisionEnvironmentServiceAccount(options) {
11356
+ const requestBody = {
11357
+ label: options.label,
11358
+ with_service_oauth_token: true
11359
+ };
11360
+ if (options.scope) {
11361
+ requestBody.caveats = options.scope;
11362
+ }
11363
+ let response;
11364
+ try {
11365
+ response = await httpSend({
11366
+ method: "POST",
11367
+ url: `${options.managementApiBase}${encodeManagementEndpoint(`/environments/${options.environment}/service_accounts`)}`,
11368
+ authHeader: `Authorization: Bearer ${options.accessToken}`,
11369
+ body: JSON.stringify(requestBody),
11370
+ contentType: "application/json",
11371
+ authPlane: "management"
11372
+ });
11373
+ } catch (error) {
11374
+ throw withServiceAccountRequestContext(error);
11375
+ }
11376
+ const created = parseApiJson(response);
11377
+ const token = assertRetrieved(created.service_oauth_token, "login", "service_account.service_oauth_token");
11378
+ assertRetrieved(created.service_account?.slug, "login", "service_account.slug");
11379
+ return { ...created, service_oauth_token: token };
11380
+ }
11381
+ function collectCatalogs(target, entries) {
11382
+ for (const entry of entries) {
11383
+ if (!entry.id || !entry.name && !entry.slug) {
11384
+ continue;
11385
+ }
11386
+ target.set(entry.id, {
11387
+ name: entry.name ?? entry.slug ?? "",
11388
+ slug: entry.slug ?? ""
11389
+ });
11390
+ }
11391
+ }
11392
+ async function fetchEnvironmentCatalogs(options) {
11393
+ const catalogs = new Map;
11394
+ for (const kind of ["databases", "connections"]) {
11395
+ try {
11396
+ const response = await httpSend({
11397
+ method: "GET",
11398
+ url: `${options.managementApiBase}${encodeManagementEndpoint(`/environments/${options.environment}/${kind}`)}`,
11399
+ authHeader: `Authorization: Bearer ${options.accessToken}`,
11400
+ authPlane: "management"
11401
+ });
11402
+ const parsed = parseApiJson(response);
11403
+ collectCatalogs(catalogs, parsed[kind] ?? []);
11404
+ } catch {
11405
+ continue;
11406
+ }
11407
+ }
11408
+ return catalogs;
11409
+ }
11410
+
11283
11411
  // src/commands/login/index.ts
11284
11412
  var loginCommand = defineCommand({
11285
11413
  metadata: {
11286
11414
  name: "login",
11287
11415
  commandGroup: "platform",
11288
11416
  description: "Sign in with your browser (OAuth) and store the session.",
11289
- examples: ["altertable login", "altertable login --replace-profile"]
11417
+ examples: [
11418
+ "altertable login",
11419
+ "altertable login --replace-profile",
11420
+ 'altertable login --service-account "CI Bot" --scope analytics:ro',
11421
+ 'altertable login --service-account "CI Bot" --scope ro'
11422
+ ]
11290
11423
  },
11291
11424
  args: {
11292
11425
  "control-plane-url": {
@@ -11304,6 +11437,16 @@ var loginCommand = defineCommand({
11304
11437
  "replace-profile": {
11305
11438
  type: "boolean",
11306
11439
  description: "Store the login session in the current profile instead of switching profiles"
11440
+ },
11441
+ "service-account": {
11442
+ type: "string",
11443
+ valueHint: "LABEL",
11444
+ description: "Create an environment-scoped service account with this label and store its access token instead of your login session"
11445
+ },
11446
+ scope: {
11447
+ type: "string",
11448
+ valueHint: "MODE|CATALOG:MODE,...",
11449
+ description: "Request a service account limited to `ro` or `rw` on every catalog, or to specific catalogs, e.g. `analytics:ro,staging:rw` (requires --service-account). The catalog access the server actually grants is reported on success."
11307
11450
  }
11308
11451
  },
11309
11452
  run: ({ args, sink }) => runLogin(args, sink)
@@ -11353,25 +11496,20 @@ function selectLoginProfile(whoami, environment, replaceCurrentProfile) {
11353
11496
  refreshCliRuntimeContext(getCliContext());
11354
11497
  return { profileName: targetProfile, profileAction };
11355
11498
  }
11499
+ function requireWhoamiEnvironment(whoami) {
11500
+ return assertRetrieved(whoami.environment_slug, "login", "whoami.environment_slug");
11501
+ }
11356
11502
  function storeLoginProfileMetadata(whoami, args, controlPlane) {
11357
- const environment = whoami.environment_slug;
11358
- if (!environment) {
11359
- throw new Error("No environment returned from `whoami` post-login. Aborting.");
11360
- }
11503
+ const environment = requireWhoamiEnvironment(whoami);
11361
11504
  const { profileName, profileAction } = selectLoginProfile(whoami, environment, Boolean(args["replace-profile"]));
11362
- if (args["data-plane-url"]) {
11363
- assertAllowedApiBase(args["data-plane-url"], {
11364
- allowInsecureHttp: Boolean(args["allow-insecure-http"])
11365
- });
11366
- }
11367
11505
  updateProfile(profileName, {
11368
11506
  environment,
11369
11507
  organizationSlug: whoami.organization?.slug,
11370
11508
  organizationName: whoami.organization?.name,
11371
11509
  principalType: whoami.principal?.type,
11372
11510
  principalName: whoami.principal?.name,
11373
- principalEmail: whoami.principal?.email,
11374
- principalSlug: whoami.principal?.slug,
11511
+ principalEmail: whoami.principal?.email ?? undefined,
11512
+ principalSlug: whoami.principal?.slug ?? undefined,
11375
11513
  ...args["data-plane-url"] ? { dataPlane: args["data-plane-url"] } : {},
11376
11514
  controlPlane
11377
11515
  });
@@ -11398,28 +11536,159 @@ async function fetchLoginWhoami(oauthResponse, managementApiBase) {
11398
11536
  });
11399
11537
  return JSON.parse(body);
11400
11538
  }
11539
+ function applyLoginDataPlaneUrl(args) {
11540
+ if (args["data-plane-url"]) {
11541
+ assertAllowedApiBase(args["data-plane-url"], {
11542
+ allowInsecureHttp: Boolean(args["allow-insecure-http"])
11543
+ });
11544
+ }
11545
+ }
11546
+ function parseServiceAccountLoginArgs(args) {
11547
+ const label = args["service-account"];
11548
+ if (args.scope !== undefined && label === undefined) {
11549
+ throw new ConfigurationError("--scope requires --service-account.");
11550
+ }
11551
+ if (label === undefined) {
11552
+ return;
11553
+ }
11554
+ if (args["replace-profile"]) {
11555
+ throw new ConfigurationError("--service-account cannot be combined with --replace-profile; a service account always gets its own profile.");
11556
+ }
11557
+ if (label.trim().length === 0) {
11558
+ throw new ConfigurationError("--service-account requires a non-empty label.");
11559
+ }
11560
+ return {
11561
+ label: label.trim(),
11562
+ ...args.scope === undefined ? {} : { scope: parseServiceAccountScope(args.scope) }
11563
+ };
11564
+ }
11565
+ function activateDerivedProfile(profileName) {
11566
+ if (!profileExists(profileName)) {
11567
+ createEmptyProfile(profileName);
11568
+ }
11569
+ setActiveProfile(profileName);
11570
+ setCliContext({ ...getCliContext(), profile: profileName });
11571
+ refreshCliRuntimeContext(getCliContext());
11572
+ }
11573
+ function catalogAccessMode(assignment) {
11574
+ if (assignment.role === "catalog:writer")
11575
+ return "rw";
11576
+ if (assignment.role === "catalog:reader")
11577
+ return "ro";
11578
+ return null;
11579
+ }
11580
+ function summarizeCatalogAccess(created, catalogs) {
11581
+ const rows = new Map;
11582
+ for (const assignment of created.role_assignments ?? []) {
11583
+ const access = catalogAccessMode(assignment);
11584
+ const catalog = catalogs.get(assignment.resource_id);
11585
+ if (!access || !catalog)
11586
+ continue;
11587
+ const existing = rows.get(assignment.resource_id);
11588
+ if (!existing || access === "rw") {
11589
+ rows.set(assignment.resource_id, { ...catalog, access });
11590
+ }
11591
+ }
11592
+ return [...rows.values()].sort((a, b) => a.name.localeCompare(b.name));
11593
+ }
11594
+ function formatCatalogAccessTable(rows) {
11595
+ return renderDocumentText(document(section(table({
11596
+ rows,
11597
+ columns: [
11598
+ { header: "CATALOG", cell: (row) => [span(row.name, "strong")], flex: true },
11599
+ { header: "SLUG", cell: (row) => [span(row.slug, "accent")] },
11600
+ { header: "ACCESS", cell: (row) => [span(row.access, "subtle")] }
11601
+ ],
11602
+ emptyMessage: ""
11603
+ }))));
11604
+ }
11605
+ async function completeServiceAccountLogin(oauthResponse, whoami, args, controlPlane, managementApiBase, request, sink) {
11606
+ const environment = requireWhoamiEnvironment(whoami);
11607
+ const organizationSlug = assertRetrieved(whoami.organization?.slug, "login", "whoami.organization.slug");
11608
+ const created = await provisionEnvironmentServiceAccount({
11609
+ managementApiBase,
11610
+ accessToken: oauthResponse.access_token,
11611
+ environment,
11612
+ label: request.label,
11613
+ ...request.scope ? { scope: request.scope } : {}
11614
+ });
11615
+ const profileName = deriveServiceAccountProfileName(organizationSlug, environment, created.service_account.slug);
11616
+ activateDerivedProfile(profileName);
11617
+ updateProfile(profileName, {
11618
+ environment,
11619
+ organizationSlug,
11620
+ organizationName: whoami.organization?.name,
11621
+ principalType: "ServiceAccount",
11622
+ principalName: created.service_account.label,
11623
+ principalSlug: created.service_account.slug,
11624
+ ...args["data-plane-url"] ? { dataPlane: args["data-plane-url"] } : {},
11625
+ controlPlane
11626
+ });
11627
+ secretSet("oauth/access-token", created.service_oauth_token, profileName);
11628
+ const catalogs = await fetchEnvironmentCatalogs({
11629
+ managementApiBase,
11630
+ accessToken: oauthResponse.access_token,
11631
+ environment
11632
+ });
11633
+ const catalogAccess = summarizeCatalogAccess(created, catalogs);
11634
+ const lines = [
11635
+ renderDisplayText([
11636
+ span("\u2713", "success"),
11637
+ span(` Created service account "${created.service_account.label}" \u2014 profile "${profileName}" is now active; environment "${environment}".`)
11638
+ ])
11639
+ ];
11640
+ if (catalogAccess.length > 0) {
11641
+ lines.push("", renderDisplayText([span("Catalog access", "subtle")]));
11642
+ lines.push(formatCatalogAccessTable(catalogAccess));
11643
+ }
11644
+ if (request.scope && (created.role_assignments ?? []).length === 0) {
11645
+ lines.push(renderDisplayText([
11646
+ span("! The server reported no role assignments, so the requested restriction could not be confirmed. Check the service account's access before using this token.", "warning")
11647
+ ]));
11648
+ }
11649
+ for (const line of lines) {
11650
+ sink.writeHuman(line);
11651
+ }
11652
+ }
11401
11653
  async function runLogin(args, sink) {
11654
+ const serviceAccountRequest = parseServiceAccountLoginArgs(args);
11655
+ applyLoginDataPlaneUrl(args);
11402
11656
  assertNoEnvConfigMode();
11403
11657
  assertInteractiveLogin();
11404
11658
  const currentProfile = resolveWorkingProfile(getCliContext().profile);
11405
11659
  const { controlPlane, oauthBase, managementApiBase } = resolveLoginEndpoints(args, currentProfile);
11406
11660
  const oauthResponse = await runLoginFlow(sink, oauthBase);
11407
11661
  const whoami = await fetchLoginWhoami(oauthResponse, managementApiBase);
11662
+ if (serviceAccountRequest) {
11663
+ await completeServiceAccountLogin(oauthResponse, whoami, args, controlPlane, managementApiBase, serviceAccountRequest, sink);
11664
+ return;
11665
+ }
11408
11666
  const { environment, profileName, profileAction } = storeLoginProfileMetadata(whoami, args, controlPlane);
11409
11667
  storeOAuthTokens(oauthResponse, profileName);
11410
11668
  refreshCliRuntimeContext(getCliContext());
11411
11669
  const identity = formatWhoamiPrincipalLine(whoami);
11412
11670
  const profileMessage = `${LOGIN_PROFILE_MESSAGES[profileAction]} "${profileName}"`;
11413
- sink.writeMetadata([
11414
- renderDisplayText([
11415
- span("\u2713", "success"),
11416
- span(` Logged in (${identity}) \u2014 ${profileMessage}; environment "${environment}".`)
11417
- ])
11418
- ]);
11671
+ sink.writeHuman(renderDisplayText([
11672
+ span("\u2713", "success"),
11673
+ span(` Logged in (${identity}) \u2014 ${profileMessage}; environment "${environment}".`)
11674
+ ]));
11419
11675
  }
11420
11676
 
11421
11677
  // src/lib/profile-configure-core.ts
11422
11678
  import { unlinkSync, rmSync as rmSync3, existsSync as existsSync4 } from "fs";
11679
+
11680
+ // src/lib/pluralize.ts
11681
+ function pluralize(count, singular, plural) {
11682
+ if (count === 1) {
11683
+ return singular;
11684
+ }
11685
+ return plural ?? `${singular}s`;
11686
+ }
11687
+ function pluralizeLabel(count, singular, plural) {
11688
+ return `${count} ${pluralize(count, singular, plural)}`;
11689
+ }
11690
+
11691
+ // src/lib/profile-configure-core.ts
11423
11692
  var ARGV_SECRET_WARNING = "Warning: passing secrets on the command line is visible in process listings. Prefer --password-stdin / --api-key-stdin.";
11424
11693
  var AUTO_PROFILE_NAME = "auto";
11425
11694
  function markCurrentProfileUpdated(profileName) {
@@ -11476,7 +11745,7 @@ async function configureRunSet(options, sink = getOutputSink(), org = "") {
11476
11745
  const passwordFromArgv = Boolean(options.password) && !options.passwordStdin && !options.interactive;
11477
11746
  const apiKeyFromArgv = Boolean(options.apiKey) && !options.apiKeyStdin && !options.interactive;
11478
11747
  if (passwordFromArgv || apiKeyFromArgv) {
11479
- sink.writeMetadata([renderDisplayText([span(ARGV_SECRET_WARNING, "subtle")])]);
11748
+ sink.writeHuman(renderDisplayText([span(ARGV_SECRET_WARNING, "subtle")]));
11480
11749
  }
11481
11750
  const hasAnyInput = user || password || basicToken || apiKey || env || options.passwordStdin || options.apiKeyStdin || dataPlaneUrl || controlPlaneUrl;
11482
11751
  if (!hasAnyInput) {
@@ -11543,24 +11812,36 @@ async function configureRunSet(options, sink = getOutputSink(), org = "") {
11543
11812
  clearProfileEndpoint("management_api_base", profileName);
11544
11813
  }
11545
11814
  if (hasApiKey) {
11546
- sink.writeMetadata([
11547
- renderDisplayText([span(`Saved management API key for environment ${env}.`, "subtle")])
11548
- ]);
11815
+ sink.writeHuman(renderDisplayText([span(`Saved management API key for environment ${env}.`, "subtle")]));
11549
11816
  } else if (hasLakehouseBasicToken) {
11550
- sink.writeMetadata([renderDisplayText([span("Saved lakehouse Basic token.", "subtle")])]);
11817
+ sink.writeHuman(renderDisplayText([span("Saved lakehouse Basic token.", "subtle")]));
11551
11818
  } else if (hasLakehouseCredentials) {
11552
- sink.writeMetadata([
11553
- renderDisplayText([span(`Saved lakehouse credentials for user ${user}.`, "subtle")])
11554
- ]);
11819
+ sink.writeHuman(renderDisplayText([span(`Saved lakehouse credentials for user ${user}.`, "subtle")]));
11555
11820
  } else if (dataPlaneUrl) {
11556
- sink.writeMetadata([
11557
- renderDisplayText([span(`Saved data plane URL ${dataPlaneUrl}.`, "subtle")])
11558
- ]);
11821
+ sink.writeHuman(renderDisplayText([span(`Saved data plane URL ${dataPlaneUrl}.`, "subtle")]));
11559
11822
  }
11560
11823
  markCurrentProfileUpdated(profileName);
11561
11824
  });
11562
11825
  }
11563
- function configureRunClear(sink = getOutputSink()) {
11826
+ function configureClearExceptCurrent(sink) {
11827
+ const keptProfile = resolveWorkingProfile(getCliContext().profile);
11828
+ ensureProfileExists(keptProfile);
11829
+ if (getActiveProfileName() !== keptProfile) {
11830
+ setActiveProfile(keptProfile);
11831
+ }
11832
+ const removed = listProfileNames().filter((name) => name !== keptProfile);
11833
+ for (const name of removed) {
11834
+ deleteProfile(name);
11835
+ }
11836
+ getCliRuntime().session = undefined;
11837
+ const summary = removed.length === 0 ? `No other profiles to clear; kept "${keptProfile}".` : `Cleared ${pluralizeLabel(removed.length, "profile")}; kept "${keptProfile}".`;
11838
+ sink.writeHuman(renderDisplayText([span(summary, "subtle")]));
11839
+ }
11840
+ function configureRunClear(sink = getOutputSink(), options = {}) {
11841
+ if (options.exceptCurrent) {
11842
+ configureClearExceptCurrent(sink);
11843
+ return;
11844
+ }
11564
11845
  const profiles = existsSync4(profilesDir()) ? listProfiles() : [];
11565
11846
  for (const profile of profiles) {
11566
11847
  configureClearLakehouseCredentials(profile.name);
@@ -11585,9 +11866,7 @@ function configureRunClear(sink = getOutputSink()) {
11585
11866
  });
11586
11867
  }
11587
11868
  getCliRuntime().session = undefined;
11588
- sink.writeMetadata([
11589
- renderDisplayText([span("Cleared all altertable configuration.", "subtle")])
11590
- ]);
11869
+ sink.writeHuman(renderDisplayText([span("Cleared all altertable configuration.", "subtle")]));
11591
11870
  }
11592
11871
 
11593
11872
  // src/commands/logout/index.ts
@@ -11596,11 +11875,17 @@ var logoutCommand = defineCommand({
11596
11875
  name: "logout",
11597
11876
  commandGroup: "platform",
11598
11877
  description: "Remove stored credentials and settings for all profiles.",
11599
- examples: ["altertable logout"]
11878
+ examples: ["altertable logout", "altertable logout --except-current"]
11879
+ },
11880
+ args: {
11881
+ "except-current": {
11882
+ type: "boolean",
11883
+ description: "Keep the current profile and remove every other profile"
11884
+ }
11600
11885
  },
11601
- run({ sink }) {
11886
+ run({ args, sink }) {
11602
11887
  assertNoEnvConfigMode();
11603
- configureRunClear(sink);
11888
+ configureRunClear(sink, { exceptCurrent: Boolean(args["except-current"]) });
11604
11889
  }
11605
11890
  });
11606
11891
 
@@ -11948,20 +12233,18 @@ function requireManagementPlane(profileName, options) {
11948
12233
  throw new ConfigurationError(`${options.requirement}, but the management plane is not configured. ${remediation}${alternative}.`);
11949
12234
  }
11950
12235
 
11951
- // src/lib/parse-api-json.ts
11952
- function parseApiJson(body) {
11953
- try {
11954
- return JSON.parse(body);
11955
- } catch {
11956
- throw new ParseError("Response body is not valid JSON.", {
11957
- details: truncateBodySnippet(body)
11958
- });
11959
- }
11960
- }
11961
-
11962
12236
  // src/lib/lakehouse-provision.ts
11963
12237
  var CREDENTIAL_LABEL = USER_AGENT;
11964
12238
  var CREDENTIAL_TTL_MS = 2 * 60 * 60 * 1000;
12239
+ var PRINCIPAL_CREDENTIAL_COLLECTIONS = {
12240
+ User: "users",
12241
+ ServiceAccount: "service_accounts"
12242
+ };
12243
+ function principalCredentialCollection(principalType) {
12244
+ if (principalType === undefined || !Object.hasOwn(PRINCIPAL_CREDENTIAL_COLLECTIONS, principalType))
12245
+ return;
12246
+ return PRINCIPAL_CREDENTIAL_COLLECTIONS[principalType];
12247
+ }
11965
12248
  function hasManagementCredentials(profileName) {
11966
12249
  return optionalAuth(() => getManagementAuthHeader(profileName)) !== undefined;
11967
12250
  }
@@ -11992,11 +12275,12 @@ async function provisionLakehouseCredential(context) {
11992
12275
  const env = requireManagementEnv(context.profile);
11993
12276
  const whoami = await sendManagementRequest(context, "GET", "/whoami");
11994
12277
  const principal = whoami.principal;
11995
- if (!principal?.id || principal.type !== "User") {
11996
- throw new ConfigurationError("Cannot auto-create lakehouse credentials for a non-user identity. Run 'altertable profile configure'.");
12278
+ const principalCollection = principalCredentialCollection(principal?.type);
12279
+ if (!principal?.id || !principalCollection) {
12280
+ throw new ConfigurationError("Cannot auto-create lakehouse credentials for this identity. Run 'altertable profile configure'.");
11997
12281
  }
11998
12282
  const expiresAt = new Date(Date.now() + CREDENTIAL_TTL_MS).toISOString();
11999
- const created = await sendManagementRequest(context, "POST", `/users/${principal.id}/environments/${env}/credentials`, JSON.stringify({ label: CREDENTIAL_LABEL, expires_at: expiresAt }));
12283
+ const created = await sendManagementRequest(context, "POST", `/${principalCollection}/${principal.id}/environments/${env}/credentials`, JSON.stringify({ label: CREDENTIAL_LABEL, expires_at: expiresAt }));
12000
12284
  const username = created.credential?.username;
12001
12285
  const password = created.password;
12002
12286
  if (!username || !password) {
@@ -14237,17 +14521,6 @@ function selectDisplayColumnNames(allNames, options) {
14237
14521
  return { columns: allNames };
14238
14522
  }
14239
14523
 
14240
- // src/lib/pluralize.ts
14241
- function pluralize(count, singular, plural) {
14242
- if (count === 1) {
14243
- return singular;
14244
- }
14245
- return plural ?? `${singular}s`;
14246
- }
14247
- function pluralizeLabel(count, singular, plural) {
14248
- return `${count} ${pluralize(count, singular, plural)}`;
14249
- }
14250
-
14251
14524
  // src/lib/relative-time.ts
14252
14525
  var SECOND_MS = 1000;
14253
14526
  var MINUTE_MS = 60 * SECOND_MS;
@@ -16716,9 +16989,13 @@ components:
16716
16989
  slug:
16717
16990
  type: string
16718
16991
  region:
16719
- type: string
16992
+ anyOf:
16993
+ - type: string
16994
+ - type: "null"
16720
16995
  endpoint:
16721
- type: string
16996
+ anyOf:
16997
+ - type: string
16998
+ - type: "null"
16722
16999
  provider:
16723
17000
  type: string
16724
17001
  enum:
@@ -16774,22 +17051,25 @@ components:
16774
17051
  type: string
16775
17052
  enum:
16776
17053
  - postgres
16777
- - bigquery
17054
+ - big_query
16778
17055
  - redshift
16779
17056
  - snowflake
16780
17057
  - mariadb
16781
17058
  - mysql
16782
17059
  - supabase
16783
- - buckettables
16784
- - icebergtables
16785
- - r2catalog
16786
- - s3tables
17060
+ - bucket_tables
17061
+ - iceberg_tables
17062
+ - r2_catalog
17063
+ - s3_tables
16787
17064
  - glue
16788
17065
  - duckdb
17066
+ - mongo
16789
17067
  read_only:
16790
17068
  type: boolean
16791
17069
  description:
16792
- type: string
17070
+ anyOf:
17071
+ - type: string
17072
+ - type: "null"
16793
17073
  labels:
16794
17074
  type: array
16795
17075
  items:
@@ -16804,6 +17084,11 @@ components:
16804
17084
  updated_at:
16805
17085
  type: string
16806
17086
  format: date-time
17087
+ config:
17088
+ anyOf:
17089
+ - type: object
17090
+ additionalProperties: {}
17091
+ - type: "null"
16807
17092
  required:
16808
17093
  - id
16809
17094
  - name
@@ -16819,94 +17104,212 @@ components:
16819
17104
  type: object
16820
17105
  properties:
16821
17106
  dataset:
16822
- type: string
17107
+ anyOf:
17108
+ - type: string
17109
+ - type: "null"
16823
17110
  project_id_override:
16824
- type: string
17111
+ anyOf:
17112
+ - type: string
17113
+ - type: "null"
16825
17114
  ConnectionBucketTablesConfig:
16826
17115
  type: object
16827
17116
  properties:
16828
17117
  bucket_id:
16829
- type: string
17118
+ anyOf:
17119
+ - type: string
17120
+ - type: "null"
16830
17121
  file_format:
16831
- type: string
16832
- enum:
16833
- - parquet
16834
- - csv
16835
- - json
17122
+ anyOf:
17123
+ - type: string
17124
+ enum:
17125
+ - parquet
17126
+ - csv
17127
+ - json
17128
+ - type: "null"
16836
17129
  assume_immutable:
16837
- type: boolean
16838
- tables: {}
17130
+ anyOf:
17131
+ - type: boolean
17132
+ - type: "null"
17133
+ tables:
17134
+ type: object
17135
+ additionalProperties:
17136
+ type: string
16839
17137
  required:
16840
17138
  - tables
16841
17139
  ConnectionDuckDBConfig:
16842
17140
  type: object
16843
17141
  properties:
16844
17142
  bucket_id:
16845
- type: string
17143
+ anyOf:
17144
+ - type: string
17145
+ - type: "null"
16846
17146
  path:
16847
- type: string
17147
+ anyOf:
17148
+ - type: string
17149
+ - type: "null"
16848
17150
  ConnectionGlueConfig:
16849
17151
  type: object
16850
17152
  properties:
16851
17153
  warehouse:
16852
- type: string
17154
+ anyOf:
17155
+ - type: string
17156
+ - type: "null"
16853
17157
  default_region:
16854
- type: string
17158
+ anyOf:
17159
+ - type: string
17160
+ - type: "null"
16855
17161
  role_arn:
16856
- type: string
17162
+ anyOf:
17163
+ - type: string
17164
+ - type: "null"
16857
17165
  ConnectionIcebergTablesConfig:
16858
17166
  type: object
16859
17167
  properties:
16860
17168
  bucket_id:
16861
- type: string
16862
- tables: {}
17169
+ anyOf:
17170
+ - type: string
17171
+ - type: "null"
17172
+ tables:
17173
+ type: object
17174
+ additionalProperties:
17175
+ type: string
16863
17176
  required:
16864
17177
  - tables
17178
+ ConnectionMongoConfig:
17179
+ type: object
17180
+ properties:
17181
+ host:
17182
+ anyOf:
17183
+ - type: string
17184
+ - type: "null"
17185
+ port:
17186
+ anyOf:
17187
+ - type: integer
17188
+ - type: "null"
17189
+ database:
17190
+ anyOf:
17191
+ - type: string
17192
+ - type: "null"
17193
+ username:
17194
+ anyOf:
17195
+ - type: string
17196
+ - type: "null"
17197
+ password:
17198
+ anyOf:
17199
+ - type: string
17200
+ - type: "null"
17201
+ ssh_tunnel:
17202
+ anyOf:
17203
+ - "$ref": "#/components/schemas/ConnectionSshTunnel"
17204
+ - type: "null"
17205
+ srv:
17206
+ anyOf:
17207
+ - type: boolean
17208
+ - type: "null"
17209
+ tls:
17210
+ anyOf:
17211
+ - type: boolean
17212
+ - type: "null"
17213
+ auth_source:
17214
+ anyOf:
17215
+ - type: string
17216
+ - type: "null"
16865
17217
  ConnectionMysqlConfig:
16866
17218
  type: object
16867
17219
  properties:
16868
17220
  host:
16869
- type: string
17221
+ anyOf:
17222
+ - type: string
17223
+ - type: "null"
16870
17224
  port:
16871
- type: integer
17225
+ anyOf:
17226
+ - type: integer
17227
+ - type: "null"
16872
17228
  database:
16873
- type: string
17229
+ anyOf:
17230
+ - type: string
17231
+ - type: "null"
16874
17232
  username:
16875
- type: string
17233
+ anyOf:
17234
+ - type: string
17235
+ - type: "null"
16876
17236
  password:
16877
- type: string
17237
+ anyOf:
17238
+ - type: string
17239
+ - type: "null"
16878
17240
  schema:
16879
- type: string
17241
+ anyOf:
17242
+ - type: string
17243
+ - type: "null"
16880
17244
  ssh_tunnel:
16881
- "$ref": "#/components/schemas/ConnectionSshTunnel"
17245
+ anyOf:
17246
+ - "$ref": "#/components/schemas/ConnectionSshTunnel"
17247
+ - type: "null"
17248
+ ssl_mode:
17249
+ anyOf:
17250
+ - type: string
17251
+ enum:
17252
+ - disabled
17253
+ - preferred
17254
+ - verify_identity
17255
+ - type: "null"
16882
17256
  ConnectionPostgresConfig:
16883
17257
  type: object
16884
17258
  properties:
16885
17259
  host:
16886
- type: string
17260
+ anyOf:
17261
+ - type: string
17262
+ - type: "null"
16887
17263
  port:
16888
- type: integer
17264
+ anyOf:
17265
+ - type: integer
17266
+ - type: "null"
16889
17267
  database:
16890
- type: string
17268
+ anyOf:
17269
+ - type: string
17270
+ - type: "null"
16891
17271
  username:
16892
- type: string
17272
+ anyOf:
17273
+ - type: string
17274
+ - type: "null"
16893
17275
  password:
16894
- type: string
17276
+ anyOf:
17277
+ - type: string
17278
+ - type: "null"
16895
17279
  schema:
16896
- type: string
17280
+ anyOf:
17281
+ - type: string
17282
+ - type: "null"
16897
17283
  ssh_tunnel:
16898
- "$ref": "#/components/schemas/ConnectionSshTunnel"
17284
+ anyOf:
17285
+ - "$ref": "#/components/schemas/ConnectionSshTunnel"
17286
+ - type: "null"
16899
17287
  sslmode:
16900
- type: string
17288
+ anyOf:
17289
+ - type: string
17290
+ enum:
17291
+ - disable
17292
+ - allow
17293
+ - prefer
17294
+ - require
17295
+ - verify-ca
17296
+ - verify-full
17297
+ - type: "null"
16901
17298
  ConnectionR2CatalogConfig:
16902
17299
  type: object
16903
17300
  properties:
16904
17301
  warehouse:
16905
- type: string
17302
+ anyOf:
17303
+ - type: string
17304
+ - type: "null"
16906
17305
  endpoint:
16907
- type: string
17306
+ anyOf:
17307
+ - type: string
17308
+ - type: "null"
16908
17309
  token:
16909
- type: string
17310
+ anyOf:
17311
+ - type: string
17312
+ - type: "null"
16910
17313
  ConnectionResponse:
16911
17314
  type: object
16912
17315
  properties:
@@ -16918,52 +17321,90 @@ components:
16918
17321
  type: object
16919
17322
  properties:
16920
17323
  warehouse:
16921
- type: string
17324
+ anyOf:
17325
+ - type: string
17326
+ - type: "null"
16922
17327
  default_region:
16923
- type: string
17328
+ anyOf:
17329
+ - type: string
17330
+ - type: "null"
16924
17331
  aws_access_key_id:
16925
- type: string
17332
+ anyOf:
17333
+ - type: string
17334
+ - type: "null"
16926
17335
  aws_secret_access_key:
16927
- type: string
17336
+ anyOf:
17337
+ - type: string
17338
+ - type: "null"
16928
17339
  ConnectionSnowflakeConfig:
16929
17340
  type: object
16930
17341
  properties:
16931
17342
  account_url:
16932
- type: string
17343
+ anyOf:
17344
+ - type: string
17345
+ - type: "null"
16933
17346
  warehouse:
16934
- type: string
17347
+ anyOf:
17348
+ - type: string
17349
+ - type: "null"
16935
17350
  username:
16936
- type: string
17351
+ anyOf:
17352
+ - type: string
17353
+ - type: "null"
16937
17354
  password:
16938
- type: string
17355
+ anyOf:
17356
+ - type: string
17357
+ - type: "null"
16939
17358
  database:
16940
- type: string
17359
+ anyOf:
17360
+ - type: string
17361
+ - type: "null"
16941
17362
  ConnectionSshTunnel:
16942
17363
  type: object
16943
17364
  properties:
16944
17365
  bastion_host:
16945
- type: string
17366
+ anyOf:
17367
+ - type: string
17368
+ - type: "null"
16946
17369
  bastion_port:
16947
- type: integer
17370
+ anyOf:
17371
+ - type: integer
17372
+ - type: "null"
16948
17373
  bastion_username:
16949
- type: string
17374
+ anyOf:
17375
+ - type: string
17376
+ - type: "null"
16950
17377
  ConnectionStandardConfig:
16951
17378
  type: object
16952
17379
  properties:
16953
17380
  host:
16954
- type: string
17381
+ anyOf:
17382
+ - type: string
17383
+ - type: "null"
16955
17384
  port:
16956
- type: integer
17385
+ anyOf:
17386
+ - type: integer
17387
+ - type: "null"
16957
17388
  database:
16958
- type: string
17389
+ anyOf:
17390
+ - type: string
17391
+ - type: "null"
16959
17392
  username:
16960
- type: string
17393
+ anyOf:
17394
+ - type: string
17395
+ - type: "null"
16961
17396
  password:
16962
- type: string
17397
+ anyOf:
17398
+ - type: string
17399
+ - type: "null"
16963
17400
  schema:
16964
- type: string
17401
+ anyOf:
17402
+ - type: string
17403
+ - type: "null"
16965
17404
  ssh_tunnel:
16966
- "$ref": "#/components/schemas/ConnectionSshTunnel"
17405
+ anyOf:
17406
+ - "$ref": "#/components/schemas/ConnectionSshTunnel"
17407
+ - type: "null"
16967
17408
  ConnectionsListResponse:
16968
17409
  type: object
16969
17410
  properties:
@@ -16983,9 +17424,13 @@ components:
16983
17424
  secret_access_key:
16984
17425
  type: string
16985
17426
  region:
16986
- type: string
17427
+ anyOf:
17428
+ - type: string
17429
+ - type: "null"
16987
17430
  endpoint:
16988
- type: string
17431
+ anyOf:
17432
+ - type: string
17433
+ - type: "null"
16989
17434
  required:
16990
17435
  - name
16991
17436
  - access_key_id
@@ -16999,48 +17444,81 @@ components:
16999
17444
  type: string
17000
17445
  enum:
17001
17446
  - postgres
17002
- - bigquery
17447
+ - big_query
17003
17448
  - redshift
17004
17449
  - snowflake
17005
17450
  - mariadb
17006
17451
  - mysql
17007
17452
  - supabase
17008
- - buckettables
17009
- - icebergtables
17010
- - r2catalog
17011
- - s3tables
17453
+ - bucket_tables
17454
+ - iceberg_tables
17455
+ - r2_catalog
17456
+ - s3_tables
17012
17457
  - glue
17013
17458
  - duckdb
17459
+ - mongo
17014
17460
  read_only:
17015
- type: boolean
17461
+ anyOf:
17462
+ - type: boolean
17463
+ - type: "null"
17016
17464
  label_ids:
17017
- type: array
17018
- items:
17019
- type: string
17465
+ anyOf:
17466
+ - type: array
17467
+ items:
17468
+ type: string
17469
+ - type: "null"
17020
17470
  description:
17021
- type: string
17471
+ anyOf:
17472
+ - type: string
17473
+ - type: "null"
17022
17474
  standard_config:
17023
- "$ref": "#/components/schemas/ConnectionStandardConfig"
17475
+ anyOf:
17476
+ - "$ref": "#/components/schemas/ConnectionStandardConfig"
17477
+ - type: "null"
17024
17478
  mysql_config:
17025
- "$ref": "#/components/schemas/ConnectionMysqlConfig"
17479
+ anyOf:
17480
+ - "$ref": "#/components/schemas/ConnectionMysqlConfig"
17481
+ - type: "null"
17026
17482
  postgres_config:
17027
- "$ref": "#/components/schemas/ConnectionPostgresConfig"
17483
+ anyOf:
17484
+ - "$ref": "#/components/schemas/ConnectionPostgresConfig"
17485
+ - type: "null"
17486
+ mongo_config:
17487
+ anyOf:
17488
+ - "$ref": "#/components/schemas/ConnectionMongoConfig"
17489
+ - type: "null"
17028
17490
  bigquery_config:
17029
- "$ref": "#/components/schemas/ConnectionBigQueryConfig"
17491
+ anyOf:
17492
+ - "$ref": "#/components/schemas/ConnectionBigQueryConfig"
17493
+ - type: "null"
17030
17494
  snowflake_config:
17031
- "$ref": "#/components/schemas/ConnectionSnowflakeConfig"
17495
+ anyOf:
17496
+ - "$ref": "#/components/schemas/ConnectionSnowflakeConfig"
17497
+ - type: "null"
17032
17498
  bucket_tables_config:
17033
- "$ref": "#/components/schemas/ConnectionBucketTablesConfig"
17499
+ anyOf:
17500
+ - "$ref": "#/components/schemas/ConnectionBucketTablesConfig"
17501
+ - type: "null"
17034
17502
  iceberg_tables_config:
17035
- "$ref": "#/components/schemas/ConnectionIcebergTablesConfig"
17503
+ anyOf:
17504
+ - "$ref": "#/components/schemas/ConnectionIcebergTablesConfig"
17505
+ - type: "null"
17036
17506
  duckdb_config:
17037
- "$ref": "#/components/schemas/ConnectionDuckDBConfig"
17507
+ anyOf:
17508
+ - "$ref": "#/components/schemas/ConnectionDuckDBConfig"
17509
+ - type: "null"
17038
17510
  r2_catalog_config:
17039
- "$ref": "#/components/schemas/ConnectionR2CatalogConfig"
17511
+ anyOf:
17512
+ - "$ref": "#/components/schemas/ConnectionR2CatalogConfig"
17513
+ - type: "null"
17040
17514
  s3_tables_config:
17041
- "$ref": "#/components/schemas/ConnectionS3TablesConfig"
17515
+ anyOf:
17516
+ - "$ref": "#/components/schemas/ConnectionS3TablesConfig"
17517
+ - type: "null"
17042
17518
  glue_config:
17043
- "$ref": "#/components/schemas/ConnectionGlueConfig"
17519
+ anyOf:
17520
+ - "$ref": "#/components/schemas/ConnectionGlueConfig"
17521
+ - type: "null"
17044
17522
  required:
17045
17523
  - name
17046
17524
  - engine
@@ -17048,10 +17526,14 @@ components:
17048
17526
  type: object
17049
17527
  properties:
17050
17528
  label:
17051
- type: string
17529
+ anyOf:
17530
+ - type: string
17531
+ - type: "null"
17052
17532
  expires_at:
17053
- type: string
17054
- format: date-time
17533
+ anyOf:
17534
+ - type: string
17535
+ format: date-time
17536
+ - type: "null"
17055
17537
  CreateCredentialResponse:
17056
17538
  type: object
17057
17539
  properties:
@@ -17068,17 +17550,27 @@ components:
17068
17550
  name:
17069
17551
  type: string
17070
17552
  bucket_id:
17071
- type: string
17553
+ anyOf:
17554
+ - type: string
17555
+ - type: "null"
17072
17556
  read_only:
17073
- type: boolean
17557
+ anyOf:
17558
+ - type: boolean
17559
+ - type: "null"
17074
17560
  label_ids:
17075
- type: array
17076
- items:
17077
- type: string
17561
+ anyOf:
17562
+ - type: array
17563
+ items:
17564
+ type: string
17565
+ - type: "null"
17078
17566
  snapshot_retention_days:
17079
- type: integer
17567
+ anyOf:
17568
+ - type: integer
17569
+ - type: "null"
17080
17570
  description:
17081
- type: string
17571
+ anyOf:
17572
+ - type: string
17573
+ - type: "null"
17082
17574
  required:
17083
17575
  - name
17084
17576
  CreateEnvironmentRequest:
@@ -17092,16 +17584,49 @@ components:
17092
17584
  - hetzner
17093
17585
  - aws
17094
17586
  cloud_provider_hetzner_region:
17095
- type: string
17096
- enum:
17097
- - fsn1
17587
+ anyOf:
17588
+ - type: string
17589
+ enum:
17590
+ - fsn1
17591
+ - type: "null"
17098
17592
  cloud_provider_aws_region:
17099
- type: string
17100
- enum:
17101
- - eu-west-1
17593
+ anyOf:
17594
+ - type: string
17595
+ enum:
17596
+ - eu-west-1
17597
+ - type: "null"
17598
+ compute_units:
17599
+ anyOf:
17600
+ - type: integer
17601
+ - type: "null"
17102
17602
  required:
17103
17603
  - name
17104
17604
  - cloud_provider
17605
+ CreateEnvironmentServiceAccountRequest:
17606
+ type: object
17607
+ properties:
17608
+ label:
17609
+ type: string
17610
+ caveats:
17611
+ anyOf:
17612
+ - oneOf:
17613
+ - type: string
17614
+ enum:
17615
+ - ro
17616
+ - rw
17617
+ - type: object
17618
+ additionalProperties:
17619
+ type: string
17620
+ enum:
17621
+ - ro
17622
+ - rw
17623
+ - type: "null"
17624
+ with_service_oauth_token:
17625
+ anyOf:
17626
+ - type: boolean
17627
+ - type: "null"
17628
+ required:
17629
+ - label
17105
17630
  CreateServiceAccountRequest:
17106
17631
  type: object
17107
17632
  properties:
@@ -17109,6 +17634,13 @@ components:
17109
17634
  type: string
17110
17635
  required:
17111
17636
  - label
17637
+ CreateUserRequest:
17638
+ type: object
17639
+ properties:
17640
+ email:
17641
+ type: string
17642
+ required:
17643
+ - email
17112
17644
  Credential:
17113
17645
  type: object
17114
17646
  properties:
@@ -17128,14 +17660,20 @@ components:
17128
17660
  type: string
17129
17661
  format: date-time
17130
17662
  expires_at:
17131
- type: string
17132
- format: date-time
17663
+ anyOf:
17664
+ - type: string
17665
+ format: date-time
17666
+ - type: "null"
17133
17667
  revoked_at:
17134
- type: string
17135
- format: date-time
17668
+ anyOf:
17669
+ - type: string
17670
+ format: date-time
17671
+ - type: "null"
17136
17672
  last_rotated_at:
17137
- type: string
17138
- format: date-time
17673
+ anyOf:
17674
+ - type: string
17675
+ format: date-time
17676
+ - type: "null"
17139
17677
  required:
17140
17678
  - id
17141
17679
  - label
@@ -17165,7 +17703,9 @@ components:
17165
17703
  built_in:
17166
17704
  type: boolean
17167
17705
  description:
17168
- type: string
17706
+ anyOf:
17707
+ - type: string
17708
+ - type: "null"
17169
17709
  labels:
17170
17710
  type: array
17171
17711
  items:
@@ -17175,7 +17715,9 @@ components:
17175
17715
  bucket_id:
17176
17716
  type: string
17177
17717
  snapshot_retention_days:
17178
- type: integer
17718
+ anyOf:
17719
+ - type: integer
17720
+ - type: "null"
17179
17721
  environment_id:
17180
17722
  type: string
17181
17723
  created_at:
@@ -17228,6 +17770,8 @@ components:
17228
17770
  - aws
17229
17771
  cloud_provider_region:
17230
17772
  type: string
17773
+ compute_units:
17774
+ type: integer
17231
17775
  created_at:
17232
17776
  type: string
17233
17777
  format: date-time
@@ -17240,6 +17784,7 @@ components:
17240
17784
  - slug
17241
17785
  - cloud_provider
17242
17786
  - cloud_provider_region
17787
+ - compute_units
17243
17788
  - created_at
17244
17789
  - updated_at
17245
17790
  EnvironmentResponse:
@@ -17249,6 +17794,22 @@ components:
17249
17794
  "$ref": "#/components/schemas/Environment"
17250
17795
  required:
17251
17796
  - environment
17797
+ EnvironmentServiceAccountResponse:
17798
+ type: object
17799
+ properties:
17800
+ service_account:
17801
+ "$ref": "#/components/schemas/ServiceAccount"
17802
+ role_assignments:
17803
+ type: array
17804
+ items:
17805
+ "$ref": "#/components/schemas/RoleAssignment"
17806
+ service_oauth_token:
17807
+ anyOf:
17808
+ - type: string
17809
+ - type: "null"
17810
+ required:
17811
+ - service_account
17812
+ - role_assignments
17252
17813
  Label:
17253
17814
  type: object
17254
17815
  properties:
@@ -17288,9 +17849,13 @@ components:
17288
17849
  name:
17289
17850
  type: string
17290
17851
  email:
17291
- type: string
17852
+ anyOf:
17853
+ - type: string
17854
+ - type: "null"
17292
17855
  slug:
17293
- type: string
17856
+ anyOf:
17857
+ - type: string
17858
+ - type: "null"
17294
17859
  required:
17295
17860
  - id
17296
17861
  - type
@@ -17333,11 +17898,13 @@ components:
17333
17898
  - organization:writer
17334
17899
  - organization:admin
17335
17900
  resource_kind:
17336
- type: string
17337
- enum:
17338
- - organization
17339
- - environment
17340
- - catalog
17901
+ anyOf:
17902
+ - type: string
17903
+ enum:
17904
+ - organization
17905
+ - environment
17906
+ - catalog
17907
+ - type: "null"
17341
17908
  resource_id:
17342
17909
  type: string
17343
17910
  required:
@@ -17367,65 +17934,126 @@ components:
17367
17934
  type: object
17368
17935
  properties:
17369
17936
  name:
17370
- type: string
17937
+ anyOf:
17938
+ - type: string
17939
+ - type: "null"
17371
17940
  access_key_id:
17372
- type: string
17941
+ anyOf:
17942
+ - type: string
17943
+ - type: "null"
17373
17944
  secret_access_key:
17374
- type: string
17945
+ anyOf:
17946
+ - type: string
17947
+ - type: "null"
17375
17948
  region:
17376
- type: string
17949
+ anyOf:
17950
+ - type: string
17951
+ - type: "null"
17377
17952
  endpoint:
17378
- type: string
17953
+ anyOf:
17954
+ - type: string
17955
+ - type: "null"
17379
17956
  UpdateConnectionRequest:
17380
17957
  type: object
17381
17958
  properties:
17382
17959
  name:
17383
- type: string
17960
+ anyOf:
17961
+ - type: string
17962
+ - type: "null"
17384
17963
  read_only:
17385
- type: boolean
17964
+ anyOf:
17965
+ - type: boolean
17966
+ - type: "null"
17386
17967
  label_ids:
17387
- type: array
17388
- items:
17389
- type: string
17968
+ anyOf:
17969
+ - type: array
17970
+ items:
17971
+ type: string
17972
+ - type: "null"
17390
17973
  description:
17391
- type: string
17974
+ anyOf:
17975
+ - type: string
17976
+ - type: "null"
17392
17977
  standard_config:
17393
- "$ref": "#/components/schemas/ConnectionStandardConfig"
17978
+ anyOf:
17979
+ - "$ref": "#/components/schemas/ConnectionStandardConfig"
17980
+ - type: "null"
17394
17981
  mysql_config:
17395
- "$ref": "#/components/schemas/ConnectionMysqlConfig"
17982
+ anyOf:
17983
+ - "$ref": "#/components/schemas/ConnectionMysqlConfig"
17984
+ - type: "null"
17396
17985
  postgres_config:
17397
- "$ref": "#/components/schemas/ConnectionPostgresConfig"
17986
+ anyOf:
17987
+ - "$ref": "#/components/schemas/ConnectionPostgresConfig"
17988
+ - type: "null"
17989
+ mongo_config:
17990
+ anyOf:
17991
+ - "$ref": "#/components/schemas/ConnectionMongoConfig"
17992
+ - type: "null"
17398
17993
  bigquery_config:
17399
- "$ref": "#/components/schemas/ConnectionBigQueryConfig"
17994
+ anyOf:
17995
+ - "$ref": "#/components/schemas/ConnectionBigQueryConfig"
17996
+ - type: "null"
17400
17997
  snowflake_config:
17401
- "$ref": "#/components/schemas/ConnectionSnowflakeConfig"
17998
+ anyOf:
17999
+ - "$ref": "#/components/schemas/ConnectionSnowflakeConfig"
18000
+ - type: "null"
17402
18001
  bucket_tables_config:
17403
- "$ref": "#/components/schemas/ConnectionBucketTablesConfig"
18002
+ anyOf:
18003
+ - "$ref": "#/components/schemas/ConnectionBucketTablesConfig"
18004
+ - type: "null"
17404
18005
  iceberg_tables_config:
17405
- "$ref": "#/components/schemas/ConnectionIcebergTablesConfig"
18006
+ anyOf:
18007
+ - "$ref": "#/components/schemas/ConnectionIcebergTablesConfig"
18008
+ - type: "null"
17406
18009
  duckdb_config:
17407
- "$ref": "#/components/schemas/ConnectionDuckDBConfig"
18010
+ anyOf:
18011
+ - "$ref": "#/components/schemas/ConnectionDuckDBConfig"
18012
+ - type: "null"
17408
18013
  r2_catalog_config:
17409
- "$ref": "#/components/schemas/ConnectionR2CatalogConfig"
18014
+ anyOf:
18015
+ - "$ref": "#/components/schemas/ConnectionR2CatalogConfig"
18016
+ - type: "null"
17410
18017
  s3_tables_config:
17411
- "$ref": "#/components/schemas/ConnectionS3TablesConfig"
18018
+ anyOf:
18019
+ - "$ref": "#/components/schemas/ConnectionS3TablesConfig"
18020
+ - type: "null"
17412
18021
  glue_config:
17413
- "$ref": "#/components/schemas/ConnectionGlueConfig"
18022
+ anyOf:
18023
+ - "$ref": "#/components/schemas/ConnectionGlueConfig"
18024
+ - type: "null"
17414
18025
  UpdateDatabaseRequest:
17415
18026
  type: object
17416
18027
  properties:
17417
18028
  name:
17418
- type: string
18029
+ anyOf:
18030
+ - type: string
18031
+ - type: "null"
17419
18032
  read_only:
17420
- type: boolean
18033
+ anyOf:
18034
+ - type: boolean
18035
+ - type: "null"
17421
18036
  label_ids:
17422
- type: array
17423
- items:
17424
- type: string
18037
+ anyOf:
18038
+ - type: array
18039
+ items:
18040
+ type: string
18041
+ - type: "null"
17425
18042
  snapshot_retention_days:
17426
- type: integer
18043
+ anyOf:
18044
+ - type: integer
18045
+ - type: "null"
17427
18046
  description:
17428
- type: string
18047
+ anyOf:
18048
+ - type: string
18049
+ - type: "null"
18050
+ UpdateEnvironmentRequest:
18051
+ type: object
18052
+ properties:
18053
+ compute_units:
18054
+ type: integer
18055
+ required:
18056
+ - compute_units
17429
18057
  UpdateRoleAssignmentsRequest:
17430
18058
  type: object
17431
18059
  properties:
@@ -17446,13 +18074,25 @@ components:
17446
18074
  type: object
17447
18075
  properties:
17448
18076
  id:
18077
+ anyOf:
18078
+ - type: string
18079
+ - type: "null"
18080
+ invitation_id:
18081
+ anyOf:
18082
+ - type: string
18083
+ - type: "null"
18084
+ iac_id:
17449
18085
  type: string
17450
18086
  email:
17451
18087
  type: string
17452
18088
  name:
17453
- type: string
18089
+ anyOf:
18090
+ - type: string
18091
+ - type: "null"
17454
18092
  required:
17455
18093
  - id
18094
+ - invitation_id
18095
+ - iac_id
17456
18096
  - email
17457
18097
  - name
17458
18098
  UserResponse:
@@ -17472,7 +18112,9 @@ components:
17472
18112
  authentication_scope:
17473
18113
  type: string
17474
18114
  environment_slug:
17475
- type: string
18115
+ anyOf:
18116
+ - type: string
18117
+ - type: "null"
17476
18118
  required:
17477
18119
  - principal
17478
18120
  - organization
@@ -17733,6 +18375,71 @@ paths:
17733
18375
  application/json:
17734
18376
  schema: { $ref: "#/components/schemas/Error" }
17735
18377
 
18378
+ /environments/{environment_id}/service_accounts:
18379
+ post:
18380
+ operationId: createEnvironmentServiceAccount
18381
+ summary: Create a service account scoped to a single environment
18382
+ description: |
18383
+ Creates a service account whose roles are confined to the given environment. \`caveats\`
18384
+ defaults to read-only on the whole environment; pass \`"rw"\` for read-write, or an object
18385
+ mapping catalog names to \`"ro"\`/\`"rw"\` to grant access per catalog. Authenticate with the
18386
+ Altertable CLI and pass \`with_service_oauth_token: true\` to receive a one-time
18387
+ \`service_oauth_token\` for the new service account; it expires at the same time as the
18388
+ CLI token used to create it.
18389
+ tags: [Service Accounts]
18390
+ parameters:
18391
+ - name: environment_id
18392
+ in: path
18393
+ required: true
18394
+ description: Environment UUID or slug
18395
+ schema:
18396
+ type: string
18397
+ examples:
18398
+ - "019d7223-796e-7917-8d7e-ca256daa7979"
18399
+ - "production"
18400
+ requestBody:
18401
+ required: true
18402
+ content:
18403
+ application/json:
18404
+ schema:
18405
+ $ref: "#/components/schemas/CreateEnvironmentServiceAccountRequest"
18406
+ examples:
18407
+ environmentReadOnly:
18408
+ summary: Read-only on the whole environment
18409
+ value:
18410
+ label: CI Deploy
18411
+ withServiceOauthToken:
18412
+ summary: Issue a follow-up CLI OAuth token for the service account
18413
+ value:
18414
+ label: CI Deploy
18415
+ with_service_oauth_token: true
18416
+ perCatalog:
18417
+ summary: Read on one catalog, write on another
18418
+ value:
18419
+ label: CI Deploy
18420
+ caveats:
18421
+ analytics: ro
18422
+ staging: rw
18423
+ responses:
18424
+ "201":
18425
+ description: Service account created
18426
+ content:
18427
+ application/json:
18428
+ schema:
18429
+ $ref: "#/components/schemas/EnvironmentServiceAccountResponse"
18430
+ "401":
18431
+ $ref: "#/components/responses/Unauthorized"
18432
+ "403":
18433
+ $ref: "#/components/responses/Forbidden"
18434
+ "404":
18435
+ $ref: "#/components/responses/NotFound"
18436
+ "422":
18437
+ description: Validation failed
18438
+ content:
18439
+ application/json:
18440
+ schema:
18441
+ $ref: "#/components/schemas/Error"
18442
+
17736
18443
  /environments/{environment_id}/buckets:
17737
18444
  get:
17738
18445
  operationId: listBuckets
@@ -18130,13 +18837,47 @@ paths:
18130
18837
  "403": { $ref: "#/components/responses/Forbidden" }
18131
18838
  "404": { $ref: "#/components/responses/NotFound" }
18132
18839
 
18840
+ /users:
18841
+ post:
18842
+ operationId: createUser
18843
+ summary: Invite a user to the organization
18844
+ description: Creates or reuses a pending invitation. The returned iac_id is the stable Terraform identity.
18845
+ tags: [Users]
18846
+ requestBody:
18847
+ required: true
18848
+ content:
18849
+ application/json:
18850
+ schema: { $ref: "#/components/schemas/CreateUserRequest" }
18851
+ responses:
18852
+ "200":
18853
+ description: Existing pending invitation
18854
+ content:
18855
+ application/json:
18856
+ schema: { $ref: "#/components/schemas/UserResponse" }
18857
+ "201":
18858
+ description: Invitation created
18859
+ content:
18860
+ application/json:
18861
+ schema: { $ref: "#/components/schemas/UserResponse" }
18862
+ "401": { $ref: "#/components/responses/Unauthorized" }
18863
+ "403": { $ref: "#/components/responses/Forbidden" }
18864
+ "422":
18865
+ description: Validation failed or the email is already an organization member
18866
+ content:
18867
+ application/json:
18868
+ schema: { $ref: "#/components/schemas/Error" }
18869
+
18133
18870
  /users/{id}:
18134
18871
  get:
18135
18872
  operationId: getUser
18136
- summary: Get a user in the organization by ID
18873
+ summary: Get a user or invitation by Terraform identity
18137
18874
  tags: [Users]
18138
18875
  parameters:
18139
- - { name: id, in: path, required: true, schema: { type: string } }
18876
+ - name: id
18877
+ in: path
18878
+ required: true
18879
+ description: Opaque iac_id returned by the user API; either a user UUID or invitation_id=<UUID>
18880
+ schema: { type: string }
18140
18881
  responses:
18141
18882
  "200":
18142
18883
  description: User
@@ -18146,6 +18887,25 @@ paths:
18146
18887
  "401": { $ref: "#/components/responses/Unauthorized" }
18147
18888
  "403": { $ref: "#/components/responses/Forbidden" }
18148
18889
  "404": { $ref: "#/components/responses/NotFound" }
18890
+ delete:
18891
+ operationId: deleteUser
18892
+ summary: Cancel an invitation or remove a user from the organization
18893
+ tags: [Users]
18894
+ parameters:
18895
+ - name: id
18896
+ in: path
18897
+ required: true
18898
+ description: Opaque iac_id returned by the user API
18899
+ schema: { type: string }
18900
+ responses:
18901
+ "204": { description: User or invitation is absent }
18902
+ "401": { $ref: "#/components/responses/Unauthorized" }
18903
+ "403": { $ref: "#/components/responses/Forbidden" }
18904
+ "422":
18905
+ description: The authenticated principal cannot remove itself
18906
+ content:
18907
+ application/json:
18908
+ schema: { $ref: "#/components/schemas/Error" }
18149
18909
 
18150
18910
  /users/{user_id}/role_assignments:
18151
18911
  get:
@@ -18153,7 +18913,13 @@ paths:
18153
18913
  summary: List a user's direct role assignments
18154
18914
  tags: [Role Assignments]
18155
18915
  parameters:
18156
- - { name: user_id, in: path, required: true, schema: { type: string } }
18916
+ - {
18917
+ name: user_id,
18918
+ in: path,
18919
+ required: true,
18920
+ description: Opaque user iac_id,
18921
+ schema: { type: string },
18922
+ }
18157
18923
  responses:
18158
18924
  "200":
18159
18925
  description: Role assignments
@@ -18168,7 +18934,13 @@ paths:
18168
18934
  summary: Replace a user's role assignments
18169
18935
  tags: [Role Assignments]
18170
18936
  parameters:
18171
- - { name: user_id, in: path, required: true, schema: { type: string } }
18937
+ - {
18938
+ name: user_id,
18939
+ in: path,
18940
+ required: true,
18941
+ description: Opaque user iac_id,
18942
+ schema: { type: string },
18943
+ }
18172
18944
  requestBody:
18173
18945
  required: true
18174
18946
  content:
@@ -18188,6 +18960,27 @@ paths:
18188
18960
  content:
18189
18961
  application/json:
18190
18962
  schema: { $ref: "#/components/schemas/Error" }
18963
+ delete:
18964
+ operationId: resetUserRoleAssignments
18965
+ summary: Reset a user's role assignments to organization:member
18966
+ tags: [Role Assignments]
18967
+ parameters:
18968
+ - {
18969
+ name: user_id,
18970
+ in: path,
18971
+ required: true,
18972
+ description: Opaque user iac_id,
18973
+ schema: { type: string },
18974
+ }
18975
+ responses:
18976
+ "204": { description: Role assignments reset }
18977
+ "401": { $ref: "#/components/responses/Unauthorized" }
18978
+ "403": { $ref: "#/components/responses/Forbidden" }
18979
+ "422":
18980
+ description: Validation failed
18981
+ content:
18982
+ application/json:
18983
+ schema: { $ref: "#/components/schemas/Error" }
18191
18984
 
18192
18985
  /service_accounts/{service_account_id}/role_assignments:
18193
18986
  get:
@@ -18230,6 +19023,22 @@ paths:
18230
19023
  content:
18231
19024
  application/json:
18232
19025
  schema: { $ref: "#/components/schemas/Error" }
19026
+ delete:
19027
+ operationId: resetServiceAccountRoleAssignments
19028
+ summary: Reset a service account's role assignments to organization:member
19029
+ tags: [Role Assignments]
19030
+ parameters:
19031
+ - { name: service_account_id, in: path, required: true, schema: { type: string } }
19032
+ responses:
19033
+ "204": { description: Role assignments reset }
19034
+ "401": { $ref: "#/components/responses/Unauthorized" }
19035
+ "403": { $ref: "#/components/responses/Forbidden" }
19036
+ "404": { $ref: "#/components/responses/NotFound" }
19037
+ "422":
19038
+ description: Validation failed
19039
+ content:
19040
+ application/json:
19041
+ schema: { $ref: "#/components/schemas/Error" }
18233
19042
 
18234
19043
  /users/{user_id}/environments/{environment_id}/credentials:
18235
19044
  post:
@@ -18237,7 +19046,13 @@ paths:
18237
19046
  summary: Create a credential for a user (returns the password once)
18238
19047
  tags: [Credentials]
18239
19048
  parameters:
18240
- - { name: user_id, in: path, required: true, schema: { type: string } }
19049
+ - {
19050
+ name: user_id,
19051
+ in: path,
19052
+ required: true,
19053
+ description: Opaque user iac_id,
19054
+ schema: { type: string },
19055
+ }
18241
19056
  - { name: environment_id, in: path, required: true, schema: { type: string } }
18242
19057
  requestBody:
18243
19058
  required: false
@@ -18265,7 +19080,13 @@ paths:
18265
19080
  summary: Get a user's credential (no secret)
18266
19081
  tags: [Credentials]
18267
19082
  parameters:
18268
- - { name: user_id, in: path, required: true, schema: { type: string } }
19083
+ - {
19084
+ name: user_id,
19085
+ in: path,
19086
+ required: true,
19087
+ description: Opaque user iac_id,
19088
+ schema: { type: string },
19089
+ }
18269
19090
  - { name: environment_id, in: path, required: true, schema: { type: string } }
18270
19091
  - { name: id, in: path, required: true, schema: { type: string } }
18271
19092
  responses:
@@ -18447,6 +19268,7 @@ var OPENAPI_OPERATIONS = [
18447
19268
  { operationId: "deleteDatabase", method: "DELETE", path: "/environments/{environment_id}/databases/{id}", summary: "Delete a database" },
18448
19269
  { operationId: "getDatabase", method: "GET", path: "/environments/{environment_id}/databases/{id}", summary: "Get a database by ID or slug" },
18449
19270
  { operationId: "updateDatabase", method: "PATCH", path: "/environments/{environment_id}/databases/{id}", summary: "Update a database" },
19271
+ { operationId: "createEnvironmentServiceAccount", method: "POST", path: "/environments/{environment_id}/service_accounts", summary: "Create a service account scoped to a single environment" },
18450
19272
  { operationId: "deleteEnvironment", method: "DELETE", path: "/environments/{id}", summary: "Delete an environment" },
18451
19273
  { operationId: "getEnvironment", method: "GET", path: "/environments/{id}", summary: "Get an environment by ID or slug" },
18452
19274
  { operationId: "createServiceAccount", method: "POST", path: "/service_accounts", summary: "Create a service account" },
@@ -18456,12 +19278,16 @@ var OPENAPI_OPERATIONS = [
18456
19278
  { operationId: "createServiceAccountCredential", method: "POST", path: "/service_accounts/{service_account_id}/environments/{environment_id}/credentials", summary: "Create a credential for a service account (returns the password once)" },
18457
19279
  { operationId: "revokeServiceAccountCredential", method: "DELETE", path: "/service_accounts/{service_account_id}/environments/{environment_id}/credentials/{id}", summary: "Revoke a service account's credential" },
18458
19280
  { operationId: "getServiceAccountCredential", method: "GET", path: "/service_accounts/{service_account_id}/environments/{environment_id}/credentials/{id}", summary: "Get a service account's credential (no secret)" },
19281
+ { operationId: "resetServiceAccountRoleAssignments", method: "DELETE", path: "/service_accounts/{service_account_id}/role_assignments", summary: "Reset a service account's role assignments to organization:member" },
18459
19282
  { operationId: "getServiceAccountRoleAssignments", method: "GET", path: "/service_accounts/{service_account_id}/role_assignments", summary: "List a service account's direct role assignments" },
18460
19283
  { operationId: "setServiceAccountRoleAssignments", method: "PUT", path: "/service_accounts/{service_account_id}/role_assignments", summary: "Replace a service account's role assignments" },
18461
- { operationId: "getUser", method: "GET", path: "/users/{id}", summary: "Get a user in the organization by ID" },
19284
+ { operationId: "createUser", method: "POST", path: "/users", summary: "Invite a user to the organization" },
19285
+ { operationId: "deleteUser", method: "DELETE", path: "/users/{id}", summary: "Cancel an invitation or remove a user from the organization" },
19286
+ { operationId: "getUser", method: "GET", path: "/users/{id}", summary: "Get a user or invitation by Terraform identity" },
18462
19287
  { operationId: "createUserCredential", method: "POST", path: "/users/{user_id}/environments/{environment_id}/credentials", summary: "Create a credential for a user (returns the password once)" },
18463
19288
  { operationId: "revokeUserCredential", method: "DELETE", path: "/users/{user_id}/environments/{environment_id}/credentials/{id}", summary: "Revoke a user's credential" },
18464
19289
  { operationId: "getUserCredential", method: "GET", path: "/users/{user_id}/environments/{environment_id}/credentials/{id}", summary: "Get a user's credential (no secret)" },
19290
+ { operationId: "resetUserRoleAssignments", method: "DELETE", path: "/users/{user_id}/role_assignments", summary: "Reset a user's role assignments to organization:member" },
18465
19291
  { operationId: "getUserRoleAssignments", method: "GET", path: "/users/{user_id}/role_assignments", summary: "List a user's direct role assignments" },
18466
19292
  { operationId: "setUserRoleAssignments", method: "PUT", path: "/users/{user_id}/role_assignments", summary: "Replace a user's role assignments" },
18467
19293
  { operationId: "lookupUser", method: "GET", path: "/users/lookup", summary: "Look up a user in the organization by email" },
@@ -18628,6 +19454,9 @@ function asStringArray(value) {
18628
19454
  return value.map(String);
18629
19455
  return value === undefined ? [] : [String(value)];
18630
19456
  }
19457
+ function aliasFlagToken(alias) {
19458
+ return alias.length === 1 ? `-${alias}` : `--${alias}`;
19459
+ }
18631
19460
  function normalizeCommandMetadata(metadata) {
18632
19461
  return {
18633
19462
  ...metadata?.name ? { name: String(metadata.name) } : {},
@@ -18763,7 +19592,7 @@ function collectCompletionContexts(root) {
18763
19592
 
18764
19593
  // src/commands/completion/lib/model.ts
18765
19594
  function flagForms(flag) {
18766
- return flag.alias ? [`-${flag.alias}`, `--${flag.name}`] : [`--${flag.name}`];
19595
+ return flag.alias ? [aliasFlagToken(flag.alias), `--${flag.name}`] : [`--${flag.name}`];
18767
19596
  }
18768
19597
  function allFlags(root, contexts) {
18769
19598
  return [...root.flags, ...contexts.flatMap((context) => context.flags)];
@@ -18882,7 +19711,7 @@ function formatNameList(names) {
18882
19711
  return names.join(" ");
18883
19712
  }
18884
19713
  function flagForms2(flag) {
18885
- return flag.alias ? [`-${flag.alias}`, `--${flag.name}`] : [`--${flag.name}`];
19714
+ return flag.alias ? [aliasFlagToken(flag.alias), `--${flag.name}`] : [`--${flag.name}`];
18886
19715
  }
18887
19716
  function formatBashFlagWordList(flags) {
18888
19717
  return flags.flatMap(flagForms2).join(" ");
@@ -19316,11 +20145,11 @@ function formatFishPathCondition(segments, positionalCount = "any") {
19316
20145
  return `__altertable_using_context '${formatPath(segments)}' '${positionalCount}'`;
19317
20146
  }
19318
20147
  function formatFishFlagCompleteLine(flag, condition) {
19319
- const shortFlag = flag.alias ? ` -s ${flag.alias}` : "";
20148
+ const aliasFlag = flag.alias ? `${flag.alias.length === 1 ? " -s " : " -l "}${flag.alias}` : "";
19320
20149
  const description = flag.description ? ` -d '${escapeFishDescription(flag.description)}'` : "";
19321
20150
  const values = flag.values && flag.values.length > 0 ? ` -f -r -a "${flag.values.join(" ")}"` : "";
19322
20151
  const conditionArg = condition ? ` -n "${condition}"` : "";
19323
- return `complete -c ${FISH_BINARY_NAME}${shortFlag} -l ${flag.name}${description}${values}${conditionArg}`;
20152
+ return `complete -c ${FISH_BINARY_NAME}${aliasFlag} -l ${flag.name}${description}${values}${conditionArg}`;
19324
20153
  }
19325
20154
  function formatFishNormalizer(model) {
19326
20155
  const valueFlags = [...model.valueFlags].map((flag) => `'${flag}'`).join(" ");
@@ -21224,7 +22053,7 @@ function optionBindings(commandArguments) {
21224
22053
  const binding = { name, argument };
21225
22054
  bindings.set(`--${name}`, binding);
21226
22055
  for (const alias of stringList(argument.alias)) {
21227
- bindings.set(`-${alias}`, binding);
22056
+ bindings.set(aliasFlagToken(alias), binding);
21228
22057
  }
21229
22058
  }
21230
22059
  return bindings;
@@ -21610,7 +22439,7 @@ function valueHint(argument) {
21610
22439
  return;
21611
22440
  }
21612
22441
  function flagLabel(argument) {
21613
- const aliases = argument.aliases.map((alias) => `-${alias}`);
22442
+ const aliases = argument.aliases.map(aliasFlagToken);
21614
22443
  const longFlag = `--${argument.name}`;
21615
22444
  const hint = valueHint(argument);
21616
22445
  const value = hint ? ` <${hint}>` : "";