演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
3058 lines
122 KiB
TypeScript
3058 lines
122 KiB
TypeScript
import type {
|
|
AgentAppComposerResponse,
|
|
AgentAppPagination,
|
|
} from '@dify/contracts/api/console/agent/types.gen'
|
|
import type { ApiBasedExtensionResponse } from '@dify/contracts/api/console/api-based-extension/types.gen'
|
|
import type { AppDetailWithSite } from '@dify/contracts/api/console/apps/types.gen'
|
|
import type {
|
|
DatasetListResponse,
|
|
DocumentWithSegmentsListResponse,
|
|
} from '@dify/contracts/api/console/datasets/types.gen'
|
|
import type { KnowledgeFsSpaceListResponse } from '@dify/contracts/api/console/knowledge-fs/types.gen'
|
|
import type { TagResponse as Tag } from '@dify/contracts/api/console/tags/types.gen'
|
|
import type { GetWorkflowRunArchivesResponse } from '@dify/contracts/api/console/workflow-run-archives/types.gen'
|
|
import type { AccountWithRoleListResponse } from '@dify/contracts/api/console/workspaces/types.gen'
|
|
import type { RouterUtils } from '@orpc/tanstack-query'
|
|
import type { InfiniteData, QueryClient, QueryKey } from '@tanstack/react-query'
|
|
import type { ConsoleClient } from './index'
|
|
import { createTanstackQueryUtils } from '@orpc/tanstack-query'
|
|
import { getHttpErrorStatus, isNotFoundError } from '@/service/http-error'
|
|
import {
|
|
legacyWorkflowVersionHistoryKey,
|
|
syncAppWorkflowVersionCaches,
|
|
syncWorkflowDeploymentCaches,
|
|
} from './workflow-version-cache'
|
|
|
|
export function createConsoleQuery(consoleClient: ConsoleClient) {
|
|
const consoleQuery: RouterUtils<ConsoleClient> = createTanstackQueryUtils(consoleClient, {
|
|
path: ['console'],
|
|
experimental_defaults: {
|
|
workflowRunArchives: {
|
|
downloads: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (task, _variables, _onMutateResult, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.workflowRunArchives.downloads.byDownloadId.get.queryKey({
|
|
input: { params: { download_id: task.download_id } },
|
|
}),
|
|
task,
|
|
)
|
|
},
|
|
},
|
|
},
|
|
},
|
|
byYear: {
|
|
byMonth: {
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (task, _variables, _onMutateResult, context) => {
|
|
const queryKey = consoleQuery.workflowRunArchives.get.queryKey()
|
|
const deletionStatus = task.status
|
|
context.client.setQueryData<GetWorkflowRunArchivesResponse>(queryKey, (data) => {
|
|
if (!data) return data
|
|
|
|
if (deletionStatus === 'completed') {
|
|
const months = data.months.filter(
|
|
(archive) => archive.year !== task.year || archive.month !== task.month,
|
|
)
|
|
return {
|
|
months,
|
|
summary: {
|
|
archived_month_count: months.length,
|
|
workflow_run_count: months.reduce(
|
|
(count, archive) => count + archive.workflow_run_count,
|
|
0,
|
|
),
|
|
archive_bytes: months.reduce(
|
|
(bytes, archive) => bytes + archive.archive_bytes,
|
|
0,
|
|
),
|
|
latest_archived_at: months.reduce<string | null>(
|
|
(latest, archive) =>
|
|
archive.latest_archived_at &&
|
|
(!latest || archive.latest_archived_at > latest)
|
|
? archive.latest_archived_at
|
|
: latest,
|
|
null,
|
|
),
|
|
},
|
|
}
|
|
}
|
|
|
|
return {
|
|
...data,
|
|
months: data.months.map((archive) =>
|
|
archive.year === task.year && archive.month === task.month
|
|
? { ...archive, deletion_status: deletionStatus }
|
|
: archive,
|
|
),
|
|
}
|
|
})
|
|
},
|
|
onSettled: (_data, _error, _variables, _onMutateResult, context) => {
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workflowRunArchives.get.queryKey(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
auth: {
|
|
plugin: {
|
|
datasource: {
|
|
list: { get: { queryOptions: { retry: false } } },
|
|
defaultList: { get: { queryOptions: { retry: false } } },
|
|
byProviderId: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.byProviderId.get.key({
|
|
input: { params: { provider_id: variables.params.provider_id } },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.list.get.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.defaultList.get.key(),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
update: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.byProviderId.get.key({
|
|
input: { params: { provider_id: variables.params.provider_id } },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.list.get.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.defaultList.get.key(),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
},
|
|
customClient: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.byProviderId.get.key({
|
|
input: { params: { provider_id: variables.params.provider_id } },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.list.get.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.defaultList.get.key(),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.byProviderId.get.key({
|
|
input: { params: { provider_id: variables.params.provider_id } },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.list.get.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.defaultList.get.key(),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
},
|
|
get: { queryOptions: { retry: false } },
|
|
default: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.byProviderId.get.key({
|
|
input: { params: { provider_id: variables.params.provider_id } },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.list.get.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.defaultList.get.key(),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.byProviderId.get.key({
|
|
input: { params: { provider_id: variables.params.provider_id } },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.list.get.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.auth.plugin.datasource.defaultList.get.key(),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
notion: {
|
|
pages: {
|
|
byPageId: {
|
|
byPageType: {
|
|
preview: {
|
|
get: {
|
|
queryOptions: {
|
|
context: { silent: true },
|
|
retry: false,
|
|
staleTime: 0,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
rag: {
|
|
pipeline: {
|
|
templates: {
|
|
byTemplateId: { get: { queryOptions: { staleTime: 0 } } },
|
|
},
|
|
},
|
|
pipelines: {
|
|
datasourcePlugins: {
|
|
get: {
|
|
queryOptions: { staleTime: 0, retry: false },
|
|
},
|
|
},
|
|
// DSL import failures are reported by the import flow.
|
|
imports: {
|
|
post: { mutationOptions: { context: { silent: true } } },
|
|
byImportId: {
|
|
confirm: { post: { mutationOptions: { context: { silent: true } } } },
|
|
},
|
|
},
|
|
byPipelineId: {
|
|
workflowRuns: {
|
|
tasks: {
|
|
byTaskId: {
|
|
stop: {
|
|
post: {
|
|
mutationOptions: {
|
|
// A failed response can still follow an accepted stop request.
|
|
onSettled: (_data, _error, variables, _result, context) => {
|
|
return context.client.invalidateQueries({
|
|
queryKey: consoleQuery.rag.pipelines.byPipelineId.workflowRuns.key({
|
|
input: { params: { pipeline_id: variables.params.pipeline_id } },
|
|
}),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
workflows: {
|
|
publish: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.rag.pipelines.byPipelineId.workflows.publish.get.key({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.rag.pipelines.byPipelineId.workflows.get.key({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: legacyWorkflowVersionHistoryKey,
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.datasets.get.key(),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
},
|
|
byWorkflowId: {
|
|
patch: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) => {
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: legacyWorkflowVersionHistoryKey,
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.rag.pipelines.byPipelineId.workflows.get.key({
|
|
input: { params: { pipeline_id: variables.params.pipeline_id } },
|
|
}),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.rag.pipelines.byPipelineId.workflows.get.key({
|
|
input: { params: { pipeline_id: variables.params.pipeline_id } },
|
|
}),
|
|
}),
|
|
},
|
|
},
|
|
},
|
|
draft: {
|
|
processing: { parameters: { get: { queryOptions: { staleTime: 0 } } } },
|
|
preProcessing: { parameters: { get: { queryOptions: { staleTime: 0 } } } },
|
|
},
|
|
published: {
|
|
processing: { parameters: { get: { queryOptions: { staleTime: 0 } } } },
|
|
preProcessing: { parameters: { get: { queryOptions: { staleTime: 0 } } } },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
workspaces: {
|
|
current: {
|
|
humanInput: {
|
|
v2: {
|
|
contacts: {
|
|
platform: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, _error, _variables, _onMutateResult, context) =>
|
|
invalidateHumanInputContactQueries(consoleQuery, context.client),
|
|
},
|
|
},
|
|
},
|
|
byContactId: {
|
|
imBindings: {
|
|
put: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _onMutateResult, context) =>
|
|
invalidateHumanInputContactQueries(consoleQuery, context.client),
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _onMutateResult, context) =>
|
|
invalidateHumanInputContactQueries(consoleQuery, context.client),
|
|
},
|
|
},
|
|
},
|
|
imOverride: {
|
|
put: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _onMutateResult, context) =>
|
|
invalidateHumanInputContactQueries(consoleQuery, context.client),
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _onMutateResult, context) =>
|
|
invalidateHumanInputContactQueries(consoleQuery, context.client),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
external: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _onMutateResult, context) =>
|
|
invalidateHumanInputContactQueries(consoleQuery, context.client),
|
|
},
|
|
},
|
|
byContactId: {
|
|
patch: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _onMutateResult, context) =>
|
|
invalidateHumanInputContactQueries(consoleQuery, context.client),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
remove: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _onMutateResult, context) =>
|
|
invalidateHumanInputContactQueries(consoleQuery, context.client),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
imSyncRuns: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (data, _variables, _onMutateResult, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.workspaces.current.humanInput.v2.imSyncRuns.latest.get.queryKey(),
|
|
data,
|
|
)
|
|
return context.client.resetQueries({
|
|
queryKey:
|
|
consoleQuery.workspaces.current.humanInput.v2.imSyncRuns.latest.results.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
channels: {
|
|
email: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _onMutateResult, context) =>
|
|
invalidateHumanInputChannelQueries(consoleQuery, context.client),
|
|
},
|
|
},
|
|
byChannelId: {
|
|
put: {
|
|
mutationOptions: {
|
|
onSettled: (_data, _error, _variables, _onMutateResult, context) =>
|
|
invalidateHumanInputChannelQueries(consoleQuery, context.client),
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSettled: (_data, _error, _variables, _onMutateResult, context) =>
|
|
invalidateHumanInputChannelQueries(consoleQuery, context.client),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
im: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _onMutateResult, context) =>
|
|
invalidateHumanInputChannelQueries(consoleQuery, context.client),
|
|
},
|
|
},
|
|
byChannelId: {
|
|
put: {
|
|
mutationOptions: {
|
|
onSettled: (_data, _error, _variables, _onMutateResult, context) =>
|
|
invalidateHumanInputChannelQueries(consoleQuery, context.client),
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSettled: (_data, _error, _variables, _onMutateResult, context) =>
|
|
invalidateHumanInputChannelQueries(consoleQuery, context.client),
|
|
},
|
|
},
|
|
replacement: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, _error, _variables, _onMutateResult, context) =>
|
|
invalidateHumanInputChannelQueries(consoleQuery, context.client),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
members: {
|
|
byMemberId: {
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) => {
|
|
context.client.setQueriesData(
|
|
{ queryKey: consoleQuery.workspaces.current.members.get.key() },
|
|
(members: AccountWithRoleListResponse | undefined) =>
|
|
members && {
|
|
...members,
|
|
accounts: members.accounts.filter(
|
|
(member) => member.id !== variables.params.member_id,
|
|
),
|
|
},
|
|
)
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.members.get.key(),
|
|
})
|
|
void invalidateHumanInputContactQueries(consoleQuery, context.client)
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
toolProvider: {
|
|
builtin: {
|
|
byProvider: {
|
|
add: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.workspaces.current.toolProvider.builtin.byProvider.credential.info.get.key(
|
|
{ input: { params: { provider: variables.params.provider } } },
|
|
),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.workspaces.current.toolProvider.builtin.byProvider.credentials.get.key(
|
|
{ input: { params: { provider: variables.params.provider } } },
|
|
),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.tools.builtin.get.key(),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
},
|
|
update: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.workspaces.current.toolProvider.builtin.byProvider.credential.info.get.key(
|
|
{ input: { params: { provider: variables.params.provider } } },
|
|
),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.workspaces.current.toolProvider.builtin.byProvider.credentials.get.key(
|
|
{ input: { params: { provider: variables.params.provider } } },
|
|
),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.tools.builtin.get.key(),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
},
|
|
oauth: {
|
|
customClient: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.workspaces.current.toolProvider.builtin.byProvider.oauth.clientSchema.get.key(
|
|
{ input: { params: { provider: variables.params.provider } } },
|
|
),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.workspaces.current.toolProvider.builtin.byProvider.oauth.customClient.get.key(
|
|
{ input: { params: { provider: variables.params.provider } } },
|
|
),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.workspaces.current.toolProvider.builtin.byProvider.oauth.clientSchema.get.key(
|
|
{ input: { params: { provider: variables.params.provider } } },
|
|
),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.workspaces.current.toolProvider.builtin.byProvider.oauth.customClient.get.key(
|
|
{ input: { params: { provider: variables.params.provider } } },
|
|
),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
defaultCredential: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.workspaces.current.toolProvider.builtin.byProvider.credential.info.get.key(
|
|
{ input: { params: { provider: variables.params.provider } } },
|
|
),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.workspaces.current.toolProvider.builtin.byProvider.credentials.get.key(
|
|
{ input: { params: { provider: variables.params.provider } } },
|
|
),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.tools.builtin.get.key(),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.workspaces.current.toolProvider.builtin.byProvider.credential.info.get.key(
|
|
{ input: { params: { provider: variables.params.provider } } },
|
|
),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.workspaces.current.toolProvider.builtin.byProvider.credentials.get.key(
|
|
{ input: { params: { provider: variables.params.provider } } },
|
|
),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.tools.builtin.get.key(),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
networkAccessGroups: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, _variables, _result, context) => {
|
|
if (error) return
|
|
return invalidateNetworkAccessGroupQueries(consoleQuery, context.client)
|
|
},
|
|
},
|
|
},
|
|
byGroupId: {
|
|
put: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, _variables, _result, context) => {
|
|
if (error) return
|
|
return invalidateNetworkAccessGroupQueries(consoleQuery, context.client)
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, _variables, _result, context) => {
|
|
if (error) return
|
|
return invalidateNetworkAccessGroupQueries(consoleQuery, context.client)
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
plugin: {
|
|
readme: {
|
|
get: {
|
|
queryOptions: {
|
|
context: { silent: true },
|
|
retry: false,
|
|
},
|
|
},
|
|
},
|
|
asset: {
|
|
get: {
|
|
queryOptions: { context: { silent: true } },
|
|
},
|
|
},
|
|
},
|
|
endpoints: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, _error, _variables, _result, context) => {
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.endpoints.list.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.plugin.list.get.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.plugin.byCategory.list.get.key(),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
byId: {
|
|
patch: {
|
|
mutationOptions: {
|
|
onSettled: (_data, _error, _variables, _result, context) => {
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.endpoints.list.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.plugin.list.get.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.plugin.byCategory.list.get.key(),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSettled: (_data, _error, _variables, _result, context) => {
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.endpoints.list.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.plugin.list.get.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.plugin.byCategory.list.get.key(),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
},
|
|
enable: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, _error, _variables, _result, context) => {
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.endpoints.list.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.plugin.list.get.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.plugin.byCategory.list.get.key(),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
},
|
|
disable: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, _error, _variables, _result, context) => {
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.endpoints.list.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.plugin.list.get.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.plugin.byCategory.list.get.key(),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
skills: {
|
|
bySkillId: {
|
|
restore: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error) return
|
|
void invalidateSkillVersionQueries(
|
|
consoleQuery,
|
|
context.client,
|
|
variables.params.skill_id,
|
|
)
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.skills.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
versions: {
|
|
byVersionId: {
|
|
delete: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error) return
|
|
void invalidateSkillVersionQueries(
|
|
consoleQuery,
|
|
context.client,
|
|
variables.params.skill_id,
|
|
)
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, _variables, _result, context) => {
|
|
if (error) return
|
|
return context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.agents.byAgentId.skills.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
// Role writes refresh the role list; role assignment changes also refresh members.
|
|
rbac: {
|
|
roles: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, _variables, _result, context) =>
|
|
error
|
|
? undefined
|
|
: context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.rbac.roles.get.key(),
|
|
}),
|
|
},
|
|
},
|
|
byRoleId: {
|
|
put: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, _variables, _result, context) =>
|
|
error
|
|
? undefined
|
|
: context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.rbac.roles.get.key(),
|
|
}),
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, _variables, _result, context) =>
|
|
error
|
|
? undefined
|
|
: Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.rbac.roles.get.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.members.get.key(),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
copy: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) =>
|
|
error
|
|
? undefined
|
|
: Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.rbac.roles.get.key(),
|
|
}),
|
|
variables.body?.copy_member &&
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.members.get.key(),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
members: {
|
|
byMemberId: {
|
|
rbacRoles: {
|
|
put: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) =>
|
|
error
|
|
? undefined
|
|
: Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.workspaces.current.rbac.members.byMemberId.rbacRoles.get.key(
|
|
{ input: { params: variables.params } },
|
|
),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.workspaces.current.members.get.key(),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
accessPolicies: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, _variables, _result, context) => {
|
|
if (error) return
|
|
return invalidateAccessPolicyQueries(consoleQuery, context.client)
|
|
},
|
|
},
|
|
},
|
|
byPolicyId: {
|
|
put: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, _variables, _result, context) => {
|
|
if (error) return
|
|
return invalidateAccessPolicyQueries(consoleQuery, context.client)
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, _variables, _result, context) => {
|
|
if (error) return
|
|
return invalidateAccessPolicyQueries(consoleQuery, context.client)
|
|
},
|
|
},
|
|
},
|
|
copy: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, _variables, _result, context) => {
|
|
if (error) return
|
|
return invalidateAccessPolicyQueries(consoleQuery, context.client)
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
agents: {
|
|
byAgentId: {
|
|
whitelist: {
|
|
put: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error) return
|
|
return invalidateAgentAccessQueries(
|
|
consoleQuery,
|
|
context.client,
|
|
variables.params.agent_id,
|
|
)
|
|
},
|
|
},
|
|
},
|
|
},
|
|
users: {
|
|
byTargetAccountId: {
|
|
accessPolicies: {
|
|
put: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error) return
|
|
return invalidateAgentAccessQueries(
|
|
consoleQuery,
|
|
context.client,
|
|
variables.params.agent_id,
|
|
)
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
accessPolicies: {
|
|
byPolicyId: {
|
|
memberBindings: {
|
|
delete: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error) return
|
|
return invalidateAgentAccessQueries(
|
|
consoleQuery,
|
|
context.client,
|
|
variables.params.agent_id,
|
|
)
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
account: {
|
|
education: {
|
|
get: {
|
|
queryOptions: {
|
|
// Passive probe: every callsite degrades to "not a student", so no toast.
|
|
context: { silent: true },
|
|
retry: false,
|
|
},
|
|
},
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (data, _variables, _onMutateResult, context) => {
|
|
if (data.message !== 'success') return
|
|
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.account.education.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
profile: {
|
|
patch: {
|
|
mutationOptions: {
|
|
onSuccess: async (_data, _variables, _onMutateResult, context) => {
|
|
await context.client.invalidateQueries({
|
|
queryKey: consoleQuery.account.profile.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
apps: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _onMutateResult, context) => {
|
|
void context.client.invalidateQueries({ queryKey: consoleQuery.features.get.key() })
|
|
void context.client.invalidateQueries({ queryKey: consoleQuery.apps.get.key() })
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.starred.get.key(),
|
|
})
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.recent.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
imports: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (data, variables, _onMutateResult, context) => {
|
|
if (data.status !== 'completed' && data.status !== 'completed-with-warnings') return
|
|
|
|
if (!('app_id' in variables.body) || !variables.body.app_id) {
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.features.get.key(),
|
|
})
|
|
}
|
|
void context.client.invalidateQueries({ queryKey: consoleQuery.apps.get.key() })
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.starred.get.key(),
|
|
})
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.recent.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
byImportId: {
|
|
confirm: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (data, _variables, _onMutateResult, context) => {
|
|
if (data.status !== 'completed' && data.status !== 'completed-with-warnings')
|
|
return
|
|
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.features.get.key(),
|
|
})
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.get.key(),
|
|
})
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.starred.get.key(),
|
|
})
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.recent.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
byAppId: {
|
|
annotations: {
|
|
byAnnotationId: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error) return
|
|
return context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.annotations.key({
|
|
input: { params: { app_id: variables.params.app_id } },
|
|
}),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error) return
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.annotations.key({
|
|
input: { params: { app_id: variables.params.app_id } },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.features.get.key(),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
},
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error) return
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.annotations.key({
|
|
input: { params: { app_id: variables.params.app_id } },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({ queryKey: consoleQuery.features.get.key() }),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
},
|
|
traceRuns: {
|
|
bySourceKind: {
|
|
bySourceId: {
|
|
get: { queryOptions: { context: { silent: true }, retry: false } },
|
|
},
|
|
},
|
|
},
|
|
workflowRuns: {
|
|
tasks: {
|
|
byTaskId: {
|
|
stop: {
|
|
post: {
|
|
mutationOptions: {
|
|
// A failed response can still follow an accepted stop request.
|
|
onSettled: (_data, _error, variables, _result, context) => {
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.workflowRuns.key({
|
|
input: { params: { app_id: variables.params.app_id } },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.advancedChat.workflowRuns.key({
|
|
input: { params: { app_id: variables.params.app_id } },
|
|
}),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
trace: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.apps.byAppId.trace.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
{
|
|
...variables.body,
|
|
capture_content: variables.body.capture_content ?? false,
|
|
capture_agent: variables.body.capture_agent ?? true,
|
|
},
|
|
)
|
|
},
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error && getHttpErrorStatus(error) !== 409) return
|
|
return Promise.all([
|
|
...(error
|
|
? [
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.traceConfig.get.key({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
]
|
|
: []),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.trace.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.traceCapabilities.get.key({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
},
|
|
traceConfig: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error && getHttpErrorStatus(error) !== 409) return
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.trace.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.traceConfig.get.queryKey({
|
|
input: {
|
|
params: variables.params,
|
|
query: { tracing_provider: variables.body.tracing_provider },
|
|
},
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.traceCapabilities.get.key({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
patch: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error && getHttpErrorStatus(error) !== 409) return
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.trace.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.traceConfig.get.queryKey({
|
|
input: {
|
|
params: variables.params,
|
|
query: { tracing_provider: variables.body.tracing_provider },
|
|
},
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.traceCapabilities.get.key({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error && getHttpErrorStatus(error) !== 409) return
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.trace.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.traceConfig.get.queryKey({
|
|
input: {
|
|
params: variables.params,
|
|
query: { tracing_provider: variables.query.tracing_provider },
|
|
},
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.traceCapabilities.get.key({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
},
|
|
// Shared invalidation uses onSettled so feature-owned onSuccess callbacks can coexist.
|
|
networkAccessGroup: {
|
|
put: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, _variables, _result, context) => {
|
|
if (error) return
|
|
return invalidateNetworkAccessGroupQueries(consoleQuery, context.client)
|
|
},
|
|
},
|
|
},
|
|
},
|
|
apiEnable: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (data, error, variables, _onMutateResult, context) => {
|
|
if (error || !data) return
|
|
|
|
context.client.setQueryData<AppDetailWithSite>(
|
|
consoleQuery.apps.byAppId.get.queryKey({ input: { params: variables.params } }),
|
|
(detail) =>
|
|
detail
|
|
? { ...detail, enable_api: data.enable_api, updated_at: data.updated_at }
|
|
: undefined,
|
|
)
|
|
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _onMutateResult, context) => {
|
|
void context.client.invalidateQueries({ queryKey: consoleQuery.features.get.key() })
|
|
return Promise.all([
|
|
context.client.invalidateQueries({ queryKey: consoleQuery.apps.get.key() }),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.starred.get.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.recent.get.key(),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
put: {
|
|
mutationOptions: {
|
|
onSuccess: (data, variables, _onMutateResult, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.apps.byAppId.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
data,
|
|
)
|
|
void context.client.invalidateQueries({ queryKey: consoleQuery.apps.get.key() })
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.starred.get.key(),
|
|
})
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.recent.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
siteEnable: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (data, error, variables, _onMutateResult, context) => {
|
|
if (error || !data) return
|
|
|
|
context.client.setQueryData<AppDetailWithSite>(
|
|
consoleQuery.apps.byAppId.get.queryKey({ input: { params: variables.params } }),
|
|
(detail) =>
|
|
detail
|
|
? { ...detail, enable_site: data.enable_site, updated_at: data.updated_at }
|
|
: undefined,
|
|
)
|
|
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
site: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _onMutateResult, context) => {
|
|
if (error) return
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
})
|
|
void context.client.invalidateQueries({ queryKey: consoleQuery.apps.get.key() })
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.starred.get.key(),
|
|
})
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.recent.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
accessTokenReset: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (data, error, variables, _onMutateResult, context) => {
|
|
if (error || !data) return
|
|
|
|
const { code } = data
|
|
if (code !== undefined) {
|
|
context.client.setQueryData<AppDetailWithSite>(
|
|
consoleQuery.apps.byAppId.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
(detail) =>
|
|
detail?.site
|
|
? {
|
|
...detail,
|
|
site: { ...detail.site, code, access_token: code },
|
|
}
|
|
: detail,
|
|
)
|
|
}
|
|
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
convertToWorkflow: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _onMutateResult, context) => {
|
|
void context.client.invalidateQueries({ queryKey: consoleQuery.apps.get.key() })
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.starred.get.key(),
|
|
})
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.recent.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
copy: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (data, _variables, _onMutateResult, context) => {
|
|
if (!('mode' in data)) return
|
|
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.features.get.key(),
|
|
})
|
|
void context.client.invalidateQueries({ queryKey: consoleQuery.apps.get.key() })
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.starred.get.key(),
|
|
})
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.recent.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
star: {
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _onMutateResult, context) =>
|
|
Promise.all([
|
|
context.client.invalidateQueries({ queryKey: consoleQuery.apps.get.key() }),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.starred.get.key(),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _onMutateResult, context) =>
|
|
Promise.all([
|
|
context.client.invalidateQueries({ queryKey: consoleQuery.apps.get.key() }),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.starred.get.key(),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
},
|
|
workflows: {
|
|
publish: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.workflows.publish.get.key({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.workflows.get.key({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: legacyWorkflowVersionHistoryKey,
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.get.key({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.triggers.get.key({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
},
|
|
byWorkflowId: {
|
|
patch: {
|
|
mutationOptions: {
|
|
onSuccess: (data, variables, _result, context) => {
|
|
syncAppWorkflowVersionCaches(
|
|
context.client,
|
|
consoleQuery,
|
|
variables.params.app_id,
|
|
data,
|
|
)
|
|
const deploymentsKey = syncWorkflowDeploymentCaches(
|
|
context.client,
|
|
consoleQuery,
|
|
variables.params.app_id,
|
|
data,
|
|
)
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: legacyWorkflowVersionHistoryKey,
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.workflows.get.key({
|
|
input: { params: { app_id: variables.params.app_id } },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({ queryKey: deploymentsKey }),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byAppId.workflows.get.key({
|
|
input: { params: { app_id: variables.params.app_id } },
|
|
}),
|
|
}),
|
|
},
|
|
},
|
|
},
|
|
draft: {
|
|
nodes: {
|
|
byNodeId: {
|
|
agentComposer: {
|
|
put: {
|
|
mutationOptions: {
|
|
onSuccess: (composerState, variables, _onMutateResult, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.apps.byAppId.workflows.draft.nodes.byNodeId.agentComposer.get.queryKey(
|
|
{
|
|
input: {
|
|
params: variables.params,
|
|
},
|
|
},
|
|
),
|
|
composerState,
|
|
)
|
|
},
|
|
},
|
|
},
|
|
copyFromRoster: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (composerState, variables, _onMutateResult, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.apps.byAppId.workflows.draft.nodes.byNodeId.agentComposer.get.queryKey(
|
|
{
|
|
input: {
|
|
params: variables.params,
|
|
},
|
|
},
|
|
),
|
|
composerState,
|
|
)
|
|
},
|
|
},
|
|
},
|
|
},
|
|
saveToRoster: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (composerState, variables, _onMutateResult, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.apps.byAppId.workflows.draft.nodes.byNodeId.agentComposer.get.queryKey(
|
|
{
|
|
input: {
|
|
params: variables.params,
|
|
},
|
|
},
|
|
),
|
|
composerState,
|
|
)
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.get.key(),
|
|
})
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.inviteOptions.get.key(),
|
|
})
|
|
|
|
const agentId =
|
|
composerState.binding?.binding_type === 'roster_agent'
|
|
? composerState.binding.agent_id
|
|
: undefined
|
|
if (agentId) {
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.get.queryKey({
|
|
input: {
|
|
params: {
|
|
agent_id: agentId,
|
|
},
|
|
},
|
|
}),
|
|
})
|
|
}
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
byResourceId: {
|
|
apiKeys: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _onMutateResult, context) => {
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byResourceId.apiKeys.get.queryKey({
|
|
input: { params: { resource_id: variables.params.resource_id } },
|
|
}),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
byApiKeyId: {
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _onMutateResult, context) => {
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.byResourceId.apiKeys.get.queryKey({
|
|
input: { params: { resource_id: variables.params.resource_id } },
|
|
}),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
knowledgeFs: {
|
|
spaces: {
|
|
byControlSpaceId: {
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) => {
|
|
context.client.setQueriesData(
|
|
{ queryKey: consoleQuery.knowledgeFs.spaces.get.key({ type: 'query' }) },
|
|
(list: KnowledgeFsSpaceListResponse | undefined) => {
|
|
if (
|
|
!list?.data.some(
|
|
(item) => item.control_space_id === variables.params.control_space_id,
|
|
)
|
|
)
|
|
return list
|
|
return {
|
|
...list,
|
|
data: list.data.filter(
|
|
(item) => item.control_space_id !== variables.params.control_space_id,
|
|
),
|
|
}
|
|
},
|
|
)
|
|
context.client.setQueriesData(
|
|
{ queryKey: consoleQuery.knowledgeFs.spaces.get.key({ type: 'infinite' }) },
|
|
(list: InfiniteData<KnowledgeFsSpaceListResponse, unknown> | undefined) => {
|
|
if (
|
|
!list?.pages.some((page) =>
|
|
page.data.some(
|
|
(item) => item.control_space_id === variables.params.control_space_id,
|
|
),
|
|
)
|
|
)
|
|
return list
|
|
return {
|
|
...list,
|
|
pages: list.pages.map((page) => ({
|
|
...page,
|
|
data: page.data.filter(
|
|
(item) => item.control_space_id !== variables.params.control_space_id,
|
|
),
|
|
})),
|
|
}
|
|
},
|
|
)
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.knowledgeFs.spaces.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
datasets: {
|
|
// Process rules are read once to describe a running import.
|
|
processRule: { get: { queryOptions: { refetchOnWindowFocus: false } } },
|
|
byDatasetId: {
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) => {
|
|
context.client.setQueriesData(
|
|
{ queryKey: consoleQuery.datasets.get.key({ type: 'query' }) },
|
|
(list: DatasetListResponse | undefined) => {
|
|
if (!list?.data.some((item) => item.id === variables.params.dataset_id))
|
|
return list
|
|
const total = Math.max(0, list.total - 1)
|
|
return {
|
|
...list,
|
|
data: list.data.filter((item) => item.id !== variables.params.dataset_id),
|
|
total,
|
|
has_more: list.page * list.limit < total,
|
|
}
|
|
},
|
|
)
|
|
context.client.setQueriesData(
|
|
{ queryKey: consoleQuery.datasets.get.key({ type: 'infinite' }) },
|
|
(list: InfiniteData<DatasetListResponse, unknown> | undefined) => {
|
|
if (
|
|
!list?.pages.some((page) =>
|
|
page.data.some((item) => item.id === variables.params.dataset_id),
|
|
)
|
|
)
|
|
return list
|
|
return {
|
|
...list,
|
|
pages: list.pages.map((page) => {
|
|
const total = Math.max(0, page.total - 1)
|
|
return {
|
|
...page,
|
|
data: page.data.filter((item) => item.id !== variables.params.dataset_id),
|
|
total,
|
|
has_more: page.page * page.limit < total,
|
|
}
|
|
}),
|
|
}
|
|
},
|
|
)
|
|
void context.client.invalidateQueries({ queryKey: consoleQuery.datasets.get.key() })
|
|
},
|
|
},
|
|
},
|
|
// The upgrade dialog reports start failures, including model issues, inline.
|
|
knowledgeFsUpgrades: {
|
|
post: { mutationOptions: { context: { silent: true } } },
|
|
},
|
|
get: {
|
|
queryOptions: {
|
|
// A missing or inaccessible dataset sends the detail page back to the list.
|
|
retry: (failureCount, error) => {
|
|
const status = getHttpErrorStatus(error)
|
|
if (status === 403 || status === 404) return false
|
|
|
|
return failureCount < 3
|
|
},
|
|
},
|
|
},
|
|
documents: {
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) => {
|
|
const documentIds = new Set(variables.query?.document_id ?? [])
|
|
const input = { params: variables.params }
|
|
context.client.setQueriesData(
|
|
{
|
|
queryKey: consoleQuery.datasets.byDatasetId.documents.get.key({
|
|
type: 'query',
|
|
input,
|
|
}),
|
|
},
|
|
(list: DocumentWithSegmentsListResponse | undefined) => {
|
|
if (!list) return list
|
|
const data = list.data.filter((document) => !documentIds.has(document.id))
|
|
if (data.length === list.data.length) return list
|
|
const total = Math.max(0, list.total - (list.data.length - data.length))
|
|
return { ...list, data, total, has_more: list.page * list.limit < total }
|
|
},
|
|
)
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.datasets.byDatasetId.documents.get.key({ input }),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
byDocumentId: {
|
|
pipelineExecutionLog: { get: { queryOptions: { staleTime: 0 } } },
|
|
},
|
|
// Document metadata shows in the dataset fields, the document list and each
|
|
// document's detail.
|
|
metadata: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error) return
|
|
const params = { dataset_id: variables.params.dataset_id }
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.datasets.byDatasetId.metadata.get.queryKey({
|
|
input: { params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.datasets.byDatasetId.documents.get.key({
|
|
input: { params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.datasets.byDatasetId.documents.byDocumentId.get.key({
|
|
input: { params },
|
|
}),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
metadata: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error) return
|
|
return context.client.invalidateQueries({
|
|
queryKey: consoleQuery.datasets.byDatasetId.metadata.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
byMetadataId: {
|
|
patch: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error) return
|
|
const params = { dataset_id: variables.params.dataset_id }
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.datasets.byDatasetId.metadata.get.queryKey({
|
|
input: { params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.datasets.byDatasetId.documents.get.key({
|
|
input: { params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.datasets.byDatasetId.documents.byDocumentId.get.key({
|
|
input: { params },
|
|
}),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error) return
|
|
const params = { dataset_id: variables.params.dataset_id }
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.datasets.byDatasetId.metadata.get.queryKey({
|
|
input: { params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.datasets.byDatasetId.documents.get.key({
|
|
input: { params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.datasets.byDatasetId.documents.byDocumentId.get.key({
|
|
input: { params },
|
|
}),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
},
|
|
builtIn: {
|
|
byAction: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error) return
|
|
return context.client.invalidateQueries({
|
|
queryKey: consoleQuery.datasets.byDatasetId.metadata.get.queryKey({
|
|
input: { params: { dataset_id: variables.params.dataset_id } },
|
|
}),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
apiKeys: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _onMutateResult, context) => {
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.datasets.apiKeys.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
byApiKeyId: {
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _onMutateResult, context) => {
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.datasets.apiKeys.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
snippets: {
|
|
bySnippetId: {
|
|
workflowRuns: {
|
|
tasks: {
|
|
byTaskId: {
|
|
stop: {
|
|
post: {
|
|
mutationOptions: {
|
|
// A failed response can still follow an accepted stop request.
|
|
onSettled: (_data, _error, variables, _result, context) => {
|
|
return context.client.invalidateQueries({
|
|
queryKey: consoleQuery.snippets.bySnippetId.workflowRuns.key({
|
|
input: { params: { snippet_id: variables.params.snippet_id } },
|
|
}),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
workflows: {
|
|
byWorkflowId: {
|
|
patch: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) => {
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: legacyWorkflowVersionHistoryKey,
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.snippets.bySnippetId.workflows.get.key({
|
|
input: { params: { snippet_id: variables.params.snippet_id } },
|
|
}),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.snippets.bySnippetId.workflows.get.key({
|
|
input: { params: { snippet_id: variables.params.snippet_id } },
|
|
}),
|
|
}),
|
|
},
|
|
},
|
|
},
|
|
draft: {
|
|
nodes: {
|
|
byNodeId: {
|
|
agentComposer: {
|
|
put: {
|
|
mutationOptions: {
|
|
onSuccess: (composerState, variables, _onMutateResult, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.snippets.bySnippetId.workflows.draft.nodes.byNodeId.agentComposer.get.queryKey(
|
|
{
|
|
input: {
|
|
params: variables.params,
|
|
},
|
|
},
|
|
),
|
|
composerState,
|
|
)
|
|
},
|
|
},
|
|
},
|
|
copyFromRoster: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (composerState, variables, _onMutateResult, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.snippets.bySnippetId.workflows.draft.nodes.byNodeId.agentComposer.get.queryKey(
|
|
{
|
|
input: {
|
|
params: variables.params,
|
|
},
|
|
},
|
|
),
|
|
composerState,
|
|
)
|
|
},
|
|
},
|
|
},
|
|
},
|
|
saveToRoster: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (composerState, variables, _onMutateResult, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.snippets.bySnippetId.workflows.draft.nodes.byNodeId.agentComposer.get.queryKey(
|
|
{
|
|
input: {
|
|
params: variables.params,
|
|
},
|
|
},
|
|
),
|
|
composerState,
|
|
)
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.get.key(),
|
|
})
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.inviteOptions.get.key(),
|
|
})
|
|
|
|
const agentId =
|
|
composerState.binding?.binding_type === 'roster_agent'
|
|
? composerState.binding.agent_id
|
|
: undefined
|
|
if (agentId) {
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.get.queryKey({
|
|
input: {
|
|
params: {
|
|
agent_id: agentId,
|
|
},
|
|
},
|
|
}),
|
|
})
|
|
}
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
installedApps: {
|
|
byInstalledAppId: {
|
|
get: {
|
|
queryOptions: {
|
|
retry: (failureCount, error) => {
|
|
if (isNotFoundError(error)) return false
|
|
|
|
return failureCount < 3
|
|
},
|
|
},
|
|
},
|
|
patch: {
|
|
mutationOptions: {
|
|
onSuccess: (_response, variables, _onMutateResult, context) => {
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.installedApps.get.key(),
|
|
})
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.installedApps.byInstalledAppId.get.queryKey({
|
|
input: {
|
|
params: variables.params,
|
|
},
|
|
}),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
agent: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_createdAgent, _variables, _onMutateResult, context) => {
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.get.key(),
|
|
})
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.inviteOptions.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
byAgentId: {
|
|
trace: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (data, variables, _result, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.agent.byAgentId.trace.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
data,
|
|
)
|
|
},
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error && getHttpErrorStatus(error) !== 409) return
|
|
return Promise.all([
|
|
...(error
|
|
? [
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.traceConfig.get.key({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
]
|
|
: []),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.trace.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.traceCapabilities.get.key({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
},
|
|
traceConfig: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error && getHttpErrorStatus(error) !== 409) return
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.trace.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.traceConfig.get.queryKey({
|
|
input: {
|
|
params: variables.params,
|
|
query: { tracing_provider: variables.body.tracing_provider },
|
|
},
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.traceCapabilities.get.key({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
patch: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error && getHttpErrorStatus(error) !== 409) return
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.trace.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.traceConfig.get.queryKey({
|
|
input: {
|
|
params: variables.params,
|
|
query: { tracing_provider: variables.body.tracing_provider },
|
|
},
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.traceCapabilities.get.key({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, variables, _result, context) => {
|
|
if (error && getHttpErrorStatus(error) !== 409) return
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.trace.get.queryKey({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.traceConfig.get.queryKey({
|
|
input: {
|
|
params: variables.params,
|
|
query: { tracing_provider: variables.query.tracing_provider },
|
|
},
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.traceCapabilities.get.key({
|
|
input: { params: variables.params },
|
|
}),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
},
|
|
apiKeys: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
void Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.apiKeys.get.queryKey({
|
|
input: { params: { agent_id: variables.params.agent_id } },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.apiAccess.get.queryKey({
|
|
input: { params: { agent_id: variables.params.agent_id } },
|
|
}),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
byApiKeyId: {
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) =>
|
|
void Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.apiKeys.get.queryKey({
|
|
input: { params: { agent_id: variables.params.agent_id } },
|
|
}),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.apiAccess.get.queryKey({
|
|
input: { params: { agent_id: variables.params.agent_id } },
|
|
}),
|
|
}),
|
|
]),
|
|
},
|
|
},
|
|
},
|
|
},
|
|
get: {
|
|
queryOptions: {
|
|
retry: (failureCount, error) => {
|
|
if (isNotFoundError(error)) return false
|
|
|
|
return failureCount < 3
|
|
},
|
|
},
|
|
},
|
|
copy: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (copiedAgent, _variables, _onMutateResult, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.agent.byAgentId.get.queryKey({
|
|
input: {
|
|
params: {
|
|
agent_id: copiedAgent.id,
|
|
},
|
|
},
|
|
}),
|
|
copiedAgent,
|
|
)
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.get.key(),
|
|
})
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.inviteOptions.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
put: {
|
|
mutationOptions: {
|
|
onSuccess: (updatedAgent, variables, _onMutateResult, context) => {
|
|
context.client.setQueriesData(
|
|
{
|
|
queryKey: consoleQuery.agent.get.key({ type: 'query' }),
|
|
},
|
|
(oldList: AgentAppPagination | undefined) => {
|
|
if (!oldList?.data.some((item) => item.id === updatedAgent.id)) return oldList
|
|
|
|
return {
|
|
...oldList,
|
|
data: oldList.data.map((item) =>
|
|
item.id === updatedAgent.id ? updatedAgent : item,
|
|
),
|
|
}
|
|
},
|
|
)
|
|
context.client.setQueriesData(
|
|
{
|
|
queryKey: consoleQuery.agent.get.key({ type: 'infinite' }),
|
|
},
|
|
(oldList: InfiniteData<AgentAppPagination, unknown> | undefined) => {
|
|
if (
|
|
!oldList?.pages.some((page) =>
|
|
page.data.some((item) => item.id === updatedAgent.id),
|
|
)
|
|
)
|
|
return oldList
|
|
|
|
return {
|
|
...oldList,
|
|
pages: oldList.pages.map((page) => ({
|
|
...page,
|
|
data: page.data.map((item) =>
|
|
item.id === updatedAgent.id ? updatedAgent : item,
|
|
),
|
|
})),
|
|
}
|
|
},
|
|
)
|
|
context.client.setQueryData(
|
|
consoleQuery.agent.byAgentId.get.queryKey({
|
|
input: {
|
|
params: {
|
|
agent_id: variables.params.agent_id,
|
|
},
|
|
},
|
|
}),
|
|
updatedAgent,
|
|
)
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.inviteOptions.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
composer: {
|
|
put: {
|
|
mutationOptions: {
|
|
onSuccess: (composerState, variables, _onMutateResult, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.agent.byAgentId.composer.get.queryKey({
|
|
input: {
|
|
params: {
|
|
agent_id: variables.params.agent_id,
|
|
},
|
|
},
|
|
}),
|
|
composerState,
|
|
)
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.get.key(),
|
|
})
|
|
if (variables.body.save_strategy !== 'save_as_new_version') return
|
|
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.inviteOptions.get.key(),
|
|
})
|
|
context.client.removeQueries({
|
|
queryKey: consoleQuery.agent.inviteOptions.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
publish: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (publishResult, variables, _onMutateResult, context) => {
|
|
context.client.setQueryData<AgentAppComposerResponse>(
|
|
consoleQuery.agent.byAgentId.composer.get.queryKey({
|
|
input: {
|
|
params: {
|
|
agent_id: variables.params.agent_id,
|
|
},
|
|
},
|
|
}),
|
|
(composerState) => {
|
|
if (!composerState) return composerState
|
|
|
|
return {
|
|
...composerState,
|
|
active_config_is_published: true,
|
|
active_config_snapshot: publishResult.active_config_snapshot,
|
|
agent: {
|
|
...composerState.agent,
|
|
active_config_snapshot_id: publishResult.active_config_snapshot_id,
|
|
},
|
|
draft:
|
|
publishResult.draft === undefined
|
|
? composerState.draft
|
|
: publishResult.draft,
|
|
}
|
|
},
|
|
)
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.get.key(),
|
|
})
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.inviteOptions.get.key(),
|
|
})
|
|
context.client.removeQueries({
|
|
queryKey: consoleQuery.agent.inviteOptions.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _onMutateResult, context) => {
|
|
context.client.removeQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.key({
|
|
input: {
|
|
params: {
|
|
agent_id: variables.params.agent_id,
|
|
},
|
|
},
|
|
}),
|
|
})
|
|
context.client.setQueriesData(
|
|
{
|
|
queryKey: consoleQuery.agent.get.key({ type: 'query' }),
|
|
},
|
|
(oldList: AgentAppPagination | undefined) => {
|
|
if (!oldList?.data.some((item) => item.id === variables.params.agent_id))
|
|
return oldList
|
|
|
|
return {
|
|
...oldList,
|
|
data: oldList.data.filter((item) => item.id !== variables.params.agent_id),
|
|
total: Math.max(0, oldList.total - 1),
|
|
}
|
|
},
|
|
)
|
|
context.client.setQueriesData(
|
|
{
|
|
queryKey: consoleQuery.agent.get.key({ type: 'infinite' }),
|
|
},
|
|
(oldList: InfiniteData<AgentAppPagination, unknown> | undefined) => {
|
|
if (
|
|
!oldList?.pages.some((page) =>
|
|
page.data.some((item) => item.id === variables.params.agent_id),
|
|
)
|
|
)
|
|
return oldList
|
|
|
|
return {
|
|
...oldList,
|
|
pages: oldList.pages.map((page) => {
|
|
const total = Math.max(0, page.total - 1)
|
|
|
|
return {
|
|
...page,
|
|
data: page.data.filter((item) => item.id !== variables.params.agent_id),
|
|
has_more: page.page * page.limit < total,
|
|
total,
|
|
}
|
|
}),
|
|
}
|
|
},
|
|
)
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.get.key(),
|
|
})
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.inviteOptions.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
apiBasedExtension: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (createdExtension, _variables, _onMutateResult, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.apiBasedExtension.get.queryKey(),
|
|
(oldExtensions: ApiBasedExtensionResponse[] | undefined) =>
|
|
oldExtensions ? [createdExtension, ...oldExtensions] : oldExtensions,
|
|
)
|
|
},
|
|
},
|
|
},
|
|
byId: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (updatedExtension, variables, _onMutateResult, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.apiBasedExtension.get.queryKey(),
|
|
(oldExtensions: ApiBasedExtensionResponse[] | undefined) =>
|
|
oldExtensions?.map((extension) =>
|
|
extension.id === variables.params.id ? updatedExtension : extension,
|
|
),
|
|
)
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _onMutateResult, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.apiBasedExtension.get.queryKey(),
|
|
(oldExtensions: ApiBasedExtensionResponse[] | undefined) =>
|
|
oldExtensions?.filter((extension) => extension.id !== variables.params.id),
|
|
)
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
resourceAccessTokens: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, _variables, _result, context) => {
|
|
if (error) return
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.resourceAccessTokens.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
byTokenId: {
|
|
patch: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, _variables, _result, context) => {
|
|
if (error) return
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.resourceAccessTokens.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
relations: {
|
|
byRelationId: {
|
|
delete: {
|
|
mutationOptions: {
|
|
onSettled: (_data, error, _variables, _result, context) => {
|
|
if (error) return
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.resourceAccessTokens.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
tags: {
|
|
post: {
|
|
mutationOptions: {
|
|
onSuccess: (tag, variables, _onMutateResult, context) => {
|
|
context.client.setQueryData(
|
|
consoleQuery.tags.get.queryKey({
|
|
input: {
|
|
query: {
|
|
type: variables.body.type,
|
|
},
|
|
},
|
|
}),
|
|
(oldTags: Tag[] | undefined) => (oldTags ? [tag, ...oldTags] : oldTags),
|
|
)
|
|
},
|
|
},
|
|
},
|
|
byTagId: {
|
|
patch: {
|
|
mutationOptions: {
|
|
onSuccess: (updatedTag, variables, _onMutateResult, context) => {
|
|
context.client.setQueriesData(
|
|
{
|
|
queryKey: consoleQuery.tags.get.key({ type: 'query' }),
|
|
},
|
|
(oldTags: Tag[] | undefined) =>
|
|
oldTags?.map((tag) => (tag.id === variables.params.tag_id ? updatedTag : tag)),
|
|
)
|
|
|
|
if (updatedTag.type !== 'app') return
|
|
|
|
void context.client.invalidateQueries({ queryKey: consoleQuery.apps.get.key() })
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.starred.get.key(),
|
|
})
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.recent.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
delete: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _onMutateResult, context) => {
|
|
const deletedTag = context.client
|
|
.getQueriesData<Tag[]>({
|
|
queryKey: consoleQuery.tags.get.key({ type: 'query' }),
|
|
})
|
|
.flatMap(([, tags]) => tags ?? [])
|
|
.find((tag) => tag.id === variables.params.tag_id)
|
|
|
|
context.client.setQueriesData(
|
|
{
|
|
queryKey: consoleQuery.tags.get.key({ type: 'query' }),
|
|
},
|
|
(oldTags: Tag[] | undefined) =>
|
|
oldTags?.filter((tag) => tag.id !== variables.params.tag_id),
|
|
)
|
|
|
|
if (deletedTag?.type !== 'app') return
|
|
|
|
void context.client.invalidateQueries({ queryKey: consoleQuery.apps.get.key() })
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.starred.get.key(),
|
|
})
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.recent.get.key(),
|
|
})
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
enterprise: {
|
|
appDeploy: {
|
|
accessService: {
|
|
updateEnvironmentApi: {
|
|
mutationOptions: {
|
|
onSuccess: (updated, variables, _result, context) => {
|
|
const { app_id, environment_id } = variables.params
|
|
context.client.setQueryData(
|
|
consoleQuery.enterprise.appDeploy.accessService.getEnvironmentApi.queryOptions({
|
|
input: { params: { app_id, environment_id } },
|
|
}).queryKey,
|
|
updated,
|
|
)
|
|
const list =
|
|
consoleQuery.enterprise.appDeploy.deploymentService.listEnvironmentDeployments.queryOptions(
|
|
{
|
|
input: { params: { app_id } },
|
|
},
|
|
)
|
|
const detail =
|
|
consoleQuery.enterprise.appDeploy.deploymentService.getEnvironmentDeployment.queryOptions(
|
|
{
|
|
input: { params: { app_id, environment_id } },
|
|
},
|
|
)
|
|
context.client.setQueryData(
|
|
list.queryKey,
|
|
(current) =>
|
|
current && {
|
|
...current,
|
|
environment_deployments: current.environment_deployments.map(
|
|
(deployment) =>
|
|
deployment.environment.id === environment_id
|
|
? {
|
|
...deployment,
|
|
access: { ...deployment.access, enable_api: updated.enabled },
|
|
}
|
|
: deployment,
|
|
),
|
|
},
|
|
)
|
|
context.client.setQueryData(
|
|
detail.queryKey,
|
|
(current) =>
|
|
current && {
|
|
...current,
|
|
environment_deployment: {
|
|
...current.environment_deployment,
|
|
access: {
|
|
...current.environment_deployment.access,
|
|
enable_api: updated.enabled,
|
|
},
|
|
},
|
|
},
|
|
)
|
|
return Promise.all([
|
|
context.client.invalidateQueries({ queryKey: list.queryKey }),
|
|
context.client.invalidateQueries({ queryKey: detail.queryKey }),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
updateEnvironmentSite: {
|
|
mutationOptions: {
|
|
onSuccess: (updated, variables, _result, context) => {
|
|
const { app_id, environment_id } = variables.params
|
|
context.client.setQueryData(
|
|
consoleQuery.enterprise.appDeploy.accessService.getEnvironmentSite.queryOptions(
|
|
{
|
|
input: { params: { app_id, environment_id } },
|
|
},
|
|
).queryKey,
|
|
updated,
|
|
)
|
|
const list =
|
|
consoleQuery.enterprise.appDeploy.deploymentService.listEnvironmentDeployments.queryOptions(
|
|
{
|
|
input: { params: { app_id } },
|
|
},
|
|
)
|
|
const detail =
|
|
consoleQuery.enterprise.appDeploy.deploymentService.getEnvironmentDeployment.queryOptions(
|
|
{
|
|
input: { params: { app_id, environment_id } },
|
|
},
|
|
)
|
|
context.client.setQueryData(
|
|
list.queryKey,
|
|
(current) =>
|
|
current && {
|
|
...current,
|
|
environment_deployments: current.environment_deployments.map(
|
|
(deployment) =>
|
|
deployment.environment.id === environment_id
|
|
? {
|
|
...deployment,
|
|
access: { ...deployment.access, enable_site: updated.enabled },
|
|
}
|
|
: deployment,
|
|
),
|
|
},
|
|
)
|
|
context.client.setQueryData(
|
|
detail.queryKey,
|
|
(current) =>
|
|
current && {
|
|
...current,
|
|
environment_deployment: {
|
|
...current.environment_deployment,
|
|
access: {
|
|
...current.environment_deployment.access,
|
|
enable_site: updated.enabled,
|
|
},
|
|
},
|
|
},
|
|
)
|
|
return Promise.all([
|
|
context.client.invalidateQueries({ queryKey: list.queryKey }),
|
|
context.client.invalidateQueries({ queryKey: detail.queryKey }),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
createEnvironmentApiKey: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) => {
|
|
const { app_id, environment_id } = variables.params
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.enterprise.appDeploy.accessService.listEnvironmentApiKeys.queryKey(
|
|
{
|
|
input: { params: { app_id, environment_id } },
|
|
},
|
|
),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.enterprise.appDeploy.accessService.getEnvironmentApi.queryKey({
|
|
input: { params: { app_id, environment_id } },
|
|
}),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
deleteEnvironmentApiKey: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) => {
|
|
const { app_id, environment_id } = variables.params
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.enterprise.appDeploy.accessService.listEnvironmentApiKeys.queryKey(
|
|
{
|
|
input: { params: { app_id, environment_id } },
|
|
},
|
|
),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.enterprise.appDeploy.accessService.getEnvironmentApi.queryKey({
|
|
input: { params: { app_id, environment_id } },
|
|
}),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
},
|
|
deploymentService: {
|
|
deployWorkflow: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) => {
|
|
const { app_id, environment_id } = variables.params
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.enterprise.appDeploy.deploymentService.listEnvironmentDeployments.queryKey(
|
|
{
|
|
input: { params: { app_id } },
|
|
},
|
|
),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.enterprise.appDeploy.deploymentService.getEnvironmentDeployment.queryKey(
|
|
{
|
|
input: { params: { app_id, environment_id } },
|
|
},
|
|
),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
undeployWorkflow: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, variables, _result, context) => {
|
|
const { app_id, environment_id } = variables.params
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.enterprise.appDeploy.deploymentService.listEnvironmentDeployments.queryKey(
|
|
{
|
|
input: { params: { app_id } },
|
|
},
|
|
),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.enterprise.appDeploy.deploymentService.getEnvironmentDeployment.queryKey(
|
|
{
|
|
input: { params: { app_id, environment_id } },
|
|
},
|
|
),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey:
|
|
consoleQuery.enterprise.appDeploy.deploymentService.listAppEnvironments.queryKey(
|
|
{
|
|
input: { params: { app_id } },
|
|
},
|
|
),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
webAppAuth: {
|
|
updateWebAppWhitelistSubjects: {
|
|
mutationOptions: {
|
|
onSuccess: (_data, _variables, _result, context) => {
|
|
void context.client.invalidateQueries({ queryKey: consoleQuery.apps.get.key() })
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.starred.get.key(),
|
|
})
|
|
void context.client.invalidateQueries({
|
|
queryKey: consoleQuery.apps.recent.get.key(),
|
|
})
|
|
|
|
return Promise.all([
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.enterprise.webAppAuth.getWebAppAccessMode.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.enterprise.webAppAuth.getWebAppWhitelistSubjects.key(),
|
|
}),
|
|
context.client.invalidateQueries({
|
|
queryKey: consoleQuery.agent.byAgentId.get.key(),
|
|
}),
|
|
])
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
return consoleQuery
|
|
}
|
|
|
|
function invalidateQueryKeys(client: QueryClient, queryKeys: QueryKey[]) {
|
|
return Promise.all(queryKeys.map((queryKey) => client.invalidateQueries({ queryKey })))
|
|
}
|
|
|
|
function invalidateNetworkAccessGroupQueries(
|
|
query: RouterUtils<ConsoleClient>,
|
|
client: QueryClient,
|
|
) {
|
|
return invalidateQueryKeys(client, [
|
|
query.workspaces.current.networkAccessGroups.get.key(),
|
|
query.workspaces.current.networkAccessGroups.byGroupId.key(),
|
|
query.apps.byAppId.networkAccessGroup.key(),
|
|
])
|
|
}
|
|
|
|
function invalidateAccessPolicyQueries(query: RouterUtils<ConsoleClient>, client: QueryClient) {
|
|
return invalidateQueryKeys(client, [
|
|
query.workspaces.current.rbac.key(),
|
|
query.agent.get.key(),
|
|
query.agent.byAgentId.get.key(),
|
|
query.apps.byAppId.get.key(),
|
|
query.datasets.byDatasetId.get.key(),
|
|
])
|
|
}
|
|
|
|
function invalidateAgentAccessQueries(
|
|
query: RouterUtils<ConsoleClient>,
|
|
client: QueryClient,
|
|
agentId: string,
|
|
) {
|
|
return invalidateQueryKeys(client, [
|
|
query.workspaces.current.rbac.agents.byAgentId.key({
|
|
input: { params: { agent_id: agentId } },
|
|
}),
|
|
query.workspaces.current.rbac.myPermissions.get.key(),
|
|
query.agent.get.key(),
|
|
query.agent.inviteOptions.get.key(),
|
|
query.agent.byAgentId.get.queryKey({ input: { params: { agent_id: agentId } } }),
|
|
])
|
|
}
|
|
|
|
function invalidateHumanInputContactQueries(
|
|
query: RouterUtils<ConsoleClient>,
|
|
client: QueryClient,
|
|
) {
|
|
return invalidateQueryKeys(client, [
|
|
query.workspaces.current.humanInput.v2.contacts.key(),
|
|
query.workspaces.current.humanInput.v2.contactOptions.key(),
|
|
query.workspaces.current.humanInput.v2.imIdentities.key(),
|
|
query.workspaces.current.humanInput.v2.organizationCandidates.key(),
|
|
])
|
|
}
|
|
|
|
function invalidateHumanInputChannelQueries(
|
|
query: RouterUtils<ConsoleClient>,
|
|
client: QueryClient,
|
|
) {
|
|
return Promise.all([
|
|
invalidateHumanInputContactQueries(query, client),
|
|
invalidateQueryKeys(client, [
|
|
query.workspaces.current.humanInput.v2.channels.key(),
|
|
query.workspaces.current.humanInput.v2.imIdentities.key(),
|
|
query.workspaces.current.humanInput.v2.imSyncRuns.key(),
|
|
]),
|
|
])
|
|
}
|
|
|
|
function invalidateSkillVersionQueries(
|
|
query: RouterUtils<ConsoleClient>,
|
|
client: QueryClient,
|
|
skillId: string,
|
|
) {
|
|
const input = { params: { skill_id: skillId } }
|
|
return invalidateQueryKeys(client, [
|
|
query.workspaces.current.skills.bySkillId.get.key({ input }),
|
|
query.workspaces.current.skills.bySkillId.versions.get.key({ input }),
|
|
query.workspaces.current.agents.byAgentId.skills.get.key(),
|
|
])
|
|
}
|