a tool for shared writing and social publishing

reorganize lexicons folder

+331 -417
+1 -1
actions/createPublication.ts
··· 1 1 "use server"; 2 2 import { TID } from "@atproto/common"; 3 - import { AtpBaseClient } from "lexicons/src"; 3 + import { AtpBaseClient } from "lexicons/api"; 4 4 import { createOauthClient } from "src/atproto-oauth"; 5 5 import { getIdentityData } from "actions/getIdentityData"; 6 6 import { supabaseServerClient } from "supabase/serverClient";
+3 -3
actions/publishToPublication.ts
··· 10 10 PubLeafletBlocksText, 11 11 PubLeafletDocument, 12 12 PubLeafletPagesLinearDocument, 13 - } from "lexicons/src"; 13 + } from "lexicons/api"; 14 14 import { Block } from "components/Blocks/Block"; 15 15 import { TID } from "@atproto/common"; 16 16 import { supabaseServerClient } from "supabase/serverClient"; ··· 18 18 import { Fact } from "src/replicache"; 19 19 import { Attributes } from "src/replicache/attributes"; 20 20 import { YJSFragmentToString } from "components/Blocks/TextBlock/RenderYJSFragment"; 21 - import { ids } from "lexicons/src/lexicons"; 22 - import { OmitKey } from "lexicons/src/util"; 21 + import { ids } from "lexicons/api/lexicons"; 22 + import { OmitKey } from "lexicons/api/util"; 23 23 import { BlobRef } from "@atproto/lexicon"; 24 24 import { IdResolver } from "@atproto/identity"; 25 25 import { AtUri } from "@atproto/syntax";
+1 -1
app/lish/PostList.tsx
··· 2 2 import Link from "next/link"; 3 3 import { Separator } from "components/Layout"; 4 4 import { Json } from "supabase/database.types"; 5 - import { PubLeafletDocument } from "lexicons/src"; 5 + import { PubLeafletDocument } from "lexicons/api"; 6 6 import { ButtonPrimary } from "components/Buttons"; 7 7 import { useIdentityData } from "components/IdentityProvider"; 8 8 import { usePublicationRelationship } from "./[handle]/[publication]/usePublicationRelationship";
+2 -2
app/lish/[handle]/[publication]/[rkey]/page.tsx
··· 3 3 import { getPds, IdResolver } from "@atproto/identity"; 4 4 import { supabaseServerClient } from "supabase/serverClient"; 5 5 import { AtUri } from "@atproto/syntax"; 6 - import { ids } from "lexicons/src/lexicons"; 6 + import { ids } from "lexicons/api/lexicons"; 7 7 import { 8 8 PubLeafletBlocksHeader, 9 9 PubLeafletBlocksImage, 10 10 PubLeafletBlocksText, 11 11 PubLeafletDocument, 12 12 PubLeafletPagesLinearDocument, 13 - } from "lexicons/src"; 13 + } from "lexicons/api"; 14 14 import { Metadata } from "next"; 15 15 16 16 const idResolver = new IdResolver();
+1 -1
app/lish/[handle]/[publication]/page.tsx
··· 7 7 AtpBaseClient, 8 8 PubLeafletDocument, 9 9 PubLeafletPublication, 10 - } from "lexicons/src"; 10 + } from "lexicons/api"; 11 11 import { CallToActionButton } from "./CallToActionButton"; 12 12 import { Metadata } from "next"; 13 13
+1 -1
app/lish/page.tsx
··· 1 1 import { LishHome } from "./LishHome"; 2 2 import { createClient } from "@supabase/supabase-js"; 3 3 import { Database } from "supabase/database.types"; 4 - import { AtpBaseClient, PubLeafletPagesLinearDocument } from "lexicons/src"; 4 + import { AtpBaseClient, PubLeafletPagesLinearDocument } from "lexicons/api"; 5 5 import { CredentialSession } from "@atproto/api"; 6 6 import { createOauthClient } from "src/atproto-oauth"; 7 7 import { getIdentityData } from "actions/getIdentityData";
+2 -2
appview/index.ts
··· 3 3 import { IdResolver } from "@atproto/identity"; 4 4 const idResolver = new IdResolver(); 5 5 import { Firehose, MemoryRunner } from "@atproto/sync"; 6 - import { ids } from "lexicons/src/lexicons"; 6 + import { ids } from "lexicons/api/lexicons"; 7 7 import { 8 8 PubLeafletDocument, 9 9 PubLeafletPost, 10 10 PubLeafletPublication, 11 - } from "lexicons/src"; 11 + } from "lexicons/api"; 12 12 import { AtUri } from "@atproto/syntax"; 13 13 import { writeFile, readFile } from "fs/promises"; 14 14
+4 -15
components/Blocks/TextBlock/keymap.ts
··· 46 46 }, 47 47 "Ctrl-a": metaA(propsRef, repRef), 48 48 "Meta-a": metaA(propsRef, repRef), 49 - Tab: () => { 50 - return um.withUndoGroup(() => { 51 - if (useUIState.getState().selectedBlocks.length > 1) return false; 52 - if (!repRef.current || !propsRef.current.previousBlock) return false; 53 - indent( 54 - propsRef.current, 55 - propsRef.current.previousBlock, 56 - repRef.current, 57 - ); 58 - return true; 59 - }); 60 - }, 61 - "Shift-Tab": () => { 62 - return um.withUndoGroup(shifttab(propsRef, repRef)); 63 - }, 64 49 Escape: (_state, _dispatch, view) => { 65 50 view?.dom.blur(); 66 51 useUIState.setState(() => ({ ··· 395 380 396 381 let newEntityID = v7(); 397 382 let position: string; 383 + useUIState.getState().setSelectedBlock({ 384 + value: newEntityID, 385 + parent: propsRef.current.parent, 386 + }); 398 387 let asyncRun = async () => { 399 388 let blockType = 400 389 propsRef.current.type === "heading" && state.selection.anchor <= 2
+11 -10
components/Blocks/useBlockKeyboardHandlers.ts
··· 27 27 28 28 let isSelected = useUIState((s) => { 29 29 let selectedBlocks = s.selectedBlocks; 30 - return ( 31 - (!isTextBlock[props.type] || selectedBlocks.length > 1 || isLocked) && 32 - !!s.selectedBlocks.find((b) => b.value === props.entityID) 33 - ); 30 + return !!s.selectedBlocks.find((b) => b.value === props.entityID); 34 31 }); 35 32 36 33 useEffect(() => { ··· 53 50 54 51 let el = e.target as HTMLElement; 55 52 if ( 56 - el.tagName === "LABEL" || 57 - el.tagName === "INPUT" || 58 - el.tagName === "TEXTAREA" || 59 - el.contentEditable === "true" 53 + (el.tagName === "LABEL" || 54 + el.tagName === "INPUT" || 55 + el.tagName === "TEXTAREA" || 56 + el.contentEditable === "true") && 57 + !isTextBlock[props.type] 60 58 ) { 61 59 if ((el as HTMLInputElement).value !== "" || e.key === "Tab") return; 62 60 } ··· 89 87 }; 90 88 91 89 function Tab({ e, props, rep }: Args) { 92 - // if tab or shift tab & not a textBlock, indent or outdent 93 - if (isTextBlock[props.type]) return; 90 + // if tab or shift tab, indent or outdent 94 91 if (e.shiftKey) { 95 92 e.preventDefault(); 96 93 outdent(props, props.previousBlock, rep); ··· 104 101 if (args.e.ctrlKey || args.e.metaKey) ArrowDown(args); 105 102 } 106 103 function ArrowDown({ e, props }: Args) { 104 + if (isTextBlock[props.type]) return; 107 105 e.preventDefault(); 108 106 let nextBlock = props.nextBlock; 109 107 if (nextBlock && useUIState.getState().selectedBlocks.length <= 1) ··· 118 116 if (args.e.ctrlKey || args.e.metaKey) ArrowUp(args); 119 117 } 120 118 function ArrowUp({ e, props }: Args) { 119 + if (isTextBlock[props.type]) return; 121 120 e.preventDefault(); 122 121 let prevBlock = props.previousBlock; 123 122 if (prevBlock && useUIState.getState().selectedBlocks.length <= 1) { ··· 190 189 } 191 190 192 191 async function Enter({ e, props, rep, entity_set }: Args) { 192 + if (isTextBlock[props.type]) return; 193 193 let newEntityID = v7(); 194 194 let position; 195 195 let el = e.target as HTMLElement; ··· 279 279 } 280 280 281 281 function Escape({ e, props, areYouSure, setAreYouSure }: Args) { 282 + if (isTextBlock[props.type]) return; 282 283 e.preventDefault(); 283 284 if (areYouSure) { 284 285 setAreYouSure(false);
+3
components/ThemeManager/ThemeSetter.tsx
··· 543 543 e.currentTarget.value.length, 544 544 ); 545 545 }} 546 + onPaste={(e) => { 547 + console.log(e); 548 + }} 546 549 onKeyDown={(e) => { 547 550 if (e.key === "Enter") { 548 551 e.currentTarget.blur();
-62
lexicons/blocks.ts
··· 1 - import * as l from "./utils"; 2 - 3 - export const PubLeafletBlocksText = l.lexicon({ 4 - id: "pub.leaflet.blocks.text", 5 - defs: { 6 - main: l.object({ 7 - required: [], 8 - properties: { 9 - plaintext: l.string(), 10 - }, 11 - }), 12 - }, 13 - }); 14 - 15 - export const PubLeafletBlocksHeader = l.lexicon({ 16 - id: "pub.leaflet.blocks.header", 17 - defs: { 18 - main: l.object({ 19 - required: [], 20 - properties: { 21 - level: l.integer({ minimum: 1, maximum: 6 }), 22 - plaintext: l.string(), 23 - }, 24 - }), 25 - }, 26 - }); 27 - 28 - export const PubLeafletBlocksImage = l.lexicon({ 29 - id: "pub.leaflet.blocks.image", 30 - defs: { 31 - main: l.object({ 32 - required: ["image", "aspectRatio"], 33 - properties: { 34 - image: l.blob({ accept: ["image/*"], maxSize: 1000000 }), 35 - alt: { 36 - type: "string", 37 - description: "Alt text description of the image, for accessibility.", 38 - }, 39 - aspectRatio: { 40 - type: "ref", 41 - ref: "#aspectRatio", 42 - }, 43 - }, 44 - }), 45 - aspectRatio: l.object({ 46 - required: ["width", "height"], 47 - properties: { 48 - width: l.integer(), 49 - height: l.integer(), 50 - }, 51 - }), 52 - }, 53 - }); 54 - 55 - export const BlockLexicons = [ 56 - PubLeafletBlocksText, 57 - PubLeafletBlocksHeader, 58 - PubLeafletBlocksImage, 59 - ]; 60 - export const BlockUnion = l.union({ 61 - refs: BlockLexicons.map((lexicon) => lexicon.id), 62 - });
+14 -9
lexicons/build.ts
··· 1 - import * as PageLexicons from "./pages"; 2 - import { BlockLexicons } from "./blocks"; 3 - import { PubLeafletDocument } from "./document"; 4 - import * as PublicationLexicons from "./publication"; 1 + import * as PageLexicons from "./src/pages"; 2 + import { BlockLexicons } from "./src/blocks"; 3 + import { PubLeafletDocument } from "./src/document"; 4 + import * as PublicationLexicons from "./src/publication"; 5 5 6 6 import * as fs from "fs"; 7 7 import * as path from "path"; 8 - import { PublicKeyPage } from "twilio/lib/rest/accounts/v1/credential/publicKey"; 9 - const outdir = path.join("lexicons", "out"); 8 + 9 + const outdir = path.join("lexicons", "pub", "leaflet"); 10 10 11 - fs.rmSync(outdir, { recursive: true }); 12 - fs.mkdirSync(outdir); 11 + if (fs.existsSync(outdir)) { 12 + fs.rmSync(outdir, { recursive: true }); 13 + } 14 + fs.mkdirSync(outdir, { recursive: true }); 13 15 14 16 const lexicons = [ 15 17 PubLeafletDocument, ··· 20 22 21 23 // Write each lexicon to a file 22 24 lexicons.forEach((lexicon) => { 23 - const filename = path.join(outdir, lexicon.id.replace(/\./g, "_") + ".json"); 25 + let id = lexicon.id.split("."); 26 + let folder = path.join(outdir, ...id.slice(2, -1)); 27 + if (!fs.existsSync(folder)) fs.mkdirSync(folder, { recursive: true }); 28 + const filename = path.join(folder, id[id.length - 1] + ".json"); 24 29 fs.writeFileSync(filename, JSON.stringify(lexicon, null, 2)); 25 30 });
-26
lexicons/document.ts
··· 1 - import { PubLeafletPagesLinearDocument } from "./pages/LinearDocument"; 2 - import * as l from "./utils"; 3 - 4 - export const PubLeafletDocument = l.lexicon({ 5 - id: "pub.leaflet.document", 6 - revision: 1, 7 - description: "A lexicon for long form rich media documents", 8 - defs: { 9 - main: l.record({ 10 - key: "tid", 11 - description: "Record containing a document", 12 - record: l.object({ 13 - required: ["pages", "author", "title", "publication"], 14 - properties: { 15 - title: l.string({ maxLength: 128 }), 16 - publishedAt: l.string({ format: "datetime" }), 17 - publication: l.string({ format: "at-uri" }), 18 - author: l.string({ format: "at-identifier" }), 19 - pages: l.array({ 20 - items: l.union({ refs: [PubLeafletPagesLinearDocument.id] }), 21 - }), 22 - }, 23 - }), 24 - }), 25 - }, 26 - });
lexicons/out/pub_leaflet_blocks_header.json lexicons/pub/leaflet/blocks/header.json
+2 -1
lexicons/out/pub_leaflet_blocks_image.json lexicons/pub/leaflet/blocks/image.json
··· 5 5 "main": { 6 6 "type": "object", 7 7 "required": [ 8 - "image" 8 + "image", 9 + "aspectRatio" 9 10 ], 10 11 "properties": { 11 12 "image": {
lexicons/out/pub_leaflet_blocks_text.json lexicons/pub/leaflet/blocks/text.json
lexicons/out/pub_leaflet_document.json lexicons/pub/leaflet/document.json
lexicons/out/pub_leaflet_pages_linearDocument.json lexicons/pub/leaflet/pages/linearDocument.json
lexicons/out/pub_leaflet_post.json lexicons/pub/leaflet/post.json
lexicons/out/pub_leaflet_publication.json lexicons/pub/leaflet/publication.json
-36
lexicons/pages/LinearDocument.ts
··· 1 - import { BlockUnion } from "../blocks"; 2 - import * as l from "../utils"; 3 - 4 - const textAlignRefs = { 5 - id: "ignore", 6 - defs: { 7 - textAlignLeft: l.token(), 8 - textAlignCenter: l.token(), 9 - textAlignRight: l.token(), 10 - }, 11 - }; 12 - 13 - export const PubLeafletPagesLinearDocument = l.lexicon({ 14 - id: "pub.leaflet.pages.linearDocument", 15 - defs: { 16 - main: l.object({ 17 - properties: { 18 - blocks: { type: "array", items: l.ref("#block") }, 19 - }, 20 - }), 21 - block: l.object({ 22 - required: ["block"], 23 - properties: { 24 - block: BlockUnion, 25 - alignment: l.string({ 26 - knownValues: [ 27 - l.refValue<typeof textAlignRefs>(null, "textAlignLeft"), 28 - l.refValue<typeof textAlignRefs>(null, "textAlignCenter"), 29 - l.refValue<typeof textAlignRefs>(null, "textAlignRight"), 30 - ], 31 - }), 32 - }, 33 - }), 34 - ...textAlignRefs.defs, 35 - }, 36 - });
lexicons/pages/index.ts lexicons/src/pages/index.ts
-35
lexicons/publication.ts
··· 1 - import * as l from "./utils"; 2 - export const PubLeafletPublication = l.lexicon({ 3 - id: "pub.leaflet.publication", 4 - defs: { 5 - main: l.record({ 6 - key: "tid", 7 - description: "Record declaring a publication", 8 - record: l.object({ 9 - required: ["name"], 10 - properties: { 11 - name: l.string({ maxLength: 2000 }), 12 - description: l.string({ maxLength: 2000 }), 13 - }, 14 - }), 15 - }), 16 - }, 17 - }); 18 - 19 - export const PubLeafletPublicationPost = l.lexicon({ 20 - id: "pub.leaflet.post", 21 - defs: { 22 - main: l.record({ 23 - key: "tid", 24 - description: "Record putting a post in a document", 25 - record: l.object({ 26 - required: ["post", "publishedAt"], 27 - properties: { 28 - publication: l.string({ format: "at-uri" }), 29 - post: { type: "ref", ref: "com.atproto.repo.strongRef" }, 30 - publishedAt: { type: "string", format: "datetime" }, 31 - }, 32 - }), 33 - }), 34 - }, 35 - });
+70
lexicons/src/blocks.ts
··· 1 + import { LexiconDoc, LexRefUnion } from "@atproto/lexicon"; 2 + 3 + export const PubLeafletBlocksText: LexiconDoc = { 4 + lexicon: 1, 5 + id: "pub.leaflet.blocks.text", 6 + defs: { 7 + main: { 8 + type: "object", 9 + required: [], 10 + properties: { 11 + plaintext: { type: "string" }, 12 + }, 13 + }, 14 + }, 15 + }; 16 + 17 + export const PubLeafletBlocksHeader: LexiconDoc = { 18 + lexicon: 1, 19 + id: "pub.leaflet.blocks.header", 20 + defs: { 21 + main: { 22 + type: "object", 23 + required: [], 24 + properties: { 25 + level: { type: "integer", minimum: 1, maximum: 6 }, 26 + plaintext: { type: "string" }, 27 + }, 28 + }, 29 + }, 30 + }; 31 + 32 + export const PubLeafletBlocksImage: LexiconDoc = { 33 + lexicon: 1, 34 + id: "pub.leaflet.blocks.image", 35 + defs: { 36 + main: { 37 + type: "object", 38 + required: ["image", "aspectRatio"], 39 + properties: { 40 + image: { type: "blob", accept: ["image/*"], maxSize: 1000000 }, 41 + alt: { 42 + type: "string", 43 + description: "Alt text description of the image, for accessibility.", 44 + }, 45 + aspectRatio: { 46 + type: "ref", 47 + ref: "#aspectRatio", 48 + }, 49 + }, 50 + }, 51 + aspectRatio: { 52 + type: "object", 53 + required: ["width", "height"], 54 + properties: { 55 + width: { type: "integer" }, 56 + height: { type: "integer" }, 57 + }, 58 + }, 59 + }, 60 + }; 61 + 62 + export const BlockLexicons = [ 63 + PubLeafletBlocksText, 64 + PubLeafletBlocksHeader, 65 + PubLeafletBlocksImage, 66 + ]; 67 + export const BlockUnion: LexRefUnion = { 68 + type: "union", 69 + refs: BlockLexicons.map((lexicon) => lexicon.id), 70 + };
+33
lexicons/src/document.ts
··· 1 + import { LexiconDoc } from "@atproto/lexicon"; 2 + import { PubLeafletPagesLinearDocument } from "./pages/LinearDocument"; 3 + 4 + export const PubLeafletDocument: LexiconDoc = { 5 + lexicon: 1, 6 + id: "pub.leaflet.document", 7 + revision: 1, 8 + description: "A lexicon for long form rich media documents", 9 + defs: { 10 + main: { 11 + type: "record", 12 + key: "tid", 13 + description: "Record containing a document", 14 + record: { 15 + type: "object", 16 + required: ["pages", "author", "title", "publication"], 17 + properties: { 18 + title: { type: "string", maxLength: 128 }, 19 + publishedAt: { type: "string", format: "datetime" }, 20 + publication: { type: "string", format: "at-uri" }, 21 + author: { type: "string", format: "at-identifier" }, 22 + pages: { 23 + type: "array", 24 + items: { 25 + type: "union", 26 + refs: [PubLeafletPagesLinearDocument.id], 27 + }, 28 + }, 29 + }, 30 + }, 31 + }, 32 + }, 33 + };
+6 -6
lexicons/src/index.ts lexicons/api/index.ts
··· 5 5 import { schemas } from './lexicons.js' 6 6 import { CID } from 'multiformats/cid' 7 7 import { OmitKey, Un$Typed } from './util.js' 8 + import * as PubLeafletDocument from './types/pub/leaflet/document.js' 9 + import * as PubLeafletPost from './types/pub/leaflet/post.js' 10 + import * as PubLeafletPublication from './types/pub/leaflet/publication.js' 8 11 import * as PubLeafletBlocksHeader from './types/pub/leaflet/blocks/header.js' 9 12 import * as PubLeafletBlocksImage from './types/pub/leaflet/blocks/image.js' 10 13 import * as PubLeafletBlocksText from './types/pub/leaflet/blocks/text.js' 11 - import * as PubLeafletDocument from './types/pub/leaflet/document.js' 12 14 import * as PubLeafletPagesLinearDocument from './types/pub/leaflet/pages/linearDocument.js' 13 - import * as PubLeafletPost from './types/pub/leaflet/post.js' 14 - import * as PubLeafletPublication from './types/pub/leaflet/publication.js' 15 15 import * as ComAtprotoLabelDefs from './types/com/atproto/label/defs.js' 16 16 import * as ComAtprotoRepoApplyWrites from './types/com/atproto/repo/applyWrites.js' 17 17 import * as ComAtprotoRepoCreateRecord from './types/com/atproto/repo/createRecord.js' ··· 26 26 import * as ComAtprotoRepoStrongRef from './types/com/atproto/repo/strongRef.js' 27 27 import * as ComAtprotoRepoUploadBlob from './types/com/atproto/repo/uploadBlob.js' 28 28 29 + export * as PubLeafletDocument from './types/pub/leaflet/document.js' 30 + export * as PubLeafletPost from './types/pub/leaflet/post.js' 31 + export * as PubLeafletPublication from './types/pub/leaflet/publication.js' 29 32 export * as PubLeafletBlocksHeader from './types/pub/leaflet/blocks/header.js' 30 33 export * as PubLeafletBlocksImage from './types/pub/leaflet/blocks/image.js' 31 34 export * as PubLeafletBlocksText from './types/pub/leaflet/blocks/text.js' 32 - export * as PubLeafletDocument from './types/pub/leaflet/document.js' 33 35 export * as PubLeafletPagesLinearDocument from './types/pub/leaflet/pages/linearDocument.js' 34 - export * as PubLeafletPost from './types/pub/leaflet/post.js' 35 - export * as PubLeafletPublication from './types/pub/leaflet/publication.js' 36 36 export * as ComAtprotoLabelDefs from './types/com/atproto/label/defs.js' 37 37 export * as ComAtprotoRepoApplyWrites from './types/com/atproto/repo/applyWrites.js' 38 38 export * as ComAtprotoRepoCreateRecord from './types/com/atproto/repo/createRecord.js'
+100 -100
lexicons/src/lexicons.ts lexicons/api/lexicons.ts
··· 10 10 import { $Typed, is$typed, maybe$typed } from './util.js' 11 11 12 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: 128, 30 + }, 31 + publishedAt: { 32 + type: 'string', 33 + format: 'datetime', 34 + }, 35 + publication: { 36 + type: 'string', 37 + format: 'at-uri', 38 + }, 39 + author: { 40 + type: 'string', 41 + format: 'at-identifier', 42 + }, 43 + pages: { 44 + type: 'array', 45 + items: { 46 + type: 'union', 47 + refs: ['lex:pub.leaflet.pages.linearDocument'], 48 + }, 49 + }, 50 + }, 51 + }, 52 + }, 53 + }, 54 + }, 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 + PubLeafletPublication: { 85 + lexicon: 1, 86 + id: 'pub.leaflet.publication', 87 + defs: { 88 + main: { 89 + type: 'record', 90 + key: 'tid', 91 + description: 'Record declaring a publication', 92 + record: { 93 + type: 'object', 94 + required: ['name'], 95 + properties: { 96 + name: { 97 + type: 'string', 98 + maxLength: 2000, 99 + }, 100 + description: { 101 + type: 'string', 102 + maxLength: 2000, 103 + }, 104 + }, 105 + }, 106 + }, 107 + }, 108 + }, 13 109 PubLeafletBlocksHeader: { 14 110 lexicon: 1, 15 111 id: 'pub.leaflet.blocks.header', ··· 36 132 defs: { 37 133 main: { 38 134 type: 'object', 39 - required: ['image'], 135 + required: ['image', 'aspectRatio'], 40 136 properties: { 41 137 image: { 42 138 type: 'blob', ··· 83 179 }, 84 180 }, 85 181 }, 86 - PubLeafletDocument: { 87 - lexicon: 1, 88 - id: 'pub.leaflet.document', 89 - revision: 1, 90 - description: 'A lexicon for long form rich media documents', 91 - defs: { 92 - main: { 93 - type: 'record', 94 - key: 'tid', 95 - description: 'Record containing a document', 96 - record: { 97 - type: 'object', 98 - required: ['pages', 'author', 'title', 'publication'], 99 - properties: { 100 - title: { 101 - type: 'string', 102 - maxLength: 128, 103 - }, 104 - publishedAt: { 105 - type: 'string', 106 - format: 'datetime', 107 - }, 108 - publication: { 109 - type: 'string', 110 - format: 'at-uri', 111 - }, 112 - author: { 113 - type: 'string', 114 - format: 'at-identifier', 115 - }, 116 - pages: { 117 - type: 'array', 118 - items: { 119 - type: 'union', 120 - refs: ['lex:pub.leaflet.pages.linearDocument'], 121 - }, 122 - }, 123 - }, 124 - }, 125 - }, 126 - }, 127 - }, 128 182 PubLeafletPagesLinearDocument: { 129 183 lexicon: 1, 130 184 id: 'pub.leaflet.pages.linearDocument', ··· 171 225 }, 172 226 textAlignRight: { 173 227 type: 'token', 174 - }, 175 - }, 176 - }, 177 - PubLeafletPost: { 178 - lexicon: 1, 179 - id: 'pub.leaflet.post', 180 - defs: { 181 - main: { 182 - type: 'record', 183 - key: 'tid', 184 - description: 'Record putting a post in a document', 185 - record: { 186 - type: 'object', 187 - required: ['post', 'publishedAt'], 188 - properties: { 189 - publication: { 190 - type: 'string', 191 - format: 'at-uri', 192 - }, 193 - post: { 194 - type: 'ref', 195 - ref: 'lex:com.atproto.repo.strongRef', 196 - }, 197 - publishedAt: { 198 - type: 'string', 199 - format: 'datetime', 200 - }, 201 - }, 202 - }, 203 - }, 204 - }, 205 - }, 206 - PubLeafletPublication: { 207 - lexicon: 1, 208 - id: 'pub.leaflet.publication', 209 - defs: { 210 - main: { 211 - type: 'record', 212 - key: 'tid', 213 - description: 'Record declaring a publication', 214 - record: { 215 - type: 'object', 216 - required: ['name'], 217 - properties: { 218 - name: { 219 - type: 'string', 220 - maxLength: 2000, 221 - }, 222 - description: { 223 - type: 'string', 224 - maxLength: 2000, 225 - }, 226 - }, 227 - }, 228 228 }, 229 229 }, 230 230 }, ··· 1207 1207 } 1208 1208 1209 1209 export const ids = { 1210 + PubLeafletDocument: 'pub.leaflet.document', 1211 + PubLeafletPost: 'pub.leaflet.post', 1212 + PubLeafletPublication: 'pub.leaflet.publication', 1210 1213 PubLeafletBlocksHeader: 'pub.leaflet.blocks.header', 1211 1214 PubLeafletBlocksImage: 'pub.leaflet.blocks.image', 1212 1215 PubLeafletBlocksText: 'pub.leaflet.blocks.text', 1213 - PubLeafletDocument: 'pub.leaflet.document', 1214 1216 PubLeafletPagesLinearDocument: 'pub.leaflet.pages.linearDocument', 1215 - PubLeafletPost: 'pub.leaflet.post', 1216 - PubLeafletPublication: 'pub.leaflet.publication', 1217 1217 ComAtprotoLabelDefs: 'com.atproto.label.defs', 1218 1218 ComAtprotoRepoApplyWrites: 'com.atproto.repo.applyWrites', 1219 1219 ComAtprotoRepoCreateRecord: 'com.atproto.repo.createRecord',
+33
lexicons/src/pages/LinearDocument.ts
··· 1 + import { LexiconDoc } from "@atproto/lexicon"; 2 + import { BlockUnion } from "../blocks"; 3 + 4 + export const PubLeafletPagesLinearDocument: LexiconDoc = { 5 + lexicon: 1, 6 + id: "pub.leaflet.pages.linearDocument", 7 + defs: { 8 + main: { 9 + type: "object", 10 + properties: { 11 + blocks: { type: "array", items: { type: "ref", ref: "#block" } }, 12 + }, 13 + }, 14 + block: { 15 + type: "object", 16 + required: ["block"], 17 + properties: { 18 + block: BlockUnion, 19 + alignment: { 20 + type: "string", 21 + knownValues: [ 22 + "#textAlignLeft", 23 + "#textAlignCenter", 24 + "#textAlignRight", 25 + ], 26 + }, 27 + }, 28 + }, 29 + textAlignLeft: { type: "token" }, 30 + textAlignCenter: { type: "token" }, 31 + textAlignRight: { type: "token" }, 32 + }, 33 + };
+42
lexicons/src/publication.ts
··· 1 + import { LexiconDoc } from "@atproto/lexicon"; 2 + 3 + export const PubLeafletPublication: LexiconDoc = { 4 + lexicon: 1, 5 + id: "pub.leaflet.publication", 6 + defs: { 7 + main: { 8 + type: "record", 9 + key: "tid", 10 + description: "Record declaring a publication", 11 + record: { 12 + type: "object", 13 + required: ["name"], 14 + properties: { 15 + name: { type: "string", maxLength: 2000 }, 16 + description: { type: "string", maxLength: 2000 }, 17 + }, 18 + }, 19 + }, 20 + }, 21 + }; 22 + 23 + export const PubLeafletPublicationPost: LexiconDoc = { 24 + lexicon: 1, 25 + id: "pub.leaflet.post", 26 + defs: { 27 + main: { 28 + type: "record", 29 + key: "tid", 30 + description: "Record putting a post in a document", 31 + record: { 32 + type: "object", 33 + required: ["post", "publishedAt"], 34 + properties: { 35 + publication: { type: "string", format: "at-uri" }, 36 + post: { type: "ref", ref: "com.atproto.repo.strongRef" }, 37 + publishedAt: { type: "string", format: "datetime" }, 38 + }, 39 + }, 40 + }, 41 + }, 42 + };
lexicons/src/types/com/atproto/label/defs.ts lexicons/api/types/com/atproto/label/defs.ts
lexicons/src/types/com/atproto/repo/applyWrites.ts lexicons/api/types/com/atproto/repo/applyWrites.ts
lexicons/src/types/com/atproto/repo/createRecord.ts lexicons/api/types/com/atproto/repo/createRecord.ts
lexicons/src/types/com/atproto/repo/defs.ts lexicons/api/types/com/atproto/repo/defs.ts
lexicons/src/types/com/atproto/repo/deleteRecord.ts lexicons/api/types/com/atproto/repo/deleteRecord.ts
lexicons/src/types/com/atproto/repo/describeRepo.ts lexicons/api/types/com/atproto/repo/describeRepo.ts
lexicons/src/types/com/atproto/repo/getRecord.ts lexicons/api/types/com/atproto/repo/getRecord.ts
lexicons/src/types/com/atproto/repo/importRepo.ts lexicons/api/types/com/atproto/repo/importRepo.ts
lexicons/src/types/com/atproto/repo/listMissingBlobs.ts lexicons/api/types/com/atproto/repo/listMissingBlobs.ts
lexicons/src/types/com/atproto/repo/listRecords.ts lexicons/api/types/com/atproto/repo/listRecords.ts
lexicons/src/types/com/atproto/repo/putRecord.ts lexicons/api/types/com/atproto/repo/putRecord.ts
lexicons/src/types/com/atproto/repo/strongRef.ts lexicons/api/types/com/atproto/repo/strongRef.ts
lexicons/src/types/com/atproto/repo/uploadBlob.ts lexicons/api/types/com/atproto/repo/uploadBlob.ts
lexicons/src/types/pub/leaflet/blocks/header.ts lexicons/api/types/pub/leaflet/blocks/header.ts
+1 -1
lexicons/src/types/pub/leaflet/blocks/image.ts lexicons/api/types/pub/leaflet/blocks/image.ts
··· 15 15 image: BlobRef 16 16 /** Alt text description of the image, for accessibility. */ 17 17 alt?: string 18 - aspectRatio?: AspectRatio 18 + aspectRatio: AspectRatio 19 19 } 20 20 21 21 const hashMain = 'main'
lexicons/src/types/pub/leaflet/blocks/text.ts lexicons/api/types/pub/leaflet/blocks/text.ts
lexicons/src/types/pub/leaflet/document.ts lexicons/api/types/pub/leaflet/document.ts
lexicons/src/types/pub/leaflet/pages/linearDocument.ts lexicons/api/types/pub/leaflet/pages/linearDocument.ts
lexicons/src/types/pub/leaflet/post.ts lexicons/api/types/pub/leaflet/post.ts
lexicons/src/types/pub/leaflet/publication.ts lexicons/api/types/pub/leaflet/publication.ts
lexicons/src/util.ts lexicons/api/util.ts
-104
lexicons/utils.ts
··· 1 - import { 2 - LexArray, 3 - // lexPrimitive 4 - LexBoolean, 5 - LexInteger, 6 - LexString, 7 - LexUnknown, 8 - // lexIpldType 9 - LexBytes, 10 - LexCidLink, 11 - // lexRefVariant 12 - LexRef, 13 - LexRefUnion, 14 - // other 15 - LexBlob, 16 - lexRecord, 17 - LexRecord, 18 - LexObject, 19 - LexiconDoc, 20 - LexToken, 21 - } from "@atproto/lexicon"; 22 - 23 - export const refValue = <T extends Pick<LexiconDoc, "defs" | "id">>( 24 - l: T | null, 25 - k?: keyof T["defs"] & string, 26 - ) => { 27 - //Could improve this somehow, to ensure you have to pass in K if l is null? 28 - if (l === null) return `#${k}` || ""; 29 - return k ? `${l.id}#k` : l.id; 30 - }; 31 - 32 - export const lexicon = <T extends { defs: LexiconDoc["defs"] }>(args: T) => { 33 - return { 34 - lexicon: 1, 35 - ...args, 36 - }; 37 - }; 38 - 39 - export const record = ( 40 - args: Omit<LexRecord, "type" | "key"> & { 41 - key: "tid" | "nsid" | `literal:${string}` | "any"; 42 - }, 43 - ): LexRecord => ({ 44 - type: "record", 45 - ...args, 46 - }); 47 - 48 - export const string = (args?: Omit<LexString, "type">) => 49 - ({ type: "string", ...args }) as const; 50 - export const token = (l?: { description: string }): LexToken => ({ 51 - type: "token", 52 - description: l?.description, 53 - }); 54 - 55 - export const integer = (args?: Omit<LexInteger, "type">) => 56 - ({ 57 - type: "integer", 58 - ...args, 59 - }) as const; 60 - 61 - export const ref = (ref: string): LexRef => ({ type: "ref", ref }); 62 - 63 - export const array = (args: Omit<LexArray, "type">): LexArray => ({ 64 - type: "array", 65 - ...args, 66 - }); 67 - 68 - export const object = < 69 - Properties extends { 70 - [k: string]: 71 - | LexArray 72 - // lexPrimitive 73 - | LexBoolean 74 - | LexInteger 75 - | LexString 76 - | LexUnknown 77 - // lexIpldType 78 - | LexBytes 79 - | LexCidLink 80 - // lexRefVariant 81 - | LexRef 82 - | LexRefUnion 83 - // other 84 - | LexBlob; 85 - }, 86 - Required extends (keyof Properties & string)[], 87 - >( 88 - args: Omit<LexObject, "type" | "properties" | "required"> & { 89 - properties: Properties; 90 - required?: Required; 91 - }, 92 - ): LexObject => ({ 93 - type: "object", 94 - ...args, 95 - }); 96 - 97 - export const blob = (args: Omit<LexBlob, "type">): LexBlob => ({ 98 - type: "blob", 99 - ...args, 100 - }); 101 - export const union = (args: Omit<LexRefUnion, "type">): LexRefUnion => ({ 102 - type: "union", 103 - ...args, 104 - });
+1 -1
package.json
··· 5 5 "main": "index.js", 6 6 "scripts": { 7 7 "dev": "next dev", 8 - "lexgen": "tsx ./lexicons/build.ts && lex gen-api ./lexicons/src ./lexicons/out/* ./lexicons/com/atproto/*/* --yes", 8 + "lexgen": "tsx ./lexicons/build.ts && lex gen-api ./lexicons/api ./lexicons/pub/leaflet/* ./lexicons/pub/leaflet/*/* ./lexicons/com/atproto/*/* --yes", 9 9 "wrangler-dev": "wrangler dev", 10 10 "start-appview": "tsx --env-file='./.env.local' --watch appview/index.ts" 11 11 },