Skip to content

Commit

Permalink
Align XRPC parameters with subset of json schema (bluesky-social#328)
Browse files Browse the repository at this point in the history
* Model procedure for setting a vote on a post

* Implement app.bsky.feed.setVote() method

* Support json schema subset for parameters in lexicon and lex-cli

* Update lexicons w/ json schema parameters

* Use enum in getVotes parameters

* Support json schema subset for parameters in xrpc-server, ajv validation

* Include parameter enums in generated markdown

* Tidy

* Unify xrpc parameter md docs with inputs and outputs: show ts interfaces

* Tidy
  • Loading branch information
devinivy authored Nov 9, 2022
1 parent 1bd8ef1 commit da8f055
Show file tree
Hide file tree
Showing 62 changed files with 923 additions and 716 deletions.
1 change: 0 additions & 1 deletion lexicons/app/bsky/actor/createScene.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"id": "app.bsky.actor.createScene",
"type": "procedure",
"description": "Create a scene.",
"parameters": {},
"input": {
"encoding": "application/json",
"schema": {
Expand Down
12 changes: 8 additions & 4 deletions lexicons/app/bsky/actor/getProfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
"id": "app.bsky.actor.getProfile",
"type": "query",
"parameters": {
"actor": {"type": "string", "required": true}
"type": "object",
"required": ["actor"],
"properties": {
"actor": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
Expand Down Expand Up @@ -43,13 +47,13 @@
}
},
"defs": {
"actorKnown": {
"actorKnown": {
"type": "string",
"enum": ["app.bsky.system.actorUser", "app.bsky.system.actorScene"]
},
"actorUnknown": {
"actorUnknown": {
"type": "string",
"not": {"enum": ["app.bsky.system.actorUser", "app.bsky.system.actorScene"]}
}
}
}
}
7 changes: 5 additions & 2 deletions lexicons/app/bsky/actor/getSuggestions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
"type": "query",
"description": "Get a list of actors suggested for following. Used in discovery UIs.",
"parameters": {
"limit": {"type": "number", "maximum": 100},
"cursor": {"type": "string"}
"type": "object",
"properties": {
"limit": {"type": "number", "maximum": 100},
"cursor": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
Expand Down
10 changes: 7 additions & 3 deletions lexicons/app/bsky/actor/search.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
"type": "query",
"description": "Find users matching search criteria.",
"parameters": {
"term": {"type": "string", "required": true},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
"type": "object",
"required": ["term"],
"properties": {
"term": {"type": "string"},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
Expand Down
8 changes: 6 additions & 2 deletions lexicons/app/bsky/actor/searchTypeahead.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
"type": "query",
"description": "Find user suggestions for a search term.",
"parameters": {
"term": {"type": "string", "required": true},
"limit": {"type": "number", "maximum": 100}
"type": "object",
"required": ["term"],
"properties": {
"term": {"type": "string"},
"limit": {"type": "number", "maximum": 100}
}
},
"output": {
"encoding": "application/json",
Expand Down
1 change: 0 additions & 1 deletion lexicons/app/bsky/actor/updateProfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
"encoding": "application/json",
"schema": {
"type": "object",
"required": [],
"properties": {
"displayName": {
"type": "string",
Expand Down
10 changes: 7 additions & 3 deletions lexicons/app/bsky/feed/getAuthorFeed.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
"type": "query",
"description": "A view of a user's feed.",
"parameters": {
"author": {"type": "string", "required": true},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
"type": "object",
"required": ["author"],
"properties": {
"author": {"type": "string"},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
Expand Down
8 changes: 6 additions & 2 deletions lexicons/app/bsky/feed/getPostThread.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
"id": "app.bsky.feed.getPostThread",
"type": "query",
"parameters": {
"uri": {"type": "string", "required": true},
"depth": {"type": "number"}
"type": "object",
"required": ["uri"],
"properties": {
"uri": {"type": "string"},
"depth": {"type": "number"}
}
},
"output": {
"encoding": "application/json",
Expand Down
12 changes: 8 additions & 4 deletions lexicons/app/bsky/feed/getRepostedBy.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
"id": "app.bsky.feed.getRepostedBy",
"type": "query",
"parameters": {
"uri": {"type": "string", "required": true},
"cid": {"type": "string", "required": false},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
"type": "object",
"required": ["uri"],
"properties": {
"uri": {"type": "string"},
"cid": {"type": "string"},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
Expand Down
9 changes: 6 additions & 3 deletions lexicons/app/bsky/feed/getTimeline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
"type": "query",
"description": "A view of the user's home timeline.",
"parameters": {
"algorithm": {"type": "string"},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
"type": "object",
"properties": {
"algorithm": {"type": "string"},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
Expand Down
14 changes: 9 additions & 5 deletions lexicons/app/bsky/feed/getVotes.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@
"id": "app.bsky.feed.getVotes",
"type": "query",
"parameters": {
"uri": {"type": "string", "required": true},
"cid": {"type": "string", "required": false},
"direction": {"type": "string", "required": false},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
"type": "object",
"required": ["uri"],
"properties": {
"uri": {"type": "string"},
"cid": {"type": "string"},
"direction": {"type": "string", "enum": ["up", "down"]},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
Expand Down
1 change: 0 additions & 1 deletion lexicons/app/bsky/feed/setVote.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"encoding": "application/json",
"schema": {
"type": "object",
"required": [],
"properties": {
"upvote": {"type": "string"},
"downvote": {"type": "string"}
Expand Down
10 changes: 7 additions & 3 deletions lexicons/app/bsky/graph/getFollowers.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
"type": "query",
"description": "Who is following a user?",
"parameters": {
"user": {"type": "string", "required": true},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
"type": "object",
"required": ["user"],
"properties": {
"user": {"type": "string"},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
Expand Down
10 changes: 7 additions & 3 deletions lexicons/app/bsky/graph/getFollows.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
"type": "query",
"description": "Who is a user following?",
"parameters": {
"user": {"type": "string", "required": true},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
"type": "object",
"required": ["user"],
"properties": {
"user": {"type": "string"},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
Expand Down
10 changes: 7 additions & 3 deletions lexicons/app/bsky/graph/getMembers.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
"type": "query",
"description": "Who is a member of the group?",
"parameters": {
"actor": {"type": "string", "required": true},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
"type": "object",
"required": ["actor"],
"properties": {
"actor": {"type": "string"},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
Expand Down
10 changes: 7 additions & 3 deletions lexicons/app/bsky/graph/getMemberships.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
"type": "query",
"description": "Which groups is the actor a member of?",
"parameters": {
"actor": {"type": "string", "required": true},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
"type": "object",
"required": ["actor"],
"properties": {
"actor": {"type": "string"},
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
Expand Down
3 changes: 1 addition & 2 deletions lexicons/app/bsky/notification/getCount.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"lexicon": 1,
"id": "app.bsky.notification.getCount",
"type": "query",
"parameters": { },
"output": {
"encoding": "application/json",
"schema": {
Expand All @@ -13,4 +12,4 @@
}
}
}
}
}
7 changes: 5 additions & 2 deletions lexicons/app/bsky/notification/list.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
"id": "app.bsky.notification.list",
"type": "query",
"parameters": {
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
"type": "object",
"properties": {
"limit": {"type": "number", "maximum": 100},
"before": {"type": "string"}
}
},
"output": {
"encoding": "application/json",
Expand Down
3 changes: 1 addition & 2 deletions lexicons/com/atproto/account/get.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
"id": "com.atproto.account.get",
"type": "query",
"description": "Get information about an account.",
"parameters": {},
"output": {
"encoding": "",
"schema": {}
}
}
}
7 changes: 5 additions & 2 deletions lexicons/com/atproto/handle/resolve.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
"type": "query",
"description": "Provides the DID of a repo.",
"parameters": {
"handle": {"type": "string", "description": "The handle to resolve. If not supplied, will resolve the host's own handle."}
"type": "object",
"properties": {
"handle": {"type": "string", "description": "The handle to resolve. If not supplied, will resolve the host's own handle."}
}
},
"output": {
"encoding": "application/json",
Expand All @@ -16,4 +19,4 @@
}
}
}
}
}
8 changes: 6 additions & 2 deletions lexicons/com/atproto/repo/describe.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
"type": "query",
"description": "Get information about the repo, including the list of collections.",
"parameters": {
"user": {"type": "string", "required": true, "description": "The handle or DID of the repo."}
"type": "object",
"required": ["user"],
"properties": {
"user": {"type": "string", "description": "The handle or DID of the repo."}
}
},
"output": {
"encoding": "application/json",
Expand All @@ -20,4 +24,4 @@
}
}
}
}
}
14 changes: 9 additions & 5 deletions lexicons/com/atproto/repo/getRecord.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
"type": "query",
"description": "Fetch a record.",
"parameters": {
"user": {"type": "string", "required": true, "description": "The handle or DID of the repo."},
"collection": {"type": "string", "required": true, "description": "The NSID of the collection."},
"rkey": {"type": "string", "required": true, "description": "The key of the record."},
"cid": {"type": "string", "required": false, "description": "The CID of the version of the record. If not specified, then return the most recent version."}
"type": "object",
"required": ["user", "collection", "rkey"],
"properties": {
"user": {"type": "string", "description": "The handle or DID of the repo."},
"collection": {"type": "string", "description": "The NSID of the collection."},
"rkey": {"type": "string", "description": "The key of the record."},
"cid": {"type": "string", "description": "The CID of the version of the record. If not specified, then return the most recent version."}
}
},
"output": {
"encoding": "application/json",
Expand All @@ -21,4 +25,4 @@
}
}
}
}
}
16 changes: 10 additions & 6 deletions lexicons/com/atproto/repo/listRecords.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
"type": "query",
"description": "List a range of records in a collection.",
"parameters": {
"user": {"type": "string", "required": true, "description": "The handle or DID of the repo."},
"collection": {"type": "string", "required": true, "description": "The NSID of the record type."},
"limit": {"type": "number", "minimum": 1, "default": 50, "description": "The number of records to return. TODO-max number?"},
"before": {"type": "string", "description": "A TID to filter the range of records returned."},
"after": {"type": "string", "description": "A TID to filter the range of records returned."},
"reverse": {"type": "boolean", "description": "Reverse the order of the returned records?", "default": false}
"type": "object",
"required": ["user", "collection"],
"properties": {
"user": {"type": "string", "description": "The handle or DID of the repo."},
"collection": {"type": "string", "description": "The NSID of the record type."},
"limit": {"type": "number", "minimum": 1, "default": 50, "description": "The number of records to return. TODO-max number?"},
"before": {"type": "string", "description": "A TID to filter the range of records returned."},
"after": {"type": "string", "description": "A TID to filter the range of records returned."},
"reverse": {"type": "boolean", "description": "Reverse the order of the returned records?"}
}
},
"output": {
"encoding": "application/json",
Expand Down
Loading

0 comments on commit da8f055

Please sign in to comment.