@temporary-name/server 1.9.3-alpha.4275e976ddda4d8be107c2cfde9899bdea9a337d → 1.9.3-alpha.4c6c68e5af7355d5a6dff1179055586e1093ac2d

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 (41) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +12 -8
  2. package/dist/adapters/aws-lambda/index.d.ts +12 -8
  3. package/dist/adapters/aws-lambda/index.mjs +12 -4
  4. package/dist/adapters/fetch/index.d.mts +15 -87
  5. package/dist/adapters/fetch/index.d.ts +15 -87
  6. package/dist/adapters/fetch/index.mjs +23 -161
  7. package/dist/adapters/node/index.d.mts +15 -64
  8. package/dist/adapters/node/index.d.ts +15 -64
  9. package/dist/adapters/node/index.mjs +21 -126
  10. package/dist/adapters/standard/index.d.mts +27 -14
  11. package/dist/adapters/standard/index.d.ts +27 -14
  12. package/dist/adapters/standard/index.mjs +9 -101
  13. package/dist/helpers/index.mjs +3 -29
  14. package/dist/index.d.mts +120 -583
  15. package/dist/index.d.ts +120 -583
  16. package/dist/index.mjs +213 -449
  17. package/dist/openapi/index.d.mts +204 -0
  18. package/dist/openapi/index.d.ts +204 -0
  19. package/dist/openapi/index.mjs +692 -0
  20. package/dist/shared/server.BbUmcWIW.d.mts +41 -0
  21. package/dist/shared/server.BfraJHay.d.mts +373 -0
  22. package/dist/shared/server.BfraJHay.d.ts +373 -0
  23. package/dist/shared/server.C1RJffw4.mjs +30 -0
  24. package/dist/shared/server.CHugaZ_Y.d.ts +41 -0
  25. package/dist/shared/server.CQIFwyhc.mjs +40 -0
  26. package/dist/shared/server.CYa9puL2.mjs +403 -0
  27. package/dist/shared/server.ChOv1yG3.mjs +319 -0
  28. package/dist/shared/server.Cza0RB3u.mjs +160 -0
  29. package/dist/shared/server.YUvuxHty.mjs +48 -0
  30. package/package.json +18 -30
  31. package/dist/plugins/index.d.mts +0 -160
  32. package/dist/plugins/index.d.ts +0 -160
  33. package/dist/plugins/index.mjs +0 -288
  34. package/dist/shared/server.BEQrAa3A.mjs +0 -207
  35. package/dist/shared/server.Bo94xDTv.d.mts +0 -73
  36. package/dist/shared/server.Btxrgkj5.d.ts +0 -73
  37. package/dist/shared/server.C1YnHvvf.d.mts +0 -192
  38. package/dist/shared/server.C1YnHvvf.d.ts +0 -192
  39. package/dist/shared/server.D6K9uoPI.mjs +0 -35
  40. package/dist/shared/server.DZ5BIITo.mjs +0 -9
  41. package/dist/shared/server.X0YaZxSJ.mjs +0 -13
