-
Notifications
You must be signed in to change notification settings - Fork 0
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
Re-implement mapeo-schema with typescript types & a binary storage encoding #20
Comments
So, I've started working on this feature on this branch. I'm using buf to work with .proto files and protobuf-es as a typescript implementation. For now I'm modelling the schema according to this reference and the actual schema on master. protobuf3 doesn't have required fields so every field has an initial default value |
Cool! A few ideas reading through that branch:
|
Thanks for the guidance!
|
Talking with @gmaclennan , there are some fields in the schema that can be derived from stuff like the core key and sequence number or that should be put on the magic bytes.
Comments on fields:
|
A doubt that has come up: const encode = (obj) => { // obj is a js object that matches the protobuf schema
return buf; // buf is the protobuf with prepended magic bytes
}
const decode = (buf) => { // buf is a buffer return by core.get(seq)
return obj // obj is the js object that matches the json client schema
} How am I able to derive the rest of the fields without getting access to the core? |
|
A follow up on the work I've been doing. I'm leaving a list of questions that we can start to address them sometime next week. Mostly to see if what I've been doing makes sense! @gmaclennan @sethvincent
|
I expect we'll need to change the schema a couple times over the coming weeks no matter what, so don't worry about that too much. I think the main thing that needs to be done in this branch is just the system for generating the types and code for encoding/decoding. We can perfect the schema in followup prs.
🤷 maybe we bump that version before doing a new release? Not sure what's best.
Yeah, I think this makes sense. I also tried using typebox and found it really challenging to even make sense of it.
At a glance it seems like this should work. I'll try using the protobufsTypescript branch in mapeo-core-next and let you know how it goes.
My impression was that the bytes that indicate the schema type/version are something we would decide ahead of time and wouldn't need to be randomized at all. But yeah the fixed byte length would need to be enough to support some maximum number of schemas. What that maximum number should be seems somewhat arbitrary. Maybe 100? |
I looked into getting types available in vs code and decided to go ahead and make a pr into the protobufsTypescript branch: https://github.com/digidem/mapeo-schema/pull/21 I also realized that this is a case where it might be helpful to publish to npm via a github action. That way we can do the build step there and publish the results instead of it needing to happen as a prepublish or prepublishOnly script. If we do that we could gitignore the docs/api/ and other generated folders. |
Awesome, thanks for adding typedoc and I agree about github actions. We can generate the types from protobufs and schemas and the documentation directly on ghactions. I'll look up into it, add some tests and then create a PR. |
🎉 This issue has been resolved in version 3.0.0-next.0 🎉 The release is available on: Your optic bot 📦🚀 |
🎉 This issue has been resolved in version 3.0.0-next.1 🎉 The release is available on: Your optic bot 📦🚀 |
🎉 This issue has been resolved in version 3.0.0-next.2 🎉 The release is available on: Your optic bot 📦🚀 |
🎉 This issue has been resolved in version 3.0.0-next.3 🎉 The release is available on: Your optic bot 📦🚀 |
🎉 This issue has been resolved in version 3.0.0-next.4 🎉 The release is available on: Your optic bot 📦🚀 |
🎉 This issue has been resolved in version 3.0.0-next.5 🎉 The release is available on: Your optic bot 📦🚀 |
🎉 This issue has been resolved in version 3.0.0-next.6 🎉 The release is available on: Your optic bot 📦🚀 |
The mapeo-schema package is responsible for defining the schemas of core data types used in mapeo.
To start we'll focus on the observation schema.
Ideally this package:
encode
,decode
, andvalidate
functions for each data schema (thevalidate
function may be less essential than the other two)Implementation options:
This cli tool looks useful for working with protocol buffers: https://github.com/bufbuild/buf
The text was updated successfully, but these errors were encountered: