@orpc/contract 0.0.0-next.e9dc36e → 0.0.0-next.ed15210

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 (49) hide show
  1. package/dist/index.js +444 -93
  2. package/dist/src/builder.d.ts +28 -9
  3. package/dist/src/client-utils.d.ts +5 -0
  4. package/dist/src/client.d.ts +19 -0
  5. package/dist/src/config.d.ts +11 -0
  6. package/dist/src/error-map.d.ts +58 -0
  7. package/dist/src/error-orpc.d.ts +109 -0
  8. package/dist/src/error.d.ts +13 -0
  9. package/dist/src/index.d.ts +16 -3
  10. package/dist/src/procedure-builder-with-input.d.ts +19 -0
  11. package/dist/src/procedure-builder-with-output.d.ts +19 -0
  12. package/dist/src/procedure-builder.d.ts +15 -0
  13. package/dist/src/procedure-client.d.ts +6 -0
  14. package/dist/src/procedure-decorated.d.ts +12 -0
  15. package/dist/src/procedure.d.ts +17 -43
  16. package/dist/src/route.d.ts +88 -0
  17. package/dist/src/router-builder.d.ts +22 -14
  18. package/dist/src/router-client.d.ts +7 -0
  19. package/dist/src/router.d.ts +8 -11
  20. package/dist/src/schema-utils.d.ts +5 -0
  21. package/dist/src/types.d.ts +6 -7
  22. package/package.json +13 -14
  23. package/dist/index.js.map +0 -1
  24. package/dist/src/builder.d.ts.map +0 -1
  25. package/dist/src/constants.d.ts +0 -3
  26. package/dist/src/constants.d.ts.map +0 -1
  27. package/dist/src/index.d.ts.map +0 -1
  28. package/dist/src/procedure.d.ts.map +0 -1
  29. package/dist/src/router-builder.d.ts.map +0 -1
  30. package/dist/src/router.d.ts.map +0 -1
  31. package/dist/src/types.d.ts.map +0 -1
  32. package/dist/src/utils.d.ts +0 -4
  33. package/dist/src/utils.d.ts.map +0 -1
  34. package/dist/tsconfig.tsbuildinfo +0 -1
  35. package/src/builder.test.ts +0 -179
  36. package/src/builder.ts +0 -52
  37. package/src/constants.ts +0 -2
  38. package/src/index.ts +0 -12
  39. package/src/procedure.test.ts +0 -99
  40. package/src/procedure.ts +0 -125
  41. package/src/router-builder.test.ts +0 -70
  42. package/src/router-builder.ts +0 -46
  43. package/src/router.test-d.ts +0 -63
  44. package/src/router.test.ts +0 -24
  45. package/src/router.ts +0 -55
  46. package/src/types.test-d.ts +0 -16
  47. package/src/types.ts +0 -25
  48. package/src/utils.test.ts +0 -18
  49. package/src/utils.ts +0 -17
