diff --git a/components/youtube_analytics_api/actions/common/reports-query.mjs b/components/youtube_analytics_api/actions/common/reports-query.mjs index 542f55179389c..71399ed6eb085 100644 --- a/components/youtube_analytics_api/actions/common/reports-query.mjs +++ b/components/youtube_analytics_api/actions/common/reports-query.mjs @@ -1,18 +1,10 @@ import app from "../../youtube_analytics_api.app.mjs"; import constants from "../../common/constants.mjs"; import utils from "../../common/utils.mjs"; -import propsFragments from "../../common/props-fragments.mjs"; export default { props: { app, - reloader: { - type: "boolean", - label: "Hidden Reloader", - description: "This prop is used to reload the props when the step gets created.", - hidden: true, - reloadProps: true, - }, startDate: { propDefinition: [ app, @@ -43,47 +35,57 @@ export default { "maxResults", ], }, + idType: { + type: "string", + label: "ID Type", + description: + "The type of ID to use for the query. This can be either `My Channel`, `Channel ID`, or `Content Owner`.", + options: Object.values(constants.ID_TYPE), + default: constants.ID_TYPE.CHANNEL.value, + reloadProps: true, + }, + ids: { + type: "string", + label: "Channel ID OR Content Owner Name", + description: + "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.", + optional: true, + hidden: true, + }, }, methods: { getIdsProps() { const { idType } = this; - if (idType === constants.ID_TYPE.CHANNEL.value) { - return { - idType: propsFragments.idType, - }; - } - if (idType === constants.ID_TYPE.CONTENT_OWNER.value) { return { - idType: propsFragments.idType, ids: { type: "string", label: "Content Owner Name", - description: "The content owner name for the user. Eg. `MyContentOwnerName`.", + description: + "The content owner name for the user. Eg. `MyContentOwnerName`.", + optional: false, + hidden: false, }, }; } - if (idType === constants.ID_TYPE.CHANNEL_ID.value) { return { - idType: propsFragments.idType, ids: { type: "string", label: "Channel ID", - 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).", + 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).", + optional: false, + hidden: false, }, }; } - - return { - idType: propsFragments.idType, - }; + return {}; }, getIdsParam() { const { - idType, - ids, + idType, ids, } = this; if (idType === constants.ID_TYPE.CHANNEL.value) { return "channel==MINE"; @@ -104,14 +106,16 @@ export default { } return utils.arrayToCommaSeparatedList( - Object.entries(filtersObj) - .reduce((acc, [ + Object.entries(filtersObj).reduce( + (acc, [ key, val, ]) => [ ...acc, `${key}==${val}`, - ], []), + ], + [], + ), ";", ); }, diff --git a/components/youtube_analytics_api/actions/get-video-metrics/get-video-metrics.mjs b/components/youtube_analytics_api/actions/get-video-metrics/get-video-metrics.mjs index e8a66998f4cc7..417a18c21a938 100644 --- a/components/youtube_analytics_api/actions/get-video-metrics/get-video-metrics.mjs +++ b/components/youtube_analytics_api/actions/get-video-metrics/get-video-metrics.mjs @@ -6,15 +6,17 @@ export default { ...common, key: "youtube_analytics_api-get-video-metrics", name: "Get Video Metrics", - description: "Retrieve detailed analytics for a specific video. [See the documentation](https://developers.google.com/youtube/analytics/reference/reports/query)", - version: "0.0.1", + description: + "Retrieve detailed analytics for a specific video. [See the documentation](https://developers.google.com/youtube/analytics/reference/reports/query)", + version: "0.0.2", type: "action", props: { ...common.props, videoId: { type: "string", label: "Video ID", - description: "The ID of the video for which you want to retrieve metrics. Eg. `pd1FJh59zxQ`.", + description: + "The ID of the video for which you want to retrieve metrics. Eg. `pd1FJh59zxQ`.", }, metrics: propsFragments.metrics, }, diff --git a/components/youtube_analytics_api/actions/list-channel-reports/list-channel-reports.mjs b/components/youtube_analytics_api/actions/list-channel-reports/list-channel-reports.mjs index 41eccc38e1d25..9bbbb93f7668e 100644 --- a/components/youtube_analytics_api/actions/list-channel-reports/list-channel-reports.mjs +++ b/components/youtube_analytics_api/actions/list-channel-reports/list-channel-reports.mjs @@ -7,13 +7,13 @@ export default { ...common, key: "youtube_analytics_api-list-channel-reports", name: "List Channel Reports", - 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)", - version: "0.0.1", + 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)", + version: "0.0.2", type: "action", additionalProps() { const { - getIdsProps, - getReportTypeProps, + getIdsProps, getReportTypeProps, } = this; return { @@ -26,16 +26,19 @@ export default { getReportTypeProps() { const { channelReportType } = this; const { - VIDEO_BASIC_USER_ACTIVITY_STATS, - PLAYLIST_BASIC_STATS, - } = constants.CHANNEL_REPORT_TYPE; + VIDEO_BASIC_USER_ACTIVITY_STATS, PLAYLIST_BASIC_STATS, + } = + constants.CHANNEL_REPORT_TYPE; if (channelReportType === VIDEO_BASIC_USER_ACTIVITY_STATS.value) { - const supportedFilters = VIDEO_BASIC_USER_ACTIVITY_STATS.metadata.filters - .reduce((acc, filter) => ({ - ...acc, - [filter]: "", - }), {}); + const supportedFilters = + VIDEO_BASIC_USER_ACTIVITY_STATS.metadata.filters.reduce( + (acc, filter) => ({ + ...acc, + [filter]: "", + }), + {}, + ); return { channelReportType: propsFragments.channelReportType, @@ -51,11 +54,13 @@ export default { } if (channelReportType === PLAYLIST_BASIC_STATS.value) { - const supportedFilters = PLAYLIST_BASIC_STATS.metadata.filters - .reduce((acc, filter) => ({ + const supportedFilters = PLAYLIST_BASIC_STATS.metadata.filters.reduce( + (acc, filter) => ({ ...acc, [filter]: "", - }), {}); + }), + {}, + ); return { channelReportType: propsFragments.channelReportType, diff --git a/components/youtube_analytics_api/actions/query-custom-analytics/query-custom-analytics.mjs b/components/youtube_analytics_api/actions/query-custom-analytics/query-custom-analytics.mjs index 55c8765cd3d4a..506e5ffde08e1 100644 --- a/components/youtube_analytics_api/actions/query-custom-analytics/query-custom-analytics.mjs +++ b/components/youtube_analytics_api/actions/query-custom-analytics/query-custom-analytics.mjs @@ -6,8 +6,9 @@ export default { ...common, key: "youtube_analytics_api-query-custom-analytics", name: "Query Custom Analytics", - 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).", - version: "0.0.1", + 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).", + version: "0.0.2", type: "action", props: { ...common.props, diff --git a/components/youtube_analytics_api/common/props-fragments.mjs b/components/youtube_analytics_api/common/props-fragments.mjs index 098547f79d376..79f42114cecae 100644 --- a/components/youtube_analytics_api/common/props-fragments.mjs +++ b/components/youtube_analytics_api/common/props-fragments.mjs @@ -1,37 +1,34 @@ import constants from "./constants.mjs"; export default { - idType: { - type: "string", - label: "ID Type", - description: "The type of ID to use for the query. This can be either `My Channel`, `Channel ID`, or `Content Owner`.", - options: Object.values(constants.ID_TYPE), - default: constants.ID_TYPE.CHANNEL.value, - reloadProps: true, - }, channelReportType: { type: "string", label: "Channel Report Type", - description: "The type of report to fetch for the specified YouTube Channel. This selects default dimensions, metrics and filters.", - options: Object.values(constants.CHANNEL_REPORT_TYPE) - .map(({ + description: + "The type of report to fetch for the specified YouTube Channel. This selects default dimensions, metrics and filters.", + options: Object.values(constants.CHANNEL_REPORT_TYPE).map( + ({ // eslint-disable-next-line no-unused-vars metadata, ...rest - }) => rest), - default: constants.CHANNEL_REPORT_TYPE.VIDEO_BASIC_USER_ACTIVITY_STATS.value, + }) => rest, + ), + default: + constants.CHANNEL_REPORT_TYPE.VIDEO_BASIC_USER_ACTIVITY_STATS.value, reloadProps: true, }, metrics: { type: "string[]", label: "Metrics", - 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.).", + 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.).", options: Object.values(constants.METRIC), }, filters: { type: "object", label: "Filters", - 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.", + 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.", optional: true, }, }; diff --git a/components/youtube_analytics_api/package.json b/components/youtube_analytics_api/package.json index c19490cbb9ffd..c0a0ae34ec7b8 100644 --- a/components/youtube_analytics_api/package.json +++ b/components/youtube_analytics_api/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/youtube_analytics_api", - "version": "0.0.1", + "version": "0.0.2", "description": "Pipedream Youtube Analytics API Components", "main": "youtube_analytics_api.app.mjs", "keywords": [