metabase-exporter 1.0.0 → 1.0.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/README.md +1 -1
- package/package.json +6 -3
- package/src/services/MetabaseService.js +11 -8
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ npm i
|
|
|
21
21
|
Run the tool with source credentials and one or more target credentials.
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
|
|
24
|
+
npx metabase-exporter --source_creds '{
|
|
25
25
|
"baseUrl": "https://source.metabase.example",
|
|
26
26
|
"userName": "admin@source",
|
|
27
27
|
"password": "******"
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "metabase-exporter",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"bin": {
|
|
5
5
|
"metabase-exporter": "./src/index.js"
|
|
6
6
|
},
|
|
7
7
|
"description": "This is the cli tool which clones reports from single source metabse account to multiple destination accounts.",
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"axios": "^1.12.2",
|
|
10
|
-
"commander": "^14.0.2"
|
|
10
|
+
"commander": "^14.0.2",
|
|
11
|
+
"metabase-exporter": "^1.0.0"
|
|
11
12
|
},
|
|
12
|
-
"keywords": [
|
|
13
|
+
"keywords": [
|
|
14
|
+
"cli"
|
|
15
|
+
],
|
|
13
16
|
"license": "MIT"
|
|
14
17
|
}
|
|
@@ -282,16 +282,17 @@ class MetabaseService {
|
|
|
282
282
|
let tempid = -1;
|
|
283
283
|
for (const srcDashcard of srcDashboard?.dashcards) {
|
|
284
284
|
const newCardId = mapperService.getCardId(srcDashcard.card_id);
|
|
285
|
+
let destinationCard;
|
|
285
286
|
|
|
286
287
|
if (!newCardId) {
|
|
287
|
-
console.warn(`${createdDashboard.name} doesn't have card id for target instance so skipping this dashboard cloning..`);
|
|
288
|
-
return;
|
|
288
|
+
// console.warn(`${createdDashboard.name} doesn't have card id for target instance so skipping this dashboard cloning..`);
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
291
|
+
else {
|
|
292
|
+
destinationCard = await targetInstance.getCard(newCardId);
|
|
293
|
+
destinationCard.dashboard_id = createdDashboard.id;
|
|
294
|
+
await targetInstance.updateCard(newCardId, destinationCard);
|
|
295
|
+
}
|
|
295
296
|
const dashCardPaylod = {
|
|
296
297
|
id: tempid--,
|
|
297
298
|
size_x: srcDashcard.size_x,
|
|
@@ -305,11 +306,13 @@ class MetabaseService {
|
|
|
305
306
|
if (srcDashcard.card_id) {
|
|
306
307
|
dashCardPaylod.card_id = newCardId;
|
|
307
308
|
dashCardPaylod.parameter_mappings = srcDashcard.parameter_mappings.map((pm) => { const copy = this.deepCopy(pm); copy.card_id = newCardId; return copy; });
|
|
309
|
+
dashCardPaylod.card = destinationCard;
|
|
308
310
|
}
|
|
309
311
|
|
|
310
|
-
if (srcDashcard.card) {
|
|
311
|
-
dashCardPaylod.card =
|
|
312
|
+
else if (srcDashcard.card) {
|
|
313
|
+
dashCardPaylod.card = srcDashcard.card;
|
|
312
314
|
}
|
|
315
|
+
|
|
313
316
|
dashCardsPayloads.push(dashCardPaylod);
|
|
314
317
|
};
|
|
315
318
|
|