refactor(core): simplify integration credentials (#31968)
This commit is contained in:
@@ -265,20 +265,10 @@ import type {
|
||||
V2AgentListResponses,
|
||||
V2CommandListErrors,
|
||||
V2CommandListResponses,
|
||||
V2ConnectorConnectKeyErrors,
|
||||
V2ConnectorConnectKeyResponses,
|
||||
V2ConnectorConnectOauthBeginErrors,
|
||||
V2ConnectorConnectOauthBeginResponses,
|
||||
V2ConnectorConnectOauthCancelErrors,
|
||||
V2ConnectorConnectOauthCancelResponses,
|
||||
V2ConnectorConnectOauthCompleteErrors,
|
||||
V2ConnectorConnectOauthCompleteResponses,
|
||||
V2ConnectorConnectOauthStatusErrors,
|
||||
V2ConnectorConnectOauthStatusResponses,
|
||||
V2ConnectorGetErrors,
|
||||
V2ConnectorGetResponses,
|
||||
V2ConnectorListErrors,
|
||||
V2ConnectorListResponses,
|
||||
V2CredentialRemoveErrors,
|
||||
V2CredentialRemoveResponses,
|
||||
V2CredentialUpdateErrors,
|
||||
V2CredentialUpdateResponses,
|
||||
V2EventSubscribeErrors,
|
||||
V2EventSubscribeResponses,
|
||||
V2FsFindErrors,
|
||||
@@ -289,6 +279,20 @@ import type {
|
||||
V2FsReadResponses,
|
||||
V2HealthGetErrors,
|
||||
V2HealthGetResponses,
|
||||
V2IntegrationAttemptCancelErrors,
|
||||
V2IntegrationAttemptCancelResponses,
|
||||
V2IntegrationAttemptCompleteErrors,
|
||||
V2IntegrationAttemptCompleteResponses,
|
||||
V2IntegrationAttemptStatusErrors,
|
||||
V2IntegrationAttemptStatusResponses,
|
||||
V2IntegrationConnectKeyErrors,
|
||||
V2IntegrationConnectKeyResponses,
|
||||
V2IntegrationConnectOauthErrors,
|
||||
V2IntegrationConnectOauthResponses,
|
||||
V2IntegrationGetErrors,
|
||||
V2IntegrationGetResponses,
|
||||
V2IntegrationListErrors,
|
||||
V2IntegrationListResponses,
|
||||
V2LocationGetErrors,
|
||||
V2LocationGetResponses,
|
||||
V2ModelListErrors,
|
||||
@@ -5581,15 +5585,61 @@ export class Provider2 extends HeyApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
export class Oauth2 extends HeyApiClient {
|
||||
export class Connect extends HeyApiClient {
|
||||
/**
|
||||
* Connect with key
|
||||
*
|
||||
* Run a key authentication method and store the resulting credential.
|
||||
*/
|
||||
public key<ThrowOnError extends boolean = false>(
|
||||
parameters: {
|
||||
integrationID: string
|
||||
location?: {
|
||||
directory?: string
|
||||
workspace?: string
|
||||
}
|
||||
key?: string
|
||||
label?: string
|
||||
},
|
||||
options?: Options<never, ThrowOnError>,
|
||||
) {
|
||||
const params = buildClientParams(
|
||||
[parameters],
|
||||
[
|
||||
{
|
||||
args: [
|
||||
{ in: "path", key: "integrationID" },
|
||||
{ in: "query", key: "location" },
|
||||
{ in: "body", key: "key" },
|
||||
{ in: "body", key: "label" },
|
||||
],
|
||||
},
|
||||
],
|
||||
)
|
||||
return (options?.client ?? this.client).post<
|
||||
V2IntegrationConnectKeyResponses,
|
||||
V2IntegrationConnectKeyErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/api/integration/{integrationID}/connect/key",
|
||||
...options,
|
||||
...params,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...options?.headers,
|
||||
...params.headers,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin OAuth connection
|
||||
*
|
||||
* Start an OAuth attempt and return the authorization details.
|
||||
*/
|
||||
public begin<ThrowOnError extends boolean = false>(
|
||||
public oauth<ThrowOnError extends boolean = false>(
|
||||
parameters: {
|
||||
connectorID: string
|
||||
integrationID: string
|
||||
location?: {
|
||||
directory?: string
|
||||
workspace?: string
|
||||
@@ -5607,7 +5657,7 @@ export class Oauth2 extends HeyApiClient {
|
||||
[
|
||||
{
|
||||
args: [
|
||||
{ in: "path", key: "connectorID" },
|
||||
{ in: "path", key: "integrationID" },
|
||||
{ in: "query", key: "location" },
|
||||
{ in: "body", key: "methodID" },
|
||||
{ in: "body", key: "inputs" },
|
||||
@@ -5617,11 +5667,11 @@ export class Oauth2 extends HeyApiClient {
|
||||
],
|
||||
)
|
||||
return (options?.client ?? this.client).post<
|
||||
V2ConnectorConnectOauthBeginResponses,
|
||||
V2ConnectorConnectOauthBeginErrors,
|
||||
V2IntegrationConnectOauthResponses,
|
||||
V2IntegrationConnectOauthErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/api/connector/{connectorID}/connect/oauth",
|
||||
url: "/api/integration/{integrationID}/connect/oauth",
|
||||
...options,
|
||||
...params,
|
||||
headers: {
|
||||
@@ -5631,7 +5681,9 @@ export class Oauth2 extends HeyApiClient {
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export class Attempt extends HeyApiClient {
|
||||
/**
|
||||
* Cancel OAuth connection
|
||||
*
|
||||
@@ -5659,11 +5711,11 @@ export class Oauth2 extends HeyApiClient {
|
||||
],
|
||||
)
|
||||
return (options?.client ?? this.client).delete<
|
||||
V2ConnectorConnectOauthCancelResponses,
|
||||
V2ConnectorConnectOauthCancelErrors,
|
||||
V2IntegrationAttemptCancelResponses,
|
||||
V2IntegrationAttemptCancelErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/api/connector/oauth/{attemptID}",
|
||||
url: "/api/integration/attempt/{attemptID}",
|
||||
...options,
|
||||
...params,
|
||||
})
|
||||
@@ -5696,11 +5748,11 @@ export class Oauth2 extends HeyApiClient {
|
||||
],
|
||||
)
|
||||
return (options?.client ?? this.client).get<
|
||||
V2ConnectorConnectOauthStatusResponses,
|
||||
V2ConnectorConnectOauthStatusErrors,
|
||||
V2IntegrationAttemptStatusResponses,
|
||||
V2IntegrationAttemptStatusErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/api/connector/oauth/{attemptID}",
|
||||
url: "/api/integration/attempt/{attemptID}",
|
||||
...options,
|
||||
...params,
|
||||
})
|
||||
@@ -5735,11 +5787,11 @@ export class Oauth2 extends HeyApiClient {
|
||||
],
|
||||
)
|
||||
return (options?.client ?? this.client).post<
|
||||
V2ConnectorConnectOauthCompleteResponses,
|
||||
V2ConnectorConnectOauthCompleteErrors,
|
||||
V2IntegrationAttemptCompleteResponses,
|
||||
V2IntegrationAttemptCompleteErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/api/connector/oauth/{attemptID}/complete",
|
||||
url: "/api/integration/attempt/{attemptID}/complete",
|
||||
...options,
|
||||
...params,
|
||||
headers: {
|
||||
@@ -5751,70 +5803,11 @@ export class Oauth2 extends HeyApiClient {
|
||||
}
|
||||
}
|
||||
|
||||
export class Connect extends HeyApiClient {
|
||||
export class Integration extends HeyApiClient {
|
||||
/**
|
||||
* Connect with key
|
||||
* List integrations
|
||||
*
|
||||
* Run a key authentication method and store the resulting credential.
|
||||
*/
|
||||
public key<ThrowOnError extends boolean = false>(
|
||||
parameters: {
|
||||
connectorID: string
|
||||
location?: {
|
||||
directory?: string
|
||||
workspace?: string
|
||||
}
|
||||
methodID?: string
|
||||
key?: string
|
||||
inputs?: {
|
||||
[key: string]: string
|
||||
}
|
||||
label?: string
|
||||
},
|
||||
options?: Options<never, ThrowOnError>,
|
||||
) {
|
||||
const params = buildClientParams(
|
||||
[parameters],
|
||||
[
|
||||
{
|
||||
args: [
|
||||
{ in: "path", key: "connectorID" },
|
||||
{ in: "query", key: "location" },
|
||||
{ in: "body", key: "methodID" },
|
||||
{ in: "body", key: "key" },
|
||||
{ in: "body", key: "inputs" },
|
||||
{ in: "body", key: "label" },
|
||||
],
|
||||
},
|
||||
],
|
||||
)
|
||||
return (options?.client ?? this.client).post<
|
||||
V2ConnectorConnectKeyResponses,
|
||||
V2ConnectorConnectKeyErrors,
|
||||
ThrowOnError
|
||||
>({
|
||||
url: "/api/connector/{connectorID}/connect/key",
|
||||
...options,
|
||||
...params,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...options?.headers,
|
||||
...params.headers,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
private _oauth?: Oauth2
|
||||
get oauth(): Oauth2 {
|
||||
return (this._oauth ??= new Oauth2({ client: this.client }))
|
||||
}
|
||||
}
|
||||
|
||||
export class Connector extends HeyApiClient {
|
||||
/**
|
||||
* List connectors
|
||||
*
|
||||
* Retrieve available connectors and their authentication methods.
|
||||
* Retrieve available integrations and their authentication methods.
|
||||
*/
|
||||
public list<ThrowOnError extends boolean = false>(
|
||||
parameters?: {
|
||||
@@ -5826,21 +5819,21 @@ export class Connector extends HeyApiClient {
|
||||
options?: Options<never, ThrowOnError>,
|
||||
) {
|
||||
const params = buildClientParams([parameters], [{ args: [{ in: "query", key: "location" }] }])
|
||||
return (options?.client ?? this.client).get<V2ConnectorListResponses, V2ConnectorListErrors, ThrowOnError>({
|
||||
url: "/api/connector",
|
||||
return (options?.client ?? this.client).get<V2IntegrationListResponses, V2IntegrationListErrors, ThrowOnError>({
|
||||
url: "/api/integration",
|
||||
...options,
|
||||
...params,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Get connector
|
||||
* Get integration
|
||||
*
|
||||
* Retrieve one connector and its authentication methods.
|
||||
* Retrieve one integration and its authentication methods.
|
||||
*/
|
||||
public get<ThrowOnError extends boolean = false>(
|
||||
parameters: {
|
||||
connectorID: string
|
||||
integrationID: string
|
||||
location?: {
|
||||
directory?: string
|
||||
workspace?: string
|
||||
@@ -5853,14 +5846,14 @@ export class Connector extends HeyApiClient {
|
||||
[
|
||||
{
|
||||
args: [
|
||||
{ in: "path", key: "connectorID" },
|
||||
{ in: "path", key: "integrationID" },
|
||||
{ in: "query", key: "location" },
|
||||
],
|
||||
},
|
||||
],
|
||||
)
|
||||
return (options?.client ?? this.client).get<V2ConnectorGetResponses, V2ConnectorGetErrors, ThrowOnError>({
|
||||
url: "/api/connector/{connectorID}",
|
||||
return (options?.client ?? this.client).get<V2IntegrationGetResponses, V2IntegrationGetErrors, ThrowOnError>({
|
||||
url: "/api/integration/{integrationID}",
|
||||
...options,
|
||||
...params,
|
||||
})
|
||||
@@ -5870,6 +5863,69 @@ export class Connector extends HeyApiClient {
|
||||
get connect(): Connect {
|
||||
return (this._connect ??= new Connect({ client: this.client }))
|
||||
}
|
||||
|
||||
private _attempt?: Attempt
|
||||
get attempt(): Attempt {
|
||||
return (this._attempt ??= new Attempt({ client: this.client }))
|
||||
}
|
||||
}
|
||||
|
||||
export class Credential extends HeyApiClient {
|
||||
/**
|
||||
* Remove credential
|
||||
*
|
||||
* Remove a stored integration credential.
|
||||
*/
|
||||
public remove<ThrowOnError extends boolean = false>(
|
||||
parameters: {
|
||||
credentialID: string
|
||||
},
|
||||
options?: Options<never, ThrowOnError>,
|
||||
) {
|
||||
const params = buildClientParams([parameters], [{ args: [{ in: "path", key: "credentialID" }] }])
|
||||
return (options?.client ?? this.client).delete<V2CredentialRemoveResponses, V2CredentialRemoveErrors, ThrowOnError>(
|
||||
{
|
||||
url: "/api/credential/{credentialID}",
|
||||
...options,
|
||||
...params,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update credential
|
||||
*
|
||||
* Update a stored credential label.
|
||||
*/
|
||||
public update<ThrowOnError extends boolean = false>(
|
||||
parameters: {
|
||||
credentialID: string
|
||||
label?: string
|
||||
},
|
||||
options?: Options<never, ThrowOnError>,
|
||||
) {
|
||||
const params = buildClientParams(
|
||||
[parameters],
|
||||
[
|
||||
{
|
||||
args: [
|
||||
{ in: "path", key: "credentialID" },
|
||||
{ in: "body", key: "label" },
|
||||
],
|
||||
},
|
||||
],
|
||||
)
|
||||
return (options?.client ?? this.client).patch<V2CredentialUpdateResponses, V2CredentialUpdateErrors, ThrowOnError>({
|
||||
url: "/api/credential/{credentialID}",
|
||||
...options,
|
||||
...params,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
...options?.headers,
|
||||
...params.headers,
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export class Request extends HeyApiClient {
|
||||
@@ -6216,9 +6272,14 @@ export class V2 extends HeyApiClient {
|
||||
return (this._provider ??= new Provider2({ client: this.client }))
|
||||
}
|
||||
|
||||
private _connector?: Connector
|
||||
get connector(): Connector {
|
||||
return (this._connector ??= new Connector({ client: this.client }))
|
||||
private _integration?: Integration
|
||||
get integration(): Integration {
|
||||
return (this._integration ??= new Integration({ client: this.client }))
|
||||
}
|
||||
|
||||
private _credential?: Credential
|
||||
get credential(): Credential {
|
||||
return (this._credential ??= new Credential({ client: this.client }))
|
||||
}
|
||||
|
||||
private _permission?: Permission3
|
||||
|
||||
Reference in New Issue
Block a user