@orpc/contract 2.0.0-beta.18 → 2.0.0-beta.19
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/README.md +5 -2
- package/dist/index.d.mts +17 -9
- package/dist/index.d.ts +17 -9
- package/dist/index.mjs +44 -14
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -49,11 +49,14 @@ You can read the documentation [here](https://orpc.dev).
|
|
|
49
49
|
**Framework & ecosystem integrations**
|
|
50
50
|
|
|
51
51
|
- [@orpc/next](https://www.npmjs.com/package/@orpc/next): Integrate with [Next.js Server Functions](https://nextjs.org/docs/app/getting-started/mutating-data).
|
|
52
|
+
- [@orpc/ai-sdk](https://www.npmjs.com/package/@orpc/ai-sdk): Turn contracts and procedures into [AI SDK](https://ai-sdk.dev/) tools.
|
|
52
53
|
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): Integrate with [TanStack Query](https://tanstack.com/query/latest).
|
|
54
|
+
- [@orpc/pinia-colada](https://www.npmjs.com/package/@orpc/pinia-colada): Integrate with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
53
55
|
- [@orpc/experimental-effect](https://www.npmjs.com/package/@orpc/experimental-effect): Integrate with [Effect](https://effect.website/).
|
|
54
56
|
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Implement your contract with [NestJS](https://nestjs.com/).
|
|
55
57
|
- [@orpc/bun](https://www.npmjs.com/package/@orpc/bun): Adapters for [Bun's Redis](https://bun.sh/).
|
|
56
58
|
- [@orpc/cloudflare](https://www.npmjs.com/package/@orpc/cloudflare): Adapters for [Cloudflare's RateLimit and Durable Objects](https://developers.cloudflare.com/workers/).
|
|
59
|
+
- [@orpc/trpc](https://www.npmjs.com/package/@orpc/trpc): Reuse existing [tRPC](https://trpc.io/) routers within oRPC.
|
|
57
60
|
|
|
58
61
|
**Observability**
|
|
59
62
|
|
|
@@ -105,11 +108,10 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
105
108
|
<td align="center"><a href="https://github.com/valerii15298?ref=orpc" target="_blank" rel="noopener" title="Valerii Petryniak"><img src="https://avatars.githubusercontent.com/u/44531564?u=88ac74d9bacd20401518441907acad21063cd397&v=4" width="139" alt="Valerii Petryniak"/><br />Valerii Petryniak</a></td>
|
|
106
109
|
<td align="center"><a href="https://github.com/letstri?ref=orpc" target="_blank" rel="noopener" title="Valerii Strilets"><img src="https://avatars.githubusercontent.com/u/13253748?u=c7b10399ccc8f8081e24db94ec32cd9858e86ac3&v=4" width="139" alt="Valerii Strilets"/><br />Valerii Strilets</a></td>
|
|
107
110
|
<td align="center"><a href="https://github.com/K-Mistele?ref=orpc" target="_blank" rel="noopener" title="Kyle Mistele"><img src="https://avatars.githubusercontent.com/u/18430555?u=3afebeb81de666e35aaac3ed46f14159d7603ffb&v=4" width="139" alt="Kyle Mistele"/><br />Kyle Mistele</a></td>
|
|
108
|
-
<td align="center"><a href="https://github.com/andrewpeters9?ref=orpc" target="_blank" rel="noopener" title="Andrew Peters"><img src="https://avatars.githubusercontent.com/u/36251325?v=4" width="139" alt="Andrew Peters"/><br />Andrew Peters</a></td>
|
|
109
111
|
<td align="center"><a href="https://github.com/R44VC0RP?ref=orpc" target="_blank" rel="noopener" title="Ryan Vogel"><img src="https://avatars.githubusercontent.com/u/89211796?u=1857347b9787d8d8a7ea5bfc333f96be92d5a683&v=4" width="139" alt="Ryan Vogel"/><br />Ryan Vogel</a></td>
|
|
112
|
+
<td align="center"><a href="https://github.com/christ12938?ref=orpc" target="_blank" rel="noopener" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="139" alt="christ12938"/><br />christ12938</a></td>
|
|
110
113
|
</tr>
|
|
111
114
|
<tr>
|
|
112
|
-
<td align="center"><a href="https://github.com/christ12938?ref=orpc" target="_blank" rel="noopener" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="139" alt="christ12938"/><br />christ12938</a></td>
|
|
113
115
|
<td align="center"><a href="https://github.com/Ryanjso?ref=orpc" target="_blank" rel="noopener" title="Ryan Soderberg"><img src="https://avatars.githubusercontent.com/u/39172778?u=5ed913c31d57e7221b75784abcad48c7ebddde27&v=4" width="139" alt="Ryan Soderberg"/><br />Ryan Soderberg</a></td>
|
|
114
116
|
<td align="center"><a href="https://github.com/itigoore01?ref=orpc" target="_blank" rel="noopener" title="shota"><img src="https://avatars.githubusercontent.com/u/11831107?u=c976a6dc7e055eb026304c46c99100ed22b0c8e0&v=4" width="139" alt="shota"/><br />shota</a></td>
|
|
115
117
|
</tr>
|
|
@@ -169,6 +171,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
169
171
|
<a href="https://github.com/nelsonlaidev?ref=orpc" target="_blank" rel="noopener" title="Nelson Lai"><img src="https://avatars.githubusercontent.com/u/75498339?u=2fc0e0b95dd184c5ffb744df977cb15a18b60672&v=4" width="32" height="32" alt="Nelson Lai" /></a>
|
|
170
172
|
<a href="https://github.com/nguyenlc1993?ref=orpc" target="_blank" rel="noopener" title="Lê Cao Nguyên"><img src="https://avatars.githubusercontent.com/u/13871971?u=83c8b69d9e35b589c4e1f066cc113b1d9461386f&v=4" width="32" height="32" alt="Lê Cao Nguyên" /></a>
|
|
171
173
|
<a href="https://github.com/wobsoriano?ref=orpc" target="_blank" rel="noopener" title="Robert Soriano"><img src="https://avatars.githubusercontent.com/u/13049130?u=6d72104182e7c9ed25934815313fb69107332111&v=4" width="32" height="32" alt="Robert Soriano" /></a>
|
|
174
|
+
<a href="https://github.com/andrewpeters9?ref=orpc" target="_blank" rel="noopener" title="Andrew Peters"><img src="https://avatars.githubusercontent.com/u/36251325?v=4" width="32" height="32" alt="Andrew Peters" /></a>
|
|
172
175
|
<a href="https://github.com/SKostyukovich?ref=orpc" target="_blank" rel="noopener" title="SKostyukovich"><img src="https://avatars.githubusercontent.com/u/10700067?v=4" width="32" height="32" alt="SKostyukovich" /></a>
|
|
173
176
|
<a href="https://github.com/peter-adam-dy?ref=orpc" target="_blank" rel="noopener" title="Peter Adam"><img src="https://avatars.githubusercontent.com/u/132129459?u=4f3dbbb3b443990b56acb7d6a5d11ed2c555f6db&v=4" width="32" height="32" alt="Peter Adam" /></a>
|
|
174
177
|
<a href="https://github.com/FabworksHQ?ref=orpc" target="_blank" rel="noopener" title="Fabworks"><img src="https://avatars.githubusercontent.com/u/160179500?v=4" width="32" height="32" alt="Fabworks" /></a>
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
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 SchemaIssue } from './shared/contract.Do92aRJ4.mjs';
|
|
2
2
|
export { g as ErrorMapItem, H as HIDDEN_META_PLUGINS_SYMBOL, h as InferRouterContractError, i as InferRouterContractErrorMap, j as InferRouterContractErrors, k as InferRouterContractInputs, l as InferRouterContractOutputs, m as MetaPluginDefinition, n as ProcedureContractDefinition, V as ValidationError, o as ValidationErrorOptions, p as getHiddenMetaPlugins, s as setHiddenMetaPlugins } from './shared/contract.Do92aRJ4.mjs';
|
|
3
|
-
import { AnyORPCError, ClientContext, Client,
|
|
3
|
+
import { AnyORPCError, ClientContext, Client, ORPCClientOptions, ClientLink } from '@orpc/client';
|
|
4
4
|
export { Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions } from '@orpc/client';
|
|
5
|
-
import { ThrowableError,
|
|
5
|
+
import { ThrowableError, AsyncIteratorClass, Promisable, IsEqual } from '@orpc/shared';
|
|
6
6
|
export { PromiseWithError, Registry, ThrowableError } from '@orpc/shared';
|
|
7
7
|
import '@standard-schema/spec';
|
|
8
8
|
|
|
@@ -68,18 +68,18 @@ type RouterContractClient<TRouter extends RouterContract, TClientContext extends
|
|
|
68
68
|
[K in keyof TRouter]: TRouter[K] extends RouterContract ? RouterContractClient<TRouter[K], TClientContext> : never;
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
interface
|
|
72
|
-
<
|
|
71
|
+
interface ContractClientFactory<TClientContext extends ClientContext> {
|
|
72
|
+
<T extends RouterContract>(contract: T): RouterContractClient<T, TClientContext>;
|
|
73
73
|
}
|
|
74
|
-
interface
|
|
74
|
+
interface ContractClientFactoryOptions<TClientContext extends ClientContext> extends Pick<ORPCClientOptions<RouterContractClient<RouterContract, TClientContext>>, 'interceptors' | 'scoped'> {
|
|
75
75
|
/**
|
|
76
76
|
* An optional reference to the root router-contract.
|
|
77
|
-
* When provided, the
|
|
77
|
+
* When provided, the client factory will automatically register the passed contract
|
|
78
78
|
* into the router at the path defined by `meta.path`.
|
|
79
79
|
*/
|
|
80
80
|
contractRef?: undefined | RouterContract;
|
|
81
81
|
}
|
|
82
|
-
declare function
|
|
82
|
+
declare function createContractClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractClientFactoryOptions<TClientContext>): ContractClientFactory<TClientContext>;
|
|
83
83
|
|
|
84
84
|
interface PathMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
|
|
85
85
|
name: '~path';
|
|
@@ -92,6 +92,14 @@ declare function getPathMeta(procedureOrLazy: {
|
|
|
92
92
|
meta: Meta;
|
|
93
93
|
};
|
|
94
94
|
}): string[] | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Resolve the base path of a contract from the first procedure-contract
|
|
97
|
+
* that defines `meta.path`: its `meta.path` minus its path inside the given contract.
|
|
98
|
+
* For a procedure-contract, this is its `meta.path` itself.
|
|
99
|
+
*
|
|
100
|
+
* Returns `undefined` when no procedure-contract defines `meta.path`.
|
|
101
|
+
*/
|
|
102
|
+
declare function resolveBasePathMeta(contract: RouterContract, currentPath?: string[]): string[] | undefined;
|
|
95
103
|
|
|
96
104
|
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>[]];
|
|
97
105
|
/**
|
|
@@ -176,5 +184,5 @@ declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutp
|
|
|
176
184
|
*/
|
|
177
185
|
declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
|
|
178
186
|
|
|
179
|
-
export { AnyMetaPlugin, AnyProcedureContract, AnySchema, ContractBuilder, ErrorMap, InferSchemaInput, InferSchemaOutput, MergedSchema, Meta, MetaPlugin, ORPCErrorFromErrorMap, ProcedureContract, RouterContract, Schema, SchemaIssue, asyncIteratorObject, augmentContractRouter,
|
|
180
|
-
export type { AsyncIteratorObjectSchemaDetails, AugmentContractRouterOptions, AugmentedContractRouter,
|
|
187
|
+
export { AnyMetaPlugin, AnyProcedureContract, AnySchema, ContractBuilder, ErrorMap, InferSchemaInput, InferSchemaOutput, MergedSchema, Meta, MetaPlugin, ORPCErrorFromErrorMap, ProcedureContract, RouterContract, Schema, SchemaIssue, asyncIteratorObject, augmentContractRouter, createContractClientFactory, defineMeta, asyncIteratorObject as eventIterator, getAsyncIteratorObjectSchemaDetails, getPathMeta, getProcedureContractOrThrow, getRouterContract, isSchemaIssue, mergeErrorMap, meta, minifyRouterContract, oc, reconcileORPCError, resolveBasePathMeta, resolveMetaPlugins, type };
|
|
188
|
+
export type { AsyncIteratorObjectSchemaDetails, AugmentContractRouterOptions, AugmentedContractRouter, ContractClientFactory, ContractClientFactoryOptions, InitialInputSchema, InitialOutputSchema, MergedErrorMap, PathMetaPlugin, ProcedureContractBuilderWithInput, ProcedureContractBuilderWithInputOutput, ProcedureContractBuilderWithOutput, ProcedureContractClient, RouterContractClient, TypeRest };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
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 SchemaIssue } from './shared/contract.Do92aRJ4.js';
|
|
2
2
|
export { g as ErrorMapItem, H as HIDDEN_META_PLUGINS_SYMBOL, h as InferRouterContractError, i as InferRouterContractErrorMap, j as InferRouterContractErrors, k as InferRouterContractInputs, l as InferRouterContractOutputs, m as MetaPluginDefinition, n as ProcedureContractDefinition, V as ValidationError, o as ValidationErrorOptions, p as getHiddenMetaPlugins, s as setHiddenMetaPlugins } from './shared/contract.Do92aRJ4.js';
|
|
3
|
-
import { AnyORPCError, ClientContext, Client,
|
|
3
|
+
import { AnyORPCError, ClientContext, Client, ORPCClientOptions, ClientLink } from '@orpc/client';
|
|
4
4
|
export { Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions } from '@orpc/client';
|
|
5
|
-
import { ThrowableError,
|
|
5
|
+
import { ThrowableError, AsyncIteratorClass, Promisable, IsEqual } from '@orpc/shared';
|
|
6
6
|
export { PromiseWithError, Registry, ThrowableError } from '@orpc/shared';
|
|
7
7
|
import '@standard-schema/spec';
|
|
8
8
|
|
|
@@ -68,18 +68,18 @@ type RouterContractClient<TRouter extends RouterContract, TClientContext extends
|
|
|
68
68
|
[K in keyof TRouter]: TRouter[K] extends RouterContract ? RouterContractClient<TRouter[K], TClientContext> : never;
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
-
interface
|
|
72
|
-
<
|
|
71
|
+
interface ContractClientFactory<TClientContext extends ClientContext> {
|
|
72
|
+
<T extends RouterContract>(contract: T): RouterContractClient<T, TClientContext>;
|
|
73
73
|
}
|
|
74
|
-
interface
|
|
74
|
+
interface ContractClientFactoryOptions<TClientContext extends ClientContext> extends Pick<ORPCClientOptions<RouterContractClient<RouterContract, TClientContext>>, 'interceptors' | 'scoped'> {
|
|
75
75
|
/**
|
|
76
76
|
* An optional reference to the root router-contract.
|
|
77
|
-
* When provided, the
|
|
77
|
+
* When provided, the client factory will automatically register the passed contract
|
|
78
78
|
* into the router at the path defined by `meta.path`.
|
|
79
79
|
*/
|
|
80
80
|
contractRef?: undefined | RouterContract;
|
|
81
81
|
}
|
|
82
|
-
declare function
|
|
82
|
+
declare function createContractClientFactory<TClientContext extends ClientContext>(link: ClientLink<TClientContext>, options?: ContractClientFactoryOptions<TClientContext>): ContractClientFactory<TClientContext>;
|
|
83
83
|
|
|
84
84
|
interface PathMetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> extends MetaPlugin<TInputSchema, TOutputSchema, TErrorMap> {
|
|
85
85
|
name: '~path';
|
|
@@ -92,6 +92,14 @@ declare function getPathMeta(procedureOrLazy: {
|
|
|
92
92
|
meta: Meta;
|
|
93
93
|
};
|
|
94
94
|
}): string[] | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* Resolve the base path of a contract from the first procedure-contract
|
|
97
|
+
* that defines `meta.path`: its `meta.path` minus its path inside the given contract.
|
|
98
|
+
* For a procedure-contract, this is its `meta.path` itself.
|
|
99
|
+
*
|
|
100
|
+
* Returns `undefined` when no procedure-contract defines `meta.path`.
|
|
101
|
+
*/
|
|
102
|
+
declare function resolveBasePathMeta(contract: RouterContract, currentPath?: string[]): string[] | undefined;
|
|
95
103
|
|
|
96
104
|
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>[]];
|
|
97
105
|
/**
|
|
@@ -176,5 +184,5 @@ declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutp
|
|
|
176
184
|
*/
|
|
177
185
|
declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
|
|
178
186
|
|
|
179
|
-
export { AnyMetaPlugin, AnyProcedureContract, AnySchema, ContractBuilder, ErrorMap, InferSchemaInput, InferSchemaOutput, MergedSchema, Meta, MetaPlugin, ORPCErrorFromErrorMap, ProcedureContract, RouterContract, Schema, SchemaIssue, asyncIteratorObject, augmentContractRouter,
|
|
180
|
-
export type { AsyncIteratorObjectSchemaDetails, AugmentContractRouterOptions, AugmentedContractRouter,
|
|
187
|
+
export { AnyMetaPlugin, AnyProcedureContract, AnySchema, ContractBuilder, ErrorMap, InferSchemaInput, InferSchemaOutput, MergedSchema, Meta, MetaPlugin, ORPCErrorFromErrorMap, ProcedureContract, RouterContract, Schema, SchemaIssue, asyncIteratorObject, augmentContractRouter, createContractClientFactory, defineMeta, asyncIteratorObject as eventIterator, getAsyncIteratorObjectSchemaDetails, getPathMeta, getProcedureContractOrThrow, getRouterContract, isSchemaIssue, mergeErrorMap, meta, minifyRouterContract, oc, reconcileORPCError, resolveBasePathMeta, resolveMetaPlugins, type };
|
|
188
|
+
export type { AsyncIteratorObjectSchemaDetails, AugmentContractRouterOptions, AugmentedContractRouter, ContractClientFactory, ContractClientFactoryOptions, InitialInputSchema, InitialOutputSchema, MergedErrorMap, PathMetaPlugin, ProcedureContractBuilderWithInput, ProcedureContractBuilderWithInputOutput, ProcedureContractBuilderWithOutput, ProcedureContractClient, RouterContractClient, TypeRest };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isTypescriptObject, toArray,
|
|
1
|
+
import { isTypescriptObject, toArray, get, set, ORPC_NAME, isAsyncIteratorObject, isPropertyKey } from '@orpc/shared';
|
|
2
2
|
import { P as ProcedureContract, r as resolveMetaPlugins, m as mergeErrorMap, a as augmentContractRouter, V as ValidationError } from './shared/contract.CW-2wl1i.mjs';
|
|
3
3
|
export { d as defineMeta, g as getProcedureContractOrThrow, b as getRouterContract, c as minifyRouterContract, e as reconcileORPCError } from './shared/contract.CW-2wl1i.mjs';
|
|
4
4
|
import { createORPCClient, wrapAsyncIteratorPreservingEventMeta, ORPCError } from '@orpc/client';
|
|
@@ -95,27 +95,57 @@ const meta = {
|
|
|
95
95
|
function getPathMeta(procedureOrLazy) {
|
|
96
96
|
return procedureOrLazy["~orpc"].meta["~path"];
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const path = getPathMeta(procedure);
|
|
98
|
+
function resolveBasePathMeta(contract, currentPath = []) {
|
|
99
|
+
if (contract instanceof ProcedureContract) {
|
|
100
|
+
const path = getPathMeta(contract);
|
|
102
101
|
if (!path) {
|
|
102
|
+
return void 0;
|
|
103
|
+
}
|
|
104
|
+
const base = path.slice(0, Math.max(0, path.length - currentPath.length));
|
|
105
|
+
if (currentPath.some((key, i) => path[base.length + i] !== key)) {
|
|
103
106
|
throw new TypeError(
|
|
104
|
-
|
|
107
|
+
`Procedure contract at "${currentPath.join(".")}" defines meta.path "${path.join(".")}" that does not match its path inside the given router contract.`
|
|
105
108
|
);
|
|
106
109
|
}
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
return base;
|
|
111
|
+
}
|
|
112
|
+
if (isTypescriptObject(contract)) {
|
|
113
|
+
for (const key in contract) {
|
|
114
|
+
const base = resolveBasePathMeta(contract[key], [...currentPath, key]);
|
|
115
|
+
if (base !== void 0) {
|
|
116
|
+
return base;
|
|
117
|
+
}
|
|
109
118
|
}
|
|
110
|
-
|
|
111
|
-
|
|
119
|
+
}
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function createContractClientFactory(link, options = {}) {
|
|
124
|
+
const factory = (contract) => {
|
|
125
|
+
const path = resolveBasePathMeta(contract);
|
|
126
|
+
if (path === void 0) {
|
|
112
127
|
throw new TypeError(
|
|
113
|
-
|
|
128
|
+
"ContractClientFactory: procedure contract must define `meta.path` that matches its path in the root router contract."
|
|
114
129
|
);
|
|
115
130
|
}
|
|
116
|
-
const
|
|
117
|
-
|
|
131
|
+
const contractRef = options.contractRef;
|
|
132
|
+
if (contractRef) {
|
|
133
|
+
const register = (contract2, path2) => {
|
|
134
|
+
if (contract2 instanceof ProcedureContract) {
|
|
135
|
+
set(contractRef, [...path2, "~orpc"], contract2["~orpc"]);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (isTypescriptObject(contract2)) {
|
|
139
|
+
for (const [key, value] of Object.entries(contract2)) {
|
|
140
|
+
register(value, [...path2, key]);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
register(contract, path);
|
|
145
|
+
}
|
|
146
|
+
return createORPCClient(link, { ...options, scoped: get(options.scoped, path), path });
|
|
118
147
|
};
|
|
148
|
+
return factory;
|
|
119
149
|
}
|
|
120
150
|
|
|
121
151
|
const ASYNC_ITERATOR_OBJECT_SCHEMA_DETAILS_SYMBOL = Symbol.for("ORPC_ASYNC_ITERATOR_OBJECT_SCHEMA_DETAILS");
|
|
@@ -190,4 +220,4 @@ function isSchemaIssue(issue) {
|
|
|
190
220
|
return true;
|
|
191
221
|
}
|
|
192
222
|
|
|
193
|
-
export { ContractBuilder, HIDDEN_META_PLUGINS_SYMBOL, ProcedureContract, ValidationError, asyncIteratorObject, augmentContractRouter,
|
|
223
|
+
export { ContractBuilder, HIDDEN_META_PLUGINS_SYMBOL, ProcedureContract, ValidationError, asyncIteratorObject, augmentContractRouter, createContractClientFactory, asyncIteratorObject as eventIterator, getAsyncIteratorObjectSchemaDetails, getHiddenMetaPlugins, getPathMeta, isSchemaIssue, mergeErrorMap, meta, oc, resolveBasePathMeta, resolveMetaPlugins, setHiddenMetaPlugins, type };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/contract",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.19",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@standard-schema/spec": "^1.1.0",
|
|
34
|
-
"@orpc/client": "2.0.0-beta.
|
|
35
|
-
"@orpc/shared": "2.0.0-beta.
|
|
34
|
+
"@orpc/client": "2.0.0-beta.19",
|
|
35
|
+
"@orpc/shared": "2.0.0-beta.19"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"arktype": "^2.2.1",
|