Skip to content

Commit 7a226d8

Browse files
authored
Merge pull request #165 from hypercerts-org/add-leaflet-lexicons
feat: add pub.leaflet lexicons
2 parents 54dba2f + 238f8a1 commit 7a226d8

28 files changed

Lines changed: 1248 additions & 109 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hypercerts-org/lexicon": minor
3+
---
4+
5+
Vendor pub.leaflet and app.bsky.richtext.facet lexicon JSONs to enable runtime validation of records with description and facet fields. Previously, these external schemas were only shimmed at the TypeScript type level via @atcute packages, causing LexiconDefNotFoundError at runtime when validating records that populated optional description or facet fields. Removes the now-unnecessary create-shims.sh script and @atcute/leaflet + @atcute/bluesky dependencies.

AGENTS.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ npm run gen-api
9797

9898
This runs `lex gen-api` on all lexicon JSON files and:
9999

100-
1. Generates TypeScript types in `generated/`
101-
2. Creates type shims for external lexicons
102-
3. Auto-generates `generated/exports.ts` with clean exports
100+
1. Generates TypeScript types in `generated/` (including vendored
101+
external lexicons from `lexicons/pub/` and `lexicons/app/bsky/`)
102+
2. Auto-generates `generated/exports.ts` with clean exports
103103

104104
Then to build the distributable bundles:
105105

@@ -231,8 +231,7 @@ scripts/ Build and codegen scripts
231231
structure
232232

233233
2. Run `npm run gen-api` to:
234-
- Generate types in `generated/`
235-
- Create type shims for external lexicons
234+
- Generate types in `generated/` (including vendored external lexicons)
236235
- Auto-generate `generated/exports.ts` with all exports
237236

238237
3. Update `ERD.puml` as appropriate:

SCHEMAS.md

Lines changed: 366 additions & 1 deletion
Large diffs are not rendered by default.

docs/AUTO_GENERATION.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ The `generated/exports.ts` file is **automatically generated** from lexicon JSON
88

99
When you run `npm run gen-api`, the build process:
1010

11-
1. Runs `lex gen-api` to generate TypeScript types in `generated/`
12-
2. Runs `scripts/create-shims.sh` to create type shims for external lexicons
13-
3. Runs `scripts/generate-exports.js` to auto-generate `generated/exports.ts`
11+
1. Runs `lex gen-api` to generate TypeScript types in `generated/` (including vendored external lexicons from `lexicons/pub/` and `lexicons/app/bsky/`)
12+
2. Runs `scripts/generate-exports.js` to auto-generate `generated/exports.ts`
1413

1514
## The Generation Script
1615

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"lexicon": 1,
3+
"id": "app.bsky.richtext.facet",
4+
"defs": {
5+
"main": {
6+
"type": "object",
7+
"description": "Annotation of a sub-string within rich text.",
8+
"required": ["index", "features"],
9+
"properties": {
10+
"index": { "type": "ref", "ref": "#byteSlice" },
11+
"features": {
12+
"type": "array",
13+
"items": { "type": "union", "refs": ["#mention", "#link", "#tag"] }
14+
}
15+
}
16+
},
17+
"mention": {
18+
"type": "object",
19+
"description": "Facet feature for mention of another account. The text is usually a handle, including a '@' prefix, but the facet reference is a DID.",
20+
"required": ["did"],
21+
"properties": {
22+
"did": { "type": "string", "format": "did" }
23+
}
24+
},
25+
"link": {
26+
"type": "object",
27+
"description": "Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL.",
28+
"required": ["uri"],
29+
"properties": {
30+
"uri": { "type": "string", "format": "uri" }
31+
}
32+
},
33+
"tag": {
34+
"type": "object",
35+
"description": "Facet feature for a hashtag. The text usually includes a '#' prefix, but the facet reference should not (except in the case of 'double hash tags').",
36+
"required": ["tag"],
37+
"properties": {
38+
"tag": { "type": "string", "maxLength": 640, "maxGraphemes": 64 }
39+
}
40+
},
41+
"byteSlice": {
42+
"type": "object",
43+
"description": "Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets.",
44+
"required": ["byteStart", "byteEnd"],
45+
"properties": {
46+
"byteStart": { "type": "integer", "minimum": 0 },
47+
"byteEnd": { "type": "integer", "minimum": 0 }
48+
}
49+
}
50+
}
51+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"lexicon": 1,
3+
"id": "pub.leaflet.blocks.blockquote",
4+
"defs": {
5+
"main": {
6+
"type": "object",
7+
"required": ["plaintext"],
8+
"properties": {
9+
"plaintext": {
10+
"type": "string"
11+
},
12+
"facets": {
13+
"type": "array",
14+
"items": {
15+
"type": "ref",
16+
"ref": "pub.leaflet.richtext.facet"
17+
}
18+
}
19+
}
20+
}
21+
}
22+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"lexicon": 1,
3+
"id": "pub.leaflet.blocks.bskyPost",
4+
"defs": {
5+
"main": {
6+
"type": "object",
7+
"required": ["postRef"],
8+
"properties": {
9+
"postRef": {
10+
"type": "ref",
11+
"ref": "com.atproto.repo.strongRef"
12+
},
13+
"clientHost": {
14+
"type": "string"
15+
}
16+
}
17+
}
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"lexicon": 1,
3+
"id": "pub.leaflet.blocks.button",
4+
"defs": {
5+
"main": {
6+
"type": "object",
7+
"required": ["text", "url"],
8+
"properties": {
9+
"text": {
10+
"type": "string"
11+
},
12+
"url": {
13+
"type": "string",
14+
"format": "uri"
15+
}
16+
}
17+
}
18+
}
19+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"lexicon": 1,
3+
"id": "pub.leaflet.blocks.code",
4+
"defs": {
5+
"main": {
6+
"type": "object",
7+
"required": ["plaintext"],
8+
"properties": {
9+
"plaintext": {
10+
"type": "string"
11+
},
12+
"language": {
13+
"type": "string"
14+
},
15+
"syntaxHighlightingTheme": {
16+
"type": "string"
17+
}
18+
}
19+
}
20+
}
21+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"lexicon": 1,
3+
"id": "pub.leaflet.blocks.header",
4+
"defs": {
5+
"main": {
6+
"type": "object",
7+
"required": ["plaintext"],
8+
"properties": {
9+
"level": {
10+
"type": "integer",
11+
"minimum": 1,
12+
"maximum": 6
13+
},
14+
"plaintext": {
15+
"type": "string"
16+
},
17+
"facets": {
18+
"type": "array",
19+
"items": {
20+
"type": "ref",
21+
"ref": "pub.leaflet.richtext.facet"
22+
}
23+
}
24+
}
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)