@altertable/cli 1.15.1 → 1.16.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 +1039 -935
  2. package/package.json +4 -1
package/dist/cli.js CHANGED
@@ -7155,8 +7155,8 @@ class ParseError extends CliError {
7155
7155
  }
7156
7156
 
7157
7157
  class QueryError extends CliError {
7158
- constructor(message) {
7159
- super(`Query failed: ${message}`);
7158
+ constructor(message, options) {
7159
+ super(`Query failed: ${message}`, options);
7160
7160
  this.name = "QueryError";
7161
7161
  }
7162
7162
  }
@@ -7338,18 +7338,6 @@ function validateJsonBody(body) {
7338
7338
  }
7339
7339
  return body;
7340
7340
  }
7341
- function normalizeFieldEntries(fields) {
7342
- if (fields === undefined) {
7343
- return [];
7344
- }
7345
- if (typeof fields === "string") {
7346
- return [fields];
7347
- }
7348
- if (Array.isArray(fields)) {
7349
- return fields;
7350
- }
7351
- return Object.values(fields);
7352
- }
7353
7341
  function parseFieldEntry(entry) {
7354
7342
  const separatorIndex = entry.indexOf("=");
7355
7343
  if (separatorIndex <= 0) {
@@ -7357,9 +7345,6 @@ function parseFieldEntry(entry) {
7357
7345
  }
7358
7346
  const key = entry.slice(0, separatorIndex);
7359
7347
  const value = entry.slice(separatorIndex + 1);
7360
- if (key.length === 0) {
7361
- throw new CliError(`Invalid field ${JSON.stringify(entry)}. Expected key=value.`);
7362
- }
7363
7348
  return [key, value];
7364
7349
  }
7365
7350
  function canonicalizeJsonInteger(value) {
@@ -7385,14 +7370,14 @@ function parseTypedFieldValue(value) {
7385
7370
  }
7386
7371
  return readFileArgument(value);
7387
7372
  }
7388
- function parseRawFields(fields) {
7389
- return normalizeFieldEntries(fields).map((entry) => {
7373
+ function parseRawFields(fields = []) {
7374
+ return fields.map((entry) => {
7390
7375
  const [key, value] = parseFieldEntry(entry);
7391
7376
  return { key, value };
7392
7377
  });
7393
7378
  }
7394
- function parseTypedFields(fields) {
7395
- return normalizeFieldEntries(fields).map((entry) => {
7379
+ function parseTypedFields(fields = []) {
7380
+ return fields.map((entry) => {
7396
7381
  const [key, value] = parseFieldEntry(entry);
7397
7382
  return { key, value: parseTypedFieldValue(value) };
7398
7383
  });
@@ -7420,45 +7405,23 @@ function serializeApiFields(fields) {
7420
7405
  function resolveApiRequestPayload(options) {
7421
7406
  const method = options.method.toUpperCase();
7422
7407
  const inputArg = options.input;
7423
- const rawFields = parseRawFields(options.rawFields ?? options.fields);
7408
+ const rawFields = parseRawFields(options.rawFields);
7424
7409
  const typedFields = parseTypedFields(options.typedFields);
7425
7410
  const parsedFields = [...rawFields, ...typedFields];
7426
- const hasBody = inputArg !== undefined && inputArg !== "";
7427
- const hasFields = parsedFields.length > 0;
7428
- if (hasBody && hasFields) {
7429
- if (!BODY_METHODS.has(method)) {
7430
- throw new CliError(`${method} requests do not accept a body. Use ${BODY_METHOD_LIST} for --input.`);
7431
- }
7432
- return {
7433
- body: readJsonInput(String(inputArg)),
7434
- queryFields: parsedFields
7435
- };
7436
- }
7437
- if (FIELD_QUERY_METHODS.has(method)) {
7438
- if (hasBody) {
7411
+ if (!BODY_METHODS.has(method)) {
7412
+ if (inputArg) {
7439
7413
  throw new CliError(`${method} requests do not accept a body. Use ${BODY_METHOD_LIST} for --input.`);
7440
7414
  }
7441
- return {
7442
- queryFields: parsedFields
7443
- };
7444
- }
7445
- if (!BODY_METHODS.has(method)) {
7446
- if (hasBody || hasFields) {
7415
+ if (parsedFields.length > 0 && !FIELD_QUERY_METHODS.has(method)) {
7447
7416
  throw new CliError(`${method} requests do not accept a body. Use ${BODY_METHOD_LIST} for --input or request fields.`);
7448
7417
  }
7449
- return { queryFields: [] };
7418
+ return { queryFields: parsedFields };
7450
7419
  }
7451
- if (hasBody) {
7452
- return {
7453
- body: readJsonInput(String(inputArg)),
7454
- queryFields: []
7455
- };
7420
+ if (inputArg) {
7421
+ return { body: readJsonInput(inputArg), queryFields: parsedFields };
7456
7422
  }
7457
- if (hasFields) {
7458
- return {
7459
- body: serializeApiFields(parsedFields),
7460
- queryFields: []
7461
- };
7423
+ if (parsedFields.length > 0) {
7424
+ return { body: serializeApiFields(parsedFields), queryFields: [] };
7462
7425
  }
7463
7426
  return { queryFields: [] };
7464
7427
  }
@@ -7547,7 +7510,9 @@ var ENV_SCHEMA = {
7547
7510
  ALTERTABLE_OAUTH_REDIRECT_PORT: { parse: port },
7548
7511
  ALTERTABLE_OAUTH_SCOPE: { parse: optional },
7549
7512
  ALTERTABLE_PROFILE: { parse: optional },
7550
- ALTERTABLE_SECRET_BACKEND: { parse: oneOf(["file", "keychain"]) },
7513
+ ALTERTABLE_SECRET_BACKEND: {
7514
+ parse: oneOf(["file", "keychain", "windows"])
7515
+ },
7551
7516
  ALTERTABLE_UPDATE_CHECK: {
7552
7517
  parse: oneOf(["0", "1", "false", "true", "never"])
7553
7518
  },
@@ -7790,6 +7755,8 @@ function kvUnset(filePath, key) {
7790
7755
  const output = content.split(`
7791
7756
  `).filter((line) => configKey(line) !== key).join(`
7792
7757
  `);
7758
+ if (output === content)
7759
+ return;
7793
7760
  writeConfigFileAtomically(filePath, output, "update");
7794
7761
  }
7795
7762
 
@@ -8083,17 +8050,13 @@ function resolveOAuthBase(profileName) {
8083
8050
  return `${resolveManagementApiRoot(profileName)}/oauth`;
8084
8051
  }
8085
8052
  var QUERY_PAGER_VALUES = new Set(["auto", "always", "never"]);
8086
- var MIN_QUERY_MAX_COL_WIDTH = 8;
8053
+ var MIN_QUERY_MAX_COLUMN_WIDTH = 8;
8054
+ function parseQueryMaxColumnWidth(value) {
8055
+ const width = Number(value);
8056
+ return /^\d+$/.test(value) && Number.isSafeInteger(width) && width >= MIN_QUERY_MAX_COLUMN_WIDTH ? width : undefined;
8057
+ }
8087
8058
  function getQueryDefaultMaxColumnWidth() {
8088
- const value = configGetGlobal("query_max_width");
8089
- if (value.length === 0) {
8090
- return;
8091
- }
8092
- const parsed = Number.parseInt(value, 10);
8093
- if (Number.isNaN(parsed) || parsed < MIN_QUERY_MAX_COL_WIDTH) {
8094
- return;
8095
- }
8096
- return parsed;
8059
+ return parseQueryMaxColumnWidth(configGetGlobal("query_max_width"));
8097
8060
  }
8098
8061
  function getQueryDefaultLayout() {
8099
8062
  const value = configGetGlobal("query_layout");
@@ -8145,6 +8108,7 @@ function createDiagnosticExecutionContext(runtime) {
8145
8108
  // src/lib/secrets.ts
8146
8109
  import { spawnSync } from "child_process";
8147
8110
  import { chmodSync, statSync } from "fs";
8111
+ import { join as join4 } from "path";
8148
8112
 
8149
8113
  // src/lib/cli-context.ts
8150
8114
  var bootstrapContext = { debug: false, json: false, agent: false };
@@ -8574,6 +8538,237 @@ function logWarn(message) {
8574
8538
  console.error(`[WARN] ${message}`);
8575
8539
  }
8576
8540
 
8541
+ // src/lib/windows-credentials.ts
8542
+ import { randomUUID as randomUUID2 } from "crypto";
8543
+ import { mkdirSync as mkdirSync3, readFileSync as readFileSync4, writeFileSync as writeFileSync2 } from "fs";
8544
+ import { dirname as dirname2 } from "path";
8545
+ function fileCredentialRevision(markerPath) {
8546
+ return {
8547
+ read() {
8548
+ try {
8549
+ return readFileSync4(markerPath(), "utf8");
8550
+ } catch {
8551
+ return "";
8552
+ }
8553
+ },
8554
+ advance() {
8555
+ const token = randomUUID2();
8556
+ mkdirSync3(dirname2(markerPath()), { recursive: true });
8557
+ writeFileSync2(markerPath(), token);
8558
+ return token;
8559
+ }
8560
+ };
8561
+ }
8562
+ var MAX_SECRET_BYTES = 5 * 512;
8563
+ var EXIT_RESTRICTED_LANGUAGE = 2;
8564
+ var EXIT_WIN32_ERROR = 3;
8565
+ var ERROR_NO_SUCH_LOGON_SESSION = 1312;
8566
+ var FILE_BACKEND_HINT = "Set ALTERTABLE_SECRET_BACKEND=file to store credentials in the configuration directory instead.";
8567
+ var CREDENTIAL_SCRIPT = String.raw`
8568
+ if ($ExecutionContext.SessionState.LanguageMode -ne 'FullLanguage') { exit ${EXIT_RESTRICTED_LANGUAGE} }
8569
+ $ErrorActionPreference = 'Stop'
8570
+ [Console]::InputEncoding = New-Object System.Text.UTF8Encoding($false)
8571
+ [Console]::OutputEncoding = New-Object System.Text.UTF8Encoding($false)
8572
+ try {
8573
+ Add-Type -TypeDefinition @'
8574
+ using System;
8575
+ using System.Collections;
8576
+ using System.ComponentModel;
8577
+ using System.Runtime.InteropServices;
8578
+ using System.Text;
8579
+ public static class AltertableCredentialManager {
8580
+ private const string Prefix = "altertable/";
8581
+ private const uint GenericType = 1;
8582
+ private const uint PersistLocalMachine = 2;
8583
+ private const int ErrorNotFound = 1168;
8584
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
8585
+ private struct Credential {
8586
+ public uint Flags, Type;
8587
+ public string TargetName, Comment;
8588
+ public long LastWritten;
8589
+ public uint CredentialBlobSize;
8590
+ public IntPtr CredentialBlob;
8591
+ public uint Persist, AttributeCount;
8592
+ public IntPtr Attributes;
8593
+ public string TargetAlias, UserName;
8594
+ }
8595
+ [DllImport("advapi32.dll", EntryPoint = "CredWriteW", CharSet = CharSet.Unicode, SetLastError = true)]
8596
+ private static extern bool Write(ref Credential credential, uint flags);
8597
+ [DllImport("advapi32.dll", EntryPoint = "CredEnumerateW", CharSet = CharSet.Unicode, SetLastError = true)]
8598
+ private static extern bool Enumerate(string filter, uint flags, out uint count, out IntPtr credentials);
8599
+ [DllImport("advapi32.dll", EntryPoint = "CredDeleteW", CharSet = CharSet.Unicode, SetLastError = true)]
8600
+ private static extern bool Delete(string target, uint type, uint flags);
8601
+ [DllImport("advapi32.dll")]
8602
+ private static extern void CredFree(IntPtr buffer);
8603
+
8604
+ public static Hashtable List() {
8605
+ Hashtable values = new Hashtable();
8606
+ uint count;
8607
+ IntPtr list;
8608
+ if (!Enumerate(Prefix + "*", 0, out count, out list)) {
8609
+ int error = Marshal.GetLastWin32Error();
8610
+ if (error == ErrorNotFound) return values;
8611
+ throw new Win32Exception(error);
8612
+ }
8613
+ try {
8614
+ for (int index = 0; index < count; index++) {
8615
+ IntPtr pointer = Marshal.ReadIntPtr(list, index * IntPtr.Size);
8616
+ Credential credential = (Credential)Marshal.PtrToStructure(pointer, typeof(Credential));
8617
+ if (credential.Type != GenericType) continue;
8618
+ byte[] blob = new byte[credential.CredentialBlobSize];
8619
+ if (blob.Length > 0) Marshal.Copy(credential.CredentialBlob, blob, 0, blob.Length);
8620
+ values[credential.TargetName.Substring(Prefix.Length)] = Encoding.UTF8.GetString(blob);
8621
+ Array.Clear(blob, 0, blob.Length);
8622
+ }
8623
+ } finally { CredFree(list); }
8624
+ return values;
8625
+ }
8626
+ public static void Set(string account, string value) {
8627
+ byte[] bytes = Encoding.UTF8.GetBytes(value);
8628
+ IntPtr blob = Marshal.AllocCoTaskMem(Math.Max(bytes.Length, 1));
8629
+ try {
8630
+ Marshal.Copy(bytes, 0, blob, bytes.Length);
8631
+ Credential credential = new Credential();
8632
+ credential.Type = GenericType;
8633
+ credential.TargetName = Prefix + account;
8634
+ credential.UserName = "Altertable";
8635
+ credential.CredentialBlobSize = (uint)bytes.Length;
8636
+ credential.CredentialBlob = blob;
8637
+ credential.Persist = PersistLocalMachine;
8638
+ if (!Write(ref credential, 0)) throw new Win32Exception(Marshal.GetLastWin32Error());
8639
+ } finally {
8640
+ Marshal.Copy(new byte[bytes.Length], 0, blob, bytes.Length);
8641
+ Marshal.FreeCoTaskMem(blob);
8642
+ Array.Clear(bytes, 0, bytes.Length);
8643
+ }
8644
+ }
8645
+ public static void Remove(string account) {
8646
+ if (Delete(Prefix + account, GenericType, 0)) return;
8647
+ int error = Marshal.GetLastWin32Error();
8648
+ if (error != ErrorNotFound) throw new Win32Exception(error);
8649
+ }
8650
+ }
8651
+ '@
8652
+ $request = [Console]::In.ReadToEnd() | ConvertFrom-Json
8653
+ $result = @{}
8654
+ switch ($request.action) {
8655
+ 'list' { $result.credentials = [AltertableCredentialManager]::List() }
8656
+ 'set' { [AltertableCredentialManager]::Set($request.account, $request.value) }
8657
+ 'delete' { [AltertableCredentialManager]::Remove($request.account) }
8658
+ default { exit 1 }
8659
+ }
8660
+ ConvertTo-Json -InputObject $result -Compress
8661
+ } catch {
8662
+ for ($exception = $_.Exception; $exception; $exception = $exception.InnerException) {
8663
+ if ($exception -is [System.ComponentModel.Win32Exception]) {
8664
+ [Console]::Error.Write($exception.NativeErrorCode)
8665
+ exit ${EXIT_WIN32_ERROR}
8666
+ }
8667
+ }
8668
+ exit 1
8669
+ }
8670
+ `;
8671
+ var ACTION_VERBS = {
8672
+ list: "read",
8673
+ set: "store",
8674
+ delete: "delete"
8675
+ };
8676
+ function createWindowsCredentialStore(run, revision) {
8677
+ let snapshot;
8678
+ function invoke(action, request = {}) {
8679
+ const result = run("powershell.exe", [
8680
+ "-NoLogo",
8681
+ "-NoProfile",
8682
+ "-NonInteractive",
8683
+ "-Command",
8684
+ CREDENTIAL_SCRIPT
8685
+ ], {
8686
+ input: JSON.stringify({ action, ...request }),
8687
+ encoding: "utf8",
8688
+ windowsHide: true,
8689
+ timeout: 15000,
8690
+ maxBuffer: 1024 * 1024
8691
+ });
8692
+ if (result.error || result.status !== 0) {
8693
+ throw new CliError(`${failureReason(ACTION_VERBS[action], result)} ${FILE_BACKEND_HINT}`);
8694
+ }
8695
+ try {
8696
+ return JSON.parse(String(result.stdout));
8697
+ } catch {
8698
+ throw new CliError("Invalid response from Windows Credential Manager.");
8699
+ }
8700
+ }
8701
+ function storedValues() {
8702
+ const current = revision.read();
8703
+ if (snapshot?.revision === current)
8704
+ return snapshot.values;
8705
+ const { credentials } = invoke("list");
8706
+ if (typeof credentials !== "object" || credentials === null) {
8707
+ throw new CliError("Invalid credential list from Windows Credential Manager.");
8708
+ }
8709
+ const values = new Map;
8710
+ for (const [account, value] of Object.entries(credentials)) {
8711
+ if (typeof value === "string")
8712
+ values.set(account, value);
8713
+ }
8714
+ snapshot = { values, revision: current };
8715
+ return values;
8716
+ }
8717
+ function write(action, account, value) {
8718
+ invoke(action, { account, value });
8719
+ const current = snapshot?.revision === revision.read() ? snapshot : undefined;
8720
+ const next = revision.advance();
8721
+ if (!current) {
8722
+ snapshot = undefined;
8723
+ return;
8724
+ }
8725
+ if (value === undefined)
8726
+ current.values.delete(account);
8727
+ else
8728
+ current.values.set(account, value);
8729
+ snapshot = { values: current.values, revision: next };
8730
+ }
8731
+ return {
8732
+ get(account) {
8733
+ return storedValues().get(account) ?? null;
8734
+ },
8735
+ exists(account) {
8736
+ return storedValues().has(account);
8737
+ },
8738
+ set(account, value) {
8739
+ const size = Buffer.byteLength(value, "utf8");
8740
+ if (size > MAX_SECRET_BYTES) {
8741
+ throw new CliError(`This secret is ${size} bytes; Windows Credential Manager stores at most ${MAX_SECRET_BYTES}. ${FILE_BACKEND_HINT}`);
8742
+ }
8743
+ write("set", account, value);
8744
+ },
8745
+ delete(account) {
8746
+ if (storedValues().has(account))
8747
+ write("delete", account);
8748
+ }
8749
+ };
8750
+ }
8751
+ function failureReason(verb, result) {
8752
+ const code = result.error?.code;
8753
+ if (code === "ENOENT") {
8754
+ return "Windows Credential Manager requires Windows PowerShell (powershell.exe), which was not found.";
8755
+ }
8756
+ if (code === "ETIMEDOUT") {
8757
+ return `Windows Credential Manager did not ${verb} credentials within 15 seconds.`;
8758
+ }
8759
+ if (result.status === EXIT_RESTRICTED_LANGUAGE) {
8760
+ return "PowerShell is restricted by a language mode policy, which blocks Windows Credential Manager access.";
8761
+ }
8762
+ const win32Error = result.status === EXIT_WIN32_ERROR ? Number.parseInt(String(result.stderr ?? ""), 10) : Number.NaN;
8763
+ if (win32Error === ERROR_NO_SUCH_LOGON_SESSION) {
8764
+ return `Windows Credential Manager could not ${verb} credentials: this logon session has no credential vault (common over SSH and in services).`;
8765
+ }
8766
+ if (Number.isInteger(win32Error)) {
8767
+ return `Windows Credential Manager could not ${verb} credentials (Windows error ${win32Error}).`;
8768
+ }
8769
+ return `Windows Credential Manager could not ${verb} credentials.`;
8770
+ }
8771
+
8577
8772
  // src/lib/secrets.ts
8578
8773
  var KEYCHAIN_ITEM_NOT_FOUND_STATUS = 44;
8579
8774
  function keychainLookupFailed(result) {
@@ -8619,11 +8814,12 @@ function stableSecretKey(key, profileId) {
8619
8814
  }
8620
8815
  function createSecretStore(secretProcess = SYSTEM_SECRET_PROCESS) {
8621
8816
  let fileBackendWarned = false;
8817
+ const windowsCredentials = createWindowsCredentialStore(secretProcess.spawnSync.bind(secretProcess), fileCredentialRevision(() => join4(configDir(), "credential-manager.revision")));
8622
8818
  function warnFileBackendOnce() {
8623
8819
  if (fileBackendWarned)
8624
8820
  return;
8625
8821
  const protection = secretProcess.platform === "win32" ? "Windows ACLs are not validated" : "chmod 600";
8626
- logWarn(`No macOS keychain; storing secrets at ${credentialsFile()} (${protection}). Prefer environment variables in CI.`);
8822
+ logWarn(`Storing secrets in plaintext at ${credentialsFile()} (${protection}). Prefer environment variables in CI.`);
8627
8823
  fileBackendWarned = true;
8628
8824
  }
8629
8825
  function hasSecurityCommand() {
@@ -8636,6 +8832,11 @@ function createSecretStore(secretProcess = SYSTEM_SECRET_PROCESS) {
8636
8832
  const override = readEnv("ALTERTABLE_SECRET_BACKEND") ?? "";
8637
8833
  if (override === "file")
8638
8834
  return "file";
8835
+ if (override === "windows") {
8836
+ if (secretProcess.platform === "win32")
8837
+ return "windows";
8838
+ throw new CliError("ALTERTABLE_SECRET_BACKEND=windows requires Windows Credential Manager.");
8839
+ }
8639
8840
  if (override === "keychain") {
8640
8841
  if (secretProcess.platform === "darwin" && hasSecurityCommand())
8641
8842
  return "macos";
@@ -8643,6 +8844,8 @@ function createSecretStore(secretProcess = SYSTEM_SECRET_PROCESS) {
8643
8844
  }
8644
8845
  if (secretProcess.platform === "darwin" && hasSecurityCommand())
8645
8846
  return "macos";
8847
+ if (secretProcess.platform === "win32")
8848
+ return "windows";
8646
8849
  return "file";
8647
8850
  }
8648
8851
  function secretSetMacos(storageAccount, value) {
@@ -8661,6 +8864,17 @@ function createSecretStore(secretProcess = SYSTEM_SECRET_PROCESS) {
8661
8864
  }
8662
8865
  }
8663
8866
  function readStoredSecret(storageAccount) {
8867
+ if (secretBackend() === "windows") {
8868
+ const value = windowsCredentials.get(storageAccount);
8869
+ if (value !== null)
8870
+ return value;
8871
+ const legacyValue = kvGet(credentialsFile(), storageAccount);
8872
+ if (legacyValue !== "") {
8873
+ windowsCredentials.set(storageAccount, legacyValue);
8874
+ kvUnset(credentialsFile(), storageAccount);
8875
+ }
8876
+ return legacyValue;
8877
+ }
8664
8878
  if (secretBackend() === "macos") {
8665
8879
  const result = secretProcess.spawnSync("security", [
8666
8880
  "find-generic-password",
@@ -8681,6 +8895,11 @@ function createSecretStore(secretProcess = SYSTEM_SECRET_PROCESS) {
8681
8895
  return kvGet(credentialsFile(), storageAccount);
8682
8896
  }
8683
8897
  function storedSecretExists(storageAccount) {
8898
+ if (secretBackend() === "windows") {
8899
+ if (windowsCredentials.exists(storageAccount))
8900
+ return true;
8901
+ return kvGet(credentialsFile(), storageAccount) !== "";
8902
+ }
8684
8903
  if (secretBackend() === "macos") {
8685
8904
  const result = secretProcess.spawnSync("security", ["find-generic-password", "-s", "altertable", "-a", storageAccount], { stdio: "ignore" });
8686
8905
  if (result.status === 0)
@@ -8693,6 +8912,9 @@ function createSecretStore(secretProcess = SYSTEM_SECRET_PROCESS) {
8693
8912
  return kvGet(credentialsFile(), storageAccount) !== "";
8694
8913
  }
8695
8914
  function deleteStoredSecret(storageAccount) {
8915
+ if (secretBackend() === "windows") {
8916
+ windowsCredentials.delete(storageAccount);
8917
+ }
8696
8918
  if (secretBackend() === "macos") {
8697
8919
  const result = secretProcess.spawnSync("security", ["delete-generic-password", "-s", "altertable", "-a", storageAccount], { stdio: "ignore" });
8698
8920
  if (result.status !== 0 && result.status !== KEYCHAIN_ITEM_NOT_FOUND_STATUS) {
@@ -8706,6 +8928,11 @@ function createSecretStore(secretProcess = SYSTEM_SECRET_PROCESS) {
8706
8928
  return;
8707
8929
  const storageAccount = stableSecretKey(account, ensureProfileId(profileName));
8708
8930
  const backend = secretBackend();
8931
+ if (backend === "windows") {
8932
+ windowsCredentials.set(storageAccount, value);
8933
+ kvUnset(credentialsFile(), storageAccount);
8934
+ return;
8935
+ }
8709
8936
  if (backend === "macos" && !options?.fromArgv) {
8710
8937
  secretSetMacos(storageAccount, value);
8711
8938
  return;
@@ -8756,6 +8983,8 @@ function createSecretStore(secretProcess = SYSTEM_SECRET_PROCESS) {
8756
8983
  if (!storedSecretExists(storageAccount)) {
8757
8984
  if (secretBackend() === "macos") {
8758
8985
  secretSetMacos(storageAccount, value);
8986
+ } else if (secretBackend() === "windows") {
8987
+ windowsCredentials.set(storageAccount, value);
8759
8988
  } else {
8760
8989
  kvSet(credentialsFile(), storageAccount, value);
8761
8990
  chmodSync(credentialsFile(), 384);
@@ -8767,7 +8996,12 @@ function createSecretStore(secretProcess = SYSTEM_SECRET_PROCESS) {
8767
8996
  }
8768
8997
  }
8769
8998
  function secretStoreDisplay() {
8770
- return secretBackend() === "macos" ? "MacOS keychain" : credentialsFile();
8999
+ const backend = secretBackend();
9000
+ if (backend === "macos")
9001
+ return "MacOS keychain";
9002
+ if (backend === "windows")
9003
+ return "Windows Credential Manager";
9004
+ return credentialsFile();
8771
9005
  }
8772
9006
  return {
8773
9007
  secretSet,
@@ -8952,16 +9186,14 @@ function parseRetryAfterMs(headerValue) {
8952
9186
  return;
8953
9187
  }
8954
9188
  const trimmed = headerValue.trim();
8955
- const seconds = Number.parseInt(trimmed, 10);
8956
- if (!Number.isNaN(seconds)) {
8957
- return seconds * 1000;
8958
- }
8959
- const retryDate = Date.parse(trimmed);
8960
- if (!Number.isNaN(retryDate)) {
8961
- const delayMs = retryDate - Date.now();
8962
- return delayMs > 0 ? delayMs : undefined;
9189
+ if (/^\d+$/.test(trimmed)) {
9190
+ const delayMs = Number(trimmed) * 1000;
9191
+ return Number.isSafeInteger(delayMs) ? delayMs : undefined;
8963
9192
  }
8964
- return;
9193
+ if (!/^[a-z]/i.test(trimmed))
9194
+ return;
9195
+ const delayMs = Date.parse(trimmed) - Date.now();
9196
+ return delayMs > 0 ? delayMs : undefined;
8965
9197
  }
8966
9198
  function computeRetryDelayMs(attemptIndex, retryAfterHeader) {
8967
9199
  const retryAfterMs = parseRetryAfterMs(retryAfterHeader);
@@ -9179,7 +9411,7 @@ function redactResponseBodyForDebug(body) {
9179
9411
  }
9180
9412
 
9181
9413
  // src/version.ts
9182
- var VERSION = "1.15.1";
9414
+ var VERSION = "1.16.0";
9183
9415
  var USER_AGENT = `altertable-cli/${VERSION}`;
9184
9416
 
9185
9417
  // src/lib/http.ts
@@ -9364,11 +9596,7 @@ function createChunkedMockStream(body) {
9364
9596
  }
9365
9597
  });
9366
9598
  }
9367
- async function executeMockRequest(options, attemptIndex) {
9368
- const mockFile = readEnv("ALTERTABLE_MOCK_HTTP_FILE");
9369
- if (!mockFile) {
9370
- throw new CliError("Mock HTTP file is not configured.");
9371
- }
9599
+ async function readMockResponse(mockFile, options, attemptIndex) {
9372
9600
  const mocks = JSON.parse(await Bun.file(mockFile).text());
9373
9601
  logHttpRequest(options);
9374
9602
  const match = findMatchingMock(mocks, options, attemptIndex);
@@ -9376,33 +9604,20 @@ async function executeMockRequest(options, attemptIndex) {
9376
9604
  throw new CliError(`No mock HTTP response for ${options.method} ${options.url}`);
9377
9605
  }
9378
9606
  const status = match.status ?? 200;
9379
- if (status >= 200 && status < 300) {
9380
- return match.body;
9381
- }
9607
+ if (status >= 200 && status < 300)
9608
+ return match;
9382
9609
  throwHttpError(status, match.body, options.method, options.url, options.authPlane, match.retryAfter ?? null);
9383
9610
  }
9384
- async function executeMockStream(options, attemptIndex) {
9385
- const mockFile = readEnv("ALTERTABLE_MOCK_HTTP_FILE");
9386
- if (!mockFile) {
9387
- throw new CliError("Mock HTTP file is not configured.");
9388
- }
9389
- const mocks = JSON.parse(await Bun.file(mockFile).text());
9390
- logHttpRequest(options);
9391
- const match = findMatchingMock(mocks, options, attemptIndex);
9392
- if (!match) {
9393
- throw new CliError(`No mock HTTP response for ${options.method} ${options.url}`);
9394
- }
9395
- const status = match.status ?? 200;
9396
- if (status < 200 || status >= 300) {
9397
- throwHttpError(status, match.body, options.method, options.url, options.authPlane, match.retryAfter ?? null);
9398
- }
9399
- if (match.chunked) {
9400
- return createChunkedMockStream(match.body);
9401
- }
9611
+ function streamMockResponse({
9612
+ body,
9613
+ chunked
9614
+ }) {
9615
+ if (chunked)
9616
+ return createChunkedMockStream(body);
9402
9617
  const encoder = new TextEncoder;
9403
9618
  return new ReadableStream({
9404
9619
  start(controller) {
9405
- controller.enqueue(encoder.encode(match.body));
9620
+ controller.enqueue(encoder.encode(body));
9406
9621
  controller.close();
9407
9622
  }
9408
9623
  });
@@ -9596,47 +9811,29 @@ async function executeLiveStream(options) {
9596
9811
  }
9597
9812
  throwHttpError(response.status, responseBody, options.method, options.url, options.authPlane, response.headers.get("Retry-After"));
9598
9813
  }
9599
- async function httpSend(options) {
9814
+ async function sendWithRetries(options, sendLive, formatMockResponse) {
9600
9815
  const maxAttempts = options.maxAttempts ?? MAX_RETRY_ATTEMPTS;
9601
9816
  const mockFile = readEnv("ALTERTABLE_MOCK_HTTP_FILE");
9602
9817
  for (let attemptIndex = 0;attemptIndex < maxAttempts; attemptIndex += 1) {
9603
9818
  try {
9604
9819
  if (mockFile) {
9605
- return await executeMockRequest(options, attemptIndex);
9820
+ return formatMockResponse(await readMockResponse(mockFile, options, attemptIndex));
9606
9821
  }
9607
- return await executeLiveRequest(options);
9822
+ return await sendLive(options);
9608
9823
  } catch (error) {
9609
- if (error instanceof HttpError) {
9610
- if (shouldRetryHttpRequest(options, error.status, attemptIndex, maxAttempts)) {
9611
- await delayBeforeHttpRetry(attemptIndex, error.retryAfterHeader ?? null);
9612
- continue;
9613
- }
9824
+ if (!(error instanceof HttpError) || !shouldRetryHttpRequest(options, error.status, attemptIndex, maxAttempts)) {
9825
+ throw error;
9614
9826
  }
9615
- throw error;
9827
+ await delayBeforeHttpRetry(attemptIndex, error.retryAfterHeader ?? null);
9616
9828
  }
9617
9829
  }
9618
9830
  throw new NetworkError("Request failed after retries.");
9619
9831
  }
9620
- async function httpSendStream(options) {
9621
- const maxAttempts = options.maxAttempts ?? MAX_RETRY_ATTEMPTS;
9622
- const mockFile = readEnv("ALTERTABLE_MOCK_HTTP_FILE");
9623
- for (let attemptIndex = 0;attemptIndex < maxAttempts; attemptIndex += 1) {
9624
- try {
9625
- if (mockFile) {
9626
- return await executeMockStream(options, attemptIndex);
9627
- }
9628
- return await executeLiveStream(options);
9629
- } catch (error) {
9630
- if (error instanceof HttpError) {
9631
- if (shouldRetryHttpRequest(options, error.status, attemptIndex, maxAttempts)) {
9632
- await delayBeforeHttpRetry(attemptIndex, error.retryAfterHeader ?? null);
9633
- continue;
9634
- }
9635
- }
9636
- throw error;
9637
- }
9638
- }
9639
- throw new NetworkError("Request failed after retries.");
9832
+ function httpSend(options) {
9833
+ return sendWithRetries(options, executeLiveRequest, (response) => response.body);
9834
+ }
9835
+ function httpSendStream(options) {
9836
+ return sendWithRetries(options, executeLiveStream, streamMockResponse);
9640
9837
  }
9641
9838
 
9642
9839
  // src/lib/management-endpoint.ts
@@ -11081,15 +11278,6 @@ function resolveCellDataType(value, columnName, columnTypeMap) {
11081
11278
  }
11082
11279
  return "string";
11083
11280
  }
11084
- function selectDisplayColumnNames(allNames, options) {
11085
- if (options.columns !== undefined && options.columns.length > 0) {
11086
- const nameSet = new Set(allNames);
11087
- const filtered = options.columns.filter((name) => nameSet.has(name));
11088
- const columns = filtered.length > 0 ? filtered : allNames;
11089
- return { columns };
11090
- }
11091
- return { columns: allNames };
11092
- }
11093
11281
 
11094
11282
  // src/lib/relative-time.ts
11095
11283
  var SECOND_MS = 1000;
@@ -11372,70 +11560,31 @@ function selectColumnNames(allNames, selected) {
11372
11560
  }
11373
11561
  return filtered;
11374
11562
  }
11375
- function getRowCellValues(row, columnNames, allColumnNames) {
11376
- if (Array.isArray(row)) {
11377
- return columnNames.map((name) => {
11378
- const columnIndex = allColumnNames.indexOf(name);
11379
- if (columnIndex < 0) {
11380
- return;
11381
- }
11382
- return row[columnIndex];
11383
- });
11384
- }
11385
- return columnNames.map((name) => row[name]);
11386
- }
11387
- function collectQueryDisplayRows(result, columnNames, allColumnNames) {
11388
- return result.rows.map((row) => {
11389
- const values = getRowCellValues(row, columnNames, allColumnNames);
11390
- return {
11391
- values,
11392
- rawCells: values.map((value) => renderDisplayText(formatQueryCellRaw(value)))
11393
- };
11394
- });
11563
+ function rowProjection(allNames, names) {
11564
+ const indices = names === allNames ? names.map((_, index) => index) : names.map((name) => allNames.indexOf(name));
11565
+ return (row) => Array.isArray(row) ? indices.map((index) => row[index]) : names.map((name) => row[name]);
11395
11566
  }
11396
11567
  function buildQueryRenderModel(result, options) {
11397
11568
  const allColumnNames = getQueryColumnNames(result);
11398
11569
  const columnTypeMap = getColumnTypeMap(result.columns);
11399
- const { columns: columnNames } = selectDisplayColumnNames(allColumnNames, options);
11570
+ const columnNames = selectColumnNames(allColumnNames, options.columns);
11400
11571
  return {
11401
11572
  columnNames,
11402
11573
  columnTypeMap,
11403
- rows: collectQueryDisplayRows(result, columnNames, allColumnNames)
11574
+ rows: result.rows.map(rowProjection(allColumnNames, columnNames))
11404
11575
  };
11405
11576
  }
11406
- function computeColumnWidths(columnNames, formattedCells, terminalWidth, maxColumnWidth) {
11407
- const naturalWidths = columnNames.map((name, columnIndex) => {
11408
- const nameWidth = getVisibleTextWidth(renderDisplayText(name));
11409
- const cellWidths = formattedCells.map((cells) => getVisibleTextWidth(cells[columnIndex] ?? ""));
11410
- const natural = Math.max(nameWidth, ...cellWidths);
11411
- return Math.min(natural, maxColumnWidth);
11412
- });
11413
- const minimumWidths = columnNames.map((name) => Math.min(getVisibleTextWidth(renderDisplayText(name)), maxColumnWidth));
11414
- const totalNatural = naturalWidths.reduce((sum, width) => sum + width, 0);
11415
- if (totalNatural <= terminalWidth || columnNames.length === 0) {
11416
- return naturalWidths;
11417
- }
11418
- let remainingWidth = terminalWidth;
11419
- const widths = [...minimumWidths];
11420
- let flexibleColumns = columnNames.map((_name, columnIndex) => columnIndex);
11421
- while (flexibleColumns.length > 0 && remainingWidth > 0) {
11422
- const share = Math.floor(remainingWidth / flexibleColumns.length);
11423
- if (share === 0) {
11424
- break;
11425
- }
11426
- const nextFlexible = [];
11427
- for (const columnIndex of flexibleColumns) {
11428
- const currentWidth = widths[columnIndex] ?? minimumWidths[columnIndex] ?? 0;
11429
- const targetWidth = Math.min(naturalWidths[columnIndex] ?? currentWidth, currentWidth + share);
11430
- widths[columnIndex] = targetWidth;
11431
- remainingWidth -= targetWidth - currentWidth;
11432
- if (targetWidth < (naturalWidths[columnIndex] ?? targetWidth)) {
11433
- nextFlexible.push(columnIndex);
11434
- }
11577
+ function computeColumnWidths(model, maxWidth) {
11578
+ return model.columnNames.map((name, index) => {
11579
+ let width = getVisibleTextWidth(renderDisplayText(name));
11580
+ for (const row of model.rows) {
11581
+ if (width >= maxWidth)
11582
+ break;
11583
+ const cell = renderDisplayText(formatQueryCellRaw(row[index]));
11584
+ width = Math.max(width, getVisibleTextWidth(cell));
11435
11585
  }
11436
- flexibleColumns = nextFlexible;
11437
- }
11438
- return widths;
11586
+ return Math.min(width, maxWidth);
11587
+ });
11439
11588
  }
11440
11589
  function getTableFrameWidth(columnCount) {
11441
11590
  if (columnCount === 0) {
@@ -11445,13 +11594,9 @@ function getTableFrameWidth(columnCount) {
11445
11594
  const innerBorders = Math.max(0, columnCount - 1);
11446
11595
  return outerBorders + innerBorders + columnCount * TABLE_CELL_PADDING * 2;
11447
11596
  }
11448
- function computeMinimumTableWidth(columnNames, formattedCells, maxColumnWidth) {
11449
- const widths = computeColumnWidths(columnNames, formattedCells, Number.MAX_SAFE_INTEGER, maxColumnWidth);
11450
- return widths.reduce((sum, width) => sum + width, 0) + getTableFrameWidth(columnNames.length);
11451
- }
11452
11597
  function getColumnAlignment(rows, columnIndex, columnName, columnTypeMap) {
11453
11598
  for (const row of rows) {
11454
- const value = row.values[columnIndex];
11599
+ const value = row[columnIndex];
11455
11600
  const dataType = resolveCellDataType(value, columnName, columnTypeMap);
11456
11601
  if (dataType === "null") {
11457
11602
  continue;
@@ -11498,7 +11643,7 @@ function renderQueryTableRow(cells, columnWidths, alignments, colorize) {
11498
11643
  }
11499
11644
  function formatCellsForTable(rows, columnNames, columnWidths, options, columnTypeMap) {
11500
11645
  const colorize = options.colorize ?? true;
11501
- return rows.map((row) => row.values.map((value, columnIndex) => {
11646
+ return rows.map((row) => row.map((value, columnIndex) => {
11502
11647
  const width = columnWidths[columnIndex] ?? DEFAULT_MAX_COLUMN_WIDTH;
11503
11648
  return formatQueryCell(value, {
11504
11649
  maxWidth: width,
@@ -11508,15 +11653,13 @@ function formatCellsForTable(rows, columnNames, columnWidths, options, columnTyp
11508
11653
  });
11509
11654
  }));
11510
11655
  }
11511
- function renderQueryTable(model, options) {
11656
+ function renderQueryTable(model, columnWidths, options) {
11512
11657
  const { columnNames, columnTypeMap, rows } = model;
11513
11658
  if (rows.length === 0) {
11514
11659
  if (columnNames.length === 0) {
11515
11660
  return "(no rows)";
11516
11661
  }
11517
11662
  }
11518
- const availableCellWidth = Math.max(0, options.terminalWidth - getTableFrameWidth(columnNames.length));
11519
- const columnWidths = computeColumnWidths(columnNames, rows.map((row) => row.rawCells), options.layout === "table" ? Number.MAX_SAFE_INTEGER : availableCellWidth, options.maxColumnWidth);
11520
11663
  const rowValues = formatCellsForTable(rows, columnNames, columnWidths, options, columnTypeMap);
11521
11664
  const colorize = options.colorize ?? true;
11522
11665
  const alignments = getColumnAlignments(rows, columnNames, columnTypeMap);
@@ -11545,7 +11688,7 @@ function renderQueryExpanded(model, options) {
11545
11688
  const showRowNumbers = rows.length > 1;
11546
11689
  const records = rows.map((row, rowIndex) => {
11547
11690
  const lines = columnNames.map((name, columnIndex) => {
11548
- const value = formatQueryCell(row.values[columnIndex], {
11691
+ const value = formatQueryCell(row[columnIndex], {
11549
11692
  colorize,
11550
11693
  includeRelative: true,
11551
11694
  columnName: name,
@@ -11599,8 +11742,9 @@ function renderQueryMarkdown(result, columnNames, options) {
11599
11742
  }
11600
11743
  const headerRow = `| ${selectedNames.map((name) => escapeMarkdownCell(name)).join(" | ")} |`;
11601
11744
  const separatorRow = `| ${selectedNames.map(() => "---").join(" | ")} |`;
11745
+ const project = rowProjection(columnNames, selectedNames);
11602
11746
  const bodyRows = result.rows.map((row) => {
11603
- const values = getRowCellValues(row, selectedNames, columnNames);
11747
+ const values = project(row);
11604
11748
  const cells = values.map((value, columnIndex) => escapeMarkdownCell(formatQueryCell(value, {
11605
11749
  colorize: false,
11606
11750
  columnName: selectedNames[columnIndex],
@@ -11621,17 +11765,13 @@ function renderQueryMarkdown(result, columnNames, options) {
11621
11765
  }
11622
11766
  function renderQueryHumanOutput(result, options) {
11623
11767
  const model = buildQueryRenderModel(result, options);
11624
- const rawCells = model.rows.map((row) => row.rawCells);
11625
- const minimumTableWidth = computeMinimumTableWidth(model.columnNames, rawCells, options.maxColumnWidth);
11626
11768
  let body;
11627
11769
  if (options.layout === "line") {
11628
11770
  body = renderQueryExpanded(model, options);
11629
- } else if (options.layout === "table") {
11630
- body = renderQueryTable(model, options);
11631
- } else if (minimumTableWidth > options.terminalWidth) {
11632
- body = renderQueryExpanded(model, options);
11633
11771
  } else {
11634
- body = renderQueryTable(model, options);
11772
+ const widths = computeColumnWidths(model, options.maxColumnWidth);
11773
+ const tableWidth = widths.reduce((sum, width) => sum + width, getTableFrameWidth(widths.length));
11774
+ body = options.layout === "auto" && tableWidth > options.terminalWidth ? renderQueryExpanded(model, options) : renderQueryTable(model, widths, options);
11635
11775
  }
11636
11776
  const footer = renderQueryFooter(result, {
11637
11777
  colorize: options.colorize ?? true
@@ -11813,29 +11953,24 @@ function renderQueryOutputText(result, format, displayOptions) {
11813
11953
  }
11814
11954
  return renderQueryHumanOutput(result, displayOptions ?? defaultDisplayOptions());
11815
11955
  }
11816
- async function writeQueryOutput(result, format, sink, displayOptions, pagerOptions, outputPath) {
11956
+ async function writeQueryOutput(result, sink, {
11957
+ format,
11958
+ displayOptions,
11959
+ pagerOptions,
11960
+ outputPath
11961
+ }) {
11817
11962
  const effectiveFormat = sink.json ? "json" : format;
11818
- if (isApiNativeQueryFormat(effectiveFormat)) {
11819
- throw new CliError(`Format ${effectiveFormat} must be streamed from the lakehouse API.`);
11820
- }
11821
- const outputText = renderQueryOutputText(result, effectiveFormat, displayOptions);
11822
- const usePager = format === "human" && !sink.json && outputPath === undefined;
11823
- if (usePager) {
11824
- await writePagedOutput(outputText, pagerOptions ?? resolvePagerOptions(), sink);
11963
+ if (effectiveFormat === "json" && outputPath === undefined) {
11964
+ sink.writeJson(result);
11825
11965
  return;
11826
11966
  }
11967
+ const outputText = renderQueryOutputText(result, effectiveFormat, displayOptions);
11827
11968
  if (outputPath !== undefined) {
11828
- if (effectiveFormat === "json") {
11829
- await writeQueryDestination(JSON.stringify(JSON.parse(outputText), null, 2), {
11830
- outputPath
11831
- });
11832
- return;
11833
- }
11834
11969
  await writeQueryDestination(outputText, { outputPath });
11835
11970
  return;
11836
11971
  }
11837
- if (effectiveFormat === "json" || sink.json) {
11838
- sink.writeJson(JSON.parse(outputText));
11972
+ if (effectiveFormat === "human") {
11973
+ await writePagedOutput(outputText, pagerOptions, sink);
11839
11974
  return;
11840
11975
  }
11841
11976
  sink.writeHuman(outputText);
@@ -11904,23 +12039,11 @@ function normalizeApiEndpoint(endpoint, env) {
11904
12039
  }
11905
12040
  return path;
11906
12041
  }
11907
- function hasFields(fields) {
11908
- if (fields === undefined) {
11909
- return false;
11910
- }
11911
- if (typeof fields === "string") {
11912
- return fields.length > 0;
11913
- }
11914
- if (Array.isArray(fields)) {
11915
- return fields.length > 0;
11916
- }
11917
- return Object.keys(fields).length > 0;
11918
- }
11919
12042
  function resolveApiMethod(args) {
11920
12043
  if (args.method && args.method.trim().length > 0) {
11921
12044
  return args.method.toUpperCase();
11922
12045
  }
11923
- if (args.input || hasFields(args.rawFields) || hasFields(args.typedFields) || hasFields(args.fields)) {
12046
+ if (args.input || args.rawFields?.length || args.typedFields?.length) {
11924
12047
  return "POST";
11925
12048
  }
11926
12049
  return "GET";
@@ -11945,7 +12068,7 @@ function resolveApiHttp(args) {
11945
12068
  const payload = resolveApiRequestPayload({
11946
12069
  method,
11947
12070
  input: args.input ? String(args.input) : undefined,
11948
- rawFields: args.rawFields ?? args.fields,
12071
+ rawFields: args.rawFields,
11949
12072
  typedFields: args.typedFields
11950
12073
  });
11951
12074
  const endpointWithQuery = appendQueryFields(endpoint, payload.queryFields);
@@ -12074,8 +12197,6 @@ function resolveApiCommandRequest(args, method) {
12074
12197
  });
12075
12198
  }
12076
12199
  function repeatableStringArg(value) {
12077
- if (typeof value === "string")
12078
- return value;
12079
12200
  if (Array.isArray(value) && value.every((entry) => typeof entry === "string")) {
12080
12201
  return value;
12081
12202
  }
@@ -14996,11 +15117,11 @@ var apiCommand = defineCommand({
14996
15117
  });
14997
15118
 
14998
15119
  // src/commands/app/build.ts
14999
- import { join as join5 } from "path";
15120
+ import { join as join6 } from "path";
15000
15121
 
15001
15122
  // src/commands/app/lib/run.ts
15002
- import { readFileSync as readFileSync4 } from "fs";
15003
- import { join as join4, resolve as resolve2 } from "path";
15123
+ import { readFileSync as readFileSync5 } from "fs";
15124
+ import { join as join5, resolve as resolve2 } from "path";
15004
15125
  function appDirectory(value) {
15005
15126
  if (value !== undefined && (typeof value !== "string" || value.length === 0)) {
15006
15127
  throw new CliError("--dir requires a directory path.");
@@ -15015,7 +15136,7 @@ function assertAppOutputMode(json, agent) {
15015
15136
  function requireAppScripts(directory, required) {
15016
15137
  let packageJson;
15017
15138
  try {
15018
- packageJson = JSON.parse(readFileSync4(join4(directory, "package.json"), "utf8"));
15139
+ packageJson = JSON.parse(readFileSync5(join5(directory, "package.json"), "utf8"));
15019
15140
  } catch {
15020
15141
  throw new ConfigurationError(`Cannot read a valid package.json in ${directory}.`);
15021
15142
  }
@@ -15091,37 +15212,43 @@ var appBuildCommand = defineCommand({
15091
15212
  const exitCode = await runAppCommand("build", directory);
15092
15213
  if (exitCode !== 0)
15093
15214
  return { exitCode: EXIT_GENERIC };
15094
- sink.writeHuman(`Built data app in ${join5(directory, "dist")}.`);
15215
+ sink.writeHuman(`Built data app in ${join6(directory, "dist")}.`);
15095
15216
  }
15096
15217
  });
15097
15218
 
15098
15219
  // src/commands/app/create.ts
15099
15220
  import { mkdir, rm, writeFile } from "fs/promises";
15100
- import { dirname as dirname2, join as join6, resolve as resolve3 } from "path";
15221
+ import { dirname as dirname3, join as join7, resolve as resolve3 } from "path";
15101
15222
 
15102
15223
  // src/commands/app/lib/distribution.ts
15103
- import { fileURLToPath } from "url";
15104
- var dataAppDirectory = fileURLToPath(new URL("../../../../../data-app/", import.meta.url));
15105
15224
  function createAppFiles(payload, identity) {
15106
15225
  const files = { ...payload.starter };
15107
15226
  const packageJson = JSON.parse(files["package.json"]);
15108
15227
  packageJson.name = identity.name;
15109
15228
  files["package.json"] = `${JSON.stringify(packageJson, null, 2)}
15110
15229
  `;
15111
- const app = JSON.parse(files["app.json"]);
15112
- app.title = identity.title;
15113
- app.scope = identity.scope;
15114
- files["app.json"] = `${JSON.stringify(app, null, 2)}
15115
- `;
15230
+ const literals = {
15231
+ APP_TITLE: identity.title,
15232
+ APP_ORGANIZATION: identity.scope.organization,
15233
+ APP_ENVIRONMENT: identity.scope.environment
15234
+ };
15235
+ files["app.ts"] = files["app.ts"].replace(/'__(APP_TITLE|APP_ORGANIZATION|APP_ENVIRONMENT)__'/g, (_match, key) => appLiteral(literals[key]));
15116
15236
  const oldName = JSON.stringify(JSON.parse(payload.starter["package.json"]).name);
15117
15237
  files["bun.lock"] = files["bun.lock"].replace(`"name": ${oldName}`, `"name": ${JSON.stringify(identity.name)}`);
15118
15238
  return files;
15119
15239
  }
15240
+ function appLiteral(value) {
15241
+ const json = JSON.stringify(value);
15242
+ const singleQuotes = value.split("'").length - 1;
15243
+ const doubleQuotes = value.split('"').length - 1;
15244
+ if (singleQuotes > doubleQuotes)
15245
+ return json;
15246
+ return "'" + json.slice(1, -1).replaceAll("\\\"", '"').replaceAll("'", "\\'") + "'";
15247
+ }
15120
15248
 
15121
15249
  // src/commands/app/lib/payload.ts
15122
- var dataAppPayload = { starter: { ".gitignore": `node_modules/
15123
- dist/
15124
- .env*
15250
+ var dataAppPayload = { starter: { ".bun-version": `1.4.4
15251
+ `, ".node-version": `24.18.0
15125
15252
  `, ".oxfmtrc.json": `{
15126
15253
  "$schema": "./node_modules/oxfmt/configuration_schema.json",
15127
15254
  "ignorePatterns": ["dist/**", "bun.lock"],
@@ -15154,58 +15281,324 @@ dist/
15154
15281
  }
15155
15282
  ]
15156
15283
  }
15284
+ ],
15285
+ "func-style": [
15286
+ "error",
15287
+ "declaration",
15288
+ {
15289
+ "overrides": {
15290
+ "namedExports": "declaration"
15291
+ }
15292
+ }
15157
15293
  ]
15158
15294
  }
15159
15295
  }
15160
- `, "AGENTS.md": `# Build this data app
15296
+ `, "AGENTS.md": "# Build this local data app\n\nRead `node_modules/@altertable/data-app/docs/app-authoring.md` and use this project\nas the selected scaffold. If dependencies are unavailable, read the\n[version-matched recipe](https://github.com/altertable-ai/data-app/blob/v0.79.0/docs/app-authoring.md). <!-- x-release-please-version -->\n\n| Task | App-owned files |\n| ------------------------------------------ | ----------------------------------------------- |\n| Define queries, filters, and operations | `app.ts`, `src/filters.ts`, `src/operations.ts` |\n| Compose app content and supported features | `src/App.tsx` |\n| Bind definitions and source evidence | `src/data-context.ts` |\n| Change identity and appearance | `app.ts` |\n| Inject styles and mount React | `src/main.tsx` |\n| Configure local serving | `src/server.ts` |\n\nSee [README.md](README.md) for setup and checks.\n\nKeep reusable app-specific conventions here.\n", LICENSE: `MIT License
15161
15297
 
15162
- Read and follow the [data app authoring instructions](https://github.com/altertable-ai/data-app/blob/main/examples/starter-local-data-app/AGENTS.md) before changing this app.
15298
+ Copyright (c) Altertable
15163
15299
 
15164
- See [README.md](README.md) for CLI setup, checks, and upgrades.
15165
- `, "README.md": `# Getting started
15300
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15301
+ of this software and associated documentation files (the "Software"), to deal
15302
+ in the Software without restriction, including without limitation the rights
15303
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15304
+ copies of the Software, and to permit persons to whom the Software is
15305
+ furnished to do so, subject to the following conditions:
15166
15306
 
15167
- This starter runs a lightweight SQL query to check the lakehouse connection. \u201CConnected\u201D appears only after that query succeeds; having a configured profile alone is not enough. The check does not establish access to specific datasets.
15307
+ The above copyright notice and this permission notice shall be included in all
15308
+ copies or substantial portions of the Software.
15168
15309
 
15169
- The generated screen is a setup state. Its operation and data context contain no analytical example to copy. Discover the relevant data and build the exploration around the user's question; broad questions deserve more than one useful angle.
15310
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15311
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15312
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15313
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15314
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15315
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15316
+ SOFTWARE.
15317
+ `, "README.md": `# Local data app starter
15170
15318
 
15171
- ## Run locally
15319
+ Use \`node_modules/@altertable/data-app/docs/app-authoring.md\` for this SDK version.
15320
+ Otherwise, read the [version-matched authoring recipe](https://github.com/altertable-ai/data-app/blob/v0.79.0/docs/app-authoring.md). <!-- x-release-please-version -->
15321
+ See [AGENTS.md](AGENTS.md) for app-owned files.
15172
15322
 
15173
- Configure a profile with lakehouse access, then run from this directory:
15323
+ ## Run the app
15324
+
15325
+ From the copied starter directory, install dependencies and set server-only
15326
+ credentials before starting:
15174
15327
 
15175
15328
  \`\`\`fish
15176
- altertable app dev
15329
+ bun install
15330
+ set -gx ALTERTABLE_LAKEHOUSE_USERNAME your-username
15331
+ read --silent --prompt-str 'Lakehouse password: ' ALTERTABLE_LAKEHOUSE_PASSWORD
15332
+ set -gx ALTERTABLE_LAKEHOUSE_PASSWORD $ALTERTABLE_LAKEHOUSE_PASSWORD
15333
+ bun run dev
15177
15334
  \`\`\`
15178
15335
 
15179
- The CLI prints the local URL. Use \`altertable app dev --port 3022\` to choose a port.
15336
+ Open <http://127.0.0.1:25837>. Alternatively, configure
15337
+ \`ALTERTABLE_DATA_PROXY_URL\` and \`ALTERTABLE_DATA_PROXY_TOKEN\` for an existing
15338
+ CLI proxy. Missing credentials stop startup.
15180
15339
 
15181
- ## Author the app
15340
+ ## Explore the example
15182
15341
 
15183
- Start with the [authoring router](AGENTS.md) for data and view changes, or the [package authoring guide](node_modules/@altertable/data-app/docs/app-authoring.md) to find components, hooks, and contracts.
15342
+ Choose a group to narrow the fictional sample counts. The chart, its inspected
15343
+ rows, and the CSV export share one query, operation, view, and dataset. Widget
15344
+ inspection exposes the registered query, selected parameters, and the sample
15345
+ count definition. Gamma demonstrates a recorded zero.
15184
15346
 
15185
- Import definitions, contracts, and clients from \`@altertable/data-app\` and its public subpaths. Use \`@altertable/data-app-react\` for React authoring, \`@altertable/data-app-react/ui\` for setup and custom UI components, and \`@altertable/data-app-bun\` for local serving. Keep all data-app package versions aligned when adding dependencies.
15347
+ ## Build the app
15186
15348
 
15187
- ## Check and upgrade
15349
+ Use inspected source data to answer the app brief. Replace the sample queries
15350
+ and views, and set identity and appearance in \`app.ts\`.
15188
15351
 
15189
- Run \`altertable app lint\` to check the app locally. Use \`altertable app lint --lakehouse\` to execute each operation's declared \`checks\` against the selected profile.
15352
+ \`\`\`fish
15353
+ bun run check
15354
+ \`\`\`
15190
15355
 
15191
- \`altertable app upgrade\` updates declared data-app packages and the lockfile to the shared version tested with your CLI. It preserves app code and does not downgrade newer packages. Update your imports and app code if the package APIs change, then run \`altertable app lint\` again and restart any running preview.
15356
+ \`bun run check\` includes the build, which writes browser assets to \`dist/\`. Hosted apps require an authorized query bridge; the local adapter does not authenticate hosted viewers.
15192
15357
 
15193
- ## Version control
15358
+ ## License
15194
15359
 
15195
- Commit app source, \`package.json\`, and \`bun.lock\`. On a fresh clone, run \`bun install --frozen-lockfile\` to restore the pinned dependencies; installation needs registry access or a populated Bun cache. Keep custom code in \`src/\`.
15196
- `, "app.json": `{
15197
- "schemaVersion": 1,
15198
- "title": "Getting started",
15199
- "scope": { "organization": "Your organization", "environment": "your environment" },
15200
- "appearance": {
15201
- "theme": "light",
15202
- "baseColor": "neutral",
15203
- "accentColor": "#405d47",
15204
- "density": "comfortable",
15205
- "cornerRadius": "medium",
15206
- "elevation": "subtle",
15207
- "typography": { "body": "system", "heading": "system" }
15208
- }
15360
+ [MIT](LICENSE)
15361
+ `, ".gitignore": `node_modules/
15362
+ dist/
15363
+ .env*
15364
+ `, "app.ts": `import { defineDataApp } from '@altertable/data-app';
15365
+
15366
+ export const dataApp = defineDataApp({
15367
+ // Replace the demo title, description, and scope labels with the app's identity.
15368
+ title: '__APP_TITLE__',
15369
+ description: 'Compare fictional sample counts across groups.',
15370
+ scope: { organization: '__APP_ORGANIZATION__', environment: '__APP_ENVIRONMENT__' },
15371
+ appearance: { theme: 'system' },
15372
+ queries: {
15373
+ sampleCountsByGroup: {
15374
+ // Fictional rows. Replace the CTE with an inspected source.
15375
+ statement: \`
15376
+ WITH sample_counts(group_name, sample_count) AS (
15377
+ VALUES ('Alpha', 1200), ('Alpha', 800), ('Beta', 450), ('Gamma', 0)
15378
+ )
15379
+ SELECT group_name, CAST(SUM(sample_count) AS BIGINT) AS sample_count
15380
+ FROM sample_counts
15381
+ WHERE $groupName = 'all' OR group_name = $groupName
15382
+ GROUP BY group_name
15383
+ ORDER BY sample_count DESC, group_name
15384
+ LIMIT $limit\`,
15385
+ params: {
15386
+ groupName: { type: 'string', defaultValue: 'all' },
15387
+ limit: { type: 'number', defaultValue: 10 },
15388
+ },
15389
+ projections: {
15390
+ group_name: { type: 'string' },
15391
+ sample_count: { type: 'number' },
15392
+ },
15393
+ },
15394
+ },
15395
+ });
15396
+ `, "bunfig.toml": `[install]
15397
+ exact = true
15398
+ `, "package.json": `{
15399
+ "name": "data-app-starter",
15400
+ "private": true,
15401
+ "type": "module",
15402
+ "imports": {
15403
+ "#app/*": "./src/*",
15404
+ "#config": "./app.ts"
15405
+ },
15406
+ "scripts": {
15407
+ "typecheck": "tsc --noEmit",
15408
+ "lint": "oxlint --type-aware src app.ts",
15409
+ "format": "oxfmt src app.ts",
15410
+ "format:check": "oxfmt --check src app.ts",
15411
+ "dev": "bun --hot src/server.ts",
15412
+ "build": "bun run typecheck && bun build src/index.html --outdir=dist --production",
15413
+ "check": "bun run lint && bun run format:check && bun run build",
15414
+ "lint:fix": "oxlint --type-aware --fix src app.ts"
15415
+ },
15416
+ "dependencies": {
15417
+ "@altertable/data-app": "0.79.0",
15418
+ "@altertable/data-app-bun": "0.79.0",
15419
+ "@altertable/data-app-react": "0.79.0",
15420
+ "react": "19.3.1",
15421
+ "react-dom": "19.3.1"
15422
+ },
15423
+ "devDependencies": {
15424
+ "@types/bun": "1.4.3",
15425
+ "@types/react": "19.3.0",
15426
+ "@types/react-dom": "19.3.0",
15427
+ "oxfmt": "0.71.0",
15428
+ "oxlint": "1.86.0",
15429
+ "oxlint-tsgolint": "7.0.2003",
15430
+ "typescript": "7.0.2"
15431
+ },
15432
+ "packageManager": "bun@1.4.4"
15433
+ }
15434
+ `, "src/App.tsx": `import {
15435
+ createDataHooks,
15436
+ DataApp,
15437
+ DataSection,
15438
+ VisualizationWidget,
15439
+ } from '@altertable/data-app-react';
15440
+ import { BarChart } from '@altertable/data-app-react/ui';
15441
+
15442
+ import { dataContext } from '#app/data-context.ts';
15443
+ import { operations } from '#app/operations.ts';
15444
+
15445
+ const { defineView } = createDataHooks(operations.createDataClient());
15446
+ const sampleCountsView = defineView({
15447
+ dataContext,
15448
+ operation: 'sampleCountsByGroup',
15449
+ emptyFallback: {
15450
+ title: 'No matching groups',
15451
+ description: 'Choose another group.',
15452
+ },
15453
+ });
15454
+ const sampleCounts = sampleCountsView.dataset({
15455
+ name: 'Sample counts',
15456
+ rowKey: row => row.groupName,
15457
+ columns: {
15458
+ groupName: { label: 'Group' },
15459
+ sampleCount: { format: { kind: 'count' } },
15460
+ },
15461
+ evidence: { id: 'counts-by-group', glossaryIds: ['sampleCount'] },
15462
+ });
15463
+ const countsContent = sampleCountsView.content(result => (
15464
+ <VisualizationWidget
15465
+ dataset={sampleCounts}
15466
+ source={result}
15467
+ title="Samples by group"
15468
+ >
15469
+ {rows => (
15470
+ <BarChart
15471
+ ariaLabel="Sample counts by group"
15472
+ unit="samples"
15473
+ valueFormat={{ kind: 'count' }}
15474
+ showYAxis
15475
+ scrollToEnd={false}
15476
+ items={rows.map(row => ({
15477
+ id: row.groupName,
15478
+ label: row.groupName,
15479
+ value: row.sampleCount,
15480
+ }))}
15481
+ />
15482
+ )}
15483
+ </VisualizationWidget>
15484
+ ));
15485
+
15486
+ export function App() {
15487
+ return (
15488
+ <DataApp view={sampleCountsView} datasets={[sampleCounts]}>
15489
+ <DataSection content={countsContent} />
15490
+ </DataApp>
15491
+ );
15492
+ }
15493
+ `, "src/assets.d.ts": `declare module '*.css';
15494
+ `, "src/data-context.ts": `import { createDataContext } from '@altertable/data-app-react';
15495
+
15496
+ import { dataApp } from '#config';
15497
+
15498
+ // Replace the description and definitions with verified source metadata.
15499
+ export const dataContext = createDataContext(dataApp.queryNames)({
15500
+ description:
15501
+ 'Fictional sample counts by group. Gamma has a recorded count of zero.',
15502
+ glossary: {
15503
+ sampleCount: {
15504
+ term: 'Sample count',
15505
+ definition:
15506
+ 'Sum of recorded samples in the selected group scope. Additive across groups.',
15507
+ queryNames: [dataApp.queryNames.sampleCountsByGroup],
15508
+ },
15509
+ },
15510
+ });
15511
+ `, "src/favicon.svg": `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 51 44">
15512
+ <style>
15513
+ path { fill: #01050b; }
15514
+ @media (prefers-color-scheme: dark) {
15515
+ path { fill: #fff; }
15516
+ }
15517
+ </style>
15518
+ <path
15519
+ fill-rule="evenodd"
15520
+ clip-rule="evenodd"
15521
+ d="M40.3274 28.9788L35.9663 28.8378L34.9541 28.6881L18.1066 10.301L24.1073 0L26.8738 0.545413L41.5212 25.6848L40.3274 28.9788ZM20.5319 20.1112L18.1894 15.6731L14.6154 16.2904L0 41.378L0.894584 44H12.9453L20.5769 20.4134L20.5319 20.1112ZM44.9804 31.6253L20.3808 36.9197L17.5838 41.2974L19.9001 44H49.2036L51 41.9551L44.9804 31.6253Z"
15522
+ />
15523
+ </svg>
15524
+ `, "src/filters.ts": `import { choiceFilter } from '@altertable/data-app/contract';
15525
+
15526
+ // The options match the fictional rows; the query treats 'all' as every group.
15527
+ export const groupName = choiceFilter({
15528
+ key: 'group',
15529
+ label: 'Group',
15530
+ defaultValue: 'all',
15531
+ options: [
15532
+ { id: 'all', label: 'All groups' },
15533
+ { id: 'Alpha', label: 'Alpha' },
15534
+ { id: 'Beta', label: 'Beta' },
15535
+ { id: 'Gamma', label: 'Gamma' },
15536
+ ],
15537
+ });
15538
+ `, "src/index.html": `<!doctype html>
15539
+ <html lang="en">
15540
+ <head>
15541
+ <meta charset="UTF-8" />
15542
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
15543
+ <meta name="theme-color" content="#ffffff" />
15544
+ <title>Altertable app</title>
15545
+ <link rel="icon" href="./favicon.svg" type="image/svg+xml" />
15546
+ <script type="module" src="./main.tsx"></script>
15547
+ </head>
15548
+ <body>
15549
+ <div id="root"></div>
15550
+ </body>
15551
+ </html>
15552
+ `, "src/main.tsx": `import { mountDataApp } from '@altertable/data-app-react';
15553
+ import { installLocalQueryLakehouse } from '@altertable/data-app/client';
15554
+
15555
+ import { App } from '#app/App.tsx';
15556
+ import { dataApp } from '#config';
15557
+
15558
+ installLocalQueryLakehouse();
15559
+ mountDataApp({ app: dataApp, component: App });
15560
+ `, "src/operations.ts": `import { groupName } from '#app/filters.ts';
15561
+ import { dataApp } from '#config';
15562
+
15563
+ export const operations = dataApp.defineOperations({
15564
+ sampleCountsByGroup: dataApp.defineOperation({
15565
+ filters: { groupName },
15566
+ policy: { maxQueryRows: 10 },
15567
+ async run({ query }, { groupName }) {
15568
+ const { rows } = await query('sampleCountsByGroup', { groupName });
15569
+ return rows.map(row => ({
15570
+ groupName: row.group_name,
15571
+ sampleCount: row.sample_count,
15572
+ }));
15573
+ },
15574
+ }),
15575
+ });
15576
+ `, "src/server.ts": `import { serveLocalApp } from '@altertable/data-app-bun';
15577
+
15578
+ import page from '#app/index.html';
15579
+ import { dataApp } from '#config';
15580
+
15581
+ serveLocalApp({ page, app: dataApp });
15582
+ `, "tsconfig.json": `{
15583
+ "compilerOptions": {
15584
+ "target": "ESNext",
15585
+ "module": "Preserve",
15586
+ "moduleResolution": "bundler",
15587
+ "allowImportingTsExtensions": true,
15588
+ "resolveJsonModule": true,
15589
+ "jsx": "react-jsx",
15590
+ "strict": true,
15591
+ "noUncheckedIndexedAccess": true,
15592
+ "noEmit": true,
15593
+ "skipLibCheck": true,
15594
+ "types": ["bun"],
15595
+ "noImplicitReturns": true,
15596
+ "noFallthroughCasesInSwitch": true,
15597
+ "noImplicitOverride": true,
15598
+ "allowUnreachableCode": false,
15599
+ "noUncheckedSideEffectImports": true
15600
+ },
15601
+ "include": ["src", "app.ts"]
15209
15602
  }
15210
15603
  `, "bun.lock": `{
15211
15604
  "lockfileVersion": 2,
@@ -15214,11 +15607,11 @@ Commit app source, \`package.json\`, and \`bun.lock\`. On a fresh clone, run \`b
15214
15607
  "": {
15215
15608
  "name": "data-app-starter",
15216
15609
  "dependencies": {
15217
- "@altertable/data-app": "0.74.0",
15218
- "@altertable/data-app-bun": "0.74.0",
15219
- "@altertable/data-app-react": "0.74.0",
15220
- "react": "19.3.0",
15221
- "react-dom": "19.3.0",
15610
+ "@altertable/data-app": "0.79.0",
15611
+ "@altertable/data-app-bun": "0.79.0",
15612
+ "@altertable/data-app-react": "0.79.0",
15613
+ "react": "19.3.1",
15614
+ "react-dom": "19.3.1",
15222
15615
  },
15223
15616
  "devDependencies": {
15224
15617
  "@types/bun": "1.4.3",
@@ -15232,11 +15625,13 @@ Commit app source, \`package.json\`, and \`bun.lock\`. On a fresh clone, run \`b
15232
15625
  },
15233
15626
  },
15234
15627
  "packages": {
15235
- "@altertable/data-app": ["@altertable/data-app@0.74.0", "", { "dependencies": { "@internationalized/date": "3.12.4" } }, "sha512-19Y72gkpid1tKXtesofrwe4oyBUp5FknQ0smgOa1Ilx+8Y/2Xu9F4lHlhAuJU3r0zlEj2Rb/AYZcWXTfUXKZhQ=="],
15628
+ "@altertable/data-app": ["@altertable/data-app@0.79.0", "", { "dependencies": { "@internationalized/date": "3.12.4", "chrono-node": "2.10.3" } }, "sha512-ii9oIcN69/AikIBkfMnyMkDIpemyQ9iZzc4xwHKJpVsZvBOo9cORhni9Dba81eNUmHNPyPbBWygm1vLNPssBSw=="],
15629
+
15630
+ "@altertable/data-app-bun": ["@altertable/data-app-bun@0.79.0", "", { "dependencies": { "@altertable/data-app": "0.79.0", "@altertable/data-app-manifest": "0.79.0", "@altertable/lakehouse": "0.4.1", "get-tsconfig": "4.14.3" }, "bin": { "data-app-preview": "bin/preview.js" } }, "sha512-cRJJ1ARn6fJG1MlpjBSf7xE/WeEoEe9Ra4EIBPPMJzNq8roYBdY6ugtpczGhzeA7KDUkqlmz6xr7guFCHjOz2A=="],
15236
15631
 
15237
- "@altertable/data-app-bun": ["@altertable/data-app-bun@0.74.0", "", { "dependencies": { "@altertable/data-app": "0.74.0", "@altertable/lakehouse": "0.4.1", "get-tsconfig": "4.14.3" }, "bin": { "data-app-preview": "bin/preview.js" } }, "sha512-zxGaxeG4hzCNcPv20a0ZgrUpFONL5fllzThSlzbYnFM2Tkva3WFP0/N70KF02SddzaboskN5ouqrdUAErq/4Dw=="],
15632
+ "@altertable/data-app-manifest": ["@altertable/data-app-manifest@0.79.0", "", { "dependencies": { "typescript": "5.9.3" } }, "sha512-7z9DTIuceocnwI88C5hLqhjPub0wzgLef7T9nVTk7bhC5ldh4r1rV1Tz3/4iS7dRpEsNq/XOtAUuW2+x+11khQ=="],
15238
15633
 
15239
- "@altertable/data-app-react": ["@altertable/data-app-react@0.74.0", "", { "dependencies": { "@altertable/data-app": "0.74.0", "@floating-ui/react": "0.27.20", "@internationalized/date": "3.12.4", "@tanstack/react-query": "5.104.3", "fflate": "0.8.3", "fuzzysort": "4.0.2", "html-to-image": "1.11.13", "lucide-react": "1.59.0", "react-aria-components": "1.22.1", "recharts": "3.10.1" }, "peerDependencies": { "react": ">=19.2.0", "react-dom": ">=19.2.0" } }, "sha512-E85+w7D1NpiJaIqLaVkHUzMU/TQxdM32NuMEvBAiPO/mclmpjSnvroU5ml/ZkMwX00b1MiKowSgKyyu6q2ckSw=="],
15634
+ "@altertable/data-app-react": ["@altertable/data-app-react@0.79.0", "", { "dependencies": { "@altertable/data-app": "0.79.0", "@floating-ui/react": "0.27.20", "@internationalized/date": "3.12.4", "@tanstack/react-query": "5.107.1", "fflate": "0.8.3", "fuzzysort": "4.0.2", "html-to-image": "1.11.13", "lucide-react": "1.73.0", "react-aria-components": "1.22.1", "recharts": "3.10.1" }, "peerDependencies": { "react": ">=19.2.0", "react-dom": ">=19.2.0" } }, "sha512-joX5dN3W+73NH4knKYrocI26rDpm2UMgUqhDW0xczKa4dXpDqh2vTMqYJvKT45oVKVPDa14x4+2zH/gHHiAg4g=="],
15240
15635
 
15241
15636
  "@altertable/lakehouse": ["@altertable/lakehouse@0.4.1", "", {}, "sha512-m7d15cWt+WUGW7lVw2KYGD+Se8MzO25G7SWSuFd+OasBxWmOJNa2IrgvOHGVEbnZ+kexTUy9NjAGQ69sG4V91w=="],
15242
15637
 
@@ -15354,9 +15749,9 @@ Commit app source, \`package.json\`, and \`bun.lock\`. On a fresh clone, run \`b
15354
15749
 
15355
15750
  "@swc/helpers": ["@swc/helpers@0.5.23", "", { "dependencies": { "tslib": "^2.8.0" } }, "sha512-5lSsMOTXURePglDfvuAQUqkGek9Hg2kksOYay2m0+XR++b2NWYL/4sWyuvVBIs8oKnJaxkdi9whaL/sqN13afw=="],
15356
15751
 
15357
- "@tanstack/query-core": ["@tanstack/query-core@5.104.3", "", {}, "sha512-DZY9TuJAOgU3UyHUhXb4CcTYEHNZszlwkPg4VViIwTxOKzLprPUU+rbaPZQd3srqkGOtpaDdKpW972UV/LKlcg=="],
15752
+ "@tanstack/query-core": ["@tanstack/query-core@5.107.1", "", {}, "sha512-PSyAik11oQBEVOiVy5hjZWHmoUqOXqK1WYy4v55mcxozEfKaQgpUMsgnXhWjuESzSht8JfzqMS1m6M/9CpNgvg=="],
15358
15753
 
15359
- "@tanstack/react-query": ["@tanstack/react-query@5.104.3", "", { "dependencies": { "@tanstack/query-core": "5.104.3" }, "peerDependencies": { "react": "^18 || ^19" } }, "sha512-5Ts1ImwJKqoJgPkLxl9WrPQy1JEoEmti3MaaODCfBamHUGFk57IFrc+AIksPq+BAm10EsroX56qm398Z42LG7w=="],
15754
+ "@tanstack/react-query": ["@tanstack/react-query@5.107.1", "", { "dependencies": { "@tanstack/query-core": "5.107.1" }, "peerDependencies": { "@types/react": "^18 || ^19", "react": "^18 || ^19" }, "optionalPeers": ["@types/react"] }, "sha512-udCOOLp3ZAheUrIHLCe+ZZge6nr2ZUrGMSWcCuXsjY1Bf2JeeE09oxst97PILiCY6N8xo/7bIo3Hvz13zh06FA=="],
15360
15755
 
15361
15756
  "@types/bun": ["@types/bun@1.4.3", "", { "dependencies": { "bun-types": "1.4.3" } }, "sha512-N67Pqy8JXbAY/j0tNraS3V5mubGvc6rrrNDmDCtZLlFzccbUJPDb0tvgUBC5q4m8ybkP93Jcn1QB+RYQ6PvBhw=="],
15362
15757
 
@@ -15430,6 +15825,8 @@ Commit app source, \`package.json\`, and \`bun.lock\`. On a fresh clone, run \`b
15430
15825
 
15431
15826
  "bun-types": ["bun-types@1.4.3", "", { "dependencies": { "@types/node": "*", "undici-types": "*" } }, "sha512-tinRJNGOmUN+tEAsn2y2e942n9JHRHR42iUYzDH75NmhJqVBokGSQkkfSFdNWwsANIdrK6ACH9t01M452YyTwg=="],
15432
15827
 
15828
+ "chrono-node": ["chrono-node@2.10.3", "", {}, "sha512-MOfrzXgSMZTH4SZ5gyRKQCVwiCrCKY+uYkSJiWoRLXS88DA6WGJm8UjgS+VVEuUQeew/UUXaxrO+SeDn/WCisg=="],
15829
+
15433
15830
  "client-only": ["client-only@0.0.1", "", {}, "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA=="],
15434
15831
 
15435
15832
  "clsx": ["clsx@2.1.1", "", {}, "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA=="],
@@ -15476,7 +15873,7 @@ Commit app source, \`package.json\`, and \`bun.lock\`. On a fresh clone, run \`b
15476
15873
 
15477
15874
  "internmap": ["internmap@2.0.3", "", {}, "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg=="],
15478
15875
 
15479
- "lucide-react": ["lucide-react@1.59.0", "", { "peerDependencies": { "@types/react": "*", "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-5qgMyyCPU6OvnKpLS2t693+ZtiqA8oaSweWoUows0BLFKFf6V75m4+CptpmohZHpD5IuOVIBXHBBiv2vpLJmtw=="],
15876
+ "lucide-react": ["lucide-react@1.73.0", "", { "peerDependencies": { "@types/react": "*", "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-fVOzGviL9mTfHenG1PbCfIceavyGlnpYNSYr+aGZHLRymAJ7DTP6KHuqt0uBkCKAoenr1UVkwSbDIYt2xIesEQ=="],
15480
15877
 
15481
15878
  "oxfmt": ["oxfmt@0.71.0", "", { "dependencies": { "tinypool": "2.2.0" }, "optionalDependencies": { "@oxfmt/binding-android-arm-eabi": "0.71.0", "@oxfmt/binding-android-arm64": "0.71.0", "@oxfmt/binding-darwin-arm64": "0.71.0", "@oxfmt/binding-darwin-x64": "0.71.0", "@oxfmt/binding-freebsd-x64": "0.71.0", "@oxfmt/binding-linux-arm-gnueabihf": "0.71.0", "@oxfmt/binding-linux-arm-musleabihf": "0.71.0", "@oxfmt/binding-linux-arm64-gnu": "0.71.0", "@oxfmt/binding-linux-arm64-musl": "0.71.0", "@oxfmt/binding-linux-ppc64-gnu": "0.71.0", "@oxfmt/binding-linux-riscv64-gnu": "0.71.0", "@oxfmt/binding-linux-riscv64-musl": "0.71.0", "@oxfmt/binding-linux-s390x-gnu": "0.71.0", "@oxfmt/binding-linux-x64-gnu": "0.71.0", "@oxfmt/binding-linux-x64-musl": "0.71.0", "@oxfmt/binding-openharmony-arm64": "0.71.0", "@oxfmt/binding-win32-arm64-msvc": "0.71.0", "@oxfmt/binding-win32-ia32-msvc": "0.71.0", "@oxfmt/binding-win32-x64-msvc": "0.71.0" }, "peerDependencies": { "svelte": "^5.0.0", "vite-plus": "*" }, "optionalPeers": ["svelte", "vite-plus"], "bin": { "oxfmt": "bin/oxfmt" } }, "sha512-lUPUl0d/+Io5pDrsPXWs6rB4N/bpB78oj9CTDpnbulfDz+0r3XXcHPlQ7kRPJ2GjIT4nX+/mcqunOeP9BvsEtg=="],
15482
15879
 
@@ -15484,223 +15881,50 @@ Commit app source, \`package.json\`, and \`bun.lock\`. On a fresh clone, run \`b
15484
15881
 
15485
15882
  "oxlint-tsgolint": ["oxlint-tsgolint@7.0.2003", "", { "optionalDependencies": { "@oxlint-tsgolint/darwin-arm64": "7.0.2003", "@oxlint-tsgolint/darwin-x64": "7.0.2003", "@oxlint-tsgolint/linux-arm64": "7.0.2003", "@oxlint-tsgolint/linux-x64": "7.0.2003", "@oxlint-tsgolint/win32-arm64": "7.0.2003", "@oxlint-tsgolint/win32-x64": "7.0.2003" }, "bin": { "tsgolint": "./bin/tsgolint.js" } }, "sha512-VnK4zlqgmgq/7ZcjzCk/WpN8kKFsYGcB85Io9qT3wL4K8Un3RKmJkp793crNETieMusPMKOA4a+Mw2wbteI6TQ=="],
15486
15883
 
15487
- "react": ["react@19.3.0", "", {}, "sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog=="],
15884
+ "react": ["react@19.3.1", "", {}, "sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw=="],
15488
15885
 
15489
15886
  "react-aria": ["react-aria@3.53.1", "", { "dependencies": { "@internationalized/date": "^3.12.4", "@internationalized/number": "^3.6.9", "@internationalized/string": "^3.2.10", "@react-types/shared": "^3.37.0", "@swc/helpers": "^0.5.0", "aria-hidden": "^1.2.3", "clsx": "^2.0.0", "react-stately": "3.51.0", "use-sync-external-store": "^1.6.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1", "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, "sha512-dikisyOjJd3D2fFrIDWmVWzqiLz5B86GzZv1zxs7xI4dVc0JIz/1Wa52I20gYvVL2WXeFXlygYsle/QcOMhtcg=="],
15490
15887
 
15491
15888
  "react-aria-components": ["react-aria-components@1.22.1", "", { "dependencies": { "@internationalized/date": "^3.12.4", "@internationalized/string": "^3.2.10", "@react-types/shared": "^3.37.0", "@swc/helpers": "^0.5.0", "client-only": "^0.0.1", "react-aria": "3.53.1", "react-stately": "3.51.0", "use-sync-external-store": "^1.6.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1", "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, "sha512-UTHaYHOaM71bOCjGPF50DcLywlrwAodE63IP64LB4kO+OizatQEL8TesVEOM8+TkBeSgHoflJ45388IlJfa7aw=="],
15492
15889
 
15493
- "react-dom": ["react-dom@19.3.0", "", { "dependencies": { "scheduler": "^0.28.0" }, "peerDependencies": { "react": "^19.3.0" } }, "sha512-JDk8dgif51OjFoDE70+OT9ICyYr+69HlmihNwp1+Nsfbna3t5sIiCa9ZJktDmQ4/1b/rn26hIAR2uYXDMr5r0Q=="],
15890
+ "react-dom": ["react-dom@19.3.1", "", { "dependencies": { "scheduler": "^0.28.0" }, "peerDependencies": { "react": "^19.3.1" } }, "sha512-Y0bARz53lhEC1NMCASs0/j+faB/zqt3R8hpvg1e8+61ZVJ4UL0UdC4cBbXfZMcIuhrfgeILTLe+ZeBCavQPtKQ=="],
15494
15891
 
15495
15892
  "react-is": ["react-is@19.3.0", "", {}, "sha512-UpMYezM4v5/18F28aC66AEsjXIgE02kyEMH6yLdgLXu/UTfa1Ntwck/nNLrbqJsEXW7gPb0coNO9FQse9WTovA=="],
15496
15893
 
15497
15894
  "react-redux": ["react-redux@9.3.0", "", { "dependencies": { "@types/use-sync-external-store": "^0.0.6", "use-sync-external-store": "^1.4.0" }, "peerDependencies": { "@types/react": "^18.2.25 || ^19", "react": "^18.0 || ^19", "redux": "^5.0.0" }, "optionalPeers": ["@types/react", "redux"] }, "sha512-KQopgqFo/p/fgmAs5qz6p5RWaNAzq40WAu7fJIXnQpYxFPbJYtsJPWvGeF2rOBaY/kEuV77AVsX8TsQzKm+A/g=="],
15498
15895
 
15499
- "react-stately": ["react-stately@3.51.0", "", { "dependencies": { "@internationalized/date": "^3.12.4", "@internationalized/number": "^3.6.9", "@internationalized/string": "^3.2.10", "@react-types/shared": "^3.37.0", "@swc/helpers": "^0.5.0", "use-sync-external-store": "^1.6.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, "sha512-YJcmkAXu2XOQP97hO/qz/cC3qv9kni3oVhwBlxWr358BHePJUpY15XwL3YSRMKxYt4EkslPqAz11JRirMfANGw=="],
15500
-
15501
- "recharts": ["recharts@3.10.1", "", { "dependencies": { "@reduxjs/toolkit": "^1.9.0 || 2.x.x", "clsx": "^2.1.1", "decimal.js-light": "^2.5.1", "es-toolkit": "^1.39.3", "eventemitter3": "^5.0.1", "immer": "^11.1.8", "react-redux": "8.x.x || 9.x.x", "reselect": "5.2.0", "tiny-invariant": "^1.3.3", "use-sync-external-store": "^1.2.2", "victory-vendor": "^37.0.2" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-is": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-QXFrvt6IVcw7eeZCoyXTwkIJAX3Dv1nyVhMicXJ47GsGDDpcN8z6o644DibE9XjpBTThtsomLKnTV6lc+cVFUA=="],
15502
-
15503
- "redux": ["redux@5.0.1", "", {}, "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w=="],
15504
-
15505
- "redux-thunk": ["redux-thunk@3.1.0", "", { "peerDependencies": { "redux": "^5.0.0" } }, "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw=="],
15506
-
15507
- "reselect": ["reselect@5.2.0", "", {}, "sha512-AgZ3UOZm3YndfrJ4OYjgrT7bmCm/1iqkjvEfH/oYjzh6PD2qw4QuT3jjnXIrpdt4MTpMXclMT3lXbmRY+XRakw=="],
15508
-
15509
- "resolve-pkg-maps": ["resolve-pkg-maps@1.0.0", "", {}, "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw=="],
15510
-
15511
- "scheduler": ["scheduler@0.28.0", "", {}, "sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw=="],
15512
-
15513
- "tabbable": ["tabbable@6.5.0", "", {}, "sha512-wieBHXygIm7OyQOu5hQlkk62/WyCFYGlWg7L6/ZCUZwx0o398Zkn4pVmMyfYhfMG8kGrj/Krt8eIk6UKC6VzwA=="],
15514
-
15515
- "tiny-invariant": ["tiny-invariant@1.3.3", "", {}, "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg=="],
15516
-
15517
- "tinypool": ["tinypool@2.2.0", "", {}, "sha512-jBrmx4lYmaC9k/mgPbylxs7kBUxHtD8256up+HjLaDFfXScKJQyil+SWXSvhAtT7XHo+yTVlpB81PGmHP8oLSQ=="],
15518
-
15519
- "tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
15520
-
15521
- "typescript": ["typescript@7.0.2", "", { "optionalDependencies": { "@typescript/typescript-aix-ppc64": "7.0.2", "@typescript/typescript-darwin-arm64": "7.0.2", "@typescript/typescript-darwin-x64": "7.0.2", "@typescript/typescript-freebsd-arm64": "7.0.2", "@typescript/typescript-freebsd-x64": "7.0.2", "@typescript/typescript-linux-arm": "7.0.2", "@typescript/typescript-linux-arm64": "7.0.2", "@typescript/typescript-linux-loong64": "7.0.2", "@typescript/typescript-linux-mips64el": "7.0.2", "@typescript/typescript-linux-ppc64": "7.0.2", "@typescript/typescript-linux-riscv64": "7.0.2", "@typescript/typescript-linux-s390x": "7.0.2", "@typescript/typescript-linux-x64": "7.0.2", "@typescript/typescript-netbsd-arm64": "7.0.2", "@typescript/typescript-netbsd-x64": "7.0.2", "@typescript/typescript-openbsd-arm64": "7.0.2", "@typescript/typescript-openbsd-x64": "7.0.2", "@typescript/typescript-sunos-x64": "7.0.2", "@typescript/typescript-win32-arm64": "7.0.2", "@typescript/typescript-win32-x64": "7.0.2" }, "bin": { "tsc": "bin/tsc" } }, "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA=="],
15522
-
15523
- "undici-types": ["undici-types@8.9.0", "", {}, "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg=="],
15524
-
15525
- "use-sync-external-store": ["use-sync-external-store@1.7.0", "", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-6L+EeigHMQhdaIPNIFUKwfWJSwWFQ8gJbJ2DLOs5sDIegTwR9fRxvnM3uciHKjIZhFz+KAv2emhWMRvDmMcY8A=="],
15526
-
15527
- "victory-vendor": ["victory-vendor@37.3.6", "", { "dependencies": { "@types/d3-array": "^3.0.3", "@types/d3-ease": "^3.0.0", "@types/d3-interpolate": "^3.0.1", "@types/d3-scale": "^4.0.2", "@types/d3-shape": "^3.1.0", "@types/d3-time": "^3.0.0", "@types/d3-timer": "^3.0.0", "d3-array": "^3.1.6", "d3-ease": "^3.0.1", "d3-interpolate": "^3.0.1", "d3-scale": "^4.0.2", "d3-shape": "^3.1.0", "d3-time": "^3.0.0", "d3-timer": "^3.0.1" } }, "sha512-SbPDPdDBYp+5MJHhBCAyI7wKM3d5ivekigc2Dk2s7pgbZ9wIgIBYGVw4zGHBml/qTFbexrofXW6Gu4noGxrOwQ=="],
15528
- }
15529
- }
15530
- `, "bunfig.toml": `[install]
15531
- exact = true
15532
- `, "package.json": `{
15533
- "name": "data-app-starter",
15534
- "private": true,
15535
- "type": "module",
15536
- "imports": {
15537
- "#app/*": "./src/*",
15538
- "#config": "./app.json"
15539
- },
15540
- "scripts": {
15541
- "typecheck": "tsc --noEmit",
15542
- "lint": "oxlint --type-aware src",
15543
- "format": "oxfmt src",
15544
- "format:check": "oxfmt --check src",
15545
- "dev": "bun --hot src/server.ts",
15546
- "build": "bun build src/index.html --outdir=dist --production"
15547
- },
15548
- "dependencies": {
15549
- "@altertable/data-app": "0.74.0",
15550
- "@altertable/data-app-bun": "0.74.0",
15551
- "@altertable/data-app-react": "0.74.0",
15552
- "react": "19.3.0",
15553
- "react-dom": "19.3.0"
15554
- },
15555
- "devDependencies": {
15556
- "@types/bun": "1.4.3",
15557
- "@types/react": "19.3.0",
15558
- "@types/react-dom": "19.3.0",
15559
- "oxfmt": "0.71.0",
15560
- "oxlint": "1.86.0",
15561
- "oxlint-tsgolint": "7.0.2003",
15562
- "typescript": "7.0.2"
15563
- }
15564
- }
15565
- `, "src/App.tsx": `import { GettingStarted } from '@altertable/data-app-react/ui';
15566
-
15567
- import { dataContext } from '#app/data-context.ts';
15568
-
15569
- /** Connectivity-only screen. Investigate the requested question, then replace this with a view
15570
- * that leads with a supported finding and explores the useful angles behind it. */
15571
- export function App() {
15572
- return <GettingStarted dataContext={dataContext} />;
15573
- }
15574
- `, "src/assets.d.ts": `declare module '*.css';
15575
- `, "src/config.ts": `import { defineDataApp } from '@altertable/data-app';
15576
- import { parseAppearance } from '@altertable/data-app/appearance';
15577
-
15578
- import app from '#config';
15579
-
15580
- export default defineDataApp({
15581
- title: app.title,
15582
- description:
15583
- 'Verify the configured lakehouse connection before authoring an exploration.',
15584
- scope: app.scope,
15585
- appearance: parseAppearance(app.appearance),
15586
- queries: {
15587
- connection: {
15588
- statement: 'SELECT 1 AS connection_check',
15589
- params: {},
15590
- projections: { connection_check: { type: 'number' } },
15591
- },
15592
- },
15593
- });
15594
- `, "src/data-context.ts": `import { createDataContext } from '@altertable/data-app-react';
15595
- import { defineQueryNames } from '@altertable/data-app/contract';
15596
-
15597
- import type app from '#app/config.ts';
15598
-
15599
- /** Setup context only. Replace it with the exploration's scope, exact definitions, limitations,
15600
- * and query evidence after inspecting the source data. */
15601
- const queryNames = defineQueryNames({
15602
- connection: 'connection' satisfies keyof typeof app.queries,
15603
- });
15604
-
15605
- export const dataContext = createDataContext(queryNames)({
15606
- description:
15607
- 'This starter runs a lightweight query to verify that the selected lakehouse profile can execute SQL. It does not check access to individual datasets. Replace the check with a query that answers a real question before sharing the app.',
15608
- glossary: {
15609
- connectionVerified: {
15610
- term: 'Connected',
15611
- definition: 'The latest connection-check query completed successfully.',
15612
- queryNames: [queryNames.connection],
15613
- },
15614
- },
15615
- });
15616
- `, "src/favicon.svg": `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 51 44">
15617
- <style>
15618
- path { fill: #01050b; }
15619
- @media (prefers-color-scheme: dark) {
15620
- path { fill: #fff; }
15621
- }
15622
- </style>
15623
- <path
15624
- fill-rule="evenodd"
15625
- clip-rule="evenodd"
15626
- d="M40.3274 28.9788L35.9663 28.8378L34.9541 28.6881L18.1066 10.301L24.1073 0L26.8738 0.545413L41.5212 25.6848L40.3274 28.9788ZM20.5319 20.1112L18.1894 15.6731L14.6154 16.2904L0 41.378L0.894584 44H12.9453L20.5769 20.4134L20.5319 20.1112ZM44.9804 31.6253L20.3808 36.9197L17.5838 41.2974L19.9001 44H49.2036L51 41.9551L44.9804 31.6253Z"
15627
- />
15628
- </svg>
15629
- `, "src/index.html": `<!doctype html>
15630
- <html lang="en">
15631
- <head>
15632
- <meta charset="UTF-8" />
15633
- <meta name="viewport" content="width=device-width, initial-scale=1" />
15634
- <meta name="theme-color" content="#ffffff" />
15635
- <title>Altertable app</title>
15636
- <link rel="icon" href="./favicon.svg" type="image/svg+xml" />
15637
- <script type="module" src="./main.tsx"></script>
15638
- </head>
15639
- <body>
15640
- <div id="root"></div>
15641
- </body>
15642
- </html>
15643
- `, "src/main.tsx": `import { injectDataAppStyles, mountDataApp } from '@altertable/data-app-react';
15896
+ "react-stately": ["react-stately@3.51.0", "", { "dependencies": { "@internationalized/date": "^3.12.4", "@internationalized/number": "^3.6.9", "@internationalized/string": "^3.2.10", "@react-types/shared": "^3.37.0", "@swc/helpers": "^0.5.0", "use-sync-external-store": "^1.6.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, "sha512-YJcmkAXu2XOQP97hO/qz/cC3qv9kni3oVhwBlxWr358BHePJUpY15XwL3YSRMKxYt4EkslPqAz11JRirMfANGw=="],
15644
15897
 
15645
- import { App } from '#app/App.tsx';
15646
- import app from '#app/config.ts';
15898
+ "recharts": ["recharts@3.10.1", "", { "dependencies": { "@reduxjs/toolkit": "^1.9.0 || 2.x.x", "clsx": "^2.1.1", "decimal.js-light": "^2.5.1", "es-toolkit": "^1.39.3", "eventemitter3": "^5.0.1", "immer": "^11.1.8", "react-redux": "8.x.x || 9.x.x", "reselect": "5.2.0", "tiny-invariant": "^1.3.3", "use-sync-external-store": "^1.2.2", "victory-vendor": "^37.0.2" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-is": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-QXFrvt6IVcw7eeZCoyXTwkIJAX3Dv1nyVhMicXJ47GsGDDpcN8z6o644DibE9XjpBTThtsomLKnTV6lc+cVFUA=="],
15647
15899
 
15648
- injectDataAppStyles();
15649
- mountDataApp({ app, component: App });
15650
- `, "src/operations.ts": `import { connectionCheck } from '@altertable/data-app/contract';
15900
+ "redux": ["redux@5.0.1", "", {}, "sha512-M9/ELqF6fy8FwmkpnF0S3YKOqMyoWJ4+CS5Efg2ct3oY9daQvd/Pc71FpGZsVsbl3Cpb+IIcjBDUnnyBdQbq4w=="],
15651
15901
 
15652
- import app from '#app/config.ts';
15902
+ "redux-thunk": ["redux-thunk@3.1.0", "", { "peerDependencies": { "redux": "^5.0.0" } }, "sha512-NW2r5T6ksUKXCabzhL9z+h206HQw/NJkcLm1GPImRQ8IzfXwRGqjVhKJGauHirT0DAuyy6hjdnMZaRoAcy0Klw=="],
15653
15903
 
15654
- /** Connectivity probe only: its successful query supplies no analytical result. Replace it with
15655
- * bounded, validated operations that cover the questions the finished app will answer. */
15656
- export const operations = { connection: connectionCheck(app.queries) };
15657
- `, "src/preview.ts": `import { resolve } from 'node:path';
15904
+ "reselect": ["reselect@5.2.0", "", {}, "sha512-AgZ3UOZm3YndfrJ4OYjgrT7bmCm/1iqkjvEfH/oYjzh6PD2qw4QuT3jjnXIrpdt4MTpMXclMT3lXbmRY+XRakw=="],
15658
15905
 
15659
- import { localLakehouse } from '@altertable/data-app-bun';
15660
- import { serveAppFile } from '@altertable/data-app-bun/preview';
15906
+ "resolve-pkg-maps": ["resolve-pkg-maps@1.0.0", "", {}, "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw=="],
15661
15907
 
15662
- const preview = await serveAppFile({
15663
- file: resolve(import.meta.dir, '../index.tsx'),
15664
- port: Number(process.env.PORT ?? 25837),
15665
- lakehouse: localLakehouse(),
15666
- });
15908
+ "scheduler": ["scheduler@0.28.0", "", {}, "sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw=="],
15667
15909
 
15668
- let stopping = false;
15669
- async function shutdown() {
15670
- if (stopping) return;
15671
- stopping = true;
15672
- try {
15673
- await preview.stop();
15674
- process.exit(0);
15675
- } catch (error) {
15676
- console.error(error);
15677
- process.exit(1);
15678
- }
15679
- }
15680
- process.on('SIGINT', shutdown);
15681
- process.on('SIGTERM', shutdown);
15682
- console.log(\`Data app running at \${preview.url}\`);
15683
- `, "src/server.ts": `import { serveLocalApp } from '@altertable/data-app-bun';
15910
+ "tabbable": ["tabbable@6.5.0", "", {}, "sha512-wieBHXygIm7OyQOu5hQlkk62/WyCFYGlWg7L6/ZCUZwx0o398Zkn4pVmMyfYhfMG8kGrj/Krt8eIk6UKC6VzwA=="],
15684
15911
 
15685
- import app from '#app/config.ts';
15686
- import page from '#app/index.html';
15687
- import { operations } from '#app/operations.ts';
15912
+ "tiny-invariant": ["tiny-invariant@1.3.3", "", {}, "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg=="],
15688
15913
 
15689
- serveLocalApp({ page, operations, title: app.title });
15690
- `, "tsconfig.json": `{
15691
- "compilerOptions": {
15692
- "target": "ESNext",
15693
- "module": "Preserve",
15694
- "moduleResolution": "bundler",
15695
- "allowImportingTsExtensions": true,
15696
- "resolveJsonModule": true,
15697
- "jsx": "react-jsx",
15698
- "strict": true,
15699
- "noEmit": true,
15700
- "skipLibCheck": true,
15701
- "types": ["bun"]
15702
- },
15703
- "include": ["src"]
15914
+ "tinypool": ["tinypool@2.2.0", "", {}, "sha512-jBrmx4lYmaC9k/mgPbylxs7kBUxHtD8256up+HjLaDFfXScKJQyil+SWXSvhAtT7XHo+yTVlpB81PGmHP8oLSQ=="],
15915
+
15916
+ "tslib": ["tslib@2.8.1", "", {}, "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="],
15917
+
15918
+ "typescript": ["typescript@7.0.2", "", { "optionalDependencies": { "@typescript/typescript-aix-ppc64": "7.0.2", "@typescript/typescript-darwin-arm64": "7.0.2", "@typescript/typescript-darwin-x64": "7.0.2", "@typescript/typescript-freebsd-arm64": "7.0.2", "@typescript/typescript-freebsd-x64": "7.0.2", "@typescript/typescript-linux-arm": "7.0.2", "@typescript/typescript-linux-arm64": "7.0.2", "@typescript/typescript-linux-loong64": "7.0.2", "@typescript/typescript-linux-mips64el": "7.0.2", "@typescript/typescript-linux-ppc64": "7.0.2", "@typescript/typescript-linux-riscv64": "7.0.2", "@typescript/typescript-linux-s390x": "7.0.2", "@typescript/typescript-linux-x64": "7.0.2", "@typescript/typescript-netbsd-arm64": "7.0.2", "@typescript/typescript-netbsd-x64": "7.0.2", "@typescript/typescript-openbsd-arm64": "7.0.2", "@typescript/typescript-openbsd-x64": "7.0.2", "@typescript/typescript-sunos-x64": "7.0.2", "@typescript/typescript-win32-arm64": "7.0.2", "@typescript/typescript-win32-x64": "7.0.2" }, "bin": { "tsc": "bin/tsc" } }, "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA=="],
15919
+
15920
+ "undici-types": ["undici-types@8.9.0", "", {}, "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg=="],
15921
+
15922
+ "use-sync-external-store": ["use-sync-external-store@1.7.0", "", { "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-6L+EeigHMQhdaIPNIFUKwfWJSwWFQ8gJbJ2DLOs5sDIegTwR9fRxvnM3uciHKjIZhFz+KAv2emhWMRvDmMcY8A=="],
15923
+
15924
+ "victory-vendor": ["victory-vendor@37.3.6", "", { "dependencies": { "@types/d3-array": "^3.0.3", "@types/d3-ease": "^3.0.0", "@types/d3-interpolate": "^3.0.1", "@types/d3-scale": "^4.0.2", "@types/d3-shape": "^3.1.0", "@types/d3-time": "^3.0.0", "@types/d3-timer": "^3.0.0", "d3-array": "^3.1.6", "d3-ease": "^3.0.1", "d3-interpolate": "^3.0.1", "d3-scale": "^4.0.2", "d3-shape": "^3.1.0", "d3-time": "^3.0.0", "d3-timer": "^3.0.1" } }, "sha512-SbPDPdDBYp+5MJHhBCAyI7wKM3d5ivekigc2Dk2s7pgbZ9wIgIBYGVw4zGHBml/qTFbexrofXW6Gu4noGxrOwQ=="],
15925
+
15926
+ "@altertable/data-app-manifest/typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
15927
+ }
15704
15928
  }
15705
15929
  ` }, filePreview: { "bun.lock": `{
15706
15930
  "lockfileVersion": 2,
@@ -15709,23 +15933,23 @@ serveLocalApp({ page, operations, title: app.title });
15709
15933
  "": {
15710
15934
  "name": "data-app-file-preview",
15711
15935
  "dependencies": {
15712
- "@altertable/data-app": "0.74.0",
15713
- "@altertable/data-app-bun": "0.74.0",
15714
- "@altertable/data-app-manifest": "0.74.0",
15715
- "@altertable/data-app-react": "0.74.0",
15716
- "react": "19.3.0",
15717
- "react-dom": "19.3.0",
15936
+ "@altertable/data-app": "0.79.0",
15937
+ "@altertable/data-app-bun": "0.79.0",
15938
+ "@altertable/data-app-manifest": "0.79.0",
15939
+ "@altertable/data-app-react": "0.79.0",
15940
+ "react": "19.3.1",
15941
+ "react-dom": "19.3.1",
15718
15942
  },
15719
15943
  },
15720
15944
  },
15721
15945
  "packages": {
15722
- "@altertable/data-app": ["@altertable/data-app@0.74.0", "", { "dependencies": { "@internationalized/date": "3.12.4" } }, "sha512-19Y72gkpid1tKXtesofrwe4oyBUp5FknQ0smgOa1Ilx+8Y/2Xu9F4lHlhAuJU3r0zlEj2Rb/AYZcWXTfUXKZhQ=="],
15946
+ "@altertable/data-app": ["@altertable/data-app@0.79.0", "", { "dependencies": { "@internationalized/date": "3.12.4", "chrono-node": "2.10.3" } }, "sha512-ii9oIcN69/AikIBkfMnyMkDIpemyQ9iZzc4xwHKJpVsZvBOo9cORhni9Dba81eNUmHNPyPbBWygm1vLNPssBSw=="],
15723
15947
 
15724
- "@altertable/data-app-bun": ["@altertable/data-app-bun@0.74.0", "", { "dependencies": { "@altertable/data-app": "0.74.0", "@altertable/lakehouse": "0.4.1", "get-tsconfig": "4.14.3" }, "bin": { "data-app-preview": "bin/preview.js" } }, "sha512-zxGaxeG4hzCNcPv20a0ZgrUpFONL5fllzThSlzbYnFM2Tkva3WFP0/N70KF02SddzaboskN5ouqrdUAErq/4Dw=="],
15948
+ "@altertable/data-app-bun": ["@altertable/data-app-bun@0.79.0", "", { "dependencies": { "@altertable/data-app": "0.79.0", "@altertable/data-app-manifest": "0.79.0", "@altertable/lakehouse": "0.4.1", "get-tsconfig": "4.14.3" }, "bin": { "data-app-preview": "bin/preview.js" } }, "sha512-cRJJ1ARn6fJG1MlpjBSf7xE/WeEoEe9Ra4EIBPPMJzNq8roYBdY6ugtpczGhzeA7KDUkqlmz6xr7guFCHjOz2A=="],
15725
15949
 
15726
- "@altertable/data-app-manifest": ["@altertable/data-app-manifest@0.74.0", "", { "dependencies": { "typescript": "5.9.3" } }, "sha512-PQEsKR1VpRkbXVn6LlmwlDBmPode0wlCJ9ivYlk4KKc9vgZcdHpjPuy+G+gaTKiIrYPJpxsLS0hcYxMENNoP2g=="],
15950
+ "@altertable/data-app-manifest": ["@altertable/data-app-manifest@0.79.0", "", { "dependencies": { "typescript": "5.9.3" } }, "sha512-7z9DTIuceocnwI88C5hLqhjPub0wzgLef7T9nVTk7bhC5ldh4r1rV1Tz3/4iS7dRpEsNq/XOtAUuW2+x+11khQ=="],
15727
15951
 
15728
- "@altertable/data-app-react": ["@altertable/data-app-react@0.74.0", "", { "dependencies": { "@altertable/data-app": "0.74.0", "@floating-ui/react": "0.27.20", "@internationalized/date": "3.12.4", "@tanstack/react-query": "5.104.3", "fflate": "0.8.3", "fuzzysort": "4.0.2", "html-to-image": "1.11.13", "lucide-react": "1.59.0", "react-aria-components": "1.22.1", "recharts": "3.10.1" }, "peerDependencies": { "react": ">=19.2.0", "react-dom": ">=19.2.0" } }, "sha512-E85+w7D1NpiJaIqLaVkHUzMU/TQxdM32NuMEvBAiPO/mclmpjSnvroU5ml/ZkMwX00b1MiKowSgKyyu6q2ckSw=="],
15952
+ "@altertable/data-app-react": ["@altertable/data-app-react@0.79.0", "", { "dependencies": { "@altertable/data-app": "0.79.0", "@floating-ui/react": "0.27.20", "@internationalized/date": "3.12.4", "@tanstack/react-query": "5.107.1", "fflate": "0.8.3", "fuzzysort": "4.0.2", "html-to-image": "1.11.13", "lucide-react": "1.73.0", "react-aria-components": "1.22.1", "recharts": "3.10.1" }, "peerDependencies": { "react": ">=19.2.0", "react-dom": ">=19.2.0" } }, "sha512-joX5dN3W+73NH4knKYrocI26rDpm2UMgUqhDW0xczKa4dXpDqh2vTMqYJvKT45oVKVPDa14x4+2zH/gHHiAg4g=="],
15729
15953
 
15730
15954
  "@altertable/lakehouse": ["@altertable/lakehouse@0.4.1", "", {}, "sha512-m7d15cWt+WUGW7lVw2KYGD+Se8MzO25G7SWSuFd+OasBxWmOJNa2IrgvOHGVEbnZ+kexTUy9NjAGQ69sG4V91w=="],
15731
15955
 
@@ -15755,9 +15979,9 @@ serveLocalApp({ page, operations, title: app.title });
15755
15979
 
15756
15980
  "@swc/helpers": ["@swc/helpers@0.5.23", "", { "dependencies": { "tslib": "^2.8.0" } }, "sha512-5lSsMOTXURePglDfvuAQUqkGek9Hg2kksOYay2m0+XR++b2NWYL/4sWyuvVBIs8oKnJaxkdi9whaL/sqN13afw=="],
15757
15981
 
15758
- "@tanstack/query-core": ["@tanstack/query-core@5.104.3", "", {}, "sha512-DZY9TuJAOgU3UyHUhXb4CcTYEHNZszlwkPg4VViIwTxOKzLprPUU+rbaPZQd3srqkGOtpaDdKpW972UV/LKlcg=="],
15982
+ "@tanstack/query-core": ["@tanstack/query-core@5.107.1", "", {}, "sha512-PSyAik11oQBEVOiVy5hjZWHmoUqOXqK1WYy4v55mcxozEfKaQgpUMsgnXhWjuESzSht8JfzqMS1m6M/9CpNgvg=="],
15759
15983
 
15760
- "@tanstack/react-query": ["@tanstack/react-query@5.104.3", "", { "dependencies": { "@tanstack/query-core": "5.104.3" }, "peerDependencies": { "react": "^18 || ^19" } }, "sha512-5Ts1ImwJKqoJgPkLxl9WrPQy1JEoEmti3MaaODCfBamHUGFk57IFrc+AIksPq+BAm10EsroX56qm398Z42LG7w=="],
15984
+ "@tanstack/react-query": ["@tanstack/react-query@5.107.1", "", { "dependencies": { "@tanstack/query-core": "5.107.1" }, "peerDependencies": { "@types/react": "^18 || ^19", "react": "^18 || ^19" }, "optionalPeers": ["@types/react"] }, "sha512-udCOOLp3ZAheUrIHLCe+ZZge6nr2ZUrGMSWcCuXsjY1Bf2JeeE09oxst97PILiCY6N8xo/7bIo3Hvz13zh06FA=="],
15761
15985
 
15762
15986
  "@types/d3-array": ["@types/d3-array@3.2.2", "", {}, "sha512-hOLWVbm7uRza0BYXpIIW5pxfrKe0W+D5lrFiAEYR+pb6w3N2SwSMaJbXdUfSEv+dT4MfHBLtn5js0LAWaO6otw=="],
15763
15987
 
@@ -15781,6 +16005,8 @@ serveLocalApp({ page, operations, title: app.title });
15781
16005
 
15782
16006
  "aria-hidden": ["aria-hidden@1.2.6", "", { "dependencies": { "tslib": "^2.0.0" } }, "sha512-ik3ZgC9dY/lYVVM++OISsaYDeg1tb0VtP5uL3ouh1koGOaUMDPpbFIei4JkFimWUFPn90sbMNMXQAIVOlnYKJA=="],
15783
16007
 
16008
+ "chrono-node": ["chrono-node@2.10.3", "", {}, "sha512-MOfrzXgSMZTH4SZ5gyRKQCVwiCrCKY+uYkSJiWoRLXS88DA6WGJm8UjgS+VVEuUQeew/UUXaxrO+SeDn/WCisg=="],
16009
+
15784
16010
  "client-only": ["client-only@0.0.1", "", {}, "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA=="],
15785
16011
 
15786
16012
  "clsx": ["clsx@2.1.1", "", {}, "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA=="],
@@ -15825,15 +16051,15 @@ serveLocalApp({ page, operations, title: app.title });
15825
16051
 
15826
16052
  "internmap": ["internmap@2.0.3", "", {}, "sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg=="],
15827
16053
 
15828
- "lucide-react": ["lucide-react@1.59.0", "", { "peerDependencies": { "@types/react": "*", "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-5qgMyyCPU6OvnKpLS2t693+ZtiqA8oaSweWoUows0BLFKFf6V75m4+CptpmohZHpD5IuOVIBXHBBiv2vpLJmtw=="],
16054
+ "lucide-react": ["lucide-react@1.73.0", "", { "peerDependencies": { "@types/react": "*", "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" }, "optionalPeers": ["@types/react"] }, "sha512-fVOzGviL9mTfHenG1PbCfIceavyGlnpYNSYr+aGZHLRymAJ7DTP6KHuqt0uBkCKAoenr1UVkwSbDIYt2xIesEQ=="],
15829
16055
 
15830
- "react": ["react@19.3.0", "", {}, "sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog=="],
16056
+ "react": ["react@19.3.1", "", {}, "sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw=="],
15831
16057
 
15832
16058
  "react-aria": ["react-aria@3.53.1", "", { "dependencies": { "@internationalized/date": "^3.12.4", "@internationalized/number": "^3.6.9", "@internationalized/string": "^3.2.10", "@react-types/shared": "^3.37.0", "@swc/helpers": "^0.5.0", "aria-hidden": "^1.2.3", "clsx": "^2.0.0", "react-stately": "3.51.0", "use-sync-external-store": "^1.6.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1", "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, "sha512-dikisyOjJd3D2fFrIDWmVWzqiLz5B86GzZv1zxs7xI4dVc0JIz/1Wa52I20gYvVL2WXeFXlygYsle/QcOMhtcg=="],
15833
16059
 
15834
16060
  "react-aria-components": ["react-aria-components@1.22.1", "", { "dependencies": { "@internationalized/date": "^3.12.4", "@internationalized/string": "^3.2.10", "@react-types/shared": "^3.37.0", "@swc/helpers": "^0.5.0", "client-only": "^0.0.1", "react-aria": "3.53.1", "react-stately": "3.51.0", "use-sync-external-store": "^1.6.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1", "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" } }, "sha512-UTHaYHOaM71bOCjGPF50DcLywlrwAodE63IP64LB4kO+OizatQEL8TesVEOM8+TkBeSgHoflJ45388IlJfa7aw=="],
15835
16061
 
15836
- "react-dom": ["react-dom@19.3.0", "", { "dependencies": { "scheduler": "^0.28.0" }, "peerDependencies": { "react": "^19.3.0" } }, "sha512-JDk8dgif51OjFoDE70+OT9ICyYr+69HlmihNwp1+Nsfbna3t5sIiCa9ZJktDmQ4/1b/rn26hIAR2uYXDMr5r0Q=="],
16062
+ "react-dom": ["react-dom@19.3.1", "", { "dependencies": { "scheduler": "^0.28.0" }, "peerDependencies": { "react": "^19.3.1" } }, "sha512-Y0bARz53lhEC1NMCASs0/j+faB/zqt3R8hpvg1e8+61ZVJ4UL0UdC4cBbXfZMcIuhrfgeILTLe+ZeBCavQPtKQ=="],
15837
16063
 
15838
16064
  "react-is": ["react-is@19.3.1", "", {}, "sha512-RRieF6IyxQBkcK6pP8xOHprLTPW6QjRkbGdImtqNme+/hYVwCZkLQLdlZGOhUqXwkS9IEynaGvPJtv6XB/cz0Q=="],
15839
16065
 
@@ -15881,21 +16107,24 @@ console.log(JSON.stringify(extractDataAppManifest(source)));
15881
16107
  "dev": "data-app-preview"
15882
16108
  },
15883
16109
  "dependencies": {
15884
- "@altertable/data-app": "0.74.0",
15885
- "@altertable/data-app-bun": "0.74.0",
15886
- "@altertable/data-app-react": "0.74.0",
15887
- "react": "19.3.0",
15888
- "react-dom": "19.3.0",
15889
- "@altertable/data-app-manifest": "0.74.0"
16110
+ "@altertable/data-app": "0.79.0",
16111
+ "@altertable/data-app-bun": "0.79.0",
16112
+ "@altertable/data-app-react": "0.79.0",
16113
+ "react": "19.3.1",
16114
+ "react-dom": "19.3.1",
16115
+ "@altertable/data-app-manifest": "0.79.0"
15890
16116
  }
15891
16117
  }
15892
16118
  ` } };
16119
+ function loadDataAppPayload() {
16120
+ return Promise.resolve(dataAppPayload);
16121
+ }
15893
16122
 
15894
16123
  // src/commands/app/create.ts
15895
16124
  var appCreateCommand = defineCommand({
15896
16125
  metadata: {
15897
16126
  name: "create",
15898
- description: "Create a local data app project with a live connection check.",
16127
+ description: "Create a local data app project from the editable standalone example.",
15899
16128
  examples: [
15900
16129
  "altertable app create product-pulse",
15901
16130
  "altertable app create product-pulse --dir ./apps/product-pulse",
@@ -15944,8 +16173,9 @@ var appCreateCommand = defineCommand({
15944
16173
  organization: profileName ? organizationName || organizationSlug : "Your organization",
15945
16174
  environment: profileName ? environment : "your environment"
15946
16175
  };
16176
+ const dataAppPayload = await loadDataAppPayload();
15947
16177
  const files = Object.entries(createAppFiles(dataAppPayload, { name, title, scope }));
15948
- await mkdir(dirname2(directory), { recursive: true });
16178
+ await mkdir(dirname3(directory), { recursive: true });
15949
16179
  try {
15950
16180
  await mkdir(directory);
15951
16181
  } catch (error) {
@@ -15958,8 +16188,8 @@ var appCreateCommand = defineCommand({
15958
16188
  }
15959
16189
  try {
15960
16190
  for (const [path, content] of files) {
15961
- await mkdir(dirname2(join6(directory, path)), { recursive: true });
15962
- await writeFile(join6(directory, path), content, { flag: "wx" });
16191
+ await mkdir(dirname3(join7(directory, path)), { recursive: true });
16192
+ await writeFile(join7(directory, path), content, { flag: "wx" });
15963
16193
  }
15964
16194
  } catch (error) {
15965
16195
  await rm(directory, { recursive: true, force: true });
@@ -15968,7 +16198,7 @@ var appCreateCommand = defineCommand({
15968
16198
  });
15969
16199
  }
15970
16200
  const nextSteps = profileName ? ["app dev", "app lint", "app build"].map((command) => `altertable --profile ${profileName} ${command}`) : [
15971
- "Set organization and environment in app.json.",
16201
+ "Set organization and environment in app.ts.",
15972
16202
  "Select a matching profile, or configure one with `altertable login --org <org> --env <env>`.",
15973
16203
  "altertable app dev",
15974
16204
  "altertable app lint --lakehouse",
@@ -15991,7 +16221,7 @@ Scope: ${scope.organization} / ${scope.environment} (profile ${profileName}).
15991
16221
  From that directory, run \`${nextSteps[0]}\`.`);
15992
16222
  else
15993
16223
  sink.writeHuman(`Created ${title} in ${directory} with placeholder scope.
15994
- Before previewing, set the organization and environment in app.json and select a matching profile (or run \`altertable login --org <org> --env <env>\`).
16224
+ Before previewing, set the organization and environment in app.ts and select a matching profile (or run \`altertable login --org <org> --env <env>\`).
15995
16225
  You can run \`altertable app build\` from that directory now.`);
15996
16226
  }
15997
16227
  });
@@ -16003,13 +16233,14 @@ import { resolve as resolve4 } from "path";
16003
16233
  import { randomBytes as randomBytes3, timingSafeEqual } from "crypto";
16004
16234
  function startAppDevProxy(execution, send = sendHttpStream) {
16005
16235
  const token = randomBytes3(32).toString("hex");
16236
+ const tokenBytes = Buffer.from(token);
16006
16237
  const server = Bun.serve({
16007
16238
  hostname: "127.0.0.1",
16008
16239
  port: 0,
16009
16240
  idleTimeout: 60,
16010
16241
  async fetch(request) {
16011
- const supplied = request.headers.get("authorization")?.replace(/^Bearer /, "") ?? "";
16012
- const valid = supplied.length === token.length && timingSafeEqual(Buffer.from(supplied), Buffer.from(token));
16242
+ const supplied = Buffer.from(request.headers.get("authorization")?.replace(/^Bearer /, "") ?? "");
16243
+ const valid = supplied.length === tokenBytes.length && timingSafeEqual(supplied, tokenBytes);
16013
16244
  if (!valid)
16014
16245
  return new Response("Unauthorized", { status: 401 });
16015
16246
  if (request.method !== "POST" || new URL(request.url).pathname !== "/query") {
@@ -16058,22 +16289,23 @@ function startAppDevProxy(execution, send = sendHttpStream) {
16058
16289
  };
16059
16290
  }
16060
16291
 
16061
- // src/commands/app/lib/file-dev.ts
16292
+ // src/commands/app/lib/manifest.ts
16062
16293
  import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
16063
16294
  import { join as join9 } from "path";
16064
16295
 
16065
16296
  // src/commands/app/lib/package.ts
16066
16297
  import { readFile } from "fs/promises";
16067
- import { join as join7 } from "path";
16298
+ import { join as join8 } from "path";
16068
16299
  var dataAppPackage = "@altertable/data-app";
16069
16300
  var dataAppPackages = [
16070
16301
  dataAppPackage,
16071
16302
  "@altertable/data-app-react",
16072
16303
  "@altertable/data-app-embed",
16073
16304
  "@altertable/data-app-bun",
16074
- "@altertable/data-app-worker"
16305
+ "@altertable/data-app-worker",
16306
+ "@altertable/data-app-manifest"
16075
16307
  ];
16076
- function recommendedDataAppVersion() {
16308
+ function recommendedDataAppVersion(dataAppPayload) {
16077
16309
  const version = JSON.parse(dataAppPayload.starter["package.json"]).dependencies[dataAppPackage];
16078
16310
  if (typeof version !== "string" || !/^\d+\.\d+\.\d+(?:-[\w.-]+)?$/.test(version)) {
16079
16311
  throw new ConfigurationError("The CLI starter must pin a published data app version.");
@@ -16082,7 +16314,7 @@ function recommendedDataAppVersion() {
16082
16314
  }
16083
16315
  async function readAppPackage(directory) {
16084
16316
  try {
16085
- const source = await readFile(join7(directory, "package.json"), "utf8");
16317
+ const source = await readFile(join8(directory, "package.json"), "utf8");
16086
16318
  const manifest = JSON.parse(source);
16087
16319
  if (!isRecord(manifest) || !isRecord(manifest.dependencies) || Object.values(manifest.dependencies).some((value) => typeof value !== "string") || manifest.devDependencies !== undefined && (!isRecord(manifest.devDependencies) || Object.values(manifest.devDependencies).some((value) => typeof value !== "string")))
16088
16320
  throw new Error;
@@ -16099,7 +16331,7 @@ async function requirePublishedDataApp(directory) {
16099
16331
  }
16100
16332
  let lock;
16101
16333
  try {
16102
- lock = await readFile(join7(directory, "bun.lock"), "utf8");
16334
+ lock = await readFile(join8(directory, "bun.lock"), "utf8");
16103
16335
  } catch {
16104
16336
  throw new ConfigurationError(`Cannot read a valid bun.lock in ${directory}.`);
16105
16337
  }
@@ -16142,8 +16374,8 @@ function lockedVersion(packages, name) {
16142
16374
  const version = entry[0].slice(`${name}@`.length);
16143
16375
  return entry[0].startsWith(`${name}@`) && /^\d+\.\d+\.\d+(?:-[\w.-]+)?$/.test(version) ? version : undefined;
16144
16376
  }
16145
- function recommendedDataAppPeers(names = dataAppPackages) {
16146
- const { packages } = readAppLock(dataAppPayload.starter["bun.lock"], "CLI starter", recommendedDataAppVersion());
16377
+ function recommendedDataAppPeers(dataAppPayload, names = dataAppPackages) {
16378
+ const { packages } = readAppLock(dataAppPayload.starter["bun.lock"], "CLI starter", recommendedDataAppVersion(dataAppPayload));
16147
16379
  const peers = {};
16148
16380
  for (const name of names) {
16149
16381
  const entry = packages[name];
@@ -16223,6 +16455,52 @@ function parseJsonc(source) {
16223
16455
  return JSON.parse(withoutTrailingCommas);
16224
16456
  }
16225
16457
 
16458
+ // src/commands/app/lib/manifest.ts
16459
+ async function extractAppManifest(source) {
16460
+ const dataAppPayload = await loadDataAppPayload();
16461
+ const directory = filePreviewDirectory(recommendedDataAppVersion(dataAppPayload));
16462
+ await mkdir2(directory, { recursive: true });
16463
+ await Promise.all(Object.entries(dataAppPayload.filePreview).map(([name, content]) => writeFile2(join9(directory, name), content)));
16464
+ if (await runAppCommand("install-frozen", directory) !== 0) {
16465
+ throw new ConfigurationError("Could not install the file preview runtime.");
16466
+ }
16467
+ const env = copyProcessEnv();
16468
+ for (const key of Object.keys(env)) {
16469
+ if (key.startsWith("ALTERTABLE_"))
16470
+ delete env[key];
16471
+ }
16472
+ env.BUN_BE_BUN = "1";
16473
+ const child = Bun.spawn([process.execPath, join9(directory, "extract-manifest.js")], {
16474
+ cwd: directory,
16475
+ env,
16476
+ stdin: new Blob([source]),
16477
+ stdout: "pipe",
16478
+ stderr: "pipe"
16479
+ });
16480
+ const [stdout, stderr, exitCode] = await Promise.all([
16481
+ new Response(child.stdout).text(),
16482
+ new Response(child.stderr).text(),
16483
+ child.exited
16484
+ ]);
16485
+ if (exitCode !== 0) {
16486
+ throw new ConfigurationError(`Could not extract the data app manifest.
16487
+ ${stderr.trim()}`);
16488
+ }
16489
+ const { manifest, diagnostics } = JSON.parse(stdout);
16490
+ if (!manifest) {
16491
+ const details = diagnostics.slice(0, 3).map(({ message, start }) => `${start.line}:${start.column}: ${message}`).join(`
16492
+ `);
16493
+ throw new ConfigurationError(`Could not extract the data app manifest.
16494
+ ${details}`);
16495
+ }
16496
+ if (typeof manifest.title !== "string" || !manifest.title.trim())
16497
+ throw new ConfigurationError("The data app declaration needs a title.");
16498
+ return manifest;
16499
+ }
16500
+ function filePreviewDirectory(version) {
16501
+ return join9(configDir(), "data-app-dev", version);
16502
+ }
16503
+
16226
16504
  // src/commands/app/lib/remote.ts
16227
16505
  import { readFile as readFile2 } from "fs/promises";
16228
16506
  async function readRequiredFile(path, label) {
@@ -16271,8 +16549,8 @@ function formatDiagnostic(kind, diagnostic) {
16271
16549
 
16272
16550
  // src/commands/app/lib/scope.ts
16273
16551
  import { readFile as readFile3 } from "fs/promises";
16274
- import { join as join8 } from "path";
16275
- function assertAppScope(scope, profile, source = "app.json") {
16552
+ import { join as join10 } from "path";
16553
+ function assertAppScope(scope, profile, source = "app.ts") {
16276
16554
  const value = scope;
16277
16555
  if (!value || typeof value.organization !== "string" || !value.organization.trim() || typeof value.environment !== "string" || !value.environment.trim() || Boolean(profile.organization) && ![profile.organization, profile.organizationName].includes(value.organization) || Boolean(profile.environment) && value.environment !== profile.environment) {
16278
16556
  throw new ConfigurationError(`${source} scope does not match the selected profile. Select the matching profile or update the app scope before querying.`);
@@ -16288,53 +16566,19 @@ function profileAppScope(profile) {
16288
16566
  async function checkAppScope(directory, profile) {
16289
16567
  let manifest;
16290
16568
  try {
16291
- manifest = JSON.parse(await readFile3(join8(directory, "app.json"), "utf8"));
16569
+ manifest = await extractAppManifest(await readFile3(join10(directory, "app.ts"), "utf8"));
16292
16570
  } catch {
16293
- throw new ConfigurationError("Cannot read a valid app.json for profile scope verification.");
16571
+ throw new ConfigurationError("Cannot read a valid app.ts for profile scope verification.");
16294
16572
  }
16295
16573
  assertAppScope(manifest?.scope, profileAppScope(profile));
16296
16574
  }
16297
16575
 
16298
16576
  // src/commands/app/lib/file-dev.ts
16299
16577
  async function prepareFilePreview(file, profile) {
16300
- const source = await readRequiredFile(file, "source");
16301
- const directory = join9(configDir(), "data-app-dev", recommendedDataAppVersion());
16302
- await mkdir2(directory, { recursive: true });
16303
- await Promise.all(Object.entries(dataAppPayload.filePreview).map(([name, content]) => writeFile2(join9(directory, name), content)));
16304
- if (await runAppCommand("install-frozen", directory) !== 0) {
16305
- throw new ConfigurationError("Could not install the file preview runtime.");
16306
- }
16307
- const env = copyProcessEnv();
16308
- for (const key of Object.keys(env)) {
16309
- if (key.startsWith("ALTERTABLE_"))
16310
- delete env[key];
16311
- }
16312
- env.BUN_BE_BUN = "1";
16313
- const child = Bun.spawn([process.execPath, join9(directory, "extract-manifest.js")], {
16314
- cwd: directory,
16315
- env,
16316
- stdin: new Blob([source]),
16317
- stdout: "pipe",
16318
- stderr: "pipe"
16319
- });
16320
- const [stdout, stderr, exitCode] = await Promise.all([
16321
- new Response(child.stdout).text(),
16322
- new Response(child.stderr).text(),
16323
- child.exited
16324
- ]);
16325
- if (exitCode !== 0) {
16326
- throw new ConfigurationError(`Could not extract the data app manifest.
16327
- ${stderr.trim()}`);
16328
- }
16329
- const { manifest, diagnostics } = JSON.parse(stdout);
16330
- if (!manifest) {
16331
- const details = diagnostics.slice(0, 3).map(({ message, start }) => `${start.line}:${start.column}: ${message}`).join(`
16332
- `);
16333
- throw new ConfigurationError(`Could not extract the data app manifest.
16334
- ${details}`);
16335
- }
16578
+ const dataAppPayload = await loadDataAppPayload();
16579
+ const manifest = await extractAppManifest(await readRequiredFile(file, "source"));
16336
16580
  assertAppScope(manifest.scope, profileAppScope(profile), "data app file");
16337
- return directory;
16581
+ return filePreviewDirectory(recommendedDataAppVersion(dataAppPayload));
16338
16582
  }
16339
16583
 
16340
16584
  // src/commands/app/dev.ts
@@ -16408,22 +16652,21 @@ function appPort(value) {
16408
16652
 
16409
16653
  // src/commands/app/lint.ts
16410
16654
  import { readFile as readFile4, readdir } from "fs/promises";
16411
- import { join as join10 } from "path";
16655
+ import { join as join11 } from "path";
16412
16656
 
16413
16657
  // src/commands/app/lib/project-check.js.txt
16414
- var project_check_js_default = `import { readFile } from "node:fs/promises";
16415
- import { join } from "node:path";
16658
+ var project_check_js_default = `import { join } from "node:path";
16416
16659
  import { pathToFileURL } from "node:url";
16417
16660
 
16418
16661
  const appFile = (path) => pathToFileURL(join(process.cwd(), path)).href;
16419
16662
 
16420
16663
  async function check() {
16421
- const manifest = JSON.parse(await readFile("app.json", "utf8"));
16664
+ const { dataApp: manifest } = await import(appFile("app.ts"));
16422
16665
  try {
16423
16666
  const { parseAppearance } = await import("@altertable/data-app/appearance");
16424
16667
  parseAppearance(manifest.appearance);
16425
16668
  } catch {
16426
- throw new Error("app.json has invalid appearance settings.");
16669
+ throw new Error("app.ts has invalid appearance settings.");
16427
16670
  }
16428
16671
 
16429
16672
  let operations;
@@ -16442,7 +16685,7 @@ async function check() {
16442
16685
  for (const name of names) {
16443
16686
  const operation = operations[name];
16444
16687
  if (
16445
- !/^[a-z][a-z0-9-]*$/.test(name) ||
16688
+ !name.trim() ||
16446
16689
  !operation ||
16447
16690
  typeof operation.input !== "function" ||
16448
16691
  typeof operation.run !== "function" ||
@@ -16481,8 +16724,7 @@ async function check() {
16481
16724
  build.onLoad({ filter: /\\.[cm]?[jt]sx?$/ }, ({ path }) => {
16482
16725
  const normalized = path.replaceAll("\\\\", "/");
16483
16726
  const root = process.cwd().replaceAll("\\\\", "/");
16484
- if (normalized === \`\${root}/src/operations.ts\` ||
16485
- normalized === \`\${root}/src/server.ts\` ||
16727
+ if (normalized === \`\${root}/src/server.ts\` ||
16486
16728
  /node_modules\\/@altertable\\/(?:data-app\\/(?:dist|src)\\/server\\/|data-app-(?:bun|worker)\\/)/.test(normalized)) {
16487
16729
  throw new Error("Browser code cannot import server operations or transport. Use import type for operation types.");
16488
16730
  }
@@ -16494,24 +16736,11 @@ async function check() {
16494
16736
  }
16495
16737
 
16496
16738
  if (process.argv[1] !== "--lakehouse") return;
16497
- const { createDataHandler } = await import("@altertable/data-app/server");
16739
+ const { createDataClient } = await import("@altertable/data-app/client");
16498
16740
  const { localLakehouse } = await import("@altertable/data-app-bun");
16499
- const handle = createDataHandler(operations, async () => ({
16500
- lakehouse: localLakehouse(process.env),
16501
- canDiscloseSql: true,
16502
- }));
16741
+ const client = createDataClient({ operations, lakehouse: localLakehouse(process.env) });
16503
16742
  for (const [name, operation] of Object.entries(operations)) {
16504
- for (const input of operation.checks) {
16505
- const response = await handle(
16506
- new Request(\`http://localhost/api/data/\${name}\`, {
16507
- method: "POST",
16508
- headers: { "content-type": "application/json" },
16509
- body: JSON.stringify(input),
16510
- }),
16511
- );
16512
- if (!response.ok)
16513
- throw new Error(\`Live check failed for operation "\${name}" (\${response.status}).\`);
16514
- }
16743
+ for (const input of operation.checks) await client.query(name, input);
16515
16744
  }
16516
16745
  }
16517
16746
 
@@ -16566,26 +16795,10 @@ async function* readTextStreamLines(stream) {
16566
16795
 
16567
16796
  // src/lib/lakehouse-ndjson.ts
16568
16797
  function isColumnNameArray(value) {
16569
- return Array.isArray(value) && value.length > 0 && value.every((entry) => typeof entry === "string");
16798
+ return Array.isArray(value) && value.every((entry) => typeof entry === "string");
16570
16799
  }
16571
16800
  function isColumnObjectArray(value) {
16572
- return Array.isArray(value) && value.length > 0 && value.every((entry) => typeof entry === "object" && entry !== null && !Array.isArray(entry));
16573
- }
16574
- function parseMetadataLine(line, lineNumber) {
16575
- const parsedMetadata = parseProtocolLine(line, lineNumber);
16576
- if (typeof parsedMetadata !== "object" || parsedMetadata === null || Array.isArray(parsedMetadata)) {
16577
- throw new ParseError("Query response metadata must be a JSON object.", {
16578
- details: `Line ${lineNumber}: ${line}`
16579
- });
16580
- }
16581
- return parsedMetadata;
16582
- }
16583
- function parseOptionalColumnsLine(line, lineNumber) {
16584
- const parsedLine = parseProtocolLine(line, lineNumber);
16585
- if (isColumnNameArray(parsedLine) || isColumnObjectArray(parsedLine)) {
16586
- return parsedLine;
16587
- }
16588
- return;
16801
+ return Array.isArray(value) && value.every(isRecord);
16589
16802
  }
16590
16803
  function parseProtocolLine(line, lineNumber) {
16591
16804
  let value;
@@ -16597,128 +16810,62 @@ function parseProtocolLine(line, lineNumber) {
16597
16810
  cause: error
16598
16811
  });
16599
16812
  }
16600
- if (typeof value === "object" && value !== null && !Array.isArray(value) && Object.keys(value).length === 1 && "error" in value && typeof value.error === "string") {
16601
- throw new QueryError(value.error);
16813
+ if (isRecord(value) && Object.keys(value).length === 1 && typeof value.error === "string") {
16814
+ throw new QueryError(value.error, { details: `Line ${lineNumber}` });
16602
16815
  }
16603
16816
  return value;
16604
16817
  }
16605
- function parseRowLine(line, lineNumber) {
16606
- return parseProtocolLine(line, lineNumber);
16607
- }
16608
- function trimTrailingEmptyLines(lines) {
16609
- const trimmedLines = [...lines];
16610
- while (trimmedLines.length > 0) {
16611
- const lastLine = trimmedLines[trimmedLines.length - 1];
16612
- if (lastLine === undefined || lastLine.trim().length > 0) {
16613
- break;
16614
- }
16615
- trimmedLines.pop();
16616
- }
16617
- return trimmedLines;
16618
- }
16619
- async function parseLakehouseQueryHeader(lineSource) {
16620
- const lineIterator = lineSource[Symbol.asyncIterator]();
16621
- try {
16622
- const firstResult = await lineIterator.next();
16623
- if (firstResult.done || firstResult.value.trim().length === 0) {
16624
- throw new ParseError("Query response is empty.");
16818
+
16819
+ class QueryResponseReader {
16820
+ result;
16821
+ lineNumber = 0;
16822
+ recordCount = 0;
16823
+ read(line) {
16824
+ const lineNumber = ++this.lineNumber;
16825
+ if (!line.trim())
16826
+ return;
16827
+ this.recordCount++;
16828
+ const value = parseProtocolLine(line, lineNumber);
16829
+ if (!this.result) {
16830
+ if (!isRecord(value)) {
16831
+ throw new ParseError("Query response metadata must be a JSON object.", {
16832
+ details: `Line ${lineNumber}: ${line}`
16833
+ });
16834
+ }
16835
+ this.result = { metadata: value, columns: [], rows: [] };
16836
+ return;
16625
16837
  }
16626
- const metadata = parseMetadataLine(firstResult.value, 1);
16627
- let columns = [];
16628
- let lineNumber = 2;
16629
- let pendingRowLine;
16630
- const secondResult = await lineIterator.next();
16631
- if (!secondResult.done) {
16632
- const parsedColumns = parseOptionalColumnsLine(secondResult.value, lineNumber);
16633
- if (parsedColumns !== undefined) {
16634
- columns = parsedColumns;
16635
- lineNumber += 1;
16636
- } else {
16637
- pendingRowLine = secondResult.value;
16838
+ if (this.recordCount === 2 && (isColumnNameArray(value) || isColumnObjectArray(value))) {
16839
+ this.result.columns = value;
16840
+ } else {
16841
+ if (!Array.isArray(value) && !isRecord(value)) {
16842
+ throw new ParseError("Query response row must be a JSON array or object.", {
16843
+ details: `Line ${lineNumber}: ${line}`
16844
+ });
16638
16845
  }
16846
+ this.result.rows.push(value);
16639
16847
  }
16640
- return {
16641
- metadata,
16642
- columns,
16643
- lineIterator,
16644
- lineNumber,
16645
- pendingRowLine
16646
- };
16647
- } catch (error) {
16648
- await lineIterator.return?.();
16649
- throw error;
16848
+ }
16849
+ finish() {
16850
+ if (!this.result)
16851
+ throw new ParseError("Query response is empty.");
16852
+ return this.result;
16650
16853
  }
16651
16854
  }
16652
16855
  function parseLakehouseQueryResponse(responseBody) {
16653
- const trimmedBody = responseBody.trimEnd();
16654
- if (trimmedBody.length === 0) {
16655
- throw new ParseError("Query response is empty.");
16656
- }
16657
- const lines = trimTrailingEmptyLines(trimmedBody.split(`
16658
- `));
16659
- if (lines.length === 0) {
16660
- throw new ParseError("Query response is empty.");
16661
- }
16662
- const metadataLine = lines[0];
16663
- if (metadataLine === undefined) {
16664
- throw new ParseError("Query response is empty.");
16665
- }
16666
- const metadata = parseMetadataLine(metadataLine, 1);
16667
- let columns = [];
16668
- const rows = [];
16669
- let lineIndex = 1;
16670
- if (lineIndex < lines.length) {
16671
- const columnsLine = lines[lineIndex];
16672
- if (columnsLine !== undefined) {
16673
- const parsedColumns = parseOptionalColumnsLine(columnsLine, lineIndex + 1);
16674
- if (parsedColumns !== undefined) {
16675
- columns = parsedColumns;
16676
- lineIndex += 1;
16677
- }
16678
- }
16679
- }
16680
- for (;lineIndex < lines.length; lineIndex += 1) {
16681
- const line = lines[lineIndex];
16682
- if (line === undefined || line.trim().length === 0) {
16683
- continue;
16684
- }
16685
- rows.push(parseRowLine(line, lineIndex + 1));
16856
+ const reader = new QueryResponseReader;
16857
+ for (const line of responseBody.split(`
16858
+ `)) {
16859
+ reader.read(line);
16686
16860
  }
16687
- return { metadata, columns, rows };
16861
+ return reader.finish();
16688
16862
  }
16689
- async function* parseLakehouseQueryStream(stream) {
16690
- const header = await parseLakehouseQueryHeader(readTextStreamLines(stream));
16691
- const rows = [];
16692
- let lineNumber = header.lineNumber;
16693
- try {
16694
- if (header.pendingRowLine !== undefined) {
16695
- const pendingLineNumber = lineNumber;
16696
- lineNumber += 1;
16697
- if (header.pendingRowLine.trim().length > 0) {
16698
- const row = parseRowLine(header.pendingRowLine, pendingLineNumber);
16699
- rows.push(row);
16700
- yield row;
16701
- }
16702
- }
16703
- while (true) {
16704
- const nextLine = await header.lineIterator.next();
16705
- if (nextLine.done) {
16706
- break;
16707
- }
16708
- const line = nextLine.value;
16709
- const currentLineNumber = lineNumber;
16710
- lineNumber += 1;
16711
- if (line.trim().length === 0) {
16712
- continue;
16713
- }
16714
- const row = parseRowLine(line, currentLineNumber);
16715
- rows.push(row);
16716
- yield row;
16717
- }
16718
- return { metadata: header.metadata, columns: header.columns, rows };
16719
- } finally {
16720
- await header.lineIterator.return?.();
16863
+ async function parseLakehouseQueryStream(stream) {
16864
+ const reader = new QueryResponseReader;
16865
+ for await (const line of readTextStreamLines(stream)) {
16866
+ reader.read(line);
16721
16867
  }
16868
+ return reader.finish();
16722
16869
  }
16723
16870
 
16724
16871
  // src/lib/lakehouse/query.ts
@@ -16751,18 +16898,10 @@ function buildLakehouseQueryRequest(input, streaming) {
16751
16898
  ...input.httpOptions
16752
16899
  };
16753
16900
  }
16754
- async function collectQueryStream(stream) {
16755
- const parser = parseLakehouseQueryStream(stream);
16756
- while (true) {
16757
- const next = await parser.next();
16758
- if (next.done)
16759
- return next.value;
16760
- }
16761
- }
16762
16901
  async function executeLakehouseQuery(input, execution, streaming) {
16763
16902
  const request = buildLakehouseQueryRequest(input, streaming);
16764
16903
  if (streaming) {
16765
- return collectQueryStream(await sendHttpStream(request, execution));
16904
+ return parseLakehouseQueryStream(await sendHttpStream(request, execution));
16766
16905
  }
16767
16906
  return parseLakehouseQueryResponse(await sendHttp(request, execution));
16768
16907
  }
@@ -17079,16 +17218,11 @@ var appLintCommand = defineCommand({
17079
17218
  }
17080
17219
  });
17081
17220
  async function readManifest(directory) {
17082
- let value;
17083
17221
  try {
17084
- value = JSON.parse(await readFile4(join10(directory, "app.json"), "utf8"));
17085
- } catch {
17086
- throw new ConfigurationError(`Cannot read a valid app.json in ${directory}.`);
17087
- }
17088
- if (typeof value !== "object" || value === null || !("schemaVersion" in value) || value.schemaVersion !== 1 || !("title" in value) || typeof value.title !== "string" || !value.title.trim()) {
17089
- throw new ConfigurationError("app.json needs schemaVersion 1 and a title.");
17222
+ return await extractAppManifest(await readFile4(join11(directory, "app.ts"), "utf8"));
17223
+ } catch (error) {
17224
+ throw new ConfigurationError(`Cannot read a valid app.ts in ${directory}.`, { cause: error });
17090
17225
  }
17091
- return value;
17092
17226
  }
17093
17227
  async function checkAppProject(directory, lakehouseEnvironment) {
17094
17228
  const env = copyProcessEnv();
@@ -17116,7 +17250,7 @@ async function checkAppProject(directory, lakehouseEnvironment) {
17116
17250
  }
17117
17251
  }
17118
17252
  async function checkClientBundle(directory, secrets = []) {
17119
- const dist = join10(directory, "dist");
17253
+ const dist = join11(directory, "dist");
17120
17254
  let files;
17121
17255
  try {
17122
17256
  files = await readdir(dist);
@@ -17132,14 +17266,14 @@ async function checkClientBundle(directory, secrets = []) {
17132
17266
  for (const entry of await readdir(path, { withFileTypes: true })) {
17133
17267
  const name = prefix ? `${prefix}/${entry.name}` : entry.name;
17134
17268
  if (entry.isDirectory())
17135
- await visit(join10(path, entry.name), name);
17269
+ await visit(join11(path, entry.name), name);
17136
17270
  else if (entry.isFile() && name !== "server.js" && name !== "server.js.map")
17137
17271
  clientAssets.push(name);
17138
17272
  }
17139
17273
  }
17140
17274
  await visit(dist);
17141
17275
  for (const name of clientAssets) {
17142
- const content = await readFile4(join10(dist, name), "utf8");
17276
+ const content = await readFile4(join11(dist, name), "utf8");
17143
17277
  if (/ALTERTABLE_(?:API_BASE|LAKEHOUSE_USERNAME|LAKEHOUSE_PASSWORD|BASIC_AUTH_TOKEN|API_KEY|DATA_PROXY_URL|DATA_PROXY_TOKEN)/.test(content)) {
17144
17278
  throw new ConfigurationError(`Client asset ${name} contains a credential environment reference.`);
17145
17279
  }
@@ -17227,6 +17361,9 @@ var appUpdateCommand = defineCommand({
17227
17361
  requirement: "Updating a data app requires the management API"
17228
17362
  });
17229
17363
  const slug = stringArg(args, "slug");
17364
+ if (!slug || slug === "." || slug === ".." || /[/\\?#]/.test(slug)) {
17365
+ throw new CliError("Provide a data app slug, e.g. APP-1.");
17366
+ }
17230
17367
  const body = await updatePayload(args);
17231
17368
  if (Object.keys(body).length === 0) {
17232
17369
  throw new CliError("Provide at least one of --title, --description, or --file.");
@@ -17257,7 +17394,7 @@ async function updatePayload(args) {
17257
17394
 
17258
17395
  // src/commands/app/upgrade.ts
17259
17396
  import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
17260
- import { join as join11 } from "path";
17397
+ import { join as join12 } from "path";
17261
17398
  var appUpgradeCommand = defineCommand({
17262
17399
  metadata: {
17263
17400
  name: "upgrade",
@@ -17276,7 +17413,7 @@ var appUpgradeCommand = defineCommand({
17276
17413
  async run({ args, sink }) {
17277
17414
  const directory = appDirectory(args.dir);
17278
17415
  const upgraded = await upgradeApp(directory);
17279
- const { packages } = readAppLock(await readFile5(join11(directory, "bun.lock"), "utf8"), directory);
17416
+ const { packages } = readAppLock(await readFile5(join12(directory, "bun.lock"), "utf8"), directory);
17280
17417
  const version = lockedVersion(packages, dataAppPackage);
17281
17418
  if (sink.json) {
17282
17419
  sink.writeJson({
@@ -17294,7 +17431,8 @@ var appUpgradeCommand = defineCommand({
17294
17431
  }
17295
17432
  });
17296
17433
  async function upgradeApp(directory, options = {}) {
17297
- const version = recommendedDataAppVersion();
17434
+ const dataAppPayload = await loadDataAppPayload();
17435
+ const version = recommendedDataAppVersion(dataAppPayload);
17298
17436
  const { source: originalPackage, manifest } = await readAppPackage(directory);
17299
17437
  const reference = manifest.dependencies?.[dataAppPackage];
17300
17438
  if (!reference || !/^[\d~^<>=*]/.test(reference)) {
@@ -17302,7 +17440,7 @@ async function upgradeApp(directory, options = {}) {
17302
17440
  }
17303
17441
  let lock;
17304
17442
  try {
17305
- lock = await readFile5(join11(directory, "bun.lock"), "utf8");
17443
+ lock = await readFile5(join12(directory, "bun.lock"), "utf8");
17306
17444
  } catch {
17307
17445
  throw new ConfigurationError(`Cannot read a valid bun.lock in ${directory}.`);
17308
17446
  }
@@ -17325,7 +17463,7 @@ async function upgradeApp(directory, options = {}) {
17325
17463
  }
17326
17464
  const defaults = JSON.parse(dataAppPayload.starter["package.json"]).dependencies;
17327
17465
  let packageChanged = names.some((name) => dependencies[name] !== version);
17328
- const peers = recommendedDataAppPeers(names);
17466
+ const peers = recommendedDataAppPeers(dataAppPayload, names);
17329
17467
  for (const [name, range] of Object.entries(peers)) {
17330
17468
  const existing = manifest.dependencies?.[name] ?? manifest.devDependencies?.[name];
17331
17469
  const resolved = lockedVersion(packages, name);
@@ -17350,9 +17488,9 @@ async function upgradeApp(directory, options = {}) {
17350
17488
  const nextPackage = `${JSON.stringify(manifest, null, 2)}
17351
17489
  `;
17352
17490
  try {
17353
- await writeFile3(join11(directory, "package.json"), nextPackage);
17491
+ await writeFile3(join12(directory, "package.json"), nextPackage);
17354
17492
  await (options.resolveLock ?? resolveLockfile)(directory);
17355
- const resolvedLock = await readFile5(join11(directory, "bun.lock"), "utf8");
17493
+ const resolvedLock = await readFile5(join12(directory, "bun.lock"), "utf8");
17356
17494
  const resolved = readAppLock(resolvedLock, directory, version);
17357
17495
  for (const name of names) {
17358
17496
  readAppLock(resolvedLock, directory, version, name);
@@ -17364,11 +17502,11 @@ async function upgradeApp(directory, options = {}) {
17364
17502
  if (!peerVersion || !Bun.semver.satisfies(peerVersion, range))
17365
17503
  throw new ConfigurationError(`Resolved ${name} is incompatible with data app's ${range} peer requirement.`);
17366
17504
  }
17367
- await writeFile3(join11(directory, "package.json"), nextPackage);
17505
+ await writeFile3(join12(directory, "package.json"), nextPackage);
17368
17506
  } catch (error) {
17369
17507
  const restored = await Promise.allSettled([
17370
- writeFile3(join11(directory, "package.json"), originalPackage),
17371
- writeFile3(join11(directory, "bun.lock"), lock)
17508
+ writeFile3(join12(directory, "package.json"), originalPackage),
17509
+ writeFile3(join12(directory, "bun.lock"), lock)
17372
17510
  ]);
17373
17511
  if (restored.some((result) => result.status === "rejected"))
17374
17512
  throw new ConfigurationError("Upgrade failed and could not restore package.json and bun.lock.", { cause: error });
@@ -17816,7 +17954,7 @@ var catalogsCommand = defineCommand({
17816
17954
 
17817
17955
  // src/commands/completion/lib/completion.ts
17818
17956
  import { mkdir as mkdir3, readFile as readFile6, writeFile as writeFile4 } from "fs/promises";
17819
- import { basename, dirname as dirname3, join as join12 } from "path";
17957
+ import { basename, dirname as dirname4, join as join13 } from "path";
17820
17958
 
17821
17959
  // src/lib/command-descriptor.ts
17822
17960
  function asStringArray(value) {
@@ -18694,18 +18832,18 @@ function shellQuote(value) {
18694
18832
  function installTarget(shell) {
18695
18833
  if (shell === "bash") {
18696
18834
  return {
18697
- completionPath: join12(dataHome(), "bash-completion", "completions", "altertable"),
18698
- rcPath: join12(homeDir(), ".bashrc")
18835
+ completionPath: join13(dataHome(), "bash-completion", "completions", "altertable"),
18836
+ rcPath: join13(homeDir(), ".bashrc")
18699
18837
  };
18700
18838
  }
18701
18839
  if (shell === "zsh") {
18702
18840
  return {
18703
- completionPath: join12(dataHome(), "zsh", "site-functions", "_altertable"),
18704
- rcPath: join12(homeDir(), ".zshrc")
18841
+ completionPath: join13(dataHome(), "zsh", "site-functions", "_altertable"),
18842
+ rcPath: join13(homeDir(), ".zshrc")
18705
18843
  };
18706
18844
  }
18707
18845
  return {
18708
- completionPath: join12(configHome(), "fish", "completions", "altertable.fish")
18846
+ completionPath: join13(configHome(), "fish", "completions", "altertable.fish")
18709
18847
  };
18710
18848
  }
18711
18849
  function managedBlock(body) {
@@ -18722,7 +18860,7 @@ function rcBlock(shell, target) {
18722
18860
  . ${shellQuote(target.completionPath)}
18723
18861
  fi`);
18724
18862
  }
18725
- return managedBlock(`fpath=(${shellQuote(dirname3(target.completionPath))} $fpath)
18863
+ return managedBlock(`fpath=(${shellQuote(dirname4(target.completionPath))} $fpath)
18726
18864
  autoload -Uz compinit
18727
18865
  compinit`);
18728
18866
  }
@@ -18762,12 +18900,12 @@ async function formatCompletionScript(shell, rootCommand) {
18762
18900
  }
18763
18901
  async function installCompletion(shell, script, options = {}) {
18764
18902
  const target = installTarget(shell);
18765
- await mkdir3(dirname3(target.completionPath), { recursive: true });
18903
+ await mkdir3(dirname4(target.completionPath), { recursive: true });
18766
18904
  await writeFile4(target.completionPath, `${script.trimEnd()}
18767
18905
  `, "utf8");
18768
18906
  const block = options.updateRc === false ? undefined : rcBlock(shell, target);
18769
18907
  if (block && target.rcPath) {
18770
- await mkdir3(dirname3(target.rcPath), { recursive: true });
18908
+ await mkdir3(dirname4(target.rcPath), { recursive: true });
18771
18909
  const existing = await readOptionalFile(target.rcPath);
18772
18910
  await writeFile4(target.rcPath, upsertManagedBlock(existing, block), "utf8");
18773
18911
  return {
@@ -18937,12 +19075,12 @@ function parseWhoamiResponse(body) {
18937
19075
  import { randomBytes as randomBytes4 } from "crypto";
18938
19076
  import {
18939
19077
  existsSync as existsSync3,
18940
- mkdirSync as mkdirSync3,
18941
- readFileSync as readFileSync5,
19078
+ mkdirSync as mkdirSync4,
19079
+ readFileSync as readFileSync6,
18942
19080
  renameSync as renameSync2,
18943
19081
  rmSync as rmSync2,
18944
19082
  statSync as statSync2,
18945
- writeFileSync as writeFileSync2
19083
+ writeFileSync as writeFileSync3
18946
19084
  } from "fs";
18947
19085
  var PROFILE_SECRET_ACCOUNTS = [
18948
19086
  "api-key",
@@ -19108,22 +19246,18 @@ function listProfiles() {
19108
19246
  principal: profilePrincipalSummary(snapshot.config),
19109
19247
  management_auth: profileManagementAuthSummary(snapshot.auth),
19110
19248
  lakehouse_auth: profileLakehouseAuthSummary(snapshot.auth),
19111
- oauth_expires_at: parseTimestampMs(snapshot.config.oauth_expiry),
19249
+ oauth_expires_at: parseProfileExpiry(snapshot.config.oauth_expiry)?.toISOString(),
19112
19250
  status: profileStatus(snapshot),
19113
19251
  data_plane: snapshot.config.api_base,
19114
19252
  control_plane: snapshot.config.management_api_base
19115
19253
  };
19116
19254
  });
19117
19255
  }
19118
- function parseTimestampMs(raw) {
19119
- if (!raw) {
19256
+ function parseProfileExpiry(raw) {
19257
+ if (!raw || !/^-?\d+$/.test(raw))
19120
19258
  return;
19121
- }
19122
- const timestamp = Number.parseInt(raw, 10);
19123
- if (Number.isNaN(timestamp)) {
19124
- return;
19125
- }
19126
- return new Date(timestamp).toISOString();
19259
+ const date = new Date(Number(raw));
19260
+ return Number.isNaN(date.getTime()) ? undefined : date;
19127
19261
  }
19128
19262
  function envLakehouseAuthKind() {
19129
19263
  if (readEnv("ALTERTABLE_BASIC_AUTH_TOKEN")) {
@@ -19173,8 +19307,8 @@ function buildProfileConfiguration(name, active, config) {
19173
19307
  created_at: config.created_at,
19174
19308
  updated_at: config.updated_at,
19175
19309
  last_verified_at: config.last_verified_at,
19176
- oauth_expires_at: parseTimestampMs(config.oauth_expiry),
19177
- lakehouse_expires_at: parseTimestampMs(config.lakehouse_credential_expiry)
19310
+ oauth_expires_at: parseProfileExpiry(config.oauth_expiry)?.toISOString(),
19311
+ lakehouse_expires_at: parseProfileExpiry(config.lakehouse_credential_expiry)?.toISOString()
19178
19312
  }
19179
19313
  };
19180
19314
  }
@@ -19241,7 +19375,7 @@ function snapshotProfileConfig(name) {
19241
19375
  return;
19242
19376
  }
19243
19377
  return {
19244
- contents: readFileSync5(filePath),
19378
+ contents: readFileSync6(filePath),
19245
19379
  mode: statSync2(filePath).mode & 511
19246
19380
  };
19247
19381
  }
@@ -19294,9 +19428,9 @@ function rollbackProfileDelete(options) {
19294
19428
  });
19295
19429
  }
19296
19430
  runProfileRollbackStep(failures, "restore profile configuration", () => {
19297
- mkdirSync3(profileDir(name), { recursive: true });
19431
+ mkdirSync4(profileDir(name), { recursive: true });
19298
19432
  if (configSnapshot) {
19299
- writeFileSync2(profileConfigFile(name), configSnapshot.contents, {
19433
+ writeFileSync3(profileConfigFile(name), configSnapshot.contents, {
19300
19434
  mode: configSnapshot.mode
19301
19435
  });
19302
19436
  }
@@ -20380,7 +20514,7 @@ async function runLogin(args, sink) {
20380
20514
  }
20381
20515
 
20382
20516
  // src/lib/profile-configure-core.ts
20383
- import { unlinkSync, rmSync as rmSync3, existsSync as existsSync4, readFileSync as readFileSync6 } from "fs";
20517
+ import { unlinkSync, rmSync as rmSync3, existsSync as existsSync4, readFileSync as readFileSync7 } from "fs";
20384
20518
  var ARGV_SECRET_WARNING = "Warning: passing secrets on the command line is visible in process listings. Prefer --password-stdin / --api-key-stdin.";
20385
20519
  var AUTO_PROFILE_NAME = "auto";
20386
20520
  function markCurrentProfileUpdated(profileName) {
@@ -20444,10 +20578,10 @@ async function configureRunSet(options, sink = getOutputSink(), org = "") {
20444
20578
  throw new CliError("Nothing to configure. Use --user/--password, --basic-token, or --api-key --env <name>.");
20445
20579
  }
20446
20580
  if (options.passwordStdin) {
20447
- password = readFileSync6(0, "utf8").replace(/\n$/, "");
20581
+ password = readFileSync7(0, "utf8").replace(/\n$/, "");
20448
20582
  }
20449
20583
  if (options.apiKeyStdin) {
20450
- apiKey = readFileSync6(0, "utf8").replace(/\n$/, "");
20584
+ apiKey = readFileSync7(0, "utf8").replace(/\n$/, "");
20451
20585
  }
20452
20586
  const hasLakehouseCredentials = Boolean(user || password);
20453
20587
  const hasLakehouseBasicToken = Boolean(basicToken);
@@ -20783,13 +20917,6 @@ function profileStatusToJson(result) {
20783
20917
  }
20784
20918
  };
20785
20919
  }
20786
- function timestampMsDisplay(raw) {
20787
- if (!raw) {
20788
- return "";
20789
- }
20790
- const ms = Number.parseInt(raw, 10);
20791
- return Number.isNaN(ms) ? "" : new Date(ms).toLocaleString();
20792
- }
20793
20920
  function organizationDisplay(organization) {
20794
20921
  const organizationSlug = organization.slug;
20795
20922
  const organizationName = organization.name;
@@ -20827,7 +20954,7 @@ function managementCredentialRows(credential, organization) {
20827
20954
  level: 1
20828
20955
  });
20829
20956
  }
20830
- const expires = timestampMsDisplay(credential.expires);
20957
+ const expires = parseProfileExpiry(credential.expires)?.toLocaleString();
20831
20958
  if (expires) {
20832
20959
  rows.push({ label: "Expires:", value: expires, level: 1 });
20833
20960
  }
@@ -20862,7 +20989,7 @@ function lakehouseCredentialRows(credential) {
20862
20989
  value: credential.basic_token ?? "set",
20863
20990
  level: 1
20864
20991
  });
20865
- const expires = timestampMsDisplay(credential.expires);
20992
+ const expires = parseProfileExpiry(credential.expires)?.toLocaleString();
20866
20993
  if (expires) {
20867
20994
  rows.push({ label: "expires:", value: expires, level: 1 });
20868
20995
  }
@@ -22750,7 +22877,6 @@ var queryCancelCommand = defineCommand({
22750
22877
  });
22751
22878
 
22752
22879
  // src/lib/query-output-args.ts
22753
- var MIN_MAX_COLUMN_WIDTH = 8;
22754
22880
  var PRESENTATION_RESULT_FORMAT_OPTIONS = ["csv", "markdown"];
22755
22881
  var QUERY_RESULT_FORMAT_OPTIONS = [
22756
22882
  "csv",
@@ -22761,15 +22887,15 @@ var QUERY_RESULT_FORMAT_OPTIONS = [
22761
22887
  var PAGER_MODE_OPTIONS = ["auto", "always", "never"];
22762
22888
  var PAGER_MODES = new Set(PAGER_MODE_OPTIONS);
22763
22889
  var AGENT_INCOMPATIBLE_QUERY_FLAGS = [
22764
- "--layout",
22765
- "--pager",
22766
- "--max-width"
22890
+ "layout",
22891
+ "pager",
22892
+ "max-width"
22767
22893
  ];
22768
22894
  var API_NATIVE_INCOMPATIBLE_PRESENTATION_FLAGS = [
22769
- "--layout",
22770
- "--columns",
22771
- "--max-width",
22772
- "--pager"
22895
+ "layout",
22896
+ "columns",
22897
+ "max-width",
22898
+ "pager"
22773
22899
  ];
22774
22900
  var queryResultFormatArgs = defineArguments({
22775
22901
  format: {
@@ -22806,69 +22932,37 @@ var queryPagerArgs = defineArguments({
22806
22932
  options: [...PAGER_MODE_OPTIONS]
22807
22933
  }
22808
22934
  });
22809
- var queryRequestArgs = defineArguments({
22810
- "compute-size": {
22811
- type: "string",
22812
- description: "Compute size for the query",
22813
- default: "AUTO"
22814
- },
22815
- dialect: {
22816
- type: "string",
22817
- description: "Source SQL dialect to transpile from (server default: DuckDB)"
22818
- },
22819
- catalog: {
22820
- type: "string",
22821
- description: "Catalog name (optional; can also come from the session)"
22822
- },
22823
- schema: {
22824
- type: "string",
22825
- description: "Schema name (optional; can also come from the session)"
22826
- },
22827
- output: {
22828
- type: "string",
22829
- description: "Write result bytes/text to this path instead of stdout"
22830
- }
22831
- });
22832
- function hasArgvFlag(rawArgs, flag) {
22833
- return rawArgs.some((arg) => arg === flag || arg.startsWith(`${flag}=`));
22834
- }
22835
22935
  function validateAgentQueryFlags(options) {
22836
22936
  if (!options.agent)
22837
22937
  return;
22838
22938
  for (const flag of AGENT_INCOMPATIBLE_QUERY_FLAGS) {
22839
- if (hasArgvFlag(options.rawArgs, flag)) {
22840
- throw new CliError(`${flag} cannot be used with --agent. Agent mode already selects structured JSON output.`);
22939
+ if (options.explicitOptions.has(flag)) {
22940
+ throw new CliError(`--${flag} cannot be used with --agent. Agent mode already selects structured JSON output.`);
22841
22941
  }
22842
22942
  }
22843
22943
  }
22844
22944
  function validateApiNativeFormatFlags(format, options) {
22845
- if (!isApiNativeQueryFormat(format))
22846
- return;
22847
22945
  if (options.json || options.agent) {
22848
22946
  throw new CliError(`--format ${format} cannot be combined with --json or --agent. Those flags expect structured CLI JSON output.`);
22849
22947
  }
22850
22948
  for (const flag of API_NATIVE_INCOMPATIBLE_PRESENTATION_FLAGS) {
22851
- if (hasArgvFlag(options.rawArgs, flag)) {
22852
- throw new CliError(`${flag} cannot be used with --format ${format}.`);
22949
+ if (options.explicitOptions.has(flag)) {
22950
+ throw new CliError(`--${flag} cannot be used with --format ${format}.`);
22853
22951
  }
22854
22952
  }
22855
22953
  }
22856
- function parseQueryLayout(args) {
22857
- const defaults = defaultDisplayOptions();
22858
- if (args.layout === undefined)
22859
- return defaults.layout;
22860
- const layout = asCliArgString(args.layout);
22954
+ function parseQueryLayout(layout) {
22861
22955
  if (!isQueryLayout(layout))
22862
22956
  throw new CliError("--layout must be auto, table, or line.");
22863
22957
  return layout;
22864
22958
  }
22865
- function parseDisplayOptions(args) {
22959
+ function parseDisplayOptions(args, explicitOptions) {
22866
22960
  const defaults = defaultDisplayOptions();
22867
22961
  let maxColumnWidth = defaults.maxColumnWidth;
22868
- if (args["max-width"] !== undefined) {
22869
- const width = Number.parseInt(asCliArgString(args["max-width"]), 10);
22870
- if (Number.isNaN(width) || width < MIN_MAX_COLUMN_WIDTH) {
22871
- throw new CliError(`--max-width must be an integer >= ${MIN_MAX_COLUMN_WIDTH}.`);
22962
+ if (explicitOptions.has("max-width")) {
22963
+ const width = parseQueryMaxColumnWidth(asCliArgString(args["max-width"]));
22964
+ if (width === undefined) {
22965
+ throw new CliError(`--max-width must be an integer >= ${MIN_QUERY_MAX_COLUMN_WIDTH}.`);
22872
22966
  }
22873
22967
  maxColumnWidth = width;
22874
22968
  }
@@ -22876,15 +22970,15 @@ function parseDisplayOptions(args) {
22876
22970
  const columns = columnsText ? columnsText.split(",").map((name) => name.trim()).filter(Boolean) : undefined;
22877
22971
  return {
22878
22972
  ...defaults,
22879
- layout: parseQueryLayout(args),
22973
+ layout: args.layout === undefined ? defaults.layout : parseQueryLayout(asCliArgString(args.layout)),
22880
22974
  maxColumnWidth,
22881
22975
  columns
22882
22976
  };
22883
22977
  }
22884
- function parsePagerOptions(args, agent) {
22978
+ function parsePagerOptions(args, { agent, explicitOptions }) {
22885
22979
  if (agent)
22886
22980
  return { mode: "never" };
22887
- if (args.pager === undefined)
22981
+ if (!explicitOptions.has("pager"))
22888
22982
  return resolvePagerOptions();
22889
22983
  const pager = asCliArgString(args.pager);
22890
22984
  if (!PAGER_MODES.has(pager)) {
@@ -22892,38 +22986,13 @@ function parsePagerOptions(args, agent) {
22892
22986
  }
22893
22987
  return resolvePagerOptions(pager);
22894
22988
  }
22895
- function optionalTrimmedString(args, name) {
22896
- const value = args[name];
22897
- if (typeof value !== "string")
22898
- return;
22899
- const trimmed = value.trim();
22900
- return trimmed === "" ? undefined : trimmed;
22901
- }
22902
- function resolveQueryComputeSize(options) {
22903
- const computeSize = options.computeSizeArg ?? "AUTO";
22904
- if (options.sessionId && !options.computeSizeExplicit)
22905
- return;
22906
- return computeSize;
22907
- }
22908
22989
  function parseQueryOutputOptions(args, options) {
22909
22990
  validateAgentQueryFlags(options);
22910
22991
  const format = parseQueryResultFormat(args.format === undefined ? "human" : asCliArgString(args.format));
22911
- validateApiNativeFormatFlags(format, options);
22912
- const sessionId = optionalTrimmedString(args, "session-id");
22913
- const computeSize = resolveQueryComputeSize({
22914
- sessionId,
22915
- computeSizeArg: args["compute-size"] === undefined ? undefined : asCliArgString(args["compute-size"]),
22916
- computeSizeExplicit: hasArgvFlag(options.rawArgs, "--compute-size")
22917
- });
22918
22992
  return {
22919
22993
  format,
22920
- displayOptions: parseDisplayOptions(args),
22921
- pagerOptions: parsePagerOptions(args, options.agent),
22922
- outputPath: optionalTrimmedString(args, "output"),
22923
- computeSize,
22924
- dialect: optionalTrimmedString(args, "dialect"),
22925
- catalog: optionalTrimmedString(args, "catalog"),
22926
- schema: optionalTrimmedString(args, "schema")
22994
+ displayOptions: parseDisplayOptions(args, options.explicitOptions),
22995
+ pagerOptions: parsePagerOptions(args, options)
22927
22996
  };
22928
22997
  }
22929
22998
 
@@ -22937,7 +23006,27 @@ var queryRunArgs = defineArguments({
22937
23006
  },
22938
23007
  ...queryApiResultFormatArgs,
22939
23008
  ...queryDisplayArgs,
22940
- ...queryRequestArgs,
23009
+ "compute-size": {
23010
+ type: "string",
23011
+ description: "Compute size for the query",
23012
+ default: "AUTO"
23013
+ },
23014
+ dialect: {
23015
+ type: "string",
23016
+ description: "Source SQL dialect to transpile from (server default: DuckDB)"
23017
+ },
23018
+ catalog: {
23019
+ type: "string",
23020
+ description: "Catalog name (optional; can also come from the session)"
23021
+ },
23022
+ schema: {
23023
+ type: "string",
23024
+ description: "Schema name (optional; can also come from the session)"
23025
+ },
23026
+ output: {
23027
+ type: "string",
23028
+ description: "Write result bytes/text to this path instead of stdout"
23029
+ },
22941
23030
  "query-id": { type: "string", description: "Optional stable query id" },
22942
23031
  "session-id": { type: "string", description: "Optional session id" },
22943
23032
  ...queryPagerArgs
@@ -22946,7 +23035,10 @@ var queryRunArgs = defineArguments({
22946
23035
  // src/commands/query/lib/statement.ts
22947
23036
  function parseQueryStatement(statementArg) {
22948
23037
  const statement = readFileArgument(statementArg);
22949
- if (statementArg.startsWith("@") && statement.trim() === "") {
23038
+ if (statement.trim() === "") {
23039
+ if (!statementArg.startsWith("@")) {
23040
+ throw new CliError("SQL statement is empty.");
23041
+ }
22950
23042
  throw new CliError(statementArg === "@-" ? "SQL from stdin is empty." : `SQL file is empty: ${statementArg.slice(1)}`);
22951
23043
  }
22952
23044
  return statement;
@@ -23003,13 +23095,13 @@ async function fetchQueryTopSnapshot(execution, sortKey) {
23003
23095
  const listResponse = await sendHttp(buildLakehouseQueryListRequest(), execution);
23004
23096
  const listed = parseRunningQueries(parseApiJson(listResponse));
23005
23097
  const details = await mapWithConcurrency(listed, DETAIL_CONCURRENCY, (query) => fetchQueryDetails(query.id, execution));
23006
- const queries = listed.map((query, index) => ({
23007
- ...query,
23008
- details: details[index] ?? null
23009
- }));
23010
- const sortValue = (entry) => SORT_VALUES[sortKey](toQueryTopRow(entry)) ?? -Infinity;
23011
- queries.sort((left, right) => sortValue(right) - sortValue(left));
23012
- return { queries };
23098
+ const sortValue = SORT_VALUES[sortKey];
23099
+ const ranked = listed.map((query, index) => {
23100
+ const entry = { ...query, details: details[index] ?? null };
23101
+ return { entry, rank: sortValue(toQueryTopRow(entry)) ?? -Infinity };
23102
+ });
23103
+ ranked.sort((left, right) => right.rank - left.rank);
23104
+ return { queries: ranked.map(({ entry }) => entry) };
23013
23105
  }
23014
23106
  function renderQueryTopTable(snapshot, options = {}) {
23015
23107
  if (snapshot.queries.length === 0) {
@@ -23231,8 +23323,9 @@ async function runLiveView(options) {
23231
23323
  const controller = new AbortController;
23232
23324
  const interrupt = () => controller.abort();
23233
23325
  process.on("SIGINT", interrupt);
23234
- await options.write(ENTER_SCREEN);
23326
+ let failed = false;
23235
23327
  try {
23328
+ await options.write(ENTER_SCREEN);
23236
23329
  while (!controller.signal.aborted) {
23237
23330
  const frame = await untilAborted(options.render({ rows: process.stdout.rows }), controller.signal);
23238
23331
  if (frame === undefined || controller.signal.aborted) {
@@ -23241,9 +23334,18 @@ async function runLiveView(options) {
23241
23334
  await options.write(redrawInPlace(frame));
23242
23335
  await abortableSleep(options.intervalMs, controller.signal);
23243
23336
  }
23337
+ } catch (error) {
23338
+ failed = true;
23339
+ throw error;
23244
23340
  } finally {
23245
- process.off("SIGINT", interrupt);
23246
- await options.write(LEAVE_SCREEN);
23341
+ try {
23342
+ await Promise.resolve().then(() => options.write(LEAVE_SCREEN)).catch((error) => {
23343
+ if (!failed)
23344
+ throw error;
23345
+ });
23346
+ } finally {
23347
+ process.off("SIGINT", interrupt);
23348
+ }
23247
23349
  }
23248
23350
  }
23249
23351
  function redrawInPlace(frame) {
@@ -23267,6 +23369,8 @@ async function untilAborted(promise, signal) {
23267
23369
  }
23268
23370
  }
23269
23371
  function abortableSleep(milliseconds, signal) {
23372
+ if (signal.aborted)
23373
+ return Promise.resolve();
23270
23374
  return new Promise((resolve) => {
23271
23375
  const timer = setTimeout(done, milliseconds);
23272
23376
  signal.addEventListener("abort", done, { once: true });
@@ -23374,42 +23478,41 @@ var queryCommand = defineCommand({
23374
23478
  top: queryTopCommand,
23375
23479
  cancel: queryCancelCommand
23376
23480
  },
23377
- async run({ args, rawArgs, execution, sink }) {
23481
+ async run({ args, explicitOptions, execution, sink }) {
23378
23482
  const statementArg = optionalStringArg(args, "statement");
23379
23483
  if (statementArg === undefined) {
23380
23484
  throw new CliError('Provide a SQL statement, e.g. altertable query "SELECT 1".');
23381
23485
  }
23382
23486
  const statement = parseQueryStatement(statementArg);
23383
- const {
23384
- format,
23385
- displayOptions,
23386
- pagerOptions,
23387
- outputPath,
23388
- computeSize,
23389
- dialect,
23390
- catalog,
23391
- schema
23392
- } = parseQueryOutputOptions(args, {
23487
+ const outputContext = {
23393
23488
  agent: execution.cli.agent,
23394
23489
  json: sink.json,
23395
- rawArgs
23396
- });
23490
+ explicitOptions
23491
+ };
23492
+ const output = parseQueryOutputOptions(args, outputContext);
23493
+ const { format } = output;
23494
+ const outputPath = optionalStringArg(args, "output");
23495
+ if (explicitOptions.has("output") && outputPath === undefined) {
23496
+ throw new CliError("--output requires a file path.");
23497
+ }
23498
+ const sessionId = optionalStringArg(args, "session-id");
23397
23499
  const input = {
23398
23500
  statement,
23399
23501
  queryId: optionalStringArg(args, "query-id"),
23400
- sessionId: optionalStringArg(args, "session-id"),
23401
- computeSize,
23402
- dialect,
23403
- catalog,
23404
- schema
23502
+ sessionId,
23503
+ computeSize: sessionId?.trim() && !explicitOptions.has("compute-size") ? undefined : asCliArgString(args["compute-size"]),
23504
+ dialect: optionalStringArg(args, "dialect")?.trim(),
23505
+ catalog: optionalStringArg(args, "catalog")?.trim(),
23506
+ schema: optionalStringArg(args, "schema")?.trim()
23405
23507
  };
23406
23508
  if (isApiNativeQueryFormat(format)) {
23509
+ validateApiNativeFormatFlags(format, outputContext);
23407
23510
  const stream = await executeLakehouseQueryBytes({ ...input, format }, execution);
23408
23511
  await writeQueryDestination(stream, { outputPath, sink });
23409
23512
  return;
23410
23513
  }
23411
23514
  const result = await executeLakehouseQuery(input, execution, !sink.json);
23412
- await writeQueryOutput(result, format, sink, displayOptions, pagerOptions, outputPath);
23515
+ await writeQueryOutput(result, sink, { ...output, outputPath });
23413
23516
  }
23414
23517
  });
23415
23518
 
@@ -23525,22 +23628,21 @@ var schemaCommand = defineCommand({
23525
23628
  ]
23526
23629
  },
23527
23630
  args: schemaArgs,
23528
- async run({ args, rawArgs, execution, sink }) {
23631
+ async run({ args, explicitOptions, execution, sink }) {
23529
23632
  const catalog = stringArg(args, "catalog");
23530
- const { format, displayOptions, pagerOptions } = parseQueryOutputOptions(args, {
23633
+ const output = parseQueryOutputOptions(args, {
23531
23634
  agent: execution.cli.agent,
23532
- json: sink.json,
23533
- rawArgs
23635
+ explicitOptions
23534
23636
  });
23535
23637
  const queryInput = {
23536
23638
  statement: buildSchemaStatement(catalog)
23537
23639
  };
23538
- const result = await executeLakehouseQuery(queryInput, execution, format !== "json" && !sink.json);
23539
- if (format !== "human" || sink.json) {
23540
- await writeQueryOutput(result, format, sink, displayOptions, pagerOptions);
23640
+ const result = await executeLakehouseQuery(queryInput, execution, !sink.json);
23641
+ if (output.format !== "human" || sink.json) {
23642
+ await writeQueryOutput(result, sink, output);
23541
23643
  return;
23542
23644
  }
23543
- await writePagedOutput(renderTreeText(buildSchemaTreeView(result, catalog)), pagerOptions, sink);
23645
+ await writePagedOutput(renderTreeText(buildSchemaTreeView(result, catalog)), output.pagerOptions, sink);
23544
23646
  }
23545
23647
  });
23546
23648
  function buildSchemaStatement(catalog) {
@@ -23589,14 +23691,14 @@ import { spawnSync as spawnSync4 } from "child_process";
23589
23691
  import { createHash, randomBytes as randomBytes5 } from "crypto";
23590
23692
  import {
23591
23693
  existsSync as existsSync5,
23592
- mkdirSync as mkdirSync4,
23593
- readFileSync as readFileSync7,
23694
+ mkdirSync as mkdirSync5,
23695
+ readFileSync as readFileSync8,
23594
23696
  renameSync as renameSync3,
23595
23697
  rmSync as rmSync4,
23596
- writeFileSync as writeFileSync3
23698
+ writeFileSync as writeFileSync4
23597
23699
  } from "fs";
23598
23700
  import { chmodSync as chmodSync2 } from "fs";
23599
- import { basename as basename2, dirname as dirname4, join as join13 } from "path";
23701
+ import { basename as basename2, dirname as dirname5, join as join14 } from "path";
23600
23702
 
23601
23703
  // src/lib/executable-path.ts
23602
23704
  import { accessSync, constants, realpathSync, statSync as statSync3 } from "fs";
@@ -23870,13 +23972,13 @@ function compareVersions(leftVersion, rightVersion) {
23870
23972
  return 0;
23871
23973
  }
23872
23974
  function updaterStateFile() {
23873
- return join13(configDir(), UpdaterConfig.stateFileName);
23975
+ return join14(configDir(), UpdaterConfig.stateFileName);
23874
23976
  }
23875
23977
  function writeJsonFileAtomic(filePath, data) {
23876
- mkdirSync4(dirname4(filePath), { recursive: true });
23978
+ mkdirSync5(dirname5(filePath), { recursive: true });
23877
23979
  const tmpPath = tempSiblingPath2(filePath, "update");
23878
23980
  try {
23879
- writeFileSync3(tmpPath, `${JSON.stringify(data, null, 2)}
23981
+ writeFileSync4(tmpPath, `${JSON.stringify(data, null, 2)}
23880
23982
  `, {
23881
23983
  mode: 384
23882
23984
  });
@@ -23890,7 +23992,7 @@ function writeJsonFileAtomic(filePath, data) {
23890
23992
  }
23891
23993
  function readUpdateState() {
23892
23994
  try {
23893
- const parsed = JSON.parse(readFileSync7(updaterStateFile(), "utf8"));
23995
+ const parsed = JSON.parse(readFileSync8(updaterStateFile(), "utf8"));
23894
23996
  if (typeof parsed === "object" && parsed !== null) {
23895
23997
  return parsed;
23896
23998
  }
@@ -24160,7 +24262,7 @@ function parseChecksums(text) {
24160
24262
  return checksums;
24161
24263
  }
24162
24264
  function verifySha256(filePath, expectedHash) {
24163
- const actualHash = createHash("sha256").update(readFileSync7(filePath)).digest("hex");
24265
+ const actualHash = createHash("sha256").update(readFileSync8(filePath)).digest("hex");
24164
24266
  return actualHash === expectedHash.toLowerCase();
24165
24267
  }
24166
24268
  async function fetchLatestRelease(options = {}) {
@@ -24315,7 +24417,7 @@ function verifyInstalledCliVersion(expectedVersion, command = "altertable", spaw
24315
24417
  return installedVersion;
24316
24418
  }
24317
24419
  function tempSiblingPath2(targetPath, suffix) {
24318
- return join13(dirname4(targetPath), `.altertable-${suffix}-${randomBytes5(8).toString("hex")}`);
24420
+ return join14(dirname5(targetPath), `.altertable-${suffix}-${randomBytes5(8).toString("hex")}`);
24319
24421
  }
24320
24422
  function replaceFileAtomically(targetPath, replacementPath) {
24321
24423
  const backupPath = tempSiblingPath2(targetPath, "backup");
@@ -24352,7 +24454,7 @@ async function writeVerifiedGitHubBinaryDownload(options) {
24352
24454
  const tempPath = tempSiblingPath2(options.targetPath, "download");
24353
24455
  try {
24354
24456
  const bytes = await fetchBytes(options.release.assetDownloadUrl, options.release.assetName, options.downloadTimeoutMs, options.fetchImpl);
24355
- writeFileSync3(tempPath, bytes, { mode: 493 });
24457
+ writeFileSync4(tempPath, bytes, { mode: 493 });
24356
24458
  const checksumsText = await fetchText(options.release.checksumsDownloadUrl, options.timeoutMs, options.fetchImpl);
24357
24459
  const expectedHash = parseChecksums(checksumsText).get(options.release.assetName);
24358
24460
  if (!expectedHash) {
@@ -24442,9 +24544,9 @@ function resolveGlobalInstalledCliPath(manager, spawnImpl) {
24442
24544
  if (!outputPath) {
24443
24545
  throw new CliError(`${manager} did not report its global binary directory.`);
24444
24546
  }
24445
- const binDirectory = "globalBinIsPrefix" in config && config.globalBinIsPrefix && process.platform !== "win32" ? join13(outputPath, "bin") : outputPath;
24547
+ const binDirectory = "globalBinIsPrefix" in config && config.globalBinIsPrefix && process.platform !== "win32" ? join14(outputPath, "bin") : outputPath;
24446
24548
  const executableName = process.platform === "win32" ? `${UpdaterConfig.executableName}.cmd` : UpdaterConfig.executableName;
24447
- return join13(binDirectory, executableName);
24549
+ return join14(binDirectory, executableName);
24448
24550
  }
24449
24551
  function installPackageManagerRelease(version, options = {}) {
24450
24552
  const plan = createInstallPlan(version);
@@ -25119,6 +25221,7 @@ function parseInvocationArguments(invocation, tokens) {
25119
25221
  const options = availableOptions(invocation.root.arguments, invocation.command.arguments);
25120
25222
  const positionals = Object.entries(invocation.command.arguments).filter(([, argument]) => argument.type === "positional");
25121
25223
  const parsed = {};
25224
+ const explicitOptions = new Set;
25122
25225
  let positionalIndex = 0;
25123
25226
  let afterSeparator = false;
25124
25227
  for (let index = 0;index < tokens.length; index += 1) {
@@ -25139,6 +25242,7 @@ function parseInvocationArguments(invocation, tokens) {
25139
25242
  if (binding.argument.flagScope === "root-only" && tokens.length !== 1) {
25140
25243
  throw new CommandParseError(`${name} is only valid at the command root.`);
25141
25244
  }
25245
+ explicitOptions.add(binding.name);
25142
25246
  if (takesValue(binding.argument)) {
25143
25247
  const inlineValue = inlineOptionValue(token);
25144
25248
  const value = inlineValue ?? nextOptionValue(tokens, index, options);
@@ -25168,15 +25272,15 @@ function parseInvocationArguments(invocation, tokens) {
25168
25272
  if (invocation.command !== invocation.root) {
25169
25273
  applyDefaultsAndValidate(parsed, invocation.command.arguments);
25170
25274
  }
25171
- return parsed;
25275
+ return { args: parsed, explicitOptions };
25172
25276
  }
25173
- function createRunContext(command, args, rawArgs) {
25277
+ function createRunContext(command, { args, explicitOptions }) {
25174
25278
  const runtime = getCliRuntime();
25175
25279
  let execution;
25176
25280
  return {
25177
25281
  command,
25178
25282
  args,
25179
- rawArgs: [...rawArgs],
25283
+ explicitOptions,
25180
25284
  runtime,
25181
25285
  sink: runtime.output,
25182
25286
  get execution() {
@@ -25190,11 +25294,11 @@ async function executeCommand(root, rawArgs) {
25190
25294
  const parsed = parseInvocationArguments(invocation, rawArgs);
25191
25295
  let runResult = undefined;
25192
25296
  if (root.run) {
25193
- runResult = await root.run(createRunContext(root, parsed, rawArgs));
25297
+ runResult = await root.run(createRunContext(root, parsed));
25194
25298
  }
25195
25299
  const selected = invocation.command.definition;
25196
25300
  if (selected !== root && selected.run) {
25197
- runResult = await selected.run(createRunContext(selected, parsed, rawArgs));
25301
+ runResult = await selected.run(createRunContext(selected, parsed));
25198
25302
  }
25199
25303
  return {
25200
25304
  command: selected,