@activepieces/piece-metabase 0.2.6 → 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;;;;;;;;;;;;;;;;;;EAmIxB,CAAC"}
@@ -1,114 +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
- props: {
16
- questionId: pieces_framework_1.Property.ShortText({
17
- displayName: 'Metabase question ID',
18
- required: true,
19
- }),
20
- enableEmbedding: pieces_framework_1.Property.Checkbox({
21
- displayName: 'Enable embedding',
22
- description: 'Whether to enable embedding for this question',
23
- required: true,
24
- defaultValue: true,
25
- }),
26
- parameterSettings: pieces_framework_1.Property.DynamicProperties({
27
- displayName: 'Parameter settings',
28
- auth: __1.metabaseAuth,
29
- description: 'Configure how each parameter should be handled in the embed',
30
- required: false,
31
- refreshers: ['questionId', 'enableEmbedding'],
32
- props: (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ auth, questionId, enableEmbedding }) {
33
- if (!questionId || !enableEmbedding || !auth) {
34
- return {};
35
- }
36
- try {
37
- const card = yield (0, common_1.queryMetabaseApi)({
38
- endpoint: `card/${questionId.split('-')[0]}`,
39
- method: pieces_common_1.HttpMethod.GET,
40
- }, auth);
41
- const parameters = card['parameters'] || [];
42
- const props = {};
43
- // Get current embedding settings if they exist
44
- const currentEmbeddingParams = card.embedding_params || {};
45
- parameters.forEach((param) => {
46
- const paramName = param.name || param.slug;
47
- const currentSetting = currentEmbeddingParams[param.slug] || 'disabled';
48
- props[param.slug] = pieces_framework_1.Property.StaticDropdown({
49
- displayName: paramName,
50
- description: `How to handle parameter: ${paramName}`,
51
- required: false,
52
- defaultValue: currentSetting,
53
- options: {
54
- options: [
55
- { label: 'Disabled', value: 'disabled' },
56
- { label: 'Editable', value: 'enabled' },
57
- { label: 'Locked', value: 'locked' },
58
- ],
59
- },
60
- });
61
- });
62
- return props;
63
- }
64
- catch (error) {
65
- return {};
66
- }
67
- }),
68
- }),
69
- },
70
- run(_a) {
71
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
72
- const questionId = propsValue.questionId.split('-')[0];
73
- // First, get the current question details
74
- const card = yield (0, common_1.queryMetabaseApi)({ endpoint: `card/${questionId}`, method: pieces_common_1.HttpMethod.GET }, auth);
75
- const parameters = card['parameters'] || [];
76
- const updatePayload = Object.assign(Object.assign({}, card), { enable_embedding: propsValue.enableEmbedding });
77
- // If parameter settings are provided, update the parameters
78
- // Create embedding_params object if parameter settings are provided
79
- if (propsValue.parameterSettings && parameters.length > 0) {
80
- const embeddingParams = {};
81
- parameters.forEach((param) => {
82
- var _a;
83
- const paramSetting = (_a = propsValue.parameterSettings) === null || _a === void 0 ? void 0 : _a[param.slug];
84
- if (paramSetting) {
85
- embeddingParams[param.slug] = paramSetting;
86
- }
87
- else {
88
- embeddingParams[param.slug] = 'disabled';
89
- }
90
- });
91
- updatePayload.embedding_params = embeddingParams;
92
- }
93
- // Update the card with embedding settings
94
- const response = yield (0, common_1.queryMetabaseApi)({
95
- endpoint: `card/${questionId}`,
96
- method: pieces_common_1.HttpMethod.PUT,
97
- body: updatePayload,
98
- }, auth);
99
- if (response.error) {
100
- throw new Error(response.error);
101
- }
102
- return {
103
- success: true,
104
- message: propsValue.enableEmbedding
105
- ? 'Question embedding has been enabled successfully'
106
- : 'Question embedding has been disabled successfully',
107
- embeddingParams: propsValue.enableEmbedding
108
- ? updatePayload.embedding_params
109
- : {},
110
- };
111
- });
112
- },
113
- });
114
- //# 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,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;YACjC,IAAI,EAAE,gBAAY;YAClB,WAAW,EACT,6DAA6D;YAC/D,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,CAAC,YAAY,EAAE,iBAAiB,CAAC;YAC7C,KAAK,EAAE,KAA8C,EAAE,oDAAzC,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE;gBACjD,IAAI,CAAC,UAAU,IAAI,CAAC,eAAe,IAAI,CAAC,IAAI,EAAE,CAAC;o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;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;;;;;;;;;;EA0HhC,CAAC"}
@@ -1,110 +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
- props: {
16
- dashboardId: pieces_framework_1.Property.ShortText({
17
- displayName: 'Metabase Dashboard ID',
18
- required: true,
19
- }),
20
- parameters: pieces_framework_1.Property.Object({
21
- displayName: 'Parameters (slug name -> value)',
22
- description: 'Dashboard parameters to apply to all questions',
23
- required: false,
24
- }),
25
- },
26
- run(_a) {
27
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
28
- const dashboardId = propsValue.dashboardId.split('-')[0];
29
- const dashboardData = yield (0, common_1.queryMetabaseApi)({ endpoint: `dashboard/${dashboardId}`, method: pieces_common_1.HttpMethod.GET }, auth);
30
- if (dashboardData.error) {
31
- throw new Error(`Error fetching dashboard: ${dashboardData.error}`);
32
- }
33
- const dashboardParameters = dashboardData.parameters || [];
34
- const result = {
35
- dashboard_name: dashboardData.name || 'Unknown Dashboard',
36
- available_parameters: dashboardParameters.map((param) => {
37
- var _a;
38
- return ({
39
- id: param.id,
40
- name: param.name || 'Unknown',
41
- slug: param.slug || '',
42
- type: param.type || '',
43
- possible_values: ((_a = param.values_source_config) === null || _a === void 0 ? void 0 : _a.values) || [],
44
- });
45
- }),
46
- cards_results: {},
47
- };
48
- // Execute each card and collect results
49
- for (const dashcard of dashboardData.dashcards || []) {
50
- const cardId = dashcard.card_id;
51
- const dashcardId = dashcard.id;
52
- if (!cardId)
53
- continue;
54
- let cardName = 'Unknown';
55
- if (dashcard.card && typeof dashcard.card === 'object') {
56
- cardName = dashcard.card.name || `Card ${cardId}`;
57
- }
58
- const cardParameters = [];
59
- // Map dashboard parameters to card parameters using parameter_mappings
60
- if (propsValue.parameters && dashcard.parameter_mappings) {
61
- for (const mapping of dashcard.parameter_mappings) {
62
- const paramId = mapping.parameter_id;
63
- // Find corresponding dashboard parameter
64
- const dashParam = dashboardParameters.find((p) => p.id === paramId);
65
- if (dashParam &&
66
- dashParam.slug &&
67
- propsValue.parameters[dashParam.slug] !== undefined) {
68
- cardParameters.push({
69
- id: paramId,
70
- target: mapping.target,
71
- type: dashParam.type,
72
- value: propsValue.parameters[dashParam.slug],
73
- });
74
- }
75
- }
76
- }
77
- try {
78
- const cardResult = yield (0, common_1.queryMetabaseApi)({
79
- endpoint: `dashboard/${dashboardId}/dashcard/${dashcardId}/card/${cardId}/query/json`,
80
- method: pieces_common_1.HttpMethod.POST,
81
- body: {
82
- parameters: cardParameters,
83
- },
84
- }, auth);
85
- const cardIdStr = String(cardId);
86
- result.cards_results[cardIdStr] = {
87
- name: cardName,
88
- data: cardResult,
89
- };
90
- }
91
- catch (error) {
92
- let errorMessage = 'Unknown error';
93
- if (error &&
94
- typeof error === 'object' &&
95
- 'message' in error &&
96
- typeof error.message === 'string') {
97
- errorMessage = error.message;
98
- }
99
- const cardIdStr = String(cardId);
100
- result.cards_results[cardIdStr] = {
101
- name: cardName,
102
- error: `Failed to execute: ${errorMessage}`,
103
- };
104
- }
105
- }
106
- return result;
107
- });
108
- },
109
- });
110
- //# 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,KAAK,EAAE;QACL,WAAW,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC9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AgB,EACvC;wBACE,QAAQ,EAAE,aAAa,WAAW,aAAa,UAAU,SAAS,MAAM,aAAa;wBACrF,MAAM,EAAE,0BAAU,CAAC,IAAI;wBACvB,IAAI,EAAE;4BACJ,UAAU,EAAE,cAAc;yBAC3B;qBACF,EACD,IAAI,CACL,CAAC;oBAEF,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;oBACjC,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,GAAG;wBAChC,IAAI,EAAE,QAAQ;wBACd,IAAI,EAAE,UAAU;qBACjB,CAAC;gBACJ,CAAC;gBAAC,OAAO,KAAc,EAAE,CAAC;oBACxB,IAAI,YAAY,GAAG,eAAe,CAAC;oBAEnC,IACE,KAAK;wBACL,OAAO,KAAK,KAAK,QAAQ;wBACzB,SAAS,IAAI,KAAK;wBAClB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EACjC,CAAC;wBACD,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC;oBAC/B,CAAC;oBAED,MAAM,SAAS,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;;;;;;;;;;;;EAiI3B,CAAC"}
@@ -1,124 +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
- 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
- waitTime: pieces_framework_1.Property.Number({
29
- displayName: 'Wait Time (seconds)',
30
- description: 'How long to wait for the graph to render completely in seconds',
31
- required: true,
32
- defaultValue: 5,
33
- }),
34
- },
35
- run(_a) {
36
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue, files }) {
37
- if ('embeddingKey' in auth.props && !auth.props.embeddingKey)
38
- return 'An embedding key is needed.';
39
- if (propsValue.waitTime <= 0)
40
- return 'The wait time needs to be superior to 0';
41
- const questionId = propsValue.questionId.split('-')[0];
42
- const numericQuestionId = parseInt(questionId);
43
- const payload = {
44
- resource: { question: numericQuestionId },
45
- params: propsValue.parameters,
46
- exp: Math.round(Date.now() / 1000) + 10 * 60,
47
- };
48
- // @ts-expect-error we expect an embedding key if the user can use this action.
49
- const token = jsonwebtoken_1.default.sign(payload, auth.props.embeddingKey);
50
- const graphName = propsValue.graphName
51
- ? propsValue.graphName + '.png'
52
- : `metabase_question_${questionId}.png`;
53
- const iframeUrl = auth.props.baseUrl +
54
- '/embed/question/' +
55
- token +
56
- '#bordered=true&titled=true';
57
- const browser = yield playwright_1.chromium.launch({
58
- headless: true,
59
- chromiumSandbox: false,
60
- executablePath: '/usr/bin/chromium',
61
- });
62
- try {
63
- const context = yield browser.newContext({
64
- viewport: {
65
- width: 1600,
66
- height: 1200,
67
- },
68
- deviceScaleFactor: 2,
69
- });
70
- const page = yield context.newPage();
71
- const response = yield page.goto(iframeUrl, {
72
- waitUntil: 'networkidle',
73
- timeout: 30000,
74
- });
75
- if (!response || !response.ok()) {
76
- throw new Error(`Page load failed with status: ${response ? response.status() : 400}`);
77
- }
78
- // we wait so the graph can load
79
- yield page.waitForTimeout(propsValue.waitTime * 1000);
80
- const mainElement = yield page.$('main');
81
- let screenshotBuffer;
82
- if (mainElement) {
83
- screenshotBuffer = yield mainElement.screenshot({
84
- path: graphName,
85
- type: 'png',
86
- });
87
- }
88
- else {
89
- screenshotBuffer = yield page.screenshot({
90
- path: graphName,
91
- type: 'png',
92
- clip: {
93
- x: 0,
94
- y: 0,
95
- width: 1600,
96
- height: 1120, // so it doesn't screenshot the metabase banner
97
- },
98
- });
99
- }
100
- const fileUrl = yield files.write({
101
- fileName: graphName,
102
- data: screenshotBuffer,
103
- });
104
- return {
105
- file: {
106
- filename: graphName,
107
- base64Content: screenshotBuffer.toString('base64'),
108
- download: fileUrl,
109
- },
110
- iframeUrl,
111
- };
112
- }
113
- catch (error) {
114
- console.error('Please verify that either your embedding key and question id are valid or that the question is embedded and published.');
115
- console.error('Error capturing Metabase chart:', error);
116
- throw error;
117
- }
118
- finally {
119
- yield browser.close();
120
- }
121
- });
122
- },
123
- });
124
- //# 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,gBAAY;IAClB,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,+BAA+B;IAC5C,WAAW,EAAE,2DAA2D;IACxE,KAAK,EAAE;QACL,UAAU,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC7B,WAAW,EAAE,sBAAsB;YACnC,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,UAAU,EAAE,2BAAQ,CAAC,MAAM,CAAC;YAC1B,WAAW,EAAE,iCAAiC;YAC9C,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC5B,WAAW,EAAE,+CAA+C;YAC5D,QAAQ,EAAE,KAAK;SAChB,CAAC;QACF,QAAQ,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACxB,WAAW,EAAE,qBAAqB;YAClC,WAAW,EACT,gEAAgE;YAClE,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,CAAC;SAChB,CAAC;KACH;IACK,GAAG;qEAAC,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE;YACnC,IAAI,cAAc,IAAI,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY;gBAC1D,OAAO,6BAA6B,CAAC;YAEvC,IAAI,UAAU,CAAC,QAAQ,IAAI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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,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;;;;;;;;;EA0ChC,CAAC"}
@@ -1,46 +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
- props: {
16
- questionId: pieces_framework_1.Property.ShortText({
17
- displayName: 'Metabase question ID',
18
- required: true,
19
- }),
20
- },
21
- run(_a) {
22
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue, files }) {
23
- const questionId = propsValue.questionId.split('-')[0];
24
- const response = yield (0, common_1.queryMetabaseApi)({
25
- endpoint: `pulse/preview_card_png/${questionId}`,
26
- method: pieces_common_1.HttpMethod.GET,
27
- headers: {
28
- Accept: 'image/png',
29
- },
30
- responseType: 'arraybuffer',
31
- }, auth);
32
- if (response.error) {
33
- throw new Error(response.error);
34
- }
35
- const fileUrl = yield files.write({
36
- fileName: `metabase_question_${questionId}.png`,
37
- data: Buffer.from(response, 'base64'),
38
- });
39
- return {
40
- fileName: `metabase_question_${questionId}.png`,
41
- file: fileUrl,
42
- };
43
- });
44
- },
45
- });
46
- //# 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,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;;;;;;;;;;EAwDtB,CAAC"}
@@ -1,58 +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
- 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
- },
25
- run(_a) {
26
- return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth, propsValue }) {
27
- const questionId = propsValue.questionId.split('-')[0];
28
- const card = yield (0, common_1.queryMetabaseApi)({ endpoint: `card/${questionId}`, method: pieces_common_1.HttpMethod.GET }, auth);
29
- const parameters = card['parameters'];
30
- const response = yield (0, common_1.queryMetabaseApi)({
31
- endpoint: `card/${questionId}/query`,
32
- method: pieces_common_1.HttpMethod.POST,
33
- body: {
34
- collection_preview: false,
35
- ignore_cache: false,
36
- parameters: parameters
37
- .filter((param) => propsValue.parameters &&
38
- propsValue.parameters[param.slug] !== undefined)
39
- .map((param) => {
40
- return {
41
- id: param.id,
42
- target: param.target,
43
- type: param.type,
44
- value: propsValue.parameters && propsValue.parameters[param.slug],
45
- };
46
- }),
47
- },
48
- }, auth);
49
- if (response.error) {
50
- throw new Error(response.error);
51
- }
52
- else {
53
- return response;
54
- }
55
- });
56
- },
57
- });
58
- //# sourceMappingURL=get-question.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-question.js","sourceRoot":"","sources":["../../../../src/lib/actions/get-question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CAAC,KAAK,EAAE,EAAE;wBACb,OAAO;4BACL,EAAE,EAAE,KAAK,CAAC,EAAE;4BACZ,MAAM,EAAE,KAAK,CAAC,MAAM;4BACpB,IAAI,EAAE,KAAK,CAAC,IAAI;4BAChB,KAAK,EACH,UAAU,CAAC,UAAU,IAAI,UAAU,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC;yBAC7D,CAAC;oBACJ,CAAC,CAAC;iBACL;aACF,EACD,IAAI,CACL,CAAC;YACF,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YAClC,CAAC;iBAAM,CAAC;gBACN,OAAO,QAAQ,CAAC;YAClB,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC"}
@@ -1,12 +0,0 @@
1
- import { HttpHeaders, HttpMethod, QueryParams } from '@activepieces/pieces-common';
2
- import { AppConnectionValueForAuthProperty } from '@activepieces/pieces-framework';
3
- import { metabaseAuth } from '..';
4
- export declare function queryMetabaseApi(params: {
5
- endpoint: string;
6
- method: HttpMethod;
7
- queryParams?: QueryParams;
8
- headers?: HttpHeaders;
9
- body?: object;
10
- responseType?: 'arraybuffer' | 'json' | 'blob' | 'text';
11
- }, auth: AppConnectionValueForAuthProperty<typeof metabaseAuth>): Promise<any>;
12
- //# sourceMappingURL=common.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/lib/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EACX,UAAU,EAEV,WAAW,EACZ,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,iCAAiC,EAGlC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAElC,wBAAsB,gBAAgB,CACpC,MAAM,EAAE;IACN,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;IACnB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;CACzD,EACD,IAAI,EAAE,iCAAiC,CAAC,OAAO,YAAY,CAAC,gBAgB7D"}