chore(web): new lint setup (#30020)

Co-authored-by: yyh <yuanyouhuilyz@gmail.com>
This commit is contained in:
Stephen Zhou
2025-12-23 16:58:55 +08:00
committed by GitHub
parent 9701a2994b
commit f2842da397
3356 changed files with 85046 additions and 81278 deletions

View File

@ -1,10 +1,10 @@
'use client'
import type { FC } from 'react'
import type { CredentialFormSchema } from '@/app/components/header/account-setting/model-provider-page/declarations'
import type { Event } from '@/app/components/tools/types'
import type { FC } from 'react'
import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'
import type { PluginTriggerVarInputs } from '@/app/components/workflow/nodes/trigger-plugin/types'
import TriggerFormItem from './item'
import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'
type Props = {
readOnly: boolean
@ -33,7 +33,7 @@ const TriggerForm: FC<Props> = ({
disableVariableInsertion = false,
}) => {
return (
<div className='space-y-1'>
<div className="space-y-1">
{
schema.map((schema, index) => (
<TriggerFormItem

View File

@ -1,19 +1,19 @@
'use client'
import type { FC } from 'react'
import type { CredentialFormSchema } from '@/app/components/header/account-setting/model-provider-page/declarations'
import type { Event } from '@/app/components/tools/types'
import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'
import type { PluginTriggerVarInputs } from '@/app/components/workflow/nodes/trigger-plugin/types'
import {
RiBracesLine,
} from '@remixicon/react'
import type { PluginTriggerVarInputs } from '@/app/components/workflow/nodes/trigger-plugin/types'
import type { CredentialFormSchema } from '@/app/components/header/account-setting/model-provider-page/declarations'
import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
import { useBoolean } from 'ahooks'
import Button from '@/app/components/base/button'
import Tooltip from '@/app/components/base/tooltip'
import FormInputItem from '@/app/components/workflow/nodes/_base/components/form-input-item'
import { useBoolean } from 'ahooks'
import { FormTypeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
import { useLanguage } from '@/app/components/header/account-setting/model-provider-page/hooks'
import SchemaModal from '@/app/components/plugins/plugin-detail-panel/tool-selector/schema-modal'
import type { Event } from '@/app/components/tools/types'
import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'
import FormInputItem from '@/app/components/workflow/nodes/_base/components/form-input-item'
type Props = {
readOnly: boolean
@ -49,39 +49,41 @@ const TriggerFormItem: FC<Props> = ({
setFalse: hideSchema,
}] = useBoolean(false)
return (
<div className='space-y-0.5 py-1'>
<div className="space-y-0.5 py-1">
<div>
<div className='flex h-6 items-center'>
<div className='system-sm-medium text-text-secondary'>{label[language] || label.en_US}</div>
<div className="flex h-6 items-center">
<div className="system-sm-medium text-text-secondary">{label[language] || label.en_US}</div>
{required && (
<div className='system-xs-regular ml-1 text-text-destructive-secondary'>*</div>
<div className="system-xs-regular ml-1 text-text-destructive-secondary">*</div>
)}
{!showDescription && tooltip && (
<Tooltip
popupContent={<div className='w-[200px]'>
{tooltip[language] || tooltip.en_US}
</div>}
triggerClassName='ml-1 w-4 h-4'
popupContent={(
<div className="w-[200px]">
{tooltip[language] || tooltip.en_US}
</div>
)}
triggerClassName="ml-1 w-4 h-4"
asChild={false}
/>
)}
{showSchemaButton && (
<>
<div className='system-xs-regular ml-1 mr-0.5 text-text-quaternary'>·</div>
<div className="system-xs-regular ml-1 mr-0.5 text-text-quaternary">·</div>
<Button
variant='ghost'
size='small'
variant="ghost"
size="small"
onClick={showSchema}
className='system-xs-regular px-1 text-text-tertiary'
className="system-xs-regular px-1 text-text-tertiary"
>
<RiBracesLine className='mr-1 size-3.5' />
<RiBracesLine className="mr-1 size-3.5" />
<span>JSON Schema</span>
</Button>
</>
)}
</div>
{showDescription && tooltip && (
<div className='body-xs-regular pb-0.5 text-text-tertiary'>{tooltip[language] || tooltip.en_US}</div>
<div className="body-xs-regular pb-0.5 text-text-tertiary">{tooltip[language] || tooltip.en_US}</div>
)}
</div>
<FormInputItem
@ -93,7 +95,7 @@ const TriggerFormItem: FC<Props> = ({
inPanel={inPanel}
currentTool={currentEvent}
currentProvider={currentProvider}
providerType='trigger'
providerType="trigger"
extraParams={extraParams}
disableVariableInsertion={disableVariableInsertion}
/>

View File

@ -1,13 +1,15 @@
import type { SchemaTypeDefinition } from '@/service/use-common'
import type { NodeDefault, Var } from '../../types'
import type { Field, StructuredOutput } from '../llm/types'
import type { PluginTriggerNodeType } from './types'
import type { SchemaTypeDefinition } from '@/service/use-common'
import { BlockEnum, VarType } from '../../types'
import { genNodeMetaData } from '../../utils'
import { VarKindType } from '../_base/types'
import { type Field, type StructuredOutput, Type } from '../llm/types'
import type { PluginTriggerNodeType } from './types'
import { Type } from '../llm/types'
const normalizeJsonSchemaType = (schema: any): string | undefined => {
if (!schema) return undefined
if (!schema)
return undefined
const { type, properties, items, oneOf, anyOf, allOf } = schema
if (Array.isArray(type))
@ -55,7 +57,7 @@ const extractSchemaType = (schema: any, _schemaTypeDefinitions?: SchemaTypeDefin
const resolveVarType = (
schema: any,
schemaTypeDefinitions?: SchemaTypeDefinition[],
): { type: VarType; schemaType?: string } => {
): { type: VarType, schemaType?: string } => {
const schemaType = extractSchemaType(schema, schemaTypeDefinitions)
const normalizedType = normalizeJsonSchemaType(schema)
@ -195,9 +197,9 @@ const buildOutputVars = (schema: Record<string, any>, schemaTypeDefinitions?: Sc
if (normalizedType === 'object') {
const childProperties = propertySchema?.properties
? Object.entries(propertySchema.properties).reduce((acc, [key, value]) => {
acc[key] = convertJsonSchemaToField(value, schemaTypeDefinitions)
return acc
}, {} as Record<string, Field>)
acc[key] = convertJsonSchemaToField(value, schemaTypeDefinitions)
return acc
}, {} as Record<string, Field>)
: {}
const required = Array.isArray(propertySchema?.required) ? propertySchema.required.filter(Boolean) : undefined
@ -263,7 +265,7 @@ const nodeDefault: NodeDefault<PluginTriggerNodeType> = {
}
const targetParam = typeof rawParam === 'object' && rawParam !== null && 'type' in rawParam
? rawParam as { type: VarKindType; value: any }
? rawParam as { type: VarKindType, value: any }
: { type: VarKindType.constant, value: rawParam }
const { type, value } = targetParam
@ -277,8 +279,9 @@ const nodeDefault: NodeDefault<PluginTriggerNodeType> = {
|| value === null
|| value === ''
|| (Array.isArray(value) && value.length === 0)
)
) {
errorMessage = t('workflow.errorMsg.fieldRequired', { field: field.label })
}
}
})
}

View File

@ -1,3 +1,4 @@
import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'
import { useCallback, useState } from 'react'
import {
useBuildTriggerSubscription,
@ -5,7 +6,6 @@ import {
useUpdateTriggerSubscriptionBuilder,
useVerifyTriggerSubscriptionBuilder,
} from '@/service/use-triggers'
import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'
// Helper function to serialize complex values to strings for backend encryption
const serializeFormValues = (values: Record<string, any>): Record<string, string> => {
@ -51,7 +51,8 @@ export const useTriggerAuthFlow = (provider: TriggerWithProvider): AuthFlowState
const buildSubscription = useBuildTriggerSubscription()
const startAuth = useCallback(async () => {
if (builderId) return // Prevent multiple calls if already started
if (builderId)
return // Prevent multiple calls if already started
setIsLoading(true)
setError(null)

View File

@ -1,12 +1,12 @@
import NodeStatus, { NodeStatusEnum } from '@/app/components/base/node-status'
import type { NodeProps } from '@/app/components/workflow/types'
import type { FC } from 'react'
import type { PluginTriggerNodeType } from './types'
import type { NodeProps } from '@/app/components/workflow/types'
import React, { useEffect, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import { InstallPluginButton } from '@/app/components/workflow/nodes/_base/components/install-plugin-button'
import { useNodePluginInstallation } from '@/app/components/workflow/hooks/use-node-plugin-installation'
import NodeStatus, { NodeStatusEnum } from '@/app/components/base/node-status'
import { useNodeDataUpdate } from '@/app/components/workflow/hooks/use-node-data-update'
import type { PluginTriggerNodeType } from './types'
import { useNodePluginInstallation } from '@/app/components/workflow/hooks/use-node-plugin-installation'
import { InstallPluginButton } from '@/app/components/workflow/nodes/_base/components/install-plugin-button'
import useConfig from './use-config'
const formatConfigValue = (rawValue: any): string => {

View File

@ -1,14 +1,14 @@
import type { FC } from 'react'
import React from 'react'
import type { PluginTriggerNodeType } from './types'
import Split from '@/app/components/workflow/nodes/_base/components/split'
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
import type { NodePanelProps } from '@/app/components/workflow/types'
import useConfig from './use-config'
import TriggerForm from './components/trigger-form'
import React from 'react'
import OutputVars, { VarItem } from '@/app/components/workflow/nodes/_base/components/output-vars'
import Split from '@/app/components/workflow/nodes/_base/components/split'
import StructureOutputItem from '@/app/components/workflow/nodes/_base/components/variable/object-child-tree-panel/show'
import { Type } from '../llm/types'
import { BlockEnum } from '@/app/components/workflow/types'
import { Type } from '../llm/types'
import TriggerForm from './components/trigger-form'
import useConfig from './use-config'
const Panel: FC<NodePanelProps<PluginTriggerNodeType>> = ({
id,
@ -35,11 +35,11 @@ const Panel: FC<NodePanelProps<PluginTriggerNodeType>> = ({
}))
return (
<div className='mt-2'>
<div className="mt-2">
{/* Dynamic Parameters Form - Only show when authenticated */}
{triggerParameterSchema.length > 0 && subscriptionSelected && (
<>
<div className='px-4 pb-4'>
<div className="px-4 pb-4">
<TriggerForm
readOnly={readOnly}
nodeId={id}
@ -69,20 +69,22 @@ const Panel: FC<NodePanelProps<PluginTriggerNodeType>> = ({
))}
{Object.entries(outputSchema.properties || {}).map(([name, schema]: [string, any]) => (
<div key={name}>
{schema.type === 'object' ? (
<StructureOutputItem
rootClassName='code-sm-semibold text-text-secondary'
payload={{
schema: {
type: Type.object,
properties: {
[name]: schema,
},
additionalProperties: false,
},
}}
/>
) : null}
{schema.type === 'object'
? (
<StructureOutputItem
rootClassName="code-sm-semibold text-text-secondary"
payload={{
schema: {
type: Type.object,
properties: {
[name]: schema,
},
additionalProperties: false,
},
}}
/>
)
: null}
</div>
))}
</>

View File

@ -1,6 +1,6 @@
import type { CommonNodeType } from '@/app/components/workflow/types'
import type { CollectionType } from '@/app/components/tools/types'
import type { ResourceVarInputs } from '../_base/types'
import type { CollectionType } from '@/app/components/tools/types'
import type { CommonNodeType } from '@/app/components/workflow/types'
export type PluginTriggerNodeType = CommonNodeType & {
provider_id: string

View File

@ -1,8 +1,8 @@
import { useCallback } from 'react'
import type { PluginTriggerNodeType } from './types'
import { useAllTriggerPlugins } from '@/service/use-triggers'
import { useGetLanguage } from '@/context/i18n'
import { useCallback } from 'react'
import { getTriggerCheckParams } from '@/app/components/workflow/utils/trigger'
import { useGetLanguage } from '@/context/i18n'
import { useAllTriggerPlugins } from '@/service/use-triggers'
type Params = {
id: string

View File

@ -1,20 +1,19 @@
import { useCallback, useEffect, useMemo } from 'react'
import type { PluginTriggerNodeType, PluginTriggerVarInputs } from './types'
import type { Event } from '@/app/components/tools/types'
import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'
import type { InputVar } from '@/app/components/workflow/types'
import { produce } from 'immer'
import type { PluginTriggerNodeType } from './types'
import type { PluginTriggerVarInputs } from './types'
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
import { useNodesReadOnly } from '@/app/components/workflow/hooks'
import {
useAllTriggerPlugins,
useTriggerSubscriptions,
} from '@/service/use-triggers'
import { useCallback, useEffect, useMemo } from 'react'
import {
getConfiguredValue,
toolParametersToFormSchemas,
} from '@/app/components/tools/utils/to-form-schema'
import type { InputVar } from '@/app/components/workflow/types'
import type { TriggerWithProvider } from '@/app/components/workflow/block-selector/types'
import type { Event } from '@/app/components/tools/types'
import { useNodesReadOnly } from '@/app/components/workflow/hooks'
import useNodeCrud from '@/app/components/workflow/nodes/_base/hooks/use-node-crud'
import {
useAllTriggerPlugins,
useTriggerSubscriptions,
} from '@/service/use-triggers'
import { VarKindType } from '../_base/types'
const normalizeEventParameters = (
@ -121,7 +120,8 @@ const useConfig = (id: string, payload: PluginTriggerNodeType) => {
// Dynamic trigger parameters (from specific trigger.parameters)
const triggerSpecificParameterSchema = useMemo(() => {
if (!currentEvent) return []
if (!currentEvent)
return []
return toolParametersToFormSchemas(currentEvent.parameters)
}, [currentEvent])

View File

@ -45,8 +45,8 @@ export const deepSanitizeFormValues = (values: Record<string, any>, visited = ne
*/
export const findMissingRequiredField = (
formData: Record<string, any>,
requiredFields: Array<{ name: string; label: any }>,
): { name: string; label: any } | null => {
requiredFields: Array<{ name: string, label: any }>,
): { name: string, label: any } | null => {
for (const field of requiredFields) {
if (!formData[field.name] || formData[field.name] === '')
return field