@orpc/server 0.0.0-next.ed15210 → 0.0.0-next.ee46dab

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 (85) hide show
  1. package/README.md +131 -0
  2. package/dist/adapters/fetch/index.d.mts +54 -0
  3. package/dist/adapters/fetch/index.d.ts +54 -0
  4. package/dist/adapters/fetch/index.mjs +9 -0
  5. package/dist/adapters/hono/index.d.mts +22 -0
  6. package/dist/adapters/hono/index.d.ts +22 -0
  7. package/dist/adapters/hono/index.mjs +32 -0
  8. package/dist/adapters/next/index.d.mts +29 -0
  9. package/dist/adapters/next/index.d.ts +29 -0
  10. package/dist/{next.js → adapters/next/index.mjs} +11 -18
  11. package/dist/adapters/node/index.d.mts +53 -0
  12. package/dist/adapters/node/index.d.ts +53 -0
  13. package/dist/adapters/node/index.mjs +85 -0
  14. package/dist/adapters/standard/index.d.mts +26 -0
  15. package/dist/adapters/standard/index.d.ts +26 -0
  16. package/dist/adapters/standard/index.mjs +6 -0
  17. package/dist/index.d.mts +291 -0
  18. package/dist/index.d.ts +291 -0
  19. package/dist/index.mjs +363 -0
  20. package/dist/plugins/index.d.mts +30 -0
  21. package/dist/plugins/index.d.ts +30 -0
  22. package/dist/plugins/index.mjs +107 -0
  23. package/dist/shared/server.B77ImKAP.d.mts +8 -0
  24. package/dist/shared/server.BHlRCrf_.d.ts +66 -0
  25. package/dist/shared/server.BVwwTHyO.mjs +9 -0
  26. package/dist/shared/server.Cud5qk0c.d.ts +10 -0
  27. package/dist/shared/server.CzxlqYZL.d.mts +66 -0
  28. package/dist/shared/server.DCCkTG29.mjs +162 -0
  29. package/dist/shared/server.DGnN7q3R.d.mts +10 -0
  30. package/dist/shared/server.DLt5njUb.d.mts +143 -0
  31. package/dist/shared/server.DLt5njUb.d.ts +143 -0
  32. package/dist/shared/server.DUF89eb-.d.ts +8 -0
  33. package/dist/shared/server.Prfzu_zf.mjs +98 -0
  34. package/dist/shared/server.e3W6AG3-.mjs +370 -0
  35. package/package.json +36 -24
  36. package/dist/chunk-6YJ5NGUE.js +0 -301
  37. package/dist/chunk-WUOGVGWG.js +0 -1
  38. package/dist/chunk-XHFINNVL.js +0 -217
  39. package/dist/fetch.js +0 -15
  40. package/dist/hono.js +0 -30
  41. package/dist/index.js +0 -1043
  42. package/dist/node.js +0 -87
  43. package/dist/src/adapters/fetch/index.d.ts +0 -6
  44. package/dist/src/adapters/fetch/orpc-handler.d.ts +0 -20
  45. package/dist/src/adapters/fetch/orpc-payload-codec.d.ts +0 -16
  46. package/dist/src/adapters/fetch/orpc-procedure-matcher.d.ts +0 -12
  47. package/dist/src/adapters/fetch/super-json.d.ts +0 -12
  48. package/dist/src/adapters/fetch/types.d.ts +0 -21
  49. package/dist/src/adapters/hono/index.d.ts +0 -3
  50. package/dist/src/adapters/hono/middleware.d.ts +0 -12
  51. package/dist/src/adapters/next/index.d.ts +0 -3
  52. package/dist/src/adapters/next/serve.d.ts +0 -19
  53. package/dist/src/adapters/node/index.d.ts +0 -5
  54. package/dist/src/adapters/node/orpc-handler.d.ts +0 -12
  55. package/dist/src/adapters/node/request-listener.d.ts +0 -28
  56. package/dist/src/adapters/node/types.d.ts +0 -22
  57. package/dist/src/builder-with-errors-middlewares.d.ts +0 -49
  58. package/dist/src/builder-with-errors.d.ts +0 -49
  59. package/dist/src/builder-with-middlewares.d.ts +0 -49
  60. package/dist/src/builder.d.ts +0 -46
  61. package/dist/src/config.d.ts +0 -6
  62. package/dist/src/context.d.ts +0 -10
  63. package/dist/src/error.d.ts +0 -10
  64. package/dist/src/hidden.d.ts +0 -4
  65. package/dist/src/implementer-chainable.d.ts +0 -16
  66. package/dist/src/index.d.ts +0 -26
  67. package/dist/src/lazy-decorated.d.ts +0 -8
  68. package/dist/src/lazy-utils.d.ts +0 -4
  69. package/dist/src/lazy.d.ts +0 -18
  70. package/dist/src/middleware-decorated.d.ts +0 -9
  71. package/dist/src/middleware.d.ts +0 -39
  72. package/dist/src/procedure-builder-with-input.d.ts +0 -35
  73. package/dist/src/procedure-builder-with-output.d.ts +0 -34
  74. package/dist/src/procedure-builder.d.ts +0 -28
  75. package/dist/src/procedure-client.d.ts +0 -21
  76. package/dist/src/procedure-decorated.d.ts +0 -25
  77. package/dist/src/procedure-implementer.d.ts +0 -23
  78. package/dist/src/procedure-utils.d.ts +0 -17
  79. package/dist/src/procedure.d.ts +0 -47
  80. package/dist/src/router-builder.d.ts +0 -33
  81. package/dist/src/router-client.d.ts +0 -26
  82. package/dist/src/router-implementer.d.ts +0 -24
  83. package/dist/src/router-utils.d.ts +0 -15
  84. package/dist/src/router.d.ts +0 -19
  85. package/dist/src/types.d.ts +0 -11
