JavaScript Schema Registry API for Data Transforms

This page contains the API reference for the Schema Registry client library of the data transforms JavaScript SDK.

Functions

newClient()

newClient (): <<SchemaRegistryClient, `SchemaRegistryClient`>>

Returns a client interface for interacting with Redpanda Schema Registry.

Example

import { newClient, SchemaFormat } from "@redpanda-data/sr";

var sr_client = newClient();
const schema = {
  type: "record",
  name: "Example",
  fields: [
    { "name": "a", "type": "long", "default": 0 },
    { "name": "b", "type": "string", "default": "" }
  ]
};

const subj_schema = sr_client.createSchema(
  "avro-value",
  {
    schema: JSON.stringify(schema),
    format: SchemaFormat.Avro,
    references: [],
  }
);

decodeSchemaID()

decodeSchemaID  (`buf`): <<DecodeResult, `DecodeResult`>>

Parameters

  • buf: string, ArrayBuffer, or Uint8Array

Returns

DecodeResult in the same type as the given argument.

Interfaces

DecodeResult

The result of a decodeSchemaID function.

Properties

  • id (read only): The decoded schema ID

  • rest (read only): The remainder of the input buffer after stripping the encoded ID.

Reference

Properties

  • name: string

  • subject: string

  • version: number

Schema

Properties

SchemaRegistryClient

Client interface for interacting with Redpanda Schema Registry.

Methods

SubjectSchema

Properties

  • id (read only): number

  • schema (read only): Schema

  • subject (read only): string

  • version (read only): number

Enumerations

SchemaFormat

Enumeration members

  • Avro: 0

  • Protobuf: 1

  • JSON: 2