chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
60158935f4
commit
6519682885
15831 files changed
+3063428
No files matched your search
@@ -0,0 +1,89 @@
|
||||
// This file is auto-generated by scripts/add-orpc-error-maps.ts
|
||||
import * as z from 'zod'
|
||||
|
||||
const zErrorResponse = /* @__PURE__ */ (() =>
|
||||
z.object({
|
||||
code: z.string(),
|
||||
details: z.record(z.string(), z.unknown()).optional(),
|
||||
message: z.string(),
|
||||
params: z.string().optional(),
|
||||
status: z.int(),
|
||||
}))()
|
||||
|
||||
const zAlreadySubmittedError = /* @__PURE__ */ (() =>
|
||||
zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('already_submitted'),
|
||||
status: z.literal(409),
|
||||
}),
|
||||
))()
|
||||
|
||||
const zExpiredError = /* @__PURE__ */ (() =>
|
||||
zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('expired'),
|
||||
status: z.literal(410),
|
||||
}),
|
||||
))()
|
||||
|
||||
const zInvalidInputError = /* @__PURE__ */ (() =>
|
||||
zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('invalid_input'),
|
||||
status: z.literal(400),
|
||||
}),
|
||||
))()
|
||||
|
||||
const zWorkflowNotActiveError = /* @__PURE__ */ (() =>
|
||||
zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('workflow_not_active'),
|
||||
status: z.literal(409),
|
||||
}),
|
||||
))()
|
||||
|
||||
const zHumanInputFormSubmittedError = /* @__PURE__ */ (() =>
|
||||
zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('human_input_form_submitted'),
|
||||
status: z.literal(412),
|
||||
}),
|
||||
))()
|
||||
|
||||
const zInvalidFormDataError = /* @__PURE__ */ (() =>
|
||||
zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('invalid_form_data'),
|
||||
status: z.literal(400),
|
||||
}),
|
||||
))()
|
||||
|
||||
const zHumanInputFormExpiredError = /* @__PURE__ */ (() =>
|
||||
zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('human_input_form_expired'),
|
||||
status: z.literal(412),
|
||||
}),
|
||||
))()
|
||||
|
||||
export const getErrors = {
|
||||
already_submitted: { status: 409, data: zAlreadySubmittedError },
|
||||
expired: { status: 410, data: zExpiredError },
|
||||
}
|
||||
|
||||
export const postErrors = {
|
||||
already_submitted: { status: 409, data: zAlreadySubmittedError },
|
||||
expired: { status: 410, data: zExpiredError },
|
||||
invalid_input: { status: 400, data: zInvalidInputError },
|
||||
workflow_not_active: { status: 409, data: zWorkflowNotActiveError },
|
||||
}
|
||||
|
||||
export const get2Errors = {
|
||||
human_input_form_submitted: { status: 412, data: zHumanInputFormSubmittedError },
|
||||
}
|
||||
|
||||
export const post2Errors = {
|
||||
human_input_form_expired: { status: 412, data: zHumanInputFormExpiredError },
|
||||
human_input_form_submitted: { status: 412, data: zHumanInputFormSubmittedError },
|
||||
invalid_form_data: { status: 400, data: zInvalidFormDataError },
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import { oc } from '@orpc/contract'
|
||||
import * as z from 'zod'
|
||||
import {
|
||||
zAlreadySubmittedError,
|
||||
zExpiredError,
|
||||
zHumanInputFormExpiredError,
|
||||
zHumanInputFormSubmittedError,
|
||||
zInvalidFormDataError,
|
||||
zInvalidInputError,
|
||||
zWorkflowNotActiveError,
|
||||
} from './zod.gen.ts'
|
||||
import {
|
||||
zGetFormHumanInputByFormTokenPath,
|
||||
zGetFormHumanInputByFormTokenResponse,
|
||||
zGetFormHumanInputV2ByFormTokenPath,
|
||||
zGetFormHumanInputV2ByFormTokenResponse,
|
||||
zPostFormHumanInputByFormTokenBody,
|
||||
zPostFormHumanInputByFormTokenPath,
|
||||
zPostFormHumanInputByFormTokenResponse,
|
||||
zPostFormHumanInputV2ByFormTokenBody,
|
||||
zPostFormHumanInputV2ByFormTokenPath,
|
||||
zPostFormHumanInputV2ByFormTokenResponse,
|
||||
} from './zod.gen.ts'
|
||||
|
||||
/**
|
||||
* Read a frozen v2 form using the current Account's Contact authorization.
|
||||
*/
|
||||
export const get = oc
|
||||
.route({
|
||||
description: "Read a frozen v2 form using the current Account's Contact authorization.",
|
||||
inputStructure: 'detailed',
|
||||
method: 'GET',
|
||||
operationId: 'getFormHumanInputV2ByFormToken',
|
||||
path: '/form/human-input/v2/{form_token}',
|
||||
tags: ['console'],
|
||||
})
|
||||
.input(z.object({ params: zGetFormHumanInputV2ByFormTokenPath }))
|
||||
.output(zGetFormHumanInputV2ByFormTokenResponse)
|
||||
.errors({
|
||||
already_submitted: { status: 409, data: zAlreadySubmittedError },
|
||||
expired: { status: 410, data: zExpiredError },
|
||||
})
|
||||
|
||||
export const post = oc
|
||||
.route({
|
||||
inputStructure: 'detailed',
|
||||
method: 'POST',
|
||||
operationId: 'postFormHumanInputV2ByFormToken',
|
||||
path: '/form/human-input/v2/{form_token}',
|
||||
tags: ['console'],
|
||||
})
|
||||
.input(
|
||||
z.object({
|
||||
body: zPostFormHumanInputV2ByFormTokenBody,
|
||||
params: zPostFormHumanInputV2ByFormTokenPath,
|
||||
}),
|
||||
)
|
||||
.output(zPostFormHumanInputV2ByFormTokenResponse)
|
||||
.errors({
|
||||
already_submitted: { status: 409, data: zAlreadySubmittedError },
|
||||
expired: { status: 410, data: zExpiredError },
|
||||
invalid_input: { status: 400, data: zInvalidInputError },
|
||||
workflow_not_active: { status: 409, data: zWorkflowNotActiveError },
|
||||
})
|
||||
|
||||
export const byFormToken = {
|
||||
get,
|
||||
post,
|
||||
}
|
||||
|
||||
export const v2 = {
|
||||
byFormToken,
|
||||
}
|
||||
|
||||
/**
|
||||
* Get human input form definition by form token
|
||||
*
|
||||
* GET /console/api/form/human_input/<form_token>
|
||||
*/
|
||||
export const get2 = oc
|
||||
.route({
|
||||
description: 'GET /console/api/form/human_input/<form_token>',
|
||||
inputStructure: 'detailed',
|
||||
method: 'GET',
|
||||
operationId: 'getFormHumanInputByFormToken',
|
||||
path: '/form/human_input/{form_token}',
|
||||
summary: 'Get human input form definition by form token',
|
||||
tags: ['console'],
|
||||
})
|
||||
.input(z.object({ params: zGetFormHumanInputByFormTokenPath }))
|
||||
.output(zGetFormHumanInputByFormTokenResponse)
|
||||
.errors({ human_input_form_submitted: { status: 412, data: zHumanInputFormSubmittedError } })
|
||||
|
||||
/**
|
||||
* Submit human input form by form token
|
||||
*
|
||||
* POST /console/api/form/human_input/<form_token>
|
||||
*
|
||||
* Request body:
|
||||
* {
|
||||
* "inputs": {
|
||||
* "content": "User input content"
|
||||
* },
|
||||
* "action": "Approve"
|
||||
* }
|
||||
*/
|
||||
export const post2 = oc
|
||||
.route({
|
||||
description:
|
||||
'POST /console/api/form/human_input/<form_token>\n\nRequest body:\n{\n "inputs": {\n "content": "User input content"\n },\n "action": "Approve"\n}',
|
||||
inputStructure: 'detailed',
|
||||
method: 'POST',
|
||||
operationId: 'postFormHumanInputByFormToken',
|
||||
path: '/form/human_input/{form_token}',
|
||||
summary: 'Submit human input form by form token',
|
||||
tags: ['console'],
|
||||
})
|
||||
.input(
|
||||
z.object({
|
||||
body: zPostFormHumanInputByFormTokenBody,
|
||||
params: zPostFormHumanInputByFormTokenPath,
|
||||
}),
|
||||
)
|
||||
.output(zPostFormHumanInputByFormTokenResponse)
|
||||
.errors({
|
||||
human_input_form_expired: { status: 412, data: zHumanInputFormExpiredError },
|
||||
human_input_form_submitted: { status: 412, data: zHumanInputFormSubmittedError },
|
||||
invalid_form_data: { status: 400, data: zInvalidFormDataError },
|
||||
})
|
||||
|
||||
export const byFormToken2 = {
|
||||
get: get2,
|
||||
post: post2,
|
||||
}
|
||||
|
||||
export const humanInput = {
|
||||
v2,
|
||||
byFormToken: byFormToken2,
|
||||
}
|
||||
|
||||
export const form = {
|
||||
humanInput,
|
||||
}
|
||||
|
||||
export const contract = {
|
||||
form,
|
||||
}
|
||||
@@ -0,0 +1,256 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
export type ClientOptions = {
|
||||
baseUrl: `${string}://${string}/console/api` | (string & {})
|
||||
}
|
||||
|
||||
export type ConsoleHumanInputV2FormDefinitionResponse = {
|
||||
expiration_time: number
|
||||
resolved_form: ResolvedForm
|
||||
}
|
||||
|
||||
export type ErrorResponse = {
|
||||
code: string
|
||||
details?: {
|
||||
[key: string]: unknown
|
||||
}
|
||||
message: string
|
||||
params?: string
|
||||
status: number
|
||||
}
|
||||
|
||||
export type AlreadySubmittedError = ErrorResponse & {
|
||||
code: 'already_submitted'
|
||||
status: 409
|
||||
}
|
||||
|
||||
export type ExpiredError = ErrorResponse & {
|
||||
code: 'expired'
|
||||
status: 410
|
||||
}
|
||||
|
||||
export type ConsoleHumanInputV2SubmitPayload = {
|
||||
action: string
|
||||
inputs: {
|
||||
[key: string]: JsonValue
|
||||
}
|
||||
}
|
||||
|
||||
export type ConsoleHumanInputV2SubmitResponse = {
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type InvalidInputError = ErrorResponse & {
|
||||
code: 'invalid_input'
|
||||
status: 400
|
||||
}
|
||||
|
||||
export type WorkflowNotActiveError = ErrorResponse & {
|
||||
code: 'workflow_not_active'
|
||||
status: 409
|
||||
}
|
||||
|
||||
export type ConsoleHumanInputFormDefinitionResponse = {
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type HumanInputFormSubmittedError = ErrorResponse & {
|
||||
code: 'human_input_form_submitted'
|
||||
status: 412
|
||||
}
|
||||
|
||||
export type HumanInputFormSubmitPayload = {
|
||||
action: string
|
||||
inputs: {
|
||||
[key: string]: JsonValue
|
||||
}
|
||||
}
|
||||
|
||||
export type ConsoleHumanInputFormSubmitResponse = {
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
export type InvalidFormDataError = ErrorResponse & {
|
||||
code: 'invalid_form_data'
|
||||
status: 400
|
||||
}
|
||||
|
||||
export type HumanInputFormExpiredError = ErrorResponse & {
|
||||
code: 'human_input_form_expired'
|
||||
status: 412
|
||||
}
|
||||
|
||||
export type ResolvedForm = {
|
||||
actions: Array<UserAction>
|
||||
legacy_form_content: string
|
||||
parts: Array<FormPart>
|
||||
title: string
|
||||
}
|
||||
|
||||
export type JsonValue = unknown
|
||||
|
||||
export type UserAction = {
|
||||
button_style: ButtonStyle
|
||||
id: string
|
||||
title: string
|
||||
}
|
||||
|
||||
export type FormPart =
|
||||
| ({
|
||||
type: 'markdown_fragment'
|
||||
} & MarkdownFragment)
|
||||
| ({
|
||||
type: 'paragraph_input'
|
||||
} & ParagraphInput)
|
||||
| ({
|
||||
type: 'select_input'
|
||||
} & SelectInput)
|
||||
| ({
|
||||
type: 'file_input'
|
||||
} & FileInput)
|
||||
| ({
|
||||
type: 'file_list_input'
|
||||
} & FileListInput)
|
||||
|
||||
export type ButtonStyle = 'accent' | 'default' | 'ghost' | 'primary'
|
||||
|
||||
export type MarkdownFragment = {
|
||||
text: string
|
||||
type?: 'markdown_fragment'
|
||||
}
|
||||
|
||||
export type ParagraphInput = {
|
||||
default_value: string | null
|
||||
output_variable_name: string
|
||||
type?: 'paragraph_input'
|
||||
}
|
||||
|
||||
export type SelectInput = {
|
||||
default_value: string | null
|
||||
options: Array<string>
|
||||
output_variable_name: string
|
||||
type?: 'select_input'
|
||||
}
|
||||
|
||||
export type FileInput = {
|
||||
allowed_file_extensions: Array<string>
|
||||
allowed_file_types: Array<FileType>
|
||||
allowed_file_upload_methods: Array<FileTransferMethod>
|
||||
output_variable_name: string
|
||||
type?: 'file_input'
|
||||
}
|
||||
|
||||
export type FileListInput = {
|
||||
allowed_file_extensions: Array<string>
|
||||
allowed_file_types: Array<FileType>
|
||||
allowed_file_upload_methods: Array<FileTransferMethod>
|
||||
number_limits: number
|
||||
output_variable_name: string
|
||||
type?: 'file_list_input'
|
||||
}
|
||||
|
||||
export type FileType = 'audio' | 'custom' | 'document' | 'image' | 'video'
|
||||
|
||||
export type FileTransferMethod = 'datasource_file' | 'local_file' | 'remote_url' | 'tool_file'
|
||||
|
||||
export type GetFormHumanInputV2ByFormTokenData = {
|
||||
body?: never
|
||||
path: {
|
||||
form_token: string
|
||||
}
|
||||
query?: never
|
||||
url: '/form/human-input/v2/{form_token}'
|
||||
}
|
||||
|
||||
export type GetFormHumanInputV2ByFormTokenErrors = {
|
||||
401: ErrorResponse
|
||||
404: ErrorResponse
|
||||
409: AlreadySubmittedError | ErrorResponse
|
||||
410: ExpiredError | ErrorResponse
|
||||
default: ErrorResponse
|
||||
}
|
||||
|
||||
export type GetFormHumanInputV2ByFormTokenError =
|
||||
GetFormHumanInputV2ByFormTokenErrors[keyof GetFormHumanInputV2ByFormTokenErrors]
|
||||
|
||||
export type GetFormHumanInputV2ByFormTokenResponses = {
|
||||
200: ConsoleHumanInputV2FormDefinitionResponse
|
||||
}
|
||||
|
||||
export type GetFormHumanInputV2ByFormTokenResponse =
|
||||
GetFormHumanInputV2ByFormTokenResponses[keyof GetFormHumanInputV2ByFormTokenResponses]
|
||||
|
||||
export type PostFormHumanInputV2ByFormTokenData = {
|
||||
body: ConsoleHumanInputV2SubmitPayload
|
||||
path: {
|
||||
form_token: string
|
||||
}
|
||||
query?: never
|
||||
url: '/form/human-input/v2/{form_token}'
|
||||
}
|
||||
|
||||
export type PostFormHumanInputV2ByFormTokenErrors = {
|
||||
400: InvalidInputError | ErrorResponse
|
||||
409: AlreadySubmittedError | WorkflowNotActiveError | ErrorResponse
|
||||
410: ExpiredError | ErrorResponse
|
||||
default: ErrorResponse
|
||||
}
|
||||
|
||||
export type PostFormHumanInputV2ByFormTokenError =
|
||||
PostFormHumanInputV2ByFormTokenErrors[keyof PostFormHumanInputV2ByFormTokenErrors]
|
||||
|
||||
export type PostFormHumanInputV2ByFormTokenResponses = {
|
||||
200: ConsoleHumanInputV2SubmitResponse
|
||||
}
|
||||
|
||||
export type PostFormHumanInputV2ByFormTokenResponse =
|
||||
PostFormHumanInputV2ByFormTokenResponses[keyof PostFormHumanInputV2ByFormTokenResponses]
|
||||
|
||||
export type GetFormHumanInputByFormTokenData = {
|
||||
body?: never
|
||||
path: {
|
||||
form_token: string
|
||||
}
|
||||
query?: never
|
||||
url: '/form/human_input/{form_token}'
|
||||
}
|
||||
|
||||
export type GetFormHumanInputByFormTokenErrors = {
|
||||
412: HumanInputFormSubmittedError | ErrorResponse
|
||||
default: ErrorResponse
|
||||
}
|
||||
|
||||
export type GetFormHumanInputByFormTokenError =
|
||||
GetFormHumanInputByFormTokenErrors[keyof GetFormHumanInputByFormTokenErrors]
|
||||
|
||||
export type GetFormHumanInputByFormTokenResponses = {
|
||||
200: ConsoleHumanInputFormDefinitionResponse
|
||||
}
|
||||
|
||||
export type GetFormHumanInputByFormTokenResponse =
|
||||
GetFormHumanInputByFormTokenResponses[keyof GetFormHumanInputByFormTokenResponses]
|
||||
|
||||
export type PostFormHumanInputByFormTokenData = {
|
||||
body: HumanInputFormSubmitPayload
|
||||
path: {
|
||||
form_token: string
|
||||
}
|
||||
query?: never
|
||||
url: '/form/human_input/{form_token}'
|
||||
}
|
||||
|
||||
export type PostFormHumanInputByFormTokenErrors = {
|
||||
400: InvalidFormDataError | ErrorResponse
|
||||
412: HumanInputFormExpiredError | HumanInputFormSubmittedError | ErrorResponse
|
||||
default: ErrorResponse
|
||||
}
|
||||
|
||||
export type PostFormHumanInputByFormTokenError =
|
||||
PostFormHumanInputByFormTokenErrors[keyof PostFormHumanInputByFormTokenErrors]
|
||||
|
||||
export type PostFormHumanInputByFormTokenResponses = {
|
||||
200: ConsoleHumanInputFormSubmitResponse
|
||||
}
|
||||
|
||||
export type PostFormHumanInputByFormTokenResponse =
|
||||
PostFormHumanInputByFormTokenResponses[keyof PostFormHumanInputByFormTokenResponses]
|
||||
@@ -0,0 +1,289 @@
|
||||
// This file is auto-generated by @hey-api/openapi-ts
|
||||
|
||||
import * as z from 'zod'
|
||||
|
||||
/**
|
||||
* ErrorResponse
|
||||
*
|
||||
* Documented non-2xx body emitted by ``register_external_error_handlers``.
|
||||
*
|
||||
* ``params`` and ``details`` appear only on the errors that set them. The schema
|
||||
* stays open because ``HTTPException.data`` may carry extra keys.
|
||||
*/
|
||||
export const zErrorResponse = z.object({
|
||||
code: z.string(),
|
||||
details: z.record(z.string(), z.unknown()).optional(),
|
||||
message: z.string(),
|
||||
params: z.string().optional(),
|
||||
status: z.int(),
|
||||
})
|
||||
|
||||
/**
|
||||
* AlreadySubmittedError
|
||||
*/
|
||||
export const zAlreadySubmittedError = zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('already_submitted'),
|
||||
status: z.literal(409),
|
||||
}),
|
||||
)
|
||||
|
||||
/**
|
||||
* ExpiredError
|
||||
*/
|
||||
export const zExpiredError = zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('expired'),
|
||||
status: z.literal(410),
|
||||
}),
|
||||
)
|
||||
|
||||
/**
|
||||
* ConsoleHumanInputV2SubmitResponse
|
||||
*/
|
||||
export const zConsoleHumanInputV2SubmitResponse = z.record(z.string(), z.unknown())
|
||||
|
||||
/**
|
||||
* InvalidInputError
|
||||
*/
|
||||
export const zInvalidInputError = zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('invalid_input'),
|
||||
status: z.literal(400),
|
||||
}),
|
||||
)
|
||||
|
||||
/**
|
||||
* WorkflowNotActiveError
|
||||
*/
|
||||
export const zWorkflowNotActiveError = zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('workflow_not_active'),
|
||||
status: z.literal(409),
|
||||
}),
|
||||
)
|
||||
|
||||
/**
|
||||
* ConsoleHumanInputFormDefinitionResponse
|
||||
*/
|
||||
export const zConsoleHumanInputFormDefinitionResponse = z.record(z.string(), z.unknown())
|
||||
|
||||
/**
|
||||
* HumanInputFormSubmittedError
|
||||
*
|
||||
* This form has already been submitted by another user, form_id={form_id}
|
||||
*/
|
||||
export const zHumanInputFormSubmittedError = zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('human_input_form_submitted'),
|
||||
status: z.literal(412),
|
||||
}),
|
||||
)
|
||||
|
||||
/**
|
||||
* ConsoleHumanInputFormSubmitResponse
|
||||
*/
|
||||
export const zConsoleHumanInputFormSubmitResponse = z.record(z.string(), z.unknown())
|
||||
|
||||
/**
|
||||
* InvalidFormDataError
|
||||
*/
|
||||
export const zInvalidFormDataError = zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('invalid_form_data'),
|
||||
status: z.literal(400),
|
||||
}),
|
||||
)
|
||||
|
||||
/**
|
||||
* HumanInputFormExpiredError
|
||||
*/
|
||||
export const zHumanInputFormExpiredError = zErrorResponse.and(
|
||||
z.object({
|
||||
code: z.literal('human_input_form_expired'),
|
||||
status: z.literal(412),
|
||||
}),
|
||||
)
|
||||
|
||||
export const zJsonValue = z.unknown()
|
||||
|
||||
/**
|
||||
* ConsoleHumanInputV2SubmitPayload
|
||||
*/
|
||||
export const zConsoleHumanInputV2SubmitPayload = z.object({
|
||||
action: z.string(),
|
||||
inputs: z.record(z.string(), zJsonValue),
|
||||
})
|
||||
|
||||
/**
|
||||
* HumanInputFormSubmitPayload
|
||||
*
|
||||
* Legacy Human Input v1 submit payload shared by existing runtime surfaces.
|
||||
*/
|
||||
export const zHumanInputFormSubmitPayload = z.object({
|
||||
action: z.string(),
|
||||
inputs: z.record(z.string(), zJsonValue),
|
||||
})
|
||||
|
||||
/**
|
||||
* ButtonStyle
|
||||
*
|
||||
* Button styles for user actions.
|
||||
*/
|
||||
export const zButtonStyle = z.enum(['accent', 'default', 'ghost', 'primary'])
|
||||
|
||||
/**
|
||||
* UserAction
|
||||
*
|
||||
* Resolved action values required for presentation and submission validation.
|
||||
*/
|
||||
export const zUserAction = z.object({
|
||||
button_style: zButtonStyle,
|
||||
id: z.string(),
|
||||
title: z.string(),
|
||||
})
|
||||
|
||||
/**
|
||||
* MarkdownFragment
|
||||
*
|
||||
* One source-ordered Markdown fragment in a resolved form.
|
||||
*/
|
||||
export const zMarkdownFragment = z.object({
|
||||
text: z.string(),
|
||||
type: z.literal('markdown_fragment').optional().default('markdown_fragment'),
|
||||
})
|
||||
|
||||
/**
|
||||
* ParagraphInput
|
||||
*
|
||||
* Resolved multiline text input.
|
||||
*/
|
||||
export const zParagraphInput = z.object({
|
||||
default_value: z.string().nullable(),
|
||||
output_variable_name: z.string(),
|
||||
type: z.literal('paragraph_input').optional().default('paragraph_input'),
|
||||
})
|
||||
|
||||
/**
|
||||
* SelectInput
|
||||
*
|
||||
* Resolved single-choice input with immutable concrete options.
|
||||
*/
|
||||
export const zSelectInput = z.object({
|
||||
default_value: z.string().nullable(),
|
||||
options: z.array(z.string()),
|
||||
output_variable_name: z.string(),
|
||||
type: z.literal('select_input').optional().default('select_input'),
|
||||
})
|
||||
|
||||
/**
|
||||
* FileType
|
||||
*/
|
||||
export const zFileType = z.enum(['audio', 'custom', 'document', 'image', 'video'])
|
||||
|
||||
/**
|
||||
* FileTransferMethod
|
||||
*/
|
||||
export const zFileTransferMethod = z.enum([
|
||||
'datasource_file',
|
||||
'local_file',
|
||||
'remote_url',
|
||||
'tool_file',
|
||||
])
|
||||
|
||||
/**
|
||||
* FileInput
|
||||
*
|
||||
* Resolved single-file input constraints.
|
||||
*/
|
||||
export const zFileInput = z.object({
|
||||
allowed_file_extensions: z.array(z.string()),
|
||||
allowed_file_types: z.array(zFileType),
|
||||
allowed_file_upload_methods: z.array(zFileTransferMethod),
|
||||
output_variable_name: z.string(),
|
||||
type: z.literal('file_input').optional().default('file_input'),
|
||||
})
|
||||
|
||||
/**
|
||||
* FileListInput
|
||||
*
|
||||
* Resolved multi-file input constraints and effective number limit.
|
||||
*/
|
||||
export const zFileListInput = z.object({
|
||||
allowed_file_extensions: z.array(z.string()),
|
||||
allowed_file_types: z.array(zFileType),
|
||||
allowed_file_upload_methods: z.array(zFileTransferMethod),
|
||||
number_limits: z.int(),
|
||||
output_variable_name: z.string(),
|
||||
type: z.literal('file_list_input').optional().default('file_list_input'),
|
||||
})
|
||||
|
||||
export const zFormPart = z.discriminatedUnion('type', [
|
||||
zMarkdownFragment,
|
||||
zParagraphInput,
|
||||
zSelectInput,
|
||||
zFileInput,
|
||||
zFileListInput,
|
||||
])
|
||||
|
||||
/**
|
||||
* ResolvedForm
|
||||
*
|
||||
* Immutable authoritative presentation snapshot for one v2 form.
|
||||
*/
|
||||
export const zResolvedForm = z.object({
|
||||
actions: z.array(zUserAction),
|
||||
legacy_form_content: z.string(),
|
||||
parts: z.array(zFormPart),
|
||||
title: z.string(),
|
||||
})
|
||||
|
||||
/**
|
||||
* ConsoleHumanInputV2FormDefinitionResponse
|
||||
*
|
||||
* Frozen form definition and effective expiration in UTC epoch seconds.
|
||||
*/
|
||||
export const zConsoleHumanInputV2FormDefinitionResponse = z.object({
|
||||
expiration_time: z.int(),
|
||||
resolved_form: zResolvedForm,
|
||||
})
|
||||
|
||||
export const zGetFormHumanInputV2ByFormTokenPath = z.object({
|
||||
form_token: z.string(),
|
||||
})
|
||||
|
||||
/**
|
||||
* Form retrieved
|
||||
*/
|
||||
export const zGetFormHumanInputV2ByFormTokenResponse = zConsoleHumanInputV2FormDefinitionResponse
|
||||
|
||||
export const zPostFormHumanInputV2ByFormTokenBody = zConsoleHumanInputV2SubmitPayload
|
||||
|
||||
export const zPostFormHumanInputV2ByFormTokenPath = z.object({
|
||||
form_token: z.string(),
|
||||
})
|
||||
|
||||
/**
|
||||
* Approval accepted
|
||||
*/
|
||||
export const zPostFormHumanInputV2ByFormTokenResponse = zConsoleHumanInputV2SubmitResponse
|
||||
|
||||
export const zGetFormHumanInputByFormTokenPath = z.object({
|
||||
form_token: z.string(),
|
||||
})
|
||||
|
||||
/**
|
||||
* Success
|
||||
*/
|
||||
export const zGetFormHumanInputByFormTokenResponse = zConsoleHumanInputFormDefinitionResponse
|
||||
|
||||
export const zPostFormHumanInputByFormTokenBody = zHumanInputFormSubmitPayload
|
||||
|
||||
export const zPostFormHumanInputByFormTokenPath = z.object({
|
||||
form_token: z.string(),
|
||||
})
|
||||
|
||||
/**
|
||||
* Success
|
||||
*/
|
||||
export const zPostFormHumanInputByFormTokenResponse = zConsoleHumanInputFormSubmitResponse
|
||||
Reference in new issue
Block a user