@atproto/bsky 0.0.10 → 0.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/api/com/atproto/admin/util.d.ts +5 -0
  3. package/dist/config.d.ts +2 -0
  4. package/dist/context.d.ts +8 -0
  5. package/dist/db/index.js +51 -2
  6. package/dist/db/index.js.map +3 -3
  7. package/dist/db/migrations/20230929T192920807Z-record-cursor-indexes.d.ts +3 -0
  8. package/dist/db/migrations/index.d.ts +1 -0
  9. package/dist/did-cache.d.ts +2 -2
  10. package/dist/index.d.ts +2 -0
  11. package/dist/index.js +1818 -580
  12. package/dist/index.js.map +3 -3
  13. package/dist/lexicon/index.d.ts +16 -0
  14. package/dist/lexicon/lexicons.d.ts +330 -3
  15. package/dist/lexicon/types/app/bsky/actor/defs.d.ts +1 -0
  16. package/dist/lexicon/types/com/atproto/admin/defs.d.ts +28 -0
  17. package/dist/lexicon/types/com/atproto/admin/getAccountInfo.d.ts +29 -0
  18. package/dist/lexicon/types/com/atproto/admin/getSubjectStatus.d.ts +39 -0
  19. package/dist/lexicon/types/com/atproto/admin/searchRepos.d.ts +0 -1
  20. package/dist/lexicon/types/com/atproto/admin/updateSubjectStatus.d.ts +46 -0
  21. package/dist/lexicon/types/com/atproto/server/confirmEmail.d.ts +27 -0
  22. package/dist/lexicon/types/com/atproto/server/createAccount.d.ts +2 -0
  23. package/dist/lexicon/types/com/atproto/server/createSession.d.ts +2 -0
  24. package/dist/lexicon/types/com/atproto/server/getSession.d.ts +1 -0
  25. package/dist/lexicon/types/com/atproto/server/refreshSession.d.ts +1 -0
  26. package/dist/lexicon/types/com/atproto/server/requestEmailConfirmation.d.ts +19 -0
  27. package/dist/lexicon/types/com/atproto/server/requestEmailUpdate.d.ts +30 -0
  28. package/dist/lexicon/types/com/atproto/server/reserveSigningKey.d.ts +30 -0
  29. package/dist/lexicon/types/com/atproto/server/updateEmail.d.ts +27 -0
  30. package/dist/lexicon/types/com/atproto/sync/listRepos.d.ts +1 -0
  31. package/dist/services/actor/index.d.ts +2 -2
  32. package/dist/services/actor/types.d.ts +1 -0
  33. package/dist/services/graph/index.d.ts +2 -0
  34. package/dist/services/moderation/index.d.ts +13 -3
  35. package/dist/services/util/search.d.ts +3 -3
  36. package/package.json +13 -14
  37. package/src/api/app/bsky/actor/searchActors.ts +36 -22
  38. package/src/api/app/bsky/actor/searchActorsTypeahead.ts +24 -17
  39. package/src/api/app/bsky/feed/getAuthorFeed.ts +2 -2
  40. package/src/api/app/bsky/feed/getPostThread.ts +2 -2
  41. package/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts +1 -0
  42. package/src/api/app/bsky/notification/listNotifications.ts +33 -22
  43. package/src/api/com/atproto/admin/getModerationAction.ts +28 -2
  44. package/src/api/com/atproto/admin/getModerationReport.ts +27 -2
  45. package/src/api/com/atproto/admin/getRecord.ts +14 -2
  46. package/src/api/com/atproto/admin/getRepo.ts +13 -2
  47. package/src/api/com/atproto/admin/reverseModerationAction.ts +31 -5
  48. package/src/api/com/atproto/admin/searchRepos.ts +6 -12
  49. package/src/api/com/atproto/admin/takeModerationAction.ts +41 -7
  50. package/src/api/com/atproto/admin/util.ts +50 -0
  51. package/src/api/well-known.ts +8 -0
  52. package/src/auth.ts +12 -5
  53. package/src/auto-moderator/index.ts +1 -0
  54. package/src/config.ts +7 -0
  55. package/src/context.ts +30 -0
  56. package/src/db/migrations/20230929T192920807Z-record-cursor-indexes.ts +40 -0
  57. package/src/db/migrations/index.ts +1 -0
  58. package/src/did-cache.ts +29 -14
  59. package/src/feed-gen/with-friends.ts +2 -2
  60. package/src/index.ts +9 -1
  61. package/src/indexer/subscription.ts +1 -21
  62. package/src/lexicon/index.ts +96 -0
  63. package/src/lexicon/lexicons.ts +368 -4
  64. package/src/lexicon/types/app/bsky/actor/defs.ts +1 -0
  65. package/src/lexicon/types/com/atproto/admin/defs.ts +61 -0
  66. package/src/lexicon/types/com/atproto/admin/getAccountInfo.ts +41 -0
  67. package/src/lexicon/types/com/atproto/admin/getSubjectStatus.ts +54 -0
  68. package/src/lexicon/types/com/atproto/admin/searchRepos.ts +0 -1
  69. package/src/lexicon/types/com/atproto/admin/updateSubjectStatus.ts +61 -0
  70. package/src/lexicon/types/com/atproto/server/confirmEmail.ts +40 -0
  71. package/src/lexicon/types/com/atproto/server/createAccount.ts +2 -0
  72. package/src/lexicon/types/com/atproto/server/createSession.ts +2 -0
  73. package/src/lexicon/types/com/atproto/server/getSession.ts +1 -0
  74. package/src/lexicon/types/com/atproto/server/refreshSession.ts +1 -0
  75. package/src/lexicon/types/com/atproto/server/requestEmailConfirmation.ts +31 -0
  76. package/src/lexicon/types/com/atproto/server/requestEmailUpdate.ts +43 -0
  77. package/src/lexicon/types/com/atproto/server/reserveSigningKey.ts +44 -0
  78. package/src/lexicon/types/com/atproto/server/updateEmail.ts +41 -0
  79. package/src/lexicon/types/com/atproto/sync/listRepos.ts +1 -0
  80. package/src/logger.ts +8 -0
  81. package/src/services/actor/index.ts +16 -10
  82. package/src/services/actor/types.ts +1 -0
  83. package/src/services/actor/views.ts +26 -8
  84. package/src/services/graph/index.ts +26 -7
  85. package/src/services/indexing/index.ts +15 -17
  86. package/src/services/moderation/index.ts +94 -14
  87. package/src/services/moderation/views.ts +1 -0
  88. package/src/services/util/search.ts +24 -23
  89. package/tests/__snapshots__/feed-generation.test.ts.snap +12 -12
  90. package/tests/__snapshots__/indexing.test.ts.snap +4 -4
  91. package/tests/admin/__snapshots__/get-moderation-action.test.ts.snap +172 -0
  92. package/tests/admin/__snapshots__/get-moderation-actions.test.ts.snap +178 -0
  93. package/tests/admin/__snapshots__/get-moderation-report.test.ts.snap +177 -0
  94. package/tests/admin/__snapshots__/get-moderation-reports.test.ts.snap +307 -0
  95. package/tests/admin/__snapshots__/get-record.test.ts.snap +275 -0
  96. package/tests/admin/__snapshots__/get-repo.test.ts.snap +103 -0
  97. package/tests/admin/get-moderation-action.test.ts +100 -0
  98. package/tests/admin/get-moderation-actions.test.ts +164 -0
  99. package/tests/admin/get-moderation-report.test.ts +100 -0
  100. package/tests/admin/get-moderation-reports.test.ts +332 -0
  101. package/tests/admin/get-record.test.ts +115 -0
  102. package/tests/admin/get-repo.test.ts +101 -0
  103. package/tests/{moderation.test.ts → admin/moderation.test.ts} +107 -9
  104. package/tests/admin/repo-search.test.ts +124 -0
  105. package/tests/algos/hot-classic.test.ts +3 -5
  106. package/tests/algos/whats-hot.test.ts +3 -5
  107. package/tests/algos/with-friends.test.ts +2 -4
  108. package/tests/auth.test.ts +64 -0
  109. package/tests/auto-moderator/fuzzy-matcher.test.ts +2 -3
  110. package/tests/auto-moderator/labeler.test.ts +5 -7
  111. package/tests/auto-moderator/takedowns.test.ts +11 -12
  112. package/tests/blob-resolver.test.ts +1 -3
  113. package/tests/did-cache.test.ts +2 -5
  114. package/tests/feed-generation.test.ts +8 -6
  115. package/tests/handle-invalidation.test.ts +2 -3
  116. package/tests/image/server.test.ts +1 -4
  117. package/tests/image/sharp.test.ts +1 -1
  118. package/tests/indexing.test.ts +4 -4
  119. package/tests/notification-server.test.ts +2 -3
  120. package/tests/pipeline/backpressure.test.ts +2 -3
  121. package/tests/pipeline/reingest.test.ts +7 -4
  122. package/tests/pipeline/repartition.test.ts +2 -3
  123. package/tests/reprocessing.test.ts +2 -6
  124. package/tests/seeds/basic.ts +4 -4
  125. package/tests/seeds/follows.ts +1 -1
  126. package/tests/seeds/likes.ts +1 -1
  127. package/tests/seeds/reposts.ts +1 -1
  128. package/tests/seeds/users-bulk.ts +1 -1
  129. package/tests/seeds/users.ts +1 -1
  130. package/tests/server.test.ts +1 -3
  131. package/tests/subscription/repo.test.ts +2 -4
  132. package/tests/views/__snapshots__/author-feed.test.ts.snap +24 -24
  133. package/tests/views/__snapshots__/block-lists.test.ts.snap +42 -7
  134. package/tests/views/__snapshots__/blocks.test.ts.snap +2 -2
  135. package/tests/views/__snapshots__/list-feed.test.ts.snap +6 -6
  136. package/tests/views/__snapshots__/mute-lists.test.ts.snap +15 -4
  137. package/tests/views/__snapshots__/mutes.test.ts.snap +2 -2
  138. package/tests/views/__snapshots__/notifications.test.ts.snap +2 -2
  139. package/tests/views/__snapshots__/posts.test.ts.snap +8 -8
  140. package/tests/views/__snapshots__/thread.test.ts.snap +10 -10
  141. package/tests/views/__snapshots__/timeline.test.ts.snap +58 -58
  142. package/tests/views/actor-likes.test.ts +2 -3
  143. package/tests/views/actor-search.test.ts +5 -5
  144. package/tests/views/admin/repo-search.test.ts +2 -4
  145. package/tests/views/author-feed.test.ts +2 -4
  146. package/tests/views/block-lists.test.ts +34 -7
  147. package/tests/views/blocks.test.ts +6 -3
  148. package/tests/views/follows.test.ts +2 -4
  149. package/tests/views/likes.test.ts +2 -5
  150. package/tests/views/list-feed.test.ts +2 -4
  151. package/tests/views/mute-lists.test.ts +23 -5
  152. package/tests/views/mutes.test.ts +2 -5
  153. package/tests/views/notifications.test.ts +2 -4
  154. package/tests/views/posts.test.ts +2 -5
  155. package/tests/views/profile.test.ts +4 -5
  156. package/tests/views/reposts.test.ts +2 -4
  157. package/tests/views/suggested-follows.test.ts +2 -3
  158. package/tests/views/suggestions.test.ts +2 -4
  159. package/tests/views/thread.test.ts +2 -4
  160. package/tests/views/threadgating.test.ts +2 -3
  161. package/tests/views/timeline.test.ts +2 -4
  162. package/dist/env.d.ts +0 -1
  163. package/example.dev.env +0 -5
  164. package/src/env.ts +0 -9
  165. package/tests/seeds/client.ts +0 -466
  166. /package/tests/{__snapshots__ → admin/__snapshots__}/moderation.test.ts.snap +0 -0
  167. /package/tests/{image/fixtures → sample-img}/at.png +0 -0
  168. /package/tests/{image/fixtures → sample-img}/hd-key.jpg +0 -0
  169. /package/tests/{image/fixtures → sample-img}/key-alt.jpg +0 -0
  170. /package/tests/{image/fixtures → sample-img}/key-landscape-large.jpg +0 -0
  171. /package/tests/{image/fixtures → sample-img}/key-landscape-small.jpg +0 -0
  172. /package/tests/{image/fixtures → sample-img}/key-portrait-large.jpg +0 -0
  173. /package/tests/{image/fixtures → sample-img}/key-portrait-small.jpg +0 -0
