Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(n8n AWS Cognito Node): New node #11767

Open
wants to merge 51 commits into
base: master
Choose a base branch
from

Conversation

valentina98
Copy link
Contributor

@valentina98 valentina98 commented Nov 17, 2024

Summary

Added new node for the AWS Cognito API.
https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/Welcome.html

The following operations were implemented for the specific resources:

Resource: User Pool

  • Get

Resource: User

  • Create
  • Get
  • Delete
  • Get Many
  • Update
  • Add to Group
  • Remove from Group

Resource: Group

  • Create
  • Delete
  • Get
  • Get Many
  • Update

@n8n-assistant n8n-assistant bot added community Authored by a community member node/improvement New feature or request node/new Creation of an entirely new node in linear Issue or PR has been created in Linear for internal review labels Nov 17, 2024
@Joffcom
Copy link
Member

Joffcom commented Nov 17, 2024

Hey @valentina98,

Thanks for the PR, We have created "GHC-455" as the internal reference to get this reviewed.

One of us will be in touch if there are any changes needed, in most cases this is normally within a couple of weeks but it depends on the current workload of the team.

@valentina98 valentina98 changed the title WIP: feat(n8n AWS Cognito Node): New node feat(n8n AWS Cognito Node): New node Dec 14, 2024
@@ -354,6 +354,7 @@ export class Aws implements ICredentialType {
} else if (service === 'rekognition' && credentials.rekognitionEndpoint) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add validation to ensure service is defined and valid before constructing the endpoint string.

Comment on lines 31 to 40
hints: [
{
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',
},
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use concise messages like "Select a parameter to update this resource" to improve clarity.

@adina-hub
Copy link
Contributor

adina-hub commented Jan 24, 2025

@Parvezkhan0 @netroy this node is still in a review phase, please wait for confirmation to continue.

@@ -353,8 +353,6 @@ export class Aws implements ICredentialType {
endpointString = credentials.sesEndpoint;
} else if (service === 'rekognition' && credentials.rekognitionEndpoint) {
endpointString = credentials.rekognitionEndpoint;
} else if (service === 'sqs' && credentials.sqsEndpoint) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these lines removed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a duplicate, there was also a comment previously with this as a to-do

@@ -339,7 +339,7 @@ export class Aws implements ICredentialType {
region = parsed.region;
}
} else {
if (!requestOptions.baseURL && !requestOptions.url) {
if (!requestOptions.baseURL && !requestOptions.url && service) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is redundant

Suggested change
if (!requestOptions.baseURL && !requestOptions.url && service) {
if (!requestOptions.baseURL && !requestOptions.url) {

Comment on lines 32 to 49
hints: [
{
message: 'Select a parameter to update this resource',
displayCondition:
'={{$parameter["resource"] === "user" && $parameter["operation"] === "update" && Object.keys($parameter["additionalOptions"]).length === 0}}',
whenToDisplay: 'always',
location: 'outputPane',
type: 'warning',
},
{
message: 'Select a parameter to update this resource',
displayCondition:
'={{$parameter["resource"] === "group" && $parameter["operation"] === "update" && Object.keys($parameter["options"]).length === 0}}',
whenToDisplay: 'always',
location: 'outputPane',
type: 'warning',
},
],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do these hints work? also there is so much duplication between the two

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ShireenMissi is this good?
Screenshot 2025-03-10 at 3 37 40 PM

outputs: [NodeConnectionType.Main],
hints: [
{
message: 'Select a parameter to update this resource',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gandreini isn't this message very generic?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ShireenMissi yes too generic. Looking at the code it seems that this is fired when I update a user and send no data. We could rephrase it as Select at least one user field to update
Same for the warning below about the group

Comment on lines 1 to 3
/* eslint-disable n8n-local-rules/no-uncaught-json-parse */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please don't disable rules like this

Suggested change
/* eslint-disable n8n-local-rules/no-uncaught-json-parse */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */

});
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the error mapping can be simplified and extracted
for example you could use

const errorMapping: Record<string, Record<string, { message: string; description: string }>> = {
		group: {
			delete: {
				message: 'The group you are deleting could not be found.',
				description: 'Adjust the "Group" parameter setting to delete the group correctly.',
			},
....

return data;
}

export async function awsRequest(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for naming consistency I suggest renaming this to

Suggested change
export async function awsRequest(
export async function makeAwsRequest(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code in this file is complex and could be significantly simplified. It is hard to read due to excessive type casting, some of which are unnecessary. Additionally, API calls, such as checking if a user is in a group, could be optimised for better readability and efficiency.

Copy link
Contributor

@ShireenMissi ShireenMissi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please update the PR descriptions with details about the changes you made for example what Node was added and all resources/operations
Additionally on the User resource/ Update I find the attributes part hard to fill without checking the API docs
Screenshot 2025-02-21 at 11 36 48
I think the standard attributes https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html these should be added as named options, and [name, value] pairs can be kept for any custom attributes

@adina-hub
Copy link
Contributor

adina-hub commented Mar 10, 2025

Could you please update the PR descriptions with details about the changes you made for example what Node was added and all resources/operations Additionally on the User resource/ Update I find the attributes part hard to fill without checking the API docs Screenshot 2025-02-21 at 11 36 48 I think the standard attributes https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html these should be added as named options, and [name, value] pairs can be kept for any custom attributes
I implemented this , is this a good approach? @gandreini

Screenshot-2025-03-03-at-11 28 17AM Screenshot-2025-03-03-at-11 28 26AM

@ShireenMissi
Copy link
Contributor

Could you please update the PR descriptions with details about the changes you made for example what Node was added and all resources/operations Additionally on the User resource/ Update I find the attributes part hard to fill without checking the API docs Screenshot 2025-02-21 at 11 36 48 I think the standard attributes https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html these should be added as named options, and [name, value] pairs can be kept for any custom attributes
I implemented this , is this a good approach? @gandreini

Screenshot-2025-03-03-at-11 28 17AM Screenshot-2025-03-03-at-11 28 26AM

@adina-hub Thanks for making the changes, what I meant by my comment is actually adding the following options directly so users don't have to look up the API docs to update them
name
family_name
given_name
middle_name
nickname
preferred_username
profile
picture
website
gender
birthdate
zoneinfo
locale
updated_at
address
email
phone_number
sub

@adina-hub
Copy link
Contributor

@ShireenMissi the code is ready for review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Authored by a community member in linear Issue or PR has been created in Linear for internal review node/improvement New feature or request node/new Creation of an entirely new node
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants