SDK issues again
# support
b
Folks, can you get your typescript SDK process under control? I upgraded to 0.10.0, and you've changed the namespace under which you export types, breaking imports across my entire codebase. You used to export types at
@vapi-ai/server-sdk/api
, and now they're at
@vapi-ai/server-sdk/dist/cjs/api
. Neither are really standard. I shouldn't need to know your internal paths in order to determine where to import things. I'm going to go ahead and downgrade for now, but this is very busted.
k
b
I've been using the typescript SDK for weeks at this point. I'm familiar with it and am nearing launch. This isn't user error. Go ahead and pull down the SDK and try to reference the
Call
type; you'll see what I'm talking about.
y
@BuckAMayzing per package.json "exports": { ".": { "types": "./dist/cjs/index.d.ts", "import": { "types": "./dist/esm/index.d.mts", "default": "./dist/esm/index.mjs" }, "require": { "types": "./dist/cjs/index.d.ts", "default": "./dist/cjs/index.js" }, "default": "./dist/cjs/index.js" }, "./package.json": "./package.json" }, all exports are barelled inside index.d.ts under namespace
Vapi
, this is staying consisent across versions, switch to that, as /api seems to be also internal
y
@BuckAMayzing You are still not importing the namespace, instead what you are doing, is trying to import the type from the barel export file itself, but the type is actually a namespace export
import { Vapi } from '@vapi-ai/server-sdk
and then
const call: Vapi.Call = {}
b
Ah. I see! That makes sense. And then when I'm overriding (several SDK types are incorrect), I can do the following then, right?
Copy code
interface CallPatches {
  summary?: string;

  artifact?: {
    messages?: Array<{
      role: "user" | "bot" | "system";
      message: string;
      time: number;
    }>;
    messagesOpenAIFormatted?: unknown[];
  } & Record<string, unknown>;
}

declare module "@vapi-ai/server-sdk" {
  namespace Vapi { // <---- declare the same namespace
    interface Call extends CallPatches {}

    interface QuestionAnswer {
      question: string;
      answer: string;
    }
  }
}
y
@BuckAMayzing yes, this is called module augmentation. Just be careful with it, usually if not recommended by sdk docs, module augmentation can mess with original types across future releases.
b
No doubt. I know it's not ideal, but I have little choice when fields are missing. I'll report the ones missing of course, but SDK maintenance is a bit low on Vapi's priority list right now.
Thanks for the help.
y
Anytime mate
c
If you need additional assistance, please feel free to reach out
2 Views