@orpc/contract 2.0.0-beta.46 → 2.0.0-beta.48

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/README.md +6 -4
  2. package/dist/builder-variants.d.mts +113 -0
  3. package/dist/builder-variants.mjs +1 -0
  4. package/dist/builder.d.mts +78 -0
  5. package/dist/builder.mjs +71 -0
  6. package/dist/client-factory.d.mts +24 -0
  7. package/dist/client-factory.mjs +34 -0
  8. package/dist/error-factory.d.mts +87 -0
  9. package/dist/error-factory.mjs +75 -0
  10. package/dist/error-utils.d.mts +11 -0
  11. package/dist/error-utils.mjs +43 -0
  12. package/dist/error.d.mts +41 -0
  13. package/dist/error.mjs +12 -0
  14. package/dist/index.d.mts +62 -433
  15. package/dist/index.mjs +25 -342
  16. package/dist/meta-built-in.d.mts +38 -0
  17. package/dist/meta-built-in.mjs +40 -0
  18. package/dist/meta-utils.d.mts +62 -0
  19. package/dist/meta-utils.mjs +33 -0
  20. package/dist/meta.d.mts +61 -0
  21. package/dist/meta.mjs +11 -0
  22. package/dist/plugins/index.d.mts +10 -45
  23. package/dist/plugins/index.mjs +6 -89
  24. package/dist/plugins/request-validation.d.mts +28 -0
  25. package/dist/plugins/request-validation.mjs +46 -0
  26. package/dist/plugins/response-validation.d.mts +15 -0
  27. package/dist/plugins/response-validation.mjs +53 -0
  28. package/dist/procedure-client.d.mts +10 -0
  29. package/dist/procedure-client.mjs +1 -0
  30. package/dist/procedure.d.mts +36 -0
  31. package/dist/procedure.mjs +19 -0
  32. package/dist/router-client.d.mts +14 -0
  33. package/dist/router-client.mjs +1 -0
  34. package/dist/router-utils.d.mts +34 -0
  35. package/dist/router-utils.mjs +67 -0
  36. package/dist/router.d.mts +42 -0
  37. package/dist/router.mjs +1 -0
  38. package/dist/schema-built-in.d.mts +28 -0
  39. package/dist/schema-built-in.mjs +73 -0
  40. package/dist/schema-utils.d.mts +26 -0
  41. package/dist/schema-utils.mjs +29 -0
  42. package/dist/schema.d.mts +31 -0
  43. package/dist/schema.mjs +1 -0
  44. package/package.json +4 -4
  45. package/dist/index.d.ts +0 -433
  46. package/dist/plugins/index.d.ts +0 -47
  47. package/dist/shared/contract.CM62dTQK.d.mts +0 -202
  48. package/dist/shared/contract.CM62dTQK.d.ts +0 -202
  49. package/dist/shared/contract.T7BNVKJ4.mjs +0 -177
