Skip to content

Commit 22d039a

Browse files
authored
✨ Ozone sets (#2636)
* ✨ Initial implementation of sets api on ozone * ✨ Introduce sortDirection to querySets * 🧹 Cleanup and refactor * ✨ Align setView for response * ♻️ Rename and add specific error * 🐛 Cleanup unnecessary check that is covered by lexicon * ✨ Rename remove to delete and add set suffix * ✨ Use id and createdAt for values pagination * ✨ Add index on createdAt for query perf and other cleanups * 🐛 Set createdAt when inserting values * 📝 Add changeset * ✨ Add index on setId and createdAt
1 parent 3e1ae8d commit 22d039a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3212
-1
lines changed

.changeset/modern-snails-flash.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@atproto/ozone": patch
3+
"@atproto/api": patch
4+
---
5+
6+
Sets api to manage lists of strings on ozone, mostly aimed for automod configuration
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"lexicon": 1,
3+
"id": "tools.ozone.set.addValues",
4+
"defs": {
5+
"main": {
6+
"type": "procedure",
7+
"description": "Add values to a specific set. Attempting to add values to a set that does not exist will result in an error.",
8+
"input": {
9+
"encoding": "application/json",
10+
"schema": {
11+
"type": "object",
12+
"required": ["name", "values"],
13+
"properties": {
14+
"name": {
15+
"type": "string",
16+
"description": "Name of the set to add values to"
17+
},
18+
"values": {
19+
"type": "array",
20+
"minLength": 1,
21+
"maxLength": 1000,
22+
"items": {
23+
"type": "string"
24+
},
25+
"description": "Array of string values to add to the set"
26+
}
27+
}
28+
}
29+
}
30+
}
31+
}
32+
}

