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

Lexicon support #140

Merged
merged 16 commits into from
May 15, 2023
Merged

Lexicon support #140

merged 16 commits into from
May 15, 2023

Conversation

timothee-haudebourg
Copy link
Collaborator

@timothee-haudebourg timothee-haudebourg commented May 4, 2023

This PR adds supports for AT Protocol's Lexicon schema definition format. It focuses on importing Lexicon documents as TreeLDR layouts.

This will be very similar to the JSON Schema implementation (hopefully better than that since I learned a lot since I implemented JSON Schemas).

Implementation plan

  • Create the treeldr-lexicon library
  • Define the core Lexicon data model
  • Lexicon document deserialization
  • Update the load library to recognize lexicon files
    • Refactor the library to avoid conflict with JSON Schema (which appens because it is also a JSON-based format)
    • Refactor treeldr-json-schema to use json-syntax and not serde-json, to be compatible with treeldr-lexicon and have better error handling
  • Non-media type
  • Media types: Image, Video, Audio
  • Tokens support
  • Type constraints (the ones supported by TreeLDR at least)
  • Testing

@timothee-haudebourg timothee-haudebourg self-assigned this May 4, 2023
@timothee-haudebourg
Copy link
Collaborator Author

It turns out the specification on AT Protocol's website is severely outdated. I now use their source code to infer the correct Lexicon interfaces specification, which is more complicated than the one presented on their website.

@timothee-haudebourg timothee-haudebourg linked an issue May 9, 2023 that may be closed by this pull request
@timothee-haudebourg timothee-haudebourg force-pushed the timothee-haudebourg/issue138 branch from 4e2cf43 to 91ae412 Compare May 9, 2023 13:02
Solves a conflict with the other JSON-based format: JSON Schema.
Still a lot of work to do though.
Generate a type for each input and output.
@timothee-haudebourg timothee-haudebourg force-pushed the timothee-haudebourg/issue138 branch from 91ae412 to 385fa44 Compare May 9, 2023 15:06
@timothee-haudebourg
Copy link
Collaborator Author

timothee-haudebourg commented May 11, 2023

I have found a Lexicon schema that does not satisfies the specification given in the source code. According to the spec here the main type must be either record, procedure, query or subscription. In the given schema it is object.

I need to investigate to see if the source code specification is outdated, or if this schema is no longer used.

I think I misunderstood. The main definition is not necessarily a record, procedure, query or subscription, but any such type must be the main definition.

Add `tldr:Bytes` for byte strings.
Add `tldr:CID` for CID links (for now just a `String`).
@timothee-haudebourg
Copy link
Collaborator Author

The Lexicon spec defines media types (Image, Video, Audio), but those types are never allowed in a Lexicon schema. I'm not sure of their purpose yet.

@timothee-haudebourg timothee-haudebourg marked this pull request as ready for review May 11, 2023 16:20
@timothee-haudebourg timothee-haudebourg merged commit 0f6e93a into main May 15, 2023
@timothee-haudebourg timothee-haudebourg deleted the timothee-haudebourg/issue138 branch May 15, 2023 10:09
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.

Lexicon support
1 participant