@@ -0,0 +1,39 @@
1
+ import express from 'express';
2
+ import { HandlerAuth } from '@atproto/xrpc-server';
3
+ import * as ComAtprotoAdminDefs from './defs';
4
+ import * as ComAtprotoRepoStrongRef from '../repo/strongRef';
5
+ export interface QueryParams {
6
+ did?: string;
7
+ uri?: string;
8
+ blob?: string;
9
+ }
10
+ export declare type InputSchema = undefined;
11
+ export interface OutputSchema {
12
+ subject: ComAtprotoAdminDefs.RepoRef | ComAtprotoRepoStrongRef.Main | ComAtprotoAdminDefs.RepoBlobRef | {
13
+ $type: string;
14
+ [k: string]: unknown;
15
+ };
16
+ takedown?: ComAtprotoAdminDefs.StatusAttr;
17
+ [k: string]: unknown;
18
+ }
19
+ export declare type HandlerInput = undefined;
20
+ export interface HandlerSuccess {
21
+ encoding: 'application/json';
22
+ body: OutputSchema;
23
+ headers?: {
24
+ [key: string]: string;
25
+ };
26
+ }
27
+ export interface HandlerError {
28
+ status: number;
29
+ message?: string;
30
+ }
31
+ export declare type HandlerOutput = HandlerError | HandlerSuccess;
32
+ export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
33
+ auth: HA;
34
+ params: QueryParams;
35
+ input: HandlerInput;
36
+ req: express.Request;
37
+ res: express.Response;
38
+ };
39
+ export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
@@ -4,7 +4,6 @@ import * as ComAtprotoAdminDefs from './defs';
4
4
  export interface QueryParams {
5
5
  term?: string;
6
6
  q?: string;
7
- invitedBy?: string;
8
7
  limit: number;
9
8
  cursor?: string;
10
9
  }
