Skip to content
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

add tags to posts #1637

Merged
merged 20 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lexicons/app/bsky/feed/post.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
"type": "union",
"refs": ["com.atproto.label.defs#selfLabels"]
},
"tags": {
estrattonbailey marked this conversation as resolved.
Show resolved Hide resolved
"type": "array",
estrattonbailey marked this conversation as resolved.
Show resolved Hide resolved
"maxLength": 8,
"items": { "type": "string", "maxLength": 640, "maxGraphemes": 64 },
estrattonbailey marked this conversation as resolved.
Show resolved Hide resolved
"description": "Additional non-inline tags describing this post."
},
"createdAt": { "type": "string", "format": "datetime" }
}
}
Expand Down
10 changes: 9 additions & 1 deletion lexicons/app/bsky/richtext/facet.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"index": { "type": "ref", "ref": "#byteSlice" },
"features": {
"type": "array",
"items": { "type": "union", "refs": ["#mention", "#link"] }
"items": { "type": "union", "refs": ["#mention", "#link", "#tag"] }
}
}
},
Expand All @@ -29,6 +29,14 @@
"uri": { "type": "string", "format": "uri" }
}
},
"tag": {
"type": "object",
"description": "A hashtag.",
"required": ["tag"],
"properties": {
"tag": { "type": "string", "maxLength": 640, "maxGraphemes": 64 }
}
},
"byteSlice": {
"type": "object",
"description": "A text segment. Start is inclusive, end is exclusive. Indices are for utf8-encoded strings.",
Expand Down
23 changes: 23 additions & 0 deletions packages/api/src/client/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5573,6 +5573,16 @@ export const schemaDict = {
type: 'union',
refs: ['lex:com.atproto.label.defs#selfLabels'],
},
tags: {
type: 'array',
maxLength: 8,
items: {
type: 'string',
maxLength: 640,
maxGraphemes: 64,
},
description: 'Additional non-inline tags describing this post.',
},
createdAt: {
type: 'string',
format: 'datetime',
Expand Down Expand Up @@ -6712,6 +6722,7 @@ export const schemaDict = {
refs: [
'lex:app.bsky.richtext.facet#mention',
'lex:app.bsky.richtext.facet#link',
'lex:app.bsky.richtext.facet#tag',
],
},
},
Expand Down Expand Up @@ -6739,6 +6750,18 @@ export const schemaDict = {
},
},
},
tag: {
type: 'object',
description: 'A hashtag.',
required: ['tag'],
properties: {
tag: {
type: 'string',
maxLength: 640,
maxGraphemes: 64,
},
},
},
byteSlice: {
type: 'object',
description:
Expand Down
2 changes: 2 additions & 0 deletions packages/api/src/client/types/app/bsky/feed/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export interface Record {
labels?:
| ComAtprotoLabelDefs.SelfLabels
| { $type: string; [k: string]: unknown }
/** Additional non-inline tags describing this post. */
tags?: string[]
createdAt: string
[k: string]: unknown
}
Expand Down
18 changes: 17 additions & 1 deletion packages/api/src/client/types/app/bsky/richtext/facet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CID } from 'multiformats/cid'

export interface Main {
index: ByteSlice
features: (Mention | Link | { $type: string; [k: string]: unknown })[]
features: (Mention | Link | Tag | { $type: string; [k: string]: unknown })[]
[k: string]: unknown
}

Expand Down Expand Up @@ -61,6 +61,22 @@ export function validateLink(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.richtext.facet#link', v)
}

/** A hashtag. */
export interface Tag {
tag: string
[k: string]: unknown
}

export function isTag(v: unknown): v is Tag {
return (
isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.richtext.facet#tag'
)
}

export function validateTag(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.richtext.facet#tag', v)
}

