@altertable/cli 1.9.0 → 1.10.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 +290 -55
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -7035,7 +7035,7 @@ var require_public_api = __commonJS(function(exports) {
7035
7035
  });
7036
7036
 
7037
7037
  // src/version.ts
7038
- var VERSION = "1.9.0";
7038
+ var VERSION = "1.10.0";
7039
7039
  var USER_AGENT = `altertable-cli/${VERSION}`;
7040
7040
 
7041
7041
  // src/lib/transport-defaults.ts
@@ -22102,7 +22102,7 @@ async function runAppCommand(command, directory, appEnvironment, signal) {
22102
22102
  var appBuildCommand = defineCommand({
22103
22103
  metadata: {
22104
22104
  name: "build",
22105
- description: "Typecheck and build a data app without Altertable credentials.",
22105
+ description: "Typecheck and build a local data app without Altertable credentials.",
22106
22106
  examples: ["altertable app build", "altertable app build --dir ./my-app"]
22107
22107
  },
22108
22108
  args: {
@@ -22180,7 +22180,12 @@ dist/
22180
22180
  ]
22181
22181
  }
22182
22182
  }
22183
- `, "AGENTS.md": "# Build this data app\n\nInspect source data, time coverage and existing definitions before choosing an exploration. For broad questions, investigate complementary angles. Build conclusions from observed results; do not present association as cause. Keep copy concise and relevant to the reader.\n\nRead `node_modules/@altertable/data-app/AGENTS.md` and its [app authoring guide](node_modules/@altertable/data-app/docs/app-authoring.md) before changing the app. Run `bun install --frozen-lockfile` if the package is not installed.\n\n| Task | App-owned files | Read next |\n| --- | --- | --- |\n| Connect a source, define a query, or change inputs | `app.json`, `src/operations.ts`, optional `src/variables.ts` | [Data and operation authoring](docs/data.md) |\n| Build a view, filters, request states, or Present steps | `src/App.tsx`, `src/styles.css` | [View authoring](docs/views.md) |\n| Explain the exploration or define terms | `src/data-context.ts` or `.tsx` | [Data guidance](docs/data.md), [context APIs](node_modules/@altertable/data-app/docs/react.md#find-ui-by-task) |\n| Change title, scope, or brand | `app.json` | [Config and appearance APIs](node_modules/@altertable/data-app/docs/app-authoring.md) |\n| Find a component, hook, or parser | Read the installed package docs | [Package authoring guide](node_modules/@altertable/data-app/docs/app-authoring.md) |\n| Replace the local server with hosting | `src/server.ts` | [Server authorization boundary](node_modules/@altertable/data-app/docs/server.md) |\n\nEdit app-owned source and use public package APIs. Do not edit installed package files. The generated connectivity screen is scaffolding, not an example analysis.\n\nRun `altertable app check --lakehouse` with the matching profile, then inspect the exploration at phone and desktop widths. Verify that its findings and interactions answer the user's question.\n", "README.md": `# Getting started
22183
+ `, "AGENTS.md": `# Build this data app
22184
+
22185
+ 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.
22186
+
22187
+ See [README.md](README.md) for CLI setup, checks, and upgrades.
22188
+ `, "README.md": `# Getting started
22184
22189
 
22185
22190
  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.
22186
22191
 
@@ -22202,7 +22207,7 @@ Start with the [authoring router](AGENTS.md) for data and view changes, or the [
22202
22207
 
22203
22208
  ## Check and upgrade
22204
22209
 
22205
- Run \`altertable app check\` to check the app locally. Use \`altertable app check --lakehouse\` to execute each operation's declared \`checks\` against the selected profile.
22210
+ 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.
22206
22211
 
22207
22212
  \`altertable app upgrade\` pins the package version tested with your CLI and updates the lockfile. It preserves app code and does not downgrade a newer installed package. Restart a running preview after upgrading.
22208
22213
 
@@ -22214,7 +22219,7 @@ Commit app source, \`package.json\`, and \`bun.lock\`. A fresh clone installs \`
22214
22219
  "title": "Getting started",
22215
22220
  "scope": { "organization": "Your organization", "environment": "your environment" },
22216
22221
  "appearance": {
22217
- "mode": "light",
22222
+ "theme": "light",
22218
22223
  "baseColor": "neutral",
22219
22224
  "accentColor": "#405d47",
22220
22225
  "density": "comfortable",
@@ -22230,7 +22235,7 @@ Commit app source, \`package.json\`, and \`bun.lock\`. A fresh clone installs \`
22230
22235
  "": {
22231
22236
  "name": "data-app-starter",
22232
22237
  "dependencies": {
22233
- "@altertable/data-app": "0.61.0",
22238
+ "@altertable/data-app": "0.66.0",
22234
22239
  "react": "19.3.0",
22235
22240
  "react-dom": "19.3.0",
22236
22241
  },
@@ -22246,7 +22251,7 @@ Commit app source, \`package.json\`, and \`bun.lock\`. A fresh clone installs \`
22246
22251
  },
22247
22252
  },
22248
22253
  "packages": {
22249
- "@altertable/data-app": ["@altertable/data-app@0.61.0", "", { "dependencies": { "@floating-ui/react": "0.27.20", "@internationalized/date": "3.12.4", "@tanstack/react-query": "5.104.0", "fuzzysort": "4.0.2", "lucide-react": "1.48.0", "react-aria-components": "1.21.1" }, "peerDependencies": { "react": ">=19.2.0", "react-dom": ">=19.2.0" } }, "sha512-68nAEv/G0C7ZJ6P+Y0kAEBXEG4cMvEqORJYqR1/9dd+CeEYHMJDN4v20/7VUnYnEfz6reXJGyuKq3MMv6zbhpA=="],
22254
+ "@altertable/data-app": ["@altertable/data-app@0.66.0", "", { "dependencies": { "@floating-ui/react": "0.27.20", "@internationalized/date": "3.12.4", "@tanstack/react-query": "5.104.0", "fflate": "0.8.3", "fuzzysort": "4.0.2", "html-to-image": "1.11.13", "lucide-react": "1.48.0", "react-aria-components": "1.21.1" }, "peerDependencies": { "react": ">=19.2.0", "react-dom": ">=19.2.0" } }, "sha512-558Acl33lVYDxpuTE8npNxeSzDYnve4s2A6kz9KxzdW+dDlJkdJT6jEzKaizZDYmIf4s86A0gY1uaEgij3kO/Q=="],
22250
22255
 
22251
22256
  "@floating-ui/core": ["@floating-ui/core@1.8.0", "", { "dependencies": { "@floating-ui/utils": "^0.2.12" } }, "sha512-0CIZ5itps/8x7BG8dEIhs53BvCUH2PCoogtakwRTut+Arm58sJooJ0AuZhLw2HJYIR5cMLNPBSS728sPho2khQ=="],
22252
22257
 
@@ -22418,8 +22423,12 @@ Commit app source, \`package.json\`, and \`bun.lock\`. A fresh clone installs \`
22418
22423
 
22419
22424
  "csstype": ["csstype@3.2.3", "", {}, "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ=="],
22420
22425
 
22426
+ "fflate": ["fflate@0.8.3", "", {}, "sha512-tbZNuJrLwGUp3zshBtdy4W+ORxZuIh8a5ilyIEQDC5rY1f3U20JMry0Ll3WBzU58EZKsEuJFXhb5gwv8CsPvgA=="],
22427
+
22421
22428
  "fuzzysort": ["fuzzysort@4.0.2", "", {}, "sha512-3c7yD6rK1EXIsqpcu1ZVzXJugODWNMzvUij6yTiziaAHrpNS8kzFOI9mJLE8pmG4K9JOaVgzQRgklfOEk8f4Tg=="],
22422
22429
 
22430
+ "html-to-image": ["html-to-image@1.11.13", "", {}, "sha512-cuOPoI7WApyhBElTTb9oqsawRvZ0rHhaHwghRLlTuffoD1B2aDemlCruLeZrUIIdvG7gs9xeELEPm6PhuASqrg=="],
22431
+
22423
22432
  "lucide-react": ["lucide-react@1.48.0", "", { "peerDependencies": { "react": "^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-R0CIKY/fXiC6y9xRBADgsK+VW2p/pcTJOMhLZf1T+uG+vJUvyUR02nGOgmIIC7MPkiNK4Ox8QDnbqF8rJYWPZQ=="],
22424
22433
 
22425
22434
  "oxfmt": ["oxfmt@0.70.0", "", { "dependencies": { "tinypool": "2.1.2" }, "optionalDependencies": { "@oxfmt/binding-android-arm-eabi": "0.70.0", "@oxfmt/binding-android-arm64": "0.70.0", "@oxfmt/binding-darwin-arm64": "0.70.0", "@oxfmt/binding-darwin-x64": "0.70.0", "@oxfmt/binding-freebsd-x64": "0.70.0", "@oxfmt/binding-linux-arm-gnueabihf": "0.70.0", "@oxfmt/binding-linux-arm-musleabihf": "0.70.0", "@oxfmt/binding-linux-arm64-gnu": "0.70.0", "@oxfmt/binding-linux-arm64-musl": "0.70.0", "@oxfmt/binding-linux-ppc64-gnu": "0.70.0", "@oxfmt/binding-linux-riscv64-gnu": "0.70.0", "@oxfmt/binding-linux-riscv64-musl": "0.70.0", "@oxfmt/binding-linux-s390x-gnu": "0.70.0", "@oxfmt/binding-linux-x64-gnu": "0.70.0", "@oxfmt/binding-linux-x64-musl": "0.70.0", "@oxfmt/binding-openharmony-arm64": "0.70.0", "@oxfmt/binding-win32-arm64-msvc": "0.70.0", "@oxfmt/binding-win32-ia32-msvc": "0.70.0", "@oxfmt/binding-win32-x64-msvc": "0.70.0" }, "peerDependencies": { "svelte": "^5.0.0", "vite-plus": "*" }, "optionalPeers": ["svelte", "vite-plus"], "bin": { "oxfmt": "bin/oxfmt" } }, "sha512-IsHxZ4y0wQLLMhnrJblBJgZsLDzfULrJnAw5j/QqsTlMa/m3AqsbToi+W71uhBGaqlqq/PbbjvHc09TJwdv3Tw=="],
@@ -22455,26 +22464,6 @@ Commit app source, \`package.json\`, and \`bun.lock\`. A fresh clone installs \`
22455
22464
  }
22456
22465
  `, "bunfig.toml": `[install]
22457
22466
  exact = true
22458
- `, "docs/data.md": `# Data authoring
22459
-
22460
- Inspect catalogs, time coverage, and existing definitions before selecting the exploration. Explore several useful angles for broad requests. Use bounded queries and observed results.
22461
-
22462
- | File | Owns |
22463
- | --- | --- |
22464
- | \`app.json\` | Title, verified scope, and appearance. |
22465
- | \`src/operations.ts\` | Bounded server-side queries, validation, and fixed live-check inputs. Credentials stay on the server. |
22466
- | \`src/variables.ts\` | Optional reader-controlled defaults, URL state, and operation inputs. |
22467
- | \`src/data-context.ts\` or \`.tsx\` | Exploration description, glossary, named queries, and optional source identifiers. |
22468
- | \`src/App.tsx\` | Questions, filters, result states, cards, and optional story. |
22469
-
22470
- [Execute named queries](../node_modules/@altertable/data-app/docs/contract.md) and [bind evidence](../node_modules/@altertable/data-app/docs/react.md#bind-evidence) using the runtime contracts. Prefer a date variable for ongoing questions; choose a fixed period for deliberate historical explorations.
22471
-
22472
- \`app check --lakehouse\` verifies declared operations and known profile scope. Environment-only credentials may not identify an organization; verify source identity during discovery when that metadata is unavailable.
22473
- `, "docs/views.md": `# View authoring
22474
-
22475
- Lead with a supported finding and provide complementary ways to explore the question. Check actual content at phone and desktop widths in both themes.
22476
-
22477
- [Bind a view](../node_modules/@altertable/data-app/docs/react.md#bind-a-view) for variables, request states, shared skeletons, metrics and comparisons. [Bind evidence](../node_modules/@altertable/data-app/docs/react.md#bind-evidence) for glossary definitions and Present steps. The [UI map](../node_modules/@altertable/data-app/docs/react.md#find-ui-by-task) routes other components to their types.
22478
22467
  `, "package.json": `{
22479
22468
  "name": "data-app-starter",
22480
22469
  "private": true,
@@ -22492,7 +22481,7 @@ Lead with a supported finding and provide complementary ways to explore the ques
22492
22481
  "build": "bun build src/index.html --outdir=dist --production"
22493
22482
  },
22494
22483
  "dependencies": {
22495
- "@altertable/data-app": "0.61.0",
22484
+ "@altertable/data-app": "0.66.0",
22496
22485
  "react": "19.3.0",
22497
22486
  "react-dom": "19.3.0"
22498
22487
  },
@@ -22506,9 +22495,9 @@ Lead with a supported finding and provide complementary ways to explore the ques
22506
22495
  "typescript": "7.0.2"
22507
22496
  }
22508
22497
  }
22509
- `, "src/App.tsx": `import { GettingStarted } from "@altertable/data-app/react";
22498
+ `, "src/App.tsx": `import { GettingStarted } from "@altertable/data-app/react/ui";
22510
22499
  import { dataContext } from "#app/data-context.ts";
22511
- import app from "#config";
22500
+ import app from "#app/config.ts";
22512
22501
 
22513
22502
  /** Connectivity-only screen. Investigate the requested question, then replace this with a view
22514
22503
  * that leads with a supported finding and explores the useful angles behind it. */
@@ -22516,6 +22505,15 @@ export function App() {
22516
22505
  return <GettingStarted config={app} dataContext={dataContext} />;
22517
22506
  }
22518
22507
  `, "src/assets.d.ts": `declare module "*.css";
22508
+ `, "src/config.ts": `import { parseAppearance } from "@altertable/data-app/appearance";
22509
+ import type { DataAppConfig } from "@altertable/data-app/config";
22510
+ import app from "#config";
22511
+
22512
+ export default {
22513
+ title: app.title,
22514
+ scope: app.scope,
22515
+ appearance: parseAppearance(app.appearance),
22516
+ } satisfies DataAppConfig;
22519
22517
  `, "src/data-context.ts": `import { createDataContext } from "@altertable/data-app/react";
22520
22518
  import { connectionQueryNames } from "@altertable/data-app/contract";
22521
22519
 
@@ -22559,11 +22557,11 @@ export const dataContext = createDataContext(connectionQueryNames)({
22559
22557
  <div id="root"></div>
22560
22558
  </body>
22561
22559
  </html>
22562
- `, "src/main.tsx": `import "@altertable/data-app/react/styles.css";
22563
- import { mountDataApp } from "@altertable/data-app/react";
22560
+ `, "src/main.tsx": `import { injectDataAppStyles, mountDataApp } from "@altertable/data-app/react";
22564
22561
  import { App } from "#app/App.tsx";
22565
- import app from "#config";
22562
+ import app from "#app/config.ts";
22566
22563
 
22564
+ injectDataAppStyles();
22567
22565
  mountDataApp({ config: app, component: App });
22568
22566
  `, "src/operations.ts": `import { connectionCheck } from "@altertable/data-app/contract";
22569
22567
 
@@ -22573,7 +22571,7 @@ export const operations = { connection: connectionCheck() };
22573
22571
  `, "src/server.ts": `import page from "#app/index.html";
22574
22572
  import { serveLocalApp } from "@altertable/data-app/server/bun";
22575
22573
  import { operations } from "#app/operations.ts";
22576
- import app from "#config";
22574
+ import app from "#app/config.ts";
22577
22575
 
22578
22576
  serveLocalApp({ page, operations, title: app.title });
22579
22577
  `, "tsconfig.json": `{
@@ -22597,7 +22595,7 @@ serveLocalApp({ page, operations, title: app.title });
22597
22595
  var appCreateCommand = defineCommand({
22598
22596
  metadata: {
22599
22597
  name: "create",
22600
- description: "Create a data app project with a live connection check.",
22598
+ description: "Create a local data app project with a live connection check.",
22601
22599
  examples: [
22602
22600
  "altertable app create product-pulse",
22603
22601
  "altertable app create product-pulse --dir ./apps/product-pulse",
@@ -22658,11 +22656,11 @@ var appCreateCommand = defineCommand({
22658
22656
  await rm(directory, { recursive: true, force: true });
22659
22657
  throw new CliError(`Could not create data app in ${directory}.`, { cause: error });
22660
22658
  }
22661
- const nextSteps = profileName ? ["app dev", "app check", "app build"].map((command) => `altertable --profile ${profileName} ${command}`) : [
22659
+ const nextSteps = profileName ? ["app dev", "app lint", "app build"].map((command) => `altertable --profile ${profileName} ${command}`) : [
22662
22660
  "Set organization and environment in app.json.",
22663
22661
  "Select a matching profile, or configure one with `altertable login --org <org> --env <env>`.",
22664
22662
  "altertable app dev",
22665
- "altertable app check --lakehouse",
22663
+ "altertable app lint --lakehouse",
22666
22664
  "altertable app build"
22667
22665
  ];
22668
22666
  const result = {
@@ -22808,7 +22806,7 @@ function appPort(value) {
22808
22806
  return value;
22809
22807
  }
22810
22808
 
22811
- // src/commands/app/check.ts
22809
+ // src/commands/app/lint.ts
22812
22810
  import { readFile as readFile4, readdir } from "fs/promises";
22813
22811
  import { join as join10 } from "path";
22814
22812
 
@@ -23058,12 +23056,12 @@ try {
23058
23056
  }
23059
23057
  `;
23060
23058
 
23061
- // src/commands/app/check.ts
23062
- var appCheckCommand = defineCommand({
23059
+ // src/commands/app/lint.ts
23060
+ var appLintCommand = defineCommand({
23063
23061
  metadata: {
23064
- name: "check",
23065
- description: "Validate a data app's format, lint, types, contracts, build, and client credential boundary.",
23066
- examples: ["altertable app check", "altertable app check --lakehouse"]
23062
+ name: "lint",
23063
+ description: "Lint a local data app project: format, lint rules, types, contracts, build, and client credential boundary.",
23064
+ examples: ["altertable app lint", "altertable app lint --lakehouse"]
23067
23065
  },
23068
23066
  args: {
23069
23067
  dir: { type: "string", description: "App directory (default: current directory)." },
@@ -23172,20 +23170,211 @@ async function checkClientBundle(directory, secrets = []) {
23172
23170
  }
23173
23171
  }
23174
23172
 
23173
+ // src/commands/app/lib/remote.ts
23174
+ import { readFile as readFile5 } from "fs/promises";
23175
+ async function readRequiredFile(path, label) {
23176
+ try {
23177
+ return await readFile5(path, "utf8");
23178
+ } catch (error) {
23179
+ throw new CliError(`Could not read ${label}: ${path}`, { cause: error });
23180
+ }
23181
+ }
23182
+ async function readJsonFile(path, label) {
23183
+ const text = await readRequiredFile(path, label);
23184
+ try {
23185
+ return JSON.parse(text);
23186
+ } catch (error) {
23187
+ throw new CliError(`${label} is not valid JSON: ${path}`, { cause: error });
23188
+ }
23189
+ }
23190
+ function parseQueries(value) {
23191
+ if (Array.isArray(value)) {
23192
+ return value.map((entry, index) => {
23193
+ if (typeof entry !== "object" || entry === null) {
23194
+ throw new CliError(`queries[${index}] must be an object with id and sql.`);
23195
+ }
23196
+ const { id, sql } = entry;
23197
+ if (typeof id !== "string" || typeof sql !== "string") {
23198
+ throw new CliError(`queries[${index}] id and sql must be strings.`);
23199
+ }
23200
+ return { id, sql };
23201
+ });
23202
+ }
23203
+ if (typeof value === "object" && value !== null) {
23204
+ return Object.entries(value).map(([id, sql]) => {
23205
+ if (typeof sql !== "string") {
23206
+ throw new CliError(`queries.${id} must be a SQL string.`);
23207
+ }
23208
+ return { id, sql };
23209
+ });
23210
+ }
23211
+ throw new CliError("queries must be a JSON object or an array of {id, sql}.");
23212
+ }
23213
+ async function readQueriesFile(path) {
23214
+ return parseQueries(await readJsonFile(path, "queries"));
23215
+ }
23216
+ function buildDataAppHttpRequest(env, method, path, body) {
23217
+ return {
23218
+ plane: "management",
23219
+ method,
23220
+ endpoint: `/environments/${env}${path}`,
23221
+ body: JSON.stringify(body),
23222
+ contentType: "application/json"
23223
+ };
23224
+ }
23225
+ function validationHasErrors(response) {
23226
+ return Array.isArray(response.errors) && response.errors.length > 0;
23227
+ }
23228
+ function formatValidationSummary(response) {
23229
+ const errors = response.errors ?? [];
23230
+ const warnings = response.warnings ?? [];
23231
+ if (errors.length === 0 && warnings.length === 0) {
23232
+ return "Data app is valid.";
23233
+ }
23234
+ const lines = [];
23235
+ for (const error of errors) {
23236
+ lines.push(formatDiagnostic("error", error));
23237
+ }
23238
+ for (const warning of warnings) {
23239
+ lines.push(formatDiagnostic("warning", warning));
23240
+ }
23241
+ return lines.join(`
23242
+ `);
23243
+ }
23244
+ function validationExitCode(response) {
23245
+ return validationHasErrors(response) ? EXIT_VALIDATION : 0;
23246
+ }
23247
+ function formatDiagnostic(kind, diagnostic) {
23248
+ const location = diagnostic.line === undefined || diagnostic.line === null ? "" : diagnostic.column === undefined || diagnostic.column === null ? `:${diagnostic.line}` : `:${diagnostic.line}:${diagnostic.column}`;
23249
+ const source = diagnostic.source === undefined ? "" : ` [${diagnostic.source}]`;
23250
+ return `${kind}${source}${location}: ${diagnostic.message ?? "unknown"}`;
23251
+ }
23252
+
23253
+ // src/commands/app/publish.ts
23254
+ var appPublishCommand = defineCommand({
23255
+ metadata: {
23256
+ name: "publish",
23257
+ description: "Create a data app from files.",
23258
+ examples: [
23259
+ "altertable app publish --title 'Revenue explorer' --file index.tsx --queries queries.json"
23260
+ ]
23261
+ },
23262
+ args: {
23263
+ title: { type: "string", description: "Title of the data app.", required: true },
23264
+ file: {
23265
+ type: "string",
23266
+ description: "Path to the single-file React source (index.tsx).",
23267
+ required: true,
23268
+ completion: "file"
23269
+ },
23270
+ queries: {
23271
+ type: "string",
23272
+ description: "Path to queries JSON (object of id \u2192 SQL, or [{id, sql}]).",
23273
+ required: true,
23274
+ completion: "file"
23275
+ },
23276
+ description: { type: "string", description: "Optional description of the data app." }
23277
+ },
23278
+ async run({ args, execution, sink }) {
23279
+ const env = requireManagementPlane(execution.profile, {
23280
+ requirement: "Publishing a data app requires the management API"
23281
+ });
23282
+ const title = stringArg(args, "title");
23283
+ const response = parseApiJson(await sendHttp(buildDataAppHttpRequest(env, "POST", "/data_apps", {
23284
+ title,
23285
+ index_tsx: await readRequiredFile(stringArg(args, "file"), "source"),
23286
+ queries: await readQueriesFile(stringArg(args, "queries")),
23287
+ description: optionalStringArg(args, "description")
23288
+ }), execution));
23289
+ const dataApp = response.data_app ?? {};
23290
+ await writeCommandOutput({
23291
+ kind: "normalized",
23292
+ data: { slug: dataApp.slug, url: dataApp.url },
23293
+ humanText: `Published ${dataApp.title ?? title} (${dataApp.slug ?? ""}).
23294
+ ${dataApp.url ?? ""}`
23295
+ }, sink);
23296
+ }
23297
+ });
23298
+
23299
+ // src/commands/app/update.ts
23300
+ var appUpdateCommand = defineCommand({
23301
+ metadata: {
23302
+ name: "update",
23303
+ description: "Update a data app from files. Omitted fields are left unchanged.",
23304
+ examples: [
23305
+ "altertable app update APP-1 --file index.tsx",
23306
+ "altertable app update APP-1 --title 'Revenue explorer' --file index.tsx --queries queries.json"
23307
+ ]
23308
+ },
23309
+ args: {
23310
+ slug: {
23311
+ type: "positional",
23312
+ description: "Data app slug to update (e.g. APP-1).",
23313
+ required: true
23314
+ },
23315
+ title: { type: "string", description: "New title of the data app." },
23316
+ file: {
23317
+ type: "string",
23318
+ description: "Path to replacement single-file React source (index.tsx).",
23319
+ completion: "file"
23320
+ },
23321
+ queries: {
23322
+ type: "string",
23323
+ description: "Path to queries JSON. Replaces the full set when provided.",
23324
+ completion: "file"
23325
+ },
23326
+ description: { type: "string", description: "New description of the data app." }
23327
+ },
23328
+ async run({ args, execution, sink }) {
23329
+ const env = requireManagementPlane(execution.profile, {
23330
+ requirement: "Updating a data app requires the management API"
23331
+ });
23332
+ const slug = stringArg(args, "slug");
23333
+ const body = await updatePayload(args);
23334
+ if (Object.keys(body).length === 0) {
23335
+ throw new CliError("Provide at least one of --title, --description, --file, or --queries.");
23336
+ }
23337
+ const response = parseApiJson(await sendHttp(buildDataAppHttpRequest(env, "PATCH", `/data_apps/${slug}`, body), execution));
23338
+ const dataApp = response.data_app ?? {};
23339
+ await writeCommandOutput({
23340
+ kind: "normalized",
23341
+ data: { slug: dataApp.slug ?? slug, url: dataApp.url },
23342
+ humanText: `Updated ${dataApp.title ?? dataApp.slug ?? slug}.
23343
+ ${dataApp.url ?? ""}`
23344
+ }, sink);
23345
+ }
23346
+ });
23347
+ async function updatePayload(args) {
23348
+ const body = {};
23349
+ const title = optionalStringArg(args, "title");
23350
+ const description = optionalStringArg(args, "description");
23351
+ const file = optionalStringArg(args, "file");
23352
+ const queries = optionalStringArg(args, "queries");
23353
+ if (title !== undefined)
23354
+ body.title = title;
23355
+ if (description !== undefined)
23356
+ body.description = description;
23357
+ if (file !== undefined)
23358
+ body.index_tsx = await readRequiredFile(file, "source");
23359
+ if (queries !== undefined)
23360
+ body.queries = await readQueriesFile(queries);
23361
+ return body;
23362
+ }
23363
+
23175
23364
  // src/commands/app/upgrade.ts
23176
- import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
23365
+ import { readFile as readFile6, writeFile as writeFile3 } from "fs/promises";
23177
23366
  import { join as join11 } from "path";
23178
23367
  var appUpgradeCommand = defineCommand({
23179
23368
  metadata: {
23180
23369
  name: "upgrade",
23181
- description: "Update the data app package to the CLI's tested version.",
23370
+ description: "Update a local data app's package to the CLI's tested version.",
23182
23371
  examples: ["altertable app upgrade", "altertable app upgrade --dir ./my-app"]
23183
23372
  },
23184
23373
  args: { dir: { type: "string", description: "App directory (default: current directory)." } },
23185
23374
  async run({ args, sink }) {
23186
23375
  const directory = appDirectory(args.dir);
23187
23376
  const upgraded = await upgradeApp(directory);
23188
- const { packages } = readAppLock(await readFile5(join11(directory, "bun.lock"), "utf8"), directory);
23377
+ const { packages } = readAppLock(await readFile6(join11(directory, "bun.lock"), "utf8"), directory);
23189
23378
  const version = lockedVersion(packages, dataAppPackage);
23190
23379
  if (sink.json) {
23191
23380
  sink.writeJson({
@@ -23193,12 +23382,12 @@ var appUpgradeCommand = defineCommand({
23193
23382
  upgraded,
23194
23383
  runtimeVersion: version,
23195
23384
  nextSteps: upgraded ? [
23196
- "Run `altertable app check` in the app directory.",
23385
+ "Run `altertable app lint` in the app directory.",
23197
23386
  "Restart any running `altertable app dev` server."
23198
23387
  ] : []
23199
23388
  });
23200
23389
  } else {
23201
- sink.writeHuman(upgraded ? `Updated data app package to ${version}. Run \`altertable app check\`, then restart any running \`altertable app dev\` server.` : `Data app package ${version} is already current.`);
23390
+ sink.writeHuman(upgraded ? `Updated data app package to ${version}. Run \`altertable app lint\`, then restart any running \`altertable app dev\` server.` : `Data app package ${version} is already current.`);
23202
23391
  }
23203
23392
  }
23204
23393
  });
@@ -23211,7 +23400,7 @@ async function upgradeApp(directory, options = {}) {
23211
23400
  }
23212
23401
  let lock;
23213
23402
  try {
23214
- lock = await readFile5(join11(directory, "bun.lock"), "utf8");
23403
+ lock = await readFile6(join11(directory, "bun.lock"), "utf8");
23215
23404
  } catch {
23216
23405
  throw new ConfigurationError(`Cannot read a valid bun.lock in ${directory}.`);
23217
23406
  }
@@ -23245,7 +23434,7 @@ async function upgradeApp(directory, options = {}) {
23245
23434
  try {
23246
23435
  await writeFile3(join11(directory, "package.json"), nextPackage);
23247
23436
  await (options.resolveLock ?? resolveLockfile)(directory);
23248
- const resolved = readAppLock(await readFile5(join11(directory, "bun.lock"), "utf8"), directory, version);
23437
+ const resolved = readAppLock(await readFile6(join11(directory, "bun.lock"), "utf8"), directory, version);
23249
23438
  if (lockedVersion(resolved.packages, dataAppPackage) !== version)
23250
23439
  throw new ConfigurationError("Dependency resolution did not lock the tested data app version.");
23251
23440
  for (const [name, range] of Object.entries(recommendedDataAppPeers())) {
@@ -23286,26 +23475,72 @@ async function resolveLockfile(directory) {
23286
23475
  ${stderr || stdout}`);
23287
23476
  }
23288
23477
 
23478
+ // src/commands/app/validate.ts
23479
+ var appValidateCommand = defineCommand({
23480
+ metadata: {
23481
+ name: "validate",
23482
+ description: "Type-check and bundle a data app from files without saving.",
23483
+ examples: ["altertable app validate --file index.tsx --queries queries.json"]
23484
+ },
23485
+ args: {
23486
+ file: {
23487
+ type: "string",
23488
+ description: "Path to the single-file React source (index.tsx).",
23489
+ required: true,
23490
+ completion: "file"
23491
+ },
23492
+ queries: {
23493
+ type: "string",
23494
+ description: "Path to queries JSON (object of id \u2192 SQL, or [{id, sql}]).",
23495
+ required: true,
23496
+ completion: "file"
23497
+ }
23498
+ },
23499
+ async run({ args, execution, sink }) {
23500
+ const env = requireManagementPlane(execution.profile, {
23501
+ requirement: "Validating a data app requires the management API"
23502
+ });
23503
+ const indexTsx = await readRequiredFile(stringArg(args, "file"), "source");
23504
+ const queries = await readQueriesFile(stringArg(args, "queries"));
23505
+ const response = parseApiJson(await sendHttp(buildDataAppHttpRequest(env, "POST", "/data_apps/validate", {
23506
+ index_tsx: indexTsx,
23507
+ queries
23508
+ }), execution));
23509
+ await writeCommandOutput({
23510
+ kind: "normalized",
23511
+ data: response,
23512
+ humanText: formatValidationSummary(response)
23513
+ }, sink);
23514
+ return { exitCode: validationExitCode(response) };
23515
+ }
23516
+ });
23517
+
23289
23518
  // src/commands/app/index.ts
23290
23519
  var appCommand = defineCommand({
23291
23520
  metadata: {
23292
23521
  name: "app",
23293
23522
  commandGroup: "platform",
23294
- description: "Create, develop, check, build, and upgrade data apps.",
23523
+ description: "Create, develop, lint, build, and upgrade local data apps; validate, publish, and update data apps.",
23295
23524
  examples: [
23296
23525
  "altertable app create my-app",
23297
23526
  "altertable app dev",
23298
- "altertable app check",
23527
+ "altertable app lint",
23299
23528
  "altertable app build",
23300
- "altertable app upgrade"
23529
+ "altertable app upgrade",
23530
+ "altertable app validate --file index.tsx --queries queries.json",
23531
+ "altertable app publish --title 'Revenue explorer' --file index.tsx --queries queries.json",
23532
+ "altertable app update APP-1 --file index.tsx"
23301
23533
  ]
23302
23534
  },
23303
23535
  subcommands: {
23304
23536
  create: appCreateCommand,
23305
23537
  dev: appDevCommand,
23306
23538
  build: appBuildCommand,
23307
- check: appCheckCommand,
23308
- upgrade: appUpgradeCommand
23539
+ lint: appLintCommand,
23540
+ upgrade: appUpgradeCommand,
23541
+ validate: appValidateCommand,
23542
+ publish: appPublishCommand,
23543
+ update: appUpdateCommand
23309
23544
  }
23310
23545
  });
23311
23546
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altertable/cli",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "description": "Altertable CLI — query and manage your data platform",
5
5
  "homepage": "https://github.com/altertable-ai/altertable-cli#readme",
6
6
  "bugs": {