@@ -0,0 +1,46 @@
1
+ import express from 'express';
2
+ import { HandlerAuth } from '@atproto/xrpc-server';
3
+ import * as ComAtprotoAdminDefs from './defs';
4
+ import * as ComAtprotoRepoStrongRef from '../repo/strongRef';
5
+ export interface QueryParams {
6
+ }
7
+ export interface InputSchema {
8
+ subject: ComAtprotoAdminDefs.RepoRef | ComAtprotoRepoStrongRef.Main | ComAtprotoAdminDefs.RepoBlobRef | {
9
+ $type: string;
10
+ [k: string]: unknown;
11
+ };
12
+ takedown?: ComAtprotoAdminDefs.StatusAttr;
13
+ [k: string]: unknown;
14
+ }
15
+ export interface OutputSchema {
16
+ subject: ComAtprotoAdminDefs.RepoRef | ComAtprotoRepoStrongRef.Main | ComAtprotoAdminDefs.RepoBlobRef | {
17
+ $type: string;
18
+ [k: string]: unknown;
19
+ };
20
+ takedown?: ComAtprotoAdminDefs.StatusAttr;
21
+ [k: string]: unknown;
22
+ }
23
+ export interface HandlerInput {
24
+ encoding: 'application/json';
25
+ body: InputSchema;
26
+ }
27
+ export interface HandlerSuccess {
28
+ encoding: 'application/json';
29
+ body: OutputSchema;
30
+ headers?: {
31
+ [key: string]: string;
32
+ };
33
+ }
34
+ export interface HandlerError {
35
+ status: number;
36
+ message?: string;
37
+ }
38
+ export declare type HandlerOutput = HandlerError | HandlerSuccess;
39
+ export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
40
+ auth: HA;
41
+ params: QueryParams;
42
+ input: HandlerInput;
43
+ req: express.Request;
44
+ res: express.Response;
45
+ };
46
+ export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
@@ -0,0 +1,27 @@
1
+ import express from 'express';
2
+ import { HandlerAuth } from '@atproto/xrpc-server';
3
+ export interface QueryParams {
4
+ }
5
+ export interface InputSchema {
6
+ email: string;
7
+ token: string;
8
+ [k: string]: unknown;
9
+ }
10
+ export interface HandlerInput {
11
+ encoding: 'application/json';
12
+ body: InputSchema;
13
+ }
14
+ export interface HandlerError {
15
+ status: number;
16
+ message?: string;
17
+ error?: 'AccountNotFound' | 'ExpiredToken' | 'InvalidToken' | 'InvalidEmail';
18
+ }
19
+ export declare type HandlerOutput = HandlerError | void;
20
+ export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
21
+ auth: HA;
22
+ params: QueryParams;
23
+ input: HandlerInput;
24
+ req: express.Request;
25
+ res: express.Response;
26
+ };
27
+ export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
@@ -9,6 +9,7 @@ export interface InputSchema {
9
9
  inviteCode?: string;
10
10
  password: string;
11
11
  recoveryKey?: string;
12
+ plcOp?: Uint8Array;
12
13
  [k: string]: unknown;
13
14
  }
