not sure what im doing here tbh

nulfrost aafb2f9e 76d8a7e9

+2 -1
.gitignore
··· 1 - node_modules 1 + node_modules 2 + dist
+73
lexicons/com/atproto/repo/createRecord.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "com.atproto.repo.createRecord", 4 + "defs": { 5 + "main": { 6 + "type": "procedure", 7 + "description": "Create a single new repository record. Requires auth, implemented by PDS.", 8 + "input": { 9 + "encoding": "application/json", 10 + "schema": { 11 + "type": "object", 12 + "required": ["repo", "collection", "record"], 13 + "properties": { 14 + "repo": { 15 + "type": "string", 16 + "format": "at-identifier", 17 + "description": "The handle or DID of the repo (aka, current account)." 18 + }, 19 + "collection": { 20 + "type": "string", 21 + "format": "nsid", 22 + "description": "The NSID of the record collection." 23 + }, 24 + "rkey": { 25 + "type": "string", 26 + "format": "record-key", 27 + "description": "The Record Key.", 28 + "maxLength": 512 29 + }, 30 + "validate": { 31 + "type": "boolean", 32 + "description": "Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it, or leave unset to validate only for known Lexicons." 33 + }, 34 + "record": { 35 + "type": "unknown", 36 + "description": "The record itself. Must contain a $type field." 37 + }, 38 + "swapCommit": { 39 + "type": "string", 40 + "format": "cid", 41 + "description": "Compare and swap with the previous commit by CID." 42 + } 43 + } 44 + } 45 + }, 46 + "output": { 47 + "encoding": "application/json", 48 + "schema": { 49 + "type": "object", 50 + "required": ["uri", "cid"], 51 + "properties": { 52 + "uri": { "type": "string", "format": "at-uri" }, 53 + "cid": { "type": "string", "format": "cid" }, 54 + "commit": { 55 + "type": "ref", 56 + "ref": "com.atproto.repo.defs#commitMeta" 57 + }, 58 + "validationStatus": { 59 + "type": "string", 60 + "knownValues": ["valid", "unknown"] 61 + } 62 + } 63 + } 64 + }, 65 + "errors": [ 66 + { 67 + "name": "InvalidSwap", 68 + "description": "Indicates that 'swapCommit' didn't match current repo commit." 69 + } 70 + ] 71 + } 72 + } 73 + }
+14
lexicons/com/atproto/repo/defs.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "com.atproto.repo.defs", 4 + "defs": { 5 + "commitMeta": { 6 + "type": "object", 7 + "required": ["cid", "rev"], 8 + "properties": { 9 + "cid": { "type": "string", "format": "cid" }, 10 + "rev": { "type": "string", "format": "tid" } 11 + } 12 + } 13 + } 14 + }
+57
lexicons/com/atproto/repo/deleteRecord.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "com.atproto.repo.deleteRecord", 4 + "defs": { 5 + "main": { 6 + "type": "procedure", 7 + "description": "Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS.", 8 + "input": { 9 + "encoding": "application/json", 10 + "schema": { 11 + "type": "object", 12 + "required": ["repo", "collection", "rkey"], 13 + "properties": { 14 + "repo": { 15 + "type": "string", 16 + "format": "at-identifier", 17 + "description": "The handle or DID of the repo (aka, current account)." 18 + }, 19 + "collection": { 20 + "type": "string", 21 + "format": "nsid", 22 + "description": "The NSID of the record collection." 23 + }, 24 + "rkey": { 25 + "type": "string", 26 + "format": "record-key", 27 + "description": "The Record Key." 28 + }, 29 + "swapRecord": { 30 + "type": "string", 31 + "format": "cid", 32 + "description": "Compare and swap with the previous record by CID." 33 + }, 34 + "swapCommit": { 35 + "type": "string", 36 + "format": "cid", 37 + "description": "Compare and swap with the previous commit by CID." 38 + } 39 + } 40 + } 41 + }, 42 + "output": { 43 + "encoding": "application/json", 44 + "schema": { 45 + "type": "object", 46 + "properties": { 47 + "commit": { 48 + "type": "ref", 49 + "ref": "com.atproto.repo.defs#commitMeta" 50 + } 51 + } 52 + } 53 + }, 54 + "errors": [{ "name": "InvalidSwap" }] 55 + } 56 + } 57 + }
+49
lexicons/com/atproto/repo/getRecord.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "com.atproto.repo.getRecord", 4 + "defs": { 5 + "main": { 6 + "type": "query", 7 + "description": "Get a single record from a repository. Does not require auth.", 8 + "parameters": { 9 + "type": "params", 10 + "required": ["repo", "collection", "rkey"], 11 + "properties": { 12 + "repo": { 13 + "type": "string", 14 + "format": "at-identifier", 15 + "description": "The handle or DID of the repo." 16 + }, 17 + "collection": { 18 + "type": "string", 19 + "format": "nsid", 20 + "description": "The NSID of the record collection." 21 + }, 22 + "rkey": { 23 + "type": "string", 24 + "description": "The Record Key.", 25 + "format": "record-key" 26 + }, 27 + "cid": { 28 + "type": "string", 29 + "format": "cid", 30 + "description": "The CID of the version of the record. If not specified, then return the most recent version." 31 + } 32 + } 33 + }, 34 + "output": { 35 + "encoding": "application/json", 36 + "schema": { 37 + "type": "object", 38 + "required": ["uri", "value"], 39 + "properties": { 40 + "uri": { "type": "string", "format": "at-uri" }, 41 + "cid": { "type": "string", "format": "cid" }, 42 + "value": { "type": "unknown" } 43 + } 44 + } 45 + }, 46 + "errors": [{ "name": "RecordNotFound" }] 47 + } 48 + } 49 + }
+69
lexicons/com/atproto/repo/listRecords.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "com.atproto.repo.listRecords", 4 + "defs": { 5 + "main": { 6 + "type": "query", 7 + "description": "List a range of records in a repository, matching a specific collection. Does not require auth.", 8 + "parameters": { 9 + "type": "params", 10 + "required": ["repo", "collection"], 11 + "properties": { 12 + "repo": { 13 + "type": "string", 14 + "format": "at-identifier", 15 + "description": "The handle or DID of the repo." 16 + }, 17 + "collection": { 18 + "type": "string", 19 + "format": "nsid", 20 + "description": "The NSID of the record type." 21 + }, 22 + "limit": { 23 + "type": "integer", 24 + "minimum": 1, 25 + "maximum": 100, 26 + "default": 50, 27 + "description": "The number of records to return." 28 + }, 29 + "cursor": { "type": "string" }, 30 + "rkeyStart": { 31 + "type": "string", 32 + "description": "DEPRECATED: The lowest sort-ordered rkey to start from (exclusive)" 33 + }, 34 + "rkeyEnd": { 35 + "type": "string", 36 + "description": "DEPRECATED: The highest sort-ordered rkey to stop at (exclusive)" 37 + }, 38 + "reverse": { 39 + "type": "boolean", 40 + "description": "Flag to reverse the order of the returned records." 41 + } 42 + } 43 + }, 44 + "output": { 45 + "encoding": "application/json", 46 + "schema": { 47 + "type": "object", 48 + "required": ["records"], 49 + "properties": { 50 + "cursor": { "type": "string" }, 51 + "records": { 52 + "type": "array", 53 + "items": { "type": "ref", "ref": "#record" } 54 + } 55 + } 56 + } 57 + } 58 + }, 59 + "record": { 60 + "type": "object", 61 + "required": ["uri", "cid", "value"], 62 + "properties": { 63 + "uri": { "type": "string", "format": "at-uri" }, 64 + "cid": { "type": "string", "format": "cid" }, 65 + "value": { "type": "unknown" } 66 + } 67 + } 68 + } 69 + }
+74
lexicons/com/atproto/repo/putRecord.json
··· 1 + { 2 + "lexicon": 1, 3 + "id": "com.atproto.repo.putRecord", 4 + "defs": { 5 + "main": { 6 + "type": "procedure", 7 + "description": "Write a repository record, creating or updating it as needed. Requires auth, implemented by PDS.", 8 + "input": { 9 + "encoding": "application/json", 10 + "schema": { 11 + "type": "object", 12 + "required": ["repo", "collection", "rkey", "record"], 13 + "nullable": ["swapRecord"], 14 + "properties": { 15 + "repo": { 16 + "type": "string", 17 + "format": "at-identifier", 18 + "description": "The handle or DID of the repo (aka, current account)." 19 + }, 20 + "collection": { 21 + "type": "string", 22 + "format": "nsid", 23 + "description": "The NSID of the record collection." 24 + }, 25 + "rkey": { 26 + "type": "string", 27 + "format": "record-key", 28 + "description": "The Record Key.", 29 + "maxLength": 512 30 + }, 31 + "validate": { 32 + "type": "boolean", 33 + "description": "Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it, or leave unset to validate only for known Lexicons." 34 + }, 35 + "record": { 36 + "type": "unknown", 37 + "description": "The record to write." 38 + }, 39 + "swapRecord": { 40 + "type": "string", 41 + "format": "cid", 42 + "description": "Compare and swap with the previous record by CID. WARNING: nullable and optional field; may cause problems with golang implementation" 43 + }, 44 + "swapCommit": { 45 + "type": "string", 46 + "format": "cid", 47 + "description": "Compare and swap with the previous commit by CID." 48 + } 49 + } 50 + } 51 + }, 52 + "output": { 53 + "encoding": "application/json", 54 + "schema": { 55 + "type": "object", 56 + "required": ["uri", "cid"], 57 + "properties": { 58 + "uri": { "type": "string", "format": "at-uri" }, 59 + "cid": { "type": "string", "format": "cid" }, 60 + "commit": { 61 + "type": "ref", 62 + "ref": "com.atproto.repo.defs#commitMeta" 63 + }, 64 + "validationStatus": { 65 + "type": "string", 66 + "knownValues": ["valid", "unknown"] 67 + } 68 + } 69 + } 70 + }, 71 + "errors": [{ "name": "InvalidSwap" }] 72 + } 73 + } 74 + }
+5 -2
package.json
··· 19 19 }, 20 20 "scripts": { 21 21 "lint": "biome lint", 22 - "lex-gen": "lex gen-api ./src/__generated__/lexicons ./lexicons/pub/leaflet/* ./lexicons/pub/leaflet/*/* ./lexicons/com/atproto/*/* --yes", 22 + "lex-gen": "lex gen-api ./src/leaflet/lexicons ./lexicons/pub/leaflet/* ./lexicons/pub/leaflet/*/* ./lexicons/com/atproto/*/* --yes", 23 23 "typecheck": "tsc --noEmit", 24 - "build": "tsc" 24 + "build": "rm -rf dist && tsc" 25 25 }, 26 26 "license": "MIT", 27 27 "files": [ ··· 41 41 "dependencies": { 42 42 "@atproto/api": "^0.16.1", 43 43 "@atproto/did": "^0.1.5", 44 + "@atproto/lexicon": "^0.4.12", 44 45 "@atproto/syntax": "^0.4.0", 46 + "@atproto/xrpc": "^0.7.1", 47 + "multiformats": "^13.4.0", 45 48 "sanitize-html": "^2.17.0" 46 49 } 47 50 }
+14
pnpm-lock.yaml
··· 14 14 '@atproto/did': 15 15 specifier: ^0.1.5 16 16 version: 0.1.5 17 + '@atproto/lexicon': 18 + specifier: ^0.4.12 19 + version: 0.4.12 17 20 '@atproto/syntax': 18 21 specifier: ^0.4.0 19 22 version: 0.4.0 23 + '@atproto/xrpc': 24 + specifier: ^0.7.1 25 + version: 0.7.1 26 + multiformats: 27 + specifier: ^13.4.0 28 + version: 13.4.0 20 29 sanitize-html: 21 30 specifier: ^2.17.0 22 31 version: 2.17.0 ··· 1315 1324 1316 1325 ms@2.1.3: 1317 1326 resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} 1327 + 1328 + multiformats@13.4.0: 1329 + resolution: {integrity: sha512-Mkb/QcclrJxKC+vrcIFl297h52QcKh2Az/9A5vbWytbQt4225UWWWmIuSsKksdww9NkIeYcA7DkfftyLuC/JSg==} 1318 1330 1319 1331 multiformats@9.9.0: 1320 1332 resolution: {integrity: sha512-HoMUjhH9T8DDBNT+6xzkrd9ga/XiBI4xLr58LJACwK6G3HTOPeMz4nB4KJs33L2BelrIJa7P0VuNaVF3hMYfjg==} ··· 3554 3566 mrmime@2.0.1: {} 3555 3567 3556 3568 ms@2.1.3: {} 3569 + 3570 + multiformats@13.4.0: {} 3557 3571 3558 3572 multiformats@9.9.0: {} 3559 3573
+68
src/__generated__/lexicons/index.ts src/leaflet/lexicons/index.ts
··· 19 19 import * as PubLeafletBlocksWebsite from './types/pub/leaflet/blocks/website.js' 20 20 import * as PubLeafletPagesLinearDocument from './types/pub/leaflet/pages/linearDocument.js' 21 21 import * as PubLeafletRichtextFacet from './types/pub/leaflet/richtext/facet.js' 22 + import * as ComAtprotoRepoCreateRecord from './types/com/atproto/repo/createRecord.js' 23 + import * as ComAtprotoRepoDefs from './types/com/atproto/repo/defs.js' 24 + import * as ComAtprotoRepoDeleteRecord from './types/com/atproto/repo/deleteRecord.js' 25 + import * as ComAtprotoRepoGetRecord from './types/com/atproto/repo/getRecord.js' 26 + import * as ComAtprotoRepoListRecords from './types/com/atproto/repo/listRecords.js' 27 + import * as ComAtprotoRepoPutRecord from './types/com/atproto/repo/putRecord.js' 22 28 import * as ComAtprotoRepoStrongRef from './types/com/atproto/repo/strongRef.js' 23 29 24 30 export * as PubLeafletDocument from './types/pub/leaflet/document.js' ··· 31 37 export * as PubLeafletBlocksWebsite from './types/pub/leaflet/blocks/website.js' 32 38 export * as PubLeafletPagesLinearDocument from './types/pub/leaflet/pages/linearDocument.js' 33 39 export * as PubLeafletRichtextFacet from './types/pub/leaflet/richtext/facet.js' 40 + export * as ComAtprotoRepoCreateRecord from './types/com/atproto/repo/createRecord.js' 41 + export * as ComAtprotoRepoDefs from './types/com/atproto/repo/defs.js' 42 + export * as ComAtprotoRepoDeleteRecord from './types/com/atproto/repo/deleteRecord.js' 43 + export * as ComAtprotoRepoGetRecord from './types/com/atproto/repo/getRecord.js' 44 + export * as ComAtprotoRepoListRecords from './types/com/atproto/repo/listRecords.js' 45 + export * as ComAtprotoRepoPutRecord from './types/com/atproto/repo/putRecord.js' 34 46 export * as ComAtprotoRepoStrongRef from './types/com/atproto/repo/strongRef.js' 35 47 36 48 export const PUB_LEAFLET_PAGES = { ··· 211 223 212 224 constructor(client: XrpcClient) { 213 225 this._client = client 226 + } 227 + 228 + createRecord( 229 + data?: ComAtprotoRepoCreateRecord.InputSchema, 230 + opts?: ComAtprotoRepoCreateRecord.CallOptions, 231 + ): Promise<ComAtprotoRepoCreateRecord.Response> { 232 + return this._client 233 + .call('com.atproto.repo.createRecord', opts?.qp, data, opts) 234 + .catch((e) => { 235 + throw ComAtprotoRepoCreateRecord.toKnownErr(e) 236 + }) 237 + } 238 + 239 + deleteRecord( 240 + data?: ComAtprotoRepoDeleteRecord.InputSchema, 241 + opts?: ComAtprotoRepoDeleteRecord.CallOptions, 242 + ): Promise<ComAtprotoRepoDeleteRecord.Response> { 243 + return this._client 244 + .call('com.atproto.repo.deleteRecord', opts?.qp, data, opts) 245 + .catch((e) => { 246 + throw ComAtprotoRepoDeleteRecord.toKnownErr(e) 247 + }) 248 + } 249 + 250 + getRecord( 251 + params?: ComAtprotoRepoGetRecord.QueryParams, 252 + opts?: ComAtprotoRepoGetRecord.CallOptions, 253 + ): Promise<ComAtprotoRepoGetRecord.Response> { 254 + return this._client 255 + .call('com.atproto.repo.getRecord', params, undefined, opts) 256 + .catch((e) => { 257 + throw ComAtprotoRepoGetRecord.toKnownErr(e) 258 + }) 259 + } 260 + 261 + listRecords( 262 + params?: ComAtprotoRepoListRecords.QueryParams, 263 + opts?: ComAtprotoRepoListRecords.CallOptions, 264 + ): Promise<ComAtprotoRepoListRecords.Response> { 265 + return this._client.call( 266 + 'com.atproto.repo.listRecords', 267 + params, 268 + undefined, 269 + opts, 270 + ) 271 + } 272 + 273 + putRecord( 274 + data?: ComAtprotoRepoPutRecord.InputSchema, 275 + opts?: ComAtprotoRepoPutRecord.CallOptions, 276 + ): Promise<ComAtprotoRepoPutRecord.Response> { 277 + return this._client 278 + .call('com.atproto.repo.putRecord', opts?.qp, data, opts) 279 + .catch((e) => { 280 + throw ComAtprotoRepoPutRecord.toKnownErr(e) 281 + }) 214 282 } 215 283 }
-481
src/__generated__/lexicons/lexicons.ts
··· 1 - /** 2 - * GENERATED CODE - DO NOT MODIFY 3 - */ 4 - import { 5 - type LexiconDoc, 6 - Lexicons, 7 - ValidationError, 8 - type ValidationResult, 9 - } from '@atproto/lexicon' 10 - import { type $Typed, is$typed, maybe$typed } from './util.js' 11 - 12 - export const schemaDict = { 13 - PubLeafletDocument: { 14 - lexicon: 1, 15 - id: 'pub.leaflet.document', 16 - revision: 1, 17 - description: 'A lexicon for long form rich media documents', 18 - defs: { 19 - main: { 20 - type: 'record', 21 - key: 'tid', 22 - description: 'Record containing a document', 23 - record: { 24 - type: 'object', 25 - required: ['pages', 'author', 'title', 'publication'], 26 - properties: { 27 - title: { 28 - type: 'string', 29 - maxLength: 1280, 30 - maxGraphemes: 128, 31 - }, 32 - postRef: { 33 - type: 'ref', 34 - ref: 'lex:com.atproto.repo.strongRef', 35 - }, 36 - description: { 37 - type: 'string', 38 - maxLength: 3000, 39 - maxGraphemes: 300, 40 - }, 41 - publishedAt: { 42 - type: 'string', 43 - format: 'datetime', 44 - }, 45 - publication: { 46 - type: 'string', 47 - format: 'at-uri', 48 - }, 49 - author: { 50 - type: 'string', 51 - format: 'at-identifier', 52 - }, 53 - pages: { 54 - type: 'array', 55 - items: { 56 - type: 'union', 57 - refs: ['lex:pub.leaflet.pages.linearDocument'], 58 - }, 59 - }, 60 - }, 61 - }, 62 - }, 63 - }, 64 - }, 65 - PubLeafletBlocksCode: { 66 - lexicon: 1, 67 - id: 'pub.leaflet.blocks.code', 68 - defs: { 69 - main: { 70 - type: 'object', 71 - required: ['plaintext'], 72 - properties: { 73 - plaintext: { 74 - type: 'string', 75 - }, 76 - language: { 77 - type: 'string', 78 - }, 79 - syntaxHighlightingTheme: { 80 - type: 'string', 81 - }, 82 - }, 83 - }, 84 - }, 85 - }, 86 - PubLeafletBlocksHeader: { 87 - lexicon: 1, 88 - id: 'pub.leaflet.blocks.header', 89 - defs: { 90 - main: { 91 - type: 'object', 92 - required: ['plaintext'], 93 - properties: { 94 - level: { 95 - type: 'integer', 96 - minimum: 1, 97 - maximum: 6, 98 - }, 99 - plaintext: { 100 - type: 'string', 101 - }, 102 - facets: { 103 - type: 'array', 104 - items: { 105 - type: 'ref', 106 - ref: 'lex:pub.leaflet.richtext.facet', 107 - }, 108 - }, 109 - }, 110 - }, 111 - }, 112 - }, 113 - PubLeafletBlocksImage: { 114 - lexicon: 1, 115 - id: 'pub.leaflet.blocks.image', 116 - defs: { 117 - main: { 118 - type: 'object', 119 - required: ['image', 'aspectRatio'], 120 - properties: { 121 - image: { 122 - type: 'blob', 123 - accept: ['image/*'], 124 - maxSize: 1000000, 125 - }, 126 - alt: { 127 - type: 'string', 128 - description: 129 - 'Alt text description of the image, for accessibility.', 130 - }, 131 - aspectRatio: { 132 - type: 'ref', 133 - ref: 'lex:pub.leaflet.blocks.image#aspectRatio', 134 - }, 135 - }, 136 - }, 137 - aspectRatio: { 138 - type: 'object', 139 - required: ['width', 'height'], 140 - properties: { 141 - width: { 142 - type: 'integer', 143 - }, 144 - height: { 145 - type: 'integer', 146 - }, 147 - }, 148 - }, 149 - }, 150 - }, 151 - PubLeafletBlocksMath: { 152 - lexicon: 1, 153 - id: 'pub.leaflet.blocks.math', 154 - defs: { 155 - main: { 156 - type: 'object', 157 - required: ['tex'], 158 - properties: { 159 - tex: { 160 - type: 'string', 161 - }, 162 - }, 163 - }, 164 - }, 165 - }, 166 - PubLeafletBlocksText: { 167 - lexicon: 1, 168 - id: 'pub.leaflet.blocks.text', 169 - defs: { 170 - main: { 171 - type: 'object', 172 - required: ['plaintext'], 173 - properties: { 174 - plaintext: { 175 - type: 'string', 176 - }, 177 - facets: { 178 - type: 'array', 179 - items: { 180 - type: 'ref', 181 - ref: 'lex:pub.leaflet.richtext.facet', 182 - }, 183 - }, 184 - }, 185 - }, 186 - }, 187 - }, 188 - PubLeafletBlocksUnorderedList: { 189 - lexicon: 1, 190 - id: 'pub.leaflet.blocks.unorderedList', 191 - defs: { 192 - main: { 193 - type: 'object', 194 - required: ['children'], 195 - properties: { 196 - children: { 197 - type: 'array', 198 - items: { 199 - type: 'ref', 200 - ref: 'lex:pub.leaflet.blocks.unorderedList#listItem', 201 - }, 202 - }, 203 - }, 204 - }, 205 - listItem: { 206 - type: 'object', 207 - required: ['content'], 208 - properties: { 209 - content: { 210 - type: 'union', 211 - refs: [ 212 - 'lex:pub.leaflet.blocks.text', 213 - 'lex:pub.leaflet.blocks.header', 214 - 'lex:pub.leaflet.blocks.image', 215 - ], 216 - }, 217 - children: { 218 - type: 'array', 219 - items: { 220 - type: 'ref', 221 - ref: 'lex:pub.leaflet.blocks.unorderedList#listItem', 222 - }, 223 - }, 224 - }, 225 - }, 226 - }, 227 - }, 228 - PubLeafletBlocksWebsite: { 229 - lexicon: 1, 230 - id: 'pub.leaflet.blocks.website', 231 - defs: { 232 - main: { 233 - type: 'object', 234 - required: ['src'], 235 - properties: { 236 - previewImage: { 237 - type: 'blob', 238 - accept: ['image/*'], 239 - maxSize: 1000000, 240 - }, 241 - title: { 242 - type: 'string', 243 - }, 244 - description: { 245 - type: 'string', 246 - }, 247 - src: { 248 - type: 'string', 249 - format: 'uri', 250 - }, 251 - }, 252 - }, 253 - }, 254 - }, 255 - PubLeafletPagesLinearDocument: { 256 - lexicon: 1, 257 - id: 'pub.leaflet.pages.linearDocument', 258 - defs: { 259 - main: { 260 - type: 'object', 261 - properties: { 262 - blocks: { 263 - type: 'array', 264 - items: { 265 - type: 'ref', 266 - ref: 'lex:pub.leaflet.pages.linearDocument#block', 267 - }, 268 - }, 269 - }, 270 - }, 271 - block: { 272 - type: 'object', 273 - required: ['block'], 274 - properties: { 275 - block: { 276 - type: 'union', 277 - refs: [ 278 - 'lex:pub.leaflet.blocks.text', 279 - 'lex:pub.leaflet.blocks.header', 280 - 'lex:pub.leaflet.blocks.image', 281 - 'lex:pub.leaflet.blocks.unorderedList', 282 - 'lex:pub.leaflet.blocks.website', 283 - 'lex:pub.leaflet.blocks.math', 284 - 'lex:pub.leaflet.blocks.code', 285 - ], 286 - }, 287 - alignment: { 288 - type: 'string', 289 - knownValues: [ 290 - 'lex:pub.leaflet.pages.linearDocument#textAlignLeft', 291 - 'lex:pub.leaflet.pages.linearDocument#textAlignCenter', 292 - 'lex:pub.leaflet.pages.linearDocument#textAlignRight', 293 - ], 294 - }, 295 - }, 296 - }, 297 - textAlignLeft: { 298 - type: 'token', 299 - }, 300 - textAlignCenter: { 301 - type: 'token', 302 - }, 303 - textAlignRight: { 304 - type: 'token', 305 - }, 306 - }, 307 - }, 308 - PubLeafletRichtextFacet: { 309 - lexicon: 1, 310 - id: 'pub.leaflet.richtext.facet', 311 - defs: { 312 - main: { 313 - type: 'object', 314 - description: 'Annotation of a sub-string within rich text.', 315 - required: ['index', 'features'], 316 - properties: { 317 - index: { 318 - type: 'ref', 319 - ref: 'lex:pub.leaflet.richtext.facet#byteSlice', 320 - }, 321 - features: { 322 - type: 'array', 323 - items: { 324 - type: 'union', 325 - refs: [ 326 - 'lex:pub.leaflet.richtext.facet#link', 327 - 'lex:pub.leaflet.richtext.facet#code', 328 - 'lex:pub.leaflet.richtext.facet#highlight', 329 - 'lex:pub.leaflet.richtext.facet#underline', 330 - 'lex:pub.leaflet.richtext.facet#strikethrough', 331 - 'lex:pub.leaflet.richtext.facet#id', 332 - 'lex:pub.leaflet.richtext.facet#bold', 333 - 'lex:pub.leaflet.richtext.facet#italic', 334 - ], 335 - }, 336 - }, 337 - }, 338 - }, 339 - byteSlice: { 340 - type: 'object', 341 - description: 342 - 'Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets.', 343 - required: ['byteStart', 'byteEnd'], 344 - properties: { 345 - byteStart: { 346 - type: 'integer', 347 - minimum: 0, 348 - }, 349 - byteEnd: { 350 - type: 'integer', 351 - minimum: 0, 352 - }, 353 - }, 354 - }, 355 - link: { 356 - type: 'object', 357 - description: 358 - 'Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL.', 359 - required: ['uri'], 360 - properties: { 361 - uri: { 362 - type: 'string', 363 - format: 'uri', 364 - }, 365 - }, 366 - }, 367 - code: { 368 - type: 'object', 369 - description: 'Facet feature for inline code.', 370 - required: [], 371 - properties: {}, 372 - }, 373 - highlight: { 374 - type: 'object', 375 - description: 'Facet feature for highlighted text.', 376 - required: [], 377 - properties: {}, 378 - }, 379 - underline: { 380 - type: 'object', 381 - description: 'Facet feature for underline markup', 382 - required: [], 383 - properties: {}, 384 - }, 385 - strikethrough: { 386 - type: 'object', 387 - description: 'Facet feature for strikethrough markup', 388 - required: [], 389 - properties: {}, 390 - }, 391 - id: { 392 - type: 'object', 393 - description: 394 - 'Facet feature for an identifier. Used for linking to a segment', 395 - required: [], 396 - properties: { 397 - id: { 398 - type: 'string', 399 - }, 400 - }, 401 - }, 402 - bold: { 403 - type: 'object', 404 - description: 'Facet feature for bold text', 405 - required: [], 406 - properties: {}, 407 - }, 408 - italic: { 409 - type: 'object', 410 - description: 'Facet feature for italic text', 411 - required: [], 412 - properties: {}, 413 - }, 414 - }, 415 - }, 416 - ComAtprotoRepoStrongRef: { 417 - lexicon: 1, 418 - id: 'com.atproto.repo.strongRef', 419 - description: 'A URI with a content-hash fingerprint.', 420 - defs: { 421 - main: { 422 - type: 'object', 423 - required: ['uri', 'cid'], 424 - properties: { 425 - uri: { 426 - type: 'string', 427 - format: 'at-uri', 428 - }, 429 - cid: { 430 - type: 'string', 431 - format: 'cid', 432 - }, 433 - }, 434 - }, 435 - }, 436 - }, 437 - } as const satisfies Record<string, LexiconDoc> 438 - export const schemas = Object.values(schemaDict) satisfies LexiconDoc[] 439 - export const lexicons: Lexicons = new Lexicons(schemas) 440 - 441 - export function validate<T extends { $type: string }>( 442 - v: unknown, 443 - id: string, 444 - hash: string, 445 - requiredType: true, 446 - ): ValidationResult<T> 447 - export function validate<T extends { $type?: string }>( 448 - v: unknown, 449 - id: string, 450 - hash: string, 451 - requiredType?: false, 452 - ): ValidationResult<T> 453 - export function validate( 454 - v: unknown, 455 - id: string, 456 - hash: string, 457 - requiredType?: boolean, 458 - ): ValidationResult { 459 - return (requiredType ? is$typed : maybe$typed)(v, id, hash) 460 - ? lexicons.validate(`${id}#${hash}`, v) 461 - : { 462 - success: false, 463 - error: new ValidationError( 464 - `Must be an object with "${hash === 'main' ? id : `${id}#${hash}`}" $type property`, 465 - ), 466 - } 467 - } 468 - 469 - export const ids = { 470 - PubLeafletDocument: 'pub.leaflet.document', 471 - PubLeafletBlocksCode: 'pub.leaflet.blocks.code', 472 - PubLeafletBlocksHeader: 'pub.leaflet.blocks.header', 473 - PubLeafletBlocksImage: 'pub.leaflet.blocks.image', 474 - PubLeafletBlocksMath: 'pub.leaflet.blocks.math', 475 - PubLeafletBlocksText: 'pub.leaflet.blocks.text', 476 - PubLeafletBlocksUnorderedList: 'pub.leaflet.blocks.unorderedList', 477 - PubLeafletBlocksWebsite: 'pub.leaflet.blocks.website', 478 - PubLeafletPagesLinearDocument: 'pub.leaflet.pages.linearDocument', 479 - PubLeafletRichtextFacet: 'pub.leaflet.richtext.facet', 480 - ComAtprotoRepoStrongRef: 'com.atproto.repo.strongRef', 481 - } as const
src/__generated__/lexicons/types/com/atproto/repo/strongRef.ts src/leaflet/lexicons/types/com/atproto/repo/strongRef.ts
src/__generated__/lexicons/types/pub/leaflet/blocks/code.ts src/leaflet/lexicons/types/pub/leaflet/blocks/code.ts
src/__generated__/lexicons/types/pub/leaflet/blocks/header.ts src/leaflet/lexicons/types/pub/leaflet/blocks/header.ts
src/__generated__/lexicons/types/pub/leaflet/blocks/image.ts src/leaflet/lexicons/types/pub/leaflet/blocks/image.ts
src/__generated__/lexicons/types/pub/leaflet/blocks/math.ts src/leaflet/lexicons/types/pub/leaflet/blocks/math.ts
src/__generated__/lexicons/types/pub/leaflet/blocks/text.ts src/leaflet/lexicons/types/pub/leaflet/blocks/text.ts
src/__generated__/lexicons/types/pub/leaflet/blocks/unorderedList.ts src/leaflet/lexicons/types/pub/leaflet/blocks/unorderedList.ts
src/__generated__/lexicons/types/pub/leaflet/blocks/website.ts src/leaflet/lexicons/types/pub/leaflet/blocks/website.ts
src/__generated__/lexicons/types/pub/leaflet/document.ts src/leaflet/lexicons/types/pub/leaflet/document.ts
src/__generated__/lexicons/types/pub/leaflet/pages/linearDocument.ts src/leaflet/lexicons/types/pub/leaflet/pages/linearDocument.ts
src/__generated__/lexicons/types/pub/leaflet/richtext/facet.ts src/leaflet/lexicons/types/pub/leaflet/richtext/facet.ts
src/__generated__/lexicons/util.ts src/leaflet/lexicons/util.ts
+1
src/index.ts
··· 1 + export { leafletLiveLoader } from "./leaflet-live-loader.js";
+895
src/leaflet/lexicons/lexicons.ts
··· 1 + /** 2 + * GENERATED CODE - DO NOT MODIFY 3 + */ 4 + import { 5 + type LexiconDoc, 6 + Lexicons, 7 + ValidationError, 8 + type ValidationResult, 9 + } from '@atproto/lexicon' 10 + import { type $Typed, is$typed, maybe$typed } from './util.js' 11 + 12 + export const schemaDict = { 13 + PubLeafletDocument: { 14 + lexicon: 1, 15 + id: 'pub.leaflet.document', 16 + revision: 1, 17 + description: 'A lexicon for long form rich media documents', 18 + defs: { 19 + main: { 20 + type: 'record', 21 + key: 'tid', 22 + description: 'Record containing a document', 23 + record: { 24 + type: 'object', 25 + required: ['pages', 'author', 'title', 'publication'], 26 + properties: { 27 + title: { 28 + type: 'string', 29 + maxLength: 1280, 30 + maxGraphemes: 128, 31 + }, 32 + postRef: { 33 + type: 'ref', 34 + ref: 'lex:com.atproto.repo.strongRef', 35 + }, 36 + description: { 37 + type: 'string', 38 + maxLength: 3000, 39 + maxGraphemes: 300, 40 + }, 41 + publishedAt: { 42 + type: 'string', 43 + format: 'datetime', 44 + }, 45 + publication: { 46 + type: 'string', 47 + format: 'at-uri', 48 + }, 49 + author: { 50 + type: 'string', 51 + format: 'at-identifier', 52 + }, 53 + pages: { 54 + type: 'array', 55 + items: { 56 + type: 'union', 57 + refs: ['lex:pub.leaflet.pages.linearDocument'], 58 + }, 59 + }, 60 + }, 61 + }, 62 + }, 63 + }, 64 + }, 65 + PubLeafletBlocksCode: { 66 + lexicon: 1, 67 + id: 'pub.leaflet.blocks.code', 68 + defs: { 69 + main: { 70 + type: 'object', 71 + required: ['plaintext'], 72 + properties: { 73 + plaintext: { 74 + type: 'string', 75 + }, 76 + language: { 77 + type: 'string', 78 + }, 79 + syntaxHighlightingTheme: { 80 + type: 'string', 81 + }, 82 + }, 83 + }, 84 + }, 85 + }, 86 + PubLeafletBlocksHeader: { 87 + lexicon: 1, 88 + id: 'pub.leaflet.blocks.header', 89 + defs: { 90 + main: { 91 + type: 'object', 92 + required: ['plaintext'], 93 + properties: { 94 + level: { 95 + type: 'integer', 96 + minimum: 1, 97 + maximum: 6, 98 + }, 99 + plaintext: { 100 + type: 'string', 101 + }, 102 + facets: { 103 + type: 'array', 104 + items: { 105 + type: 'ref', 106 + ref: 'lex:pub.leaflet.richtext.facet', 107 + }, 108 + }, 109 + }, 110 + }, 111 + }, 112 + }, 113 + PubLeafletBlocksImage: { 114 + lexicon: 1, 115 + id: 'pub.leaflet.blocks.image', 116 + defs: { 117 + main: { 118 + type: 'object', 119 + required: ['image', 'aspectRatio'], 120 + properties: { 121 + image: { 122 + type: 'blob', 123 + accept: ['image/*'], 124 + maxSize: 1000000, 125 + }, 126 + alt: { 127 + type: 'string', 128 + description: 129 + 'Alt text description of the image, for accessibility.', 130 + }, 131 + aspectRatio: { 132 + type: 'ref', 133 + ref: 'lex:pub.leaflet.blocks.image#aspectRatio', 134 + }, 135 + }, 136 + }, 137 + aspectRatio: { 138 + type: 'object', 139 + required: ['width', 'height'], 140 + properties: { 141 + width: { 142 + type: 'integer', 143 + }, 144 + height: { 145 + type: 'integer', 146 + }, 147 + }, 148 + }, 149 + }, 150 + }, 151 + PubLeafletBlocksMath: { 152 + lexicon: 1, 153 + id: 'pub.leaflet.blocks.math', 154 + defs: { 155 + main: { 156 + type: 'object', 157 + required: ['tex'], 158 + properties: { 159 + tex: { 160 + type: 'string', 161 + }, 162 + }, 163 + }, 164 + }, 165 + }, 166 + PubLeafletBlocksText: { 167 + lexicon: 1, 168 + id: 'pub.leaflet.blocks.text', 169 + defs: { 170 + main: { 171 + type: 'object', 172 + required: ['plaintext'], 173 + properties: { 174 + plaintext: { 175 + type: 'string', 176 + }, 177 + facets: { 178 + type: 'array', 179 + items: { 180 + type: 'ref', 181 + ref: 'lex:pub.leaflet.richtext.facet', 182 + }, 183 + }, 184 + }, 185 + }, 186 + }, 187 + }, 188 + PubLeafletBlocksUnorderedList: { 189 + lexicon: 1, 190 + id: 'pub.leaflet.blocks.unorderedList', 191 + defs: { 192 + main: { 193 + type: 'object', 194 + required: ['children'], 195 + properties: { 196 + children: { 197 + type: 'array', 198 + items: { 199 + type: 'ref', 200 + ref: 'lex:pub.leaflet.blocks.unorderedList#listItem', 201 + }, 202 + }, 203 + }, 204 + }, 205 + listItem: { 206 + type: 'object', 207 + required: ['content'], 208 + properties: { 209 + content: { 210 + type: 'union', 211 + refs: [ 212 + 'lex:pub.leaflet.blocks.text', 213 + 'lex:pub.leaflet.blocks.header', 214 + 'lex:pub.leaflet.blocks.image', 215 + ], 216 + }, 217 + children: { 218 + type: 'array', 219 + items: { 220 + type: 'ref', 221 + ref: 'lex:pub.leaflet.blocks.unorderedList#listItem', 222 + }, 223 + }, 224 + }, 225 + }, 226 + }, 227 + }, 228 + PubLeafletBlocksWebsite: { 229 + lexicon: 1, 230 + id: 'pub.leaflet.blocks.website', 231 + defs: { 232 + main: { 233 + type: 'object', 234 + required: ['src'], 235 + properties: { 236 + previewImage: { 237 + type: 'blob', 238 + accept: ['image/*'], 239 + maxSize: 1000000, 240 + }, 241 + title: { 242 + type: 'string', 243 + }, 244 + description: { 245 + type: 'string', 246 + }, 247 + src: { 248 + type: 'string', 249 + format: 'uri', 250 + }, 251 + }, 252 + }, 253 + }, 254 + }, 255 + PubLeafletPagesLinearDocument: { 256 + lexicon: 1, 257 + id: 'pub.leaflet.pages.linearDocument', 258 + defs: { 259 + main: { 260 + type: 'object', 261 + properties: { 262 + blocks: { 263 + type: 'array', 264 + items: { 265 + type: 'ref', 266 + ref: 'lex:pub.leaflet.pages.linearDocument#block', 267 + }, 268 + }, 269 + }, 270 + }, 271 + block: { 272 + type: 'object', 273 + required: ['block'], 274 + properties: { 275 + block: { 276 + type: 'union', 277 + refs: [ 278 + 'lex:pub.leaflet.blocks.text', 279 + 'lex:pub.leaflet.blocks.header', 280 + 'lex:pub.leaflet.blocks.image', 281 + 'lex:pub.leaflet.blocks.unorderedList', 282 + 'lex:pub.leaflet.blocks.website', 283 + 'lex:pub.leaflet.blocks.math', 284 + 'lex:pub.leaflet.blocks.code', 285 + ], 286 + }, 287 + alignment: { 288 + type: 'string', 289 + knownValues: [ 290 + 'lex:pub.leaflet.pages.linearDocument#textAlignLeft', 291 + 'lex:pub.leaflet.pages.linearDocument#textAlignCenter', 292 + 'lex:pub.leaflet.pages.linearDocument#textAlignRight', 293 + ], 294 + }, 295 + }, 296 + }, 297 + textAlignLeft: { 298 + type: 'token', 299 + }, 300 + textAlignCenter: { 301 + type: 'token', 302 + }, 303 + textAlignRight: { 304 + type: 'token', 305 + }, 306 + }, 307 + }, 308 + PubLeafletRichtextFacet: { 309 + lexicon: 1, 310 + id: 'pub.leaflet.richtext.facet', 311 + defs: { 312 + main: { 313 + type: 'object', 314 + description: 'Annotation of a sub-string within rich text.', 315 + required: ['index', 'features'], 316 + properties: { 317 + index: { 318 + type: 'ref', 319 + ref: 'lex:pub.leaflet.richtext.facet#byteSlice', 320 + }, 321 + features: { 322 + type: 'array', 323 + items: { 324 + type: 'union', 325 + refs: [ 326 + 'lex:pub.leaflet.richtext.facet#link', 327 + 'lex:pub.leaflet.richtext.facet#code', 328 + 'lex:pub.leaflet.richtext.facet#highlight', 329 + 'lex:pub.leaflet.richtext.facet#underline', 330 + 'lex:pub.leaflet.richtext.facet#strikethrough', 331 + 'lex:pub.leaflet.richtext.facet#id', 332 + 'lex:pub.leaflet.richtext.facet#bold', 333 + 'lex:pub.leaflet.richtext.facet#italic', 334 + ], 335 + }, 336 + }, 337 + }, 338 + }, 339 + byteSlice: { 340 + type: 'object', 341 + description: 342 + 'Specifies the sub-string range a facet feature applies to. Start index is inclusive, end index is exclusive. Indices are zero-indexed, counting bytes of the UTF-8 encoded text. NOTE: some languages, like Javascript, use UTF-16 or Unicode codepoints for string slice indexing; in these languages, convert to byte arrays before working with facets.', 343 + required: ['byteStart', 'byteEnd'], 344 + properties: { 345 + byteStart: { 346 + type: 'integer', 347 + minimum: 0, 348 + }, 349 + byteEnd: { 350 + type: 'integer', 351 + minimum: 0, 352 + }, 353 + }, 354 + }, 355 + link: { 356 + type: 'object', 357 + description: 358 + 'Facet feature for a URL. The text URL may have been simplified or truncated, but the facet reference should be a complete URL.', 359 + required: ['uri'], 360 + properties: { 361 + uri: { 362 + type: 'string', 363 + format: 'uri', 364 + }, 365 + }, 366 + }, 367 + code: { 368 + type: 'object', 369 + description: 'Facet feature for inline code.', 370 + required: [], 371 + properties: {}, 372 + }, 373 + highlight: { 374 + type: 'object', 375 + description: 'Facet feature for highlighted text.', 376 + required: [], 377 + properties: {}, 378 + }, 379 + underline: { 380 + type: 'object', 381 + description: 'Facet feature for underline markup', 382 + required: [], 383 + properties: {}, 384 + }, 385 + strikethrough: { 386 + type: 'object', 387 + description: 'Facet feature for strikethrough markup', 388 + required: [], 389 + properties: {}, 390 + }, 391 + id: { 392 + type: 'object', 393 + description: 394 + 'Facet feature for an identifier. Used for linking to a segment', 395 + required: [], 396 + properties: { 397 + id: { 398 + type: 'string', 399 + }, 400 + }, 401 + }, 402 + bold: { 403 + type: 'object', 404 + description: 'Facet feature for bold text', 405 + required: [], 406 + properties: {}, 407 + }, 408 + italic: { 409 + type: 'object', 410 + description: 'Facet feature for italic text', 411 + required: [], 412 + properties: {}, 413 + }, 414 + }, 415 + }, 416 + ComAtprotoRepoCreateRecord: { 417 + lexicon: 1, 418 + id: 'com.atproto.repo.createRecord', 419 + defs: { 420 + main: { 421 + type: 'procedure', 422 + description: 423 + 'Create a single new repository record. Requires auth, implemented by PDS.', 424 + input: { 425 + encoding: 'application/json', 426 + schema: { 427 + type: 'object', 428 + required: ['repo', 'collection', 'record'], 429 + properties: { 430 + repo: { 431 + type: 'string', 432 + format: 'at-identifier', 433 + description: 434 + 'The handle or DID of the repo (aka, current account).', 435 + }, 436 + collection: { 437 + type: 'string', 438 + format: 'nsid', 439 + description: 'The NSID of the record collection.', 440 + }, 441 + rkey: { 442 + type: 'string', 443 + format: 'record-key', 444 + description: 'The Record Key.', 445 + maxLength: 512, 446 + }, 447 + validate: { 448 + type: 'boolean', 449 + description: 450 + "Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it, or leave unset to validate only for known Lexicons.", 451 + }, 452 + record: { 453 + type: 'unknown', 454 + description: 'The record itself. Must contain a $type field.', 455 + }, 456 + swapCommit: { 457 + type: 'string', 458 + format: 'cid', 459 + description: 460 + 'Compare and swap with the previous commit by CID.', 461 + }, 462 + }, 463 + }, 464 + }, 465 + output: { 466 + encoding: 'application/json', 467 + schema: { 468 + type: 'object', 469 + required: ['uri', 'cid'], 470 + properties: { 471 + uri: { 472 + type: 'string', 473 + format: 'at-uri', 474 + }, 475 + cid: { 476 + type: 'string', 477 + format: 'cid', 478 + }, 479 + commit: { 480 + type: 'ref', 481 + ref: 'lex:com.atproto.repo.defs#commitMeta', 482 + }, 483 + validationStatus: { 484 + type: 'string', 485 + knownValues: ['valid', 'unknown'], 486 + }, 487 + }, 488 + }, 489 + }, 490 + errors: [ 491 + { 492 + name: 'InvalidSwap', 493 + description: 494 + "Indicates that 'swapCommit' didn't match current repo commit.", 495 + }, 496 + ], 497 + }, 498 + }, 499 + }, 500 + ComAtprotoRepoDefs: { 501 + lexicon: 1, 502 + id: 'com.atproto.repo.defs', 503 + defs: { 504 + commitMeta: { 505 + type: 'object', 506 + required: ['cid', 'rev'], 507 + properties: { 508 + cid: { 509 + type: 'string', 510 + format: 'cid', 511 + }, 512 + rev: { 513 + type: 'string', 514 + format: 'tid', 515 + }, 516 + }, 517 + }, 518 + }, 519 + }, 520 + ComAtprotoRepoDeleteRecord: { 521 + lexicon: 1, 522 + id: 'com.atproto.repo.deleteRecord', 523 + defs: { 524 + main: { 525 + type: 'procedure', 526 + description: 527 + "Delete a repository record, or ensure it doesn't exist. Requires auth, implemented by PDS.", 528 + input: { 529 + encoding: 'application/json', 530 + schema: { 531 + type: 'object', 532 + required: ['repo', 'collection', 'rkey'], 533 + properties: { 534 + repo: { 535 + type: 'string', 536 + format: 'at-identifier', 537 + description: 538 + 'The handle or DID of the repo (aka, current account).', 539 + }, 540 + collection: { 541 + type: 'string', 542 + format: 'nsid', 543 + description: 'The NSID of the record collection.', 544 + }, 545 + rkey: { 546 + type: 'string', 547 + format: 'record-key', 548 + description: 'The Record Key.', 549 + }, 550 + swapRecord: { 551 + type: 'string', 552 + format: 'cid', 553 + description: 554 + 'Compare and swap with the previous record by CID.', 555 + }, 556 + swapCommit: { 557 + type: 'string', 558 + format: 'cid', 559 + description: 560 + 'Compare and swap with the previous commit by CID.', 561 + }, 562 + }, 563 + }, 564 + }, 565 + output: { 566 + encoding: 'application/json', 567 + schema: { 568 + type: 'object', 569 + properties: { 570 + commit: { 571 + type: 'ref', 572 + ref: 'lex:com.atproto.repo.defs#commitMeta', 573 + }, 574 + }, 575 + }, 576 + }, 577 + errors: [ 578 + { 579 + name: 'InvalidSwap', 580 + }, 581 + ], 582 + }, 583 + }, 584 + }, 585 + ComAtprotoRepoGetRecord: { 586 + lexicon: 1, 587 + id: 'com.atproto.repo.getRecord', 588 + defs: { 589 + main: { 590 + type: 'query', 591 + description: 592 + 'Get a single record from a repository. Does not require auth.', 593 + parameters: { 594 + type: 'params', 595 + required: ['repo', 'collection', 'rkey'], 596 + properties: { 597 + repo: { 598 + type: 'string', 599 + format: 'at-identifier', 600 + description: 'The handle or DID of the repo.', 601 + }, 602 + collection: { 603 + type: 'string', 604 + format: 'nsid', 605 + description: 'The NSID of the record collection.', 606 + }, 607 + rkey: { 608 + type: 'string', 609 + description: 'The Record Key.', 610 + format: 'record-key', 611 + }, 612 + cid: { 613 + type: 'string', 614 + format: 'cid', 615 + description: 616 + 'The CID of the version of the record. If not specified, then return the most recent version.', 617 + }, 618 + }, 619 + }, 620 + output: { 621 + encoding: 'application/json', 622 + schema: { 623 + type: 'object', 624 + required: ['uri', 'value'], 625 + properties: { 626 + uri: { 627 + type: 'string', 628 + format: 'at-uri', 629 + }, 630 + cid: { 631 + type: 'string', 632 + format: 'cid', 633 + }, 634 + value: { 635 + type: 'unknown', 636 + }, 637 + }, 638 + }, 639 + }, 640 + errors: [ 641 + { 642 + name: 'RecordNotFound', 643 + }, 644 + ], 645 + }, 646 + }, 647 + }, 648 + ComAtprotoRepoListRecords: { 649 + lexicon: 1, 650 + id: 'com.atproto.repo.listRecords', 651 + defs: { 652 + main: { 653 + type: 'query', 654 + description: 655 + 'List a range of records in a repository, matching a specific collection. Does not require auth.', 656 + parameters: { 657 + type: 'params', 658 + required: ['repo', 'collection'], 659 + properties: { 660 + repo: { 661 + type: 'string', 662 + format: 'at-identifier', 663 + description: 'The handle or DID of the repo.', 664 + }, 665 + collection: { 666 + type: 'string', 667 + format: 'nsid', 668 + description: 'The NSID of the record type.', 669 + }, 670 + limit: { 671 + type: 'integer', 672 + minimum: 1, 673 + maximum: 100, 674 + default: 50, 675 + description: 'The number of records to return.', 676 + }, 677 + cursor: { 678 + type: 'string', 679 + }, 680 + rkeyStart: { 681 + type: 'string', 682 + description: 683 + 'DEPRECATED: The lowest sort-ordered rkey to start from (exclusive)', 684 + }, 685 + rkeyEnd: { 686 + type: 'string', 687 + description: 688 + 'DEPRECATED: The highest sort-ordered rkey to stop at (exclusive)', 689 + }, 690 + reverse: { 691 + type: 'boolean', 692 + description: 'Flag to reverse the order of the returned records.', 693 + }, 694 + }, 695 + }, 696 + output: { 697 + encoding: 'application/json', 698 + schema: { 699 + type: 'object', 700 + required: ['records'], 701 + properties: { 702 + cursor: { 703 + type: 'string', 704 + }, 705 + records: { 706 + type: 'array', 707 + items: { 708 + type: 'ref', 709 + ref: 'lex:com.atproto.repo.listRecords#record', 710 + }, 711 + }, 712 + }, 713 + }, 714 + }, 715 + }, 716 + record: { 717 + type: 'object', 718 + required: ['uri', 'cid', 'value'], 719 + properties: { 720 + uri: { 721 + type: 'string', 722 + format: 'at-uri', 723 + }, 724 + cid: { 725 + type: 'string', 726 + format: 'cid', 727 + }, 728 + value: { 729 + type: 'unknown', 730 + }, 731 + }, 732 + }, 733 + }, 734 + }, 735 + ComAtprotoRepoPutRecord: { 736 + lexicon: 1, 737 + id: 'com.atproto.repo.putRecord', 738 + defs: { 739 + main: { 740 + type: 'procedure', 741 + description: 742 + 'Write a repository record, creating or updating it as needed. Requires auth, implemented by PDS.', 743 + input: { 744 + encoding: 'application/json', 745 + schema: { 746 + type: 'object', 747 + required: ['repo', 'collection', 'rkey', 'record'], 748 + nullable: ['swapRecord'], 749 + properties: { 750 + repo: { 751 + type: 'string', 752 + format: 'at-identifier', 753 + description: 754 + 'The handle or DID of the repo (aka, current account).', 755 + }, 756 + collection: { 757 + type: 'string', 758 + format: 'nsid', 759 + description: 'The NSID of the record collection.', 760 + }, 761 + rkey: { 762 + type: 'string', 763 + format: 'record-key', 764 + description: 'The Record Key.', 765 + maxLength: 512, 766 + }, 767 + validate: { 768 + type: 'boolean', 769 + description: 770 + "Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it, or leave unset to validate only for known Lexicons.", 771 + }, 772 + record: { 773 + type: 'unknown', 774 + description: 'The record to write.', 775 + }, 776 + swapRecord: { 777 + type: 'string', 778 + format: 'cid', 779 + description: 780 + 'Compare and swap with the previous record by CID. WARNING: nullable and optional field; may cause problems with golang implementation', 781 + }, 782 + swapCommit: { 783 + type: 'string', 784 + format: 'cid', 785 + description: 786 + 'Compare and swap with the previous commit by CID.', 787 + }, 788 + }, 789 + }, 790 + }, 791 + output: { 792 + encoding: 'application/json', 793 + schema: { 794 + type: 'object', 795 + required: ['uri', 'cid'], 796 + properties: { 797 + uri: { 798 + type: 'string', 799 + format: 'at-uri', 800 + }, 801 + cid: { 802 + type: 'string', 803 + format: 'cid', 804 + }, 805 + commit: { 806 + type: 'ref', 807 + ref: 'lex:com.atproto.repo.defs#commitMeta', 808 + }, 809 + validationStatus: { 810 + type: 'string', 811 + knownValues: ['valid', 'unknown'], 812 + }, 813 + }, 814 + }, 815 + }, 816 + errors: [ 817 + { 818 + name: 'InvalidSwap', 819 + }, 820 + ], 821 + }, 822 + }, 823 + }, 824 + ComAtprotoRepoStrongRef: { 825 + lexicon: 1, 826 + id: 'com.atproto.repo.strongRef', 827 + description: 'A URI with a content-hash fingerprint.', 828 + defs: { 829 + main: { 830 + type: 'object', 831 + required: ['uri', 'cid'], 832 + properties: { 833 + uri: { 834 + type: 'string', 835 + format: 'at-uri', 836 + }, 837 + cid: { 838 + type: 'string', 839 + format: 'cid', 840 + }, 841 + }, 842 + }, 843 + }, 844 + }, 845 + } as const satisfies Record<string, LexiconDoc> 846 + export const schemas = Object.values(schemaDict) satisfies LexiconDoc[] 847 + export const lexicons: Lexicons = new Lexicons(schemas) 848 + 849 + export function validate<T extends { $type: string }>( 850 + v: unknown, 851 + id: string, 852 + hash: string, 853 + requiredType: true, 854 + ): ValidationResult<T> 855 + export function validate<T extends { $type?: string }>( 856 + v: unknown, 857 + id: string, 858 + hash: string, 859 + requiredType?: false, 860 + ): ValidationResult<T> 861 + export function validate( 862 + v: unknown, 863 + id: string, 864 + hash: string, 865 + requiredType?: boolean, 866 + ): ValidationResult { 867 + return (requiredType ? is$typed : maybe$typed)(v, id, hash) 868 + ? lexicons.validate(`${id}#${hash}`, v) 869 + : { 870 + success: false, 871 + error: new ValidationError( 872 + `Must be an object with "${hash === 'main' ? id : `${id}#${hash}`}" $type property`, 873 + ), 874 + } 875 + } 876 + 877 + export const ids = { 878 + PubLeafletDocument: 'pub.leaflet.document', 879 + PubLeafletBlocksCode: 'pub.leaflet.blocks.code', 880 + PubLeafletBlocksHeader: 'pub.leaflet.blocks.header', 881 + PubLeafletBlocksImage: 'pub.leaflet.blocks.image', 882 + PubLeafletBlocksMath: 'pub.leaflet.blocks.math', 883 + PubLeafletBlocksText: 'pub.leaflet.blocks.text', 884 + PubLeafletBlocksUnorderedList: 'pub.leaflet.blocks.unorderedList', 885 + PubLeafletBlocksWebsite: 'pub.leaflet.blocks.website', 886 + PubLeafletPagesLinearDocument: 'pub.leaflet.pages.linearDocument', 887 + PubLeafletRichtextFacet: 'pub.leaflet.richtext.facet', 888 + ComAtprotoRepoCreateRecord: 'com.atproto.repo.createRecord', 889 + ComAtprotoRepoDefs: 'com.atproto.repo.defs', 890 + ComAtprotoRepoDeleteRecord: 'com.atproto.repo.deleteRecord', 891 + ComAtprotoRepoGetRecord: 'com.atproto.repo.getRecord', 892 + ComAtprotoRepoListRecords: 'com.atproto.repo.listRecords', 893 + ComAtprotoRepoPutRecord: 'com.atproto.repo.putRecord', 894 + ComAtprotoRepoStrongRef: 'com.atproto.repo.strongRef', 895 + } as const
+68
src/leaflet/lexicons/types/com/atproto/repo/createRecord.ts
··· 1 + /** 2 + * GENERATED CODE - DO NOT MODIFY 3 + */ 4 + import { HeadersMap, XRPCError } from '@atproto/xrpc' 5 + import { type ValidationResult, BlobRef } from '@atproto/lexicon' 6 + import { CID } from 'multiformats/cid' 7 + import { validate as _validate } from '../../../../lexicons' 8 + import { 9 + type $Typed, 10 + is$typed as _is$typed, 11 + type OmitKey, 12 + } from '../../../../util' 13 + import type * as ComAtprotoRepoDefs from './defs.js' 14 + 15 + const is$typed = _is$typed, 16 + validate = _validate 17 + const id = 'com.atproto.repo.createRecord' 18 + 19 + export type QueryParams = {} 20 + 21 + export interface InputSchema { 22 + /** The handle or DID of the repo (aka, current account). */ 23 + repo: string 24 + /** The NSID of the record collection. */ 25 + collection: string 26 + /** The Record Key. */ 27 + rkey?: string 28 + /** Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it, or leave unset to validate only for known Lexicons. */ 29 + validate?: boolean 30 + /** The record itself. Must contain a $type field. */ 31 + record: { [_ in string]: unknown } 32 + /** Compare and swap with the previous commit by CID. */ 33 + swapCommit?: string 34 + } 35 + 36 + export interface OutputSchema { 37 + uri: string 38 + cid: string 39 + commit?: ComAtprotoRepoDefs.CommitMeta 40 + validationStatus?: 'valid' | 'unknown' | (string & {}) 41 + } 42 + 43 + export interface CallOptions { 44 + signal?: AbortSignal 45 + headers?: HeadersMap 46 + qp?: QueryParams 47 + encoding?: 'application/json' 48 + } 49 + 50 + export interface Response { 51 + success: boolean 52 + headers: HeadersMap 53 + data: OutputSchema 54 + } 55 + 56 + export class InvalidSwapError extends XRPCError { 57 + constructor(src: XRPCError) { 58 + super(src.status, src.error, src.message, src.headers, { cause: src }) 59 + } 60 + } 61 + 62 + export function toKnownErr(e: any) { 63 + if (e instanceof XRPCError) { 64 + if (e.error === 'InvalidSwap') return new InvalidSwapError(e) 65 + } 66 + 67 + return e 68 + }
+31
src/leaflet/lexicons/types/com/atproto/repo/defs.ts
··· 1 + /** 2 + * GENERATED CODE - DO NOT MODIFY 3 + */ 4 + import { type ValidationResult, BlobRef } from '@atproto/lexicon' 5 + import { CID } from 'multiformats/cid' 6 + import { validate as _validate } from '../../../../lexicons' 7 + import { 8 + type $Typed, 9 + is$typed as _is$typed, 10 + type OmitKey, 11 + } from '../../../../util' 12 + 13 + const is$typed = _is$typed, 14 + validate = _validate 15 + const id = 'com.atproto.repo.defs' 16 + 17 + export interface CommitMeta { 18 + $type?: 'com.atproto.repo.defs#commitMeta' 19 + cid: string 20 + rev: string 21 + } 22 + 23 + const hashCommitMeta = 'commitMeta' 24 + 25 + export function isCommitMeta<V>(v: V) { 26 + return is$typed(v, id, hashCommitMeta) 27 + } 28 + 29 + export function validateCommitMeta<V>(v: V) { 30 + return validate<CommitMeta & V>(v, id, hashCommitMeta) 31 + }
+63
src/leaflet/lexicons/types/com/atproto/repo/deleteRecord.ts
··· 1 + /** 2 + * GENERATED CODE - DO NOT MODIFY 3 + */ 4 + import { HeadersMap, XRPCError } from '@atproto/xrpc' 5 + import { type ValidationResult, BlobRef } from '@atproto/lexicon' 6 + import { CID } from 'multiformats/cid' 7 + import { validate as _validate } from '../../../../lexicons' 8 + import { 9 + type $Typed, 10 + is$typed as _is$typed, 11 + type OmitKey, 12 + } from '../../../../util' 13 + import type * as ComAtprotoRepoDefs from './defs.js' 14 + 15 + const is$typed = _is$typed, 16 + validate = _validate 17 + const id = 'com.atproto.repo.deleteRecord' 18 + 19 + export type QueryParams = {} 20 + 21 + export interface InputSchema { 22 + /** The handle or DID of the repo (aka, current account). */ 23 + repo: string 24 + /** The NSID of the record collection. */ 25 + collection: string 26 + /** The Record Key. */ 27 + rkey: string 28 + /** Compare and swap with the previous record by CID. */ 29 + swapRecord?: string 30 + /** Compare and swap with the previous commit by CID. */ 31 + swapCommit?: string 32 + } 33 + 34 + export interface OutputSchema { 35 + commit?: ComAtprotoRepoDefs.CommitMeta 36 + } 37 + 38 + export interface CallOptions { 39 + signal?: AbortSignal 40 + headers?: HeadersMap 41 + qp?: QueryParams 42 + encoding?: 'application/json' 43 + } 44 + 45 + export interface Response { 46 + success: boolean 47 + headers: HeadersMap 48 + data: OutputSchema 49 + } 50 + 51 + export class InvalidSwapError extends XRPCError { 52 + constructor(src: XRPCError) { 53 + super(src.status, src.error, src.message, src.headers, { cause: src }) 54 + } 55 + } 56 + 57 + export function toKnownErr(e: any) { 58 + if (e instanceof XRPCError) { 59 + if (e.error === 'InvalidSwap') return new InvalidSwapError(e) 60 + } 61 + 62 + return e 63 + }
+59
src/leaflet/lexicons/types/com/atproto/repo/getRecord.ts
··· 1 + /** 2 + * GENERATED CODE - DO NOT MODIFY 3 + */ 4 + import { HeadersMap, XRPCError } from '@atproto/xrpc' 5 + import { type ValidationResult, BlobRef } from '@atproto/lexicon' 6 + import { CID } from 'multiformats/cid' 7 + import { validate as _validate } from '../../../../lexicons' 8 + import { 9 + type $Typed, 10 + is$typed as _is$typed, 11 + type OmitKey, 12 + } from '../../../../util' 13 + 14 + const is$typed = _is$typed, 15 + validate = _validate 16 + const id = 'com.atproto.repo.getRecord' 17 + 18 + export type QueryParams = { 19 + /** The handle or DID of the repo. */ 20 + repo: string 21 + /** The NSID of the record collection. */ 22 + collection: string 23 + /** The Record Key. */ 24 + rkey: string 25 + /** The CID of the version of the record. If not specified, then return the most recent version. */ 26 + cid?: string 27 + } 28 + export type InputSchema = undefined 29 + 30 + export interface OutputSchema { 31 + uri: string 32 + cid?: string 33 + value: { [_ in string]: unknown } 34 + } 35 + 36 + export interface CallOptions { 37 + signal?: AbortSignal 38 + headers?: HeadersMap 39 + } 40 + 41 + export interface Response { 42 + success: boolean 43 + headers: HeadersMap 44 + data: OutputSchema 45 + } 46 + 47 + export class RecordNotFoundError extends XRPCError { 48 + constructor(src: XRPCError) { 49 + super(src.status, src.error, src.message, src.headers, { cause: src }) 50 + } 51 + } 52 + 53 + export function toKnownErr(e: any) { 54 + if (e instanceof XRPCError) { 55 + if (e.error === 'RecordNotFound') return new RecordNotFoundError(e) 56 + } 57 + 58 + return e 59 + }
+70
src/leaflet/lexicons/types/com/atproto/repo/listRecords.ts
··· 1 + /** 2 + * GENERATED CODE - DO NOT MODIFY 3 + */ 4 + import { HeadersMap, XRPCError } from '@atproto/xrpc' 5 + import { type ValidationResult, BlobRef } from '@atproto/lexicon' 6 + import { CID } from 'multiformats/cid' 7 + import { validate as _validate } from '../../../../lexicons' 8 + import { 9 + type $Typed, 10 + is$typed as _is$typed, 11 + type OmitKey, 12 + } from '../../../../util' 13 + 14 + const is$typed = _is$typed, 15 + validate = _validate 16 + const id = 'com.atproto.repo.listRecords' 17 + 18 + export type QueryParams = { 19 + /** The handle or DID of the repo. */ 20 + repo: string 21 + /** The NSID of the record type. */ 22 + collection: string 23 + /** The number of records to return. */ 24 + limit?: number 25 + cursor?: string 26 + /** DEPRECATED: The lowest sort-ordered rkey to start from (exclusive) */ 27 + rkeyStart?: string 28 + /** DEPRECATED: The highest sort-ordered rkey to stop at (exclusive) */ 29 + rkeyEnd?: string 30 + /** Flag to reverse the order of the returned records. */ 31 + reverse?: boolean 32 + } 33 + export type InputSchema = undefined 34 + 35 + export interface OutputSchema { 36 + cursor?: string 37 + records: Record[] 38 + } 39 + 40 + export interface CallOptions { 41 + signal?: AbortSignal 42 + headers?: HeadersMap 43 + } 44 + 45 + export interface Response { 46 + success: boolean 47 + headers: HeadersMap 48 + data: OutputSchema 49 + } 50 + 51 + export function toKnownErr(e: any) { 52 + return e 53 + } 54 + 55 + export interface Record { 56 + $type?: 'com.atproto.repo.listRecords#record' 57 + uri: string 58 + cid: string 59 + value: { [_ in string]: unknown } 60 + } 61 + 62 + const hashRecord = 'record' 63 + 64 + export function isRecord<V>(v: V) { 65 + return is$typed(v, id, hashRecord) 66 + } 67 + 68 + export function validateRecord<V>(v: V) { 69 + return validate<Record & V>(v, id, hashRecord) 70 + }
+70
src/leaflet/lexicons/types/com/atproto/repo/putRecord.ts
··· 1 + /** 2 + * GENERATED CODE - DO NOT MODIFY 3 + */ 4 + import { HeadersMap, XRPCError } from '@atproto/xrpc' 5 + import { type ValidationResult, BlobRef } from '@atproto/lexicon' 6 + import { CID } from 'multiformats/cid' 7 + import { validate as _validate } from '../../../../lexicons' 8 + import { 9 + type $Typed, 10 + is$typed as _is$typed, 11 + type OmitKey, 12 + } from '../../../../util' 13 + import type * as ComAtprotoRepoDefs from './defs.js' 14 + 15 + const is$typed = _is$typed, 16 + validate = _validate 17 + const id = 'com.atproto.repo.putRecord' 18 + 19 + export type QueryParams = {} 20 + 21 + export interface InputSchema { 22 + /** The handle or DID of the repo (aka, current account). */ 23 + repo: string 24 + /** The NSID of the record collection. */ 25 + collection: string 26 + /** The Record Key. */ 27 + rkey: string 28 + /** Can be set to 'false' to skip Lexicon schema validation of record data, 'true' to require it, or leave unset to validate only for known Lexicons. */ 29 + validate?: boolean 30 + /** The record to write. */ 31 + record: { [_ in string]: unknown } 32 + /** Compare and swap with the previous record by CID. WARNING: nullable and optional field; may cause problems with golang implementation */ 33 + swapRecord?: string | null 34 + /** Compare and swap with the previous commit by CID. */ 35 + swapCommit?: string 36 + } 37 + 38 + export interface OutputSchema { 39 + uri: string 40 + cid: string 41 + commit?: ComAtprotoRepoDefs.CommitMeta 42 + validationStatus?: 'valid' | 'unknown' | (string & {}) 43 + } 44 + 45 + export interface CallOptions { 46 + signal?: AbortSignal 47 + headers?: HeadersMap 48 + qp?: QueryParams 49 + encoding?: 'application/json' 50 + } 51 + 52 + export interface Response { 53 + success: boolean 54 + headers: HeadersMap 55 + data: OutputSchema 56 + } 57 + 58 + export class InvalidSwapError extends XRPCError { 59 + constructor(src: XRPCError) { 60 + super(src.status, src.error, src.message, src.headers, { cause: src }) 61 + } 62 + } 63 + 64 + export function toKnownErr(e: any) { 65 + if (e instanceof XRPCError) { 66 + if (e.error === 'InvalidSwap') return new InvalidSwapError(e) 67 + } 68 + 69 + return e 70 + }
+1 -1
src/types.ts
··· 1 1 import type { Agent } from "@atproto/api"; 2 - import type { PubLeafletRichtextFacet } from "./__generated__/lexicons/index.js"; 2 + import type { PubLeafletRichtextFacet } from "./leaflet/lexicons/index.js"; 3 3 4 4 export interface LeafletLoaderOptions { 5 5 /**
+1 -1
src/utils.ts
··· 6 6 type PubLeafletDocument, 7 7 PubLeafletPagesLinearDocument, 8 8 PubLeafletRichtextFacet, 9 - } from "./__generated__/lexicons/index.js"; 9 + } from "./leaflet/lexicons/index.js"; 10 10 import { LiveLoaderError } from "./leaflet-live-loader.js"; 11 11 import type { 12 12 Facet,
+6 -4
tsconfig.json
··· 6 6 "lib": ["es2022"], 7 7 "target": "es2022", 8 8 "allowJs": true, 9 - "resolveJsonModule": true, 10 9 "moduleDetection": "force", 11 10 "isolatedModules": true, 12 - "verbatimModuleSyntax": true, 13 11 "strict": true, 14 12 "noUncheckedIndexedAccess": true, 15 13 "noImplicitOverride": true, 16 - "module": "NodeNext", 14 + "module": "esnext", 15 + "baseUrl": "./src", 17 16 "outDir": "dist", 17 + "moduleResolution": "bundler", 18 18 "rootDir": "src", 19 19 "sourceMap": true, 20 20 "declaration": true 21 - } 21 + }, 22 + "include": ["./src"], 23 + "exclude": ["node_modules", "dist"] 22 24 }