@altertable/cli 1.9.1 → 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 +273 -49
  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.1";
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
 
@@ -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.65.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.65.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", "lucide-react": "1.48.0", "react-aria-components": "1.21.1" }, "peerDependencies": { "react": ">=19.2.0", "react-dom": ">=19.2.0" } }, "sha512-BvaUwOhjUx0PzQbc8DUf5NUPpXL4VBcZ5LGegFB8Y41rQnmJIQk81AmP+Dg5iz1j/NwlsuiB8ABBUE6nY6e1aQ=="],
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
 
@@ -22422,6 +22427,8 @@ Commit app source, \`package.json\`, and \`bun.lock\`. A fresh clone installs \`
22422
22427
 
22423
22428
  "fuzzysort": ["fuzzysort@4.0.2", "", {}, "sha512-3c7yD6rK1EXIsqpcu1ZVzXJugODWNMzvUij6yTiziaAHrpNS8kzFOI9mJLE8pmG4K9JOaVgzQRgklfOEk8f4Tg=="],
22424
22429
 
22430
+ "html-to-image": ["html-to-image@1.11.13", "", {}, "sha512-cuOPoI7WApyhBElTTb9oqsawRvZ0rHhaHwghRLlTuffoD1B2aDemlCruLeZrUIIdvG7gs9xeELEPm6PhuASqrg=="],
22431
+
22425
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=="],
22426
22433
 
22427
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=="],
@@ -22457,26 +22464,6 @@ Commit app source, \`package.json\`, and \`bun.lock\`. A fresh clone installs \`
22457
22464
  }
22458
22465
  `, "bunfig.toml": `[install]
22459
22466
  exact = true
22460
- `, "docs/data.md": `# Data authoring
22461
-
22462
- Inspect catalogs, time coverage, and existing definitions before selecting the exploration. Explore several useful angles for broad requests. Use bounded queries and observed results.
22463
-
22464
- | File | Owns |
22465
- | --- | --- |
22466
- | \`app.json\` | Title, verified scope, and appearance. |
22467
- | \`src/operations.ts\` | Bounded server-side queries, validation, and fixed live-check inputs. Credentials stay on the server. |
22468
- | \`src/variables.ts\` | Optional reader-controlled defaults, URL state, and operation inputs. |
22469
- | \`src/data-context.ts\` or \`.tsx\` | Exploration description, glossary, named queries, and optional source identifiers. |
22470
- | \`src/App.tsx\` | Questions, filters, result states, cards, and optional story. |
22471
-
22472
- [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.
22473
-
22474
- \`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.
22475
- `, "docs/views.md": `# View authoring
22476
-
22477
- Lead with a supported finding and provide complementary ways to explore the question. Check actual content at phone and desktop widths in both themes.
22478
-
22479
- [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.
22480
22467
  `, "package.json": `{
22481
22468
  "name": "data-app-starter",
22482
22469
  "private": true,
@@ -22494,7 +22481,7 @@ Lead with a supported finding and provide complementary ways to explore the ques
22494
22481
  "build": "bun build src/index.html --outdir=dist --production"
22495
22482
  },
22496
22483
  "dependencies": {
22497
- "@altertable/data-app": "0.65.0",
22484
+ "@altertable/data-app": "0.66.0",
22498
22485
  "react": "19.3.0",
22499
22486
  "react-dom": "19.3.0"
22500
22487
  },
@@ -22508,7 +22495,7 @@ Lead with a supported finding and provide complementary ways to explore the ques
22508
22495
  "typescript": "7.0.2"
22509
22496
  }
22510
22497
  }
22511
- `, "src/App.tsx": `import { GettingStarted } from "@altertable/data-app/react";
22498
+ `, "src/App.tsx": `import { GettingStarted } from "@altertable/data-app/react/ui";
22512
22499
  import { dataContext } from "#app/data-context.ts";
22513
22500
  import app from "#app/config.ts";
22514
22501
 
@@ -22608,7 +22595,7 @@ serveLocalApp({ page, operations, title: app.title });
22608
22595
  var appCreateCommand = defineCommand({
22609
22596
  metadata: {
22610
22597
  name: "create",
22611
- description: "Create a data app project with a live connection check.",
22598
+ description: "Create a local data app project with a live connection check.",
22612
22599
  examples: [
22613
22600
  "altertable app create product-pulse",
22614
22601
  "altertable app create product-pulse --dir ./apps/product-pulse",
@@ -22669,11 +22656,11 @@ var appCreateCommand = defineCommand({
22669
22656
  await rm(directory, { recursive: true, force: true });
22670
22657
  throw new CliError(`Could not create data app in ${directory}.`, { cause: error });
22671
22658
  }
22672
- 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}`) : [
22673
22660
  "Set organization and environment in app.json.",
22674
22661
  "Select a matching profile, or configure one with `altertable login --org <org> --env <env>`.",
22675
22662
  "altertable app dev",
22676
- "altertable app check --lakehouse",
22663
+ "altertable app lint --lakehouse",
22677
22664
  "altertable app build"
22678
22665
  ];
