···1+---
2+"prototypey": minor
3+---
4+5+generate prototypey lexicon utils from json definitions
+53-11
packages/prototypey/README.md
···138prototypey gen-emit ./lexicons ./src/lexicons/**/*.ts
139```
140141-### Typical Workflow
0000000000000000000000000001421431. Author lexicons in TypeScript using the library
1442. Emit JSON schemas with `gen-emit` for runtime validation
···159npm run lexicon:emit
160```
161000000000000000000000162## State of the Project
163164**Done:**
···169- Inferrance of valid type from full lexicon definition
170 - the really cool part of this is that it fills in the refs from the defs all at the type level
171- `lx.lexicon(...).validate(data)` for validating data using `@atproto/lexicon` and your lexicon definitions
172-173-**TODO/In Progress:**
174-175-- Library art! Please reach out if you'd be willing to contribute some drawings or anything!
176-- Add CLI support for inferring and validating from json as the starting point
177178-Please give any and all feedback. I've not really written many lexicons much myself yet, so this project is at a point of "well I think this makes sense" 😂. Both the [issues page](https://github.com/tylersayshi/prototypey/issues) and [discussions](https://github.com/tylersayshi/prototypey/discussions) are open and ready for y'all 🙂.
179180----
181182-> 💝 This package was templated with
183-> [`create-typescript-app`](https://github.com/JoshuaKGoldberg/create-typescript-app)
184-> using the [Bingo framework](https://create.bingo).
···138prototypey gen-emit ./lexicons ./src/lexicons/**/*.ts
139```
140141+#### `gen-from-json` - Generate TypeScript from JSON schemas
142+143+```bash
144+prototypey gen-from-json <outdir> <sources...>
145+```
146+147+Generates TypeScript files from JSON lexicon schemas using the `fromJSON` helper. This is useful when you have existing lexicon JSON files and want to work with them in TypeScript with full type inference.
148+149+**Example:**
150+151+```bash
152+prototypey gen-from-json ./src/lexicons ./lexicons/**/*.json
153+```
154+155+This will create TypeScript files that export typed lexicon objects:
156+157+```ts
158+// Generated file: src/lexicons/app.bsky.feed.post.ts
159+import { fromJSON } from "prototypey";
160+161+export const appBskyFeedPost = fromJSON({
162+ // ... lexicon JSON
163+});
164+```
165+166+### Typical Workflows
167+168+#### TypeScript-first workflow
1691701. Author lexicons in TypeScript using the library
1712. Emit JSON schemas with `gen-emit` for runtime validation
···186npm run lexicon:emit
187```
188189+#### JSON-first workflow
190+191+1. Start with JSON lexicon schemas (e.g., from atproto)
192+2. Generate TypeScript with `gen-from-json` for type-safe access
193+194+**Recommended:** Add as a script to your `package.json`:
195+196+```json
197+{
198+ "scripts": {
199+ "lexicon:import": "prototypey gen-from-json ./src/lexicons ./lexicons/**/*.json"
200+ }
201+}
202+```
203+204+Then run:
205+206+```bash
207+npm run lexicon:import
208+```
209+210## State of the Project
211212**Done:**
···217- Inferrance of valid type from full lexicon definition
218 - the really cool part of this is that it fills in the refs from the defs all at the type level
219- `lx.lexicon(...).validate(data)` for validating data using `@atproto/lexicon` and your lexicon definitions
220+- `fromJSON()` helper for creating lexicons directly from JSON objects with full type inference
0000221222+Please give any and all feedback. I've not really written many lexicons much myself yet, so this project is at a point of "well I think this makes sense". Both the [issues page](https://github.com/tylersayshi/prototypey/issues) and [discussions](https://github.com/tylersayshi/prototypey/discussions) are open and ready for y'all 🙂.
223224+**Call For Contribution:**
225226+- We need library art! Please reach out if you'd be willing to contribute some drawings or anything :)
00