@amritk/adapters 0.4.4 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AI.md +13 -5
- package/README.md +50 -5
- package/dist/adapter.d.ts +5 -1
- package/dist/avro-to-json-schema.d.ts +89 -0
- package/dist/avro-to-json-schema.js +367 -0
- package/dist/get-adapter.js +8 -1
- package/dist/report-lossy-constructs.d.ts +1 -1
- package/dist/source-format.d.ts +6 -1
- package/package.json +11 -3
package/AI.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# @amritk/adapters — notes for AI coding agents
|
|
2
2
|
|
|
3
|
-
Convert schemas authored in TypeBox, Zod, Valibot, or Effect
|
|
4
|
-
|
|
5
|
-
reference is [README.md](./README.md).
|
|
3
|
+
Convert schemas authored in TypeBox, Zod, Valibot, or Effect — or an Apache
|
|
4
|
+
Avro `.avsc` document — into Draft 2020-12 JSON Schema, the single input shape
|
|
5
|
+
the mjst generators consume. Full reference is [README.md](./README.md).
|
|
6
6
|
|
|
7
7
|
> Pre-alpha: APIs change in **minor** versions.
|
|
8
8
|
|
|
@@ -27,17 +27,25 @@ const jsonSchema = await adapter.toJSONSchema(User) // always await
|
|
|
27
27
|
is the caller's job.
|
|
28
28
|
3. **`getAdapter('json')` throws** — `'json'` is a valid `SourceFormat` but has no
|
|
29
29
|
adapter (JSON Schema is read directly). Only `typebox` / `zod` / `valibot` /
|
|
30
|
-
`effect` resolve.
|
|
30
|
+
`effect` / `avro` resolve.
|
|
31
31
|
4. **Source libraries are optional peer deps**, imported dynamically. **Zod must
|
|
32
32
|
be v4+** (`toJSONSchema` doesn't exist earlier). Always `await` — even
|
|
33
33
|
TypeBox's synchronous path is typed to allow a Promise.
|
|
34
34
|
5. **Unrepresentable constructs widen to `{}`** with a stderr `[mjst]` warning
|
|
35
35
|
(Effect throws on nested ones). `date` / `bigint` become `x-mjst` hints. Pass
|
|
36
36
|
`{ strict: true }` to throw instead of widening.
|
|
37
|
+
6. **Avro takes a parsed `.avsc`, not a module, and needs no peer dep.** Pick the
|
|
38
|
+
encoding deliberately: `avroToJsonSchema(avro)` describes the idiomatic
|
|
39
|
+
decoded object (nullable unions, base64 bytes, defaulted fields optional);
|
|
40
|
+
`{ encoding: 'avro-json' }` describes the spec's JSON encoding (branch-tagged
|
|
41
|
+
union wrappers, every field required) — that is the one to validate an
|
|
42
|
+
AsyncAPI `examples.payload` against. Do not expect `timestamp-millis` to
|
|
43
|
+
become `format: 'date-time'`: Avro encodes it as a `long` in JSON too.
|
|
37
44
|
|
|
38
45
|
## Subpaths
|
|
39
46
|
|
|
40
47
|
`@amritk/adapters/get-adapter`, `.../typebox-to-json-schema`,
|
|
41
48
|
`.../zod-to-json-schema`, `.../valibot-to-json-schema`,
|
|
42
|
-
`.../effect-to-json-schema`, `.../adapter` (types),
|
|
49
|
+
`.../effect-to-json-schema`, `.../avro-to-json-schema`, `.../adapter` (types),
|
|
50
|
+
`.../source-format` (types).
|
|
43
51
|
Install: `bun add @amritk/adapters` (+ your source library).
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# @amritk/adapters
|
|
4
4
|
|
|
5
|
-
**Convert schemas authored in TypeBox, Zod, Valibot, or
|
|
5
|
+
**Convert schemas authored in TypeBox, Zod, Valibot, Effect, or Apache Avro into Draft 2020-12 JSON Schema — the single input shape the mjst generators understand.**
|
|
6
6
|
|
|
7
7
|

|
|
8
8
|

