@lightdash/cli 2.5.1 → 2.6.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.
|
@@ -66,12 +66,18 @@ type MetadataEntry = {
|
|
|
66
66
|
declare const sanitizeChartForDownload: (chart: ChartAsCode, stripPivotSeries: boolean) => ChartAsCode;
|
|
67
67
|
type DownloadContentType = 'charts' | 'dashboards' | 'sqlCharts';
|
|
68
68
|
declare const extractAppSlugsFromDashboards: (dashboards: DashboardAsCode[]) => string[];
|
|
69
|
+
/**
|
|
70
|
+
* Custom chart type refs bound by DATA_APP_VIZ charts — the portable slug,
|
|
71
|
+
* or the legacy uuid for files written before slug bindings.
|
|
72
|
+
*/
|
|
73
|
+
declare const extractChartTypeRefsFromCharts: (charts: ChartAsCode[]) => string[];
|
|
69
74
|
declare const extractChartTableNames: (charts: ChartAsCode[]) => string[];
|
|
70
75
|
export type DownloadContentResult = {
|
|
71
76
|
total: number;
|
|
72
77
|
chartSlugs: string[];
|
|
73
78
|
chartTableNames: string[];
|
|
74
79
|
appSlugs: string[];
|
|
80
|
+
chartTypeRefs: string[];
|
|
75
81
|
metadataEntries: MetadataEntry[];
|
|
76
82
|
spaces: SpaceAsCode[];
|
|
77
83
|
};
|
|
@@ -127,6 +133,7 @@ export declare const testHelpers: {
|
|
|
127
133
|
downloadSpaces: typeof downloadSpaces;
|
|
128
134
|
extractAppSlugsFromDashboards: typeof extractAppSlugsFromDashboards;
|
|
129
135
|
extractChartTableNames: typeof extractChartTableNames;
|
|
136
|
+
extractChartTypeRefsFromCharts: typeof extractChartTypeRefsFromCharts;
|
|
130
137
|
getFlatSpaceFileNames: typeof getFlatSpaceFileNames;
|
|
131
138
|
getDashboardAppSlugs: typeof getDashboardAppSlugs;
|
|
132
139
|
getDashboardChartSlugs: typeof getDashboardChartSlugs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/handlers/download.ts"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,cAAc,EAAE,MAAM,EAAE,CAAC;CAC5B,KAAG,MAAM,EAWT,CAAC;AAEF,QAAA,MAAM,sBAAsB,mBACR,MAAM,EAAE,eACX,MAAM,oBACF,CAAC,eAAe,GAAG;IAAE,aAAa,EAAE,OAAO,CAAA;CAAE,CAAC,EAAE,KAClE,OAAO,CAAC,MAAM,EAAE,CAId,CAAC;AAEN,QAAA,MAAM,oBAAoB,mBACN,MAAM,EAAE,eACX,MAAM,oBACF,CAAC,eAAe,GAAG;IAAE,aAAa,EAAE,OAAO,CAAA;CAAE,CAAC,EAAE,KAClE,OAAO,CAAC,MAAM,EAAE,CAId,CAAC;AAIN,QAAA,MAAM,0BAA0B,eAChB,OAAO,kBACH,MAAM,EAAE,KACzB,OAAoD,CAAC;AAExD,eAAO,MAAM,aAAa,YACb,sBAAsB,KAChC,OAAO,CAAC,IAAI,CA+lCd,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCvB,CAAC"}
|
|
@@ -349,6 +349,19 @@ const extractAppSlugsFromDashboards = (dashboards) => [
|
|
|
349
349
|
: acc;
|
|
350
350
|
}, []))),
|
|
351
351
|
];
|
|
352
|
+
/**
|
|
353
|
+
* Custom chart type refs bound by DATA_APP_VIZ charts — the portable slug,
|
|
354
|
+
* or the legacy uuid for files written before slug bindings.
|
|
355
|
+
*/
|
|
356
|
+
const extractChartTypeRefsFromCharts = (charts) => [
|
|
357
|
+
...new Set(charts.reduce((acc, chart) => {
|
|
358
|
+
if (chart.chartConfig.type !== common_1.ChartType.DATA_APP_VIZ)
|
|
359
|
+
return acc;
|
|
360
|
+
const ref = chart.chartConfig.config?.dataAppVizSlug ??
|
|
361
|
+
chart.chartConfig.config?.dataAppVizUuid;
|
|
362
|
+
return ref ? [...acc, ref] : acc;
|
|
363
|
+
}, [])),
|
|
364
|
+
];
|
|
352
365
|
// A virtual view's slug is the explore name charts store in tableName, so
|
|
353
366
|
// these names double as virtual view slug candidates.
|
|
354
367
|
const extractChartTableNames = (charts) => [
|
|
@@ -365,6 +378,7 @@ const downloadContent = async (ids, type, projectId, projectName, customPath, la
|
|
|
365
378
|
let chartSlugs = [];
|
|
366
379
|
let chartTableNames = [];
|
|
367
380
|
let appSlugs = [];
|
|
381
|
+
let chartTypeRefs = [];
|
|
368
382
|
let allMetadataEntries = [];
|
|
369
383
|
let allSpaces = [];
|
|
370
384
|
do {
|
|
@@ -452,6 +466,10 @@ const downloadContent = async (ids, type, projectId, projectName, customPath, la
|
|
|
452
466
|
...chartTableNames,
|
|
453
467
|
...extractChartTableNames(results.charts),
|
|
454
468
|
];
|
|
469
|
+
chartTypeRefs = [
|
|
470
|
+
...chartTypeRefs,
|
|
471
|
+
...extractChartTypeRefsFromCharts(results.charts),
|
|
472
|
+
];
|
|
455
473
|
}
|
|
456
474
|
// Accumulate space metadata from each page
|
|
457
475
|
if ('spaces' in results && results.spaces) {
|
|
@@ -472,6 +490,7 @@ const downloadContent = async (ids, type, projectId, projectName, customPath, la
|
|
|
472
490
|
chartSlugs: [...new Set(chartSlugs)],
|
|
473
491
|
chartTableNames: [...new Set(chartTableNames)],
|
|
474
492
|
appSlugs: [...new Set(appSlugs)],
|
|
493
|
+
chartTypeRefs: [...new Set(chartTypeRefs)],
|
|
475
494
|
metadataEntries: allMetadataEntries,
|
|
476
495
|
spaces: allSpaces,
|
|
477
496
|
};
|
|
@@ -1113,6 +1132,11 @@ const downloadHandler = async (options) => {
|
|
|
1113
1132
|
// the Dashboards step and consumed by the Linked data apps step.
|
|
1114
1133
|
let dashboardAppSlugs = [];
|
|
1115
1134
|
const explicitAppRefs = new Set((Array.isArray(options.apps) ? options.apps : []).map(appsDownload_1.getDataAppReference));
|
|
1135
|
+
// Chart-type refs bound by downloaded charts, populated by the
|
|
1136
|
+
// Charts and Linked charts steps and consumed by the Linked custom
|
|
1137
|
+
// chart types step.
|
|
1138
|
+
let downloadedChartVizRefs = [];
|
|
1139
|
+
const explicitChartTypeRefs = new Set((Array.isArray(options.chartTypes) ? options.chartTypes : []).map(appsDownload_1.getDataAppReference));
|
|
1116
1140
|
if (shouldDownloadSpaces) {
|
|
1117
1141
|
output.startItem('Spaces');
|
|
1118
1142
|
try {
|
|
@@ -1151,7 +1175,7 @@ const downloadHandler = async (options) => {
|
|
|
1151
1175
|
globalState_1.default.log(styles.warning(`No charts filters provided, skipping`));
|
|
1152
1176
|
}
|
|
1153
1177
|
else {
|
|
1154
|
-
const { total: regularChartTotal, metadataEntries: regularChartMeta, } = await output.runItem({
|
|
1178
|
+
const { total: regularChartTotal, metadataEntries: regularChartMeta, chartTypeRefs: mainChartTypeRefs, } = await output.runItem({
|
|
1155
1179
|
label: 'Charts',
|
|
1156
1180
|
action: () => (0, exports.downloadContent)(options.charts, 'charts', projectId, projectName, options.path, options.languageMap, options.nested, skipEmbeddedSpaces, options.stripPivotSeries, options.rootSpaces, output.updateActive),
|
|
1157
1181
|
detail: ({ total }) => `${total} downloaded`,
|
|
@@ -1160,6 +1184,10 @@ const downloadHandler = async (options) => {
|
|
|
1160
1184
|
...allMetadataEntries,
|
|
1161
1185
|
...regularChartMeta,
|
|
1162
1186
|
];
|
|
1187
|
+
downloadedChartVizRefs = [
|
|
1188
|
+
...downloadedChartVizRefs,
|
|
1189
|
+
...mainChartTypeRefs,
|
|
1190
|
+
];
|
|
1163
1191
|
const { total: sqlChartTotal, metadataEntries: sqlChartMeta } = await output.runItem({
|
|
1164
1192
|
label: 'SQL charts',
|
|
1165
1193
|
action: () => (0, exports.downloadContent)(options.charts, 'sqlCharts', projectId, projectName, options.path, options.languageMap, options.nested, skipEmbeddedSpaces, false, options.rootSpaces, output.updateActive),
|
|
@@ -1194,11 +1222,15 @@ const downloadHandler = async (options) => {
|
|
|
1194
1222
|
!options.skipCharts) {
|
|
1195
1223
|
output.startItem('Linked charts');
|
|
1196
1224
|
output.updateActive(`${chartSlugs.length} dashboard dependencies`);
|
|
1197
|
-
const { total: regularCharts, chartTableNames: linkedChartTableNames, metadataEntries: linkedChartMeta, } = await (0, exports.downloadContent)(chartSlugs, 'charts', projectId, projectName, options.path, options.languageMap, options.nested, skipEmbeddedSpaces, options.stripPivotSeries, options.rootSpaces, output.updateActive);
|
|
1225
|
+
const { total: regularCharts, chartTableNames: linkedChartTableNames, metadataEntries: linkedChartMeta, chartTypeRefs: linkedChartVizRefs, } = await (0, exports.downloadContent)(chartSlugs, 'charts', projectId, projectName, options.path, options.languageMap, options.nested, skipEmbeddedSpaces, options.stripPivotSeries, options.rootSpaces, output.updateActive);
|
|
1198
1226
|
allMetadataEntries = [
|
|
1199
1227
|
...allMetadataEntries,
|
|
1200
1228
|
...linkedChartMeta,
|
|
1201
1229
|
];
|
|
1230
|
+
downloadedChartVizRefs = [
|
|
1231
|
+
...downloadedChartVizRefs,
|
|
1232
|
+
...linkedChartVizRefs,
|
|
1233
|
+
];
|
|
1202
1234
|
const { total: sqlCharts, metadataEntries: linkedSqlMeta } = await (0, exports.downloadContent)(chartSlugs, 'sqlCharts', projectId, projectName, options.path, options.languageMap, options.nested, skipEmbeddedSpaces, false, options.rootSpaces, output.updateActive);
|
|
1203
1235
|
allMetadataEntries = [
|
|
1204
1236
|
...allMetadataEntries,
|
|
@@ -1404,6 +1436,10 @@ const downloadHandler = async (options) => {
|
|
|
1404
1436
|
: undefined,
|
|
1405
1437
|
includeApps: includeChartTypes,
|
|
1406
1438
|
});
|
|
1439
|
+
// Refs (slug AND uuid) covered by a possibly-truncated
|
|
1440
|
+
// --include-chart-types listing, so the Linked custom chart types
|
|
1441
|
+
// step knows what was already downloaded.
|
|
1442
|
+
let cappedChartTypeRefs = new Set();
|
|
1407
1443
|
if (chartTypesSelection.mode !== 'none') {
|
|
1408
1444
|
output.startItem('Custom chart types');
|
|
1409
1445
|
let chartTypeRefsToDownload;
|
|
@@ -1444,6 +1480,13 @@ const downloadHandler = async (options) => {
|
|
|
1444
1480
|
if (chartTypesTruncated > 0) {
|
|
1445
1481
|
globalState_1.default.log(styles.warning(`Found ${listedChartTypes.length} custom chart types, downloading the first ${chartTypesLimit}. Pass --chart-types-limit <n> to raise the cap.`));
|
|
1446
1482
|
}
|
|
1483
|
+
const cappedChartTypeUuidSet = new Set(cappedChartTypeUuids);
|
|
1484
|
+
cappedChartTypeRefs = new Set(listedChartTypes
|
|
1485
|
+
.filter((chartType) => cappedChartTypeUuidSet.has(chartType.appUuid))
|
|
1486
|
+
.flatMap((chartType) => [
|
|
1487
|
+
chartType.slug,
|
|
1488
|
+
chartType.appUuid,
|
|
1489
|
+
]));
|
|
1447
1490
|
chartTypeRefsToDownload = [
|
|
1448
1491
|
...new Set([
|
|
1449
1492
|
...cappedChartTypeUuids,
|
|
@@ -1532,6 +1575,51 @@ const downloadHandler = async (options) => {
|
|
|
1532
1575
|
linkedSummary.failureLines.forEach((line) => globalState_1.default.log(styles.warning(line)));
|
|
1533
1576
|
}
|
|
1534
1577
|
}
|
|
1578
|
+
// Custom chart types the downloaded charts render with, not already
|
|
1579
|
+
// covered by an explicit --chart-types ref or a (non-truncated)
|
|
1580
|
+
// --include-chart-types listing — a chart file without its chart
|
|
1581
|
+
// type cannot be uploaded elsewhere.
|
|
1582
|
+
const linkedChartTypeRefs = (0, appsDownload_1.computeLinkedAppSlugs)({
|
|
1583
|
+
appSlugs: [...new Set(downloadedChartVizRefs)],
|
|
1584
|
+
explicitRefs: explicitChartTypeRefs,
|
|
1585
|
+
includeApps: includeChartTypes,
|
|
1586
|
+
cappedAppSlugs: cappedChartTypeRefs,
|
|
1587
|
+
});
|
|
1588
|
+
if (linkedChartTypeRefs.length > 0) {
|
|
1589
|
+
output.startItem('Linked custom chart types');
|
|
1590
|
+
const chartTypesDir = path.join((0, contentAsCodePaths_1.getDownloadFolder)(options.path), 'chart-types');
|
|
1591
|
+
const linkedChartTypesOutcome = await (0, appsDownload_1.downloadAppsToDir)({
|
|
1592
|
+
appRefs: linkedChartTypeRefs,
|
|
1593
|
+
projectId,
|
|
1594
|
+
appsDir: chartTypesDir,
|
|
1595
|
+
takenFolders: downloadedChartTypeFolders,
|
|
1596
|
+
cliVersion: env_1.CLI_VERSION,
|
|
1597
|
+
fetchApp: (fetchProjectId, appRef) => (0, apiClient_1.lightdashApi)({
|
|
1598
|
+
method: 'GET',
|
|
1599
|
+
url: `/api/v1/ee/projects/${fetchProjectId}/apps/${encodeURIComponent(appRef)}/download`,
|
|
1600
|
+
body: undefined,
|
|
1601
|
+
}),
|
|
1602
|
+
// Chart configs reference chart types, never data apps.
|
|
1603
|
+
skipBundle: (manifest) => manifest.template !== common_1.DATA_APP_VIZ_TEMPLATE
|
|
1604
|
+
? 'this is a data app — chart configs cannot reference it'
|
|
1605
|
+
: null,
|
|
1606
|
+
onProgress: (processed, total) => output.updateActive(`${processed} of ${total} processed`),
|
|
1607
|
+
});
|
|
1608
|
+
const linkedChartTypesSkipped = linkedChartTypesOutcome.skippedNotBuiltCount +
|
|
1609
|
+
linkedChartTypesOutcome.skippedWrongKindCount;
|
|
1610
|
+
const linkedChartTypesSummary = (0, appsDownload_1.appsDownloadSummary)(linkedChartTypesOutcome.successCount, linkedChartTypeRefs.length, linkedChartTypesOutcome.failures, chartTypesDir, linkedChartTypesSkipped, 'custom chart type');
|
|
1611
|
+
counts.chartTypesNum =
|
|
1612
|
+
(counts.chartTypesNum ?? 0) +
|
|
1613
|
+
linkedChartTypesOutcome.successCount;
|
|
1614
|
+
output.completeItem(`${linkedChartTypesOutcome.successCount} downloaded${linkedChartTypesSkipped > 0
|
|
1615
|
+
? `, ${linkedChartTypesSkipped} skipped`
|
|
1616
|
+
: ''}${linkedChartTypesOutcome.failures.length > 0
|
|
1617
|
+
? `, ${linkedChartTypesOutcome.failures.length} failed`
|
|
1618
|
+
: ''}`, linkedChartTypesSummary.ok ? undefined : 'warning');
|
|
1619
|
+
if (!linkedChartTypesSummary.ok) {
|
|
1620
|
+
linkedChartTypesSummary.failureLines.forEach((line) => globalState_1.default.log(styles.warning(line)));
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1535
1623
|
// Write metadata file with all downloadedAt timestamps
|
|
1536
1624
|
const metadataToWrite = {
|
|
1537
1625
|
version: 1,
|
|
@@ -2626,6 +2714,7 @@ exports.testHelpers = {
|
|
|
2626
2714
|
downloadSpaces: spacesAsCode_1.downloadSpaces,
|
|
2627
2715
|
extractAppSlugsFromDashboards,
|
|
2628
2716
|
extractChartTableNames,
|
|
2717
|
+
extractChartTypeRefsFromCharts,
|
|
2629
2718
|
getFlatSpaceFileNames: spacesAsCode_1.getFlatSpaceFileNames,
|
|
2630
2719
|
getDashboardAppSlugs,
|
|
2631
2720
|
getDashboardChartSlugs,
|
|
@@ -39,7 +39,7 @@ vitest_1.vi.mock('./dbt/apiClient', async (importOriginal) => ({
|
|
|
39
39
|
getContentAsCodeUploadPermissions: vitest_1.vi.fn(),
|
|
40
40
|
lightdashApi: vitest_1.vi.fn(),
|
|
41
41
|
}));
|
|
42
|
-
const { assertUniqueSpacePaths, downloadLinkedVirtualViews, downloadSpaces, extractChartTableNames, getDashboardAppSlugs, getDashboardChartSlugs, getFlatSpaceFileNames, hasContentFilters, isAiAgentsUnavailableError, isExternalConnectionsUnavailableError, isVirtualViewsUnavailableError, countChangeDelta, downloadAiAgents, isFilteredWithNoDashboards, readAiAgentFiles, readSpaceFiles, readSpaceNames, sanitizeChartForDownload, shouldFallBackToEmbeddedSpaces, shouldDownloadAiAgents, summarizeUploadChanges, upsertAiAgents, upsertExternalConnections, upsertSpaces, upsertVirtualViews, validateSpaceIdentity, writeSpaceFiles, } = download_1.testHelpers;
|
|
42
|
+
const { assertUniqueSpacePaths, downloadLinkedVirtualViews, downloadSpaces, extractChartTableNames, extractChartTypeRefsFromCharts, getDashboardAppSlugs, getDashboardChartSlugs, getFlatSpaceFileNames, hasContentFilters, isAiAgentsUnavailableError, isExternalConnectionsUnavailableError, isVirtualViewsUnavailableError, countChangeDelta, downloadAiAgents, isFilteredWithNoDashboards, readAiAgentFiles, readSpaceFiles, readSpaceNames, sanitizeChartForDownload, shouldFallBackToEmbeddedSpaces, shouldDownloadAiAgents, summarizeUploadChanges, upsertAiAgents, upsertExternalConnections, upsertSpaces, upsertVirtualViews, validateSpaceIdentity, writeSpaceFiles, } = download_1.testHelpers;
|
|
43
43
|
const makeDownloadHandlerOptions = (overrides = {}) => ({
|
|
44
44
|
verbose: false,
|
|
45
45
|
charts: [],
|
|
@@ -344,6 +344,28 @@ describe('extractChartTableNames', () => {
|
|
|
344
344
|
expect(extractChartTableNames([chart(undefined), chart(''), chart('one')])).toEqual(['one']);
|
|
345
345
|
});
|
|
346
346
|
});
|
|
347
|
+
describe('extractChartTypeRefsFromCharts', () => {
|
|
348
|
+
const vizChart = (config) => ({
|
|
349
|
+
slug: 'a-chart',
|
|
350
|
+
chartConfig: { type: 'data_app_viz', config },
|
|
351
|
+
});
|
|
352
|
+
it('collects slugs from viz charts, deduped, ignoring other chart types', () => {
|
|
353
|
+
expect(extractChartTypeRefsFromCharts([
|
|
354
|
+
vizChart({ dataAppVizSlug: 'heatmap', fieldMapping: {} }),
|
|
355
|
+
vizChart({ dataAppVizSlug: 'heatmap', fieldMapping: {} }),
|
|
356
|
+
{
|
|
357
|
+
slug: 'bar-chart',
|
|
358
|
+
chartConfig: { type: 'cartesian', config: {} },
|
|
359
|
+
},
|
|
360
|
+
])).toEqual(['heatmap']);
|
|
361
|
+
});
|
|
362
|
+
it('falls back to the legacy uuid and skips configless charts', () => {
|
|
363
|
+
expect(extractChartTypeRefsFromCharts([
|
|
364
|
+
vizChart({ dataAppVizUuid: 'viz-uuid', fieldMapping: {} }),
|
|
365
|
+
vizChart(undefined),
|
|
366
|
+
])).toEqual(['viz-uuid']);
|
|
367
|
+
});
|
|
368
|
+
});
|
|
347
369
|
describe('selectVirtualViewCandidates', () => {
|
|
348
370
|
const chart = (slug, tableName) => ({
|
|
349
371
|
slug,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash/cli",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.0",
|
|
4
4
|
"description": "Lightdash CLI tool",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"unique-names-generator": "4.7.1",
|
|
46
46
|
"uuid": "11.1.1",
|
|
47
47
|
"yaml": "2.8.3",
|
|
48
|
-
"@lightdash/common": "2.
|
|
49
|
-
"@lightdash/warehouses": "2.
|
|
48
|
+
"@lightdash/common": "2.6.0",
|
|
49
|
+
"@lightdash/warehouses": "2.6.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/inquirer": "8.2.4",
|