-
Notifications
You must be signed in to change notification settings - Fork 7
feat: add app.certified.graph.follow lexicon #209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@hypercerts-org/lexicon": minor | ||
| --- | ||
|
|
||
| Add `app.certified.graph.follow` lexicon — a social-graph follow record schema-compatible with `app.bsky.graph.follow` (same `tid` key, same `subject` / `createdAt` / optional `via` strongRef fields). Exports new `GRAPH_FOLLOW_NSID`, `GRAPH_FOLLOW_LEXICON_JSON`, `GRAPH_FOLLOW_LEXICON_DOC`, and `AppCertifiedGraphFollow` type namespace. | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| { | ||
| "lexicon": 1, | ||
| "id": "app.certified.graph.follow", | ||
| "defs": { | ||
| "main": { | ||
| "type": "record", | ||
| "description": "Record declaring a social 'follow' relationship of another account. Duplicate follows will be ignored by the AppView.", | ||
| "key": "tid", | ||
| "record": { | ||
| "type": "object", | ||
| "required": ["subject", "createdAt"], | ||
| "properties": { | ||
| "subject": { | ||
| "type": "string", | ||
| "format": "did", | ||
| "description": "DID of the account being followed." | ||
| }, | ||
| "createdAt": { | ||
| "type": "string", | ||
| "format": "datetime", | ||
| "description": "Client-declared timestamp when this record was originally created." | ||
| }, | ||
| "via": { | ||
| "type": "ref", | ||
| "ref": "com.atproto.repo.strongRef", | ||
| "description": "Optional strong reference to a record that mediated this follow (e.g. a starter pack or other curated list). Mirrors the optional `via` field on app.bsky.graph.follow; the referenced record may conform with any lexicon." | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,111 @@ | ||
| import { describe, it, expect } from "vitest"; | ||
| import { validate, ids } from "../generated/lexicons"; | ||
| import * as Follow from "../generated/types/app/certified/graph/follow"; | ||
|
|
||
| const VALID_DID = "did:plc:ewvi7nxzyoun6zhxrhs64oiz"; | ||
| const VALID_CID = "bafyreigh2akiscaildcqabsyg3dfr6chu3fgpregiymsck7e7aqa4s52zy"; | ||
|
|
||
| describe("app.certified.graph.follow", () => { | ||
| it("should accept a valid follow record (subject + createdAt only)", () => { | ||
| const result = Follow.validateMain({ | ||
| $type: ids.AppCertifiedGraphFollow, | ||
| subject: VALID_DID, | ||
| createdAt: "2024-01-01T00:00:00Z", | ||
| }); | ||
| expect(result.success).toBe(true); | ||
| if (result.success) { | ||
| expect(result.value.subject).toBe(VALID_DID); | ||
| } | ||
| }); | ||
|
|
||
| it("should accept a follow record with optional via strongRef", () => { | ||
| const result = Follow.validateMain({ | ||
| $type: ids.AppCertifiedGraphFollow, | ||
| subject: VALID_DID, | ||
| createdAt: "2024-01-01T00:00:00Z", | ||
| via: { | ||
| uri: "at://did:plc:alice/app.certified.graph.starterpack/3k2abc", | ||
| cid: VALID_CID, | ||
| }, | ||
| }); | ||
| expect(result.success).toBe(true); | ||
| if (result.success) { | ||
| expect(result.value.via?.uri).toBe( | ||
| "at://did:plc:alice/app.certified.graph.starterpack/3k2abc", | ||
| ); | ||
| } | ||
| }); | ||
|
|
||
| it("should reject a record missing required subject", () => { | ||
| const result = validate( | ||
| { createdAt: "2024-01-01T00:00:00Z" }, | ||
| ids.AppCertifiedGraphFollow, | ||
| "main", | ||
| false, | ||
| ); | ||
| expect(result.success).toBe(false); | ||
| }); | ||
|
|
||
| it("should reject a record missing required createdAt", () => { | ||
| const result = validate( | ||
| { subject: VALID_DID }, | ||
| ids.AppCertifiedGraphFollow, | ||
| "main", | ||
| false, | ||
| ); | ||
| expect(result.success).toBe(false); | ||
| }); | ||
|
|
||
| it("should reject a subject that is not a valid DID", () => { | ||
| const result = validate( | ||
| { | ||
| subject: "not-a-did", | ||
| createdAt: "2024-01-01T00:00:00Z", | ||
| }, | ||
| ids.AppCertifiedGraphFollow, | ||
| "main", | ||
| false, | ||
| ); | ||
| expect(result.success).toBe(false); | ||
| }); | ||
|
|
||
| it("should reject an invalid datetime", () => { | ||
| const result = validate( | ||
| { | ||
| subject: VALID_DID, | ||
| createdAt: "not-a-datetime", | ||
| }, | ||
| ids.AppCertifiedGraphFollow, | ||
| "main", | ||
| false, | ||
| ); | ||
| expect(result.success).toBe(false); | ||
| }); | ||
|
|
||
| it("should reject a via that is not a valid strongRef", () => { | ||
| const result = validate( | ||
| { | ||
| subject: VALID_DID, | ||
| createdAt: "2024-01-01T00:00:00Z", | ||
| via: { uri: "at://did:plc:alice/app.certified.graph.starterpack/x" }, // missing cid | ||
| }, | ||
| ids.AppCertifiedGraphFollow, | ||
| "main", | ||
| false, | ||
| ); | ||
| expect(result.success).toBe(false); | ||
| }); | ||
|
|
||
| it("should require $type when requiredType is true", () => { | ||
| const result = validate( | ||
| { | ||
| subject: VALID_DID, | ||
| createdAt: "2024-01-01T00:00:00Z", | ||
| }, | ||
| ids.AppCertifiedGraphFollow, | ||
| "main", | ||
| true, | ||
| ); | ||
| expect(result.success).toBe(false); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.