Scratch space for learning atproto app development

fix the oauth flow by adding the label def and repo strongRef lexicons (#21)

Changed files
+580
lexicons
src
lexicon
types
com
atproto
label
repo
+156
lexicons/defs.json
···
+
{
+
"lexicon": 1,
+
"id": "com.atproto.label.defs",
+
"defs": {
+
"label": {
+
"type": "object",
+
"description": "Metadata tag on an atproto resource (eg, repo or record).",
+
"required": ["src", "uri", "val", "cts"],
+
"properties": {
+
"ver": {
+
"type": "integer",
+
"description": "The AT Protocol version of the label object."
+
},
+
"src": {
+
"type": "string",
+
"format": "did",
+
"description": "DID of the actor who created this label."
+
},
+
"uri": {
+
"type": "string",
+
"format": "uri",
+
"description": "AT URI of the record, repository (account), or other resource that this label applies to."
+
},
+
"cid": {
+
"type": "string",
+
"format": "cid",
+
"description": "Optionally, CID specifying the specific version of 'uri' resource this label applies to."
+
},
+
"val": {
+
"type": "string",
+
"maxLength": 128,
+
"description": "The short string name of the value or type of this label."
+
},
+
"neg": {
+
"type": "boolean",
+
"description": "If true, this is a negation label, overwriting a previous label."
+
},
+
"cts": {
+
"type": "string",
+
"format": "datetime",
+
"description": "Timestamp when this label was created."
+
},
+
"exp": {
+
"type": "string",
+
"format": "datetime",
+
"description": "Timestamp at which this label expires (no longer applies)."
+
},
+
"sig": {
+
"type": "bytes",
+
"description": "Signature of dag-cbor encoded label."
+
}
+
}
+
},
+
"selfLabels": {
+
"type": "object",
+
"description": "Metadata tags on an atproto record, published by the author within the record.",
+
"required": ["values"],
+
"properties": {
+
"values": {
+
"type": "array",
+
"items": { "type": "ref", "ref": "#selfLabel" },
+
"maxLength": 10
+
}
+
}
+
},
+
"selfLabel": {
+
"type": "object",
+
"description": "Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.",
+
"required": ["val"],
+
"properties": {
+
"val": {
+
"type": "string",
+
"maxLength": 128,
+
"description": "The short string name of the value or type of this label."
+
}
+
}
+
},
+
"labelValueDefinition": {
+
"type": "object",
+
"description": "Declares a label value and its expected interpretations and behaviors.",
+
"required": ["identifier", "severity", "blurs", "locales"],
+
"properties": {
+
"identifier": {
+
"type": "string",
+
"description": "The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).",
+
"maxLength": 100,
+
"maxGraphemes": 100
+
},
+
"severity": {
+
"type": "string",
+
"description": "How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.",
+
"knownValues": ["inform", "alert", "none"]
+
},
+
"blurs": {
+
"type": "string",
+
"description": "What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.",
+
"knownValues": ["content", "media", "none"]
+
},
+
"defaultSetting": {
+
"type": "string",
+
"description": "The default setting for this label.",
+
"knownValues": ["ignore", "warn", "hide"],
+
"default": "warn"
+
},
+
"adultOnly": {
+
"type": "boolean",
+
"description": "Does the user need to have adult content enabled in order to configure this label?"
+
},
+
"locales": {
+
"type": "array",
+
"items": { "type": "ref", "ref": "#labelValueDefinitionStrings" }
+
}
+
}
+
},
+
"labelValueDefinitionStrings": {
+
"type": "object",
+
"description": "Strings which describe the label in the UI, localized into a specific language.",
+
"required": ["lang", "name", "description"],
+
"properties": {
+
"lang": {
+
"type": "string",
+
"description": "The code of the language these strings are written in.",
+
"format": "language"
+
},
+
"name": {
+
"type": "string",
+
"description": "A short human-readable name for the label.",
+
"maxGraphemes": 64,
+
"maxLength": 640
+
},
+
"description": {
+
"type": "string",
+
"description": "A longer description of what the label means and why it might be applied.",
+
"maxGraphemes": 10000,
+
"maxLength": 100000
+
}
+
}
+
},
+
"labelValue": {
+
"type": "string",
+
"knownValues": [
+
"!hide",
+
"!no-promote",
+
"!warn",
+
"!no-unauthenticated",
+
"dmca-violation",
+
"doxxing",
+
"porn",
+
"sexual",
+
"nudity",
+
"nsfl",
+
"gore"
+
]
+
}
+
}
+
}
+15
lexicons/strongRef.json
···
+
{
+
"lexicon": 1,
+
"id": "com.atproto.repo.strongRef",
+
"description": "A URI with a content-hash fingerprint.",
+
"defs": {
+
"main": {
+
"type": "object",
+
"required": ["uri", "cid"],
+
"properties": {
+
"uri": { "type": "string", "format": "at-uri" },
+
"cid": { "type": "string", "format": "cid" }
+
}
+
}
+
}
+
}
+30
src/lexicon/index.ts
···
xrpc: XrpcServer
app: AppNS
xyz: XyzNS
+
com: ComNS
constructor(options?: XrpcOptions) {
this.xrpc = createXrpcServer(schemas, options)
this.app = new AppNS(this)
this.xyz = new XyzNS(this)
+
this.com = new ComNS(this)
}
}
···
}
export class XyzStatusphereNS {
+
_server: Server
+
+
constructor(server: Server) {
+
this._server = server
+
}
+
}
+
+
export class ComNS {
+
_server: Server
+
atproto: ComAtprotoNS
+
+
constructor(server: Server) {
+
this._server = server
+
this.atproto = new ComAtprotoNS(server)
+
}
+
}
+
+
export class ComAtprotoNS {
+
_server: Server
+
repo: ComAtprotoRepoNS
+
+
constructor(server: Server) {
+
this._server = server
+
this.repo = new ComAtprotoRepoNS(server)
+
}
+
}
+
+
export class ComAtprotoRepoNS {
_server: Server
constructor(server: Server) {
+202
src/lexicon/lexicons.ts
···
import { LexiconDoc, Lexicons } from '@atproto/lexicon'
export const schemaDict = {
+
ComAtprotoLabelDefs: {
+
lexicon: 1,
+
id: 'com.atproto.label.defs',
+
defs: {
+
label: {
+
type: 'object',
+
description:
+
'Metadata tag on an atproto resource (eg, repo or record).',
+
required: ['src', 'uri', 'val', 'cts'],
+
properties: {
+
ver: {
+
type: 'integer',
+
description: 'The AT Protocol version of the label object.',
+
},
+
src: {
+
type: 'string',
+
format: 'did',
+
description: 'DID of the actor who created this label.',
+
},
+
uri: {
+
type: 'string',
+
format: 'uri',
+
description:
+
'AT URI of the record, repository (account), or other resource that this label applies to.',
+
},
+
cid: {
+
type: 'string',
+
format: 'cid',
+
description:
+
"Optionally, CID specifying the specific version of 'uri' resource this label applies to.",
+
},
+
val: {
+
type: 'string',
+
maxLength: 128,
+
description:
+
'The short string name of the value or type of this label.',
+
},
+
neg: {
+
type: 'boolean',
+
description:
+
'If true, this is a negation label, overwriting a previous label.',
+
},
+
cts: {
+
type: 'string',
+
format: 'datetime',
+
description: 'Timestamp when this label was created.',
+
},
+
exp: {
+
type: 'string',
+
format: 'datetime',
+
description:
+
'Timestamp at which this label expires (no longer applies).',
+
},
+
sig: {
+
type: 'bytes',
+
description: 'Signature of dag-cbor encoded label.',
+
},
+
},
+
},
+
selfLabels: {
+
type: 'object',
+
description:
+
'Metadata tags on an atproto record, published by the author within the record.',
+
required: ['values'],
+
properties: {
+
values: {
+
type: 'array',
+
items: {
+
type: 'ref',
+
ref: 'lex:com.atproto.label.defs#selfLabel',
+
},
+
maxLength: 10,
+
},
+
},
+
},
+
selfLabel: {
+
type: 'object',
+
description:
+
'Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.',
+
required: ['val'],
+
properties: {
+
val: {
+
type: 'string',
+
maxLength: 128,
+
description:
+
'The short string name of the value or type of this label.',
+
},
+
},
+
},
+
labelValueDefinition: {
+
type: 'object',
+
description:
+
'Declares a label value and its expected interpretations and behaviors.',
+
required: ['identifier', 'severity', 'blurs', 'locales'],
+
properties: {
+
identifier: {
+
type: 'string',
+
description:
+
"The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).",
+
maxLength: 100,
+
maxGraphemes: 100,
+
},
+
severity: {
+
type: 'string',
+
description:
+
"How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.",
+
knownValues: ['inform', 'alert', 'none'],
+
},
+
blurs: {
+
type: 'string',
+
description:
+
"What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing.",
+
knownValues: ['content', 'media', 'none'],
+
},
+
defaultSetting: {
+
type: 'string',
+
description: 'The default setting for this label.',
+
knownValues: ['ignore', 'warn', 'hide'],
+
default: 'warn',
+
},
+
adultOnly: {
+
type: 'boolean',
+
description:
+
'Does the user need to have adult content enabled in order to configure this label?',
+
},
+
locales: {
+
type: 'array',
+
items: {
+
type: 'ref',
+
ref: 'lex:com.atproto.label.defs#labelValueDefinitionStrings',
+
},
+
},
+
},
+
},
+
labelValueDefinitionStrings: {
+
type: 'object',
+
description:
+
'Strings which describe the label in the UI, localized into a specific language.',
+
required: ['lang', 'name', 'description'],
+
properties: {
+
lang: {
+
type: 'string',
+
description:
+
'The code of the language these strings are written in.',
+
format: 'language',
+
},
+
name: {
+
type: 'string',
+
description: 'A short human-readable name for the label.',
+
maxGraphemes: 64,
+
maxLength: 640,
+
},
+
description: {
+
type: 'string',
+
description:
+
'A longer description of what the label means and why it might be applied.',
+
maxGraphemes: 10000,
+
maxLength: 100000,
+
},
+
},
+
},
+
labelValue: {
+
type: 'string',
+
knownValues: [
+
'!hide',
+
'!no-promote',
+
'!warn',
+
'!no-unauthenticated',
+
'dmca-violation',
+
'doxxing',
+
'porn',
+
'sexual',
+
'nudity',
+
'nsfl',
+
'gore',
+
],
+
},
+
},
+
},
AppBskyActorProfile: {
lexicon: 1,
id: 'app.bsky.actor.profile',
···
},
},
},
+
ComAtprotoRepoStrongRef: {
+
lexicon: 1,
+
id: 'com.atproto.repo.strongRef',
+
description: 'A URI with a content-hash fingerprint.',
+
defs: {
+
main: {
+
type: 'object',
+
required: ['uri', 'cid'],
+
properties: {
+
uri: {
+
type: 'string',
+
format: 'at-uri',
+
},
+
cid: {
+
type: 'string',
+
format: 'cid',
+
},
+
},
+
},
+
},
+
},
}
export const schemas: LexiconDoc[] = Object.values(schemaDict) as LexiconDoc[]
export const lexicons: Lexicons = new Lexicons(schemas)
export const ids = {
+
ComAtprotoLabelDefs: 'com.atproto.label.defs',
AppBskyActorProfile: 'app.bsky.actor.profile',
XyzStatusphereStatus: 'xyz.statusphere.status',
+
ComAtprotoRepoStrongRef: 'com.atproto.repo.strongRef',
}
+151
src/lexicon/types/com/atproto/label/defs.ts
···
+
/**
+
* GENERATED CODE - DO NOT MODIFY
+
*/
+
import { ValidationResult, BlobRef } from '@atproto/lexicon'
+
import { lexicons } from '../../../../lexicons'
+
import { isObj, hasProp } from '../../../../util'
+
import { CID } from 'multiformats/cid'
+
+
/** Metadata tag on an atproto resource (eg, repo or record). */
+
export interface Label {
+
/** The AT Protocol version of the label object. */
+
ver?: number
+
/** DID of the actor who created this label. */
+
src: string
+
/** AT URI of the record, repository (account), or other resource that this label applies to. */
+
uri: string
+
/** Optionally, CID specifying the specific version of 'uri' resource this label applies to. */
+
cid?: string
+
/** The short string name of the value or type of this label. */
+
val: string
+
/** If true, this is a negation label, overwriting a previous label. */
+
neg?: boolean
+
/** Timestamp when this label was created. */
+
cts: string
+
/** Timestamp at which this label expires (no longer applies). */
+
exp?: string
+
/** Signature of dag-cbor encoded label. */
+
sig?: Uint8Array
+
[k: string]: unknown
+
}
+
+
export function isLabel(v: unknown): v is Label {
+
return (
+
isObj(v) &&
+
hasProp(v, '$type') &&
+
v.$type === 'com.atproto.label.defs#label'
+
)
+
}
+
+
export function validateLabel(v: unknown): ValidationResult {
+
return lexicons.validate('com.atproto.label.defs#label', v)
+
}
+
+
/** Metadata tags on an atproto record, published by the author within the record. */
+
export interface SelfLabels {
+
values: SelfLabel[]
+
[k: string]: unknown
+
}
+
+
export function isSelfLabels(v: unknown): v is SelfLabels {
+
return (
+
isObj(v) &&
+
hasProp(v, '$type') &&
+
v.$type === 'com.atproto.label.defs#selfLabels'
+
)
+
}
+
+
export function validateSelfLabels(v: unknown): ValidationResult {
+
return lexicons.validate('com.atproto.label.defs#selfLabels', v)
+
}
+
+
/** Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel. */
+
export interface SelfLabel {
+
/** The short string name of the value or type of this label. */
+
val: string
+
[k: string]: unknown
+
}
+
+
export function isSelfLabel(v: unknown): v is SelfLabel {
+
return (
+
isObj(v) &&
+
hasProp(v, '$type') &&
+
v.$type === 'com.atproto.label.defs#selfLabel'
+
)
+
}
+
+
export function validateSelfLabel(v: unknown): ValidationResult {
+
return lexicons.validate('com.atproto.label.defs#selfLabel', v)
+
}
+
+
/** Declares a label value and its expected interpretations and behaviors. */
+
export interface LabelValueDefinition {
+
/** The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+). */
+
identifier: string
+
/** How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing. */
+
severity: 'inform' | 'alert' | 'none' | (string & {})
+
/** What should this label hide in the UI, if applied? 'content' hides all of the target; 'media' hides the images/video/audio; 'none' hides nothing. */
+
blurs: 'content' | 'media' | 'none' | (string & {})
+
/** The default setting for this label. */
+
defaultSetting: 'ignore' | 'warn' | 'hide' | (string & {})
+
/** Does the user need to have adult content enabled in order to configure this label? */
+
adultOnly?: boolean
+
locales: LabelValueDefinitionStrings[]
+
[k: string]: unknown
+
}
+
+
export function isLabelValueDefinition(v: unknown): v is LabelValueDefinition {
+
return (
+
isObj(v) &&
+
hasProp(v, '$type') &&
+
v.$type === 'com.atproto.label.defs#labelValueDefinition'
+
)
+
}
+
+
export function validateLabelValueDefinition(v: unknown): ValidationResult {
+
return lexicons.validate('com.atproto.label.defs#labelValueDefinition', v)
+
}
+
+
/** Strings which describe the label in the UI, localized into a specific language. */
+
export interface LabelValueDefinitionStrings {
+
/** The code of the language these strings are written in. */
+
lang: string
+
/** A short human-readable name for the label. */
+
name: string
+
/** A longer description of what the label means and why it might be applied. */
+
description: string
+
[k: string]: unknown
+
}
+
+
export function isLabelValueDefinitionStrings(
+
v: unknown,
+
): v is LabelValueDefinitionStrings {
+
return (
+
isObj(v) &&
+
hasProp(v, '$type') &&
+
v.$type === 'com.atproto.label.defs#labelValueDefinitionStrings'
+
)
+
}
+
+
export function validateLabelValueDefinitionStrings(
+
v: unknown,
+
): ValidationResult {
+
return lexicons.validate(
+
'com.atproto.label.defs#labelValueDefinitionStrings',
+
v,
+
)
+
}
+
+
export type LabelValue =
+
| '!hide'
+
| '!no-promote'
+
| '!warn'
+
| '!no-unauthenticated'
+
| 'dmca-violation'
+
| 'doxxing'
+
| 'porn'
+
| 'sexual'
+
| 'nudity'
+
| 'nsfl'
+
| 'gore'
+
| (string & {})
+26
src/lexicon/types/com/atproto/repo/strongRef.ts
···
+
/**
+
* GENERATED CODE - DO NOT MODIFY
+
*/
+
import { ValidationResult, BlobRef } from '@atproto/lexicon'
+
import { lexicons } from '../../../../lexicons'
+
import { isObj, hasProp } from '../../../../util'
+
import { CID } from 'multiformats/cid'
+
+
export interface Main {
+
uri: string
+
cid: string
+
[k: string]: unknown
+
}
+
+
export function isMain(v: unknown): v is Main {
+
return (
+
isObj(v) &&
+
hasProp(v, '$type') &&
+
(v.$type === 'com.atproto.repo.strongRef#main' ||
+
v.$type === 'com.atproto.repo.strongRef')
+
)
+
}
+
+
export function validateMain(v: unknown): ValidationResult {
+
return lexicons.validate('com.atproto.repo.strongRef#main', v)
+
}