@orpc/openapi 0.0.0-next.f99e554 → 0.0.0-next.fe39bf3
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/dist/chunk-LPBZEW4B.js +165 -0
- package/dist/chunk-UU2TTVB2.js +32 -0
- package/dist/chunk-XGHV4TH3.js +13 -0
- package/dist/fetch.js +5 -42
- package/dist/hono.js +9 -0
- package/dist/index.js +259 -48
- package/dist/next.js +9 -0
- package/dist/node.js +20 -36
- package/dist/src/adapters/fetch/index.d.ts +0 -8
- package/dist/src/adapters/fetch/openapi-handler.d.ts +9 -31
- package/dist/src/adapters/hono/index.d.ts +2 -0
- package/dist/src/adapters/next/index.d.ts +2 -0
- package/dist/src/adapters/node/index.d.ts +0 -3
- package/dist/src/adapters/node/openapi-handler.d.ts +8 -9
- package/dist/src/adapters/standard/index.d.ts +4 -0
- package/dist/src/adapters/standard/openapi-codec.d.ts +16 -0
- package/dist/src/adapters/standard/openapi-handler.d.ts +7 -0
- package/dist/src/adapters/standard/openapi-matcher.d.ts +20 -0
- package/dist/src/index.d.ts +5 -1
- package/dist/src/openapi-generator.d.ts +12 -5
- package/dist/src/openapi-input-structure-parser.d.ts +2 -2
- package/dist/src/openapi-operation-extender.d.ts +7 -0
- package/dist/src/openapi-output-structure-parser.d.ts +2 -2
- package/dist/src/schema-converter.d.ts +2 -2
- package/dist/src/schema.d.ts +1 -1
- package/dist/src/utils.d.ts +2 -16
- package/dist/standard.js +10 -0
- package/package.json +25 -14
- package/dist/chunk-KNYXLM77.js +0 -107
- package/dist/chunk-YXHH6XHB.js +0 -642
- package/dist/src/adapters/fetch/bracket-notation.d.ts +0 -84
- package/dist/src/adapters/fetch/input-structure-compact.d.ts +0 -6
- package/dist/src/adapters/fetch/input-structure-detailed.d.ts +0 -11
- package/dist/src/adapters/fetch/openapi-handler-server.d.ts +0 -7
- package/dist/src/adapters/fetch/openapi-handler-serverless.d.ts +0 -7
- package/dist/src/adapters/fetch/openapi-payload-codec.d.ts +0 -15
- package/dist/src/adapters/fetch/openapi-procedure-matcher.d.ts +0 -19
- package/dist/src/adapters/fetch/schema-coercer.d.ts +0 -10
- package/dist/src/adapters/node/openapi-handler-server.d.ts +0 -7
- package/dist/src/adapters/node/openapi-handler-serverless.d.ts +0 -7
- package/dist/src/adapters/node/types.d.ts +0 -2
- package/dist/src/json-serializer.d.ts +0 -5
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Serialize an object or array into a list of [key, value] pairs.
|
|
3
|
-
* The key will express by using bracket-notation.
|
|
4
|
-
*
|
|
5
|
-
* Notice: This way cannot express the empty object or array.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* const payload = {
|
|
10
|
-
* name: 'John Doe',
|
|
11
|
-
* pets: ['dog', 'cat'],
|
|
12
|
-
* }
|
|
13
|
-
*
|
|
14
|
-
* const entities = serialize(payload)
|
|
15
|
-
*
|
|
16
|
-
* expect(entities).toEqual([
|
|
17
|
-
* ['name', 'John Doe'],
|
|
18
|
-
* ['name[pets][0]', 'dog'],
|
|
19
|
-
* ['name[pets][1]', 'cat'],
|
|
20
|
-
* ])
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare function serialize(payload: unknown, parentKey?: string): [string, unknown][];
|
|
24
|
-
/**
|
|
25
|
-
* Deserialize a list of [key, value] pairs into an object or array.
|
|
26
|
-
* The key is expressed by using bracket-notation.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* const entities = [
|
|
31
|
-
* ['name', 'John Doe'],
|
|
32
|
-
* ['name[pets][0]', 'dog'],
|
|
33
|
-
* ['name[pets][1]', 'cat'],
|
|
34
|
-
* ['name[dogs][]', 'hello'],
|
|
35
|
-
* ['name[dogs][]', 'kitty'],
|
|
36
|
-
* ]
|
|
37
|
-
*
|
|
38
|
-
* const payload = deserialize(entities)
|
|
39
|
-
*
|
|
40
|
-
* expect(payload).toEqual({
|
|
41
|
-
* name: 'John Doe',
|
|
42
|
-
* pets: { 0: 'dog', 1: 'cat' },
|
|
43
|
-
* dogs: ['hello', 'kitty'],
|
|
44
|
-
* })
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
export declare function deserialize(entities: readonly (readonly [string, unknown])[]): Record<string, unknown> | unknown[] | undefined;
|
|
48
|
-
/**
|
|
49
|
-
* Escape the `[`, `]`, and `\` chars in a path segment.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```ts
|
|
53
|
-
* expect(escapeSegment('name[pets')).toEqual('name\\[pets')
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
export declare function escapeSegment(segment: string): string;
|
|
57
|
-
/**
|
|
58
|
-
* Convert an array of path segments into a path string using bracket-notation.
|
|
59
|
-
*
|
|
60
|
-
* For the special char `[`, `]`, and `\` will be escaped by adding `\` at start.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```ts
|
|
64
|
-
* expect(stringifyPath(['name', 'pets', '0'])).toEqual('name[pets][0]')
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
export declare function stringifyPath(path: readonly [string, ...string[]]): string;
|
|
68
|
-
/**
|
|
69
|
-
* Convert a path string using bracket-notation into an array of path segments.
|
|
70
|
-
*
|
|
71
|
-
* For the special char `[`, `]`, and `\` you should escape by adding `\` at start.
|
|
72
|
-
* It only treats a pair `[${string}]` as a path segment.
|
|
73
|
-
* If missing or escape it will bypass and treat as normal string.
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```ts
|
|
77
|
-
* expect(parsePath('name[pets][0]')).toEqual(['name', 'pets', '0'])
|
|
78
|
-
* expect(parsePath('name[pets][0')).toEqual(['name', 'pets', '[0'])
|
|
79
|
-
* expect(parsePath('name[pets[0]')).toEqual(['name', 'pets[0')
|
|
80
|
-
* expect(parsePath('name\\[pets][0]')).toEqual(['name[pets]', '0'])
|
|
81
|
-
* ```
|
|
82
|
-
*/
|
|
83
|
-
export declare function parsePath(path: string): [string, ...string[]];
|
|
84
|
-
//# sourceMappingURL=bracket-notation.d.ts.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { Params } from 'hono/router';
|
|
2
|
-
export declare class InputStructureCompact {
|
|
3
|
-
build(params: Params, payload: unknown): unknown;
|
|
4
|
-
}
|
|
5
|
-
export type PublicInputStructureCompact = Pick<InputStructureCompact, keyof InputStructureCompact>;
|
|
6
|
-
//# sourceMappingURL=input-structure-compact.d.ts.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Params } from 'hono/router';
|
|
2
|
-
export declare class InputStructureDetailed {
|
|
3
|
-
build(params: Params, query: unknown, headers: unknown, body: unknown): {
|
|
4
|
-
params: Params;
|
|
5
|
-
query: unknown;
|
|
6
|
-
headers: unknown;
|
|
7
|
-
body: unknown;
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
export type PublicInputStructureDetailed = Pick<InputStructureDetailed, keyof InputStructureDetailed>;
|
|
11
|
-
//# sourceMappingURL=input-structure-detailed.d.ts.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Context, Router } from '@orpc/server';
|
|
2
|
-
import type { OpenAPIHandlerOptions } from './openapi-handler';
|
|
3
|
-
import { OpenAPIHandler } from './openapi-handler';
|
|
4
|
-
export declare class OpenAPIServerHandler<T extends Context> extends OpenAPIHandler<T> {
|
|
5
|
-
constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=openapi-handler-server.d.ts.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Context, Router } from '@orpc/server';
|
|
2
|
-
import type { OpenAPIHandlerOptions } from './openapi-handler';
|
|
3
|
-
import { OpenAPIHandler } from './openapi-handler';
|
|
4
|
-
export declare class OpenAPIServerlessHandler<T extends Context> extends OpenAPIHandler<T> {
|
|
5
|
-
constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=openapi-handler-serverless.d.ts.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { PublicJSONSerializer } from '../../json-serializer';
|
|
2
|
-
export declare class OpenAPIPayloadCodec {
|
|
3
|
-
private readonly jsonSerializer;
|
|
4
|
-
constructor(jsonSerializer: PublicJSONSerializer);
|
|
5
|
-
encode(payload: unknown, accept: string | undefined): {
|
|
6
|
-
body: FormData | Blob | string | undefined;
|
|
7
|
-
headers?: Headers;
|
|
8
|
-
};
|
|
9
|
-
private encodeAsJSON;
|
|
10
|
-
private encodeAsFormData;
|
|
11
|
-
private encodeAsURLSearchParams;
|
|
12
|
-
decode(re: Request | Response | Headers | URLSearchParams | FormData): Promise<unknown>;
|
|
13
|
-
}
|
|
14
|
-
export type PublicOpenAPIPayloadCodec = Pick<OpenAPIPayloadCodec, keyof OpenAPIPayloadCodec>;
|
|
15
|
-
//# sourceMappingURL=openapi-payload-codec.d.ts.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Router as BaseHono, Params } from 'hono/router';
|
|
2
|
-
import { type ANY_PROCEDURE, type ANY_ROUTER } from '@orpc/server';
|
|
3
|
-
export type Hono = BaseHono<[string, string[]]>;
|
|
4
|
-
export declare class OpenAPIProcedureMatcher {
|
|
5
|
-
private readonly hono;
|
|
6
|
-
private readonly router;
|
|
7
|
-
private pendingRouters;
|
|
8
|
-
constructor(hono: Hono, router: ANY_ROUTER);
|
|
9
|
-
match(method: string, pathname: string): Promise<{
|
|
10
|
-
path: string[];
|
|
11
|
-
procedure: ANY_PROCEDURE;
|
|
12
|
-
params: Params;
|
|
13
|
-
} | undefined>;
|
|
14
|
-
private add;
|
|
15
|
-
private handlePendingRouters;
|
|
16
|
-
private convertOpenAPIPathToRouterPath;
|
|
17
|
-
}
|
|
18
|
-
export type PublicOpenAPIProcedureMatcher = Pick<OpenAPIProcedureMatcher, keyof OpenAPIProcedureMatcher>;
|
|
19
|
-
//# sourceMappingURL=openapi-procedure-matcher.d.ts.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Schema } from '@orpc/contract';
|
|
2
|
-
export interface SchemaCoercer {
|
|
3
|
-
coerce: (schema: Schema, value: unknown) => unknown;
|
|
4
|
-
}
|
|
5
|
-
export declare class CompositeSchemaCoercer implements SchemaCoercer {
|
|
6
|
-
private readonly coercers;
|
|
7
|
-
constructor(coercers: SchemaCoercer[]);
|
|
8
|
-
coerce(schema: Schema, value: unknown): unknown;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=schema-coercer.d.ts.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Context, Router } from '@orpc/server';
|
|
2
|
-
import type { OpenAPIHandlerOptions } from '../fetch/openapi-handler';
|
|
3
|
-
import { OpenAPIHandler } from './openapi-handler';
|
|
4
|
-
export declare class OpenAPIServerHandler<T extends Context> extends OpenAPIHandler<T> {
|
|
5
|
-
constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=openapi-handler-server.d.ts.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { Context, Router } from '@orpc/server';
|
|
2
|
-
import type { OpenAPIHandlerOptions } from '../fetch/openapi-handler';
|
|
3
|
-
import { OpenAPIHandler } from './openapi-handler';
|
|
4
|
-
export declare class OpenAPIServerlessHandler<T extends Context> extends OpenAPIHandler<T> {
|
|
5
|
-
constructor(router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>>);
|
|
6
|
-
}
|
|
7
|
-
//# sourceMappingURL=openapi-handler-serverless.d.ts.map
|