effect-orpc 0.1.4 → 0.2.1
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 +95 -0
- package/dist/index.js +806 -476
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/contract.ts +491 -0
- package/src/effect-builder.ts +349 -619
- package/src/effect-enhance-router.ts +20 -21
- package/src/effect-procedure.ts +274 -263
- package/src/effect-runtime.ts +134 -0
- package/src/eoc.ts +499 -0
- package/src/extension/compose-surfaces.ts +15 -0
- package/src/extension/create-node-proxy.ts +270 -0
- package/src/extension/state.ts +108 -0
- package/src/index.ts +20 -3
- package/src/tagged-error.ts +24 -4
- package/src/tests/contract.test.ts +346 -0
- package/src/tests/effect-builder.proxy.test.ts +253 -0
- package/src/tests/effect-error-map.test.ts +22 -3
- package/src/tests/parity-shared.ts +32 -0
- package/src/tests/parity.contract-builder-variants.test.ts +192 -0
- package/src/tests/parity.contract-builder.test.ts +222 -0
- package/src/tests/parity.effect-builder.test.ts +210 -0
- package/src/tests/parity.effect-procedure.test.ts +124 -0
- package/src/tests/parity.implementer-variants.test.ts +249 -0
- package/src/tests/parity.implementer.test.ts +280 -0
- package/src/tests/shared.ts +2 -0
- package/src/types/effect-builder-surface.ts +441 -0
- package/src/types/effect-procedure-surface.ts +243 -0
- package/src/types/index.ts +22 -26
- package/src/types/variants.ts +100 -16
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import {
|
|
2
|
+
effectInternalsSymbol,
|
|
3
|
+
getEffectInternals,
|
|
4
|
+
type EffectExtensionState,
|
|
5
|
+
type EffectProxyTarget,
|
|
6
|
+
} from "./state";
|
|
7
|
+
|
|
8
|
+
const unhandledProperty = Symbol("effect-orpc/unhandledProperty");
|
|
9
|
+
|
|
10
|
+
export type UnhandledProperty = typeof unhandledProperty;
|
|
11
|
+
|
|
12
|
+
export interface NodeProxyContext<
|
|
13
|
+
TTarget extends EffectProxyTarget<TSource>,
|
|
14
|
+
TSource extends object,
|
|
15
|
+
> {
|
|
16
|
+
methodCache: Map<PropertyKey, unknown>;
|
|
17
|
+
state: EffectExtensionState;
|
|
18
|
+
target: TTarget;
|
|
19
|
+
upstream: TSource;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface NodeProxyInternalConfig<
|
|
23
|
+
TTarget extends EffectProxyTarget<TSource>,
|
|
24
|
+
TSource extends object,
|
|
25
|
+
> {
|
|
26
|
+
getProperty?: (
|
|
27
|
+
context: NodeProxyContext<TTarget, TSource>,
|
|
28
|
+
prop: PropertyKey,
|
|
29
|
+
receiver: unknown,
|
|
30
|
+
) => unknown | UnhandledProperty;
|
|
31
|
+
getVirtual?: (
|
|
32
|
+
context: NodeProxyContext<TTarget, TSource>,
|
|
33
|
+
prop: PropertyKey,
|
|
34
|
+
receiver: unknown,
|
|
35
|
+
) => unknown | UnhandledProperty;
|
|
36
|
+
virtualDescriptors?: Partial<
|
|
37
|
+
Record<string | symbol, Pick<PropertyDescriptor, "enumerable">>
|
|
38
|
+
>;
|
|
39
|
+
virtualKeys?: readonly (string | symbol)[];
|
|
40
|
+
wrapResult?: (
|
|
41
|
+
context: NodeProxyContext<TTarget, TSource>,
|
|
42
|
+
prop: PropertyKey,
|
|
43
|
+
result: unknown,
|
|
44
|
+
receiver: unknown,
|
|
45
|
+
) => unknown;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Configures how an Effect-aware node proxy exposes virtual properties and
|
|
50
|
+
* rewrites returned values while the upstream builder/procedure remains the
|
|
51
|
+
* source of truth for passthrough behavior.
|
|
52
|
+
*/
|
|
53
|
+
export interface NodeProxyConfig<
|
|
54
|
+
TTarget extends EffectProxyTarget<TSource>,
|
|
55
|
+
TSource extends object,
|
|
56
|
+
> extends NodeProxyInternalConfig<TTarget, TSource> {
|
|
57
|
+
/**
|
|
58
|
+
* Returns a value for virtual properties such as `~effect` or custom
|
|
59
|
+
* proxy-backed methods. Return `unhandled()` to fall back to the next step.
|
|
60
|
+
*/
|
|
61
|
+
getVirtual?: (
|
|
62
|
+
context: NodeProxyContext<TTarget, TSource>,
|
|
63
|
+
prop: PropertyKey,
|
|
64
|
+
receiver: unknown,
|
|
65
|
+
) => unknown | UnhandledProperty;
|
|
66
|
+
/**
|
|
67
|
+
* Intercepts property access before upstream passthrough. Return
|
|
68
|
+
* `unhandled()` to delegate to the wrapped upstream node.
|
|
69
|
+
*/
|
|
70
|
+
getProperty?: (
|
|
71
|
+
context: NodeProxyContext<TTarget, TSource>,
|
|
72
|
+
prop: PropertyKey,
|
|
73
|
+
receiver: unknown,
|
|
74
|
+
) => unknown | UnhandledProperty;
|
|
75
|
+
/**
|
|
76
|
+
* Declares which virtual keys should appear in reflection APIs like `in`,
|
|
77
|
+
* `Object.keys`, and descriptor lookup.
|
|
78
|
+
*/
|
|
79
|
+
virtualKeys?: readonly (string | symbol)[];
|
|
80
|
+
/**
|
|
81
|
+
* Controls enumerability for virtual keys exposed through the proxy.
|
|
82
|
+
*/
|
|
83
|
+
virtualDescriptors?: Partial<
|
|
84
|
+
Record<string | symbol, Pick<PropertyDescriptor, "enumerable">>
|
|
85
|
+
>;
|
|
86
|
+
/**
|
|
87
|
+
* Rewraps upstream method results when they should stay inside the Effect
|
|
88
|
+
* extension model.
|
|
89
|
+
*/
|
|
90
|
+
wrapResult?: (
|
|
91
|
+
context: NodeProxyContext<TTarget, TSource>,
|
|
92
|
+
prop: PropertyKey,
|
|
93
|
+
result: unknown,
|
|
94
|
+
receiver: unknown,
|
|
95
|
+
) => unknown;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function createNodeProxyContext<
|
|
99
|
+
TTarget extends EffectProxyTarget<TSource>,
|
|
100
|
+
TSource extends object,
|
|
101
|
+
>(target: TTarget): NodeProxyContext<TTarget, TSource> {
|
|
102
|
+
const internals = getEffectInternals(target);
|
|
103
|
+
return {
|
|
104
|
+
methodCache: internals.methodCache,
|
|
105
|
+
state: internals.state,
|
|
106
|
+
target,
|
|
107
|
+
upstream: internals.upstream as TSource,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function createBoundMethod<
|
|
112
|
+
TTarget extends EffectProxyTarget<TSource>,
|
|
113
|
+
TSource extends object,
|
|
114
|
+
>(
|
|
115
|
+
context: NodeProxyContext<TTarget, TSource>,
|
|
116
|
+
prop: PropertyKey,
|
|
117
|
+
value: (...args: unknown[]) => unknown,
|
|
118
|
+
config: NodeProxyInternalConfig<TTarget, TSource>,
|
|
119
|
+
receiver: unknown,
|
|
120
|
+
): (...args: unknown[]) => unknown {
|
|
121
|
+
const cache = context.methodCache;
|
|
122
|
+
if (cache.has(prop)) {
|
|
123
|
+
return cache.get(prop) as (...args: unknown[]) => unknown;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const wrapped = (...args: unknown[]) => {
|
|
127
|
+
const result = Reflect.apply(value, context.upstream, args);
|
|
128
|
+
return config.wrapResult?.(context, prop, result, receiver) ?? result;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
cache.set(prop, wrapped);
|
|
132
|
+
return wrapped;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Creates an Effect-aware proxy around a local shell object.
|
|
137
|
+
*
|
|
138
|
+
* @param target The local Effect wrapper instance that already has upstream and
|
|
139
|
+
* state symbols attached via `attachEffectState`.
|
|
140
|
+
* @param config The extension hooks that define virtual properties,
|
|
141
|
+
* interception points, and result rewrapping behavior for the proxy.
|
|
142
|
+
*/
|
|
143
|
+
export function createNodeProxy<
|
|
144
|
+
TTarget extends EffectProxyTarget<TSource>,
|
|
145
|
+
TSource extends object,
|
|
146
|
+
>(target: TTarget, config: NodeProxyConfig<TTarget, TSource>): TTarget {
|
|
147
|
+
const privateKeys = new Set<PropertyKey>([effectInternalsSymbol]);
|
|
148
|
+
const virtualKeys = new Set(config.virtualKeys ?? []);
|
|
149
|
+
|
|
150
|
+
return new Proxy(target, {
|
|
151
|
+
get(currentTarget, prop, receiver) {
|
|
152
|
+
if (privateKeys.has(prop)) {
|
|
153
|
+
return Reflect.get(currentTarget, prop, receiver);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const context = createNodeProxyContext<TTarget, TSource>(
|
|
157
|
+
currentTarget as TTarget,
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
const virtualValue = config.getVirtual?.(context, prop, receiver);
|
|
161
|
+
if (virtualValue !== undefined && virtualValue !== unhandledProperty) {
|
|
162
|
+
return virtualValue;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const propertyValue = config.getProperty?.(context, prop, receiver);
|
|
166
|
+
if (propertyValue !== undefined && propertyValue !== unhandledProperty) {
|
|
167
|
+
return propertyValue;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const sourceValue = Reflect.get(context.upstream, prop, context.upstream);
|
|
171
|
+
|
|
172
|
+
if (Reflect.has(context.upstream, prop)) {
|
|
173
|
+
if (typeof sourceValue === "function") {
|
|
174
|
+
return createBoundMethod(
|
|
175
|
+
context,
|
|
176
|
+
prop,
|
|
177
|
+
sourceValue as (...args: unknown[]) => unknown,
|
|
178
|
+
config,
|
|
179
|
+
receiver,
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return sourceValue;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return Reflect.get(currentTarget, prop, receiver);
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
has(currentTarget, prop) {
|
|
190
|
+
if (virtualKeys.has(prop)) {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const context = createNodeProxyContext<TTarget, TSource>(currentTarget);
|
|
195
|
+
return (
|
|
196
|
+
Reflect.has(context.upstream, prop) || Reflect.has(currentTarget, prop)
|
|
197
|
+
);
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
ownKeys(currentTarget) {
|
|
201
|
+
const keys = new Set<string | symbol>();
|
|
202
|
+
|
|
203
|
+
for (const key of Reflect.ownKeys(currentTarget)) {
|
|
204
|
+
if (!privateKeys.has(key)) {
|
|
205
|
+
keys.add(key);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
const context = createNodeProxyContext<TTarget, TSource>(
|
|
210
|
+
currentTarget as TTarget,
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
for (const key of Reflect.ownKeys(context.upstream)) {
|
|
214
|
+
keys.add(key);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
for (const key of virtualKeys) {
|
|
218
|
+
keys.add(key);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
return [...keys];
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
getOwnPropertyDescriptor(currentTarget, prop) {
|
|
225
|
+
const context = createNodeProxyContext<TTarget, TSource>(
|
|
226
|
+
currentTarget as TTarget,
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
if (virtualKeys.has(prop)) {
|
|
230
|
+
const value = config.getVirtual?.(context, prop, currentTarget);
|
|
231
|
+
if (value !== undefined && value !== unhandledProperty) {
|
|
232
|
+
return {
|
|
233
|
+
configurable: true,
|
|
234
|
+
enumerable: config.virtualDescriptors?.[prop]?.enumerable ?? false,
|
|
235
|
+
value,
|
|
236
|
+
writable: false,
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(
|
|
242
|
+
context.upstream,
|
|
243
|
+
prop,
|
|
244
|
+
);
|
|
245
|
+
|
|
246
|
+
if (descriptor === undefined) {
|
|
247
|
+
return Reflect.getOwnPropertyDescriptor(currentTarget, prop);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if ("value" in descriptor && typeof descriptor.value === "function") {
|
|
251
|
+
return {
|
|
252
|
+
...descriptor,
|
|
253
|
+
value: createBoundMethod(
|
|
254
|
+
context,
|
|
255
|
+
prop,
|
|
256
|
+
descriptor.value as (...args: unknown[]) => unknown,
|
|
257
|
+
config,
|
|
258
|
+
currentTarget,
|
|
259
|
+
),
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return descriptor;
|
|
264
|
+
},
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export function unhandled(): UnhandledProperty {
|
|
269
|
+
return unhandledProperty;
|
|
270
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { ManagedRuntime } from "effect";
|
|
2
|
+
|
|
3
|
+
import type { EffectErrorMap } from "../tagged-error";
|
|
4
|
+
import type { EffectSpanConfig } from "../types";
|
|
5
|
+
|
|
6
|
+
export interface EffectExtensionState<
|
|
7
|
+
TRequirementsProvided = any,
|
|
8
|
+
TRuntimeError = any,
|
|
9
|
+
> {
|
|
10
|
+
/**
|
|
11
|
+
* Extended error map that supports both traditional oRPC errors and ORPCTaggedError classes.
|
|
12
|
+
* @see {@link EffectErrorMap}
|
|
13
|
+
*/
|
|
14
|
+
effectErrorMap: EffectErrorMap;
|
|
15
|
+
/**
|
|
16
|
+
* The Effect ManagedRuntime that provides services for Effect procedures.
|
|
17
|
+
* @see {@link ManagedRuntime.ManagedRuntime}
|
|
18
|
+
*/
|
|
19
|
+
runtime: ManagedRuntime.ManagedRuntime<TRequirementsProvided, TRuntimeError>;
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for Effect span tracing.
|
|
22
|
+
* @see {@link EffectSpanConfig}
|
|
23
|
+
*/
|
|
24
|
+
spanConfig?: EffectSpanConfig;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface EffectInternals<TUpstream extends object = object> {
|
|
28
|
+
upstream: TUpstream;
|
|
29
|
+
state: EffectExtensionState;
|
|
30
|
+
methodCache: Map<PropertyKey, unknown>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const effectInternalsSymbol = Symbol("effect-orpc/internals");
|
|
34
|
+
|
|
35
|
+
export interface EffectProxyTarget<TUpstream extends object = object> {
|
|
36
|
+
[effectInternalsSymbol]: EffectInternals<TUpstream>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function attachEffectState<
|
|
40
|
+
TTarget extends object,
|
|
41
|
+
TUpstream extends object,
|
|
42
|
+
>(
|
|
43
|
+
target: TTarget,
|
|
44
|
+
upstream: TUpstream,
|
|
45
|
+
state: EffectExtensionState,
|
|
46
|
+
): asserts target is TTarget & EffectProxyTarget<TUpstream> {
|
|
47
|
+
Object.defineProperties(target, {
|
|
48
|
+
[effectInternalsSymbol]: {
|
|
49
|
+
configurable: true,
|
|
50
|
+
value: {
|
|
51
|
+
methodCache: new Map<PropertyKey, unknown>(),
|
|
52
|
+
state,
|
|
53
|
+
upstream,
|
|
54
|
+
} satisfies EffectInternals<TUpstream>,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function getEffectInternals<TUpstream extends object>(
|
|
60
|
+
target: EffectProxyTarget<TUpstream>,
|
|
61
|
+
): EffectInternals<TUpstream> {
|
|
62
|
+
return target[effectInternalsSymbol];
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function getEffectUpstream<TUpstream extends object>(
|
|
66
|
+
target: EffectProxyTarget<TUpstream>,
|
|
67
|
+
): TUpstream {
|
|
68
|
+
return getEffectInternals(target).upstream;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function getEffectState(
|
|
72
|
+
target: EffectProxyTarget,
|
|
73
|
+
): EffectExtensionState {
|
|
74
|
+
return getEffectInternals(target).state;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function getEffectMethodCache(
|
|
78
|
+
target: EffectProxyTarget,
|
|
79
|
+
): Map<PropertyKey, unknown> {
|
|
80
|
+
return getEffectInternals(target).methodCache;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function hasEffectState(value: unknown): value is EffectProxyTarget {
|
|
84
|
+
return (
|
|
85
|
+
typeof value === "object" &&
|
|
86
|
+
value !== null &&
|
|
87
|
+
effectInternalsSymbol in (value as object)
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function assertEffectState<TUpstream extends object>(
|
|
92
|
+
value: object,
|
|
93
|
+
): asserts value is EffectProxyTarget<TUpstream> {
|
|
94
|
+
if (!hasEffectState(value)) {
|
|
95
|
+
throw new Error("Expected effect state to be attached");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function getEffectErrorMap(value: {
|
|
100
|
+
"~effect"?: { effectErrorMap: EffectErrorMap };
|
|
101
|
+
"~orpc": { errorMap: EffectErrorMap };
|
|
102
|
+
}): EffectErrorMap {
|
|
103
|
+
return value["~effect"]?.effectErrorMap ?? value["~orpc"].errorMap;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function unwrapEffectUpstream<T extends object>(value: T): T {
|
|
107
|
+
return hasEffectState(value) ? (getEffectUpstream(value) as T) : value;
|
|
108
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
export { implementEffect } from "./contract";
|
|
2
|
+
export type {
|
|
3
|
+
EffectImplementer,
|
|
4
|
+
EffectImplementerInternal,
|
|
5
|
+
EffectProcedureImplementer,
|
|
6
|
+
} from "./contract";
|
|
7
|
+
export { eoc } from "./eoc";
|
|
8
|
+
export type {
|
|
9
|
+
EffectContractBuilder,
|
|
10
|
+
EffectContractProcedureBuilder,
|
|
11
|
+
EffectContractProcedureBuilderWithInput,
|
|
12
|
+
EffectContractProcedureBuilderWithInputOutput,
|
|
13
|
+
EffectContractProcedureBuilderWithOutput,
|
|
14
|
+
EffectContractRouterBuilder,
|
|
15
|
+
} from "./eoc";
|
|
1
16
|
export {
|
|
2
17
|
addSpanStackTrace,
|
|
3
18
|
EffectBuilder,
|
|
@@ -30,6 +45,8 @@ export type {
|
|
|
30
45
|
export type {
|
|
31
46
|
AnyBuilderLike,
|
|
32
47
|
EffectBuilderDef,
|
|
48
|
+
EffectBuilderSurface,
|
|
49
|
+
EffectDecoratedProcedureSurface,
|
|
33
50
|
EffectBuilderWithMiddlewares,
|
|
34
51
|
EffectErrorMapToErrorMap,
|
|
35
52
|
EffectProcedureBuilder,
|
|
@@ -40,10 +57,10 @@ export type {
|
|
|
40
57
|
EffectProcedureHandler,
|
|
41
58
|
EffectRouterBuilder,
|
|
42
59
|
EffectSpanConfig,
|
|
43
|
-
InferBuilderInitialContext,
|
|
44
60
|
InferBuilderCurrentContext,
|
|
45
|
-
InferBuilderInputSchema,
|
|
46
|
-
InferBuilderOutputSchema,
|
|
47
61
|
InferBuilderErrorMap,
|
|
62
|
+
InferBuilderInitialContext,
|
|
63
|
+
InferBuilderInputSchema,
|
|
48
64
|
InferBuilderMeta,
|
|
65
|
+
InferBuilderOutputSchema,
|
|
49
66
|
} from "./types";
|
package/src/tagged-error.ts
CHANGED
|
@@ -15,7 +15,6 @@ import type {
|
|
|
15
15
|
ErrorMapItem,
|
|
16
16
|
InferSchemaOutput,
|
|
17
17
|
} from "@orpc/contract";
|
|
18
|
-
import type { ORPCErrorConstructorMap } from "@orpc/server";
|
|
19
18
|
import type { MaybeOptionalOptions } from "@orpc/shared";
|
|
20
19
|
import { resolveMaybeOptionalOptions } from "@orpc/shared";
|
|
21
20
|
import type { Pipeable } from "effect";
|
|
@@ -433,8 +432,29 @@ export type EffectErrorMapToUnion<T extends EffectErrorMap> = {
|
|
|
433
432
|
/**
|
|
434
433
|
* Constructor map for EffectErrorMap - provides typed error constructors for handlers.
|
|
435
434
|
*/
|
|
436
|
-
|
|
437
|
-
|
|
435
|
+
type EffectErrorConstructor<
|
|
436
|
+
TCode extends ORPCErrorCode,
|
|
437
|
+
TItem,
|
|
438
|
+
> = TItem extends AnyORPCTaggedErrorClass
|
|
439
|
+
? (...args: ConstructorParameters<TItem>) => InstanceType<TItem>
|
|
440
|
+
: TItem extends { data?: infer TSchema extends AnySchema }
|
|
441
|
+
? (
|
|
442
|
+
...rest: MaybeOptionalOptions<
|
|
443
|
+
Omit<
|
|
444
|
+
ORPCErrorOptions<InferSchemaOutput<TSchema>>,
|
|
445
|
+
"defined" | "status"
|
|
446
|
+
>
|
|
447
|
+
>
|
|
448
|
+
) => ORPCError<TCode, InferSchemaOutput<TSchema>>
|
|
449
|
+
: (
|
|
450
|
+
...rest: MaybeOptionalOptions<
|
|
451
|
+
Omit<ORPCErrorOptions<unknown>, "defined" | "status">
|
|
452
|
+
>
|
|
453
|
+
) => ORPCError<TCode, unknown>;
|
|
454
|
+
|
|
455
|
+
export type EffectErrorConstructorMap<T extends EffectErrorMap> = {
|
|
456
|
+
[K in Extract<keyof T, ORPCErrorCode>]: EffectErrorConstructor<K, T[K]>;
|
|
457
|
+
};
|
|
438
458
|
|
|
439
459
|
/**
|
|
440
460
|
* Creates an error constructor map from an EffectErrorMap.
|
|
@@ -478,7 +498,7 @@ export function createEffectErrorConstructorMap<T extends EffectErrorMap>(
|
|
|
478
498
|
},
|
|
479
499
|
});
|
|
480
500
|
|
|
481
|
-
return proxy as EffectErrorConstructorMap<T>;
|
|
501
|
+
return proxy as unknown as EffectErrorConstructorMap<T>;
|
|
482
502
|
}
|
|
483
503
|
|
|
484
504
|
/**
|