User and Stream descriptions

This commit is contained in:
Rupenieks 2020-05-19 13:47:21 +02:00
parent 718929cb3b
commit 6e0a8a143a
3 changed files with 770 additions and 0 deletions

View file

@ -0,0 +1,459 @@
import { INodeProperties } from "n8n-workflow";
export const streamOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'stream',
],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a stream.',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a stream.',
},
{
name: 'Get All',
value: 'getAll',
description: 'Get all streams.',
},
{
name: 'Get Subscribed',
value: 'getSubscribed',
description: 'Get subscribed streams.',
},
{
name: 'Update',
value: 'update',
description: 'Update a stream.',
},
],
default: 'create',
description: 'The operation to perform.',
},
] as INodeProperties[];
export const streamFields = [
/* -------------------------------------------------------------------------- */
/* stream:create */
/* -------------------------------------------------------------------------- */
{
displayName: 'Name',
name: 'name',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'stream',
],
operation: [
'create',
],
},
},
description: 'Name of stream to create.',
},
{
displayName: 'Description',
name: 'description',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'stream',
],
operation: [
'create',
],
},
},
description: 'Description of stream to create.',
},
{
displayName: 'JSON Parameters',
name: 'jsonParameters',
type: 'boolean',
default: false,
description: '',
displayOptions: {
show: {
resource: [
'stream',
],
operation: [
'create',
],
},
},
},
{
displayName: ' Additional Fields',
name: 'additionalFieldsJson',
type: 'json',
typeOptions: {
alwaysOpenEditWindow: true,
},
default: '',
displayOptions: {
show: {
resource: [
'stream',
],
operation: [
'create',
],
jsonParameters: [
true,
],
},
},
description: `JSON format parameters for stream creation.`,
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'stream',
],
operation: [
'create',
],
jsonParameters: [
false,
],
},
},
options: [
{
displayName: 'Invite Only',
name: 'inviteOnly',
type: 'boolean',
default: false,
description: 'A boolean specifying whether the streams specified in subscriptions are invite-only or not.',
},
{
displayName: 'Principals',
name: 'principals',
type: 'fixedCollection',
description: 'A list of email addresses of the users that will be subscribed/unsubscribed to the streams specified in the subscriptions argument. If not provided, then the requesting user/bot is subscribed.',
typeOptions: {
multipleValues: true,
},
options: [
{
displayName: 'Principals Properties',
name: 'properties',
values: [
{
displayName: 'Principal Email',
name: 'email',
type: 'string',
required: true,
default: '',
description: 'Principal email address.',
}
],
},
],
},
{
displayName: 'Authorization Errors Fatal',
name: 'authorizationsErrorsFatal',
type: 'boolean',
default: false,
description: 'A boolean specifying whether authorization errors (such as when the requesting user is not authorized to access a private stream) should be considered fatal or not. When True, an authorization error is reported as such. When set to False, the returned JSON payload indicates that there was an authorization error, but the response is still considered a successful one.',
},
{
displayName: 'History Public to Subscribers',
name: 'historyPublicToSubscribers',
type: 'boolean',
default: false,
description: 'Whether the streams message history should be available to newly subscribed members, or users can only access messages they actually received while subscribed to the stream.',
},
{
displayName: 'Stream Post Policy',
name: 'streamPostPolicy',
type: 'options',
default: '',
description: 'Policy for which users can post messages to the stream.',
options: [
{
name: '1',
value: 1,
description: 'Any user can post.'
},
{
name: '2',
value: 2,
description: 'Only administrators can post.'
},
{
name: '3',
value: 3,
description: 'Only new members can post.'
},
],
},
{
displayName: 'Announce',
name: 'announce',
type: 'boolean',
default: false,
description: 'If announce is True and one of the streams specified in subscriptions has to be created (i.e. doesnt exist to begin with), an announcement will be made notifying that a new stream was created.',
},
]
},
/* -------------------------------------------------------------------------- */
/* stream:get all */
/* -------------------------------------------------------------------------- */
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'stream',
],
operation: [
'getAll',
],
},
},
options: [
{
displayName: 'Include Public',
name: 'includePublic',
type: 'boolean',
default: true,
description: 'Include all public streams.',
},
{
displayName: 'Include Subscribed',
name: 'includeSubscribed',
type: 'boolean',
default: true,
description: 'Include all streams that the user is subscribed to.',
},
{
displayName: 'Include All Active',
name: 'includeAllActive',
type: 'boolean',
default: true,
description: 'Include all active streams. The user must have administrative privileges to use this parameter.',
},
{
displayName: 'Include Default',
name: 'includeDefault',
type: 'boolean',
default: true,
description: 'Include all default streams for the users realm.',
},
{
displayName: 'Include Owner Subscribed',
name: 'includeOwnersubscribed',
type: 'boolean',
default: true,
description: 'If the user is a bot, include all streams that the bots owner is subscribed to.',
},
]
},
/* -------------------------------------------------------------------------- */
/* stream:get subscribed */
/* -------------------------------------------------------------------------- */
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'stream',
],
operation: [
'getSubscribed',
],
},
},
options: [
{
displayName: 'Include Subscribers',
name: 'includeSubscribers',
type: 'boolean',
default: true,
description: 'Whether each returned stream object should include a subscribers field containing a list of the user IDs of its subscribers.',
}
]
},
/* -------------------------------------------------------------------------- */
/* stream:update */
/* -------------------------------------------------------------------------- */
{
displayName: 'Stream ID',
name: 'streamId',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: [
'stream',
],
operation: [
'update',
],
},
},
description: 'ID of stream to delete.',
},
{
displayName: 'JSON Parameters',
name: 'jsonParameters',
type: 'boolean',
default: false,
description: '',
displayOptions: {
show: {
resource: [
'stream',
],
operation: [
'update',
],
},
},
},
{
displayName: ' Additional Fields',
name: 'additionalFieldsJson',
type: 'json',
typeOptions: {
alwaysOpenEditWindow: true,
},
default: '',
displayOptions: {
show: {
resource: [
'stream',
],
operation: [
'update',
],
jsonParameters: [
true,
],
},
},
description: `JSON format parameters for stream creation.`,
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'stream',
],
operation: [
'update',
],
jsonParameters: [
false,
],
},
},
options: [
{
displayName: 'Description',
name: 'description',
type: 'string',
default: '',
description: 'The new description for the stream.',
},
{
displayName: 'New Name',
name: 'newName',
type: 'string',
default: '',
description: 'The new name for the stream.',
},
{
displayName: 'Announcement Only',
name: 'isAnnouncementOnly',
type: 'boolean',
default: false,
description: 'Whether the stream is limited to announcements.',
},
{
displayName: 'Is Private',
name: 'isPrivate',
type: 'boolean',
default: false,
description: 'Change whether the stream is a private stream.',
},
{
displayName: 'History Public to Subscribers',
name: 'historyPublicToSubscribers',
type: 'boolean',
default: false,
description: 'Whether the streams message history should be available to newly subscribed members, or users can only access messages they actually received while subscribed to the stream.',
},
{
displayName: 'Stream Post Policy',
name: 'streamPostPolicy',
type: 'options',
default: '',
description: 'Policy for which users can post messages to the stream.',
options: [
{
name: '1',
value: 1,
description: 'Any user can post.'
},
{
name: '2',
value: 2,
description: 'Only administrators can post.'
},
{
name: '3',
value: 3,
description: 'Only new members can post.'
},
],
},
]
},
] as INodeProperties[];

