@temporary-name/server 1.9.3-alpha.ce6ed5061c5dc25f4390f71c2c5c5411546e85c1 → 1.9.3-alpha.d0c8ba895f81e5ee5f2f893da0804bd96a5aa41c

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 (40) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +4 -5
  2. package/dist/adapters/aws-lambda/index.d.ts +4 -5
  3. package/dist/adapters/aws-lambda/index.mjs +4 -4
  4. package/dist/adapters/fetch/index.d.mts +8 -85
  5. package/dist/adapters/fetch/index.d.ts +8 -85
  6. package/dist/adapters/fetch/index.mjs +16 -155
  7. package/dist/adapters/node/index.d.mts +8 -62
  8. package/dist/adapters/node/index.d.ts +8 -62
  9. package/dist/adapters/node/index.mjs +14 -120
  10. package/dist/adapters/standard/index.d.mts +3 -4
  11. package/dist/adapters/standard/index.d.ts +3 -4
  12. package/dist/adapters/standard/index.mjs +4 -4
  13. package/dist/index.d.mts +104 -184
  14. package/dist/index.d.ts +104 -184
  15. package/dist/index.mjs +38 -104
  16. package/dist/openapi/index.d.mts +11 -27
  17. package/dist/openapi/index.d.ts +11 -27
  18. package/dist/openapi/index.mjs +8 -75
  19. package/dist/shared/server.BYV-qTJt.d.ts +41 -0
  20. package/dist/shared/server.CQIFwyhc.mjs +40 -0
  21. package/dist/shared/server.CWb33y9B.d.mts +41 -0
  22. package/dist/shared/server.ChOv1yG3.mjs +319 -0
  23. package/dist/shared/server.DXzEGRE2.mjs +403 -0
  24. package/dist/shared/server.DgzAlPjF.mjs +160 -0
  25. package/dist/shared/server.DimTvmOQ.d.mts +373 -0
  26. package/dist/shared/server.DimTvmOQ.d.ts +373 -0
  27. package/dist/shared/server.YUvuxHty.mjs +48 -0
  28. package/package.json +9 -15
  29. package/dist/plugins/index.d.mts +0 -84
  30. package/dist/plugins/index.d.ts +0 -84
  31. package/dist/plugins/index.mjs +0 -116
  32. package/dist/shared/server.B-meye9-.d.ts +0 -55
  33. package/dist/shared/server.Ba0Z2fNc.mjs +0 -254
  34. package/dist/shared/server.DkYpsO6W.d.mts +0 -251
  35. package/dist/shared/server.DkYpsO6W.d.ts +0 -251
  36. package/dist/shared/server.DwNnHUZP.d.ts +0 -23
  37. package/dist/shared/server.I-tTl_ce.d.mts +0 -23
  38. package/dist/shared/server.JtIZ8YG7.mjs +0 -237
  39. package/dist/shared/server.miXh-9wo.mjs +0 -416
  40. package/dist/shared/server.vLcMd_kA.d.mts +0 -55
