@altertable/cli 1.10.0 → 1.10.1
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.
- package/dist/cli.js +14 -73
- 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.10.
|
|
7038
|
+
var VERSION = "1.10.1";
|
|
7039
7039
|
var USER_AGENT = `altertable-cli/${VERSION}`;
|
|
7040
7040
|
|
|
7041
7041
|
// src/lib/transport-defaults.ts
|
|
@@ -23179,40 +23179,6 @@ async function readRequiredFile(path, label) {
|
|
|
23179
23179
|
throw new CliError(`Could not read ${label}: ${path}`, { cause: error });
|
|
23180
23180
|
}
|
|
23181
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
23182
|
function buildDataAppHttpRequest(env, method, path, body) {
|
|
23217
23183
|
return {
|
|
23218
23184
|
plane: "management",
|
|
@@ -23254,22 +23220,14 @@ function formatDiagnostic(kind, diagnostic) {
|
|
|
23254
23220
|
var appPublishCommand = defineCommand({
|
|
23255
23221
|
metadata: {
|
|
23256
23222
|
name: "publish",
|
|
23257
|
-
description: "Create a data app from
|
|
23258
|
-
examples: [
|
|
23259
|
-
"altertable app publish --title 'Revenue explorer' --file index.tsx --queries queries.json"
|
|
23260
|
-
]
|
|
23223
|
+
description: "Create a data app from source.",
|
|
23224
|
+
examples: ["altertable app publish --title 'Revenue explorer' --file index.tsx"]
|
|
23261
23225
|
},
|
|
23262
23226
|
args: {
|
|
23263
23227
|
title: { type: "string", description: "Title of the data app.", required: true },
|
|
23264
23228
|
file: {
|
|
23265
23229
|
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}]).",
|
|
23230
|
+
description: "Path to the single-file React source (index.tsx). Queries are declared in the file via defineDataApp.",
|
|
23273
23231
|
required: true,
|
|
23274
23232
|
completion: "file"
|
|
23275
23233
|
},
|
|
@@ -23283,7 +23241,6 @@ var appPublishCommand = defineCommand({
|
|
|
23283
23241
|
const response = parseApiJson(await sendHttp(buildDataAppHttpRequest(env, "POST", "/data_apps", {
|
|
23284
23242
|
title,
|
|
23285
23243
|
index_tsx: await readRequiredFile(stringArg(args, "file"), "source"),
|
|
23286
|
-
queries: await readQueriesFile(stringArg(args, "queries")),
|
|
23287
23244
|
description: optionalStringArg(args, "description")
|
|
23288
23245
|
}), execution));
|
|
23289
23246
|
const dataApp = response.data_app ?? {};
|
|
@@ -23300,10 +23257,10 @@ ${dataApp.url ?? ""}`
|
|
|
23300
23257
|
var appUpdateCommand = defineCommand({
|
|
23301
23258
|
metadata: {
|
|
23302
23259
|
name: "update",
|
|
23303
|
-
description: "Update a data app from
|
|
23260
|
+
description: "Update a data app from source. Omitted fields are left unchanged.",
|
|
23304
23261
|
examples: [
|
|
23305
23262
|
"altertable app update APP-1 --file index.tsx",
|
|
23306
|
-
"altertable app update APP-1 --title 'Revenue explorer' --file index.tsx
|
|
23263
|
+
"altertable app update APP-1 --title 'Revenue explorer' --file index.tsx"
|
|
23307
23264
|
]
|
|
23308
23265
|
},
|
|
23309
23266
|
args: {
|
|
@@ -23315,12 +23272,7 @@ var appUpdateCommand = defineCommand({
|
|
|
23315
23272
|
title: { type: "string", description: "New title of the data app." },
|
|
23316
23273
|
file: {
|
|
23317
23274
|
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.",
|
|
23275
|
+
description: "Path to replacement single-file React source (index.tsx). Replaces the queries with those the file declares.",
|
|
23324
23276
|
completion: "file"
|
|
23325
23277
|
},
|
|
23326
23278
|
description: { type: "string", description: "New description of the data app." }
|
|
@@ -23332,7 +23284,7 @@ var appUpdateCommand = defineCommand({
|
|
|
23332
23284
|
const slug = stringArg(args, "slug");
|
|
23333
23285
|
const body = await updatePayload(args);
|
|
23334
23286
|
if (Object.keys(body).length === 0) {
|
|
23335
|
-
throw new CliError("Provide at least one of --title, --description,
|
|
23287
|
+
throw new CliError("Provide at least one of --title, --description, or --file.");
|
|
23336
23288
|
}
|
|
23337
23289
|
const response = parseApiJson(await sendHttp(buildDataAppHttpRequest(env, "PATCH", `/data_apps/${slug}`, body), execution));
|
|
23338
23290
|
const dataApp = response.data_app ?? {};
|
|
@@ -23349,15 +23301,12 @@ async function updatePayload(args) {
|
|
|
23349
23301
|
const title = optionalStringArg(args, "title");
|
|
23350
23302
|
const description = optionalStringArg(args, "description");
|
|
23351
23303
|
const file = optionalStringArg(args, "file");
|
|
23352
|
-
const queries = optionalStringArg(args, "queries");
|
|
23353
23304
|
if (title !== undefined)
|
|
23354
23305
|
body.title = title;
|
|
23355
23306
|
if (description !== undefined)
|
|
23356
23307
|
body.description = description;
|
|
23357
23308
|
if (file !== undefined)
|
|
23358
23309
|
body.index_tsx = await readRequiredFile(file, "source");
|
|
23359
|
-
if (queries !== undefined)
|
|
23360
|
-
body.queries = await readQueriesFile(queries);
|
|
23361
23310
|
return body;
|
|
23362
23311
|
}
|
|
23363
23312
|
|
|
@@ -23479,19 +23428,13 @@ ${stderr || stdout}`);
|
|
|
23479
23428
|
var appValidateCommand = defineCommand({
|
|
23480
23429
|
metadata: {
|
|
23481
23430
|
name: "validate",
|
|
23482
|
-
description: "Type-check and bundle a data app from
|
|
23483
|
-
examples: ["altertable app validate --file index.tsx
|
|
23431
|
+
description: "Type-check and bundle a data app from source without saving.",
|
|
23432
|
+
examples: ["altertable app validate --file index.tsx"]
|
|
23484
23433
|
},
|
|
23485
23434
|
args: {
|
|
23486
23435
|
file: {
|
|
23487
23436
|
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}]).",
|
|
23437
|
+
description: "Path to the single-file React source (index.tsx). Queries are declared in the file via defineDataApp.",
|
|
23495
23438
|
required: true,
|
|
23496
23439
|
completion: "file"
|
|
23497
23440
|
}
|
|
@@ -23501,10 +23444,8 @@ var appValidateCommand = defineCommand({
|
|
|
23501
23444
|
requirement: "Validating a data app requires the management API"
|
|
23502
23445
|
});
|
|
23503
23446
|
const indexTsx = await readRequiredFile(stringArg(args, "file"), "source");
|
|
23504
|
-
const queries = await readQueriesFile(stringArg(args, "queries"));
|
|
23505
23447
|
const response = parseApiJson(await sendHttp(buildDataAppHttpRequest(env, "POST", "/data_apps/validate", {
|
|
23506
|
-
index_tsx: indexTsx
|
|
23507
|
-
queries
|
|
23448
|
+
index_tsx: indexTsx
|
|
23508
23449
|
}), execution));
|
|
23509
23450
|
await writeCommandOutput({
|
|
23510
23451
|
kind: "normalized",
|
|
@@ -23527,8 +23468,8 @@ var appCommand = defineCommand({
|
|
|
23527
23468
|
"altertable app lint",
|
|
23528
23469
|
"altertable app build",
|
|
23529
23470
|
"altertable app upgrade",
|
|
23530
|
-
"altertable app validate --file index.tsx
|
|
23531
|
-
"altertable app publish --title 'Revenue explorer' --file index.tsx
|
|
23471
|
+
"altertable app validate --file index.tsx",
|
|
23472
|
+
"altertable app publish --title 'Revenue explorer' --file index.tsx",
|
|
23532
23473
|
"altertable app update APP-1 --file index.tsx"
|
|
23533
23474
|
]
|
|
23534
23475
|
},
|