dify/packages/contracts/scripts/knowledge-fs-contract-utils.mjs
Stephen Zhou bd8f0104d6
feat(dataset): expose New RAG KnowledgeFS contracts (#39314)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-07-23 01:48:36 +00:00

20 lines
730 B
JavaScript

export function getStreamingOperationIds(document) {
return Object.values(document.paths ?? {})
.flatMap((pathItem) =>
Object.values(pathItem).flatMap((operation) => {
if (typeof operation !== 'object' || operation === null) return []
const isEventStream = Object.entries(operation.responses ?? {}).some(
([status, response]) =>
(status === '2XX' || /^2\d\d$/.test(status)) &&
typeof response === 'object' &&
response !== null &&
'text/event-stream' in (response.content ?? {}),
)
return isEventStream && typeof operation.operationId === 'string'
? [operation.operationId]
: []
}),
)
.sort()
}