package/dist/index.mjs CHANGED
@@ -1,11 +1,13 @@
1
- import { mergePrefix, mergeTags, ContractProcedure, mergeErrorMap, mergeMeta, parseEndpointDefinition, mergeRoute, prefixRoute, initialSchemas, isContractProcedure, getContractRouter } from '@temporary-name/contract';
2
- export { ValidationError, eventIterator, validateORPCError } from '@temporary-name/contract';
3
- import { assertNever, splitFirst, ORPCError, onError, resolveMaybeOptionalOptions } from '@temporary-name/shared';
4
- export { AsyncIteratorClass, EventPublisher, ORPCError, asyncIteratorToStream as eventIteratorToStream, isDefinedError, onError, onFinish, onStart, onSuccess, safe, streamToAsyncIteratorClass as streamToEventIterator } from '@temporary-name/shared';
1
+ import { assertNever, splitFirst, ORPCError, onError, resolveMaybeOptionalOptions, isTypescriptObject, isPropertyKey } from '@temporary-name/shared';
2
+ export { AsyncIteratorClass, EventPublisher, ORPCError, asyncIteratorToStream as eventIteratorToStream, isDefinedError, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@temporary-name/shared';
3
+ import * as z from '@temporary-name/zod';
5
4
  import { SchemaClass, object, core, gatingContext } from '@temporary-name/zod';
6
5
  import { g as getCookie } from './shared/server.C1RJffw4.mjs';
7
- import { P as Procedure, c as createProcedureClient, e as enhanceRouter, a as addMiddleware, s as setHiddenRouterContract, l as lazyInternal, g as getLazyMeta, u as unlazy, i as isProcedure, b as isLazy, d as getRouter } from './shared/server.miXh-9wo.mjs';
8
- export { L as LAZY_SYMBOL, p as createAccessibleLazyRouter, f as createORPCErrorConstructorMap, o as getHiddenRouterContract, k as isStartWithMiddlewares, h as lazy, m as mergeCurrentContext, n as mergeMiddlewares, j as middlewareOutputFn, r as resolveContractProcedures, t as traverseContractProcedures, q as unlazyRouter } from './shared/server.miXh-9wo.mjs';
6
+ import { P as Procedure, m as mergePrefix, a as mergeTags, e as enhanceRouter, C as Contract, p as parseEndpointDefinition, b as mergeRoute, c as prefixRoute, d as addMiddleware, l as lazyInternal, f as getLazyMeta, u as unlazy, i as isProcedure, h as isLazy, j as getRouter } from './shared/server.ChOv1yG3.mjs';
7
+ export { L as LAZY_SYMBOL, V as ValidationError, q as createAccessibleLazyRouter, w as endpointRegex, g as getDynamicParams, n as isStartWithMiddlewares, k as lazy, o as mergeMiddlewares, r as resolveContractProcedures, s as standardizeHTTPPath, t as traverseContractProcedures, v as unlazyRouter } from './shared/server.ChOv1yG3.mjs';
8
+ import { c as createProcedureClient } from './shared/server.DgzAlPjF.mjs';
9
+ export { m as mergeCurrentContext, a as middlewareOutputFn } from './shared/server.DgzAlPjF.mjs';
10
+ export { e as eventIterator, g as getEventIteratorSchemaDetails } from './shared/server.YUvuxHty.mjs';
9
11
  export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
10
12
  import 'cookie';
11
13
 
@@ -60,6 +62,10 @@ function authDescription(config) {
60
62
  return type === "basic" ? "a Basic Authentication header" : type === "bearer" ? "a Bearer Authentication header" : type === "header" ? `a header named "${config.name}"` : type === "query" ? `a query parameter named "${config.name}"` : type === "cookie" ? `a cookie named "${config.name}"` : type === "none" ? "no authentication" : assertNever(type);
61
63
  }
62
64
 
65
+ function mergeMeta(meta1, meta2) {
66
+ return { ...meta1, ...meta2 };
67
+ }
68
+
63
69
  class DecoratedProcedure extends Procedure {
64
70
  /**
65
71
  * Make this procedure callable (works like a function while still being a procedure).
@@ -79,24 +85,19 @@ class DecoratedProcedure extends Procedure {
79
85
  }
80
86
  }
81
87
 
82
- class ProcedureBuilder extends ContractProcedure {
88
+ const initialSchemas = {
89
+ pathSchema: z.strictObject({}),
90
+ querySchema: z.strictObject({}),
91
+ bodySchema: z.strictObject({}),
92
+ outputSchema: z.unknown()
93
+ };
94
+
95
+ class ProcedureBuilder extends Contract {
83
96
  z;
84
97
  constructor(def) {
85
98
  super(def);
86
99
  this.z = new SchemaClass();
87
100
  }
88
- /**
89
- * Adds type-safe custom errors to the contract.
90
- * The provided errors are spared-merged with any existing errors in the contract.
91
- *
92
- * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
93
- */
94
- errors(errors) {
95
- return new ProcedureBuilder({
96
- ...this["~orpc"],
97
- errorMap: mergeErrorMap(this["~orpc"].errorMap, errors)
98
- });
99
- }
100
101
  /**
101
102
  * Sets or updates the metadata for the contract.
102
103
  * The provided metadata is spared-merged with any existing metadata in the contract.
@@ -333,7 +334,6 @@ function createApiBuilder(opts = {}) {
333
334
  return new Builder({
334
335
  route: {},
335
336
  meta: opts.meta ?? {},
336
- errorMap: {},
337
337
  inputValidationIndex: 0,
338
338
  outputValidationIndex: 0,
339
339
  middlewares: [
@@ -350,81 +350,6 @@ function createApiBuilder(opts = {}) {
350
350
  }
351
351
  const os = createApiBuilder();
352
352
 
353
- function implementerInternal(contract, middlewares) {
354
- if (isContractProcedure(contract)) {
355
- const impl2 = new Builder({
356
- ...contract["~orpc"],
357
- middlewares,
358
- authConfigs: [],
359
- inputValidationIndex: middlewares.length,
360
- outputValidationIndex: middlewares.length,
361
- dedupeLeadingMiddlewares: true
362
- });
363
- return impl2;
364
- }
365
- const impl = new Proxy(contract, {
366
- get: (target, key) => {
367
- if (typeof key !== "string") {
368
- return Reflect.get(target, key);
369
- }
370
- let method;
371
- if (key === "middleware") {
372
- method = (mid) => decorateMiddleware(mid);
373
- } else if (key === "use") {
374
- method = (mid) => {
375
- return implementerInternal(contract, addMiddleware(middlewares, mid));
376
- };
377
- } else if (key === "router") {
378
- method = (router) => {
379
- const adapted = enhanceRouter(router, {
380
- middlewares,
381
- errorMap: {},
382
- prefix: void 0,
383
- tags: void 0,
384
- dedupeLeadingMiddlewares: true
385
- });
386
- return setHiddenRouterContract(adapted, contract);
387
- };
388
- }
389
- const next = getContractRouter(target, [key]);
390
- if (!next) {
391
- return method ?? next;
392
- }
393
- const nextImpl = implementerInternal(next, middlewares);
394
- if (method) {
395
- return new Proxy(method, {
396
- get(_, key2) {
397
- return Reflect.get(nextImpl, key2);
398
- }
399
- });
400
- }
401
- return nextImpl;
402
- }
403
- });
404
- return impl;
405
- }
406
- function implement(contract) {
407
- const implInternal = implementerInternal(contract, []);
408
- const impl = new Proxy(implInternal, {
409
- get: (target, key) => {
410
- let method;
411
- if (key === "$context") {
412
- method = () => impl;
413
- }
414
- const next = Reflect.get(target, key);
415
- if (!method || !next || typeof next !== "function" && typeof next !== "object") {
416
- return method || next;
417
- }
418
- return new Proxy(method, {
419
- get(_, key2) {
420
- return Reflect.get(next, key2);
421
- }
422
- });
423
- }
424
- });
425
- return impl;
426
- }
427
-
428
353
  function createAssertedLazyProcedure(lazied) {
429
354
  const lazyProcedure = lazyInternal(async () => {
430
355
  const { default: maybeProcedure } = await unlazy(lazied);
@@ -439,14 +364,6 @@ function createAssertedLazyProcedure(lazied) {
439
364
  }, getLazyMeta(lazied));
440
365
  return lazyProcedure;
441
366
  }
442
- function createContractedProcedure(procedure, contract) {
443
- return new Procedure({
444
- ...procedure["~orpc"],
445
- errorMap: contract["~orpc"].errorMap,
446
- route: contract["~orpc"].route,
447
- meta: contract["~orpc"].meta
448
- });
449
- }
450
367
  function call(procedure, input, ...rest) {
451
368
  const options = resolveMaybeOptionalOptions(rest);
452
369
  return createProcedureClient(procedure, options)(input, options);
@@ -477,4 +394,21 @@ function createRouterClient(router, ...rest) {
477
394
  return recursive;
478
395
  }
479
396
 
480
- export { Builder, BuilderWithMiddlewares, DecoratedProcedure, Procedure, ProcedureBuilder, addMiddleware, call, createApiBuilder, createAssertedLazyProcedure, createContractedProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, getLazyMeta, getRouter, implement, implementerInternal, isLazy, isProcedure, lazyInternal, os, setHiddenRouterContract, unlazy };
397
+ function isSchemaIssue(issue) {
398
+ if (!isTypescriptObject(issue) || typeof issue.message !== "string") {
399
+ return false;
400
+ }
401
+ if (issue.path !== void 0) {
402
+ if (!Array.isArray(issue.path)) {
403
+ return false;
404
+ }
405
+ if (!issue.path.every(
406
+ (segment) => isPropertyKey(segment) || isTypescriptObject(segment) && isPropertyKey(segment.key)
407
+ )) {
408
+ return false;
409
+ }
410
+ }
411
+ return true;
412
+ }
413
+
414
+ export { Builder, BuilderWithMiddlewares, Contract, DecoratedProcedure, Procedure, ProcedureBuilder, addMiddleware, call, createApiBuilder, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, getLazyMeta, getRouter, initialSchemas, isLazy, isProcedure, isSchemaIssue, lazyInternal, mergeMeta, os, parseEndpointDefinition, unlazy };
@@ -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
@@ -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
@@ -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 { standardizeHTTPPath, fallbackContractConfig, getDynamicParams, 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 { j as jsonSerialize, d as deserialize, s as serialize } from '../shared/server.JtIZ8YG7.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);
@@ -696,64 +683,10 @@ ${errors.join("\n\n")}`
696
683
  }
697
684
  }
698
685
  }
699
- async #errorResponse(ref, def, baseSchemaConvertOptions, undefinedErrorSchema) {
700
- const errorMap = def.errorMap;
701
- const errors = {};
702
- for (const code in errorMap) {
703
- const config = errorMap[code];
704
- if (!config) {
705
- continue;
706
- }
707
- const status = fallbackORPCErrorStatus(code, config.status);
708
- const message = fallbackORPCErrorMessage(code, config.message);
709
- const [dataRequired, dataSchema] = await this.converter.convert(config.data, {
710
- ...baseSchemaConvertOptions,
711
- strategy: "output"
712
- });
713
- errors[status] ??= [];
714
- errors[status].push({
715
- type: "object",
716
- properties: {
717
- defined: { const: true },
718
- code: { const: code },
719
- status: { const: status },
720
- message: { type: "string", default: message },
721
- data: dataSchema
722
- },
723
- required: dataRequired ? ["defined", "code", "status", "message", "data"] : ["defined", "code", "status", "message"]
724
- });
725
- }
726
- ref.responses ??= {};
727
- for (const status in errors) {
728
- const schemas = errors[status];
729
- ref.responses[status] = {
730
- description: status,
731
- content: toOpenAPIContent({
732
- oneOf: [...schemas, undefinedErrorSchema]
733
- })
734
- };
735
- }
736
- }
737
- }
738
-
739
- function createJsonifiedRouterClient(router, ...rest) {
740
- const options = resolveMaybeOptionalOptions(rest);
741
- options.interceptors ??= [];
742
- options.interceptors.unshift(async (options2) => {
743
- try {
744
- return deserialize(serialize(await options2.next()));
745
- } catch (e) {
746
- if (e instanceof ORPCError) {
747
- throw createORPCErrorFromJson(deserialize(serialize(e.toJSON(), { outputFormat: "plain" })));
748
- }
749
- throw e;
750
- }
751
- });
752
- return createRouterClient(router, options);
753
686
  }
754
687
 
755
688
  const oo = {
756
689
  spec: customOpenAPIOperation
757
690
  };
758
691
 
759
- 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,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 };