n8n/packages/nodes-base/nodes/Reddit/SubredditDescription.ts

163 lines
2.7 KiB
TypeScript
Raw Normal View History

:sparkles: Add Reddit Node (#1345) * Set up initial scaffolding and auth * Add grant type to credentials * Add Account operations and OAuth2 request * Add post submission functionality * Refactor resources into resource descriptions * Refactor request for no auth URL * Refactor submission description for consistency * Add listing resource * Refactor My Account resource into details * Add request for all items * Add listings for specific subreddits * Fix minor linting details * Add subreddit resource * Add All-Reddit and Subreddit resource descriptions * Adjust display options for credentials * Add subreddit search functionality * Clean up auth parameter * Add user resource with GET endpoint * Add user description * Add submission search and commenting functionality * Clean up logging and comments * Fix minor details * Fix casing in properties * Add dividers to execute() method * Refactor per feedback * Remove unused description * Add punctuation to property descriptions * Fix resources indentation * Add resource dividers * Remove deprecated sidebar option * Make subreddit:get responses consistent * Remove returnAll and limit from subreddit:get * Flatten user:get response for about * Rename comment target property * Remove best property from post:getAll * Enrich subreddit search by keyword operation * Remove unneeded scopes * Add endpoint documentation * Add scaffolding for post comment * Add all operations for postComment resource * Add all operations for post resource * Refactor subreddit:getAll * Fix postComment:getAll * Flatten responses for profile:get * :zap: Improvements * Fix response traversal for postComment:add * Flatten response for postComment:reply * Fix subreddit:getAll with keyword search * Fix pagination to enforce limit * Wrap unauthenticated API call in try-catch block * Add 404 error for empty array responses * Revert "Fix pagination to enforce limit" This reverts commit 72548d952378a2f899517522b5ba4950a940c6e4. * Turn user:get (gilded) into listing * :zap: Small improvement * :zap: Improve Reddit-Node Co-authored-by: ricardo <ricardoespinoza105@gmail.com> Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
2021-02-04 00:37:03 -08:00
import {
INodeProperties,
} from 'n8n-workflow';
export const subredditOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
default: 'get',
description: 'Operation to perform',
options: [
{
name: 'Get',
value: 'get',
description: 'Retrieve background information about a subreddit.',
},
{
name: 'Get All',
value: 'getAll',
description: 'Retrieve information about subreddits from all of Reddit.',
},
],
displayOptions: {
show: {
resource: [
'subreddit',
],
},
},
},
] as INodeProperties[];
export const subredditFields = [
// ----------------------------------
// subreddit: get
// ----------------------------------
{
displayName: 'Content',
name: 'content',
type: 'options',
required: true,
default: 'about',
description: 'Subreddit content to retrieve.',
options: [
{
name: 'About',
value: 'about',
},
{
name: 'Rules',
value: 'rules',
},
],
displayOptions: {
show: {
resource: [
'subreddit',
],
operation: [
'get',
],
},
},
},
{
displayName: 'Subreddit',
name: 'subreddit',
type: 'string',
required: true,
default: '',
description: 'The name of subreddit to retrieve the content from.',
displayOptions: {
show: {
resource: [
'subreddit',
],
operation: [
'get',
],
},
},
},
// ----------------------------------
// subreddit: getAll
// ----------------------------------
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
default: false,
description: 'Return all results.',
displayOptions: {
show: {
resource: [
'subreddit',
],
operation: [
'getAll',
],
},
},
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
default: 100,
description: 'The number of results to return.',
typeOptions: {
minValue: 1,
maxValue: 100,
},
displayOptions: {
show: {
resource: [
'subreddit',
],
operation: [
'getAll',
],
returnAll: [
false,
],
},
},
},
{
displayName: 'Filters',
name: 'filters',
type: 'collection',
placeholder: 'Add Field',
default: {},
options: [
{
displayName: 'Keyword',
name: 'keyword',
type: 'string',
default: '',
description: 'The keyword for the subreddit search.',
},
{
displayName: 'Trending',
name: 'trending',
type: 'boolean',
default: false,
description: 'Currently trending subreddits in all of Reddit.',
},
],
displayOptions: {
show: {
resource: [
'subreddit',
],
operation: [
'getAll',
],
},
},
},
] as INodeProperties[];