mirror of
https://github.com/langgenius/dify.git
synced 2026-10-04 13:47:55 +08:00
style: format with vp fmt (#38803)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
1 parent
fde08d24fe
commit
a84c2d36a3
6213 files changed
+227959
-187183
No files matched your search
@@ -1,6 +1,13 @@
|
||||
import type { AppDescribeResponse } from '@dify/contracts/api/openapi/types.gen'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { covers, FieldInfo, FieldInputSchema, FieldParameters, fromDescribe, mergeMeta } from './app-meta'
|
||||
import {
|
||||
covers,
|
||||
FieldInfo,
|
||||
FieldInputSchema,
|
||||
FieldParameters,
|
||||
fromDescribe,
|
||||
mergeMeta,
|
||||
} from './app-meta'
|
||||
|
||||
function describeResp(): AppDescribeResponse {
|
||||
return {
|
||||
|
||||
+12
-10
@@ -18,14 +18,16 @@ export type AppMetaCacheRecord = {
|
||||
fetchedAt: string
|
||||
}
|
||||
|
||||
export function fromDescribe(resp: AppDescribeResponse, requested: readonly AppMetaFieldKey[]): AppMeta {
|
||||
export function fromDescribe(
|
||||
resp: AppDescribeResponse,
|
||||
requested: readonly AppMetaFieldKey[],
|
||||
): AppMeta {
|
||||
const covered = new Set<AppMetaFieldKey>()
|
||||
if (requested.length === 0) {
|
||||
covered.add(FieldInfo)
|
||||
covered.add(FieldParameters)
|
||||
covered.add(FieldInputSchema)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
for (const f of requested) covered.add(f)
|
||||
}
|
||||
return {
|
||||
@@ -37,8 +39,7 @@ export function fromDescribe(resp: AppDescribeResponse, requested: readonly AppM
|
||||
}
|
||||
|
||||
export function mergeMeta(prev: AppMeta | undefined, next: AppMeta): AppMeta {
|
||||
if (prev === undefined)
|
||||
return next
|
||||
if (prev === undefined) return next
|
||||
const merged = new Set<AppMetaFieldKey>(prev.coveredFields)
|
||||
for (const f of next.coveredFields) merged.add(f)
|
||||
return {
|
||||
@@ -51,13 +52,14 @@ export function mergeMeta(prev: AppMeta | undefined, next: AppMeta): AppMeta {
|
||||
|
||||
export function covers(meta: AppMeta, fields: readonly AppMetaFieldKey[]): boolean {
|
||||
if (fields.length === 0) {
|
||||
return meta.coveredFields.has(FieldInfo)
|
||||
&& meta.coveredFields.has(FieldParameters)
|
||||
&& meta.coveredFields.has(FieldInputSchema)
|
||||
return (
|
||||
meta.coveredFields.has(FieldInfo) &&
|
||||
meta.coveredFields.has(FieldParameters) &&
|
||||
meta.coveredFields.has(FieldInputSchema)
|
||||
)
|
||||
}
|
||||
for (const f of fields) {
|
||||
if (!meta.coveredFields.has(f))
|
||||
return false
|
||||
if (!meta.coveredFields.has(f)) return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
Reference in new issue
Block a user