CondeNast/atjson

Define Schema interface

Closed this issue · 1 comments

As a kickoff of #183, let's have a discussion of how schemas should be structured.

In the branch that I created, the schema interface looks like:

interface SchemaDefinition {
  type: string;
  version: string;
  annotations: {
    [key: string]: typeof Annotation;
  }
}

The other option here is the most minimal approach, which is an annotation lookup table:

interface SchemaDefinition {
  [key: string]: typeof Annotation;
}

Before we start writing this, we want to solicit some feedback and ensure that we understand requirements that we may want on this.

Some general questions:

  • We've made a "content negotiation framework" to support dynamic markdown fetching so we don't need to optimistically write migrations. Do we want to add some friendly hooks here to handle this more easily?
  • We've had some discussions around versioning, and was wondering if it made sense for the version of the schema to be computed by the hash of the annotations included in the document.
  • How do we handle code that currently does lookups via strings? Should we require type to retain this behaviour, or should we sunset that pattern?

@bachbui, @colinarobinson, @blaine have all contributed to this discussion prior to this issue being opened
❤️ Thank you ❤️

We are going forward with:

interface SchemaDefinition {
  annotations: {
    [key: string]: typeof Annotation;
  }
}