-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #674 from bluesky-social/lex/richtext
Lexicon: richtext facets, replacing post entities
- Loading branch information
Showing
27 changed files
with
541 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"lexicon": 1, | ||
"id": "app.bsky.richtext.facet", | ||
"defs": { | ||
"main": { | ||
"type": "object", | ||
"required": ["index", "value"], | ||
"properties": { | ||
"index": {"type": "ref", "ref": "#textSlice"}, | ||
"value": {"type": "union", "refs": ["#mention", "#link"]} | ||
} | ||
}, | ||
"mention": { | ||
"type": "object", | ||
"description": "A facet value for actor mentions.", | ||
"required": ["did"], | ||
"properties": { | ||
"did": {"type": "string", "format": "did"} | ||
} | ||
}, | ||
"link": { | ||
"type": "object", | ||
"description": "A facet value for links.", | ||
"required": ["uri"], | ||
"properties": { | ||
"uri": {"type": "string"} | ||
} | ||
}, | ||
"textSlice": { | ||
"type": "object", | ||
"description": "A text segment. Start is inclusive, end is exclusive.", | ||
"required": ["start", "end"], | ||
"properties": { | ||
"start": {"type": "integer", "minimum": 0}, | ||
"end": {"type": "integer", "minimum": 0} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* GENERATED CODE - DO NOT MODIFY | ||
*/ | ||
import { ValidationResult } from '@atproto/lexicon' | ||
import { isObj, hasProp } from '../../../../util' | ||
import { lexicons } from '../../../../lexicons' | ||
|
||
export interface Main { | ||
index: TextSlice | ||
value: Mention | Link | { $type: string; [k: string]: unknown } | ||
[k: string]: unknown | ||
} | ||
|
||
export function isMain(v: unknown): v is Main { | ||
return ( | ||
isObj(v) && | ||
hasProp(v, '$type') && | ||
(v.$type === 'app.bsky.richtext.facet#main' || | ||
v.$type === 'app.bsky.richtext.facet') | ||
) | ||
} | ||
|
||
export function validateMain(v: unknown): ValidationResult { | ||
return lexicons.validate('app.bsky.richtext.facet#main', v) | ||
} | ||
|
||
/** A facet value for actor mentions. */ | ||
export interface Mention { | ||
did: string | ||
[k: string]: unknown | ||
} | ||
|
||
export function isMention(v: unknown): v is Mention { | ||
return ( | ||
isObj(v) && | ||
hasProp(v, '$type') && | ||
v.$type === 'app.bsky.richtext.facet#mention' | ||
) | ||
} | ||
|
||
export function validateMention(v: unknown): ValidationResult { | ||
return lexicons.validate('app.bsky.richtext.facet#mention', v) | ||
} | ||
|
||
/** A facet value for links. */ | ||
export interface Link { | ||
uri: string | ||
[k: string]: unknown | ||
} | ||
|
||
export function isLink(v: unknown): v is Link { | ||
return ( | ||
isObj(v) && | ||
hasProp(v, '$type') && | ||
v.$type === 'app.bsky.richtext.facet#link' | ||
) | ||
} | ||
|
||
export function validateLink(v: unknown): ValidationResult { | ||
return lexicons.validate('app.bsky.richtext.facet#link', v) | ||
} | ||
|
||
/** A text segment. Start is inclusive, end is exclusive. */ | ||
export interface TextSlice { | ||
start: number | ||
end: number | ||
[k: string]: unknown | ||
} | ||
|
||
export function isTextSlice(v: unknown): v is TextSlice { | ||
return ( | ||
isObj(v) && | ||
hasProp(v, '$type') && | ||
v.$type === 'app.bsky.richtext.facet#textSlice' | ||
) | ||
} | ||
|
||
export function validateTextSlice(v: unknown): ValidationResult { | ||
return lexicons.validate('app.bsky.richtext.facet#textSlice', v) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.