14
15
  export interface OutputSchema {
@@ -16,6 +17,7 @@ export interface OutputSchema {
16
17
  refreshJwt: string;
17
18
  handle: string;
18
19
  did: string;
20
+ didDoc?: {};
19
21
  [k: string]: unknown;
20
22
  }
21
23
  export interface HandlerInput {
@@ -12,7 +12,9 @@ export interface OutputSchema {
12
12
  refreshJwt: string;
13
13
  handle: string;
14
14
  did: string;
15
+ didDoc?: {};
15
16
  email?: string;
17
+ emailConfirmed?: boolean;
16
18
  [k: string]: unknown;
17
19
  }
18
20
  export interface HandlerInput {
@@ -7,6 +7,7 @@ export interface OutputSchema {
7
7
  handle: string;
8
8
  did: string;
9
9
  email?: string;
10
+ emailConfirmed?: boolean;
10
11
  [k: string]: unknown;
11
12
  }
12
13
  export declare type HandlerInput = undefined;
@@ -8,6 +8,7 @@ export interface OutputSchema {
8
8
  refreshJwt: string;
9
9
  handle: string;
10
10
  did: string;
11
+ didDoc?: {};
11
12
  [k: string]: unknown;
12
13
  }
13
14
  export declare type HandlerInput = undefined;
@@ -0,0 +1,19 @@
1
+ import express from 'express';
2
+ import { HandlerAuth } from '@atproto/xrpc-server';
3
+ export interface QueryParams {
4
+ }
5
+ export declare type InputSchema = undefined;
6
+ export declare type HandlerInput = undefined;
7
+ export interface HandlerError {
8
+ status: number;
9
+ message?: string;
10
+ }
11
+ export declare type HandlerOutput = HandlerError | void;
12
+ export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
13
+ auth: HA;
14
+ params: QueryParams;
15
+ input: HandlerInput;
16
+ req: express.Request;
17
+ res: express.Response;
18
+ };
19
+ export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
@@ -0,0 +1,30 @@
1
+ import express from 'express';
2
+ import { HandlerAuth } from '@atproto/xrpc-server';
3
+ export interface QueryParams {
4
+ }
5
+ export declare type InputSchema = undefined;
6
+ export interface OutputSchema {
7
+ tokenRequired: boolean;
8
+ [k: string]: unknown;
9
+ }
10
+ export declare type HandlerInput = undefined;
11
+ export interface HandlerSuccess {
12
+ encoding: 'application/json';
13
+ body: OutputSchema;
14
+ headers?: {
15
+ [key: string]: string;
16
+ };
17
+ }
18
+ export interface HandlerError {
19
+ status: number;
20
+ message?: string;
21
+ }
22
+ export declare type HandlerOutput = HandlerError | HandlerSuccess;
23
+ export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
24
+ auth: HA;
25
+ params: QueryParams;
26
+ input: HandlerInput;
27
+ req: express.Request;
28
+ res: express.Response;
29
+ };
30
+ export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
@@ -0,0 +1,30 @@
1
+ import express from 'express';
2
+ import { HandlerAuth } from '@atproto/xrpc-server';
3
+ export interface QueryParams {
4
+ }
5
+ export declare type InputSchema = undefined;
6
+ export interface OutputSchema {
7
+ signingKey: string;
8
+ [k: string]: unknown;
9
+ }
10
+ export declare type HandlerInput = undefined;
11
+ export interface HandlerSuccess {
12
+ encoding: 'application/json';
13
+ body: OutputSchema;
14
+ headers?: {
15
+ [key: string]: string;
16
+ };
17
+ }
18
+ export interface HandlerError {
19
+ status: number;
20
+ message?: string;
21
+ }
22
+ export declare type HandlerOutput = HandlerError | HandlerSuccess;
23
+ export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
24
+ auth: HA;
25
+ params: QueryParams;
26
+ input: HandlerInput;
27
+ req: express.Request;
28
+ res: express.Response;
29
+ };
30
+ export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
@@ -0,0 +1,27 @@
1
+ import express from 'express';
2
+ import { HandlerAuth } from '@atproto/xrpc-server';
3
+ export interface QueryParams {
4
+ }
5
+ export interface InputSchema {
6
+ email: string;
7
+ token?: string;
8
+ [k: string]: unknown;
9
+ }
10
+ export interface HandlerInput {
11
+ encoding: 'application/json';
12
+ body: InputSchema;
13
+ }
14
+ export interface HandlerError {
15
+ status: number;
16
+ message?: string;
17
+ error?: 'ExpiredToken' | 'InvalidToken' | 'TokenRequired';
18
+ }
19
+ export declare type HandlerOutput = HandlerError | void;
20
+ export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
21
+ auth: HA;
22
+ params: QueryParams;
23
+ input: HandlerInput;
24
+ req: express.Request;
25
+ res: express.Response;
26
+ };
27
+ export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
@@ -35,6 +35,7 @@ export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCt
35
35
  export interface Repo {
36
36
  did: string;
37
37
  head: string;
38
+ rev: string;
38
39
  [k: string]: unknown;
39
40
  }
