@godspeedai/cognate-protocol-connect 0.1.2 → 0.3.0
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/package.json +5 -5
- package/src/index.ts +30 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@godspeedai/cognate-protocol-connect",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Maps RuntimeService to the generated Connect service (server routes and a remote client). Transport-agnostic.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@bufbuild/protobuf": "2.15.0",
|
|
26
|
-
"@godspeedai/cognate-events": "^0.
|
|
27
|
-
"@godspeedai/cognate-kernel-api": "^0.
|
|
28
|
-
"@godspeedai/cognate-proto": "^0.
|
|
29
|
-
"@godspeedai/cognate-runtime-api": "^0.
|
|
26
|
+
"@godspeedai/cognate-events": "^0.3.0",
|
|
27
|
+
"@godspeedai/cognate-kernel-api": "^0.3.0",
|
|
28
|
+
"@godspeedai/cognate-proto": "^0.3.0",
|
|
29
|
+
"@godspeedai/cognate-runtime-api": "^0.3.0",
|
|
30
30
|
"@connectrpc/connect": "2.2.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -468,8 +468,21 @@ export function registerRuntimeService(router: ConnectRouter, service: RuntimeSe
|
|
|
468
468
|
async readProjection(req, context) {
|
|
469
469
|
try {
|
|
470
470
|
const caller = await requireCaller(options, context);
|
|
471
|
-
const
|
|
472
|
-
return {
|
|
471
|
+
const read = await withDeadline(context, service.readProjection(caller, { name: req.name }));
|
|
472
|
+
return {
|
|
473
|
+
entries: read.rows.map((entry) => ({ key: entry.key, value: jsonToValue(entry.value) })),
|
|
474
|
+
checkpoint: read.checkpoint
|
|
475
|
+
? {
|
|
476
|
+
name: read.checkpoint.name,
|
|
477
|
+
version: read.checkpoint.version,
|
|
478
|
+
position: BigInt(read.checkpoint.position),
|
|
479
|
+
status: read.checkpoint.status,
|
|
480
|
+
errorPosition: read.checkpoint.error ? BigInt(read.checkpoint.error.position) : undefined,
|
|
481
|
+
errorEventId: read.checkpoint.error?.eventId,
|
|
482
|
+
errorMessage: read.checkpoint.error?.message,
|
|
483
|
+
}
|
|
484
|
+
: undefined,
|
|
485
|
+
};
|
|
473
486
|
} catch (e) {
|
|
474
487
|
throwConnectError(e);
|
|
475
488
|
}
|
|
@@ -648,7 +661,21 @@ export function createRemoteRuntimeService(transport: Transport, tokenFor: (call
|
|
|
648
661
|
async readProjection(caller, request) {
|
|
649
662
|
try {
|
|
650
663
|
const response = await client.readProjection({ name: request.name }, { headers: headersFor(caller) });
|
|
651
|
-
return
|
|
664
|
+
return {
|
|
665
|
+
rows: response.entries.map((entry) => ({ key: entry.key, value: valueToJson(entry.value) })),
|
|
666
|
+
checkpoint: response.checkpoint
|
|
667
|
+
? {
|
|
668
|
+
name: response.checkpoint.name,
|
|
669
|
+
version: response.checkpoint.version,
|
|
670
|
+
position: Number(response.checkpoint.position),
|
|
671
|
+
status: response.checkpoint.status === "error" ? "error" : "ok",
|
|
672
|
+
error:
|
|
673
|
+
response.checkpoint.errorEventId !== ""
|
|
674
|
+
? { position: Number(response.checkpoint.errorPosition), eventId: response.checkpoint.errorEventId, message: response.checkpoint.errorMessage }
|
|
675
|
+
: null,
|
|
676
|
+
}
|
|
677
|
+
: null,
|
|
678
|
+
};
|
|
652
679
|
} catch (e) {
|
|
653
680
|
throwServiceError(e);
|
|
654
681
|
}
|