@ovotech/schema-registry-api

v1.1.1
A simple typescript node-fetch wrapper on the confluent schema-registry api

Schema Registry API

A simple typescript node-fetch wrapper on the confluent schema-registry api.

This allows calling the api in a promise-based type-safe manner.

Using

yarn add @ovotech/schema-registry-api
import { Schema } from 'avsc';
const schema: Schema = {
  type: 'record',
  name: 'TestSchema',
  fields: [{ name: 'accountId', type: 'string' }],
};

const subjects = await getSubjects(schemaRegistryUrl);
const newVersion = await addSubjectVersion(schemaRegistryUrl, 'clients', schema);
const foundSchema = await getSchema(schemaRegistryUrl, newVersion.id);

The api rest endpoint are directly translated into functions calling node-fetch:

Function Rest Docs
getSchema(baseUrl: string, id: number) GET /schemas/ids/:id
getSubjects(baseUrl: string) GET /subjects
getSubjectVersions(baseUrl: string, subject: string) GET /subjects/:subject/versions
deleteSubject(baseUrl: string, subject: string) DELETE /subjects/:subject
getSubjectVersionSchema(baseUrl: string, subject: string, version: number) GET /subjects/:subject/versions/:version/schema
addSubjectVersion(baseUrl: string, subject: string, schema: Schema) POST /subjects/:subject/versions
checkSubjectRegistered(baseUrl: string, subject: string, schema: Schema) POST /subjects/:subject
deleteSubjectVersion(baseUrl: string, subject: string, version: number) DELETE /subjects/:subject/versions/:version
`checkCompatibility( baseUrl: string, subject: string, version: number 'latest', schema: Schema)`

But there are also to slightly higher level functions:

idToSchema(baseUrl: string, id: number) - return a schema as a parsed Schema object from a schema id. schemaToId(baseUrl: string, subject: string, schema: Schema) - return the id of a schema object. This will check for an existence of a schema within the given subject, and create a schema version if one was not found.

Running the tests

The tests require a running schema registry service, and we're using docker compose to start it, alongside kafka and zookeeper, required by the service.

So in the project's parent directory run:

docker-compose up

Then you can run the tests with:

yarn test

Coding style (linting, etc) tests

Style is maintained with prettier and tslint

yarn lint

Deployment

Deployment is preferment by lerna automatically on merge / push to master, but you'll need to bump the package version numbers yourself. Only updated packages with newer versions will be pushed to the npm registry.

Contributing

Have a bug? File an issue with a simple example that reproduces this so we can take a look & confirm.

Want to make a change? Submit a PR, explain why it's useful, and make sure you've updated the docs (this file) and the tests (see test folder).

License

This project is licensed under Apache 2 - see the LICENSE file for details

npm i @ovotech/schema-registry-api

Metadata

Downloads

Maintainers

v.kolesnyk, petro.shevchuk.corgi, pedromss, blair.calderwood.radically, fulvio.ovo, ovo-bit-tech, benaston13, retrojetpacks, petegrace, jgarciapaj, willbinzi, ursula_rodgers, kir_exp, j.okeefe, cbousie, oep-accounts-bot, tom-greenwood, dave.allison, apgoodier, nickfitton-ovo, ahmediieovo, dvidg, peterh-ovo, mykola.p, vkobyletskyi_ovo, mugishau, babickd, vmary, mollyboyle, maciek-kaluza, mishabruml, martinzokov, vgrixti-kaluza, ewan-m, eddwilliamsovo, anhnguyenis, tom.mottram.kaluza, vholovko, jchoskins, ablagodyr, vasyl.semenov, suhaelovo, zoelanham, vslepkan, nazarii.dmytrakh, mtardugno-ovo, petro.pavlenko, kslat3r, kieran.allen, oli-boyle, mbayoumy, hersheyovo, radek_tomasek, joelthornhill, clarencedglee, ovocms, ovotech-sme-team, kenneth-gray, philip-ovo, orion-migration-team, ovotech-sg, ovotech-qs, kelveden, ovotech-paym, ovotech-payments, ovotech-live, ovotech-payg, freddybushboy, grug, sarahlikeshiny, ovotech-boost, agaovo, filose, tomverran-ovo, ericaovo, props, yesdaveovo, ikerin, mwidurek, tomshawovo, ovotech-identity, lcatallo, orex-team, smart-heat-uat, smart-heat-prod, potsec, asalvadore, rosario-ovo, tech.international, elbird, teodora.danciu, tozzy, emilyrigby, jvmovo, boost-smile, nicolasov, ovo.cms.devs, mkohlmyr, pdpi_ovo, sketchingdev, mrkiplin, ovo-devices, sophiepoole, joepurnell-ovo, gmbovo, connelldave, molbalazs, joewhittles, sampennington64, marcusgriff, amelia.ovo, taurelius-ovo, juliabutterly, chris.smith, sophiesillmanovo, marcesquerra, pedoublety, ovo-engagement, tokict, marcuskielly, mhipszki, david.chellapah.ovo, kupxc, benaud12, harrisonbaxter, fei-liao, apjm, shnist, mikemchugh, sarahbeharry, ursularodgers, nishanthsinghgurung, inlustra, andrewjtn, ailwyn, tarlingovo, saumyasarpal, troyb95, david.ovo, ovoenergyapps, vytautas.vargonas, sblausten, msinton, marina-ovo, tom-g-dane, kittsville, homemoves, dopperman, samwest, sophiefield, simonmclean-ovo, jamesbaum, robert-g-j, peterwilkins, jamesgregoryovo, paceteamkaluza, henrywoodsend, ovo-oot-bot, tomjeatt, stuharv-ovo, eddiec86, richardjonesovo, csherwin, tudor-harries, rom1hr, g-tibbs, kevin-ovo, puzzledbytheweb, adryanovo, lewright, pedro.caldeira, mikewallace9791, aidenscott2016, keirlawson, notthatchris, dwfullerton, gordok, saralopezib, mvalle_npm, darrenthomas-sse, seagullmouse, markwood23, timsteeleovo, tiffany.yu, jacktreble, gordon-rennie-ovo, adam-mcdevitt, jkiely, ovo-dc, tomsquires, mikebull, orion-digital-support-experience, ovotech-smart-thermostat, olmesm, claudsonoliveira-kaluza, ovosunk, harrylaou, dan-ovo, jbeckett, yahmad, russ-kal, inbrewj, kelemensanyi, gianlo-ovo, samatovo, wtaylor-ovo, jrdavenport, dleyland-ovo, rob.desbois, sicrossley, joey.ciechanowicz, lewisdick-ovo, sophiar, sjmann, stevemossovo, nbrites, eduardolaranjo, unibozu, cp-ui-tooling, lenardprattovo, dieman89, jensraaby-ovo, anthonysmithovo, jacobthwaitesovo, tom.sherman, rumblesan, tomlloyd, matyas-ovo, jamesnoble1, phil-pinkowski, ovo-aarongibbison, nebuladesignsystem, wunderk1nd-e, ovo-matt-hodges, luke-adams-ovo, ovolly, j_kapella, marcovotech, johntaylorovo, mike.walters, bgzstephen, matthewbursteinovo,