@temporary-name/server 1.9.3-alpha.65222302f1b71807a849530b3fe0fa0326d3c1a2 → 1.9.3-alpha.6d3c10e7b535aec2de4b812161c8001a916134b9

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 (42) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +4 -6
  2. package/dist/adapters/aws-lambda/index.d.ts +4 -6
  3. package/dist/adapters/aws-lambda/index.mjs +5 -7
  4. package/dist/adapters/fetch/index.d.mts +8 -86
  5. package/dist/adapters/fetch/index.d.ts +8 -86
  6. package/dist/adapters/fetch/index.mjs +17 -158
  7. package/dist/adapters/node/index.d.mts +8 -63
  8. package/dist/adapters/node/index.d.ts +8 -63
  9. package/dist/adapters/node/index.mjs +15 -123
  10. package/dist/adapters/standard/index.d.mts +20 -33
  11. package/dist/adapters/standard/index.d.ts +20 -33
  12. package/dist/adapters/standard/index.mjs +5 -7
  13. package/dist/helpers/index.mjs +3 -29
  14. package/dist/index.d.mts +122 -267
  15. package/dist/index.d.ts +122 -267
  16. package/dist/index.mjs +214 -380
  17. package/dist/openapi/index.d.mts +12 -28
  18. package/dist/openapi/index.d.ts +12 -28
  19. package/dist/openapi/index.mjs +66 -150
  20. package/dist/shared/server.BYV-qTJt.d.ts +41 -0
  21. package/dist/shared/server.C1RJffw4.mjs +30 -0
  22. package/dist/shared/server.CQIFwyhc.mjs +40 -0
  23. package/dist/shared/server.CWb33y9B.d.mts +41 -0
  24. package/dist/shared/server.ChOv1yG3.mjs +319 -0
  25. package/dist/shared/server.DXzEGRE2.mjs +403 -0
  26. package/dist/shared/server.DgzAlPjF.mjs +160 -0
  27. package/dist/shared/server.DimTvmOQ.d.mts +373 -0
  28. package/dist/shared/server.DimTvmOQ.d.ts +373 -0
  29. package/dist/shared/server.YUvuxHty.mjs +48 -0
  30. package/package.json +10 -26
  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.BEHw7Eyx.mjs +0 -247
  35. package/dist/shared/server.BKSOrA6h.d.mts +0 -192
  36. package/dist/shared/server.BKSOrA6h.d.ts +0 -192
  37. package/dist/shared/server.BKh8I1Ny.mjs +0 -239
  38. package/dist/shared/server.BeuTpcmO.d.mts +0 -23
  39. package/dist/shared/server.C1fnTLq0.d.mts +0 -57
  40. package/dist/shared/server.CQyYNJ1H.d.ts +0 -57
  41. package/dist/shared/server.DLsti1Pv.mjs +0 -293
  42. package/dist/shared/server.SLLuK6_v.d.ts +0 -23