@@ -0,0 +1,11 @@
1
+ import type { HTTPMethod, InputStructure, Route } from './route';
2
+ export interface ContractConfig {
3
+ defaultMethod: HTTPMethod;
4
+ defaultSuccessStatus: number;
5
+ defaultSuccessDescription: string;
6
+ defaultInputStructure: InputStructure;
7
+ defaultOutputStructure: InputStructure;
8
+ defaultInitialRoute: Route;
9
+ }
10
+ export declare function fallbackContractConfig<T extends keyof ContractConfig>(key: T, value: ContractConfig[T] | undefined): ContractConfig[T];
11
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1,58 @@
1
+ import type { CommonORPCErrorCode } from './error-orpc';
2
+ import type { Schema } from './types';
3
+ export type ErrorMapItem<TDataSchema extends Schema> = {
4
+ /**
5
+ *
6
+ * @default 500
7
+ */
8
+ status?: number;
9
+ message?: string;
10
+ description?: string;
11
+ data?: TDataSchema;
12
+ };
13
+ export interface ErrorMap {
14
+ [k: string]: ErrorMapItem<Schema>;
15
+ }
16
+ /**
17
+ * const U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions
18
+ *
19
+ * Purpose:
20
+ * - Helps `U` suggest `CommonORPCErrorCode` to the user when typing.
21
+ *
22
+ * Why not replace `ErrorMap` with `ErrorMapSuggestions`?
23
+ * - `ErrorMapSuggestions` has a drawback: it allows `undefined` values for items.
24
+ * - `ErrorMapGuard<TErrorMap>` uses `Partial`, which can introduce `undefined` values.
25
+ *
26
+ * This could lead to unintended behavior where `undefined` values override `TErrorMap`,
27
+ * potentially resulting in a `never` type after merging.
28
+ *
29
+ * Recommendation:
30
+ * - Use `ErrorMapSuggestions` to assist users in typing correctly but do not replace `ErrorMap`.
31
+ * - Ensure `ErrorMapGuard<TErrorMap>` is adjusted to prevent `undefined` values.
32
+ */
33
+ export type ErrorMapSuggestions = {
34
+ [key in CommonORPCErrorCode | (string & {})]?: ErrorMapItem<Schema>;
35
+ };
36
+ /**
37
+ * `U` extends `ErrorMap` & `ErrorMapGuard<TErrorMap>`
38
+ *
39
+ * `ErrorMapGuard` is a utility type that ensures `U` cannot redefine the structure of `TErrorMap`.
40
+ * It achieves this by setting each key in `TErrorMap` to `never`, effectively preventing any redefinition.
41
+ *
42
+ * Why not just use `Partial<TErrorMap>`?
43
+ * - Allowing users to redefine existing error map items would require using `StrictErrorMap`.
44
+ * - However, I prefer not to use `StrictErrorMap` frequently, due to perceived performance concerns,
45
+ * though this has not been benchmarked and is based on personal preference.
46
+ *
47
+ */
48
+ export type ErrorMapGuard<TErrorMap extends ErrorMap> = {
49
+ [K in keyof TErrorMap]?: never;
50
+ };
51
+ /**
52
+ * Since `undefined` has a specific meaning (it use default value),
53
+ * we ensure all additional properties in each item of the ErrorMap are explicitly set to `undefined`.
54
+ */
55
+ export type StrictErrorMap<T extends ErrorMap> = {
56
+ [K in keyof T]: T[K] & Partial<Record<Exclude<keyof ErrorMapItem<any>, keyof T[K]>, undefined>>;
57
+ };
58
+ //# sourceMappingURL=error-map.d.ts.map
@@ -0,0 +1,109 @@
1
+ import type { ErrorMap, ErrorMapItem } from './error-map';
2
+ import type { SchemaOutput } from './types';
3
+ export type ORPCErrorFromErrorMap<TErrorMap extends ErrorMap> = {
4
+ [K in keyof TErrorMap]: K extends string ? TErrorMap[K] extends ErrorMapItem<infer TDataSchema> ? ORPCError<K, SchemaOutput<TDataSchema>> : never : never;
5
+ }[keyof TErrorMap];
6
+ export declare const COMMON_ORPC_ERROR_DEFS: {
7
+ readonly BAD_REQUEST: {
8
+ readonly status: 400;
9
+ readonly message: "Bad Request";
10
+ };
11
+ readonly UNAUTHORIZED: {
12
+ readonly status: 401;
13
+ readonly message: "Unauthorized";
14
+ };
15
+ readonly FORBIDDEN: {
16
+ readonly status: 403;
17
+ readonly message: "Forbidden";
18
+ };
19
+ readonly NOT_FOUND: {
20
+ readonly status: 404;
21
+ readonly message: "Not Found";
22
+ };
23
+ readonly METHOD_NOT_SUPPORTED: {
24
+ readonly status: 405;
25
+ readonly message: "Method Not Supported";
26
+ };
27
+ readonly NOT_ACCEPTABLE: {
28
+ readonly status: 406;
29
+ readonly message: "Not Acceptable";
30
+ };
31
+ readonly TIMEOUT: {
32
+ readonly status: 408;
33
+ readonly message: "Request Timeout";
34
+ };
35
+ readonly CONFLICT: {
36
+ readonly status: 409;
37
+ readonly message: "Conflict";
38
+ };
39
+ readonly PRECONDITION_FAILED: {
40
+ readonly status: 412;
41
+ readonly message: "Precondition Failed";
42
+ };
43
+ readonly PAYLOAD_TOO_LARGE: {
44
+ readonly status: 413;
45
+ readonly message: "Payload Too Large";
46
+ };
47
+ readonly UNSUPPORTED_MEDIA_TYPE: {
48
+ readonly status: 415;
49
+ readonly message: "Unsupported Media Type";
50
+ };
51
+ readonly UNPROCESSABLE_CONTENT: {
52
+ readonly status: 422;
53
+ readonly message: "Unprocessable Content";
54
+ };
55
+ readonly TOO_MANY_REQUESTS: {
56
+ readonly status: 429;
57
+ readonly message: "Too Many Requests";
58
+ };
59
+ readonly CLIENT_CLOSED_REQUEST: {
60
+ readonly status: 499;
61
+ readonly message: "Client Closed Request";
62
+ };
63
+ readonly INTERNAL_SERVER_ERROR: {
64
+ readonly status: 500;
65
+ readonly message: "Internal Server Error";
66
+ };
67
+ readonly NOT_IMPLEMENTED: {
68
+ readonly status: 501;
69
+ readonly message: "Not Implemented";
70
+ };
71
+ readonly BAD_GATEWAY: {
72
+ readonly status: 502;
73
+ readonly message: "Bad Gateway";
74
+ };
75
+ readonly SERVICE_UNAVAILABLE: {
76
+ readonly status: 503;
77
+ readonly message: "Service Unavailable";
78
+ };
79
+ readonly GATEWAY_TIMEOUT: {
80
+ readonly status: 504;
81
+ readonly message: "Gateway Timeout";
82
+ };
83
+ };
84
+ export type CommonORPCErrorCode = keyof typeof COMMON_ORPC_ERROR_DEFS;
85
+ export type ORPCErrorOptions<TCode extends string, TData> = ErrorOptions & {
86
+ defined?: boolean;
87
+ code: TCode;
88
+ status?: number;
89
+ message?: string;
90
+ } & (undefined extends TData ? {
91
+ data?: TData;
92
+ } : {
93
+ data: TData;
94
+ });
95
+ export declare function fallbackORPCErrorStatus(code: CommonORPCErrorCode | (string & {}), status: number | undefined): number;
96
+ export declare function fallbackORPCErrorMessage(code: CommonORPCErrorCode | (string & {}), message: string | undefined): string;
97
+ export declare class ORPCError<TCode extends CommonORPCErrorCode | (string & {}), TData> extends Error {
98
+ readonly defined: boolean;
99
+ readonly code: TCode;
100
+ readonly status: number;
101
+ readonly data: TData;
102
+ constructor(options: ORPCErrorOptions<TCode, TData>);
103
+ toJSON(): ORPCErrorJSON<TCode, TData>;
104
+ static isValidJSON(json: unknown): json is ORPCErrorJSON<string, unknown>;
105
+ }
106
+ export type ORPCErrorJSON<TCode extends string, TData> = Pick<ORPCError<TCode, TData>, 'defined' | 'code' | 'status' | 'message' | 'data'>;
107
+ export declare function isDefinedError<T>(error: T): error is Extract<T, ORPCError<any, any>>;
108
+ export declare function validateORPCError(map: ErrorMap, error: ORPCError<any, any>): Promise<ORPCError<string, unknown>>;
109
+ //# sourceMappingURL=error-orpc.d.ts.map
@@ -0,0 +1,13 @@
1
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
2
+ import type { ErrorMap } from './error-map';
3
+ import type { ORPCErrorFromErrorMap } from './error-orpc';
4
+ export type ErrorFromErrorMap<TErrorMap extends ErrorMap> = Error | ORPCErrorFromErrorMap<TErrorMap>;
5
+ export interface ValidationErrorOptions extends ErrorOptions {
6
+ message: string;
7
+ issues: readonly StandardSchemaV1.Issue[];
8
+ }
9
+ export declare class ValidationError extends Error {
10
+ readonly issues: readonly StandardSchemaV1.Issue[];
11
+ constructor(options: ValidationErrorOptions);
12
+ }
13
+ //# sourceMappingURL=error.d.ts.map
@@ -1,10 +1,23 @@
1
1
  /** unnoq */
