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(schema): expose useful functions for building schemas #569

Merged
merged 1 commit into from
Aug 5, 2024

Conversation

hannahhoward
Copy link
Collaborator

Goals

fix #568

Implementation

add more minimal form of schema compilation and useful functions for merging one type system into another. this would enable the various types of schema type system building I discussed in #568.

Note that most of these functions have been written without access to private data members, in part cause until this is merged I'm just going to build on top. The absolute minimal version of this PR would simply make spawnType at https://github.com/ipld/go-ipld-prime/blob/master/schema/dmt/compile.go#L135 a public function SpawnType (just to avoid a large copy paste). Pretty much everything else could be built outside the library if you want to target the minimal form.

However, one can see that some of the functions would probably be better with private members. Clone for example is not a full depth clone and only works on types that are in a typesystem, cause many of the public functions of various kinds of types return not the type names but actual types looked up from the TypeSystem.

Anyway, FYC, happy to modify to super minimal (i.e. just spawnType -> SpawnType to make it exported) to building a full incremental builder for type systems. Up to reviewer!

add more minimal form of schema compilation and useful functions for merging one type system into
another.

fix #568
@hannahhoward hannahhoward requested a review from rvagg August 2, 2024 06:02
Comment on lines +191 to +193
kindedType.ValueIsNullable())
case *TypeList:
return SpawnList(kindedType.Name(), kindedType.ValueType().Name(), kindedType.ValueIsNullable())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hah, we don't store representation strategy for these even though we have space for it in the dmt, TODO at some point I guess

@hannahhoward hannahhoward merged commit 36adac0 into master Aug 5, 2024
13 checks passed
@hannahhoward hannahhoward deleted the feat/ts-builder branch August 5, 2024 20:59
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.

Incremental schema type building
2 participants