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,244 @@
|
||||
import type { UserProperties } from '../../Interfaces';
|
||||
|
||||
export const userCreateDescription: UserProperties = [
|
||||
{
|
||||
displayName: 'Username',
|
||||
name: 'username',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Auth Service',
|
||||
name: 'authService',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Email',
|
||||
value: 'email',
|
||||
},
|
||||
{
|
||||
name: 'Gitlab',
|
||||
value: 'gitlab',
|
||||
},
|
||||
{
|
||||
name: 'Google',
|
||||
value: 'google',
|
||||
},
|
||||
{
|
||||
name: 'LDAP',
|
||||
value: 'ldap',
|
||||
},
|
||||
{
|
||||
name: 'Office365',
|
||||
value: 'office365',
|
||||
},
|
||||
{
|
||||
name: 'SAML',
|
||||
value: 'saml',
|
||||
},
|
||||
],
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['create'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Auth Data',
|
||||
name: 'authData',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['create'],
|
||||
},
|
||||
hide: {
|
||||
authService: ['email'],
|
||||
},
|
||||
},
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
type: 'string',
|
||||
placeholder: 'name@email.com',
|
||||
default: '',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['create'],
|
||||
authService: ['email'],
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
displayName: 'Password',
|
||||
name: 'password',
|
||||
type: 'string',
|
||||
typeOptions: {
|
||||
password: true,
|
||||
},
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['create'],
|
||||
authService: ['email'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'The password used for email authentication',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
operation: ['create'],
|
||||
resource: ['user'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'First Name',
|
||||
name: 'first_name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Last Name',
|
||||
name: 'last_name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Locale',
|
||||
name: 'locale',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Nickname',
|
||||
name: 'nickname',
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Notification Settings',
|
||||
name: 'notificationUi',
|
||||
type: 'fixedCollection',
|
||||
placeholder: 'Add Notification Setting',
|
||||
default: {},
|
||||
typeOptions: {
|
||||
multipleValues: false,
|
||||
},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Notify',
|
||||
name: 'notificationValues',
|
||||
values: [
|
||||
{
|
||||
displayName: 'Channel',
|
||||
name: 'channel',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description:
|
||||
'Whether to enable channel-wide notifications (@channel, @all, etc.), "false" to disable. Defaults to "true".',
|
||||
},
|
||||
{
|
||||
displayName: 'Desktop',
|
||||
name: 'desktop',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'All',
|
||||
value: 'all',
|
||||
description: 'Notifications for all activity',
|
||||
},
|
||||
{
|
||||
name: 'Mention',
|
||||
value: 'mention',
|
||||
description: 'Mentions and direct messages only',
|
||||
},
|
||||
{
|
||||
name: 'None',
|
||||
value: 'none',
|
||||
description: 'Mentions and direct messages only',
|
||||
},
|
||||
],
|
||||
default: 'all',
|
||||
},
|
||||
{
|
||||
displayName: 'Desktop Sound',
|
||||
name: 'desktop_sound',
|
||||
type: 'boolean',
|
||||
default: true,
|
||||
description:
|
||||
'Whether to enable sound on desktop notifications, "false" to disable. Defaults to "true".',
|
||||
},
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description:
|
||||
'Whether to enable email notifications, "false" to disable. Defaults to "false".',
|
||||
},
|
||||
{
|
||||
displayName: 'First Name',
|
||||
name: 'first_name',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description:
|
||||
'Whether to enable mentions for first name. Defaults to "true" if a first name is set, "false" otherwise.',
|
||||
},
|
||||
{
|
||||
displayName: 'Mention Keys',
|
||||
name: 'mention_keys',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description:
|
||||
'A comma-separated list of words to count as mentions. Defaults to username and @username.',
|
||||
},
|
||||
{
|
||||
displayName: 'Push',
|
||||
name: 'push',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'All',
|
||||
value: 'all',
|
||||
description: 'Notifications for all activity',
|
||||
},
|
||||
{
|
||||
name: 'Mention',
|
||||
value: 'mention',
|
||||
description: 'Mentions and direct messages only',
|
||||
},
|
||||
{
|
||||
name: 'None',
|
||||
value: 'none',
|
||||
description: 'Mentions and direct messages only',
|
||||
},
|
||||
],
|
||||
default: 'mention',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,37 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function create(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const username = this.getNodeParameter('username', index) as string;
|
||||
const authService = this.getNodeParameter('authService', index) as string;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', index);
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'POST';
|
||||
const endpoint = 'users';
|
||||
const body = {} as IDataObject;
|
||||
|
||||
body.auth_service = authService;
|
||||
|
||||
body.username = username;
|
||||
Object.assign(body, additionalFields);
|
||||
|
||||
if (body.notificationUi) {
|
||||
body.notify_props = (body.notificationUi as IDataObject).notificationValues;
|
||||
}
|
||||
|
||||
if (authService === 'email') {
|
||||
body.email = this.getNodeParameter('email', index) as string;
|
||||
body.password = this.getNodeParameter('password', index) as string;
|
||||
} else {
|
||||
body.auth_data = this.getNodeParameter('authData', index) as string;
|
||||
}
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
|
||||
return this.helpers.returnJsonArray(responseData as IDataObject[]);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { userCreateDescription as description } from './description';
|
||||
import { create as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { UserProperties } from '../../Interfaces';
|
||||
|
||||
export const userDeactiveDescription: UserProperties = [
|
||||
{
|
||||
displayName: 'User ID',
|
||||
name: 'userId',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['deactive'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: 'User GUID',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function deactive(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const userId = this.getNodeParameter('userId', index) as string;
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'DELETE';
|
||||
const endpoint = `users/${userId}`;
|
||||
const body = {} as IDataObject;
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
|
||||
return this.helpers.returnJsonArray(responseData as IDataObject[]);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { userDeactiveDescription as description } from './description';
|
||||
import { deactive as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,103 @@
|
||||
import type { UserProperties } from '../../Interfaces';
|
||||
|
||||
export const userGetAllDescription: UserProperties = [
|
||||
{
|
||||
displayName: 'Return All',
|
||||
name: 'returnAll',
|
||||
type: 'boolean',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: true,
|
||||
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: 100,
|
||||
description: 'Max number of results to return',
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['getAll'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'In Channel',
|
||||
name: 'inChannel',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The ID of the channel to get users for',
|
||||
},
|
||||
{
|
||||
displayName: 'In Team',
|
||||
name: 'inTeam',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The ID of the team to get users for',
|
||||
},
|
||||
{
|
||||
displayName: 'Not In Team',
|
||||
name: 'notInTeam',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The ID of the team to exclude users for',
|
||||
},
|
||||
{
|
||||
displayName: 'Not In Channel',
|
||||
name: 'notInChannel',
|
||||
type: 'string',
|
||||
default: '',
|
||||
description: 'The ID of the channel to exclude users for',
|
||||
},
|
||||
{
|
||||
displayName: 'Sort',
|
||||
name: 'sort',
|
||||
type: 'options',
|
||||
options: [
|
||||
{
|
||||
name: 'Created At',
|
||||
value: 'createdAt',
|
||||
},
|
||||
{
|
||||
name: 'Last Activity At',
|
||||
value: 'lastActivityAt',
|
||||
},
|
||||
{
|
||||
name: 'Status',
|
||||
value: 'status',
|
||||
},
|
||||
{
|
||||
name: 'Username',
|
||||
value: 'username',
|
||||
},
|
||||
],
|
||||
default: 'username',
|
||||
description: 'The ID of the channel to exclude users for',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,111 @@
|
||||
import { snakeCase } from 'change-case';
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
import { NodeOperationError } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest, apiRequestAllItems } from '../../../transport';
|
||||
|
||||
export async function getAll(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const returnAll = this.getNodeParameter('returnAll', index);
|
||||
const additionalFields = this.getNodeParameter('additionalFields', index);
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'GET';
|
||||
const endpoint = '/users';
|
||||
const body = {} as IDataObject;
|
||||
|
||||
if (additionalFields.inTeam) {
|
||||
qs.in_team = additionalFields.inTeam;
|
||||
}
|
||||
|
||||
if (additionalFields.notInTeam) {
|
||||
qs.not_in_team = additionalFields.notInTeam;
|
||||
}
|
||||
|
||||
if (additionalFields.inChannel) {
|
||||
qs.in_channel = additionalFields.inChannel;
|
||||
}
|
||||
|
||||
if (additionalFields.notInChannel) {
|
||||
qs.not_in_channel = additionalFields.notInChannel;
|
||||
}
|
||||
|
||||
if (additionalFields.sort) {
|
||||
qs.sort = snakeCase(additionalFields.sort as string);
|
||||
}
|
||||
|
||||
const validRules = {
|
||||
inTeam: ['last_activity_at', 'created_at', 'username'],
|
||||
inChannel: ['status', 'username'],
|
||||
};
|
||||
|
||||
if (additionalFields.sort) {
|
||||
if (additionalFields.inTeam !== undefined || additionalFields.inChannel !== undefined) {
|
||||
if (
|
||||
additionalFields.inTeam !== undefined &&
|
||||
!validRules.inTeam.includes(snakeCase(additionalFields.sort as string))
|
||||
) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`When In Team is set the only valid values for sorting are ${validRules.inTeam.join(
|
||||
',',
|
||||
)}`,
|
||||
{ itemIndex: index },
|
||||
);
|
||||
}
|
||||
if (
|
||||
additionalFields.inChannel !== undefined &&
|
||||
!validRules.inChannel.includes(snakeCase(additionalFields.sort as string))
|
||||
) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`When In Channel is set the only valid values for sorting are ${validRules.inChannel.join(
|
||||
',',
|
||||
)}`,
|
||||
{ itemIndex: index },
|
||||
);
|
||||
}
|
||||
if (additionalFields.inChannel === '' && additionalFields.sort !== 'username') {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'When sort is different than username In Channel must be set',
|
||||
{ itemIndex: index },
|
||||
);
|
||||
}
|
||||
|
||||
if (additionalFields.inTeam === '' && additionalFields.sort !== 'username') {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'When sort is different than username In Team must be set',
|
||||
{ itemIndex: index },
|
||||
);
|
||||
}
|
||||
} else {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
"When sort is defined either 'in team' or 'in channel' must be defined",
|
||||
{ itemIndex: index },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (additionalFields.sort === 'username') {
|
||||
qs.sort = '';
|
||||
}
|
||||
|
||||
if (!returnAll) {
|
||||
qs.per_page = this.getNodeParameter('limit', index);
|
||||
}
|
||||
|
||||
let responseData;
|
||||
|
||||
if (returnAll) {
|
||||
responseData = await apiRequestAllItems.call(this, requestMethod, endpoint, body, qs);
|
||||
} else {
|
||||
responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
}
|
||||
|
||||
return this.helpers.returnJsonArray(responseData as IDataObject[]);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { userGetAllDescription as description } from './description';
|
||||
import { getAll as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { UserProperties } from '../../Interfaces';
|
||||
|
||||
export const userGetByEmailDescription: UserProperties = [
|
||||
{
|
||||
displayName: 'Email',
|
||||
name: 'email',
|
||||
type: 'string',
|
||||
placeholder: 'name@email.com',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['getByEmail'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: "User's email",
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function getByEmail(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const email = this.getNodeParameter('email', index) as string;
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'GET';
|
||||
const endpoint = `users/email/${email}`;
|
||||
const body = {} as IDataObject;
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
|
||||
return this.helpers.returnJsonArray(responseData as IDataObject[]);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { userGetByEmailDescription as description } from './description';
|
||||
import { getByEmail as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,41 @@
|
||||
import type { UserProperties } from '../../Interfaces';
|
||||
|
||||
export const userGetByIdDescription: UserProperties = [
|
||||
{
|
||||
displayName: 'User IDs',
|
||||
name: 'userIds',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['getById'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: "User's ID",
|
||||
},
|
||||
{
|
||||
displayName: 'Additional Fields',
|
||||
name: 'additionalFields',
|
||||
type: 'collection',
|
||||
placeholder: 'Add Field',
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['getById'],
|
||||
},
|
||||
},
|
||||
default: {},
|
||||
options: [
|
||||
{
|
||||
displayName: 'Since',
|
||||
name: 'since',
|
||||
type: 'dateTime',
|
||||
default: '',
|
||||
description:
|
||||
'Only return users that have been modified since the given Unix timestamp (in milliseconds)',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,23 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function getById(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'POST';
|
||||
const endpoint = 'users/ids';
|
||||
const userIds = (this.getNodeParameter('userIds', index) as string).split(',');
|
||||
const additionalFields = this.getNodeParameter('additionalFields', index);
|
||||
const body = userIds;
|
||||
|
||||
if (additionalFields.since) {
|
||||
qs.since = new Date(additionalFields.since as string).getTime();
|
||||
}
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
|
||||
return this.helpers.returnJsonArray(responseData as IDataObject[]);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { userGetByIdDescription as description } from './description';
|
||||
import { getById as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
@@ -0,0 +1,70 @@
|
||||
import type { INodeProperties } from 'n8n-workflow';
|
||||
|
||||
import * as create from './create';
|
||||
import * as deactive from './deactive';
|
||||
import * as getAll from './getAll';
|
||||
import * as getByEmail from './getByEmail';
|
||||
import * as getById from './getById';
|
||||
import * as invite from './invite';
|
||||
|
||||
export { create, deactive, getAll, getByEmail, getById, invite };
|
||||
|
||||
export const descriptions: INodeProperties[] = [
|
||||
{
|
||||
displayName: 'Operation',
|
||||
name: 'operation',
|
||||
type: 'options',
|
||||
noDataExpression: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
},
|
||||
},
|
||||
options: [
|
||||
{
|
||||
name: 'Create',
|
||||
value: 'create',
|
||||
description: 'Create a new user',
|
||||
action: 'Create a user',
|
||||
},
|
||||
{
|
||||
name: 'Deactive',
|
||||
value: 'deactive',
|
||||
description:
|
||||
'Deactivates the user and revokes all its sessions by archiving its user object',
|
||||
action: 'Deactivate a user',
|
||||
},
|
||||
{
|
||||
name: 'Get By Email',
|
||||
value: 'getByEmail',
|
||||
description: 'Get a user by email',
|
||||
action: 'Get a user by email',
|
||||
},
|
||||
{
|
||||
name: 'Get By ID',
|
||||
value: 'getById',
|
||||
description: 'Get a user by ID',
|
||||
action: 'Get a user by ID',
|
||||
},
|
||||
{
|
||||
name: 'Get Many',
|
||||
value: 'getAll',
|
||||
description: 'Retrieve many users',
|
||||
action: 'Get many users',
|
||||
},
|
||||
{
|
||||
name: 'Invite',
|
||||
value: 'invite',
|
||||
description: 'Invite user to team',
|
||||
action: 'Invite a user',
|
||||
},
|
||||
],
|
||||
default: '',
|
||||
},
|
||||
...create.description,
|
||||
...deactive.description,
|
||||
...getAll.description,
|
||||
...getByEmail.description,
|
||||
...getById.description,
|
||||
...invite.description,
|
||||
];
|
||||
@@ -0,0 +1,36 @@
|
||||
import type { UserProperties } from '../../Interfaces';
|
||||
|
||||
export const userInviteDescription: UserProperties = [
|
||||
{
|
||||
displayName: 'Team Name or ID',
|
||||
name: 'teamId',
|
||||
type: 'options',
|
||||
description:
|
||||
'Choose from the list, or specify an ID using an <a href="https://docs.n8n.io/code/expressions/">expression</a>',
|
||||
typeOptions: {
|
||||
loadOptionsMethod: 'getTeams',
|
||||
},
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['invite'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
},
|
||||
{
|
||||
displayName: 'Emails',
|
||||
name: 'emails',
|
||||
type: 'string',
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
resource: ['user'],
|
||||
operation: ['invite'],
|
||||
},
|
||||
},
|
||||
default: '',
|
||||
description: "User's email. Multiple emails can be set separated by comma.",
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { IExecuteFunctions, IDataObject, INodeExecutionData } from 'n8n-workflow';
|
||||
|
||||
import { apiRequest } from '../../../transport';
|
||||
|
||||
export async function invite(
|
||||
this: IExecuteFunctions,
|
||||
index: number,
|
||||
): Promise<INodeExecutionData[]> {
|
||||
const teamId = this.getNodeParameter('teamId', index) as string;
|
||||
|
||||
const emails = (this.getNodeParameter('emails', index) as string).split(',');
|
||||
|
||||
const qs = {} as IDataObject;
|
||||
const requestMethod = 'POST';
|
||||
const endpoint = `teams/${teamId}/invite/email`;
|
||||
const body = emails;
|
||||
|
||||
const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs);
|
||||
|
||||
return this.helpers.returnJsonArray(responseData as IDataObject[]);
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import { userInviteDescription as description } from './description';
|
||||
import { invite as execute } from './execute';
|
||||
|
||||
export { description, execute };
|
||||
Reference in New Issue
Block a user