/** A text segment. Start is inclusive, end is exclusive. Indices are for utf8-encoded strings. */
export interface ByteSlice {
byteStart: number
Expand Down
23 changes: 23 additions & 0 deletions packages/bsky/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5573,6 +5573,16 @@ export const schemaDict = {
type: 'union',
refs: ['lex:com.atproto.label.defs#selfLabels'],
},
tags: {
type: 'array',
maxLength: 8,
items: {
type: 'string',
maxLength: 640,
maxGraphemes: 64,
},
description: 'Additional non-inline tags describing this post.',
},
createdAt: {
type: 'string',
format: 'datetime',
Expand Down Expand Up @@ -6712,6 +6722,7 @@ export const schemaDict = {
refs: [
'lex:app.bsky.richtext.facet#mention',
'lex:app.bsky.richtext.facet#link',
'lex:app.bsky.richtext.facet#tag',
],
},
},
Expand Down Expand Up @@ -6739,6 +6750,18 @@ export const schemaDict = {
},
},
},
tag: {
type: 'object',
description: 'A hashtag.',
required: ['tag'],
properties: {
tag: {
type: 'string',
maxLength: 640,
maxGraphemes: 64,
},
},
},
byteSlice: {
type: 'object',
description:
Expand Down
2 changes: 2 additions & 0 deletions packages/bsky/src/lexicon/types/app/bsky/feed/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export interface Record {
labels?:
| ComAtprotoLabelDefs.SelfLabels
| { $type: string; [k: string]: unknown }
/** Additional non-inline tags describing this post. */
tags?: string[]
createdAt: string
[k: string]: unknown
}
Expand Down
18 changes: 17 additions & 1 deletion packages/bsky/src/lexicon/types/app/bsky/richtext/facet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CID } from 'multiformats/cid'

export interface Main {
index: ByteSlice
features: (Mention | Link | { $type: string; [k: string]: unknown })[]
features: (Mention | Link | Tag | { $type: string; [k: string]: unknown })[]
[k: string]: unknown
}

Expand Down Expand Up @@ -61,6 +61,22 @@ export function validateLink(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.richtext.facet#link', v)
}

/** A hashtag. */
export interface Tag {
tag: string
[k: string]: unknown
}

export function isTag(v: unknown): v is Tag {
return (
isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.richtext.facet#tag'
)
}

export function validateTag(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.richtext.facet#tag', v)
}

/** A text segment. Start is inclusive, end is exclusive. Indices are for utf8-encoded strings. */
export interface ByteSlice {
byteStart: number
Expand Down
23 changes: 23 additions & 0 deletions packages/pds/src/lexicon/lexicons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5573,6 +5573,16 @@ export const schemaDict = {
type: 'union',
refs: ['lex:com.atproto.label.defs#selfLabels'],
},
tags: {
type: 'array',
maxLength: 8,
items: {
type: 'string',
maxLength: 640,
maxGraphemes: 64,
},
description: 'Additional non-inline tags describing this post.',
},
createdAt: {
type: 'string',
format: 'datetime',
Expand Down Expand Up @@ -6712,6 +6722,7 @@ export const schemaDict = {
refs: [
'lex:app.bsky.richtext.facet#mention',
'lex:app.bsky.richtext.facet#link',
'lex:app.bsky.richtext.facet#tag',
],
},
},
Expand Down Expand Up @@ -6739,6 +6750,18 @@ export const schemaDict = {
},
},
},
tag: {
type: 'object',
description: 'A hashtag.',
required: ['tag'],
properties: {
tag: {
type: 'string',
maxLength: 640,
maxGraphemes: 64,
},
},
},
byteSlice: {
type: 'object',
description:
Expand Down
2 changes: 2 additions & 0 deletions packages/pds/src/lexicon/types/app/bsky/feed/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export interface Record {
labels?:
| ComAtprotoLabelDefs.SelfLabels
| { $type: string; [k: string]: unknown }
/** Additional non-inline tags describing this post. */
tags?: string[]
createdAt: string
[k: string]: unknown
}
Expand Down
18 changes: 17 additions & 1 deletion packages/pds/src/lexicon/types/app/bsky/richtext/facet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CID } from 'multiformats/cid'

export interface Main {
index: ByteSlice
features: (Mention | Link | { $type: string; [k: string]: unknown })[]
features: (Mention | Link | Tag | { $type: string; [k: string]: unknown })[]
[k: string]: unknown
}

Expand Down Expand Up @@ -61,6 +61,22 @@ export function validateLink(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.richtext.facet#link', v)
}

/** A hashtag. */
export interface Tag {
tag: string
[k: string]: unknown
}

export function isTag(v: unknown): v is Tag {
return (
isObj(v) && hasProp(v, '$type') && v.$type === 'app.bsky.richtext.facet#tag'
)
}

export function validateTag(v: unknown): ValidationResult {
return lexicons.validate('app.bsky.richtext.facet#tag', v)
}

/** A text segment. Start is inclusive, end is exclusive. Indices are for utf8-encoded strings. */
export interface ByteSlice {
byteStart: number
Expand Down