@orpc/openapi 0.0.0-next.93e7a4c → 0.0.0-next.93ea2ee

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.
Files changed (43) hide show
  1. package/README.md +99 -0
  2. package/dist/adapters/aws-lambda/index.d.mts +19 -0
  3. package/dist/adapters/aws-lambda/index.d.ts +19 -0
  4. package/dist/adapters/aws-lambda/index.mjs +18 -0
  5. package/dist/adapters/fetch/index.d.mts +19 -0
  6. package/dist/adapters/fetch/index.d.ts +19 -0
  7. package/dist/adapters/fetch/index.mjs +18 -0
  8. package/dist/adapters/node/index.d.mts +19 -0
  9. package/dist/adapters/node/index.d.ts +19 -0
  10. package/dist/adapters/node/index.mjs +18 -0
  11. package/dist/adapters/standard/index.d.mts +29 -0
  12. package/dist/adapters/standard/index.d.ts +29 -0
  13. package/dist/adapters/standard/index.mjs +9 -0
  14. package/dist/index.d.mts +110 -0
  15. package/dist/index.d.ts +110 -0
  16. package/dist/index.mjs +41 -0
  17. package/dist/plugins/index.d.mts +69 -0
  18. package/dist/plugins/index.d.ts +69 -0
  19. package/dist/plugins/index.mjs +108 -0
  20. package/dist/shared/openapi.BkBlt1Qf.mjs +187 -0
  21. package/dist/shared/openapi.BtoY8ZFF.mjs +742 -0
  22. package/dist/shared/openapi.CQmjvnb0.d.mts +31 -0
  23. package/dist/shared/openapi.CQmjvnb0.d.ts +31 -0
  24. package/dist/shared/openapi.DPAN3GVs.d.mts +108 -0
  25. package/dist/shared/openapi.DPAN3GVs.d.ts +108 -0
  26. package/package.json +35 -25
  27. package/dist/chunk-UPDKQRQG.js +0 -665
  28. package/dist/fetch.js +0 -31
  29. package/dist/index.js +0 -4608
  30. package/dist/src/fetch/bracket-notation.d.ts +0 -84
  31. package/dist/src/fetch/index.d.ts +0 -10
  32. package/dist/src/fetch/input-builder-full.d.ts +0 -11
  33. package/dist/src/fetch/input-builder-simple.d.ts +0 -6
  34. package/dist/src/fetch/openapi-handler-server.d.ts +0 -7
  35. package/dist/src/fetch/openapi-handler-serverless.d.ts +0 -7
  36. package/dist/src/fetch/openapi-handler.d.ts +0 -28
  37. package/dist/src/fetch/openapi-payload-codec.d.ts +0 -13
  38. package/dist/src/fetch/openapi-procedure-matcher.d.ts +0 -19
  39. package/dist/src/fetch/schema-coercer.d.ts +0 -10
  40. package/dist/src/generator.d.ts +0 -26
  41. package/dist/src/index.d.ts +0 -3
  42. package/dist/src/utils.d.ts +0 -17
  43. package/dist/src/zod-to-json-schema.d.ts +0 -43
