@orpc/openapi 2.0.0-beta.45 → 2.0.0-beta.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -19
- package/dist/adapters/aws-lambda/index.d.mts +2 -1
- package/dist/adapters/aws-lambda/index.d.ts +2 -1
- package/dist/adapters/aws-lambda/index.mjs +1 -1
- package/dist/adapters/fastify/index.d.mts +1 -1
- package/dist/adapters/fastify/index.d.ts +1 -1
- package/dist/adapters/fastify/index.mjs +1 -1
- package/dist/adapters/fetch/index.d.mts +1 -1
- package/dist/adapters/fetch/index.d.ts +1 -1
- package/dist/adapters/fetch/index.mjs +2 -2
- package/dist/adapters/node/index.d.mts +1 -1
- package/dist/adapters/node/index.d.ts +1 -1
- package/dist/adapters/node/index.mjs +1 -1
- package/dist/adapters/standard/index.d.mts +52 -10
- package/dist/adapters/standard/index.d.ts +52 -10
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/index.d.mts +25 -16
- package/dist/index.d.ts +25 -16
- package/dist/index.mjs +10 -8
- package/dist/shared/{openapi.BNe1y1cD.mjs → openapi.CQkXu1nY.mjs} +12 -6
- package/dist/shared/{openapi.BTq9wym2.d.mts → openapi.Covi8zVE.d.mts} +1 -1
- package/dist/shared/{openapi.BTq9wym2.d.ts → openapi.Covi8zVE.d.ts} +1 -1
- package/dist/shared/{openapi.B8v9IrIK.d.mts → openapi.DfmCR1pB.d.mts} +10 -3
- package/dist/shared/{openapi.C_r_fZl2.d.ts → openapi.Y4K_-I5W.d.ts} +10 -3
- package/dist/shared/{openapi.D42Ps1fQ.d.mts → openapi.YMRD3b4R.d.mts} +7 -1
- package/dist/shared/{openapi.D42Ps1fQ.d.ts → openapi.YMRD3b4R.d.ts} +7 -1
- package/dist/shared/{openapi.DXqJL3gB.mjs → openapi.g7ucL05o.mjs} +6 -4
- package/dist/shared/{openapi.B_SoJfYz.d.mts → openapi.zGZlCOwp.d.mts} +4 -3
- package/dist/shared/{openapi.B_SoJfYz.d.ts → openapi.zGZlCOwp.d.ts} +4 -3
- package/package.json +11 -11
- package/dist/shared/openapi.C1MLxqih.d.ts +0 -45
- package/dist/shared/openapi.CCZPbgOq.d.mts +0 -45
package/README.md
CHANGED
|
@@ -21,9 +21,40 @@
|
|
|
21
21
|
</a>
|
|
22
22
|
</div>
|
|
23
23
|
|
|
24
|
+
**oRPC** is a TypeScript framework for building end-to-end typesafe APIs. Write your API once as plain TypeScript functions, and oRPC gives you a fully typed client, a REST API with an OpenAPI document, and MCP tools for AI agents, with no code generation. It runs on Node.js, Bun, Deno, Cloudflare Workers, and more.
|
|
25
|
+
|
|
26
|
+
Define procedures on the server and serve them with an [RPC handler](https://orpc.dev/docs/rpc/handler):
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { os } from '@orpc/server'
|
|
30
|
+
import * as z from 'zod'
|
|
31
|
+
|
|
32
|
+
export const router = {
|
|
33
|
+
planet: {
|
|
34
|
+
find: os
|
|
35
|
+
.input(z.object({ id: z.number() }))
|
|
36
|
+
.handler(({ input }) => ({ id: input.id, name: 'Earth' })),
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Then call them from a client that knows every input and output, without generating anything:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import type { RouterClient } from '@orpc/server'
|
|
45
|
+
import type { router } from './router'
|
|
46
|
+
import { createORPCClient } from '@orpc/client'
|
|
47
|
+
import { RPCLink } from '@orpc/client/fetch'
|
|
48
|
+
|
|
49
|
+
const link = new RPCLink({ origin: 'http://localhost:3000', url: '/rpc' })
|
|
50
|
+
const client: RouterClient<typeof router> = createORPCClient(link)
|
|
51
|
+
|
|
52
|
+
const planet = await client.planet.find({ id: 1 }) // { id: number, name: string }
|
|
53
|
+
```
|
|
54
|
+
|
|
24
55
|
## Documentation
|
|
25
56
|
|
|
26
|
-
|
|
57
|
+
Read the full documentation at [orpc.dev](https://orpc.dev), starting with the [Getting Started guide](https://orpc.dev/docs/getting-started).
|
|
27
58
|
|
|
28
59
|
## Packages
|
|
29
60
|
|
|
@@ -56,21 +87,21 @@ You can read the documentation [here](https://orpc.dev).
|
|
|
56
87
|
|
|
57
88
|
**Framework & ecosystem integrations**
|
|
58
89
|
|
|
59
|
-
| Package
|
|
60
|
-
|
|
|
61
|
-
| [@orpc/next](https://www.npmjs.com/package/@orpc/next)
|
|
62
|
-
| [@orpc/ai-sdk](https://www.npmjs.com/package/@orpc/ai-sdk)
|
|
63
|
-
| [@orpc/mcp](https://www.npmjs.com/package/@orpc/mcp)
|
|
64
|
-
| [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query)
|
|
65
|
-
| [@orpc/pinia-colada](https://www.npmjs.com/package/@orpc/pinia-colada)
|
|
66
|
-
| [@orpc/swr](https://www.npmjs.com/package/@orpc/swr)
|
|
67
|
-
| [@orpc/msw](https://www.npmjs.com/package/@orpc/msw)
|
|
68
|
-
| [@orpc/
|
|
69
|
-
| [@orpc/nest](https://www.npmjs.com/package/@orpc/nest)
|
|
70
|
-
| [@orpc/node](https://www.npmjs.com/package/@orpc/node)
|
|
71
|
-
| [@orpc/bun](https://www.npmjs.com/package/@orpc/bun)
|
|
72
|
-
| [@orpc/cloudflare](https://www.npmjs.com/package/@orpc/cloudflare)
|
|
73
|
-
| [@orpc/trpc](https://www.npmjs.com/package/@orpc/trpc)
|
|
90
|
+
| Package | Purpose | Docs |
|
|
91
|
+
| -------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
92
|
+
| [@orpc/next](https://www.npmjs.com/package/@orpc/next) | Integrate with [Next.js Server Functions](https://nextjs.org/docs/app/getting-started/mutating-data). | [Next.js](https://orpc.dev/docs/integrations/next) |
|
|
93
|
+
| [@orpc/ai-sdk](https://www.npmjs.com/package/@orpc/ai-sdk) | Turn contracts and procedures into [AI SDK](https://ai-sdk.dev/) tools. | [AI SDK](https://orpc.dev/docs/integrations/ai-sdk) |
|
|
94
|
+
| [@orpc/mcp](https://www.npmjs.com/package/@orpc/mcp) | Expose procedures as [MCP](https://modelcontextprotocol.io/) tools. | [MCP](https://orpc.dev/docs/integrations/mcp) |
|
|
95
|
+
| [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query) | Integrate with [TanStack Query](https://tanstack.com/query/latest). | [TanStack Query](https://orpc.dev/docs/integrations/tanstack-query) |
|
|
96
|
+
| [@orpc/pinia-colada](https://www.npmjs.com/package/@orpc/pinia-colada) | Integrate with [Pinia Colada](https://pinia-colada.esm.dev/). | [Pinia Colada](https://orpc.dev/docs/integrations/pinia-colada) |
|
|
97
|
+
| [@orpc/swr](https://www.npmjs.com/package/@orpc/swr) | Integrate with [SWR](https://swr.vercel.app/). | [SWR](https://orpc.dev/docs/integrations/swr) |
|
|
98
|
+
| [@orpc/msw](https://www.npmjs.com/package/@orpc/msw) | Mock procedures with [Mock Service Worker](https://mswjs.io/). | [MSW](https://orpc.dev/docs/integrations/msw) |
|
|
99
|
+
| [@orpc/effect](https://www.npmjs.com/package/@orpc/effect) | Integrate with [Effect](https://effect.website/). | [Effect](https://orpc.dev/docs/integrations/effect) |
|
|
100
|
+
| [@orpc/nest](https://www.npmjs.com/package/@orpc/nest) | Implement your contract with [NestJS](https://nestjs.com/). | [NestJS](https://orpc.dev/docs/integrations/nest) |
|
|
101
|
+
| [@orpc/node](https://www.npmjs.com/package/@orpc/node) | [Node.js](https://nodejs.org/) plugins for static file serving and large uploads. | [Static File](https://orpc.dev/docs/plugins/static-file), [Tmp File Upload](https://orpc.dev/docs/plugins/tmp-file-upload), [Batch Response Compression](https://orpc.dev/docs/plugins/batch-response-compression) |
|
|
102
|
+
| [@orpc/bun](https://www.npmjs.com/package/@orpc/bun) | Adapters for [Bun's Redis](https://bun.sh/). | [Publisher](https://orpc.dev/docs/helpers/publisher), [Rate Limit](https://orpc.dev/docs/helpers/ratelimit), [Lock](https://orpc.dev/docs/helpers/lock) |
|
|
103
|
+
| [@orpc/cloudflare](https://www.npmjs.com/package/@orpc/cloudflare) | Adapters for [Cloudflare Workers](https://developers.cloudflare.com/workers/). | [Publisher](https://orpc.dev/docs/helpers/publisher), [Rate Limit](https://orpc.dev/docs/helpers/ratelimit), [Lock](https://orpc.dev/docs/helpers/lock), [Traces](https://orpc.dev/docs/integrations/cloudflare-traces) |
|
|
104
|
+
| [@orpc/trpc](https://www.npmjs.com/package/@orpc/trpc) | Reuse existing [tRPC](https://trpc.io/) routers within oRPC. | [tRPC](https://orpc.dev/docs/integrations/trpc) |
|
|
74
105
|
|
|
75
106
|
**Observability**
|
|
76
107
|
|
|
@@ -125,10 +156,11 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
125
156
|
<td align="center"><a href="https://github.com/christ12938?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="167" alt="christ12938"/><br />christ12938</a></td>
|
|
126
157
|
<td align="center"><a href="https://github.com/Ryanjso?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ryan Soderberg"><img src="https://avatars.githubusercontent.com/u/39172778?u=5ed913c31d57e7221b75784abcad48c7ebddde27&v=4" width="167" alt="Ryan Soderberg"/><br />Ryan Soderberg</a></td>
|
|
127
158
|
<td align="center"><a href="https://github.com/itigoore01?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="shota"><img src="https://avatars.githubusercontent.com/u/11831107?u=c976a6dc7e055eb026304c46c99100ed22b0c8e0&v=4" width="167" alt="shota"/><br />shota</a></td>
|
|
159
|
+
<td align="center"><a href="https://github.com/Nic13Gamer?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Nicholas"><img src="https://avatars.githubusercontent.com/u/54724556?u=56a7ab430ce7a80d648ab6eba051d454a818ed0b&v=4" width="167" alt="Nicholas"/><br />Nicholas</a></td>
|
|
128
160
|
<td align="center"><a href="https://github.com/ellis-driscoll?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ellis Driscoll"><img src="https://avatars.githubusercontent.com/u/70685966?u=c5f95bc33b5991d9744abe00052542e4a2ed3cb9&v=4" width="167" alt="Ellis Driscoll"/><br />Ellis Driscoll</a></td>
|
|
129
|
-
<td align="center"><a href="https://github.com/hoangbn?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Hoang Nguyen"><img src="https://avatars.githubusercontent.com/u/38968280?u=c90084c6de65c56facabab7ba13a72a49ddbc3e4&v=4" width="167" alt="Hoang Nguyen"/><br />Hoang Nguyen</a></td>
|
|
130
161
|
</tr>
|
|
131
162
|
<tr>
|
|
163
|
+
<td align="center"><a href="https://github.com/hoangbn?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Hoang Nguyen"><img src="https://avatars.githubusercontent.com/u/38968280?u=c90084c6de65c56facabab7ba13a72a49ddbc3e4&v=4" width="167" alt="Hoang Nguyen"/><br />Hoang Nguyen</a></td>
|
|
132
164
|
<td align="center"><a href="https://opencollective.com/guest-ac41de3b?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Orestis Ioannou"><img src="https://images.opencollective.com/guest-ac41de3b/avatar/460.png" width="167" alt="Orestis Ioannou"/><br />Orestis Ioannou</a></td>
|
|
133
165
|
<td align="center"><a href="https://automatio.ai/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Stefan Smiljkovic"><img src="https://avatars.githubusercontent.com/u/1984909?u=b7bf5bc40ed49df3c22f69d2da7b8d78709c49ed&v=4" width="167" alt="Stefan Smiljkovic"/><br />Stefan Smiljkovic</a></td>
|
|
134
166
|
</tr>
|
|
@@ -167,7 +199,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
167
199
|
</tr>
|
|
168
200
|
</table>
|
|
169
201
|
|
|
170
|
-
With thanks to [
|
|
202
|
+
With thanks to [39 past sponsors](https://orpc.dev/sponsors#past-sponsors) who helped get oRPC here.
|
|
171
203
|
|
|
172
204
|
## Open Source Programs
|
|
173
205
|
|
|
@@ -175,7 +207,9 @@ With thanks to [40 past sponsors](https://orpc.dev/sponsors#past-sponsors) who h
|
|
|
175
207
|
|
|
176
208
|
<table>
|
|
177
209
|
<tr>
|
|
178
|
-
<td align="center"><a href="https://claude.com/contact-sales/claude-for-oss" target="_blank" rel="noopener" title="Claude for Open Source"><img src="https://cdn.simpleicons.org/claude" width="64" alt="Claude"/><br />Claude
|
|
210
|
+
<td align="center"><a href="https://claude.com/contact-sales/claude-for-oss" target="_blank" rel="noopener" title="Claude for Open Source"><img src="https://cdn.simpleicons.org/claude" width="64" alt="Claude"/><br />Claude</a></td>
|
|
211
|
+
<td align="center"><a href="https://pullfrog.com/for-oss" target="_blank" rel="noopener" title="Pullfrog for OSS"><img src="https://avatars.githubusercontent.com/in/1768019?s=128&v=4" width="64" alt="Pullfrog"/><br />Pullfrog</a></td>
|
|
212
|
+
<td align="center"><a href="https://macroscope.com/open-source" target="_blank" rel="noopener" title="Macroscope for Open Source"><img src="https://avatars.githubusercontent.com/in/900172?s=128&v=4" width="64" alt="Macroscope"/><br />Macroscope</a></td>
|
|
179
213
|
</tr>
|
|
180
214
|
</table>
|
|
181
215
|
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
|
2
2
|
import { AwsLambdaHandler, AwsLambdaHandlerOptions } from '@orpc/server/aws-lambda';
|
|
3
|
+
export { APIGatewayProxyEvent, APIGatewayProxyEventV2, AnyAPIGatewayProxyEvent, AwsLambdaGlobal, HttpResponseStream } from '@orpc/server/aws-lambda';
|
|
3
4
|
import { StandardHandlerOptions } from '@orpc/server/standard';
|
|
4
5
|
import { OpenAPIHandlerCodecOptions } from '../standard/index.mjs';
|
|
5
6
|
import '@orpc/client';
|
|
6
7
|
import '@orpc/shared';
|
|
7
8
|
import '@standard-server/core';
|
|
8
9
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/openapi.
|
|
10
|
+
import '../../shared/openapi.YMRD3b4R.mjs';
|
|
10
11
|
|
|
11
12
|
interface OpenAPIHandlerOptions<T extends Context> extends AwsLambdaHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
12
13
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Context, Router } from '@orpc/server';
|
|
2
2
|
import { AwsLambdaHandler, AwsLambdaHandlerOptions } from '@orpc/server/aws-lambda';
|
|
3
|
+
export { APIGatewayProxyEvent, APIGatewayProxyEventV2, AnyAPIGatewayProxyEvent, AwsLambdaGlobal, HttpResponseStream } from '@orpc/server/aws-lambda';
|
|
3
4
|
import { StandardHandlerOptions } from '@orpc/server/standard';
|
|
4
5
|
import { OpenAPIHandlerCodecOptions } from '../standard/index.js';
|
|
5
6
|
import '@orpc/client';
|
|
6
7
|
import '@orpc/shared';
|
|
7
8
|
import '@standard-server/core';
|
|
8
9
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/openapi.
|
|
10
|
+
import '../../shared/openapi.YMRD3b4R.js';
|
|
10
11
|
|
|
11
12
|
interface OpenAPIHandlerOptions<T extends Context> extends AwsLambdaHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
12
13
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AwsLambdaHandler } from '@orpc/server/aws-lambda';
|
|
2
2
|
import { StandardHandler } from '@orpc/server/standard';
|
|
3
|
-
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.
|
|
3
|
+
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.g7ucL05o.mjs';
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/server';
|
|
6
6
|
import '@orpc/shared';
|
|
@@ -6,7 +6,7 @@ import '@orpc/client';
|
|
|
6
6
|
import '@orpc/shared';
|
|
7
7
|
import '@standard-server/core';
|
|
8
8
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/openapi.
|
|
9
|
+
import '../../shared/openapi.YMRD3b4R.mjs';
|
|
10
10
|
|
|
11
11
|
interface OpenAPIHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
12
12
|
}
|
|
@@ -6,7 +6,7 @@ import '@orpc/client';
|
|
|
6
6
|
import '@orpc/shared';
|
|
7
7
|
import '@standard-server/core';
|
|
8
8
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/openapi.
|
|
9
|
+
import '../../shared/openapi.YMRD3b4R.js';
|
|
10
10
|
|
|
11
11
|
interface OpenAPIHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
12
12
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FastifyHandler } from '@orpc/server/fastify';
|
|
2
2
|
import { StandardHandler } from '@orpc/server/standard';
|
|
3
|
-
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.
|
|
3
|
+
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.g7ucL05o.mjs';
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/server';
|
|
6
6
|
import '@orpc/shared';
|
|
@@ -9,7 +9,7 @@ import { RouterContract } from '@orpc/contract';
|
|
|
9
9
|
import { OpenAPILinkCodecOptions } from '../standard/index.mjs';
|
|
10
10
|
import '@orpc/shared';
|
|
11
11
|
import '@standard-server/core';
|
|
12
|
-
import '../../shared/openapi.
|
|
12
|
+
import '../../shared/openapi.YMRD3b4R.mjs';
|
|
13
13
|
|
|
14
14
|
interface OpenAPIHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
15
15
|
}
|
|
@@ -9,7 +9,7 @@ import { RouterContract } from '@orpc/contract';
|
|
|
9
9
|
import { OpenAPILinkCodecOptions } from '../standard/index.js';
|
|
10
10
|
import '@orpc/shared';
|
|
11
11
|
import '@standard-server/core';
|
|
12
|
-
import '../../shared/openapi.
|
|
12
|
+
import '../../shared/openapi.YMRD3b4R.js';
|
|
13
13
|
|
|
14
14
|
interface OpenAPIHandlerOptions<T extends Context> extends FetchHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
15
15
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FetchHandler } from '@orpc/server/fetch';
|
|
2
2
|
import { StandardHandler } from '@orpc/server/standard';
|
|
3
|
-
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.
|
|
3
|
+
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.g7ucL05o.mjs';
|
|
4
4
|
import { FetchLinkTransport } from '@orpc/client/fetch';
|
|
5
5
|
import { StandardLink } from '@orpc/client/standard';
|
|
6
|
-
import { O as OpenAPILinkCodec } from '../../shared/openapi.
|
|
6
|
+
import { O as OpenAPILinkCodec } from '../../shared/openapi.CQkXu1nY.mjs';
|
|
7
7
|
import '@orpc/client';
|
|
8
8
|
import '@orpc/server';
|
|
9
9
|
import '@orpc/shared';
|
|
@@ -6,7 +6,7 @@ import '@orpc/client';
|
|
|
6
6
|
import '@orpc/shared';
|
|
7
7
|
import '@standard-server/core';
|
|
8
8
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/openapi.
|
|
9
|
+
import '../../shared/openapi.YMRD3b4R.mjs';
|
|
10
10
|
|
|
11
11
|
interface OpenAPIHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
12
12
|
}
|
|
@@ -6,7 +6,7 @@ import '@orpc/client';
|
|
|
6
6
|
import '@orpc/shared';
|
|
7
7
|
import '@standard-server/core';
|
|
8
8
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/openapi.
|
|
9
|
+
import '../../shared/openapi.YMRD3b4R.js';
|
|
10
10
|
|
|
11
11
|
interface OpenAPIHandlerOptions<T extends Context> extends NodeHttpHandlerOptions<T>, StandardHandlerOptions<T>, OpenAPIHandlerCodecOptions<T> {
|
|
12
12
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NodeHttpHandler } from '@orpc/server/node';
|
|
2
2
|
import { StandardHandler } from '@orpc/server/standard';
|
|
3
|
-
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.
|
|
3
|
+
import { O as OpenAPIHandlerCodec } from '../../shared/openapi.g7ucL05o.mjs';
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/server';
|
|
6
6
|
import '@orpc/shared';
|
|
@@ -1,14 +1,56 @@
|
|
|
1
|
-
export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecCore, c as OpenAPIHandlerCodecCoreOptions, O as OpenAPIHandlerCodecOptions, d as OpenAPIMatcher, e as OpenAPIMatcherOptions } from '../../shared/openapi.
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import '@
|
|
1
|
+
export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecCore, c as OpenAPIHandlerCodecCoreOptions, O as OpenAPIHandlerCodecOptions, d as OpenAPIMatcher, e as OpenAPIMatcherOptions } from '../../shared/openapi.DfmCR1pB.mjs';
|
|
2
|
+
import { ClientContext, ClientOptions, AnyORPCError } from '@orpc/client';
|
|
3
|
+
import { StandardLinkCodec, StandardLinkCodecDecodedResponse } from '@orpc/client/standard';
|
|
4
|
+
import { RouterContract } from '@orpc/contract';
|
|
5
|
+
import { Value, Promisable, Public } from '@orpc/shared';
|
|
6
|
+
import { StandardUrl, StandardHeaders, StandardLazyResponse, StandardRequest } from '@standard-server/core';
|
|
7
|
+
import { OpenAPISerializer } from '../../index.mjs';
|
|
7
8
|
import '@orpc/server';
|
|
8
9
|
import '@orpc/server/standard';
|
|
9
|
-
import '@orpc/contract';
|
|
10
|
-
import '@orpc/client/standard';
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
interface OpenAPILinkCodecOptions<T extends ClientContext> {
|
|
12
|
+
/**
|
|
13
|
+
* Base URL for all requests, without origin. Should match the OpenAPI handler mount path.
|
|
14
|
+
*
|
|
15
|
+
* @example '/api'
|
|
16
|
+
* @default '/'
|
|
17
|
+
*/
|
|
18
|
+
url?: Value<Promisable<StandardUrl>, [options: ClientOptions<T>, path: string[], input: unknown]> | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Inject headers into the request.
|
|
21
|
+
*/
|
|
22
|
+
headers?: Value<Promisable<StandardHeaders | Headers>, [options: ClientOptions<T>, path: string[], input: unknown]> | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Override the default OpenAPI serializer.
|
|
25
|
+
*/
|
|
26
|
+
serializer?: Public<OpenAPISerializer> | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Customize how an error response body is converted into an ORPC error.
|
|
29
|
+
* Return `null` or `undefined` to fall back to the default decoding behavior.
|
|
30
|
+
*/
|
|
31
|
+
errorResponseBodyDecoder?: ((deserializedBody: unknown, response: StandardLazyResponse) => AnyORPCError | null | undefined) | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Parse error responses with this `content-type` as JSON, ignoring case and parameters such as `charset`.
|
|
34
|
+
* Should match the handler's `errorResponseContentType`.
|
|
35
|
+
*
|
|
36
|
+
* @example 'application/problem+json'
|
|
37
|
+
*/
|
|
38
|
+
errorResponseContentType?: string | undefined;
|
|
39
|
+
}
|
|
40
|
+
declare class OpenAPILinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
|
|
41
|
+
private readonly router;
|
|
42
|
+
private readonly baseUrl;
|
|
43
|
+
private readonly headers;
|
|
44
|
+
private readonly serializer;
|
|
45
|
+
private readonly errorResponseBodyDecoder;
|
|
46
|
+
private readonly errorResponseMediaType;
|
|
47
|
+
constructor(router: RouterContract, options?: OpenAPILinkCodecOptions<T>);
|
|
48
|
+
encodeInput(input: unknown, path: string[], options: ClientOptions<T>): Promise<StandardRequest>;
|
|
49
|
+
private encodePathParam;
|
|
50
|
+
private serializeQueryString;
|
|
51
|
+
decodeResponse(response: StandardLazyResponse, path: string[], _options: ClientOptions<T>): Promise<StandardLinkCodecDecodedResponse>;
|
|
52
|
+
private resolveProcedure;
|
|
53
|
+
}
|
|
13
54
|
|
|
14
|
-
export {
|
|
55
|
+
export { OpenAPILinkCodec };
|
|
56
|
+
export type { OpenAPILinkCodecOptions };
|
|
@@ -1,14 +1,56 @@
|
|
|
1
|
-
export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecCore, c as OpenAPIHandlerCodecCoreOptions, O as OpenAPIHandlerCodecOptions, d as OpenAPIMatcher, e as OpenAPIMatcherOptions } from '../../shared/openapi.
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import '@
|
|
1
|
+
export { a as OpenAPIHandlerCodec, b as OpenAPIHandlerCodecCore, c as OpenAPIHandlerCodecCoreOptions, O as OpenAPIHandlerCodecOptions, d as OpenAPIMatcher, e as OpenAPIMatcherOptions } from '../../shared/openapi.Y4K_-I5W.js';
|
|
2
|
+
import { ClientContext, ClientOptions, AnyORPCError } from '@orpc/client';
|
|
3
|
+
import { StandardLinkCodec, StandardLinkCodecDecodedResponse } from '@orpc/client/standard';
|
|
4
|
+
import { RouterContract } from '@orpc/contract';
|
|
5
|
+
import { Value, Promisable, Public } from '@orpc/shared';
|
|
6
|
+
import { StandardUrl, StandardHeaders, StandardLazyResponse, StandardRequest } from '@standard-server/core';
|
|
7
|
+
import { OpenAPISerializer } from '../../index.js';
|
|
7
8
|
import '@orpc/server';
|
|
8
9
|
import '@orpc/server/standard';
|
|
9
|
-
import '@orpc/contract';
|
|
10
|
-
import '@orpc/client/standard';
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
interface OpenAPILinkCodecOptions<T extends ClientContext> {
|
|
12
|
+
/**
|
|
13
|
+
* Base URL for all requests, without origin. Should match the OpenAPI handler mount path.
|
|
14
|
+
*
|
|
15
|
+
* @example '/api'
|
|
16
|
+
* @default '/'
|
|
17
|
+
*/
|
|
18
|
+
url?: Value<Promisable<StandardUrl>, [options: ClientOptions<T>, path: string[], input: unknown]> | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* Inject headers into the request.
|
|
21
|
+
*/
|
|
22
|
+
headers?: Value<Promisable<StandardHeaders | Headers>, [options: ClientOptions<T>, path: string[], input: unknown]> | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Override the default OpenAPI serializer.
|
|
25
|
+
*/
|
|
26
|
+
serializer?: Public<OpenAPISerializer> | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Customize how an error response body is converted into an ORPC error.
|
|
29
|
+
* Return `null` or `undefined` to fall back to the default decoding behavior.
|
|
30
|
+
*/
|
|
31
|
+
errorResponseBodyDecoder?: ((deserializedBody: unknown, response: StandardLazyResponse) => AnyORPCError | null | undefined) | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Parse error responses with this `content-type` as JSON, ignoring case and parameters such as `charset`.
|
|
34
|
+
* Should match the handler's `errorResponseContentType`.
|
|
35
|
+
*
|
|
36
|
+
* @example 'application/problem+json'
|
|
37
|
+
*/
|
|
38
|
+
errorResponseContentType?: string | undefined;
|
|
39
|
+
}
|
|
40
|
+
declare class OpenAPILinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
|
|
41
|
+
private readonly router;
|
|
42
|
+
private readonly baseUrl;
|
|
43
|
+
private readonly headers;
|
|
44
|
+
private readonly serializer;
|
|
45
|
+
private readonly errorResponseBodyDecoder;
|
|
46
|
+
private readonly errorResponseMediaType;
|
|
47
|
+
constructor(router: RouterContract, options?: OpenAPILinkCodecOptions<T>);
|
|
48
|
+
encodeInput(input: unknown, path: string[], options: ClientOptions<T>): Promise<StandardRequest>;
|
|
49
|
+
private encodePathParam;
|
|
50
|
+
private serializeQueryString;
|
|
51
|
+
decodeResponse(response: StandardLazyResponse, path: string[], _options: ClientOptions<T>): Promise<StandardLinkCodecDecodedResponse>;
|
|
52
|
+
private resolveProcedure;
|
|
53
|
+
}
|
|
13
54
|
|
|
14
|
-
export {
|
|
55
|
+
export { OpenAPILinkCodec };
|
|
56
|
+
export type { OpenAPILinkCodecOptions };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { O as OpenAPIHandlerCodec, a as OpenAPIHandlerCodecCore, b as OpenAPIMatcher
|
|
2
|
-
export { O as OpenAPILinkCodec } from '../../shared/openapi.
|
|
1
|
+
export { O as OpenAPIHandlerCodec, a as OpenAPIHandlerCodecCore, b as OpenAPIMatcher } from '../../shared/openapi.g7ucL05o.mjs';
|
|
2
|
+
export { O as OpenAPILinkCodec } from '../../shared/openapi.CQkXu1nY.mjs';
|
|
3
3
|
import '@orpc/client';
|
|
4
4
|
import '@orpc/server';
|
|
5
5
|
import '@orpc/shared';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { B as BracketNotationSerializeResult, b as BracketNotationSerializer, c as BracketNotationSerializerOptions, d as OpenAPIJsonSerialization, e as OpenAPIJsonSerializerHandler, f as OpenAPIJsonSerializerOptions,
|
|
1
|
+
import { a as OpenAPIJsonSerializer } from './shared/openapi.YMRD3b4R.mjs';
|
|
2
|
+
export { B as BracketNotationSerializeResult, b as BracketNotationSerializer, c as BracketNotationSerializerOptions, d as OpenAPIJsonSerialization, e as OpenAPIJsonSerializerHandler, f as OpenAPIJsonSerializerOptions, O as OpenAPISerializer, g as OpenAPISerializerOptions, h as OpenAPISerializerSerializeOptions } from './shared/openapi.YMRD3b4R.mjs';
|
|
3
3
|
import { ClientContext, ORPCClientOptions, ClientLink } from '@orpc/client';
|
|
4
4
|
export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
|
|
5
5
|
import { RouterContract, RouterContractClient, AnyProcedureContract, ProcedureContract } from '@orpc/contract';
|
|
6
|
-
import { J as JsonifiedClient,
|
|
7
|
-
export { b as JsonifiedArray, c as JsonifiedClientError, d as JsonifiedValue } from './shared/openapi.
|
|
8
|
-
export { a as OpenAPIFunction, O as OpenAPIMeta, b as OpenAPIMetaPlugin, c as OpenAPIMethodMetaPlugin, d as OpenAPIPathMetaPlugin, e as OpenAPIPrefixMetaPlugin, f as OpenAPISpecMetaPlugin, g as getOpenAPIMeta, o as openapi } from './shared/openapi.
|
|
6
|
+
import { J as JsonifiedClient, a as OpenAPIVersion, O as OpenAPIDocument } from './shared/openapi.Covi8zVE.mjs';
|
|
7
|
+
export { b as JsonifiedArray, c as JsonifiedClientError, d as JsonifiedValue } from './shared/openapi.Covi8zVE.mjs';
|
|
8
|
+
export { a as OpenAPIFunction, O as OpenAPIMeta, b as OpenAPIMetaPlugin, c as OpenAPIMethodMetaPlugin, d as OpenAPIPathMetaPlugin, e as OpenAPIPrefixMetaPlugin, f as OpenAPISpecMetaPlugin, g as getOpenAPIMeta, o as openapi } from './shared/openapi.zGZlCOwp.mjs';
|
|
9
9
|
import { JsonSchema, JsonSchemaConverter } from '@orpc/json-schema';
|
|
10
|
+
export { JsonSchema } from '@orpc/json-schema';
|
|
10
11
|
import { AnyRouter, AnyProcedure } from '@orpc/server';
|
|
11
12
|
import { Public, Value } from '@orpc/shared';
|
|
12
13
|
import * as OpenAPIV3_2 from '@openapi-spec/types/v3.2';
|
|
@@ -28,18 +29,19 @@ interface ContractJsonifiedClientFactoryOptions<TClientContext extends ClientCon
|
|
|
28
29
|
*/
|
|
29
30
|
contractRef?: RouterContract | undefined;
|
|
30
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Like `createContractClientFactory`, but the clients it builds are typed as `JsonifiedClient`,
|
|
34
|
+
* for links that require it, such as OpenAPI Link.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* **Warning**: Every procedure contract passed to the factory must define `meta.path` matching its location in the root contract.
|
|
38
|
+
*
|
|
39
|
+
* @see {@link https://orpc.dev/docs/contract/client-factory | Contract Client Factory}
|
|
40
|
+
*/
|
|
31
41
|
declare function createContractJsonifiedClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedClientFactoryOptions<TClientContext>): ContractJsonifiedClientFactory<TClientContext>;
|
|
32
42
|
|
|
33
43
|
declare const DEFAULT_OPENAPI_METHOD = "POST";
|
|
34
|
-
declare const DEFAULT_OPENAPI_SUCCESS_DESCRIPTION = "OK";
|
|
35
|
-
declare const DEFAULT_OPENAPI_INPUT_STRUCTURE = "compact";
|
|
36
|
-
declare const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = "compact";
|
|
37
44
|
|
|
38
|
-
/**
|
|
39
|
-
* GET and HEAD requests cannot carry a request body,
|
|
40
|
-
* so their compact input maps to query parameters instead.
|
|
41
|
-
*/
|
|
42
|
-
declare function isBodylessMethod(method: string): boolean;
|
|
43
45
|
/**
|
|
44
46
|
* Dynamic parameters are always returned in path order.
|
|
45
47
|
*/
|
|
@@ -91,7 +93,7 @@ interface OpenAPIGeneratorGenerateOptions<TVersion extends OpenAPIVersion> {
|
|
|
91
93
|
*
|
|
92
94
|
* @default defName => defName
|
|
93
95
|
*/
|
|
94
|
-
|
|
96
|
+
componentName?: ((defName: string, defSchema: JsonSchema) => string | undefined) | undefined;
|
|
95
97
|
/**
|
|
96
98
|
* Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
|
|
97
99
|
*
|
|
@@ -107,10 +109,17 @@ interface OpenAPIGeneratorGenerateOptions<TVersion extends OpenAPIVersion> {
|
|
|
107
109
|
* - Return `null | undefined` to use the default error response body shaper.
|
|
108
110
|
* - The schema is an OpenAPI 3.2 Schema Object, it is downgraded with the rest of the document when an older `version` is requested.
|
|
109
111
|
*/
|
|
110
|
-
|
|
112
|
+
errorResponseBodySchema?: Value<JsonSchema | undefined | null, [
|
|
111
113
|
definedErrors: OpenAPIErrorBodyDefinition[],
|
|
112
114
|
status: number
|
|
113
115
|
]> | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Media type of error responses in the generated document, e.g. `application/problem+json`.
|
|
118
|
+
* Should match the handler's `errorResponseContentType`.
|
|
119
|
+
*
|
|
120
|
+
* @default 'application/json'
|
|
121
|
+
*/
|
|
122
|
+
errorResponseContentType?: string | undefined;
|
|
114
123
|
/**
|
|
115
124
|
* Mapping ORPCError Code -> HTTP Status Code
|
|
116
125
|
* Codes missing from the map fall back to `DEFAULT_ERROR_STATUS` (400).
|
|
@@ -153,5 +162,5 @@ interface PopulateRouterContractOpenAPIPathsOptions {
|
|
|
153
162
|
*/
|
|
154
163
|
declare function populateRouterContractOpenAPIPaths<T extends RouterContract>(router: T, options?: PopulateRouterContractOpenAPIPathsOptions): PopulatedContractRouterOpenAPIPaths<T>;
|
|
155
164
|
|
|
156
|
-
export {
|
|
165
|
+
export { DEFAULT_OPENAPI_METHOD, JsonifiedClient, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPIJsonSerializer, OpenAPIVersion, createContractJsonifiedClientFactory, getDynamicPathParams, populateRouterContractOpenAPIPaths };
|
|
157
166
|
export type { ContractJsonifiedClientFactory, ContractJsonifiedClientFactoryOptions, OpenAPIErrorBodyDefinition, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, PopulateRouterContractOpenAPIPathsOptions, PopulatedContractRouterOpenAPIPaths };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { B as BracketNotationSerializeResult, b as BracketNotationSerializer, c as BracketNotationSerializerOptions, d as OpenAPIJsonSerialization, e as OpenAPIJsonSerializerHandler, f as OpenAPIJsonSerializerOptions,
|
|
1
|
+
import { a as OpenAPIJsonSerializer } from './shared/openapi.YMRD3b4R.js';
|
|
2
|
+
export { B as BracketNotationSerializeResult, b as BracketNotationSerializer, c as BracketNotationSerializerOptions, d as OpenAPIJsonSerialization, e as OpenAPIJsonSerializerHandler, f as OpenAPIJsonSerializerOptions, O as OpenAPISerializer, g as OpenAPISerializerOptions, h as OpenAPISerializerSerializeOptions } from './shared/openapi.YMRD3b4R.js';
|
|
3
3
|
import { ClientContext, ORPCClientOptions, ClientLink } from '@orpc/client';
|
|
4
4
|
export { COMMON_ERROR_STATUS_MAP } from '@orpc/client';
|
|
5
5
|
import { RouterContract, RouterContractClient, AnyProcedureContract, ProcedureContract } from '@orpc/contract';
|
|
6
|
-
import { J as JsonifiedClient,
|
|
7
|
-
export { b as JsonifiedArray, c as JsonifiedClientError, d as JsonifiedValue } from './shared/openapi.
|
|
8
|
-
export { a as OpenAPIFunction, O as OpenAPIMeta, b as OpenAPIMetaPlugin, c as OpenAPIMethodMetaPlugin, d as OpenAPIPathMetaPlugin, e as OpenAPIPrefixMetaPlugin, f as OpenAPISpecMetaPlugin, g as getOpenAPIMeta, o as openapi } from './shared/openapi.
|
|
6
|
+
import { J as JsonifiedClient, a as OpenAPIVersion, O as OpenAPIDocument } from './shared/openapi.Covi8zVE.js';
|
|
7
|
+
export { b as JsonifiedArray, c as JsonifiedClientError, d as JsonifiedValue } from './shared/openapi.Covi8zVE.js';
|
|
8
|
+
export { a as OpenAPIFunction, O as OpenAPIMeta, b as OpenAPIMetaPlugin, c as OpenAPIMethodMetaPlugin, d as OpenAPIPathMetaPlugin, e as OpenAPIPrefixMetaPlugin, f as OpenAPISpecMetaPlugin, g as getOpenAPIMeta, o as openapi } from './shared/openapi.zGZlCOwp.js';
|
|
9
9
|
import { JsonSchema, JsonSchemaConverter } from '@orpc/json-schema';
|
|
10
|
+
export { JsonSchema } from '@orpc/json-schema';
|
|
10
11
|
import { AnyRouter, AnyProcedure } from '@orpc/server';
|
|
11
12
|
import { Public, Value } from '@orpc/shared';
|
|
12
13
|
import * as OpenAPIV3_2 from '@openapi-spec/types/v3.2';
|
|
@@ -28,18 +29,19 @@ interface ContractJsonifiedClientFactoryOptions<TClientContext extends ClientCon
|
|
|
28
29
|
*/
|
|
29
30
|
contractRef?: RouterContract | undefined;
|
|
30
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Like `createContractClientFactory`, but the clients it builds are typed as `JsonifiedClient`,
|
|
34
|
+
* for links that require it, such as OpenAPI Link.
|
|
35
|
+
*
|
|
36
|
+
* @remarks
|
|
37
|
+
* **Warning**: Every procedure contract passed to the factory must define `meta.path` matching its location in the root contract.
|
|
38
|
+
*
|
|
39
|
+
* @see {@link https://orpc.dev/docs/contract/client-factory | Contract Client Factory}
|
|
40
|
+
*/
|
|
31
41
|
declare function createContractJsonifiedClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractJsonifiedClientFactoryOptions<TClientContext>): ContractJsonifiedClientFactory<TClientContext>;
|
|
32
42
|
|
|
33
43
|
declare const DEFAULT_OPENAPI_METHOD = "POST";
|
|
34
|
-
declare const DEFAULT_OPENAPI_SUCCESS_DESCRIPTION = "OK";
|
|
35
|
-
declare const DEFAULT_OPENAPI_INPUT_STRUCTURE = "compact";
|
|
36
|
-
declare const DEFAULT_OPENAPI_OUTPUT_STRUCTURE = "compact";
|
|
37
44
|
|
|
38
|
-
/**
|
|
39
|
-
* GET and HEAD requests cannot carry a request body,
|
|
40
|
-
* so their compact input maps to query parameters instead.
|
|
41
|
-
*/
|
|
42
|
-
declare function isBodylessMethod(method: string): boolean;
|
|
43
45
|
/**
|
|
44
46
|
* Dynamic parameters are always returned in path order.
|
|
45
47
|
*/
|
|
@@ -91,7 +93,7 @@ interface OpenAPIGeneratorGenerateOptions<TVersion extends OpenAPIVersion> {
|
|
|
91
93
|
*
|
|
92
94
|
* @default defName => defName
|
|
93
95
|
*/
|
|
94
|
-
|
|
96
|
+
componentName?: ((defName: string, defSchema: JsonSchema) => string | undefined) | undefined;
|
|
95
97
|
/**
|
|
96
98
|
* Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
|
|
97
99
|
*
|
|
@@ -107,10 +109,17 @@ interface OpenAPIGeneratorGenerateOptions<TVersion extends OpenAPIVersion> {
|
|
|
107
109
|
* - Return `null | undefined` to use the default error response body shaper.
|
|
108
110
|
* - The schema is an OpenAPI 3.2 Schema Object, it is downgraded with the rest of the document when an older `version` is requested.
|
|
109
111
|
*/
|
|
110
|
-
|
|
112
|
+
errorResponseBodySchema?: Value<JsonSchema | undefined | null, [
|
|
111
113
|
definedErrors: OpenAPIErrorBodyDefinition[],
|
|
112
114
|
status: number
|
|
113
115
|
]> | undefined;
|
|
116
|
+
/**
|
|
117
|
+
* Media type of error responses in the generated document, e.g. `application/problem+json`.
|
|
118
|
+
* Should match the handler's `errorResponseContentType`.
|
|
119
|
+
*
|
|
120
|
+
* @default 'application/json'
|
|
121
|
+
*/
|
|
122
|
+
errorResponseContentType?: string | undefined;
|
|
114
123
|
/**
|
|
115
124
|
* Mapping ORPCError Code -> HTTP Status Code
|
|
116
125
|
* Codes missing from the map fall back to `DEFAULT_ERROR_STATUS` (400).
|
|
@@ -153,5 +162,5 @@ interface PopulateRouterContractOpenAPIPathsOptions {
|
|
|
153
162
|
*/
|
|
154
163
|
declare function populateRouterContractOpenAPIPaths<T extends RouterContract>(router: T, options?: PopulateRouterContractOpenAPIPathsOptions): PopulatedContractRouterOpenAPIPaths<T>;
|
|
155
164
|
|
|
156
|
-
export {
|
|
165
|
+
export { DEFAULT_OPENAPI_METHOD, JsonifiedClient, OpenAPIDocument, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPIJsonSerializer, OpenAPIVersion, createContractJsonifiedClientFactory, getDynamicPathParams, populateRouterContractOpenAPIPaths };
|
|
157
166
|
export type { ContractJsonifiedClientFactory, ContractJsonifiedClientFactoryOptions, OpenAPIErrorBodyDefinition, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, PopulateRouterContractOpenAPIPathsOptions, PopulatedContractRouterOpenAPIPaths };
|
package/dist/index.mjs
CHANGED
|
@@ -18,9 +18,9 @@ function createContractJsonifiedClientFactory(link, options = {}) {
|
|
|
18
18
|
const DEFS_REF_PREFIX = "#/$defs/";
|
|
19
19
|
const COMPONENTS_REF_PREFIX = "#/components/schemas/";
|
|
20
20
|
class OpenAPIComponentRegistry {
|
|
21
|
-
constructor(doc,
|
|
21
|
+
constructor(doc, componentName) {
|
|
22
22
|
this.doc = doc;
|
|
23
|
-
this.
|
|
23
|
+
this.componentName = componentName;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Registers `schema` as a component under `preferredName` (or an equivalent/postfixed name)
|
|
@@ -68,7 +68,7 @@ class OpenAPIComponentRegistry {
|
|
|
68
68
|
componentsSchemas,
|
|
69
69
|
new Set(renameMap.values()),
|
|
70
70
|
defName,
|
|
71
|
-
this.
|
|
71
|
+
this.componentName?.(defName, cleanSchema) ?? defName,
|
|
72
72
|
defs,
|
|
73
73
|
direction
|
|
74
74
|
);
|
|
@@ -366,6 +366,7 @@ function renderQueryParameters(ctx, operation, queryEntries, queryStyles) {
|
|
|
366
366
|
"application/json": { schema: parameter.schema }
|
|
367
367
|
};
|
|
368
368
|
delete parameter.schema;
|
|
369
|
+
delete parameter.allowReserved;
|
|
369
370
|
} else if (style === void 0) {
|
|
370
371
|
if (flattenJsonUnionSchema(schema).some((s) => !isJsonPrimitiveSchema(s))) {
|
|
371
372
|
const arrayable = matchArrayableJsonSchema(schema);
|
|
@@ -537,7 +538,7 @@ function buildErrorResponse(ctx, operation, def) {
|
|
|
537
538
|
for (const [status, definitions] of definitionsByStatus.entries()) {
|
|
538
539
|
const descriptions = definitions.map(({ defaultMessage }) => defaultMessage).filter((m) => m !== void 0);
|
|
539
540
|
const customBodySchema = value(
|
|
540
|
-
ctx.
|
|
541
|
+
ctx.errorResponseBodySchema,
|
|
541
542
|
definitions.map((def2) => ({ ...def2, dataJsonSchema: ctx.registry.hoistDefs(def2.dataJsonSchema, "output") })),
|
|
542
543
|
status
|
|
543
544
|
);
|
|
@@ -560,7 +561,7 @@ function buildErrorResponse(ctx, operation, def) {
|
|
|
560
561
|
operation.responses[toResponseStatusKey(status)] = {
|
|
561
562
|
description: descriptions.length ? descriptions.join(", ") : status.toString(),
|
|
562
563
|
content: {
|
|
563
|
-
|
|
564
|
+
[ctx.errorResponseContentType]: {
|
|
564
565
|
schema: ctx.registry.toOpenAPISchema(responseSchema, "output")
|
|
565
566
|
}
|
|
566
567
|
}
|
|
@@ -657,10 +658,11 @@ class OpenAPIGenerator {
|
|
|
657
658
|
info: options.base?.info ?? { title: "API Reference", version: "0.0.0" }
|
|
658
659
|
};
|
|
659
660
|
const ctx = {
|
|
660
|
-
registry: new OpenAPIComponentRegistry(doc, options.
|
|
661
|
+
registry: new OpenAPIComponentRegistry(doc, options.componentName),
|
|
661
662
|
convertSchemas: (schemas, direction) => this.convertSchemas(schemas, direction),
|
|
662
663
|
errorStatusMap: options.errorStatusMap ?? COMMON_ERROR_STATUS_MAP,
|
|
663
|
-
|
|
664
|
+
errorResponseBodySchema: options.errorResponseBodySchema,
|
|
665
|
+
errorResponseContentType: options.errorResponseContentType ?? "application/json"
|
|
664
666
|
};
|
|
665
667
|
const errors = [];
|
|
666
668
|
await walkProcedureContractsAsync(router, (contract, path) => {
|
|
@@ -775,4 +777,4 @@ function populateRouterContractOpenAPIPaths(router, options = {}) {
|
|
|
775
777
|
return populated;
|
|
776
778
|
}
|
|
777
779
|
|
|
778
|
-
export {
|
|
780
|
+
export { DEFAULT_OPENAPI_METHOD, OpenAPIGenerator, OpenAPIGeneratorError, OpenAPIJsonSerializer, createContractJsonifiedClientFactory, getDynamicPathParams, getOpenAPIMeta, openapi, populateRouterContractOpenAPIPaths };
|
|
@@ -2,11 +2,11 @@ import { MalformedResponseError, isORPCErrorJson, createORPCErrorFromJson, Respo
|
|
|
2
2
|
import { getRouterContract, ProcedureContract } from '@orpc/contract';
|
|
3
3
|
import { unlazy } from '@orpc/server';
|
|
4
4
|
import { value, pathToHttpPath, mergeHttpPath, isTypescriptObject, stringifyJSON, safeEncodeURIComponent } from '@orpc/shared';
|
|
5
|
-
import { mergeStandardHeaders, parseStandardUrl } from '@standard-server/core';
|
|
5
|
+
import { mergeStandardHeaders, parseStandardUrl, flattenStandardHeader } from '@standard-server/core';
|
|
6
6
|
import { toStandardHeaders } from '@standard-server/fetch';
|
|
7
7
|
import { O as OpenAPISerializer, D as DEFAULT_OPENAPI_METHOD, a as DEFAULT_OPENAPI_INPUT_STRUCTURE, g as getDynamicPathParams, i as isBodylessMethod, b as DEFAULT_OPENAPI_OUTPUT_STRUCTURE } from './openapi.E3ZBiweM.mjs';
|
|
8
8
|
import { g as getOpenAPIMeta } from './openapi.B9PQzqBn.mjs';
|
|
9
|
-
import { s as serializeHeaders } from './openapi.
|
|
9
|
+
import { s as serializeHeaders } from './openapi.g7ucL05o.mjs';
|
|
10
10
|
|
|
11
11
|
const END_SLASH_REGEX = /\/$/;
|
|
12
12
|
const DOT_SEGMENT_REGEX = /(?:^|\/)\.{1,2}(?:\/|$)/;
|
|
@@ -16,12 +16,14 @@ class OpenAPILinkCodec {
|
|
|
16
16
|
this.baseUrl = options.url ?? "/";
|
|
17
17
|
this.headers = options.headers ?? {};
|
|
18
18
|
this.serializer = options.serializer ?? new OpenAPISerializer();
|
|
19
|
-
this.
|
|
19
|
+
this.errorResponseBodyDecoder = options.errorResponseBodyDecoder;
|
|
20
|
+
this.errorResponseMediaType = toMediaType(options.errorResponseContentType);
|
|
20
21
|
}
|
|
21
22
|
baseUrl;
|
|
22
23
|
headers;
|
|
23
24
|
serializer;
|
|
24
|
-
|
|
25
|
+
errorResponseBodyDecoder;
|
|
26
|
+
errorResponseMediaType;
|
|
25
27
|
async encodeInput(input, path, options) {
|
|
26
28
|
let headers = toResolvedStandardHeaders(await value(this.headers, options, path, input));
|
|
27
29
|
if (options.lastEventId !== void 0) {
|
|
@@ -252,7 +254,8 @@ class OpenAPILinkCodec {
|
|
|
252
254
|
const isOk = response.status < 400;
|
|
253
255
|
const procedure = await this.resolveProcedure(path);
|
|
254
256
|
const meta = getOpenAPIMeta(procedure);
|
|
255
|
-
const
|
|
257
|
+
const errorBodyHint = !isOk && this.errorResponseMediaType !== void 0 && toMediaType(flattenStandardHeader(response.headers["content-type"])) === this.errorResponseMediaType ? "json" : void 0;
|
|
258
|
+
const body = await response.resolveBody(isOk ? meta?.responseBodyHint : errorBodyHint);
|
|
256
259
|
const deserialized = await (async () => {
|
|
257
260
|
try {
|
|
258
261
|
return this.serializer.deserialize(body);
|
|
@@ -265,7 +268,7 @@ class OpenAPILinkCodec {
|
|
|
265
268
|
}
|
|
266
269
|
})();
|
|
267
270
|
if (!isOk) {
|
|
268
|
-
const customError = this.
|
|
271
|
+
const customError = this.errorResponseBodyDecoder?.(deserialized, response);
|
|
269
272
|
if (customError !== void 0 && customError !== null) {
|
|
270
273
|
return { kind: "error", error: customError };
|
|
271
274
|
}
|
|
@@ -309,6 +312,9 @@ function combineSearch(baseSearch, additionalSearch) {
|
|
|
309
312
|
}
|
|
310
313
|
return `${baseSearch}&${additionalSearch}`;
|
|
311
314
|
}
|
|
315
|
+
function toMediaType(contentType) {
|
|
316
|
+
return contentType?.split(";")[0]?.trim().toLowerCase();
|
|
317
|
+
}
|
|
312
318
|
function toResolvedStandardHeaders(headers) {
|
|
313
319
|
if (typeof headers.forEach === "function") {
|
|
314
320
|
return toStandardHeaders(headers);
|
|
@@ -30,4 +30,4 @@ type JsonifiedClient<T extends AnyNestedClient> = T extends Client<infer UClient
|
|
|
30
30
|
[K in keyof T]: T[K] extends AnyNestedClient ? JsonifiedClient<T[K]> : T[K];
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
export type { JsonifiedClient as J,
|
|
33
|
+
export type { JsonifiedClient as J, OpenAPIDocument as O, OpenAPIVersion as a, JsonifiedArray as b, JsonifiedClientError as c, JsonifiedValue as d };
|
|
@@ -30,4 +30,4 @@ type JsonifiedClient<T extends AnyNestedClient> = T extends Client<infer UClient
|
|
|
30
30
|
[K in keyof T]: T[K] extends AnyNestedClient ? JsonifiedClient<T[K]> : T[K];
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
export type { JsonifiedClient as J,
|
|
33
|
+
export type { JsonifiedClient as J, OpenAPIDocument as O, OpenAPIVersion as a, JsonifiedArray as b, JsonifiedClientError as c, JsonifiedValue as d };
|
|
@@ -4,7 +4,7 @@ import { StandardHandlerCodec, ResolvedStandardHandlerHandleOptions, StandardHan
|
|
|
4
4
|
import { Value, Public, Promisable } from '@orpc/shared';
|
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@standard-server/core';
|
|
6
6
|
import { AnyProcedureContract } from '@orpc/contract';
|
|
7
|
-
import {
|
|
7
|
+
import { O as OpenAPISerializer } from './openapi.YMRD3b4R.mjs';
|
|
8
8
|
|
|
9
9
|
interface OpenAPIMatcherOptions {
|
|
10
10
|
/**
|
|
@@ -56,12 +56,19 @@ interface OpenAPIHandlerCodecCoreOptions<_T extends Context> {
|
|
|
56
56
|
*
|
|
57
57
|
* @default ((e) => e.toJSON())
|
|
58
58
|
*/
|
|
59
|
-
|
|
59
|
+
errorResponseBodyEncoder?: ((error: AnyORPCError) => unknown) | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* The `content-type` of error responses, e.g. `application/problem+json` for RFC 9457 Problem Details.
|
|
62
|
+
*
|
|
63
|
+
* @default 'application/json'
|
|
64
|
+
*/
|
|
65
|
+
errorResponseContentType?: string | undefined;
|
|
60
66
|
}
|
|
61
67
|
declare class OpenAPIHandlerCodecCore<T extends Context> {
|
|
62
68
|
private readonly serializer;
|
|
63
69
|
private readonly errorStatusMap;
|
|
64
|
-
private readonly
|
|
70
|
+
private readonly errorResponseBodyEncoder;
|
|
71
|
+
private readonly errorResponseContentType;
|
|
65
72
|
constructor(options?: OpenAPIHandlerCodecCoreOptions<T>);
|
|
66
73
|
decodeInput(matched: {
|
|
67
74
|
procedure: AnyProcedure;
|
|
@@ -4,7 +4,7 @@ import { StandardHandlerCodec, ResolvedStandardHandlerHandleOptions, StandardHan
|
|
|
4
4
|
import { Value, Public, Promisable } from '@orpc/shared';
|
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@standard-server/core';
|
|
6
6
|
import { AnyProcedureContract } from '@orpc/contract';
|
|
7
|
-
import {
|
|
7
|
+
import { O as OpenAPISerializer } from './openapi.YMRD3b4R.js';
|
|
8
8
|
|
|
9
9
|
interface OpenAPIMatcherOptions {
|
|
10
10
|
/**
|
|
@@ -56,12 +56,19 @@ interface OpenAPIHandlerCodecCoreOptions<_T extends Context> {
|
|
|
56
56
|
*
|
|
57
57
|
* @default ((e) => e.toJSON())
|
|
58
58
|
*/
|
|
59
|
-
|
|
59
|
+
errorResponseBodyEncoder?: ((error: AnyORPCError) => unknown) | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* The `content-type` of error responses, e.g. `application/problem+json` for RFC 9457 Problem Details.
|
|
62
|
+
*
|
|
63
|
+
* @default 'application/json'
|
|
64
|
+
*/
|
|
65
|
+
errorResponseContentType?: string | undefined;
|
|
60
66
|
}
|
|
61
67
|
declare class OpenAPIHandlerCodecCore<T extends Context> {
|
|
62
68
|
private readonly serializer;
|
|
63
69
|
private readonly errorStatusMap;
|
|
64
|
-
private readonly
|
|
70
|
+
private readonly errorResponseBodyEncoder;
|
|
71
|
+
private readonly errorResponseContentType;
|
|
65
72
|
constructor(options?: OpenAPIHandlerCodecCoreOptions<T>);
|
|
66
73
|
decodeInput(matched: {
|
|
67
74
|
procedure: AnyProcedure;
|
|
@@ -93,6 +93,12 @@ interface OpenAPIJsonSerializerOptions {
|
|
|
93
93
|
*/
|
|
94
94
|
omitUndefinedProperties?: boolean | undefined;
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* The JSON layer behind `OpenAPISerializer`: one-way serialization of types like `Date`, `BigInt`,
|
|
98
|
+
* and `Set` into JSON-friendly values, for places that only accept JSON.
|
|
99
|
+
*
|
|
100
|
+
* @see {@link https://orpc.dev/docs/openapi/serializer#openapi-json-serializer | OpenAPI Serializer - OpenAPI JSON Serializer}
|
|
101
|
+
*/
|
|
96
102
|
declare class OpenAPIJsonSerializer {
|
|
97
103
|
private readonly inlineBuiltInHandlers;
|
|
98
104
|
private readonly handlerEntries;
|
|
@@ -147,5 +153,5 @@ declare class OpenAPISerializer extends OpenAPIJsonSerializer {
|
|
|
147
153
|
deserialize(data: StandardBody): unknown;
|
|
148
154
|
}
|
|
149
155
|
|
|
150
|
-
export {
|
|
156
|
+
export { OpenAPISerializer as O, OpenAPIJsonSerializer as a, BracketNotationSerializer as b };
|
|
151
157
|
export type { BracketNotationSerializeResult as B, BracketNotationSerializerOptions as c, OpenAPIJsonSerialization as d, OpenAPIJsonSerializerHandler as e, OpenAPIJsonSerializerOptions as f, OpenAPISerializerOptions as g, OpenAPISerializerSerializeOptions as h };
|
|
@@ -93,6 +93,12 @@ interface OpenAPIJsonSerializerOptions {
|
|
|
93
93
|
*/
|
|
94
94
|
omitUndefinedProperties?: boolean | undefined;
|
|
95
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* The JSON layer behind `OpenAPISerializer`: one-way serialization of types like `Date`, `BigInt`,
|
|
98
|
+
* and `Set` into JSON-friendly values, for places that only accept JSON.
|
|
99
|
+
*
|
|
100
|
+
* @see {@link https://orpc.dev/docs/openapi/serializer#openapi-json-serializer | OpenAPI Serializer - OpenAPI JSON Serializer}
|
|
101
|
+
*/
|
|
96
102
|
declare class OpenAPIJsonSerializer {
|
|
97
103
|
private readonly inlineBuiltInHandlers;
|
|
98
104
|
private readonly handlerEntries;
|
|
@@ -147,5 +153,5 @@ declare class OpenAPISerializer extends OpenAPIJsonSerializer {
|
|
|
147
153
|
deserialize(data: StandardBody): unknown;
|
|
148
154
|
}
|
|
149
155
|
|
|
150
|
-
export {
|
|
156
|
+
export { OpenAPISerializer as O, OpenAPIJsonSerializer as a, BracketNotationSerializer as b };
|
|
151
157
|
export type { BracketNotationSerializeResult as B, BracketNotationSerializerOptions as c, OpenAPIJsonSerialization as d, OpenAPIJsonSerializerHandler as e, OpenAPIJsonSerializerOptions as f, OpenAPISerializerOptions as g, OpenAPISerializerSerializeOptions as h };
|
|
@@ -218,11 +218,13 @@ function serializeHeaderValue(value, serializer) {
|
|
|
218
218
|
class OpenAPIHandlerCodecCore {
|
|
219
219
|
serializer;
|
|
220
220
|
errorStatusMap;
|
|
221
|
-
|
|
221
|
+
errorResponseBodyEncoder;
|
|
222
|
+
errorResponseContentType;
|
|
222
223
|
constructor(options = {}) {
|
|
223
224
|
this.serializer = options.serializer ?? new OpenAPISerializer();
|
|
224
225
|
this.errorStatusMap = options.errorStatusMap ?? COMMON_ERROR_STATUS_MAP;
|
|
225
|
-
this.
|
|
226
|
+
this.errorResponseBodyEncoder = options.errorResponseBodyEncoder;
|
|
227
|
+
this.errorResponseContentType = options.errorResponseContentType;
|
|
226
228
|
}
|
|
227
229
|
async decodeInput(matched, request) {
|
|
228
230
|
const meta = getOpenAPIMeta(matched.procedure);
|
|
@@ -288,8 +290,8 @@ class OpenAPIHandlerCodecCore {
|
|
|
288
290
|
const status = getOwn(this.errorStatusMap, error.code) ?? DEFAULT_ERROR_STATUS;
|
|
289
291
|
return {
|
|
290
292
|
status,
|
|
291
|
-
headers: {},
|
|
292
|
-
body: this.serializer.serialize(this.
|
|
293
|
+
headers: this.errorResponseContentType !== void 0 ? { "content-type": this.errorResponseContentType } : {},
|
|
294
|
+
body: this.serializer.serialize(this.errorResponseBodyEncoder?.(error) ?? error.toJSON())
|
|
293
295
|
};
|
|
294
296
|
}
|
|
295
297
|
deserializeQuery(url, styles) {
|
|
@@ -159,7 +159,7 @@ interface OpenAPIMeta {
|
|
|
159
159
|
/**
|
|
160
160
|
* Hint for how to parse the incoming request body.
|
|
161
161
|
*
|
|
162
|
-
* Note:
|
|
162
|
+
* Note: This option takes priority over the `standard-server` and `Content-Type` headers.
|
|
163
163
|
* `form-data` and `url-search-params` are decoded using bracket notation,
|
|
164
164
|
* so the resulting value will be an object or array.
|
|
165
165
|
*
|
|
@@ -167,9 +167,10 @@ interface OpenAPIMeta {
|
|
|
167
167
|
*/
|
|
168
168
|
requestBodyHint?: StandardBodyHint | undefined;
|
|
169
169
|
/**
|
|
170
|
-
* Hint for how to parse
|
|
170
|
+
* Hint for how to parse a successful response body (status below 400).
|
|
171
|
+
* Error response bodies are always parsed from their headers.
|
|
171
172
|
*
|
|
172
|
-
* Note:
|
|
173
|
+
* Note: This option takes priority over the `standard-server` and `Content-Type` headers.
|
|
173
174
|
* `form-data` and `url-search-params` are decoded using bracket notation,
|
|
174
175
|
* so the resulting value will be an object or array.
|
|
175
176
|
*
|
|
@@ -159,7 +159,7 @@ interface OpenAPIMeta {
|
|
|
159
159
|
/**
|
|
160
160
|
* Hint for how to parse the incoming request body.
|
|
161
161
|
*
|
|
162
|
-
* Note:
|
|
162
|
+
* Note: This option takes priority over the `standard-server` and `Content-Type` headers.
|
|
163
163
|
* `form-data` and `url-search-params` are decoded using bracket notation,
|
|
164
164
|
* so the resulting value will be an object or array.
|
|
165
165
|
*
|
|
@@ -167,9 +167,10 @@ interface OpenAPIMeta {
|
|
|
167
167
|
*/
|
|
168
168
|
requestBodyHint?: StandardBodyHint | undefined;
|
|
169
169
|
/**
|
|
170
|
-
* Hint for how to parse
|
|
170
|
+
* Hint for how to parse a successful response body (status below 400).
|
|
171
|
+
* Error response bodies are always parsed from their headers.
|
|
171
172
|
*
|
|
172
|
-
* Note:
|
|
173
|
+
* Note: This option takes priority over the `standard-server` and `Content-Type` headers.
|
|
173
174
|
* `form-data` and `url-search-params` are decoded using bracket notation,
|
|
174
175
|
* so the resulting value will be an object or array.
|
|
175
176
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/openapi",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.47",
|
|
5
5
|
"description": "Generate OpenAPI specs from oRPC routers and serve OpenAPI-compliant APIs with end-to-end type safety",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": [
|
|
@@ -97,20 +97,20 @@
|
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
99
|
"dependencies": {
|
|
100
|
-
"@openapi-spec/downgrader": "~0.
|
|
101
|
-
"@openapi-spec/types": "~0.
|
|
102
|
-
"@orpc/client": "2.0.0-beta.
|
|
103
|
-
"@orpc/contract": "2.0.0-beta.
|
|
104
|
-
"@orpc/json-schema": "2.0.0-beta.
|
|
105
|
-
"@orpc/server": "2.0.0-beta.
|
|
106
|
-
"@orpc/shared": "2.0.0-beta.
|
|
107
|
-
"@standard-server/core": "~0.
|
|
108
|
-
"@standard-server/fetch": "~0.
|
|
100
|
+
"@openapi-spec/downgrader": "~0.4.0",
|
|
101
|
+
"@openapi-spec/types": "~0.4.0",
|
|
102
|
+
"@orpc/client": "2.0.0-beta.47",
|
|
103
|
+
"@orpc/contract": "2.0.0-beta.47",
|
|
104
|
+
"@orpc/json-schema": "2.0.0-beta.47",
|
|
105
|
+
"@orpc/server": "2.0.0-beta.47",
|
|
106
|
+
"@orpc/shared": "2.0.0-beta.47",
|
|
107
|
+
"@standard-server/core": "~0.13.0",
|
|
108
|
+
"@standard-server/fetch": "~0.13.0",
|
|
109
109
|
"rou3": "^1.0.0"
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
112
|
"@scalar/api-reference": "^1.74.0",
|
|
113
|
-
"@standard-server/aws-lambda": "~0.
|
|
113
|
+
"@standard-server/aws-lambda": "~0.13.0",
|
|
114
114
|
"@types/swagger-ui": "^5.32.0",
|
|
115
115
|
"fastify": "^5.12.7",
|
|
116
116
|
"swagger-ui": "^5.33.2",
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { ClientContext, ClientOptions, AnyORPCError } from '@orpc/client';
|
|
2
|
-
import { StandardLinkCodec, StandardLinkCodecDecodedResponse } from '@orpc/client/standard';
|
|
3
|
-
import { RouterContract } from '@orpc/contract';
|
|
4
|
-
import { Value, Promisable, Public } from '@orpc/shared';
|
|
5
|
-
import { StandardUrl, StandardHeaders, StandardLazyResponse, StandardRequest } from '@standard-server/core';
|
|
6
|
-
import { a as OpenAPISerializer } from './openapi.D42Ps1fQ.js';
|
|
7
|
-
|
|
8
|
-
interface OpenAPILinkCodecOptions<T extends ClientContext> {
|
|
9
|
-
/**
|
|
10
|
-
* Base URL for all requests, without origin. Should match the OpenAPI handler mount path.
|
|
11
|
-
*
|
|
12
|
-
* @example '/api'
|
|
13
|
-
* @default '/'
|
|
14
|
-
*/
|
|
15
|
-
url?: Value<Promisable<StandardUrl>, [options: ClientOptions<T>, path: string[], input: unknown]> | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Inject headers into the request.
|
|
18
|
-
*/
|
|
19
|
-
headers?: Value<Promisable<StandardHeaders | Headers>, [options: ClientOptions<T>, path: string[], input: unknown]> | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Override the default OpenAPI serializer.
|
|
22
|
-
*/
|
|
23
|
-
serializer?: Public<OpenAPISerializer> | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Customize how an error response body is converted into an ORPC error.
|
|
26
|
-
* Return `null` or `undefined` to fall back to the default decoding behavior.
|
|
27
|
-
*/
|
|
28
|
-
customErrorResponseBodyDecoder?: ((deserializedBody: unknown, response: StandardLazyResponse) => AnyORPCError | null | undefined) | undefined;
|
|
29
|
-
}
|
|
30
|
-
declare class OpenAPILinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
|
|
31
|
-
private readonly router;
|
|
32
|
-
private readonly baseUrl;
|
|
33
|
-
private readonly headers;
|
|
34
|
-
private readonly serializer;
|
|
35
|
-
private readonly customErrorResponseBodyDecoder;
|
|
36
|
-
constructor(router: RouterContract, options?: OpenAPILinkCodecOptions<T>);
|
|
37
|
-
encodeInput(input: unknown, path: string[], options: ClientOptions<T>): Promise<StandardRequest>;
|
|
38
|
-
private encodePathParam;
|
|
39
|
-
private serializeQueryString;
|
|
40
|
-
decodeResponse(response: StandardLazyResponse, path: string[], _options: ClientOptions<T>): Promise<StandardLinkCodecDecodedResponse>;
|
|
41
|
-
private resolveProcedure;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { OpenAPILinkCodec as a };
|
|
45
|
-
export type { OpenAPILinkCodecOptions as O };
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { ClientContext, ClientOptions, AnyORPCError } from '@orpc/client';
|
|
2
|
-
import { StandardLinkCodec, StandardLinkCodecDecodedResponse } from '@orpc/client/standard';
|
|
3
|
-
import { RouterContract } from '@orpc/contract';
|
|
4
|
-
import { Value, Promisable, Public } from '@orpc/shared';
|
|
5
|
-
import { StandardUrl, StandardHeaders, StandardLazyResponse, StandardRequest } from '@standard-server/core';
|
|
6
|
-
import { a as OpenAPISerializer } from './openapi.D42Ps1fQ.mjs';
|
|
7
|
-
|
|
8
|
-
interface OpenAPILinkCodecOptions<T extends ClientContext> {
|
|
9
|
-
/**
|
|
10
|
-
* Base URL for all requests, without origin. Should match the OpenAPI handler mount path.
|
|
11
|
-
*
|
|
12
|
-
* @example '/api'
|
|
13
|
-
* @default '/'
|
|
14
|
-
*/
|
|
15
|
-
url?: Value<Promisable<StandardUrl>, [options: ClientOptions<T>, path: string[], input: unknown]> | undefined;
|
|
16
|
-
/**
|
|
17
|
-
* Inject headers into the request.
|
|
18
|
-
*/
|
|
19
|
-
headers?: Value<Promisable<StandardHeaders | Headers>, [options: ClientOptions<T>, path: string[], input: unknown]> | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Override the default OpenAPI serializer.
|
|
22
|
-
*/
|
|
23
|
-
serializer?: Public<OpenAPISerializer> | undefined;
|
|
24
|
-
/**
|
|
25
|
-
* Customize how an error response body is converted into an ORPC error.
|
|
26
|
-
* Return `null` or `undefined` to fall back to the default decoding behavior.
|
|
27
|
-
*/
|
|
28
|
-
customErrorResponseBodyDecoder?: ((deserializedBody: unknown, response: StandardLazyResponse) => AnyORPCError | null | undefined) | undefined;
|
|
29
|
-
}
|
|
30
|
-
declare class OpenAPILinkCodec<T extends ClientContext> implements StandardLinkCodec<T> {
|
|
31
|
-
private readonly router;
|
|
32
|
-
private readonly baseUrl;
|
|
33
|
-
private readonly headers;
|
|
34
|
-
private readonly serializer;
|
|
35
|
-
private readonly customErrorResponseBodyDecoder;
|
|
36
|
-
constructor(router: RouterContract, options?: OpenAPILinkCodecOptions<T>);
|
|
37
|
-
encodeInput(input: unknown, path: string[], options: ClientOptions<T>): Promise<StandardRequest>;
|
|
38
|
-
private encodePathParam;
|
|
39
|
-
private serializeQueryString;
|
|
40
|
-
decodeResponse(response: StandardLazyResponse, path: string[], _options: ClientOptions<T>): Promise<StandardLinkCodecDecodedResponse>;
|
|
41
|
-
private resolveProcedure;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { OpenAPILinkCodec as a };
|
|
45
|
-
export type { OpenAPILinkCodecOptions as O };
|