@activepieces/piece-metabase 0.2.7 → 0.2.8

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/src/index.d.ts DELETED
@@ -1,17 +0,0 @@
1
- export declare const metabaseAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
2
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
- apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
- } | {
5
- embeddingKey: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
7
- apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
8
- }>;
9
- export declare const metabase: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
10
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
11
- apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
12
- } | {
13
- embeddingKey: import("@activepieces/pieces-framework").ShortTextProperty<false>;
14
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
15
- apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
16
- }>>;
17
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AA2CA,eAAO,MAAM,YAAY;;;;;;;EA2BvB,CAAC;AAEH,eAAO,MAAM,QAAQ;;;;;;;GAwBnB,CAAC"}
package/src/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAIwC;AACxC,6DAAyD;AACzD,uEAAwE;AACxE,+DAAoE;AACpE,yCAAgD;AAChD,+DAIqC;AACrC,yEAAoE;AACpE,iEAA6D;AAC7D,iDAAyD;AAEzD,MAAM,SAAS,GAAG;IAChB,OAAO,EAAE,2BA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D;IAC3D,OAAO,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,qBAAqB,EAAE,cAAc,CAAC;IAC1E,OAAO,EAAE;QACP,0BAAW;QACX,yCAAqB;QACrB,qCAAqB;QACrB,8BAAa;QACb,GAAG,CAAC,IAAA,qCAAqB,GAAE,CAAC,CAAC,CAAC,CAAC,qCAAgB,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACtD,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAE,oBAAY;YAClB,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CAChB,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE;YAC5D,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAAC,OAAA,CAAC;oBAC5B,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM;iBAC/B,CAAC,CAAA;cAAA;SACH,CAAC;KACH;IACD,QAAQ,EAAE,EAAE;CACb,CAAC,CAAC"}
@@ -1,20 +0,0 @@
1
- export declare const embedQuestion: 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
- } | {
5
- embeddingKey: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
7
- apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
8
- }>, {
9
- questionId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
10
- enableEmbedding: import("@activepieces/pieces-framework").CheckboxProperty<true>;
11
- parameterSettings: import("@activepieces/pieces-framework").DynamicProperties<false, import("@activepieces/pieces-framework").CustomAuthProperty<{
12
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
13
- apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
14
- } | {
15
- embeddingKey: import("@activepieces/pieces-framework").ShortTextProperty<false>;
16
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
17
- apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
18
- }>>;
19
- }>;
20
- //# sourceMappingURL=embed-question.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"embed-question.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/embed-question.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;EAyIxB,CAAC"}
@@ -1,119 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.embedQuestion = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const common_1 = require("../common");
7
- const __1 = require("../..");
8
- const pieces_common_1 = require("@activepieces/pieces-common");
9
- exports.embedQuestion = (0, pieces_framework_1.createAction)({
10
- name: 'embedQuestion',
11
- auth: __1.metabaseAuth,
12
- requireAuth: true,
13
- displayName: 'Embed question',
14
- description: 'Enable embedding for a Metabase question and configure parameters',
15
- audience: 'both',
16
- aiMetadata: {
17
- description: "Updates a Metabase question (card) by its ID to toggle static embedding on or off and set how each parameter is exposed in the embed (disabled, editable, or locked). Use when configuring a question for external embedding. This mutates the card's settings, but is idempotent — re-running with the same inputs leaves the card in the same configured state.",
18
- idempotent: true,
19
- },
20
- props: {
21
- questionId: pieces_framework_1.Property.ShortText({
22
- displayName: 'Metabase question ID',
23
- required: true,
24
- }),
25
- enableEmbedding: pieces_framework_1.Property.Checkbox({
26
- displayName: 'Enable embedding',
27
- description: 'Whether to enable embedding for this question',
28
- required: true,
29
- defaultValue: true,
30
- }),
31
- parameterSettings: pieces_framework_1.Property.DynamicProperties({
32
- displayName: 'Parameter settings',
33
- auth: __1.metabaseAuth,
34
- description: 'Configure how each parameter should be handled in the embed',
35
- required: false,
36
- refreshers: ['questionId', 'enableEmbedding'],
37
- props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, questionId, enableEmbedding }) {
38
- if (!questionId || !enableEmbedding || !auth) {
39
- return {};
40
- }
41
- try {
42
- const card = yield (0, common_1.queryMetabaseApi)({
43
- endpoint: `card/${questionId.split('-')[0]}`,
44
- method: pieces_common_1.HttpMethod.GET,
45
- }, auth);
46
- const parameters = card['parameters'] || [];
47
- const props = {};
48
- // Get current embedding settings if they exist
49
- const currentEmbeddingParams = card.embedding_params || {};
50
- parameters.forEach((param) => {
51
- const paramName = param.name || param.slug;
52
- const currentSetting = currentEmbeddingParams[param.slug] || 'disabled';
53
- props[param.slug] = pieces_framework_1.Property.StaticDropdown({
54
- displayName: paramName,
55
- description: `How to handle parameter: ${paramName}`,
56
- required: false,
57
- defaultValue: currentSetting,
58
- options: {
59
- options: [
60
- { label: 'Disabled', value: 'disabled' },
61
- { label: 'Editable', value: 'enabled' },
62
- { label: 'Locked', value: 'locked' },
63
- ],
64
- },
65
- });
66
- });
67
- return props;
68
- }
69
- catch (error) {
70
- return {};
71
- }
72
- }),
73
- }),
74
- },
75
- run(_a) {
76
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
77
- const questionId = propsValue.questionId.split('-')[0];
78
- // First, get the current question details
79
- const card = yield (0, common_1.queryMetabaseApi)({ endpoint: `card/${questionId}`, method: pieces_common_1.HttpMethod.GET }, auth);
80
- const parameters = card['parameters'] || [];
81
- const updatePayload = Object.assign(Object.assign({}, card), { enable_embedding: propsValue.enableEmbedding });
82
- // If parameter settings are provided, update the parameters
83
- // Create embedding_params object if parameter settings are provided
84
- if (propsValue.parameterSettings && parameters.length > 0) {
85
- const embeddingParams = {};
86
- parameters.forEach((param) => {
87
- var _a;
88
- const paramSetting = (_a = propsValue.parameterSettings) === null || _a === void 0 ? void 0 : _a[param.slug];
89
- if (paramSetting) {
90
- embeddingParams[param.slug] = paramSetting;
91
- }
92
- else {
93
- embeddingParams[param.slug] = 'disabled';
94
- }
95
- });
96
- updatePayload.embedding_params = embeddingParams;
97
- }
98
- // Update the card with embedding settings
99
- const response = yield (0, common_1.queryMetabaseApi)({
100
- endpoint: `card/${questionId}`,
101
- method: pieces_common_1.HttpMethod.PUT,
102
- body: updatePayload,
103
- }, auth);
104
- if (response.error) {
105
- throw new Error(response.error);
106
- }
107
- return {
108
- success: true,
109
- message: propsValue.enableEmbedding
110
- ? 'Question embedding has been enabled successfully'
111
- : 'Question embedding has been disabled successfully',
112
- embeddingParams: propsValue.enableEmbedding
113
- ? updatePayload.embedding_params
114
- : {},
115
- };
116
- });
117
- },
118
- });
119
- //# sourceMappingURL=embed-question.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"embed-question.js","sourceRoot":"","sources":["../../../../src/lib/actions/embed-question.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,sCAA6C;AAC7C,6BAAqC;AACrC,+DAAyD;AAQ5C,QAAA,aAAa,GAAG,IAAA,+BAAY,EAAC;IACxC,IAAI,EAAE,eAAe;IACrB,IAAI,EAAE,gBAAY;IAClB,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,gBAAgB;IAC7B,WAAW,EACT,mEAAmE;IACrE,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE;QACV,WAAW,EACT,mWAAmW;QACrW,UAAU,EAAE,IAAI;KACjB;IACD,KAAK,EAAE;QACL,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,sBAAsB;YACnC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,eAAe,EAAE,2BAAQ,CAAC,QAAQ,CAAC;YACjC,WAAW,EAAE,kBAAkB;YAC/B,WAAW,EAAE,+CAA+C;YAC5D,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,IAAI;SACnB,CAAC;QACF,iBAAiB,EAAE,2BAAQ,CAAC,iBAAiB,CAA6B;YACxE,WAAW,EAAE,oBAAoB;YACj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AAK,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;oBAC3C,CAAC;gBACH,CAAC,CAAC,CAAC;gBAEH,aAAa,CAAC,gBAAgB,GAAG,eAAe,CAAC;YACnD,CAAC;YAED,0CAA0C;YAC1C,MAAM,QAAQ,GAAG,MAAM,IAAA,yBAAgB,EACrC;gBACE,QAAQ,EAAE,QAAQ,UAAU,EAAE;gBAC9B,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,IAAI,EAAE,aAAa;aACpB,EACD,IAAI,CACL,CAAC;YAEF,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;YAED,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,OAAO,EAAE,UAAU,CAAC,eAAe;oBACjC,CAAC,CAAC,kDAAkD;oBACpD,CAAC,CAAC,mDAAmD;gBACvD,eAAe,EAAE,UAAU,CAAC,eAAe;oBACzC,CAAC,CAAC,aAAa,CAAC,gBAAgB;oBAChC,CAAC,CAAC,EAAE;aACP,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- export declare const getDashboardQuestions: 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
- } | {
5
- embeddingKey: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
7
- apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
8
- }>, {
9
- dashboardId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
10
- parameters: import("@activepieces/pieces-framework").ObjectProperty<false>;
11
- }>;
12
- //# sourceMappingURL=get-dashboard.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-dashboard.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/get-dashboard.ts"],"names":[],"mappings":"AAiCA,eAAO,MAAM,qBAAqB;;;;;;;;;;EAgIhC,CAAC"}
@@ -1,115 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDashboardQuestions = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const common_1 = require("../common");
7
- const __1 = require("../..");
8
- const pieces_common_1 = require("@activepieces/pieces-common");
9
- exports.getDashboardQuestions = (0, pieces_framework_1.createAction)({
10
- name: 'getDashboardQuestions',
11
- auth: __1.metabaseAuth,
12
- requireAuth: true,
13
- displayName: 'Get Dashboard Questions',
14
- description: 'Execute all questions across all tabs in a Metabase dashboard and return their consolidated results in a single response',
15
- audience: 'both',
16
- aiMetadata: {
17
- description: "Runs every question (card) on a Metabase dashboard, identified by dashboard ID, and returns all of their results plus the dashboard's available parameters in one consolidated response. Use to retrieve data from an entire dashboard at once rather than fetching cards individually. Optionally pass a parameters object (keyed by parameter slug) applied across all cards. Read-only and idempotent.",
18
- idempotent: true,
19
- },
20
- props: {
21
- dashboardId: pieces_framework_1.Property.ShortText({
22
- displayName: 'Metabase Dashboard ID',
23
- required: true,
24
- }),
25
- parameters: pieces_framework_1.Property.Object({
26
- displayName: 'Parameters (slug name -> value)',
27
- description: 'Dashboard parameters to apply to all questions',
28
- required: false,
29
- }),
30
- },
31
- run(_a) {
32
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
33
- const dashboardId = propsValue.dashboardId.split('-')[0];
34
- const dashboardData = yield (0, common_1.queryMetabaseApi)({ endpoint: `dashboard/${dashboardId}`, method: pieces_common_1.HttpMethod.GET }, auth);
35
- if (dashboardData.error) {
36
- throw new Error(`Error fetching dashboard: ${dashboardData.error}`);
37
- }
38
- const dashboardParameters = dashboardData.parameters || [];
39
- const result = {
40
- dashboard_name: dashboardData.name || 'Unknown Dashboard',
41
- available_parameters: dashboardParameters.map((param) => {
42
- var _a;
43
- return ({
44
- id: param.id,
45
- name: param.name || 'Unknown',
46
- slug: param.slug || '',
47
- type: param.type || '',
48
- possible_values: ((_a = param.values_source_config) === null || _a === void 0 ? void 0 : _a.values) || [],
49
- });
50
- }),
51
- cards_results: {},
52
- };
53
- // Execute each card and collect results
54
- for (const dashcard of dashboardData.dashcards || []) {
55
- const cardId = dashcard.card_id;
56
- const dashcardId = dashcard.id;
57
- if (!cardId)
58
- continue;
59
- let cardName = 'Unknown';
60
- if (dashcard.card && typeof dashcard.card === 'object') {
61
- cardName = dashcard.card.name || `Card ${cardId}`;
62
- }
63
- const cardParameters = [];
64
- // Map dashboard parameters to card parameters using parameter_mappings
65
- if (propsValue.parameters && dashcard.parameter_mappings) {
66
- for (const mapping of dashcard.parameter_mappings) {
67
- const paramId = mapping.parameter_id;
68
- // Find corresponding dashboard parameter
69
- const dashParam = dashboardParameters.find((p) => p.id === paramId);
70
- if (dashParam &&
71
- dashParam.slug &&
72
- propsValue.parameters[dashParam.slug] !== undefined) {
73
- cardParameters.push({
74
- id: paramId,
75
- target: mapping.target,
76
- type: dashParam.type,
77
- value: propsValue.parameters[dashParam.slug],
78
- });
79
- }
80
- }
81
- }
82
- try {
83
- const cardResult = yield (0, common_1.queryMetabaseApi)({
84
- endpoint: `dashboard/${dashboardId}/dashcard/${dashcardId}/card/${cardId}/query/json`,
85
- method: pieces_common_1.HttpMethod.POST,
86
- body: {
87
- parameters: cardParameters,
88
- },
89
- }, auth);
90
- const cardIdStr = String(cardId);
91
- result.cards_results[cardIdStr] = {
92
- name: cardName,
93
- data: cardResult,
94
- };
95
- }
96
- catch (error) {
97
- let errorMessage = 'Unknown error';
98
- if (error &&
99
- typeof error === 'object' &&
100
- 'message' in error &&
101
- typeof error.message === 'string') {
102
- errorMessage = error.message;
103
- }
104
- const cardIdStr = String(cardId);
105
- result.cards_results[cardIdStr] = {
106
- name: cardName,
107
- error: `Failed to execute: ${errorMessage}`,
108
- };
109
- }
110
- }
111
- return result;
112
- });
113
- },
114
- });
115
- //# sourceMappingURL=get-dashboard.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-dashboard.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-dashboard.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,sCAA6C;AAC7C,6BAAqC;AACrC,+DAAyD;AA8B5C,QAAA,qBAAqB,GAAG,IAAA,+BAAY,EAAC;IAChD,IAAI,EAAE,uBAAuB;IAC7B,IAAI,EAAE,gBAAY;IAClB,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,yBAAyB;IACtC,WAAW,EACT,0HAA0H;IAC5H,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE;QACV,WAAW,EACT,2YAA2Y;QAC7Y,UAAU,EAAE,IAAI;KACjB;IACD,KAAK,EAAE;QACL,WAAW,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC9B,WAAW,EAAE,uBAAuB;YACpC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,MAAM,CAAC;YAC1B,WAAW,EAAE,iCAAiC;YAC9C,WAAW,EAAE,gDAAgD;YAC7D,QAAQ,EAAE,KAAK;SAChB,CAAC;KACH;IACK,GAAG;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE;YAC5B,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAEzD,MAAM,aAAa,GAAG,MAAM,IAAA,yBAAgB,EAC1C,EAAE,QAAQ,EAAE,aAAa,WAAW,EAAE,EAAE,MAAM,EAAE,0BAAU,CAAC,GAAG,EAAE,EAChE,IAAI,CACL,CAAC;YAEF,IAAI,aAAa,CAAC,KAAK,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CAAC,6BAA6B,aAAa,CAAC,KAAK,EAAE,CAAC,CAAC;YACtE,CAAC;YAED,MAAM,mB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S,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;oBACjC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG;wBAChC,IAAI,EAAE,QAAQ;wBACd,KAAK,EAAE,sBAAsB,YAAY,EAAE;qBAC5C,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,OAAO,MAAM,CAAC;QAChB,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -1,14 +0,0 @@
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
- } | {
5
- embeddingKey: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
7
- apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
8
- }>, {
9
- questionId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
10
- parameters: import("@activepieces/pieces-framework").ObjectProperty<false>;
11
- graphName: import("@activepieces/pieces-framework").ShortTextProperty<false>;
12
- waitTime: import("@activepieces/pieces-framework").NumberProperty<true>;
13
- }>;
14
- //# sourceMappingURL=get-graph-question.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-graph-question.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/get-graph-question.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;EAuI3B,CAAC"}
@@ -1,129 +0,0 @@
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 playwright_1 = require("playwright");
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
- audience: 'both',
16
- aiMetadata: {
17
- description: "Renders the chart/graph of a Metabase question (by ID) via a signed embed URL in a headless browser and saves a high-resolution PNG screenshot. Use when an agent needs the rendered visualization of a report rather than its data rows. Requires the connection's embedding key to be set and the question to be published for embedding; the question must already exist. Read-only and idempotent — it does not modify Metabase.",
18
- idempotent: true,
19
- },
20
- props: {
21
- questionId: pieces_framework_1.Property.ShortText({
22
- displayName: 'Metabase question ID',
23
- required: true,
24
- }),
25
- parameters: pieces_framework_1.Property.Object({
26
- displayName: 'Parameters (slug name -> value)',
27
- required: false,
28
- }),
29
- graphName: pieces_framework_1.Property.ShortText({
30
- displayName: 'The name of the graph (without the extension)',
31
- required: false,
32
- }),
33
- waitTime: pieces_framework_1.Property.Number({
34
- displayName: 'Wait Time (seconds)',
35
- description: 'How long to wait for the graph to render completely in seconds',
36
- required: true,
37
- defaultValue: 5,
38
- }),
39
- },
40
- run(_a) {
41
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue, files }) {
42
- if ('embeddingKey' in auth.props && !auth.props.embeddingKey)
43
- return 'An embedding key is needed.';
44
- if (propsValue.waitTime <= 0)
45
- return 'The wait time needs to be superior to 0';
46
- const questionId = propsValue.questionId.split('-')[0];
47
- const numericQuestionId = parseInt(questionId);
48
- const payload = {
49
- resource: { question: numericQuestionId },
50
- params: propsValue.parameters,
51
- exp: Math.round(Date.now() / 1000) + 10 * 60,
52
- };
53
- // @ts-expect-error we expect an embedding key if the user can use this action.
54
- const token = jsonwebtoken_1.default.sign(payload, auth.props.embeddingKey);
55
- const graphName = propsValue.graphName
56
- ? propsValue.graphName + '.png'
57
- : `metabase_question_${questionId}.png`;
58
- const iframeUrl = auth.props.baseUrl +
59
- '/embed/question/' +
60
- token +
61
- '#bordered=true&titled=true';
62
- const browser = yield playwright_1.chromium.launch({
63
- headless: true,
64
- chromiumSandbox: false,
65
- executablePath: '/usr/bin/chromium',
66
- });
67
- try {
68
- const context = yield browser.newContext({
69
- viewport: {
70
- width: 1600,
71
- height: 1200,
72
- },
73
- deviceScaleFactor: 2,
74
- });
75
- const page = yield context.newPage();
76
- const response = yield page.goto(iframeUrl, {
77
- waitUntil: 'networkidle',
78
- timeout: 30000,
79
- });
80
- if (!response || !response.ok()) {
81
- throw new Error(`Page load failed with status: ${response ? response.status() : 400}`);
82
- }
83
- // we wait so the graph can load
84
- yield page.waitForTimeout(propsValue.waitTime * 1000);
85
- const mainElement = yield page.$('main');
86
- let screenshotBuffer;
87
- if (mainElement) {
88
- screenshotBuffer = yield mainElement.screenshot({
89
- path: graphName,
90
- type: 'png',
91
- });
92
- }
93
- else {
94
- screenshotBuffer = yield page.screenshot({
95
- path: graphName,
96
- type: 'png',
97
- clip: {
98
- x: 0,
99
- y: 0,
100
- width: 1600,
101
- height: 1120, // so it doesn't screenshot the metabase banner
102
- },
103
- });
104
- }
105
- const fileUrl = yield files.write({
106
- fileName: graphName,
107
- data: screenshotBuffer,
108
- });
109
- return {
110
- file: {
111
- filename: graphName,
112
- base64Content: screenshotBuffer.toString('base64'),
113
- download: fileUrl,
114
- },
115
- iframeUrl,
116
- };
117
- }
118
- catch (error) {
119
- console.error('Please verify that either your embedding key and question id are valid or that the question is embedded and published.');
120
- console.error('Error capturing Metabase chart:', error);
121
- throw error;
122
- }
123
- finally {
124
- yield browser.close();
125
- }
126
- });
127
- },
128
- });
129
- //# sourceMappingURL=get-graph-question.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-graph-question.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-graph-question.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,6BAAqC;AACrC,wEAA+B;AAC/B,2CAAsC;AAEzB,QAAA,gBAAgB,GAAG,IAAA,+BAAY,EAAC;IAC3C,IAAI,EAAE,kBAAkB;IACxB,IAAI,EAAE,gB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@ -1,11 +0,0 @@
1
- export declare const getQuestionPngPreview: 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
- } | {
5
- embeddingKey: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
7
- apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
8
- }>, {
9
- questionId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
10
- }>;
11
- //# sourceMappingURL=get-png-rendering.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-png-rendering.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/get-png-rendering.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,qBAAqB;;;;;;;;;EAgDhC,CAAC"}
@@ -1,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getQuestionPngPreview = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const __1 = require("../..");
7
- const common_1 = require("../common");
8
- const pieces_common_1 = require("@activepieces/pieces-common");
9
- exports.getQuestionPngPreview = (0, pieces_framework_1.createAction)({
10
- name: 'getQuestionPngPreview',
11
- auth: __1.metabaseAuth,
12
- requireAuth: true,
13
- displayName: 'Get Question PNG Preview',
14
- description: 'Get PNG preview rendering (low resolution) of a Metabase card/question.',
15
- audience: 'both',
16
- aiMetadata: {
17
- description: 'Fetches a low-resolution PNG preview image of a saved Metabase question (card) by its ID and saves it as a file. Use when an agent needs a quick visual snapshot of a report rather than the underlying data rows. Read-only and idempotent.',
18
- idempotent: true,
19
- },
20
- props: {
21
- questionId: pieces_framework_1.Property.ShortText({
22
- displayName: 'Metabase question ID',
23
- required: true,
24
- }),
25
- },
26
- run(_a) {
27
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue, files }) {
28
- const questionId = propsValue.questionId.split('-')[0];
29
- const response = yield (0, common_1.queryMetabaseApi)({
30
- endpoint: `pulse/preview_card_png/${questionId}`,
31
- method: pieces_common_1.HttpMethod.GET,
32
- headers: {
33
- Accept: 'image/png',
34
- },
35
- responseType: 'arraybuffer',
36
- }, auth);
37
- if (response.error) {
38
- throw new Error(response.error);
39
- }
40
- const fileUrl = yield files.write({
41
- fileName: `metabase_question_${questionId}.png`,
42
- data: Buffer.from(response, 'base64'),
43
- });
44
- return {
45
- fileName: `metabase_question_${questionId}.png`,
46
- file: fileUrl,
47
- };
48
- });
49
- },
50
- });
51
- //# sourceMappingURL=get-png-rendering.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-png-rendering.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-png-rendering.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,6BAAqC;AACrC,sCAA6C;AAC7C,+DAAyD;AAE5C,QAAA,qBAAqB,GAAG,IAAA,+BAAY,EAAC;IAChD,IAAI,EAAE,uBAAuB;IAC7B,IAAI,EAAE,gBAAY;IAClB,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,0BAA0B;IACvC,WAAW,EACT,yEAAyE;IAC3E,QAAQ,EAAE,MAAM;IAChB,UAAU,EAAE;QACV,WAAW,EACT,8OAA8O;QAChP,UAAU,EAAE,IAAI;KACjB;IACD,KAAK,EAAE;QACL,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,sBAAsB;YACnC,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;IACK,GAAG;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE;YACnC,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;YAEvD,MAAM,QAAQ,GAAG,MAAM,IAAA,yBAAgB,EACrC;gBACE,QAAQ,EAAE,0BAA0B,UAAU,EAAE;gBAChD,MAAM,EAAE,0BAAU,CAAC,GAAG;gBACtB,OAAO,EAAE;oBACP,MAAM,EAAE,WAAW;iBACpB;gBACD,YAAY,EAAE,aAAa;aAC5B,EACD,IAAI,CACL,CAAC;YAEF,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;YAED,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC;gBAChC,QAAQ,EAAE,qBAAqB,UAAU,MAAM;gBAC/C,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC;aACtC,CAAC,CAAC;YAEH,OAAO;gBACL,QAAQ,EAAE,qBAAqB,UAAU,MAAM;gBAC/C,IAAI,EAAE,OAAO;aACd,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- export declare const getQuestion: 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
- } | {
5
- embeddingKey: import("@activepieces/pieces-framework").ShortTextProperty<false>;
6
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
7
- apiKey: import("@activepieces/pieces-framework").SecretTextProperty<true>;
8
- }>, {
9
- questionId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
10
- parameters: import("@activepieces/pieces-framework").ObjectProperty<false>;
11
- }>;
12
- //# sourceMappingURL=get-question.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-question.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/get-question.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,WAAW;;;;;;;;;;EA8DtB,CAAC"}
@@ -1,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getQuestion = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const common_1 = require("../common");
7
- const __1 = require("../..");
8
- const pieces_common_1 = require("@activepieces/pieces-common");
9
- exports.getQuestion = (0, pieces_framework_1.createAction)({
10
- name: 'getQuestion',
11
- auth: __1.metabaseAuth,
12
- requireAuth: true,
13
- displayName: 'Get question',
14
- description: 'Fetch the results of a Metabase question',
15
- audience: 'both',
16
- aiMetadata: {
17
- description: 'Runs a saved Metabase question (card) by its ID and returns the query result rows. Use to pull live data from an existing report rather than writing raw SQL. Optionally pass a parameters object (keyed by parameter slug) to filter the query; slugs not defined on the card are ignored. Read-only and idempotent — re-running with the same inputs re-executes the query without side effects.',
18
- idempotent: true,
19
- },
20
- props: {
21
- questionId: pieces_framework_1.Property.ShortText({
22
- displayName: 'Metabase question ID',
23
- required: true,
24
- }),
25
- parameters: pieces_framework_1.Property.Object({
26
- displayName: 'Parameters (slug name -> value)',
27
- required: false,
28
- }),
29
- },
30
- run(_a) {
31
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
32
- const questionId = propsValue.questionId.split('-')[0];
33
- const card = yield (0, common_1.queryMetabaseApi)({ endpoint: `card/${questionId}`, method: pieces_common_1.HttpMethod.GET }, auth);
34
- const parameters = card['parameters'];
35
- const response = yield (0, common_1.queryMetabaseApi)({
36
- endpoint: `card/${questionId}/query`,
37
- method: pieces_common_1.HttpMethod.POST,
38
- body: {
39
- collection_preview: false,
40
- ignore_cache: false,
41
- parameters: parameters
42
- .filter((param) => propsValue.parameters &&
43
- propsValue.parameters[param.slug] !== undefined)
44
- .map((param) => {
45
- return {
46
- id: param.id,
47
- target: param.target,
48
- type: param.type,
49
- value: propsValue.parameters && propsValue.parameters[param.slug],
50
- };
51
- }),
52
- },
53
- }, auth);
54
- if (response.error) {
55
- throw new Error(response.error);
56
- }
57
- else {
58
- return response;
59
- }
60
- });
61
- },
62
- });
63
- //# sourceMappingURL=get-question.js.map