@orpc/swr 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.
- package/README.md +6 -4
- package/dist/index.d.mts +9 -162
- package/dist/index.mjs +6 -240
- package/dist/key.d.mts +18 -0
- package/dist/key.mjs +8 -0
- package/dist/procedure-utils.d.mts +50 -0
- package/dist/procedure-utils.mjs +158 -0
- package/dist/router-utils.d.mts +17 -0
- package/dist/router-utils.mjs +36 -0
- package/dist/shared-utils.d.mts +14 -0
- package/dist/shared-utils.mjs +28 -0
- package/dist/types.d.mts +83 -0
- package/dist/types.mjs +2 -0
- package/dist/utils.d.mts +1 -0
- package/dist/utils.mjs +4 -0
- package/package.json +3 -3
- package/dist/index.d.ts +0 -162
package/README.md
CHANGED
|
@@ -156,10 +156,11 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
156
156
|
<td align="center"><a href="https://github.com/christ12938?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="167" alt="christ12938"/><br />christ12938</a></td>
|
|
157
157
|
<td align="center"><a href="https://github.com/Ryanjso?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ryan Soderberg"><img src="https://avatars.githubusercontent.com/u/39172778?u=5ed913c31d57e7221b75784abcad48c7ebddde27&v=4" width="167" alt="Ryan Soderberg"/><br />Ryan Soderberg</a></td>
|
|
158
158
|
<td align="center"><a href="https://github.com/itigoore01?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="shota"><img src="https://avatars.githubusercontent.com/u/11831107?u=c976a6dc7e055eb026304c46c99100ed22b0c8e0&v=4" width="167" alt="shota"/><br />shota</a></td>
|
|
159
|
+
<td align="center"><a href="https://github.com/Nic13Gamer?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Nicholas"><img src="https://avatars.githubusercontent.com/u/54724556?u=56a7ab430ce7a80d648ab6eba051d454a818ed0b&v=4" width="167" alt="Nicholas"/><br />Nicholas</a></td>
|
|
159
160
|
<td align="center"><a href="https://github.com/ellis-driscoll?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ellis Driscoll"><img src="https://avatars.githubusercontent.com/u/70685966?u=c5f95bc33b5991d9744abe00052542e4a2ed3cb9&v=4" width="167" alt="Ellis Driscoll"/><br />Ellis Driscoll</a></td>
|
|
160
|
-
<td align="center"><a href="https://github.com/hoangbn?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Hoang Nguyen"><img src="https://avatars.githubusercontent.com/u/38968280?u=c90084c6de65c56facabab7ba13a72a49ddbc3e4&v=4" width="167" alt="Hoang Nguyen"/><br />Hoang Nguyen</a></td>
|
|
161
161
|
</tr>
|
|
162
162
|
<tr>
|
|
163
|
+
<td align="center"><a href="https://github.com/hoangbn?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Hoang Nguyen"><img src="https://avatars.githubusercontent.com/u/38968280?u=c90084c6de65c56facabab7ba13a72a49ddbc3e4&v=4" width="167" alt="Hoang Nguyen"/><br />Hoang Nguyen</a></td>
|
|
163
164
|
<td align="center"><a href="https://opencollective.com/guest-ac41de3b?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Orestis Ioannou"><img src="https://images.opencollective.com/guest-ac41de3b/avatar/460.png" width="167" alt="Orestis Ioannou"/><br />Orestis Ioannou</a></td>
|
|
164
165
|
<td align="center"><a href="https://automatio.ai/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Stefan Smiljkovic"><img src="https://avatars.githubusercontent.com/u/1984909?u=b7bf5bc40ed49df3c22f69d2da7b8d78709c49ed&v=4" width="167" alt="Stefan Smiljkovic"/><br />Stefan Smiljkovic</a></td>
|
|
165
166
|
</tr>
|
|
@@ -190,10 +191,9 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
190
191
|
<td align="center"><a href="https://kellychan.im/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kelly Peilin Chan"><img src="https://avatars.githubusercontent.com/u/520852?u=6b0f7105f694e7b5cacf410a3f04c7044b469dc8&v=4" width="139" alt="Kelly Peilin Chan"/><br />Kelly Peilin Chan</a></td>
|
|
191
192
|
<td align="center"><a href="https://guyariely.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Guy Ariely"><img src="https://avatars.githubusercontent.com/u/42813496?u=edb6b7f563bf28e160a290832e7da57c0506f8ca&v=4" width="139" alt="Guy Ariely"/><br />Guy Ariely</a></td>
|
|
192
193
|
<td align="center"><a href="https://paulsenon.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="PaulSenon"><img src="https://avatars.githubusercontent.com/u/19531087?u=6385741eb91d200b8c513ec6045482e301767ca6&v=4" width="139" alt="PaulSenon"/><br />PaulSenon</a></td>
|
|
193
|
-
<td align="center"><a href="https://
|
|
194
|
+
<td align="center"><a href="https://piscis.dev/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&v=4" width="139" alt="Alex"/><br />Alex</a></td>
|
|
194
195
|
</tr>
|
|
195
196
|
<tr>
|
|
196
|
-
<td align="center"><a href="https://piscis.dev/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&v=4" width="139" alt="Alex"/><br />Alex</a></td>
|
|
197
197
|
<td align="center"><a href="https://opensource.gubanov.eu/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Andrey Gubanov"><img src="https://avatars.githubusercontent.com/u/1082083?u=c5f2daf7ebece498e85c83367bb37b4e10e2649d&v=4" width="139" alt="Andrey Gubanov"/><br />Andrey Gubanov</a></td>
|
|
198
198
|
</tr>
|
|
199
199
|
</table>
|
|
@@ -206,7 +206,9 @@ With thanks to [40 past sponsors](https://orpc.dev/sponsors#past-sponsors) who h
|
|
|
206
206
|
|
|
207
207
|
<table>
|
|
208
208
|
<tr>
|
|
209
|
-
<td align="center"><a href="https://claude.com/contact-sales/claude-for-oss" target="_blank" rel="noopener" title="Claude for Open Source"><img src="https://cdn.simpleicons.org/claude" width="64" alt="Claude"/><br />Claude
|
|
209
|
+
<td align="center"><a href="https://claude.com/contact-sales/claude-for-oss" target="_blank" rel="noopener" title="Claude for Open Source"><img src="https://cdn.simpleicons.org/claude" width="64" alt="Claude"/><br />Claude</a></td>
|
|
210
|
+
<td align="center"><a href="https://pullfrog.com/for-oss" target="_blank" rel="noopener" title="Pullfrog for OSS"><img src="https://avatars.githubusercontent.com/in/1768019?s=128&v=4" width="64" alt="Pullfrog"/><br />Pullfrog</a></td>
|
|
211
|
+
<td align="center"><a href="https://macroscope.com/open-source" target="_blank" rel="noopener" title="Macroscope for Open Source"><img src="https://avatars.githubusercontent.com/in/900172?s=128&v=4" width="64" alt="Macroscope"/><br />Macroscope</a></td>
|
|
210
212
|
</tr>
|
|
211
213
|
</table>
|
|
212
214
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,162 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
*/
|
|
11
|
-
prefix?: string | undefined;
|
|
12
|
-
}
|
|
13
|
-
type OperationKeyOptions<TInput> = OperationKeyPrefixOptions & {
|
|
14
|
-
input?: PartialDeep<TInput> | undefined;
|
|
15
|
-
};
|
|
16
|
-
type OperationKey<TInput> = [path: string[], options: Omit<OperationKeyOptions<TInput>, 'prefix'>] | [prefix: string, path: string[], options: Omit<OperationKeyOptions<TInput>, 'prefix'>];
|
|
17
|
-
|
|
18
|
-
type InferSubscriberOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
19
|
-
type InferLiveSubscriberOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U : never;
|
|
20
|
-
type OperationType = 'fetcher' | 'mutator' | 'subscriber' | 'liveSubscriber';
|
|
21
|
-
/**
|
|
22
|
-
* The symbol under which SWR utils attach operation details
|
|
23
|
-
* (key and operation type) to the client context.
|
|
24
|
-
*
|
|
25
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#operation-context | SWR Integration - Operation Context}
|
|
26
|
-
*/
|
|
27
|
-
declare const OPERATION_CONTEXT_SYMBOL: unique symbol;
|
|
28
|
-
/**
|
|
29
|
-
* A client context automatically populated by SWR utils,
|
|
30
|
-
* exposing the operation key and type of the calling operation.
|
|
31
|
-
*
|
|
32
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#operation-context | SWR Integration - Operation Context}
|
|
33
|
-
*/
|
|
34
|
-
interface OperationContext {
|
|
35
|
-
[OPERATION_CONTEXT_SYMBOL]?: {
|
|
36
|
-
key: unknown;
|
|
37
|
-
type: OperationType;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
type KeyOptions<TInput> = undefined extends TInput ? {
|
|
41
|
-
input?: TInput;
|
|
42
|
-
} : {
|
|
43
|
-
input: TInput;
|
|
44
|
-
};
|
|
45
|
-
type MatcherStrategy = 'exact' | 'partial';
|
|
46
|
-
type MatcherOptions<TStrategy extends MatcherStrategy, TInput> = ('partial' extends TStrategy ? {
|
|
47
|
-
input?: PartialDeep<TInput> | undefined;
|
|
48
|
-
} : undefined extends TInput ? {
|
|
49
|
-
input?: TInput;
|
|
50
|
-
} : {
|
|
51
|
-
input: TInput;
|
|
52
|
-
}) & {
|
|
53
|
-
strategy?: TStrategy | undefined;
|
|
54
|
-
};
|
|
55
|
-
type Matcher = (key?: unknown) => boolean;
|
|
56
|
-
type FetcherOptions<TClientContext extends ClientContext> = object extends TClientContext ? {
|
|
57
|
-
context?: TClientContext | undefined;
|
|
58
|
-
} : {
|
|
59
|
-
context: TClientContext;
|
|
60
|
-
};
|
|
61
|
-
type SubscriberOptions<TClientContext extends ClientContext> = FetcherOptions<TClientContext> & {
|
|
62
|
-
/**
|
|
63
|
-
* Determines how data is handled when the subscription is subscribed again
|
|
64
|
-
*
|
|
65
|
-
* - `'reset'`: Clears existing data before streaming new data.
|
|
66
|
-
* - `'append'`: Adds new streamed chunks to the existing data.
|
|
67
|
-
* - `'replace'`: Buffers streamed data and replaces existing data after the stream completes.
|
|
68
|
-
*
|
|
69
|
-
* @default 'reset'
|
|
70
|
-
*/
|
|
71
|
-
refetchMode?: 'append' | 'reset' | 'replace' | undefined;
|
|
72
|
-
/**
|
|
73
|
-
* Maximum number of chunks to store.
|
|
74
|
-
* When exceeded, the oldest chunks will be removed.
|
|
75
|
-
*/
|
|
76
|
-
maxChunks?: number | undefined;
|
|
77
|
-
};
|
|
78
|
-
type MutatorOptions<TClientContext extends ClientContext> = FetcherOptions<TClientContext>;
|
|
79
|
-
type Fetcher<TInput, TOutput> = (key: OperationKey<TInput>) => Promise<TOutput>;
|
|
80
|
-
type Mutator<TInput, TOutput> = (key: unknown, options: Readonly<{
|
|
81
|
-
arg: TInput;
|
|
82
|
-
}>) => Promise<TOutput>;
|
|
83
|
-
type Subscriber<TInput, TData, TError> = (key: OperationKey<TInput>, options: SWRSubscriptionOptions<TData, TError>) => (() => void);
|
|
84
|
-
|
|
85
|
-
declare class SharedUtils<TInput> {
|
|
86
|
-
protected readonly path: string[];
|
|
87
|
-
protected readonly options: OperationKeyPrefixOptions;
|
|
88
|
-
constructor(path: string[], options: OperationKeyPrefixOptions);
|
|
89
|
-
/**
|
|
90
|
-
* Generate a matcher function that returns `true` if the key matches the specified conditions.
|
|
91
|
-
*
|
|
92
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#manual-revalidation | SWR Integration - Manual Revalidation}
|
|
93
|
-
*/
|
|
94
|
-
matcher<TStrategy extends MatcherStrategy>(...rest: MaybeOptionalOptions<MatcherOptions<TStrategy, TInput>>): Matcher;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
interface ProcedureUtilsOptions extends OperationKeyPrefixOptions {
|
|
98
|
-
}
|
|
99
|
-
declare class ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError> extends SharedUtils<TInput> {
|
|
100
|
-
/**
|
|
101
|
-
* Calling corresponding procedure client
|
|
102
|
-
*
|
|
103
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#calling-clients | SWR Integration - Calling Clients}
|
|
104
|
-
*/
|
|
105
|
-
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
106
|
-
constructor(path: string[], client: Client<TClientContext, TInput, TOutput, TError>, options?: ProcedureUtilsOptions);
|
|
107
|
-
/**
|
|
108
|
-
* Generate a **full matching** key for SWR operations.
|
|
109
|
-
*
|
|
110
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#data-fetching | SWR Integration - Data Fetching}
|
|
111
|
-
*/
|
|
112
|
-
key(...rest: MaybeOptionalOptions<KeyOptions<TInput>>): OperationKey<TInput>;
|
|
113
|
-
/**
|
|
114
|
-
* Generate a fetcher function for use with useSWR, useSWRInfinite, and other SWR hooks.
|
|
115
|
-
*
|
|
116
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#data-fetching | SWR Integration - Data Fetching}
|
|
117
|
-
*/
|
|
118
|
-
fetcher(...rest: MaybeOptionalOptions<FetcherOptions<TClientContext>>): Fetcher<TInput, TOutput>;
|
|
119
|
-
/**
|
|
120
|
-
* Generate a subscriber function that subscribes to an [AsyncIteratorObject](https://orpc.dev/docs/async-iterator-object) for use with useSWRSubscription, etc.
|
|
121
|
-
*
|
|
122
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#subscriptions | SWR Integration - Subscriptions}
|
|
123
|
-
*/
|
|
124
|
-
subscriber(...rest: MaybeOptionalOptions<SubscriberOptions<TClientContext>>): Subscriber<TInput, InferSubscriberOutput<TOutput>, TError>;
|
|
125
|
-
/**
|
|
126
|
-
* Generate a live subscriber that subscribes to the latest events from an [AsyncIteratorObject](https://orpc.dev/docs/async-iterator-object) for use with useSWRSubscription, etc.
|
|
127
|
-
*
|
|
128
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#subscriptions | SWR Integration - Subscriptions}
|
|
129
|
-
*/
|
|
130
|
-
liveSubscriber(...rest: MaybeOptionalOptions<FetcherOptions<TClientContext>>): Subscriber<TInput, InferLiveSubscriberOutput<TOutput>, TError>;
|
|
131
|
-
/**
|
|
132
|
-
* Generate a mutator function for use with useSWRMutation, etc.
|
|
133
|
-
*
|
|
134
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#mutations | SWR Integration - Mutations}
|
|
135
|
-
*/
|
|
136
|
-
mutator(...rest: MaybeOptionalOptions<MutatorOptions<TClientContext>>): Mutator<TInput, TOutput>;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
type RouterUtils<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Public<ProcedureUtils<UClientContext, UInput, UOutput, UError>> : {
|
|
140
|
-
[K in keyof T]: T[K] extends AnyNestedClient ? RouterUtils<T[K]> : never;
|
|
141
|
-
} & Public<SharedUtils<unknown>>;
|
|
142
|
-
interface RouterUtilsOptions extends OperationKeyPrefixOptions {
|
|
143
|
-
/**
|
|
144
|
-
* Base path for all keys.
|
|
145
|
-
*
|
|
146
|
-
* @internal
|
|
147
|
-
*/
|
|
148
|
-
path?: string[] | undefined;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Creates SWR utils from a client, exposing fetcher/mutator/subscriber
|
|
152
|
-
* helpers for every procedure in the router.
|
|
153
|
-
*
|
|
154
|
-
* @remarks
|
|
155
|
-
* **Note**: Both client-side and server-side clients are supported.
|
|
156
|
-
*
|
|
157
|
-
* @see {@link https://orpc.dev/docs/integrations/swr | SWR Integration}
|
|
158
|
-
*/
|
|
159
|
-
declare function createRouterUtils<T extends AnyNestedClient>(client: T, options?: RouterUtilsOptions): RouterUtils<T>;
|
|
160
|
-
|
|
161
|
-
export { OPERATION_CONTEXT_SYMBOL, ProcedureUtils, OPERATION_CONTEXT_SYMBOL as SWR_OPERATION_CONTEXT_SYMBOL, SharedUtils, createRouterUtils, createRouterUtils as createSWRUtils };
|
|
162
|
-
export type { Fetcher, FetcherOptions, InferLiveSubscriberOutput, InferSubscriberOutput, KeyOptions, Matcher, MatcherOptions, MatcherStrategy, Mutator, MutatorOptions, OperationContext, OperationKey, OperationKeyOptions, OperationKeyPrefixOptions, OperationType, ProcedureUtilsOptions, RouterUtils, RouterUtilsOptions, OperationContext as SWROperationContext, Subscriber, SubscriberOptions };
|
|
1
|
+
export type { OperationKey, OperationKeyOptions, OperationKeyPrefixOptions } from "./key.mjs";
|
|
2
|
+
export { ProcedureUtils } from "./procedure-utils.mjs";
|
|
3
|
+
export type { ProcedureUtilsOptions } from "./procedure-utils.mjs";
|
|
4
|
+
export * from "./router-utils.mjs";
|
|
5
|
+
export { createRouterUtils as createSWRUtils } from "./router-utils.mjs";
|
|
6
|
+
export { SharedUtils } from "./shared-utils.mjs";
|
|
7
|
+
export * from "./types.mjs";
|
|
8
|
+
export { OPERATION_CONTEXT_SYMBOL as SWR_OPERATION_CONTEXT_SYMBOL, type OperationContext as SWROperationContext } from "./types.mjs";
|
|
9
|
+
export type { Public } from "@orpc/shared";
|
package/dist/index.mjs
CHANGED
|
@@ -1,240 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
path,
|
|
8
|
-
{
|
|
9
|
-
...options.input !== void 0 ? { input: options.input } : {}
|
|
10
|
-
}
|
|
11
|
-
];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function isSubsetOf(subsetKey, fullKey) {
|
|
15
|
-
return subsetKey === fullKey ? true : typeof subsetKey !== typeof fullKey ? false : isPlainObject(subsetKey) && isPlainObject(fullKey) ? Object.keys(subsetKey).every((key) => subsetKey[key] === void 0 || isSubsetOf(subsetKey[key], fullKey[key])) : Array.isArray(subsetKey) && Array.isArray(fullKey) ? subsetKey.every((value, index) => isSubsetOf(value, fullKey[index])) : subsetKey instanceof Date && fullKey instanceof Date ? Object.is(subsetKey.getTime(), fullKey.getTime()) : false;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
class SharedUtils {
|
|
19
|
-
constructor(path, options) {
|
|
20
|
-
this.path = path;
|
|
21
|
-
this.options = options;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Generate a matcher function that returns `true` if the key matches the specified conditions.
|
|
25
|
-
*
|
|
26
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#manual-revalidation | SWR Integration - Manual Revalidation}
|
|
27
|
-
*/
|
|
28
|
-
matcher(...rest) {
|
|
29
|
-
const { input, strategy = "partial" } = resolveMaybeOptionalOptions(rest);
|
|
30
|
-
const expectedKey = generateOperationKey(this.path, { prefix: this.options.prefix, input });
|
|
31
|
-
return (key) => {
|
|
32
|
-
if (!isSubsetOf(expectedKey, key)) {
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
if (strategy === "exact" && !isSubsetOf(key, expectedKey)) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
return true;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const OPERATION_CONTEXT_SYMBOL = Symbol.for("ORPC_SWR_OPERATION_CONTEXT");
|
|
44
|
-
|
|
45
|
-
class ProcedureUtils extends SharedUtils {
|
|
46
|
-
/**
|
|
47
|
-
* Calling corresponding procedure client
|
|
48
|
-
*
|
|
49
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#calling-clients | SWR Integration - Calling Clients}
|
|
50
|
-
*/
|
|
51
|
-
call;
|
|
52
|
-
constructor(path, client, options = {}) {
|
|
53
|
-
super(path, options);
|
|
54
|
-
this.call = client;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Generate a **full matching** key for SWR operations.
|
|
58
|
-
*
|
|
59
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#data-fetching | SWR Integration - Data Fetching}
|
|
60
|
-
*/
|
|
61
|
-
key(...rest) {
|
|
62
|
-
const options = resolveMaybeOptionalOptions(rest);
|
|
63
|
-
return generateOperationKey(this.path, { ...options, prefix: this.options.prefix });
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Generate a fetcher function for use with useSWR, useSWRInfinite, and other SWR hooks.
|
|
67
|
-
*
|
|
68
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#data-fetching | SWR Integration - Data Fetching}
|
|
69
|
-
*/
|
|
70
|
-
fetcher(...rest) {
|
|
71
|
-
const options = resolveMaybeOptionalOptions(rest);
|
|
72
|
-
return async (key) => {
|
|
73
|
-
const { input } = key[key.length - 1];
|
|
74
|
-
return this.call(input, {
|
|
75
|
-
context: {
|
|
76
|
-
[OPERATION_CONTEXT_SYMBOL]: { key, type: "fetcher" },
|
|
77
|
-
...options.context
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Generate a subscriber function that subscribes to an [AsyncIteratorObject](https://orpc.dev/docs/async-iterator-object) for use with useSWRSubscription, etc.
|
|
84
|
-
*
|
|
85
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#subscriptions | SWR Integration - Subscriptions}
|
|
86
|
-
*/
|
|
87
|
-
subscriber(...rest) {
|
|
88
|
-
const { maxChunks, refetchMode = "reset", ...options } = resolveMaybeOptionalOptions(rest);
|
|
89
|
-
return (key, { next }) => {
|
|
90
|
-
const controller = new AbortController();
|
|
91
|
-
void (async () => {
|
|
92
|
-
try {
|
|
93
|
-
const { input } = key[key.length - 1];
|
|
94
|
-
const iterator = await this.call(input, {
|
|
95
|
-
context: {
|
|
96
|
-
[OPERATION_CONTEXT_SYMBOL]: { key, type: "subscriber" },
|
|
97
|
-
...options.context
|
|
98
|
-
},
|
|
99
|
-
signal: controller.signal
|
|
100
|
-
});
|
|
101
|
-
if (!isAsyncIteratorObject(iterator)) {
|
|
102
|
-
throw new TypeError(".subscriber requires an AsyncIteratorObject output");
|
|
103
|
-
}
|
|
104
|
-
if (controller.signal.aborted) {
|
|
105
|
-
await iterator.return?.();
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
let hasPreviousData = false;
|
|
109
|
-
if (refetchMode === "reset") {
|
|
110
|
-
next(void 0, void 0);
|
|
111
|
-
} else if (refetchMode === "replace") {
|
|
112
|
-
next(void 0, (old) => {
|
|
113
|
-
hasPreviousData = old !== void 0;
|
|
114
|
-
return old;
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
const shouldUpdateDataDuringStream = refetchMode !== "replace" || !hasPreviousData;
|
|
118
|
-
let buffer = [];
|
|
119
|
-
for await (const event of iterator) {
|
|
120
|
-
if (controller.signal.aborted) {
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
if (shouldUpdateDataDuringStream) {
|
|
124
|
-
next(void 0, (old) => {
|
|
125
|
-
const newData = Array.isArray(old) ? [...old, event] : [event];
|
|
126
|
-
if (typeof maxChunks === "number" && newData.length > maxChunks) {
|
|
127
|
-
return newData.slice(newData.length - maxChunks);
|
|
128
|
-
}
|
|
129
|
-
return newData;
|
|
130
|
-
});
|
|
131
|
-
} else {
|
|
132
|
-
buffer = [...buffer, event];
|
|
133
|
-
if (typeof maxChunks === "number" && buffer.length > maxChunks) {
|
|
134
|
-
buffer = buffer.slice(buffer.length - maxChunks);
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
if (!shouldUpdateDataDuringStream && !controller.signal.aborted) {
|
|
139
|
-
next(void 0, buffer);
|
|
140
|
-
}
|
|
141
|
-
} catch (error) {
|
|
142
|
-
if (!controller.signal.aborted) {
|
|
143
|
-
next(error);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
})();
|
|
147
|
-
return () => {
|
|
148
|
-
controller.abort();
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Generate a live subscriber that subscribes to the latest events from an [AsyncIteratorObject](https://orpc.dev/docs/async-iterator-object) for use with useSWRSubscription, etc.
|
|
154
|
-
*
|
|
155
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#subscriptions | SWR Integration - Subscriptions}
|
|
156
|
-
*/
|
|
157
|
-
liveSubscriber(...rest) {
|
|
158
|
-
const options = resolveMaybeOptionalOptions(rest);
|
|
159
|
-
return (key, { next }) => {
|
|
160
|
-
const controller = new AbortController();
|
|
161
|
-
void (async () => {
|
|
162
|
-
try {
|
|
163
|
-
const { input } = key[key.length - 1];
|
|
164
|
-
const iterator = await this.call(input, {
|
|
165
|
-
context: {
|
|
166
|
-
[OPERATION_CONTEXT_SYMBOL]: { key, type: "liveSubscriber" },
|
|
167
|
-
...options.context
|
|
168
|
-
},
|
|
169
|
-
signal: controller.signal
|
|
170
|
-
});
|
|
171
|
-
if (!isAsyncIteratorObject(iterator)) {
|
|
172
|
-
throw new TypeError(".liveSubscriber requires an AsyncIteratorObject output");
|
|
173
|
-
}
|
|
174
|
-
for await (const event of iterator) {
|
|
175
|
-
if (controller.signal.aborted) {
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
next(void 0, event);
|
|
179
|
-
}
|
|
180
|
-
} catch (error) {
|
|
181
|
-
if (!controller.signal.aborted) {
|
|
182
|
-
next(error);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
})();
|
|
186
|
-
return () => {
|
|
187
|
-
controller.abort();
|
|
188
|
-
};
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Generate a mutator function for use with useSWRMutation, etc.
|
|
193
|
-
*
|
|
194
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#mutations | SWR Integration - Mutations}
|
|
195
|
-
*/
|
|
196
|
-
mutator(...rest) {
|
|
197
|
-
const options = resolveMaybeOptionalOptions(rest);
|
|
198
|
-
return (key, { arg }) => this.call(arg, {
|
|
199
|
-
context: {
|
|
200
|
-
[OPERATION_CONTEXT_SYMBOL]: { key, type: "mutator" },
|
|
201
|
-
...options.context
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
function createRouterUtils(client, options = {}) {
|
|
208
|
-
const path = toArray(options.path);
|
|
209
|
-
const utils = typeof client === "function" ? bindMethods(new ProcedureUtils(path, client, { prefix: options.prefix }), { unbound: ["call"] }) : bindMethods(new SharedUtils(path, { prefix: options.prefix }));
|
|
210
|
-
const cache = /* @__PURE__ */ new Map();
|
|
211
|
-
const recursive = new Proxy(utils, {
|
|
212
|
-
get(target, prop) {
|
|
213
|
-
const value = Reflect.get(target, prop);
|
|
214
|
-
if (RECURSIVE_CLIENT_UNWRAP_KEYS.has(prop)) {
|
|
215
|
-
return value ?? Reflect.get(Object.prototype, prop);
|
|
216
|
-
}
|
|
217
|
-
const nextClient = Reflect.get(client, prop);
|
|
218
|
-
if (typeof prop !== "string" || !isTypescriptObject(nextClient)) {
|
|
219
|
-
return value;
|
|
220
|
-
}
|
|
221
|
-
let result = cache.get(prop);
|
|
222
|
-
if (result === void 0) {
|
|
223
|
-
const nextUtils = createRouterUtils(nextClient, { ...options, path: [...path, prop] });
|
|
224
|
-
result = typeof value !== "function" ? nextUtils : new Proxy(value, {
|
|
225
|
-
get(target2, prop2) {
|
|
226
|
-
if (typeof prop2 !== "string" || RECURSIVE_CLIENT_UNWRAP_KEYS.has(prop2)) {
|
|
227
|
-
return Reflect.get(target2, prop2);
|
|
228
|
-
}
|
|
229
|
-
return Reflect.get(nextUtils, prop2);
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
cache.set(prop, result);
|
|
233
|
-
}
|
|
234
|
-
return result;
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
return recursive;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
export { OPERATION_CONTEXT_SYMBOL, ProcedureUtils, OPERATION_CONTEXT_SYMBOL as SWR_OPERATION_CONTEXT_SYMBOL, SharedUtils, createRouterUtils, createRouterUtils as createSWRUtils };
|
|
1
|
+
export { ProcedureUtils } from "./procedure-utils.mjs";
|
|
2
|
+
export * from "./router-utils.mjs";
|
|
3
|
+
export { createRouterUtils as createSWRUtils } from "./router-utils.mjs";
|
|
4
|
+
export { SharedUtils } from "./shared-utils.mjs";
|
|
5
|
+
export * from "./types.mjs";
|
|
6
|
+
export { OPERATION_CONTEXT_SYMBOL as SWR_OPERATION_CONTEXT_SYMBOL } from "./types.mjs";
|
package/dist/key.d.mts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { PartialDeep } from "@orpc/shared";
|
|
2
|
+
export interface OperationKeyPrefixOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Prepended as the first element of the key when present.
|
|
5
|
+
* Use this to avoid key conflicts when multiple router utils share the same client.
|
|
6
|
+
*/
|
|
7
|
+
prefix?: string | undefined;
|
|
8
|
+
}
|
|
9
|
+
export type OperationKeyOptions<TInput> = OperationKeyPrefixOptions & {
|
|
10
|
+
input?: PartialDeep<TInput> | undefined;
|
|
11
|
+
};
|
|
12
|
+
export type OperationKey<TInput> = [path: string[], options: Omit<OperationKeyOptions<TInput>, "prefix">] | [prefix: string, path: string[], options: Omit<OperationKeyOptions<TInput>, "prefix">];
|
|
13
|
+
/**
|
|
14
|
+
* Generate a **full matching** key for SWR operations.
|
|
15
|
+
*
|
|
16
|
+
* @see {@link https://orpc.dev/docs/integrations/swr#data-fetching | SWR Integration - Data Fetching}
|
|
17
|
+
*/
|
|
18
|
+
export declare function generateOperationKey<TInput>(path: string[], options?: OperationKeyOptions<TInput>): OperationKey<TInput>;
|
package/dist/key.mjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Client, ClientContext } from "@orpc/client";
|
|
2
|
+
import type { MaybeOptionalOptions } from "@orpc/shared";
|
|
3
|
+
import type { OperationKey, OperationKeyPrefixOptions } from "./key.mjs";
|
|
4
|
+
import type { Fetcher, FetcherOptions, InferLiveSubscriberOutput, InferSubscriberOutput, KeyOptions, Mutator, MutatorOptions, Subscriber, SubscriberOptions } from "./types.mjs";
|
|
5
|
+
import { SharedUtils } from "./shared-utils.mjs";
|
|
6
|
+
export interface ProcedureUtilsOptions extends OperationKeyPrefixOptions {}
|
|
7
|
+
export declare class ProcedureUtils<
|
|
8
|
+
TClientContext extends ClientContext,
|
|
9
|
+
TInput,
|
|
10
|
+
TOutput,
|
|
11
|
+
TError
|
|
12
|
+
> extends SharedUtils<TInput> {
|
|
13
|
+
/**
|
|
14
|
+
* Calling corresponding procedure client
|
|
15
|
+
*
|
|
16
|
+
* @see {@link https://orpc.dev/docs/integrations/swr#calling-clients | SWR Integration - Calling Clients}
|
|
17
|
+
*/
|
|
18
|
+
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
19
|
+
constructor(path: string[], client: Client<TClientContext, TInput, TOutput, TError>, options?: ProcedureUtilsOptions);
|
|
20
|
+
/**
|
|
21
|
+
* Generate a **full matching** key for SWR operations.
|
|
22
|
+
*
|
|
23
|
+
* @see {@link https://orpc.dev/docs/integrations/swr#data-fetching | SWR Integration - Data Fetching}
|
|
24
|
+
*/
|
|
25
|
+
key(...rest: MaybeOptionalOptions<KeyOptions<TInput>>): OperationKey<TInput>;
|
|
26
|
+
/**
|
|
27
|
+
* Generate a fetcher function for use with useSWR, useSWRInfinite, and other SWR hooks.
|
|
28
|
+
*
|
|
29
|
+
* @see {@link https://orpc.dev/docs/integrations/swr#data-fetching | SWR Integration - Data Fetching}
|
|
30
|
+
*/
|
|
31
|
+
fetcher(...rest: MaybeOptionalOptions<FetcherOptions<TClientContext>>): Fetcher<TInput, TOutput>;
|
|
32
|
+
/**
|
|
33
|
+
* Generate a subscriber function that subscribes to an [AsyncIteratorObject](https://orpc.dev/docs/async-iterator-object) for use with useSWRSubscription, etc.
|
|
34
|
+
*
|
|
35
|
+
* @see {@link https://orpc.dev/docs/integrations/swr#subscriptions | SWR Integration - Subscriptions}
|
|
36
|
+
*/
|
|
37
|
+
subscriber(...rest: MaybeOptionalOptions<SubscriberOptions<TClientContext>>): Subscriber<TInput, InferSubscriberOutput<TOutput>, TError>;
|
|
38
|
+
/**
|
|
39
|
+
* Generate a live subscriber that subscribes to the latest events from an [AsyncIteratorObject](https://orpc.dev/docs/async-iterator-object) for use with useSWRSubscription, etc.
|
|
40
|
+
*
|
|
41
|
+
* @see {@link https://orpc.dev/docs/integrations/swr#subscriptions | SWR Integration - Subscriptions}
|
|
42
|
+
*/
|
|
43
|
+
liveSubscriber(...rest: MaybeOptionalOptions<FetcherOptions<TClientContext>>): Subscriber<TInput, InferLiveSubscriberOutput<TOutput>, TError>;
|
|
44
|
+
/**
|
|
45
|
+
* Generate a mutator function for use with useSWRMutation, etc.
|
|
46
|
+
*
|
|
47
|
+
* @see {@link https://orpc.dev/docs/integrations/swr#mutations | SWR Integration - Mutations}
|
|
48
|
+
*/
|
|
49
|
+
mutator(...rest: MaybeOptionalOptions<MutatorOptions<TClientContext>>): Mutator<TInput, TOutput>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { isAsyncIteratorObject, resolveMaybeOptionalOptions } from "@orpc/shared";
|
|
2
|
+
import { generateOperationKey } from "./key.mjs";
|
|
3
|
+
import { SharedUtils } from "./shared-utils.mjs";
|
|
4
|
+
import { OPERATION_CONTEXT_SYMBOL } from "./types.mjs";
|
|
5
|
+
export class ProcedureUtils extends SharedUtils {
|
|
6
|
+
|
|
7
|
+
call;
|
|
8
|
+
constructor(path, client, options = {}) {
|
|
9
|
+
super(path, options);
|
|
10
|
+
this.call = client;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
key(...rest) {
|
|
14
|
+
const options = resolveMaybeOptionalOptions(rest);
|
|
15
|
+
return generateOperationKey(this.path, {
|
|
16
|
+
...options,
|
|
17
|
+
prefix: this.options.prefix
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fetcher(...rest) {
|
|
22
|
+
const options = resolveMaybeOptionalOptions(rest);
|
|
23
|
+
return async (key) => {
|
|
24
|
+
|
|
25
|
+
const { input } = key[key.length - 1];
|
|
26
|
+
return this.call(input, { context: {
|
|
27
|
+
[OPERATION_CONTEXT_SYMBOL]: {
|
|
28
|
+
key,
|
|
29
|
+
type: "fetcher"
|
|
30
|
+
},
|
|
31
|
+
...options.context
|
|
32
|
+
} });
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
subscriber(...rest) {
|
|
37
|
+
const { maxChunks, refetchMode = "reset", ...options } = resolveMaybeOptionalOptions(rest);
|
|
38
|
+
return (key, { next }) => {
|
|
39
|
+
const controller = new AbortController();
|
|
40
|
+
void (async () => {
|
|
41
|
+
try {
|
|
42
|
+
|
|
43
|
+
const { input } = key[key.length - 1];
|
|
44
|
+
const iterator = await this.call(input, {
|
|
45
|
+
context: {
|
|
46
|
+
[OPERATION_CONTEXT_SYMBOL]: {
|
|
47
|
+
key,
|
|
48
|
+
type: "subscriber"
|
|
49
|
+
},
|
|
50
|
+
...options.context
|
|
51
|
+
},
|
|
52
|
+
signal: controller.signal
|
|
53
|
+
});
|
|
54
|
+
if (!isAsyncIteratorObject(iterator)) {
|
|
55
|
+
throw new TypeError(".subscriber requires an AsyncIteratorObject output");
|
|
56
|
+
}
|
|
57
|
+
if (controller.signal.aborted) {
|
|
58
|
+
await iterator.return?.();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
let hasPreviousData = false;
|
|
62
|
+
if (refetchMode === "reset") {
|
|
63
|
+
next(undefined, undefined);
|
|
64
|
+
} else if (refetchMode === "replace") {
|
|
65
|
+
|
|
66
|
+
next(undefined, (old) => {
|
|
67
|
+
hasPreviousData = old !== undefined;
|
|
68
|
+
return old;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const shouldUpdateDataDuringStream = refetchMode !== "replace" || !hasPreviousData;
|
|
72
|
+
let buffer = [];
|
|
73
|
+
for await (const event of iterator) {
|
|
74
|
+
if (controller.signal.aborted) {
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
if (shouldUpdateDataDuringStream) {
|
|
78
|
+
next(undefined, (old) => {
|
|
79
|
+
const newData = Array.isArray(old) ? [...old, event] : [event];
|
|
80
|
+
if (typeof maxChunks === "number" && newData.length > maxChunks) {
|
|
81
|
+
return newData.slice(newData.length - maxChunks);
|
|
82
|
+
}
|
|
83
|
+
return newData;
|
|
84
|
+
});
|
|
85
|
+
} else {
|
|
86
|
+
buffer = [...buffer, event];
|
|
87
|
+
if (typeof maxChunks === "number" && buffer.length > maxChunks) {
|
|
88
|
+
buffer = buffer.slice(buffer.length - maxChunks);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (!shouldUpdateDataDuringStream && !controller.signal.aborted) {
|
|
93
|
+
next(undefined, buffer);
|
|
94
|
+
}
|
|
95
|
+
} catch (error) {
|
|
96
|
+
|
|
97
|
+
if (!controller.signal.aborted) {
|
|
98
|
+
next(error);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
})();
|
|
102
|
+
return () => {
|
|
103
|
+
controller.abort();
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
liveSubscriber(...rest) {
|
|
109
|
+
const options = resolveMaybeOptionalOptions(rest);
|
|
110
|
+
return (key, { next }) => {
|
|
111
|
+
const controller = new AbortController();
|
|
112
|
+
void (async () => {
|
|
113
|
+
try {
|
|
114
|
+
|
|
115
|
+
const { input } = key[key.length - 1];
|
|
116
|
+
const iterator = await this.call(input, {
|
|
117
|
+
context: {
|
|
118
|
+
[OPERATION_CONTEXT_SYMBOL]: {
|
|
119
|
+
key,
|
|
120
|
+
type: "liveSubscriber"
|
|
121
|
+
},
|
|
122
|
+
...options.context
|
|
123
|
+
},
|
|
124
|
+
signal: controller.signal
|
|
125
|
+
});
|
|
126
|
+
if (!isAsyncIteratorObject(iterator)) {
|
|
127
|
+
throw new TypeError(".liveSubscriber requires an AsyncIteratorObject output");
|
|
128
|
+
}
|
|
129
|
+
for await (const event of iterator) {
|
|
130
|
+
if (controller.signal.aborted) {
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
next(undefined, event);
|
|
134
|
+
}
|
|
135
|
+
} catch (error) {
|
|
136
|
+
|
|
137
|
+
if (!controller.signal.aborted) {
|
|
138
|
+
next(error);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
})();
|
|
142
|
+
return () => {
|
|
143
|
+
controller.abort();
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
mutator(...rest) {
|
|
149
|
+
const options = resolveMaybeOptionalOptions(rest);
|
|
150
|
+
return (key, { arg }) => this.call(arg, { context: {
|
|
151
|
+
[OPERATION_CONTEXT_SYMBOL]: {
|
|
152
|
+
key,
|
|
153
|
+
type: "mutator"
|
|
154
|
+
},
|
|
155
|
+
...options.context
|
|
156
|
+
} });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AnyNestedClient, Client } from "@orpc/client";
|
|
2
|
+
import type { Public } from "@orpc/shared";
|
|
3
|
+
import type { OperationKeyPrefixOptions } from "./key.mjs";
|
|
4
|
+
import { ProcedureUtils } from "./procedure-utils.mjs";
|
|
5
|
+
import { SharedUtils } from "./shared-utils.mjs";
|
|
6
|
+
export type RouterUtils<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Public<ProcedureUtils<UClientContext, UInput, UOutput, UError>> : { [K in keyof T]: T[K] extends AnyNestedClient ? RouterUtils<T[K]> : never } & Public<SharedUtils<unknown>>;
|
|
7
|
+
export interface RouterUtilsOptions extends OperationKeyPrefixOptions {}
|
|
8
|
+
/**
|
|
9
|
+
* Creates SWR utils from a client, exposing fetcher/mutator/subscriber
|
|
10
|
+
* helpers for every procedure in the router.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* **Note**: Both client-side and server-side clients are supported.
|
|
14
|
+
*
|
|
15
|
+
* @see {@link https://orpc.dev/docs/integrations/swr | SWR Integration}
|
|
16
|
+
*/
|
|
17
|
+
export declare function createRouterUtils<T extends AnyNestedClient>(client: T, options?: RouterUtilsOptions): RouterUtils<T>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RECURSIVE_CLIENT_UNWRAP_KEYS } from "@orpc/client";
|
|
2
|
+
import { bindMethods, isTypescriptObject, toArray } from "@orpc/shared";
|
|
3
|
+
import { ProcedureUtils } from "./procedure-utils.mjs";
|
|
4
|
+
import { SharedUtils } from "./shared-utils.mjs";
|
|
5
|
+
|
|
6
|
+
export function createRouterUtils(client, options = {}) {
|
|
7
|
+
const path = toArray(options.path);
|
|
8
|
+
const utils = typeof client === "function" ? bindMethods(new ProcedureUtils(path, client, { prefix: options.prefix }), { unbound: ["call"] }) : bindMethods(new SharedUtils(path, { prefix: options.prefix }));
|
|
9
|
+
const cache = new Map();
|
|
10
|
+
const recursive = new Proxy(utils, { get(target, prop) {
|
|
11
|
+
const value = Reflect.get(target, prop);
|
|
12
|
+
if (RECURSIVE_CLIENT_UNWRAP_KEYS.has(prop)) {
|
|
13
|
+
return value ?? Reflect.get(Object.prototype, prop);
|
|
14
|
+
}
|
|
15
|
+
const nextClient = Reflect.get(client, prop);
|
|
16
|
+
if (typeof prop !== "string" || !isTypescriptObject(nextClient)) {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
let result = cache.get(prop);
|
|
20
|
+
if (result === undefined) {
|
|
21
|
+
const nextUtils = createRouterUtils(nextClient, {
|
|
22
|
+
...options,
|
|
23
|
+
path: [...path, prop]
|
|
24
|
+
});
|
|
25
|
+
result = typeof value !== "function" ? nextUtils : new Proxy(value, { get(target, prop) {
|
|
26
|
+
if (typeof prop !== "string" || RECURSIVE_CLIENT_UNWRAP_KEYS.has(prop)) {
|
|
27
|
+
return Reflect.get(target, prop);
|
|
28
|
+
}
|
|
29
|
+
return Reflect.get(nextUtils, prop);
|
|
30
|
+
} });
|
|
31
|
+
cache.set(prop, result);
|
|
32
|
+
}
|
|
33
|
+
return result;
|
|
34
|
+
} });
|
|
35
|
+
return recursive;
|
|
36
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { MaybeOptionalOptions } from "@orpc/shared";
|
|
2
|
+
import type { OperationKeyPrefixOptions } from "./key.mjs";
|
|
3
|
+
import type { Matcher, MatcherOptions, MatcherStrategy } from "./types.mjs";
|
|
4
|
+
export declare class SharedUtils<TInput> {
|
|
5
|
+
protected readonly path: string[];
|
|
6
|
+
protected readonly options: OperationKeyPrefixOptions;
|
|
7
|
+
constructor(path: string[], options: OperationKeyPrefixOptions);
|
|
8
|
+
/**
|
|
9
|
+
* Generate a matcher function that returns `true` if the key matches the specified conditions.
|
|
10
|
+
*
|
|
11
|
+
* @see {@link https://orpc.dev/docs/integrations/swr#manual-revalidation | SWR Integration - Manual Revalidation}
|
|
12
|
+
*/
|
|
13
|
+
matcher<TStrategy extends MatcherStrategy>(...rest: MaybeOptionalOptions<MatcherOptions<TStrategy, TInput>>): Matcher;
|
|
14
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { resolveMaybeOptionalOptions } from "@orpc/shared";
|
|
2
|
+
import { generateOperationKey } from "./key.mjs";
|
|
3
|
+
import { isSubsetOf } from "./utils.mjs";
|
|
4
|
+
export class SharedUtils {
|
|
5
|
+
path;
|
|
6
|
+
options;
|
|
7
|
+
constructor(path, options) {
|
|
8
|
+
this.path = path;
|
|
9
|
+
this.options = options;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
matcher(...rest) {
|
|
13
|
+
const { input, strategy = "partial" } = resolveMaybeOptionalOptions(rest);
|
|
14
|
+
const expectedKey = generateOperationKey(this.path, {
|
|
15
|
+
prefix: this.options.prefix,
|
|
16
|
+
input
|
|
17
|
+
});
|
|
18
|
+
return (key) => {
|
|
19
|
+
if (!isSubsetOf(expectedKey, key)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (strategy === "exact" && !isSubsetOf(key, expectedKey)) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
return true;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { ClientContext } from "@orpc/client";
|
|
2
|
+
import type { PartialDeep } from "@orpc/shared";
|
|
3
|
+
import type { SWRSubscriptionOptions } from "swr/subscription";
|
|
4
|
+
import type { OperationKey } from "./key.mjs";
|
|
5
|
+
export type InferSubscriberOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
6
|
+
export type InferLiveSubscriberOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U : never;
|
|
7
|
+
export type OperationType = "fetcher" | "mutator" | "subscriber" | "liveSubscriber";
|
|
8
|
+
/**
|
|
9
|
+
* The symbol under which SWR utils attach operation details
|
|
10
|
+
* (key and operation type) to the client context.
|
|
11
|
+
*
|
|
12
|
+
* @see {@link https://orpc.dev/docs/integrations/swr#operation-context | SWR Integration - Operation Context}
|
|
13
|
+
*/
|
|
14
|
+
export declare const OPERATION_CONTEXT_SYMBOL: unique symbol;
|
|
15
|
+
/**
|
|
16
|
+
* A client context automatically populated by SWR utils,
|
|
17
|
+
* exposing the operation key and type of the calling operation.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link https://orpc.dev/docs/integrations/swr#operation-context | SWR Integration - Operation Context}
|
|
20
|
+
*/
|
|
21
|
+
export interface OperationContext {
|
|
22
|
+
[OPERATION_CONTEXT_SYMBOL]?: {
|
|
23
|
+
key: unknown;
|
|
24
|
+
type: OperationType;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export type KeyOptions<TInput> = undefined extends TInput ? {
|
|
28
|
+
input?: TInput;
|
|
29
|
+
} : {
|
|
30
|
+
input: TInput;
|
|
31
|
+
};
|
|
32
|
+
export type MatcherStrategy = "exact" | "partial";
|
|
33
|
+
export type MatcherOptions<
|
|
34
|
+
TStrategy extends MatcherStrategy,
|
|
35
|
+
TInput
|
|
36
|
+
> = ("partial" extends TStrategy ? {
|
|
37
|
+
input?: PartialDeep<TInput> | undefined;
|
|
38
|
+
} : undefined extends TInput ? {
|
|
39
|
+
input?: TInput;
|
|
40
|
+
} : {
|
|
41
|
+
input: TInput;
|
|
42
|
+
}) & {
|
|
43
|
+
strategy?: TStrategy | undefined;
|
|
44
|
+
};
|
|
45
|
+
export type Matcher = (key?: unknown) => boolean;
|
|
46
|
+
export type FetcherOptions<TClientContext extends ClientContext> = object extends TClientContext ? {
|
|
47
|
+
context?: TClientContext | undefined;
|
|
48
|
+
} : {
|
|
49
|
+
context: TClientContext;
|
|
50
|
+
};
|
|
51
|
+
export type SubscriberOptions<TClientContext extends ClientContext> = FetcherOptions<TClientContext> & {
|
|
52
|
+
/**
|
|
53
|
+
* Determines how data is handled when the subscription is subscribed again
|
|
54
|
+
*
|
|
55
|
+
* - `'reset'`: Clears existing data before streaming new data.
|
|
56
|
+
* - `'append'`: Adds new streamed chunks to the existing data.
|
|
57
|
+
* - `'replace'`: Buffers streamed data and replaces existing data after the stream completes.
|
|
58
|
+
*
|
|
59
|
+
* @default 'reset'
|
|
60
|
+
*/
|
|
61
|
+
refetchMode?: "append" | "reset" | "replace" | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Maximum number of chunks to store.
|
|
64
|
+
* When exceeded, the oldest chunks will be removed.
|
|
65
|
+
*/
|
|
66
|
+
maxChunks?: number | undefined;
|
|
67
|
+
};
|
|
68
|
+
export type MutatorOptions<TClientContext extends ClientContext> = FetcherOptions<TClientContext>;
|
|
69
|
+
export type Fetcher<
|
|
70
|
+
TInput,
|
|
71
|
+
TOutput
|
|
72
|
+
> = (key: OperationKey<TInput>) => Promise<TOutput>;
|
|
73
|
+
export type Mutator<
|
|
74
|
+
TInput,
|
|
75
|
+
TOutput
|
|
76
|
+
> = (key: unknown, options: Readonly<{
|
|
77
|
+
arg: TInput;
|
|
78
|
+
}>) => Promise<TOutput>;
|
|
79
|
+
export type Subscriber<
|
|
80
|
+
TInput,
|
|
81
|
+
TData,
|
|
82
|
+
TError
|
|
83
|
+
> = (key: OperationKey<TInput>, options: SWRSubscriptionOptions<TData, TError>) => () => void;
|
package/dist/types.mjs
ADDED
package/dist/utils.d.mts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isSubsetOf(subsetKey: unknown, fullKey: unknown): boolean;
|
package/dist/utils.mjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { isPlainObject } from "@orpc/shared";
|
|
2
|
+
export function isSubsetOf(subsetKey, fullKey) {
|
|
3
|
+
return subsetKey === fullKey ? true : typeof subsetKey !== typeof fullKey ? false : isPlainObject(subsetKey) && isPlainObject(fullKey) ? Object.keys(subsetKey).every((key) => subsetKey[key] === undefined || isSubsetOf(subsetKey[key], fullKey[key])) : Array.isArray(subsetKey) && Array.isArray(fullKey) ? subsetKey.every((value, index) => isSubsetOf(value, fullKey[index])) : subsetKey instanceof Date && fullKey instanceof Date ? Object.is(subsetKey.getTime(), fullKey.getTime()) : false;
|
|
4
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/swr",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.48",
|
|
5
5
|
"description": "SWR integration for oRPC: typesafe React data fetching hooks",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": [
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"swr": ">=2.4.2"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@orpc/client": "2.0.0-beta.
|
|
44
|
-
"@orpc/shared": "2.0.0-beta.
|
|
43
|
+
"@orpc/client": "2.0.0-beta.48",
|
|
44
|
+
"@orpc/shared": "2.0.0-beta.48"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"swr": "^2.5.0",
|
package/dist/index.d.ts
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import { PartialDeep, MaybeOptionalOptions, Public } from '@orpc/shared';
|
|
2
|
-
export { Public } from '@orpc/shared';
|
|
3
|
-
import { ClientContext, Client, AnyNestedClient } from '@orpc/client';
|
|
4
|
-
import { SWRSubscriptionOptions } from 'swr/subscription';
|
|
5
|
-
|
|
6
|
-
interface OperationKeyPrefixOptions {
|
|
7
|
-
/**
|
|
8
|
-
* Prepended as the first element of the key when present.
|
|
9
|
-
* Use this to avoid key conflicts when multiple router utils share the same client.
|
|
10
|
-
*/
|
|
11
|
-
prefix?: string | undefined;
|
|
12
|
-
}
|
|
13
|
-
type OperationKeyOptions<TInput> = OperationKeyPrefixOptions & {
|
|
14
|
-
input?: PartialDeep<TInput> | undefined;
|
|
15
|
-
};
|
|
16
|
-
type OperationKey<TInput> = [path: string[], options: Omit<OperationKeyOptions<TInput>, 'prefix'>] | [prefix: string, path: string[], options: Omit<OperationKeyOptions<TInput>, 'prefix'>];
|
|
17
|
-
|
|
18
|
-
type InferSubscriberOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U[] : never;
|
|
19
|
-
type InferLiveSubscriberOutput<TOutput> = TOutput extends AsyncIterable<infer U> ? U : never;
|
|
20
|
-
type OperationType = 'fetcher' | 'mutator' | 'subscriber' | 'liveSubscriber';
|
|
21
|
-
/**
|
|
22
|
-
* The symbol under which SWR utils attach operation details
|
|
23
|
-
* (key and operation type) to the client context.
|
|
24
|
-
*
|
|
25
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#operation-context | SWR Integration - Operation Context}
|
|
26
|
-
*/
|
|
27
|
-
declare const OPERATION_CONTEXT_SYMBOL: unique symbol;
|
|
28
|
-
/**
|
|
29
|
-
* A client context automatically populated by SWR utils,
|
|
30
|
-
* exposing the operation key and type of the calling operation.
|
|
31
|
-
*
|
|
32
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#operation-context | SWR Integration - Operation Context}
|
|
33
|
-
*/
|
|
34
|
-
interface OperationContext {
|
|
35
|
-
[OPERATION_CONTEXT_SYMBOL]?: {
|
|
36
|
-
key: unknown;
|
|
37
|
-
type: OperationType;
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
type KeyOptions<TInput> = undefined extends TInput ? {
|
|
41
|
-
input?: TInput;
|
|
42
|
-
} : {
|
|
43
|
-
input: TInput;
|
|
44
|
-
};
|
|
45
|
-
type MatcherStrategy = 'exact' | 'partial';
|
|
46
|
-
type MatcherOptions<TStrategy extends MatcherStrategy, TInput> = ('partial' extends TStrategy ? {
|
|
47
|
-
input?: PartialDeep<TInput> | undefined;
|
|
48
|
-
} : undefined extends TInput ? {
|
|
49
|
-
input?: TInput;
|
|
50
|
-
} : {
|
|
51
|
-
input: TInput;
|
|
52
|
-
}) & {
|
|
53
|
-
strategy?: TStrategy | undefined;
|
|
54
|
-
};
|
|
55
|
-
type Matcher = (key?: unknown) => boolean;
|
|
56
|
-
type FetcherOptions<TClientContext extends ClientContext> = object extends TClientContext ? {
|
|
57
|
-
context?: TClientContext | undefined;
|
|
58
|
-
} : {
|
|
59
|
-
context: TClientContext;
|
|
60
|
-
};
|
|
61
|
-
type SubscriberOptions<TClientContext extends ClientContext> = FetcherOptions<TClientContext> & {
|
|
62
|
-
/**
|
|
63
|
-
* Determines how data is handled when the subscription is subscribed again
|
|
64
|
-
*
|
|
65
|
-
* - `'reset'`: Clears existing data before streaming new data.
|
|
66
|
-
* - `'append'`: Adds new streamed chunks to the existing data.
|
|
67
|
-
* - `'replace'`: Buffers streamed data and replaces existing data after the stream completes.
|
|
68
|
-
*
|
|
69
|
-
* @default 'reset'
|
|
70
|
-
*/
|
|
71
|
-
refetchMode?: 'append' | 'reset' | 'replace' | undefined;
|
|
72
|
-
/**
|
|
73
|
-
* Maximum number of chunks to store.
|
|
74
|
-
* When exceeded, the oldest chunks will be removed.
|
|
75
|
-
*/
|
|
76
|
-
maxChunks?: number | undefined;
|
|
77
|
-
};
|
|
78
|
-
type MutatorOptions<TClientContext extends ClientContext> = FetcherOptions<TClientContext>;
|
|
79
|
-
type Fetcher<TInput, TOutput> = (key: OperationKey<TInput>) => Promise<TOutput>;
|
|
80
|
-
type Mutator<TInput, TOutput> = (key: unknown, options: Readonly<{
|
|
81
|
-
arg: TInput;
|
|
82
|
-
}>) => Promise<TOutput>;
|
|
83
|
-
type Subscriber<TInput, TData, TError> = (key: OperationKey<TInput>, options: SWRSubscriptionOptions<TData, TError>) => (() => void);
|
|
84
|
-
|
|
85
|
-
declare class SharedUtils<TInput> {
|
|
86
|
-
protected readonly path: string[];
|
|
87
|
-
protected readonly options: OperationKeyPrefixOptions;
|
|
88
|
-
constructor(path: string[], options: OperationKeyPrefixOptions);
|
|
89
|
-
/**
|
|
90
|
-
* Generate a matcher function that returns `true` if the key matches the specified conditions.
|
|
91
|
-
*
|
|
92
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#manual-revalidation | SWR Integration - Manual Revalidation}
|
|
93
|
-
*/
|
|
94
|
-
matcher<TStrategy extends MatcherStrategy>(...rest: MaybeOptionalOptions<MatcherOptions<TStrategy, TInput>>): Matcher;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
interface ProcedureUtilsOptions extends OperationKeyPrefixOptions {
|
|
98
|
-
}
|
|
99
|
-
declare class ProcedureUtils<TClientContext extends ClientContext, TInput, TOutput, TError> extends SharedUtils<TInput> {
|
|
100
|
-
/**
|
|
101
|
-
* Calling corresponding procedure client
|
|
102
|
-
*
|
|
103
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#calling-clients | SWR Integration - Calling Clients}
|
|
104
|
-
*/
|
|
105
|
-
call: Client<TClientContext, TInput, TOutput, TError>;
|
|
106
|
-
constructor(path: string[], client: Client<TClientContext, TInput, TOutput, TError>, options?: ProcedureUtilsOptions);
|
|
107
|
-
/**
|
|
108
|
-
* Generate a **full matching** key for SWR operations.
|
|
109
|
-
*
|
|
110
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#data-fetching | SWR Integration - Data Fetching}
|
|
111
|
-
*/
|
|
112
|
-
key(...rest: MaybeOptionalOptions<KeyOptions<TInput>>): OperationKey<TInput>;
|
|
113
|
-
/**
|
|
114
|
-
* Generate a fetcher function for use with useSWR, useSWRInfinite, and other SWR hooks.
|
|
115
|
-
*
|
|
116
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#data-fetching | SWR Integration - Data Fetching}
|
|
117
|
-
*/
|
|
118
|
-
fetcher(...rest: MaybeOptionalOptions<FetcherOptions<TClientContext>>): Fetcher<TInput, TOutput>;
|
|
119
|
-
/**
|
|
120
|
-
* Generate a subscriber function that subscribes to an [AsyncIteratorObject](https://orpc.dev/docs/async-iterator-object) for use with useSWRSubscription, etc.
|
|
121
|
-
*
|
|
122
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#subscriptions | SWR Integration - Subscriptions}
|
|
123
|
-
*/
|
|
124
|
-
subscriber(...rest: MaybeOptionalOptions<SubscriberOptions<TClientContext>>): Subscriber<TInput, InferSubscriberOutput<TOutput>, TError>;
|
|
125
|
-
/**
|
|
126
|
-
* Generate a live subscriber that subscribes to the latest events from an [AsyncIteratorObject](https://orpc.dev/docs/async-iterator-object) for use with useSWRSubscription, etc.
|
|
127
|
-
*
|
|
128
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#subscriptions | SWR Integration - Subscriptions}
|
|
129
|
-
*/
|
|
130
|
-
liveSubscriber(...rest: MaybeOptionalOptions<FetcherOptions<TClientContext>>): Subscriber<TInput, InferLiveSubscriberOutput<TOutput>, TError>;
|
|
131
|
-
/**
|
|
132
|
-
* Generate a mutator function for use with useSWRMutation, etc.
|
|
133
|
-
*
|
|
134
|
-
* @see {@link https://orpc.dev/docs/integrations/swr#mutations | SWR Integration - Mutations}
|
|
135
|
-
*/
|
|
136
|
-
mutator(...rest: MaybeOptionalOptions<MutatorOptions<TClientContext>>): Mutator<TInput, TOutput>;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
type RouterUtils<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? Public<ProcedureUtils<UClientContext, UInput, UOutput, UError>> : {
|
|
140
|
-
[K in keyof T]: T[K] extends AnyNestedClient ? RouterUtils<T[K]> : never;
|
|
141
|
-
} & Public<SharedUtils<unknown>>;
|
|
142
|
-
interface RouterUtilsOptions extends OperationKeyPrefixOptions {
|
|
143
|
-
/**
|
|
144
|
-
* Base path for all keys.
|
|
145
|
-
*
|
|
146
|
-
* @internal
|
|
147
|
-
*/
|
|
148
|
-
path?: string[] | undefined;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Creates SWR utils from a client, exposing fetcher/mutator/subscriber
|
|
152
|
-
* helpers for every procedure in the router.
|
|
153
|
-
*
|
|
154
|
-
* @remarks
|
|
155
|
-
* **Note**: Both client-side and server-side clients are supported.
|
|
156
|
-
*
|
|
157
|
-
* @see {@link https://orpc.dev/docs/integrations/swr | SWR Integration}
|
|
158
|
-
*/
|
|
159
|
-
declare function createRouterUtils<T extends AnyNestedClient>(client: T, options?: RouterUtilsOptions): RouterUtils<T>;
|
|
160
|
-
|
|
161
|
-
export { OPERATION_CONTEXT_SYMBOL, ProcedureUtils, OPERATION_CONTEXT_SYMBOL as SWR_OPERATION_CONTEXT_SYMBOL, SharedUtils, createRouterUtils, createRouterUtils as createSWRUtils };
|
|
162
|
-
export type { Fetcher, FetcherOptions, InferLiveSubscriberOutput, InferSubscriberOutput, KeyOptions, Matcher, MatcherOptions, MatcherStrategy, Mutator, MutatorOptions, OperationContext, OperationKey, OperationKeyOptions, OperationKeyPrefixOptions, OperationType, ProcedureUtilsOptions, RouterUtils, RouterUtilsOptions, OperationContext as SWROperationContext, Subscriber, SubscriberOptions };
|