mirror of
https://github.com/langgenius/dify.git
synced 2026-09-03 06:53:26 +08:00
# Conflicts: # api/commands/system.py # api/controllers/console/init_validate.py # api/controllers/console/workspace/account.py # api/controllers/console/wraps.py # api/controllers/openapi/auth/data.py # api/core/hosting_configuration.py # api/core/provider_manager.py # api/core/rag/retrieval/dataset_retrieval.py # api/services/workspace_service.py # api/tasks/workflow_cfs_scheduler/entities.py # api/tests/test_containers_integration_tests/controllers/console/auth/test_password_reset.py # api/tests/test_containers_integration_tests/services/test_feature_service.py # api/tests/unit_tests/controllers/console/auth/test_account_activation.py # api/tests/unit_tests/controllers/openapi/auth/test_data.py # api/tests/unit_tests/controllers/service_api/app/test_hitl_service_api.py # api/tests/unit_tests/extensions/otel/test_retrieval_tracing.py # api/tests/unit_tests/services/test_feature_service_knowledge_fs.py # dev/start-worker # packages/contracts/console.ts # packages/contracts/package.json # packages/iconify-collections/custom-public/icons.json # web/app/components/workflow/__tests__/index.spec.tsx # web/app/components/workflow/index.tsx # web/features/new-rag/document-chunk-tree.tsx # web/service/fetch.spec.ts
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import type { AnyContractRouter } from '@orpc/contract'
|
|
import { contractLoaders } from '@dify/contracts/api/console/orpc.gen'
|
|
|
|
const generatedConsoleContractLoaders: Partial<Record<string, () => Promise<AnyContractRouter>>> =
|
|
contractLoaders
|
|
|
|
async function loadGeneratedConsoleContract(segment: string) {
|
|
const loader = generatedConsoleContractLoaders[segment]
|
|
if (!loader) return null
|
|
|
|
return loader()
|
|
}
|
|
|
|
async function loadEnterpriseContract(): Promise<AnyContractRouter> {
|
|
const [{ contract: enterpriseContract }, { contract: appDeployContract }] = await Promise.all([
|
|
import('@dify/contracts/enterprise/orpc.gen'),
|
|
import('@dify/contracts/enterprise-app-deploy/orpc.gen'),
|
|
])
|
|
|
|
return {
|
|
enterprise: {
|
|
...enterpriseContract,
|
|
appDeploy: appDeployContract,
|
|
},
|
|
}
|
|
}
|
|
|
|
export async function loadConsoleContractForSegment(segment: string) {
|
|
if (segment === 'enterprise') return loadEnterpriseContract()
|
|
|
|
const generatedContract = await loadGeneratedConsoleContract(segment)
|
|
if (generatedContract) return generatedContract
|
|
|
|
throw new Error(`Console contract segment "${segment}" is not configured.`)
|
|
}
|