-
Notifications
You must be signed in to change notification settings - Fork 437
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
Conversation
docs-v2/reference/sdks/node.mdx
Outdated
@@ -94,6 +157,42 @@ await nango.listIntegrations() | |||
|
|||
Returns a specific integration. | |||
|
|||
```js | |||
await nango.getIntegrationV2(<UNIQUE_KEY>, { include?: ['webhook'] }); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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/server/lib/controllers/integrations/uniqueKey/getIntegration.ts
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]) |
There was a problem hiding this comment.
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
There was a problem hiding this 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
@TBonnin Updated with signature change, thanks for the suggestion 💪🏻 |
## 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.
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
inGET /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.