package/dist/index.d.mts CHANGED
@@ -1,433 +1,62 @@
1
- import { E as ErrorMap, A as AnySchema, P as ProcedureContract, M as MetaPlugin, a as MergedSchema, b as Meta, c as AnyMetaPlugin, R as RouterContract, d as AnyProcedureContract, S as Schema, I as InferSchemaInput, e as InferSchemaOutput, O as ORPCErrorFromErrorMap, f as ErrorMapItem, g as SchemaIssue } from './shared/contract.CM62dTQK.mjs';
2
- export { h as InferContractRouterErrorMap, i as InferContractRouterInputs, j as InferContractRouterOutputs, k as InferRouterContractError, h as InferRouterContractErrorMap, l as InferRouterContractErrors, i as InferRouterContractInputs, j as InferRouterContractOutputs, m as MetaPluginDefinition, n as ProcedureContractDefinition, V as ValidationError, o as ValidationErrorOptions, p as getHiddenMetaPlugins, s as setHiddenMetaPlugins } from './shared/contract.CM62dTQK.mjs';
3
- import { AnyORPCError, ClientContext, Client, ORPCClientOptions, ClientLink, ORPCErrorCode, ORPCErrorOptions, ORPCError } from '@orpc/client';
4
- export { Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions } from '@orpc/client';
5
- import { ThrowableError, MaybeOptionalOptions, AsyncIteratorClass, Promisable, IsEqual } from '@orpc/shared';
6
- export { AsyncIteratorClass, PromiseWithError, Registry, ThrowableError } from '@orpc/shared';
7
- import '@standard-schema/spec';
8
-
9
- type MergedErrorMap<T1 extends ErrorMap, T2 extends ErrorMap> = keyof T1 extends never | keyof T2 ? T2 : Omit<T1, keyof T2> & T2;
10
- declare function mergeErrorMap<T1 extends ErrorMap = object, T2 extends ErrorMap = object>(errorMap1: T1 | undefined, errorMap2: T2 | undefined): MergedErrorMap<T1, T2>;
11
- declare function reconcileORPCError(map: ErrorMap, error: AnyORPCError): Promise<AnyORPCError>;
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
- */
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
- */
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
- */
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
- */
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
- */
43
- output<T extends AnySchema>(schema: T): ProcedureContractBuilderWithInputOutput<TInputSchema, T, TErrorMap>;
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
- */
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
- */
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
- */
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
- */
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
- */
75
- output<T extends AnySchema>(schema: T): ProcedureContractBuilderWithOutput<MergedSchema<T, TOutputSchema>, TErrorMap>;
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
- */
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
- */
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
- */
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
- */
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
- */
108
- output<T extends AnySchema>(schema: T): ProcedureContractBuilderWithInputOutput<TInputSchema, MergedSchema<T, TOutputSchema>, TErrorMap>;
109
- }
110
-
111
- type AugmentedContractRouter<T extends RouterContract, TErrorMap extends ErrorMap> = T extends ProcedureContract<infer $InputSchema, infer $OutputSchema, infer $Errors> ? ProcedureContract<$InputSchema, $OutputSchema, MergedErrorMap<TErrorMap, $Errors>> : {
112
- [K in keyof T]: T[K] extends RouterContract ? AugmentedContractRouter<T[K], TErrorMap> : never;
113
- };
114
- interface AugmentContractRouterOptions<TErrorMap extends ErrorMap> {
115
- meta: Meta;
116
- metaPlugins?: AnyMetaPlugin[] | undefined;
117
- errorMap: TErrorMap;
118
- }
119
- declare function getRouterContract(router: RouterContract, path: readonly string[]): RouterContract | undefined;
120
- declare function getProcedureContractOrThrow(router: RouterContract, path: readonly string[]): AnyProcedureContract;
121
- /**
122
- * Minifies a router contract so it can be safely exported to the client
123
- * without exposing internal logic.
124
- *
125
- * @remarks
126
- * **Note**: Only the metadata needed by the client is preserved; all other data is stripped out.
127
- *
128
- * @see {@link https://orpc.dev/docs/contract/router | Router Contract}
129
- */
130
- declare function minifyRouterContract(router: RouterContract): RouterContract;
131
-
132
- /**
133
- * The input schema type used before `.input` is called.
134
- * Input is `void` for better compatibility with third-party libraries,
135
- * such as TanStack Query, which allow calling mutations without input.
136
- */
137
- type InitialInputSchema = Schema<void, unknown>;
138
- /**
139
- * The output schema type used before `.output` is called.
140
- */
141
- type InitialOutputSchema = Schema<unknown>;
142
- /**
143
- * The contract builder behind `oc`. Chain its methods to define procedure
144
- * contracts — metadata, errors, and input/output schemas — without any
145
- * business logic.
146
- *
147
- * @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
148
- */
149
- declare class ContractBuilder<TErrorMap extends ErrorMap> extends ProcedureContract<InitialInputSchema, InitialOutputSchema, TErrorMap> {
150
- /**
151
- * Private constructor to prevent direct instantiation.
152
- * Use the static `create` method to initialize a new instance with a safe initial definition.
153
- */
154
- private constructor();
155
- /**
156
- * Creates a fresh contract builder with an empty definition.
157
- * Prefer the exported `oc` instance over calling this directly.
158
- *
159
- * @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
160
- */
161
- static create(): ContractBuilder<Record<never, never>>;
162
- /**
163
- * Applies metadata plugins to contracts built from this builder.
164
- *
165
- * @see {@link https://orpc.dev/docs/contract/procedure#metadata | Procedure Contract - Metadata}
166
- */
167
- meta(...plugins: MetaPlugin<InitialInputSchema, InitialOutputSchema, TErrorMap>[]): ContractBuilder<TErrorMap>;
168
- /**
169
- * Defines typesafe errors that implementations of this contract can throw.
170
- *
171
- * @see {@link https://orpc.dev/docs/contract/procedure#typesafe-errors | Procedure Contract - Typesafe Errors}
172
- */
173
- errors<T extends ErrorMap>(errors: T): ContractBuilder<MergedErrorMap<TErrorMap, T>>;
174
- /**
175
- * Defines the input schema used to validate and type the procedure input.
176
- *
177
- * @see {@link https://orpc.dev/docs/contract/procedure#inputoutput-validation | Procedure Contract - Input/Output Validation}
178
- */
179
- input<T extends AnySchema>(schema: T): ProcedureContractBuilderWithInput<T, TErrorMap>;
180
- /**
181
- * Defines the output schema used to validate and type the procedure output.
182
- *
183
- * @see {@link https://orpc.dev/docs/contract/procedure#inputoutput-validation | Procedure Contract - Input/Output Validation}
184
- */
185
- output<T extends AnySchema>(schema: T): ProcedureContractBuilderWithOutput<T, TErrorMap>;
186
- /**
187
- * Applies the builder's errors and metadata to every procedure contract in
188
- * the given router contract.
189
- *
190
- * @see {@link https://orpc.dev/docs/contract/router#extending-router | Router Contract - Extending Router}
191
- */
192
- router<T extends RouterContract>(router: T): AugmentedContractRouter<T, TErrorMap>;
193
- }
194
- /**
195
- * The oRPC contract builder. Chain methods like `.input`, `.errors`, and
196
- * `.output` to define procedure contracts, then compose them into router
197
- * contracts.
198
- *
199
- * @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
200
- */
201
- declare const oc: ContractBuilder<Record<never, never>>;
202
-
203
- type ProcedureContractClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ORPCErrorFromErrorMap<TErrorMap> | ThrowableError>;
204
-
205
- /**
206
- * Client type inferred from a router contract, preserving its shape.
207
- * Useful for typing a client without importing the server router.
208
- *
209
- * @see {@link https://orpc.dev/docs/client/client-side | Client-Side Clients}
210
- */
211
- type RouterContractClient<TRouter extends RouterContract, TClientContext extends ClientContext = object> = TRouter extends ProcedureContract<infer UInputSchema, infer UOutputSchema, infer UErrorMap> ? ProcedureContractClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
212
- [K in keyof TRouter]: TRouter[K] extends RouterContract ? RouterContractClient<TRouter[K], TClientContext> : never;
213
- };
214
-
215
- interface ContractClientFactory<TClientContext extends ClientContext> {
216
- <T extends RouterContract>(contract: T): RouterContractClient<T, TClientContext>;
217
- }
218
- interface ContractClientFactoryOptions<TClientContext extends ClientContext> extends Pick<ORPCClientOptions<RouterContractClient<RouterContract, TClientContext>>, 'interceptors' | 'scoped'> {
219
- /**
220
- * An optional reference to the root router-contract.
221
- * When provided, the client factory will automatically register the passed contract
222
- * into the router at the path defined by `meta.path`.
223
- */
224
- contractRef?: RouterContract | undefined;
225
- }
226
- /**
227
- * Creates a client factory that builds a client from any procedure or router contract,
228
- * so large projects can import individual contracts instead of a single root client.
229
- *
230
- * @remarks
231
- * **Warning**: Every procedure contract passed to the factory must define `meta.path` matching its location in the root contract.
232
- *
233
- * @see {@link https://orpc.dev/docs/contract/client-factory | Contract Client Factory}
234
- */
235
- declare function createContractClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractClientFactoryOptions<TClientContext>): ContractClientFactory<TClientContext>;
236
-
237
- interface ORPCErrorFactoryOptions<TData> {
238
- /**
239
- * Optional schema used to type and validate the error data.
240
- * Must be a synchronous schema.
241
- */
242
- data?: Schema<TData> | undefined;
243
- /**
244
- * Optional default message, can be overridden when constructing an error.
245
- */
246
- message?: string | undefined;
247
- }
248
- interface ORPCErrorFactory<TCode extends ORPCErrorCode, TData> extends ErrorMapItem {
249
- code: TCode;
250
- data: Schema<TData>;
251
- new (...rest: MaybeOptionalOptions<ORPCErrorOptions<TData>>): ORPCError<TCode, TData>;
252
- }
253
- /**
254
- * Creates a reusable error class ({@link ORPCErrorFactory}) for the given code,
255
- * default message, and data schema.
256
- *
257
- * @example
258
- * ```ts
259
- * const RateLimitedError = error('RATE_LIMITED', {
260
- * message: 'You are being rate limited',
261
- * data: z.object({ retryAfter: z.number() }),
262
- * })
263
- *
264
- * const procedure = os
265
- * .errors({ [RateLimitedError.code]: RateLimitedError })
266
- * .handler(() => {
267
- * throw new RateLimitedError({ data: { retryAfter: 60 } })
268
- * })
269
- *
270
- * try {
271
- * const output = call(procedure)
272
- * } catch (error) {
273
- * if (error instanceof RateLimitedError) {
274
- * console.log(error.data.retryAfter)
275
- * }
276
- * }
277
- * ```
278
- *
279
- * @see {@link https://orpc.dev/docs/error-handling#error-factory | Error Handling - Error Factory}
280
- */
281
- declare function error<TCode extends ORPCErrorCode, TData = unknown>(code: TCode, { data: dataSchema, message }?: ORPCErrorFactoryOptions<TData>): ORPCErrorFactory<TCode, TData>;
282
- type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'status'>;
283
- interface ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> {
284
- (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>): ORPCError<TCode, TInData>;
285
- }
286
- type ORPCErrorConstructorMap<T extends ErrorMap> = {
287
- [K in keyof T]: T[K] extends ErrorMapItem ? ORPCErrorConstructorMapItem<K & ORPCErrorCode, T[K]['data'] extends AnySchema ? InferSchemaInput<T[K]['data']> : unknown> : never;
288
- };
289
- /**
290
- * Creates a map of ORPC error constructors.
291
- *
292
- * The returned object is a `Proxy` that allows access to arbitrary error codes:
293
- * - If the code exists in the provided `errorMap`, the corresponding constructor
294
- * will create a **defined** `ORPCError`.
295
- * - If the code does not exist, a fallback `ORPCError` constructor is returned.
296
- *
297
- * The `in` operator can be used to check whether an error code is explicitly
298
- * defined in the map.
299
- *
300
- * @example
301
- * ```ts
302
- * const errorMap = createORPCErrorConstructorMap({
303
- * NOT_FOUND: {
304
- * message: 'Not Found',
305
- * },
306
- * })
307
- *
308
- * throw errorMap.NOT_FOUND()
309
- * ```
310
- */
311
- declare function createORPCErrorConstructorMap<T extends ErrorMap>(errorMap: T): ORPCErrorConstructorMap<T>;
312
-
313
- interface PathMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
314
- name: '~path';
315
- }
316
- /**
317
- * Built-in metadata plugins.
318
- * `meta.path` records a procedure contract's path inside the root contract,
319
- * which is required for the contract client factory pattern.
320
- *
321
- * @see {@link https://orpc.dev/docs/contract/client-factory | Contract Client Factory}
322
- */
323
- declare const meta: {
324
- path<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(path: string[]): PathMetaPlugin<TInputSchema, TOutputSchema, TErrorMap>;
325
- };
326
- declare function getPathMeta(procedureOrLazy: {
327
- '~orpc': {
328
- meta: Meta;
329
- };
330
- }): string[] | undefined;
331
- /**
332
- * Resolve the base path of a contract from the first procedure-contract
333
- * that defines `meta.path`: its `meta.path` minus its path inside the given contract.
334
- * For a procedure-contract, this is its `meta.path` itself.
335
- *
336
- * Returns `undefined` when no procedure-contract defines `meta.path`.
337
- */
338
- declare function resolveBasePathMeta(contract: RouterContract, currentPath?: string[]): string[] | undefined;
339
-
340
- declare function resolveMetaPlugins<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap>(baseMeta: Meta, existingPlugins: MetaPlugin<TInputSchema, TOutputSchema, TErrorMap>[] | undefined, incomingPlugins: MetaPlugin<TInputSchema, TOutputSchema, TErrorMap>[] | undefined): [meta: Meta, plugins: MetaPlugin<TInputSchema, TOutputSchema, TErrorMap>[]];
341
- /**
342
- * Quickly defines a meta plugin factory and reader.
343
- *
344
- * @example Mark a procedure as requiring authentication and read it in middleware.
345
- * ```ts
346
- * interface AuthMeta {
347
- * required?: boolean
348
- * scope?: 'user' | 'admin'
349
- * }
350
- *
351
- * const [authMeta, getAuthMeta] = defineMeta(
352
- * 'auth',
353
- * (incoming: AuthMeta, current) => ({ ...current, ...incoming }),
354
- * )
355
- *
356
- * const deletePostContract = oc
357
- * .meta(authMeta({ required: true, scope: 'admin' }))
358
- * .input(z.object({ postId: z.string() }))
359
- * .output(z.object({ success: z.boolean() }))
360
- *
361
- * const authMiddleware = os.middleware(async ({ context, procedure, next }) => {
362
- * const auth = getAuthMeta(procedure)
363
- *
364
- * if (auth?.required && !context.user) {
365
- * throw new ORPCError('UNAUTHORIZED')
366
- * }
367
- *
368
- * if (auth?.scope === 'admin' && !context.user?.isAdmin) {
369
- * throw new ORPCError('FORBIDDEN')
370
- * }
371
- *
372
- * return next()
373
- * })
374
- * ```
375
- *
376
- * @param name - Unique key for storing this meta entry.
377
- * @param merge - Merges the existing value (or `undefined`) with the incoming value when applied multiple times.
378
- *
379
- * @returns A `[metaPlugin, getMeta]` tuple:
380
- * - `metaPlugin(metadata)` - Attaches metadata to a procedure under `name`.
381
- * - `getMeta(procedureOrLazy)` - Retrieves the metadata, or `undefined` if not set.
382
- *
383
- * @see {@link https://orpc.dev/docs/metadata | Metadata}
384
- */
385
- declare function defineMeta<TName extends string, TData>(name: TName, merge: (incoming: TData, current: TData | undefined) => TData): [
386
- metaPlugin: (meta: TData) => AnyMetaPlugin & {
387
- name: TName;
388
- },
389
- getMeta: (procedureOrLazy: {
390
- '~orpc': {
391
- meta: Meta;
392
- };
393
- }) => TData | undefined
394
- ];
395
-
396
- /**
397
- * Defines a schema for an AsyncIteratorObject, validating each yielded value
398
- * (and optionally the return value) with the given schemas.
399
- *
400
- * @see {@link https://orpc.dev/docs/async-iterator-object | AsyncIteratorObject (SSE)}
401
- */
402
- declare function asyncIteratorObject<TYieldIn, TYieldOut, TReturnIn = unknown, TReturnOut = unknown>(yieldSchema: Schema<TYieldIn, TYieldOut>, returnSchema?: Schema<TReturnIn, TReturnOut>): Schema<AsyncIteratorObject<TYieldIn, TReturnIn, void>, AsyncIteratorClass<TYieldOut, TReturnOut, void>>;
403
- interface AsyncIteratorObjectSchemasDetails {
404
- yieldSchemas: AnySchema[];
405
- returnSchemas: AnySchema[];
406
- }
407
- /**
408
- * Collects the yield and return schemas of multiple schemas, such as the `.output` schemas of a procedure,
409
- * or returns `undefined` when there are none or any of them does not describe an AsyncIteratorObject.
410
- */
411
- declare function getAsyncIteratorObjectSchemasDetails(schemas: readonly AnySchema[] | undefined): undefined | AsyncIteratorObjectSchemasDetails;
412
-
413
- type TypeRest<TInput, TOutput> = [map: (input: TInput) => Promisable<TOutput>] | (IsEqual<TInput, TOutput> extends true ? [] : never);
414
- /**
415
- * Create a schema for things can be trust without validation.
416
- * You can optionally pass a map function for mapping
417
- *
418
- * @example
419
- * ```ts
420
- * const normal = type<number>()
421
- * const withMap = type<number, string>(input => input.toString())
422
- *```
423
- *
424
- * @see {@link https://orpc.dev/docs/procedure#type-utility | Procedure - type Utility}
425
- */
426
- declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutput>): Schema<TInput, TOutput>;
427
- /**
428
- * Check if the given issue is following the standard-schema issue format.
429
- */
430
- declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
431
-
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, createContractClientFactory, createORPCErrorConstructorMap, defineMeta, error, asyncIteratorObject as eventIterator, getAsyncIteratorObjectSchemasDetails, getRouterContract as getContractRouter, getPathMeta, getProcedureContractOrThrow, getRouterContract, isSchemaIssue, mergeErrorMap, meta, minifyRouterContract as minifyContractRouter, minifyRouterContract, oc, reconcileORPCError, resolveBasePathMeta, resolveMetaPlugins, type };
433
- export type { AsyncIteratorObjectSchemasDetails, AugmentContractRouterOptions, AugmentedContractRouter, ContractClientFactory, ContractClientFactoryOptions, RouterContractClient as ContractRouterClient, InitialInputSchema, InitialOutputSchema, MergedErrorMap, ORPCErrorConstructorMap, ORPCErrorConstructorMapItem, ORPCErrorConstructorMapItemOptions, ORPCErrorFactory, ORPCErrorFactoryOptions, PathMetaPlugin, ProcedureContractBuilderWithInput, ProcedureContractBuilderWithInputOutput, ProcedureContractBuilderWithOutput, ProcedureContractClient, RouterContractClient, TypeRest };
1
+ export * from "./builder.mjs";
2
+ export * from "./builder-variants.mjs";
3
+ export * from "./client-factory.mjs";
4
+ export * from "./error.mjs";
5
+ export * from "./error-factory.mjs";
6
+ export * from "./error-utils.mjs";
7
+ export * from "./meta.mjs";
8
+ export * from "./meta-built-in.mjs";
9
+ export * from "./meta-utils.mjs";
10
+ export * from "./procedure.mjs";
11
+ export type {
12
+ /**
13
+ * @deprecated Use `AnyProcedureContract` instead.
14
+ */
15
+ AnyProcedureContract as AnyContractProcedure } from "./procedure.mjs";
16
+ export * from "./procedure-client.mjs";
17
+ export * from "./router.mjs";
18
+ export type {
19
+ /**
20
+ * @deprecated Use `RouterContract` instead.
21
+ */
22
+ RouterContract as AnyContractRouter,
23
+ /**
24
+ * @deprecated Use `InferRouterContractErrorMap` instead.
25
+ */
26
+ InferRouterContractErrorMap as InferContractRouterErrorMap,
27
+ /**
28
+ * @deprecated Use `InferRouterContractInputs` instead.
29
+ */
30
+ InferRouterContractInputs as InferContractRouterInputs,
31
+ /**
32
+ * @deprecated Use `InferRouterContractOutputs` instead.
33
+ */
34
+ InferRouterContractOutputs as InferContractRouterOutputs } from "./router.mjs";
35
+ export * from "./router-client.mjs";
36
+ export type {
37
+ /**
38
+ * @deprecated Use `RouterContractClient` instead.
39
+ */
40
+ RouterContractClient as ContractRouterClient } from "./router-client.mjs";
41
+ export { getProcedureContractOrThrow, getRouterContract, minifyRouterContract } from "./router-utils.mjs";
42
+ export type { AugmentContractRouterOptions, AugmentedContractRouter } from "./router-utils.mjs";
43
+ export {
44
+ /**
45
+ * @deprecated Use `getRouterContract` instead.
46
+ */
47
+ getRouterContract as getContractRouter,
48
+ /**
49
+ * @deprecated Use `minifyRouterContract` instead.
50
+ */
51
+ minifyRouterContract as minifyContractRouter } from "./router-utils.mjs";
52
+ export * from "./schema.mjs";
53
+ export { asyncIteratorObject, getAsyncIteratorObjectSchemasDetails } from "./schema-built-in.mjs";
54
+ export type { AsyncIteratorObjectSchemasDetails } from "./schema-built-in.mjs";
55
+ export {
56
+ /**
57
+ * @deprecated Use `asyncIteratorObject` instead.
58
+ */
59
+ asyncIteratorObject as eventIterator } from "./schema-built-in.mjs";
60
+ export * from "./schema-utils.mjs";
61
+ export type { Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions } from "@orpc/client";
62
+ export type { AsyncIteratorClass, PromiseWithError, Registry, ThrowableError } from "@orpc/shared";