Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

add autofix pnpm (#25557)

Asuka Minato77ba3e8f261f
diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml
index be6ce80dfc8..e1b7c8f4e83 100644
--- a/.github/workflows/autofix.yml
+++ b/.github/workflows/autofix.yml
@@ -23,11 +23,37 @@ jobs:
uv run ruff check --fix .
# Format code
uv run ruff format .
+
- name: ast-grep
run: |
uvx --from ast-grep-cli sg --pattern 'db.session.query($WHATEVER).filter($HERE)' --rewrite 'db.session.query($WHATEVER).where($HERE)' -l py --update-all
uvx --from ast-grep-cli sg --pattern 'session.query($WHATEVER).filter($HERE)' --rewrite 'session.query($WHATEVER).where($HERE)' -l py --update-all
+
+
- name: mdformat
run: |
uvx mdformat .
+
+ - name: Install pnpm
+ uses: pnpm/action-setup@v4
+ with:
+ package_json_file: web/package.json
+ run_install: false
+
+ - name: Setup NodeJS
+ uses: actions/setup-node@v4
+ with:
+ node-version: 22
+ cache: pnpm
+ cache-dependency-path: ./web/package.json
+
+ - name: Web dependencies
+ working-directory: ./web
+ run: pnpm install --frozen-lockfile
+
+ - name: oxlint
+ working-directory: ./web
+ run: |
+ pnpx oxlint --fix
+
- uses: autofix-ci/action@635ffb0c9798bd160680f18fd73371e355b85f27
diff --git a/sdks/nodejs-client/index.js b/sdks/nodejs-client/index.js
index 0ba7bba8bb8..3025cc2ab68 100644
--- a/sdks/nodejs-client/index.js
+++ b/sdks/nodejs-client/index.js
@@ -95,10 +95,9 @@ export class DifyClient {
headerParams = {}
) {
const headers = {
- ...{
+
Authorization: `Bearer ${this.apiKey}`,
"Content-Type": "application/json",
- },
...headerParams
};
diff --git a/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout-main.tsx b/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout-main.tsx
index f8189b0c8a5..6d72e957e37 100644
--- a/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout-main.tsx
+++ b/web/app/(commonLayout)/datasets/(datasetDetailLayout)/[datasetId]/layout-main.tsx
@@ -129,7 +129,7 @@ const DatasetDetailLayout: FC<IAppDetailLayoutProps> = (props) => {
params: { datasetId },
} = props
const pathname = usePathname()
- const hideSideBar = /documents\/create$/.test(pathname)
+ const hideSideBar = pathname.endsWith('documents/create')
const { t } = useTranslation()
const { isCurrentWorkspaceDatasetOperator } = useAppContext()
diff --git a/web/app/components/app/configuration/config-vision/index.tsx b/web/app/components/app/configuration/config-vision/index.tsx
index f719822bf9a..f0904b3fd87 100644
--- a/web/app/components/app/configuration/config-vision/index.tsx
+++ b/web/app/components/app/configuration/config-vision/index.tsx
@@ -45,7 +45,7 @@ const ConfigVision: FC = () => {
if (draft.file) {
draft.file.enabled = (draft.file.allowed_file_types?.length ?? 0) > 0
draft.file.image = {
- ...(draft.file.image || {}),
+ ...draft.file.image,
enabled: value,
}
}
diff --git a/web/app/components/base/chat/chat/hooks.ts b/web/app/components/base/chat/chat/hooks.ts
index 17373cec9d6..665e7e8bc3a 100644
--- a/web/app/components/base/chat/chat/hooks.ts
+++ b/web/app/components/base/chat/chat/hooks.ts
@@ -682,7 +682,7 @@ export const useChat = (
updateChatTreeNode(targetAnswerId, {
content: chatList[index].content,
annotation: {
- ...(chatList[index].annotation || {}),
+ ...chatList[index].annotation,
id: '',
} as Annotation,
})
diff --git a/web/app/components/base/features/new-feature-panel/conversation-opener/modal.tsx b/web/app/components/base/features/new-feature-panel/conversation-opener/modal.tsx
index 53db991e71a..ec8681f37c8 100644
--- a/web/app/components/base/features/new-feature-panel/conversation-opener/modal.tsx
+++ b/web/app/components/base/features/new-feature-panel/conversation-opener/modal.tsx
@@ -83,9 +83,7 @@ const OpeningSettingModal = ({
}, [handleSave, hideConfirmAddVar])
const autoAddVar = useCallback(() => {
- onAutoAddPromptVariable?.([
- ...notIncludeKeys.map(key => getNewVar(key, 'string')),
- ])
+ onAutoAddPromptVariable?.(notIncludeKeys.map(key => getNewVar(key, 'string')))
hideConfirmAddVar()
handleSave(true)
}, [handleSave, hideConfirmAddVar, notIncludeKeys, onAutoAddPromptVariable])
diff --git a/web/app/components/base/markdown-blocks/link.tsx b/web/app/components/base/markdown-blocks/link.tsx
index 0274ee0141f..9bf13040a7f 100644
--- a/web/app/components/base/markdown-blocks/link.tsx
+++ b/web/app/components/base/markdown-blocks/link.tsx
@@ -17,7 +17,7 @@ const Link = ({ node, children, ...props }: any) => {
}
else {
const href = props.href || node.properties?.href
- if (href && /^#[a-zA-Z0-9_\-]+$/.test(href.toString())) {
+ if (href && /^#[a-zA-Z0-9_-]+$/.test(href.toString())) {
const handleClick = (e: React.MouseEvent<HTMLAnchorElement>) => {
e.preventDefault()
// scroll to target element if exists within the answer container
diff --git a/web/app/components/base/notion-page-selector/page-selector/index.tsx b/web/app/components/base/notion-page-selector/page-selector/index.tsx
index 498955994c6..a1ce3116db5 100644
--- a/web/app/components/base/notion-page-selector/page-selector/index.tsx
+++ b/web/app/components/base/notion-page-selector/page-selector/index.tsx
@@ -229,7 +229,7 @@ const PageSelector = ({
if (current.expand) {
current.expand = false
- newDataList = [...dataList.filter(item => !descendantsIds.includes(item.page_id))]
+ newDataList = dataList.filter(item => !descendantsIds.includes(item.page_id))
}
else {
current.expand = true
@@ -246,7 +246,7 @@ const PageSelector = ({
setDataList(newDataList)
}
- const copyValue = new Set([...value])
+ const copyValue = new Set(value)
const handleCheck = (index: number) => {
const current = currentDataList[index]
const pageId = current.page_id
@@ -269,7 +269,7 @@ const PageSelector = ({
copyValue.add(pageId)
}
- onSelect(new Set([...copyValue]))
+ onSelect(new Set(copyValue))
}
const handlePreview = (index: number) => {
diff --git a/web/app/components/base/portal-to-follow-elem/index.tsx b/web/app/components/base/portal-to-follow-elem/index.tsx
index dd4795c5287..bdf457b38f4 100644
--- a/web/app/components/base/portal-to-follow-elem/index.tsx
+++ b/web/app/components/base/portal-to-follow-elem/index.tsx
@@ -142,7 +142,7 @@ export const PortalToFollowElemTrigger = (
context.getReferenceProps({
ref,
...props,
- ...(children.props || {}),
+ ...children.props,
'data-state': context.open ? 'open' : 'closed',
} as React.HTMLProps<HTMLElement>),
)
diff --git a/web/app/components/datasets/documents/detail/completed/skeleton/full-doc-list-skeleton.tsx b/web/app/components/datasets/documents/detail/completed/skeleton/full-doc-list-skeleton.tsx
index cc7daa534c0..9697e05ee81 100644
--- a/web/app/components/datasets/documents/detail/completed/skeleton/full-doc-list-skeleton.tsx
+++ b/web/app/components/datasets/documents/detail/completed/skeleton/full-doc-list-skeleton.tsx
@@ -17,7 +17,7 @@ const FullDocListSkeleton = () => {
return (
<div className='relative z-10 flex w-full grow flex-col gap-y-3 overflow-y-hidden'>
<div className='absolute bottom-14 left-0 top-0 z-20 h-full w-full bg-dataset-chunk-list-mask-bg' />
- {[...Array.from({ length: 15 })].map((_, index) => <Slice key={index} />)}
+ {Array.from({ length: 15 }).map((_, index) => <Slice key={index} />)}
</div>
)
}
diff --git a/web/app/components/datasets/documents/detail/completed/skeleton/general-list-skeleton.tsx b/web/app/components/datasets/documents/detail/completed/skeleton/general-list-skeleton.tsx
index bf22a532e71..12256b05bce 100644
--- a/web/app/components/datasets/documents/detail/completed/skeleton/general-list-skeleton.tsx
+++ b/web/app/components/datasets/documents/detail/completed/skeleton/general-list-skeleton.tsx
@@ -50,7 +50,7 @@ const GeneralListSkeleton = () => {
return (
<div className='relative z-10 flex grow flex-col overflow-y-hidden'>
<div className='absolute left-0 top-0 z-20 h-full w-full bg-dataset-chunk-list-mask-bg' />
- {[...Array.from({ length: 10 })].map((_, index) => {
+ {Array.from({ length: 10 }).map((_, index) => {
return (
<div key={index} className='flex items-start gap-x-2'>
<Checkbox
diff --git a/web/app/components/datasets/documents/detail/completed/skeleton/paragraph-list-skeleton.tsx b/web/app/components/datasets/documents/detail/completed/skeleton/paragraph-list-skeleton.tsx
index eb01feb9e7b..ee4d1a1d871 100644
--- a/web/app/components/datasets/documents/detail/completed/skeleton/paragraph-list-skeleton.tsx
+++ b/web/app/components/datasets/documents/detail/completed/skeleton/paragraph-list-skeleton.tsx
@@ -52,7 +52,7 @@ const ParagraphListSkeleton = () => {
return (
<div className='relative z-10 flex h-full flex-col overflow-y-hidden'>
<div className='absolute left-0 top-0 z-20 h-full w-full bg-dataset-chunk-list-mask-bg' />
- {[...Array.from({ length: 10 })].map((_, index) => {
+ {Array.from({ length: 10 }).map((_, index) => {
return (
<div key={index} className='flex items-start gap-x-2'>
<Checkbox
diff --git a/web/app/components/datasets/documents/detail/embedding/skeleton/index.tsx b/web/app/components/datasets/documents/detail/embedding/skeleton/index.tsx
index 523af54d863..4d92aaf9499 100644
--- a/web/app/components/datasets/documents/detail/embedding/skeleton/index.tsx
+++ b/web/app/components/datasets/documents/detail/embedding/skeleton/index.tsx
@@ -49,7 +49,7 @@ const EmbeddingSkeleton = () => {
return (
<div className='relative z-10 flex grow flex-col overflow-y-hidden'>
<div className='absolute left-0 top-0 z-20 h-full w-full bg-dataset-chunk-list-mask-bg' />
- {[...Array.from({ length: 5 })].map((_, index) => {
+ {Array.from({ length: 5 }).map((_, index) => {
return (
<div key={index} className='w-full px-11'>
<CardSkelton />
diff --git a/web/app/components/datasets/documents/detail/metadata/index.tsx b/web/app/components/datasets/documents/detail/metadata/index.tsx
index da269fc54db..c07192ea7d1 100644
--- a/web/app/components/datasets/documents/detail/metadata/index.tsx
+++ b/web/app/components/datasets/documents/detail/metadata/index.tsx
@@ -285,7 +285,7 @@ const Metadata: FC<IMetadataProps> = ({ docDetail, loading, onUpdate }) => {
}
const onCancel = () => {
- setMetadataParams({ documentType: doc_type || '', metadata: { ...(docDetail?.doc_metadata || {}) } })
+ setMetadataParams({ documentType: doc_type || '', metadata: { ...docDetail?.doc_metadata } })
setEditStatus(!doc_type)
if (!doc_type)
setShowDocTypes(true)
diff --git a/web/app/components/header/account-setting/model-provider-page/hooks.ts b/web/app/components/header/account-setting/model-provider-page/hooks.ts
index c9e4f9961e1..b10aeeb47eb 100644
--- a/web/app/components/header/account-setting/model-provider-page/hooks.ts
+++ b/web/app/components/header/account-setting/model-provider-page/hooks.ts
@@ -299,7 +299,7 @@ export const useMarketplaceAllPlugins = (providers: ModelProvider[], searchText:
}, [queryPlugins, queryPluginsWithDebounced, searchText, exclude])
const allPlugins = useMemo(() => {
- const allPlugins = [...collectionPlugins.filter(plugin => !exclude.includes(plugin.plugin_id))]
+ const allPlugins = collectionPlugins.filter(plugin => !exclude.includes(plugin.plugin_id))
if (plugins?.length) {
for (let i = 0; i < plugins.length; i++) {
diff --git a/web/app/components/plugins/install-plugin/utils.ts b/web/app/components/plugins/install-plugin/utils.ts
index 43df1050264..f19a7fd2871 100644
--- a/web/app/components/plugins/install-plugin/utils.ts
+++ b/web/app/components/plugins/install-plugin/utils.ts
@@ -53,7 +53,7 @@ export const pluginManifestInMarketToPluginProps = (pluginManifest: PluginManife
}
export const parseGitHubUrl = (url: string): GitHubUrlInfo => {
- const match = url.match(/^https:\/\/github\.com\/([^\/]+)\/([^\/]+)\/?$/)
+ const match = url.match(/^https:\/\/github\.com\/([^/]+)\/([^/]+)\/?$/)
return match ? { isValid: true, owner: match[1], repo: match[2] } : { isValid: false }
}
diff --git a/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx b/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx
index e03cb8565ca..cf400d3c3a6 100644
--- a/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx
+++ b/web/app/components/plugins/plugin-detail-panel/model-selector/index.tsx
@@ -165,7 +165,7 @@ const ModelParameterModal: FC<ModelParameterModalProps> = ({
const handleLLMParamsChange = (newParams: FormValue) => {
const newValue = {
- ...(value?.completionParams || {}),
+ ...value?.completionParams,
completion_params: newParams,
}
setModel({
diff --git a/web/app/components/tools/mcp/modal.tsx b/web/app/components/tools/mcp/modal.tsx
index bf395cf1cb1..211d594caf6 100644
--- a/web/app/components/tools/mcp/modal.tsx
+++ b/web/app/components/tools/mcp/modal.tsx
@@ -102,7 +102,7 @@ const MCPModal = ({
const isValidUrl = (string: string) => {
try {
- const urlPattern = /^(https?:\/\/)((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d{1,3}\.){3}\d{1,3})|localhost)(\:\d+)?(\/[-a-z\d%_.~+]*)*(\?[;&a-z\d%_.~+=-]*)?/i
+ const urlPattern = /^(https?:\/\/)((([a-z\d]([a-z\d-]*[a-z\d])*)\.)+[a-z]{2,}|((\d{1,3}\.){3}\d{1,3})|localhost)(:\d+)?(\/[-a-z\d%_.~+]*)*(\?[;&a-z\d%_.~+=-]*)?/i
return urlPattern.test(string)
}
catch {
diff --git a/web/app/components/workflow/hooks/use-nodes-interactions.ts b/web/app/components/workflow/hooks/use-nodes-interactions.ts
index 60549c870e1..625a6a61864 100644
--- a/web/app/components/workflow/hooks/use-nodes-interactions.ts
+++ b/web/app/components/workflow/hooks/use-nodes-interactions.ts
@@ -699,7 +699,7 @@ export const useNodesInteractions = () => {
data: {
...NODES_INITIAL_DATA[nodeType],
title: nodesWithSameType.length > 0 ? `${t(`workflow.blocks.${nodeType}`)} ${nodesWithSameType.length + 1}` : t(`workflow.blocks.${nodeType}`),
- ...(toolDefaultValue || {}),
+ ...toolDefaultValue,
selected: true,
_showAddVariablePopup: (nodeType === BlockEnum.VariableAssigner || nodeType === BlockEnum.VariableAggregator) && !!prevNodeId,
_holdAddVariablePopup: false,
@@ -1131,7 +1131,7 @@ export const useNodesInteractions = () => {
data: {
...NODES_INITIAL_DATA[nodeType],
title: nodesWithSameType.length > 0 ? `${t(`workflow.blocks.${nodeType}`)} ${nodesWithSameType.length + 1}` : t(`workflow.blocks.${nodeType}`),
- ...(toolDefaultValue || {}),
+ ...toolDefaultValue,
_connectedSourceHandleIds: [],
_connectedTargetHandleIds: [],
selected: currentNode.data.selected,
@@ -1149,9 +1149,7 @@ export const useNodesInteractions = () => {
zIndex: currentNode.zIndex,
})
const nodesConnectedSourceOrTargetHandleIdsMap = getNodesConnectedSourceOrTargetHandleIdsMap(
- [
- ...connectedEdges.map(edge => ({ type: 'remove', edge })),
- ],
+ connectedEdges.map(edge => ({ type: 'remove', edge })),
nodes,
)
const newNodes = produce(nodes, (draft) => {
diff --git a/web/app/components/workflow/nodes/http/components/key-value/key-value-edit/input-item.tsx b/web/app/components/workflow/nodes/http/components/key-value/key-value-edit/input-item.tsx
index 79171df68b3..72e4d781fec 100644
--- a/web/app/components/workflow/nodes/http/components/key-value/key-value-edit/input-item.tsx
+++ b/web/app/components/workflow/nodes/http/components/key-value/key-value-edit/input-item.tsx
@@ -45,7 +45,7 @@ const InputItem: FC<Props> = ({
filterVar: (varPayload: Var) => {
const supportVarTypes = [VarType.string, VarType.number, VarType.secret]
if (isSupportFile)
- supportVarTypes.push(...[VarType.file, VarType.arrayFile])
+ supportVarTypes.push(VarType.file, VarType.arrayFile)
return supportVarTypes.includes(varPayload.type)
},
diff --git a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/hooks.ts b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/hooks.ts
index d11ad92241d..8256a3c8622 100644
--- a/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/hooks.ts
+++ b/web/app/components/workflow/nodes/llm/components/json-schema-config-modal/visual-editor/hooks.ts
@@ -229,7 +229,7 @@ export const useSchemaNodeOperations = (props: VisualEditorProps) => {
const schema = findPropertyWithPath(draft, path) as Field
if (schema.type === Type.object) {
schema.properties = {
- ...(schema.properties || {}),
+ ...schema.properties,
'': {
type: Type.string,
},
@@ -238,7 +238,7 @@ export const useSchemaNodeOperations = (props: VisualEditorProps) => {
}
if (schema.type === Type.array && schema.items && schema.items.type === Type.object) {
schema.items.properties = {
- ...(schema.items.properties || {}),
+ ...schema.items.properties,
'': {
type: Type.string,
},
diff --git a/web/app/components/workflow/operator/add-block.tsx b/web/app/components/workflow/operator/add-block.tsx
index 5bc541a45ab..6e196de887f 100644
--- a/web/app/components/workflow/operator/add-block.tsx
+++ b/web/app/components/workflow/operator/add-block.tsx
@@ -61,7 +61,7 @@ const AddBlock = ({
data: {
...NODES_INITIAL_DATA[type],
title: nodesWithSameType.length > 0 ? `${t(`workflow.blocks.${type}`)} ${nodesWithSameType.length + 1}` : t(`workflow.blocks.${type}`),
- ...(toolDefaultValue || {}),
+ ...toolDefaultValue,
_isCandidate: true,
},
position: {
diff --git a/web/service/share.ts b/web/service/share.ts
index 8c33b85522a..f1e512564b4 100644
--- a/web/service/share.ts
+++ b/web/service/share.ts
@@ -149,7 +149,7 @@ export const fetchAppInfo = async () => {
}
export const fetchConversations = async (isInstalledApp: boolean, installedAppId = '', last_id?: string, pinned?: boolean, limit?: number) => {
- return getAction('get', isInstalledApp)(getUrl('conversations', isInstalledApp, installedAppId), { params: { ...{ limit: limit || 20 }, ...(last_id ? { last_id } : {}), ...(pinned !== undefined ? { pinned } : {}) } }) as Promise<AppConversationData>
+ return getAction('get', isInstalledApp)(getUrl('conversations', isInstalledApp, installedAppId), { params: { limit: limit || 20, ...(last_id ? { last_id } : {}), ...(pinned !== undefined ? { pinned } : {}) } }) as Promise<AppConversationData>
}
export const pinConversation = async (isInstalledApp: boolean, installedAppId = '', id: string) => {
diff --git a/web/utils/model-config.ts b/web/utils/model-config.ts
index b76eabfc27d..c940a6969f9 100644
--- a/web/utils/model-config.ts
+++ b/web/utils/model-config.ts
@@ -187,7 +187,7 @@ export const promptVariablesToUserInputsForm = (promptVariables: PromptVariable[
export const formatBooleanInputs = (useInputs?: PromptVariable[] | null, inputs?: Record<string, string | number | object | boolean> | null) => {
if(!useInputs)
return inputs
- const res = { ...(inputs || {}) }
+ const res = { ...inputs }
useInputs.forEach((item) => {
const isBooleanInput = item.type === 'boolean'
if (isBooleanInput) {