Alternative ATProto PDS implementation
1#![allow(unnameable_types, unused_qualifications)]
2pub mod pds {
3
4 // Legacy tables
5
6 diesel::table! {
7 oauth_par_requests (request_uri) {
8 request_uri -> Varchar,
9 client_id -> Varchar,
10 response_type -> Varchar,
11 code_challenge -> Varchar,
12 code_challenge_method -> Varchar,
13 state -> Nullable<Varchar>,
14 login_hint -> Nullable<Varchar>,
15 scope -> Nullable<Varchar>,
16 redirect_uri -> Nullable<Varchar>,
17 response_mode -> Nullable<Varchar>,
18 display -> Nullable<Varchar>,
19 created_at -> Int8,
20 expires_at -> Int8,
21 }
22 }
23 diesel::table! {
24 oauth_authorization_codes (code) {
25 code -> Varchar,
26 client_id -> Varchar,
27 subject -> Varchar,
28 code_challenge -> Varchar,
29 code_challenge_method -> Varchar,
30 redirect_uri -> Varchar,
31 scope -> Nullable<Varchar>,
32 created_at -> Int8,
33 expires_at -> Int8,
34 used -> Bool,
35 }
36 }
37 diesel::table! {
38 oauth_refresh_tokens (token) {
39 token -> Varchar,
40 client_id -> Varchar,
41 subject -> Varchar,
42 dpop_thumbprint -> Varchar,
43 scope -> Nullable<Varchar>,
44 created_at -> Int8,
45 expires_at -> Int8,
46 revoked -> Bool,
47 }
48 }
49 diesel::table! {
50 oauth_used_jtis (jti) {
51 jti -> Varchar,
52 issuer -> Varchar,
53 created_at -> Int8,
54 expires_at -> Int8,
55 }
56 }
57
58 // Upcoming tables
59
60 diesel::table! {
61 account (did) {
62 did -> Varchar,
63 email -> Varchar,
64 recoveryKey -> Nullable<Varchar>,
65 password -> Varchar,
66 createdAt -> Varchar,
67 invitesDisabled -> Int2,
68 emailConfirmedAt -> Nullable<Varchar>,
69 }
70 }
71
72 diesel::table! {
73 actor (did) {
74 did -> Varchar,
75 handle -> Nullable<Varchar>,
76 createdAt -> Varchar,
77 takedownRef -> Nullable<Varchar>,
78 deactivatedAt -> Nullable<Varchar>,
79 deleteAfter -> Nullable<Varchar>,
80 }
81 }
82
83 diesel::table! {
84 app_password (did, name) {
85 did -> Varchar,
86 name -> Varchar,
87 password -> Varchar,
88 createdAt -> Varchar,
89 }
90 }
91
92 diesel::table! {
93 authorization_request (id) {
94 id -> Varchar,
95 did -> Nullable<Varchar>,
96 deviceId -> Nullable<Varchar>,
97 clientId -> Varchar,
98 clientAuth -> Varchar,
99 parameters -> Varchar,
100 expiresAt -> TimestamptzSqlite,
101 code -> Nullable<Varchar>,
102 }
103 }
104
105 diesel::table! {
106 device (id) {
107 id -> Varchar,
108 sessionId -> Nullable<Varchar>,
109 userAgent -> Nullable<Varchar>,
110 ipAddress -> Varchar,
111 lastSeenAt -> TimestamptzSqlite,
112 }
113 }
114
115 diesel::table! {
116 device_account (deviceId, did) {
117 did -> Varchar,
118 deviceId -> Varchar,
119 authenticatedAt -> TimestamptzSqlite,
120 remember -> Bool,
121 authorizedClients -> Varchar,
122 }
123 }
124
125 diesel::table! {
126 did_doc (did) {
127 did -> Varchar,
128 doc -> Text,
129 updatedAt -> Int8,
130 }
131 }
132
133 diesel::table! {
134 email_token (purpose, did) {
135 purpose -> Varchar,
136 did -> Varchar,
137 token -> Varchar,
138 requestedAt -> Varchar,
139 }
140 }
141
142 diesel::table! {
143 invite_code (code) {
144 code -> Varchar,
145 availableUses -> Int4,
146 disabled -> Int2,
147 forAccount -> Varchar,
148 createdBy -> Varchar,
149 createdAt -> Varchar,
150 }
151 }
152
153 diesel::table! {
154 invite_code_use (code, usedBy) {
155 code -> Varchar,
156 usedBy -> Varchar,
157 usedAt -> Varchar,
158 }
159 }
160
161 diesel::table! {
162 refresh_token (id) {
163 id -> Varchar,
164 did -> Varchar,
165 expiresAt -> Varchar,
166 nextId -> Nullable<Varchar>,
167 appPasswordName -> Nullable<Varchar>,
168 }
169 }
170
171 diesel::table! {
172 repo_seq (seq) {
173 seq -> Int8,
174 did -> Varchar,
175 eventType -> Varchar,
176 event -> Bytea,
177 invalidated -> Int2,
178 sequencedAt -> Varchar,
179 }
180 }
181
182 diesel::table! {
183 token (id) {
184 id -> Varchar,
185 did -> Varchar,
186 tokenId -> Varchar,
187 createdAt -> TimestamptzSqlite,
188 updatedAt -> TimestamptzSqlite,
189 expiresAt -> TimestamptzSqlite,
190 clientId -> Varchar,
191 clientAuth -> Varchar,
192 deviceId -> Nullable<Varchar>,
193 parameters -> Varchar,
194 details -> Nullable<Varchar>,
195 code -> Nullable<Varchar>,
196 currentRefreshToken -> Nullable<Varchar>,
197 }
198 }
199
200 diesel::table! {
201 used_refresh_token (refreshToken) {
202 refreshToken -> Varchar,
203 tokenId -> Varchar,
204 }
205 }
206
207 diesel::allow_tables_to_appear_in_same_query!(
208 account,
209 actor,
210 app_password,
211 authorization_request,
212 device,
213 device_account,
214 did_doc,
215 email_token,
216 invite_code,
217 invite_code_use,
218 refresh_token,
219 repo_seq,
220 token,
221 used_refresh_token,
222 );
223}
224
225pub mod actor_store {
226 // Actor Store
227
228 // Blob
229 diesel::table! {
230 blob (cid, did) {
231 cid -> Varchar,
232 did -> Varchar,
233 mimeType -> Varchar,
234 size -> Int4,
235 tempKey -> Nullable<Varchar>,
236 width -> Nullable<Int4>,
237 height -> Nullable<Int4>,
238 createdAt -> Varchar,
239 takedownRef -> Nullable<Varchar>,
240 }
241 }
242
243 diesel::table! {
244 record_blob (blobCid, recordUri) {
245 blobCid -> Varchar,
246 recordUri -> Varchar,
247 did -> Varchar,
248 }
249 }
250
251 // Preference
252
253 diesel::table! {
254 account_pref (id) {
255 id -> Int4,
256 did -> Varchar,
257 name -> Varchar,
258 valueJson -> Nullable<Text>,
259 }
260 }
261 // Record
262
263 diesel::table! {
264 record (uri) {
265 uri -> Varchar,
266 cid -> Varchar,
267 did -> Varchar,
268 collection -> Varchar,
269 rkey -> Varchar,
270 repoRev -> Nullable<Varchar>,
271 indexedAt -> Varchar,
272 takedownRef -> Nullable<Varchar>,
273 }
274 }
275
276 diesel::table! {
277 repo_block (cid, did) {
278 cid -> Varchar,
279 did -> Varchar,
280 repoRev -> Varchar,
281 size -> Int4,
282 content -> Bytea,
283 }
284 }
285
286 diesel::table! {
287 backlink (uri, path) {
288 uri -> Varchar,
289 path -> Varchar,
290 linkTo -> Varchar,
291 }
292 }
293 // sql_repo
294
295 diesel::table! {
296 repo_root (did) {
297 did -> Varchar,
298 cid -> Varchar,
299 rev -> Varchar,
300 indexedAt -> Varchar,
301 }
302 }
303
304 diesel::allow_tables_to_appear_in_same_query!(
305 account_pref,
306 backlink,
307 blob,
308 record,
309 record_blob,
310 repo_block,
311 repo_root,
312 );
313}