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: make connectionId optional when creating a new connection #2746

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

TBonnin
Copy link
Collaborator

@TBonnin TBonnin commented Sep 19, 2024

Describe your changes

Making connectionId optional when creating a connection. If connectionId is not provided a uuid is generated.
I haven't updated the documentation which is still relevant. I will do it once we decide not passing the connectionId is the default way. With this PR we are making it possible without promoting it yet.

Issue ticket number and link

https://linear.app/nango/issue/NAN-1747/make-connectionid-optional-when-creating-a-new-connection

Checklist before requesting a review (skip if just adding/editing APIs & templates)

  • I added tests, otherwise the reason is:
  • I added observability, otherwise the reason is:
  • I added analytics, otherwise the reason is:

Copy link

linear bot commented Sep 19, 2024

providerConfigKey: string,
connectionIdOrConnectionConfig?: string | ConnectionConfig,
moreConnectionConfig?: ConnectionConfig
): Promise<AuthResult> {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

method overload to allow passing connectionConfig without having to specify an undefined connectionId

? nango.create(target.integration_unique_key.value, target.connection_id.value, connectionConfig)
: nango.auth(target.integration_unique_key.value, target.connection_id.value, connectionConfig);

getConnection
Copy link
Collaborator Author

@TBonnin TBonnin Sep 19, 2024

Choose a reason for hiding this comment

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

the compiler doesn't like the dynamic index method calling (I don't know how this is called) with method overloadding. No logic has changed here

Copy link
Collaborator

Choose a reason for hiding this comment

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

honestly more readable like 👌🏻

Copy link
Collaborator

@bodinsamuel bodinsamuel left a comment

Choose a reason for hiding this comment

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

It works great, tested locally by modifying the frontend 👌🏻

? nango.create(target.integration_unique_key.value, target.connection_id.value, connectionConfig)
: nango.auth(target.integration_unique_key.value, target.connection_id.value, connectionConfig);

getConnection
Copy link
Collaborator

Choose a reason for hiding this comment

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

honestly more readable like 👌🏻

async verify(expectedDigest: string, id: number, ...values: string[]): Promise<boolean> {
const actualDigest = await this.digest(id, ...values);
async verify(expectedDigest: string, id: number, ...values: (string | undefined)[]): Promise<boolean> {
const definedValues: string[] = values.flatMap((v) => (v === undefined ? [] : [v]));
Copy link
Collaborator

Choose a reason for hiding this comment

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

filter(Boolean) would not work here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

you are right, that should work. let me check

Copy link
Collaborator Author

@TBonnin TBonnin Sep 20, 2024

Choose a reason for hiding this comment

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

it does work but it will require to cast to string[] because filter doesn't change the type of values. I will leave it like it is then

@TBonnin TBonnin force-pushed the tbonnin/nan-1747/optional-connectionid branch from 11873d3 to f88f672 Compare September 20, 2024 13:38
@TBonnin TBonnin merged commit 0e229c5 into master Sep 20, 2024
22 checks passed
@TBonnin TBonnin deleted the tbonnin/nan-1747/optional-connectionid branch September 20, 2024 14:32
hassan254-prog pushed a commit that referenced this pull request Sep 25, 2024
## Describe your changes

Making connectionId optional when creating a connection. If connectionId
is not provided a uuid is generated.
I haven't updated the documentation which is still relevant. I will do
it once we decide not passing the connectionId is the default way. With
this PR we are making it possible without promoting it yet.

## Issue ticket number and link


https://linear.app/nango/issue/NAN-1747/make-connectionid-optional-when-creating-a-new-connection

## Checklist before requesting a review (skip if just adding/editing
APIs & templates)
- [ ] I added tests, otherwise the reason is: 
- [ ] I added observability, otherwise the reason is:
- [ ] I added analytics, otherwise the reason is:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants