@orpc/contract 2.0.0-beta.24 → 2.0.0-beta.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -10,22 +10,101 @@ type MergedErrorMap<T1 extends ErrorMap, T2 extends ErrorMap> = keyof T1 extends
10
10
  declare function mergeErrorMap<T1 extends ErrorMap = object, T2 extends ErrorMap = object>(errorMap1: T1 | undefined, errorMap2: T2 | undefined): MergedErrorMap<T1, T2>;
11
11
  declare function reconcileORPCError(map: ErrorMap, error: AnyORPCError): Promise<AnyORPCError>;
12
12
 
13
+ /**
14
+ * The contract builder variant returned after `.input` is called.
15
+ * It is already a complete procedure contract that can still be refined.
16
+ *
17
+ * @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
18
+ */
13
19
  interface ProcedureContractBuilderWithInput<TInputSchema extends AnySchema, TErrorMap extends ErrorMap> extends ProcedureContract<TInputSchema, InitialOutputSchema, TErrorMap> {
20
+ /**
21
+ * Applies metadata plugins to contracts built from this builder.
22
+ *
23
+ * @see {@link https://orpc.dev/docs/contract/procedure#metadata | Procedure Contract - Metadata}
24
+ */
14
25
  meta(...plugins: MetaPlugin<TInputSchema, InitialOutputSchema, TErrorMap>[]): ProcedureContractBuilderWithInput<TInputSchema, TErrorMap>;
26
+ /**
27
+ * Defines typesafe errors that implementations of this contract can throw.
28
+ *
29
+ * @see {@link https://orpc.dev/docs/contract/procedure#typesafe-errors | Procedure Contract - Typesafe Errors}
30
+ */
15
31
  errors<T extends ErrorMap>(errors: T): ProcedureContractBuilderWithInput<TInputSchema, MergedErrorMap<TErrorMap, T>>;
32
+ /**
33
+ * Adds an additional input schema, merged with the previously defined one.
34
+ *
35
+ * @see {@link https://orpc.dev/docs/contract/procedure#multiple-schemas | Procedure Contract - Multiple Schemas}
36
+ */
16
37
  input<T extends AnySchema>(schema: T): ProcedureContractBuilderWithInput<MergedSchema<T, TInputSchema>, TErrorMap>;
38
+ /**
39
+ * Defines the output schema used to validate and type the procedure output.
40
+ *
41
+ * @see {@link https://orpc.dev/docs/contract/procedure#inputoutput-validation | Procedure Contract - Input/Output Validation}
42
+ */
17
43
  output<T extends AnySchema>(schema: T): ProcedureContractBuilderWithInputOutput<TInputSchema, T, TErrorMap>;
18
44
  }
45
+ /**
46
+ * The contract builder variant returned after `.output` is called.
47
+ * It is already a complete procedure contract that can still be refined.
48
+ *
49
+ * @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
50
+ */
19
51
  interface ProcedureContractBuilderWithOutput<TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends ProcedureContract<InitialInputSchema, TOutputSchema, TErrorMap> {
52
+ /**
53
+ * Applies metadata plugins to contracts built from this builder.
54
+ *
55
+ * @see {@link https://orpc.dev/docs/contract/procedure#metadata | Procedure Contract - Metadata}
56
+ */
20
57
  meta(...plugins: MetaPlugin<InitialInputSchema, TOutputSchema, TErrorMap>[]): ProcedureContractBuilderWithOutput<TOutputSchema, TErrorMap>;
58
+ /**
59
+ * Defines typesafe errors that implementations of this contract can throw.
60
+ *
61
+ * @see {@link https://orpc.dev/docs/contract/procedure#typesafe-errors | Procedure Contract - Typesafe Errors}
62
+ */
21
63
  errors<T extends ErrorMap>(errors: T): ProcedureContractBuilderWithOutput<TOutputSchema, MergedErrorMap<TErrorMap, T>>;
64
+ /**
65
+ * Defines the input schema used to validate and type the procedure input.
66
+ *
67
+ * @see {@link https://orpc.dev/docs/contract/procedure#inputoutput-validation | Procedure Contract - Input/Output Validation}
68
+ */
22
69
  input<T extends AnySchema>(schema: T): ProcedureContractBuilderWithInputOutput<T, TOutputSchema, TErrorMap>;
70
+ /**
71
+ * Adds an additional output schema, merged with the previously defined one.
72
+ *
73
+ * @see {@link https://orpc.dev/docs/contract/procedure#multiple-schemas | Procedure Contract - Multiple Schemas}
74
+ */
23
75
  output<T extends AnySchema>(schema: T): ProcedureContractBuilderWithOutput<MergedSchema<T, TOutputSchema>, TErrorMap>;
24
76
  }
