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

use spaces in README.md so it formats correctly on npm (#20)

* use spaces in README.md so it formats correctly on npm

* changeset

authored by tyler and committed by GitHub 0b16bc37 e78a8df4

+69 -60
+5
.changeset/cyan-eels-smell.md
···
··· 1 + --- 2 + "prototypey": patch 3 + --- 4 + 5 + use spaces for readme so npm doesn't format it weird
+5 -1
.prettierrc.json
··· 1 - { "$schema": "http://json.schemastore.org/prettierrc", "useTabs": true }
··· 1 + { 2 + "$schema": "http://json.schemastore.org/prettierrc", 3 + "useTabs": true, 4 + "overrides": [{ "files": ["README.md"], "options": { "useTabs": false } }] 5 + }
+59 -59
packages/prototypey/README.md
··· 18 19 ```ts 20 const lex = lx.lexicon("app.bsky.actor.profile", { 21 - main: lx.record({ 22 - key: "self", 23 - record: lx.object({ 24 - displayName: lx.string({ maxLength: 64, maxGraphemes: 64 }), 25 - description: lx.string({ maxLength: 256, maxGraphemes: 256 }), 26 - }), 27 - }), 28 }); 29 ``` 30 ··· 32 33 ```json 34 { 35 - "lexicon": 1, 36 - "id": "app.bsky.actor.profile", 37 - "defs": { 38 - "main": { 39 - "type": "record", 40 - "key": "self", 41 - "record": { 42 - "type": "object", 43 - "properties": { 44 - "displayName": { 45 - "type": "string", 46 - "maxLength": 64, 47 - "maxGraphemes": 64 48 - }, 49 - "description": { 50 - "type": "string", 51 - "maxLength": 256, 52 - "maxGraphemes": 256 53 - } 54 - } 55 - } 56 - } 57 - } 58 } 59 ``` 60 ··· 66 67 ```ts 68 const lex = lx.lexicon("app.bsky.actor.profile", { 69 - main: lx.record({ 70 - key: "self", 71 - record: lx.object({ 72 - displayName: lx.string({ maxLength: 64, maxGraphemes: 64 }), 73 - description: lx.string({ maxLength: 256, maxGraphemes: 256 }), 74 - }), 75 - }), 76 }); 77 78 // Validate data against the schema 79 const result = lex.validate({ 80 - displayName: "Alice", 81 - description: "Software engineer", 82 }); 83 84 if (result.success) { 85 - console.log("Valid data:", result.value); 86 } else { 87 - console.error("Validation error:", result.error); 88 } 89 ``` 90 ··· 94 95 ```ts 96 const lex = lx.lexicon("app.bsky.feed.post", { 97 - user: lx.object({ 98 - handle: lx.string({ required: true }), 99 - displayName: lx.string(), 100 - }), 101 - main: lx.record({ 102 - key: "tid", 103 - record: lx.object({ 104 - text: lx.string({ required: true }), 105 - author: lx.ref("#user", { required: true }), 106 - }), 107 - }), 108 }); 109 110 // Validate against the "user" definition 111 const userResult = lex.validate( 112 - { handle: "alice.bsky.social", displayName: "Alice" }, 113 - "user", 114 ); 115 116 // Validate against "main" (default if not specified) 117 const postResult = lex.validate({ 118 - text: "Hello world", 119 - author: { handle: "bob.bsky.social" }, 120 }); 121 ``` 122 ··· 147 148 ```json 149 { 150 - "scripts": { 151 - "lexicon:emit": "prototypey gen-emit ./schemas ./src/lexicons/**/*.ts" 152 - } 153 } 154 ``` 155
··· 18 19 ```ts 20 const lex = lx.lexicon("app.bsky.actor.profile", { 21 + main: lx.record({ 22 + key: "self", 23 + record: lx.object({ 24 + displayName: lx.string({ maxLength: 64, maxGraphemes: 64 }), 25 + description: lx.string({ maxLength: 256, maxGraphemes: 256 }), 26 + }), 27 + }), 28 }); 29 ``` 30 ··· 32 33 ```json 34 { 35 + "lexicon": 1, 36 + "id": "app.bsky.actor.profile", 37 + "defs": { 38 + "main": { 39 + "type": "record", 40 + "key": "self", 41 + "record": { 42 + "type": "object", 43 + "properties": { 44 + "displayName": { 45 + "type": "string", 46 + "maxLength": 64, 47 + "maxGraphemes": 64 48 + }, 49 + "description": { 50 + "type": "string", 51 + "maxLength": 256, 52 + "maxGraphemes": 256 53 + } 54 + } 55 + } 56 + } 57 + } 58 } 59 ``` 60 ··· 66 67 ```ts 68 const lex = lx.lexicon("app.bsky.actor.profile", { 69 + main: lx.record({ 70 + key: "self", 71 + record: lx.object({ 72 + displayName: lx.string({ maxLength: 64, maxGraphemes: 64 }), 73 + description: lx.string({ maxLength: 256, maxGraphemes: 256 }), 74 + }), 75 + }), 76 }); 77 78 // Validate data against the schema 79 const result = lex.validate({ 80 + displayName: "Alice", 81 + description: "Software engineer", 82 }); 83 84 if (result.success) { 85 + console.log("Valid data:", result.value); 86 } else { 87 + console.error("Validation error:", result.error); 88 } 89 ``` 90 ··· 94 95 ```ts 96 const lex = lx.lexicon("app.bsky.feed.post", { 97 + user: lx.object({ 98 + handle: lx.string({ required: true }), 99 + displayName: lx.string(), 100 + }), 101 + main: lx.record({ 102 + key: "tid", 103 + record: lx.object({ 104 + text: lx.string({ required: true }), 105 + author: lx.ref("#user", { required: true }), 106 + }), 107 + }), 108 }); 109 110 // Validate against the "user" definition 111 const userResult = lex.validate( 112 + { handle: "alice.bsky.social", displayName: "Alice" }, 113 + "user", 114 ); 115 116 // Validate against "main" (default if not specified) 117 const postResult = lex.validate({ 118 + text: "Hello world", 119 + author: { handle: "bob.bsky.social" }, 120 }); 121 ``` 122 ··· 147 148 ```json 149 { 150 + "scripts": { 151 + "lexicon:emit": "prototypey gen-emit ./schemas ./src/lexicons/**/*.ts" 152 + } 153 } 154 ``` 155