a tool for shared writing and social publishing

update lexicons

+30 -197
+3 -16
appview/index.ts
··· 4 4 const idResolver = new IdResolver(); 5 5 import { Firehose, MemoryRunner } from "@atproto/sync"; 6 6 import { ids } from "lexicons/api/lexicons"; 7 - import { 8 - PubLeafletDocument, 9 - PubLeafletPost, 10 - PubLeafletPublication, 11 - } from "lexicons/api"; 7 + import { PubLeafletDocument, PubLeafletPublication } from "lexicons/api"; 12 8 import { AtUri } from "@atproto/syntax"; 13 9 import { writeFile, readFile } from "fs/promises"; 14 10 ··· 35 31 excludeIdentity: true, 36 32 runner, 37 33 idResolver, 38 - filterCollections: [ 39 - ids.PubLeafletDocument, 40 - ids.PubLeafletPublication, 41 - ids.PubLeafletPost, 42 - ], 34 + filterCollections: [ids.PubLeafletDocument, ids.PubLeafletPublication], 43 35 handleEvent: async (evt) => { 44 36 if ( 45 37 evt.event == "account" || ··· 84 76 uri: evt.uri.toString(), 85 77 identity_did: evt.did, 86 78 name: record.value.name, 79 + record: record.value as Json, 87 80 }); 88 81 } 89 82 if (evt.event === "delete") { ··· 91 84 .from("publications") 92 85 .delete() 93 86 .eq("uri", evt.uri.toString()); 94 - } 95 - } 96 - if (evt.collection === ids.PubLeafletPost) { 97 - if (evt.event === "create" || evt.event === "update") { 98 - let record = PubLeafletPost.validateRecord(evt.record); 99 - if (!record.success) return; 100 87 } 101 88 } 102 89 },
-65
lexicons/api/index.ts
··· 6 6 import { CID } from 'multiformats/cid' 7 7 import { OmitKey, Un$Typed } from './util' 8 8 import * as PubLeafletDocument from './types/pub/leaflet/document' 9 - import * as PubLeafletPost from './types/pub/leaflet/post' 10 9 import * as PubLeafletPublication from './types/pub/leaflet/publication' 11 10 import * as PubLeafletBlocksHeader from './types/pub/leaflet/blocks/header' 12 11 import * as PubLeafletBlocksImage from './types/pub/leaflet/blocks/image' ··· 27 26 import * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob' 28 27 29 28 export * as PubLeafletDocument from './types/pub/leaflet/document' 30 - export * as PubLeafletPost from './types/pub/leaflet/post' 31 29 export * as PubLeafletPublication from './types/pub/leaflet/publication' 32 30 export * as PubLeafletBlocksHeader from './types/pub/leaflet/blocks/header' 33 31 export * as PubLeafletBlocksImage from './types/pub/leaflet/blocks/image' ··· 84 82 export class PubLeafletNS { 85 83 _client: XrpcClient 86 84 document: DocumentRecord 87 - post: PostRecord 88 85 publication: PublicationRecord 89 86 blocks: PubLeafletBlocksNS 90 87 pages: PubLeafletPagesNS ··· 94 91 this.blocks = new PubLeafletBlocksNS(client) 95 92 this.pages = new PubLeafletPagesNS(client) 96 93 this.document = new DocumentRecord(client) 97 - this.post = new PostRecord(client) 98 94 this.publication = new PublicationRecord(client) 99 95 } 100 96 } ··· 171 167 'com.atproto.repo.deleteRecord', 172 168 undefined, 173 169 { collection: 'pub.leaflet.document', ...params }, 174 - { headers }, 175 - ) 176 - } 177 - } 178 - 179 - export class PostRecord { 180 - _client: XrpcClient 181 - 182 - constructor(client: XrpcClient) { 183 - this._client = client 184 - } 185 - 186 - async list( 187 - params: OmitKey<ComAtprotoRepoListRecords.QueryParams, 'collection'>, 188 - ): Promise<{ 189 - cursor?: string 190 - records: { uri: string; value: PubLeafletPost.Record }[] 191 - }> { 192 - const res = await this._client.call('com.atproto.repo.listRecords', { 193 - collection: 'pub.leaflet.post', 194 - ...params, 195 - }) 196 - return res.data 197 - } 198 - 199 - async get( 200 - params: OmitKey<ComAtprotoRepoGetRecord.QueryParams, 'collection'>, 201 - ): Promise<{ uri: string; cid: string; value: PubLeafletPost.Record }> { 202 - const res = await this._client.call('com.atproto.repo.getRecord', { 203 - collection: 'pub.leaflet.post', 204 - ...params, 205 - }) 206 - return res.data 207 - } 208 - 209 - async create( 210 - params: OmitKey< 211 - ComAtprotoRepoCreateRecord.InputSchema, 212 - 'collection' | 'record' 213 - >, 214 - record: Un$Typed<PubLeafletPost.Record>, 215 - headers?: Record<string, string>, 216 - ): Promise<{ uri: string; cid: string }> { 217 - const collection = 'pub.leaflet.post' 218 - const res = await this._client.call( 219 - 'com.atproto.repo.createRecord', 220 - undefined, 221 - { collection, ...params, record: { ...record, $type: collection } }, 222 - { encoding: 'application/json', headers }, 223 - ) 224 - return res.data 225 - } 226 - 227 - async delete( 228 - params: OmitKey<ComAtprotoRepoDeleteRecord.InputSchema, 'collection'>, 229 - headers?: Record<string, string>, 230 - ): Promise<void> { 231 - await this._client.call( 232 - 'com.atproto.repo.deleteRecord', 233 - undefined, 234 - { collection: 'pub.leaflet.post', ...params }, 235 170 { headers }, 236 171 ) 237 172 }
+11 -31
lexicons/api/lexicons.ts
··· 26 26 properties: { 27 27 title: { 28 28 type: 'string', 29 - maxLength: 128, 29 + maxLength: 1280, 30 + maxGraphemes: 128, 31 + }, 32 + description: { 33 + type: 'string', 34 + maxLength: 3000, 35 + maxGraphemes: 300, 30 36 }, 31 37 publishedAt: { 32 38 type: 'string', ··· 52 58 }, 53 59 }, 54 60 }, 55 - PubLeafletPost: { 56 - lexicon: 1, 57 - id: 'pub.leaflet.post', 58 - defs: { 59 - main: { 60 - type: 'record', 61 - key: 'tid', 62 - description: 'Record putting a post in a document', 63 - record: { 64 - type: 'object', 65 - required: ['post', 'publishedAt'], 66 - properties: { 67 - publication: { 68 - type: 'string', 69 - format: 'at-uri', 70 - }, 71 - post: { 72 - type: 'ref', 73 - ref: 'lex:com.atproto.repo.strongRef', 74 - }, 75 - publishedAt: { 76 - type: 'string', 77 - format: 'datetime', 78 - }, 79 - }, 80 - }, 81 - }, 82 - }, 83 - }, 84 61 PubLeafletPublication: { 85 62 lexicon: 1, 86 63 id: 'pub.leaflet.publication', ··· 96 73 name: { 97 74 type: 'string', 98 75 maxLength: 2000, 76 + }, 77 + domain: { 78 + type: 'string', 79 + format: 'uri', 99 80 }, 100 81 description: { 101 82 type: 'string', ··· 1213 1194 1214 1195 export const ids = { 1215 1196 PubLeafletDocument: 'pub.leaflet.document', 1216 - PubLeafletPost: 'pub.leaflet.post', 1217 1197 PubLeafletPublication: 'pub.leaflet.publication', 1218 1198 PubLeafletBlocksHeader: 'pub.leaflet.blocks.header', 1219 1199 PubLeafletBlocksImage: 'pub.leaflet.blocks.image',
+1
lexicons/api/types/pub/leaflet/document.ts
··· 14 14 export interface Record { 15 15 $type: 'pub.leaflet.document' 16 16 title: string 17 + description?: string 17 18 publishedAt?: string 18 19 publication: string 19 20 author: string
-30
lexicons/api/types/pub/leaflet/post.ts
··· 1 - /** 2 - * GENERATED CODE - DO NOT MODIFY 3 - */ 4 - import { ValidationResult, BlobRef } from '@atproto/lexicon' 5 - import { CID } from 'multiformats/cid' 6 - import { validate as _validate } from '../../../lexicons' 7 - import { $Typed, is$typed as _is$typed, OmitKey } from '../../../util' 8 - import type * as ComAtprotoRepoStrongRef from '../../com/atproto/repo/strongRef' 9 - 10 - const is$typed = _is$typed, 11 - validate = _validate 12 - const id = 'pub.leaflet.post' 13 - 14 - export interface Record { 15 - $type: 'pub.leaflet.post' 16 - publication?: string 17 - post: ComAtprotoRepoStrongRef.Main 18 - publishedAt: string 19 - [k: string]: unknown 20 - } 21 - 22 - const hashRecord = 'main' 23 - 24 - export function isRecord<V>(v: V) { 25 - return is$typed(v, id, hashRecord) 26 - } 27 - 28 - export function validateRecord<V>(v: V) { 29 - return validate<Record & V>(v, id, hashRecord, true) 30 - }
+1
lexicons/api/types/pub/leaflet/publication.ts
··· 13 13 export interface Record { 14 14 $type: 'pub.leaflet.publication' 15 15 name: string 16 + domain?: string 16 17 description?: string 17 18 icon?: BlobRef 18 19 [k: string]: unknown
+7 -1
lexicons/pub/leaflet/document.json
··· 19 19 "properties": { 20 20 "title": { 21 21 "type": "string", 22 - "maxLength": 128 22 + "maxLength": 1280, 23 + "maxGraphemes": 128 24 + }, 25 + "description": { 26 + "type": "string", 27 + "maxLength": 3000, 28 + "maxGraphemes": 300 23 29 }, 24 30 "publishedAt": { 25 31 "type": "string",
-32
lexicons/pub/leaflet/post.json
··· 1 - { 2 - "lexicon": 1, 3 - "id": "pub.leaflet.post", 4 - "defs": { 5 - "main": { 6 - "type": "record", 7 - "key": "tid", 8 - "description": "Record putting a post in a document", 9 - "record": { 10 - "type": "object", 11 - "required": [ 12 - "post", 13 - "publishedAt" 14 - ], 15 - "properties": { 16 - "publication": { 17 - "type": "string", 18 - "format": "at-uri" 19 - }, 20 - "post": { 21 - "type": "ref", 22 - "ref": "com.atproto.repo.strongRef" 23 - }, 24 - "publishedAt": { 25 - "type": "string", 26 - "format": "datetime" 27 - } 28 - } 29 - } 30 - } 31 - } 32 - }
+4
lexicons/pub/leaflet/publication.json
··· 16 16 "type": "string", 17 17 "maxLength": 2000 18 18 }, 19 + "domain": { 20 + "type": "string", 21 + "format": "uri" 22 + }, 19 23 "description": { 20 24 "type": "string", 21 25 "maxLength": 2000
+2 -1
lexicons/src/document.ts
··· 15 15 type: "object", 16 16 required: ["pages", "author", "title", "publication"], 17 17 properties: { 18 - title: { type: "string", maxLength: 128 }, 18 + title: { type: "string", maxLength: 1280, maxGraphemes: 128 }, 19 + description: { type: "string", maxLength: 3000, maxGraphemes: 300 }, 19 20 publishedAt: { type: "string", format: "datetime" }, 20 21 publication: { type: "string", format: "at-uri" }, 21 22 author: { type: "string", format: "at-identifier" },
+1 -21
lexicons/src/publication.ts
··· 13 13 required: ["name"], 14 14 properties: { 15 15 name: { type: "string", maxLength: 2000 }, 16 + domain: { type: "string", format: "uri" }, 16 17 description: { type: "string", maxLength: 2000 }, 17 18 icon: { type: "blob", accept: ["image/*"], maxSize: 1000000 }, 18 19 }, ··· 20 21 }, 21 22 }, 22 23 }; 23 - 24 - export const PubLeafletPublicationPost: LexiconDoc = { 25 - lexicon: 1, 26 - id: "pub.leaflet.post", 27 - defs: { 28 - main: { 29 - type: "record", 30 - key: "tid", 31 - description: "Record putting a post in a document", 32 - record: { 33 - type: "object", 34 - required: ["post", "publishedAt"], 35 - properties: { 36 - publication: { type: "string", format: "at-uri" }, 37 - post: { type: "ref", ref: "com.atproto.repo.strongRef" }, 38 - publishedAt: { type: "string", format: "datetime" }, 39 - }, 40 - }, 41 - }, 42 - }, 43 - };