View file

@ -0,0 +1,291 @@
import { INodeProperties } from "n8n-workflow";
export const userOperations = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
displayOptions: {
show: {
resource: [
'user',
],
},
},
options: [
{
name: 'Create',
value: 'create',
description: 'Create a user.',
},
{
name: 'Deactivate',
value: 'deactivate',
description: 'Deactivate a user.',
},
{
name: 'Get',
value: 'get',
description: 'Get a user.',
},
{
name: 'Get All',
value: 'getAll',
description: 'Get all users.',
},
{
name: 'Update',
value: 'update',
description: 'Update a user.',
},
],
default: 'create',
description: 'The operation to perform.',
},
] as INodeProperties[];
export const userFields = [
/* -------------------------------------------------------------------------- */
/* user:create */
/* -------------------------------------------------------------------------- */
{
displayName: 'Email',
name: 'email',
type: 'string',
required: true,
displayOptions: {
show: {
resource: [
'user',
],
operation: [
'create',
],
},
},
default: '',
description: 'The email address of the new user.',
},
{
displayName: 'Password',
name: 'password',
type: 'string',
required: true,
displayOptions: {
show: {
resource: [
'user',
],
operation: [
'create',
],
},
},
default: '',
description: 'The password of the new user.',
},
{
displayName: 'Full Name',
name: 'fullName',
type: 'string',
required: true,
displayOptions: {
show: {
resource: [
'user',
],
operation: [
'create',
],
},
},
default: '',
description: 'The full name of the new user.',
},
{
displayName: 'Short Name',
name: 'fullName',
type: 'string',
required: true,
displayOptions: {
show: {
resource: [
'user',
],
operation: [
'create',
],
},
},
default: '',
description: 'The short name of the new user. Not user-visible.',
},
/* -------------------------------------------------------------------------- */
/* user:get / getAll */
/* -------------------------------------------------------------------------- */
{
displayName: 'User ID',
name: 'userId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: [
'user',
],
operation: [
'get',
],
},
},
default: '',
description: 'The ID of user to get.',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'user',
],
operation: [
'get', 'getAll'
],
},
},
options: [
{
displayName: 'Client Gravatar',
name: 'clientGravatar',
type: 'boolean',
default: false,
description: 'Whether the client supports computing gravatars URLs. If enabled, avatar_url will be included in the response only if there is a Zulip avatar, and will be null for users who are using gravatar as their avatar.',
},
{
displayName: 'Custom Profile Fields',
name: 'includeCustomProfileFields',
type: 'boolean',
default: false,
description: 'Whether the client wants custom profile field data to be included in the response.',
},
]
},
/* -------------------------------------------------------------------------- */
/* user:update */
/* -------------------------------------------------------------------------- */
{
displayName: 'User ID',
name: 'userId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: [
'user',
],
operation: [
'update',
],
},
},
default: '',
description: 'The ID of user to update.',
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'user',
],
operation: [
'update'
],
},
},
options: [
{
displayName: 'Full Name',
name: 'fullName',
type: 'string',
default: '',
description: 'The users full name.',
},
{
displayName: 'Is Admin',
name: 'isAdmin',
type: 'boolean',
default: false,
description: 'Whether the target user is an administrator.',
},
{
displayName: 'Is Guest',
name: 'isGuest',
type: 'boolean',
default: false,
description: 'Whether the target user is a guest.',
},
{
displayName: 'Profile Data',
name: 'profileData',
type: 'fixedCollection',
description: 'A dictionary containing the to be updated custom profile field data for the user.',
typeOptions: {
multipleValues: true,
},
options: [
{
displayName: 'Property',
name: 'property',
values: [
{
displayName: 'ID',
name: 'id',
type: 'string',
required: true,
default: '',
description: 'Id of custom profile data value.',
},
{
displayName: 'Value',
name: 'value',
type: 'string',
default: '',
description: 'Value of custom profile data.',
}
],
},
],
},
]
},
/* -------------------------------------------------------------------------- */
/* user:deactivate */
/* -------------------------------------------------------------------------- */
{
displayName: 'User ID',
name: 'userId',
type: 'string',
required: true,
displayOptions: {
show: {
resource: [
'user',
],
operation: [
'deactivate',
],
},
},
default: '',
description: 'The ID of user to deactivate.',
},
] as INodeProperties[];

View file

@ -21,6 +21,8 @@ import {
IMessage,
} from './MessageInterface';
import { snakeCase } from 'change-case';
import { streamFields, streamOperations } from './StreamDescription';
import { userOperations, userFields } from './UserDescription';
export class Zulip implements INodeType {
description: INodeTypeDescription = {
@ -53,12 +55,30 @@ export class Zulip implements INodeType {
name: 'Message',
value: 'message',
},
{
name: 'Stream',
value: 'stream',
},
{
name: 'User',
value: 'user',
},
],
default: 'message',
description: 'Resource to consume.',
},
// MESSAGE
...messageOperations,
...messageFields,
// STREAM
...streamOperations,
...streamFields,
// USER
...userOperations,
...userFields
],
};