@activepieces/piece-metabase 0.1.5 → 0.1.6
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/package.json +8 -6
- package/src/index.d.ts +2 -0
- package/src/index.js +14 -3
- package/src/index.js.map +1 -1
- package/src/lib/actions/get-dashboard.d.ts +1 -0
- package/src/lib/actions/get-graph-question.d.ts +9 -0
- package/src/lib/actions/get-graph-question.js +97 -0
- package/src/lib/actions/get-graph-question.js.map +1 -0
- package/src/lib/actions/get-png-rendering.d.ts +1 -0
- package/src/lib/actions/get-question.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@activepieces/piece-metabase",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@anthropic-ai/sdk": "0.33.1",
|
|
6
6
|
"@sinclair/typebox": "0.34.11",
|
|
7
|
-
"axios": "1.8.
|
|
7
|
+
"axios": "1.8.3",
|
|
8
8
|
"axios-retry": "4.4.1",
|
|
9
9
|
"deepmerge-ts": "7.1.0",
|
|
10
|
+
"jsonwebtoken": "9.0.1",
|
|
10
11
|
"mime-types": "2.1.35",
|
|
11
12
|
"nanoid": "3.3.8",
|
|
12
13
|
"openai": "4.67.1",
|
|
14
|
+
"puppeteer": "22.15.0",
|
|
13
15
|
"replicate": "0.34.1",
|
|
14
16
|
"semver": "7.6.0",
|
|
15
|
-
"zod": "3.
|
|
16
|
-
"@activepieces/pieces-common": "0.4.
|
|
17
|
-
"@activepieces/pieces-framework": "0.7.
|
|
18
|
-
"@activepieces/shared": "0.10.
|
|
17
|
+
"zod": "3.24.2",
|
|
18
|
+
"@activepieces/pieces-common": "0.4.4",
|
|
19
|
+
"@activepieces/pieces-framework": "0.7.46",
|
|
20
|
+
"@activepieces/shared": "0.10.171",
|
|
19
21
|
"tslib": "1.14.1"
|
|
20
22
|
},
|
|
21
23
|
"overrides": {
|
package/src/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export declare const metabaseAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
2
|
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
3
|
apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
embeddingKey: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
5
|
}>;
|
|
5
6
|
export declare const metabase: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
6
7
|
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
8
|
apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
9
|
+
embeddingKey: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
8
10
|
}>>;
|
package/src/index.js
CHANGED
|
@@ -8,8 +8,9 @@ const get_png_rendering_1 = require("./lib/actions/get-png-rendering");
|
|
|
8
8
|
const get_dashboard_1 = require("./lib/actions/get-dashboard");
|
|
9
9
|
const common_1 = require("./lib/common");
|
|
10
10
|
const pieces_common_1 = require("@activepieces/pieces-common");
|
|
11
|
+
const get_graph_question_1 = require("./lib/actions/get-graph-question");
|
|
11
12
|
exports.metabaseAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
12
|
-
description: 'Metabase authentication requires a
|
|
13
|
+
description: 'Metabase authentication requires a baseUrl and a password.',
|
|
13
14
|
required: true,
|
|
14
15
|
props: {
|
|
15
16
|
baseUrl: pieces_framework_1.Property.ShortText({
|
|
@@ -21,6 +22,11 @@ exports.metabaseAuth = pieces_framework_1.PieceAuth.CustomAuth({
|
|
|
21
22
|
description: 'Generate one on your Metabase instance (settings -> authentication -> API keys)',
|
|
22
23
|
required: true,
|
|
23
24
|
}),
|
|
25
|
+
embeddingKey: pieces_framework_1.Property.ShortText({
|
|
26
|
+
displayName: 'Embedding key',
|
|
27
|
+
description: 'Needed if you want to generate a graph of a question (settings -> embedding -> static embedding).',
|
|
28
|
+
required: false,
|
|
29
|
+
}),
|
|
24
30
|
},
|
|
25
31
|
validate: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth }) {
|
|
26
32
|
try {
|
|
@@ -46,8 +52,13 @@ exports.metabase = (0, pieces_framework_1.createPiece)({
|
|
|
46
52
|
auth: exports.metabaseAuth,
|
|
47
53
|
minimumSupportedRelease: '0.30.0',
|
|
48
54
|
logoUrl: 'https://cdn.activepieces.com/pieces/metabase.png',
|
|
49
|
-
authors: ['AdamSelene', 'abuaboud', 'valentin-mourtialon'],
|
|
50
|
-
actions: [
|
|
55
|
+
authors: ['AdamSelene', 'abuaboud', 'valentin-mourtialon', 'Kevinyu-alan'],
|
|
56
|
+
actions: [
|
|
57
|
+
get_question_1.getQuestion,
|
|
58
|
+
get_png_rendering_1.getQuestionPngPreview,
|
|
59
|
+
get_dashboard_1.getDashboardQuestions,
|
|
60
|
+
get_graph_question_1.getGraphQuestion,
|
|
61
|
+
],
|
|
51
62
|
triggers: [],
|
|
52
63
|
});
|
|
53
64
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/metabase/src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,6DAAyD;AACzD,uEAAwE;AACxE,+DAAoE;AACpE,yCAAgD;AAChD,+DAAyD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/metabase/src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,6DAAyD;AACzD,uEAAwE;AACxE,+DAAoE;AACpE,yCAAgD;AAChD,+DAAyD;AACzD,yEAAoE;AAEvD,QAAA,YAAY,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC/C,WAAW,EAAE,4DAA4D;IACzE,QAAQ,EA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Questions: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
2
|
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
3
|
apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
embeddingKey: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
5
|
}>, {
|
|
5
6
|
dashboardId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
6
7
|
parameters: import("@activepieces/pieces-framework").ObjectProperty<false>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const getGraphQuestion: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
|
+
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
|
+
apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
embeddingKey: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
}>, {
|
|
6
|
+
questionId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
7
|
+
parameters: import("@activepieces/pieces-framework").ObjectProperty<false>;
|
|
8
|
+
graphName: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGraphQuestion = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const __1 = require("../..");
|
|
7
|
+
const jsonwebtoken_1 = tslib_1.__importDefault(require("jsonwebtoken"));
|
|
8
|
+
const puppeteer_1 = tslib_1.__importDefault(require("puppeteer"));
|
|
9
|
+
exports.getGraphQuestion = (0, pieces_framework_1.createAction)({
|
|
10
|
+
name: 'getGraphQuestion',
|
|
11
|
+
auth: __1.metabaseAuth,
|
|
12
|
+
requireAuth: true,
|
|
13
|
+
displayName: 'Get the graph of the question',
|
|
14
|
+
description: 'Get the graph of a Metabase question and save it as a png',
|
|
15
|
+
props: {
|
|
16
|
+
questionId: pieces_framework_1.Property.ShortText({
|
|
17
|
+
displayName: 'Metabase question ID',
|
|
18
|
+
required: true,
|
|
19
|
+
}),
|
|
20
|
+
parameters: pieces_framework_1.Property.Object({
|
|
21
|
+
displayName: 'Parameters (slug name -> value)',
|
|
22
|
+
required: false,
|
|
23
|
+
}),
|
|
24
|
+
graphName: pieces_framework_1.Property.ShortText({
|
|
25
|
+
displayName: 'The name of the graph (without the extension)',
|
|
26
|
+
required: false,
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
run(_a) {
|
|
30
|
+
return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue, files }) {
|
|
31
|
+
if (!auth.embeddingKey)
|
|
32
|
+
return 'An embedding key is needed.';
|
|
33
|
+
const questionId = propsValue.questionId.split('-')[0];
|
|
34
|
+
const numericQuestionId = parseInt(questionId);
|
|
35
|
+
const payload = {
|
|
36
|
+
resource: { question: numericQuestionId },
|
|
37
|
+
params: propsValue.parameters,
|
|
38
|
+
exp: Math.round(Date.now() / 1000) + 10 * 60,
|
|
39
|
+
};
|
|
40
|
+
const token = jsonwebtoken_1.default.sign(payload, auth.embeddingKey);
|
|
41
|
+
const graphName = propsValue.graphName
|
|
42
|
+
? propsValue.graphName + '.png'
|
|
43
|
+
: `metabase_question_${questionId}.png`;
|
|
44
|
+
const iframeUrl = auth.baseUrl + '/embed/question/' + token + '#bordered=true&titled=true';
|
|
45
|
+
const browser = yield puppeteer_1.default.launch({
|
|
46
|
+
headless: true,
|
|
47
|
+
args: ['--no-sandbox', '--disable-setuid-sandbox'],
|
|
48
|
+
});
|
|
49
|
+
try {
|
|
50
|
+
const page = yield browser.newPage();
|
|
51
|
+
yield page.setViewport({
|
|
52
|
+
width: 1600,
|
|
53
|
+
height: 1200,
|
|
54
|
+
deviceScaleFactor: 2,
|
|
55
|
+
});
|
|
56
|
+
const response = yield page.goto(iframeUrl, {
|
|
57
|
+
waitUntil: 'networkidle0',
|
|
58
|
+
timeout: 30000,
|
|
59
|
+
});
|
|
60
|
+
if (!response || !response.ok()) {
|
|
61
|
+
throw new Error(`Page load failed with status: ${response ? response.status() : 400}`);
|
|
62
|
+
}
|
|
63
|
+
const screenshotBuffer = yield page.screenshot({
|
|
64
|
+
path: graphName,
|
|
65
|
+
type: 'png',
|
|
66
|
+
clip: {
|
|
67
|
+
x: 0,
|
|
68
|
+
y: 0,
|
|
69
|
+
width: 1600,
|
|
70
|
+
height: 1120, // so it screenshots only the graph
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
const fileUrl = yield files.write({
|
|
74
|
+
fileName: graphName,
|
|
75
|
+
data: screenshotBuffer,
|
|
76
|
+
});
|
|
77
|
+
return {
|
|
78
|
+
file: {
|
|
79
|
+
filename: graphName,
|
|
80
|
+
base64Content: screenshotBuffer.toString('base64'),
|
|
81
|
+
download: fileUrl,
|
|
82
|
+
},
|
|
83
|
+
iframeUrl,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
console.error('Please verify that either your embedding key and question id are valid or that the question is embedded and published.');
|
|
88
|
+
console.error('Error capturing Metabase chart:', error);
|
|
89
|
+
throw error;
|
|
90
|
+
}
|
|
91
|
+
finally {
|
|
92
|
+
yield browser.close();
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
//# sourceMappingURL=get-graph-question.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-graph-question.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/metabase/src/lib/actions/get-graph-question.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,6BAAqC;AACrC,wEAA+B;AAC/B,kEAAkC;AAErB,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAA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E;wBACJ,QAAQ,EAAE,SAAS;wBACnB,aAAa,EAAE,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,CAAC;wBAClD,QAAQ,EAAE,OAAO;qBAClB;oBACD,SAAS;iBACV,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CACX,wHAAwH,CACzH,CAAC;gBACF,OAAO,CAAC,KAAK,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;gBACxD,MAAM,KAAK,CAAC;YACd,CAAC;oBAAS,CAAC;gBACT,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;YACxB,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const getQuestionPngPreview: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
2
|
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
3
|
apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
embeddingKey: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
5
|
}>, {
|
|
5
6
|
questionId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
6
7
|
}>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const getQuestion: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
|
|
2
2
|
baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
3
3
|
apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
|
|
4
|
+
embeddingKey: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
4
5
|
}>, {
|
|
5
6
|
questionId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
|
|
6
7
|
parameters: import("@activepieces/pieces-framework").ObjectProperty<false>;
|