Refactor per feedback

This commit is contained in:
Iván Ovejero 2021-01-22 19:35:12 -03:00
parent 04ad3f2b77
commit 0b0213549b
7 changed files with 658 additions and 568 deletions

View file

@ -1,106 +1,106 @@
import {
INodeProperties,
} from 'n8n-workflow';
// import {
// INodeProperties,
// } from 'n8n-workflow';
export const allRedditOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
default: 'get',
description: 'Operation to perform',
options: [
{
name: 'Get',
value: 'get',
},
],
displayOptions: {
show: {
resource: [
'allReddit',
],
},
},
},
] as INodeProperties[];
// export const allRedditOperations = [
// {
// displayName: 'Operation',
// name: 'operation',
// type: 'options',
// default: 'get',
// description: 'Operation to perform',
// options: [
// {
// name: 'Get All',
// value: 'getAll',
// },
// ],
// displayOptions: {
// show: {
// resource: [
// 'allReddit',
// ],
// },
// },
// },
// ] as INodeProperties[];
export const allRedditFields = [
{
displayName: 'Information',
name: 'information',
type: 'options',
required: true,
default: 'trending',
description: 'All-Reddit information to retrieve',
options: [
{
name: 'Trending',
value: 'trending',
description: 'Currently trending subreddits',
},
{
name: 'Best',
value: 'best',
description: 'Top posts in all of Reddit',
},
],
displayOptions: {
show: {
resource: [
'allReddit',
],
operation: [
'get',
],
},
},
},
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
default: false,
description: 'Return all results',
displayOptions: {
show: {
resource: [
'allReddit',
],
operation: [
'get',
],
information: [
'best',
],
},
},
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
default: 5,
description: 'The number of results to return',
typeOptions: {
minValue: 1,
maxValue: 100,
},
displayOptions: {
show: {
resource: [
'allReddit',
],
operation: [
'get',
],
information: [
'best',
],
returnAll: [
false,
],
},
},
},
] as INodeProperties[];
// export const allRedditFields = [
// {
// displayName: 'Information',
// name: 'information',
// type: 'options',
// required: true,
// default: 'trending',
// description: 'All-Reddit information to retrieve',
// options: [
// {
// name: 'Trending',
// value: 'trending',
// description: 'Currently trending subreddits',
// },
// {
// name: 'Best',
// value: 'best',
// description: 'Top posts in all of Reddit',
// },
// ],
// displayOptions: {
// show: {
// resource: [
// 'allReddit',
// ],
// operation: [
// 'getAll',
// ],
// },
// },
// },
// {
// displayName: 'Return All',
// name: 'returnAll',
// type: 'boolean',
// default: false,
// description: 'Return all results',
// displayOptions: {
// show: {
// resource: [
// 'allReddit',
// ],
// operation: [
// 'getAll',
// ],
// information: [
// 'best',
// ],
// },
// },
// },
// {
// displayName: 'Limit',
// name: 'limit',
// type: 'number',
// default: 5,
// description: 'The number of results to return',
// typeOptions: {
// minValue: 1,
// maxValue: 100,
// },
// displayOptions: {
// show: {
// resource: [
// 'allReddit',
// ],
// operation: [
// 'getAll',
// ],
// information: [
// 'best',
// ],
// returnAll: [
// false,
// ],
// },
// },
// },
// ] as INodeProperties[];

View file