77
+ /**
78
+ * The contract builder variant returned after both `.input` and `.output`
79
+ * are called. It is already a complete procedure contract that can still be
80
+ * refined.
81
+ *
82
+ * @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
83
+ */
25
84
  interface ProcedureContractBuilderWithInputOutput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends ProcedureContract<TInputSchema, TOutputSchema, TErrorMap> {
85
+ /**
86
+ * Applies metadata plugins to contracts built from this builder.
87
+ *
88
+ * @see {@link https://orpc.dev/docs/contract/procedure#metadata | Procedure Contract - Metadata}
89
+ */
26
90
  meta(...plugins: MetaPlugin<TInputSchema, TOutputSchema, TErrorMap>[]): ProcedureContractBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap>;
91
+ /**
92
+ * Defines typesafe errors that implementations of this contract can throw.
93
+ *
94
+ * @see {@link https://orpc.dev/docs/contract/procedure#typesafe-errors | Procedure Contract - Typesafe Errors}
95
+ */
27
96
  errors<T extends ErrorMap>(errors: T): ProcedureContractBuilderWithInputOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, T>>;
97
+ /**
98
+ * Adds an additional input schema, merged with the previously defined one.
99
+ *
100
+ * @see {@link https://orpc.dev/docs/contract/procedure#multiple-schemas | Procedure Contract - Multiple Schemas}
101
+ */
28
102
  input<T extends AnySchema>(schema: T): ProcedureContractBuilderWithInputOutput<MergedSchema<T, TInputSchema>, TOutputSchema, TErrorMap>;
103
+ /**
104
+ * Adds an additional output schema, merged with the previously defined one.
105
+ *
106
+ * @see {@link https://orpc.dev/docs/contract/procedure#multiple-schemas | Procedure Contract - Multiple Schemas}
107
+ */
29
108
  output<T extends AnySchema>(schema: T): ProcedureContractBuilderWithInputOutput<TInputSchema, MergedSchema<T, TOutputSchema>, TErrorMap>;
30
109
  }
31
110
 
