Files
gsfdc/demo-dify/dify/web/service/human-input-v2.ts
T
wuzilongandCursor 6519682885 chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-18 13:59:25 +08:00

33 lines
1.3 KiB
TypeScript

import type { ContractRouterClient } from '@orpc/contract'
import type { JsonifiedClient } from '@orpc/openapi-client'
import {
humanInput2,
public_ as publicHumanInputV2Contract,
} from '@dify/contracts/api/web/orpc.gen'
import { createORPCClient } from '@orpc/client'
import { OpenAPILink } from '@orpc/openapi-client/fetch'
import { PUBLIC_API_PREFIX } from '@/config'
const humanInputV2FormContract = {
getForm: publicHumanInputV2Contract.byFormToken.get,
requestAccess: publicHumanInputV2Contract.byFormToken.accessRequest.post,
requestUploadToken: publicHumanInputV2Contract.byFormToken.uploadToken.post,
submit: publicHumanInputV2Contract.byFormToken.post,
uploadFile: humanInput2.v2.files.post,
uploadRemoteFile: humanInput2.v2.files.remote.post,
}
export const humanInputV2FormClient: JsonifiedClient<
ContractRouterClient<typeof humanInputV2FormContract>
> = createORPCClient(
new OpenAPILink(humanInputV2FormContract, {
url: () => new URL(PUBLIC_API_PREFIX, window.location.origin),
fetch: (request, init) =>
// oxlint-disable-next-line no-restricted-properties -- Public token-authenticated form contracts must omit Console cookies and bypass its session recovery transport.
globalThis.fetch(request, {
...init,
credentials: 'omit',
cache: 'no-store',
}),
}),
)