the statusphere demo reworked into a vite/react app in a monorepo

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

authored by

Afterlifepro and committed by
GitHub
d6e29d5a bcb0d344

+580
+156
lexicons/defs.json
···
··· 1 + { 2 + "lexicon": 1, 3 + "id": "com.atproto.label.defs", 4 + "defs": { 5 + "label": { 6 + "type": "object", 7 + "description": "Metadata tag on an atproto resource (eg, repo or record).", 8 + "required": ["src", "uri", "val", "cts"], 9 + "properties": { 10 + "ver": { 11 + "type": "integer", 12 + "description": "The AT Protocol version of the label object." 13 + }, 14 + "src": { 15 + "type": "string", 16 + "format": "did", 17 + "description": "DID of the actor who created this label." 18 + }, 19 + "uri": { 20 + "type": "string", 21 + "format": "uri", 22 + "description": "AT URI of the record, repository (account), or other resource that this label applies to." 23 + }, 24 + "cid": { 25 + "type": "string", 26 + "format": "cid", 27 + "description": "Optionally, CID specifying the specific version of 'uri' resource this label applies to." 28 + }, 29 + "val": { 30 + "type": "string", 31 + "maxLength": 128, 32 + "description": "The short string name of the value or type of this label." 33 + }, 34 + "neg": { 35 + "type": "boolean", 36 + "description": "If true, this is a negation label, overwriting a previous label." 37 + }, 38 + "cts": { 39 + "type": "string", 40 + "format": "datetime", 41 + "description": "Timestamp when this label was created." 42 + }, 43 + "exp": { 44 + "type": "string", 45 + "format": "datetime", 46 + "description": "Timestamp at which this label expires (no longer applies)." 47 + }, 48 + "sig": { 49 + "type": "bytes", 50 + "description": "Signature of dag-cbor encoded label." 51 + } 52 + } 53 + }, 54 + "selfLabels": { 55 + "type": "object", 56 + "description": "Metadata tags on an atproto record, published by the author within the record.", 57 + "required": ["values"], 58 + "properties": { 59 + "values": { 60 + "type": "array", 61 + "items": { "type": "ref", "ref": "#selfLabel" }, 62 + "maxLength": 10 63 + } 64 + } 65 + }, 66 + "selfLabel": { 67 + "type": "object", 68 + "description": "Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.", 69 + "required": ["val"], 70 + "properties": { 71 + "val": { 72 + "type": "string", 73 + "maxLength": 128, 74 + "description": "The short string name of the value or type of this label." 75 + } 76 + } 77 + }, 78 + "labelValueDefinition": { 79 + "type": "object", 80 + "description": "Declares a label value and its expected interpretations and behaviors.", 81 + "required": ["identifier", "severity", "blurs", "locales"], 82 + "properties": { 83 + "identifier": { 84 + "type": "string", 85 + "description": "The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).", 86 + "maxLength": 100, 87 + "maxGraphemes": 100 88 + }, 89 + "severity": { 90 + "type": "string", 91 + "description": "How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.", 92 + "knownValues": ["inform", "alert", "none"] 93 + }, 94 + "blurs": { 95 + "type": "string", 96 + "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.", 97 + "knownValues": ["content", "media", "none"] 98 + }, 99 + "defaultSetting": { 100 + "type": "string", 101 + "description": "The default setting for this label.", 102 + "knownValues": ["ignore", "warn", "hide"], 103 + "default": "warn" 104 + }, 105 + "adultOnly": { 106 + "type": "boolean", 107 + "description": "Does the user need to have adult content enabled in order to configure this label?" 108 + }, 109 + "locales": { 110 + "type": "array", 111 + "items": { "type": "ref", "ref": "#labelValueDefinitionStrings" } 112 + } 113 + } 114 + }, 115 + "labelValueDefinitionStrings": { 116 + "type": "object", 117 + "description": "Strings which describe the label in the UI, localized into a specific language.", 118 + "required": ["lang", "name", "description"], 119 + "properties": { 120 + "lang": { 121 + "type": "string", 122 + "description": "The code of the language these strings are written in.", 123 + "format": "language" 124 + }, 125 + "name": { 126 + "type": "string", 127 + "description": "A short human-readable name for the label.", 128 + "maxGraphemes": 64, 129 + "maxLength": 640 130 + }, 131 + "description": { 132 + "type": "string", 133 + "description": "A longer description of what the label means and why it might be applied.", 134 + "maxGraphemes": 10000, 135 + "maxLength": 100000 136 + } 137 + } 138 + }, 139 + "labelValue": { 140 + "type": "string", 141 + "knownValues": [ 142 + "!hide", 143 + "!no-promote", 144 + "!warn", 145 + "!no-unauthenticated", 146 + "dmca-violation", 147 + "doxxing", 148 + "porn", 149 + "sexual", 150 + "nudity", 151 + "nsfl", 152 + "gore" 153 + ] 154 + } 155 + } 156 + }
+15
lexicons/strongRef.json
···
··· 1 + { 2 + "lexicon": 1, 3 + "id": "com.atproto.repo.strongRef", 4 + "description": "A URI with a content-hash fingerprint.", 5 + "defs": { 6 + "main": { 7 + "type": "object", 8 + "required": ["uri", "cid"], 9 + "properties": { 10 + "uri": { "type": "string", "format": "at-uri" }, 11 + "cid": { "type": "string", "format": "cid" } 12 + } 13 + } 14 + } 15 + }
+30
src/lexicon/index.ts
··· 18 xrpc: XrpcServer 19 app: AppNS 20 xyz: XyzNS 21 22 constructor(options?: XrpcOptions) { 23 this.xrpc = createXrpcServer(schemas, options) 24 this.app = new AppNS(this) 25 this.xyz = new XyzNS(this) 26 } 27 } 28 ··· 65 } 66 67 export class XyzStatusphereNS { 68 _server: Server 69 70 constructor(server: Server) {
··· 18 xrpc: XrpcServer 19 app: AppNS 20 xyz: XyzNS 21 + com: ComNS 22 23 constructor(options?: XrpcOptions) { 24 this.xrpc = createXrpcServer(schemas, options) 25 this.app = new AppNS(this) 26 this.xyz = new XyzNS(this) 27 + this.com = new ComNS(this) 28 } 29 } 30 ··· 67 } 68 69 export class XyzStatusphereNS { 70 + _server: Server 71 + 72 + constructor(server: Server) { 73 + this._server = server 74 + } 75 + } 76 + 77 + export class ComNS { 78 + _server: Server 79 + atproto: ComAtprotoNS 80 + 81 + constructor(server: Server) { 82 + this._server = server 83 + this.atproto = new ComAtprotoNS(server) 84 + } 85 + } 86 + 87 + export class ComAtprotoNS { 88 + _server: Server 89 + repo: ComAtprotoRepoNS 90 + 91 + constructor(server: Server) { 92 + this._server = server 93 + this.repo = new ComAtprotoRepoNS(server) 94 + } 95 + } 96 + 97 + export class ComAtprotoRepoNS { 98 _server: Server 99 100 constructor(server: Server) {
+202
src/lexicon/lexicons.ts
··· 4 import { LexiconDoc, Lexicons } from '@atproto/lexicon' 5 6 export const schemaDict = { 7 AppBskyActorProfile: { 8 lexicon: 1, 9 id: 'app.bsky.actor.profile', ··· 85 }, 86 }, 87 }, 88 } 89 export const schemas: LexiconDoc[] = Object.values(schemaDict) as LexiconDoc[] 90 export const lexicons: Lexicons = new Lexicons(schemas) 91 export const ids = { 92 AppBskyActorProfile: 'app.bsky.actor.profile', 93 XyzStatusphereStatus: 'xyz.statusphere.status', 94 }
··· 4 import { LexiconDoc, Lexicons } from '@atproto/lexicon' 5 6 export const schemaDict = { 7 + ComAtprotoLabelDefs: { 8 + lexicon: 1, 9 + id: 'com.atproto.label.defs', 10 + defs: { 11 + label: { 12 + type: 'object', 13 + description: 14 + 'Metadata tag on an atproto resource (eg, repo or record).', 15 + required: ['src', 'uri', 'val', 'cts'], 16 + properties: { 17 + ver: { 18 + type: 'integer', 19 + description: 'The AT Protocol version of the label object.', 20 + }, 21 + src: { 22 + type: 'string', 23 + format: 'did', 24 + description: 'DID of the actor who created this label.', 25 + }, 26 + uri: { 27 + type: 'string', 28 + format: 'uri', 29 + description: 30 + 'AT URI of the record, repository (account), or other resource that this label applies to.', 31 + }, 32 + cid: { 33 + type: 'string', 34 + format: 'cid', 35 + description: 36 + "Optionally, CID specifying the specific version of 'uri' resource this label applies to.", 37 + }, 38 + val: { 39 + type: 'string', 40 + maxLength: 128, 41 + description: 42 + 'The short string name of the value or type of this label.', 43 + }, 44 + neg: { 45 + type: 'boolean', 46 + description: 47 + 'If true, this is a negation label, overwriting a previous label.', 48 + }, 49 + cts: { 50 + type: 'string', 51 + format: 'datetime', 52 + description: 'Timestamp when this label was created.', 53 + }, 54 + exp: { 55 + type: 'string', 56 + format: 'datetime', 57 + description: 58 + 'Timestamp at which this label expires (no longer applies).', 59 + }, 60 + sig: { 61 + type: 'bytes', 62 + description: 'Signature of dag-cbor encoded label.', 63 + }, 64 + }, 65 + }, 66 + selfLabels: { 67 + type: 'object', 68 + description: 69 + 'Metadata tags on an atproto record, published by the author within the record.', 70 + required: ['values'], 71 + properties: { 72 + values: { 73 + type: 'array', 74 + items: { 75 + type: 'ref', 76 + ref: 'lex:com.atproto.label.defs#selfLabel', 77 + }, 78 + maxLength: 10, 79 + }, 80 + }, 81 + }, 82 + selfLabel: { 83 + type: 'object', 84 + description: 85 + 'Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel.', 86 + required: ['val'], 87 + properties: { 88 + val: { 89 + type: 'string', 90 + maxLength: 128, 91 + description: 92 + 'The short string name of the value or type of this label.', 93 + }, 94 + }, 95 + }, 96 + labelValueDefinition: { 97 + type: 'object', 98 + description: 99 + 'Declares a label value and its expected interpretations and behaviors.', 100 + required: ['identifier', 'severity', 'blurs', 'locales'], 101 + properties: { 102 + identifier: { 103 + type: 'string', 104 + description: 105 + "The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+).", 106 + maxLength: 100, 107 + maxGraphemes: 100, 108 + }, 109 + severity: { 110 + type: 'string', 111 + description: 112 + "How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing.", 113 + knownValues: ['inform', 'alert', 'none'], 114 + }, 115 + blurs: { 116 + type: 'string', 117 + description: 118 + "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.", 119 + knownValues: ['content', 'media', 'none'], 120 + }, 121 + defaultSetting: { 122 + type: 'string', 123 + description: 'The default setting for this label.', 124 + knownValues: ['ignore', 'warn', 'hide'], 125 + default: 'warn', 126 + }, 127 + adultOnly: { 128 + type: 'boolean', 129 + description: 130 + 'Does the user need to have adult content enabled in order to configure this label?', 131 + }, 132 + locales: { 133 + type: 'array', 134 + items: { 135 + type: 'ref', 136 + ref: 'lex:com.atproto.label.defs#labelValueDefinitionStrings', 137 + }, 138 + }, 139 + }, 140 + }, 141 + labelValueDefinitionStrings: { 142 + type: 'object', 143 + description: 144 + 'Strings which describe the label in the UI, localized into a specific language.', 145 + required: ['lang', 'name', 'description'], 146 + properties: { 147 + lang: { 148 + type: 'string', 149 + description: 150 + 'The code of the language these strings are written in.', 151 + format: 'language', 152 + }, 153 + name: { 154 + type: 'string', 155 + description: 'A short human-readable name for the label.', 156 + maxGraphemes: 64, 157 + maxLength: 640, 158 + }, 159 + description: { 160 + type: 'string', 161 + description: 162 + 'A longer description of what the label means and why it might be applied.', 163 + maxGraphemes: 10000, 164 + maxLength: 100000, 165 + }, 166 + }, 167 + }, 168 + labelValue: { 169 + type: 'string', 170 + knownValues: [ 171 + '!hide', 172 + '!no-promote', 173 + '!warn', 174 + '!no-unauthenticated', 175 + 'dmca-violation', 176 + 'doxxing', 177 + 'porn', 178 + 'sexual', 179 + 'nudity', 180 + 'nsfl', 181 + 'gore', 182 + ], 183 + }, 184 + }, 185 + }, 186 AppBskyActorProfile: { 187 lexicon: 1, 188 id: 'app.bsky.actor.profile', ··· 264 }, 265 }, 266 }, 267 + ComAtprotoRepoStrongRef: { 268 + lexicon: 1, 269 + id: 'com.atproto.repo.strongRef', 270 + description: 'A URI with a content-hash fingerprint.', 271 + defs: { 272 + main: { 273 + type: 'object', 274 + required: ['uri', 'cid'], 275 + properties: { 276 + uri: { 277 + type: 'string', 278 + format: 'at-uri', 279 + }, 280 + cid: { 281 + type: 'string', 282 + format: 'cid', 283 + }, 284 + }, 285 + }, 286 + }, 287 + }, 288 } 289 export const schemas: LexiconDoc[] = Object.values(schemaDict) as LexiconDoc[] 290 export const lexicons: Lexicons = new Lexicons(schemas) 291 export const ids = { 292 + ComAtprotoLabelDefs: 'com.atproto.label.defs', 293 AppBskyActorProfile: 'app.bsky.actor.profile', 294 XyzStatusphereStatus: 'xyz.statusphere.status', 295 + ComAtprotoRepoStrongRef: 'com.atproto.repo.strongRef', 296 }
+151
src/lexicon/types/com/atproto/label/defs.ts
···
··· 1 + /** 2 + * GENERATED CODE - DO NOT MODIFY 3 + */ 4 + import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 + import { lexicons } from '../../../../lexicons' 6 + import { isObj, hasProp } from '../../../../util' 7 + import { CID } from 'multiformats/cid' 8 + 9 + /** Metadata tag on an atproto resource (eg, repo or record). */ 10 + export interface Label { 11 + /** The AT Protocol version of the label object. */ 12 + ver?: number 13 + /** DID of the actor who created this label. */ 14 + src: string 15 + /** AT URI of the record, repository (account), or other resource that this label applies to. */ 16 + uri: string 17 + /** Optionally, CID specifying the specific version of 'uri' resource this label applies to. */ 18 + cid?: string 19 + /** The short string name of the value or type of this label. */ 20 + val: string 21 + /** If true, this is a negation label, overwriting a previous label. */ 22 + neg?: boolean 23 + /** Timestamp when this label was created. */ 24 + cts: string 25 + /** Timestamp at which this label expires (no longer applies). */ 26 + exp?: string 27 + /** Signature of dag-cbor encoded label. */ 28 + sig?: Uint8Array 29 + [k: string]: unknown 30 + } 31 + 32 + export function isLabel(v: unknown): v is Label { 33 + return ( 34 + isObj(v) && 35 + hasProp(v, '$type') && 36 + v.$type === 'com.atproto.label.defs#label' 37 + ) 38 + } 39 + 40 + export function validateLabel(v: unknown): ValidationResult { 41 + return lexicons.validate('com.atproto.label.defs#label', v) 42 + } 43 + 44 + /** Metadata tags on an atproto record, published by the author within the record. */ 45 + export interface SelfLabels { 46 + values: SelfLabel[] 47 + [k: string]: unknown 48 + } 49 + 50 + export function isSelfLabels(v: unknown): v is SelfLabels { 51 + return ( 52 + isObj(v) && 53 + hasProp(v, '$type') && 54 + v.$type === 'com.atproto.label.defs#selfLabels' 55 + ) 56 + } 57 + 58 + export function validateSelfLabels(v: unknown): ValidationResult { 59 + return lexicons.validate('com.atproto.label.defs#selfLabels', v) 60 + } 61 + 62 + /** Metadata tag on an atproto record, published by the author within the record. Note that schemas should use #selfLabels, not #selfLabel. */ 63 + export interface SelfLabel { 64 + /** The short string name of the value or type of this label. */ 65 + val: string 66 + [k: string]: unknown 67 + } 68 + 69 + export function isSelfLabel(v: unknown): v is SelfLabel { 70 + return ( 71 + isObj(v) && 72 + hasProp(v, '$type') && 73 + v.$type === 'com.atproto.label.defs#selfLabel' 74 + ) 75 + } 76 + 77 + export function validateSelfLabel(v: unknown): ValidationResult { 78 + return lexicons.validate('com.atproto.label.defs#selfLabel', v) 79 + } 80 + 81 + /** Declares a label value and its expected interpretations and behaviors. */ 82 + export interface LabelValueDefinition { 83 + /** The value of the label being defined. Must only include lowercase ascii and the '-' character ([a-z-]+). */ 84 + identifier: string 85 + /** How should a client visually convey this label? 'inform' means neutral and informational; 'alert' means negative and warning; 'none' means show nothing. */ 86 + severity: 'inform' | 'alert' | 'none' | (string & {}) 87 + /** 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. */ 88 + blurs: 'content' | 'media' | 'none' | (string & {}) 89 + /** The default setting for this label. */ 90 + defaultSetting: 'ignore' | 'warn' | 'hide' | (string & {}) 91 + /** Does the user need to have adult content enabled in order to configure this label? */ 92 + adultOnly?: boolean 93 + locales: LabelValueDefinitionStrings[] 94 + [k: string]: unknown 95 + } 96 + 97 + export function isLabelValueDefinition(v: unknown): v is LabelValueDefinition { 98 + return ( 99 + isObj(v) && 100 + hasProp(v, '$type') && 101 + v.$type === 'com.atproto.label.defs#labelValueDefinition' 102 + ) 103 + } 104 + 105 + export function validateLabelValueDefinition(v: unknown): ValidationResult { 106 + return lexicons.validate('com.atproto.label.defs#labelValueDefinition', v) 107 + } 108 + 109 + /** Strings which describe the label in the UI, localized into a specific language. */ 110 + export interface LabelValueDefinitionStrings { 111 + /** The code of the language these strings are written in. */ 112 + lang: string 113 + /** A short human-readable name for the label. */ 114 + name: string 115 + /** A longer description of what the label means and why it might be applied. */ 116 + description: string 117 + [k: string]: unknown 118 + } 119 + 120 + export function isLabelValueDefinitionStrings( 121 + v: unknown, 122 + ): v is LabelValueDefinitionStrings { 123 + return ( 124 + isObj(v) && 125 + hasProp(v, '$type') && 126 + v.$type === 'com.atproto.label.defs#labelValueDefinitionStrings' 127 + ) 128 + } 129 + 130 + export function validateLabelValueDefinitionStrings( 131 + v: unknown, 132 + ): ValidationResult { 133 + return lexicons.validate( 134 + 'com.atproto.label.defs#labelValueDefinitionStrings', 135 + v, 136 + ) 137 + } 138 + 139 + export type LabelValue = 140 + | '!hide' 141 + | '!no-promote' 142 + | '!warn' 143 + | '!no-unauthenticated' 144 + | 'dmca-violation' 145 + | 'doxxing' 146 + | 'porn' 147 + | 'sexual' 148 + | 'nudity' 149 + | 'nsfl' 150 + | 'gore' 151 + | (string & {})
+26
src/lexicon/types/com/atproto/repo/strongRef.ts
···
··· 1 + /** 2 + * GENERATED CODE - DO NOT MODIFY 3 + */ 4 + import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 + import { lexicons } from '../../../../lexicons' 6 + import { isObj, hasProp } from '../../../../util' 7 + import { CID } from 'multiformats/cid' 8 + 9 + export interface Main { 10 + uri: string 11 + cid: string 12 + [k: string]: unknown 13 + } 14 + 15 + export function isMain(v: unknown): v is Main { 16 + return ( 17 + isObj(v) && 18 + hasProp(v, '$type') && 19 + (v.$type === 'com.atproto.repo.strongRef#main' || 20 + v.$type === 'com.atproto.repo.strongRef') 21 + ) 22 + } 23 + 24 + export function validateMain(v: unknown): ValidationResult { 25 + return lexicons.validate('com.atproto.repo.strongRef#main', v) 26 + }