UNPKG

@orpc/openapi-client

Version:

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

44 lines (41 loc) 1.66 kB
import { S as StandardBracketNotationSerializer } from '../../shared/openapi-client.D3eD5ojB.mjs'; export { a as StandardOpenAPIJsonSerializer, b as StandardOpenAPILink, d as StandardOpenAPISerializer, c as StandardOpenapiLinkCodec, g as getDynamicParams, s as standardizeHTTPPath } from '../../shared/openapi-client.D3eD5ojB.mjs'; import { isSchemaIssue } from '@orpc/contract'; import { isTypescriptObject } from '@orpc/shared'; import '@orpc/client/standard'; import '@orpc/client'; import '@orpc/standard-server'; function parseFormData(form) { const serializer = new StandardBracketNotationSerializer(); return serializer.deserialize(Array.from(form.entries())); } function getIssueMessage(error, path) { if (!isTypescriptObject(error) || !isTypescriptObject(error.data) || !Array.isArray(error.data.issues)) { return void 0; } const serializer = new StandardBracketNotationSerializer(); for (const issue of error.data.issues) { if (!isSchemaIssue(issue)) { continue; } if (issue.path === void 0) { if (path === "") { return issue.message; } continue; } const issuePath = serializer.stringifyPath( issue.path.map((segment) => typeof segment === "object" ? segment.key.toString() : segment.toString()) ); if (issuePath === path) { return issue.message; } if (path.endsWith("[]") && issuePath.replace(/\[(?:0|[1-9]\d*)\]$/, "[]") === path) { return issue.message; } if (path === "" && issuePath.match(/(?:0|[1-9]\d*)$/)) { return issue.message; } } } export { StandardBracketNotationSerializer, getIssueMessage, parseFormData };