@@ -1,9 +0,0 @@
1
- import type { Context } from './context';
2
- import type { ORPCErrorConstructorMap } from './error';
3
- import type { MapInputMiddleware, Middleware } from './middleware';
4
- export interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>> extends Middleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap> {
5
- concat: (<UOutContext extends Context, UInput>(middleware: Middleware<TInContext & TOutContext, UOutContext, UInput & TInput, TOutput, TErrorConstructorMap>) => DecoratedMiddleware<TInContext, TOutContext & UOutContext, UInput & TInput, TOutput, TErrorConstructorMap>) & (<UOutContext extends Context, UInput = TInput, UMappedInput = unknown>(middleware: Middleware<TInContext & TOutContext, UOutContext, UMappedInput, TOutput, TErrorConstructorMap>, mapInput: MapInputMiddleware<UInput & TInput, UMappedInput>) => DecoratedMiddleware<TInContext, TOutContext & UOutContext, UInput & TInput, TOutput, TErrorConstructorMap>);
6
- mapInput: <UInput = unknown>(map: MapInputMiddleware<UInput, TInput>) => DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TErrorConstructorMap>;
7
- }
8
- export declare function decorateMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>>(middleware: Middleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap>): DecoratedMiddleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap>;
9
- //# sourceMappingURL=middleware-decorated.d.ts.map
@@ -1,39 +0,0 @@
1
- import type { Promisable } from '@orpc/shared';
2
- import type { Context } from './context';
3
- import type { ORPCErrorConstructorMap } from './error';
4
- import type { ANY_PROCEDURE } from './procedure';
5
- import type { AbortSignal } from './types';
6
- export type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
7
- output: TOutput;
8
- context: TOutContext;
9
- }>;
10
- export type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never, never> extends TOutContext ? {
11
- context?: TOutContext;
12
- } : {
13
- context: TOutContext;
14
- };
15
- export type MiddlewareNextFnRest<TOutContext extends Context> = [options: MiddlewareNextFnOptions<TOutContext>] | (Record<never, never> extends TOutContext ? [] : never);
16
- export interface MiddlewareNextFn<TInContext extends Context, TOutput> {
17
- <U extends Context & Partial<TInContext> = Record<never, never>>(...rest: MiddlewareNextFnRest<U>): MiddlewareResult<U, TOutput>;
18
- }
19
- export interface MiddlewareOutputFn<TOutput> {
20
- (output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
21
- }
22
- export interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>> {
23
- context: TInContext;
24
- path: string[];
25
- procedure: ANY_PROCEDURE;
26
- signal?: AbortSignal;
27
- next: MiddlewareNextFn<TInContext, TOutput>;
28
- errors: TErrorConstructorMap;
29
- }
30
- export interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>> {
31
- (options: MiddlewareOptions<TInContext, TOutput, TErrorConstructorMap>, input: TInput, output: MiddlewareOutputFn<TOutput>): Promisable<MiddlewareResult<TOutContext, TOutput>>;
32
- }
33
- export type ANY_MIDDLEWARE = Middleware<any, any, any, any, any>;
34
- export interface MapInputMiddleware<TInput, TMappedInput> {
35
- (input: TInput): TMappedInput;
36
- }
37
- export type ANY_MAP_INPUT_MIDDLEWARE = MapInputMiddleware<any, any>;
38
- export declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
39
- //# sourceMappingURL=middleware.d.ts.map
@@ -1,35 +0,0 @@
1
- import type { ContractProcedure, ErrorMap, ErrorMapGuard, ErrorMapSuggestions, Route, Schema, SchemaOutput } from '@orpc/contract';
2
- import type { ConflictContextGuard, Context, TypeCurrentContext, TypeInitialContext } from './context';
3
- import type { ORPCErrorConstructorMap } from './error';
4
- import type { MapInputMiddleware, Middleware } from './middleware';
5
- import type { ProcedureHandler } from './procedure';
6
- import { DecoratedProcedure } from './procedure-decorated';
7
- import { ProcedureImplementer } from './procedure-implementer';
8
- export interface ProcedureBuilderWithInputDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TErrorMap extends ErrorMap> {
9
- __initialContext?: TypeInitialContext<TInitialContext>;
10
- __currentContext?: TypeCurrentContext<TCurrentContext>;
11
- contract: ContractProcedure<TInputSchema, undefined, TErrorMap, Route>;
12
- middlewares: Middleware<any, any, any, any, any>[];
13
- inputValidationIndex: number;
14
- outputValidationIndex: number;
15
- }
16
- /**
17
- * `ProcedureBuilderWithInput` is a branch of `ProcedureBuilder` which it has input schema.
18
- *
19
- * Why?
20
- * - prevents override input schema after .input
21
- * - allows .use between .input and .output
22
- *
23
- */
24
- export declare class ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TErrorMap extends ErrorMap> {
25
- '~type': "ProcedureBuilderWithInput";
26
- '~orpc': ProcedureBuilderWithInputDef<TInitialContext, TCurrentContext, TInputSchema, TErrorMap>;
27
- constructor(def: ProcedureBuilderWithInputDef<TInitialContext, TCurrentContext, TInputSchema, TErrorMap>);
28
- errors<U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TErrorMap & U>;
29
- route(route: Route): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TErrorMap>;
30
- use<U extends Context>(middleware: Middleware<TCurrentContext, U, SchemaOutput<TInputSchema>, unknown, ORPCErrorConstructorMap<TErrorMap>>): ConflictContextGuard<TCurrentContext & U> & ProcedureBuilderWithInput<TInitialContext, TCurrentContext & U, TInputSchema, TErrorMap>;
31
- use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<TCurrentContext & UOutContext> & ProcedureBuilderWithInput<TInitialContext, TCurrentContext & UOutContext, TInputSchema, TErrorMap>;
32
- output<U extends Schema>(schema: U, example?: SchemaOutput<U>): ProcedureImplementer<TInitialContext, TCurrentContext, TInputSchema, U, TErrorMap, Route>;
33
- handler<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, TInputSchema, undefined, UFuncOutput, TErrorMap>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, undefined, UFuncOutput, TErrorMap, Route>;
34
- }
35
- //# sourceMappingURL=procedure-builder-with-input.d.ts.map
@@ -1,34 +0,0 @@
1
- import type { ContractProcedure, ErrorMap, ErrorMapGuard, ErrorMapSuggestions, Route, Schema, SchemaInput } from '@orpc/contract';
2
- import type { ConflictContextGuard, Context, TypeCurrentContext, TypeInitialContext } from './context';
3
- import type { ORPCErrorConstructorMap } from './error';
4
- import type { Middleware } from './middleware';
5
- import type { ProcedureHandler } from './procedure';
6
- import { DecoratedProcedure } from './procedure-decorated';
7
- import { ProcedureImplementer } from './procedure-implementer';
8
- export interface ProcedureBuilderWithOutputDef<TInitialContext extends Context, TCurrentContext extends Context, TOutputSchema extends Schema, TErrorMap extends ErrorMap> {
9
- __initialContext?: TypeInitialContext<TInitialContext>;
10
- __currentContext?: TypeCurrentContext<TCurrentContext>;
11
- contract: ContractProcedure<undefined, TOutputSchema, TErrorMap, Route>;
12
- middlewares: Middleware<any, any, any, any, any>[];
13
- inputValidationIndex: number;
14
- outputValidationIndex: number;
15
- }
16
- /**
17
- * `ProcedureBuilderWithOutput` is a branch of `ProcedureBuilder` which it has output schema.
18
- *
19
- * Why?
20
- * - prevents override output schema after .output
21
- * - allows .use between .input and .output
22
- *
23
- */
24
- export declare class ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TOutputSchema extends Schema, TErrorMap extends ErrorMap> {
25
- '~type': "ProcedureBuilderWithOutput";
26
- '~orpc': ProcedureBuilderWithOutputDef<TInitialContext, TCurrentContext, TOutputSchema, TErrorMap>;
27
- constructor(def: ProcedureBuilderWithOutputDef<TInitialContext, TCurrentContext, TOutputSchema, TErrorMap>);
28
- errors<U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TOutputSchema, TErrorMap & U>;
29
- route(route: Route): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TOutputSchema, TErrorMap>;
30
- use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>>): ConflictContextGuard<TCurrentContext & U> & ProcedureBuilderWithOutput<TInitialContext, TCurrentContext & U, TOutputSchema, TErrorMap>;
31
- input<U extends Schema>(schema: U, example?: SchemaInput<U>): ProcedureImplementer<TInitialContext, TCurrentContext, U, TOutputSchema, TErrorMap, Route>;
32
- handler<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, undefined, TOutputSchema, UFuncOutput, TErrorMap>): DecoratedProcedure<TInitialContext, TCurrentContext, undefined, TOutputSchema, UFuncOutput, TErrorMap, Route>;
33
- }
34
- //# sourceMappingURL=procedure-builder-with-output.d.ts.map
@@ -1,28 +0,0 @@
1
- import type { ContractProcedure, ErrorMap, ErrorMapGuard, ErrorMapSuggestions, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
- import type { ConflictContextGuard, Context, TypeCurrentContext, TypeInitialContext } from './context';
3
- import type { ORPCErrorConstructorMap } from './error';
4
- import type { Middleware } from './middleware';
5
- import type { ProcedureHandler } from './procedure';
6
- import { ProcedureBuilderWithInput } from './procedure-builder-with-input';
7
- import { ProcedureBuilderWithOutput } from './procedure-builder-with-output';
8
- import { DecoratedProcedure } from './procedure-decorated';
9
- export interface ProcedureBuilderDef<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap> {
10
- __initialContext?: TypeInitialContext<TInitialContext>;
11
- __currentContext?: TypeCurrentContext<TCurrentContext>;
12
- contract: ContractProcedure<undefined, undefined, TErrorMap, Route>;
13
- middlewares: Middleware<any, any, any, any, any>[];
14
- inputValidationIndex: number;
15
- outputValidationIndex: number;
16
- }
17
- export declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap> {
18
- '~type': "ProcedureBuilder";
19
- '~orpc': ProcedureBuilderDef<TInitialContext, TCurrentContext, TErrorMap>;
20
- constructor(def: ProcedureBuilderDef<TInitialContext, TCurrentContext, TErrorMap>);
21
- errors<U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TErrorMap & U>;
22
- route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TErrorMap>;
23
- use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>>): ConflictContextGuard<TCurrentContext & U> & ProcedureBuilder<TInitialContext, TCurrentContext & U, TErrorMap>;
24
- input<U extends Schema>(schema: U, example?: SchemaInput<U>): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, U, TErrorMap>;
25
- output<U extends Schema>(schema: U, example?: SchemaOutput<U>): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, U, TErrorMap>;
26
- handler<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, undefined, undefined, UFuncOutput, TErrorMap>): DecoratedProcedure<TInitialContext, TCurrentContext, undefined, undefined, UFuncOutput, TErrorMap, Route>;
27
- }
28
- //# sourceMappingURL=procedure-builder.d.ts.map
@@ -1,21 +0,0 @@
1
- import type { Client, ErrorFromErrorMap, ErrorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
- import type { Hooks, Value } from '@orpc/shared';
3
- import type { Context } from './context';
4
- import type { Lazyable } from './lazy';
5
- import type { Procedure } from './procedure';
6
- import type { Meta } from './types';
7
- export type ProcedureClient<TClientContext, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap> = Client<TClientContext, SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>;
8
- /**
9
- * Options for creating a procedure caller with comprehensive type safety
10
- */
11
- export type CreateProcedureClientOptions<TInitialContext extends Context, TCurrentContext extends Schema, THandlerOutput extends SchemaInput<TCurrentContext>, TClientContext> = {
12
- /**
13
- * This is helpful for logging and analytics.
14
- */
15
- path?: string[];
16
- } & ({
17
- context: Value<TInitialContext, [clientContext: TClientContext]>;
18
- } | (Record<never, never> extends TInitialContext ? Record<never, never> : never)) & Hooks<unknown, SchemaOutput<TCurrentContext, THandlerOutput>, TInitialContext, Meta>;
19
- export type CreateProcedureClientRest<TInitialContext extends Context, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TClientContext> = [options: CreateProcedureClientOptions<TInitialContext, TOutputSchema, THandlerOutput, TClientContext>] | (Record<never, never> extends TInitialContext ? [] : never);
20
- export declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, any>>, ...[options]: CreateProcedureClientRest<TInitialContext, TOutputSchema, THandlerOutput, TClientContext>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
21
- //# sourceMappingURL=procedure-client.d.ts.map
@@ -1,25 +0,0 @@
1
- import type { ClientRest, ErrorMap, ErrorMapGuard, ErrorMapSuggestions, HTTPPath, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
- import type { ConflictContextGuard, Context } from './context';
3
- import type { ORPCErrorConstructorMap } from './error';
4
- import type { MapInputMiddleware, Middleware } from './middleware';
5
- import type { CreateProcedureClientRest, ProcedureClient } from './procedure-client';
6
- import { Procedure } from './procedure';
7
- export declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TRoute extends Route> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TRoute> {
8
- static decorate<UInitialContext extends Context, UCurrentContext extends Context, UInputSchema extends Schema, UOutputSchema extends Schema, UHandlerOutput extends SchemaInput<UOutputSchema>, UErrorMap extends ErrorMap, URoute extends Route>(procedure: Procedure<UInitialContext, UCurrentContext, UInputSchema, UOutputSchema, UHandlerOutput, UErrorMap, URoute>): DecoratedProcedure<any, any, any, any, any, any, any> | DecoratedProcedure<UInitialContext, UCurrentContext, UInputSchema, UOutputSchema, UHandlerOutput, UErrorMap, URoute>;
9
- prefix(prefix: HTTPPath): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, Route>;
10
- route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, Route>;
11
- errors<U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap & U, TRoute>;
12
- use<U extends Context>(middleware: Middleware<TCurrentContext, U, SchemaOutput<TInputSchema>, THandlerOutput, ORPCErrorConstructorMap<TErrorMap>>): ConflictContextGuard<TCurrentContext & U> & DecoratedProcedure<TInitialContext, TCurrentContext & U, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TRoute>;
13
- use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, THandlerOutput, ORPCErrorConstructorMap<TErrorMap>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema, THandlerOutput>, UInput>): ConflictContextGuard<TCurrentContext & UOutContext> & DecoratedProcedure<TInitialContext, TCurrentContext & UOutContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TRoute>;
14
- unshiftTag(...tags: string[]): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, Route>;
15
- unshiftMiddleware<U extends Context>(...middlewares: Middleware<TInitialContext, U, unknown, SchemaOutput<TOutputSchema, THandlerOutput>, ORPCErrorConstructorMap<TErrorMap>>[]): ConflictContextGuard<TInitialContext & U> & DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TRoute>;
16
- /**
17
- * Make this procedure callable (works like a function while still being a procedure).
18
- */
19
- callable<TClientContext>(...rest: CreateProcedureClientRest<TInitialContext, TOutputSchema, THandlerOutput, TClientContext>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TRoute> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
20
- /**
21
- * Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
22
- */
23
- actionable<TClientContext>(...rest: CreateProcedureClientRest<TInitialContext, TOutputSchema, THandlerOutput, TClientContext>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TRoute> & ((...rest: ClientRest<TClientContext, SchemaInput<TInputSchema>>) => Promise<SchemaOutput<TOutputSchema, THandlerOutput>>);
24
- }
25
- //# sourceMappingURL=procedure-decorated.d.ts.map
@@ -1,23 +0,0 @@
1
- import type { ContractProcedure, ErrorMap, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
- import type { ConflictContextGuard, Context, TypeCurrentContext, TypeInitialContext } from './context';
3
- import type { ORPCErrorConstructorMap } from './error';
4
- import type { MapInputMiddleware, Middleware } from './middleware';
5
- import type { ProcedureHandler } from './procedure';
6
- import { DecoratedProcedure } from './procedure-decorated';
7
- export type ProcedureImplementerDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TRoute extends Route> = {
8
- __initialContext?: TypeInitialContext<TInitialContext>;
9
- __currentContext?: TypeCurrentContext<TCurrentContext>;
10
- contract: ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TRoute>;
11
- middlewares: Middleware<any, any, any, any, any>[];
12
- inputValidationIndex: number;
13
- outputValidationIndex: number;
14
- };
15
- export declare class ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TRoute extends Route> {
16
- '~type': "ProcedureImplementer";
17
- '~orpc': ProcedureImplementerDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TRoute>;
18
- constructor(def: ProcedureImplementerDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TRoute>);
19
- use<U extends Context>(middleware: Middleware<TCurrentContext, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>>): ConflictContextGuard<TCurrentContext & U> & ProcedureImplementer<TInitialContext, TCurrentContext & U, TInputSchema, TOutputSchema, TErrorMap, TRoute>;
20
- use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<TCurrentContext & UOutContext> & ProcedureImplementer<TInitialContext, TCurrentContext & UOutContext, TInputSchema, TOutputSchema, TErrorMap, TRoute>;
21
- handler<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TRoute>;
22
- }
23
- //# sourceMappingURL=procedure-implementer.d.ts.map
@@ -1,17 +0,0 @@
1
- import type { ClientPromiseResult, ErrorFromErrorMap, ErrorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
- import type { Context } from './context';
3
- import type { Lazyable } from './lazy';
4
- import type { Procedure } from './procedure';
5
- import { type CreateProcedureClientRest } from './procedure-client';
6
- /**
7
- * Directly call a procedure without creating a client.
8
- *
9
- * @example
10
- * ```ts
11
- * const output = await call(getting, 'input')
12
- * const output = await call(getting, 'input', { context: { db: 'postgres' } })
13
- * ```
14
- *
15
- */
16
- export declare function call<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, any>>, input: SchemaInput<TInputSchema>, ...rest: CreateProcedureClientRest<TInitialContext, TOutputSchema, THandlerOutput, unknown>): ClientPromiseResult<SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>;
17
- //# sourceMappingURL=procedure-utils.d.ts.map
@@ -1,47 +0,0 @@
1
- import type { ContractProcedure, ErrorMap, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
- import type { Promisable } from '@orpc/shared';
3
- import type { Context, TypeInitialContext } from './context';
4
- import type { ORPCErrorConstructorMap } from './error';
5
- import type { Lazy } from './lazy';
6
- import type { Middleware } from './middleware';
7
- import type { AbortSignal } from './types';
8
- export interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>> {
9
- context: TCurrentContext;
10
- input: TInput;
11
- path: string[];
12
- procedure: ANY_PROCEDURE;
13
- signal?: AbortSignal;
14
- errors: TErrorConstructorMap;
15
- }
16
- export interface ProcedureHandler<TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap> {
17
- (opt: ProcedureHandlerOptions<TCurrentContext, SchemaOutput<TInputSchema>, ORPCErrorConstructorMap<TErrorMap>>): Promisable<SchemaInput<TOutputSchema, THandlerOutput>>;
18
- }
19
- /**
20
- * Why is `ErrorConstructorMap` passed to `middlewares` as `any`?
21
- * Why is `ErrorMap` passed to `ProcedureHandler` as `any`?
22
- *
23
- * Passing `ErrorMap/ErrorConstructorMap` directly to `Middleware/ProcedureHandler`
24
- * causes unexpected errors in the router (the root cause is unclear, but it occurs consistently).
25
- * To avoid these issues, `any` is used as a workaround.
26
- *
27
- * This approach is still functional because `ProcedureDef` can infer the `ErrorMap` from `ContractProcedure`.
28
- * The only downside is that direct access to them requires careful type checking to ensure safety.
29
- */
30
- export interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TRoute extends Route> {
31
- __initialContext?: TypeInitialContext<TInitialContext>;
32
- middlewares: Middleware<any, any, any, any, any>[];
33
- inputValidationIndex: number;
34
- outputValidationIndex: number;
35
- contract: ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TRoute>;
36
- handler: ProcedureHandler<TCurrentContext, any, any, THandlerOutput, any>;
37
- }
38
- export declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TRoute extends Route> {
39
- '~type': "Procedure";
40
- '~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TRoute>;
41
- constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TRoute>);
42
- }
43
- export type ANY_PROCEDURE = Procedure<any, any, any, any, any, any, any>;
44
- export type WELL_PROCEDURE = Procedure<Context, Context, Schema, Schema, unknown, any, any>;
45
- export type ANY_LAZY_PROCEDURE = Lazy<ANY_PROCEDURE>;
46
- export declare function isProcedure(item: unknown): item is ANY_PROCEDURE;
47
- //# sourceMappingURL=procedure.d.ts.map
@@ -1,33 +0,0 @@
1
- import type { ContractRouter, ErrorMap, ErrorMapGuard, ErrorMapSuggestions, HTTPPath, Route, StrictErrorMap } from '@orpc/contract';
2
- import type { ConflictContextGuard, Context, TypeCurrentContext, TypeInitialContext } from './context';
3
- import type { FlattenLazy, Lazy } from './lazy';
4
- import type { Middleware } from './middleware';
5
- import type { Procedure } from './procedure';
6
- import type { ANY_ROUTER, Router } from './router';
7
- import { type DecoratedLazy } from './lazy-decorated';
8
- import { DecoratedProcedure } from './procedure-decorated';
9
- export type AdaptedRouter<TInitialContext extends Context, TRouter extends ANY_ROUTER, TErrorMapExtra extends ErrorMap> = TRouter extends Lazy<infer U extends ANY_ROUTER> ? DecoratedLazy<AdaptedRouter<TInitialContext, U, TErrorMapExtra>> : TRouter extends Procedure<any, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UFuncOutput, infer UErrorMap, any> ? DecoratedProcedure<TInitialContext, UCurrentContext, UInputSchema, UOutputSchema, UFuncOutput, UErrorMap & TErrorMapExtra, Route> : {
10
- [K in keyof TRouter]: TRouter[K] extends ANY_ROUTER ? AdaptedRouter<TInitialContext, TRouter[K], TErrorMapExtra> : never;
11
- };
12
- export type RouterBuilderDef<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap> = {
13
- __initialContext?: TypeInitialContext<TInitialContext>;
14
- __currentContext?: TypeCurrentContext<TCurrentContext>;
15
- prefix?: HTTPPath;
16
- tags?: readonly string[];
17
- middlewares: Middleware<any, any, any, any, any>[];
18
- errorMap: TErrorMap;
19
- };
20
- export declare class RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap> {
21
- '~type': "RouterBuilder";
22
- '~orpc': RouterBuilderDef<TInitialContext, TCurrentContext, TErrorMap>;
23
- constructor(def: RouterBuilderDef<TInitialContext, TCurrentContext, TErrorMap>);
24
- prefix(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap>;
25
- tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap>;
26
- errors<U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): RouterBuilder<TInitialContext, TCurrentContext, StrictErrorMap<U> & TErrorMap>;
27
- use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, Record<never, never>>): ConflictContextGuard<TCurrentContext & U> & RouterBuilder<TInitialContext, TCurrentContext & U, TErrorMap>;
28
- router<U extends Router<TCurrentContext, ContractRouter<ErrorMap & Partial<TErrorMap>>>>(router: U): AdaptedRouter<TInitialContext, U, TErrorMap>;
29
- lazy<U extends Router<TCurrentContext, ContractRouter<ErrorMap & Partial<TErrorMap>>>>(loader: () => Promise<{
30
- default: U;
31
- }>): AdaptedRouter<TInitialContext, FlattenLazy<U>, TErrorMap>;
32
- }
33
- //# sourceMappingURL=router-builder.d.ts.map
@@ -1,26 +0,0 @@
1
- import type { Hooks, Value } from '@orpc/shared';
2
- import type { Lazy } from './lazy';
3
- import type { Procedure } from './procedure';
4
- import type { CreateProcedureClientRest, ProcedureClient } from './procedure-client';
5
- import type { Meta } from './types';
6
- import { type ANY_ROUTER, type Router } from './router';
7
- /**
8
- * FIXME: separate RouterClient and ContractRouterClient, don't mix them
9
- */
10
- export type RouterClient<TRouter extends ANY_ROUTER, TClientContext> = TRouter extends Lazy<infer U extends ANY_ROUTER> ? RouterClient<U, TClientContext> : TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UFuncOutput, UErrorMap> : {
11
- [K in keyof TRouter]: TRouter[K] extends ANY_ROUTER ? RouterClient<TRouter[K], TClientContext> : never;
12
- };
13
- export type CreateRouterClientOptions<TRouter extends ANY_ROUTER> = {
14
- /**
15
- * This is helpful for logging and analytics.
16
- *
17
- * @internal
18
- */
19
- path?: string[];
20
- } & (TRouter extends Router<infer UContext, any> ? undefined extends UContext ? {
21
- context?: Value<UContext>;
22
- } : {
23
- context: Value<UContext>;
24
- } : never) & Hooks<unknown, unknown, TRouter extends Router<infer UContext, any> ? UContext : never, Meta>;
25
- export declare function createRouterClient<TRouter extends ANY_ROUTER, TClientContext>(router: TRouter | Lazy<undefined>, ...rest: CreateProcedureClientRest<TRouter extends Router<infer UContext, any> ? UContext : never, undefined, unknown, TClientContext>): RouterClient<TRouter, TClientContext>;
26
- //# sourceMappingURL=router-client.d.ts.map
@@ -1,24 +0,0 @@
1
- import type { ContractRouter } from '@orpc/contract';
2
- import type { ConflictContextGuard, Context, TypeCurrentContext, TypeInitialContext } from './context';
3
- import type { FlattenLazy } from './lazy';
4
- import type { Middleware } from './middleware';
5
- import type { Router, RouterToContract } from './router';
6
- import { type UnshiftedMiddlewaresRouter } from './router-utils';
7
- export type EqualContractGuard<TContract extends ContractRouter<any>, TRouter extends Router<any, TContract>> = TContract extends RouterToContract<TRouter> ? unknown : never;
8
- export interface RouterImplementerDef<TInitialContext extends Context, TCurrentContext extends Context, TContract extends ContractRouter<any>> {
9
- __initialContext?: TypeInitialContext<TInitialContext>;
10
- __currentContext?: TypeCurrentContext<TCurrentContext>;
11
- middlewares: Middleware<any, any, any, any, any>[];
12
- contract: TContract;
13
- }
14
- export declare class RouterImplementer<TInitialContext extends Context, TCurrentContext extends Context, TContract extends ContractRouter<any>> {
15
- '~type': "RouterImplementer";
16
- '~orpc': RouterImplementerDef<TInitialContext, TCurrentContext, TContract>;
17
- constructor(def: RouterImplementerDef<TInitialContext, TCurrentContext, TContract>);
18
- use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, Record<never, never>>): ConflictContextGuard<TCurrentContext & U> & RouterImplementer<TInitialContext, TCurrentContext & U, TContract>;
19
- router<U extends Router<TCurrentContext, TContract>>(router: U): EqualContractGuard<TContract, U> & UnshiftedMiddlewaresRouter<U, TInitialContext>;
20
- lazy<U extends Router<TCurrentContext, TContract>>(loader: () => Promise<{
21
- default: U;
22
- }>): EqualContractGuard<TContract, U> & UnshiftedMiddlewaresRouter<FlattenLazy<U>, TInitialContext>;
23
- }
24
- //# sourceMappingURL=router-implementer.d.ts.map
@@ -1,15 +0,0 @@
1
- import type { Context, TypeInitialContext } from './context';
2
- import type { Lazy } from './lazy';
3
- import type { ANY_MIDDLEWARE } from './middleware';
4
- import type { ANY_ROUTER } from './router';
5
- import { type DecoratedLazy } from './lazy-decorated';
6
- import { type Procedure } from './procedure';
7
- import { DecoratedProcedure } from './procedure-decorated';
8
- export type UnshiftedMiddlewaresRouter<TRouter extends ANY_ROUTER, TInitialContext extends Context> = TRouter extends Lazy<infer U extends ANY_ROUTER> ? DecoratedLazy<UnshiftedMiddlewaresRouter<U, TInitialContext>> : TRouter extends Procedure<any, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UFuncOutput, infer UErrorMap, infer URoute> ? DecoratedProcedure<TInitialContext, UCurrentContext, UInputSchema, UOutputSchema, UFuncOutput, UErrorMap, URoute> : {
9
- [K in keyof TRouter]: TRouter[K] extends ANY_ROUTER ? UnshiftedMiddlewaresRouter<TRouter[K], TInitialContext> : never;
10
- };
11
- export declare function unshiftMiddlewaresRouter<TRouter extends ANY_ROUTER, TInitialContext extends Context>(router: TRouter, options: {
12
- __initialContext?: TypeInitialContext<TInitialContext>;
13
- middlewares: ANY_MIDDLEWARE[];
14
- }): UnshiftedMiddlewaresRouter<TRouter, TInitialContext>;
15
- //# sourceMappingURL=router-utils.d.ts.map
@@ -1,19 +0,0 @@
1
- import type { ContractProcedure, ContractRouter, SchemaInput, SchemaOutput } from '@orpc/contract';
2
- import type { Context } from './context';
3
- import type { ANY_LAZY, Lazy, Lazyable } from './lazy';
4
- import type { ANY_PROCEDURE, Procedure } from './procedure';
5
- export type Router<TInitialContext extends Context, TContract extends ContractRouter<any>> = Lazyable<TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer URoute> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, any, UErrorMap, URoute> : {
6
- [K in keyof TContract]: TContract[K] extends ContractRouter<any> ? Router<TInitialContext, TContract[K]> : never;
7
- }>;
8
- export type RouterToContract<T extends Router<any, any>> = T extends Lazy<infer U extends Router<any, any>> ? RouterToContract<U> : T extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, any, infer UErrorMap, infer URoute> ? ContractProcedure<UInputSchema, UOutputSchema, UErrorMap, URoute> : {
9
- [K in keyof T]: T[K] extends Router<any, any> ? RouterToContract<T[K]> : never;
10
- };
11
- export type ANY_ROUTER = Router<any, any>;
12
- export type InferRouterInputs<T extends ANY_ROUTER> = T extends Lazy<infer U extends ANY_ROUTER> ? InferRouterInputs<U> : T extends Procedure<any, any, infer UInputSchema, any, any, any, any> ? SchemaInput<UInputSchema> : {
13
- [K in keyof T]: T[K] extends ANY_ROUTER ? InferRouterInputs<T[K]> : never;
14
- };
15
- export type InferRouterOutputs<T extends ANY_ROUTER> = T extends Lazy<infer U extends ANY_ROUTER> ? InferRouterOutputs<U> : T extends Procedure<any, any, any, infer UOutputSchema, infer UFuncOutput, any, any> ? SchemaOutput<UOutputSchema, UFuncOutput> : {
16
- [K in keyof T]: T[K] extends ANY_ROUTER ? InferRouterOutputs<T[K]> : never;
17
- };
18
- export declare function getRouterChild<T extends ANY_ROUTER | Lazy<undefined>>(router: T, ...path: string[]): T extends ANY_LAZY ? Lazy<ANY_PROCEDURE> | Lazy<Record<string, ANY_ROUTER>> | Lazy<undefined> : ANY_ROUTER | Lazy<undefined> | undefined;
19
- //# sourceMappingURL=router.d.ts.map
@@ -1,11 +0,0 @@
1
- import type { FindGlobalInstanceType } from '@orpc/shared';
2
- import type { ANY_PROCEDURE } from './procedure';
3
- export type AbortSignal = FindGlobalInstanceType<'AbortSignal'>;
4
- export interface WithSignal {
5
- signal?: AbortSignal;
6
- }
7
- export interface Meta extends WithSignal {
8
- path: string[];
9
- procedure: ANY_PROCEDURE;
10
- }
11
- //# sourceMappingURL=types.d.ts.map