mirror of
https://github.com/langgenius/dify.git
synced 2026-09-08 19:15:59 +08:00
refactor(console): unify environment-aware oRPC clients and query policies (#41932)
This commit is contained in:
parent
749d1f8d04
commit
22189f69f6
@ -28,7 +28,7 @@ Read this document when a component consumes generated contracts, nullable API v
|
||||
|
||||
- Use generated `mutationOptions()` directly for owner-local mutations.
|
||||
- Do not introduce deprecated `useInvalid` or `useReset` APIs.
|
||||
- Put shared invalidation, retries, and cache behavior in `createTanstackQueryUtils(...experimental_defaults...)`. Local callbacks may own toast, close, and navigation effects but must not replace shared cache policy.
|
||||
- Put shared invalidation, retries, and cache behavior in `createTanstackQueryUtils(...experimental_defaults...)`. In oRPC v1, caller options override defaults, including callbacks. Local callbacks may own toast, close, and navigation effects but must preserve shared cache behavior.
|
||||
- Prefer `mutate(...)`. Use `mutateAsync(...)` only when Promise composition is required, and catch awaited failures.
|
||||
- Preserve intentional empty values and current list/detail ownership when updating data. Do not add optimistic updates without a verified owner contract.
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ Web owns application-specific requirements and consumes shared architecture guid
|
||||
|
||||
- For truncated text disclosure and native `title` decisions, follow [Truncated Text Disclosure].
|
||||
- User-facing strings must use `web/i18n/en-US/` keys. When adding or renaming a key, update every supported locale with the correct localized value.
|
||||
- For new backend calls and migrated surfaces, use generated `consoleQuery` / `consoleClient` APIs from `@/service/client`. Do not add handwritten REST helpers or DTO mirrors, mock-backed app state, or direct edits to generated contracts.
|
||||
- For new backend calls and migrated surfaces, use generated `consoleQuery` / `consoleClient` APIs from `@/service/console`. Do not add handwritten REST helpers or DTO mirrors, mock-backed app state, or direct edits to generated contracts.
|
||||
- Prefer `@langgenius/dify-ui/*` primitives, data attributes, and design tokens. Use the [Dify UI package index] to find a primitive; read the relevant contract directly when it is already known. Preserve a visible focus indicator on the final focusable element.
|
||||
- Reuse the Web `SearchInput` composite when its search, clear, and IME contract matches the feature; otherwise follow the canonical [Input Group contract].
|
||||
- Give save and submit flows a real form boundary with visible labels and accessible errors. Use Dify UI `Form` when its structured submission and validation contract is the owner; otherwise use a native form. Follow the canonical [form contract].
|
||||
|
||||
@ -20,7 +20,7 @@ import PriorityLabel from '@/app/components/billing/priority-label'
|
||||
import TriggerEventsLimitModal from '@/app/components/billing/trigger-events-limit-modal'
|
||||
import UpgradeBtn from '@/app/components/billing/upgrade-btn'
|
||||
import VectorSpaceFull from '@/app/components/billing/vector-space-full'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import {
|
||||
createConsoleQueryClient,
|
||||
createConsoleQueryWrapper,
|
||||
|
||||
@ -30,8 +30,8 @@ vi.mock('@/context/workspace-state', async () => {
|
||||
return createWorkspaceStateModuleMock(() => mockConsoleState)
|
||||
})
|
||||
|
||||
vi.mock('@/service/client', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('@/service/client')>()
|
||||
vi.mock('@/service/console', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('@/service/console')>()
|
||||
return {
|
||||
...actual,
|
||||
consoleClient: new Proxy(actual.consoleClient, {
|
||||
|
||||
@ -8,7 +8,7 @@ import type { DeepPartial } from '@/test/console/system-features'
|
||||
import { cleanup, screen } from '@testing-library/react'
|
||||
import * as React from 'react'
|
||||
import PlanComp from '@/app/components/billing/plan'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import {
|
||||
createConsoleQueryClient,
|
||||
createConsoleQueryWrapper,
|
||||
|
||||
@ -49,8 +49,8 @@ vi.mock('@/context/i18n', () => ({
|
||||
useGetPricingPageLanguage: () => 'en',
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('@/service/client')>()
|
||||
vi.mock('@/service/console', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('@/service/console')>()
|
||||
return {
|
||||
...actual,
|
||||
consoleClient: new Proxy(actual.consoleClient, {
|
||||
|
||||
@ -11,7 +11,6 @@ const mocks = vi.hoisted(() => ({
|
||||
workspaceQueryOptions: vi.fn(),
|
||||
permissionQueryFn: vi.fn(),
|
||||
permissionQueryOptions: vi.fn(),
|
||||
getServerConsoleClientContext: vi.fn(),
|
||||
redirect: vi.fn((url: string) => {
|
||||
throw new Error(`NEXT_REDIRECT:${url}`)
|
||||
}),
|
||||
@ -48,10 +47,12 @@ vi.mock('@/features/account-profile/server', () => ({
|
||||
}),
|
||||
}))
|
||||
|
||||
vi.mock('@/service/server', () => ({
|
||||
getServerConsoleClientContext: () => mocks.getServerConsoleClientContext(),
|
||||
vi.mock('@/service/console/server', () => ({
|
||||
resolveServerConsoleApiUrl: (...args: unknown[]) => mocks.resolveServerConsoleApiUrl(...args),
|
||||
serverConsoleQuery: {
|
||||
}))
|
||||
|
||||
vi.mock('@/service/console', () => ({
|
||||
consoleQuery: {
|
||||
workspaces: {
|
||||
current: {
|
||||
summary: {
|
||||
@ -111,10 +112,6 @@ describe('CommonLayoutHydrationBoundary', () => {
|
||||
app: { default_permission_keys: [], overrides: [] },
|
||||
dataset: { default_permission_keys: [], overrides: [] },
|
||||
})
|
||||
mocks.getServerConsoleClientContext.mockResolvedValue({
|
||||
cookie: 'session=abc',
|
||||
csrfToken: 'csrf-token',
|
||||
})
|
||||
mocks.workspaceQueryOptions.mockReturnValue({
|
||||
queryKey: ['console', 'workspaces', 'current', 'summary', 'get'],
|
||||
queryFn: mocks.workspaceQueryFn,
|
||||
@ -144,20 +141,11 @@ describe('CommonLayoutHydrationBoundary', () => {
|
||||
)
|
||||
expect(screen.getByText('Common shell')).toBeInTheDocument()
|
||||
expect(mocks.profileQueryFn).toHaveBeenCalledTimes(1)
|
||||
expect(mocks.getServerConsoleClientContext).toHaveBeenCalledTimes(1)
|
||||
expect(mocks.workspaceQueryOptions).toHaveBeenCalledWith({
|
||||
context: {
|
||||
cookie: 'session=abc',
|
||||
csrfToken: 'csrf-token',
|
||||
},
|
||||
retry: false,
|
||||
})
|
||||
expect(mocks.workspaceQueryFn).toHaveBeenCalledTimes(1)
|
||||
expect(mocks.permissionQueryOptions).toHaveBeenCalledWith({
|
||||
context: {
|
||||
cookie: 'session=abc',
|
||||
csrfToken: 'csrf-token',
|
||||
},
|
||||
retry: false,
|
||||
})
|
||||
expect(mocks.permissionQueryFn).toHaveBeenCalledTimes(1)
|
||||
|
||||
@ -20,7 +20,7 @@ import { getLangGeniusVersionInfo } from '@/context/app-context-normalizers'
|
||||
import { currentWorkspaceAtom } from '@/context/workspace-state'
|
||||
import { userProfileQueryOptions } from '@/features/account-profile/client'
|
||||
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
|
||||
type AmplitudeProperties = Record<string, string | number | boolean>
|
||||
|
||||
|
||||
@ -4,11 +4,8 @@ import { getQueryClient } from '@/app/get-query-client'
|
||||
import { serverUserProfileQueryOptions } from '@/features/account-profile/server'
|
||||
import { headers } from '@/next/headers'
|
||||
import { redirect } from '@/next/navigation'
|
||||
import {
|
||||
getServerConsoleClientContext,
|
||||
resolveServerConsoleApiUrl,
|
||||
serverConsoleQuery,
|
||||
} from '@/service/server'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { resolveServerConsoleApiUrl } from '@/service/console/server'
|
||||
|
||||
const CURRENT_PATHNAME_HEADER = 'x-dify-pathname'
|
||||
const CURRENT_SEARCH_HEADER = 'x-dify-search'
|
||||
@ -60,22 +57,18 @@ export async function CommonLayoutHydrationBoundary({ children }: { children: Re
|
||||
|
||||
if (accountProfileUrl) {
|
||||
try {
|
||||
const context = await getServerConsoleClientContext()
|
||||
|
||||
await Promise.all([
|
||||
queryClient.query(serverUserProfileQueryOptions()),
|
||||
queryClient
|
||||
.query(
|
||||
serverConsoleQuery.workspaces.current.summary.get.queryOptions({
|
||||
context,
|
||||
consoleQuery.workspaces.current.summary.get.queryOptions({
|
||||
retry: false,
|
||||
}),
|
||||
)
|
||||
.catch(noop),
|
||||
queryClient
|
||||
.query(
|
||||
serverConsoleQuery.workspaces.current.rbac.myPermissions.get.queryOptions({
|
||||
context,
|
||||
consoleQuery.workspaces.current.rbac.myPermissions.get.queryOptions({
|
||||
retry: false,
|
||||
}),
|
||||
)
|
||||
|
||||
@ -4,6 +4,8 @@ const mocks = vi.hoisted(() => ({
|
||||
headers: vi.fn(async () => new Headers()),
|
||||
}))
|
||||
|
||||
vi.mock('@/service/console/server', () => ({}))
|
||||
|
||||
vi.mock('@/features/system-features/server', () => ({
|
||||
dehydrateSystemFeatures: mocks.dehydrateSystemFeatures,
|
||||
getOptionalSystemFeatures: mocks.getOptionalSystemFeatures,
|
||||
|
||||
@ -19,8 +19,8 @@ import { validPassword } from '@/config'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
import { userProfileQueryOptions } from '@/features/account-profile/client'
|
||||
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { updateUserProfile } from '@/service/common'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import DeleteAccount from '../delete-account'
|
||||
import AvatarWithEdit from './AvatarWithEdit'
|
||||
import EmailChangeModal from './email-change-modal'
|
||||
|
||||
@ -14,7 +14,7 @@ import PremiumBadge from '@/app/components/base/premium-badge'
|
||||
import { useProviderContext } from '@/context/provider-context'
|
||||
import { userProfileQueryOptions } from '@/features/account-profile/client'
|
||||
import { useRouter } from '@/next/navigation'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { useLogout } from '@/service/use-common'
|
||||
|
||||
export default function AppSelector() {
|
||||
|
||||
@ -20,7 +20,7 @@ import { isLegacyBase401, userProfileQueryOptions } from '@/features/account-pro
|
||||
import useDocumentTitle from '@/hooks/use-document-title'
|
||||
import Link from '@/next/link'
|
||||
import { useRouter, useSearchParams } from '@/next/navigation'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { useLogout } from '@/service/use-common'
|
||||
import { buildOAuthCallbackUrl, buildReturnUrl, useSilentAuthorize } from './use-silent-authorize'
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import type { LoginRedirectTarget } from '@/utils/login-redirect'
|
||||
import { resolveServerConsoleApiUrl } from '@/service/server'
|
||||
import { resolveServerConsoleApiUrl } from '@/service/console/server'
|
||||
import { getServerLoginFallback, resolveLoginRedirectTarget } from '@/utils/login-redirect'
|
||||
import { basePath } from '@/utils/var'
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ const apiMocks = vi.hoisted(() => ({
|
||||
deleteEnvironment: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', () => ({
|
||||
vi.mock('@/service/console', () => ({
|
||||
consoleQuery: {
|
||||
apps: {
|
||||
byResourceId: {
|
||||
|
||||
@ -24,7 +24,7 @@ import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import Loading from '@/app/components/base/loading'
|
||||
import { currentWorkspaceAtom } from '@/context/workspace-state'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { ApiKeyTable } from './api-key-table'
|
||||
import { CreatedApiKeyDialog } from './created-api-key-dialog'
|
||||
import { DatasetScopeDialog } from './dataset-scope-dialog'
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { act, renderHook } from '@testing-library/react'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
import { getRedirection } from '@/utils/app-redirection'
|
||||
import { useAppInfoActions } from '../use-app-info-actions'
|
||||
|
||||
@ -20,7 +20,7 @@ import {
|
||||
markAppDeletionSucceeded,
|
||||
} from '@/service/app-deletion'
|
||||
import { fetchAppDetail, updateAppInfo } from '@/service/apps'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
import { getRedirection } from '@/utils/app-redirection'
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ const mocks = vi.hoisted(() => ({
|
||||
toastPromise: vi.fn((promise: Promise<unknown>) => promise),
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', () => ({
|
||||
vi.mock('@/service/console', () => ({
|
||||
consoleClient: {
|
||||
apps: {
|
||||
byAppId: {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import type { ReactElement } from 'react'
|
||||
import { screen } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { createConsoleQueryClient, renderWithConsoleQuery } from '@/test/console/query-data'
|
||||
import { ApiSecretKeyButton } from '../shared/api-secret-key-button'
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ const mocks = vi.hoisted(() => ({
|
||||
updateAccessMode: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', () => ({
|
||||
vi.mock('@/service/console', () => ({
|
||||
consoleQuery: {
|
||||
enterprise: {
|
||||
appDeploy: {
|
||||
|
||||
@ -19,65 +19,6 @@ const mocks = vi.hoisted(() => ({
|
||||
apiKeyButtonProps: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', () => ({
|
||||
consoleQuery: {
|
||||
enterprise: {
|
||||
appDeploy: {
|
||||
accessService: {
|
||||
getEnvironmentApi: {
|
||||
queryOptions: ({
|
||||
input,
|
||||
}: {
|
||||
input: { params: { app_id: string; environment_id: string } }
|
||||
}) => ({
|
||||
queryKey: ['environment-api', input.params.app_id, input.params.environment_id],
|
||||
queryFn: () => mocks.getApi(input),
|
||||
}),
|
||||
},
|
||||
getEnvironmentSite: {
|
||||
queryOptions: ({
|
||||
input,
|
||||
}: {
|
||||
input: { params: { app_id: string; environment_id: string } }
|
||||
}) => ({
|
||||
queryKey: ['environment-site', input.params.app_id, input.params.environment_id],
|
||||
queryFn: () => mocks.getSite(input),
|
||||
}),
|
||||
},
|
||||
getEnvironmentWebAppSubjects: {
|
||||
queryOptions: ({
|
||||
input,
|
||||
}: {
|
||||
input: { params: { app_id: string; environment_id: string } }
|
||||
}) => ({
|
||||
queryKey: ['environment-subjects', input.params.app_id, input.params.environment_id],
|
||||
queryFn: () => mocks.getSubjects(input),
|
||||
}),
|
||||
},
|
||||
resetEnvironmentSiteAccessToken: {
|
||||
mutationOptions: (options = {}) => ({
|
||||
mutationFn: mocks.resetSite,
|
||||
...options,
|
||||
}),
|
||||
},
|
||||
updateEnvironmentApi: {
|
||||
mutationOptions: (options = {}) => ({
|
||||
mutationFn: mocks.updateApi,
|
||||
...options,
|
||||
}),
|
||||
},
|
||||
updateEnvironmentSite: {
|
||||
mutationOptions: (options = {}) => ({
|
||||
mutationFn: mocks.updateSite,
|
||||
...options,
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('@/features/system-features/client', () => ({
|
||||
systemFeaturesQueryOptions: () => ({
|
||||
queryKey: ['system-features'],
|
||||
@ -189,8 +130,7 @@ const api = {
|
||||
enabled: true,
|
||||
}
|
||||
|
||||
function renderCard(ui: ReactElement) {
|
||||
const queryClient = createTestQueryClient()
|
||||
function renderCard(ui: ReactElement, queryClient = createTestQueryClient()) {
|
||||
queryClient.setQueryData(['system-features'], {
|
||||
webapp_auth: {
|
||||
enabled: true,
|
||||
@ -211,9 +151,46 @@ function createDeferredPromise<T>() {
|
||||
return { promise, reject, resolve }
|
||||
}
|
||||
|
||||
// Keep HTTP mocked through Testing Library's asynchronous cleanup.
|
||||
afterAll(() => vi.unstubAllGlobals())
|
||||
|
||||
describe('environment access point cards', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
mockAppMode = 'workflow'
|
||||
vi.stubGlobal('fetch', async (input: RequestInfo | URL, init?: RequestInit) => {
|
||||
const request = new Request(input, init)
|
||||
const path = new URL(request.url).pathname
|
||||
const match = /\/enterprise\/app-deploy\/apps\/([^/]+)\/environments\/([^/]+)\/(.+)$/.exec(
|
||||
path,
|
||||
)
|
||||
if (!match) throw new Error(`Unexpected request: ${request.method} ${path}`)
|
||||
const params = { app_id: match[1], environment_id: match[2] }
|
||||
let data: unknown
|
||||
switch (`${request.method} ${match[3]}`) {
|
||||
case 'GET api':
|
||||
data = await mocks.getApi({ params })
|
||||
break
|
||||
case 'GET site':
|
||||
data = await mocks.getSite({ params })
|
||||
break
|
||||
case 'GET webapp/subjects':
|
||||
data = await mocks.getSubjects({ params })
|
||||
break
|
||||
case 'POST site/access-token-reset':
|
||||
data = await mocks.resetSite({ params })
|
||||
break
|
||||
case 'PATCH api':
|
||||
data = await mocks.updateApi({ params, body: await request.json() })
|
||||
break
|
||||
case 'PATCH site':
|
||||
data = await mocks.updateSite({ params, body: await request.json() })
|
||||
break
|
||||
default:
|
||||
throw new Error(`Unexpected request: ${request.method} ${path}`)
|
||||
}
|
||||
return Response.json(data)
|
||||
})
|
||||
mocks.getApi.mockResolvedValue(api)
|
||||
mocks.getSite.mockResolvedValue(site)
|
||||
mocks.getSubjects.mockResolvedValue({
|
||||
@ -243,6 +220,45 @@ describe('environment access point cards', () => {
|
||||
})
|
||||
})
|
||||
|
||||
it.each(['site', 'api'] as const)(
|
||||
'keeps the saved %s status when reopening an environment without changing another environment',
|
||||
async (target) => {
|
||||
const user = userEvent.setup()
|
||||
const queryClient = createTestQueryClient()
|
||||
const card = (environmentId: string) =>
|
||||
target === 'site' ? (
|
||||
<EnvironmentWebAppCard
|
||||
appId="app-1"
|
||||
environmentId={environmentId}
|
||||
canManageAccessPoint
|
||||
canReleaseAndVersion
|
||||
/>
|
||||
) : (
|
||||
<EnvironmentServiceApiCard
|
||||
appId="app-1"
|
||||
environmentId={environmentId}
|
||||
canManageAccessPoint
|
||||
/>
|
||||
)
|
||||
|
||||
const staging = renderCard(card('staging'), queryClient)
|
||||
const toggle = await screen.findByRole('switch')
|
||||
expect(toggle).toHaveAttribute('aria-checked', 'true')
|
||||
await user.click(toggle)
|
||||
await waitFor(() =>
|
||||
expect(target === 'site' ? mocks.updateSite : mocks.updateApi).toHaveBeenCalled(),
|
||||
)
|
||||
staging.unmount()
|
||||
|
||||
const production = renderCard(card('production'), queryClient)
|
||||
expect(await screen.findByRole('switch')).toHaveAttribute('aria-checked', 'true')
|
||||
production.unmount()
|
||||
|
||||
renderCard(card('staging'), queryClient)
|
||||
expect(await screen.findByRole('switch')).toHaveAttribute('aria-checked', 'false')
|
||||
},
|
||||
)
|
||||
|
||||
it('sends a chatflow app to the chat web app shell', async () => {
|
||||
mockAppMode = 'advanced-chat'
|
||||
|
||||
@ -258,8 +274,6 @@ describe('environment access point cards', () => {
|
||||
expect(await screen.findByText(/environment\/chat\/site-code/)).toHaveTextContent(
|
||||
'https://site.example.test/environment/chat/site-code',
|
||||
)
|
||||
|
||||
mockAppMode = 'workflow'
|
||||
})
|
||||
|
||||
it('renders the real environment Web app URL and workflow actions without Embed', async () => {
|
||||
@ -281,7 +295,9 @@ describe('environment access point cards', () => {
|
||||
}),
|
||||
).toBeEnabled()
|
||||
expect(screen.queryByRole('button', { name: /embedIntoSite/ })).not.toBeInTheDocument()
|
||||
expect(screen.getByRole('button', { name: /customize\.entry/ })).toBeEnabled()
|
||||
await waitFor(() =>
|
||||
expect(screen.getByRole('button', { name: /customize\.entry/ })).toBeEnabled(),
|
||||
)
|
||||
expect(screen.getByRole('button', { name: /settings\.settings/ })).toBeEnabled()
|
||||
})
|
||||
|
||||
@ -307,8 +323,9 @@ describe('environment access point cards', () => {
|
||||
).toBeEnabled()
|
||||
})
|
||||
|
||||
it('shows the environment Web app query as loading instead of failed', () => {
|
||||
mocks.getSite.mockImplementation(() => new Promise(() => {}))
|
||||
it('shows loading until the environment Web app becomes available', async () => {
|
||||
const pending = createDeferredPromise<typeof site>()
|
||||
mocks.getSite.mockReturnValue(pending.promise)
|
||||
|
||||
renderCard(
|
||||
<EnvironmentWebAppCard
|
||||
@ -325,6 +342,9 @@ describe('environment access point cards', () => {
|
||||
expect(
|
||||
screen.queryByText('deployments.health.ENVIRONMENT_STATUS_FAILED'),
|
||||
).not.toBeInTheDocument()
|
||||
pending.resolve(site)
|
||||
expect(await screen.findByRole('link', { name: /studio\.accessPoint\.open/ })).toBeEnabled()
|
||||
expect(card).not.toHaveAttribute('aria-busy', 'true')
|
||||
})
|
||||
|
||||
it('does not announce the access control placeholder as loading after the Site query fails', async () => {
|
||||
@ -446,6 +466,9 @@ describe('environment access point cards', () => {
|
||||
)
|
||||
|
||||
await screen.findByText(/environment\/workflow\/site-code/)
|
||||
await waitFor(() =>
|
||||
expect(screen.getByRole('button', { name: /customize\.entry/ })).toBeEnabled(),
|
||||
)
|
||||
await user.click(screen.getByRole('button', { name: /customize\.entry/ }))
|
||||
expect(screen.getByRole('dialog', { name: 'environment customize' })).toHaveTextContent(
|
||||
'https://api.example.test/v1',
|
||||
@ -487,7 +510,9 @@ describe('environment access point cards', () => {
|
||||
|
||||
expect(await screen.findByRole('switch')).toBeEnabled()
|
||||
expect(screen.getByRole('button', { name: /regenerate/ })).toBeEnabled()
|
||||
expect(screen.getByRole('button', { name: /customize\.entry/ })).toBeEnabled()
|
||||
await waitFor(() =>
|
||||
expect(screen.getByRole('button', { name: /customize\.entry/ })).toBeEnabled(),
|
||||
)
|
||||
expect(screen.getByRole('button', { name: /settings\.settings/ })).toBeEnabled()
|
||||
expect(
|
||||
screen.getByRole('button', { name: /accessControlDialog\.accessItems\.specific/ }),
|
||||
|
||||
@ -5,7 +5,7 @@ import { EnvironmentStatus } from '@dify/contracts/enterprise-app-deploy/types.g
|
||||
import { screen, waitFor } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { NuqsTestingAdapter } from 'nuqs/adapters/testing'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { seedAccountProfileQuery } from '@/test/console/account-profile'
|
||||
import { QueryClientTestProvider } from '@/test/console/query-provider'
|
||||
import { render } from '@/test/console/render'
|
||||
|
||||
@ -27,7 +27,7 @@ vi.mock('@langgenius/dify-ui/toast', () => ({
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', () => ({
|
||||
vi.mock('@/service/console', () => ({
|
||||
consoleQuery: {
|
||||
apps: {
|
||||
byAppId: {
|
||||
|
||||
@ -21,7 +21,7 @@ vi.mock('@langgenius/dify-ui/toast', () => ({
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', () => ({
|
||||
vi.mock('@/service/console', () => ({
|
||||
consoleQuery: {
|
||||
apps: {
|
||||
byAppId: {
|
||||
|
||||
@ -39,7 +39,7 @@ vi.mock('@/context/i18n', () => ({
|
||||
useDocLink: () => (path: string) => `https://docs.example.test/en${path}`,
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', () => ({
|
||||
vi.mock('@/service/console', () => ({
|
||||
consoleQuery: {
|
||||
apps: {
|
||||
byAppId: {
|
||||
|
||||
@ -23,7 +23,7 @@ vi.mock('@/service/apps', () => ({
|
||||
updateAppSiteConfig: mocks.updateAppSiteConfig,
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', () => ({
|
||||
vi.mock('@/service/console', () => ({
|
||||
consoleQuery: {
|
||||
apps: {
|
||||
get: { key: () => ['apps'] },
|
||||
|
||||
@ -25,7 +25,7 @@ vi.mock('@langgenius/dify-ui/toast', () => ({
|
||||
},
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', () => ({
|
||||
vi.mock('@/service/console', () => ({
|
||||
consoleQuery: {
|
||||
apps: {
|
||||
byAppId: {
|
||||
|
||||
@ -19,7 +19,7 @@ import { AccessPointCard } from '@/app/components/base/access-point/card'
|
||||
import { AccessPointUrl } from '@/app/components/base/access-point/url'
|
||||
import MCPServerModal from '@/app/components/tools/mcp/mcp-server-modal'
|
||||
import { BlockEnum } from '@/app/components/workflow/types'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import {
|
||||
useInvalidateMCPServerDetail,
|
||||
useMCPServerDetail,
|
||||
|
||||
@ -7,7 +7,7 @@ import { useMutation } from '@tanstack/react-query'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
||||
import { getAccessPointStatus } from '@/app/components/base/access-point/status'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { ServiceApiCardView } from '../shared/service-api-card-view'
|
||||
import { getBuiltInAccessUrls } from '../shared/utils'
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ import { useTriggerStatusStore } from '@/app/components/workflow/store/trigger-s
|
||||
import { BlockEnum } from '@/app/components/workflow/types'
|
||||
import { useDocLink } from '@/context/i18n'
|
||||
import Link from '@/next/link'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { useAppTriggers, useInvalidateAppTriggers } from '@/service/use-tools'
|
||||
import { useAllTriggerPlugins } from '@/service/use-triggers'
|
||||
import { canFindTool } from '@/utils'
|
||||
|
||||
@ -30,7 +30,7 @@ import { AccessPointUrl } from '@/app/components/base/access-point/url'
|
||||
import AppIcon from '@/app/components/base/app-icon'
|
||||
import { AccessMode } from '@/models/access-control'
|
||||
import { useAppWhiteListSubjects } from '@/service/access-control/use-app-access-control'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
import { useAccessPointStatusLabel } from '../shared/use-access-point-status-label'
|
||||
import { getBuiltInAccessUrls, getHiddenStartInputs } from '../shared/utils'
|
||||
|
||||
@ -13,7 +13,7 @@ import { useTranslation } from 'react-i18next'
|
||||
import { AccessControlForm } from '@/app/components/app/app-access-control/access-control-form'
|
||||
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
|
||||
import { AccessMode, SubjectType } from '@/models/access-control'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
|
||||
const EMPTY_SUBJECTS: AccessControlSubjects = {
|
||||
groups: [],
|
||||
|
||||
@ -4,7 +4,7 @@ import { toast } from '@langgenius/dify-ui/toast'
|
||||
import { useMutation, useQuery } from '@tanstack/react-query'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { ServiceApiCardView } from '../shared/service-api-card-view'
|
||||
|
||||
type EnvironmentServiceApiCardProps = {
|
||||
|
||||
@ -23,7 +23,7 @@ import { AccessPointUrl } from '@/app/components/base/access-point/url'
|
||||
import AppIcon from '@/app/components/base/app-icon'
|
||||
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
|
||||
import { AccessMode, isAccessMode } from '@/models/access-control'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { useAccessPointActions } from '../shared/use-access-point-actions'
|
||||
import { useAccessPointStatusLabel } from '../shared/use-access-point-status-label'
|
||||
import {
|
||||
|
||||
@ -6,7 +6,7 @@ import { skipToken, useQuery } from '@tanstack/react-query'
|
||||
import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { ApiKeyModal } from '@/app/components/api-key/api-key-modal'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
|
||||
type ApiSecretKeyButtonProps = {
|
||||
appId: string
|
||||
|
||||
@ -9,7 +9,7 @@ import { useCallback } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useStore as useAppStore } from '@/app/components/app/store'
|
||||
import { fetchAppDetail, updateAppSiteConfig } from '@/service/apps'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { asyncRunSafe } from '@/utils'
|
||||
|
||||
export function useAccessPointActions(appId: string, canManageAccessPoint: boolean) {
|
||||
|
||||
@ -5,7 +5,7 @@ import { skipToken } from '@tanstack/react-query'
|
||||
import { atom } from 'jotai'
|
||||
import { atomWithQuery } from 'jotai-tanstack-query'
|
||||
import { selectAtom, useHydrateAtoms } from 'jotai/utils'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
|
||||
export const BUILT_IN_ENVIRONMENT_ID = 'built-in'
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ import { useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import AnnotationFull from '@/app/components/billing/annotation-full'
|
||||
import { deploymentEditionAtom } from '@/features/system-features/state'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import EditItem, { EditItemType } from './edit-item'
|
||||
|
||||
type Props = Readonly<{
|
||||
|
||||
@ -12,7 +12,7 @@ import { useTranslation } from 'react-i18next'
|
||||
import AnnotationFull from '@/app/components/billing/annotation-full'
|
||||
import { deploymentEditionAtom } from '@/features/system-features/state'
|
||||
import { annotationBatchImport, checkAnnotationBatchImportProgress } from '@/service/annotation'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import CSVDownloader from './csv-downloader'
|
||||
import CSVUploader from './csv-uploader'
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ import {
|
||||
updateAnnotationScore,
|
||||
updateAnnotationStatus,
|
||||
} from '@/service/annotation'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
import { sleep } from '@/utils'
|
||||
import PageTitle from '../log-annotation/page-title'
|
||||
|
||||
@ -32,7 +32,7 @@ vi.mock('@/service/access-control', () => ({
|
||||
mockUseSearchForWhiteListCandidates(...args),
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', () => ({
|
||||
vi.mock('@/service/console', () => ({
|
||||
consoleQuery: {
|
||||
systemFeatures: {
|
||||
get: {
|
||||
|
||||
@ -13,7 +13,7 @@ import { useTranslation } from 'react-i18next'
|
||||
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
|
||||
import { AccessMode, isAccessMode, SubjectType } from '@/models/access-control'
|
||||
import { useAppWhiteListSubjects } from '@/service/access-control'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { AccessControlForm } from './access-control-form'
|
||||
|
||||
const EMPTY_SUBJECTS: AccessControlSubjects = {
|
||||
|
||||
@ -14,7 +14,7 @@ import userEvent from '@testing-library/user-event'
|
||||
import { createStore, Provider, useAtomValue, useSetAtom } from 'jotai'
|
||||
import { queryClientAtom } from 'jotai-tanstack-query'
|
||||
import { useEffect } from 'react'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import {
|
||||
createConsoleQueryClient,
|
||||
renderWithConsoleQuery as render,
|
||||
|
||||
@ -5,7 +5,7 @@ import userEvent from '@testing-library/user-event'
|
||||
import * as React from 'react'
|
||||
import { WorkflowContext } from '@/app/components/workflow/context'
|
||||
import { AccessMode } from '@/models/access-control'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { appWorkflowVersionsInfiniteQueryOptions } from '@/service/workflow-queries'
|
||||
import { createConsoleQueryClient, renderWithConsoleQuery } from '@/test/console/query-data'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
|
||||
@ -51,7 +51,7 @@ const queryMocks = vi.hoisted(() => ({
|
||||
environmentRequest: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', async () => {
|
||||
vi.mock('@/service/console', async () => {
|
||||
const { skipToken } = await import('@tanstack/react-query')
|
||||
|
||||
return {
|
||||
|
||||
@ -5,7 +5,7 @@ import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useAtomValue, useSetAtom } from 'jotai'
|
||||
import { useEffect, useRef } from 'react'
|
||||
import { shouldPollEnvironmentDeployment } from '@/app/components/app/deploy/utils/environment-deployment'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import {
|
||||
appPublisherOpenAtom,
|
||||
finishPublisherEnvironmentDeploymentPollingAtom,
|
||||
|
||||
@ -12,7 +12,7 @@ import { trackEvent } from '@/app/components/base/amplitude'
|
||||
import { collaborationManager } from '@/app/components/workflow/collaboration/core/collaboration-manager'
|
||||
import { webSocketClient } from '@/app/components/workflow/collaboration/core/websocket-manager'
|
||||
import { WorkflowContext } from '@/app/components/workflow/context'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { useAppWorkflow, useInvalidateAppWorkflow } from '@/service/use-workflow'
|
||||
import {
|
||||
appWorkflowQueryOptions,
|
||||
|
||||
@ -7,7 +7,7 @@ import { atom } from 'jotai'
|
||||
import { atomWithQuery } from 'jotai-tanstack-query'
|
||||
import { selectAtom, useHydrateAtoms } from 'jotai/utils'
|
||||
import { shouldPollEnvironmentDeployment } from '@/app/components/app/deploy/utils/environment-deployment'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
|
||||
export const BUILT_IN_ENVIRONMENT_ID = 'built-in'
|
||||
const PUBLISHER_DEPLOYMENT_POLLING_INTERVAL = 3000
|
||||
|
||||
@ -25,7 +25,7 @@ import Loading from '@/app/components/base/loading'
|
||||
import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
||||
import { useModelListAndDefaultModelAndCurrentProviderAndModel } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||
import ModelParameterModal from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { generateBasicAppFirstTimeRule, generateRule } from '@/service/debug'
|
||||
import { useAutoGenModel } from '../auto-gen-model-storage'
|
||||
import IdeaOutput from './idea-output'
|
||||
|
||||
@ -24,7 +24,7 @@ import Loading from '@/app/components/base/loading'
|
||||
import { ModelTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
|
||||
import { useModelListAndDefaultModelAndCurrentProviderAndModel } from '@/app/components/header/account-setting/model-provider-page/hooks'
|
||||
import ModelParameterModal from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { generateRule } from '@/service/debug'
|
||||
import { languageMap } from '../../../../workflow/nodes/_base/components/editor/code-editor/index'
|
||||
import { useAutoGenModel } from '../auto-gen-model-storage'
|
||||
|
||||
@ -13,7 +13,7 @@ import {
|
||||
DataSourceType,
|
||||
RerankingModeEnum,
|
||||
} from '@/models/datasets'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { updateDatasetSetting } from '@/service/datasets'
|
||||
import { useMembers } from '@/service/use-common'
|
||||
import { seedAccountProfileQuery } from '@/test/console/account-profile'
|
||||
|
||||
@ -12,7 +12,7 @@ import {
|
||||
DataSourceType,
|
||||
RerankingModeEnum,
|
||||
} from '@/models/datasets'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { createConsoleQueryClient, renderWithConsoleQuery } from '@/test/console/query-data'
|
||||
import { withSelectorKey } from '@/test/i18n-mock'
|
||||
import { RETRIEVE_METHOD } from '@/types/app'
|
||||
|
||||
@ -17,7 +17,7 @@ import ModelName from '@/app/components/header/account-setting/model-provider-pa
|
||||
import ModelParameterModal from '@/app/components/header/account-setting/model-provider-page/model-parameter-modal'
|
||||
import { useCredentialPanelState } from '@/app/components/header/account-setting/model-provider-page/provider-added-card/use-credential-panel-state'
|
||||
import { useDebugConfigurationContext } from '@/context/debug-configuration'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { useDebugWithMultipleModelContext } from './context'
|
||||
|
||||
type ModelParameterTriggerProps = {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/* oxlint-disable typescript/no-explicit-any */
|
||||
import { act, waitFor } from '@testing-library/react'
|
||||
import { updateAppModelConfig } from '@/service/apps'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { seedAccountProfileQuery } from '@/test/console/account-profile'
|
||||
import { createQueryClientWrapper } from '@/test/console/query-client'
|
||||
import { renderHook as renderHookWithConsoleState } from '@/test/console/render'
|
||||
|
||||
@ -8,7 +8,7 @@ import { currentWorkspaceAtom, currentWorkspaceLoadingAtom } from '@/context/wor
|
||||
import { userProfileQueryOptions } from '@/features/account-profile/client'
|
||||
import { usePathname } from '@/next/navigation'
|
||||
import { updateAppModelConfig } from '@/service/apps'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { getAppACLCapabilities } from '@/utils/permission'
|
||||
|
||||
export function useConfigurationAppContext() {
|
||||
|
||||
@ -131,8 +131,8 @@ vi.mock('@langgenius/dify-ui/toast', () => ({
|
||||
vi.mock('@/utils/create-app-tracking', () => ({
|
||||
trackCreateApp: (...args: unknown[]) => mockTrackCreateApp(...args),
|
||||
}))
|
||||
vi.mock('@/service/client', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('@/service/client')>()
|
||||
vi.mock('@/service/console', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('@/service/console')>()
|
||||
|
||||
return {
|
||||
...actual,
|
||||
|
||||
@ -21,7 +21,7 @@ import { workspacePermissionKeysAtom } from '@/context/permission-state'
|
||||
import { userProfileQueryOptions } from '@/features/account-profile/client'
|
||||
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
|
||||
import { useRouter } from '@/next/navigation'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { fetchAppDetail } from '@/service/explore'
|
||||
import { useExploreAppList } from '@/service/use-explore'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
|
||||
@ -41,8 +41,8 @@ vi.mock('@/next/navigation', () => ({
|
||||
vi.mock('@/utils/create-app-tracking', () => ({
|
||||
trackCreateApp: vi.fn(),
|
||||
}))
|
||||
vi.mock('@/service/client', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('@/service/client')>()
|
||||
vi.mock('@/service/console', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('@/service/console')>()
|
||||
|
||||
return {
|
||||
...actual,
|
||||
|
||||
@ -23,7 +23,7 @@ import { userProfileQueryOptions } from '@/features/account-profile/client'
|
||||
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
|
||||
import useTheme from '@/hooks/use-theme'
|
||||
import { useRouter } from '@/next/navigation'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
import { getRedirection } from '@/utils/app-redirection'
|
||||
import { trackCreateApp } from '@/utils/create-app-tracking'
|
||||
|
||||
@ -63,8 +63,8 @@ vi.mock('@/utils/create-app-tracking', () => ({
|
||||
trackCreateApp: (...args: unknown[]) => mockTrackCreateApp(...args),
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('@/service/client')>()
|
||||
vi.mock('@/service/console', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('@/service/console')>()
|
||||
return {
|
||||
...actual,
|
||||
consoleClient: {
|
||||
|
||||
@ -29,7 +29,7 @@ import { workspacePermissionKeysAtom } from '@/context/permission-state'
|
||||
import { userProfileQueryOptions } from '@/features/account-profile/client'
|
||||
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
|
||||
import { useRouter } from '@/next/navigation'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { AppModeEnum as AppMode } from '@/types/app'
|
||||
import { getRedirection } from '@/utils/app-redirection'
|
||||
import { trackCreateApp } from '@/utils/create-app-tracking'
|
||||
|
||||
@ -22,7 +22,7 @@ import {
|
||||
import { toast } from '@langgenius/dify-ui/toast'
|
||||
import { act, screen, waitFor, within } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import {
|
||||
appWorkflowQueryOptions,
|
||||
appWorkflowVersionsInfiniteQueryOptions,
|
||||
|
||||
@ -27,7 +27,7 @@ const queryOptionsMocks = vi.hoisted(() => ({
|
||||
versions: vi.fn(),
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', () => ({
|
||||
vi.mock('@/service/console', () => ({
|
||||
consoleQuery: {
|
||||
apps: {
|
||||
byAppId: {
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
import type { DeployWorkflowResponse } from '@dify/contracts/enterprise-app-deploy/types.gen'
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
|
||||
export function useDeployWorkflow({
|
||||
appId,
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
import type { ListEnvironmentDeploymentsResponse } from '@dify/contracts/enterprise-app-deploy/types.gen'
|
||||
import { hashKey, useQueryClient } from '@tanstack/react-query'
|
||||
import { useEffect } from 'react'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { hasDeploymentsRequiringPolling } from '../utils/environment-deployment'
|
||||
|
||||
export function useRefreshAppEnvironmentsAfterDeploymentPolling(appId: string) {
|
||||
|
||||
@ -5,7 +5,7 @@ import { toast } from '@langgenius/dify-ui/toast'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import { useCallback } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
|
||||
export function useUndeployWorkflow(appId: string) {
|
||||
const { t } = useTranslation('deployments')
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
import type { QueryFunction } from '@tanstack/react-query'
|
||||
import { skipToken, useQuery } from '@tanstack/react-query'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { normalizeDeploymentError } from './utils/deployment-error'
|
||||
|
||||
function withNormalizedDeploymentError<TData>(queryFn: QueryFunction<TData>): QueryFunction<TData> {
|
||||
|
||||
@ -6,7 +6,7 @@ import { atom } from 'jotai'
|
||||
import { atomWithInfiniteQuery, atomWithQuery } from 'jotai-tanstack-query'
|
||||
import { selectAtom, useHydrateAtoms } from 'jotai/utils'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import {
|
||||
appWorkflowQueryOptions,
|
||||
appWorkflowVersionsInfiniteQueryOptions,
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import type { ReactElement } from 'react'
|
||||
import { act, screen, waitFor } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import {
|
||||
createConsoleQueryClient,
|
||||
renderWithConsoleQuery,
|
||||
|
||||
@ -14,7 +14,7 @@ import { useTranslation } from 'react-i18next'
|
||||
import AppIcon from '@/app/components/base/app-icon'
|
||||
import AppsFull from '@/app/components/billing/apps-full-in-dialog'
|
||||
import { deploymentEditionAtom } from '@/features/system-features/state'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import AppIconPicker from '../../base/app-icon-picker'
|
||||
|
||||
export type DuplicateAppModalProps = {
|
||||
|
||||
@ -16,7 +16,7 @@ vi.mock('@/context/i18n', () => ({
|
||||
useLocale: () => mockLocale.value,
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', () => ({
|
||||
vi.mock('@/service/console', () => ({
|
||||
consoleQuery: {
|
||||
systemFeatures: {
|
||||
get: {
|
||||
|
||||
@ -5,7 +5,7 @@ import { useMutation, useQuery, useSuspenseQuery } from '@tanstack/react-query'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useLocale } from '@/context/i18n'
|
||||
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import InSiteMessage from './index'
|
||||
|
||||
type NotificationBodyPayload = {
|
||||
|
||||
@ -3,7 +3,7 @@ import type { DeploymentEdition } from '@dify/contracts/api/console/system-featu
|
||||
import type { ReactElement } from 'react'
|
||||
import type { QueryParam } from '../index'
|
||||
import { act, fireEvent, screen, waitFor, within } from '@testing-library/react'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import {
|
||||
createConsoleQueryClient,
|
||||
renderWithConsoleQuery,
|
||||
|
||||
@ -3,7 +3,7 @@ import type { DeploymentEdition } from '@dify/contracts/api/console/system-featu
|
||||
import { screen, within } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { useModalContext } from '@/context/modal-context'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { createConsoleQueryWrapper, seedFeatures } from '@/test/console/query-data'
|
||||
import { render } from '@/test/console/render'
|
||||
import { RetentionUpgradeNotice } from '../retention-upgrade-notice'
|
||||
|
||||
@ -11,7 +11,7 @@ import {
|
||||
} from '@/app/components/header/account-setting/query-params'
|
||||
import { isCurrentWorkspaceManagerAtom } from '@/context/workspace-state'
|
||||
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
|
||||
export function ArchivedLogsNotice() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
import { useQuery, useSuspenseQuery } from '@tanstack/react-query'
|
||||
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
|
||||
export const CLOUD_SANDBOX_TIME_PERIOD_KEYS = new Set(['1', '2', '3'])
|
||||
export const CLOUD_SANDBOX_CLEARED_TIME_PERIOD = '1'
|
||||
|
||||
@ -11,7 +11,7 @@ import * as React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Infotip } from '@/app/components/base/infotip'
|
||||
import Loading from '@/app/components/base/loading'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import {
|
||||
buildChartOptions,
|
||||
CHART_TYPE_CONFIG,
|
||||
|
||||
@ -3,7 +3,7 @@ import type { ModalContextState } from '@/context/modal-context'
|
||||
import type { AppDetailResponse } from '@/models/app'
|
||||
import type { AppSSO } from '@/types/app'
|
||||
import { fireEvent, screen, waitFor } from '@testing-library/react'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { createConsoleQueryClient, renderWithConsoleQuery } from '@/test/console/query-data'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
import SettingsModal from '../index'
|
||||
|
||||
@ -41,7 +41,7 @@ import { useModalContext } from '@/context/modal-context'
|
||||
import { deploymentEditionAtom } from '@/features/system-features/state'
|
||||
import { languages } from '@/i18n-config/language'
|
||||
import Link from '@/next/link'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
|
||||
type ISettingsModalProps = {
|
||||
|
||||
@ -25,7 +25,7 @@ import AppIcon from '@/app/components/base/app-icon'
|
||||
import AppsFull from '@/app/components/billing/apps-full-in-dialog'
|
||||
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
|
||||
import { useRouter } from '@/next/navigation'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
import { getRedirection } from '@/utils/app-redirection'
|
||||
import AppIconPicker from '../../base/app-icon-picker'
|
||||
|
||||
@ -5,7 +5,7 @@ import { toast } from '@langgenius/dify-ui/toast'
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import { useCallback } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { consoleClient } from '@/service/client'
|
||||
import { consoleClient } from '@/service/console'
|
||||
import { downloadBlob } from '@/utils/download'
|
||||
|
||||
type ExportAppDslInput = {
|
||||
|
||||
@ -48,8 +48,8 @@ const mockUnstarAppMutation = vi.hoisted(() =>
|
||||
vi.fn((_variables: unknown): Promise<unknown> => Promise.resolve()),
|
||||
)
|
||||
|
||||
vi.mock('@/service/client', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('@/service/client')>()
|
||||
vi.mock('@/service/console', async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import('@/service/console')>()
|
||||
const withMutation = (operation: object, mutationFn: typeof mockCopyApp) =>
|
||||
new Proxy(operation, {
|
||||
get(target, property, receiver) {
|
||||
|
||||
@ -79,7 +79,7 @@ vi.mock('@/next/navigation', () => ({
|
||||
useSearchParams: () => mockSearchParams,
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', () => ({
|
||||
vi.mock('@/service/console', () => ({
|
||||
consoleClient: {
|
||||
systemFeatures: {
|
||||
get: vi.fn(),
|
||||
|
||||
@ -58,7 +58,7 @@ import { AccessMode } from '@/models/access-control'
|
||||
import dynamic from '@/next/dynamic'
|
||||
import { useRouter } from '@/next/navigation'
|
||||
import { useGetUserCanAccessApp } from '@/service/access-control/use-app-access-control'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { fetchInstalledAppList } from '@/service/explore'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
import { getRedirection } from '@/utils/app-redirection'
|
||||
|
||||
@ -17,7 +17,7 @@ import { useTranslation } from 'react-i18next'
|
||||
import { InfiniteScrollSentinel } from '@/app/components/base/infinite-scroll-sentinel'
|
||||
import { STEP_BY_STEP_TOUR_TARGETS } from '@/app/components/step-by-step-tour/target-registry'
|
||||
import { systemFeaturesQueryOptions } from '@/features/system-features/client'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { AppModeEnum } from '@/types/app'
|
||||
import { AppCard } from './app-card'
|
||||
import { AppCardSkeleton } from './app-card-skeleton'
|
||||
|
||||
@ -22,7 +22,7 @@ vi.mock('@tanstack/react-query', () => ({
|
||||
useQuery: mockUseQuery,
|
||||
}))
|
||||
|
||||
vi.mock('@/service/client', () => ({
|
||||
vi.mock('@/service/console', () => ({
|
||||
consoleQuery: {
|
||||
apps: {
|
||||
workflows: {
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import type { WorkflowOnlineUser, WorkflowOnlineUsersResponse } from '@/models/app'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
|
||||
type WorkflowOnlineUsersMap = Record<string, WorkflowOnlineUser[]>
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ import { useTranslation } from 'react-i18next'
|
||||
import { useModalContext } from '@/context/modal-context'
|
||||
import { deploymentEditionAtom } from '@/features/system-features/state'
|
||||
import { addAnnotation } from '@/service/annotation'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
|
||||
type Props = Readonly<{
|
||||
appId: string
|
||||
|
||||
@ -9,7 +9,7 @@ import { AnnotationEnableStatus, JobStatus } from '@/app/components/app/annotati
|
||||
import { ANNOTATION_DEFAULT } from '@/config'
|
||||
import { deploymentEditionAtom } from '@/features/system-features/state'
|
||||
import { queryAnnotationJobStatus, updateAnnotationStatus } from '@/service/annotation'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { sleep } from '@/utils'
|
||||
|
||||
type Params = {
|
||||
|
||||
@ -22,7 +22,7 @@ import { useFeatures, useFeaturesStore } from '@/app/components/base/features/ho
|
||||
import { Infotip } from '@/app/components/base/infotip'
|
||||
import { languages } from '@/i18n-config/language'
|
||||
import { usePathname } from '@/next/navigation'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { TtsAutoPlay } from '@/types/app'
|
||||
|
||||
type SelectOption = {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import { consoleClient } from '@/service/client'
|
||||
import { consoleClient } from '@/service/console'
|
||||
import { AppSourceType, audioToText } from '@/service/share'
|
||||
import { transcribeAudio } from '../api'
|
||||
|
||||
@ -10,7 +10,7 @@ vi.mock('@/service/share', async (importOriginal) => {
|
||||
}
|
||||
})
|
||||
|
||||
vi.mock('@/service/client', () => ({
|
||||
vi.mock('@/service/console', () => ({
|
||||
consoleClient: {
|
||||
apps: {
|
||||
byAppId: {
|
||||
|
||||
@ -7,7 +7,7 @@ export async function transcribeAudio(
|
||||
signal?: AbortSignal,
|
||||
): Promise<{ text: string }> {
|
||||
if (target.type === 'agent' || target.type === 'consoleApp') {
|
||||
const { consoleClient } = await import('@/service/client')
|
||||
const { consoleClient } = await import('@/service/console')
|
||||
if (target.type === 'agent') {
|
||||
return consoleClient.agent.byAgentId.audioToText.post(
|
||||
{
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { act, render, screen, waitFor, within } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { ModalContextProvider } from '@/context/modal-context-provider'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import {
|
||||
createConsoleQueryClient,
|
||||
createConsoleQueryWrapper,
|
||||
|
||||
@ -3,7 +3,7 @@ import type { FC } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import * as React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { MessageFastPlus } from '../../base/icons/src/vender/line/communication'
|
||||
import UsageInfo from '../usage-info'
|
||||
import { parseLimit } from '../utils'
|
||||
|
||||
@ -9,7 +9,7 @@ import * as React from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { mailToSupport } from '@/app/components/header/utils/util'
|
||||
import { userProfileQueryOptions } from '@/features/account-profile/client'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import UpgradeBtn from '../upgrade-btn'
|
||||
import s from './style.module.css'
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { screen } from '@testing-library/react'
|
||||
import userEvent from '@testing-library/user-event'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import { createConsoleQueryClient, createConsoleQueryWrapper } from '@/test/console/query-data'
|
||||
import { render } from '@/test/console/render'
|
||||
import Billing from '../index'
|
||||
|
||||
@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next'
|
||||
import Loading from '@/app/components/base/loading'
|
||||
import { isCurrentWorkspaceManagerAtom } from '@/context/workspace-state'
|
||||
import { deploymentEditionAtom } from '@/features/system-features/state'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
import PlanComp from '../plan'
|
||||
|
||||
const Billing: FC = () => {
|
||||
|
||||
@ -4,7 +4,7 @@ import { useAtomValue } from 'jotai'
|
||||
import { useCallback, useState } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { isCurrentWorkspaceManagerAtom } from '@/context/workspace-state'
|
||||
import { consoleClient } from '@/service/client'
|
||||
import { consoleClient } from '@/service/console'
|
||||
|
||||
export function useEducationDiscount() {
|
||||
const { t } = useTranslation()
|
||||
|
||||
@ -4,7 +4,7 @@ import Cookies from 'js-cookie'
|
||||
import { useCallback } from 'react'
|
||||
import { PARTNER_STACK_CONFIG } from '@/config'
|
||||
import { useSearchParams } from '@/next/navigation'
|
||||
import { consoleQuery } from '@/service/client'
|
||||
import { consoleQuery } from '@/service/console'
|
||||
|
||||
const usePSInfo = () => {
|
||||
const searchParams = useSearchParams()
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user