extracted spec from an ADR for implementing an atproto client and public lexicon
livtet_lexicon.md
113 lines 3.6 kB view raw view code

ATProto Lexicons#

ATProto lexicons use JSON with NSID identifiers. The lexicon format includes lexicon, id, defs, and record/query/procedure types. Custom lexicons are stored as JSON and embedded via include_str!.

Domain: livtet.app (user owns this domain). Not a full PDS implementation—just a minimal lexicon server.

app.livtet.work - Work record (literary work like "Frankenstein"):

{
  "lexicon": 1,
  "id": "app.livtet.work",
  "defs": {
    "main": {
      "type": "record",
      "description": "A literary work tracked by Livtet.",
      "key": "tid",
      "record": {
        "type": "object",
        "required": ["name", "language", "datePublished"],
        "properties": {
          "name": { "type": "string", "description": "Title of the work" },
          "language": { "type": "string", "description": "ISO 639-1 language code" },
          "datePublished": { "type": "string", "format": "datetime" },
          "description": { "type": "string" },
          "series": { "type": "ref", "ref": "app.livtet.defs#seriesRef" },
          "identifiers": {
            "type": "array",
            "items": { "type": "ref", "ref": "app.livtet.defs#identifier" }
          }
        }
      }
    }
  }
}

app.livtet.edition - Edition record (specific form of a work):

{
  "lexicon": 1,
  "id": "app.livtet.edition",
  "defs": {
    "main": {
      "type": "record",
      "description": "A specific edition of a work.",
      "key": "tid",
      "record": {
        "type": "object",
        "required": ["work", "format"],
        "properties": {
          "work": { "type": "ref", "ref": "com.atproto.repo.strongRef" },
          "format": {
            "type": "union",
            "refs": ["app.livtet.defs#physicalFormat", "app.livtet.defs#virtualFormat", "app.livtet.defs#audiobookFormat"]
          },
          "datePublished": { "type": "string", "format": "datetime" },
          "seriesIndex": { "type": "integer" },
          "url": { "type": "string", "format": "uri" },
          "identifiers": {
            "type": "array",
            "items": { "type": "ref", "ref": "app.livtet.defs#identifier" }
          }
        }
      }
    }
  }
}

app.livtet.readProgress - Reading progress record:

{
  "lexicon": 1,
  "id": "app.livtet.readProgress",
  "defs": {
    "main": {
      "type": "record",
      "description": "Reading progress for a specific edition.",
      "key": "tid",
      "record": {
        "type": "object",
        "required": ["edition", "progress", "updatedAt"],
        "properties": {
          "edition": { "type": "ref", "ref": "com.atproto.repo.strongRef" },
          "progress": { "type": "integer", "minimum": 0, "maximum": 100 },
          "lastPosition": { "type": "string" },
          "updatedAt": { "type": "string", "format": "datetime" },
          "highlights": { "type": "array", "items": { "type": "ref", "ref": "#highlight" } }
        }
      }
    },
    "highlight": {
      "type": "object",
      "properties": {
        "text": { "type": "string" },
        "location": { "type": "string" },
        "note": { "type": "string" },
        "createdAt": { "type": "string", "format": "datetime" }
      }
    }
  }
}

Supporting definitions in app.livtet.defs:

  • seriesRef: { seriesId: string }
  • identifier: { type: string, value: string } (e.g., {"type": "isbn", "value": "978-0-123456-78-9"})
  • physicalFormat: { pages: integer }
  • virtualFormat: { size: integer } (bytes)
  • audiobookFormat: { duration: integer } (seconds)