Fixed issues after feedback

This commit is contained in:
Adina Totorean 2024-12-09 16:16:01 +02:00
parent 3615cd9021
commit 3f15fd5cfc
4 changed files with 42 additions and 25 deletions

View file

@ -29,15 +29,22 @@ export class AwsCognito implements INodeType {
inputs: [NodeConnectionType.Main],
outputs: [NodeConnectionType.Main],
hints: [
// ToDo: Add hints
// {
// message: 'Please select a parameter in the options to modify the post',
// displayCondition:
// '={{$parameter["resource"] === "user" && $parameter["operation"] === "update" && Object.keys($parameter["additionalOptions"]).length === 0}}',
// whenToDisplay: 'always',
// location: 'outputPane',
// type: 'warning',
// },
{
message: 'Please select a parameter in the options to update the user',
displayCondition:
'={{$parameter["resource"] === "user" && $parameter["operation"] === "update" && Object.keys($parameter["additionalOptions"]).length === 0}}',
whenToDisplay: 'always',
location: 'outputPane',
type: 'warning',
},
{
message: 'Please select a parameter in the options to update the group',
displayCondition:
'={{$parameter["resource"] === "group" && $parameter["operation"] === "update" && Object.keys($parameter["options"]).length === 0}}',
whenToDisplay: 'always',
location: 'outputPane',
type: 'warning',
},
],
credentials: [
{

View file

@ -37,8 +37,6 @@ export async function presendFilter(
let filterType = additionalFields.filterType as string;
const filterValue = additionalFields.filterValue as string;
console.log('Attribute', filterAttribute, 'Type', filterType, 'Value', filterValue);
if (!filterAttribute || !filterType || !filterValue) {
throw new NodeOperationError(
this.getNode(),
@ -240,6 +238,12 @@ export async function handleErrorPostReceive(
}
} else if (resource === 'user') {
if (operation === 'create') {
if (errorType === 'UserNotFoundException') {
throw new NodeApiError(this.getNode(), response as unknown as JsonObject, {
message: "'Message Action: Resend' needs an existing user",
description: 'Adjust the "User Name" parameter setting to create the user correctly.',
});
}
if (
errorType === 'UsernameExistsException' &&
errorMessage === 'User account already exists'

View file

@ -1,6 +1,11 @@
import type { INodeProperties } from 'n8n-workflow';
import { handleErrorPostReceive, handlePagination, presendPath } from '../GenericFunctions';
import {
handleErrorPostReceive,
handlePagination,
presendOptions,
presendPath,
} from '../GenericFunctions';
export const groupOperations: INodeProperties[] = [
{
@ -51,7 +56,7 @@ export const groupOperations: INodeProperties[] = [
{
type: 'set',
properties: {
value: '={{ { "deleted": true } }}',
value: '={{ { "success": true } }}',
},
},
],
@ -106,6 +111,9 @@ export const groupOperations: INodeProperties[] = [
value: 'update',
description: 'Update an existing group',
routing: {
send: {
preSend: [presendOptions],
},
request: {
method: 'POST',
headers: {
@ -119,7 +127,7 @@ export const groupOperations: INodeProperties[] = [
{
type: 'set',
properties: {
value: '={{ { "updated": true } }}',
value: '={{ { "success": true } }}',
},
},
],

View file

@ -39,7 +39,7 @@ export const userOperations: INodeProperties[] = [
{
type: 'set',
properties: {
value: '={{ { "added": true } }}',
value: '={{ { "success": true } }}',
},
},
],
@ -83,7 +83,7 @@ export const userOperations: INodeProperties[] = [
{
type: 'set',
properties: {
value: '={{ { "deleted": true } }}',
value: '={{ { "success": true } }}',
},
},
],
@ -113,7 +113,10 @@ export const userOperations: INodeProperties[] = [
value: 'getAll',
description: 'Retrieve a list of users',
routing: {
send: { paginate: true },
send: {
paginate: true,
preSend: [presendFilter],
},
operations: { pagination: handlePagination },
request: {
method: 'POST',
@ -151,7 +154,7 @@ export const userOperations: INodeProperties[] = [
{
type: 'set',
properties: {
value: '={{ { "removed": true } }}',
value: '={{ { "success": true } }}',
},
},
],
@ -177,7 +180,7 @@ export const userOperations: INodeProperties[] = [
{
type: 'set',
properties: {
value: '={{ { "updated": true } }}',
value: '={{ { "success": true } }}',
},
},
],
@ -428,11 +431,11 @@ const createFields: INodeProperties[] = [
],
routing: {
send: {
preSend: [processAttributes],
type: 'body',
property: 'UserAttributes',
value:
'={{ $value.attributes?.map(attribute => ({ Name: attribute.Name, Value: attribute.Value })) || [] }}',
preSend: [processAttributes],
},
},
},
@ -703,11 +706,6 @@ const getAllFields: INodeProperties[] = [
default: 'username',
hint: 'Make sure to select an attribute, type, and provide a value before submitting.',
description: 'The attribute to search for',
routing: {
send: {
preSend: [presendFilter],
},
},
options: [
{ name: 'Cognito User Status', value: 'cognito:user_status' },
{ name: 'Email', value: 'email' },