@orpc/openapi 0.0.0-next.da8ae32 → 0.0.0-next.da92bc0

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 (62) hide show
  1. package/README.md +99 -0
  2. package/dist/adapters/aws-lambda/index.d.mts +17 -0
  3. package/dist/adapters/aws-lambda/index.d.ts +17 -0
  4. package/dist/adapters/aws-lambda/index.mjs +18 -0
  5. package/dist/adapters/fetch/index.d.mts +17 -0
  6. package/dist/adapters/fetch/index.d.ts +17 -0
  7. package/dist/adapters/fetch/index.mjs +18 -0
  8. package/dist/adapters/node/index.d.mts +17 -0
  9. package/dist/adapters/node/index.d.ts +17 -0
  10. package/dist/adapters/node/index.mjs +18 -0
  11. package/dist/adapters/standard/index.d.mts +35 -0
  12. package/dist/adapters/standard/index.d.ts +35 -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.-sXpEIAO.mjs +179 -0
  21. package/dist/shared/openapi.8DHd5bRK.d.mts +101 -0
  22. package/dist/shared/openapi.8DHd5bRK.d.ts +101 -0
  23. package/dist/shared/openapi.BWrlhfev.d.mts +12 -0
  24. package/dist/shared/openapi.BWrlhfev.d.ts +12 -0
  25. package/dist/shared/openapi.DrrBsJ0w.mjs +738 -0
  26. package/package.json +31 -38
  27. package/dist/chunk-DRV7KYES.js +0 -420
  28. package/dist/chunk-HC5PVG4R.js +0 -52
  29. package/dist/chunk-NHYWV7BW.js +0 -32
  30. package/dist/fetch.js +0 -9
  31. package/dist/hono.js +0 -9
  32. package/dist/index.js +0 -602
  33. package/dist/next.js +0 -9
  34. package/dist/node.js +0 -30
  35. package/dist/src/adapters/fetch/index.d.ts +0 -2
  36. package/dist/src/adapters/fetch/openapi-handler.d.ts +0 -11
  37. package/dist/src/adapters/hono/index.d.ts +0 -2
  38. package/dist/src/adapters/next/index.d.ts +0 -2
  39. package/dist/src/adapters/node/index.d.ts +0 -2
  40. package/dist/src/adapters/node/openapi-handler.d.ts +0 -11
  41. package/dist/src/adapters/standard/bracket-notation.d.ts +0 -84
  42. package/dist/src/adapters/standard/index.d.ts +0 -6
  43. package/dist/src/adapters/standard/openapi-codec.d.ts +0 -15
  44. package/dist/src/adapters/standard/openapi-handler.d.ts +0 -7
  45. package/dist/src/adapters/standard/openapi-matcher.d.ts +0 -20
  46. package/dist/src/adapters/standard/openapi-serializer.d.ts +0 -11
  47. package/dist/src/index.d.ts +0 -17
  48. package/dist/src/json-serializer.d.ts +0 -5
  49. package/dist/src/openapi-content-builder.d.ts +0 -10
  50. package/dist/src/openapi-error.d.ts +0 -3
  51. package/dist/src/openapi-generator.d.ts +0 -67
  52. package/dist/src/openapi-input-structure-parser.d.ts +0 -22
  53. package/dist/src/openapi-operation-extender.d.ts +0 -7
  54. package/dist/src/openapi-output-structure-parser.d.ts +0 -18
  55. package/dist/src/openapi-parameters-builder.d.ts +0 -12
  56. package/dist/src/openapi-path-parser.d.ts +0 -8
  57. package/dist/src/openapi.d.ts +0 -3
  58. package/dist/src/schema-converter.d.ts +0 -16
  59. package/dist/src/schema-utils.d.ts +0 -11
  60. package/dist/src/schema.d.ts +0 -12
  61. package/dist/src/utils.d.ts +0 -3
  62. package/dist/standard.js +0 -14
