-
Notifications
You must be signed in to change notification settings - Fork 412
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
Lexicon: richtext facets, replacing post entities #674
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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"} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor note: in #587 I think the intention was to use a uri format here, but we decided to just have the at-uri format for now, which wouldn't apply here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually I'd be down to throw in a uri format 🤷♂️ |
||
} | ||
}, | ||
"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} | ||
} | ||
} | ||
} | ||
} |
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 was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.