@temporary-name/server 1.9.3-alpha.82e5e55517330d6049913c9b2f19e60239cd25d9 → 1.9.3-alpha.907c7c78d0193d34752279de92d699e50d6bc3a1
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/adapters/aws-lambda/index.d.mts +4 -6
- package/dist/adapters/aws-lambda/index.d.ts +4 -6
- package/dist/adapters/aws-lambda/index.mjs +5 -7
- package/dist/adapters/fetch/index.d.mts +8 -86
- package/dist/adapters/fetch/index.d.ts +8 -86
- package/dist/adapters/fetch/index.mjs +17 -158
- package/dist/adapters/node/index.d.mts +8 -63
- package/dist/adapters/node/index.d.ts +8 -63
- package/dist/adapters/node/index.mjs +15 -123
- package/dist/adapters/standard/index.d.mts +20 -33
- package/dist/adapters/standard/index.d.ts +20 -33
- package/dist/adapters/standard/index.mjs +5 -7
- package/dist/helpers/index.mjs +3 -29
- package/dist/index.d.mts +121 -469
- package/dist/index.d.ts +121 -469
- package/dist/index.mjs +242 -445
- package/dist/openapi/index.d.mts +12 -28
- package/dist/openapi/index.d.ts +12 -28
- package/dist/openapi/index.mjs +66 -150
- package/dist/shared/server.Bj_UpI5O.d.mts +372 -0
- package/dist/shared/server.Bj_UpI5O.d.ts +372 -0
- package/dist/shared/server.C1RJffw4.mjs +30 -0
- package/dist/shared/server.C6VnFy4S.d.mts +41 -0
- package/dist/shared/server.CQIFwyhc.mjs +40 -0
- package/dist/shared/server.ChOv1yG3.mjs +319 -0
- package/dist/shared/server.CnzXkSjj.d.ts +41 -0
- package/dist/shared/server.DXzEGRE2.mjs +403 -0
- package/dist/shared/server.DgzAlPjF.mjs +160 -0
- package/dist/shared/server.YUvuxHty.mjs +48 -0
- package/package.json +10 -26
- package/dist/plugins/index.d.mts +0 -160
- package/dist/plugins/index.d.ts +0 -160
- package/dist/plugins/index.mjs +0 -288
- package/dist/shared/server.BEHw7Eyx.mjs +0 -247
- package/dist/shared/server.BKSOrA6h.d.mts +0 -192
- package/dist/shared/server.BKSOrA6h.d.ts +0 -192
- package/dist/shared/server.BKh8I1Ny.mjs +0 -239
- package/dist/shared/server.BeuTpcmO.d.mts +0 -23
- package/dist/shared/server.C1fnTLq0.d.mts +0 -57
- package/dist/shared/server.CQyYNJ1H.d.ts +0 -57
- package/dist/shared/server.DLsti1Pv.mjs +0 -293
- package/dist/shared/server.SLLuK6_v.d.ts +0 -23
package/dist/openapi/index.d.mts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
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.Bj_UpI5O.mjs';
|
|
5
5
|
import { JSONSchema } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
|
|
6
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';
|
|
7
8
|
|
|
8
|
-
type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, procedure:
|
|
9
|
+
type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, procedure: Contract) => OpenAPI.OperationObject);
|
|
9
10
|
/**
|
|
10
11
|
* Customize The Operation Object by proxy an error map item or a middleware.
|
|
11
12
|
*
|
|
@@ -13,7 +14,7 @@ type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: Open
|
|
|
13
14
|
*/
|
|
14
15
|
declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
|
|
15
16
|
declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
|
|
16
|
-
declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract:
|
|
17
|
+
declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: Contract): OpenAPI.OperationObject;
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* @internal
|
|
@@ -55,7 +56,7 @@ interface SchemaConvertOptions {
|
|
|
55
56
|
minStructureDepthForRef?: number;
|
|
56
57
|
}
|
|
57
58
|
interface SchemaConverter {
|
|
58
|
-
convert(
|
|
59
|
+
convert(schemas: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
|
|
59
60
|
}
|
|
60
61
|
interface ConditionalSchemaConverter extends SchemaConverter {
|
|
61
62
|
condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
|
|
@@ -76,7 +77,7 @@ interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document,
|
|
|
76
77
|
* @deprecated Use `filter` option instead.
|
|
77
78
|
* @default () => false
|
|
78
79
|
*/
|
|
79
|
-
exclude?: (procedure:
|
|
80
|
+
exclude?: (procedure: Contract$1, path: readonly string[]) => boolean;
|
|
80
81
|
/**
|
|
81
82
|
* Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
|
|
82
83
|
*
|
|
@@ -129,7 +130,7 @@ declare class OpenAPIGenerator {
|
|
|
129
130
|
*
|
|
130
131
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
131
132
|
*/
|
|
132
|
-
generate(router:
|
|
133
|
+
generate(router: ContractRouter | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
/**
|
|
@@ -162,23 +163,6 @@ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): bool
|
|
|
162
163
|
declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
|
|
163
164
|
declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
|
|
164
165
|
|
|
165
|
-
type JsonifiedValue<T> = T extends string ? T : T extends number ? T : T extends boolean ? T : T extends null ? T : T extends undefined ? T : T extends Array<unknown> ? JsonifiedArray<T> : T extends Record<string, unknown> ? {
|
|
166
|
-
[K in keyof T]: JsonifiedValue<T[K]>;
|
|
167
|
-
} : T extends Date ? string : T extends bigint ? string : T extends File ? File : T extends Blob ? Blob : T extends RegExp ? string : T extends URL ? string : T extends Map<infer K, infer V> ? JsonifiedArray<[K, V][]> : T extends Set<infer U> ? JsonifiedArray<U[]> : T extends AsyncIteratorObject<infer U, infer V> ? AsyncIteratorObject<JsonifiedValue<U>, JsonifiedValue<V>> : unknown;
|
|
168
|
-
type JsonifiedArray<T extends Array<unknown>> = T extends readonly [] ? [] : T extends readonly [infer U, ...infer V] ? [
|
|
169
|
-
U extends undefined ? null : JsonifiedValue<U>,
|
|
170
|
-
...JsonifiedArray<V>
|
|
171
|
-
] : T extends Array<infer U> ? Array<JsonifiedValue<U>> : unknown;
|
|
172
|
-
/**
|
|
173
|
-
* Convert types that JSON not support to corresponding json types
|
|
174
|
-
*
|
|
175
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/client/openapi-link OpenAPI Link Docs}
|
|
176
|
-
*/
|
|
177
|
-
type JsonifiedClient<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Client<UClientContext, UInput, JsonifiedValue<UOutput>, UError extends ORPCError<infer UCode, infer UData> ? ORPCError<UCode, JsonifiedValue<UData>> : UError> : {
|
|
178
|
-
[K in keyof T]: T[K] extends NestedClient<any> ? JsonifiedClient<T[K]> : T[K];
|
|
179
|
-
};
|
|
180
|
-
declare function createJsonifiedRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): JsonifiedClient<RouterClient<T, TClientContext>>;
|
|
181
|
-
|
|
182
166
|
/**
|
|
183
167
|
*@internal
|
|
184
168
|
*/
|
|
@@ -216,5 +200,5 @@ declare const oo: {
|
|
|
216
200
|
spec: typeof customOpenAPIOperation;
|
|
217
201
|
};
|
|
218
202
|
|
|
219
|
-
export { CompositeSchemaConverter, LOGIC_KEYWORDS, OpenAPIGenerator, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema,
|
|
220
|
-
export type { ConditionalSchemaConverter, FileSchema,
|
|
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 };
|
package/dist/openapi/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
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.Bj_UpI5O.js';
|
|
5
5
|
import { JSONSchema } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
|
|
6
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';
|
|
7
8
|
|
|
8
|
-
type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, procedure:
|
|
9
|
+
type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: OpenAPI.OperationObject, procedure: Contract) => OpenAPI.OperationObject);
|
|
9
10
|
/**
|
|
10
11
|
* Customize The Operation Object by proxy an error map item or a middleware.
|
|
11
12
|
*
|
|
@@ -13,7 +14,7 @@ type OverrideOperationValue = Partial<OpenAPI.OperationObject> | ((current: Open
|
|
|
13
14
|
*/
|
|
14
15
|
declare function customOpenAPIOperation<T extends object>(o: T, extend: OverrideOperationValue): T;
|
|
15
16
|
declare function getCustomOpenAPIOperation(o: object): OverrideOperationValue | undefined;
|
|
16
|
-
declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract:
|
|
17
|
+
declare function applyCustomOpenAPIOperation(operation: OpenAPI.OperationObject, contract: Contract): OpenAPI.OperationObject;
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* @internal
|
|
@@ -55,7 +56,7 @@ interface SchemaConvertOptions {
|
|
|
55
56
|
minStructureDepthForRef?: number;
|
|
56
57
|
}
|
|
57
58
|
interface SchemaConverter {
|
|
58
|
-
convert(
|
|
59
|
+
convert(schemas: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
|
|
59
60
|
}
|
|
60
61
|
interface ConditionalSchemaConverter extends SchemaConverter {
|
|
61
62
|
condition(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<boolean>;
|
|
@@ -76,7 +77,7 @@ interface OpenAPIGeneratorGenerateOptions extends Partial<Omit<OpenAPI.Document,
|
|
|
76
77
|
* @deprecated Use `filter` option instead.
|
|
77
78
|
* @default () => false
|
|
78
79
|
*/
|
|
79
|
-
exclude?: (procedure:
|
|
80
|
+
exclude?: (procedure: Contract$1, path: readonly string[]) => boolean;
|
|
80
81
|
/**
|
|
81
82
|
* Filter procedures. Return `false` to exclude a procedure from the OpenAPI specification.
|
|
82
83
|
*
|
|
@@ -129,7 +130,7 @@ declare class OpenAPIGenerator {
|
|
|
129
130
|
*
|
|
130
131
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification OpenAPI Specification Docs}
|
|
131
132
|
*/
|
|
132
|
-
generate(router:
|
|
133
|
+
generate(router: ContractRouter | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
|
|
133
134
|
}
|
|
134
135
|
|
|
135
136
|
/**
|
|
@@ -162,23 +163,6 @@ declare function checkParamsSchema(schema: ObjectSchema, params: string[]): bool
|
|
|
162
163
|
declare function toOpenAPISchema(schema: JSONSchema): OpenAPI.SchemaObject & object;
|
|
163
164
|
declare function resolveOpenAPIJsonSchemaRef(doc: OpenAPI.Document, schema: JSONSchema): JSONSchema;
|
|
164
165
|
|
|
165
|
-
type JsonifiedValue<T> = T extends string ? T : T extends number ? T : T extends boolean ? T : T extends null ? T : T extends undefined ? T : T extends Array<unknown> ? JsonifiedArray<T> : T extends Record<string, unknown> ? {
|
|
166
|
-
[K in keyof T]: JsonifiedValue<T[K]>;
|
|
167
|
-
} : T extends Date ? string : T extends bigint ? string : T extends File ? File : T extends Blob ? Blob : T extends RegExp ? string : T extends URL ? string : T extends Map<infer K, infer V> ? JsonifiedArray<[K, V][]> : T extends Set<infer U> ? JsonifiedArray<U[]> : T extends AsyncIteratorObject<infer U, infer V> ? AsyncIteratorObject<JsonifiedValue<U>, JsonifiedValue<V>> : unknown;
|
|
168
|
-
type JsonifiedArray<T extends Array<unknown>> = T extends readonly [] ? [] : T extends readonly [infer U, ...infer V] ? [
|
|
169
|
-
U extends undefined ? null : JsonifiedValue<U>,
|
|
170
|
-
...JsonifiedArray<V>
|
|
171
|
-
] : T extends Array<infer U> ? Array<JsonifiedValue<U>> : unknown;
|
|
172
|
-
/**
|
|
173
|
-
* Convert types that JSON not support to corresponding json types
|
|
174
|
-
*
|
|
175
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/client/openapi-link OpenAPI Link Docs}
|
|
176
|
-
*/
|
|
177
|
-
type JsonifiedClient<T extends NestedClient<any>> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Client<UClientContext, UInput, JsonifiedValue<UOutput>, UError extends ORPCError<infer UCode, infer UData> ? ORPCError<UCode, JsonifiedValue<UData>> : UError> : {
|
|
178
|
-
[K in keyof T]: T[K] extends NestedClient<any> ? JsonifiedClient<T[K]> : T[K];
|
|
179
|
-
};
|
|
180
|
-
declare function createJsonifiedRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): JsonifiedClient<RouterClient<T, TClientContext>>;
|
|
181
|
-
|
|
182
166
|
/**
|
|
183
167
|
*@internal
|
|
184
168
|
*/
|
|
@@ -216,5 +200,5 @@ declare const oo: {
|
|
|
216
200
|
spec: typeof customOpenAPIOperation;
|
|
217
201
|
};
|
|
218
202
|
|
|
219
|
-
export { CompositeSchemaConverter, LOGIC_KEYWORDS, OpenAPIGenerator, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema,
|
|
220
|
-
export type { ConditionalSchemaConverter, FileSchema,
|
|
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 };
|
package/dist/openapi/index.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { isObject, stringifyJSON, findDeepMatches, toArray, clone, value, toHttpPath, isORPCErrorStatus, fallbackORPCErrorStatus, fallbackORPCErrorMessage, resolveMaybeOptionalOptions, createORPCErrorFromJson } from '@temporary-name/shared';
|
|
4
|
-
import { a as standardizeHTTPPath, j as jsonSerialize, g as getDynamicParams, d as deserialize, s as serialize } from '../shared/server.BEHw7Eyx.mjs';
|
|
1
|
+
import { isObject, stringifyJSON, findDeepMatches, toArray, clone, value, fallbackContractConfig, toHttpPath, isORPCErrorStatus } from '@temporary-name/shared';
|
|
2
|
+
import { j as jsonSerialize } from '../shared/server.CQIFwyhc.mjs';
|
|
5
3
|
import '@temporary-name/standard-server';
|
|
4
|
+
import { g as getEventIteratorSchemaDetails } from '../shared/server.YUvuxHty.mjs';
|
|
5
|
+
import { s as standardizeHTTPPath, r as resolveContractProcedures, g as getDynamicParams } from '../shared/server.ChOv1yG3.mjs';
|
|
6
6
|
import { TypeName } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
|
|
7
7
|
export { ContentEncoding as JSONSchemaContentEncoding, Format as JSONSchemaFormat, TypeName as JSONSchemaTypeName } from '@temporary-name/interop/json-schema-typed/draft-2020-12';
|
|
8
|
+
import '@temporary-name/zod';
|
|
8
9
|
|
|
9
10
|
const OPERATION_EXTENDER_SYMBOL = Symbol("ORPC_OPERATION_EXTENDER");
|
|
10
11
|
function customOpenAPIOperation(o, extend) {
|
|
@@ -22,20 +23,12 @@ function getCustomOpenAPIOperation(o) {
|
|
|
22
23
|
}
|
|
23
24
|
function applyCustomOpenAPIOperation(operation, contract) {
|
|
24
25
|
const operationCustoms = [];
|
|
25
|
-
for (const
|
|
26
|
-
const maybeExtender =
|
|
26
|
+
for (const middleware of contract["~orpc"].middlewares) {
|
|
27
|
+
const maybeExtender = getCustomOpenAPIOperation(middleware);
|
|
27
28
|
if (maybeExtender) {
|
|
28
29
|
operationCustoms.push(maybeExtender);
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
|
-
if (isProcedure(contract)) {
|
|
32
|
-
for (const middleware of contract["~orpc"].middlewares) {
|
|
33
|
-
const maybeExtender = getCustomOpenAPIOperation(middleware);
|
|
34
|
-
if (maybeExtender) {
|
|
35
|
-
operationCustoms.push(maybeExtender);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
32
|
let currentOperation = operation;
|
|
40
33
|
for (const custom of operationCustoms) {
|
|
41
34
|
if (typeof custom === "function") {
|
|
@@ -432,12 +425,6 @@ class OpenAPIGenerator {
|
|
|
432
425
|
};
|
|
433
426
|
await this.#request(doc, operationObjectRef, def, baseSchemaConvertOptions);
|
|
434
427
|
await this.#successResponse(doc, operationObjectRef, def, baseSchemaConvertOptions);
|
|
435
|
-
await this.#errorResponse(
|
|
436
|
-
operationObjectRef,
|
|
437
|
-
def,
|
|
438
|
-
baseSchemaConvertOptions,
|
|
439
|
-
undefinedErrorJsonSchema
|
|
440
|
-
);
|
|
441
428
|
}
|
|
442
429
|
if (typeof def.route.spec === "function") {
|
|
443
430
|
operationObjectRef = def.route.spec(operationObjectRef);
|
|
@@ -530,94 +517,77 @@ ${errors.join("\n\n")}`
|
|
|
530
517
|
}
|
|
531
518
|
async #request(doc, ref, def, baseSchemaConvertOptions) {
|
|
532
519
|
const method = fallbackContractConfig("defaultMethod", def.route.method);
|
|
533
|
-
const details = getEventIteratorSchemaDetails(def.inputSchema);
|
|
534
|
-
if (details) {
|
|
535
|
-
ref.requestBody = {
|
|
536
|
-
required: true,
|
|
537
|
-
content: toOpenAPIEventIteratorContent(
|
|
538
|
-
await this.converter.convert(details.yields, { ...baseSchemaConvertOptions, strategy: "input" }),
|
|
539
|
-
await this.converter.convert(details.returns, { ...baseSchemaConvertOptions, strategy: "input" })
|
|
540
|
-
)
|
|
541
|
-
};
|
|
542
|
-
return;
|
|
543
|
-
}
|
|
544
520
|
const dynamicParams = getDynamicParams(def.route.path)?.map((v) => v.name);
|
|
545
|
-
const
|
|
546
|
-
let [required, schema] = await this.converter.convert(def.inputSchema, {
|
|
521
|
+
const [_pathRequired, pathSchema] = await this.converter.convert(def.schemas.pathSchema, {
|
|
547
522
|
...baseSchemaConvertOptions,
|
|
548
523
|
strategy: "input",
|
|
549
|
-
minStructureDepthForRef:
|
|
524
|
+
minStructureDepthForRef: 1
|
|
550
525
|
});
|
|
551
|
-
if (
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
);
|
|
559
|
-
if (!isObjectSchema(schema)) {
|
|
560
|
-
throw error2;
|
|
561
|
-
}
|
|
562
|
-
const [paramsSchema, rest] = separateObjectSchema(schema, dynamicParams);
|
|
563
|
-
schema = rest;
|
|
564
|
-
required = rest.required ? rest.required.length !== 0 : false;
|
|
565
|
-
if (!checkParamsSchema(paramsSchema, dynamicParams)) {
|
|
566
|
-
throw error2;
|
|
567
|
-
}
|
|
568
|
-
ref.parameters ??= [];
|
|
569
|
-
ref.parameters.push(...toOpenAPIParameters(paramsSchema, "path"));
|
|
526
|
+
if (dynamicParams?.length) {
|
|
527
|
+
const error = new OpenAPIGeneratorError(
|
|
528
|
+
// TODO: fix this error
|
|
529
|
+
'When input structure is "compact", and path has dynamic params, input schema must be an object with all dynamic params as required.'
|
|
530
|
+
);
|
|
531
|
+
if (!isObjectSchema(pathSchema)) {
|
|
532
|
+
throw error;
|
|
570
533
|
}
|
|
571
|
-
if (
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
534
|
+
if (!checkParamsSchema(pathSchema, dynamicParams)) {
|
|
535
|
+
throw error;
|
|
536
|
+
}
|
|
537
|
+
ref.parameters ??= [];
|
|
538
|
+
ref.parameters.push(...toOpenAPIParameters(pathSchema, "path"));
|
|
539
|
+
} else {
|
|
540
|
+
const error = new OpenAPIGeneratorError("Params set via path do not match those on the route");
|
|
541
|
+
if (!isObjectSchema(pathSchema)) {
|
|
542
|
+
console.log("FOO", pathSchema);
|
|
543
|
+
throw error;
|
|
544
|
+
}
|
|
545
|
+
if (!checkParamsSchema(pathSchema, [])) {
|
|
546
|
+
console.log("BAR", pathSchema);
|
|
547
|
+
throw error;
|
|
585
548
|
}
|
|
586
|
-
return;
|
|
587
|
-
}
|
|
588
|
-
const error = new OpenAPIGeneratorError(
|
|
589
|
-
'When input structure is "detailed", input schema must satisfy: { params?: Record<string, unknown>, query?: Record<string, unknown>, headers?: Record<string, unknown>, body?: unknown }'
|
|
590
|
-
);
|
|
591
|
-
if (!isObjectSchema(schema)) {
|
|
592
|
-
throw error;
|
|
593
549
|
}
|
|
594
|
-
const
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
550
|
+
const [_queryRequired, querySchema] = await this.converter.convert(def.schemas.querySchema, {
|
|
551
|
+
...baseSchemaConvertOptions,
|
|
552
|
+
strategy: "input",
|
|
553
|
+
minStructureDepthForRef: 0
|
|
554
|
+
});
|
|
555
|
+
if (!isAnySchema(querySchema)) {
|
|
556
|
+
const resolvedSchema = resolveOpenAPIJsonSchemaRef(doc, querySchema);
|
|
557
|
+
if (!isObjectSchema(resolvedSchema)) {
|
|
558
|
+
throw new OpenAPIGeneratorError("Query param schema must satisfy: object | any | unknown");
|
|
559
|
+
}
|
|
560
|
+
ref.parameters ??= [];
|
|
561
|
+
ref.parameters.push(...toOpenAPIParameters(resolvedSchema, "query"));
|
|
599
562
|
}
|
|
600
|
-
|
|
601
|
-
const
|
|
602
|
-
if (
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
563
|
+
if (method !== "GET") {
|
|
564
|
+
const details = getEventIteratorSchemaDetails(def.schemas.bodySchema);
|
|
565
|
+
if (details) {
|
|
566
|
+
ref.requestBody = {
|
|
567
|
+
required: true,
|
|
568
|
+
content: toOpenAPIEventIteratorContent(
|
|
569
|
+
await this.converter.convert(details.yields, { ...baseSchemaConvertOptions, strategy: "input" }),
|
|
570
|
+
await this.converter.convert(details.returns, { ...baseSchemaConvertOptions, strategy: "input" })
|
|
571
|
+
)
|
|
572
|
+
};
|
|
573
|
+
} else {
|
|
574
|
+
const [bodyRequired, bodySchema] = await this.converter.convert(def.schemas.bodySchema, {
|
|
575
|
+
...baseSchemaConvertOptions,
|
|
576
|
+
strategy: "input",
|
|
577
|
+
minStructureDepthForRef: 0
|
|
578
|
+
});
|
|
579
|
+
if (isAnySchema(bodySchema)) {
|
|
580
|
+
return;
|
|
606
581
|
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
582
|
+
ref.requestBody = {
|
|
583
|
+
required: bodyRequired,
|
|
584
|
+
content: toOpenAPIContent(bodySchema)
|
|
585
|
+
};
|
|
610
586
|
}
|
|
611
587
|
}
|
|
612
|
-
if (schema.properties?.body !== void 0) {
|
|
613
|
-
ref.requestBody = {
|
|
614
|
-
required: schema.required?.includes("body"),
|
|
615
|
-
content: toOpenAPIContent(schema.properties.body)
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
588
|
}
|
|
619
589
|
async #successResponse(doc, ref, def, baseSchemaConvertOptions) {
|
|
620
|
-
const outputSchema = def.outputSchema;
|
|
590
|
+
const outputSchema = def.schemas.outputSchema;
|
|
621
591
|
const status = fallbackContractConfig("defaultSuccessStatus", def.route.successStatus);
|
|
622
592
|
const description = fallbackContractConfig("defaultSuccessDescription", def.route?.successDescription);
|
|
623
593
|
const eventIteratorSchemaDetails = getEventIteratorSchemaDetails(outputSchema);
|
|
@@ -713,64 +683,10 @@ ${errors.join("\n\n")}`
|
|
|
713
683
|
}
|
|
714
684
|
}
|
|
715
685
|
}
|
|
716
|
-
async #errorResponse(ref, def, baseSchemaConvertOptions, undefinedErrorSchema) {
|
|
717
|
-
const errorMap = def.errorMap;
|
|
718
|
-
const errors = {};
|
|
719
|
-
for (const code in errorMap) {
|
|
720
|
-
const config = errorMap[code];
|
|
721
|
-
if (!config) {
|
|
722
|
-
continue;
|
|
723
|
-
}
|
|
724
|
-
const status = fallbackORPCErrorStatus(code, config.status);
|
|
725
|
-
const message = fallbackORPCErrorMessage(code, config.message);
|
|
726
|
-
const [dataRequired, dataSchema] = await this.converter.convert(config.data, {
|
|
727
|
-
...baseSchemaConvertOptions,
|
|
728
|
-
strategy: "output"
|
|
729
|
-
});
|
|
730
|
-
errors[status] ??= [];
|
|
731
|
-
errors[status].push({
|
|
732
|
-
type: "object",
|
|
733
|
-
properties: {
|
|
734
|
-
defined: { const: true },
|
|
735
|
-
code: { const: code },
|
|
736
|
-
status: { const: status },
|
|
737
|
-
message: { type: "string", default: message },
|
|
738
|
-
data: dataSchema
|
|
739
|
-
},
|
|
740
|
-
required: dataRequired ? ["defined", "code", "status", "message", "data"] : ["defined", "code", "status", "message"]
|
|
741
|
-
});
|
|
742
|
-
}
|
|
743
|
-
ref.responses ??= {};
|
|
744
|
-
for (const status in errors) {
|
|
745
|
-
const schemas = errors[status];
|
|
746
|
-
ref.responses[status] = {
|
|
747
|
-
description: status,
|
|
748
|
-
content: toOpenAPIContent({
|
|
749
|
-
oneOf: [...schemas, undefinedErrorSchema]
|
|
750
|
-
})
|
|
751
|
-
};
|
|
752
|
-
}
|
|
753
|
-
}
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
function createJsonifiedRouterClient(router, ...rest) {
|
|
757
|
-
const options = resolveMaybeOptionalOptions(rest);
|
|
758
|
-
options.interceptors ??= [];
|
|
759
|
-
options.interceptors.unshift(async (options2) => {
|
|
760
|
-
try {
|
|
761
|
-
return deserialize(serialize(await options2.next()));
|
|
762
|
-
} catch (e) {
|
|
763
|
-
if (e instanceof ORPCError) {
|
|
764
|
-
throw createORPCErrorFromJson(deserialize(serialize(e.toJSON(), { outputFormat: "plain" })));
|
|
765
|
-
}
|
|
766
|
-
throw e;
|
|
767
|
-
}
|
|
768
|
-
});
|
|
769
|
-
return createRouterClient(router, options);
|
|
770
686
|
}
|
|
771
687
|
|
|
772
688
|
const oo = {
|
|
773
689
|
spec: customOpenAPIOperation
|
|
774
690
|
};
|
|
775
691
|
|
|
776
|
-
export { CompositeSchemaConverter, LOGIC_KEYWORDS, OpenAPIGenerator, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema,
|
|
692
|
+
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 };
|