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(sdk): add new endpoints #2747

Merged
merged 8 commits into from
Sep 20, 2024
Merged

feat(sdk): add new endpoints #2747

merged 8 commits into from
Sep 20, 2024

Conversation

bodinsamuel
Copy link
Collaborator

Describe your changes

Fixes https://linear.app/nango/issue/NAN-1753/document-new-endpoints-integrations-and-providers

  • Add new endpoints to the SDK
    There is only one method that was different enough, queries and output that even with signature overload it wasn't possible to make it non-breaking. Honestly, I didn't find anything compelling to deprecate without either being ugly or breaking customers' scripts, so very open to suggestions.

  • Document new SDK method

  • Add support for include=webhook in GET /integrations/:key
    The SDK needs it, and some customers use it. It's a secret but not credentials, so I didn't put a too vague name. If we need credentials at some point, we can differentiate.

@bodinsamuel bodinsamuel self-assigned this Sep 19, 2024
Copy link

linear bot commented Sep 19, 2024

@bodinsamuel bodinsamuel changed the title Feat/sdk add new endpoints feat(sdk): add new endpoints Sep 19, 2024
@bodinsamuel bodinsamuel changed the title feat(sdk): add new endpoints feat(sdk): add new endpoints Sep 19, 2024
@@ -94,6 +157,42 @@ await nango.listIntegrations()

Returns a specific integration.

```js
await nango.getIntegrationV2(<UNIQUE_KEY>, { include?: ['webhook'] });
Copy link
Collaborator

Choose a reason for hiding this comment

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

what about having the new method take an single options object instead, then signature is different and we can use method overloading.

type getIntegrationOptions = {uniqueKey: string, query?: ...}

public async getIntegration({uniqueKey, query} : getIntegrationOptions);
public async getIntegration(name: string);
public async getIntegration(nameOrOptions: string | getIntegrationOptions) {
...

Same for getProvider({name}: { name: string}) to keep it consistent

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Could work indeed, it's a paradigm shift though. Usually in Nodejs SDK the first param to get() is an id, string or number not an object.

We can have naming consistency:

- getProvider({ id })
- getIntegration({ id })
- getConnection({ id })

or still use the name

- getProvider({ name })
- getIntegration({ unique_key })
- getConnection({ connection_id })

wdyt?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I prefer option 2. It is a bit more self-explanatory what the param is.

packages/node-client/lib/utils.ts Outdated Show resolved Hide resolved
@@ -4,7 +4,7 @@ const args = process.argv.slice(2);
const nango = new Nango({ host: 'http://localhost:3003', secretKey: args[0] });

nango
.getIntegration(args[1], args[2])
.getIntegrationV2(args[1])
Copy link
Member

Choose a reason for hiding this comment

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

Would rather this be a separate file until we actually retire the original method

@khaliqgant khaliqgant self-requested a review September 20, 2024 10:37
Copy link
Member

@khaliqgant khaliqgant left a comment

Choose a reason for hiding this comment

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

non blocking comment inline

@bodinsamuel
Copy link
Collaborator Author

@TBonnin Updated with signature change, thanks for the suggestion 💪🏻

@bodinsamuel bodinsamuel merged commit 53d383b into master Sep 20, 2024
22 checks passed
@bodinsamuel bodinsamuel deleted the feat/sdk-add-new-endpoints branch September 20, 2024 16:12
hassan254-prog pushed a commit that referenced this pull request Sep 25, 2024
## Describe your changes

Fixes
https://linear.app/nango/issue/NAN-1753/document-new-endpoints-integrations-and-providers

- Add new endpoints to the SDK
There is only one method that was different enough, queries and output
that even with signature overload it wasn't possible to make it
non-breaking. Honestly, I didn't find anything compelling to deprecate
without either being ugly or breaking customers' scripts, so very open
to suggestions.

- Document new SDK method
- Add support for `include=webhook` in `GET /integrations/:key`
The SDK needs it, and some customers use it. It's a secret but not
credentials, so I didn't put a too vague name. If we need credentials at
some point, we can differentiate.
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