feat: add envelopes api (#2105)

This commit is contained in:
David Nguyen
2025-11-07 14:17:52 +11:00
committed by GitHub
parent d2a009d52e
commit d05bfa9fed
230 changed files with 10066 additions and 2812 deletions

View File

@ -1,17 +1,23 @@
import { createTRPCClient, httpBatchLink, httpLink, splitLink } from '@trpc/client';
import SuperJSON from 'superjson';
import {
createTRPCClient,
httpBatchLink,
httpLink,
isNonJsonSerializable,
splitLink,
} from '@trpc/client';
import { getBaseUrl } from '@documenso/lib/universal/get-base-url';
import type { AppRouter } from '../server/router';
import { dataTransformer } from '../utils/data-transformer';
export const trpc = createTRPCClient<AppRouter>({
links: [
splitLink({
condition: (op) => op.context.skipBatch === true,
condition: (op) => op.context.skipBatch === true || isNonJsonSerializable(op.input),
true: httpLink({
url: `${getBaseUrl()}/api/trpc`,
transformer: SuperJSON,
transformer: dataTransformer,
headers: (opts) => {
if (typeof opts.op.context.teamId === 'string') {
return {
@ -24,7 +30,7 @@ export const trpc = createTRPCClient<AppRouter>({
}),
false: httpBatchLink({
url: `${getBaseUrl()}/api/trpc`,
transformer: SuperJSON,
transformer: dataTransformer,
headers: (opts) => {
const operationWithTeamId = opts.opList.find(
(op) => op.context.teamId && typeof op.context.teamId === 'string',