Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: protocol buffers, json schema, & types for each #22

Merged
merged 82 commits into from
Feb 14, 2023

Conversation

tomasciccola
Copy link
Contributor

This PR implements a migration to using protocol buffers as encoding scheme for records in mapeo.
Typescript types are generated from a .proto file for each possible record type (this PR only implements Observation).

Additionally, it exposes an encode and decode functions that validate the records against a json schema.

Tomás Ciccola and others added 30 commits November 1, 2022 17:53
Since we're transitioning to using protobufs I've started  removed code
that's not needed anymore
`protobuf-es` generated a class where each field that is not optional has
a default value (i.e. string -> '') which can't be changes. This doesn't
seem like a useful way of preventing errors since an empty object is a
valid initializer.
`ts-proto`  generates typescript types and actually enforce type checking
and its easy to integrate with `buf`
Additionaly ts-proto provides decode and encode functions so maybe
wrapping in a class is not necessary anymore?
Also, some formatting from eslint and standard
* Added jsdoc params and return type
* Added Observation schema validation generated using typebox
Additionally change buf.slice with buf.subarray since the former is
deprecated
I've added json-schema-to-typescript to turn all the schemas to .d.ts
files. This replaces typebox use since it seemed easier.
Additionally this meant setting the ts-proto opt to turn snake_case
fields of protobuf schema to camelCase to false since fields in json
schema are snake_case.
Jsonschema treats dates as strings with a special format, so every proto
field that was a Timestamp now is just a string (for now)
the type of the message

i.e. in observation proto we declare inside Observation
```
message Metadata {
}
```
to use that field we need to additionaly add that message as a field
```
optional Metadata metadata = 11;
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Re-implement mapeo-schema with typescript types & a binary storage encoding
3 participants