@temporary-name/server 1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc → 1.9.3-alpha.ec3bfb9dce56198911349c322c970208b21b50db
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 +4 -4
- package/dist/adapters/fetch/index.d.mts +8 -86
- package/dist/adapters/fetch/index.d.ts +8 -86
- package/dist/adapters/fetch/index.mjs +16 -155
- package/dist/adapters/node/index.d.mts +8 -63
- package/dist/adapters/node/index.d.ts +8 -63
- package/dist/adapters/node/index.mjs +14 -120
- package/dist/adapters/standard/index.d.mts +10 -7
- package/dist/adapters/standard/index.d.ts +10 -7
- package/dist/adapters/standard/index.mjs +4 -4
- package/dist/helpers/index.mjs +3 -29
- package/dist/index.d.mts +121 -239
- package/dist/index.d.ts +121 -239
- package/dist/index.mjs +167 -352
- package/dist/openapi/index.d.mts +12 -28
- package/dist/openapi/index.d.ts +12 -28
- package/dist/openapi/index.mjs +59 -112
- package/dist/shared/server.C1RJffw4.mjs +30 -0
- package/dist/shared/server.CQIFwyhc.mjs +40 -0
- package/dist/shared/server.CVhIyQ4x.d.mts +41 -0
- package/dist/shared/server.CYa9puL2.mjs +403 -0
- package/dist/shared/server.ChOv1yG3.mjs +319 -0
- package/dist/shared/server.Cj3_Lp61.d.mts +373 -0
- package/dist/shared/server.Cj3_Lp61.d.ts +373 -0
- package/dist/shared/server.Cza0RB3u.mjs +160 -0
- package/dist/shared/server.D8RAzJ_p.d.ts +41 -0
- package/dist/shared/server.YUvuxHty.mjs +48 -0
- package/package.json +10 -28
- 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.B93y_8tj.d.mts +0 -23
- package/dist/shared/server.BYYf0Wn6.mjs +0 -202
- package/dist/shared/server.C3RuMHWl.d.mts +0 -192
- package/dist/shared/server.C3RuMHWl.d.ts +0 -192
- package/dist/shared/server.CT1xhSmE.d.mts +0 -56
- package/dist/shared/server.CqTex_jI.mjs +0 -265
- package/dist/shared/server.D_fags8X.d.ts +0 -23
- package/dist/shared/server.Kxw442A9.mjs +0 -247
- package/dist/shared/server.cjcgLdr1.d.ts +0 -56
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, ab as TraverseContractProcedureCallbackOptions, a1 as ContractRouter, v as AnyRouter } from '../shared/server.Cj3_Lp61.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, ab as TraverseContractProcedureCallbackOptions, a1 as ContractRouter, v as AnyRouter } from '../shared/server.Cj3_Lp61.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.Kxw442A9.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") {
|
|
@@ -401,10 +394,7 @@ class OpenAPIGenerator {
|
|
|
401
394
|
filter: void 0,
|
|
402
395
|
commonSchemas: void 0
|
|
403
396
|
};
|
|
404
|
-
const { baseSchemaConvertOptions
|
|
405
|
-
doc,
|
|
406
|
-
options.commonSchemas
|
|
407
|
-
);
|
|
397
|
+
const { baseSchemaConvertOptions } = await this.#resolveCommonSchemas(doc, options.commonSchemas);
|
|
408
398
|
const contracts = [];
|
|
409
399
|
await resolveContractProcedures({ path: [], router }, (traverseOptions) => {
|
|
410
400
|
if (!value(filter, traverseOptions)) {
|
|
@@ -432,12 +422,6 @@ class OpenAPIGenerator {
|
|
|
432
422
|
};
|
|
433
423
|
await this.#request(doc, operationObjectRef, def, baseSchemaConvertOptions);
|
|
434
424
|
await this.#successResponse(doc, operationObjectRef, def, baseSchemaConvertOptions);
|
|
435
|
-
await this.#errorResponse(
|
|
436
|
-
operationObjectRef,
|
|
437
|
-
def,
|
|
438
|
-
baseSchemaConvertOptions,
|
|
439
|
-
undefinedErrorJsonSchema
|
|
440
|
-
);
|
|
441
425
|
}
|
|
442
426
|
if (typeof def.route.spec === "function") {
|
|
443
427
|
operationObjectRef = def.route.spec(operationObjectRef);
|
|
@@ -530,60 +514,77 @@ ${errors.join("\n\n")}`
|
|
|
530
514
|
}
|
|
531
515
|
async #request(doc, ref, def, baseSchemaConvertOptions) {
|
|
532
516
|
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
517
|
const dynamicParams = getDynamicParams(def.route.path)?.map((v) => v.name);
|
|
545
|
-
|
|
518
|
+
const [_pathRequired, pathSchema] = await this.converter.convert(def.schemas.pathSchema, {
|
|
546
519
|
...baseSchemaConvertOptions,
|
|
547
520
|
strategy: "input",
|
|
548
|
-
minStructureDepthForRef:
|
|
521
|
+
minStructureDepthForRef: 1
|
|
549
522
|
});
|
|
550
|
-
if (isAnySchema(schema) && !dynamicParams?.length) {
|
|
551
|
-
return;
|
|
552
|
-
}
|
|
553
523
|
if (dynamicParams?.length) {
|
|
554
524
|
const error = new OpenAPIGeneratorError(
|
|
525
|
+
// TODO: fix this error
|
|
555
526
|
'When input structure is "compact", and path has dynamic params, input schema must be an object with all dynamic params as required.'
|
|
556
527
|
);
|
|
557
|
-
if (!isObjectSchema(
|
|
528
|
+
if (!isObjectSchema(pathSchema)) {
|
|
558
529
|
throw error;
|
|
559
530
|
}
|
|
560
|
-
|
|
561
|
-
schema = rest;
|
|
562
|
-
required = rest.required ? rest.required.length !== 0 : false;
|
|
563
|
-
if (!checkParamsSchema(paramsSchema, dynamicParams)) {
|
|
531
|
+
if (!checkParamsSchema(pathSchema, dynamicParams)) {
|
|
564
532
|
throw error;
|
|
565
533
|
}
|
|
566
534
|
ref.parameters ??= [];
|
|
567
|
-
ref.parameters.push(...toOpenAPIParameters(
|
|
535
|
+
ref.parameters.push(...toOpenAPIParameters(pathSchema, "path"));
|
|
536
|
+
} else {
|
|
537
|
+
const error = new OpenAPIGeneratorError("Params set via path do not match those on the route");
|
|
538
|
+
if (!isObjectSchema(pathSchema)) {
|
|
539
|
+
console.log("FOO", pathSchema);
|
|
540
|
+
throw error;
|
|
541
|
+
}
|
|
542
|
+
if (!checkParamsSchema(pathSchema, [])) {
|
|
543
|
+
console.log("BAR", pathSchema);
|
|
544
|
+
throw error;
|
|
545
|
+
}
|
|
568
546
|
}
|
|
569
|
-
|
|
570
|
-
|
|
547
|
+
const [_queryRequired, querySchema] = await this.converter.convert(def.schemas.querySchema, {
|
|
548
|
+
...baseSchemaConvertOptions,
|
|
549
|
+
strategy: "input",
|
|
550
|
+
minStructureDepthForRef: 0
|
|
551
|
+
});
|
|
552
|
+
if (!isAnySchema(querySchema)) {
|
|
553
|
+
const resolvedSchema = resolveOpenAPIJsonSchemaRef(doc, querySchema);
|
|
571
554
|
if (!isObjectSchema(resolvedSchema)) {
|
|
572
|
-
throw new OpenAPIGeneratorError(
|
|
573
|
-
'When method is "GET", input schema must satisfy: object | any | unknown'
|
|
574
|
-
);
|
|
555
|
+
throw new OpenAPIGeneratorError("Query param schema must satisfy: object | any | unknown");
|
|
575
556
|
}
|
|
576
557
|
ref.parameters ??= [];
|
|
577
558
|
ref.parameters.push(...toOpenAPIParameters(resolvedSchema, "query"));
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
559
|
+
}
|
|
560
|
+
if (method !== "GET") {
|
|
561
|
+
const details = getEventIteratorSchemaDetails(def.schemas.bodySchema);
|
|
562
|
+
if (details) {
|
|
563
|
+
ref.requestBody = {
|
|
564
|
+
required: true,
|
|
565
|
+
content: toOpenAPIEventIteratorContent(
|
|
566
|
+
await this.converter.convert(details.yields, { ...baseSchemaConvertOptions, strategy: "input" }),
|
|
567
|
+
await this.converter.convert(details.returns, { ...baseSchemaConvertOptions, strategy: "input" })
|
|
568
|
+
)
|
|
569
|
+
};
|
|
570
|
+
} else {
|
|
571
|
+
const [bodyRequired, bodySchema] = await this.converter.convert(def.schemas.bodySchema, {
|
|
572
|
+
...baseSchemaConvertOptions,
|
|
573
|
+
strategy: "input",
|
|
574
|
+
minStructureDepthForRef: 0
|
|
575
|
+
});
|
|
576
|
+
if (isAnySchema(bodySchema)) {
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
ref.requestBody = {
|
|
580
|
+
required: bodyRequired,
|
|
581
|
+
content: toOpenAPIContent(bodySchema)
|
|
582
|
+
};
|
|
583
|
+
}
|
|
583
584
|
}
|
|
584
585
|
}
|
|
585
586
|
async #successResponse(doc, ref, def, baseSchemaConvertOptions) {
|
|
586
|
-
const outputSchema = def.outputSchema;
|
|
587
|
+
const outputSchema = def.schemas.outputSchema;
|
|
587
588
|
const status = fallbackContractConfig("defaultSuccessStatus", def.route.successStatus);
|
|
588
589
|
const description = fallbackContractConfig("defaultSuccessDescription", def.route?.successDescription);
|
|
589
590
|
const eventIteratorSchemaDetails = getEventIteratorSchemaDetails(outputSchema);
|
|
@@ -679,64 +680,10 @@ ${errors.join("\n\n")}`
|
|
|
679
680
|
}
|
|
680
681
|
}
|
|
681
682
|
}
|
|
682
|
-
async #errorResponse(ref, def, baseSchemaConvertOptions, undefinedErrorSchema) {
|
|
683
|
-
const errorMap = def.errorMap;
|
|
684
|
-
const errors = {};
|
|
685
|
-
for (const code in errorMap) {
|
|
686
|
-
const config = errorMap[code];
|
|
687
|
-
if (!config) {
|
|
688
|
-
continue;
|
|
689
|
-
}
|
|
690
|
-
const status = fallbackORPCErrorStatus(code, config.status);
|
|
691
|
-
const message = fallbackORPCErrorMessage(code, config.message);
|
|
692
|
-
const [dataRequired, dataSchema] = await this.converter.convert(config.data, {
|
|
693
|
-
...baseSchemaConvertOptions,
|
|
694
|
-
strategy: "output"
|
|
695
|
-
});
|
|
696
|
-
errors[status] ??= [];
|
|
697
|
-
errors[status].push({
|
|
698
|
-
type: "object",
|
|
699
|
-
properties: {
|
|
700
|
-
defined: { const: true },
|
|
701
|
-
code: { const: code },
|
|
702
|
-
status: { const: status },
|
|
703
|
-
message: { type: "string", default: message },
|
|
704
|
-
data: dataSchema
|
|
705
|
-
},
|
|
706
|
-
required: dataRequired ? ["defined", "code", "status", "message", "data"] : ["defined", "code", "status", "message"]
|
|
707
|
-
});
|
|
708
|
-
}
|
|
709
|
-
ref.responses ??= {};
|
|
710
|
-
for (const status in errors) {
|
|
711
|
-
const schemas = errors[status];
|
|
712
|
-
ref.responses[status] = {
|
|
713
|
-
description: status,
|
|
714
|
-
content: toOpenAPIContent({
|
|
715
|
-
oneOf: [...schemas, undefinedErrorSchema]
|
|
716
|
-
})
|
|
717
|
-
};
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
function createJsonifiedRouterClient(router, ...rest) {
|
|
723
|
-
const options = resolveMaybeOptionalOptions(rest);
|
|
724
|
-
options.interceptors ??= [];
|
|
725
|
-
options.interceptors.unshift(async (options2) => {
|
|
726
|
-
try {
|
|
727
|
-
return deserialize(serialize(await options2.next()));
|
|
728
|
-
} catch (e) {
|
|
729
|
-
if (e instanceof ORPCError) {
|
|
730
|
-
throw createORPCErrorFromJson(deserialize(serialize(e.toJSON(), { outputFormat: "plain" })));
|
|
731
|
-
}
|
|
732
|
-
throw e;
|
|
733
|
-
}
|
|
734
|
-
});
|
|
735
|
-
return createRouterClient(router, options);
|
|
736
683
|
}
|
|
737
684
|
|
|
738
685
|
const oo = {
|
|
739
686
|
spec: customOpenAPIOperation
|
|
740
687
|
};
|
|
741
688
|
|
|
742
|
-
export { CompositeSchemaConverter, LOGIC_KEYWORDS, OpenAPIGenerator, applyCustomOpenAPIOperation, applySchemaOptionality, checkParamsSchema,
|
|
689
|
+
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 };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { parse, serialize } from 'cookie';
|
|
2
|
+
|
|
3
|
+
function setCookie(headers, name, value, options = {}) {
|
|
4
|
+
if (headers === void 0) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const cookieString = serialize(name, value, {
|
|
8
|
+
path: "/",
|
|
9
|
+
...options
|
|
10
|
+
});
|
|
11
|
+
headers.append("Set-Cookie", cookieString);
|
|
12
|
+
}
|
|
13
|
+
function getCookie(headers, name, options = {}) {
|
|
14
|
+
if (headers === void 0) {
|
|
15
|
+
return void 0;
|
|
16
|
+
}
|
|
17
|
+
const cookieHeader = headers.get("cookie");
|
|
18
|
+
if (cookieHeader === null) {
|
|
19
|
+
return void 0;
|
|
20
|
+
}
|
|
21
|
+
return parse(cookieHeader, options)[name];
|
|
22
|
+
}
|
|
23
|
+
function deleteCookie(headers, name, options = {}) {
|
|
24
|
+
return setCookie(headers, name, "", {
|
|
25
|
+
...options,
|
|
26
|
+
maxAge: 0
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { deleteCookie as d, getCookie as g, setCookie as s };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { isObject } from '@temporary-name/shared';
|
|
2
|
+
|
|
3
|
+
function jsonSerialize(data, hasBlobRef = { value: false }) {
|
|
4
|
+
if (data instanceof Blob) {
|
|
5
|
+
hasBlobRef.value = true;
|
|
6
|
+
return [data, hasBlobRef.value];
|
|
7
|
+
}
|
|
8
|
+
if (data instanceof Set) {
|
|
9
|
+
return jsonSerialize(Array.from(data), hasBlobRef);
|
|
10
|
+
}
|
|
11
|
+
if (data instanceof Map) {
|
|
12
|
+
return jsonSerialize(Array.from(data.entries()), hasBlobRef);
|
|
13
|
+
}
|
|
14
|
+
if (Array.isArray(data)) {
|
|
15
|
+
const json = data.map((v) => v === void 0 ? null : jsonSerialize(v, hasBlobRef)[0]);
|
|
16
|
+
return [json, hasBlobRef.value];
|
|
17
|
+
}
|
|
18
|
+
if (isObject(data)) {
|
|
19
|
+
const json = {};
|
|
20
|
+
for (const k in data) {
|
|
21
|
+
if (k === "toJSON" && typeof data[k] === "function") {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
json[k] = jsonSerialize(data[k], hasBlobRef)[0];
|
|
25
|
+
}
|
|
26
|
+
return [json, hasBlobRef.value];
|
|
27
|
+
}
|
|
28
|
+
if (typeof data === "bigint" || data instanceof RegExp || data instanceof URL) {
|
|
29
|
+
return [data.toString(), hasBlobRef.value];
|
|
30
|
+
}
|
|
31
|
+
if (data instanceof Date) {
|
|
32
|
+
return [Number.isNaN(data.getTime()) ? null : data.toISOString(), hasBlobRef.value];
|
|
33
|
+
}
|
|
34
|
+
if (Number.isNaN(data)) {
|
|
35
|
+
return [null, hasBlobRef.value];
|
|
36
|
+
}
|
|
37
|
+
return [data, hasBlobRef.value];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export { jsonSerialize as j };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { HTTPPath, StandardResponse, StandardLazyRequest } from '@temporary-name/shared';
|
|
2
|
+
import { C as Context, m as Router } from './server.Cj3_Lp61.mjs';
|
|
3
|
+
|
|
4
|
+
interface StandardHandleOptions<T extends Context> {
|
|
5
|
+
prefix?: HTTPPath;
|
|
6
|
+
context: T;
|
|
7
|
+
}
|
|
8
|
+
type StandardHandleResult = {
|
|
9
|
+
matched: true;
|
|
10
|
+
response: StandardResponse;
|
|
11
|
+
} | {
|
|
12
|
+
matched: false;
|
|
13
|
+
response: undefined;
|
|
14
|
+
};
|
|
15
|
+
interface StandardHandlerOptions<_TContext extends Context> {
|
|
16
|
+
}
|
|
17
|
+
declare class StandardHandler<T extends Context> {
|
|
18
|
+
private readonly matcher;
|
|
19
|
+
constructor(router: Router<T>, _options: NoInfer<StandardHandlerOptions<T>>);
|
|
20
|
+
handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (object extends T ? {
|
|
24
|
+
context?: T;
|
|
25
|
+
} : {
|
|
26
|
+
context: T;
|
|
27
|
+
});
|
|
28
|
+
declare function resolveFriendlyStandardHandleOptions<T extends Context>(options: FriendlyStandardHandleOptions<T>): StandardHandleOptions<T>;
|
|
29
|
+
/**
|
|
30
|
+
* {@link https://github.com/unjs/rou3}
|
|
31
|
+
*
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
declare function toRou3Pattern(path: HTTPPath): string;
|
|
35
|
+
/**
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
declare function decodeParams(params: Record<string, string>): Record<string, string>;
|
|
39
|
+
|
|
40
|
+
export { StandardHandler as c, decodeParams as d, resolveFriendlyStandardHandleOptions as r, toRou3Pattern as t };
|
|
41
|
+
export type { FriendlyStandardHandleOptions as F, StandardHandleOptions as S, StandardHandleResult as a, StandardHandlerOptions as b };
|