Skip to content

Commit 56b5ab7

Browse files
danhsiungjcortes
andauthored
Make idType a standard prop in the base props, so the default case (#16409)
* Make idType a standard prop in the base props, so the default case (where the `ids` prop is not needed) works without calling reloadProps * update package version * fix: resolve linting errors in youtube analytics API components * one more change to make ids also available as a base prop * fix eslint * pnpm-lock --------- Co-authored-by: Jorge Cortes <jacortesmahmud@gmail.com>
1 parent e24d7cc commit 56b5ab7

File tree

6 files changed

+73
-64
lines changed

6 files changed

+73
-64
lines changed

components/youtube_analytics_api/actions/common/reports-query.mjs

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
11
import app from "../../youtube_analytics_api.app.mjs";
22
import constants from "../../common/constants.mjs";
33
import utils from "../../common/utils.mjs";
4-
import propsFragments from "../../common/props-fragments.mjs";
54

65
export default {
76
props: {
87
app,
9-
reloader: {
10-
type: "boolean",
11-
label: "Hidden Reloader",
12-
description: "This prop is used to reload the props when the step gets created.",
13-
hidden: true,
14-
reloadProps: true,
15-
},
168
startDate: {
179
propDefinition: [
1810
app,
@@ -43,47 +35,57 @@ export default {
4335
"maxResults",
4436
],
4537
},
38+
idType: {
39+
type: "string",
40+
label: "ID Type",
41+
description:
42+
"The type of ID to use for the query. This can be either `My Channel`, `Channel ID`, or `Content Owner`.",
43+
options: Object.values(constants.ID_TYPE),
44+
default: constants.ID_TYPE.CHANNEL.value,
45+
reloadProps: true,
46+
},
47+
ids: {
48+
type: "string",
49+
label: "Channel ID OR Content Owner Name",
50+
description:
51+
"The use of this property depends on the value of the `idType` prop. If `idType` is set to `MINE`, then this property is unused. If `idType` is set to `channelId`, then this property is used to specify the Channel ID for this action. If `idType` is set to `contentOwner`, then this property is used to specify the Content Owner Name for this action.",
52+
optional: true,
53+
hidden: true,
54+
},
4655
},
4756
methods: {
4857
getIdsProps() {
4958
const { idType } = this;
5059

51-
if (idType === constants.ID_TYPE.CHANNEL.value) {
52-
return {
53-
idType: propsFragments.idType,
54-
};
55-
}
56-
5760
if (idType === constants.ID_TYPE.CONTENT_OWNER.value) {
5861
return {
59-
idType: propsFragments.idType,
6062
ids: {
6163
type: "string",
6264
label: "Content Owner Name",
63-
description: "The content owner name for the user. Eg. `MyContentOwnerName`.",
65+
description:
66+
"The content owner name for the user. Eg. `MyContentOwnerName`.",
67+
optional: false,
68+
hidden: false,
6469
},
6570
};
6671
}
67-
6872
if (idType === constants.ID_TYPE.CHANNEL_ID.value) {
6973
return {
70-
idType: propsFragments.idType,
7174
ids: {
7275
type: "string",
7376
label: "Channel ID",
74-
description: "The channel ID for the user. Eg. `UC_x5XG1OV2P6uZZ5FSM9Ttw`. You can find the ID using the [YouTube Data API](https://developers.google.com/youtube/v3/docs/channels/list).",
77+
description:
78+
"The channel ID for the user. Eg. `UC_x5XG1OV2P6uZZ5FSM9Ttw`. You can find the ID using the [YouTube Data API](https://developers.google.com/youtube/v3/docs/channels/list).",
79+
optional: false,
80+
hidden: false,
7581
},
7682
};
7783
}
78-
79-
return {
80-
idType: propsFragments.idType,
81-
};
84+
return {};
8285
},
8386
getIdsParam() {
8487
const {
85-
idType,
86-
ids,
88+
idType, ids,
8789
} = this;
8890
if (idType === constants.ID_TYPE.CHANNEL.value) {
8991
return "channel==MINE";
@@ -104,14 +106,16 @@ export default {
104106
}
105107

106108
return utils.arrayToCommaSeparatedList(
107-
Object.entries(filtersObj)
108-
.reduce((acc, [
109+
Object.entries(filtersObj).reduce(
110+
(acc, [
109111
key,
110112
val,
111113
]) => [
112114
...acc,
113115
`${key}==${val}`,
114-
], []),
116+
],
117+
[],
118+
),
115119
";",
116120
);
117121
},

components/youtube_analytics_api/actions/get-video-metrics/get-video-metrics.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ export default {
66
...common,
77
key: "youtube_analytics_api-get-video-metrics",
88
name: "Get Video Metrics",
9-
description: "Retrieve detailed analytics for a specific video. [See the documentation](https://developers.google.com/youtube/analytics/reference/reports/query)",
10-
version: "0.0.1",
9+
description:
10+
"Retrieve detailed analytics for a specific video. [See the documentation](https://developers.google.com/youtube/analytics/reference/reports/query)",
11+
version: "0.0.2",
1112
type: "action",
1213
props: {
1314
...common.props,
1415
videoId: {
1516
type: "string",
1617
label: "Video ID",
17-
description: "The ID of the video for which you want to retrieve metrics. Eg. `pd1FJh59zxQ`.",
18+
description:
19+
"The ID of the video for which you want to retrieve metrics. Eg. `pd1FJh59zxQ`.",
1820
},
1921
metrics: propsFragments.metrics,
2022
},

components/youtube_analytics_api/actions/list-channel-reports/list-channel-reports.mjs

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ export default {
77
...common,
88
key: "youtube_analytics_api-list-channel-reports",
99
name: "List Channel Reports",
10-
description: "Fetch summary analytics reports for a specified youtube channel. Optional filters include date range and report type. [See the documentation](https://developers.google.com/youtube/analytics/reference/reports/query)",
11-
version: "0.0.1",
10+
description:
11+
"Fetch summary analytics reports for a specified youtube channel. Optional filters include date range and report type. [See the documentation](https://developers.google.com/youtube/analytics/reference/reports/query)",
12+
version: "0.0.2",
1213
type: "action",
1314
additionalProps() {
1415
const {
15-
getIdsProps,
16-
getReportTypeProps,
16+
getIdsProps, getReportTypeProps,
1717
} = this;
1818

1919
return {
@@ -26,16 +26,19 @@ export default {
2626
getReportTypeProps() {
2727
const { channelReportType } = this;
2828
const {
29-
VIDEO_BASIC_USER_ACTIVITY_STATS,
30-
PLAYLIST_BASIC_STATS,
31-
} = constants.CHANNEL_REPORT_TYPE;
29+
VIDEO_BASIC_USER_ACTIVITY_STATS, PLAYLIST_BASIC_STATS,
30+
} =
31+
constants.CHANNEL_REPORT_TYPE;
3232

3333
if (channelReportType === VIDEO_BASIC_USER_ACTIVITY_STATS.value) {
34-
const supportedFilters = VIDEO_BASIC_USER_ACTIVITY_STATS.metadata.filters
35-
.reduce((acc, filter) => ({
36-
...acc,
37-
[filter]: "",
38-
}), {});
34+
const supportedFilters =
35+
VIDEO_BASIC_USER_ACTIVITY_STATS.metadata.filters.reduce(
36+
(acc, filter) => ({
37+
...acc,
38+
[filter]: "",
39+
}),
40+
{},
41+
);
3942

4043
return {
4144
channelReportType: propsFragments.channelReportType,
@@ -51,11 +54,13 @@ export default {
5154
}
5255

5356
if (channelReportType === PLAYLIST_BASIC_STATS.value) {
54-
const supportedFilters = PLAYLIST_BASIC_STATS.metadata.filters
55-
.reduce((acc, filter) => ({
57+
const supportedFilters = PLAYLIST_BASIC_STATS.metadata.filters.reduce(
58+
(acc, filter) => ({
5659
...acc,
5760
[filter]: "",
58-
}), {});
61+
}),
62+
{},
63+
);
5964

6065
return {
6166
channelReportType: propsFragments.channelReportType,

components/youtube_analytics_api/actions/query-custom-analytics/query-custom-analytics.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ export default {
66
...common,
77
key: "youtube_analytics_api-query-custom-analytics",
88
name: "Query Custom Analytics",
9-
description: "Execute a custom analytics query using specified metrics, dimensions, filters, and date ranges. Requires query parameters to configure. [See the documentation](https://developers.google.com/youtube/analytics/reference/reports/query).",
10-
version: "0.0.1",
9+
description:
10+
"Execute a custom analytics query using specified metrics, dimensions, filters, and date ranges. Requires query parameters to configure. [See the documentation](https://developers.google.com/youtube/analytics/reference/reports/query).",
11+
version: "0.0.2",
1112
type: "action",
1213
props: {
1314
...common.props,
Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
import constants from "./constants.mjs";
22

33
export default {
4-
idType: {
5-
type: "string",
6-
label: "ID Type",
7-
description: "The type of ID to use for the query. This can be either `My Channel`, `Channel ID`, or `Content Owner`.",
8-
options: Object.values(constants.ID_TYPE),
9-
default: constants.ID_TYPE.CHANNEL.value,
10-
reloadProps: true,
11-
},
124
channelReportType: {
135
type: "string",
146
label: "Channel Report Type",
15-
description: "The type of report to fetch for the specified YouTube Channel. This selects default dimensions, metrics and filters.",
16-
options: Object.values(constants.CHANNEL_REPORT_TYPE)
17-
.map(({
7+
description:
8+
"The type of report to fetch for the specified YouTube Channel. This selects default dimensions, metrics and filters.",
9+
options: Object.values(constants.CHANNEL_REPORT_TYPE).map(
10+
({
1811
// eslint-disable-next-line no-unused-vars
1912
metadata,
2013
...rest
21-
}) => rest),
22-
default: constants.CHANNEL_REPORT_TYPE.VIDEO_BASIC_USER_ACTIVITY_STATS.value,
14+
}) => rest,
15+
),
16+
default:
17+
constants.CHANNEL_REPORT_TYPE.VIDEO_BASIC_USER_ACTIVITY_STATS.value,
2318
reloadProps: true,
2419
},
2520
metrics: {
2621
type: "string[]",
2722
label: "Metrics",
28-
description: "Metrics, such as `views` or `likes`, `dislikes`. See the documentation for [channel reports](https://developers.google.com/youtube/analytics/channel_reports) or [content owner reports](https://developers.google.com/youtube/analytics/content_owner_reports) for a list of the reports that you can retrieve and the metrics available in each report. (The [Metrics](https://developers.google.com/youtube/reporting#metrics) document contains definitions for all of the metrics.).",
23+
description:
24+
"Metrics, such as `views` or `likes`, `dislikes`. See the documentation for [channel reports](https://developers.google.com/youtube/analytics/channel_reports) or [content owner reports](https://developers.google.com/youtube/analytics/content_owner_reports) for a list of the reports that you can retrieve and the metrics available in each report. (The [Metrics](https://developers.google.com/youtube/reporting#metrics) document contains definitions for all of the metrics.).",
2925
options: Object.values(constants.METRIC),
3026
},
3127
filters: {
3228
type: "object",
3329
label: "Filters",
34-
description: "A list of filters that should be applied when retrieving YouTube Analytics data. The documentation for [channel reports](https://developers.google.com/youtube/analytics/channel_reports) and [content owner reports](https://developers.google.com/youtube/analytics/content_owner_reports) identifies the dimensions that can be used to filter each report, and the [Dimensions](https://developers.google.com/youtube/analytics/dimsmets/dims) document defines those dimensions.\n\nIf a request uses multiple filters the returned result table will satisfy both filters. For example, a filters parameter value of `{\"video\":\"dMH0bHeiRNg\",\"country\":\"IT\"}` restricts the result set to include data for the given video in Italy.\n\nSpecifying multiple values for a filter\nThe API supports the ability to specify multiple values for the [video](https://developers.google.com/youtube/reporting#supported-reports), [playlist](https://developers.google.com/youtube/reporting#supported-reports), and [channel](https://developers.google.com/youtube/reporting#supported-reports) filters. To do so, specify a separated list of the video, playlist, or channel IDs for which the API response should be filtered. For example, a filters parameter value of `{\"video\":\"pd1FJh59zxQ,Zhawgd0REhA\",\"country\":\"IT\"}` restricts the result set to include data for the given videos in Italy. The parameter value can specify up to 500 IDs. For more details on the filters parameter, see the filters parameter in [Parameters](https://developers.google.com/youtube/analytics/reference/reports/query#Parameters) section.",
30+
description:
31+
"A list of filters that should be applied when retrieving YouTube Analytics data. The documentation for [channel reports](https://developers.google.com/youtube/analytics/channel_reports) and [content owner reports](https://developers.google.com/youtube/analytics/content_owner_reports) identifies the dimensions that can be used to filter each report, and the [Dimensions](https://developers.google.com/youtube/analytics/dimsmets/dims) document defines those dimensions.\n\nIf a request uses multiple filters the returned result table will satisfy both filters. For example, a filters parameter value of `{\"video\":\"dMH0bHeiRNg\",\"country\":\"IT\"}` restricts the result set to include data for the given video in Italy.\n\nSpecifying multiple values for a filter\nThe API supports the ability to specify multiple values for the [video](https://developers.google.com/youtube/reporting#supported-reports), [playlist](https://developers.google.com/youtube/reporting#supported-reports), and [channel](https://developers.google.com/youtube/reporting#supported-reports) filters. To do so, specify a separated list of the video, playlist, or channel IDs for which the API response should be filtered. For example, a filters parameter value of `{\"video\":\"pd1FJh59zxQ,Zhawgd0REhA\",\"country\":\"IT\"}` restricts the result set to include data for the given videos in Italy. The parameter value can specify up to 500 IDs. For more details on the filters parameter, see the filters parameter in [Parameters](https://developers.google.com/youtube/analytics/reference/reports/query#Parameters) section.",
3532
optional: true,
3633
},
3734
};

components/youtube_analytics_api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pipedream/youtube_analytics_api",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "Pipedream Youtube Analytics API Components",
55
"main": "youtube_analytics_api.app.mjs",
66
"keywords": [

0 commit comments

Comments
 (0)