@@ -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,10 +0,0 @@
1
- export * from './bracket-notation';
2
- export * from './input-builder-full';
3
- export * from './input-builder-simple';
4
- export * from './openapi-handler';
5
- export * from './openapi-handler-server';
6
- export * from './openapi-handler-serverless';
7
- export * from './openapi-payload-codec';
8
- export * from './openapi-procedure-matcher';
9
- export * from './schema-coercer';
10
- //# sourceMappingURL=index.d.ts.map
@@ -1,11 +0,0 @@
1
- import type { Params } from 'hono/router';
2
- export declare class InputBuilderFull {
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 PublicInputBuilderFull = Pick<InputBuilderFull, keyof InputBuilderFull>;
11
- //# sourceMappingURL=input-builder-full.d.ts.map
@@ -1,6 +0,0 @@
1
- import type { Params } from 'hono/router';
2
- export declare class InputBuilderSimple {
3
- build(params: Params, payload: unknown): unknown;
4
- }
5
- export type PublicInputBuilderSimple = Pick<InputBuilderSimple, keyof InputBuilderSimple>;
6
- //# sourceMappingURL=input-builder-simple.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,28 +0,0 @@
1
- import type { ConditionalFetchHandler, FetchOptions } from '@orpc/server/fetch';
2
- import type { PublicInputBuilderSimple } from './input-builder-simple';
3
- import { type Context, type Router, type WithSignal } from '@orpc/server';
4
- import { type Hooks } from '@orpc/shared';
5
- import { type PublicInputBuilderFull } from './input-builder-full';
6
- import { type PublicOpenAPIPayloadCodec } from './openapi-payload-codec';
7
- import { type Hono, type PublicOpenAPIProcedureMatcher } from './openapi-procedure-matcher';
8
- import { type SchemaCoercer } from './schema-coercer';
9
- export type OpenAPIHandlerOptions<T extends Context> = Hooks<Request, Response, T, WithSignal> & {
10
- procedureMatcher?: PublicOpenAPIProcedureMatcher;
11
- payloadCodec?: PublicOpenAPIPayloadCodec;
12
- inputBuilderSimple?: PublicInputBuilderSimple;
13
- inputBuilderFull?: PublicInputBuilderFull;
14
- schemaCoercers?: SchemaCoercer[];
15
- };
16
- export declare class OpenAPIHandler<T extends Context> implements ConditionalFetchHandler<T> {
17
- private readonly options?;
18
- private readonly procedureMatcher;
19
- private readonly payloadCodec;
20
- private readonly inputBuilderSimple;
21
- private readonly inputBuilderFull;
22
- private readonly compositeSchemaCoercer;
23
- constructor(hono: Hono, router: Router<T, any>, options?: NoInfer<OpenAPIHandlerOptions<T>> | undefined);
24
- condition(request: Request): boolean;
25
- fetch(request: Request, ...[options]: [options: FetchOptions<T>] | (undefined extends T ? [] : never)): Promise<Response>;
26
- private convertToORPCError;
27
- }
28
- //# sourceMappingURL=openapi-handler.d.ts.map
@@ -1,13 +0,0 @@
1
- export declare class OpenAPIPayloadCodec {
2
- encode(payload: unknown, accept?: string): {
3
- body: FormData | Blob | string | undefined;
4
- headers?: Headers;
5
- };
6
- private encodeAsJSON;
7
- private encodeAsFormData;
8
- private encodeAsURLSearchParams;
9
- serialize(payload: unknown): unknown;
10
- decode(re: Request | Response | Headers | URLSearchParams | FormData): Promise<unknown>;
11
- }
12
- export type PublicOpenAPIPayloadCodec = Pick<OpenAPIPayloadCodec, keyof OpenAPIPayloadCodec>;
13
- //# 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,26 +0,0 @@
1
- import type { PublicOpenAPIPayloadCodec } from './fetch';
2
- import { type ContractRouter } from '@orpc/contract';
3
- import { type ANY_ROUTER } from '@orpc/server';
4
- import { type OpenAPIObject } from 'openapi3-ts/oas31';
5
- export interface GenerateOpenAPIOptions {
6
- /**
7
- * Throw error when you missing define tag definition on OpenAPI root tags
8
- *
9
- * Example: if procedure has tags ['foo', 'bar'], and OpenAPI root tags is ['foo'], then error will be thrown
10
- * Because OpenAPI root tags is missing 'bar' tag
11
- *
12
- * @default false
13
- */
14
- throwOnMissingTagDefinition?: boolean;
15
- /**
16
- * Weather ignore procedures that has no path defined.
17
- *
18
- * @default false
19
- */
20
- ignoreUndefinedPathProcedures?: boolean;
21
- payloadCodec?: PublicOpenAPIPayloadCodec;
22
- }
23
- export declare function generateOpenAPI(opts: {
24
- router: ContractRouter | ANY_ROUTER;
25
- } & Omit<OpenAPIObject, 'openapi'>, options?: GenerateOpenAPIOptions): Promise<OpenAPIObject>;
26
- //# sourceMappingURL=generator.d.ts.map
@@ -1,3 +0,0 @@
1
- /** unnoq */
2
- export * from './generator';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,17 +0,0 @@
1
- import type { ContractRouter, HTTPPath, WELL_CONTRACT_PROCEDURE } from '@orpc/contract';
2
- import type { ANY_PROCEDURE, ANY_ROUTER, Lazy } from '@orpc/server';
3
- export interface EachLeafOptions {
4
- router: ContractRouter | ANY_ROUTER;
5
- path: string[];
6
- }
7
- export interface EachLeafCallbackOptions {
8
- contract: WELL_CONTRACT_PROCEDURE;
9
- path: string[];
10
- }
11
- export interface EachContractLeafResultItem {
12
- router: Lazy<ANY_PROCEDURE> | Lazy<Record<string, ANY_ROUTER> | ANY_PROCEDURE>;
13
- path: string[];
14
- }
15
- export declare function forEachContractProcedure(options: EachLeafOptions, callback: (options: EachLeafCallbackOptions) => void, result?: EachContractLeafResultItem[], isCurrentRouterContract?: boolean): EachContractLeafResultItem[];
16
- export declare function standardizeHTTPPath(path: HTTPPath): HTTPPath;
17
- //# sourceMappingURL=utils.d.ts.map
@@ -1,43 +0,0 @@
1
- import type { StandardSchemaV1 } from '@standard-schema/spec';
2
- import { type JSONSchema } from 'json-schema-typed/draft-2020-12';
3
- export declare const NON_LOGIC_KEYWORDS: ("$anchor" | "$comment" | "$defs" | "$dynamicAnchor" | "$dynamicRef" | "$id" | "$schema" | "$vocabulary" | "contentEncoding" | "contentMediaType" | "default" | "definitions" | "deprecated" | "description" | "examples" | "format" | "readOnly" | "title" | "writeOnly")[];
4
- export declare const UNSUPPORTED_JSON_SCHEMA: {
5
- not: {};
6
- };
7
- export declare const UNDEFINED_JSON_SCHEMA: {
8
- const: string;
9
- };
10
- export interface ZodToJsonSchemaOptions {
11
- /**
12
- * Max depth of lazy type, if it exceeds.
13
- *
14
- * Used `{}` when reach max depth
15
- *
16
- * @default 5
17
- */
18
- maxLazyDepth?: number;
19
- /**
20
- * The length used to track the depth of lazy type
21
- *
22
- * @internal
23
- */
24
- lazyDepth?: number;
25
- /**
26
- * The expected json schema for input or output zod schema
27
- *
28
- * @default input
29
- */
30
- mode?: 'input' | 'output';
31
- /**
32
- * Track if current level schema is handled custom json schema to prevent recursive
33
- *
34
- * @internal
35
- */
36
- isHandledCustomJSONSchema?: boolean;
37
- }
38
- export declare function zodToJsonSchema(schema: StandardSchemaV1, options?: ZodToJsonSchemaOptions): Exclude<JSONSchema, boolean>;
39
- export declare function extractJSONSchema(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): {
40
- schema: JSONSchema | undefined;
41
- matches: JSONSchema[];
42
- };
43
- //# sourceMappingURL=zod-to-json-schema.d.ts.map