feat(plugin): add session request hook (#35794)

This commit is contained in:
Dax 2026-07-07 19:56:47 -04:00 committed by GitHub
commit 4f976bcf1a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
124 changed files with 7743 additions and 5620 deletions

View file

@ -180,7 +180,7 @@ function KeyMethod(props: {
onConfirm={(key) => {
if (!key) return
void sdk.api.integration
.connectKey({
.connect.key({
integrationID: props.integration.id,
location: location(data),
key,
@ -219,7 +219,7 @@ function OAuthStarting(props: {
onMount(() => {
void sdk.api.integration
.connectOauth({
.connect.oauth({
integrationID: props.integration.id,
location: location(data),
methodID: props.method.id,
@ -288,7 +288,7 @@ function OAuthAuto(props: {
const poll = () => {
void sdk.api.integration
.attemptStatus({ attemptID: props.attempt.attemptID, location: location(data) })
.attempt.status({ attemptID: props.attempt.attemptID, location: location(data) })
.then((result) => {
const status = result.data
if (status.status === "pending") {
@ -314,7 +314,7 @@ function OAuthAuto(props: {
onCleanup(() => {
if (timer) clearTimeout(timer)
if (settled) return
void sdk.api.integration.attemptCancel({ attemptID: props.attempt.attemptID, location: location(data) })
void sdk.api.integration.attempt.cancel({ attemptID: props.attempt.attemptID, location: location(data) })
})
return (
@ -344,7 +344,7 @@ function OAuthCode(props: {
onCleanup(() => {
if (settled) return
void sdk.api.integration.attemptCancel({ attemptID: props.attempt.attemptID, location: location(data) })
void sdk.api.integration.attempt.cancel({ attemptID: props.attempt.attemptID, location: location(data) })
})
return (
@ -354,7 +354,7 @@ function OAuthCode(props: {
onConfirm={(code) => {
if (!code) return
void sdk.api.integration
.attemptComplete({ attemptID: props.attempt.attemptID, location: location(data), code })
.attempt.complete({ attemptID: props.attempt.attemptID, location: location(data), code })
.then(() => {
settled = true
return connected(props.integration, data, dialog, toast, props.onConnected)

View file

@ -1127,7 +1127,7 @@ export function Prompt(props: PromptProps) {
})
}
if (session?.revert) {
const error = await sdk.api.session.revertCommit({ sessionID }).then(
const error = await sdk.api.session.revert.commit({ sessionID }).then(
() => undefined,
(error) => error,
)

View file

@ -919,7 +919,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
return store.project.permission[projectID]
},
async refresh(projectID: string) {
setStore("project", "permission", projectID, mutable(await sdk.api.permission.listSaved({ projectID })))
setStore("project", "permission", projectID, mutable(await sdk.api.permission.saved.list({ projectID })))
},
},
},
@ -1064,7 +1064,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
)
for (const session of response.data) registerSession(session.id)
}),
sdk.api.permission.listRequests({ location: locationQuery(defaultLocation()) }).then((response) => {
sdk.api.permission.request.list({ location: locationQuery(defaultLocation()) }).then((response) => {
const permissions = mutable(response.data).reduce<Record<string, PermissionV2Request[]>>(
(result, request) => ({
...result,
@ -1074,7 +1074,7 @@ export const { use: useData, provider: DataProvider } = createSimpleContext({
)
setStore("session", "permission", reconcile(permissions))
}),
sdk.api.form.listRequests({ location: locationQuery(defaultLocation()) }).then((response) => {
sdk.api.form.request.list({ location: locationQuery(defaultLocation()) }).then((response) => {
const forms = mutable(response.data).reduce<Record<string, FormInfo[]>>(
(result, form) => ({
...result,

View file

@ -24,7 +24,7 @@ export function DialogMessage(props: { messageID: string; sessionID: string }) {
description: "undo messages and file changes",
onSelect: async (dialog) => {
await sdk.api.session
.revertStage({ sessionID: props.sessionID, messageID: props.messageID })
.revert.stage({ sessionID: props.sessionID, messageID: props.messageID })
.catch((error) => toast.show({ message: errorMessage(error), variant: "error", duration: 5000 }))
dialog.clear()
},

View file

@ -437,7 +437,7 @@ export function Session() {
dialog.clear()
return
}
const error = await sdk.api.session.revertStage({ sessionID: route.sessionID, messageID: target }).then(
const error = await sdk.api.session.revert.stage({ sessionID: route.sessionID, messageID: target }).then(
() => undefined,
(error) => error,
)
@ -454,7 +454,7 @@ export function Session() {
slash: { name: "redo" },
run: () => {
void (async () => {
const error = await sdk.api.session.revertClear({ sessionID: route.sessionID }).then(
const error = await sdk.api.session.revert.clear({ sessionID: route.sessionID }).then(
() => undefined,
(error) => error,
)
@ -1383,7 +1383,7 @@ function RevertMessage(props: {
onMouseUp={() => {
if (renderer.getSelection()?.getSelectedText()) return
void (async () => {
const error = await sdk.api.session.revertClear({ sessionID: route.sessionID }).then(
const error = await sdk.api.session.revert.clear({ sessionID: route.sessionID }).then(
() => undefined,
(error) => error,
)