@ -0,0 +1,68 @@
import {
INodeProperties,
} from 'n8n-workflow';
export const commentOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
default: 'create',
description: 'Operation to perform',
options: [
{
name: 'Create',
value: 'create',
},
],
displayOptions: {
show: {
resource: [
'comment',
],
},
},
},
] as INodeProperties[];
export const commentFields = [
// ----------------------------------
// comment: create
// ----------------------------------
{
displayName: 'Target',
name: 'target',
type: 'string',
default: '',
description: 'ID of the comment target',
placeholder: 't3_15bfi0',
displayOptions: {
show: {
resource: [
'comment',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Text',
name: 'text',
type: 'string',
required: true,
default: '',
description: 'Text of the comment (Markdown supported)',
displayOptions: {
show: {
resource: [
'comment',
],
operation: [
'create',
],
},
},
},
] as INodeProperties[];

View file

@ -20,35 +20,27 @@ export async function redditApiRequest(
method: string,
endpoint: string,
qs: IDataObject,
body: IDataObject,
): Promise<any> { // tslint:disable-line:no-any
const resource = this.getNodeParameter('resource', 0) as string;
const operation = this.getNodeParameter('operation', 0) as string;
const requiresAuth = resource === 'myAccount' ||
(resource === 'submission' && ['post', 'comment'].includes(operation));
const authRequired = ['profile', 'post', 'comment'].includes(resource);
const options: OptionsWithUri = {
headers: {
'user-agent': 'n8n',
},
method,
uri: requiresAuth ? `https://oauth.reddit.com/${endpoint}` : `https://www.reddit.com/${endpoint}`,
uri: authRequired ? `https://oauth.reddit.com/${endpoint}` : `https://www.reddit.com/${endpoint}`,
qs,
body,
json: true,
};
if (!Object.keys(body).length) {
delete options.body;
}
if (!Object.keys(qs).length) {
delete options.qs;
}
try {
return requiresAuth
return authRequired
? await this.helpers.requestOAuth2.call(this, 'redditOAuth2Api', options)
: await this.helpers.request.call(this, options);
@ -70,16 +62,24 @@ export async function redditApiRequestAllItems(
method: string,
endpoint: string,
qs: IDataObject,
body: IDataObject,
): Promise<any> { // tslint:disable-line:no-any
let responseData;
const returnData: IDataObject[] = [];
do {
responseData = await redditApiRequest.call(this, method, endpoint, qs, body);
console.log(method);
console.log(endpoint);
console.log(qs);
responseData = await redditApiRequest.call(this, method, endpoint, qs);
console.log(responseData);
qs.after = responseData.after;
responseData.data.children.forEach((child: any) => returnData.push(child.data)); // tslint:disable-line:no-any
if (endpoint === 'api/search_reddit_names.json') {
responseData.names.forEach((name: IDataObject) => returnData.push(name));
} else {
responseData.data.children.forEach((child: any) => returnData.push(child.data)); // tslint:disable-line:no-any
}
if (qs.limit && returnData.length >= qs.limit) {
return returnData;
@ -98,18 +98,30 @@ export async function handleListing(
i: number,
endpoint: string,
): Promise<any> { // tslint:disable-line:no-any
let responseData;
const returnAll = this.getNodeParameter('returnAll', i);
if (returnAll) {
return await redditApiRequestAllItems.call(this, 'GET', endpoint, {}, {});
const resource = this.getNodeParameter('resource', 0);
const operation = this.getNodeParameter('operation', 0);
const qs: IDataObject = {};
if (resource === 'subreddit' && operation === 'getAll') {
const filters = this.getNodeParameter('filters', i) as IDataObject;
if (filters.query) {
qs.query = filters.query;
}
}
const qs: IDataObject = {
limit: this.getNodeParameter('limit', i),
};
responseData = await redditApiRequestAllItems.call(this, 'GET', endpoint, qs, {});
responseData = responseData.splice(0, qs.limit);
const returnAll = this.getNodeParameter('returnAll', i);
if (returnAll) {
responseData = await redditApiRequestAllItems.call(this, 'GET', endpoint, qs);
} else {
qs.limit = this.getNodeParameter('limit', i);
responseData = await redditApiRequestAllItems.call(this, 'GET', endpoint, qs);
responseData = responseData.splice(0, qs.limit);
}
return responseData;
}

View file

@ -1,264 +1,306 @@
import {
INodeProperties,
} from 'n8n-workflow';
export const submissionOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
default: 'post',
description: 'Operation to perform',
options: [
{
name: 'Post',
value: 'post',
description: 'Post a submission to a subreddit',
},
{
name: 'Comment',
value: 'comment',
description: 'Comment on a submission in a subreddit',
},
{
name: 'Search',
value: 'search',
description: 'Search for a submission in a subreddit',
},
],
displayOptions: {
show: {
resource: [
'submission',
],
},
},
},
] as INodeProperties[];
export const submissionFields = [
// ----------------------------------
// post submission
// ----------------------------------
{
displayName: 'Title',
name: 'title',
type: 'string',
required: true,
default: '',
description: 'Title of the submission, up to 300 characters long',
displayOptions: {
show: {
resource: [
'submission',
],
operation: [
'post',
],
},
},
},
{
displayName: 'Subreddit',
name: 'subreddit',
type: 'string',
required: true,
default: '',
description: 'Subreddit to post the submission to',
displayOptions: {
show: {
resource: [
'submission',
],
operation: [
'post',
],
},
},
},
{
displayName: 'Kind',
name: 'kind',
type: 'options',
options: [
{
name: 'Text Post',
value: 'self',
},
{
name: 'Link Post',
value: 'link',
},
{
name: 'Image Post',
value: 'image',
},
{
name: 'Video Post',
value: 'video',
},
{
name: 'Video GIF Post',
value: 'videogif',
},
],
default: 'self',
description: 'The kind of the submission to be posted',
displayOptions: {
show: {
resource: [
'submission',
],
operation: [
'post',
],
},
},
},
{
displayName: 'URL',
name: 'url',
type: 'string',
required: true,
default: '',
description: 'URL of the content of the submission',
displayOptions: {
show: {
resource: [
'submission',
],
operation: [
'post',
],
kind: [
'link',
'image',
'video',
'videogif',
],
},
},
},
{
displayName: 'Text',
name: 'text',
type: 'string',
required: true,
default: '',
description: 'Text content of the submission (Markdown supported)',
displayOptions: {
show: {
resource: [
'submission',
],
operation: [
'post',
],
kind: [
'self',
],
},
},
},
{
displayName: 'Resubmit',
name: 'resubmit',
type: 'boolean',
default: false,
description: 'If toggled on, the URL will be submitted even if<br>it was already submitted to the subreddit before.<br>Otherwise, a resubmission will trigger an error.',
displayOptions: {
show: {
resource: [
'submission',
],
operation: [
'post',
],
kind: [
'link',
'image',
'video',
'videogif',
],
},
},
},
// ----------------------------------
// comment on submission
// ----------------------------------
{
displayName: 'Target',
name: 'target',
type: 'string',
default: '',
description: 'ID of the target of the comment. The target can be either<br>the top-level submission or a reply in that submission.',
placeholder: 't3_15bfi0',
displayOptions: {
show: {
resource: [
'submission',
],
operation: [
'comment',
],
},
},
},
{
displayName: 'Text',
name: 'text',
type: 'string',
required: true,
default: '',
description: 'Text content of the comment (Markdown supported)',
displayOptions: {
show: {
resource: [
'submission',
],
operation: [
'comment',
],
},
},
},
// ----------------------------------
// search for submission
// ----------------------------------
{
displayName: 'Subreddit',
name: 'subreddit',
type: 'string',
required: true,
default: '',
description: 'Subreddit to search for posts',
displayOptions: {
show: {
resource: [
'submission',
],
operation: [
'search',
],
},
},
},
{
displayName: 'Keyword',
name: 'keyword',
type: 'string',
required: true,
default: '',
description: 'The keyword for the subreddit post search',
displayOptions: {
show: {
resource: [
'submission',
],
operation: [
'search',
],
},
},
},
] as INodeProperties[];
import {
INodeProperties,
} from 'n8n-workflow';
export const postOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
default: 'create',
description: 'Operation to perform',
options: [
{
name: 'Create',
value: 'create',
},
{
name: 'Get All',
value: 'getAll',
},
],
displayOptions: {
show: {
resource: [
'post',
],
},
},
},
] as INodeProperties[];
export const postFields = [
// ----------------------------------
// post: create
// ----------------------------------
{
displayName: 'Subreddit',
name: 'subreddit',
type: 'string',
required: true,
default: '',
description: 'Subreddit to create the post in',
displayOptions: {
show: {
resource: [
'post',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Kind',
name: 'kind',
type: 'options',
options: [
{
name: 'Text Post',
value: 'self',
},
{
name: 'Link Post',
value: 'link',
},
{
name: 'Image Post',
value: 'image',
},
{
name: 'Video Post',
value: 'video',
},
{
name: 'Video GIF Post',
value: 'videogif',
},
],
default: 'self',
description: 'The kind of the post to create',
displayOptions: {
show: {
resource: [
'post',
],
operation: [
'create',
],
},
},
},
{
displayName: 'Title',
name: 'title',
type: 'string',
required: true,
default: '',
description: 'Title of the post, up to 300 characters long',
displayOptions: {
show: {
resource: [
'post',
],
operation: [
'create',
],
},
},
},
{
displayName: 'URL',
name: 'url',
type: 'string',
required: true,
default: '',
description: 'URL of the post',
displayOptions: {
show: {
resource: [
'post',
],
operation: [
'create',
],
kind: [
'link',
'image',
'video',
'videogif',
],
},
},
},
{
displayName: 'Text',
name: 'text',
type: 'string',
required: true,
default: '',
description: 'Text of the post (Markdown supported)',
displayOptions: {
show: {
resource: [
'post',
],
operation: [
'create',
],
kind: [
'self',
],
},
},
},
{
displayName: 'Resubmit',
name: 'resubmit',
type: 'boolean',
default: false,
description: 'If toggled on, the URL will be posted even if<br>it was already posted to the subreddit before.<br>Otherwise, the re-posting will trigger an error.',
displayOptions: {
show: {
resource: [
'post',
],
operation: [
'create',
],
kind: [
'link',
'image',
'video',
'videogif',
],
},
},
},
// ----------------------------------
// post: getAll
// ----------------------------------
{
displayName: 'Best',
name: 'best',
type: 'boolean',
default: false,
description: 'Best posts in all of Reddit',
displayOptions: {
show: {
resource: [
'post',
],
operation: [
'getAll',
],
},
},
},
{
displayName: 'Subreddit',
name: 'subreddit',
type: 'string',
required: true,
default: '',
description: 'The name of subreddit to retrieve the posts from',
displayOptions: {
show: {
resource: [
'post',
],
operation: [
'getAll',
],
best: [
false,
],
},
},
},
{
displayName: 'Content',
name: 'content',
type: 'options',
required: true,
default: 'top',
description: 'Content of posts to retrieve',
options: [
{
name: 'Top Posts',
value: 'top',
},
{
name: 'Hot Posts',
value: 'hot',
},
{
name: 'New Posts',
value: 'new',
},
{
name: 'Rising Posts',
value: 'rising',
},
],
displayOptions: {
show: {
resource: [
'post',
],
operation: [
'getAll',
],
best: [
false,
],
},
},
},
{
displayName: 'Return All',
name: 'returnAll',
type: 'boolean',
default: false,
description: 'Return all results',
displayOptions: {
show: {
resource: [
'post',
],
operation: [
'getAll',
],
best: [
false,
],
},
},
},
{
displayName: 'Limit',
name: 'limit',
type: 'number',
default: 5,
description: 'The number of results to return',
typeOptions: {
minValue: 1,
maxValue: 100,
},
displayOptions: {
show: {
resource: [
'post',
],
operation: [
'getAll',
],
returnAll: [
false,
],
best: [
false,
],
},
},
},
] as INodeProperties[];

View file

@ -2,7 +2,7 @@ import {
INodeProperties,
} from 'n8n-workflow';
export const myAccountOperations = [
export const profileOperations = [
{
displayName: 'Operation',
name: 'operation',
@ -10,7 +10,7 @@ export const myAccountOperations = [
displayOptions: {
show: {
resource: [
'myAccount',
'profile',
],
},
},
@ -26,7 +26,7 @@ export const myAccountOperations = [
] as INodeProperties[];
export const myAccountFields = [
export const profileFields = [
{
displayName: 'Details',
name: 'details',
@ -69,7 +69,7 @@ export const myAccountFields = [
displayOptions: {
show: {
resource: [
'myAccount',
'profile',
],
operation: [
'get',

View file

@ -15,19 +15,19 @@ import {
} from './GenericFunctions';
import {
allRedditFields,
allRedditOperations,
} from './AllRedditDescription';
commentFields,
commentOperations,
} from './CommentDescription';
import {
myAccountFields,
myAccountOperations,
} from './MyAccountDescription';
postFields,
postOperations,
} from './PostDescription';
import {
submissionFields,
submissionOperations,
} from './SubmissionDescription';
profileFields,
profileOperations,
} from './ProfileDescription';
import {
subredditFields,
@ -61,13 +61,9 @@ export class Reddit implements INodeType {
displayOptions: {
show: {
resource: [
'myAccount',
'submission',
],
},
hide: {
operation: [
'search',
'profile',
'comment',
'post',
],
},
},
@ -80,16 +76,16 @@ export class Reddit implements INodeType {
type: 'options',
options: [
{
name: 'All Reddit',
value: 'allReddit',
name: 'Comment',
value: 'comment',
},
{
name: 'My Account',
value: 'myAccount',
name: 'Post',
value: 'post',
},
{
name: 'Submission',
value: 'submission',
name: 'Profile',
value: 'profile',
},
{
name: 'Subreddit',
@ -100,27 +96,17 @@ export class Reddit implements INodeType {
value: 'user',
},
],
default: 'myAccount',
default: 'comment',
description: 'Resource to consume',
},
// allReddit
...allRedditOperations,
...allRedditFields,
// myAccount
...myAccountOperations,
...myAccountFields,
// submission
...submissionOperations,
...submissionFields,
// subreddit
...commentOperations,
...commentFields,
...profileOperations,
...profileFields,
...subredditOperations,
...subredditFields,
// user
...postOperations,
...postFields,
...userOperations,
...userFields,
],
@ -137,62 +123,90 @@ export class Reddit implements INodeType {
for (let i = 0; i < items.length; i++) {
if (resource === 'allReddit') {
if (resource === 'comment') {
// ----------------------------------
// allReddit: get
// comment: create
// ----------------------------------
const qs: IDataObject = {
thing_id: this.getNodeParameter('target', i),
text: this.getNodeParameter('text', i),
};
responseData = await redditApiRequest.call(this, 'POST', 'api/comment', qs);
} else if (resource === 'profile') {
// ----------------------------------
// profile: get
// ----------------------------------
if (operation === 'get') {
const information = this.getNodeParameter('information', i) as string;
const endpoints: {[key: string]: string} = {
identity: 'me',
blockedUsers: 'me/blocked',
friends: 'me/friends',
karma: 'me/karma',
prefs: 'me/prefs',
trophies: 'me/trophies',
};
if (information === 'trending') {
const endpoint = 'api/trending_subreddits.json';
responseData = await redditApiRequest.call(this, 'GET', endpoint, {}, {});
} else {
const endpoint = 'best.json';
responseData = await handleListing.call(this, i, endpoint);
const details = this.getNodeParameter('details', i) as string;
const endpoint = `api/v1/${endpoints[details]}`;
responseData = await redditApiRequest.call(this, 'GET', endpoint, {});
if (details === 'identity') {
responseData = responseData.features;
}
}
} else if (resource === 'myAccount') {
} else if (resource === 'subreddit') {
// ----------------------------------
// myAccount: get
// ----------------------------------
// ----------------------------------
// subreddit: get
// ----------------------------------
if (operation === 'get') {
const endpoints: {[key: string]: string} = {
identity: 'me',
blockedUsers: 'me/blocked',
friends: 'me/friends',
karma: 'me/karma',
prefs: 'me/prefs',
trophies: 'me/trophies',
};
const qs: IDataObject = {};
const details = this.getNodeParameter('details', i) as string;
responseData = await redditApiRequest.call(this, 'GET', `api/v1/${endpoints[details]}`, {}, {});
const subreddit = this.getNodeParameter('subreddit', i);
const content = this.getNodeParameter('content', i) as string;
const endpoint = `r/${subreddit}/about/${content}.json`;
if (details === 'identity') {
responseData = responseData.features;
responseData = await redditApiRequest.call(this, 'GET', endpoint, qs);
if (content === 'rules') {
responseData = responseData.rules;
}
// ----------------------------------
// subreddit: getAll
// ----------------------------------
} else if (operation === 'getAll') {
const trending = this.getNodeParameter('trending', i) as IDataObject;
if (trending) {
const endpoint = 'api/trending_subreddits.json';
responseData = await redditApiRequest.call(this, 'GET', endpoint, {});
} else {
const endpoint = 'api/search_reddit_names.json';
responseData = await handleListing.call(this, i, endpoint);
}
}
} else if (resource === 'submission') {
} else if (resource === 'post') {
// ----------------------------------
// submission: post
// ----------------------------------
// ----------------------------------
// post: create
// ----------------------------------
if (operation === 'post') {
if (operation === 'create') {
const qs: IDataObject = {
title: this.getNodeParameter('title', i),
@ -208,73 +222,21 @@ export class Reddit implements INodeType {
qs.resubmit = this.getNodeParameter('resubmit', i);
}
responseData = await redditApiRequest.call(this, 'POST', 'api/submit', qs, {});
// ----------------------------------
// submission: comment
// ----------------------------------
} else if (operation === 'comment') {
const qs: IDataObject = {
thing_id: this.getNodeParameter('target', i),
text: this.getNodeParameter('text', i),
};
responseData = await redditApiRequest.call(this, 'POST', 'api/comment', qs, {});
} else if (operation === 'search') {
const subreddit = this.getNodeParameter('subreddit', i);
const qs: IDataObject = {
q: this.getNodeParameter('keyword', i),
restrict_sr: 'on',
};
const endpoint = `r/${subreddit}/search.json`;
responseData = await redditApiRequest.call(this, 'GET', endpoint, qs, {});
responseData = await redditApiRequest.call(this, 'POST', 'api/submit', qs);
}
} else if (resource === 'subreddit') {
// ----------------------------------
// post: getAll
// ----------------------------------
// ----------------------------------
// subreddit: get
// ----------------------------------
else if (operation === 'getAll') {
if (operation === 'get') {
const qs: IDataObject = {};
const content = this.getNodeParameter('content', i) as string;
const subreddit = this.getNodeParameter('subreddit', i);
const content = this.getNodeParameter('content', i);
const endpoint = `r/${subreddit}/${content}.json`;
if (['about', 'rules', 'sidebar', 'sticky'].includes(content)) {
const endpoint = `r/${subreddit}/about/${content}.json`;
responseData = await redditApiRequest.call(this, 'GET', endpoint, qs, {});
if (content === 'rules') {
responseData = responseData.rules;
}
} else if (['top', 'hot', 'new', 'rising'].includes(content)) {
const endpoint = `r/${subreddit}/${content}.json`;
responseData = await handleListing.call(this, i, endpoint);
}
} else if (operation === 'search') {
const endpoint = `api/search_reddit_names.json`;
const qs: IDataObject = {
query: this.getNodeParameter('keyword', i),
};
responseData = await redditApiRequest.call(this, 'GET', endpoint, qs, {});
responseData = await handleListing.call(this, i, endpoint);
}
@ -291,7 +253,7 @@ export class Reddit implements INodeType {
const endpoint = `user/${username}/${details}.json`;
responseData = ['about', 'gilded'].includes(details)
? await redditApiRequest.call(this, 'GET', endpoint, {}, {})
? await redditApiRequest.call(this, 'GET', endpoint, {})
: await handleListing.call(this, i, endpoint);
}

View file

@ -15,8 +15,8 @@ export const subredditOperations = [
value: 'get',
},
{
name: 'Search',
value: 'search',
name: 'Get All',
value: 'getAll',
},
],
displayOptions: {
@ -31,7 +31,7 @@ export const subredditOperations = [
export const subredditFields = [
// ----------------------------------
// get: subreddit
// subreddit: get
// ----------------------------------
{
displayName: 'Content',
@ -57,22 +57,6 @@ export const subredditFields = [
name: 'Sticky Posts',
value: 'sticky',
},
{
name: 'Top Posts',
value: 'top',
},
{
name: 'Hot Posts',
value: 'hot',
},
{
name: 'New Posts',
value: 'new',
},
{
name: 'Rising Posts',
value: 'rising',
},
],
displayOptions: {
show: {
@ -117,12 +101,6 @@ export const subredditFields = [
operation: [
'get',
],
content: [
'top',
'hot',
'new',
'rising',
],
},
},
},
@ -144,12 +122,6 @@ export const subredditFields = [
operation: [
'get',
],
content: [
'top',
'hot',
'new',
'rising',
],
returnAll: [
false,
],
@ -157,22 +129,21 @@ export const subredditFields = [
},
},
// ----------------------------------
// search: subreddit
// subreddit: getAll
// ----------------------------------
{
displayName: 'Keyword',
name: 'keyword',
type: 'string',
required: true,
default: '',
description: 'The keyword for the subreddit name search',
displayName: 'Trending',
name: 'trending',
type: 'boolean',
default: false,
description: 'Currently trending subreddits in all of Reddit',
displayOptions: {
show: {
resource: [
'subreddit',
],
operation: [
'search',
'getAll',
],
},
},
@ -189,7 +160,10 @@ export const subredditFields = [
'subreddit',
],
operation: [
'search',
'getAll',
],
trending: [
false,
],
},
},
@ -210,11 +184,43 @@ export const subredditFields = [
'subreddit',
],
operation: [
'search',
'getAll',
],
returnAll: [
false,
],
trending: [
false,
],
},
},
},
{
displayName: 'Filters',
name: 'filters',
type: 'collection',
placeholder: 'Add Field',
default: {},
options: [
{
displayName: 'Query',
name: 'query',
type: 'string',
default: '',
description: 'The term for the subreddit name search',
},
],
displayOptions: {
show: {
resource: [
'subreddit',
],
operation: [
'getAll',
],
trending: [
false,
],
},
},
},