@dr_nikson/effect-grpc 0.2.0-mvp-35390ba5835ef85042f042d86878a7e9aee0dad9
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/LICENSE +201 -0
- package/bin/protoc-gen-effect +6 -0
- package/dist/client.d.ts +176 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.internal.d.ts +8 -0
- package/dist/client.internal.d.ts.map +1 -0
- package/dist/client.internal.js +57 -0
- package/dist/client.internal.js.map +1 -0
- package/dist/client.js +51 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/protoRuntime.d.ts +85 -0
- package/dist/protoRuntime.d.ts.map +1 -0
- package/dist/protoRuntime.internal.d.ts +26 -0
- package/dist/protoRuntime.internal.d.ts.map +1 -0
- package/dist/protoRuntime.internal.js +45 -0
- package/dist/protoRuntime.internal.js.map +1 -0
- package/dist/protoRuntime.js +4 -0
- package/dist/protoRuntime.js.map +1 -0
- package/dist/protocGenPlugin.d.ts +2 -0
- package/dist/protocGenPlugin.d.ts.map +1 -0
- package/dist/protocGenPlugin.js +335 -0
- package/dist/protocGenPlugin.js.map +1 -0
- package/dist/server.d.ts +214 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.internal.d.ts +30 -0
- package/dist/server.internal.d.ts.map +1 -0
- package/dist/server.internal.js +134 -0
- package/dist/server.internal.js.map +1 -0
- package/dist/server.js +49 -0
- package/dist/server.js.map +1 -0
- package/dist/typeUtils.d.ts +21 -0
- package/dist/typeUtils.d.ts.map +1 -0
- package/dist/typeUtils.js +2 -0
- package/dist/typeUtils.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protoRuntime.internal.d.ts","sourceRoot":"","sources":["../src/protoRuntime.internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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A6B,CAAC,IAAI,CAAC;CAiBvC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* Live implementation of the Executor interface using Effect's ManagedRuntime.
|
|
5
|
+
* Handles the execution of Effect programs within gRPC service handlers.
|
|
6
|
+
*/
|
|
7
|
+
export class ServerExecutorLive {
|
|
8
|
+
runtime;
|
|
9
|
+
constructor(runtime) {
|
|
10
|
+
this.runtime = runtime;
|
|
11
|
+
}
|
|
12
|
+
static make(runtime) {
|
|
13
|
+
return new ServerExecutorLive(runtime);
|
|
14
|
+
}
|
|
15
|
+
unary(req, ctx, prog) {
|
|
16
|
+
return this.runtime.runPromise(prog(req, ctx), { signal: ctx.signal });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* @internal
|
|
21
|
+
* Transformer class that handles context transformations for executors.
|
|
22
|
+
* Allows chaining context transformations in a type-safe manner.
|
|
23
|
+
*/
|
|
24
|
+
export class ServerExecutorTransformerLive {
|
|
25
|
+
transformation;
|
|
26
|
+
constructor(transformation) {
|
|
27
|
+
this.transformation = transformation;
|
|
28
|
+
}
|
|
29
|
+
static empty() {
|
|
30
|
+
return new ServerExecutorTransformerLive((underlying) => underlying);
|
|
31
|
+
}
|
|
32
|
+
transformContext(f) {
|
|
33
|
+
return new ServerExecutorTransformerLive((underlying) => {
|
|
34
|
+
const executor = this.transformation(underlying);
|
|
35
|
+
return {
|
|
36
|
+
unary(req, ctx, prog) {
|
|
37
|
+
return executor.unary(req, ctx, (req, ctx0) => {
|
|
38
|
+
return Effect.flatMap(f(ctx0), (ctx1) => prog(req, ctx1));
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=protoRuntime.internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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AAC,CAAC,CAAC;gBACL,CAAC;aACwB,CAAC;QAC9B,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protoRuntime.js","sourceRoot":"","sources":["../src/protoRuntime.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,QAAQ,MAAM,4BAA4B,CAAC;AAgFvD,MAAM,CAAC,MAAM,cAAc,GAEvB,QAAQ,CAAC,kBAAkB,CAAC,IAAI,CAAC;AAOrC,MAAM,CAAC,MAAM,yBAAyB,GAElC,QAAQ,CAAC,6BAA6B,CAAC,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocGenPlugin.d.ts","sourceRoot":"","sources":["../src/protocGenPlugin.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB,wCAI9B,CAAC"}
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
// #!/usr/bin/env -S node
|
|
2
|
+
import { createEcmaScriptPlugin, safeIdentifier } from "@bufbuild/protoplugin";
|
|
3
|
+
import packageJson from "../package.json" with { type: "json" };
|
|
4
|
+
export const protocGenEffectGrpc = createEcmaScriptPlugin({
|
|
5
|
+
name: "protoc-gen-effect-grpc",
|
|
6
|
+
version: `v${String(packageJson.version)}`,
|
|
7
|
+
generateTs,
|
|
8
|
+
});
|
|
9
|
+
function generateTs(schema) {
|
|
10
|
+
for (const file of schema.files) {
|
|
11
|
+
const f = schema.generateFile(file.name + "_effect.ts");
|
|
12
|
+
f.preamble(file);
|
|
13
|
+
file.services.forEach(service => generateEffectService(f, service));
|
|
14
|
+
/*
|
|
15
|
+
for (const service of file.services) {
|
|
16
|
+
f.print(f.jsDoc(service));
|
|
17
|
+
f.print(f.export("class", safeIdentifier(service.name + "Client")), " {");
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
// To support the custom option we defined in customoptions/default_host.proto,
|
|
21
|
+
// we need to generate code for this proto file first. This will generate the
|
|
22
|
+
// file customoptions/default_host_pb.ts, which contains the generated option
|
|
23
|
+
// extension `default_host`.
|
|
24
|
+
// Then we use the functions hasOption() and getOption() to see whether the
|
|
25
|
+
// option is set, and set the value as the default for the constructor argument.
|
|
26
|
+
if (hasOption(service, default_host)) {
|
|
27
|
+
const defaultHost = getOption(service, default_host);
|
|
28
|
+
f.print(" constructor(private readonly baseUrl = ", f.string(defaultHost), ") {}");
|
|
29
|
+
} else {
|
|
30
|
+
f.print(" constructor(private readonly baseUrl: string) {}");
|
|
31
|
+
}
|
|
32
|
+
f.print();
|
|
33
|
+
for (const method of service.methods) {
|
|
34
|
+
if (method.methodKind != "unary") {
|
|
35
|
+
// Fetch only supports unary RPCs
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
f.print(f.jsDoc(method, " "));
|
|
39
|
+
const inputType = f.importShape(method.input);
|
|
40
|
+
const inputDesc = f.importSchema(method.input);
|
|
41
|
+
const outputType = f.importShape(method.output);
|
|
42
|
+
const outputDesc = f.importSchema(method.output);
|
|
43
|
+
f.print(" async ", method.localName, "(request: ", inputType, "): Promise<", outputType, "> {");
|
|
44
|
+
f.print(' const method = "POST";');
|
|
45
|
+
f.print(' const url = `${this.baseUrl}/', service.typeName, '/', method.name, '`;');
|
|
46
|
+
f.print(' const headers = new Headers({');
|
|
47
|
+
f.print(' "Content-Type": "application/json",');
|
|
48
|
+
f.print(' });');
|
|
49
|
+
f.print(' const body = ', f.runtime.toJsonString, '(', inputDesc, ', request);');
|
|
50
|
+
if (schema.options.logRequests) {
|
|
51
|
+
f.print(" console.log(`${method} ${url}`, request);");
|
|
52
|
+
}
|
|
53
|
+
f.print(" const response = await fetch(url, { method, headers, body });");
|
|
54
|
+
f.print(" if (response.status !== 200) {");
|
|
55
|
+
f.print(" throw Error(`HTTP ${response.status} ${response.statusText}`);");
|
|
56
|
+
f.print(" }");
|
|
57
|
+
f.print(" return ", f.runtime.fromJson, "(", outputDesc, ", await response.json());");
|
|
58
|
+
f.print(" }");
|
|
59
|
+
}
|
|
60
|
+
f.print("}");
|
|
61
|
+
}*/
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function generateEffectService(f, service) {
|
|
65
|
+
const importEffect = f.import("Effect", "effect");
|
|
66
|
+
const importContext = f.import("Context", "effect");
|
|
67
|
+
const importLayer = f.import("Layer", "effect");
|
|
68
|
+
const importHandlerContext = f.import("HandlerContext", "@connectrpc/connect");
|
|
69
|
+
const importEffectGrpcService = f.import("EffectGrpcServer", packageJson.name);
|
|
70
|
+
const importService = f.importSchema(service);
|
|
71
|
+
const serviceId = service.typeName;
|
|
72
|
+
const serviceIdSymbol = safeIdentifier(service.name + "Id");
|
|
73
|
+
const serviceSymbol = safeIdentifier(service.name + "Service");
|
|
74
|
+
const grpcServiceSymbol = safeIdentifier(service.name + "GrpcService");
|
|
75
|
+
const serviceTagSymbol = safeIdentifier(service.name + "Tag");
|
|
76
|
+
const makeTagSymbol = safeIdentifier("make" + service.name + "ServiceTag");
|
|
77
|
+
const makeLiveLayerSymbol = safeIdentifier("make" + service.name + "LiveLayer");
|
|
78
|
+
f.print(f.export("const", serviceIdSymbol), " = ", f.string(serviceId), " as const;");
|
|
79
|
+
f.print(f.export("type", serviceIdSymbol), " = typeof ", serviceIdSymbol, ";");
|
|
80
|
+
f.print();
|
|
81
|
+
f.print(f.jsDoc(service));
|
|
82
|
+
f.print(f.export("interface", serviceSymbol), "<Ctx> {");
|
|
83
|
+
service.methods.forEach(generateServerMethod);
|
|
84
|
+
f.print("}");
|
|
85
|
+
/**
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* export const DebugAPIService: {
|
|
89
|
+
* makeTag<Ctx>(ctxKey: string): DebugAPITag<Ctx>;
|
|
90
|
+
*
|
|
91
|
+
* liveLayer<Ctx>(service: DebugAPIService<Ctx>):
|
|
92
|
+
* <Tag extends DebugAPITag<Ctx>>(tag: Tag) => Layer.Layer<Context.Tag.Identifier<Tag>, never, never>;
|
|
93
|
+
* } = {
|
|
94
|
+
* makeTag: makeDebugAPIServiceTag,
|
|
95
|
+
* liveLayer: makeDebugApiLiveLayer
|
|
96
|
+
* };
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
f.print(f.export("const", serviceSymbol), ": {");
|
|
100
|
+
f.print(" makeTag<Ctx>(ctxKey: string): ", serviceTagSymbol, "<Ctx>;");
|
|
101
|
+
f.print();
|
|
102
|
+
f.print(" liveLayer<Ctx>(");
|
|
103
|
+
f.print(" service: ", serviceSymbol, "<Ctx>");
|
|
104
|
+
f.print(" ): <Tag extends ", serviceTagSymbol, "<Ctx>>(tag: Tag) => ", importLayer, ".Layer<", importContext, ".Tag.Identifier<Tag>, never, never>;");
|
|
105
|
+
f.print("} = {");
|
|
106
|
+
f.print(" makeTag: ", makeTagSymbol, ",");
|
|
107
|
+
f.print(" liveLayer: ", makeLiveLayerSymbol);
|
|
108
|
+
f.print("};");
|
|
109
|
+
f.print();
|
|
110
|
+
// export type DebugAPIGrpcService<Ctx = HandlerContext> = EffectGrpcServer.GrpcService<"DebugAPI", typeof proto.DebugAPI, Ctx>
|
|
111
|
+
f.print(f.export("type", grpcServiceSymbol), "<Ctx = ", importHandlerContext, ">", " = ", importEffectGrpcService, `.GrpcService<"`, service.typeName, `", typeof `, importService, ", Ctx>");
|
|
112
|
+
// export type DebugAPITag<Ctx> = Context.Tag<DebugAPIGrpcService<Ctx>, DebugAPIGrpcService<Ctx>>
|
|
113
|
+
f.print(f.export("type", serviceTagSymbol), "<Ctx>", " = ", importContext, ".Tag<", grpcServiceSymbol, "<Ctx>, ", grpcServiceSymbol, "<Ctx>>");
|
|
114
|
+
/**
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* function makeDebugAPIServiceTag<Ctx>(ctxKey: string & keyof Ctx): DebugAPITag<Ctx> {
|
|
118
|
+
* return Context.GenericTag<DebugAPIGrpcService<Ctx>, DebugAPIGrpcService<Ctx>>(`${proto.DebugAPI.typeName}<${ctxKey}}>`);
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
f.print("function ", makeTagSymbol, "<Ctx>(ctxKey: string): ", serviceTagSymbol, "<Ctx> {");
|
|
123
|
+
f.print(" return ", importContext, ".GenericTag<", grpcServiceSymbol, "<Ctx>>(`", service.typeName, "<${ctxKey}>`);");
|
|
124
|
+
f.print("}");
|
|
125
|
+
f.print();
|
|
126
|
+
/**
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* function makeDebugApiLiveLayer<Ctx>(service: DebugAPIService<Ctx>) {
|
|
130
|
+
* return <Tag extends DebugAPITag<Ctx>>(tag: Tag) => {
|
|
131
|
+
* type Proto = typeof proto.DebugAPI;
|
|
132
|
+
*
|
|
133
|
+
* const instance: DebugAPIGrpcService<Ctx> = EffectGrpcServer.GrpcService("DebugAPI" as const, proto.DebugAPI)(
|
|
134
|
+
* (executor: EffectGrpcServer.Executor<Ctx>): ServiceImpl<Proto> => {
|
|
135
|
+
* return {
|
|
136
|
+
* getDebugInfo: (req: proto.GetDebugInfoRequest, ctx: HandlerContext) => {
|
|
137
|
+
* return executor.unary(
|
|
138
|
+
* req,
|
|
139
|
+
* ctx,
|
|
140
|
+
* (req, ctx) => service.getDebugInfo(req, ctx)
|
|
141
|
+
* );
|
|
142
|
+
* }
|
|
143
|
+
* } as ServiceImpl<Proto>;
|
|
144
|
+
* }
|
|
145
|
+
* );
|
|
146
|
+
*
|
|
147
|
+
* return Layer.succeed(tag, instance);
|
|
148
|
+
*
|
|
149
|
+
* }
|
|
150
|
+
* }
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
f.print("function ", makeLiveLayerSymbol, "<Ctx>(service: ", serviceSymbol, "<Ctx>) {");
|
|
154
|
+
f.print(" return <Tag extends ", serviceTagSymbol, "<Ctx>>(tag: Tag) => {");
|
|
155
|
+
f.print();
|
|
156
|
+
f.print(" const instance: ", grpcServiceSymbol, "<Ctx> = ", importEffectGrpcService, '.GrpcService("', service.typeName, '" as const, ', importService, ")(");
|
|
157
|
+
f.print(" (executor) => ({");
|
|
158
|
+
service.methods.forEach((method) => {
|
|
159
|
+
if (method.methodKind === "unary") {
|
|
160
|
+
f.print(" ", method.localName, ": (req, ctx) => executor.unary(req, ctx, (req, ctx) => service.", method.localName, "(req, ctx))", ",");
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
f.print(" })");
|
|
164
|
+
f.print(" );");
|
|
165
|
+
f.print();
|
|
166
|
+
f.print(" return ", importLayer, ".succeed(tag, instance);");
|
|
167
|
+
f.print(" };");
|
|
168
|
+
f.print("}");
|
|
169
|
+
f.print();
|
|
170
|
+
const clientSymbol = safeIdentifier(service.name + "Client");
|
|
171
|
+
/**
|
|
172
|
+
* @example
|
|
173
|
+
* ```typescript
|
|
174
|
+
* export interface DebugAPIClient<Meta> {
|
|
175
|
+
* getDebugInfo(
|
|
176
|
+
* request: MessageInitShape<typeof proto.GetDebugInfoRequestSchema>,
|
|
177
|
+
* meta: Meta,
|
|
178
|
+
* ): Effect.Effect<proto.GetDebugInfoResponse>
|
|
179
|
+
* }
|
|
180
|
+
* ```
|
|
181
|
+
*/
|
|
182
|
+
f.print(f.jsDoc(service));
|
|
183
|
+
f.print(f.export("interface", clientSymbol), "<Meta> {");
|
|
184
|
+
service.methods.forEach(generateClientMethod);
|
|
185
|
+
f.print("}");
|
|
186
|
+
/**
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* export const DebugAPIClient: {
|
|
190
|
+
* makeTag<Meta>(metaKey: string): DebugAPIClientTag<Meta>
|
|
191
|
+
*
|
|
192
|
+
* liveLayer<Meta>(transformMeta: (meta: Meta) => RequestMeta):
|
|
193
|
+
* <Tag extends DebugAPIClientTag<Meta>>(tag: Tag) => Layer.Layer<Context.Tag.Identifier<Tag>, never, EffectGrpcClient.GrpcClient>
|
|
194
|
+
* } = {
|
|
195
|
+
* makeTag: makeDebugAPIClientTag,
|
|
196
|
+
* liveLayer: makeDebugApiClientLiveLayer,
|
|
197
|
+
* }
|
|
198
|
+
* ```
|
|
199
|
+
*/
|
|
200
|
+
const importEffectGrpcClient = f.import("EffectGrpcClient", packageJson.name);
|
|
201
|
+
const clientTagSymbol = safeIdentifier(service.name + "ClientTag");
|
|
202
|
+
const configTagSymbol = safeIdentifier(service.name + "ConfigTag");
|
|
203
|
+
const makeClientTagSymbol = safeIdentifier("make" + service.name + "ClientTag");
|
|
204
|
+
const makeClientLiveLayerSymbol = safeIdentifier("make" + service.name + "ClientLiveLayer");
|
|
205
|
+
f.print(f.export("const", clientSymbol), ": {");
|
|
206
|
+
f.print(" makeTag<Meta>(metaKey: string): ", clientTagSymbol, "<Meta>;");
|
|
207
|
+
f.print();
|
|
208
|
+
f.print(" liveLayer<Tag extends ", clientTagSymbol, "<Meta>, Meta>(");
|
|
209
|
+
f.print(" transformMeta: (meta: Meta) => ", importEffectGrpcClient, ".RequestMeta,");
|
|
210
|
+
f.print(" tag: Tag");
|
|
211
|
+
f.print(" ): ", importLayer, ".Layer<");
|
|
212
|
+
f.print(" ", importContext, ".Tag.Identifier<Tag>,");
|
|
213
|
+
f.print(" never,");
|
|
214
|
+
f.print(" ", importContext, ".Tag.Identifier<", configTagSymbol, "> | ", importEffectGrpcClient, ".GrpcClientRuntime");
|
|
215
|
+
f.print(" >;");
|
|
216
|
+
f.print();
|
|
217
|
+
f.print(" liveLayer<Tag extends ", clientTagSymbol, "<object>>(");
|
|
218
|
+
f.print(" tag: Tag");
|
|
219
|
+
f.print(" ): ", importLayer, ".Layer<");
|
|
220
|
+
f.print(" ", importContext, ".Tag.Identifier<Tag>,");
|
|
221
|
+
f.print(" never,");
|
|
222
|
+
f.print(" ", importContext, ".Tag.Identifier<", configTagSymbol, "> | ", importEffectGrpcClient, ".GrpcClientRuntime");
|
|
223
|
+
f.print(" >;");
|
|
224
|
+
f.print("} = {");
|
|
225
|
+
f.print(" makeTag: ", makeClientTagSymbol, ",");
|
|
226
|
+
f.print(" liveLayer: ", makeClientLiveLayerSymbol, ",");
|
|
227
|
+
f.print("};");
|
|
228
|
+
f.print();
|
|
229
|
+
// export type DebugAPIClientTag<Meta> = Context.Tag<DebugAPIClient<Meta>, DebugAPIClient<Meta>>
|
|
230
|
+
f.print(f.export("type", clientTagSymbol), "<Meta>", " = ", importContext, ".Tag<", clientSymbol, "<Meta>, ", clientSymbol, "<Meta>>");
|
|
231
|
+
f.print();
|
|
232
|
+
// export type HelloWorldAPIConfigTag = Context.Tag<EffectGrpcClient.GrpcClientConfig<HelloWorldAPIId>, EffectGrpcClient.GrpcClientConfig<HelloWorldAPIId>>
|
|
233
|
+
f.print(f.export("type", configTagSymbol), " = ", importContext, ".Tag<", importEffectGrpcClient, ".GrpcClientConfig<", serviceIdSymbol, ">, ", importEffectGrpcClient, ".GrpcClientConfig<", serviceIdSymbol, ">>");
|
|
234
|
+
// export const HelloWorldAPIConfigTag: HelloWorldAPIConfigTag = EffectGrpcClient.GrpcClientConfig.makeTag(HelloWorldAPIId);
|
|
235
|
+
f.print(f.export("const", configTagSymbol), ": ", configTagSymbol, " = ", importEffectGrpcClient, ".GrpcClientConfig.makeTag(", serviceIdSymbol, ");");
|
|
236
|
+
f.print();
|
|
237
|
+
// function makeDebugAPIClientTag<Meta>(metaKey: string): DebugAPIClientTag<Meta>
|
|
238
|
+
f.print("function ", makeClientTagSymbol, "<Meta>(metaKey: string): ", clientTagSymbol, "<Meta> {");
|
|
239
|
+
f.print(" return ", importContext, ".GenericTag<", clientSymbol, "<Meta>>(`", service.typeName, "Client<${metaKey}>`);");
|
|
240
|
+
f.print("}");
|
|
241
|
+
f.print();
|
|
242
|
+
/**
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* function makeDebugApiClientLiveLayer<Meta>(transformMeta: (meta: Meta) => RequestMeta) {
|
|
246
|
+
* return <Tag extends DebugAPIClientTag<Meta>>(tag: Tag) => {
|
|
247
|
+
* const prog = Effect.gen(function* () {
|
|
248
|
+
* const grpcService = yield* EffectGrpcClient.GrpcClient
|
|
249
|
+
* const executor = grpcService.makeExecutor(proto.DebugAPI, ["getDebugInfo"]);
|
|
250
|
+
*
|
|
251
|
+
* return {
|
|
252
|
+
* getDebugInfo(req, meta) {
|
|
253
|
+
* return executor.getDebugInfo(req, meta ?? transformMeta(meta));
|
|
254
|
+
* },
|
|
255
|
+
* } as DebugAPIClient<Meta>;
|
|
256
|
+
* });
|
|
257
|
+
*
|
|
258
|
+
* return Layer.effect(tag, prog);
|
|
259
|
+
* }
|
|
260
|
+
* }
|
|
261
|
+
* ```
|
|
262
|
+
*/
|
|
263
|
+
// function makeDebugAPIClientLiveLayer<Tag extends DebugAPIClientTag<Meta>, Meta = object>(...args: readonly [(meta: Meta) => RequestMeta, Tag] | readonly [Tag])
|
|
264
|
+
f.print("function ", makeClientLiveLayerSymbol, "<Tag extends ", clientTagSymbol, "<Meta>, Meta = object>(");
|
|
265
|
+
f.print(" ...args: readonly [(meta: Meta) => ", importEffectGrpcClient, ".RequestMeta, Tag] | readonly [Tag]");
|
|
266
|
+
f.print(") {");
|
|
267
|
+
f.print(" const [transformMeta, tag] =");
|
|
268
|
+
f.print(" isDefaultMetaArguments(args) ?");
|
|
269
|
+
f.print(" ([() => ({}) as ", importEffectGrpcClient, ".RequestMeta, args[0]] as const)");
|
|
270
|
+
f.print(" : args;");
|
|
271
|
+
f.print();
|
|
272
|
+
f.print(" const prog = ", importEffect, ".gen(function* () {");
|
|
273
|
+
f.print(" const config = yield* ", configTagSymbol, ";");
|
|
274
|
+
f.print(" const grpcRuntime = yield* ", importEffectGrpcClient, ".GrpcClientRuntime;");
|
|
275
|
+
// Collect method names for makeExecutor
|
|
276
|
+
const methodNames = service.methods
|
|
277
|
+
.filter(method => method.methodKind === "unary")
|
|
278
|
+
.map(method => `"${method.localName}"`)
|
|
279
|
+
.join(", ");
|
|
280
|
+
f.print(" const executor = yield* grpcRuntime.makeExecutor(", importService, ", [", methodNames, "], config);");
|
|
281
|
+
f.print();
|
|
282
|
+
f.print(" return {");
|
|
283
|
+
service.methods.forEach((method, index) => {
|
|
284
|
+
if (method.methodKind === "unary") {
|
|
285
|
+
f.print(" ", method.localName, "(req, meta) {");
|
|
286
|
+
f.print(" return executor.", method.localName, "(req, transformMeta(meta));");
|
|
287
|
+
f.print(" }", index === service.methods.length - 1 ? "" : ",");
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
f.print(" } as ", clientSymbol, "<Meta>;");
|
|
291
|
+
f.print(" });");
|
|
292
|
+
f.print();
|
|
293
|
+
f.print(" return ", importLayer, ".effect(tag, prog);");
|
|
294
|
+
f.print();
|
|
295
|
+
f.print(" function isDefaultMetaArguments(args: unknown): args is readonly [Tag] {");
|
|
296
|
+
f.print(" return Array.isArray(args) && args.length === 1;");
|
|
297
|
+
f.print(" }");
|
|
298
|
+
f.print("}");
|
|
299
|
+
function generateClientMethod(method) {
|
|
300
|
+
const inputDesc = f.importSchema(method.input);
|
|
301
|
+
const outputType = f.importShape(method.output);
|
|
302
|
+
const importMessageInitShape = f.import("MessageInitShape", "@bufbuild/protobuf", true);
|
|
303
|
+
switch (method.methodKind) {
|
|
304
|
+
case "unary":
|
|
305
|
+
f.print();
|
|
306
|
+
f.print(f.jsDoc(method, " "));
|
|
307
|
+
f.print(" ", method.localName, "(");
|
|
308
|
+
f.print(" request: ", importMessageInitShape, "<typeof ", inputDesc, ">,");
|
|
309
|
+
f.print(" meta: Meta");
|
|
310
|
+
f.print(" ): ", importEffect, ".Effect<", outputType, ">;");
|
|
311
|
+
return;
|
|
312
|
+
default:
|
|
313
|
+
f.print(" // Method[", method.localName, "] wasn't generated: methodKind is not yet supported [", method.methodKind, "]");
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
function generateServerMethod(method) {
|
|
318
|
+
const inputType = f.importShape(method.input);
|
|
319
|
+
// const inputDesc = f.importSchema(method.input);
|
|
320
|
+
// const outputType = f.importShape(method.output);
|
|
321
|
+
const outputDesc = f.importSchema(method.output);
|
|
322
|
+
const importMessageInitShape = f.import("MessageInitShape", "@bufbuild/protobuf", true);
|
|
323
|
+
switch (method.methodKind) {
|
|
324
|
+
case "unary":
|
|
325
|
+
f.print();
|
|
326
|
+
f.print(f.jsDoc(method, " "));
|
|
327
|
+
f.print(" ", method.localName, "(request: ", inputType, ", ctx: Ctx): ", importEffect, ".Effect<", importMessageInitShape, "<typeof ", outputDesc, ">>;");
|
|
328
|
+
return;
|
|
329
|
+
default:
|
|
330
|
+
f.print("// Method[", method.localName, "] wasn't generated: methodKind is not yet supported [", method.methodKind, "]");
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
//# sourceMappingURL=protocGenPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocGenPlugin.js","sourceRoot":"","sources":["../src/protocGenPlugin.ts"],"names":[],"mappings":"AAAA,yBAAyB;AACzB,OAAO,EAAE,sBAAsB,EAAiB,cAAc,EAAe,MAAM,uBAAuB,CAAC;AAE3G,OAAO,WAAW,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAEhE,MAAM,CAAC,MAAM,mBAAmB,GAAG,sBAAsB,CAAC;IACtD,IAAI,EAAE,wBAAwB;IAC9B,OAAO,EAAE,IAAI,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE;IAC1C,UAAU;CACb,CAAC,CAAC;AAEH,SAAS,UAAU,CAAC,MAAsB;IACtC,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QAC9B,MAAM,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC,CAAC;QACxD,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAEjB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,E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,EAAE,MAAM,CAAC,SAAS,EAAE,uDAAuD,EAAE,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;gBAC3H,OAAO;QACf,CAAC;IACL,CAAC;IAGD,SAAS,oBAAoB,CAAC,MAAkB;QAC5C,MAAM,SAAS,GAAG,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9C,kDAAkD;QAClD,mDAAmD;QACnD,MAAM,UAAU,GAAG,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACjD,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC,kBAAkB,EAAE,oBAAoB,EAAE,IAAI,CAAC,CAAC;QAExF,QAAQ,MAAM,CAAC,UAAU,EAAE,CAAC;YACxB,KAAK,OAAO;gBACR,CAAC,CAAC,KAAK,EAAE,CAAC;gBACV,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;gBAC/B,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,sBAAsB,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;gBAC3J,OAAO;YACX;gBACI,CAAC,CAAC,KAAK,CAAC,YAAY,EAAE,MAAM,CAAC,SAAS,EAAE,uDAAuD,EAAE,MAAM,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;gBACzH,OAAO;QACf,CAAC;IACL,CAAC;AACL,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { Effect, Scope, Types } from "effect";
|
|
2
|
+
import type { GenService, GenServiceMethods } from "@bufbuild/protobuf/codegenv2";
|
|
3
|
+
import { HandlerContext, ServiceImpl } from "@connectrpc/connect";
|
|
4
|
+
import * as ProtoRuntime from "./protoRuntime.js";
|
|
5
|
+
import * as internal from "./server.internal.js";
|
|
6
|
+
/**
|
|
7
|
+
* Represents a gRPC server that can run multiple services within an Effect environment.
|
|
8
|
+
* The server manages the lifecycle and execution of registered gRPC services.
|
|
9
|
+
*
|
|
10
|
+
* @template Services - Union type of all service tags registered with this server
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { Effect } from "effect"
|
|
15
|
+
* import { EffectGrpcServer } from "@dr_nikson/effect-grpc"
|
|
16
|
+
*
|
|
17
|
+
* // Create a server with multiple services
|
|
18
|
+
* const server = EffectGrpcServer.GrpcServerBuilder()
|
|
19
|
+
* .withService(userService)
|
|
20
|
+
* .withService(productService)
|
|
21
|
+
* .build()
|
|
22
|
+
*
|
|
23
|
+
* // Run the server within an Effect program
|
|
24
|
+
* const program = Effect.gen(function* () {
|
|
25
|
+
* yield* server.run()
|
|
26
|
+
* // Server is now running and handling gRPC requests
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* // Execute with proper resource management
|
|
30
|
+
* Effect.runPromise(Effect.scoped(program))
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export interface GrpcServer<in Services> {
|
|
34
|
+
readonly _Services: Types.Contravariant<Services>;
|
|
35
|
+
run(): Effect.Effect<never, never, Scope.Scope>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Utility type that concatenates service tags when adding a new service to an existing collection.
|
|
39
|
+
* If Services is never (empty collection), returns just the new Tag.
|
|
40
|
+
* Otherwise, returns a union of the new Tag and existing Services.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* // Adding first service to empty collection
|
|
45
|
+
* type FirstService = ConcatServiceTags<GrpcService<"UserService", UserProto, any>, never>
|
|
46
|
+
* // Result: "UserService"
|
|
47
|
+
*
|
|
48
|
+
* // Adding second service to existing collection
|
|
49
|
+
* type SecondService = ConcatServiceTags<GrpcService<"ProductService", ProductProto, any>, "UserService">
|
|
50
|
+
* // Result: "UserService" | "ProductService"
|
|
51
|
+
*
|
|
52
|
+
* // Adding third service
|
|
53
|
+
* type ThirdService = ConcatServiceTags<GrpcService<"OrderService", OrderProto, any>, "UserService" | "ProductService">
|
|
54
|
+
* // Result: "UserService" | "ProductService" | "OrderService"
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export type ConcatServiceTags<S extends GrpcService<any, any, any>, Services> = S extends GrpcService<infer Tag, any, any> ? [
|
|
58
|
+
Services
|
|
59
|
+
] extends [never] ? Tag : Tag | Services : never;
|
|
60
|
+
/**
|
|
61
|
+
* Utility type that ensures service tags are unique when adding to a collection.
|
|
62
|
+
* If Services is never (empty collection), allows any service S.
|
|
63
|
+
* If the service's Tag already exists in Services, returns never to prevent duplicates.
|
|
64
|
+
* Otherwise, returns the service S to allow it to be added.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* // Adding first service - always allowed
|
|
69
|
+
* type FirstService = UniqueTag<GrpcService<"UserService", UserProto, any>, never>
|
|
70
|
+
* // Result: GrpcService<"UserService", UserProto, any>
|
|
71
|
+
*
|
|
72
|
+
* // Adding unique service - allowed
|
|
73
|
+
* type SecondService = UniqueTag<GrpcService<"ProductService", ProductProto, any>, "UserService">
|
|
74
|
+
* // Result: GrpcService<"ProductService", ProductProto, any>
|
|
75
|
+
*
|
|
76
|
+
* // Adding duplicate service - blocked
|
|
77
|
+
* type DuplicateService = UniqueTag<GrpcService<"UserService", AnotherProto, any>, "UserService" | "ProductService">
|
|
78
|
+
* // Result: never (prevents duplicate tags)
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export type UniqueTag<S extends GrpcService<any, any, any>, Services> = S extends GrpcService<infer Tag, any, any> ? [
|
|
82
|
+
Services
|
|
83
|
+
] extends [never] ? S : Tag extends Services ? never : S : never;
|
|
84
|
+
/**
|
|
85
|
+
* Builder interface for constructing gRPC servers with type-safe service registration.
|
|
86
|
+
* Provides a fluent API for configuring context transformation and adding services.
|
|
87
|
+
*
|
|
88
|
+
* @template Ctx - The context type that will be provided to service handlers
|
|
89
|
+
* @template Services - Union type of all registered service tags
|
|
90
|
+
*
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* import { Effect } from "effect"
|
|
94
|
+
* import { EffectGrpcServer } from "@dr_nikson/effect-grpc"
|
|
95
|
+
*
|
|
96
|
+
* // Create a server with custom context transformation
|
|
97
|
+
* const server = EffectGrpcServer.GrpcServerBuilder()
|
|
98
|
+
* .withContextTransformer((handlerCtx) =>
|
|
99
|
+
* Effect.succeed({
|
|
100
|
+
* userId: handlerCtx.requestHeader.get("user-id"),
|
|
101
|
+
* timestamp: Date.now()
|
|
102
|
+
* })
|
|
103
|
+
* )
|
|
104
|
+
* .withService(userService)
|
|
105
|
+
* .withService(productService)
|
|
106
|
+
* .build()
|
|
107
|
+
*
|
|
108
|
+
* // Or with default HandlerContext
|
|
109
|
+
* const simpleServer = EffectGrpcServer.GrpcServerBuilder()
|
|
110
|
+
* .withService(userService)
|
|
111
|
+
* .build()
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export interface GrpcServerBuilder<Ctx, Services> {
|
|
115
|
+
readonly transformCtx: (ctx: HandlerContext) => Effect.Effect<Ctx>;
|
|
116
|
+
readonly services: Record<string & Services, GrpcService<any, any, Ctx>>;
|
|
117
|
+
withContextTransformer<This extends GrpcServerBuilder<Ctx, Services>, Ctx1>(this: [Services] extends [never] ? This : never, f: (ctx: Ctx) => Effect.Effect<Ctx1>): GrpcServerBuilder<Ctx1, never>;
|
|
118
|
+
withService<S extends GrpcService<any, any, Ctx>>(service: UniqueTag<S, Services>): GrpcServerBuilder<Ctx, ConcatServiceTags<S, Services>>;
|
|
119
|
+
build<This extends GrpcServerBuilder<Ctx, Services>>(this: [Services] extends [never] ? never : This): GrpcServer<Services>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Creates a new GrpcServerBuilder instance with default HandlerContext.
|
|
123
|
+
* This is the entry point for building a gRPC server.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* import { EffectGrpcServer } from "@dr_nikson/effect-grpc"
|
|
128
|
+
*
|
|
129
|
+
* // Create a new server builder
|
|
130
|
+
* const builder = EffectGrpcServer.GrpcServerBuilder()
|
|
131
|
+
*
|
|
132
|
+
* // Chain methods to configure the server
|
|
133
|
+
* const server = builder
|
|
134
|
+
* .withService(myService)
|
|
135
|
+
* .build()
|
|
136
|
+
* ```
|
|
137
|
+
*/
|
|
138
|
+
export declare const GrpcServerBuilder: {
|
|
139
|
+
(): GrpcServerBuilder<HandlerContext, never>;
|
|
140
|
+
};
|
|
141
|
+
export type GrpcServiceTypeId = typeof internal.grpcServiceTypeId;
|
|
142
|
+
/**
|
|
143
|
+
* Represents a gRPC service with a specific tag, Protocol Buffer definition, and context type.
|
|
144
|
+
* This interface binds together the service definition and its implementation.
|
|
145
|
+
*
|
|
146
|
+
* Note: GrpcService instances are typically created by the protoc-gen-effect code generator
|
|
147
|
+
* when processing .proto files, rather than being manually constructed.
|
|
148
|
+
*
|
|
149
|
+
* @template Tag - A unique identifier for this service (typically a string literal)
|
|
150
|
+
* @template Proto - The Protocol Buffer service definition generated from .proto files
|
|
151
|
+
* @template Ctx - The context type available to service method handlers
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* import { EffectGrpcServer } from "@dr_nikson/effect-grpc"
|
|
156
|
+
* import { UserService } from "./gen/user_pb" // Generated by protoc-gen-effect
|
|
157
|
+
*
|
|
158
|
+
* // Define a service with custom context
|
|
159
|
+
* interface AppContext {
|
|
160
|
+
* userId: string
|
|
161
|
+
* db: Database
|
|
162
|
+
* }
|
|
163
|
+
*
|
|
164
|
+
* // Service definition generated by code generator
|
|
165
|
+
* const userService: EffectGrpcServer.GrpcService<"UserService", typeof UserService, AppContext> =
|
|
166
|
+
* EffectGrpcServer.GrpcService("UserService", UserService)((exec) => ({
|
|
167
|
+
* getUser: (req) => exec.unary(req, ctx, (req, appCtx) =>
|
|
168
|
+
* Effect.gen(function* () {
|
|
169
|
+
* const user = yield* findUser(appCtx.db, req.userId)
|
|
170
|
+
* return { user }
|
|
171
|
+
* })
|
|
172
|
+
* )
|
|
173
|
+
* }))
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export interface GrpcService<Tag, Proto extends GenService<any>, Ctx> {
|
|
177
|
+
readonly Type: GrpcServiceTypeId;
|
|
178
|
+
readonly _Tag: Tag;
|
|
179
|
+
readonly _Ctx: Types.Invariant<Ctx>;
|
|
180
|
+
readonly definition: Proto;
|
|
181
|
+
implementation(executor: ProtoRuntime.ServerExecutor<Ctx>): ServiceImpl<Proto>;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Creates a new GrpcService instance with the specified tag and Protocol Buffer definition.
|
|
185
|
+
* This is typically used by code generators rather than being called manually.
|
|
186
|
+
*
|
|
187
|
+
* @template Tag - The service tag identifier
|
|
188
|
+
* @template Proto - The Protocol Buffer service definition
|
|
189
|
+
* @template RuntimeShape - The runtime shape of the service methods
|
|
190
|
+
*
|
|
191
|
+
* @param tag - Unique identifier for this service
|
|
192
|
+
* @param definition - Protocol Buffer service definition
|
|
193
|
+
* @returns A function that takes an implementation and returns a GrpcService
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```typescript
|
|
197
|
+
* import { EffectGrpcServer } from "@dr_nikson/effect-grpc"
|
|
198
|
+
* import { UserService } from "./gen/user_pb"
|
|
199
|
+
*
|
|
200
|
+
* // Create a service (typically done by code generator)
|
|
201
|
+
* const createUserService = EffectGrpcServer.GrpcService("UserService", UserService)
|
|
202
|
+
*
|
|
203
|
+
* // Provide implementation
|
|
204
|
+
* const userService = createUserService<AppContext>((exec) => ({
|
|
205
|
+
* getUser: (req) => exec.unary(req, ctx, (req, appCtx) =>
|
|
206
|
+
* Effect.succeed({ user: { id: req.userId, name: "John" } })
|
|
207
|
+
* )
|
|
208
|
+
* }))
|
|
209
|
+
* ```
|
|
210
|
+
*/
|
|
211
|
+
export declare const GrpcService: {
|
|
212
|
+
<Tag, Proto extends GenService<RuntimeShape>, RuntimeShape extends GenServiceMethods>(tag: Tag, definition: Proto): <Ctx>(implementation: (exec: ProtoRuntime.ServerExecutor<Ctx>) => ServiceImpl<Proto>) => GrpcService<Tag, Proto, Ctx>;
|
|
213
|
+
};
|
|
214
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAClF,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElE,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,QAAQ,MAAM,sBAAsB,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,WAAW,UAAU,CAAC,EAAE,CAAC,QAAQ;IACrC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAElD,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;CACjD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,QAAQ,IAC1E,CAAC,SAAS,WAAW,CAAC,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,C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