From e518a69b587f50a9a13cd8c4951f17f7af43b9a5 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Thu, 2 Jul 2026 12:26:55 -0400 Subject: [PATCH 1/3] new actions --- .../get-reddit-post-transcript.mjs | 38 ++++++ .../actions/get-subreddit/get-subreddit.mjs | 38 ++++++ .../list-reddit-post-comments.mjs | 48 ++++++++ .../list-subreddit-posts.mjs | 55 +++++++++ components/social_fetch/common/constants.mjs | 16 +++ components/social_fetch/common/utils.mjs | 21 ++++ components/social_fetch/package.json | 2 +- components/social_fetch/social_fetch.app.mjs | 113 ++++++++++++++++++ 8 files changed, 330 insertions(+), 1 deletion(-) create mode 100644 components/social_fetch/actions/get-reddit-post-transcript/get-reddit-post-transcript.mjs create mode 100644 components/social_fetch/actions/get-subreddit/get-subreddit.mjs create mode 100644 components/social_fetch/actions/list-reddit-post-comments/list-reddit-post-comments.mjs create mode 100644 components/social_fetch/actions/list-subreddit-posts/list-subreddit-posts.mjs diff --git a/components/social_fetch/actions/get-reddit-post-transcript/get-reddit-post-transcript.mjs b/components/social_fetch/actions/get-reddit-post-transcript/get-reddit-post-transcript.mjs new file mode 100644 index 0000000000000..7fde33c58a040 --- /dev/null +++ b/components/social_fetch/actions/get-reddit-post-transcript/get-reddit-post-transcript.mjs @@ -0,0 +1,38 @@ +import app from "../../social_fetch.app.mjs"; + +export default { + key: "social_fetch-get-reddit-post-transcript", + name: "Get Reddit Post Transcript", + description: "Get the captions transcript for a Reddit video post. [See the documentation](https://app.socialfetch.dev/playground?path=/v1/reddit/posts/transcript&method=GET)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + app, + url: { + propDefinition: [ + app, + "redditPostUrl", + ], + }, + language: { + propDefinition: [ + app, + "language", + ], + }, + }, + async run({ $ }) { + const response = await this.app.getPostTranscript({ + $, + url: this.url, + language: this.language, + }); + $.export("$summary", "Successfully fetched post transcript"); + return response; + }, +}; diff --git a/components/social_fetch/actions/get-subreddit/get-subreddit.mjs b/components/social_fetch/actions/get-subreddit/get-subreddit.mjs new file mode 100644 index 0000000000000..00fca64410fcf --- /dev/null +++ b/components/social_fetch/actions/get-subreddit/get-subreddit.mjs @@ -0,0 +1,38 @@ +import app from "../../social_fetch.app.mjs"; + +export default { + key: "social_fetch-get-subreddit", + name: "Get Subreddit", + description: "Get details for a Reddit community. [See the documentation](https://app.socialfetch.dev/playground?path=/v1/reddit/subreddits&method=GET)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + app, + subreddit: { + propDefinition: [ + app, + "subreddit", + ], + }, + url: { + propDefinition: [ + app, + "subredditUrl", + ], + }, + }, + async run({ $ }) { + const response = await this.app.getSubreddit({ + $, + subreddit: this.subreddit, + url: this.url, + }); + $.export("$summary", "Successfully fetched subreddit details"); + return response; + }, +}; diff --git a/components/social_fetch/actions/list-reddit-post-comments/list-reddit-post-comments.mjs b/components/social_fetch/actions/list-reddit-post-comments/list-reddit-post-comments.mjs new file mode 100644 index 0000000000000..b8fafa12f69bb --- /dev/null +++ b/components/social_fetch/actions/list-reddit-post-comments/list-reddit-post-comments.mjs @@ -0,0 +1,48 @@ +import app from "../../social_fetch.app.mjs"; +import { truncateArrays } from "../../common/utils.mjs"; + +export default { + key: "social_fetch-list-reddit-post-comments", + name: "List Reddit Post Comments", + description: "Get comments on a Reddit post. [See the documentation](https://app.socialfetch.dev/playground?path=/v1/reddit/posts/comments&method=GET)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + app, + url: { + propDefinition: [ + app, + "redditPostUrl", + ], + }, + trim: { + propDefinition: [ + app, + "trim", + ], + }, + cursor: { + propDefinition: [ + app, + "cursor", + ], + }, + }, + async run({ $ }) { + const MAX_COMMENTS = 10; + const response = await this.app.listPostComments({ + $, + url: this.url, + trim: this.trim, + cursor: this.cursor, + }); + truncateArrays(response?.data, MAX_COMMENTS); + $.export("$summary", "Successfully listed post comments"); + return response; + }, +}; diff --git a/components/social_fetch/actions/list-subreddit-posts/list-subreddit-posts.mjs b/components/social_fetch/actions/list-subreddit-posts/list-subreddit-posts.mjs new file mode 100644 index 0000000000000..d77cf1392f8d0 --- /dev/null +++ b/components/social_fetch/actions/list-subreddit-posts/list-subreddit-posts.mjs @@ -0,0 +1,55 @@ +import app from "../../social_fetch.app.mjs"; +import { truncateArrays } from "../../common/utils.mjs"; + +export default { + key: "social_fetch-list-subreddit-posts", + name: "List Subreddit Posts", + description: "Get posts from a specific subreddit. [See the documentation](https://app.socialfetch.dev/playground?path=/v1/reddit/subreddits/%7Bsubreddit%7D/posts&method=GET)", + version: "0.0.1", + type: "action", + annotations: { + destructiveHint: false, + openWorldHint: true, + readOnlyHint: true, + }, + props: { + app, + subreddit: { + propDefinition: [ + app, + "subreddit", + ], + }, + sort: { + propDefinition: [ + app, + "sort", + ], + }, + timeframe: { + propDefinition: [ + app, + "timeframe", + ], + }, + cursor: { + propDefinition: [ + app, + "cursor", + ], + }, + }, + async run({ $ }) { + const MAX_POSTS = 10; + const response = await this.app.listSubredditPosts({ + $, + subreddit: this.subreddit, + sort: this.sort, + timeframe: this.timeframe, + cursor: this.cursor, + }); + truncateArrays(response?.data, MAX_POSTS); + $.export("$summary", "Successfully listed subreddit posts"); + return response; + }, +}; diff --git a/components/social_fetch/common/constants.mjs b/components/social_fetch/common/constants.mjs index 1ab6195e66860..9d9fa83a5b36f 100644 --- a/components/social_fetch/common/constants.mjs +++ b/components/social_fetch/common/constants.mjs @@ -40,6 +40,22 @@ export const TRANSCRIPT_PLATFORMS = [ "youtube", ]; +export const SUBREDDIT_POST_SORT_OPTIONS = [ + "best", + "hot", + "new", + "top", + "rising", +]; + +export const SUBREDDIT_POST_TIMEFRAME_OPTIONS = [ + "all", + "day", + "week", + "month", + "year", +]; + export const CONTENT_TYPE_OPTIONS = [ { label: "Videos", diff --git a/components/social_fetch/common/utils.mjs b/components/social_fetch/common/utils.mjs index 4f7b8f11704b1..91623e9b80891 100644 --- a/components/social_fetch/common/utils.mjs +++ b/components/social_fetch/common/utils.mjs @@ -1,3 +1,24 @@ +/** + * Truncate top-level arrays in a response `data` object to keep step exports + * manageable, flagging any array that was shortened. + * + * @param {Record | undefined} data + * @param {number} max + */ +export function truncateArrays(data, max) { + if (!data || typeof data !== "object") { + return data; + } + for (const key of Object.keys(data)) { + if (Array.isArray(data[key]) && data[key].length > max) { + const total = data[key].length; + data[key] = data[key].slice(0, max); + data._truncated = `${key} truncated to ${max} of ${total} items`; + } + } + return data; +} + /** * Recursively compare two objects and return a structured diff map. * diff --git a/components/social_fetch/package.json b/components/social_fetch/package.json index 0f5a4c2973264..e61a52d378c63 100644 --- a/components/social_fetch/package.json +++ b/components/social_fetch/package.json @@ -1,6 +1,6 @@ { "name": "@pipedream/social_fetch", - "version": "0.1.0", + "version": "0.2.0", "description": "Pipedream Social Fetch Components", "main": "social_fetch.app.mjs", "keywords": [ diff --git a/components/social_fetch/social_fetch.app.mjs b/components/social_fetch/social_fetch.app.mjs index 7f6b4f71ad8fc..2a3675bbf311d 100644 --- a/components/social_fetch/social_fetch.app.mjs +++ b/components/social_fetch/social_fetch.app.mjs @@ -5,6 +5,8 @@ import { LIST_PROFILE_POSTS_PLATFORMS, POST_PLATFORMS, PROFILE_PLATFORMS, + SUBREDDIT_POST_SORT_OPTIONS, + SUBREDDIT_POST_TIMEFRAME_OPTIONS, TRANSCRIPT_PLATFORMS, } from "./common/constants.mjs"; import { @@ -107,6 +109,53 @@ export default { description: "Pagination cursor from a previous response (`data.page.nextCursor`).", optional: true, }, + subreddit: { + type: "string", + label: "Subreddit", + description: + "Subreddit name, optional `r/` prefix, or Reddit subreddit URL (string). Must match Reddit's exact casing. E.g. `pics`, `r/pics`, or `https://www.reddit.com/r/pics`.", + }, + subredditUrl: { + type: "string", + label: "Subreddit URL", + description: + "Optional full subreddit URL (string, https://). E.g. `https://www.reddit.com/r/pics`.", + optional: true, + }, + sort: { + type: "string", + label: "Sort", + description: "Sort order for the returned posts (string).", + options: SUBREDDIT_POST_SORT_OPTIONS, + optional: true, + }, + timeframe: { + type: "string", + label: "Timeframe", + description: + "Timeframe used with time-based sort orders such as `top` (string).", + options: SUBREDDIT_POST_TIMEFRAME_OPTIONS, + optional: true, + }, + redditPostUrl: { + type: "string", + label: "Post URL", + description: + "Link to the Reddit post (string, https://). E.g. `https://www.reddit.com/r/pics/comments/abc123/title/`.", + }, + trim: { + type: "boolean", + label: "Trim", + description: "When enabled, requests a lighter response shape when available.", + optional: true, + }, + language: { + type: "string", + label: "Language", + description: + "Optional ISO 639-1 language code (two letters) to prefer when multiple caption tracks exist. E.g. `en`.", + optional: true, + }, }, methods: { /** @returns {Record} */ @@ -222,6 +271,70 @@ export default { ...opts, }); }, + /** @param {{ subreddit?: string; url?: string; [key: string]: unknown }} [args] */ + getSubreddit({ + subreddit, url, ...opts + } = {}) { + return this._makeRequest({ + path: "/v1/reddit/subreddits", + params: { + subreddit, + url, + }, + ...opts, + }); + }, + /** + * @param {{ subreddit?: string; sort?: string; timeframe?: string; + * cursor?: string; [key: string]: unknown }} [args] + */ + listSubredditPosts({ + subreddit, sort, timeframe, cursor, ...opts + } = {}) { + const value = subreddit?.trim(); + if (!value) { + throw new Error("Subreddit is required."); + } + return this._makeRequest({ + path: `/v1/reddit/subreddits/${encodeURIComponent(value)}/posts`, + params: { + sort, + timeframe, + cursor, + }, + ...opts, + }); + }, + /** + * @param {{ url?: string; cursor?: string; trim?: boolean; + * [key: string]: unknown }} [args] + */ + listPostComments({ + url, cursor, trim, ...opts + } = {}) { + return this._makeRequest({ + path: "/v1/reddit/posts/comments", + params: { + url, + cursor, + trim, + }, + ...opts, + }); + }, + /** @param {{ url?: string; language?: string; [key: string]: unknown }} [args] */ + getPostTranscript({ + url, language, ...opts + } = {}) { + return this._makeRequest({ + path: "/v1/reddit/posts/transcript", + params: { + url, + language, + }, + ...opts, + }); + }, /** * @param {string} platform * @param {string | undefined} handle From 8be94cf9dbaa851b06fe2446f45c9cbca0ba2fbe Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Thu, 2 Jul 2026 12:31:40 -0400 Subject: [PATCH 2/3] versions --- .../actions/get-credit-balance/get-credit-balance.mjs | 2 +- components/social_fetch/actions/get-post/get-post.mjs | 2 +- components/social_fetch/actions/get-profile/get-profile.mjs | 2 +- .../social_fetch/actions/get-transcript/get-transcript.mjs | 2 +- .../actions/list-profile-posts/list-profile-posts.mjs | 2 +- .../sources/new-profile-update/new-profile-update.mjs | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/social_fetch/actions/get-credit-balance/get-credit-balance.mjs b/components/social_fetch/actions/get-credit-balance/get-credit-balance.mjs index 9cca9dabac674..e8a40647341f3 100644 --- a/components/social_fetch/actions/get-credit-balance/get-credit-balance.mjs +++ b/components/social_fetch/actions/get-credit-balance/get-credit-balance.mjs @@ -6,7 +6,7 @@ export default { key: "social_fetch-get-credit-balance", name: "Get Credit Balance", description: "Returns the current API credit balance for your Social Fetch account. [See the documentation](https://www.socialfetch.dev/docs/api/v1/balance)", - version: "0.0.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: false, diff --git a/components/social_fetch/actions/get-post/get-post.mjs b/components/social_fetch/actions/get-post/get-post.mjs index a06555f16522a..4caedd9bb89b0 100644 --- a/components/social_fetch/actions/get-post/get-post.mjs +++ b/components/social_fetch/actions/get-post/get-post.mjs @@ -6,7 +6,7 @@ export default { key: "social_fetch-get-post", name: "Get Post", description: "Fetches public post, video, or tweet data from a URL. [See the documentation](https://www.socialfetch.dev/docs/api)", - version: "0.0.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: false, diff --git a/components/social_fetch/actions/get-profile/get-profile.mjs b/components/social_fetch/actions/get-profile/get-profile.mjs index 11ebd88c04d9a..f8eca8c2bfaaa 100644 --- a/components/social_fetch/actions/get-profile/get-profile.mjs +++ b/components/social_fetch/actions/get-profile/get-profile.mjs @@ -6,7 +6,7 @@ export default { key: "social_fetch-get-profile", name: "Get Profile", description: "Fetches public profile data. Choose platform, then handle or profile URL. [See the documentation](https://www.socialfetch.dev/docs/api)", - version: "0.0.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: false, diff --git a/components/social_fetch/actions/get-transcript/get-transcript.mjs b/components/social_fetch/actions/get-transcript/get-transcript.mjs index 6b153fdfed1af..10cd6eb7a7708 100644 --- a/components/social_fetch/actions/get-transcript/get-transcript.mjs +++ b/components/social_fetch/actions/get-transcript/get-transcript.mjs @@ -6,7 +6,7 @@ export default { key: "social_fetch-get-transcript", name: "Get Transcript", description: "Fetches a transcript for a video or post URL. [See the documentation](https://www.socialfetch.dev/docs/api)", - version: "0.0.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: false, diff --git a/components/social_fetch/actions/list-profile-posts/list-profile-posts.mjs b/components/social_fetch/actions/list-profile-posts/list-profile-posts.mjs index 260ee3413e86a..45eb4d1a4deb9 100644 --- a/components/social_fetch/actions/list-profile-posts/list-profile-posts.mjs +++ b/components/social_fetch/actions/list-profile-posts/list-profile-posts.mjs @@ -4,7 +4,7 @@ export default { key: "social_fetch-list-profile-posts", name: "List Profile Posts", description: "Lists recent posts, videos, reels, or tweets for a profile. [See the documentation](https://www.socialfetch.dev/docs/api)", - version: "0.0.1", + version: "0.0.2", type: "action", annotations: { destructiveHint: false, diff --git a/components/social_fetch/sources/new-profile-update/new-profile-update.mjs b/components/social_fetch/sources/new-profile-update/new-profile-update.mjs index 8a766809b5e39..d19178ddd70ce 100644 --- a/components/social_fetch/sources/new-profile-update/new-profile-update.mjs +++ b/components/social_fetch/sources/new-profile-update/new-profile-update.mjs @@ -9,7 +9,7 @@ export default { name: "New Profile Update", description: "Emit new event when a monitored profile changes. [See the documentation](https://www.socialfetch.dev/docs/api)", - version: "0.0.1", + version: "0.0.2", type: "source", dedupe: "unique", props: { From b5f07b1c9d4797f9601adbba9edabcb55b09cae9 Mon Sep 17 00:00:00 2001 From: Michelle Bergeron Date: Thu, 2 Jul 2026 12:59:01 -0400 Subject: [PATCH 3/3] coderabbit suggestions --- .../get-reddit-post-transcript.mjs | 2 +- .../actions/get-subreddit/get-subreddit.mjs | 2 +- .../list-reddit-post-comments.mjs | 2 +- .../list-subreddit-posts.mjs | 2 +- components/social_fetch/common/routing.mjs | 22 +++++++++++++++++++ components/social_fetch/common/utils.mjs | 6 ++++- components/social_fetch/social_fetch.app.mjs | 8 ++++--- 7 files changed, 36 insertions(+), 8 deletions(-) diff --git a/components/social_fetch/actions/get-reddit-post-transcript/get-reddit-post-transcript.mjs b/components/social_fetch/actions/get-reddit-post-transcript/get-reddit-post-transcript.mjs index 7fde33c58a040..2dc6675f5bfe0 100644 --- a/components/social_fetch/actions/get-reddit-post-transcript/get-reddit-post-transcript.mjs +++ b/components/social_fetch/actions/get-reddit-post-transcript/get-reddit-post-transcript.mjs @@ -3,7 +3,7 @@ import app from "../../social_fetch.app.mjs"; export default { key: "social_fetch-get-reddit-post-transcript", name: "Get Reddit Post Transcript", - description: "Get the captions transcript for a Reddit video post. [See the documentation](https://app.socialfetch.dev/playground?path=/v1/reddit/posts/transcript&method=GET)", + description: "Get the captions transcript for a Reddit video post. Use this when you need the spoken text of a Reddit-hosted video; for the post's comment thread use **List Reddit Post Comments** instead. Provide the post URL or a direct hosted video URL, and optionally a two-letter ISO 639-1 language code (e.g. `en`) to prefer a caption track when several exist. [See the documentation](https://app.socialfetch.dev/playground?path=/v1/reddit/posts/transcript&method=GET)", version: "0.0.1", type: "action", annotations: { diff --git a/components/social_fetch/actions/get-subreddit/get-subreddit.mjs b/components/social_fetch/actions/get-subreddit/get-subreddit.mjs index 00fca64410fcf..52c9dfe0ae29c 100644 --- a/components/social_fetch/actions/get-subreddit/get-subreddit.mjs +++ b/components/social_fetch/actions/get-subreddit/get-subreddit.mjs @@ -3,7 +3,7 @@ import app from "../../social_fetch.app.mjs"; export default { key: "social_fetch-get-subreddit", name: "Get Subreddit", - description: "Get details for a Reddit community. [See the documentation](https://app.socialfetch.dev/playground?path=/v1/reddit/subreddits&method=GET)", + description: "Get metadata for a single Reddit community — title, description, subscriber counts, and icon/banner images when available. Use this to look up details about one subreddit; to fetch its posts use **List Subreddit Posts** instead. Provide the community as a bare name (`pics`), an `r/`-prefixed name (`r/pics`), or a full subreddit URL (`https://www.reddit.com/r/pics`); casing must match Reddit exactly. [See the documentation](https://app.socialfetch.dev/playground?path=/v1/reddit/subreddits&method=GET)", version: "0.0.1", type: "action", annotations: { diff --git a/components/social_fetch/actions/list-reddit-post-comments/list-reddit-post-comments.mjs b/components/social_fetch/actions/list-reddit-post-comments/list-reddit-post-comments.mjs index b8fafa12f69bb..e69d242985cfa 100644 --- a/components/social_fetch/actions/list-reddit-post-comments/list-reddit-post-comments.mjs +++ b/components/social_fetch/actions/list-reddit-post-comments/list-reddit-post-comments.mjs @@ -4,7 +4,7 @@ import { truncateArrays } from "../../common/utils.mjs"; export default { key: "social_fetch-list-reddit-post-comments", name: "List Reddit Post Comments", - description: "Get comments on a Reddit post. [See the documentation](https://app.socialfetch.dev/playground?path=/v1/reddit/posts/comments&method=GET)", + description: "List the comments and nested replies on a specific Reddit post. Use this after locating a post via **List Subreddit Posts** when you need its discussion thread. Provide the full post URL (e.g. `https://www.reddit.com/r/pics/comments/abc123/title/`). Enable **Trim** for a lighter response shape, and page through long threads with the cursor. [See the documentation](https://app.socialfetch.dev/playground?path=/v1/reddit/posts/comments&method=GET)", version: "0.0.1", type: "action", annotations: { diff --git a/components/social_fetch/actions/list-subreddit-posts/list-subreddit-posts.mjs b/components/social_fetch/actions/list-subreddit-posts/list-subreddit-posts.mjs index d77cf1392f8d0..c9ef296ee8104 100644 --- a/components/social_fetch/actions/list-subreddit-posts/list-subreddit-posts.mjs +++ b/components/social_fetch/actions/list-subreddit-posts/list-subreddit-posts.mjs @@ -4,7 +4,7 @@ import { truncateArrays } from "../../common/utils.mjs"; export default { key: "social_fetch-list-subreddit-posts", name: "List Subreddit Posts", - description: "Get posts from a specific subreddit. [See the documentation](https://app.socialfetch.dev/playground?path=/v1/reddit/subreddits/%7Bsubreddit%7D/posts&method=GET)", + description: "List posts from a single subreddit, with optional sorting (`best`, `hot`, `new`, `top`, `rising`) and a timeframe for time-based sorts (`all`, `day`, `week`, `month`, `year`). Use this to browse or page through a community's feed; for details about the community itself use **Get Subreddit**, and to read a specific post's replies use **List Reddit Post Comments**. Accepts the subreddit as a bare name (`pics`), an `r/`-prefixed name (`r/pics`), or a subreddit URL. Page through results with the cursor. [See the documentation](https://app.socialfetch.dev/playground?path=/v1/reddit/subreddits/%7Bsubreddit%7D/posts&method=GET)", version: "0.0.1", type: "action", annotations: { diff --git a/components/social_fetch/common/routing.mjs b/components/social_fetch/common/routing.mjs index 5e4e883b155b9..21f7cb905fcf5 100644 --- a/components/social_fetch/common/routing.mjs +++ b/components/social_fetch/common/routing.mjs @@ -3,6 +3,28 @@ import { URL_PROFILE_PLATFORMS, } from "./constants.mjs"; +/** + * Extract the canonical subreddit name from a bare name, an `r/`-prefixed + * name, or a full Reddit subreddit URL, so it can be safely used as a single + * path segment. Reddit's exact casing is preserved. + * + * @param {string | undefined} input + * @returns {string} + */ +export function normalizeSubreddit(input) { + const value = input?.trim(); + if (!value) { + return ""; + } + const urlMatch = value.match(/reddit\.com\/r\/([^/?#]+)/i); + if (urlMatch) { + return urlMatch[1]; + } + return value + .replace(/^\/?r\//i, "") + .split(/[/?#]/)[0]; +} + /** * @param {Record} query * @param {string | undefined} cursor diff --git a/components/social_fetch/common/utils.mjs b/components/social_fetch/common/utils.mjs index 91623e9b80891..16bab93c3b2f2 100644 --- a/components/social_fetch/common/utils.mjs +++ b/components/social_fetch/common/utils.mjs @@ -9,13 +9,17 @@ export function truncateArrays(data, max) { if (!data || typeof data !== "object") { return data; } + const notices = []; for (const key of Object.keys(data)) { if (Array.isArray(data[key]) && data[key].length > max) { const total = data[key].length; data[key] = data[key].slice(0, max); - data._truncated = `${key} truncated to ${max} of ${total} items`; + notices.push(`${key} truncated to ${max} of ${total} items`); } } + if (notices.length) { + data._truncated = notices; + } return data; } diff --git a/components/social_fetch/social_fetch.app.mjs b/components/social_fetch/social_fetch.app.mjs index 2a3675bbf311d..bd88fe1bd7925 100644 --- a/components/social_fetch/social_fetch.app.mjs +++ b/components/social_fetch/social_fetch.app.mjs @@ -10,6 +10,7 @@ import { TRANSCRIPT_PLATFORMS, } from "./common/constants.mjs"; import { + normalizeSubreddit, profileLabel, resolveGetPostRoute, resolveGetProfileRoute, @@ -125,7 +126,8 @@ export default { sort: { type: "string", label: "Sort", - description: "Sort order for the returned posts (string).", + description: + `Sort order for the returned posts (string). One of: ${SUBREDDIT_POST_SORT_OPTIONS.map((v) => `\`${v}\``).join(", ")}.`, options: SUBREDDIT_POST_SORT_OPTIONS, optional: true, }, @@ -133,7 +135,7 @@ export default { type: "string", label: "Timeframe", description: - "Timeframe used with time-based sort orders such as `top` (string).", + `Timeframe used with time-based sort orders such as \`top\` (string). One of: ${SUBREDDIT_POST_TIMEFRAME_OPTIONS.map((v) => `\`${v}\``).join(", ")}.`, options: SUBREDDIT_POST_TIMEFRAME_OPTIONS, optional: true, }, @@ -291,7 +293,7 @@ export default { listSubredditPosts({ subreddit, sort, timeframe, cursor, ...opts } = {}) { - const value = subreddit?.trim(); + const value = normalizeSubreddit(subreddit); if (!value) { throw new Error("Subreddit is required."); }