@@ -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
- export * as BracketNotation from './bracket-notation';
2
- export * from './openapi-codec';
3
- export * from './openapi-handler';
4
- export * from './openapi-matcher';
5
- export * from './openapi-serializer';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1,15 +0,0 @@
1
- import type { AnyProcedure } from '@orpc/server';
2
- import type { StandardCodec, StandardParams, StandardRequest, StandardResponse } from '@orpc/server/standard';
3
- import { type ORPCError } from '@orpc/contract';
4
- import { OpenAPISerializer } from './openapi-serializer';
5
- export interface OpenAPICodecOptions {
6
- serializer?: OpenAPISerializer;
7
- }
8
- export declare class OpenAPICodec implements StandardCodec {
9
- private readonly serializer;
10
- constructor(options?: OpenAPICodecOptions);
11
- decode(request: StandardRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
12
- encode(output: unknown, procedure: AnyProcedure): StandardResponse;
13
- encodeError(error: ORPCError<any, any>): StandardResponse;
14
- }
15
- //# sourceMappingURL=openapi-codec.d.ts.map
@@ -1,7 +0,0 @@
1
- import type { Context } from '@orpc/server';
2
- import type { RPCHandlerOptions } from '@orpc/server/standard';
3
- import type { OpenAPICodecOptions } from './openapi-codec';
4
- import type { OpenAPIMatcherOptions } from './openapi-matcher';
5
- export interface OpenAPIHandlerOptions<T extends Context> extends RPCHandlerOptions<T>, OpenAPIMatcherOptions, OpenAPICodecOptions {
6
- }
7
- //# sourceMappingURL=openapi-handler.d.ts.map
@@ -1,20 +0,0 @@
1
- import type { AnyRouter } from '@orpc/server';
2
- import type { StandardMatcher, StandardMatchResult } from '@orpc/server/standard';
3
- import { type HTTPPath } from '@orpc/contract';
4
- export interface OpenAPIMatcherOptions {
5
- /**
6
- * Ignore procedure that does not have a method defined in the contract.
7
- *
8
- * @default false
9
- */
10
- ignoreUndefinedMethod?: boolean;
11
- }
12
- export declare class OpenAPIMatcher implements StandardMatcher {
13
- private readonly tree;
14
- private readonly ignoreUndefinedMethod;
15
- constructor(options?: OpenAPIMatcherOptions);
16
- private pendingRouters;
17
- init(router: AnyRouter, path?: string[]): void;
18
- match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
19
- }
20
- //# sourceMappingURL=openapi-matcher.d.ts.map
@@ -1,11 +0,0 @@
1
- import type { PublicJSONSerializer } from '../../json-serializer';
2
- export interface OpenAPISerializerOptions {
3
- jsonSerializer?: PublicJSONSerializer;
4
- }
5
- export declare class OpenAPISerializer {
6
- private readonly jsonSerializer;
7
- constructor(options?: OpenAPISerializerOptions);
8
- serialize(data: unknown): unknown;
9
- deserialize(serialized: unknown): unknown;
10
- }
11
- //# sourceMappingURL=openapi-serializer.d.ts.map
@@ -1,17 +0,0 @@
1
- /** unnoq */
2
- import { setOperationExtender } from './openapi-operation-extender';
3
- export * from './json-serializer';
4
- export * from './openapi';
5
- export * from './openapi-content-builder';
6
- export * from './openapi-generator';
7
- export * from './openapi-operation-extender';
8
- export * from './openapi-parameters-builder';
9
- export * from './openapi-path-parser';
10
- export * from './schema';
11
- export * from './schema-converter';
12
- export * from './schema-utils';
13
- export * from './utils';
14
- export declare const oo: {
15
- spec: typeof setOperationExtender;
16
- };
17
- //# sourceMappingURL=index.d.ts.map
@@ -1,5 +0,0 @@
1
- export declare class JSONSerializer {
2
- serialize(payload: unknown): unknown;
3
- }
4
- export type PublicJSONSerializer = Pick<JSONSerializer, keyof JSONSerializer>;
5
- //# sourceMappingURL=json-serializer.d.ts.map
@@ -1,10 +0,0 @@
1
- import type { OpenAPI } from './openapi';
2
- import type { JSONSchema } from './schema';
3
- import type { PublicSchemaUtils } from './schema-utils';
4
- export declare class OpenAPIContentBuilder {
5
- private readonly schemaUtils;
6
- constructor(schemaUtils: PublicSchemaUtils);
7
- build(jsonSchema: JSONSchema.JSONSchema, options?: Partial<OpenAPI.MediaTypeObject>): OpenAPI.ContentObject;
8
- }
9
- export type PublicOpenAPIContentBuilder = Pick<OpenAPIContentBuilder, keyof OpenAPIContentBuilder>;
10
- //# sourceMappingURL=openapi-content-builder.d.ts.map
@@ -1,3 +0,0 @@
1
- export declare class OpenAPIError extends Error {
2
- }
3
- //# sourceMappingURL=openapi-error.d.ts.map
@@ -1,67 +0,0 @@
1
- import type { PublicOpenAPIInputStructureParser } from './openapi-input-structure-parser';
2
- import type { PublicOpenAPIOutputStructureParser } from './openapi-output-structure-parser';
3
- import type { PublicOpenAPIPathParser } from './openapi-path-parser';
4
- import type { SchemaConverter } from './schema-converter';
5
- import { type ContractRouter } from '@orpc/contract';
6
- import { type AnyRouter } from '@orpc/server';
7
- import { type PublicJSONSerializer } from './json-serializer';
8
- import { type OpenAPI } from './openapi';
9
- import { type PublicOpenAPIContentBuilder } from './openapi-content-builder';
10
- import { type PublicOpenAPIParametersBuilder } from './openapi-parameters-builder';
11
- import { type PublicSchemaUtils } from './schema-utils';
12
- type ErrorHandlerStrategy = 'throw' | 'log' | 'ignore';
13
- export interface OpenAPIGeneratorOptions {
14
- contentBuilder?: PublicOpenAPIContentBuilder;
15
- parametersBuilder?: PublicOpenAPIParametersBuilder;
16
- schemaConverters?: SchemaConverter[];
17
- schemaUtils?: PublicSchemaUtils;
18
- jsonSerializer?: PublicJSONSerializer;
19
- pathParser?: PublicOpenAPIPathParser;
20
- inputStructureParser?: PublicOpenAPIInputStructureParser;
21
- outputStructureParser?: PublicOpenAPIOutputStructureParser;
22
- /**
23
- * Throw error when you missing define tag definition on OpenAPI root tags
24
- *
25
- * Example: if procedure has tags ['foo', 'bar'], and OpenAPI root tags is ['foo'], then error will be thrown
26
- * Because OpenAPI root tags is missing 'bar' tag
27
- *
28
- * @default false
29
- */
30
- considerMissingTagDefinitionAsError?: boolean;
31
- /**
32
- * Weather ignore procedures that has no path defined.
33
- *
34
- * @default false
35
- */
36
- ignoreUndefinedPathProcedures?: boolean;
37
- /**
38
- * What to do when we found an error with our router
39
- *
40
- * @default 'throw'
41
- */
42
- errorHandlerStrategy?: ErrorHandlerStrategy;
43
- /**
44
- * Strict error response
45
- *
46
- * @default true
47
- */
48
- strictErrorResponses?: boolean;
49
- }
50
- export declare class OpenAPIGenerator {
51
- private readonly contentBuilder;
52
- private readonly parametersBuilder;
53
- private readonly schemaConverter;
54
- private readonly schemaUtils;
55
- private readonly jsonSerializer;
56
- private readonly pathParser;
57
- private readonly inputStructureParser;
58
- private readonly outputStructureParser;
59
- private readonly errorHandlerStrategy;
60
- private readonly ignoreUndefinedPathProcedures;
61
- private readonly considerMissingTagDefinitionAsError;
62
- private readonly strictErrorResponses;
63
- constructor(options?: OpenAPIGeneratorOptions);
64
- generate(router: ContractRouter<any> | AnyRouter, doc: Omit<OpenAPI.OpenAPIObject, 'openapi'>): Promise<OpenAPI.OpenAPIObject>;
65
- }
66
- export {};
67
- //# sourceMappingURL=openapi-generator.d.ts.map
@@ -1,22 +0,0 @@
1
- import type { AnyContractProcedure } from '@orpc/contract';
2
- import type { PublicOpenAPIPathParser } from './openapi-path-parser';
3
- import type { JSONSchema, ObjectSchema } from './schema';
4
- import type { SchemaConverter } from './schema-converter';
5
- import type { PublicSchemaUtils } from './schema-utils';
6
- export interface OpenAPIInputStructureParseResult {
7
- paramsSchema: ObjectSchema | undefined;
8
- querySchema: ObjectSchema | undefined;
9
- headersSchema: ObjectSchema | undefined;
10
- bodySchema: JSONSchema.JSONSchema | undefined;
11
- }
12
- export declare class OpenAPIInputStructureParser {
13
- private readonly schemaConverter;
14
- private readonly schemaUtils;
15
- private readonly pathParser;
16
- constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils, pathParser: PublicOpenAPIPathParser);
17
- parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIInputStructureParseResult;
18
- private parseDetailedSchema;
19
- private parseCompactSchema;
20
- }
21
- export type PublicOpenAPIInputStructureParser = Pick<OpenAPIInputStructureParser, keyof OpenAPIInputStructureParser>;
22
- //# sourceMappingURL=openapi-input-structure-parser.d.ts.map
@@ -1,7 +0,0 @@
1
- import type { AnyContractProcedure } from '@orpc/contract';
2
- import type { OpenAPI } from './openapi';
3
- export type OverrideOperationValue = OpenAPI.OperationObject | ((current: OpenAPI.OperationObject, procedure: AnyContractProcedure) => OpenAPI.OperationObject);
4
- export declare function setOperationExtender<T extends object>(o: T, extend: OverrideOperationValue): T;
5
- export declare function getOperationExtender(o: object): OverrideOperationValue | undefined;
6
- export declare function extendOperation(operation: OpenAPI.OperationObject, procedure: AnyContractProcedure): OpenAPI.OperationObject;
7
- //# sourceMappingURL=openapi-operation-extender.d.ts.map
@@ -1,18 +0,0 @@
1
- import type { AnyContractProcedure } from '@orpc/contract';
2
- import type { JSONSchema, ObjectSchema } from './schema';
3
- import type { SchemaConverter } from './schema-converter';
4
- import type { PublicSchemaUtils } from './schema-utils';
5
- export interface OpenAPIOutputStructureParseResult {
6
- headersSchema: ObjectSchema | undefined;
7
- bodySchema: JSONSchema.JSONSchema | undefined;
8
- }
9
- export declare class OpenAPIOutputStructureParser {
10
- private readonly schemaConverter;
11
- private readonly schemaUtils;
12
- constructor(schemaConverter: SchemaConverter, schemaUtils: PublicSchemaUtils);
13
- parse(contract: AnyContractProcedure, structure: 'compact' | 'detailed'): OpenAPIOutputStructureParseResult;
14
- private parseDetailedSchema;
15
- private parseCompactSchema;
16
- }
17
- export type PublicOpenAPIOutputStructureParser = Pick<OpenAPIOutputStructureParser, keyof OpenAPIOutputStructureParser>;
18
- //# sourceMappingURL=openapi-output-structure-parser.d.ts.map
@@ -1,12 +0,0 @@
1
- import type { OpenAPI } from './openapi';
2
- import type { JSONSchema } from './schema';
3
- export declare class OpenAPIParametersBuilder {
4
- build(paramIn: OpenAPI.ParameterObject['in'], jsonSchema: JSONSchema.JSONSchema & {
5
- type: 'object';
6
- } & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.ParameterObject[];
7
- buildHeadersObject(jsonSchema: JSONSchema.JSONSchema & {
8
- type: 'object';
9
- } & object, options?: Pick<OpenAPI.ParameterObject, 'example' | 'style' | 'required'>): OpenAPI.HeadersObject;
10
- }
11
- export type PublicOpenAPIParametersBuilder = Pick<OpenAPIParametersBuilder, keyof OpenAPIParametersBuilder>;
12
- //# sourceMappingURL=openapi-parameters-builder.d.ts.map
@@ -1,8 +0,0 @@
1
- export declare class OpenAPIPathParser {
2
- parseDynamicParams(path: string): {
3
- name: string;
4
- raw: string;
5
- }[];
6
- }
7
- export type PublicOpenAPIPathParser = Pick<OpenAPIPathParser, keyof OpenAPIPathParser>;
8
- //# sourceMappingURL=openapi-path-parser.d.ts.map
@@ -1,3 +0,0 @@
1
- export { OpenApiBuilder } from 'openapi3-ts/oas31';
2
- export type * as OpenAPI from 'openapi3-ts/oas31';
3
- //# sourceMappingURL=openapi.d.ts.map
@@ -1,16 +0,0 @@
1
- import type { Schema } from '@orpc/contract';
2
- import type { JSONSchema } from './schema';
3
- export interface SchemaConvertOptions {
4
- strategy: 'input' | 'output';
5
- }
6
- export interface SchemaConverter {
7
- condition(schema: Schema, options: SchemaConvertOptions): boolean;
8
- convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema;
9
- }
10
- export declare class CompositeSchemaConverter implements SchemaConverter {
11
- private readonly converters;
12
- constructor(converters: SchemaConverter[]);
13
- condition(): boolean;
14
- convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema;
15
- }
16
- //# sourceMappingURL=schema-converter.d.ts.map
@@ -1,11 +0,0 @@
1
- import { type FileSchema, type JSONSchema, type ObjectSchema } from './schema';
2
- export declare class SchemaUtils {
3
- isFileSchema(schema: JSONSchema.JSONSchema): schema is FileSchema;
4
- isObjectSchema(schema: JSONSchema.JSONSchema): schema is ObjectSchema;
5
- isAnySchema(schema: JSONSchema.JSONSchema): boolean;
6
- isUndefinableSchema(schema: JSONSchema.JSONSchema): boolean;
7
- separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
8
- filterSchemaBranches(schema: JSONSchema.JSONSchema, check: (schema: JSONSchema.JSONSchema) => boolean, matches?: JSONSchema.JSONSchema[]): [matches: JSONSchema.JSONSchema[], rest: JSONSchema.JSONSchema | undefined];
9
- }
10
- export type PublicSchemaUtils = Pick<SchemaUtils, keyof SchemaUtils>;
11
- //# sourceMappingURL=schema-utils.d.ts.map
@@ -1,12 +0,0 @@
1
- import * as JSONSchema from 'json-schema-typed/draft-2020-12';
2
- export { Format as JSONSchemaFormat } from 'json-schema-typed/draft-2020-12';
3
- export { JSONSchema };
4
- export type ObjectSchema = JSONSchema.JSONSchema & {
5
- type: 'object';
6
- } & object;
7
- export type FileSchema = JSONSchema.JSONSchema & {
8
- type: 'string';
9
- contentMediaType: string;
10
- } & object;
11
- export declare const NON_LOGIC_KEYWORDS: string[];
12
- //# sourceMappingURL=schema.d.ts.map
@@ -1,3 +0,0 @@
1
- import type { HTTPPath } from '@orpc/contract';
2
- export declare function standardizeHTTPPath(path: HTTPPath): HTTPPath;
3
- //# sourceMappingURL=utils.d.ts.map
package/dist/standard.js DELETED
@@ -1,14 +0,0 @@
1
- import {
2
- OpenAPICodec,
3
- OpenAPIMatcher,
4
- OpenAPISerializer,
5
- bracket_notation_exports
6
- } from "./chunk-DRV7KYES.js";
7
- import "./chunk-HC5PVG4R.js";
8
- export {
9
- bracket_notation_exports as BracketNotation,
10
- OpenAPICodec,
11
- OpenAPIMatcher,
12
- OpenAPISerializer
13
- };
14
- //# sourceMappingURL=standard.js.map