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

Configure Feed

Select the types of activity you want to include in your feed.

reorganize repo

Tyler 649c6787 f94f49c0

+15 -29
-1
.gitignore
··· 1 - .claude
+2 -2
README.md
··· 1 1 # typed-lexicon 2 2 3 3 > [!WARNING] 4 - > this project is in the middle of active initial development and not ready for use. there will be updates posted [here](https://bsky.app/profile/tylur.dev) if you'd like to follow along! 4 + > this project is in the middle of active initial development and not ready for use. there will be updates posted [here](https://bsky.app/profile/tylur.dev) if you'd like to follow along! or checkout the [todo.md](./todo.md) 5 5 6 6 this will be a toolkit for writing lexicon json schema's in typescript and providing types for lexicon data shape. it will: 7 7 ··· 10 10 - infer the typescript type definitions for the data shape to avoid duplication and skew 11 11 - methods and a cli for generating json 12 12 13 - With each of the above finished, i'll plan to write a `validate` method that will be published alongside this that takes any lexicon json definition and validates payloads off that. 13 + With each of the above finished, i'll plan to write a `validate` method that will be published alongside this that takes any lexicon json definition and validates payloads off that. 14 14 15 15 My working hypothesis: it will be easier to write lexicons in typescript with a single api, then validate based off the json definition, than it would be to start with validation library types (standard-schema style) and attempt to use those as the authoring and validation tools. 16 16
lib.ts src/lib.ts
+1 -1
tests/base-case.test.ts
··· 1 1 import { assertEquals } from "@std/assert"; 2 - import { lx } from "../lib.ts"; 2 + import { lx } from "../src/lib.ts"; 3 3 4 4 Deno.test("app.bsky.actor.profile", () => { 5 5 const profileNamespace = lx.namespace("app.bsky.actor.profile", {
+5 -2
tests/bsky-actor.test.ts
··· 1 1 import { assertEquals } from "@std/assert"; 2 - import { lx } from "../lib.ts"; 2 + import { lx } from "../src/lib.ts"; 3 3 4 4 Deno.test("app.bsky.actor.defs - profileViewBasic", () => { 5 5 const profileViewBasic = lx.object({ ··· 407 407 Deno.test("app.bsky.actor.defs - savedFeed", () => { 408 408 const savedFeed = lx.object({ 409 409 id: lx.string({ required: true }), 410 - type: lx.string({ required: true, knownValues: ["feed", "list", "timeline"] }), 410 + type: lx.string({ 411 + required: true, 412 + knownValues: ["feed", "list", "timeline"], 413 + }), 411 414 value: lx.string({ required: true }), 412 415 pinned: lx.boolean({ required: true }), 413 416 });
+1 -1
tests/bsky-feed.test.ts
··· 1 1 import { assertEquals } from "@std/assert"; 2 - import { lx } from "../lib.ts"; 2 + import { lx } from "../src/lib.ts"; 3 3 4 4 Deno.test("app.bsky.feed.defs - postView", () => { 5 5 const postView = lx.object({
+6 -22
tests/primitives.test.ts
··· 1 1 import { assertEquals } from "@std/assert"; 2 - import { lx } from "../lib.ts"; 2 + import { lx } from "../src/lib.ts"; 3 3 4 4 Deno.test("lx.null()", () => { 5 5 const result = lx.null(); ··· 615 615 cid: lx.string({ required: true }), 616 616 }), 617 617 }, 618 - errors: [ 619 - { name: "InvalidSwap" }, 620 - { name: "InvalidRecord" }, 621 - ], 618 + errors: [{ name: "InvalidSwap" }, { name: "InvalidRecord" }], 622 619 }); 623 620 assertEquals(result, { 624 621 type: "procedure", ··· 647 644 required: ["uri", "cid"], 648 645 }, 649 646 }, 650 - errors: [ 651 - { name: "InvalidSwap" }, 652 - { name: "InvalidRecord" }, 653 - ], 647 + errors: [{ name: "InvalidSwap" }, { name: "InvalidRecord" }], 654 648 }); 655 649 }); 656 650 ··· 689 683 Deno.test("lx.subscription() with message", () => { 690 684 const result = lx.subscription({ 691 685 message: { 692 - schema: lx.union([ 693 - "#commit", 694 - "#identity", 695 - "#account", 696 - ]), 686 + schema: lx.union(["#commit", "#identity", "#account"]), 697 687 }, 698 688 }); 699 689 assertEquals(result, { ··· 760 750 "#info", 761 751 ]), 762 752 }, 763 - errors: [ 764 - { name: "FutureCursor" }, 765 - { name: "ConsumerTooSlow" }, 766 - ], 753 + errors: [{ name: "FutureCursor" }, { name: "ConsumerTooSlow" }], 767 754 }); 768 755 assertEquals(result, { 769 756 type: "subscription", ··· 791 778 ], 792 779 }, 793 780 }, 794 - errors: [ 795 - { name: "FutureCursor" }, 796 - { name: "ConsumerTooSlow" }, 797 - ], 781 + errors: [{ name: "FutureCursor" }, { name: "ConsumerTooSlow" }], 798 782 }); 799 783 });