@dr_nikson/effect-grpc 0.2.0-mvp-9971208edee70b39058f12d8c2a1fcfaeecd3b51 → 3.0.0-mvp-e2b78b1c4be4bb339577d68dfce008ef1b56218c
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 +928 -0
- package/dist/client.internal.d.ts.map +1 -1
- package/dist/client.internal.js +2 -1
- package/dist/client.internal.js.map +1 -1
- package/dist/client.js +3 -0
- package/dist/client.js.map +1 -1
- package/dist/grpcException.d.ts +243 -0
- package/dist/grpcException.d.ts.map +1 -0
- package/dist/grpcException.internal.d.ts +28 -0
- package/dist/grpcException.internal.d.ts.map +1 -0
- package/dist/grpcException.internal.js +72 -0
- package/dist/grpcException.internal.js.map +1 -0
- package/dist/grpcException.js +218 -0
- package/dist/grpcException.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/protoRuntime.d.ts +5 -4
- package/dist/protoRuntime.d.ts.map +1 -1
- package/dist/protoRuntime.internal.d.ts +4 -3
- package/dist/protoRuntime.internal.d.ts.map +1 -1
- package/dist/protoRuntime.internal.js +16 -2
- package/dist/protoRuntime.internal.js.map +1 -1
- package/dist/protoRuntime.js +2 -0
- package/dist/protoRuntime.js.map +1 -1
- package/dist/protocGenPlugin.d.ts.map +1 -1
- package/dist/protocGenPlugin.js +3 -3
- package/dist/protocGenPlugin.js.map +1 -1
- package/dist/server.d.ts +8 -4
- package/dist/server.d.ts.map +1 -1
- package/dist/server.internal.d.ts +5 -4
- package/dist/server.internal.d.ts.map +1 -1
- package/dist/server.internal.js +7 -8
- package/dist/server.internal.js.map +1 -1
- package/dist/server.js +4 -0
- package/dist/server.js.map +1 -1
- package/dist/typeUtils.js +1 -1
- package/dist/typeUtils.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.internal.d.ts","sourceRoot":"","sources":["../src/client.internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"client.internal.d.ts","sourceRoot":"","sources":["../src/client.internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,KAAK,EAAE,MAAM,QAAQ,CAAC;AAQhD,OAAO,KAAK,KAAK,CAAC,MAAM,aAAa,CAAC;AAGtC,eAAO,MAAM,uBAAuB,eAAqD,CAAC;AAE1F,eAAO,MAAM,oBAAoB,uDAEhC,CAAC;AAGF,wBAAgB,qBAAqB,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,CA8BxE;AAoCD,wBAAgB,uBAAuB,CAAC,OAAO,SAAS,MAAM,EAAE,OAAO,EAAE,OAAO,yEAI/E;AAED,wBAAgB,oBAAoB,CAAC,OAAO,SAAS,MAAM,EACzD,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,EAAE,UAAU,CAAC,GAK9C,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CACjC"}
|
package/dist/client.internal.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Context, Effect, Layer } from "effect";
|
|
2
|
-
import { createClient, createContextValues
|
|
2
|
+
import { createClient, createContextValues } from "@connectrpc/connect";
|
|
3
3
|
import { createGrpcTransport } from "@connectrpc/connect-node";
|
|
4
|
+
import * as protoRuntime from "./protoRuntime.js";
|
|
4
5
|
export const grpcClientRuntimeTypeId = Symbol("@dr_nikson/effect-grpc/GrpcClientRuntime");
|
|
5
6
|
export const grpcClientRuntimeTag = Context.GenericTag(grpcClientRuntimeTypeId.toString());
|
|
6
7
|
// TODO: this abstraction is kinda useless, right? We can make more in use .. can we?
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.internal.js","sourceRoot":"","sources":["../src/client.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CHANGED
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,qCAAqC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAIvD,OAAO,EAAsB,MAAM,qBAAqB,CAAC;AAGzD,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAwCjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAC5B,QAAQ,CAAC,oBAAoB,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAEnC,QAAQ,CAAC,qBAAqB,CAAC;AAmEnC,MAAM,CAAC,MAAM,gBAAgB,GAQzB,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;IAC1D,OAAO,EAAE,QAAQ,CAAC,uBAAuB;CAC1C,CAAC,CAAC"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
import type { Code, ConnectError } from "@connectrpc/connect";
|
|
2
|
+
declare const GrpcException_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
|
|
3
|
+
readonly _tag: "@dr_nikson/effect-grpc/grpcException/GrpcException";
|
|
4
|
+
} & Readonly<A>;
|
|
5
|
+
/**
|
|
6
|
+
* A high-level error type for gRPC operations in Effect programs.
|
|
7
|
+
*
|
|
8
|
+
* GrpcException is a tagged error that extends Data.TaggedError, designed as part of the DSL
|
|
9
|
+
* for gRPC error handling. It focuses on application-level concerns (code, message, description, cause)
|
|
10
|
+
* rather than low-level wire-format details.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { Effect } from "effect";
|
|
15
|
+
* import { GrpcException } from "@dr_nikson/effect-grpc";
|
|
16
|
+
* import { Code } from "@connectrpc/connect";
|
|
17
|
+
*
|
|
18
|
+
* // Create an exception with a code and message
|
|
19
|
+
* const notFoundError = GrpcException.create(
|
|
20
|
+
* Code.NotFound,
|
|
21
|
+
* "User not found"
|
|
22
|
+
* );
|
|
23
|
+
*
|
|
24
|
+
* // Use in Effect programs with catchTag
|
|
25
|
+
* const program = Effect.gen(function* () {
|
|
26
|
+
* yield* notFoundError; // The error is yieldable
|
|
27
|
+
* yield* Effect.fail(notFoundError);
|
|
28
|
+
* }).pipe(
|
|
29
|
+
* Effect.catchTag(GrpcException, (error) => {
|
|
30
|
+
* console.log(`gRPC error [${Code[error.code]}]: ${error.message}`);
|
|
31
|
+
* return Effect.succeed("recovered");
|
|
32
|
+
* })
|
|
33
|
+
* );
|
|
34
|
+
*
|
|
35
|
+
* // Convert from unknown error
|
|
36
|
+
* try {
|
|
37
|
+
* // some operation
|
|
38
|
+
* } catch (error) {
|
|
39
|
+
* yield* GrpcException.from(Code.Internal, error);
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* // Add context with description
|
|
43
|
+
* const enriched = GrpcException.withDescription(
|
|
44
|
+
* notFoundError,
|
|
45
|
+
* "Database query failed"
|
|
46
|
+
* );
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @category Error Handling
|
|
50
|
+
* @since 0.2.0
|
|
51
|
+
*/
|
|
52
|
+
export declare class GrpcException extends GrpcException_base<{
|
|
53
|
+
/**
|
|
54
|
+
* The gRPC status code for this error.
|
|
55
|
+
*/
|
|
56
|
+
readonly code: Code;
|
|
57
|
+
/**
|
|
58
|
+
* The error message describing what went wrong.
|
|
59
|
+
*/
|
|
60
|
+
readonly message: string;
|
|
61
|
+
/**
|
|
62
|
+
* Optional description providing additional context about the error.
|
|
63
|
+
* This can be used to add higher-level context without modifying the original message.
|
|
64
|
+
*
|
|
65
|
+
* Unlike the message field, description can be easily modified as errors bubble up
|
|
66
|
+
* through the call stack using withDescription.
|
|
67
|
+
*/
|
|
68
|
+
readonly description?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Optional cause of this error.
|
|
71
|
+
* Used to chain errors and preserve the original error that caused this exception.
|
|
72
|
+
* Can be a native Error, Effect tagged error.
|
|
73
|
+
*/
|
|
74
|
+
readonly cause?: unknown;
|
|
75
|
+
}> {
|
|
76
|
+
/**
|
|
77
|
+
* Returns a formatted error message including the status code, message, and description (if present).
|
|
78
|
+
* This is called automatically when the error is converted to a string.
|
|
79
|
+
*
|
|
80
|
+
* Format:
|
|
81
|
+
* - Without description: "[code] message"
|
|
82
|
+
* - With description: "[code] message (description)"
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* import { GrpcException } from "@dr_nikson/effect-grpc";
|
|
87
|
+
* import { Code } from "@connectrpc/connect";
|
|
88
|
+
*
|
|
89
|
+
* const error1 = GrpcException.create(
|
|
90
|
+
* Code.NotFound,
|
|
91
|
+
* "User not found"
|
|
92
|
+
* );
|
|
93
|
+
* console.log(error1.toString());
|
|
94
|
+
* // Output: "[not_found] User not found"
|
|
95
|
+
*
|
|
96
|
+
* const error2 = GrpcException.withDescription(
|
|
97
|
+
* error1,
|
|
98
|
+
* "Database query failed"
|
|
99
|
+
* );
|
|
100
|
+
* console.log(error2.toString());
|
|
101
|
+
* // Output: "[not_found] User not found (Database query failed)"
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
toString(): string;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Creates a new GrpcException from the provided parameters.
|
|
108
|
+
*
|
|
109
|
+
* This is the primary constructor for creating GrpcException instances.
|
|
110
|
+
* Code and message are required; cause is optional.
|
|
111
|
+
*
|
|
112
|
+
* @param code - The gRPC status code (required)
|
|
113
|
+
* @param message - The error message (required)
|
|
114
|
+
* @param cause - Optional cause of the error
|
|
115
|
+
* @returns A new GrpcException instance
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```typescript
|
|
119
|
+
* import { GrpcException } from "@dr_nikson/effect-grpc";
|
|
120
|
+
* import { Code } from "@connectrpc/connect";
|
|
121
|
+
*
|
|
122
|
+
* // Simple error
|
|
123
|
+
* const error1 = GrpcException.create(
|
|
124
|
+
* Code.NotFound,
|
|
125
|
+
* "User not found"
|
|
126
|
+
* );
|
|
127
|
+
*
|
|
128
|
+
* // With cause
|
|
129
|
+
* try {
|
|
130
|
+
* // some operation
|
|
131
|
+
* } catch (err) {
|
|
132
|
+
* const error2 = GrpcException.create(
|
|
133
|
+
* Code.Internal,
|
|
134
|
+
* "Operation failed",
|
|
135
|
+
* err
|
|
136
|
+
* );
|
|
137
|
+
* }
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export declare const create: {
|
|
141
|
+
(code: Code, message: string, cause?: unknown): GrpcException;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Converts any value into a GrpcException, following these rules:
|
|
145
|
+
* - If the cause is a ConnectError, wraps it preserving code and message
|
|
146
|
+
* - For other Errors, creates a GrpcException with the error message and sets it as cause
|
|
147
|
+
* - For other values, converts to string and uses as message
|
|
148
|
+
*
|
|
149
|
+
* @param code - The gRPC status code to use (required)
|
|
150
|
+
* @param cause - The error/value to convert (native Error, ConnectError, or any value)
|
|
151
|
+
* @returns A GrpcException instance
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* import { Effect } from "effect";
|
|
156
|
+
* import { GrpcException } from "@dr_nikson/effect-grpc";
|
|
157
|
+
* import { Code, ConnectError } from "@connectrpc/connect";
|
|
158
|
+
*
|
|
159
|
+
* const handleError = (error: unknown) =>
|
|
160
|
+
* Effect.fail(GrpcException.from(Code.Internal, error));
|
|
161
|
+
*
|
|
162
|
+
* // From ConnectError - preserves code and message
|
|
163
|
+
* const connectErr = new ConnectError("Not found", Code.NotFound);
|
|
164
|
+
* const grpcErr1 = GrpcException.from(Code.Internal, connectErr);
|
|
165
|
+
* // grpcErr1.code === Code.NotFound (from ConnectError, not the parameter)
|
|
166
|
+
* // grpcErr1.message === "Not found"
|
|
167
|
+
*
|
|
168
|
+
* // From regular Error - sets as cause
|
|
169
|
+
* const regularErr = new Error("Network timeout");
|
|
170
|
+
* const grpcErr2 = GrpcException.from(Code.Unavailable, regularErr);
|
|
171
|
+
* // grpcErr2.code === Code.Unavailable
|
|
172
|
+
* // grpcErr2.message === "Network timeout"
|
|
173
|
+
* // grpcErr2.cause === regularErr
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export declare const from: {
|
|
177
|
+
(code: Code, cause: unknown): GrpcException;
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Sets or replaces the description field of a GrpcException.
|
|
181
|
+
* Returns a new GrpcException with the specified description.
|
|
182
|
+
*
|
|
183
|
+
* @param error - The GrpcException to modify
|
|
184
|
+
* @param description - The description to set
|
|
185
|
+
* @returns A new GrpcException with the description
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* import { GrpcException } from "@dr_nikson/effect-grpc";
|
|
190
|
+
* import { Code } from "@connectrpc/connect";
|
|
191
|
+
*
|
|
192
|
+
* const error = GrpcException.create(
|
|
193
|
+
* Code.NotFound,
|
|
194
|
+
* "User not found"
|
|
195
|
+
* );
|
|
196
|
+
* const enriched = GrpcException.withDescription(
|
|
197
|
+
* error,
|
|
198
|
+
* "Database query failed"
|
|
199
|
+
* );
|
|
200
|
+
* // enriched.description === "Database query failed"
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
export declare const withDescription: {
|
|
204
|
+
(error: GrpcException, description: string): GrpcException;
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Converts a GrpcException to a ConnectError for use with Connect-RPC.
|
|
208
|
+
* This is useful when you need to throw or return errors in Connect-RPC handlers.
|
|
209
|
+
*
|
|
210
|
+
* Only the code, message, and cause are preserved. Description is not included
|
|
211
|
+
* as ConnectError doesn't have a corresponding field.
|
|
212
|
+
*
|
|
213
|
+
* @param error - The GrpcException to convert
|
|
214
|
+
* @returns A ConnectError instance
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* ```typescript
|
|
218
|
+
* import { GrpcException } from "@dr_nikson/effect-grpc";
|
|
219
|
+
* import { Code } from "@connectrpc/connect";
|
|
220
|
+
*
|
|
221
|
+
* const error = GrpcException.create(
|
|
222
|
+
* Code.NotFound,
|
|
223
|
+
* "User not found"
|
|
224
|
+
* );
|
|
225
|
+
* const withDesc = GrpcException.withDescription(
|
|
226
|
+
* error,
|
|
227
|
+
* "Database query failed"
|
|
228
|
+
* );
|
|
229
|
+
*
|
|
230
|
+
* const connectError = GrpcException.toConnectError(withDesc);
|
|
231
|
+
* // connectError.code === Code.NotFound
|
|
232
|
+
* // connectError.rawMessage === "User not found"
|
|
233
|
+
* // Note: description is lost in conversion
|
|
234
|
+
*
|
|
235
|
+
* // Can be thrown in Connect-RPC handlers
|
|
236
|
+
* throw GrpcException.toConnectError(error);
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
export declare const toConnectError: {
|
|
240
|
+
(error: GrpcException): ConnectError;
|
|
241
|
+
};
|
|
242
|
+
export {};
|
|
243
|
+
//# sourceMappingURL=grpcException.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grpcException.d.ts","sourceRoot":"","sources":["../src/grpcException.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;;;;AAI9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,qBAAa,aAAc,SAAQ,mBAEjC;IACA;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;;;;;OAMG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAE9B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,QAAQ,IAAI,MAAM;CAUnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,MAAM,EAAE;IACnB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;CAC7C,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,IAAI,EAAE;IACjB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,GAAG,aAAa,CAAC;CAC7B,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,eAAe,EAAE;IAC5B,CAAC,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,GAAG,aAAa,CAAC;CACjC,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,cAAc,EAAE;IAC3B,CAAC,KAAK,EAAE,aAAa,GAAG,YAAY,CAAC;CACZ,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ConnectError } from "@connectrpc/connect";
|
|
2
|
+
import type { Code } from "@connectrpc/connect";
|
|
3
|
+
import { GrpcException } from "./grpcException.js";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export declare const create: (code: Code, message: string, cause?: unknown) => GrpcException;
|
|
8
|
+
/**
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare const from: (code: Code, cause: unknown) => GrpcException;
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare const withDescription: (error: GrpcException, description: string) => GrpcException;
|
|
16
|
+
/**
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export declare const toConnectError: (error: GrpcException) => ConnectError;
|
|
20
|
+
/**
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare const toString: (error: GrpcException) => string;
|
|
24
|
+
/**
|
|
25
|
+
* @internal
|
|
26
|
+
*/
|
|
27
|
+
export declare const inspect: (error: GrpcException) => string;
|
|
28
|
+
//# sourceMappingURL=grpcException.internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grpcException.internal.d.ts","sourceRoot":"","sources":["../src/grpcException.internal.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,MAAM,IAAI,EAAE,SAAS,MAAM,EAAE,QAAQ,OAAO,KAAG,aAErE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,IAAI,GAAI,MAAM,IAAI,EAAE,OAAO,OAAO,KAAG,aA2BjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,aAAa,EAAE,aAAa,MAAM,KAAG,aAO3E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,aAAa,KAAG,YAErD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,QAAQ,GAAI,OAAO,aAAa,KAAG,MAO/C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,aAAa,KAAG,MAE9C,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// packages/effect-grpc/src/grpcException.internal.ts
|
|
2
|
+
import { ConnectError } from "@connectrpc/connect";
|
|
3
|
+
import { GrpcException } from "./grpcException.js";
|
|
4
|
+
/**
|
|
5
|
+
* @internal
|
|
6
|
+
*/
|
|
7
|
+
export const create = (code, message, cause) => {
|
|
8
|
+
return new GrpcException({ code, message, cause });
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export const from = (code, cause) => {
|
|
14
|
+
// Handle ConnectError - preserve code and message
|
|
15
|
+
if (cause instanceof ConnectError) {
|
|
16
|
+
return new GrpcException({
|
|
17
|
+
code: cause.code,
|
|
18
|
+
message: cause.rawMessage,
|
|
19
|
+
cause,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
// Handle regular Error - use error message and set as cause
|
|
23
|
+
if (cause instanceof Error) {
|
|
24
|
+
return new GrpcException({
|
|
25
|
+
code,
|
|
26
|
+
message: cause.message,
|
|
27
|
+
cause,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
// For other values, convert to string and use as message
|
|
31
|
+
const message = String(cause);
|
|
32
|
+
return new GrpcException({
|
|
33
|
+
code,
|
|
34
|
+
message,
|
|
35
|
+
cause,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export const withDescription = (error, description) => {
|
|
42
|
+
return new GrpcException({
|
|
43
|
+
code: error.code,
|
|
44
|
+
message: error.message,
|
|
45
|
+
description,
|
|
46
|
+
cause: error.cause,
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
export const toConnectError = (error) => {
|
|
53
|
+
return new ConnectError(error.message, error.code, undefined, undefined, error.cause);
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
export const toString = (error) => {
|
|
59
|
+
const codeStr = error.code;
|
|
60
|
+
const parts = [`[${codeStr}]`, error.message];
|
|
61
|
+
if (error.description) {
|
|
62
|
+
parts.push(`(${error.description})`);
|
|
63
|
+
}
|
|
64
|
+
return parts.join(" ");
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* @internal
|
|
68
|
+
*/
|
|
69
|
+
export const inspect = (error) => {
|
|
70
|
+
return toString(error);
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=grpcException.internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grpcException.internal.js","sourceRoot":"","sources":["../src/grpcException.internal.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAGnD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;GAEG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,IAAU,EAAE,OAAe,EAAE,KAAe,EAAiB,EAAE;IACpF,OAAO,IAAI,aAAa,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;AACrD,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,IAAU,EAAE,KAAc,EAAiB,EAAE;IAChE,kDAAkD;IAClD,IAAI,KAAK,YAAY,YAAY,EAAE,CAAC;QAClC,OAAO,IAAI,aAAa,CAAC;YACvB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,UAAU;YACzB,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED,4DAA4D;IAC5D,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,IAAI,aAAa,CAAC;YACvB,IAAI;YACJ,OAAO,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C,KAAK,CAAC,CAAC;AACzB,CAAC,CAAC"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// packages/effect-grpc/src/grpcException.ts
|
|
2
|
+
import { Data } from "effect";
|
|
3
|
+
import * as internal from "./grpcException.internal.js";
|
|
4
|
+
/**
|
|
5
|
+
* A high-level error type for gRPC operations in Effect programs.
|
|
6
|
+
*
|
|
7
|
+
* GrpcException is a tagged error that extends Data.TaggedError, designed as part of the DSL
|
|
8
|
+
* for gRPC error handling. It focuses on application-level concerns (code, message, description, cause)
|
|
9
|
+
* rather than low-level wire-format details.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { Effect } from "effect";
|
|
14
|
+
* import { GrpcException } from "@dr_nikson/effect-grpc";
|
|
15
|
+
* import { Code } from "@connectrpc/connect";
|
|
16
|
+
*
|
|
17
|
+
* // Create an exception with a code and message
|
|
18
|
+
* const notFoundError = GrpcException.create(
|
|
19
|
+
* Code.NotFound,
|
|
20
|
+
* "User not found"
|
|
21
|
+
* );
|
|
22
|
+
*
|
|
23
|
+
* // Use in Effect programs with catchTag
|
|
24
|
+
* const program = Effect.gen(function* () {
|
|
25
|
+
* yield* notFoundError; // The error is yieldable
|
|
26
|
+
* yield* Effect.fail(notFoundError);
|
|
27
|
+
* }).pipe(
|
|
28
|
+
* Effect.catchTag(GrpcException, (error) => {
|
|
29
|
+
* console.log(`gRPC error [${Code[error.code]}]: ${error.message}`);
|
|
30
|
+
* return Effect.succeed("recovered");
|
|
31
|
+
* })
|
|
32
|
+
* );
|
|
33
|
+
*
|
|
34
|
+
* // Convert from unknown error
|
|
35
|
+
* try {
|
|
36
|
+
* // some operation
|
|
37
|
+
* } catch (error) {
|
|
38
|
+
* yield* GrpcException.from(Code.Internal, error);
|
|
39
|
+
* }
|
|
40
|
+
*
|
|
41
|
+
* // Add context with description
|
|
42
|
+
* const enriched = GrpcException.withDescription(
|
|
43
|
+
* notFoundError,
|
|
44
|
+
* "Database query failed"
|
|
45
|
+
* );
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @category Error Handling
|
|
49
|
+
* @since 0.2.0
|
|
50
|
+
*/
|
|
51
|
+
export class GrpcException extends Data.TaggedError("@dr_nikson/effect-grpc/grpcException/GrpcException") {
|
|
52
|
+
/**
|
|
53
|
+
* Returns a formatted error message including the status code, message, and description (if present).
|
|
54
|
+
* This is called automatically when the error is converted to a string.
|
|
55
|
+
*
|
|
56
|
+
* Format:
|
|
57
|
+
* - Without description: "[code] message"
|
|
58
|
+
* - With description: "[code] message (description)"
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```typescript
|
|
62
|
+
* import { GrpcException } from "@dr_nikson/effect-grpc";
|
|
63
|
+
* import { Code } from "@connectrpc/connect";
|
|
64
|
+
*
|
|
65
|
+
* const error1 = GrpcException.create(
|
|
66
|
+
* Code.NotFound,
|
|
67
|
+
* "User not found"
|
|
68
|
+
* );
|
|
69
|
+
* console.log(error1.toString());
|
|
70
|
+
* // Output: "[not_found] User not found"
|
|
71
|
+
*
|
|
72
|
+
* const error2 = GrpcException.withDescription(
|
|
73
|
+
* error1,
|
|
74
|
+
* "Database query failed"
|
|
75
|
+
* );
|
|
76
|
+
* console.log(error2.toString());
|
|
77
|
+
* // Output: "[not_found] User not found (Database query failed)"
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
toString() {
|
|
81
|
+
return internal.toString(this);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Custom inspection for Node.js util.inspect
|
|
85
|
+
*/
|
|
86
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
87
|
+
return internal.inspect(this);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Creates a new GrpcException from the provided parameters.
|
|
92
|
+
*
|
|
93
|
+
* This is the primary constructor for creating GrpcException instances.
|
|
94
|
+
* Code and message are required; cause is optional.
|
|
95
|
+
*
|
|
96
|
+
* @param code - The gRPC status code (required)
|
|
97
|
+
* @param message - The error message (required)
|
|
98
|
+
* @param cause - Optional cause of the error
|
|
99
|
+
* @returns A new GrpcException instance
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* import { GrpcException } from "@dr_nikson/effect-grpc";
|
|
104
|
+
* import { Code } from "@connectrpc/connect";
|
|
105
|
+
*
|
|
106
|
+
* // Simple error
|
|
107
|
+
* const error1 = GrpcException.create(
|
|
108
|
+
* Code.NotFound,
|
|
109
|
+
* "User not found"
|
|
110
|
+
* );
|
|
111
|
+
*
|
|
112
|
+
* // With cause
|
|
113
|
+
* try {
|
|
114
|
+
* // some operation
|
|
115
|
+
* } catch (err) {
|
|
116
|
+
* const error2 = GrpcException.create(
|
|
117
|
+
* Code.Internal,
|
|
118
|
+
* "Operation failed",
|
|
119
|
+
* err
|
|
120
|
+
* );
|
|
121
|
+
* }
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
export const create = internal.create;
|
|
125
|
+
/**
|
|
126
|
+
* Converts any value into a GrpcException, following these rules:
|
|
127
|
+
* - If the cause is a ConnectError, wraps it preserving code and message
|
|
128
|
+
* - For other Errors, creates a GrpcException with the error message and sets it as cause
|
|
129
|
+
* - For other values, converts to string and uses as message
|
|
130
|
+
*
|
|
131
|
+
* @param code - The gRPC status code to use (required)
|
|
132
|
+
* @param cause - The error/value to convert (native Error, ConnectError, or any value)
|
|
133
|
+
* @returns A GrpcException instance
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* import { Effect } from "effect";
|
|
138
|
+
* import { GrpcException } from "@dr_nikson/effect-grpc";
|
|
139
|
+
* import { Code, ConnectError } from "@connectrpc/connect";
|
|
140
|
+
*
|
|
141
|
+
* const handleError = (error: unknown) =>
|
|
142
|
+
* Effect.fail(GrpcException.from(Code.Internal, error));
|
|
143
|
+
*
|
|
144
|
+
* // From ConnectError - preserves code and message
|
|
145
|
+
* const connectErr = new ConnectError("Not found", Code.NotFound);
|
|
146
|
+
* const grpcErr1 = GrpcException.from(Code.Internal, connectErr);
|
|
147
|
+
* // grpcErr1.code === Code.NotFound (from ConnectError, not the parameter)
|
|
148
|
+
* // grpcErr1.message === "Not found"
|
|
149
|
+
*
|
|
150
|
+
* // From regular Error - sets as cause
|
|
151
|
+
* const regularErr = new Error("Network timeout");
|
|
152
|
+
* const grpcErr2 = GrpcException.from(Code.Unavailable, regularErr);
|
|
153
|
+
* // grpcErr2.code === Code.Unavailable
|
|
154
|
+
* // grpcErr2.message === "Network timeout"
|
|
155
|
+
* // grpcErr2.cause === regularErr
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
export const from = internal.from;
|
|
159
|
+
/**
|
|
160
|
+
* Sets or replaces the description field of a GrpcException.
|
|
161
|
+
* Returns a new GrpcException with the specified description.
|
|
162
|
+
*
|
|
163
|
+
* @param error - The GrpcException to modify
|
|
164
|
+
* @param description - The description to set
|
|
165
|
+
* @returns A new GrpcException with the description
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
* ```typescript
|
|
169
|
+
* import { GrpcException } from "@dr_nikson/effect-grpc";
|
|
170
|
+
* import { Code } from "@connectrpc/connect";
|
|
171
|
+
*
|
|
172
|
+
* const error = GrpcException.create(
|
|
173
|
+
* Code.NotFound,
|
|
174
|
+
* "User not found"
|
|
175
|
+
* );
|
|
176
|
+
* const enriched = GrpcException.withDescription(
|
|
177
|
+
* error,
|
|
178
|
+
* "Database query failed"
|
|
179
|
+
* );
|
|
180
|
+
* // enriched.description === "Database query failed"
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
export const withDescription = internal.withDescription;
|
|
184
|
+
/**
|
|
185
|
+
* Converts a GrpcException to a ConnectError for use with Connect-RPC.
|
|
186
|
+
* This is useful when you need to throw or return errors in Connect-RPC handlers.
|
|
187
|
+
*
|
|
188
|
+
* Only the code, message, and cause are preserved. Description is not included
|
|
189
|
+
* as ConnectError doesn't have a corresponding field.
|
|
190
|
+
*
|
|
191
|
+
* @param error - The GrpcException to convert
|
|
192
|
+
* @returns A ConnectError instance
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* import { GrpcException } from "@dr_nikson/effect-grpc";
|
|
197
|
+
* import { Code } from "@connectrpc/connect";
|
|
198
|
+
*
|
|
199
|
+
* const error = GrpcException.create(
|
|
200
|
+
* Code.NotFound,
|
|
201
|
+
* "User not found"
|
|
202
|
+
* );
|
|
203
|
+
* const withDesc = GrpcException.withDescription(
|
|
204
|
+
* error,
|
|
205
|
+
* "Database query failed"
|
|
206
|
+
* );
|
|
207
|
+
*
|
|
208
|
+
* const connectError = GrpcException.toConnectError(withDesc);
|
|
209
|
+
* // connectError.code === Code.NotFound
|
|
210
|
+
* // connectError.rawMessage === "User not found"
|
|
211
|
+
* // Note: description is lost in conversion
|
|
212
|
+
*
|
|
213
|
+
* // Can be thrown in Connect-RPC handlers
|
|
214
|
+
* throw GrpcException.toConnectError(error);
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
export const toConnectError = internal.toConnectError;
|
|
218
|
+
//# sourceMappingURL=grpcException.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grpcException.js","sourceRoot":"","sources":["../src/grpcException.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAI9B,OAAO,KAAK,QAAQ,MAAM,6BAA6B,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,OAAO,aAAc,SAAQ,IAAI,CAAC,WAAW,CACjD,oDAAoD,CA2BpD;IACA;;;;;;;;;;;;;;;;;;;;;;;;;;;OA2BG;IACH,QAAQ;QACN,OAAO,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAED;;OAEG;IACH,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QACxC,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,CAAC,MAAM,MAAM,GAEf,QAAQ,CAAC,MAAM,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,MAAM,IAAI,GAEb,QAAQ,CAAC,IAAI,CAAC;AAElB;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,eAAe,GAExB,QAAQ,CAAC,eAAe,CAAC;AAE7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,MAAM,cAAc,GAEvB,QAAQ,CAAC,cAAc,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,gBAAgB,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,gBAAgB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,gBAAgB,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,gBAAgB,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,gBAAgB,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,gBAAgB,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,gBAAgB,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,gBAAgB,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAC"}
|
package/dist/protoRuntime.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Effect, Runtime } from "effect";
|
|
2
2
|
import type { DescMessage, MessageInitShape, MessageShape } from "@bufbuild/protobuf";
|
|
3
3
|
import type { GenMessage, GenServiceMethods } from "@bufbuild/protobuf/codegenv2";
|
|
4
|
-
import { HandlerContext } from "@connectrpc/connect";
|
|
5
|
-
import
|
|
4
|
+
import type { HandlerContext } from "@connectrpc/connect";
|
|
5
|
+
import * as GrpcException from "./grpcException.js";
|
|
6
|
+
import type { RequestMeta } from "./client.js";
|
|
6
7
|
/**
|
|
7
8
|
* Type-safe executor interface for gRPC service methods.
|
|
8
9
|
*
|
|
@@ -69,14 +70,14 @@ type UnaryClientExecutorFn<I extends DescMessage, O extends DescMessage> = (requ
|
|
|
69
70
|
* ```
|
|
70
71
|
*/
|
|
71
72
|
export interface ServerExecutor<Ctx> {
|
|
72
|
-
unary<In, Out>(req: In, ctx: HandlerContext, prog: (req: In, ctx: Ctx) => Effect.Effect<Out>): Promise<Out>;
|
|
73
|
+
unary<In, Out>(req: In, ctx: HandlerContext, prog: (req: In, ctx: Ctx) => Effect.Effect<Out, GrpcException.GrpcException>): Promise<Out>;
|
|
73
74
|
}
|
|
74
75
|
export declare const ServerExecutor: {
|
|
75
76
|
(runtime: Runtime.Runtime<never>): ServerExecutor<HandlerContext>;
|
|
76
77
|
};
|
|
77
78
|
export interface ServerExecutorTransformer<Ctx> {
|
|
78
79
|
readonly transformation: (underlying: ServerExecutor<HandlerContext>) => ServerExecutor<Ctx>;
|
|
79
|
-
transformContext<Ctx1>(f: (ctx: Ctx) => Effect.Effect<Ctx1>): ServerExecutorTransformer<Ctx1>;
|
|
80
|
+
transformContext<Ctx1>(f: (ctx: Ctx) => Effect.Effect<Ctx1, GrpcException.GrpcException>): ServerExecutorTransformer<Ctx1>;
|
|
80
81
|
}
|
|
81
82
|
export declare const ServerExecutorTransformer: {
|
|
82
83
|
(): ServerExecutorTransformer<HandlerContext>;
|