|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
|
|
18
18
|
## Overview
|
|
19
19
|
|
|
20
|
-
mjst's generators — parsers, validators, types, docs, test data — all take **one** input: a Draft 2020-12 JSON Schema. This package lets you author that schema
|
|
20
|
+
mjst's generators — parsers, validators, types, docs, test data — all take **one** input: a Draft 2020-12 JSON Schema. This package lets you author that schema somewhere else instead. It converts a **TypeBox**, **Zod**, **Valibot**, or **Effect** schema — or an **Apache Avro** `.avsc` document — into JSON Schema, then hands the result straight to the generators.
|
|
21
21
|
|
|
22
|
-
The [`mjst`](../cli) CLI wires these in behind the `--input <format>` flag (`typebox`, `zod`, `valibot`, `effect`)
|
|
22
|
+
The [`mjst`](../cli) CLI wires these in behind the `--input <format>` flag (`typebox`, `zod`, `valibot`, `effect`, `avro`). For the library formats the `--schema` path points at a JS/TS **module** that exports a schema rather than a `.json` file; for `avro` it points at the `.avsc` document itself, which is read as data and never imported. You can also call the adapters directly — each is a small, pure function.
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
The library adapters lean on their source library's own JSON Schema exporter (Zod 4's `toJSONSchema`, `@valibot/to-json-schema`, Effect's `JSONSchema.make`; TypeBox schemas are already JSON Schema at runtime) and then normalise the result. Avro is the exception — it has no such exporter, so that conversion is implemented here in full (and needs no dependency, since an Avro schema is itself JSON). Normalisation:
|
|
25
25
|
|
|
26
26
|
- strips the dialect marker (`$schema`) the generators don't need,
|
|
27
27
|
- rewrites constructs JSON Schema can't express — runtime `Date`, `bigint` — into the shared [`x-mjst`](#the-x-mjst-extension) hint the generators read, and
|
|
@@ -46,6 +46,7 @@ The source libraries are **optional peer dependencies** — each adapter dynamic
|
|
|
46
46
|
| `zod` | `zod@>=4` |
|
|
47
47
|
| `valibot` | `valibot@>=1` **and** `@valibot/to-json-schema@>=1` |
|
|
48
48
|
| `effect` | `effect@>=3` |
|
|
49
|
+
| `avro` | *(nothing — an Avro schema is plain JSON)* |
|
|
49
50
|
|
|
50
51
|
If the required package is missing (or too old), the adapter throws a clear, actionable error naming what to install — e.g. *"The Zod adapter requires 'zod' (v4 or later) to be installed in your project."*
|
|
51
52
|
|
|
@@ -56,9 +57,10 @@ If the required package is missing (or too old), the adapter throws a clear, act
|
|
|
56
57
|
|
|
57
58
|
## Usage
|
|
58
59
|
|
|
59
|
-
Each adapter is a function `(source: unknown) => Promise<JSONSchema>` (TypeBox
|
|
60
|
+
Each adapter is a function `(source: unknown) => Promise<JSONSchema>` (the TypeBox and Avro adapters are synchronous, but are exposed through `getAdapter` with the same signature for uniformity — so always `await` when you go through it). Import them by subpath:
|
|
60
61
|
|
|
61
62
|
```ts
|
|
63
|
+
import { avroToJsonSchema } from '@amritk/adapters/avro-to-json-schema'
|
|
62
64
|
import { typeboxToJsonSchema } from '@amritk/adapters/typebox-to-json-schema'
|
|
63
65
|
import { zodToJsonSchema } from '@amritk/adapters/zod-to-json-schema'
|
|
64
66
|
import { valibotToJsonSchema } from '@amritk/adapters/valibot-to-json-schema'
|
|
@@ -147,6 +149,48 @@ const jsonSchema = await effectToJsonSchema(User)
|
|
|
147
149
|
|
|
148
150
|
Requires `effect@>=3`. A `Schema.BigIntFromSelf` / `Schema.DateFromSelf` **anywhere in the tree** — top level or nested inside a struct, array, or union — is rescued into an `x-mjst` hint; every subtree `JSONSchema.make` accepts is taken from it verbatim. **Read the [encoded-representation caveat](#effect-encodes-the-wire-representation) before choosing between `Schema.Date` and `Schema.DateFromSelf`** — it changes whether you get a `string` or a runtime `Date`.
|
|
149
151
|
|
|
152
|
+
### Avro
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import { readFile } from 'node:fs/promises'
|
|
156
|
+
import { avroToJsonSchema } from '@amritk/adapters/avro-to-json-schema'
|
|
157
|
+
|
|
158
|
+
const avro = JSON.parse(await readFile('user.avsc', 'utf-8'))
|
|
159
|
+
const jsonSchema = avroToJsonSchema(avro)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
No peer dependency: an Avro schema is a JSON document, so the adapter reads it directly. Every named type — `record`, `enum`, `fixed` — is defined once under its **fullname** in `$defs` and referenced by `$ref` everywhere it appears, so a recursive type stays finite and `com.example.User` generates a `ComExampleUser` type rather than an inline shape repeated at each use site.
|
|
163
|
+
|
|
164
|
+
#### Pick the encoding you actually mean
|
|
165
|
+
|
|
166
|
+
Avro is a binary format with a *separately specified* JSON encoding, and the two readings of "the JSON for this schema" genuinely disagree. The adapter makes you choose:
|
|
167
|
+
|
|
168
|
+
| `encoding` | Describes | Unions | `bytes` | Fields with a `default` |
|
|
169
|
+
|:---|:---|:---|:---|:---|
|
|
170
|
+
| `'json'` *(default)* | the object your application code sees | plain `anyOf`; `["null", T]` collapses to a nullable `T` | base64 string | optional |
|
|
171
|
+
| `'avro-json'` | the spec's JSON encoding — what travels as `application/vnd.apache.avro+json` | single-key wrapper objects tagged with the branch's fullname | codepoint-per-byte string | required |
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
// Generating TypeScript types and parsers? You want the idiomatic shape.
|
|
175
|
+
avroToJsonSchema(avro)
|
|
176
|
+
|
|
177
|
+
// Validating an AsyncAPI examples.payload? You want the wire shape.
|
|
178
|
+
avroToJsonSchema(avro, { encoding: 'avro-json' })
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The `default` column is not a stylistic choice. Avro has **no optional fields** — every declared field is present in the encoding, and a `default` is only consulted during schema resolution, when reading data written against a *different* schema. So `'avro-json'` marks every field required, because that is what is on the wire, while `'json'` treats a defaulted field as optional, because that is the shape application code deals with.
|
|
182
|
+
|
|
183
|
+
The default **value** is translated too, not just copied, because Avro writes it in neither encoding exactly. Avro states a union's default as a *bare* value of the union's **first** branch, so under `'avro-json'` it is wrapped to match the branch tagging the data uses (`null` stays bare, in both the `"null"` and `{"type": "null"}` spellings). Under `'json'` a byte default is in the wrong alphabet — Avro writes it latin-1, the idiomatic shape is base64 — so it is dropped rather than mistranslated. Both rules apply at any depth: a union nested inside a record, array, or map default is tagged the same way, and a byte value anywhere inside a default drops the whole thing, since a half-translated default is worse than none. This matters more than a stray annotation would, because `@amritk/generate-parsers` coerces with `default`.
|
|
184
|
+
|
|
185
|
+
#### What deliberately does not get refined
|
|
186
|
+
|
|
187
|
+
Two mappings look like omissions and are not:
|
|
188
|
+
|
|
189
|
+
- **A `long` gets no bounds.** Its range is ±2^63, which no JSON number can represent — a stated `maximum` would round to 2^63 and be both wrong and unreachable. (A `long` past 2^53 will not survive `JSON.parse` intact either, whatever the schema says.) An `int` *is* bounded, since ±2^31 lands exactly on a double.
|
|
190
|
+
- **Date and time logical types stay integers.** Avro encodes `timestamp-millis` as a `long` in its JSON encoding as much as in binary, so `format: 'date-time'` would describe a string that never arrives. Only `uuid` genuinely narrows its base type, to `{ type: 'string', format: 'uuid' }`.
|
|
191
|
+
|
|
192
|
+
`decimal` and `duration` carry structure JSON Schema cannot express (precision/scale; three unsigned 32-bit ints in 12 bytes), so they degrade to their base type and are reported through the usual widening warning. An unrecognised `logicalType` falls through to its base type silently, which the Avro spec requires — as does one declared on a base it is not defined for (`decimal` on a `record`, say), which is invalid rather than lossy and so is ignored rather than reported. `aliases` and field `order` describe how *two* schemas relate during resolution and have no place in a single document's shape, so they are ignored. Names **are** validated: one is written straight into a `$defs` key and the `$ref` pointing at it, so an illegal name would silently produce a different, broken JSON Pointer rather than an error.
|
|
193
|
+
|
|
150
194
|
---
|
|
151
195
|
|
|
152
196
|
## The `x-mjst` extension
|
|
@@ -213,6 +257,7 @@ Some source types have no faithful JSON Schema representation and are **not** re
|
|
|
213
257
|
- **Zod.** These Zod types become "accept anything": `symbol`, `nan`, `void`, `undefined`, `never`, `map`, `set`, `promise`, `function`. When any appear, the adapter logs, e.g.: *"[mjst] Zod adapter: function, symbol have no JSON Schema representation and became 'accept anything'. The generated type will be wider than the Zod schema."*
|
|
214
258
|
- **Valibot.** The converter runs in `errorMode: 'warn'`: an unsupported construct degrades to an open schema and `@valibot/to-json-schema` logs which one, so the widening is reported by the converter itself.
|
|
215
259
|
- **TypeBox.** An extended `type` string with no mapping (see below) is left unchanged with a warning: *"[mjst] TypeBox type '…' has no JSON Schema or x-mjst mapping; leaving it unchanged."*
|
|
260
|
+
- **Avro.** Only the `decimal` and `duration` logical types widen, each degrading to its base type: *"[mjst] Avro adapter: the decimal logical type (precision/scale) has no full JSON Schema representation and was widened."* Everything else in Avro maps exactly, or is rejected outright — a duplicate name, a reference to an undefined name, or a malformed `record`/`enum`/`fixed` throws rather than converting to something wrong.
|
|
216
261
|
- **Effect.** Effect does not widen — it is stricter. `JSONSchema.make` throws on any unrepresentable type, wherever it sits. The adapter catches that and descends structurally, rebuilding the container (struct, array, union, refinement, …) and rescuing every `BigIntFromSelf` / `DateFromSelf` leaf it reaches into an `x-mjst` hint. Only a leaf it has no rescue for (a raw `symbol`, say) is fatal, and then it throws an actionable message rather than Effect's opaque one: replace the type with a JSON-representable one, or add a `jsonSchema` annotation to that field.
|
|
217
262
|
|
|
218
263
|
If any of these matter to your schema, prefer a representable alternative (e.g. model a set as an array) or add the library's own JSON Schema annotation.
|
package/dist/adapter.d.ts
CHANGED
|
@@ -2,8 +2,12 @@ import type { JSONSchema } from 'json-schema-typed/draft-2020-12';
|
|
|
2
2
|
import type { SourceFormat } from './source-format.js';
|
|
3
3
|
/**
|
|
4
4
|
* Options that tune how an adapter handles source constructs with no JSON
|
|
5
|
-
* Schema representation.
|
|
5
|
+
* Schema representation. The Zod, Valibot and Avro adapters read these today;
|
|
6
6
|
* adapters that ignore the argument simply keep their default behaviour.
|
|
7
|
+
*
|
|
8
|
+
* An adapter may also accept options of its own by widening this type — see
|
|
9
|
+
* `AvroAdapterOptions`, whose `encoding` no other adapter reads. That stays
|
|
10
|
+
* assignable to {@link Adapter} because the extra field is optional.
|
|
7
11
|
*/
|
|
8
12
|
export type AdapterOptions = {
|
|
9
13
|
/**
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { JSONSchema } from 'json-schema-typed/draft-2020-12';
|
|
2
|
+
import type { AdapterOptions } from './adapter.js';
|
|
3
|
+
/**
|
|
4
|
+
* Which JSON shape the produced schema describes.
|
|
5
|
+
*
|
|
6
|
+
* Avro is a binary format with a *separately specified* JSON encoding, and the
|
|
7
|
+
* two readings of "the JSON for this Avro schema" genuinely disagree — most
|
|
8
|
+
* visibly on unions, where the spec wraps a value in its branch name
|
|
9
|
+
* (`{"string": "hi"}`) and application code almost never does. One converter
|
|
10
|
+
* cannot serve both silently, so the caller picks.
|
|
11
|
+
*
|
|
12
|
+
* - `'json'` (default) describes the **idiomatic** object an application sees
|
|
13
|
+
* after decoding: unions are plain `anyOf`, a `["null", T]` union is just a
|
|
14
|
+
* nullable `T`, and `bytes` is base64. This is the shape you want when
|
|
15
|
+
* generating TypeScript types and parsers.
|
|
16
|
+
* - `'avro-json'` describes the **spec's JSON encoding** — the bytes that
|
|
17
|
+
* actually travel under the `application/vnd.apache.avro+json` media type.
|
|
18
|
+
* Unions become single-key wrapper objects and `bytes` is the spec's
|
|
19
|
+
* codepoint-per-byte string. This is the shape to validate an AsyncAPI
|
|
20
|
+
* `examples.payload` against.
|
|
21
|
+
*/
|
|
22
|
+
export type AvroEncoding = 'json' | 'avro-json';
|
|
23
|
+
/** Options for {@link avroToJsonSchema}; `encoding` is read by this adapter alone. */
|
|
24
|
+
export type AvroAdapterOptions = AdapterOptions & {
|
|
25
|
+
/** Which JSON shape to describe. Defaults to `'json'` (idiomatic). */
|
|
26
|
+
readonly encoding?: AvroEncoding;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Converts an Apache Avro schema (the parsed contents of a `.avsc` file) into a
|
|
30
|
+
* Draft 2020-12 JSON Schema.
|
|
31
|
+
*
|
|
32
|
+
* Every named type — record, enum, fixed — is defined once under its **fullname**
|
|
33
|
+
* in `$defs` and referenced by `$ref` everywhere it appears, including at its
|
|
34
|
+
* own declaration. That keeps a recursive type finite, writes a shared type
|
|
35
|
+
* once, and gives the mjst generators a named node per Avro type, so
|
|
36
|
+
* `com.example.User` generates a `ComExampleUser` type rather than an inline
|
|
37
|
+
* shape repeated at each use site.
|
|
38
|
+
*
|
|
39
|
+
* Two things this deliberately does *not* do, because doing them would describe
|
|
40
|
+
* data that never arrives:
|
|
41
|
+
*
|
|
42
|
+
* - **A `long` gets no bounds.** Its range is ±2^63, which no JSON number can
|
|
43
|
+
* represent; a stated `maximum` would round to 2^63 and be both wrong and
|
|
44
|
+
* unreachable. Note that a `long` past 2^53 cannot survive `JSON.parse`
|
|
45
|
+
* intact either, whatever the schema says.
|
|
46
|
+
* - **Date and time logical types stay integers.** Avro encodes
|
|
47
|
+
* `timestamp-millis` as a `long` in its JSON encoding as much as in binary, so
|
|
48
|
+
* `format: 'date-time'` would be a lie. Only `uuid` narrows its base type.
|
|
49
|
+
*
|
|
50
|
+
* Schema resolution features that describe how *two* schemas relate — `aliases`
|
|
51
|
+
* and field `order` — have no place in a single document's shape and are
|
|
52
|
+
* ignored.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const avro = {
|
|
57
|
+
* type: 'record',
|
|
58
|
+
* name: 'User',
|
|
59
|
+
* namespace: 'com.example',
|
|
60
|
+
* fields: [
|
|
61
|
+
* { name: 'id', type: 'string' },
|
|
62
|
+
* { name: 'nickname', type: ['null', 'string'], default: null },
|
|
63
|
+
* ],
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* avroToJsonSchema(avro)
|
|
67
|
+
* // {
|
|
68
|
+
* // $ref: '#/$defs/com.example.User',
|
|
69
|
+
* // $defs: {
|
|
70
|
+
* // 'com.example.User': {
|
|
71
|
+
* // title: 'User',
|
|
72
|
+
* // type: 'object',
|
|
73
|
+
* // properties: {
|
|
74
|
+
* // id: { type: 'string' },
|
|
75
|
+
* // nickname: { type: ['string', 'null'], default: null },
|
|
76
|
+
* // },
|
|
77
|
+
* // required: ['id'],
|
|
78
|
+
* // additionalProperties: false,
|
|
79
|
+
* // },
|
|
80
|
+
* // },
|
|
81
|
+
* // }
|
|
82
|
+
*
|
|
83
|
+
* // The same schema as it travels under application/vnd.apache.avro+json:
|
|
84
|
+
* avroToJsonSchema(avro, { encoding: 'avro-json' })
|
|
85
|
+
* // nickname becomes anyOf: [{type:'null'}, {type:'object', properties:{string:…}}]
|
|
86
|
+
* // and is required, because Avro's encoding carries every declared field.
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare const avroToJsonSchema: (source: unknown, options?: AvroAdapterOptions) => JSONSchema;
|
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
import { reportLossyConstructs } from "./report-lossy-constructs.js";
|
|
2
|
+
const JSON_TYPE_NAMES = ["null", "boolean", "integer", "number", "string", "object", "array"];
|
|
3
|
+
const NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
4
|
+
const assertLegalFullname = (fullname, what) => {
|
|
5
|
+
const parts = fullname.split(".");
|
|
6
|
+
if (parts.every((part) => NAME_PATTERN.test(part)))
|
|
7
|
+
return;
|
|
8
|
+
throw new Error(`Avro adapter: ${what} "${fullname}" is not a legal Avro name. Each dot-separated part must match [A-Za-z_][A-Za-z0-9_]*.`);
|
|
9
|
+
};
|
|
10
|
+
const PRIMITIVES = /* @__PURE__ */ new Set(["null", "boolean", "int", "long", "float", "double", "bytes", "string"]);
|
|
11
|
+
const NAMED_TYPES = /* @__PURE__ */ new Set(["record", "enum", "fixed"]);
|
|
12
|
+
const INT_MIN = -2147483648;
|
|
13
|
+
const INT_MAX = 2147483647;
|
|
14
|
+
const BYTE_STRING_PATTERN = "^[\\u0000-\\u00ff]*$";
|
|
15
|
+
const isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
16
|
+
const readString = (source, key) => {
|
|
17
|
+
if (!Object.hasOwn(source, key))
|
|
18
|
+
return void 0;
|
|
19
|
+
const value = source[key];
|
|
20
|
+
return typeof value === "string" ? value : void 0;
|
|
21
|
+
};
|
|
22
|
+
const namespaceOf = (fullname) => {
|
|
23
|
+
const lastDot = fullname.lastIndexOf(".");
|
|
24
|
+
return lastDot === -1 ? void 0 : fullname.slice(0, lastDot);
|
|
25
|
+
};
|
|
26
|
+
const definitionFullname = (node, context) => {
|
|
27
|
+
const name = readString(node, "name");
|
|
28
|
+
if (name === void 0 || name === "") {
|
|
29
|
+
throw new Error(`Avro adapter: a ${String(node["type"])} definition is missing its required "name".`);
|
|
30
|
+
}
|
|
31
|
+
const fullname = (() => {
|
|
32
|
+
if (name.includes("."))
|
|
33
|
+
return name;
|
|
34
|
+
const declared = readString(node, "namespace");
|
|
35
|
+
if (declared !== void 0)
|
|
36
|
+
return declared === "" ? name : `${declared}.${name}`;
|
|
37
|
+
return context.namespace === void 0 ? name : `${context.namespace}.${name}`;
|
|
38
|
+
})();
|
|
39
|
+
assertLegalFullname(fullname, "the name");
|
|
40
|
+
return fullname;
|
|
41
|
+
};
|
|
42
|
+
const resolveReference = (name, context) => {
|
|
43
|
+
assertLegalFullname(name, "the reference");
|
|
44
|
+
if (name.includes("."))
|
|
45
|
+
return name;
|
|
46
|
+
const qualified = context.namespace === void 0 ? void 0 : `${context.namespace}.${name}`;
|
|
47
|
+
if (qualified !== void 0 && context.defs.has(qualified))
|
|
48
|
+
return qualified;
|
|
49
|
+
return name;
|
|
50
|
+
};
|
|
51
|
+
const refTo = (fullname) => ({ $ref: `#/$defs/${fullname}` });
|
|
52
|
+
const soleTypeOf = (schema) => {
|
|
53
|
+
if (!isRecord(schema))
|
|
54
|
+
return void 0;
|
|
55
|
+
const keys = Object.keys(schema);
|
|
56
|
+
if (keys.length !== 1 || keys[0] !== "type")
|
|
57
|
+
return void 0;
|
|
58
|
+
const type = schema["type"];
|
|
59
|
+
return JSON_TYPE_NAMES.find((name) => name === type);
|
|
60
|
+
};
|
|
61
|
+
const convertPrimitive = (type, context) => {
|
|
62
|
+
switch (type) {
|
|
63
|
+
case "null":
|
|
64
|
+
return { type: "null" };
|
|
65
|
+
case "boolean":
|
|
66
|
+
return { type: "boolean" };
|
|
67
|
+
case "int":
|
|
68
|
+
return { type: "integer", minimum: INT_MIN, maximum: INT_MAX };
|
|
69
|
+
case "long":
|
|
70
|
+
return { type: "integer" };
|
|
71
|
+
case "float":
|
|
72
|
+
case "double":
|
|
73
|
+
return { type: "number" };
|
|
74
|
+
case "string":
|
|
75
|
+
return { type: "string" };
|
|
76
|
+
case "bytes":
|
|
77
|
+
return context.encoding === "avro-json" ? { type: "string", pattern: BYTE_STRING_PATTERN } : { type: "string", contentEncoding: "base64" };
|
|
78
|
+
default:
|
|
79
|
+
throw new Error(`Avro adapter: unknown primitive type "${type}".`);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const applyLogicalType = (base, logicalType, avroType, context) => {
|
|
83
|
+
switch (logicalType) {
|
|
84
|
+
case "uuid":
|
|
85
|
+
return avroType === "string" && soleTypeOf(base) === "string" ? { ...base, format: "uuid" } : base;
|
|
86
|
+
case "decimal":
|
|
87
|
+
if (avroType !== "bytes" && avroType !== "fixed")
|
|
88
|
+
return base;
|
|
89
|
+
context.lossy.add("the decimal logical type (precision/scale)");
|
|
90
|
+
return base;
|
|
91
|
+
case "duration":
|
|
92
|
+
if (avroType !== "fixed")
|
|
93
|
+
return base;
|
|
94
|
+
context.lossy.add("the duration logical type");
|
|
95
|
+
return base;
|
|
96
|
+
default:
|
|
97
|
+
return base;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const convertUnion = (branches, context) => {
|
|
101
|
+
if (branches.length === 0) {
|
|
102
|
+
throw new Error("Avro adapter: a union must have at least one branch, but an empty array was found.");
|
|
103
|
+
}
|
|
104
|
+
if (context.encoding === "avro-json") {
|
|
105
|
+
const wrapped = branches.map((branch) => {
|
|
106
|
+
const schema = convertSchema(branch, context);
|
|
107
|
+
if (soleTypeOf(schema) === "null")
|
|
108
|
+
return schema;
|
|
109
|
+
const tag = avroJsonBranchName(branch, context);
|
|
110
|
+
return {
|
|
111
|
+
type: "object",
|
|
112
|
+
properties: { [tag]: schema },
|
|
113
|
+
required: [tag],
|
|
114
|
+
additionalProperties: false
|
|
115
|
+
};
|
|
116
|
+
});
|
|
117
|
+
return wrapped.length === 1 ? wrapped[0] : { anyOf: wrapped };
|
|
118
|
+
}
|
|
119
|
+
const converted = branches.map((branch) => convertSchema(branch, context));
|
|
120
|
+
if (converted.length === 1)
|
|
121
|
+
return converted[0];
|
|
122
|
+
const types = converted.map(soleTypeOf);
|
|
123
|
+
if (types.every((type) => type !== void 0)) {
|
|
124
|
+
const unique = [...new Set(types)];
|
|
125
|
+
const ordered = [...unique.filter((type) => type !== "null"), ...unique.filter((type) => type === "null")];
|
|
126
|
+
const [only] = ordered;
|
|
127
|
+
return ordered.length === 1 && only !== void 0 ? { type: only } : { type: ordered };
|
|
128
|
+
}
|
|
129
|
+
return { anyOf: converted };
|
|
130
|
+
};
|
|
131
|
+
const avroJsonBranchName = (branch, context) => {
|
|
132
|
+
if (typeof branch === "string") {
|
|
133
|
+
return PRIMITIVES.has(branch) ? branch : resolveReference(branch, context);
|
|
134
|
+
}
|
|
135
|
+
if (isRecord(branch)) {
|
|
136
|
+
const type = readString(branch, "type");
|
|
137
|
+
if (type !== void 0 && NAMED_TYPES.has(type))
|
|
138
|
+
return definitionFullname(branch, context);
|
|
139
|
+
if (type !== void 0) {
|
|
140
|
+
return PRIMITIVES.has(type) || type === "array" || type === "map" ? type : resolveReference(type, context);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
throw new Error(`Avro adapter: cannot name the union branch ${JSON.stringify(branch)}.`);
|
|
144
|
+
};
|
|
145
|
+
const dereferenceAvroType = (avroType, context) => {
|
|
146
|
+
if (typeof avroType === "string") {
|
|
147
|
+
if (PRIMITIVES.has(avroType))
|
|
148
|
+
return { node: avroType, namespace: context.namespace };
|
|
149
|
+
const fullname = resolveReference(avroType, context);
|
|
150
|
+
const found = context.avroDefs.get(fullname);
|
|
151
|
+
return found === void 0 ? { node: avroType, namespace: context.namespace } : { node: found, namespace: namespaceOf(fullname) };
|
|
152
|
+
}
|
|
153
|
+
if (isRecord(avroType)) {
|
|
154
|
+
const type = readString(avroType, "type");
|
|
155
|
+
if (type !== void 0 && NAMED_TYPES.has(type)) {
|
|
156
|
+
return { node: avroType, namespace: namespaceOf(definitionFullname(avroType, context)) };
|
|
157
|
+
}
|
|
158
|
+
if (type !== void 0 && !PRIMITIVES.has(type) && type !== "array" && type !== "map") {
|
|
159
|
+
return dereferenceAvroType(type, context);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return { node: avroType, namespace: context.namespace };
|
|
163
|
+
};
|
|
164
|
+
const isNullType = (avroType) => avroType === "null" || isRecord(avroType) && readString(avroType, "type") === "null";
|
|
165
|
+
const DROPPED = { carried: false };
|
|
166
|
+
const encodeDefault = (avroType, value, context) => {
|
|
167
|
+
const { node, namespace } = dereferenceAvroType(avroType, context);
|
|
168
|
+
const scope = namespace === context.namespace ? context : { ...context, namespace };
|
|
169
|
+
if (Array.isArray(node)) {
|
|
170
|
+
const [first] = node;
|
|
171
|
+
if (first === void 0)
|
|
172
|
+
return DROPPED;
|
|
173
|
+
const inner = encodeDefault(first, value, scope);
|
|
174
|
+
if (!inner.carried)
|
|
175
|
+
return DROPPED;
|
|
176
|
+
if (scope.encoding === "json" || isNullType(first))
|
|
177
|
+
return inner;
|
|
178
|
+
return { carried: true, value: { [avroJsonBranchName(first, scope)]: inner.value } };
|
|
179
|
+
}
|
|
180
|
+
const typeName = typeof node === "string" ? node : isRecord(node) ? readString(node, "type") : void 0;
|
|
181
|
+
if (typeName === "bytes" || typeName === "fixed") {
|
|
182
|
+
if (scope.encoding === "avro-json")
|
|
183
|
+
return { carried: true, value };
|
|
184
|
+
return typeof value === "string" ? DROPPED : { carried: true, value };
|
|
185
|
+
}
|
|
186
|
+
if (typeName === "record" && isRecord(node) && isRecord(value)) {
|
|
187
|
+
const fields = node["fields"];
|
|
188
|
+
if (!Array.isArray(fields))
|
|
189
|
+
return { carried: true, value };
|
|
190
|
+
const translated = /* @__PURE__ */ new Map();
|
|
191
|
+
for (const field of fields) {
|
|
192
|
+
if (!isRecord(field))
|
|
193
|
+
continue;
|
|
194
|
+
const name = readString(field, "name");
|
|
195
|
+
if (name === void 0)
|
|
196
|
+
continue;
|
|
197
|
+
if (!Object.hasOwn(value, name)) {
|
|
198
|
+
if (scope.encoding === "avro-json" || !Object.hasOwn(field, "default"))
|
|
199
|
+
return DROPPED;
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
const inner = encodeDefault(field["type"], value[name], scope);
|
|
203
|
+
if (!inner.carried)
|
|
204
|
+
return DROPPED;
|
|
205
|
+
translated.set(name, inner.value);
|
|
206
|
+
}
|
|
207
|
+
return { carried: true, value: Object.fromEntries(translated) };
|
|
208
|
+
}
|
|
209
|
+
if (typeName === "array" && isRecord(node) && Array.isArray(value)) {
|
|
210
|
+
const items = [];
|
|
211
|
+
for (const item of value) {
|
|
212
|
+
const inner = encodeDefault(node["items"], item, scope);
|
|
213
|
+
if (!inner.carried)
|
|
214
|
+
return DROPPED;
|
|
215
|
+
items.push(inner.value);
|
|
216
|
+
}
|
|
217
|
+
return { carried: true, value: items };
|
|
218
|
+
}
|
|
219
|
+
if (typeName === "map" && isRecord(node) && isRecord(value)) {
|
|
220
|
+
const translated = /* @__PURE__ */ new Map();
|
|
221
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
222
|
+
const inner = encodeDefault(node["values"], entry, scope);
|
|
223
|
+
if (!inner.carried)
|
|
224
|
+
return DROPPED;
|
|
225
|
+
translated.set(key, inner.value);
|
|
226
|
+
}
|
|
227
|
+
return { carried: true, value: Object.fromEntries(translated) };
|
|
228
|
+
}
|
|
229
|
+
return { carried: true, value };
|
|
230
|
+
};
|
|
231
|
+
const convertFields = (fields, context) => {
|
|
232
|
+
const properties = /* @__PURE__ */ new Map();
|
|
233
|
+
const required = [];
|
|
234
|
+
for (const field of fields) {
|
|
235
|
+
if (!isRecord(field)) {
|
|
236
|
+
throw new Error(`Avro adapter: a record field must be an object, but found ${JSON.stringify(field)}.`);
|
|
237
|
+
}
|
|
238
|
+
const name = readString(field, "name");
|
|
239
|
+
if (name === void 0 || name === "") {
|
|
240
|
+
throw new Error('Avro adapter: a record field is missing its required "name".');
|
|
241
|
+
}
|
|
242
|
+
const converted = convertSchema(field["type"], context);
|
|
243
|
+
const doc = readString(field, "doc");
|
|
244
|
+
const hasDefault = Object.hasOwn(field, "default");
|
|
245
|
+
const encoded = hasDefault ? encodeDefault(field["type"], field["default"], context) : { carried: false };
|
|
246
|
+
properties.set(name, {
|
|
247
|
+
...converted,
|
|
248
|
+
...doc === void 0 ? {} : { description: doc },
|
|
249
|
+
...encoded.carried ? { default: encoded.value } : {}
|
|
250
|
+
});
|
|
251
|
+
if (context.encoding === "avro-json" || !hasDefault)
|
|
252
|
+
required.push(name);
|
|
253
|
+
}
|
|
254
|
+
return { properties: Object.fromEntries(properties), required };
|
|
255
|
+
};
|
|
256
|
+
const defineNamedType = (node, type, context) => {
|
|
257
|
+
const fullname = definitionFullname(node, context);
|
|
258
|
+
if (context.defs.has(fullname)) {
|
|
259
|
+
throw new Error(`Avro adapter: the name "${fullname}" is defined more than once.`);
|
|
260
|
+
}
|
|
261
|
+
context.defs.set(fullname, {});
|
|
262
|
+
const inner = { ...context, namespace: namespaceOf(fullname) };
|
|
263
|
+
const doc = readString(node, "doc");
|
|
264
|
+
const annotations = {
|
|
265
|
+
title: fullname.slice(fullname.lastIndexOf(".") + 1),
|
|
266
|
+
...doc === void 0 ? {} : { description: doc }
|
|
267
|
+
};
|
|
268
|
+
context.avroDefs.set(fullname, node);
|
|
269
|
+
const body = convertNamedBody(node, type, inner);
|
|
270
|
+
const logicalType = readString(node, "logicalType");
|
|
271
|
+
const refined = logicalType === void 0 ? body : applyLogicalType(body, logicalType, type, inner);
|
|
272
|
+
context.defs.set(fullname, { ...annotations, ...refined });
|
|
273
|
+
return refTo(fullname);
|
|
274
|
+
};
|
|
275
|
+
const convertNamedBody = (node, type, context) => {
|
|
276
|
+
if (type === "record") {
|
|
277
|
+
const fields = node["fields"];
|
|
278
|
+
if (!Array.isArray(fields)) {
|
|
279
|
+
throw new Error(`Avro adapter: record "${String(node["name"])}" is missing its required "fields" array.`);
|
|
280
|
+
}
|
|
281
|
+
const { properties, required } = convertFields(fields, context);
|
|
282
|
+
return {
|
|
283
|
+
type: "object",
|
|
284
|
+
properties,
|
|
285
|
+
...required.length > 0 ? { required } : {},
|
|
286
|
+
// Avro records are closed: the encoding carries exactly the declared
|
|
287
|
+
// fields, so an extra key is a genuine mismatch rather than a passenger.
|
|
288
|
+
additionalProperties: false
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
if (type === "enum") {
|
|
292
|
+
const symbols = node["symbols"];
|
|
293
|
+
if (!Array.isArray(symbols) || !symbols.every((symbol) => typeof symbol === "string")) {
|
|
294
|
+
throw new Error(`Avro adapter: enum "${String(node["name"])}" needs a "symbols" array of strings.`);
|
|
295
|
+
}
|
|
296
|
+
const fallback = readString(node, "default");
|
|
297
|
+
return {
|
|
298
|
+
type: "string",
|
|
299
|
+
enum: [...symbols],
|
|
300
|
+
...fallback === void 0 ? {} : { default: fallback }
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
const size = node["size"];
|
|
304
|
+
if (typeof size !== "number" || !Number.isInteger(size) || size < 0) {
|
|
305
|
+
throw new Error(`Avro adapter: fixed "${String(node["name"])}" needs a non-negative integer "size".`);
|
|
306
|
+
}
|
|
307
|
+
return context.encoding === "avro-json" ? { type: "string", pattern: BYTE_STRING_PATTERN, minLength: size, maxLength: size } : { type: "string", contentEncoding: "base64" };
|
|
308
|
+
};
|
|
309
|
+
const convertSchema = (node, context) => {
|
|
310
|
+
if (typeof node === "string") {
|
|
311
|
+
if (PRIMITIVES.has(node))
|
|
312
|
+
return convertPrimitive(node, context);
|
|
313
|
+
const fullname = resolveReference(node, context);
|
|
314
|
+
if (!context.defs.has(fullname)) {
|
|
315
|
+
throw new Error(`Avro adapter: "${node}" is neither a primitive type nor a name defined earlier in the schema. Avro requires a named type to be defined before it is referenced.`);
|
|
316
|
+
}
|
|
317
|
+
return refTo(fullname);
|
|
318
|
+
}
|
|
319
|
+
if (Array.isArray(node))
|
|
320
|
+
return convertUnion(node, context);
|
|
321
|
+
if (!isRecord(node)) {
|
|
322
|
+
throw new Error(`Avro adapter: expected a type name, union array, or schema object, but found ${typeof node}.`);
|
|
323
|
+
}
|
|
324
|
+
const type = node["type"];
|
|
325
|
+
if (typeof type !== "string")
|
|
326
|
+
return convertSchema(type, context);
|
|
327
|
+
if (NAMED_TYPES.has(type))
|
|
328
|
+
return defineNamedType(node, type, context);
|
|
329
|
+
if (type === "array") {
|
|
330
|
+
if (!Object.hasOwn(node, "items")) {
|
|
331
|
+
throw new Error('Avro adapter: an array type is missing its required "items".');
|
|
332
|
+
}
|
|
333
|
+
return { type: "array", items: convertSchema(node["items"], context) };
|
|
334
|
+
}
|
|
335
|
+
if (type === "map") {
|
|
336
|
+
if (!Object.hasOwn(node, "values")) {
|
|
337
|
+
throw new Error('Avro adapter: a map type is missing its required "values".');
|
|
338
|
+
}
|
|
339
|
+
return { type: "object", additionalProperties: convertSchema(node["values"], context) };
|
|
340
|
+
}
|
|
341
|
+
if (PRIMITIVES.has(type)) {
|
|
342
|
+
const base = convertPrimitive(type, context);
|
|
343
|
+
const logicalType = readString(node, "logicalType");
|
|
344
|
+
return logicalType === void 0 ? base : applyLogicalType(base, logicalType, type, context);
|
|
345
|
+
}
|
|
346
|
+
return convertSchema(type, context);
|
|
347
|
+
};
|
|
348
|
+
const avroToJsonSchema = (source, options) => {
|
|
349
|
+
if (typeof source === "string" && !PRIMITIVES.has(source)) {
|
|
350
|
+
throw new Error(`Avro adapter: "${source}" is not an Avro primitive type name. Pass the parsed contents of the .avsc file, not the file text itself.`);
|
|
351
|
+
}
|
|
352
|
+
const context = {
|
|
353
|
+
namespace: void 0,
|
|
354
|
+
defs: /* @__PURE__ */ new Map(),
|
|
355
|
+
avroDefs: /* @__PURE__ */ new Map(),
|
|
356
|
+
encoding: options?.encoding ?? "json",
|
|
357
|
+
lossy: /* @__PURE__ */ new Set()
|
|
358
|
+
};
|
|
359
|
+
const root = convertSchema(source, context);
|
|
360
|
+
reportLossyConstructs("Avro", context.lossy, options?.strict);
|
|
361
|
+
if (context.defs.size === 0)
|
|
362
|
+
return root;
|
|
363
|
+
return { ...root, $defs: Object.fromEntries(context.defs) };
|
|
364
|
+
};
|
|
365
|
+
export {
|
|
366
|
+
avroToJsonSchema
|
|
367
|
+
};
|
package/dist/get-adapter.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import { avroToJsonSchema } from "./avro-to-json-schema.js";
|
|
1
2
|
import { effectToJsonSchema } from "./effect-to-json-schema.js";
|
|
2
3
|
import { typeboxToJsonSchema } from "./typebox-to-json-schema.js";
|
|
3
4
|
import { valibotToJsonSchema } from "./valibot-to-json-schema.js";
|
|
4
5
|
import { zodToJsonSchema } from "./zod-to-json-schema.js";
|
|
6
|
+
const avroAdapter = {
|
|
7
|
+
format: "avro",
|
|
8
|
+
toJSONSchema: avroToJsonSchema
|
|
9
|
+
};
|
|
5
10
|
const typeboxAdapter = {
|
|
6
11
|
format: "typebox",
|
|
7
12
|
toJSONSchema: typeboxToJsonSchema
|
|
@@ -28,8 +33,10 @@ const getAdapter = (format) => {
|
|
|
28
33
|
return valibotAdapter;
|
|
29
34
|
case "effect":
|
|
30
35
|
return effectAdapter;
|
|
36
|
+
case "avro":
|
|
37
|
+
return avroAdapter;
|
|
31
38
|
default:
|
|
32
|
-
throw new Error(`No adapter is available for input format '${format}'. Supported: 'typebox', 'zod', 'valibot', 'effect'. Use --input json for plain JSON Schema files.`);
|
|
39
|
+
throw new Error(`No adapter is available for input format '${format}'. Supported: 'typebox', 'zod', 'valibot', 'effect', 'avro'. Use --input json for plain JSON Schema files.`);
|
|
33
40
|
}
|
|
34
41
|
};
|
|
35
42
|
export {
|
|
@@ -18,4 +18,4 @@
|
|
|
18
18
|
* Does nothing when no constructs were widened, so callers can invoke it
|
|
19
19
|
* unconditionally after a conversion.
|
|
20
20
|
*/
|
|
21
|
-
export declare const reportLossyConstructs: (adapter: 'Zod' | 'Valibot', constructs: ReadonlySet<string>, strict: boolean | undefined) => void;
|
|
21
|
+
export declare const reportLossyConstructs: (adapter: 'Zod' | 'Valibot' | 'Avro', constructs: ReadonlySet<string>, strict: boolean | undefined) => void;
|
package/dist/source-format.d.ts
CHANGED
|
@@ -5,7 +5,12 @@
|
|
|
5
5
|
* handed straight to the generators. The others name external libraries whose
|
|
6
6
|
* schemas are first converted to JSON Schema by a matching adapter.
|
|
7
7
|
*
|
|
8
|
+
* `'avro'` is the odd one out in how it is *loaded*, not converted: an Avro
|
|
9
|
+
* schema is a `.avsc` JSON document rather than a module exporting a value, so
|
|
10
|
+
* the CLI reads and parses it like a JSON Schema file and only then hands it to
|
|
11
|
+
* the adapter. Nothing is imported and no export needs naming.
|
|
12
|
+
*
|
|
8
13
|
* A format may appear here before its adapter exists — `getAdapter` is the
|
|
9
14
|
* source of truth for what is actually implemented today.
|
|
10
15
|
*/
|
|
11
|
-
export type SourceFormat = 'json' | 'typebox' | 'zod' | 'valibot' | 'effect';
|
|
16
|
+
export type SourceFormat = 'json' | 'typebox' | 'zod' | 'valibot' | 'effect' | 'avro';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amritk/adapters",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Convert schemas from external libraries (TypeBox, Zod, ...) into JSON Schema for mjst.",
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Convert schemas from external libraries (TypeBox, Zod, Avro, ...) into JSON Schema for mjst.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"engines": {
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"zod",
|
|
17
17
|
"valibot",
|
|
18
18
|
"effect",
|
|
19
|
+
"avro",
|
|
19
20
|
"adapter",
|
|
20
21
|
"mjst"
|
|
21
22
|
],
|
|
@@ -43,7 +44,10 @@
|
|
|
43
44
|
},
|
|
44
45
|
"dependencies": {
|
|
45
46
|
"json-schema-typed": "^8.0.1",
|
|
46
|
-
"@amritk/helpers": "^0.
|
|
47
|
+
"@amritk/helpers": "^0.16.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@amritk/runtime-validators": "^0.12.0"
|
|
47
51
|
},
|
|
48
52
|
"exports": {
|
|
49
53
|
"./package.json": "./package.json",
|
|
@@ -59,6 +63,10 @@
|
|
|
59
63
|
"types": "./dist/get-adapter.d.ts",
|
|
60
64
|
"default": "./dist/get-adapter.js"
|
|
61
65
|
},
|
|
66
|
+
"./avro-to-json-schema": {
|
|
67
|
+
"types": "./dist/avro-to-json-schema.d.ts",
|
|
68
|
+
"default": "./dist/avro-to-json-schema.js"
|
|
69
|
+
},
|
|
62
70
|
"./typebox-to-json-schema": {
|
|
63
71
|
"types": "./dist/typebox-to-json-schema.d.ts",
|
|
64
72
|
"default": "./dist/typebox-to-json-schema.js"
|