@@ -54,24 +133,72 @@ declare function getProcedureContractOrThrow(router: RouterContract, path: reado
54
133
  */
55
134
  declare function minifyRouterContract(router: RouterContract): RouterContract;
56
135
 
136
+ /**
137
+ * The input schema type used before `.input` is called.
138
+ * Input is `void` for better compatibility with third-party libraries,
139
+ * such as TanStack Query, which allow calling mutations without input.
140
+ */
57
141
  type InitialInputSchema = Schema<void, unknown>;
142
+ /**
143
+ * The output schema type used before `.output` is called.
144
+ */
58
145
  type InitialOutputSchema = Schema<unknown>;
146
+ /**
147
+ * The contract builder behind `oc`. Chain its methods to define procedure
148
+ * contracts — metadata, errors, and input/output schemas — without any
149
+ * business logic.
150
+ *
151
+ * @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
152
+ */
59
153
  declare class ContractBuilder<TErrorMap extends ErrorMap> extends ProcedureContract<InitialInputSchema, InitialOutputSchema, TErrorMap> {
60
154
  /**
61
155
  * Private constructor to prevent direct instantiation.
62
156
  * Use the static `create` method to initialize a new instance with a safe initial definition.
63
157
  */
64
158
  private constructor();
159
+ /**
160
+ * Creates a fresh contract builder with an empty definition.
161
+ * Prefer the exported `oc` instance over calling this directly.
162
+ *
163
+ * @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
164
+ */
65
165
  static create(): ContractBuilder<object>;
166
+ /**
167
+ * Applies metadata plugins to contracts built from this builder.
168
+ *
169
+ * @see {@link https://orpc.dev/docs/contract/procedure#metadata | Procedure Contract - Metadata}
170
+ */
66
171
  meta(...plugins: MetaPlugin<InitialInputSchema, InitialOutputSchema, TErrorMap>[]): ContractBuilder<TErrorMap>;
172
+ /**
173
+ * Defines typesafe errors that implementations of this contract can throw.
174
+ *
175
+ * @see {@link https://orpc.dev/docs/contract/procedure#typesafe-errors | Procedure Contract - Typesafe Errors}
176
+ */
67
177
  errors<T extends ErrorMap>(errors: T): ContractBuilder<MergedErrorMap<TErrorMap, T>>;
178
+ /**
179
+ * Defines the input schema used to validate and type the procedure input.
180
+ *
181
+ * @see {@link https://orpc.dev/docs/contract/procedure#inputoutput-validation | Procedure Contract - Input/Output Validation}
182
+ */
68
183
  input<T extends AnySchema>(schema: T): ProcedureContractBuilderWithInput<T, TErrorMap>;
184
+ /**
185
+ * Defines the output schema used to validate and type the procedure output.
186
+ *
187
+ * @see {@link https://orpc.dev/docs/contract/procedure#inputoutput-validation | Procedure Contract - Input/Output Validation}
188
+ */
69
189
  output<T extends AnySchema>(schema: T): ProcedureContractBuilderWithOutput<T, TErrorMap>;
190
+ /**
191
+ * Applies the builder's errors and metadata to every procedure contract in
192
+ * the given router contract.
193
+ *
194
+ * @see {@link https://orpc.dev/docs/contract/router#extending-router | Router Contract - Extending Router}
195
+ */
70
196
  router<T extends RouterContract>(router: T): AugmentedContractRouter<T, TErrorMap>;
71
197
  }
72
198
  /**
73
- * The contract builder the entry point for defining procedure and router contracts
74
- * (input/output schemas, errors, and metadata) without any business logic.
199
+ * The oRPC contract builder. Chain methods like `.input`, `.errors`, and
200
+ * `.output` to define procedure contracts, then compose them into router
201
+ * contracts.
75
202
  *
76
203
  * @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
77
204
  */
@@ -303,4 +430,4 @@ declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutp
303
430
  declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
304
431
 
305
432
  export { AnyProcedureContract as AnyContractProcedure, RouterContract as AnyContractRouter, AnyMetaPlugin, AnyProcedureContract, AnySchema, ContractBuilder, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedSchema, Meta, MetaPlugin, ORPCErrorFromErrorMap, ProcedureContract, RouterContract, Schema, SchemaIssue, asyncIteratorObject, augmentContractRouter, createContractClientFactory, createORPCErrorConstructorMap, defineMeta, error, asyncIteratorObject as eventIterator, getAsyncIteratorObjectSchemaDetails, getRouterContract as getContractRouter, getPathMeta, getProcedureContractOrThrow, getRouterContract, isSchemaIssue, mergeErrorMap, meta, minifyRouterContract as minifyContractRouter, minifyRouterContract, oc, reconcileORPCError, resolveBasePathMeta, resolveMetaPlugins, type };
306
- export type { AsyncIteratorObjectSchemaDetails, AugmentContractRouterOptions, AugmentedContractRouter, ContractClientFactory, ContractClientFactoryOptions, InitialInputSchema, InitialOutputSchema, MergedErrorMap, ORPCErrorConstructorMap, ORPCErrorConstructorMapItem, ORPCErrorConstructorMapItemOptions, ORPCErrorFactory, ORPCErrorFactoryOptions, PathMetaPlugin, ProcedureContractBuilderWithInput, ProcedureContractBuilderWithInputOutput, ProcedureContractBuilderWithOutput, ProcedureContractClient, RouterContractClient, TypeRest };
433
+ export type { AsyncIteratorObjectSchemaDetails, AugmentContractRouterOptions, AugmentedContractRouter, ContractClientFactory, ContractClientFactoryOptions, RouterContractClient as ContractRouterClient, InitialInputSchema, InitialOutputSchema, MergedErrorMap, ORPCErrorConstructorMap, ORPCErrorConstructorMapItem, ORPCErrorConstructorMapItemOptions, ORPCErrorFactory, ORPCErrorFactoryOptions, PathMetaPlugin, ProcedureContractBuilderWithInput, ProcedureContractBuilderWithInputOutput, ProcedureContractBuilderWithOutput, ProcedureContractClient, RouterContractClient, TypeRest };
package/dist/index.d.ts CHANGED
@@ -10,22 +10,101 @@ type MergedErrorMap<T1 extends ErrorMap, T2 extends ErrorMap> = keyof T1 extends
10
10
  declare function mergeErrorMap<T1 extends ErrorMap = object, T2 extends ErrorMap = object>(errorMap1: T1 | undefined, errorMap2: T2 | undefined): MergedErrorMap<T1, T2>;
11
11
  declare function reconcileORPCError(map: ErrorMap, error: AnyORPCError): Promise<AnyORPCError>;
12
12
 
13
+ /**
14
+ * The contract builder variant returned after `.input` is called.
15
+ * It is already a complete procedure contract that can still be refined.
16
+ *
17
+ * @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
18
+ */
13
19
  interface ProcedureContractBuilderWithInput<TInputSchema extends AnySchema, TErrorMap extends ErrorMap> extends ProcedureContract<TInputSchema, InitialOutputSchema, TErrorMap> {
20
+ /**
21
+ * Applies metadata plugins to contracts built from this builder.
22
+ *
23
+ * @see {@link https://orpc.dev/docs/contract/procedure#metadata | Procedure Contract - Metadata}
24
+ */
14
25
  meta(...plugins: MetaPlugin<TInputSchema, InitialOutputSchema, TErrorMap>[]): ProcedureContractBuilderWithInput<TInputSchema, TErrorMap>;
26
+ /**
27
+ * Defines typesafe errors that implementations of this contract can throw.
28
+ *
29
+ * @see {@link https://orpc.dev/docs/contract/procedure#typesafe-errors | Procedure Contract - Typesafe Errors}
30
+ */
15
31
  errors<T extends ErrorMap>(errors: T): ProcedureContractBuilderWithInput<TInputSchema, MergedErrorMap<TErrorMap, T>>;
32
+ /**
33
+ * Adds an additional input schema, merged with the previously defined one.
34
+ *
35
+ * @see {@link https://orpc.dev/docs/contract/procedure#multiple-schemas | Procedure Contract - Multiple Schemas}
36
+ */
16
37
  input<T extends AnySchema>(schema: T): ProcedureContractBuilderWithInput<MergedSchema<T, TInputSchema>, TErrorMap>;
38
+ /**
39
+ * Defines the output schema used to validate and type the procedure output.
40
+ *
41
+ * @see {@link https://orpc.dev/docs/contract/procedure#inputoutput-validation | Procedure Contract - Input/Output Validation}
42
+ */
17
43
  output<T extends AnySchema>(schema: T): ProcedureContractBuilderWithInputOutput<TInputSchema, T, TErrorMap>;
18
44
  }
45
+ /**
46
+ * The contract builder variant returned after `.output` is called.
47
+ * It is already a complete procedure contract that can still be refined.
48
+ *
49
+ * @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
50
+ */
19
51
  interface ProcedureContractBuilderWithOutput<TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends ProcedureContract<InitialInputSchema, TOutputSchema, TErrorMap> {
52
+ /**
53
+ * Applies metadata plugins to contracts built from this builder.
54
+ *
55
+ * @see {@link https://orpc.dev/docs/contract/procedure#metadata | Procedure Contract - Metadata}
56
+ */
20
57
  meta(...plugins: MetaPlugin<InitialInputSchema, TOutputSchema, TErrorMap>[]): ProcedureContractBuilderWithOutput<TOutputSchema, TErrorMap>;
58
+ /**
59
+ * Defines typesafe errors that implementations of this contract can throw.
60
+ *
61
+ * @see {@link https://orpc.dev/docs/contract/procedure#typesafe-errors | Procedure Contract - Typesafe Errors}
62
+ */
21
63
  errors<T extends ErrorMap>(errors: T): ProcedureContractBuilderWithOutput<TOutputSchema, MergedErrorMap<TErrorMap, T>>;
64
+ /**
65
+ * Defines the input schema used to validate and type the procedure input.
66
+ *
67
+ * @see {@link https://orpc.dev/docs/contract/procedure#inputoutput-validation | Procedure Contract - Input/Output Validation}
68
+ */
22
69
  input<T extends AnySchema>(schema: T): ProcedureContractBuilderWithInputOutput<T, TOutputSchema, TErrorMap>;
70
+ /**
71
+ * Adds an additional output schema, merged with the previously defined one.
72
+ *
73
+ * @see {@link https://orpc.dev/docs/contract/procedure#multiple-schemas | Procedure Contract - Multiple Schemas}
74
+ */
23
75
  output<T extends AnySchema>(schema: T): ProcedureContractBuilderWithOutput<MergedSchema<T, TOutputSchema>, TErrorMap>;
24
76
  }
77
+ /**
78
+ * The contract builder variant returned after both `.input` and `.output`
79
+ * are called. It is already a complete procedure contract that can still be
80
+ * refined.
81
+ *
82
+ * @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
83
+ */
25
84
  interface ProcedureContractBuilderWithInputOutput<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends ProcedureContract<TInputSchema, TOutputSchema, TErrorMap> {
85
+ /**
86
+ * Applies metadata plugins to contracts built from this builder.
87
+ *
88
+ * @see {@link https://orpc.dev/docs/contract/procedure#metadata | Procedure Contract - Metadata}
89
+ */
26
90
  meta(...plugins: MetaPlugin<TInputSchema, TOutputSchema, TErrorMap>[]): ProcedureContractBuilderWithInputOutput<TInputSchema, TOutputSchema, TErrorMap>;
91
+ /**
92
+ * Defines typesafe errors that implementations of this contract can throw.
93
+ *
94
+ * @see {@link https://orpc.dev/docs/contract/procedure#typesafe-errors | Procedure Contract - Typesafe Errors}
95
+ */
27
96
  errors<T extends ErrorMap>(errors: T): ProcedureContractBuilderWithInputOutput<TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, T>>;
97
+ /**
98
+ * Adds an additional input schema, merged with the previously defined one.
99
+ *
100
+ * @see {@link https://orpc.dev/docs/contract/procedure#multiple-schemas | Procedure Contract - Multiple Schemas}
101
+ */
28
102
  input<T extends AnySchema>(schema: T): ProcedureContractBuilderWithInputOutput<MergedSchema<T, TInputSchema>, TOutputSchema, TErrorMap>;
103
+ /**
104
+ * Adds an additional output schema, merged with the previously defined one.
105
+ *
106
+ * @see {@link https://orpc.dev/docs/contract/procedure#multiple-schemas | Procedure Contract - Multiple Schemas}
107
+ */
29
108
  output<T extends AnySchema>(schema: T): ProcedureContractBuilderWithInputOutput<TInputSchema, MergedSchema<T, TOutputSchema>, TErrorMap>;
30
109
  }
31
110
 
@@ -54,24 +133,72 @@ declare function getProcedureContractOrThrow(router: RouterContract, path: reado
54
133
  */
55
134
  declare function minifyRouterContract(router: RouterContract): RouterContract;
56
135
 
136
+ /**
137
+ * The input schema type used before `.input` is called.
138
+ * Input is `void` for better compatibility with third-party libraries,
139
+ * such as TanStack Query, which allow calling mutations without input.
140
+ */
57
141
  type InitialInputSchema = Schema<void, unknown>;
142
+ /**
143
+ * The output schema type used before `.output` is called.
144
+ */
58
145
  type InitialOutputSchema = Schema<unknown>;
146
+ /**
147
+ * The contract builder behind `oc`. Chain its methods to define procedure
148
+ * contracts — metadata, errors, and input/output schemas — without any
149
+ * business logic.
150
+ *
151
+ * @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
152
+ */
59
153
  declare class ContractBuilder<TErrorMap extends ErrorMap> extends ProcedureContract<InitialInputSchema, InitialOutputSchema, TErrorMap> {
60
154
  /**
61
155
  * Private constructor to prevent direct instantiation.
62
156
  * Use the static `create` method to initialize a new instance with a safe initial definition.
63
157
  */
64
158
  private constructor();
159
+ /**
160
+ * Creates a fresh contract builder with an empty definition.
161
+ * Prefer the exported `oc` instance over calling this directly.
162
+ *
163
+ * @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
164
+ */
65
165
  static create(): ContractBuilder<object>;
166
+ /**
167
+ * Applies metadata plugins to contracts built from this builder.
168
+ *
169
+ * @see {@link https://orpc.dev/docs/contract/procedure#metadata | Procedure Contract - Metadata}
170
+ */
66
171
  meta(...plugins: MetaPlugin<InitialInputSchema, InitialOutputSchema, TErrorMap>[]): ContractBuilder<TErrorMap>;
172
+ /**
173
+ * Defines typesafe errors that implementations of this contract can throw.
174
+ *
175
+ * @see {@link https://orpc.dev/docs/contract/procedure#typesafe-errors | Procedure Contract - Typesafe Errors}
176
+ */
67
177
  errors<T extends ErrorMap>(errors: T): ContractBuilder<MergedErrorMap<TErrorMap, T>>;
178
+ /**
179
+ * Defines the input schema used to validate and type the procedure input.
180
+ *
181
+ * @see {@link https://orpc.dev/docs/contract/procedure#inputoutput-validation | Procedure Contract - Input/Output Validation}
182
+ */
68
183
  input<T extends AnySchema>(schema: T): ProcedureContractBuilderWithInput<T, TErrorMap>;
184
+ /**
185
+ * Defines the output schema used to validate and type the procedure output.
186
+ *
187
+ * @see {@link https://orpc.dev/docs/contract/procedure#inputoutput-validation | Procedure Contract - Input/Output Validation}
188
+ */
69
189
  output<T extends AnySchema>(schema: T): ProcedureContractBuilderWithOutput<T, TErrorMap>;
190
+ /**
191
+ * Applies the builder's errors and metadata to every procedure contract in
192
+ * the given router contract.
193
+ *
194
+ * @see {@link https://orpc.dev/docs/contract/router#extending-router | Router Contract - Extending Router}
195
+ */
70
196
  router<T extends RouterContract>(router: T): AugmentedContractRouter<T, TErrorMap>;
71
197
  }
72
198
  /**
73
- * The contract builder the entry point for defining procedure and router contracts
74
- * (input/output schemas, errors, and metadata) without any business logic.
199
+ * The oRPC contract builder. Chain methods like `.input`, `.errors`, and
200
+ * `.output` to define procedure contracts, then compose them into router
201
+ * contracts.
75
202
  *
76
203
  * @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
77
204
  */
@@ -303,4 +430,4 @@ declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutp
303
430
  declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
304
431
 
305
432
  export { AnyProcedureContract as AnyContractProcedure, RouterContract as AnyContractRouter, AnyMetaPlugin, AnyProcedureContract, AnySchema, ContractBuilder, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedSchema, Meta, MetaPlugin, ORPCErrorFromErrorMap, ProcedureContract, RouterContract, Schema, SchemaIssue, asyncIteratorObject, augmentContractRouter, createContractClientFactory, createORPCErrorConstructorMap, defineMeta, error, asyncIteratorObject as eventIterator, getAsyncIteratorObjectSchemaDetails, getRouterContract as getContractRouter, getPathMeta, getProcedureContractOrThrow, getRouterContract, isSchemaIssue, mergeErrorMap, meta, minifyRouterContract as minifyContractRouter, minifyRouterContract, oc, reconcileORPCError, resolveBasePathMeta, resolveMetaPlugins, type };
306
- export type { AsyncIteratorObjectSchemaDetails, AugmentContractRouterOptions, AugmentedContractRouter, ContractClientFactory, ContractClientFactoryOptions, InitialInputSchema, InitialOutputSchema, MergedErrorMap, ORPCErrorConstructorMap, ORPCErrorConstructorMapItem, ORPCErrorConstructorMapItemOptions, ORPCErrorFactory, ORPCErrorFactoryOptions, PathMetaPlugin, ProcedureContractBuilderWithInput, ProcedureContractBuilderWithInputOutput, ProcedureContractBuilderWithOutput, ProcedureContractClient, RouterContractClient, TypeRest };
433
+ export type { AsyncIteratorObjectSchemaDetails, AugmentContractRouterOptions, AugmentedContractRouter, ContractClientFactory, ContractClientFactoryOptions, RouterContractClient as ContractRouterClient, InitialInputSchema, InitialOutputSchema, MergedErrorMap, ORPCErrorConstructorMap, ORPCErrorConstructorMapItem, ORPCErrorConstructorMapItemOptions, ORPCErrorFactory, ORPCErrorFactoryOptions, PathMetaPlugin, ProcedureContractBuilderWithInput, ProcedureContractBuilderWithInputOutput, ProcedureContractBuilderWithOutput, ProcedureContractClient, RouterContractClient, TypeRest };
package/dist/index.mjs CHANGED
@@ -22,12 +22,23 @@ class ContractBuilder extends ProcedureContract {
22
22
  constructor(definition) {
23
23
  super(definition);
24
24
  }
25
+ /**
26
+ * Creates a fresh contract builder with an empty definition.
27
+ * Prefer the exported `oc` instance over calling this directly.
28
+ *
29
+ * @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
30
+ */
25
31
  static create() {
26
32
  return new ContractBuilder({
27
33
  errorMap: {},
28
34
  meta: {}
29
35
  });
30
36
  }
37
+ /**
38
+ * Applies metadata plugins to contracts built from this builder.
39
+ *
40
+ * @see {@link https://orpc.dev/docs/contract/procedure#metadata | Procedure Contract - Metadata}
41
+ */
31
42
  meta(...plugins) {
32
43
  const [meta, metaPlugins] = resolveMetaPlugins(
33
44
  this["~orpc"].meta,
@@ -40,6 +51,11 @@ class ContractBuilder extends ProcedureContract {
40
51
  metaPlugins
41
52
  });
42
53
  }
54
+ /**
55
+ * Defines typesafe errors that implementations of this contract can throw.
56
+ *
57
+ * @see {@link https://orpc.dev/docs/contract/procedure#typesafe-errors | Procedure Contract - Typesafe Errors}
58
+ */
43
59
  errors(errors) {
44
60
  let result = new ContractBuilder({
45
61
  ...this["~orpc"],
@@ -51,6 +67,11 @@ class ContractBuilder extends ProcedureContract {
51
67
  }
52
68
  return result;
53
69
  }
70
+ /**
71
+ * Defines the input schema used to validate and type the procedure input.
72
+ *
73
+ * @see {@link https://orpc.dev/docs/contract/procedure#inputoutput-validation | Procedure Contract - Input/Output Validation}
74
+ */
54
75
  input(schema) {
55
76
  let result = new ContractBuilder({
56
77
  ...this["~orpc"],
@@ -62,6 +83,11 @@ class ContractBuilder extends ProcedureContract {
62
83
  }
63
84
  return result;
64
85
  }
86
+ /**
87
+ * Defines the output schema used to validate and type the procedure output.
88
+ *
89
+ * @see {@link https://orpc.dev/docs/contract/procedure#inputoutput-validation | Procedure Contract - Input/Output Validation}
90
+ */
65
91
  output(schema) {
66
92
  let result = new ContractBuilder({
67
93
  ...this["~orpc"],
@@ -73,6 +99,12 @@ class ContractBuilder extends ProcedureContract {
73
99
  }
74
100
  return result;
75
101
  }
102
+ /**
103
+ * Applies the builder's errors and metadata to every procedure contract in
104
+ * the given router contract.
105
+ *
106
+ * @see {@link https://orpc.dev/docs/contract/router#extending-router | Router Contract - Extending Router}
107
+ */
76
108
  router(router) {
77
109
  return augmentContractRouter(router, this["~orpc"]);
78
110
  }
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@orpc/contract",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.24",
4
+ "version": "2.0.0-beta.26",
5
5
  "license": "MIT",
6
+ "funding": "https://github.com/sponsors/dinwwwh",
6
7
  "homepage": "https://orpc.dev",
7
8
  "repository": {
8
9
  "type": "git",
@@ -31,8 +32,8 @@
31
32
  ],
32
33
  "dependencies": {
33
34
  "@standard-schema/spec": "^1.1.0",
34
- "@orpc/client": "2.0.0-beta.24",
35
- "@orpc/shared": "2.0.0-beta.24"
35
+ "@orpc/client": "2.0.0-beta.26",
36
+ "@orpc/shared": "2.0.0-beta.26"
36
37
  },
37
38
  "devDependencies": {
38
39
  "arktype": "^2.2.1",