@@ -1,11 +1,12 @@
1
- import { OpenAPI, AnyContractProcedure, AnySchema, AnyContractRouter } from '@temporary-name/contract';
2
- export { OpenAPI } from '@temporary-name/contract';
3
- import { AnyProcedure, TraverseContractProcedureCallbackOptions, AnyRouter, ORPCError, ClientContext, Lazyable, CreateProcedureClientOptions, InferRouterInitialContext, Schema, ErrorMap, Meta, RouterClient } from '@temporary-name/server';
4
- import { Promisable, Value, HTTPPath, HTTPMethod, NestedClient, Client, MaybeOptionalOptions } from '@temporary-name/shared';
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.DimTvmOQ.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: AnyContractProcedure) => OpenAPI.OperationObject);
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: AnyContractProcedure): OpenAPI.OperationObject;
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(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
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: AnyProcedure | AnyContractProcedure, path: readonly string[]) => boolean;
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: AnyContractRouter | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
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, createJsonifiedRouterClient, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
220
- export type { ConditionalSchemaConverter, FileSchema, JsonifiedArray, JsonifiedClient, JsonifiedValue, ObjectSchema, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, OverrideOperationValue, SchemaConvertOptions, SchemaConverter, SchemaConverterComponent };
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 };
@@ -1,11 +1,12 @@
1
- import { OpenAPI, AnyContractProcedure, AnySchema, AnyContractRouter } from '@temporary-name/contract';
2
- export { OpenAPI } from '@temporary-name/contract';
3
- import { AnyProcedure, TraverseContractProcedureCallbackOptions, AnyRouter, ORPCError, ClientContext, Lazyable, CreateProcedureClientOptions, InferRouterInitialContext, Schema, ErrorMap, Meta, RouterClient } from '@temporary-name/server';
4
- import { Promisable, Value, HTTPPath, HTTPMethod, NestedClient, Client, MaybeOptionalOptions } from '@temporary-name/shared';
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.DimTvmOQ.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: AnyContractProcedure) => OpenAPI.OperationObject);
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: AnyContractProcedure): OpenAPI.OperationObject;
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(schema: AnySchema | undefined, options: SchemaConvertOptions): Promisable<[required: boolean, jsonSchema: JSONSchema]>;
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: AnyProcedure | AnyContractProcedure, path: readonly string[]) => boolean;
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: AnyContractRouter | AnyRouter, options?: OpenAPIGeneratorGenerateOptions): Promise<OpenAPI.Document>;
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, createJsonifiedRouterClient, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
220
- export type { ConditionalSchemaConverter, FileSchema, JsonifiedArray, JsonifiedClient, JsonifiedValue, ObjectSchema, OpenAPIGeneratorGenerateOptions, OpenAPIGeneratorOptions, OverrideOperationValue, SchemaConvertOptions, SchemaConverter, SchemaConverterComponent };
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 };
@@ -1,10 +1,11 @@
1
- import { isProcedure, resolveContractProcedures, ORPCError, createRouterClient } from '@temporary-name/server';
2
- import { fallbackContractConfig, getEventIteratorSchemaDetails } from '@temporary-name/contract';
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 errorItem of Object.values(contract["~orpc"].errorMap)) {
26
- const maybeExtender = errorItem ? getCustomOpenAPIOperation(errorItem) : void 0;
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 inputStructure = fallbackContractConfig("defaultInputStructure", def.route.inputStructure);
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: dynamicParams?.length || inputStructure === "detailed" ? 1 : 0
524
+ minStructureDepthForRef: 1
550
525
  });
551
- if (isAnySchema(schema) && !dynamicParams?.length) {
552
- return;
553
- }
554
- if (inputStructure === "compact") {
555
- if (dynamicParams?.length) {
556
- const error2 = new OpenAPIGeneratorError(
557
- 'When input structure is "compact", and path has dynamic params, input schema must be an object with all dynamic params as required.'
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 (method === "GET") {
572
- const resolvedSchema = resolveOpenAPIJsonSchemaRef(doc, schema);
573
- if (!isObjectSchema(resolvedSchema)) {
574
- throw new OpenAPIGeneratorError(
575
- 'When method is "GET", input schema must satisfy: object | any | unknown'
576
- );
577
- }
578
- ref.parameters ??= [];
579
- ref.parameters.push(...toOpenAPIParameters(resolvedSchema, "query"));
580
- } else {
581
- ref.requestBody = {
582
- required,
583
- content: toOpenAPIContent(schema)
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 resolvedParamSchema = schema.properties?.params !== void 0 ? resolveOpenAPIJsonSchemaRef(doc, schema.properties.params) : void 0;
595
- if (dynamicParams?.length && (resolvedParamSchema === void 0 || !isObjectSchema(resolvedParamSchema) || !checkParamsSchema(resolvedParamSchema, dynamicParams))) {
596
- throw new OpenAPIGeneratorError(
597
- 'When input structure is "detailed" and path has dynamic params, the "params" schema must be an object with all dynamic params as required.'
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
- for (const from of ["params", "query", "headers"]) {
601
- const fromSchema = schema.properties?.[from];
602
- if (fromSchema !== void 0) {
603
- const resolvedSchema = resolveOpenAPIJsonSchemaRef(doc, fromSchema);
604
- if (!isObjectSchema(resolvedSchema)) {
605
- throw error;
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
- const parameterIn = from === "params" ? "path" : from === "headers" ? "header" : "query";
608
- ref.parameters ??= [];
609
- ref.parameters.push(...toOpenAPIParameters(resolvedSchema, parameterIn));
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, createJsonifiedRouterClient, customOpenAPIOperation, expandArrayableSchema, expandUnionSchema, filterSchemaBranches, getCustomOpenAPIOperation, isAnySchema, isFileSchema, isObjectSchema, isPrimitiveSchema, oo, resolveOpenAPIJsonSchemaRef, separateObjectSchema, toOpenAPIContent, toOpenAPIEventIteratorContent, toOpenAPIMethod, toOpenAPIParameters, toOpenAPIPath, toOpenAPISchema };
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 };
@@ -0,0 +1,41 @@
1
+ import { HTTPPath, StandardResponse, StandardLazyRequest } from '@temporary-name/shared';
2
+ import { C as Context, m as Router } from './server.DimTvmOQ.js';
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'> & (Record<never, never> 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 };
@@ -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.DimTvmOQ.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'> & (Record<never, never> 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 };