mirror of
https://github.com/langgenius/dify.git
synced 2026-09-21 05:11:22 +08:00
refactor(api): migrate dataset rag pipeline endpoints to BaseModel (#37958)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Asuka Minato <i@asukaminato.eu.org>
This commit is contained in:
co-authored by
autofix-ci[bot]
Asuka Minato
parent
c3b1508712
commit
77ae583b44
@@ -4,8 +4,12 @@ export type ClientOptions = {
|
||||
baseUrl: `${string}://${string}/console/api` | (string & {})
|
||||
}
|
||||
|
||||
export type DatasourceCredentialsResponse = {
|
||||
result: unknown
|
||||
export type DatasourceProviderAuthListResponse = {
|
||||
result: Array<DatasourceProviderAuthResponse>
|
||||
}
|
||||
|
||||
export type DatasourceCredentialListResponse = {
|
||||
result: Array<DatasourceCredentialResponse>
|
||||
}
|
||||
|
||||
export type DatasourceCredentialPayload = {
|
||||
@@ -47,6 +51,90 @@ export type DatasourceUpdateNamePayload = {
|
||||
name: string
|
||||
}
|
||||
|
||||
export type DatasourceProviderAuthResponse = {
|
||||
author: string
|
||||
credential_schema: Array<ProviderConfig>
|
||||
credentials_list: Array<DatasourceCredentialResponse>
|
||||
description: I18nObject
|
||||
icon: string
|
||||
label: I18nObject
|
||||
name: string
|
||||
oauth_schema: DatasourceOAuthSchemaResponse | null
|
||||
plugin_id: string
|
||||
plugin_unique_identifier: string
|
||||
provider: string
|
||||
}
|
||||
|
||||
export type DatasourceCredentialResponse = {
|
||||
avatar_url: string | null
|
||||
credential: {
|
||||
[key: string]: unknown
|
||||
}
|
||||
id: string
|
||||
is_default: boolean
|
||||
name: string
|
||||
type: string
|
||||
}
|
||||
|
||||
export type ProviderConfig = {
|
||||
default?: number | string | number | boolean | null
|
||||
help?: I18nObject | null
|
||||
label?: I18nObject | null
|
||||
multiple?: boolean
|
||||
name: string
|
||||
options?: Array<Option> | null
|
||||
placeholder?: I18nObject | null
|
||||
required?: boolean
|
||||
scope?: AppSelectorScope | ModelSelectorScope | ToolSelectorScope | null
|
||||
type: CoreEntitiesProviderEntitiesBasicProviderConfigType
|
||||
url?: string | null
|
||||
}
|
||||
|
||||
export type I18nObject = {
|
||||
en_US: string
|
||||
ja_JP?: string | null
|
||||
pt_BR?: string | null
|
||||
zh_Hans?: string | null
|
||||
}
|
||||
|
||||
export type DatasourceOAuthSchemaResponse = {
|
||||
client_schema: Array<ProviderConfig>
|
||||
credentials_schema: Array<ProviderConfig>
|
||||
is_oauth_custom_client_enabled: boolean
|
||||
is_system_oauth_params_exists: boolean
|
||||
oauth_custom_client_params: {
|
||||
[key: string]: unknown
|
||||
} | null
|
||||
redirect_uri: string
|
||||
}
|
||||
|
||||
export type Option = {
|
||||
label: I18nObject
|
||||
value: string
|
||||
}
|
||||
|
||||
export type AppSelectorScope = 'all' | 'chat' | 'completion' | 'workflow'
|
||||
|
||||
export type ModelSelectorScope
|
||||
= | 'llm'
|
||||
| 'moderation'
|
||||
| 'rerank'
|
||||
| 'speech2text'
|
||||
| 'text-embedding'
|
||||
| 'tts'
|
||||
| 'vision'
|
||||
|
||||
export type ToolSelectorScope = 'all' | 'builtin' | 'custom' | 'workflow'
|
||||
|
||||
export type CoreEntitiesProviderEntitiesBasicProviderConfigType
|
||||
= | 'app-selector'
|
||||
| 'array[tools]'
|
||||
| 'boolean'
|
||||
| 'model-selector'
|
||||
| 'secret-input'
|
||||
| 'select'
|
||||
| 'text-input'
|
||||
|
||||
export type GetAuthPluginDatasourceDefaultListData = {
|
||||
body?: never
|
||||
path?: never
|
||||
@@ -55,7 +143,7 @@ export type GetAuthPluginDatasourceDefaultListData = {
|
||||
}
|
||||
|
||||
export type GetAuthPluginDatasourceDefaultListResponses = {
|
||||
200: DatasourceCredentialsResponse
|
||||
200: DatasourceProviderAuthListResponse
|
||||
}
|
||||
|
||||
export type GetAuthPluginDatasourceDefaultListResponse
|
||||
@@ -69,7 +157,7 @@ export type GetAuthPluginDatasourceListData = {
|
||||
}
|
||||
|
||||
export type GetAuthPluginDatasourceListResponses = {
|
||||
200: DatasourceCredentialsResponse
|
||||
200: DatasourceProviderAuthListResponse
|
||||
}
|
||||
|
||||
export type GetAuthPluginDatasourceListResponse
|
||||
@@ -85,7 +173,7 @@ export type GetAuthPluginDatasourceByProviderIdData = {
|
||||
}
|
||||
|
||||
export type GetAuthPluginDatasourceByProviderIdResponses = {
|
||||
200: DatasourceCredentialsResponse
|
||||
200: DatasourceCredentialListResponse
|
||||
}
|
||||
|
||||
export type GetAuthPluginDatasourceByProviderIdResponse
|
||||
|
||||
@@ -2,13 +2,6 @@
|
||||
|
||||
import * as z from 'zod'
|
||||
|
||||
/**
|
||||
* DatasourceCredentialsResponse
|
||||
*/
|
||||
export const zDatasourceCredentialsResponse = z.object({
|
||||
result: z.unknown(),
|
||||
})
|
||||
|
||||
/**
|
||||
* DatasourceCredentialPayload
|
||||
*/
|
||||
@@ -64,23 +57,153 @@ export const zDatasourceUpdateNamePayload = z.object({
|
||||
})
|
||||
|
||||
/**
|
||||
* Success
|
||||
* DatasourceCredentialResponse
|
||||
*/
|
||||
export const zGetAuthPluginDatasourceDefaultListResponse = zDatasourceCredentialsResponse
|
||||
export const zDatasourceCredentialResponse = z.object({
|
||||
avatar_url: z.string().nullable(),
|
||||
credential: z.record(z.string(), z.unknown()),
|
||||
id: z.string(),
|
||||
is_default: z.boolean(),
|
||||
name: z.string(),
|
||||
type: z.string(),
|
||||
})
|
||||
|
||||
/**
|
||||
* Success
|
||||
* DatasourceCredentialListResponse
|
||||
*/
|
||||
export const zGetAuthPluginDatasourceListResponse = zDatasourceCredentialsResponse
|
||||
export const zDatasourceCredentialListResponse = z.object({
|
||||
result: z.array(zDatasourceCredentialResponse),
|
||||
})
|
||||
|
||||
/**
|
||||
* I18nObject
|
||||
*
|
||||
* Model class for i18n object.
|
||||
*/
|
||||
export const zI18nObject = z.object({
|
||||
en_US: z.string(),
|
||||
ja_JP: z.string().nullish(),
|
||||
pt_BR: z.string().nullish(),
|
||||
zh_Hans: z.string().nullish(),
|
||||
})
|
||||
|
||||
/**
|
||||
* Option
|
||||
*/
|
||||
export const zOption = z.object({
|
||||
label: zI18nObject,
|
||||
value: z.string(),
|
||||
})
|
||||
|
||||
/**
|
||||
* AppSelectorScope
|
||||
*/
|
||||
export const zAppSelectorScope = z.enum(['all', 'chat', 'completion', 'workflow'])
|
||||
|
||||
/**
|
||||
* ModelSelectorScope
|
||||
*/
|
||||
export const zModelSelectorScope = z.enum([
|
||||
'llm',
|
||||
'moderation',
|
||||
'rerank',
|
||||
'speech2text',
|
||||
'text-embedding',
|
||||
'tts',
|
||||
'vision',
|
||||
])
|
||||
|
||||
/**
|
||||
* ToolSelectorScope
|
||||
*/
|
||||
export const zToolSelectorScope = z.enum(['all', 'builtin', 'custom', 'workflow'])
|
||||
|
||||
/**
|
||||
* Type
|
||||
*/
|
||||
export const zCoreEntitiesProviderEntitiesBasicProviderConfigType = z.enum([
|
||||
'app-selector',
|
||||
'array[tools]',
|
||||
'boolean',
|
||||
'model-selector',
|
||||
'secret-input',
|
||||
'select',
|
||||
'text-input',
|
||||
])
|
||||
|
||||
/**
|
||||
* ProviderConfig
|
||||
*
|
||||
* Model class for common provider settings like credentials
|
||||
*/
|
||||
export const zProviderConfig = z.object({
|
||||
default: z.union([z.int(), z.string(), z.number(), z.boolean()]).nullish(),
|
||||
help: zI18nObject.nullish(),
|
||||
label: zI18nObject.nullish(),
|
||||
multiple: z.boolean().optional().default(false),
|
||||
name: z.string(),
|
||||
options: z.array(zOption).nullish(),
|
||||
placeholder: zI18nObject.nullish(),
|
||||
required: z.boolean().optional().default(false),
|
||||
scope: z.union([zAppSelectorScope, zModelSelectorScope, zToolSelectorScope]).nullish(),
|
||||
type: zCoreEntitiesProviderEntitiesBasicProviderConfigType,
|
||||
url: z.string().nullish(),
|
||||
})
|
||||
|
||||
/**
|
||||
* DatasourceOAuthSchemaResponse
|
||||
*/
|
||||
export const zDatasourceOAuthSchemaResponse = z.object({
|
||||
client_schema: z.array(zProviderConfig),
|
||||
credentials_schema: z.array(zProviderConfig),
|
||||
is_oauth_custom_client_enabled: z.boolean(),
|
||||
is_system_oauth_params_exists: z.boolean(),
|
||||
oauth_custom_client_params: z.record(z.string(), z.unknown()).nullable(),
|
||||
redirect_uri: z.string(),
|
||||
})
|
||||
|
||||
/**
|
||||
* DatasourceProviderAuthResponse
|
||||
*/
|
||||
export const zDatasourceProviderAuthResponse = z.object({
|
||||
author: z.string(),
|
||||
credential_schema: z.array(zProviderConfig),
|
||||
credentials_list: z.array(zDatasourceCredentialResponse),
|
||||
description: zI18nObject,
|
||||
icon: z.string(),
|
||||
label: zI18nObject,
|
||||
name: z.string(),
|
||||
oauth_schema: zDatasourceOAuthSchemaResponse.nullable(),
|
||||
plugin_id: z.string(),
|
||||
plugin_unique_identifier: z.string(),
|
||||
provider: z.string(),
|
||||
})
|
||||
|
||||
/**
|
||||
* DatasourceProviderAuthListResponse
|
||||
*/
|
||||
export const zDatasourceProviderAuthListResponse = z.object({
|
||||
result: z.array(zDatasourceProviderAuthResponse),
|
||||
})
|
||||
|
||||
/**
|
||||
* Default datasource credentials retrieved successfully
|
||||
*/
|
||||
export const zGetAuthPluginDatasourceDefaultListResponse = zDatasourceProviderAuthListResponse
|
||||
|
||||
/**
|
||||
* Datasource credentials retrieved successfully
|
||||
*/
|
||||
export const zGetAuthPluginDatasourceListResponse = zDatasourceProviderAuthListResponse
|
||||
|
||||
export const zGetAuthPluginDatasourceByProviderIdPath = z.object({
|
||||
provider_id: z.string(),
|
||||
})
|
||||
|
||||
/**
|
||||
* Success
|
||||
* Datasource credentials retrieved successfully
|
||||
*/
|
||||
export const zGetAuthPluginDatasourceByProviderIdResponse = zDatasourceCredentialsResponse
|
||||
export const zGetAuthPluginDatasourceByProviderIdResponse = zDatasourceCredentialListResponse
|
||||
|
||||
export const zPostAuthPluginDatasourceByProviderIdBody = zDatasourceCredentialPayload
|
||||
|
||||
@@ -89,7 +212,7 @@ export const zPostAuthPluginDatasourceByProviderIdPath = z.object({
|
||||
})
|
||||
|
||||
/**
|
||||
* Success
|
||||
* Datasource credential created successfully
|
||||
*/
|
||||
export const zPostAuthPluginDatasourceByProviderIdResponse = zSimpleResultResponse
|
||||
|
||||
@@ -109,7 +232,7 @@ export const zPostAuthPluginDatasourceByProviderIdCustomClientPath = z.object({
|
||||
})
|
||||
|
||||
/**
|
||||
* Success
|
||||
* Datasource OAuth custom client saved successfully
|
||||
*/
|
||||
export const zPostAuthPluginDatasourceByProviderIdCustomClientResponse = zSimpleResultResponse
|
||||
|
||||
@@ -142,7 +265,7 @@ export const zPostAuthPluginDatasourceByProviderIdUpdatePath = z.object({
|
||||
})
|
||||
|
||||
/**
|
||||
* Success
|
||||
* Datasource credential updated successfully
|
||||
*/
|
||||
export const zPostAuthPluginDatasourceByProviderIdUpdateResponse = zSimpleResultResponse
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ export const zGetOauthPluginByProviderIdDatasourceGetAuthorizationUrlQuery = z.o
|
||||
})
|
||||
|
||||
/**
|
||||
* Authorization URL retrieved successfully
|
||||
* Datasource OAuth authorization URL generated successfully
|
||||
*/
|
||||
export const zGetOauthPluginByProviderIdDatasourceGetAuthorizationUrlResponse
|
||||
= zPluginOAuthAuthorizationUrlResponse
|
||||
|
||||
@@ -327,8 +327,6 @@ export type Parser = {
|
||||
}
|
||||
}
|
||||
|
||||
export type DataSourceContentPreviewResponse = unknown
|
||||
|
||||
export type PublishedWorkflowRunPayload = {
|
||||
datasource_info_list: Array<{
|
||||
[key: string]: unknown
|
||||
@@ -1329,7 +1327,9 @@ export type PostRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNodeI
|
||||
|
||||
export type PostRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNodeIdPreviewResponses
|
||||
= {
|
||||
200: DataSourceContentPreviewResponse
|
||||
200: {
|
||||
[key: string]: unknown
|
||||
}
|
||||
}
|
||||
|
||||
export type PostRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNodeIdPreviewResponse
|
||||
|
||||
@@ -199,11 +199,6 @@ export const zParser = z.object({
|
||||
inputs: z.record(z.string(), z.unknown()),
|
||||
})
|
||||
|
||||
/**
|
||||
* DataSourceContentPreviewResponse
|
||||
*/
|
||||
export const zDataSourceContentPreviewResponse = z.unknown()
|
||||
|
||||
/**
|
||||
* PublishedWorkflowRunPayload
|
||||
*/
|
||||
@@ -1179,7 +1174,7 @@ export const zPostRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNod
|
||||
* Success
|
||||
*/
|
||||
export const zPostRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNodeIdPreviewResponse
|
||||
= zDataSourceContentPreviewResponse
|
||||
= z.record(z.string(), z.unknown())
|
||||
|
||||
export const zPostRagPipelinesByPipelineIdWorkflowsPublishedDatasourceNodesByNodeIdRunBody
|
||||
= zDatasourceNodeRunPayload
|
||||
|
||||
@@ -567,7 +567,7 @@ export type DatasourceNodeRunPayload = {
|
||||
export type DatasourcePluginListResponse = Array<DatasourcePluginResponse>
|
||||
|
||||
export type DatasourcePluginResponse = {
|
||||
credentials: Array<DatasourceCredentialInfoResponse>
|
||||
credentials?: Array<DatasourceCredentialInfoResponse>
|
||||
datasource_type?: string | null
|
||||
node_id?: string | null
|
||||
plugin_id?: string | null
|
||||
@@ -3196,7 +3196,9 @@ export type PostDatasetsByDatasetIdPipelineDatasourceNodesByNodeIdRunErrors = {
|
||||
}
|
||||
|
||||
export type PostDatasetsByDatasetIdPipelineDatasourceNodesByNodeIdRunResponses = {
|
||||
200: GeneratedAppResponse
|
||||
200: {
|
||||
[key: string]: unknown
|
||||
}
|
||||
}
|
||||
|
||||
export type PostDatasetsByDatasetIdPipelineDatasourceNodesByNodeIdRunResponse
|
||||
|
||||
@@ -698,7 +698,7 @@ export const zDatasourceNodeRunPayload = z.object({
|
||||
* DatasourcePluginResponse
|
||||
*/
|
||||
export const zDatasourcePluginResponse = z.object({
|
||||
credentials: z.array(zDatasourceCredentialInfoResponse),
|
||||
credentials: z.array(zDatasourceCredentialInfoResponse).optional(),
|
||||
datasource_type: z.string().nullish(),
|
||||
node_id: z.string().nullish(),
|
||||
plugin_id: z.string().nullish(),
|
||||
@@ -3063,8 +3063,10 @@ export const zPostDatasetsByDatasetIdPipelineDatasourceNodesByNodeIdRunPath = z.
|
||||
/**
|
||||
* Streaming response with node execution events.
|
||||
*/
|
||||
export const zPostDatasetsByDatasetIdPipelineDatasourceNodesByNodeIdRunResponse
|
||||
= zGeneratedAppResponse
|
||||
export const zPostDatasetsByDatasetIdPipelineDatasourceNodesByNodeIdRunResponse = z.record(
|
||||
z.string(),
|
||||
z.unknown(),
|
||||
)
|
||||
|
||||
export const zPostDatasetsByDatasetIdPipelineRunBody = zPipelineRunApiEntity
|
||||
|
||||
|
||||
Reference in New Issue
Block a user