Skip to content

Commit 07aecc4

Browse files
committed
refactor: move avsc into its own package
1 parent 46e0d9b commit 07aecc4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+4718
-16401
lines changed

.envrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#1/usr/bin/false
2+
# shellcheck shell=bash
3+
4+
eval "$(mise hook-env --shell bash)"

.github/workflows/ci.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
jobs:
7+
test:
8+
name: Test
9+
uses: mtth/sdk.ts/.github/workflows/test.yaml

.github/workflows/ci.yml

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/pr.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: PR
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
paths-ignore:
7+
- '**.md'
8+
jobs:
9+
test:
10+
name: Test
11+
uses: mtth/sdk.ts/.github/workflows/test.yaml

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

.mise/config.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[tools]
2+
pre-commit = "latest"
3+
node = "22"
4+
pnpm = "10"

.pre-commit-config.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: prettier
5+
name: Prettify TypeScript
6+
language: system
7+
entry: node_modules/.bin/prettier
8+
types: [file, ts]
9+
pass_filenames: true
10+
- id: eslint
11+
name: Lint TypeScript
12+
language: system
13+
entry: node_modules/.bin/eslint
14+
types: [file, ts]
15+
pass_filenames: true

README.md

Lines changed: 10 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -3,94 +3,13 @@
33
Pure JavaScript implementation of the [Avro
44
specification](https://avro.apache.org/docs/current/spec.html).
55

6-
7-
## Features
8-
9-
+ Blazingly [fast and compact][benchmarks] serialization! Typically faster than
10-
JSON with much smaller encodings.
11-
+ All the Avro goodness and more: [type inference][type-inference], [schema
12-
evolution][schema-evolution]...
13-
+ Support for [serializing arbitrary JavaScript objects][logical-types].
14-
+ Unopinionated [64-bit integer compatibility][custom-long].
15-
16-
17-
## Installation
18-
19-
```sh
20-
$ npm install avsc
21-
```
22-
23-
24-
## Documentation
25-
26-
+ [Home][home]
27-
+ [API](https://github.com/mtth/avsc/wiki/API)
28-
+ [Quickstart](https://github.com/mtth/avsc/wiki/Quickstart)
29-
+ [Advanced usage](https://github.com/mtth/avsc/wiki/Advanced-usage)
30-
+ [Benchmarks][benchmarks]
31-
32-
33-
## Examples
34-
35-
```javascript
36-
const avro = require('avsc');
37-
```
38-
39-
+ Encode and decode values from a known schema:
40-
41-
```javascript
42-
const type = avro.Type.forSchema({
43-
type: 'record',
44-
name: 'Pet',
45-
fields: [
46-
{
47-
name: 'kind',
48-
type: {type: 'enum', name: 'PetKind', symbols: ['CAT', 'DOG']}
49-
},
50-
{name: 'name', type: 'string'}
51-
]
52-
});
53-
54-
const buf = type.toBuffer({kind: 'CAT', name: 'Albert'}); // Encoded buffer.
55-
const val = type.fromBuffer(buf); // = {kind: 'CAT', name: 'Albert'}
56-
```
57-
58-
+ Infer a value's schema and encode similar values:
59-
60-
```javascript
61-
const type = avro.Type.forValue({
62-
city: 'Cambridge',
63-
zipCodes: ['02138', '02139'],
64-
visits: 2
65-
});
66-
67-
// We can use `type` to encode any values with the same structure:
68-
const bufs = [
69-
type.toBuffer({city: 'Seattle', zipCodes: ['98101'], visits: 3}),
70-
type.toBuffer({city: 'NYC', zipCodes: [], visits: 0})
71-
];
72-
```
73-
74-
+ Get a [readable stream][readable-stream] of decoded values from an Avro
75-
container file (see the [`BlockDecoder` API][decoder-api] for an example
76-
compressed using [Snappy][snappy]):
77-
78-
```javascript
79-
avro.createFileDecoder('./values.avro')
80-
.on('metadata', function (type) { /* `type` is the writer's type. */ })
81-
.on('data', function (val) { /* Do something with the decoded value. */ });
82-
```
83-
84-
85-
[benchmarks]: https://github.com/mtth/avsc/wiki/Benchmarks
86-
[browser-support]: https://github.com/mtth/avsc/wiki#browser-support
87-
[custom-long]: https://github.com/mtth/avsc/wiki/Advanced-usage#custom-long-types
88-
[decoder-api]: https://github.com/mtth/avsc/wiki/API#class-blockdecoderopts
89-
[home]: https://github.com/mtth/avsc/wiki
90-
[idl]: https://avro.apache.org/docs/current/idl.html
91-
[logical-types]: https://github.com/mtth/avsc/wiki/Advanced-usage#logical-types
92-
[node.js]: https://nodejs.org/en/
93-
[readable-stream]: https://nodejs.org/api/stream.html#stream_class_stream_readable
94-
[schema-evolution]: https://github.com/mtth/avsc/wiki/Advanced-usage#schema-evolution
95-
[snappy]: https://avro.apache.org/docs/current/spec.html#snappy
96-
[type-inference]: https://github.com/mtth/avsc/wiki/Advanced-usage#type-inference
6+
## Migration checklist
7+
8+
* [x] Switch to pnpm
9+
* [ ] Port `@avro/types`
10+
* [ ] Port `@avro/streams`
11+
* [ ] Port `@avro/idl`
12+
* [ ] Add `avsc` shim
13+
* [ ] Add benchmark
14+
* [ ] Update README
15+
* [ ] Add migration guide

doc

Lines changed: 0 additions & 1 deletion
This file was deleted.

etc/schemas/ArrayInt.avsc

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)