diff --git a/src/get-reddit-posts/action-definition.js b/src/get-reddit-posts/action-definition.js new file mode 100644 index 0000000..4e4a600 --- /dev/null +++ b/src/get-reddit-posts/action-definition.js @@ -0,0 +1,27 @@ +// See README.MD for an in-depth explanation of each parameter. +module.exports = { + name: "get-top-reddit-posts", + function: require('./get-top-reddit-posts.js'), + documentationUri: "https://github.com/clay-run/action-template-nodejs/blob/master/README.md", + iconUri: "https://logo.clearbit.com/reddit.com?size=80", + displayName: "Get Top Reddit Posts", + description: "This action allows to get the top posts of a sub-reddit", + inputParameterSchema: [ + { + name: "subredditName", + type: "text", + optional: false, + displayName: "SubReddit Name", + description: "The sub-reddit name to get posts from" + }, + { + name: "numberOfPosts", + type: "number", + displayName: "# of posts", + description: "The number of posts to fetch" + } + ], + outputParameterSchema: require('./output-schema.js'), + inputSample: require('./test-inputs').goodSample, + outputSample: require('./output-sample.js'), +} diff --git a/src/get_top_reddit_posts/get_top_reddit_posts.js b/src/get-reddit-posts/get-top-reddit-posts.js similarity index 100% rename from src/get_top_reddit_posts/get_top_reddit_posts.js rename to src/get-reddit-posts/get-top-reddit-posts.js diff --git a/src/get_top_reddit_posts/output_sample.js b/src/get-reddit-posts/output-sample.js similarity index 100% rename from src/get_top_reddit_posts/output_sample.js rename to src/get-reddit-posts/output-sample.js diff --git a/src/get_top_reddit_posts/output_parameter_schema.js b/src/get-reddit-posts/output-schema.js similarity index 83% rename from src/get_top_reddit_posts/output_parameter_schema.js rename to src/get-reddit-posts/output-schema.js index edf025b..5bdc828 100644 --- a/src/get_top_reddit_posts/output_parameter_schema.js +++ b/src/get-reddit-posts/output-schema.js @@ -1,4 +1,6 @@ -module.exports = [ // the action function must return an object with the following parameters +// These are used to help Clay's interface provide ways to extract data from the output of this action into the table + +module.exports = [ { name: "arrayOfPosts", type: "array", diff --git a/src/get_top_reddit_posts/test_get_top_reddit_posts.js b/src/get-reddit-posts/test-inputs.js similarity index 99% rename from src/get_top_reddit_posts/test_get_top_reddit_posts.js rename to src/get-reddit-posts/test-inputs.js index 3326baa..657a2ac 100644 --- a/src/get_top_reddit_posts/test_get_top_reddit_posts.js +++ b/src/get-reddit-posts/test-inputs.js @@ -17,4 +17,4 @@ module.exports = { anotherSample: { subredditName: "dogs" } -} \ No newline at end of file +} diff --git a/src/get_top_reddit_posts/definition.js b/src/get_top_reddit_posts/definition.js deleted file mode 100644 index 85b7656..0000000 --- a/src/get_top_reddit_posts/definition.js +++ /dev/null @@ -1,64 +0,0 @@ -const getTopRedditPostsActionFunction = require('./get_top_reddit_posts.js') - -/* - * This is where you define your Action. - */ -const getTopRedditPostsActionDefinition = { - name: "gettopredditposts", // unique action name across the entire action package - function: getTopRedditPostsActionFunction, // the action function to execute - documentationUri: "https://github.com/clay-run/action-template-nodejs/blob/master/README.md", // optional - link to documentation - iconUri: "https://logo.clearbit.com/reddit.com?size=80", // optional - icon to be displayed on Clay - displayName: "Get top reddit posts", // the action name to be displayed on Clay - description: "This action allows to get the top posts of a specific subreddit", // the action description to be displayed on Clay - //actionGroups: ["Social Media", "Reddit"], // INTERNAL ONLY - folders that will include the public action on Clay - //authentications: [ // optional - authentication methods that can be used by the action function - // { - // provider: "api_key", - // } - //], - inputParameterSchema: [ // the action function expects an object with the following parameters - { - name: "subredditName", // the parameter key in the object - type: "text", // the parameter type - boolean, number, text, array, object - optional: false, // optional - determines if the parameter is optional, defaults to false - displayName: "SubReddit Name", // optional field - the parameter name displayed on Clay - description: "The SubReddit name to get posts from" // optional field - the parameter description displayed on Clay - }, - { - name: "numberOfPosts", - type: "number", - optional: true, - displayName: "# of posts", - description: "The number of posts to fetch" - } - ], - //supportsBatching: true, // optional - if allowed, the action function will receive a flag to indicate that it is running in batch mode - //maximumBatchSize: 100, // optional - the maximum number of input objects to be received if batch mode is enabled - outputParameterSchema: require('./output_parameter_schema.js'), - inputSample: { // optional - a sample input object for the action function - subredditName: "cats", - numberOfPosts: 10 - }, - outputSample: require('./output_sample.js'), - //pricing: { // INTERNAL ONLY - pricing rules for the action function - // requiresPayment: true, - // chargedById: "a1b2c3d4", - // paymentPlan: "subscription", - // trialRuns: 1000, - // pricePerRun: 5 // integer in one hundredth of a cent - //}, - //restrictionFlags: { // INTERNAL ONLY - restriction rules related to the action function - // isExportable: true //optional - prevents the action function output to be exported from Clay - //}, - //isPublic: false, // INTERNAL ONLY - allows Clay admins to make the action function public - //rateLimitRules: { // optional - allows rate limiting rules to be defined in order to throttle the execution of the action function - // concurrency: [ - // { - // bucket: ['USER'], - // limit: 4 - // } - // ] - //} -} - -module.exports = getTopRedditPostsActionDefinition diff --git a/src/index.js b/src/index.js index 2a883c2..c1955f1 100644 --- a/src/index.js +++ b/src/index.js @@ -1,22 +1,12 @@ /* - * - * This is where you define your Action Package. - * - * An Action Package contains one or more Action Definitions. - * - * Be sure to add any actions you want included in your Action Package to the `actionDefinitions` array. - * - */ + This is an Action Package. It consists of one more Actions. + Add an Action by importing it's action-definition.js and adding it to the actionDefinitions array +*/ -const getTopRedditPostsActionDefinition = require("./get_top_reddit_posts/definition.js") +const getTopRedditPosts = require("./get-reddit-posts/action-definition.js") -/* - * The Action Package definition - */ -const RedditActionPackage = { - name: "redditactionpackage", // a globally unique name to identify the package - description: "Actions to help search and read posts on Reddit", // a description of the package's purpose or content - actionDefinitions: [getTopRedditPostsActionDefinition], // the actions included in the action package +module.exports = { + name: "Reddit-Action-Package", + description: "Actions to search and get posts from Reddit", + actionDefinitions: [getTopRedditPosts], } - -module.exports = RedditActionPackage