UNPKG

@orpc/openapi-client

Version:

<div align="center"> <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" /> </div>

74 lines (70 loc) 2.59 kB
export { S as StandardBracketNotationSerialized, b as StandardBracketNotationSerializer, a as StandardBracketNotationSerializerOptions, d as StandardOpenAPICustomJsonSerializer, c as StandardOpenAPIJsonSerialized, f as StandardOpenAPIJsonSerializer, e as StandardOpenAPIJsonSerializerOptions, h as StandardOpenAPILink, g as StandardOpenAPILinkOptions, k as StandardOpenAPISerializeOptions, l as StandardOpenAPISerializer, j as StandardOpenapiLinkCodec, i as StandardOpenapiLinkCodecOptions } from '../../shared/openapi-client.f2unmElJ.mjs'; import { HTTPPath } from '@orpc/client'; import '@orpc/client/standard'; import '@orpc/contract'; import '@orpc/shared'; import '@orpc/standard-server'; /** * parse a form data with bracket notation * * @example * ```ts * const form = new FormData() * form.append('a', '1') * form.append('user[name]', 'John') * form.append('user[age]', '20') * form.append('user[friends][]', 'Bob') * form.append('user[friends][]', 'Alice') * form.append('user[friends][]', 'Charlie') * form.append('thumb', new Blob(['hello']), 'thumb.png') * * parseFormData(form) * // { * // a: '1', * // user: { * // name: 'John', * // age: '20', * // friends: ['Bob', 'Alice', 'Charlie'], * // }, * // thumb: form.get('thumb'), * // } * ``` * * @see {@link https://orpc.unnoq.com/docs/openapi/bracket-notation Bracket Notation Docs} */ declare function parseFormData(form: FormData): any; /** * Get the issue message from the error. * * @param error - The error (can be anything) can contain `data.issues` (standard schema issues) * @param path - The path of the field that has the issue follow [bracket notation](https://orpc.unnoq.com/docs/openapi/bracket-notation) * * @example * ```tsx * const { error, data, execute } = useServerAction(someAction) * * return <form action={(form) => execute(parseFormData(form))}> * <input name="user[name]" type="text" /> * <p>{getIssueMessage(error, 'user[name]')}</p> * * <input name="user[age]" type="number" /> * <p>{getIssueMessage(error, 'user[age]')}</p> * * <input name="images[]" type="file" /> * <p>{getIssueMessage(error, 'images[]')}</p> * </form> * */ declare function getIssueMessage(error: unknown, path: string): string | undefined; /** * @internal */ declare function standardizeHTTPPath(path: HTTPPath): HTTPPath; /** * @internal */ declare function getDynamicParams(path: HTTPPath | undefined): { raw: string; name: string; }[] | undefined; export { getDynamicParams, getIssueMessage, parseFormData, standardizeHTTPPath };