prototypey.org - atproto lexicon typescript toolkit - mirror https://github.com/tylersayshi/prototypey

ai generated readme so i can review and see what this thing made

Tyler 80ef5398 cc75989b

+100
+100
packages/cli/README.md
··· 1 + # @prototypey/cli 2 + 3 + CLI tool for generating types from ATProto lexicon schemas. 4 + 5 + ## Installation 6 + 7 + ```bash 8 + npm install -g @prototypey/cli 9 + ``` 10 + 11 + Or use directly with npx: 12 + 13 + ```bash 14 + npx @prototypey/cli 15 + ``` 16 + 17 + ## Commands 18 + 19 + ### `gen-inferred` 20 + 21 + Generate type-inferred TypeScript code from JSON lexicon schemas. 22 + 23 + **Usage:** 24 + 25 + ```bash 26 + prototypey gen-inferred <outdir> <schemas...> 27 + ``` 28 + 29 + **Arguments:** 30 + 31 + - `outdir` - Output directory for generated TypeScript files 32 + - `schemas...` - One or more glob patterns matching lexicon JSON schema files 33 + 34 + **Example:** 35 + 36 + ```bash 37 + prototypey gen-inferred ./generated/inferred ./lexicons/**/*.json 38 + ``` 39 + 40 + **What it does:** 41 + 42 + - Reads ATProto lexicon JSON schemas 43 + - Generates TypeScript types that match the schema structure 44 + - Organizes output files by namespace (e.g., `app.bsky.feed.post` → `app/bsky/feed/post.ts`) 45 + - Provides type-safe interfaces for working with lexicon data 46 + 47 + ### `gen-emit` 48 + 49 + Emit JSON lexicon schemas from authored TypeScript files. 50 + 51 + **Usage:** 52 + 53 + ```bash 54 + prototypey gen-emit <outdir> <sources...> 55 + ``` 56 + 57 + **Arguments:** 58 + 59 + - `outdir` - Output directory for emitted JSON schema files 60 + - `sources...` - One or more glob patterns matching TypeScript source files 61 + 62 + **Example:** 63 + 64 + ```bash 65 + prototypey gen-emit ./lexicons ./src/lexicons/**/*.ts 66 + ``` 67 + 68 + **What it does:** 69 + 70 + - Scans TypeScript files for exported lexicon namespace definitions 71 + - Extracts the `.json` property from each namespace 72 + - Emits properly formatted JSON lexicon schema files 73 + - Names output files by lexicon ID (e.g., `app.bsky.feed.post.json`) 74 + 75 + ## Workflow 76 + 77 + The typical workflow combines both commands for bidirectional type safety: 78 + 79 + 1. **Author lexicons in TypeScript** using the `prototypey` library 80 + 2. **Emit to JSON** with `gen-emit` for runtime validation and API contracts 81 + 3. **Generate inferred types** with `gen-inferred` for consuming code 82 + 83 + ```bash 84 + # Write your lexicons in TypeScript 85 + # src/lexicons/app.bsky.actor.profile.ts 86 + 87 + # Emit JSON schemas 88 + prototypey gen-emit ./schemas ./src/lexicons/**/*.ts 89 + 90 + # Generate TypeScript types from schemas 91 + prototypey gen-inferred ./generated ./schemas/**/*.json 92 + ``` 93 + 94 + ## Requirements 95 + 96 + - Node.js >= 20.19.0 97 + 98 + ## License 99 + 100 + MIT