22679
22666
  const result = {
@@ -22819,7 +22806,7 @@ function appPort(value) {
22819
22806
  return value;
22820
22807
  }
22821
22808
 
22822
- // src/commands/app/check.ts
22809
+ // src/commands/app/lint.ts
22823
22810
  import { readFile as readFile4, readdir } from "fs/promises";
22824
22811
  import { join as join10 } from "path";
22825
22812
 
@@ -23069,12 +23056,12 @@ try {
23069
23056
  }
23070
23057
  `;
23071
23058
 
23072
- // src/commands/app/check.ts
23073
- var appCheckCommand = defineCommand({
23059
+ // src/commands/app/lint.ts
23060
+ var appLintCommand = defineCommand({
23074
23061
  metadata: {
23075
- name: "check",
23076
- description: "Validate a data app's format, lint, types, contracts, build, and client credential boundary.",
23077
- 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"]
23078
23065
  },
23079
23066
  args: {
23080
23067
  dir: { type: "string", description: "App directory (default: current directory)." },
@@ -23183,20 +23170,211 @@ async function checkClientBundle(directory, secrets = []) {
23183
23170
  }
23184
23171
  }
23185
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
+
23186
23364
  // src/commands/app/upgrade.ts
23187
- import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
23365
+ import { readFile as readFile6, writeFile as writeFile3 } from "fs/promises";
23188
23366
  import { join as join11 } from "path";
23189
23367
  var appUpgradeCommand = defineCommand({
23190
23368
  metadata: {
23191
23369
  name: "upgrade",
23192
- 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.",
23193
23371
  examples: ["altertable app upgrade", "altertable app upgrade --dir ./my-app"]
23194
23372
  },
23195
23373
  args: { dir: { type: "string", description: "App directory (default: current directory)." } },
23196
23374
  async run({ args, sink }) {
23197
23375
  const directory = appDirectory(args.dir);
23198
23376
  const upgraded = await upgradeApp(directory);
23199
- const { packages } = readAppLock(await readFile5(join11(directory, "bun.lock"), "utf8"), directory);
23377
+ const { packages } = readAppLock(await readFile6(join11(directory, "bun.lock"), "utf8"), directory);
23200
23378
  const version = lockedVersion(packages, dataAppPackage);
23201
23379
  if (sink.json) {
23202
23380
  sink.writeJson({
@@ -23204,12 +23382,12 @@ var appUpgradeCommand = defineCommand({
23204
23382
  upgraded,
23205
23383
  runtimeVersion: version,
23206
23384
  nextSteps: upgraded ? [
23207
- "Run `altertable app check` in the app directory.",
23385
+ "Run `altertable app lint` in the app directory.",
23208
23386
  "Restart any running `altertable app dev` server."
23209
23387
  ] : []
23210
23388
  });
23211
23389
  } else {
23212
- 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.`);
23213
23391
  }
23214
23392
  }
23215
23393
  });
@@ -23222,7 +23400,7 @@ async function upgradeApp(directory, options = {}) {
23222
23400
  }
23223
23401
  let lock;
23224
23402
  try {
23225
- lock = await readFile5(join11(directory, "bun.lock"), "utf8");
23403
+ lock = await readFile6(join11(directory, "bun.lock"), "utf8");
23226
23404
  } catch {
23227
23405
  throw new ConfigurationError(`Cannot read a valid bun.lock in ${directory}.`);
23228
23406
  }
@@ -23256,7 +23434,7 @@ async function upgradeApp(directory, options = {}) {
23256
23434
  try {
23257
23435
  await writeFile3(join11(directory, "package.json"), nextPackage);
23258
23436
  await (options.resolveLock ?? resolveLockfile)(directory);
23259
- 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);
23260
23438
  if (lockedVersion(resolved.packages, dataAppPackage) !== version)
23261
23439
  throw new ConfigurationError("Dependency resolution did not lock the tested data app version.");
23262
23440
  for (const [name, range] of Object.entries(recommendedDataAppPeers())) {
@@ -23297,26 +23475,72 @@ async function resolveLockfile(directory) {
23297
23475
  ${stderr || stdout}`);
23298
23476
  }
23299
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
+
23300
23518
  // src/commands/app/index.ts
23301
23519
  var appCommand = defineCommand({
23302
23520
  metadata: {
23303
23521
  name: "app",
23304
23522
  commandGroup: "platform",
23305
- 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.",
23306
23524
  examples: [
23307
23525
  "altertable app create my-app",
23308
23526
  "altertable app dev",
23309
- "altertable app check",
23527
+ "altertable app lint",
23310
23528
  "altertable app build",
23311
- "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"
23312
23533
  ]
23313
23534
  },
23314
23535
  subcommands: {
23315
23536
  create: appCreateCommand,
23316
23537
  dev: appDevCommand,
23317
23538
  build: appBuildCommand,
23318
- check: appCheckCommand,
23319
- upgrade: appUpgradeCommand
23539
+ lint: appLintCommand,
23540
+ upgrade: appUpgradeCommand,
23541
+ validate: appValidateCommand,
23542
+ publish: appPublishCommand,
23543
+ update: appUpdateCommand
23320
23544
  }
23321
23545
  });
23322
23546
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altertable/cli",
3
- "version": "1.9.1",
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": {