mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
Updated User description
This commit is contained in:
parent
6eb585dc1a
commit
e85ced02df
|
@ -9,7 +9,12 @@ import {
|
||||||
groupOperations,
|
groupOperations,
|
||||||
groupFields,
|
groupFields,
|
||||||
} from './descriptions';
|
} from './descriptions';
|
||||||
import { presendStringifyBody, searchUserPools, searchGroups } from './GenericFunctions';
|
import {
|
||||||
|
presendStringifyBody,
|
||||||
|
searchUserPools,
|
||||||
|
searchGroups,
|
||||||
|
searchUsers,
|
||||||
|
} from './GenericFunctions';
|
||||||
|
|
||||||
export class AwsCognito implements INodeType {
|
export class AwsCognito implements INodeType {
|
||||||
description: INodeTypeDescription = {
|
description: INodeTypeDescription = {
|
||||||
|
@ -88,6 +93,7 @@ export class AwsCognito implements INodeType {
|
||||||
listSearch: {
|
listSearch: {
|
||||||
searchUserPools,
|
searchUserPools,
|
||||||
searchGroups,
|
searchGroups,
|
||||||
|
searchUsers,
|
||||||
// Todo: Add more search methods
|
// Todo: Add more search methods
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -342,39 +342,72 @@ export async function searchUsers(
|
||||||
filter?: string,
|
filter?: string,
|
||||||
paginationToken?: string,
|
paginationToken?: string,
|
||||||
): Promise<INodeListSearchResult> {
|
): Promise<INodeListSearchResult> {
|
||||||
|
// Get the userPoolId from the input
|
||||||
|
const userPoolIdRaw = this.getNodeParameter('userPoolId', '') as IDataObject;
|
||||||
|
|
||||||
|
// Extract the actual value
|
||||||
|
const userPoolId = userPoolIdRaw.value as string;
|
||||||
|
|
||||||
|
// Ensure that userPoolId is provided
|
||||||
|
if (!userPoolId) {
|
||||||
|
throw new ApplicationError('User Pool ID is required to search users');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup the options for the AWS request
|
||||||
const opts: IHttpRequestOptions = {
|
const opts: IHttpRequestOptions = {
|
||||||
url: '', // the base url is set in "awsRequest"
|
url: '', // the base URL is set in "awsRequest"
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'X-Amz-Target': 'AWSCognitoIdentityProviderService.ListUsers',
|
'X-Amz-Target': 'AWSCognitoIdentityProviderService.ListUsers',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
MaxResults: 60, // the maximum number by documentation is 60
|
UserPoolId: userPoolId,
|
||||||
|
MaxResults: 60,
|
||||||
NextToken: paginationToken ?? undefined,
|
NextToken: paginationToken ?? undefined,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Make the AWS request
|
||||||
const responseData: IDataObject = await awsRequest.call(this, opts);
|
const responseData: IDataObject = await awsRequest.call(this, opts);
|
||||||
|
|
||||||
const users = responseData.Users as Array<{ Name: string; Id: string }>;
|
// Extract users from the response
|
||||||
|
const users = responseData.Users as IDataObject[] | undefined;
|
||||||
|
|
||||||
|
// Handle cases where no users are returned
|
||||||
|
if (!users) {
|
||||||
|
console.warn('No users found in the response');
|
||||||
|
return { results: [] };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Map and filter the response data to create results
|
||||||
const results: INodeListSearchItems[] = users
|
const results: INodeListSearchItems[] = users
|
||||||
.map((a) => ({
|
.map((user) => {
|
||||||
name: a.Name,
|
// Extract user attributes, if any
|
||||||
value: a.Id,
|
const attributes = user.Attributes as Array<{ Name: string; Value: string }> | undefined;
|
||||||
}))
|
|
||||||
|
// Find the `email` or `sub` attribute, fallback to `Username`
|
||||||
|
const email = attributes?.find((attr) => attr.Name === 'email')?.Value;
|
||||||
|
const sub = attributes?.find((attr) => attr.Name === 'sub')?.Value;
|
||||||
|
const username = user.Username as string;
|
||||||
|
|
||||||
|
// Use email, sub, or Username as the user name and value
|
||||||
|
const name = email || sub || username;
|
||||||
|
const value = username;
|
||||||
|
|
||||||
|
return { name, value };
|
||||||
|
})
|
||||||
.filter(
|
.filter(
|
||||||
(a) =>
|
(user) =>
|
||||||
!filter ||
|
!filter ||
|
||||||
a.name.toLowerCase().includes(filter.toLowerCase()) ||
|
user.name.toLowerCase().includes(filter.toLowerCase()) ||
|
||||||
a.value.toLowerCase().includes(filter.toLowerCase()),
|
user.value.toLowerCase().includes(filter.toLowerCase()),
|
||||||
)
|
)
|
||||||
.sort((a, b) => {
|
.sort((a, b) => {
|
||||||
if (a.name.toLowerCase() < b.name.toLowerCase()) return -1;
|
return a.name.toLowerCase().localeCompare(b.name.toLowerCase());
|
||||||
if (a.name.toLowerCase() > b.name.toLowerCase()) return 1;
|
|
||||||
return 0;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return { results, paginationToken: responseData.NextToken }; // ToDo: Test if pagination for the search methods works
|
// Return the results and the pagination token
|
||||||
|
return { results, paginationToken: responseData.NextToken as string | undefined };
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function searchGroups(
|
export async function searchGroups(
|
||||||
|
@ -384,7 +417,6 @@ export async function searchGroups(
|
||||||
): Promise<INodeListSearchResult> {
|
): Promise<INodeListSearchResult> {
|
||||||
// Get the userPoolId from the input
|
// Get the userPoolId from the input
|
||||||
const userPoolIdRaw = this.getNodeParameter('userPoolId', '') as IDataObject;
|
const userPoolIdRaw = this.getNodeParameter('userPoolId', '') as IDataObject;
|
||||||
console.log('Raw User Pool ID:', userPoolIdRaw);
|
|
||||||
|
|
||||||
// Extract the actual value
|
// Extract the actual value
|
||||||
const userPoolId = userPoolIdRaw.value as string;
|
const userPoolId = userPoolIdRaw.value as string;
|
||||||
|
|
|
@ -1,9 +1,4 @@
|
||||||
import {
|
import type { INodeProperties } from 'n8n-workflow';
|
||||||
NodeOperationError,
|
|
||||||
type IExecuteSingleFunctions,
|
|
||||||
type IHttpRequestOptions,
|
|
||||||
type INodeProperties,
|
|
||||||
} from 'n8n-workflow';
|
|
||||||
|
|
||||||
import { handleErrorPostReceive, presendFilter, presendTest } from '../GenericFunctions';
|
import { handleErrorPostReceive, presendFilter, presendTest } from '../GenericFunctions';
|
||||||
|
|
||||||
|
@ -14,7 +9,11 @@ export const userOperations: INodeProperties[] = [
|
||||||
type: 'options',
|
type: 'options',
|
||||||
noDataExpression: true,
|
noDataExpression: true,
|
||||||
default: 'getAll',
|
default: 'getAll',
|
||||||
displayOptions: { show: { resource: ['user'] } },
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: ['user'],
|
||||||
|
},
|
||||||
|
},
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
name: 'Add to Group',
|
name: 'Add to Group',
|
||||||
|
@ -25,7 +24,7 @@ export const userOperations: INodeProperties[] = [
|
||||||
request: {
|
request: {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'X-Amz-Target': 'AWSCognitoIdentityProviderService.AddUserToGroup',
|
'X-Amz-Target': 'AWSCognitoIdentityProviderService.AdminAddUserToGroup',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
|
@ -42,7 +41,7 @@ export const userOperations: INodeProperties[] = [
|
||||||
request: {
|
request: {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'X-Amz-Target': 'AWSCognitoIdentityProviderService.CreateUser',
|
'X-Amz-Target': 'AWSCognitoIdentityProviderService.AdminCreateUser',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
|
@ -59,7 +58,7 @@ export const userOperations: INodeProperties[] = [
|
||||||
request: {
|
request: {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'X-Amz-Target': 'AWSCognitoIdentityProviderService.DeleteUser',
|
'X-Amz-Target': 'AWSCognitoIdentityProviderService.AdminDeleteUser',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
|
@ -76,7 +75,7 @@ export const userOperations: INodeProperties[] = [
|
||||||
request: {
|
request: {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'X-Amz-Target': 'AWSCognitoIdentityProviderService.GetUser',
|
'X-Amz-Target': 'AWSCognitoIdentityProviderService.AdminGetUser',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
|
@ -118,7 +117,7 @@ export const userOperations: INodeProperties[] = [
|
||||||
request: {
|
request: {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'X-Amz-Target': 'AWSCognitoIdentityProviderService.RemoveUserFromGroup',
|
'X-Amz-Target': 'AWSCognitoIdentityProviderService.AdminRemoveUserFromGroup',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
|
@ -135,7 +134,7 @@ export const userOperations: INodeProperties[] = [
|
||||||
request: {
|
request: {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'X-Amz-Target': 'AWSCognitoIdentityProviderService.UpdateUser',
|
'X-Amz-Target': 'AWSCognitoIdentityProviderService.AdminUpdateUserAttributes',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
|
@ -148,61 +147,61 @@ export const userOperations: INodeProperties[] = [
|
||||||
];
|
];
|
||||||
|
|
||||||
const createFields: INodeProperties[] = [
|
const createFields: INodeProperties[] = [
|
||||||
// {
|
|
||||||
// displayName: 'User Pool ID',
|
|
||||||
// name: 'userPoolId',
|
|
||||||
// required: true,
|
|
||||||
// type: 'resourceLocator',
|
|
||||||
// default: {
|
|
||||||
// mode: 'list',
|
|
||||||
// value: '',
|
|
||||||
// },
|
|
||||||
// description: 'The user pool ID where the users are managed',
|
|
||||||
// displayOptions: {
|
|
||||||
// show: {
|
|
||||||
// resource: ['user'],
|
|
||||||
// operation: ['create'],
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// routing: {
|
|
||||||
// send: {
|
|
||||||
// type: 'body',
|
|
||||||
// property: 'UserPoolId',
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// modes: [
|
|
||||||
// {
|
|
||||||
// displayName: 'From list', // ToDo: Fix error when selecting this option
|
|
||||||
// name: 'list',
|
|
||||||
// type: 'list',
|
|
||||||
// typeOptions: {
|
|
||||||
// searchListMethod: 'searchUserPools',
|
|
||||||
// searchable: true,
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// displayName: 'By ID',
|
|
||||||
// name: 'id',
|
|
||||||
// type: 'string',
|
|
||||||
// hint: 'Enter the user pool ID',
|
|
||||||
// placeholder: 'e.g. eu-central-1_ab12cdefgh',
|
|
||||||
// validation: [
|
|
||||||
// {
|
|
||||||
// type: 'regex',
|
|
||||||
// properties: {
|
|
||||||
// regex: '^[\\w-]+_[0-9a-zA-Z]+$',
|
|
||||||
// errorMessage: 'The ID must follow the pattern "xxxxxx_xxxxxxxxxxx"',
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
// ],
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
displayName: 'User Name',
|
displayName: 'User Pool ID',
|
||||||
name: 'UserName',
|
name: 'userPoolId',
|
||||||
|
required: true,
|
||||||
|
type: 'resourceLocator',
|
||||||
|
default: {
|
||||||
|
mode: 'list',
|
||||||
|
value: '',
|
||||||
|
},
|
||||||
|
description: 'The user pool ID where the users are managed',
|
||||||
|
displayOptions: {
|
||||||
|
show: {
|
||||||
|
resource: ['user'],
|
||||||
|
operation: ['create'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
routing: {
|
||||||
|
send: {
|
||||||
|
type: 'body',
|
||||||
|
property: 'UserPoolId',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
modes: [
|
||||||
|
{
|
||||||
|
displayName: 'From list', // ToDo: Fix error when selecting this option
|
||||||
|
name: 'list',
|
||||||
|
type: 'list',
|
||||||
|
typeOptions: {
|
||||||
|
searchListMethod: 'searchUserPools',
|
||||||
|
searchable: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'By ID',
|
||||||
|
name: 'id',
|
||||||
|
type: 'string',
|
||||||
|
hint: 'Enter the user pool ID',
|
||||||
|
placeholder: 'e.g. eu-central-1_ab12cdefgh',
|
||||||
|
validation: [
|
||||||
|
{
|
||||||
|
type: 'regex',
|
||||||
|
properties: {
|
||||||
|
regex: '^[\\w-]+_[0-9a-zA-Z]+$',
|
||||||
|
errorMessage: 'The ID must follow the pattern "xxxxxx_xxxxxxxxxxx"',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
displayName: 'Username',
|
||||||
|
name: 'Username',
|
||||||
default: '',
|
default: '',
|
||||||
description: 'The name of the new user to create',
|
description: 'The username of the new user to create',
|
||||||
placeholder: 'e.g. JohnSmith',
|
placeholder: 'e.g. JohnSmith',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
|
@ -213,7 +212,7 @@ const createFields: INodeProperties[] = [
|
||||||
required: true,
|
required: true,
|
||||||
routing: {
|
routing: {
|
||||||
send: {
|
send: {
|
||||||
property: 'UserName',
|
property: 'Username',
|
||||||
type: 'body',
|
type: 'body',
|
||||||
preSend: [presendTest],
|
preSend: [presendTest],
|
||||||
},
|
},
|
||||||
|
@ -236,7 +235,7 @@ const createFields: INodeProperties[] = [
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
displayName: 'Path',
|
displayName: 'Path',
|
||||||
name: 'path',
|
name: 'Path',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validateType: 'string',
|
validateType: 'string',
|
||||||
default: '/',
|
default: '/',
|
||||||
|
@ -245,14 +244,15 @@ const createFields: INodeProperties[] = [
|
||||||
'The path for the user name, if it is not included, it defaults to a slash (/)',
|
'The path for the user name, if it is not included, it defaults to a slash (/)',
|
||||||
routing: {
|
routing: {
|
||||||
send: {
|
send: {
|
||||||
property: 'path',
|
property: 'Path',
|
||||||
type: 'body',
|
type: 'body',
|
||||||
|
preSend: [presendTest],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Permissions Boundary',
|
displayName: 'Permissions Boundary',
|
||||||
name: 'permissionsBoundary',
|
name: 'PermissionsBoundary',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validateType: 'string',
|
validateType: 'string',
|
||||||
default: '',
|
default: '',
|
||||||
|
@ -260,14 +260,15 @@ const createFields: INodeProperties[] = [
|
||||||
description: 'Enter the ARN of a policy to set as the Permissions Boundary',
|
description: 'Enter the ARN of a policy to set as the Permissions Boundary',
|
||||||
routing: {
|
routing: {
|
||||||
send: {
|
send: {
|
||||||
property: 'permissionsBoundary',
|
property: 'PermissionsBoundary',
|
||||||
type: 'body',
|
type: 'body',
|
||||||
|
preSend: [presendTest],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Tags',
|
displayName: 'Tags',
|
||||||
name: 'tags',
|
name: 'Tags',
|
||||||
type: 'multiOptions',
|
type: 'multiOptions',
|
||||||
placeholder: 'Add Tags',
|
placeholder: 'Add Tags',
|
||||||
default: [],
|
default: [],
|
||||||
|
@ -276,8 +277,9 @@ const createFields: INodeProperties[] = [
|
||||||
options: [],
|
options: [],
|
||||||
routing: {
|
routing: {
|
||||||
send: {
|
send: {
|
||||||
property: 'tags',
|
property: 'Tags',
|
||||||
type: 'body',
|
type: 'body',
|
||||||
|
preSend: [presendTest],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -306,6 +308,7 @@ const getFields: INodeProperties[] = [
|
||||||
send: {
|
send: {
|
||||||
type: 'body',
|
type: 'body',
|
||||||
property: 'UserPoolId',
|
property: 'UserPoolId',
|
||||||
|
preSend: [presendTest],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
modes: [
|
modes: [
|
||||||
|
@ -337,10 +340,8 @@ const getFields: INodeProperties[] = [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'User',
|
displayName: 'User Name',
|
||||||
name: 'user',
|
name: 'Username',
|
||||||
required: true,
|
|
||||||
type: 'resourceLocator',
|
|
||||||
default: {
|
default: {
|
||||||
mode: 'list',
|
mode: 'list',
|
||||||
value: '',
|
value: '',
|
||||||
|
@ -354,11 +355,11 @@ const getFields: INodeProperties[] = [
|
||||||
},
|
},
|
||||||
modes: [
|
modes: [
|
||||||
{
|
{
|
||||||
displayName: 'From list', // ToDo: Fix error when selecting this option
|
displayName: 'From List',
|
||||||
name: 'list',
|
name: 'list',
|
||||||
type: 'list',
|
type: 'list',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
searchListMethod: 'searchUserPools',
|
searchListMethod: 'searchUsers',
|
||||||
searchable: true,
|
searchable: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -367,7 +368,7 @@ const getFields: INodeProperties[] = [
|
||||||
name: 'id',
|
name: 'id',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
hint: 'Enter the user ID',
|
hint: 'Enter the user ID',
|
||||||
placeholder: 'e.g. eu-central-1_ab12cdefgh',
|
placeholder: 'e.g. 02bd9fd6-8f93-4758-87c3-1fb73740a315',
|
||||||
validation: [
|
validation: [
|
||||||
{
|
{
|
||||||
type: 'regex',
|
type: 'regex',
|
||||||
|
@ -379,6 +380,15 @@ const getFields: INodeProperties[] = [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
routing: {
|
||||||
|
send: {
|
||||||
|
type: 'body',
|
||||||
|
property: 'Username',
|
||||||
|
preSend: [presendTest],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
required: true,
|
||||||
|
type: 'resourceLocator',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -603,6 +613,7 @@ const deleteFields: INodeProperties[] = [
|
||||||
send: {
|
send: {
|
||||||
type: 'body',
|
type: 'body',
|
||||||
property: 'UserPoolId',
|
property: 'UserPoolId',
|
||||||
|
preSend: [presendTest],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
modes: [
|
modes: [
|
||||||
|
@ -620,7 +631,6 @@ const deleteFields: INodeProperties[] = [
|
||||||
name: 'id',
|
name: 'id',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
hint: 'Enter the user pool ID',
|
hint: 'Enter the user pool ID',
|
||||||
placeholder: 'e.g. eu-central-1_ab12cdefgh',
|
|
||||||
validation: [
|
validation: [
|
||||||
{
|
{
|
||||||
type: 'regex',
|
type: 'regex',
|
||||||
|
@ -630,14 +640,13 @@ const deleteFields: INodeProperties[] = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
placeholder: 'e.g. eu-central-1_ab12cdefgh',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'User',
|
displayName: 'User Name',
|
||||||
name: 'user',
|
name: 'Username',
|
||||||
required: true,
|
|
||||||
type: 'resourceLocator',
|
|
||||||
default: {
|
default: {
|
||||||
mode: 'list',
|
mode: 'list',
|
||||||
value: '',
|
value: '',
|
||||||
|
@ -655,7 +664,7 @@ const deleteFields: INodeProperties[] = [
|
||||||
name: 'list',
|
name: 'list',
|
||||||
type: 'list',
|
type: 'list',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
searchListMethod: 'searchUserPools',
|
searchListMethod: 'searchUsers',
|
||||||
searchable: true,
|
searchable: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -676,6 +685,15 @@ const deleteFields: INodeProperties[] = [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
routing: {
|
||||||
|
send: {
|
||||||
|
type: 'body',
|
||||||
|
property: 'Username',
|
||||||
|
preSend: [presendTest],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
required: true,
|
||||||
|
type: 'resourceLocator',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -700,6 +718,7 @@ const updateFields: INodeProperties[] = [
|
||||||
send: {
|
send: {
|
||||||
type: 'body',
|
type: 'body',
|
||||||
property: 'UserPoolId',
|
property: 'UserPoolId',
|
||||||
|
preSend: [presendTest],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
modes: [
|
modes: [
|
||||||
|
@ -731,8 +750,8 @@ const updateFields: INodeProperties[] = [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'User',
|
displayName: 'User Name',
|
||||||
name: 'user',
|
name: 'Username',
|
||||||
default: {
|
default: {
|
||||||
mode: 'list',
|
mode: 'list',
|
||||||
value: '',
|
value: '',
|
||||||
|
@ -750,7 +769,7 @@ const updateFields: INodeProperties[] = [
|
||||||
name: 'list',
|
name: 'list',
|
||||||
type: 'list',
|
type: 'list',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
searchListMethod: 'searchUserPools',
|
searchListMethod: 'searchUsers',
|
||||||
searchable: true,
|
searchable: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -771,60 +790,71 @@ const updateFields: INodeProperties[] = [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
routing: {
|
||||||
|
send: {
|
||||||
|
type: 'body',
|
||||||
|
property: 'Username',
|
||||||
|
preSend: [presendTest],
|
||||||
|
},
|
||||||
|
},
|
||||||
required: true,
|
required: true,
|
||||||
type: 'resourceLocator',
|
type: 'resourceLocator',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'User Name',
|
displayName: 'User Attributes',
|
||||||
name: 'userName',
|
name: 'UserAttributes',
|
||||||
default: '',
|
type: 'fixedCollection',
|
||||||
description: 'The name of the new user to create',
|
placeholder: 'Add Attribute',
|
||||||
placeholder: 'e.g. JohnSmith',
|
default: {
|
||||||
|
attributes: [],
|
||||||
|
},
|
||||||
|
required: true,
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: ['user'],
|
resource: ['user'],
|
||||||
operation: ['update'],
|
operation: ['update'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
required: true,
|
description: 'Attributes to update for the user',
|
||||||
routing: {
|
typeOptions: {
|
||||||
send: {
|
multipleValues: true,
|
||||||
property: 'userName',
|
},
|
||||||
type: 'body',
|
options: [
|
||||||
preSend: [
|
{
|
||||||
async function (
|
displayName: 'Attributes',
|
||||||
this: IExecuteSingleFunctions,
|
name: 'attributes',
|
||||||
requestOptions: IHttpRequestOptions,
|
values: [
|
||||||
): Promise<IHttpRequestOptions> {
|
{
|
||||||
const userName = this.getNodeParameter('userName') as string;
|
displayName: 'Name',
|
||||||
if (userName.length < 1 || userName.length > 128) {
|
name: 'Name',
|
||||||
throw new NodeOperationError(
|
type: 'string',
|
||||||
this.getNode(),
|
default: '',
|
||||||
'User Name must be between 1 and 128 characters.',
|
description: 'The name of the attribute (e.g., custom:deliverables)',
|
||||||
);
|
},
|
||||||
}
|
{
|
||||||
|
displayName: 'Value',
|
||||||
// Regex validation
|
name: 'Value',
|
||||||
if (!/^[\w+=,.@-]+$/.test(userName)) {
|
type: 'string',
|
||||||
throw new NodeOperationError(
|
default: '',
|
||||||
this.getNode(),
|
description: 'The value of the attribute',
|
||||||
'User Name contains invalid characters. Allowed characters: [\\w+=,.@-].',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return requestOptions;
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
],
|
||||||
|
routing: {
|
||||||
|
send: {
|
||||||
|
type: 'body',
|
||||||
|
property: 'UserAttributes',
|
||||||
|
value:
|
||||||
|
'={{ $value.attributes?.map(attribute => ({ Name: attribute.Name, Value: attribute.Value })) || [] }}',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
type: 'string',
|
|
||||||
validateType: 'string',
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Options',
|
displayName: 'Additional Fields',
|
||||||
name: 'option',
|
name: 'additionalFields',
|
||||||
type: 'collection',
|
type: 'collection',
|
||||||
placeholder: 'Add Option',
|
placeholder: 'Add Field',
|
||||||
default: {},
|
default: {},
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
|
@ -834,33 +864,45 @@ const updateFields: INodeProperties[] = [
|
||||||
},
|
},
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
displayName: 'Path',
|
displayName: 'Client Metadata',
|
||||||
name: 'path',
|
name: 'clientMetadata',
|
||||||
type: 'string',
|
type: 'fixedCollection',
|
||||||
validateType: 'string',
|
placeholder: 'Add Metadata Pair',
|
||||||
default: '/',
|
default: { metadata: [] },
|
||||||
placeholder: 'e.g. /division_abc/engineering/',
|
description: 'A map of custom key-value pairs for workflows triggered by this action',
|
||||||
description:
|
typeOptions: {
|
||||||
'The path for the user name, if it is not included, it defaults to a slash (/)',
|
multipleValues: true,
|
||||||
},
|
},
|
||||||
{
|
options: [
|
||||||
displayName: 'Permissions Boundary',
|
{
|
||||||
name: 'permissionsBoundary',
|
displayName: 'Metadata',
|
||||||
type: 'string',
|
name: 'metadata',
|
||||||
validateType: 'string',
|
values: [
|
||||||
default: '',
|
{
|
||||||
placeholder: 'e.g. arn:aws:iam::123456789012:policy/ExampleBoundaryPolicy',
|
displayName: 'Key',
|
||||||
description: 'Enter the ARN of a policy to set as the Permissions Boundary',
|
name: 'key',
|
||||||
},
|
type: 'string',
|
||||||
{
|
default: '',
|
||||||
displayName: 'Tags',
|
description: 'The key of the metadata attribute',
|
||||||
name: 'tags',
|
},
|
||||||
type: 'multiOptions',
|
{
|
||||||
placeholder: 'Add Tags',
|
displayName: 'Value',
|
||||||
default: [],
|
name: 'value',
|
||||||
description: 'A list of tags that you want to attach to the new user',
|
type: 'string',
|
||||||
//TO-DO-GET TAGS LIST
|
default: '',
|
||||||
options: [],
|
description: 'The value of the metadata attribute',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
routing: {
|
||||||
|
send: {
|
||||||
|
type: 'body',
|
||||||
|
property: 'ClientMetadata',
|
||||||
|
value:
|
||||||
|
'={{ $value.metadata && $value.metadata.length > 0 ? Object.fromEntries($value.metadata.map(attribute => [attribute.Name, attribute.Value])) : {} }}',
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -876,7 +918,7 @@ const addToGroupFields: INodeProperties[] = [
|
||||||
mode: 'list',
|
mode: 'list',
|
||||||
value: '',
|
value: '',
|
||||||
},
|
},
|
||||||
description: 'The ID of the user pool',
|
description: 'The user pool ID where the users are managed',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: ['user'],
|
resource: ['user'],
|
||||||
|
@ -904,7 +946,6 @@ const addToGroupFields: INodeProperties[] = [
|
||||||
name: 'id',
|
name: 'id',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
hint: 'Enter the user pool ID',
|
hint: 'Enter the user pool ID',
|
||||||
placeholder: 'e.g. eu-central-1_ab12cdefgh',
|
|
||||||
validation: [
|
validation: [
|
||||||
{
|
{
|
||||||
type: 'regex',
|
type: 'regex',
|
||||||
|
@ -914,12 +955,13 @@ const addToGroupFields: INodeProperties[] = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
placeholder: 'e.g. eu-central-1_ab12cdefgh',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'User',
|
displayName: 'User Name',
|
||||||
name: 'user',
|
name: 'Username',
|
||||||
default: {
|
default: {
|
||||||
mode: 'list',
|
mode: 'list',
|
||||||
value: '',
|
value: '',
|
||||||
|
@ -937,7 +979,7 @@ const addToGroupFields: INodeProperties[] = [
|
||||||
name: 'list',
|
name: 'list',
|
||||||
type: 'list',
|
type: 'list',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
searchListMethod: 'searchUserPools',
|
searchListMethod: 'searchUsers',
|
||||||
searchable: true,
|
searchable: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -958,29 +1000,29 @@ const addToGroupFields: INodeProperties[] = [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
routing: {
|
||||||
|
send: {
|
||||||
|
type: 'body',
|
||||||
|
property: 'Username',
|
||||||
|
},
|
||||||
|
},
|
||||||
required: true,
|
required: true,
|
||||||
type: 'resourceLocator',
|
type: 'resourceLocator',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Group',
|
displayName: 'Group Name',
|
||||||
name: 'group',
|
name: 'GroupName',
|
||||||
description: 'Select the group you want to add the user to',
|
|
||||||
default: {
|
default: {
|
||||||
mode: 'list',
|
mode: 'list',
|
||||||
value: '',
|
value: '',
|
||||||
},
|
},
|
||||||
|
description: 'Select the group you want to update',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: ['user'],
|
resource: ['user'],
|
||||||
operation: ['addToGroup'],
|
operation: ['addToGroup'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
routing: {
|
|
||||||
send: {
|
|
||||||
type: 'body',
|
|
||||||
property: 'GroupId',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
modes: [
|
modes: [
|
||||||
{
|
{
|
||||||
displayName: 'From List',
|
displayName: 'From List',
|
||||||
|
@ -992,23 +1034,30 @@ const addToGroupFields: INodeProperties[] = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'By ID',
|
displayName: 'By Name',
|
||||||
name: 'id',
|
name: 'GroupName',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
hint: 'Enter the group ID',
|
hint: 'Enter the group name',
|
||||||
placeholder: 'e.g. 02bd9fd6-8f93-4758-87c3-1fb73740a315',
|
|
||||||
validation: [
|
validation: [
|
||||||
{
|
{
|
||||||
type: 'regex',
|
type: 'regex',
|
||||||
properties: {
|
properties: {
|
||||||
regex: '^[\\w-]+_[0-9a-zA-Z]+$',
|
regex: '^[\\w+=,.@-]+$',
|
||||||
errorMessage: 'The ID must follow the pattern "xxxxxx_xxxxxxxxxxx"',
|
errorMessage: 'The group name must follow the allowed pattern.',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
placeholder: 'e.g. Admins',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
required: true,
|
required: true,
|
||||||
|
routing: {
|
||||||
|
send: {
|
||||||
|
preSend: [presendTest], // ToDo: Remove this line before completing the pull request
|
||||||
|
type: 'body',
|
||||||
|
property: 'GroupName',
|
||||||
|
},
|
||||||
|
},
|
||||||
type: 'resourceLocator',
|
type: 'resourceLocator',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -1023,7 +1072,7 @@ const removeFromGroupFields: INodeProperties[] = [
|
||||||
mode: 'list',
|
mode: 'list',
|
||||||
value: '',
|
value: '',
|
||||||
},
|
},
|
||||||
description: 'The ID of the user pool',
|
description: 'The user pool ID where the users are managed',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: ['user'],
|
resource: ['user'],
|
||||||
|
@ -1051,7 +1100,6 @@ const removeFromGroupFields: INodeProperties[] = [
|
||||||
name: 'id',
|
name: 'id',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
hint: 'Enter the user pool ID',
|
hint: 'Enter the user pool ID',
|
||||||
placeholder: 'e.g. eu-central-1_ab12cdefgh',
|
|
||||||
validation: [
|
validation: [
|
||||||
{
|
{
|
||||||
type: 'regex',
|
type: 'regex',
|
||||||
|
@ -1061,12 +1109,13 @@ const removeFromGroupFields: INodeProperties[] = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
placeholder: 'e.g. eu-central-1_ab12cdefgh',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'User',
|
displayName: 'User Name',
|
||||||
name: 'user',
|
name: 'Username',
|
||||||
default: {
|
default: {
|
||||||
mode: 'list',
|
mode: 'list',
|
||||||
value: '',
|
value: '',
|
||||||
|
@ -1084,7 +1133,7 @@ const removeFromGroupFields: INodeProperties[] = [
|
||||||
name: 'list',
|
name: 'list',
|
||||||
type: 'list',
|
type: 'list',
|
||||||
typeOptions: {
|
typeOptions: {
|
||||||
searchListMethod: 'searchUserPools',
|
searchListMethod: 'searchUsers',
|
||||||
searchable: true,
|
searchable: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1105,17 +1154,24 @@ const removeFromGroupFields: INodeProperties[] = [
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
routing: {
|
||||||
|
send: {
|
||||||
|
preSend: [presendTest], // ToDo: Remove this line before completing the pull request
|
||||||
|
type: 'body',
|
||||||
|
property: 'Username',
|
||||||
|
},
|
||||||
|
},
|
||||||
required: true,
|
required: true,
|
||||||
type: 'resourceLocator',
|
type: 'resourceLocator',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'Group',
|
displayName: 'Group Name',
|
||||||
name: 'group',
|
name: 'GroupName',
|
||||||
default: {
|
default: {
|
||||||
mode: 'list',
|
mode: 'list',
|
||||||
value: '',
|
value: '',
|
||||||
},
|
},
|
||||||
description: 'Select the group you want to remove the user from',
|
description: 'Select the group you want to update',
|
||||||
displayOptions: {
|
displayOptions: {
|
||||||
show: {
|
show: {
|
||||||
resource: ['user'],
|
resource: ['user'],
|
||||||
|
@ -1133,23 +1189,30 @@ const removeFromGroupFields: INodeProperties[] = [
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: 'By ID',
|
displayName: 'By Name',
|
||||||
name: 'id',
|
name: 'GroupName',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
hint: 'Enter the group ID',
|
hint: 'Enter the group name',
|
||||||
placeholder: 'e.g. 02bd9fd6-8f93-4758-87c3-1fb73740a315',
|
|
||||||
validation: [
|
validation: [
|
||||||
{
|
{
|
||||||
type: 'regex',
|
type: 'regex',
|
||||||
properties: {
|
properties: {
|
||||||
regex: '^[\\w-]+_[0-9a-zA-Z]+$',
|
regex: '^[\\w+=,.@-]+$',
|
||||||
errorMessage: 'The ID must follow the pattern "xxxxxx_xxxxxxxxxxx"',
|
errorMessage: 'The group name must follow the allowed pattern.',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
placeholder: 'e.g. Admins',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
required: true,
|
required: true,
|
||||||
|
routing: {
|
||||||
|
send: {
|
||||||
|
preSend: [presendTest], // ToDo: Remove this line before completing the pull request
|
||||||
|
type: 'body',
|
||||||
|
property: 'GroupName',
|
||||||
|
},
|
||||||
|
},
|
||||||
type: 'resourceLocator',
|
type: 'resourceLocator',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
Loading…
Reference in a new issue