Skip to content

The catalogue as data

Besides types, the package exports the catalogue as runtime data: a JSON Schema document and wiring tables. Devtools panels, inspectors and validators read these.

Subpath Exports For
/schema eventsSchema, catalogue The full JSON Schema document with $defs
/catalogue catalogue, stubs Wiring tables and payload stubs without the heavy $defs
import { catalogue, eventsSchema } from "@vkma.dev/bridge-schema/schema";
catalogue.props.VKWebAppInit; // "VKWebAppInitProps" — the definition name in $defs
catalogue.events.VKWebAppGetAuthToken; // { result: "VKWebAppAccessTokenReceived", failed: "VKWebAppAccessTokenFailed" }
eventsSchema.$defs.UserInfo; // the payload's JSON Schema node

eventsSchema is a JSON Schema draft 2020-12 document:

  • $defs — 270 payload definitions (plain objects, enums, anyOf branches);
  • x-vkma-catalogue — three wiring tables: props (96 sendable methods), receive (115 receivable names), events (94 methods with Result/Failed wiring).

Table entries reference $defs by name. The TypeScript types in the root entrypoint are generated from this same document — data and types cannot drift apart.

import type { EventsCatalogue, EventsSchemaDocument } from "@vkma.dev/bridge-schema/schema";
const wiring: EventsCatalogue["events"] = catalogue.events;
const doc: EventsSchemaDocument = eventsSchema;

$defs is a plain JSON Schema document. When data arrives from outside (a log record, a foreign collector), validate it with your validator of choice:

import { eventsSchema } from "@vkma.dev/bridge-schema/schema";
import { Ajv2020 } from "ajv/dist/2020.js";
const ajv = new Ajv2020();
const validateUserInfo = ajv.compile(eventsSchema.$defs.UserInfo);
if (validateUserInfo(data)) {
// data conforms to the catalogue's VKWebAppGetUserInfo payload
}

stubs from /catalogue maps a method to a minimal object of its required props, precomputed from $defs at generation time (required keys only, depth-capped, first branch of any anyOf; anything underivable is simply absent):

import { stubs } from "@vkma.dev/bridge-schema/catalogue";
stubs.VKWebAppStorageGet; // { keys: [] }
stubs.VKWebAppShowWallPostBox; // { attachments: "" }

The use case is a “pick a method, get a props skeleton” form: the devtools execute panel and the inspector prefill fields this way, without shipping the whole $defs document.

declare module augmentation does not affect the data — extending the catalogue extends types only.