Files
n8n-enterprise-unlocked/packages/nodes-base/nodes/Aws/Cognito/descriptions/group/create.operation.ts
Valentina Lilova f6e5efc2e0 feat(n8n AWS Cognito Node): New node (#11767)
Co-authored-by: Stamsy <stams_89@abv.bg>
Co-authored-by: Adina Totorean <adinatotorean99@gmail.com>
Co-authored-by: Giulio Andreini <g.andreini@gmail.com>
Co-authored-by: AdinaTotorean <64439268+adina-hub@users.noreply.github.com>
Co-authored-by: Shireen Missi <94372015+ShireenMissi@users.noreply.github.com>
Co-authored-by: feelgood-interface <feelgood.interface@gmail.com>
2025-05-08 10:50:48 +01:00

107 lines
2.5 KiB
TypeScript

import type { IExecuteSingleFunctions, IHttpRequestOptions, INodeProperties } from 'n8n-workflow';
import { NodeApiError, updateDisplayOptions } from 'n8n-workflow';
import { validateArn } from '../../helpers/utils';
import { userPoolResourceLocator } from '../common.description';
const properties: INodeProperties[] = [
{
...userPoolResourceLocator,
description: 'Select the user pool to use',
},
{
displayName: 'Group Name',
name: 'newGroupName',
default: '',
placeholder: 'e.g. MyNewGroup',
description: 'The name of the new group to create',
required: true,
type: 'string',
validateType: 'string',
routing: {
send: {
property: 'GroupName',
type: 'body',
preSend: [
async function (
this: IExecuteSingleFunctions,
requestOptions: IHttpRequestOptions,
): Promise<IHttpRequestOptions> {
const newGroupName = this.getNodeParameter('newGroupName', '') as string;
const groupNameRegex = /^[\p{L}\p{M}\p{S}\p{N}\p{P}]+$/u;
if (!groupNameRegex.test(newGroupName)) {
throw new NodeApiError(this.getNode(), {
message: 'Invalid format for Group Name',
description: 'Group Name should not contain spaces.',
});
}
return requestOptions;
},
],
},
},
},
{
displayName: 'Additional Fields',
name: 'additionalFields',
default: {},
options: [
{
displayName: 'Description',
name: 'description',
default: '',
placeholder: 'e.g. New group description',
description: 'A description for the new group',
type: 'string',
routing: {
send: {
type: 'body',
property: 'Description',
},
},
},
{
displayName: 'Precedence',
name: 'precedence',
default: '',
placeholder: 'e.g. 10',
description: 'Precedence value for the group. Lower values indicate higher priority.',
type: 'number',
routing: {
send: {
type: 'body',
property: 'Precedence',
},
},
validateType: 'number',
},
{
displayName: 'Role ARN',
name: 'arn',
default: '',
placeholder: 'e.g. arn:aws:iam::123456789012:role/GroupRole',
description: 'The role ARN for the group, used for setting claims in tokens',
type: 'string',
routing: {
send: {
type: 'body',
property: 'Arn',
preSend: [validateArn],
},
},
},
],
placeholder: 'Add Option',
type: 'collection',
},
];
const displayOptions = {
show: {
resource: ['group'],
operation: ['create'],
},
};
export const description = updateDisplayOptions(displayOptions, properties);