@temporary-name/server 1.9.3-alpha.6ef4729e23affbe6454d37025d1dfc4d998b0649 → 1.9.3-alpha.70ac9623e5fa2a8af7954e34ef97cee968e5cad9

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