@overscore/cli 0.10.1 → 0.10.2
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/index.js +7 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -72,7 +72,7 @@ function loadEnv() {
|
|
|
72
72
|
}
|
|
73
73
|
process.exit(1);
|
|
74
74
|
}
|
|
75
|
-
async function apiRequest(method, urlPath, body) {
|
|
75
|
+
async function apiRequest(method, urlPath, body, command) {
|
|
76
76
|
const { apiUrl, apiKey } = loadEnv();
|
|
77
77
|
const baseUrl = apiUrl.replace(/\/api$/, "");
|
|
78
78
|
const url = `${baseUrl}${urlPath}`;
|
|
@@ -82,6 +82,9 @@ async function apiRequest(method, urlPath, body) {
|
|
|
82
82
|
if (body !== undefined) {
|
|
83
83
|
headers["Content-Type"] = "application/json";
|
|
84
84
|
}
|
|
85
|
+
if (command) {
|
|
86
|
+
headers["X-Overscore-Command"] = command;
|
|
87
|
+
}
|
|
85
88
|
const res = await fetch(url, {
|
|
86
89
|
method,
|
|
87
90
|
headers,
|
|
@@ -332,7 +335,7 @@ async function deploy() {
|
|
|
332
335
|
}
|
|
333
336
|
async function queryList() {
|
|
334
337
|
const { dashboardSlug } = loadEnv();
|
|
335
|
-
const data = (await apiRequest("GET", `/api/dashboards/${dashboardSlug}/queries
|
|
338
|
+
const data = (await apiRequest("GET", `/api/dashboards/${dashboardSlug}/queries`, undefined, "query-list"));
|
|
336
339
|
console.log(`\n Dashboard: ${data.dashboard}\n`);
|
|
337
340
|
// Registered queries
|
|
338
341
|
if (data.queries.length === 0) {
|
|
@@ -450,7 +453,7 @@ async function queryAdd(name, sql) {
|
|
|
450
453
|
let body;
|
|
451
454
|
if (datasetName) {
|
|
452
455
|
// Look up the dataset UUID from project_datasets in the queries endpoint
|
|
453
|
-
const listData = (await apiRequest("GET", `/api/dashboards/${dashboardSlug}/queries
|
|
456
|
+
const listData = (await apiRequest("GET", `/api/dashboards/${dashboardSlug}/queries`, undefined, "query-add"));
|
|
454
457
|
const dataset = (listData.project_datasets ?? []).find((ds) => ds.name === datasetName);
|
|
455
458
|
if (!dataset) {
|
|
456
459
|
console.error(`\n Error: Dataset "${datasetName}" not found in this project.\n`);
|
|
@@ -466,7 +469,7 @@ async function queryAdd(name, sql) {
|
|
|
466
469
|
else {
|
|
467
470
|
body = { query_name: name, sql_text: resolvedSql };
|
|
468
471
|
}
|
|
469
|
-
const data = (await apiRequest("POST", `/api/dashboards/${dashboardSlug}/queries`, body));
|
|
472
|
+
const data = (await apiRequest("POST", `/api/dashboards/${dashboardSlug}/queries`, body, "query-add"));
|
|
470
473
|
console.log(`\n Query "${data.query_name}" created.\n`);
|
|
471
474
|
console.log(` Use it in your dashboard:`);
|
|
472
475
|
console.log(` const { data } = useQuery("${data.query_name}");\n`);
|