Skip to content

Commit

Permalink
correct import type paths (#769)
Browse files Browse the repository at this point in the history
  • Loading branch information
turbocrime authored Mar 15, 2024
1 parent 5c3f23f commit c410a21
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
25 changes: 10 additions & 15 deletions apps/extension/src/utils/rethrow-impl-errors.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { AnyMessage, MethodKind, ServiceType } from '@bufbuild/protobuf';
import { ConnectError, ServiceImpl } from '@connectrpc/connect';
import {
BiDiStreamingImpl,
ClientStreamingImpl,
HandlerContext,
ServerStreamingImpl,
UnaryImpl,
} from '@connectrpc/connect/dist/cjs/implementation';
import { ConnectError, HandlerContext, MethodImplSpec, ServiceImpl } from '@connectrpc/connect';

type Implementation<K extends MethodKind> = (MethodImplSpec & {
kind: K;
})['impl'];

const wrapUnaryImpl =
(methodImplementation: UnaryImpl<AnyMessage, AnyMessage>) =>
(methodImplementation: Implementation<MethodKind.Unary>) =>
(req: AnyMessage, ctx: HandlerContext) => {
try {
const result = methodImplementation(req, ctx);
Expand All @@ -24,7 +21,7 @@ const wrapUnaryImpl =
};

const wrapServerStreamingImpl = (
methodImplementation: ServerStreamingImpl<AnyMessage, AnyMessage>,
methodImplementation: Implementation<MethodKind.ServerStreaming>,
) =>
async function* (req: AnyMessage, ctx: HandlerContext) {
try {
Expand All @@ -38,9 +35,7 @@ const wrapServerStreamingImpl = (

const wrapUnhandledImpl =
(
methodImplementation:
| ClientStreamingImpl<AnyMessage, AnyMessage>
| BiDiStreamingImpl<AnyMessage, AnyMessage>,
methodImplementation: Implementation<MethodKind.ClientStreaming | MethodKind.BiDiStreaming>,
kind: MethodKind,
) =>
(req: AsyncIterable<AnyMessage>, ctx: HandlerContext) => {
Expand All @@ -55,7 +50,7 @@ const isUnaryMethodKind = (
methodImplementation:
| ((req: AsyncIterable<AnyMessage>, ctx: HandlerContext) => unknown)
| ((req: AnyMessage, ctx: HandlerContext) => unknown),
): methodImplementation is UnaryImpl<AnyMessage, AnyMessage> => {
): methodImplementation is Implementation<MethodKind.Unary> => {
methodImplementation;
return methodKind === MethodKind.Unary;
};
Expand All @@ -65,7 +60,7 @@ const isServerStreamingMethodKind = (
methodImplementation:
| ((req: AsyncIterable<AnyMessage>, ctx: HandlerContext) => unknown)
| ((req: AnyMessage, ctx: HandlerContext) => unknown),
): methodImplementation is ServerStreamingImpl<AnyMessage, AnyMessage> => {
): methodImplementation is Implementation<MethodKind.ServerStreaming> => {
methodImplementation;
return methodKind === MethodKind.ServerStreaming;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/base64.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
InnerBase64Schema,
uint8ArrayToBase64,
} from './base64';
import { SafeParseError } from 'zod/lib/types';
import type { SafeParseError } from 'zod';

describe('Base64StringSchema', () => {
it('validates base64 strings', () => {
Expand Down

0 comments on commit c410a21

Please sign in to comment.