@@ -0,0 +1,204 @@
1
+ import { Contract } from '@temporary-name/server';
2
+ import { OpenAPI, Promisable, Value, HTTPPath, HTTPMethod } from '@temporary-name/shared';
3
+ export { OpenAPI } from '@temporary-name/shared';
4
+ import { d as AnySchema, b as Contract$1, ac as TraverseContractProcedureCallbackOptions, a2 as ContractRouter, w as AnyRouter } from '../shared/server.BfraJHay.mjs';
5
+ import { JSONSchema } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
6
+ export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
7
+ import '@temporary-name/zod';
8
+
9
+ type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, procedure: Contract) => OpenAPI.OperationObject);
10
+ /**
11
+ * Customize The Operation Object by proxy an error map item or a middleware.
12
+ *
13
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#customizing-operation-objects Customizing Operation Objects Docs}
14
+ */
15
+ declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
16
+ declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
17
+ declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: Contract): OpenAPI.OperationObject;
18
+
19
+ /**
20
+ * @internal
21
+ */
22
+ type ObjectSchema = JSONSchema & {
23
+ type: 'object';
24
+ } & object;
25
+ /**
26
+ * @internal
27
+ */
28
+ type FileSchema = JSONSchema & {
29
+ type: 'string';
30
+ contentMediaType: string;
31
+ } & object;
32
+ /**
33
+ * @internal
34
+ */
35
+ declare const LOGIC_KEYWORDS: string[];
36
+
37
+ interface SchemaConverterComponent {
38
+ allowedStrategies: readonly SchemaConvertOptions['strategy'][];
39
+ schema: AnySchema;
40
+ required: boolean;
41
+ ref: string;
42
+ }
43
+ interface SchemaConvertOptions {
44
+ strategy: 'input' | 'output';
45
+ /**
46
+ * Common components should use `$ref` to represent themselves if matched.
47
+ */
48
+ components?: readonly SchemaConverterComponent[];
49
+ /**
50
+ * Minimum schema structure depth required before using `$ref` for components.
51
+ *
52
+ * For example, if set to 2, `$ref` will only be used for schemas nested at depth 2 or greater.
53
+ *
54
+ * @default 0 - No depth limit;
55
+ */
56
+ minStructureDepthForRef?: number;
57
+ }
58
+ interface SchemaConverter {
59
+ convert(schemas: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
60
+ }
61
+ interface ConditionalSchemaConverter extends SchemaConverter {
62
+ condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
63
+ }
64
+ declare class CompositeSchemaConverter implements SchemaConverter {
65
+ private readonly converters;
66
+ constructor(converters: readonly ConditionalSchemaConverter[]);
67
+ convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promise<[required: boolean, jsonSchema: JSONSchema]>;
68
+ }
69
+
70
+ interface OpenAPIGeneratorOptions {
71
+ schemaConverters?: ConditionalSchemaConverter[];
72
+ }
73
+ interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document, 'openapi'>> {
74
+ /**
75
+ * Exclude procedures from the OpenAPI specification.
76
+ *
77
+ * @deprecated Use `filter` option instead.
78
+ * @default () => false
79
+ */
80
+ exclude?: (procedure: Contract$1, path: readonly string[]) => boolean;
81
+ /**
82
+ * Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
83
+ *
84
+ * @default true
85
+ */
86
+ filter?: Value<boolean, [options: TraverseContractProcedureCallbackOptions]>;
87
+ /**
88
+ * Common schemas to be used for $ref resolution.
89
+ */
90
+ commonSchemas?: Record<string, {
91
+ /**
92
+ * Determines which schema definition to use when input and output schemas differ.
93
+ * This is needed because some schemas transform data differently between input and output,
94
+ * making it impossible to use a single $ref for both cases.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * // This schema transforms a string input into a number output
99
+ * const Schema = z.string()
100
+ * .transform(v => Number(v))
101
+ * .pipe(z.number())
102
+ *
103
+ * // Input schema: { type: 'string' }
104
+ * // Output schema: { type: 'number' }
105
+ * ```
106
+ *
107
+ * When schemas differ between input and output, you must explicitly choose
108
+ * which version to use for the OpenAPI specification.
109
+ *
110
+ * @default 'input' - Uses the input schema definition by default
111
+ */
112
+ strategy?: SchemaConvertOptions['strategy'];
113
+ schema: AnySchema;
114
+ } | {
115
+ error: 'UndefinedError';
116
+ schema?: never;
117
+ }>;
118
+ }
119
+ /**
120
+ * The generator that converts oRPC routers/contracts to OpenAPI specifications.
121
+ *
122
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
123
+ */
124
+ declare class OpenAPIGenerator {
125
+ #private;
126
+ private readonly converter;
127
+ constructor(options?: OpenAPIGeneratorOptions);
128
+ /**
129
+ * Generates OpenAPI specifications from oRPC routers/contracts.
130
+ *
131
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
132
+ */
133
+ generate(router: ContractRouter | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
134
+ }
135
+
136
+ /**
137
+ * @internal
138
+ */
139
+ declare function toOpenAPIPath(path: HTTPPath): string;
140
+ /**
141
+ * @internal
142
+ */
143
+ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
144
+ /**
145
+ * @internal
146
+ */
147
+ declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
148
+ /**
149
+ * @internal
150
+ */
151
+ declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPI.MediaTypeObject>;
152
+ /**
153
+ * @internal
154
+ */
155
+ declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPI.ParameterObject[];
156
+ /**
157
+ * @internal
158
+ */
159
+ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
160
+ /**
161
+ * @internal
162
+ */
163
+ declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
164
+ declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
165
+
166
+ /**
167
+ *@internal
168
+ */
169
+ declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
170
+ /**
171
+ * @internal
172
+ */
173
+ declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
174
+ /**
175
+ * @internal
176
+ */
177
+ declare function isAnySchema(schema: JSONSchema): boolean;
178
+ /**
179
+ * @internal
180
+ */
181
+ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
182
+ /**
183
+ * @internal
184
+ */
185
+ declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
186
+ declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
187
+ /**
188
+ * Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),
189
+ * recursively expands it into an array of its constituent, non-union base schemas.
190
+ * If the schema is not a simple union or is a base type, it's returned as a single-element array.
191
+ */
192
+ declare function expandUnionSchema(schema: JSONSchema): JSONSchema[];
193
+ declare function expandArrayableSchema(schema: JSONSchema): undefined | [items: JSONSchema, array: JSONSchema & {
194
+ type: 'array';
195
+ items?: JSONSchema;
196
+ }];
197
+ declare function isPrimitiveSchema(schema: JSONSchema): boolean;
198
+
199
+ declare const oo: {
200
+ spec: typeof customOpenAPIOperation;
201
+ };
202
+
203
+ export { CompositeSchemaConverter, LOGIC_KEYWORDS, OpenAPIGenerator, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
204
+ export type { ConditionalSchemaConverter, FileSchema, ObjectSchema, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, OverrideOperationValue, SchemaConvertOptions, SchemaConverter, SchemaConverterComponent };
@@ -0,0 +1,204 @@
1
+ import { Contract } from '@temporary-name/server';
2
+ import { OpenAPI, Promisable, Value, HTTPPath, HTTPMethod } from '@temporary-name/shared';
3
+ export { OpenAPI } from '@temporary-name/shared';
4
+ import { d as AnySchema, b as Contract$1, ac as TraverseContractProcedureCallbackOptions, a2 as ContractRouter, w as AnyRouter } from '../shared/server.BfraJHay.js';
5
+ import { JSONSchema } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
6
+ export { JSONSchema, ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
7
+ import '@temporary-name/zod';
8
+
9
+ type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, procedure: Contract) => OpenAPI.OperationObject);
10
+ /**
11
+ * Customize The Operation Object by proxy an error map item or a middleware.
12
+ *
13
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#customizing-operation-objects Customizing Operation Objects Docs}
14
+ */
15
+ declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
16
+ declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
17
+ declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: Contract): OpenAPI.OperationObject;
18
+
19
+ /**
20
+ * @internal
21
+ */
22
+ type ObjectSchema = JSONSchema & {
23
+ type: 'object';
24
+ } & object;
25
+ /**
26
+ * @internal
27
+ */
28
+ type FileSchema = JSONSchema & {
29
+ type: 'string';
30
+ contentMediaType: string;
31
+ } & object;
32
+ /**
33
+ * @internal
34
+ */
35
+ declare const LOGIC_KEYWORDS: string[];
36
+
37
+ interface SchemaConverterComponent {
38
+ allowedStrategies: readonly SchemaConvertOptions['strategy'][];
39
+ schema: AnySchema;
40
+ required: boolean;
41
+ ref: string;
42
+ }
43
+ interface SchemaConvertOptions {
44
+ strategy: 'input' | 'output';
45
+ /**
46
+ * Common components should use `$ref` to represent themselves if matched.
47
+ */
48
+ components?: readonly SchemaConverterComponent[];
49
+ /**
50
+ * Minimum schema structure depth required before using `$ref` for components.
51
+ *
52
+ * For example, if set to 2, `$ref` will only be used for schemas nested at depth 2 or greater.
53
+ *
54
+ * @default 0 - No depth limit;
55
+ */
56
+ minStructureDepthForRef?: number;
57
+ }
58
+ interface SchemaConverter {
59
+ convert(schemas: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
60
+ }
61
+ interface ConditionalSchemaConverter extends SchemaConverter {
62
+ condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
63
+ }
64
+ declare class CompositeSchemaConverter implements SchemaConverter {
65
+ private readonly converters;
66
+ constructor(converters: readonly ConditionalSchemaConverter[]);
67
+ convert(schema: AnySchema | undefined, options: SchemaConvertOptions): Promise<[required: boolean, jsonSchema: JSONSchema]>;
68
+ }
69
+
70
+ interface OpenAPIGeneratorOptions {
71
+ schemaConverters?: ConditionalSchemaConverter[];
72
+ }
73
+ interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document, 'openapi'>> {
74
+ /**
75
+ * Exclude procedures from the OpenAPI specification.
76
+ *
77
+ * @deprecated Use `filter` option instead.
78
+ * @default () => false
79
+ */
80
+ exclude?: (procedure: Contract$1, path: readonly string[]) => boolean;
81
+ /**
82
+ * Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
83
+ *
84
+ * @default true
85
+ */
86
+ filter?: Value<boolean, [options: TraverseContractProcedureCallbackOptions]>;
87
+ /**
88
+ * Common schemas to be used for $ref resolution.
89
+ */
90
+ commonSchemas?: Record<string, {
91
+ /**
92
+ * Determines which schema definition to use when input and output schemas differ.
93
+ * This is needed because some schemas transform data differently between input and output,
94
+ * making it impossible to use a single $ref for both cases.
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * // This schema transforms a string input into a number output
99
+ * const Schema = z.string()
100
+ * .transform(v => Number(v))
101
+ * .pipe(z.number())
102
+ *
103
+ * // Input schema: { type: 'string' }
104
+ * // Output schema: { type: 'number' }
105
+ * ```
106
+ *
107
+ * When schemas differ between input and output, you must explicitly choose
108
+ * which version to use for the OpenAPI specification.
109
+ *
110
+ * @default 'input' - Uses the input schema definition by default
111
+ */
112
+ strategy?: SchemaConvertOptions['strategy'];
113
+ schema: AnySchema;
114
+ } | {
115
+ error: 'UndefinedError';
116
+ schema?: never;
117
+ }>;
118
+ }
119
+ /**
120
+ * The generator that converts oRPC routers/contracts to OpenAPI specifications.
121
+ *
122
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
123
+ */
124
+ declare class OpenAPIGenerator {
125
+ #private;
126
+ private readonly converter;
127
+ constructor(options?: OpenAPIGeneratorOptions);
128
+ /**
129
+ * Generates OpenAPI specifications from oRPC routers/contracts.
130
+ *
131
+ * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
132
+ */
133
+ generate(router: ContractRouter | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
134
+ }
135
+
136
+ /**
137
+ * @internal
138
+ */
139
+ declare function toOpenAPIPath(path: HTTPPath): string;
140
+ /**
141
+ * @internal
142
+ */
143
+ declare function toOpenAPIMethod(method: HTTPMethod): Lowercase<HTTPMethod>;
144
+ /**
145
+ * @internal
146
+ */
147
+ declare function toOpenAPIContent(schema: JSONSchema): Record<string, OpenAPI.MediaTypeObject>;
148
+ /**
149
+ * @internal
150
+ */
151
+ declare function toOpenAPIEventIteratorContent([yieldsRequired, yieldsSchema]: [boolean, JSONSchema], [returnsRequired, returnsSchema]: [boolean, JSONSchema]): Record<string, OpenAPI.MediaTypeObject>;
152
+ /**
153
+ * @internal
154
+ */
155
+ declare function toOpenAPIParameters(schema: ObjectSchema, parameterIn: 'path' | 'query' | 'header' | 'cookie'): OpenAPI.ParameterObject[];
156
+ /**
157
+ * @internal
158
+ */
159
+ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): boolean;
160
+ /**
161
+ * @internal
162
+ */
163
+ declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
164
+ declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
165
+
166
+ /**
167
+ *@internal
168
+ */
169
+ declare function isFileSchema(schema: JSONSchema): schema is FileSchema;
170
+ /**
171
+ * @internal
172
+ */
173
+ declare function isObjectSchema(schema: JSONSchema): schema is ObjectSchema;
174
+ /**
175
+ * @internal
176
+ */
177
+ declare function isAnySchema(schema: JSONSchema): boolean;
178
+ /**
179
+ * @internal
180
+ */
181
+ declare function separateObjectSchema(schema: ObjectSchema, separatedProperties: string[]): [matched: ObjectSchema, rest: ObjectSchema];
182
+ /**
183
+ * @internal
184
+ */
185
+ declare function filterSchemaBranches(schema: JSONSchema, check: (schema: JSONSchema) => boolean, matches?: JSONSchema[]): [matches: JSONSchema[], rest: JSONSchema | undefined];
186
+ declare function applySchemaOptionality(required: boolean, schema: JSONSchema): JSONSchema;
187
+ /**
188
+ * Takes a JSON schema and, if it's primarily a union type (anyOf, oneOf),
189
+ * recursively expands it into an array of its constituent, non-union base schemas.
190
+ * If the schema is not a simple union or is a base type, it's returned as a single-element array.
191
+ */
192
+ declare function expandUnionSchema(schema: JSONSchema): JSONSchema[];
193
+ declare function expandArrayableSchema(schema: JSONSchema): undefined | [items: JSONSchema, array: JSONSchema & {
194
+ type: 'array';
195
+ items?: JSONSchema;
196
+ }];
197
+ declare function isPrimitiveSchema(schema: JSONSchema): boolean;
198
+
199
+ declare const oo: {
200
+ spec: typeof customOpenAPIOperation;
201
+ };
202
+
203
+ export { CompositeSchemaConverter, LOGIC_KEYWORDS, OpenAPIGenerator, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
204
+ export type { ConditionalSchemaConverter, FileSchema, ObjectSchema, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, OverrideOperationValue, SchemaConvertOptions, SchemaConverter, SchemaConverterComponent };