From c410a216a94ad11fd4cc0b913ebc321b7609ebfa Mon Sep 17 00:00:00 2001 From: turbocrime <134443988+turbocrime@users.noreply.github.com> Date: Fri, 15 Mar 2024 07:37:41 -0700 Subject: [PATCH] correct import type paths (#769) --- .../src/utils/rethrow-impl-errors.ts | 25 ++++++++----------- packages/types/src/base64.test.ts | 2 +- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/apps/extension/src/utils/rethrow-impl-errors.ts b/apps/extension/src/utils/rethrow-impl-errors.ts index 4f801c4ed6..08eb02e4f7 100644 --- a/apps/extension/src/utils/rethrow-impl-errors.ts +++ b/apps/extension/src/utils/rethrow-impl-errors.ts @@ -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 = (MethodImplSpec & { + kind: K; +})['impl']; const wrapUnaryImpl = - (methodImplementation: UnaryImpl) => + (methodImplementation: Implementation) => (req: AnyMessage, ctx: HandlerContext) => { try { const result = methodImplementation(req, ctx); @@ -24,7 +21,7 @@ const wrapUnaryImpl = }; const wrapServerStreamingImpl = ( - methodImplementation: ServerStreamingImpl, + methodImplementation: Implementation, ) => async function* (req: AnyMessage, ctx: HandlerContext) { try { @@ -38,9 +35,7 @@ const wrapServerStreamingImpl = ( const wrapUnhandledImpl = ( - methodImplementation: - | ClientStreamingImpl - | BiDiStreamingImpl, + methodImplementation: Implementation, kind: MethodKind, ) => (req: AsyncIterable, ctx: HandlerContext) => { @@ -55,7 +50,7 @@ const isUnaryMethodKind = ( methodImplementation: | ((req: AsyncIterable, ctx: HandlerContext) => unknown) | ((req: AnyMessage, ctx: HandlerContext) => unknown), -): methodImplementation is UnaryImpl => { +): methodImplementation is Implementation => { methodImplementation; return methodKind === MethodKind.Unary; }; @@ -65,7 +60,7 @@ const isServerStreamingMethodKind = ( methodImplementation: | ((req: AsyncIterable, ctx: HandlerContext) => unknown) | ((req: AnyMessage, ctx: HandlerContext) => unknown), -): methodImplementation is ServerStreamingImpl => { +): methodImplementation is Implementation => { methodImplementation; return methodKind === MethodKind.ServerStreaming; }; diff --git a/packages/types/src/base64.test.ts b/packages/types/src/base64.test.ts index b2435a869a..938840a749 100644 --- a/packages/types/src/base64.test.ts +++ b/packages/types/src/base64.test.ts @@ -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', () => {