Fix app.bsky.post entity def to be more intuitive ()

This commit is contained in:
devin ivy 2022-11-02 11:19:07 -04:00 committed by GitHub
parent aa604b0a98
commit 55a07dd4d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 84 additions and 92 deletions
lexicons/bsky.app
packages
api/src/client
schemas.ts
types/app/bsky
pds/src/lexicon
schemas.ts
types/app/bsky

@ -8,7 +8,10 @@
"required": ["text", "createdAt"],
"properties": {
"text": {"type": "string", "maxLength": 256},
"entities": {"$ref": "#/defs/entity"},
"entities": {
"type": "array",
"items": {"$ref": "#/defs/entity"}
},
"reply": {
"type": "object",
"required": ["root", "parent"],
@ -30,18 +33,15 @@
}
},
"entity": {
"type": "array",
"items": {
"type": "object",
"required": ["index", "type", "value"],
"properties": {
"index": {"$ref": "#/defs/textSlice"},
"type": {
"type": "string",
"$comment": "Expected values are 'mention', 'hashtag', and 'link'."
},
"value": {"type": "string"}
}
"type": "object",
"required": ["index", "type", "value"],
"properties": {
"index": {"$ref": "#/defs/textSlice"},
"type": {
"type": "string",
"$comment": "Expected values are 'mention', 'hashtag', and 'link'."
},
"value": {"type": "string"}
}
},
"textSlice": {
@ -51,4 +51,4 @@
"maxItems": 2
}
}
}
}

@ -3124,7 +3124,10 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
maxLength: 256,
},
entities: {
$ref: '#/$defs/entity',
type: 'array',
items: {
$ref: '#/$defs/entity',
},
},
reply: {
type: 'object',
@ -3145,22 +3148,18 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
$defs: {
entity: {
type: 'array',
items: {
type: 'object',
required: ['index', 'type', 'value'],
properties: {
index: {
$ref: '#/$defs/textSlice',
},
type: {
type: 'string',
$comment:
"Expected values are 'mention', 'hashtag', and 'link'.",
},
value: {
type: 'string',
},
type: 'object',
required: ['index', 'type', 'value'],
properties: {
index: {
$ref: '#/$defs/textSlice',
},
type: {
type: 'string',
$comment: "Expected values are 'mention', 'hashtag', and 'link'.",
},
value: {
type: 'string',
},
},
},
@ -3205,21 +3204,18 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
entity: {
type: 'array',
items: {
type: 'object',
required: ['index', 'type', 'value'],
properties: {
index: {
$ref: '#/$defs/textSlice',
},
type: {
type: 'string',
$comment: "Expected values are 'mention', 'hashtag', and 'link'.",
},
value: {
type: 'string',
},
type: 'object',
required: ['index', 'type', 'value'],
properties: {
index: {
$ref: '#/$defs/textSlice',
},
type: {
type: 'string',
$comment: "Expected values are 'mention', 'hashtag', and 'link'.",
},
value: {
type: 'string',
},
},
},

@ -6,16 +6,10 @@
* @maxItems 2
*/
export type TextSlice = [number, number]
export type Entity = {
index: TextSlice,
type: string,
value: string,
[k: string]: unknown,
}[]
export interface Record {
text: string;
entities?: Entity;
entities?: Entity[];
reply?: {
root: PostRef,
parent: PostRef,
@ -24,6 +18,12 @@ export interface Record {
createdAt: string;
[k: string]: unknown;
}
export interface Entity {
index: TextSlice;
type: string;
value: string;
[k: string]: unknown;
}
export interface PostRef {
uri: string;
cid: string;

@ -3124,7 +3124,10 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
maxLength: 256,
},
entities: {
$ref: '#/$defs/entity',
type: 'array',
items: {
$ref: '#/$defs/entity',
},
},
reply: {
type: 'object',
@ -3145,22 +3148,18 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
$defs: {
entity: {
type: 'array',
items: {
type: 'object',
required: ['index', 'type', 'value'],
properties: {
index: {
$ref: '#/$defs/textSlice',
},
type: {
type: 'string',
$comment:
"Expected values are 'mention', 'hashtag', and 'link'.",
},
value: {
type: 'string',
},
type: 'object',
required: ['index', 'type', 'value'],
properties: {
index: {
$ref: '#/$defs/textSlice',
},
type: {
type: 'string',
$comment: "Expected values are 'mention', 'hashtag', and 'link'.",
},
value: {
type: 'string',
},
},
},
@ -3205,21 +3204,18 @@ export const recordSchemaDict: Record<string, RecordSchema> = {
},
},
entity: {
type: 'array',
items: {
type: 'object',
required: ['index', 'type', 'value'],
properties: {
index: {
$ref: '#/$defs/textSlice',
},
type: {
type: 'string',
$comment: "Expected values are 'mention', 'hashtag', and 'link'.",
},
value: {
type: 'string',
},
type: 'object',
required: ['index', 'type', 'value'],
properties: {
index: {
$ref: '#/$defs/textSlice',
},
type: {
type: 'string',
$comment: "Expected values are 'mention', 'hashtag', and 'link'.",
},
value: {
type: 'string',
},
},
},

@ -6,16 +6,10 @@
* @maxItems 2
*/
export type TextSlice = [number, number]
export type Entity = {
index: TextSlice,
type: string,
value: string,
[k: string]: unknown,
}[]
export interface Record {
text: string;
entities?: Entity;
entities?: Entity[];
reply?: {
root: PostRef,
parent: PostRef,
@ -24,6 +18,12 @@ export interface Record {
createdAt: string;
[k: string]: unknown;
}
export interface Entity {
index: TextSlice;
type: string;
value: string;
[k: string]: unknown;
}
export interface PostRef {
uri: string;
cid: string;