Skip to content

bridge-schema

@vkma.dev/bridge-schema is a JSON Schema catalogue of every VK Bridge event, covering method request props, response/receive data and the Result/Failed event wiring, with generated TypeScript types on top. Thanks to VKCOM/vk-bridge (MIT) for the reference catalogue.

Окно терминала
npm install @vkma.dev/bridge-schema

The root entrypoint exports the payload types plus the three catalogue maps:

  • RequestPropsMap: request props of every sendable method
  • ReceiveDataMap: data of every receivable event
  • ReceiveEventMap: wiring of a method to its Result/Failed event names
import type { RequestPropsMap, UserInfo } from "@vkma.dev/bridge-schema";
type InitProps = RequestPropsMap["VKWebAppInit"];

The maps are declared as interfaces in the package root specifically so that declaration merging works: add your own (or your backend’s proxy) events without forking anything.

declare module "@vkma.dev/bridge-schema" {
interface RequestPropsMap {
VKWebAppMyCustomMethod: { foo: string };
}
interface ReceiveDataMap {
VKWebAppMyCustomMethodResult: { bar: number };
VKWebAppMyCustomMethodFailed: { error_type: string };
}
interface ReceiveEventMap {
VKWebAppMyCustomMethod: {
result: "VKWebAppMyCustomMethodResult";
failed: "VKWebAppMyCustomMethodFailed";
};
}
}

After this, send("VKWebAppMyCustomMethod", { foo: "x" }) is fully typed through @vkma.dev/bridge (which resolves response types via these maps).

Two rules of the road:

  • The augmentation target must be @vkma.dev/bridge-schema. Merging only applies to the module that declares the interfaces; re-exports don’t merge.
  • Extend only. TS interface merging cannot alter existing members; fixes to the built-in catalogue ship as schema releases.

@vkma.dev/bridge-schema/schema exports the raw document for runtime consumers: devtools panels, inspectors, validators.