40
41
  export declare function isRepo(v: unknown): v is Repo;
@@ -15,10 +15,10 @@ export declare class ActorService {
15
15
  getActorDid(handleOrDid: string): Promise<string | null>;
16
16
  getActor(handleOrDid: string, includeSoftDeleted?: boolean): Promise<ActorResult | null>;
17
17
  getActors(handleOrDids: string[], includeSoftDeleted?: boolean): Promise<ActorResult[]>;
18
- getSearchResults({ cursor, limit, term, includeSoftDeleted, }: {
18
+ getSearchResults({ cursor, limit, query, includeSoftDeleted, }: {
19
19
  cursor?: string;
20
20
  limit?: number;
21
- term?: string;
21
+ query?: string;
22
22
  includeSoftDeleted?: boolean;
23
23
  }): Promise<{
24
24
  results: Actor[];
@@ -15,6 +15,7 @@ export declare type ActorInfo = {
15
15
  mutedByList?: ListViewBasic;
16
16
  blockedBy?: boolean;
17
17
  blocking?: string;
18
+ blockingByList?: ListViewBasic;
18
19
  following?: string;
19
20
  followedBy?: string;
20
21
  };
@@ -85,6 +85,7 @@ export declare type RelationshipPair = [didA: string, didB: string];
85
85
  export declare class BlockAndMuteState {
86
86
  hasIdx: Map<string, Set<string>>;
87
87
  blockIdx: Map<string, Map<string, string>>;
88
+ blockListIdx: Map<string, Map<string, string>>;
88
89
  muteIdx: Map<string, Set<string>>;
89
90
  muteListIdx: Map<string, Map<string, string>>;
90
91
  constructor(items?: BlockAndMuteInfo[]);
@@ -93,6 +94,7 @@ export declare class BlockAndMuteState {
93
94
  blocking(pair: RelationshipPair): string | null;
94
95
  blockedBy(pair: RelationshipPair): string | null;
95
96
  mute(pair: RelationshipPair): boolean;
97
+ blockList(pair: RelationshipPair): string | null;
96
98
  muteList(pair: RelationshipPair): string | null;
97
99
  has(pair: RelationshipPair): boolean;
98
100
  }
@@ -6,6 +6,8 @@ import { ModerationAction, ModerationReport } from '../../db/tables/moderation';
6
6
  import { ModerationViews } from './views';
7
7
  import { ImageUriBuilder } from '../../image/uri';
8
8
  import { ImageInvalidator } from '../../image/invalidator';
9
+ import { RepoRef, RepoBlobRef } from '../../lexicon/types/com/atproto/admin/defs';
10
+ import { Main as StrongRef } from '../../lexicon/types/com/atproto/repo/strongRef';
9
11
  export declare class ModerationService {
10
12
  db: PrimaryDatabase;
11
13
  imgUriBuilder: ImageUriBuilder;
@@ -74,20 +76,24 @@ export declare class ModerationService {
74
76
  durationInHours?: number;
75
77
  }): Promise<ModerationActionRow>;
76
78
  getActionsDueForReversal(): Promise<ModerationActionRow[]>;
77
- revertAction({ id, createdBy, createdAt, reason, }: ReversibleModerationAction): Promise<ModerationActionRow>;
79
+ revertAction({ id, createdBy, createdAt, reason, }: ReversibleModerationAction): Promise<{
80
+ result: ModerationActionRow;
81
+ restored?: TakedownSubjects;
82
+ }>;
78
83
  logReverseAction(info: ReversibleModerationAction): Promise<ModerationActionRow>;
79
84
  takedownRepo(info: {
80
85
  takedownId: number;
81
86
  did: string;
82
- }): Promise<void>;
87
+ }): Promise<TakedownSubjects>;
83
88
  reverseTakedownRepo(info: {
84
89
  did: string;
85
90
  }): Promise<void>;
86
91
  takedownRecord(info: {
87
92
  takedownId: number;
88
93
  uri: AtUri;
94
+ cid: CID;
89
95
  blobCids?: CID[];
90
- }): Promise<void>;
96
+ }): Promise<TakedownSubjects>;
91
97
  reverseTakedownRecord(info: {
92
98
  uri: AtUri;
93
99
  }): Promise<void>;
@@ -110,6 +116,10 @@ export declare class ModerationService {
110
116
  createdAt?: Date;
111
117
  }): Promise<ModerationReportRow>;