2
2
  import { ContractBuilder } from './builder';
3
3
  export * from './builder';
4
- export * from './constants';
4
+ export * from './client';
5
+ export * from './client-utils';
6
+ export * from './config';
7
+ export * from './error';
8
+ export * from './error-map';
9
+ export * from './error-orpc';
5
10
  export * from './procedure';
11
+ export * from './procedure-builder';
12
+ export * from './procedure-builder-with-input';
13
+ export * from './procedure-builder-with-output';
14
+ export * from './procedure-client';
15
+ export * from './procedure-decorated';
16
+ export * from './route';
6
17
  export * from './router';
18
+ export * from './router-builder';
19
+ export * from './router-client';
20
+ export * from './schema-utils';
7
21
  export * from './types';
8
- export * from './utils';
9
- export declare const oc: ContractBuilder;
22
+ export declare const oc: ContractBuilder<{}, {}>;
10
23
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,19 @@
1
+ import type { ErrorMap, ErrorMapGuard, ErrorMapSuggestions, StrictErrorMap } from './error-map';
2
+ import type { HTTPPath, MergeRoute, PrefixRoute, Route, UnshiftTagRoute } from './route';
3
+ import type { Schema, SchemaOutput } from './types';
4
+ import { ContractProcedure } from './procedure';
5
+ import { DecoratedContractProcedure } from './procedure-decorated';
6
+ /**
7
+ * `ContractProcedureBuilderWithInput` is a branch of `ContractProcedureBuilder` which it has input schema.
8
+ *
9
+ * Why?
10
+ * - prevents override input schema after .input
11
+ */
12
+ export declare class ContractProcedureBuilderWithInput<TInputSchema extends Schema, TErrorMap extends ErrorMap, TRoute extends Route> extends ContractProcedure<TInputSchema, undefined, TErrorMap, TRoute> {
13
+ errors<const U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): ContractProcedureBuilderWithInput<TInputSchema, StrictErrorMap<U> & TErrorMap, TRoute>;
14
+ route<const U extends Route>(route: U): ContractProcedureBuilderWithInput<TInputSchema, TErrorMap, MergeRoute<TRoute, U>>;
15
+ prefix<U extends HTTPPath>(prefix: U): ContractProcedureBuilderWithInput<TInputSchema, TErrorMap, PrefixRoute<TRoute, U>>;
16
+ unshiftTag<U extends string[]>(...tags: U): ContractProcedureBuilderWithInput<TInputSchema, TErrorMap, UnshiftTagRoute<TRoute, U>>;
17
+ output<U extends Schema>(schema: U, example?: SchemaOutput<U>): DecoratedContractProcedure<TInputSchema, U, TErrorMap, TRoute>;
18
+ }
19
+ //# sourceMappingURL=procedure-builder-with-input.d.ts.map
@@ -0,0 +1,19 @@
1
+ import type { ErrorMap, ErrorMapGuard, ErrorMapSuggestions, StrictErrorMap } from './error-map';
2
+ import type { HTTPPath, MergeRoute, PrefixRoute, Route, UnshiftTagRoute } from './route';
3
+ import type { Schema, SchemaInput } from './types';
4
+ import { ContractProcedure } from './procedure';
5
+ import { DecoratedContractProcedure } from './procedure-decorated';
6
+ /**
7
+ * `ContractProcedureBuilderWithOutput` is a branch of `ContractProcedureBuilder` which it has output schema.
8
+ *
9
+ * Why?
10
+ * - prevents override output schema after .output
11
+ */
12
+ export declare class ContractProcedureBuilderWithOutput<TOutputSchema extends Schema, TErrorMap extends ErrorMap, TRoute extends Route> extends ContractProcedure<undefined, TOutputSchema, TErrorMap, TRoute> {
13
+ errors<const U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): ContractProcedureBuilderWithOutput<TOutputSchema, StrictErrorMap<U> & TErrorMap, TRoute>;
14
+ route<const U extends Route>(route: U): ContractProcedureBuilderWithOutput<TOutputSchema, TErrorMap, MergeRoute<TRoute, U>>;
15
+ prefix<U extends HTTPPath>(prefix: U): ContractProcedureBuilderWithOutput<TOutputSchema, TErrorMap, PrefixRoute<TRoute, U>>;
16
+ unshiftTag<U extends string[]>(...tags: U): ContractProcedureBuilderWithOutput<TOutputSchema, TErrorMap, UnshiftTagRoute<TRoute, U>>;
17
+ input<U extends Schema>(schema: U, example?: SchemaInput<U>): DecoratedContractProcedure<U, TOutputSchema, TErrorMap, TRoute>;
18
+ }
19
+ //# sourceMappingURL=procedure-builder-with-output.d.ts.map
@@ -0,0 +1,15 @@
1
+ import type { ErrorMap, ErrorMapGuard, ErrorMapSuggestions, StrictErrorMap } from './error-map';
2
+ import type { HTTPPath, MergeRoute, PrefixRoute, Route, UnshiftTagRoute } from './route';
3
+ import type { Schema, SchemaInput, SchemaOutput } from './types';
4
+ import { ContractProcedure } from './procedure';
5
+ import { ContractProcedureBuilderWithInput } from './procedure-builder-with-input';
6
+ import { ContractProcedureBuilderWithOutput } from './procedure-builder-with-output';
7
+ export declare class ContractProcedureBuilder<TErrorMap extends ErrorMap, TRoute extends Route> extends ContractProcedure<undefined, undefined, TErrorMap, TRoute> {
8
+ errors<const U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): ContractProcedureBuilder<StrictErrorMap<U> & TErrorMap, TRoute>;
9
+ route<const U extends Route>(route: U): ContractProcedureBuilder<TErrorMap, MergeRoute<TRoute, U>>;
10
+ prefix<U extends HTTPPath>(prefix: U): ContractProcedureBuilder<TErrorMap, PrefixRoute<TRoute, U>>;
11
+ unshiftTag<U extends string[]>(...tags: U): ContractProcedureBuilder<TErrorMap, UnshiftTagRoute<TRoute, U>>;
12
+ input<U extends Schema>(schema: U, example?: SchemaInput<U>): ContractProcedureBuilderWithInput<U, TErrorMap, TRoute>;
13
+ output<U extends Schema>(schema: U, example?: SchemaOutput<U>): ContractProcedureBuilderWithOutput<U, TErrorMap, TRoute>;
14
+ }
15
+ //# sourceMappingURL=procedure-builder.d.ts.map
@@ -0,0 +1,6 @@
1
+ import type { Client } from './client';
2
+ import type { ErrorFromErrorMap } from './error';
3
+ import type { ErrorMap } from './error-map';
4
+ import type { Schema, SchemaInput, SchemaOutput } from './types';
5
+ export type ContractProcedureClient<TClientContext, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap> = Client<TClientContext, SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
6
+ //# sourceMappingURL=procedure-client.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { ErrorMap, ErrorMapGuard, ErrorMapSuggestions, StrictErrorMap } from './error-map';
2
+ import type { Schema } from './types';
3
+ import { ContractProcedure } from './procedure';
4
+ import { type HTTPPath, type MergeRoute, type PrefixRoute, type Route, type UnshiftTagRoute } from './route';
5
+ export declare class DecoratedContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TRoute extends Route> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TRoute> {
6
+ static decorate<UInputSchema extends Schema, UOutputSchema extends Schema, UErrorMap extends ErrorMap, URoute extends Route>(procedure: ContractProcedure<UInputSchema, UOutputSchema, UErrorMap, URoute>): DecoratedContractProcedure<UInputSchema, UOutputSchema, UErrorMap, URoute>;
7
+ errors<const U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): DecoratedContractProcedure<TInputSchema, TOutputSchema, StrictErrorMap<U> & TErrorMap, TRoute>;
8
+ route<const U extends Route>(route: U): DecoratedContractProcedure<TInputSchema, TOutputSchema, TErrorMap, MergeRoute<TRoute, U>>;
9
+ prefix<U extends HTTPPath>(prefix: U): DecoratedContractProcedure<TInputSchema, TOutputSchema, TErrorMap, PrefixRoute<TRoute, U>>;
10
+ unshiftTag<U extends string[]>(...tags: U): DecoratedContractProcedure<TInputSchema, TOutputSchema, TErrorMap, UnshiftTagRoute<TRoute, U>>;
11
+ }
12
+ //# sourceMappingURL=procedure-decorated.d.ts.map
@@ -1,46 +1,20 @@
1
- import type { HTTPMethod, HTTPPath, Schema, SchemaInput, SchemaOutput } from './types';
2
- export interface RouteOptions {
3
- method?: HTTPMethod;
4
- path?: HTTPPath;
5
- summary?: string;
6
- description?: string;
7
- deprecated?: boolean;
8
- tags?: string[];
1
+ import type { ErrorMap } from './error-map';
2
+ import type { Route } from './route';
3
+ import type { Schema, SchemaOutput } from './types';
4
+ export interface ContractProcedureDef<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TRoute extends Route> {
5
+ route: TRoute;
6
+ InputSchema: TInputSchema;
7
+ inputExample?: SchemaOutput<TInputSchema>;
8
+ OutputSchema: TOutputSchema;
9
+ outputExample?: SchemaOutput<TOutputSchema>;
10
+ errorMap: TErrorMap;
9
11
  }
10
- export declare class ContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema> {
11
- zz$cp: {
12
- path?: HTTPPath;
13
- method?: HTTPMethod;
14
- summary?: string;
15
- description?: string;
16
- deprecated?: boolean;
17
- tags?: string[];
18
- InputSchema: TInputSchema;
19
- inputExample?: SchemaOutput<TInputSchema>;
20
- OutputSchema: TOutputSchema;
21
- outputExample?: SchemaOutput<TOutputSchema>;
22
- };
23
- constructor(zz$cp: {
24
- path?: HTTPPath;
25
- method?: HTTPMethod;
26
- summary?: string;
27
- description?: string;
28
- deprecated?: boolean;
29
- tags?: string[];
30
- InputSchema: TInputSchema;
31
- inputExample?: SchemaOutput<TInputSchema>;
32
- OutputSchema: TOutputSchema;
33
- outputExample?: SchemaOutput<TOutputSchema>;
34
- });
12
+ export declare class ContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TRoute extends Route> {
13
+ '~type': "ContractProcedure";
14
+ '~orpc': ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TRoute>;
15
+ constructor(def: ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TRoute>);
35
16
  }
36
- export declare class DecoratedContractProcedure<TInputSchema extends Schema, TOutputSchema extends Schema> extends ContractProcedure<TInputSchema, TOutputSchema> {
37
- static decorate<TInputSchema extends Schema, TOutputSchema extends Schema>(cp: ContractProcedure<TInputSchema, TOutputSchema>): DecoratedContractProcedure<TInputSchema, TOutputSchema>;
38
- route(opts: RouteOptions): DecoratedContractProcedure<TInputSchema, TOutputSchema>;
39
- prefix(prefix: HTTPPath): DecoratedContractProcedure<TInputSchema, TOutputSchema>;
40
- addTags(...tags: string[]): DecoratedContractProcedure<TInputSchema, TOutputSchema>;
41
- input<USchema extends Schema>(schema: USchema, example?: SchemaInput<USchema>): DecoratedContractProcedure<USchema, TOutputSchema>;
42
- output<USchema extends Schema>(schema: USchema, example?: SchemaOutput<USchema>): DecoratedContractProcedure<TInputSchema, USchema>;
43
- }
44
- export type WELL_DEFINED_CONTRACT_PROCEDURE = ContractProcedure<Schema, Schema>;
45
- export declare function isContractProcedure(item: unknown): item is WELL_DEFINED_CONTRACT_PROCEDURE;
17
+ export type ANY_CONTRACT_PROCEDURE = ContractProcedure<any, any, any, any>;
18
+ export type WELL_CONTRACT_PROCEDURE = ContractProcedure<Schema, Schema, ErrorMap, Route>;
19
+ export declare function isContractProcedure(item: unknown): item is ANY_CONTRACT_PROCEDURE;
46
20
  //# sourceMappingURL=procedure.d.ts.map
@@ -0,0 +1,88 @@
1
+ export type HTTPPath = `/${string}`;
2
+ export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
3
+ export type InputStructure = 'compact' | 'detailed';
4
+ export type OutputStructure = 'compact' | 'detailed';
5
+ export interface Route {
6
+ method?: HTTPMethod;
7
+ path?: HTTPPath;
8
+ summary?: string;
9
+ description?: string;
10
+ deprecated?: boolean;
11
+ tags?: readonly string[];
12
+ /**
13
+ * The status code of the response when the procedure is successful.
14
+ *
15
+ * @default 200
16
+ */
17
+ successStatus?: number;
18
+ /**
19
+ * The description of the response when the procedure is successful.
20
+ *
21
+ * @default 'OK'
22
+ */
23
+ successDescription?: string;
24
+ /**
25
+ * Determines how the input should be structured based on `params`, `query`, `headers`, and `body`.
26
+ *
27
+ * @option 'compact'
28
+ * Combines `params` and either `query` or `body` (depending on the HTTP method) into a single object.
29
+ *
30
+ * @option 'detailed'
31
+ * Keeps each part of the request (`params`, `query`, `headers`, and `body`) as separate fields in the input object.
32
+ *
33
+ * Example:
34
+ * ```ts
35
+ * const input = {
36
+ * params: { id: 1 },
37
+ * query: { search: 'hello' },
38
+ * headers: { 'Content-Type': 'application/json' },
39
+ * body: { name: 'John' },
40
+ * }
41
+ * ```
42
+ *
43
+ * @default 'compact'
44
+ */
45
+ inputStructure?: InputStructure;
46
+ /**
47
+ * Determines how the response should be structured based on the output.
48
+ *
49
+ * @option 'compact'
50
+ * Includes only the body data, encoded directly in the response.
51
+ *
52
+ * @option 'detailed'
53
+ * Separates the output into `headers` and `body` fields.
54
+ * - `headers`: Custom headers to merge with the response headers.
55
+ * - `body`: The response data.
56
+ *
57
+ * Example:
58
+ * ```ts
59
+ * const output = {
60
+ * headers: { 'x-custom-header': 'value' },
61
+ * body: { message: 'Hello, world!' },
62
+ * };
63
+ * ```
64
+ *
65
+ * @default 'compact'
66
+ */
67
+ outputStructure?: OutputStructure;
68
+ }
69
+ /**
70
+ * Since `undefined` has a specific meaning (it use default value),
71
+ * we ensure all additional properties in each item of the ErrorMap are explicitly set to `undefined`.
72
+ */
73
+ export type StrictRoute<T extends Route> = T & Partial<Record<Exclude<keyof Route, keyof T>, undefined>>;
74
+ export type MergeRoute<A extends Route, B extends Route> = Omit<A, keyof B> & B;
75
+ export declare function mergeRoute<A extends Route, B extends Route>(a: A, b: B): MergeRoute<A, B>;
76
+ export type PrefixRoute<TRoute extends Route, TPrefix extends HTTPPath> = TRoute['path'] extends HTTPPath ? Omit<TRoute, 'path'> & {
77
+ path: TPrefix extends HTTPPath ? `${TPrefix}${TRoute['path']}` : TRoute['path'];
78
+ } : TRoute;
79
+ export declare function prefixRoute<TRoute extends Route, TPrefix extends HTTPPath>(route: TRoute, prefix: TPrefix): PrefixRoute<TRoute, TPrefix>;
80
+ export type UnshiftTagRoute<TRoute extends Route, TTags extends readonly string[]> = Omit<TRoute, 'tags'> & {
81
+ tags: TRoute['tags'] extends string[] ? [...TTags, ...TRoute['tags']] : TTags;
82
+ };
83
+ export declare function unshiftTagRoute<TRoute extends Route, TTags extends readonly string[]>(route: TRoute, tags: TTags): UnshiftTagRoute<TRoute, TTags>;
84
+ export type MergePrefix<A extends HTTPPath | undefined, B extends HTTPPath> = A extends HTTPPath ? `${A}${B}` : B;
85
+ export declare function mergePrefix<A extends HTTPPath | undefined, B extends HTTPPath>(a: A, b: B): MergePrefix<A, B>;
86
+ export type MergeTags<A extends readonly string[] | undefined, B extends readonly string[]> = A extends readonly string[] ? [...A, ...B] : B;
87
+ export declare function mergeTags<A extends readonly string[] | undefined, B extends readonly string[]>(a: A, b: B): MergeTags<A, B>;
88
+ //# sourceMappingURL=route.d.ts.map
@@ -1,16 +1,24 @@
1
- import type { ContractRouter, HandledContractRouter } from './router';
2
- import type { HTTPPath } from './types';
3
- export declare class ContractRouterBuilder {
4
- zz$crb: {
5
- prefix?: HTTPPath;
6
- tags?: string[];
7
- };
8
- constructor(zz$crb: {
9
- prefix?: HTTPPath;
10
- tags?: string[];
11
- });
12
- prefix(prefix: HTTPPath): ContractRouterBuilder;
13
- tags(...tags: string[]): ContractRouterBuilder;
14
- router<T extends ContractRouter>(router: T): HandledContractRouter<T>;
1
+ import type { ErrorMap, ErrorMapGuard, ErrorMapSuggestions, StrictErrorMap } from './error-map';
2
+ import type { ContractProcedure } from './procedure';
3
+ import type { ContractRouter } from './router';
4
+ import { DecoratedContractProcedure } from './procedure-decorated';
5
+ import { type HTTPPath, type MergePrefix, type MergeTags, type PrefixRoute, type Route, type UnshiftTagRoute } from './route';
6
+ export type AdaptRoute<TRoute extends Route, TPrefix extends HTTPPath | undefined, TTags extends readonly string[] | undefined> = TPrefix extends HTTPPath ? PrefixRoute<TTags extends readonly string[] ? UnshiftTagRoute<TRoute, TTags> : TRoute, TPrefix> : TTags extends readonly string[] ? UnshiftTagRoute<TRoute, TTags> : TRoute;
7
+ export type AdaptedContractRouter<TContract extends ContractRouter<any>, TErrorMapExtra extends ErrorMap, TPrefix extends HTTPPath | undefined, TTags extends readonly string[] | undefined> = {
8
+ [K in keyof TContract]: TContract[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrors, infer URoute> ? DecoratedContractProcedure<UInputSchema, UOutputSchema, UErrors & TErrorMapExtra, AdaptRoute<URoute, TPrefix, TTags>> : TContract[K] extends ContractRouter<any> ? AdaptedContractRouter<TContract[K], TErrorMapExtra, TPrefix, TTags> : never;
9
+ };
10
+ export interface ContractRouterBuilderDef<TErrorMap extends ErrorMap, TPrefix extends HTTPPath | undefined, TTags extends readonly string[] | undefined> {
11
+ errorMap: TErrorMap;
12
+ prefix: TPrefix;
13
+ tags: TTags;
14
+ }
15
+ export declare class ContractRouterBuilder<TErrorMap extends ErrorMap, TPrefix extends HTTPPath | undefined, TTags extends readonly string[] | undefined> {
16
+ '~type': "ContractProcedure";
17
+ '~orpc': ContractRouterBuilderDef<TErrorMap, TPrefix, TTags>;
18
+ constructor(def: ContractRouterBuilderDef<TErrorMap, TPrefix, TTags>);
19
+ prefix<U extends HTTPPath>(prefix: U): ContractRouterBuilder<TErrorMap, MergePrefix<TPrefix, U>, TTags>;
20
+ tag<U extends string[]>(...tags: U): ContractRouterBuilder<TErrorMap, TPrefix, MergeTags<TTags, U>>;
21
+ errors<const U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): ContractRouterBuilder<StrictErrorMap<U> & TErrorMap, TPrefix, TTags>;
22
+ router<T extends ContractRouter<ErrorMap & Partial<TErrorMap>>>(router: T): AdaptedContractRouter<T, TErrorMap, TPrefix, TTags>;
15
23
  }
16
24
  //# sourceMappingURL=router-builder.d.ts.map
@@ -0,0 +1,7 @@
1
+ import type { ContractProcedure } from './procedure';
2
+ import type { ContractProcedureClient } from './procedure-client';
3
+ import type { ContractRouter } from './router';
4
+ export type ContractRouterClient<TRouter extends ContractRouter<any>, TClientContext> = TRouter extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ContractProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
5
+ [K in keyof TRouter]: TRouter[K] extends ContractRouter<any> ? ContractRouterClient<TRouter[K], TClientContext> : never;
6
+ };
7
+ //# sourceMappingURL=router-client.d.ts.map
@@ -1,16 +1,13 @@
1
+ import type { ErrorMap } from './error-map';
2
+ import type { ContractProcedure } from './procedure';
1
3
  import type { SchemaInput, SchemaOutput } from './types';
2
- import { type ContractProcedure, type DecoratedContractProcedure, type WELL_DEFINED_CONTRACT_PROCEDURE } from './procedure';
3
- export interface ContractRouter {
4
- [k: string]: ContractProcedure<any, any> | ContractRouter;
5
- }
6
- export type HandledContractRouter<TContract extends ContractRouter> = {
7
- [K in keyof TContract]: TContract[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? DecoratedContractProcedure<UInputSchema, UOutputSchema> : TContract[K] extends ContractRouter ? HandledContractRouter<TContract[K]> : never;
4
+ export type ContractRouter<T extends ErrorMap> = ContractProcedure<any, any, T, any> | {
5
+ [k: string]: ContractRouter<T>;
8
6
  };
9
- export declare function eachContractRouterLeaf(router: ContractRouter, callback: (item: WELL_DEFINED_CONTRACT_PROCEDURE, path: string[]) => void, prefix?: string[]): void;
10
- export type InferContractRouterInputs<T extends ContractRouter> = {
11
- [K in keyof T]: T[K] extends ContractProcedure<infer UInputSchema, any> ? SchemaInput<UInputSchema> : T[K] extends ContractRouter ? InferContractRouterInputs<T[K]> : never;
7
+ export type InferContractRouterInputs<T extends ContractRouter<any>> = T extends ContractProcedure<infer UInputSchema, any, any, any> ? SchemaInput<UInputSchema> : {
8
+ [K in keyof T]: T[K] extends ContractRouter<any> ? InferContractRouterInputs<T[K]> : never;
12
9
  };
13
- export type InferContractRouterOutputs<T extends ContractRouter> = {
14
- [K in keyof T]: T[K] extends ContractProcedure<any, infer UOutputSchema> ? SchemaOutput<UOutputSchema> : T[K] extends ContractRouter ? InferContractRouterOutputs<T[K]> : never;
10
+ export type InferContractRouterOutputs<T extends ContractRouter<any>> = T extends ContractProcedure<any, infer UOutputSchema, any, any> ? SchemaOutput<UOutputSchema> : {
11
+ [K in keyof T]: T[K] extends ContractRouter<any> ? InferContractRouterOutputs<T[K]> : never;
15
12
  };
16
13
  //# sourceMappingURL=router.d.ts.map
@@ -0,0 +1,5 @@
1
+ import type { IsEqual, Promisable } from '@orpc/shared';
2
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
3
+ export type TypeRest<TInput, TOutput> = [map: (input: TInput) => Promisable<TOutput>] | (IsEqual<TInput, TOutput> extends true ? [] : never);
4
+ export declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutput>): StandardSchemaV1<TInput, TOutput>;
5
+ //# sourceMappingURL=schema-utils.d.ts.map
@@ -1,8 +1,7 @@
1
- import type { input, output, ZodType } from 'zod';
2
- export type HTTPPath = `/${string}`;
3
- export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
4
- export type HTTPStatus = number;
5
- export type Schema = ZodType<any, any, any> | undefined;
6
- export type SchemaInput<TSchema extends Schema, TFallback = unknown> = TSchema extends undefined ? TFallback : TSchema extends ZodType<any, any, any> ? input<TSchema> : TFallback;
7
- export type SchemaOutput<TSchema extends Schema, TFallback = unknown> = TSchema extends undefined ? TFallback : TSchema extends ZodType<any, any, any> ? output<TSchema> : TFallback;
1
+ import type { FindGlobalInstanceType } from '@orpc/shared';
2
+ import type { StandardSchemaV1 } from '@standard-schema/spec';
3
+ export type Schema = StandardSchemaV1 | undefined;
4
+ export type SchemaInput<TSchema extends Schema, TFallback = unknown> = TSchema extends undefined ? TFallback : TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferInput<TSchema> : TFallback;
5
+ export type SchemaOutput<TSchema extends Schema, TFallback = unknown> = TSchema extends undefined ? TFallback : TSchema extends StandardSchemaV1 ? StandardSchemaV1.InferOutput<TSchema> : TFallback;
6
+ export type AbortSignal = FindGlobalInstanceType<'AbortSignal'>;
8
7
  //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -1,17 +1,12 @@
1
1
  {
2
2
  "name": "@orpc/contract",
3
3
  "type": "module",
4
- "version": "0.0.0-next.e9dc36e",
5
- "author": {
6
- "name": "unnoq",
7
- "email": "contact@unnoq.com",
8
- "url": "https://unnoq.com"
9
- },
4
+ "version": "0.0.0-next.ed15210",
10
5
  "license": "MIT",
11
- "homepage": "https://github.com/unnoq/orpc",
6
+ "homepage": "https://orpc.unnoq.com",
12
7
  "repository": {
13
8
  "type": "git",
14
- "url": "https://github.com/unnoq/orpc.git",
9
+ "url": "git+https://github.com/unnoq/orpc.git",
15
10
  "directory": "packages/contract"
16
11
  },
17
12
  "keywords": [
@@ -29,14 +24,18 @@
29
24
  }
30
25
  },
31
26
  "files": [
32
- "dist",
33
- "src"
27
+ "!**/*.map",
28
+ "!**/*.tsbuildinfo",
29
+ "dist"
34
30
  ],
35
- "peerDependencies": {
36
- "zod": ">=3.23.0"
37
- },
38
31
  "dependencies": {
39
- "@orpc/shared": "0.0.0-next.e9dc36e"
32
+ "@standard-schema/spec": "1.0.0-beta.4",
33
+ "@orpc/shared": "0.0.0-next.ed15210"
34
+ },
35
+ "devDependencies": {
36
+ "arktype": "2.0.0-rc.26",
37
+ "valibot": "1.0.0-beta.9",
38
+ "zod": "3.24.1"
40
39
  },
41
40
  "scripts": {
42
41
  "build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/procedure.ts","../src/router-builder.ts","../src/builder.ts","../src/constants.ts","../src/router.ts","../src/utils.ts","../src/index.ts"],"sourcesContent":["import type {\n HTTPMethod,\n HTTPPath,\n Schema,\n SchemaInput,\n SchemaOutput,\n} from './types'\n\nexport interface RouteOptions {\n method?: HTTPMethod\n path?: HTTPPath\n summary?: string\n description?: string\n deprecated?: boolean\n tags?: string[]\n}\n\nexport class ContractProcedure<\n TInputSchema extends Schema,\n TOutputSchema extends Schema,\n> {\n constructor(\n public zz$cp: {\n path?: HTTPPath\n method?: HTTPMethod\n summary?: string\n description?: string\n deprecated?: boolean\n tags?: string[]\n InputSchema: TInputSchema\n inputExample?: SchemaOutput<TInputSchema>\n OutputSchema: TOutputSchema\n outputExample?: SchemaOutput<TOutputSchema>\n },\n ) {}\n}\n\nexport class DecoratedContractProcedure<\n TInputSchema extends Schema,\n TOutputSchema extends Schema,\n> extends ContractProcedure<TInputSchema, TOutputSchema> {\n static decorate<TInputSchema extends Schema, TOutputSchema extends Schema>(\n cp: ContractProcedure<TInputSchema, TOutputSchema>,\n ): DecoratedContractProcedure<TInputSchema, TOutputSchema> {\n if (cp instanceof DecoratedContractProcedure)\n return cp\n return new DecoratedContractProcedure(cp.zz$cp)\n }\n\n route(\n opts: RouteOptions,\n ): DecoratedContractProcedure<TInputSchema, TOutputSchema> {\n return new DecoratedContractProcedure({\n ...this.zz$cp,\n ...opts,\n method: opts.method,\n path: opts.path,\n })\n }\n\n prefix(\n prefix: HTTPPath,\n ): DecoratedContractProcedure<TInputSchema, TOutputSchema> {\n if (!this.zz$cp.path)\n return this\n\n return new DecoratedContractProcedure({\n ...this.zz$cp,\n path: `${prefix}${this.zz$cp.path}`,\n })\n }\n\n addTags(\n ...tags: string[]\n ): DecoratedContractProcedure<TInputSchema, TOutputSchema> {\n if (!tags.length)\n return this\n\n return new DecoratedContractProcedure({\n ...this.zz$cp,\n tags: [...(this.zz$cp.tags ?? []), ...tags],\n })\n }\n\n input<USchema extends Schema>(\n schema: USchema,\n example?: SchemaInput<USchema>,\n ): DecoratedContractProcedure<USchema, TOutputSchema> {\n return new DecoratedContractProcedure({\n ...this.zz$cp,\n InputSchema: schema,\n inputExample: example,\n })\n }\n\n output<USchema extends Schema>(\n schema: USchema,\n example?: SchemaOutput<USchema>,\n ): DecoratedContractProcedure<TInputSchema, USchema> {\n return new DecoratedContractProcedure({\n ...this.zz$cp,\n OutputSchema: schema,\n outputExample: example,\n })\n }\n}\n\nexport type WELL_DEFINED_CONTRACT_PROCEDURE = ContractProcedure<Schema, Schema>\n\nexport function isContractProcedure(\n item: unknown,\n): item is WELL_DEFINED_CONTRACT_PROCEDURE {\n if (item instanceof ContractProcedure)\n return true\n\n return (\n (typeof item === 'object' || typeof item === 'function')\n && item !== null\n && 'zz$cp' in item\n && typeof item.zz$cp === 'object'\n && item.zz$cp !== null\n && 'InputSchema' in item.zz$cp\n && 'OutputSchema' in item.zz$cp\n )\n}\n","import type { ContractRouter, HandledContractRouter } from './router'\nimport type { HTTPPath } from './types'\nimport { DecoratedContractProcedure, isContractProcedure } from './procedure'\n\nexport class ContractRouterBuilder {\n constructor(public zz$crb: { prefix?: HTTPPath, tags?: string[] }) {}\n\n prefix(prefix: HTTPPath): ContractRouterBuilder {\n return new ContractRouterBuilder({\n ...this.zz$crb,\n prefix: `${this.zz$crb.prefix ?? ''}${prefix}`,\n })\n }\n\n tags(...tags: string[]): ContractRouterBuilder {\n if (!tags.length)\n return this\n\n return new ContractRouterBuilder({\n ...this.zz$crb,\n tags: [...(this.zz$crb.tags ?? []), ...tags],\n })\n }\n\n router<T extends ContractRouter>(router: T): HandledContractRouter<T> {\n const handled: ContractRouter = {}\n\n for (const key in router) {\n const item = router[key]\n if (isContractProcedure(item)) {\n const decorated = DecoratedContractProcedure.decorate(item).addTags(\n ...(this.zz$crb.tags ?? []),\n )\n\n handled[key] = this.zz$crb.prefix\n ? decorated.prefix(this.zz$crb.prefix)\n : decorated\n }\n else {\n handled[key] = this.router(item as ContractRouter)\n }\n }\n\n return handled as HandledContractRouter<T>\n }\n}\n","import type { ContractRouter } from './router'\nimport type { HTTPPath, Schema, SchemaInput, SchemaOutput } from './types'\nimport { DecoratedContractProcedure, type RouteOptions } from './procedure'\nimport { ContractRouterBuilder } from './router-builder'\n\nexport class ContractBuilder {\n prefix(prefix: HTTPPath): ContractRouterBuilder {\n return new ContractRouterBuilder({\n prefix,\n })\n }\n\n tags(...tags: string[]): ContractRouterBuilder {\n return new ContractRouterBuilder({\n tags,\n })\n }\n\n route(opts: RouteOptions): DecoratedContractProcedure<undefined, undefined> {\n return new DecoratedContractProcedure({\n InputSchema: undefined,\n OutputSchema: undefined,\n ...opts,\n })\n }\n\n input<USchema extends Schema>(\n schema: USchema,\n example?: SchemaInput<USchema>,\n ): DecoratedContractProcedure<USchema, undefined> {\n return new DecoratedContractProcedure({\n InputSchema: schema,\n inputExample: example,\n OutputSchema: undefined,\n })\n }\n\n output<USchema extends Schema>(\n schema: USchema,\n example?: SchemaOutput<USchema>,\n ): DecoratedContractProcedure<undefined, USchema> {\n return new DecoratedContractProcedure({\n InputSchema: undefined,\n OutputSchema: schema,\n outputExample: example,\n })\n }\n\n router<T extends ContractRouter>(router: T): T {\n return router\n }\n}\n","export const ORPC_HEADER = 'x-orpc-transformer'\nexport const ORPC_HEADER_VALUE = 't'\n","import type { SchemaInput, SchemaOutput } from './types'\nimport {\n type ContractProcedure,\n type DecoratedContractProcedure,\n isContractProcedure,\n type WELL_DEFINED_CONTRACT_PROCEDURE,\n} from './procedure'\n\nexport interface ContractRouter {\n [k: string]: ContractProcedure<any, any> | ContractRouter\n}\n\nexport type HandledContractRouter<TContract extends ContractRouter> = {\n [K in keyof TContract]: TContract[K] extends ContractProcedure<\n infer UInputSchema,\n infer UOutputSchema\n >\n ? DecoratedContractProcedure<UInputSchema, UOutputSchema>\n : TContract[K] extends ContractRouter\n ? HandledContractRouter<TContract[K]>\n : never\n}\n\nexport function eachContractRouterLeaf(\n router: ContractRouter,\n callback: (item: WELL_DEFINED_CONTRACT_PROCEDURE, path: string[]) => void,\n prefix: string[] = [],\n) {\n for (const key in router) {\n const item = router[key]\n\n if (isContractProcedure(item)) {\n callback(item, [...prefix, key])\n }\n else {\n eachContractRouterLeaf(item as ContractRouter, callback, [...prefix, key])\n }\n }\n}\n\nexport type InferContractRouterInputs<T extends ContractRouter> = {\n [K in keyof T]: T[K] extends ContractProcedure<infer UInputSchema, any>\n ? SchemaInput<UInputSchema>\n : T[K] extends ContractRouter\n ? InferContractRouterInputs<T[K]>\n : never\n}\n\nexport type InferContractRouterOutputs<T extends ContractRouter> = {\n [K in keyof T]: T[K] extends ContractProcedure<any, infer UOutputSchema>\n ? SchemaOutput<UOutputSchema>\n : T[K] extends ContractRouter\n ? InferContractRouterOutputs<T[K]>\n : never\n}\n","import type { HTTPPath } from './types'\n\nexport function standardizeHTTPPath(path: HTTPPath): HTTPPath {\n return `/${path.replace(/\\/{2,}/g, '/').replace(/^\\/|\\/$/g, '')}`\n}\n\nexport function prefixHTTPPath(prefix: HTTPPath, path: HTTPPath): HTTPPath {\n const prefix_ = standardizeHTTPPath(prefix)\n const path_ = standardizeHTTPPath(path)\n\n if (prefix_ === '/')\n return path_\n if (path_ === '/')\n return prefix_\n\n return `${prefix_}${path_}`\n}\n","/** unnoq */\n\nimport { ContractBuilder } from './builder'\n\nexport * from './builder'\nexport * from './constants'\nexport * from './procedure'\nexport * from './router'\nexport * from './types'\nexport * from './utils'\n\nexport const oc = new ContractBuilder()\n"],"mappings":"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","names":[]}