(workspaceId?: string)
| 70 | } |
| 71 | |
| 72 | export async function getTrpcClient(workspaceId?: string): Promise<TrpcClient> { |
| 73 | const wsId = resolveWorkspaceId(workspaceId); |
| 74 | const cacheKey = wsId ?? PERSONAL_KEY; |
| 75 | const cached = _clients.get(cacheKey); |
| 76 | if (cached) return cached; |
| 77 | |
| 78 | const { headers, serverUrl } = await getAuthAndServer(); |
| 79 | const client = createTRPCClient<LambdaRouter>({ |
| 80 | links: [ |
| 81 | httpLink({ |
| 82 | headers: wsId ? { ...headers, 'X-Workspace-Id': wsId } : headers, |
| 83 | transformer: superjson, |
| 84 | url: `${serverUrl}/trpc/lambda`, |
| 85 | }), |
| 86 | ], |
| 87 | }); |
| 88 | _clients.set(cacheKey, client); |
| 89 | |
| 90 | return client; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Build a Lambda tRPC client from an already-resolved auth context, without |
no test coverage detected