first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const categoryOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
description: 'Choose an operation',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['category'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a category',
|
||||
action: 'Create a category',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many categories',
|
||||
action: 'Get many categories',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a category',
|
||||
action: 'Update a category',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const categoryFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* category:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['category'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Name of the category',
|
||||
},
|
||||
{
|
||||
displayName: 'Color',
|
||||
name: 'color',
|
||||
type: 'color',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['category'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '0000FF',
|
||||
description: 'Color of the category',
|
||||
},
|
||||
{
|
||||
displayName: 'Text Color',
|
||||
name: 'textColor',
|
||||
type: 'color',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['category'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '0000FF',
|
||||
description: 'Text color of the category',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* category:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['category'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['category'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 50,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* category:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Category ID',
|
||||
name: 'categoryId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['category'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'ID of the category',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['category'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'New name of the category',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['category'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Color',
|
||||
name: 'color',
|
||||
type: 'color',
|
||||
default: '0000FF',
|
||||
description: 'Color of the category',
|
||||
},
|
||||
{
|
||||
displayName: 'Text Color',
|
||||
name: 'textColor',
|
||||
type: 'color',
|
||||
default: '0000FF',
|
||||
description: 'Text color of the category',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"node": "n8n-nodes-base.discourse",
|
||||
"nodeVersion": "1.0",
|
||||
"codexVersion": "1.0",
|
||||
"categories": ["Communication"],
|
||||
"resources": {
|
||||
"credentialDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/credentials/discourse/"
|
||||
}
|
||||
],
|
||||
"primaryDocumentation": [
|
||||
{
|
||||
"url": "https://docs.n8n.io/integrations/builtin/app-nodes/n8n-nodes-base.discourse/"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,456 @@
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
IDataObject,
|
||||
ILoadOptionsFunctions,
|
||||
INodeExecutionData,
|
||||
INodePropertyOptions,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeConnectionTypes } from 'n8n-workflow';
|
||||
|
||||
import { categoryFields, categoryOperations } from './CategoryDescription';
|
||||
import { discourseApiRequest } from './GenericFunctions';
|
||||
import { groupFields, groupOperations } from './GroupDescription';
|
||||
import { postFields, postOperations } from './PostDescription';
|
||||
import { userFields, userOperations } from './UserDescription';
|
||||
import { userGroupFields, userGroupOperations } from './UserGroupDescription';
|
||||
|
||||
export class Discourse implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
displayName: 'Discourse',
|
||||
name: 'discourse',
|
||||
icon: 'file:discourse.svg',
|
||||
group: ['input'],
|
||||
version: 1,
|
||||
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
|
||||
description: 'Consume Discourse API',
|
||||
defaults: {
|
||||
name: 'Discourse',
|
||||
},
|
||||
usableAsTool: true,
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: [NodeConnectionTypes.Main],
|
||||
credentials: [
|
||||
{
|
||||
name: 'discourseApi',
|
||||
required: true,
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Resource',
|
||||
name: 'resource',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
options: [
|
||||
{
|
||||
name: 'Category',
|
||||
value: 'category',
|
||||
},
|
||||
{
|
||||
name: 'Group',
|
||||
value: 'group',
|
||||
},
|
||||
{
|
||||
name: 'Post',
|
||||
value: 'post',
|
||||
},
|
||||
// {
|
||||
// name: 'Search',
|
||||
// value: 'search',
|
||||
// },
|
||||
{
|
||||
name: 'User',
|
||||
value: 'user',
|
||||
},
|
||||
{
|
||||
name: 'User Group',
|
||||
value: 'userGroup',
|
||||
},
|
||||
],
|
||||
default: 'post',
|
||||
},
|
||||
...categoryOperations,
|
||||
...categoryFields,
|
||||
...groupOperations,
|
||||
...groupFields,
|
||||
...postOperations,
|
||||
...postFields,
|
||||
// ...searchOperations,
|
||||
// ...searchFields,
|
||||
...userOperations,
|
||||
...userFields,
|
||||
...userGroupOperations,
|
||||
...userGroupFields,
|
||||
],
|
||||
};
|
||||
|
||||
methods = {
|
||||
loadOptions: {
|
||||
// Get all the calendars to display them to user so that they can
|
||||
// select them easily
|
||||
async getCategories(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { category_list } = await discourseApiRequest.call(this, 'GET', '/categories.json');
|
||||
for (const category of category_list.categories) {
|
||||
returnData.push({
|
||||
name: category.name,
|
||||
value: category.id,
|
||||
});
|
||||
}
|
||||
return returnData;
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const items = this.getInputData();
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
const length = items.length;
|
||||
const qs: IDataObject = {};
|
||||
let responseData;
|
||||
const resource = this.getNodeParameter('resource', 0);
|
||||
const operation = this.getNodeParameter('operation', 0);
|
||||
for (let i = 0; i < length; i++) {
|
||||
try {
|
||||
if (resource === 'category') {
|
||||
//https://docs.discourse.org/#tag/Categories/paths/~1categories.json/post
|
||||
if (operation === 'create') {
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
const color = this.getNodeParameter('color', i) as string;
|
||||
const textColor = this.getNodeParameter('textColor', i) as string;
|
||||
|
||||
const body: IDataObject = {
|
||||
name,
|
||||
color,
|
||||
text_color: textColor,
|
||||
};
|
||||
|
||||
responseData = await discourseApiRequest.call(this, 'POST', '/categories.json', body);
|
||||
|
||||
responseData = responseData.category;
|
||||
}
|
||||
//https://docs.discourse.org/#tag/Categories/paths/~1categories.json/get
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
responseData = await discourseApiRequest.call(this, 'GET', '/categories.json', {}, qs);
|
||||
|
||||
responseData = responseData.category_list.categories;
|
||||
|
||||
if (!returnAll) {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
responseData = responseData.splice(0, limit);
|
||||
}
|
||||
}
|
||||
//https://docs.discourse.org/#tag/Categories/paths/~1categories~1{id}/put
|
||||
if (operation === 'update') {
|
||||
const categoryId = this.getNodeParameter('categoryId', i) as string;
|
||||
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
|
||||
const body: IDataObject = {
|
||||
name,
|
||||
};
|
||||
|
||||
Object.assign(body, updateFields);
|
||||
|
||||
responseData = await discourseApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/categories/${categoryId}.json`,
|
||||
body,
|
||||
);
|
||||
|
||||
responseData = responseData.category;
|
||||
}
|
||||
}
|
||||
if (resource === 'group') {
|
||||
//https://docs.discourse.org/#tag/Posts/paths/~1posts.json/post
|
||||
if (operation === 'create') {
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
|
||||
const body: IDataObject = {
|
||||
name,
|
||||
};
|
||||
|
||||
responseData = await discourseApiRequest.call(this, 'POST', '/admin/groups.json', {
|
||||
group: body,
|
||||
});
|
||||
|
||||
responseData = responseData.basic_group;
|
||||
}
|
||||
//https://docs.discourse.org/#tag/Groups/paths/~1groups~1{name}.json/get
|
||||
if (operation === 'get') {
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
|
||||
responseData = await discourseApiRequest.call(this, 'GET', `/groups/${name}`, {}, qs);
|
||||
|
||||
responseData = responseData.group;
|
||||
}
|
||||
//https://docs.discourse.org/#tag/Groups/paths/~1groups.json/get
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
|
||||
responseData = await discourseApiRequest.call(this, 'GET', '/groups.json', {}, qs);
|
||||
|
||||
responseData = responseData.groups;
|
||||
|
||||
if (!returnAll) {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
responseData = responseData.splice(0, limit);
|
||||
}
|
||||
}
|
||||
//https://docs.discourse.org/#tag/Posts/paths/~1posts~1{id}.json/put
|
||||
if (operation === 'update') {
|
||||
const groupId = this.getNodeParameter('groupId', i) as string;
|
||||
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
|
||||
const body: IDataObject = {
|
||||
name,
|
||||
};
|
||||
|
||||
responseData = await discourseApiRequest.call(this, 'PUT', `/groups/${groupId}.json`, {
|
||||
group: body,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (resource === 'post') {
|
||||
//https://docs.discourse.org/#tag/Posts/paths/~1posts.json/post
|
||||
if (operation === 'create') {
|
||||
const content = this.getNodeParameter('content', i) as string;
|
||||
const title = this.getNodeParameter('title', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
|
||||
const body: IDataObject = {
|
||||
title,
|
||||
raw: content,
|
||||
};
|
||||
|
||||
Object.assign(body, additionalFields);
|
||||
|
||||
responseData = await discourseApiRequest.call(this, 'POST', '/posts.json', body);
|
||||
}
|
||||
//https://docs.discourse.org/#tag/Posts/paths/~1posts~1{id}.json/get
|
||||
if (operation === 'get') {
|
||||
const postId = this.getNodeParameter('postId', i) as string;
|
||||
|
||||
responseData = await discourseApiRequest.call(this, 'GET', `/posts/${postId}`, {}, qs);
|
||||
}
|
||||
//https://docs.discourse.org/#tag/Posts/paths/~1posts.json/get
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const limit = this.getNodeParameter('limit', i, 0);
|
||||
|
||||
responseData = await discourseApiRequest.call(this, 'GET', '/posts.json', {}, qs);
|
||||
responseData = responseData.latest_posts;
|
||||
|
||||
//Getting all posts relying on https://github.com/discourse/discourse_api/blob/main/spec/discourse_api/api/posts_spec.rb
|
||||
let lastPost = responseData.pop();
|
||||
let previousLastPostID;
|
||||
while (lastPost.id !== previousLastPostID) {
|
||||
if (limit && responseData.length > limit) {
|
||||
break;
|
||||
}
|
||||
const chunk = await discourseApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/posts.json?before=${lastPost.id}`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.concat(chunk.latest_posts);
|
||||
previousLastPostID = lastPost.id;
|
||||
lastPost = responseData.pop();
|
||||
}
|
||||
responseData.push(lastPost);
|
||||
|
||||
if (!returnAll) {
|
||||
responseData = responseData.splice(0, limit);
|
||||
}
|
||||
}
|
||||
//https://docs.discourse.org/#tag/Posts/paths/~1posts~1{id}.json/put
|
||||
if (operation === 'update') {
|
||||
const postId = this.getNodeParameter('postId', i) as string;
|
||||
|
||||
const content = this.getNodeParameter('content', i) as string;
|
||||
|
||||
const updateFields = this.getNodeParameter('updateFields', i);
|
||||
|
||||
const body: IDataObject = {
|
||||
raw: content,
|
||||
};
|
||||
|
||||
Object.assign(body, updateFields);
|
||||
|
||||
responseData = await discourseApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/posts/${postId}.json`,
|
||||
body,
|
||||
);
|
||||
|
||||
responseData = responseData.post;
|
||||
}
|
||||
}
|
||||
// TODO figure how to paginate the results
|
||||
// if (resource === 'search') {
|
||||
// //https://docs.discourse.org/#tag/Search/paths/~1search~1query/get
|
||||
// if (operation === 'query') {
|
||||
// qs.term = this.getNodeParameter('term', i) as string;
|
||||
|
||||
// const simple = this.getNodeParameter('simple', i) as boolean;
|
||||
|
||||
// const updateFields = this.getNodeParameter('updateFields', i);
|
||||
|
||||
// Object.assign(qs, updateFields);
|
||||
|
||||
// qs.page = 1;
|
||||
|
||||
// responseData = await discourseApiRequest.call(
|
||||
// this,
|
||||
// 'GET',
|
||||
// `/search/query`,
|
||||
// {},
|
||||
// qs,
|
||||
// );
|
||||
|
||||
// if (simple === true) {
|
||||
// const response = [];
|
||||
// for (const key of Object.keys(responseData)) {
|
||||
// for (const data of responseData[key]) {
|
||||
// response.push(Object.assign(data, { __type: key }));
|
||||
// }
|
||||
// }
|
||||
// responseData = response;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if (resource === 'user') {
|
||||
//https://docs.discourse.org/#tag/Users/paths/~1users/post
|
||||
if (operation === 'create') {
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
const email = this.getNodeParameter('email', i) as string;
|
||||
const password = this.getNodeParameter('password', i) as string;
|
||||
const username = this.getNodeParameter('username', i) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i);
|
||||
|
||||
const body: IDataObject = {
|
||||
name,
|
||||
password,
|
||||
email,
|
||||
username,
|
||||
};
|
||||
|
||||
Object.assign(body, additionalFields);
|
||||
|
||||
responseData = await discourseApiRequest.call(this, 'POST', '/users.json', body);
|
||||
}
|
||||
//https://docs.discourse.org/#tag/Users/paths/~1users~1{username}.json/get
|
||||
if (operation === 'get') {
|
||||
const by = this.getNodeParameter('by', i) as string;
|
||||
let endpoint = '';
|
||||
if (by === 'username') {
|
||||
const username = this.getNodeParameter('username', i) as string;
|
||||
endpoint = `/users/${username}`;
|
||||
} else if (by === 'externalId') {
|
||||
const externalId = this.getNodeParameter('externalId', i) as string;
|
||||
endpoint = `/u/by-external/${externalId}.json`;
|
||||
}
|
||||
|
||||
responseData = await discourseApiRequest.call(this, 'GET', endpoint);
|
||||
}
|
||||
//https://docs.discourse.org/#tag/Users/paths/~1admin~1users~1{id}.json/delete
|
||||
if (operation === 'getAll') {
|
||||
const returnAll = this.getNodeParameter('returnAll', i);
|
||||
const flag = this.getNodeParameter('flag', i) as boolean;
|
||||
|
||||
const options = this.getNodeParameter('options', i);
|
||||
|
||||
if (options.stats) {
|
||||
qs.stats = options.stats as boolean;
|
||||
}
|
||||
|
||||
if (options.asc) {
|
||||
qs.asc = options.asc as boolean;
|
||||
}
|
||||
|
||||
if (options.showEmails) {
|
||||
qs.show_emails = options.showEmails as boolean;
|
||||
}
|
||||
|
||||
if (options.order) {
|
||||
qs.order = options.order as string;
|
||||
}
|
||||
|
||||
responseData = await discourseApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/admin/users/list/${flag}.json`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
|
||||
if (!returnAll) {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
responseData = responseData.splice(0, limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resource === 'userGroup') {
|
||||
//https://docs.discourse.org/#tag/Groups/paths/~1groups~1{group_id}~1members.json/put
|
||||
if (operation === 'add') {
|
||||
const usernames = this.getNodeParameter('usernames', i) as string;
|
||||
const groupId = this.getNodeParameter('groupId', i) as string;
|
||||
const body: IDataObject = {
|
||||
usernames,
|
||||
};
|
||||
|
||||
responseData = await discourseApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/groups/${groupId}/members.json`,
|
||||
body,
|
||||
);
|
||||
}
|
||||
//https://docs.discourse.org/#tag/Groups/paths/~1groups~1{group_id}~1members.json/delete
|
||||
if (operation === 'remove') {
|
||||
const usernames = this.getNodeParameter('usernames', i) as string;
|
||||
const groupId = this.getNodeParameter('groupId', i) as string;
|
||||
const body: IDataObject = {
|
||||
usernames,
|
||||
};
|
||||
|
||||
responseData = await discourseApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/groups/${groupId}/members.json`,
|
||||
body,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData as IDataObject[]),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} catch (error) {
|
||||
if (this.continueOnFail()) {
|
||||
const executionErrorData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray({ error: error.message }),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionErrorData);
|
||||
continue;
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
return [returnData];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
IDataObject,
|
||||
JsonObject,
|
||||
IHttpRequestMethods,
|
||||
IRequestOptions,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function discourseApiRequest(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: IHttpRequestMethods,
|
||||
path: string,
|
||||
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
_option = {},
|
||||
): Promise<any> {
|
||||
const credentials = await this.getCredentials<{ url: string }>('discourseApi');
|
||||
|
||||
const options: IRequestOptions = {
|
||||
method,
|
||||
body,
|
||||
qs,
|
||||
uri: `${credentials.url}${path}`,
|
||||
json: true,
|
||||
};
|
||||
|
||||
try {
|
||||
if (Object.keys(body as IDataObject).length === 0) {
|
||||
delete options.body;
|
||||
}
|
||||
return await this.helpers.requestWithAuthentication.call(this, 'discourseApi', options);
|
||||
} catch (error) {
|
||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||
}
|
||||
}
|
||||
|
||||
export async function discourseApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const returnData: IDataObject[] = [];
|
||||
|
||||
let responseData;
|
||||
query.page = 1;
|
||||
do {
|
||||
responseData = await discourseApiRequest.call(this, method, endpoint, body, query);
|
||||
returnData.push.apply(returnData, responseData as IDataObject[]);
|
||||
query.page++;
|
||||
} while (responseData.length !== 0);
|
||||
return returnData;
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const groupOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
description: 'Choose an operation',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['group'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a group',
|
||||
action: 'Create a group',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a group',
|
||||
action: 'Get a group',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many groups',
|
||||
action: 'Get many groups',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a group',
|
||||
action: 'Update a group',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const groupFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* group:create & get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['group'],
|
||||
operation: ['get', 'create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Name of the group',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* group:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['group'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['group'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 50,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* group:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Group ID',
|
||||
name: 'groupId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['group'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'ID of the group to update',
|
||||
},
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['group'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'New name of the group',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,228 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const postOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
description: 'Choose an operation',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['post'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a post',
|
||||
action: 'Create a post',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a post',
|
||||
action: 'Get a post',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many posts',
|
||||
action: 'Get many posts',
|
||||
},
|
||||
{
|
||||
name: 'Update',
|
||||
value: 'update',
|
||||
description: 'Update a post',
|
||||
action: 'Update a post',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const postFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* post:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Title',
|
||||
name: 'title',
|
||||
type: 'string',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['post'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Title of the post',
|
||||
},
|
||||
{
|
||||
displayName: 'Content',
|
||||
name: 'content',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['post'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Content of the post',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['post'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Category Name or ID',
|
||||
name: 'category',
|
||||
type: 'options',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getCategories',
|
||||
},
|
||||
default: '',
|
||||
description:
|
||||
'ID of the category. Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>.',
|
||||
},
|
||||
{
|
||||
displayName: 'Reply To Post Number',
|
||||
name: 'reply_to_post_number',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The number of the post to reply to',
|
||||
},
|
||||
{
|
||||
displayName: 'Topic ID',
|
||||
name: 'topic_id',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'ID of the topic',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* post:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Post ID',
|
||||
name: 'postId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['post'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'ID of the post',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* post:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['post'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['post'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 50,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* post:update */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Post ID',
|
||||
name: 'postId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['post'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'ID of the post',
|
||||
},
|
||||
{
|
||||
displayName: 'Content',
|
||||
name: 'content',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['post'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Content of the post. HTML is supported.',
|
||||
},
|
||||
{
|
||||
displayName: 'Update Fields',
|
||||
name: 'updateFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['post'],
|
||||
operation: ['update'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Edit Reason',
|
||||
name: 'edit_reason',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Cooked',
|
||||
name: 'cooked',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,59 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const searchOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
description: 'Choose an operation',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['search'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Query',
|
||||
value: 'query',
|
||||
description: 'Search for something',
|
||||
action: 'Perform a query',
|
||||
},
|
||||
],
|
||||
default: 'query',
|
||||
},
|
||||
];
|
||||
|
||||
export const searchFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* search:query */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Term',
|
||||
name: 'term',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['search'],
|
||||
operation: ['query'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Term to search for',
|
||||
},
|
||||
{
|
||||
displayName: 'Simplify',
|
||||
name: 'simple',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['search'],
|
||||
operation: ['query'],
|
||||
},
|
||||
},
|
||||
default: true,
|
||||
description: 'Whether to return a simplified version of the response instead of the raw data',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,352 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const userOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
description: 'Choose an operation',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a user',
|
||||
action: 'Create a user',
|
||||
},
|
||||
{
|
||||
name: 'Get',
|
||||
value: 'get',
|
||||
description: 'Get a user',
|
||||
action: 'Get a user',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Get many users',
|
||||
action: 'Get many users',
|
||||
},
|
||||
],
|
||||
default: 'create',
|
||||
},
|
||||
];
|
||||
|
||||
export const userFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* user:create */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Name',
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Name of the user to create',
|
||||
},
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
type: 'string',
|
||||
placeholder: 'name@email.com',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Email of the user to create',
|
||||
},
|
||||
{
|
||||
displayName: 'Username',
|
||||
name: 'username',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The username of the user to create',
|
||||
},
|
||||
{
|
||||
displayName: 'Password',
|
||||
name: 'password',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
password: true,
|
||||
},
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The password of the user to create',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Active',
|
||||
name: 'active',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
{
|
||||
displayName: 'Approved',
|
||||
name: 'approved',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* user:get */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'By',
|
||||
name: 'by',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Username',
|
||||
value: 'username',
|
||||
},
|
||||
{
|
||||
name: 'SSO External ID',
|
||||
value: 'externalId',
|
||||
},
|
||||
],
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['get'],
|
||||
},
|
||||
},
|
||||
default: 'username',
|
||||
description: 'What to search by',
|
||||
},
|
||||
{
|
||||
displayName: 'Username',
|
||||
name: 'username',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['get'],
|
||||
by: ['username'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The username of the user to return',
|
||||
},
|
||||
{
|
||||
displayName: 'SSO External ID',
|
||||
name: 'externalId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['get'],
|
||||
by: ['externalId'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Discourse SSO external ID',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* user:getAll */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Flag',
|
||||
name: 'flag',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Active',
|
||||
value: 'active',
|
||||
},
|
||||
{
|
||||
name: 'Blocked',
|
||||
value: 'blocked',
|
||||
},
|
||||
{
|
||||
name: 'New',
|
||||
value: 'new',
|
||||
},
|
||||
{
|
||||
name: 'Staff',
|
||||
value: 'staff',
|
||||
},
|
||||
{
|
||||
name: 'Suspect',
|
||||
value: 'suspect',
|
||||
},
|
||||
{
|
||||
name: 'Suspended',
|
||||
value: 'suspended',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'User flags to search for',
|
||||
},
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: false,
|
||||
description: 'Whether to return all results or only up to a given limit',
|
||||
},
|
||||
{
|
||||
displayName: 'Limit',
|
||||
name: 'limit',
|
||||
type: 'number',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['getAll'],
|
||||
returnAll: [false],
|
||||
},
|
||||
},
|
||||
typeOptions: {
|
||||
minValue: 1,
|
||||
maxValue: 100,
|
||||
},
|
||||
default: 50,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
{
|
||||
displayName: 'Options',
|
||||
name: 'options',
|
||||
type: 'collection',
|
||||
placeholder: 'Add option',
|
||||
default: {},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Ascending',
|
||||
name: 'asc',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description: 'Whether to sort ascending',
|
||||
},
|
||||
{
|
||||
displayName: 'Order',
|
||||
name: 'order',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Created',
|
||||
value: 'created',
|
||||
},
|
||||
{
|
||||
name: 'Days Visited',
|
||||
value: 'days_visited',
|
||||
},
|
||||
{
|
||||
name: 'Email',
|
||||
value: 'email',
|
||||
},
|
||||
{
|
||||
name: 'Last Emailed',
|
||||
value: 'last_emailed',
|
||||
},
|
||||
{
|
||||
name: 'Posts',
|
||||
value: 'posts',
|
||||
},
|
||||
{
|
||||
name: 'Posts Read',
|
||||
value: 'posts_read',
|
||||
},
|
||||
{
|
||||
name: 'Read Time',
|
||||
value: 'read_time',
|
||||
},
|
||||
{
|
||||
name: 'Seen',
|
||||
value: 'seen',
|
||||
},
|
||||
{
|
||||
name: 'Topics Viewed',
|
||||
value: 'topics_viewed',
|
||||
},
|
||||
{
|
||||
name: 'Trust Level',
|
||||
value: 'trust_level',
|
||||
},
|
||||
{
|
||||
name: 'Username',
|
||||
value: 'username',
|
||||
},
|
||||
],
|
||||
default: 'created',
|
||||
description: 'What to order by',
|
||||
},
|
||||
{
|
||||
displayName: 'Show Emails',
|
||||
name: 'showEmails',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to include user email addresses',
|
||||
},
|
||||
{
|
||||
displayName: 'Stats',
|
||||
name: 'stats',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description: 'Whether to return user stats',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,98 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
export const userGroupOperations: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
description: 'Choose an operation',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['userGroup'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Add',
|
||||
value: 'add',
|
||||
description: 'Create a user to group',
|
||||
action: 'Add a user to a group',
|
||||
},
|
||||
{
|
||||
name: 'Remove',
|
||||
value: 'remove',
|
||||
description: 'Remove user from group',
|
||||
action: 'Remove a user from a group',
|
||||
},
|
||||
],
|
||||
default: 'add',
|
||||
},
|
||||
];
|
||||
|
||||
export const userGroupFields: INodeProperties[] = [
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* userGroup:add */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Usernames',
|
||||
name: 'usernames',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['userGroup'],
|
||||
operation: ['add'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Usernames to add to group. Multiples can be defined separated by comma.',
|
||||
},
|
||||
{
|
||||
displayName: 'Group ID',
|
||||
name: 'groupId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['userGroup'],
|
||||
operation: ['add'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'ID of the group',
|
||||
},
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* userGroup:remove */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
{
|
||||
displayName: 'Usernames',
|
||||
name: 'usernames',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['userGroup'],
|
||||
operation: ['remove'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'Usernames to remove from group. Multiples can be defined separated by comma.',
|
||||
},
|
||||
{
|
||||
displayName: 'Group ID',
|
||||
name: 'groupId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['userGroup'],
|
||||
operation: ['remove'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'ID of the group to remove',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -1 104 106"><g data-name="Layer 2"><g data-name="Layer 3"><path fill="#231f20" d="M51.87 0C23.71 0 0 22.83 0 51v52.81l51.86-.05c28.16 0 51-23.71 51-51.87S80 0 51.87 0"/><path fill="#fff9ae" d="M52.37 19.74a31.62 31.62 0 0 0-27.79 46.67l-5.72 18.4 20.54-4.64a31.61 31.61 0 1 0 13-60.43z"/><path fill="#00aeef" d="M77.45 32.12a31.6 31.6 0 0 1-38.05 48l-20.54 4.7 20.91-2.47a31.6 31.6 0 0 0 37.68-50.23"/><path fill="#00a94f" d="M71.63 26.29A31.6 31.6 0 0 1 38.8 78l-19.94 6.82 20.54-4.65a31.6 31.6 0 0 0 32.23-53.88"/><path fill="#f15d22" d="M26.47 67.11a31.61 31.61 0 0 1 51-35 31.61 31.61 0 0 0-52.89 34.3l-5.72 18.4z"/><path fill="#e31b23" d="M24.58 66.41a31.61 31.61 0 0 1 47.05-40.12 31.61 31.61 0 0 0-49 39.63l-3.76 18.9z"/></g></g></svg>
|
||||
|
After Width: | Height: | Size: 793 B |
Reference in New Issue
Block a user