lexicons/tools/ozone/set/defs.json

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"lexicon": 1,
3+
"id": "tools.ozone.set.defs",
4+
"defs": {
5+
"set": {
6+
"type": "object",
7+
"required": ["name"],
8+
"properties": {
9+
"name": {
10+
"type": "string",
11+
"minLength": 3,
12+
"maxLength": 128
13+
},
14+
"description": {
15+
"type": "string",
16+
"maxGraphemes": 1024,
17+
"maxLength": 10240
18+
}
19+
}
20+
},
21+
"setView": {
22+
"type": "object",
23+
"required": ["name", "setSize", "createdAt", "updatedAt"],
24+
"properties": {
25+
"name": {
26+
"type": "string",
27+
"minLength": 3,
28+
"maxLength": 128
29+
},
30+
"description": {
31+
"type": "string",
32+
"maxGraphemes": 1024,
33+
"maxLength": 10240
34+
},
35+
"setSize": {
36+
"type": "integer"
37+
},
38+
"createdAt": {
39+
"type": "string",
40+
"format": "datetime"
41+
},
42+
"updatedAt": {
43+
"type": "string",
44+
"format": "datetime"
45+
}
46+
}
47+
}
48+
}
49+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"lexicon": 1,
3+
"id": "tools.ozone.set.deleteSet",
4+
"defs": {
5+
"main": {
6+
"type": "procedure",
7+
"description": "Delete an entire set. Attempting to delete a set that does not exist will result in an error.",
8+
"input": {
9+
"encoding": "application/json",
10+
"schema": {
11+
"type": "object",
12+
"required": ["name"],
13+
"properties": {
14+
"name": {
15+
"type": "string",
16+
"description": "Name of the set to delete"
17+
}
18+
}
19+
}
20+
},
21+
"output": {
22+
"encoding": "application/json",
23+
"schema": {
24+
"type": "object",
25+
"properties": {}
26+
}
27+
},
28+
"errors": [
29+
{
30+
"name": "SetNotFound",
31+
"description": "set with the given name does not exist"
32+
}
33+
]
34+
}
35+
}
36+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"lexicon": 1,
3+
"id": "tools.ozone.set.deleteValues",
4+
"defs": {
5+
"main": {
6+
"type": "procedure",
7+
"description": "Delete values from a specific set. Attempting to delete values that are not in the set will not result in an error",
8+
"input": {
9+
"encoding": "application/json",
10+
"schema": {
11+
"type": "object",
12+
"required": ["name", "values"],
13+
"properties": {
14+
"name": {
15+
"type": "string",
16+
"description": "Name of the set to delete values from"
17+
},
18+
"values": {
19+
"type": "array",
20+
"minLength": 1,
21+
"items": {
22+
"type": "string"
23+
},
24+
"description": "Array of string values to delete from the set"
25+
}
26+
}
27+
}
28+
},
29+
"errors": [
30+
{
31+
"name": "SetNotFound",
32+
"description": "set with the given name does not exist"
33+
}
34+
]
35+
}
36+
}
37+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"lexicon": 1,
3+
"id": "tools.ozone.set.getValues",
4+
"defs": {
5+
"main": {
6+
"type": "query",
7+
"description": "Get a specific set and its values",
8+
"parameters": {
9+
"type": "params",
10+
"required": ["name"],
11+
"properties": {
12+
"name": {
13+
"type": "string"
14+
},
15+
"limit": {
16+
"type": "integer",
17+
"minimum": 1,
18+
"maximum": 1000,
19+
"default": 100
20+
},
21+
"cursor": {
22+
"type": "string"
23+
}
24+
}
25+
},
26+
"output": {
27+
"encoding": "application/json",
28+
"schema": {
29+
"type": "object",
30+
"required": ["set", "values"],
31+
"properties": {
32+
"set": {
33+
"type": "ref",
34+
"ref": "tools.ozone.set.defs#setView"
35+
},
36+
"values": {
37+
"type": "array",
38+
"items": {
39+
"type": "string"
40+
}
41+
},
42+
"cursor": {
43+
"type": "string"
44+
}
45+
}
46+
}
47+
},
48+
"errors": [
49+
{
50+
"name": "SetNotFound",
51+
"description": "set with the given name does not exist"
52+
}
53+
]
54+
}
55+
}
56+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
{
2+
"lexicon": 1,
3+
"id": "tools.ozone.set.querySets",
4+
"defs": {
5+
"main": {
6+
"type": "query",
7+
"description": "Query available sets",
8+
"parameters": {
9+
"type": "params",
10+
"properties": {
11+
"limit": {
12+
"type": "integer",
13+
"minimum": 1,
14+
"maximum": 100,
15+
"default": 50
16+
},
17+
"cursor": {
18+
"type": "string"
19+
},
20+
"namePrefix": {
21+
"type": "string"
22+
},
23+
"sortBy": {
24+
"type": "string",
25+
"enum": ["name", "createdAt", "updatedAt"],
26+
"default": "name"
27+
},
28+
"sortDirection": {
29+
"type": "string",
30+
"default": "asc",
31+
"enum": ["asc", "desc"],
32+
"description": "Defaults to ascending order of name field."
33+
}
34+
}
35+
},
36+
"output": {
37+
"encoding": "application/json",
38+
"schema": {
39+
"type": "object",
40+
"required": ["sets"],
41+
"properties": {
42+
"sets": {
43+
"type": "array",
44+
"items": {
45+
"type": "ref",
46+
"ref": "tools.ozone.set.defs#setView"
47+
}
48+
},
49+
"cursor": {
50+
"type": "string"
51+
}
52+
}
53+
}
54+
}
55+
}
56+
}
57+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"lexicon": 1,
3+
"id": "tools.ozone.set.upsertSet",
4+
"defs": {
5+
"main": {
6+
"type": "procedure",
7+
"description": "Create or update set metadata",
8+
"input": {
9+
"encoding": "application/json",
10+
"schema": {
11+
"type": "ref",
12+
"ref": "tools.ozone.set.defs#set"
13+
}
14+
},
15+
"output": {
16+
"encoding": "application/json",
17+
"schema": {
18+
"type": "ref",
19+
"ref": "tools.ozone.set.defs#setView"
20+
}
21+
}
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)