112
118
  }
119
+ export declare type TakedownSubjects = {
120
+ did: string;
121
+ subjects: (RepoRef | RepoBlobRef | StrongRef)[];
122
+ };
113
123
  export declare type ModerationActionRow = Selectable<ModerationAction>;
114
124
  export declare type ReversibleModerationAction = Pick<ModerationActionRow, 'id' | 'createdBy' | 'reason'> & {
115
125
  createdAt?: Date;
@@ -1,7 +1,7 @@
1
1
  import { Database } from '../../db';
2
2
  import { GenericKeyset } from '../../db/pagination';
3
3
  export declare const getUserSearchQuery: (db: Database, opts: {
4
- term: string;
4
+ query: string;
5
5
  limit: number;
6
6
  cursor?: string;
7
7
  includeSoftDeleted?: boolean;
@@ -10,13 +10,13 @@ export declare const getUserSearchQuery: (db: Database, opts: {
10
10
  distance: number;
11
11
  }, "results">>, "actor" | "results", {}>;
12
12
  export declare const getUserSearchQuerySimple: (db: Database, opts: {
13
- term: string;
13
+ query: string;
14
14
  limit: number;
15
15
  }) => import("kysely").SelectQueryBuilder<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, import("kysely").AliasedQueryBuilder<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, import("kysely").AliasedQueryBuilder<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "actor">, "actor", import("kysely").Selection<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "actor">, "actor", import("kysely").AliasedRawBuilder<number, "distance"> | import("kysely").AliasedRawBuilder<unknown, "did">>, "accounts_and_profiles">>, "accounts_and_profiles", {
16
16
  did: unknown;
17
17
  distance: number;
18
18
  }, "results">>, "actor" | "results", {}>;
19
- export declare const cleanTerm: (term: string) => string;
19
+ export declare const cleanQuery: (query: string) => string;
20
20
  declare type Result = {
21
21
  distance: number;
22
22
  did: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/bsky",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "license": "MIT",
5
5
  "description": "Reference implementation of app.bsky App View (Bluesky API)",
6
6
  "keywords": [
@@ -20,7 +20,6 @@
20
20
  "@isaacs/ttlcache": "^1.4.1",
21
21
  "compression": "^1.7.4",
22
22
  "cors": "^2.8.5",
23
- "dotenv": "^16.0.0",
24
23
  "express": "^4.17.2",
25
24
  "express-async-errors": "^3.1.1",
26
25
  "form-data": "^4.0.0",
@@ -36,14 +35,14 @@
36
35
  "sharp": "^0.31.2",
37
36
  "typed-emitter": "^2.1.0",
38
37
  "uint8arrays": "3.0.0",
39
- "@atproto/api": "^0.6.19",
40
- "@atproto/common": "^0.3.0",
38
+ "@atproto/api": "^0.6.21",
39
+ "@atproto/common": "^0.3.2",
41
40
  "@atproto/crypto": "^0.2.2",
42
- "@atproto/syntax": "^0.1.1",
43
- "@atproto/identity": "^0.2.0",
44
- "@atproto/lexicon": "^0.2.1",
45
- "@atproto/repo": "^0.3.1",
46
- "@atproto/xrpc-server": "^0.3.1"
41
+ "@atproto/syntax": "^0.1.3",
42
+ "@atproto/identity": "^0.3.0",
43
+ "@atproto/lexicon": "^0.2.3",
44
+ "@atproto/repo": "^0.3.3",
45
+ "@atproto/xrpc-server": "^0.3.3"
47
46
  },
48
47
  "devDependencies": {
49
48
  "@did-plc/server": "^0.0.1",
@@ -54,11 +53,11 @@
54
53
  "@types/qs": "^6.9.7",
55
54
  "@types/sharp": "^0.31.0",
56
55
  "axios": "^0.27.2",
57
- "@atproto/api": "^0.6.19",
58
- "@atproto/dev-env": "^0.2.10",
59
- "@atproto/lex-cli": "^0.2.1",
60
- "@atproto/pds": "^0.1.19",
61
- "@atproto/xrpc": "^0.3.1"
56
+ "@atproto/api": "^0.6.21",
57
+ "@atproto/dev-env": "^0.2.12",
58
+ "@atproto/lex-cli": "^0.2.3",
59
+ "@atproto/pds": "^0.3.0",
60
+ "@atproto/xrpc": "^0.3.3"
62
61
  },
63
62
  "scripts": {
64
63
  "codegen": "lex gen-server ./src/lexicon ../../lexicons/com/atproto/*/* ../../lexicons/app/bsky/*/*",
@@ -2,7 +2,7 @@ import { sql } from 'kysely'
2
2
  import AppContext from '../../../../context'
3
3
  import { Server } from '../../../../lexicon'
4
4
  import {
5
- cleanTerm,
5
+ cleanQuery,
6
6
  getUserSearchQuery,
7
7
  SearchKeyset,
8
8
  } from '../../../../services/util/search'
@@ -11,37 +11,51 @@ export default function (server: Server, ctx: AppContext) {
11
11
  server.app.bsky.actor.searchActors({
12
12
  auth: ctx.authOptionalVerifier,
13
13
  handler: async ({ auth, params }) => {
14
- let { cursor, limit, term: rawTerm, q: rawQ } = params
14
+ const { cursor, limit } = params
15
15
  const requester = auth.credentials.did
16
-
17
- // prefer new 'q' query param over deprecated 'term'
18
- if (rawQ) {
19
- rawTerm = rawQ
20
- }
21
-
22
- const term = cleanTerm(rawTerm || '')
23
-
16
+ const rawQuery = params.q ?? params.term
17
+ const query = cleanQuery(rawQuery || '')
24
18
  const db = ctx.db.getReplica('search')
25
19
 
26
- const results = term
27
- ? await getUserSearchQuery(db, { term, limit, cursor })
28
- .select('distance')
29
- .selectAll('actor')
30
- .execute()
31
- : []
32
- const keyset = new SearchKeyset(sql``, sql``)
20
+ let results: string[]
21
+ let resCursor: string | undefined
22
+ if (ctx.searchAgent) {
23
+ const res =
24
+ await ctx.searchAgent.api.app.bsky.unspecced.searchActorsSkeleton({
25
+ q: query,
26
+ cursor,
27
+ limit,
28
+ })
29
+ results = res.data.actors.map((a) => a.did)
30
+ resCursor = res.data.cursor
31
+ } else {
32
+ const res = query
33
+ ? await getUserSearchQuery(db, { query, limit, cursor })
34
+ .select('distance')
35
+ .selectAll('actor')
36
+ .execute()
37
+ : []
38
+ results = res.map((a) => a.did)
39
+ const keyset = new SearchKeyset(sql``, sql``)
40
+ resCursor = keyset.packFromResult(res)
41
+ }
33
42
 
34
43
  const actors = await ctx.services
35
44
  .actor(db)
36
- .views.profilesList(results, requester)
37
- const filtered = actors.filter(
38
- (actor) => !actor.viewer?.blocking && !actor.viewer?.blockedBy,
39
- )
45
+ .views.profiles(results, requester)
46
+
47
+ const SKIP = []
48
+ const filtered = results.flatMap((did) => {
49
+ const actor = actors[did]
50
+ if (!actor) return SKIP
51
+ if (actor.viewer?.blocking || actor.viewer?.blockedBy) return SKIP
52
+ return actor
53
+ })
40
54
 
41
55
  return {
42
56
  encoding: 'application/json',
43
57
  body: {
44
- cursor: keyset.packFromResult(results),
58
+ cursor: resCursor,
45
59
  actors: filtered,
46
60
  },
47
61
  }
@@ -1,7 +1,7 @@
1
1
  import AppContext from '../../../../context'
2
2
  import { Server } from '../../../../lexicon'
3
3
  import {
4
- cleanTerm,
4
+ cleanQuery,
5
5
  getUserSearchQuerySimple,
6
6
  } from '../../../../services/util/search'
7
7
 
@@ -9,31 +9,38 @@ export default function (server: Server, ctx: AppContext) {
9
9
  server.app.bsky.actor.searchActorsTypeahead({
10
10
  auth: ctx.authOptionalVerifier,
11
11
  handler: async ({ params, auth }) => {
12
- let { limit, term: rawTerm, q: rawQ } = params
12
+ const { limit } = params
13
13
  const requester = auth.credentials.did
14
-
15
- // prefer new 'q' query param over deprecated 'term'
16
- if (rawQ) {
17
- rawTerm = rawQ
18
- }
19
-
20
- const term = cleanTerm(rawTerm || '')
21
-
14
+ const rawQuery = params.q ?? params.term
15
+ const query = cleanQuery(rawQuery || '')
22
16
  const db = ctx.db.getReplica('search')
23
17
 
24
- const results = term
25
- ? await getUserSearchQuerySimple(db, { term, limit })
26
- .selectAll('actor')
27
- .execute()
28
- : []
18
+ let results: string[]
19
+ if (ctx.searchAgent) {
20
+ const res =
21
+ await ctx.searchAgent.api.app.bsky.unspecced.searchActorsSkeleton({
22
+ q: query,
23
+ typeahead: true,
24
+ limit,
25
+ })
26
+ results = res.data.actors.map((a) => a.did)
27
+ } else {
28
+ const res = query
29
+ ? await getUserSearchQuerySimple(db, { query, limit })
30
+ .selectAll('actor')
31
+ .execute()
32
+ : []
33
+ results = res.map((a) => a.did)
34
+ }
29
35
 
30
36
  const actors = await ctx.services
31
37
  .actor(db)
32
38
  .views.profilesBasic(results, requester, { omitLabels: true })
33
39
 
34
40
  const SKIP = []
35
- const filtered = results.flatMap((res) => {
36
- const actor = actors[res.did]
41
+ const filtered = results.flatMap((did) => {
42
+ const actor = actors[did]
43
+ if (!actor) return SKIP
37
44
  if (actor.viewer?.blocking || actor.viewer?.blockedBy) return SKIP
38
45
  return actor
39
46
  })
@@ -89,8 +89,8 @@ export const skeleton = async (
89
89
 
90
90
  if (filter === 'posts_with_media') {
91
91
  feedItemsQb = feedItemsQb
92
- // and only your own posts/reposts
93
- .where('post.creator', '=', actorDid)
92
+ // only your own posts
93
+ .where('type', '=', 'post')
94
94
  // only posts with media
95
95
  .whereExists((qb) =>
96
96
  qb
@@ -37,9 +37,9 @@ export default function (server: Server, ctx: AppContext) {
37
37
  presentation,
38
38
  )
39
39
  server.app.bsky.feed.getPostThread({
40
- auth: ctx.authOptionalVerifier,
40
+ auth: ctx.authOptionalAccessOrRoleVerifier,
41
41
  handler: async ({ params, auth, res }) => {
42
- const viewer = auth.credentials.did
42
+ const viewer = 'did' in auth.credentials ? auth.credentials.did : null
43
43
  const db = ctx.db.getReplica('thread')
44
44
  const feedService = ctx.services.feed(db)
45
45
  const actorService = ctx.services.actor(db)
@@ -78,6 +78,7 @@ async function getSkeleton(
78
78
  .selectFrom('like')
79
79
  .where('creator', '=', params.actor)
80
80
  .select(sql`split_part(subject, '/', 3)`.as('subjectDid'))
81
+ .orderBy('sortAt', 'desc')
81
82
  .limit(1000) // limit to 1000
82
83
  .as('likes'),
83
84
  )