@atproto/bsky 0.0.16 → 0.0.18

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 (110) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cache/read-through.d.ts +30 -0
  3. package/dist/config.d.ts +18 -0
  4. package/dist/context.d.ts +6 -6
  5. package/dist/daemon/config.d.ts +15 -0
  6. package/dist/daemon/context.d.ts +15 -0
  7. package/dist/daemon/index.d.ts +23 -0
  8. package/dist/daemon/logger.d.ts +3 -0
  9. package/dist/daemon/notifications.d.ts +18 -0
  10. package/dist/daemon/services.d.ts +11 -0
  11. package/dist/db/database-schema.d.ts +1 -2
  12. package/dist/db/index.js +16 -1
  13. package/dist/db/index.js.map +3 -3
  14. package/dist/db/migrations/20231205T000257238Z-remove-did-cache.d.ts +3 -0
  15. package/dist/db/migrations/index.d.ts +1 -0
  16. package/dist/did-cache.d.ts +10 -7
  17. package/dist/index.d.ts +4 -0
  18. package/dist/index.js +1921 -938
  19. package/dist/index.js.map +3 -3
  20. package/dist/indexer/context.d.ts +2 -0
  21. package/dist/indexer/index.d.ts +1 -0
  22. package/dist/lexicon/index.d.ts +12 -0
  23. package/dist/lexicon/lexicons.d.ts +134 -0
  24. package/dist/lexicon/types/com/atproto/admin/deleteAccount.d.ts +25 -0
  25. package/dist/lexicon/types/com/atproto/temp/importRepo.d.ts +32 -0
  26. package/dist/lexicon/types/com/atproto/temp/pushBlob.d.ts +25 -0
  27. package/dist/lexicon/types/com/atproto/temp/transferAccount.d.ts +42 -0
  28. package/dist/logger.d.ts +1 -0
  29. package/dist/redis.d.ts +10 -1
  30. package/dist/services/actor/index.d.ts +18 -4
  31. package/dist/services/actor/views.d.ts +5 -7
  32. package/dist/services/feed/index.d.ts +6 -4
  33. package/dist/services/feed/views.d.ts +5 -4
  34. package/dist/services/index.d.ts +3 -7
  35. package/dist/services/label/index.d.ts +10 -4
  36. package/dist/services/moderation/index.d.ts +0 -1
  37. package/dist/services/types.d.ts +3 -0
  38. package/dist/services/util/notification.d.ts +5 -0
  39. package/dist/services/util/post.d.ts +6 -6
  40. package/dist/util/retry.d.ts +1 -6
  41. package/package.json +6 -6
  42. package/src/api/app/bsky/actor/searchActorsTypeahead.ts +1 -1
  43. package/src/cache/read-through.ts +151 -0
  44. package/src/config.ts +90 -1
  45. package/src/context.ts +7 -7
  46. package/src/daemon/config.ts +60 -0
  47. package/src/daemon/context.ts +27 -0
  48. package/src/daemon/index.ts +78 -0
  49. package/src/daemon/logger.ts +6 -0
  50. package/src/daemon/notifications.ts +54 -0
  51. package/src/daemon/services.ts +22 -0
  52. package/src/db/database-schema.ts +0 -2
  53. package/src/db/migrations/20231205T000257238Z-remove-did-cache.ts +14 -0
  54. package/src/db/migrations/index.ts +1 -0
  55. package/src/did-cache.ts +33 -56
  56. package/src/feed-gen/index.ts +0 -4
  57. package/src/index.ts +55 -16
  58. package/src/indexer/context.ts +5 -0
  59. package/src/indexer/index.ts +10 -7
  60. package/src/lexicon/index.ts +50 -0
  61. package/src/lexicon/lexicons.ts +156 -0
  62. package/src/lexicon/types/com/atproto/admin/deleteAccount.ts +38 -0
  63. package/src/lexicon/types/com/atproto/temp/importRepo.ts +45 -0
  64. package/src/lexicon/types/com/atproto/temp/pushBlob.ts +39 -0
  65. package/src/lexicon/types/com/atproto/temp/transferAccount.ts +62 -0
  66. package/src/logger.ts +2 -0
  67. package/src/redis.ts +43 -3
  68. package/src/services/actor/index.ts +55 -7
  69. package/src/services/actor/views.ts +16 -13
  70. package/src/services/feed/index.ts +27 -13
  71. package/src/services/feed/views.ts +20 -10
  72. package/src/services/index.ts +14 -14
  73. package/src/services/indexing/index.ts +7 -10
  74. package/src/services/indexing/plugins/post.ts +13 -0
  75. package/src/services/label/index.ts +66 -22
  76. package/src/services/moderation/index.ts +1 -1
  77. package/src/services/moderation/status.ts +1 -4
  78. package/src/services/types.ts +4 -0
  79. package/src/services/util/notification.ts +70 -0
  80. package/src/util/retry.ts +1 -44
  81. package/tests/admin/get-repo.test.ts +5 -3
  82. package/tests/admin/moderation.test.ts +2 -2
  83. package/tests/admin/repo-search.test.ts +1 -0
  84. package/tests/algos/hot-classic.test.ts +1 -2
  85. package/tests/auth.test.ts +1 -1
  86. package/tests/auto-moderator/labeler.test.ts +19 -20
  87. package/tests/auto-moderator/takedowns.test.ts +16 -10
  88. package/tests/blob-resolver.test.ts +4 -2
  89. package/tests/daemon.test.ts +191 -0
  90. package/tests/did-cache.test.ts +20 -5
  91. package/tests/handle-invalidation.test.ts +1 -5
  92. package/tests/indexing.test.ts +20 -13
  93. package/tests/redis-cache.test.ts +231 -0
  94. package/tests/seeds/basic.ts +3 -0
  95. package/tests/subscription/repo.test.ts +4 -7
  96. package/tests/views/profile.test.ts +0 -1
  97. package/tests/views/thread.test.ts +73 -78
  98. package/tests/views/threadgating.test.ts +38 -0
  99. package/dist/db/tables/did-cache.d.ts +0 -10
  100. package/dist/feed-gen/best-of-follows.d.ts +0 -29
  101. package/dist/feed-gen/whats-hot.d.ts +0 -29
  102. package/dist/feed-gen/with-friends.d.ts +0 -3
  103. package/dist/label-cache.d.ts +0 -19
  104. package/src/db/tables/did-cache.ts +0 -13
  105. package/src/feed-gen/best-of-follows.ts +0 -77
  106. package/src/feed-gen/whats-hot.ts +0 -101
  107. package/src/feed-gen/with-friends.ts +0 -43
  108. package/src/label-cache.ts +0 -90
  109. package/tests/algos/whats-hot.test.ts +0 -118
  110. package/tests/algos/with-friends.test.ts +0 -145
@@ -11,6 +11,7 @@ export declare class IndexerContext {
11
11
  constructor(opts: {
12
12
  db: PrimaryDatabase;
13
13
  redis: Redis;
14
+ redisCache: Redis;
14
15
  cfg: IndexerConfig;
15
16
  services: Services;
16
17
  idResolver: IdResolver;
@@ -20,6 +21,7 @@ export declare class IndexerContext {
20
21
  });
21
22
  get db(): PrimaryDatabase;
22
23
  get redis(): Redis;
24
+ get redisCache(): Redis;
23
25
  get cfg(): IndexerConfig;
24
26
  get services(): Services;
25
27
  get idResolver(): IdResolver;
@@ -22,6 +22,7 @@ export declare class BskyIndexer {
22
22
  static create(opts: {
23
23
  db: PrimaryDatabase;
24
24
  redis: Redis;
25
+ redisCache: Redis;
25
26
  cfg: IndexerConfig;
26
27
  imgInvalidator?: ImageInvalidator;
27
28
  }): BskyIndexer;
@@ -1,4 +1,5 @@
1
1
  import { Server as XrpcServer, Options as XrpcOptions, AuthVerifier, StreamAuthVerifier } from '@atproto/xrpc-server';
2
+ import * as ComAtprotoAdminDeleteAccount from './types/com/atproto/admin/deleteAccount';
2
3
  import * as ComAtprotoAdminDisableAccountInvites from './types/com/atproto/admin/disableAccountInvites';
3
4
  import * as ComAtprotoAdminDisableInviteCodes from './types/com/atproto/admin/disableInviteCodes';
4
5
  import * as ComAtprotoAdminEmitModerationEvent from './types/com/atproto/admin/emitModerationEvent';
@@ -63,6 +64,9 @@ import * as ComAtprotoSyncNotifyOfUpdate from './types/com/atproto/sync/notifyOf
63
64
  import * as ComAtprotoSyncRequestCrawl from './types/com/atproto/sync/requestCrawl';
64
65
  import * as ComAtprotoSyncSubscribeRepos from './types/com/atproto/sync/subscribeRepos';
65
66
  import * as ComAtprotoTempFetchLabels from './types/com/atproto/temp/fetchLabels';
67
+ import * as ComAtprotoTempImportRepo from './types/com/atproto/temp/importRepo';
68
+ import * as ComAtprotoTempPushBlob from './types/com/atproto/temp/pushBlob';
69
+ import * as ComAtprotoTempTransferAccount from './types/com/atproto/temp/transferAccount';
66
70
  import * as AppBskyActorGetPreferences from './types/app/bsky/actor/getPreferences';
67
71
  import * as AppBskyActorGetProfile from './types/app/bsky/actor/getProfile';
68
72
  import * as AppBskyActorGetProfiles from './types/app/bsky/actor/getProfiles';
@@ -152,6 +156,7 @@ export declare class AtprotoNS {
152
156
  export declare class AdminNS {
153
157
  _server: Server;
154
158
  constructor(server: Server);
159
+ deleteAccount<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminDeleteAccount.Handler<ExtractAuth<AV>>, ComAtprotoAdminDeleteAccount.HandlerReqCtx<ExtractAuth<AV>>>): void;
155
160
  disableAccountInvites<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminDisableAccountInvites.Handler<ExtractAuth<AV>>, ComAtprotoAdminDisableAccountInvites.HandlerReqCtx<ExtractAuth<AV>>>): void;
156
161
  disableInviteCodes<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminDisableInviteCodes.Handler<ExtractAuth<AV>>, ComAtprotoAdminDisableInviteCodes.HandlerReqCtx<ExtractAuth<AV>>>): void;
157
162
  emitModerationEvent<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoAdminEmitModerationEvent.Handler<ExtractAuth<AV>>, ComAtprotoAdminEmitModerationEvent.HandlerReqCtx<ExtractAuth<AV>>>): void;
@@ -244,6 +249,9 @@ export declare class TempNS {
244
249
  _server: Server;
245
250
  constructor(server: Server);
246
251
  fetchLabels<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoTempFetchLabels.Handler<ExtractAuth<AV>>, ComAtprotoTempFetchLabels.HandlerReqCtx<ExtractAuth<AV>>>): void;
252
+ importRepo<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoTempImportRepo.Handler<ExtractAuth<AV>>, ComAtprotoTempImportRepo.HandlerReqCtx<ExtractAuth<AV>>>): void;
253
+ pushBlob<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoTempPushBlob.Handler<ExtractAuth<AV>>, ComAtprotoTempPushBlob.HandlerReqCtx<ExtractAuth<AV>>>): void;
254
+ transferAccount<AV extends AuthVerifier>(cfg: ConfigOf<AV, ComAtprotoTempTransferAccount.Handler<ExtractAuth<AV>>, ComAtprotoTempTransferAccount.HandlerReqCtx<ExtractAuth<AV>>>): void;
247
255
  }
248
256
  export declare class AppNS {
249
257
  _server: Server;
@@ -345,9 +353,13 @@ declare type RouteRateLimitOpts<T> = {
345
353
  calcKey?: (ctx: T) => string;
346
354
  calcPoints?: (ctx: T) => number;
347
355
  };
356
+ declare type HandlerOpts = {
357
+ blobLimit?: number;
358
+ };
348
359
  declare type HandlerRateLimitOpts<T> = SharedRateLimitOpts<T> | RouteRateLimitOpts<T>;
349
360
  declare type ConfigOf<Auth, Handler, ReqCtx> = Handler | {
350
361
  auth?: Auth;
362
+ opts?: HandlerOpts;
351
363
  rateLimit?: HandlerRateLimitOpts<ReqCtx> | HandlerRateLimitOpts<ReqCtx>[];
352
364
  handler: Handler;
353
365
  };
@@ -709,6 +709,29 @@ export declare const schemaDict: {
709
709
  };
710
710
  };
711
711
  };
712
+ ComAtprotoAdminDeleteAccount: {
713
+ lexicon: number;
714
+ id: string;
715
+ defs: {
716
+ main: {
717
+ type: string;
718
+ description: string;
719
+ input: {
720
+ encoding: string;
721
+ schema: {
722
+ type: string;
723
+ required: string[];
724
+ properties: {
725
+ did: {
726
+ type: string;
727
+ format: string;
728
+ };
729
+ };
730
+ };
731
+ };
732
+ };
733
+ };
734
+ };
712
735
  ComAtprotoAdminDisableAccountInvites: {
713
736
  lexicon: number;
714
737
  id: string;
@@ -3656,6 +3679,113 @@ export declare const schemaDict: {
3656
3679
  };
3657
3680
  };
3658
3681
  };
3682
+ ComAtprotoTempImportRepo: {
3683
+ lexicon: number;
3684
+ id: string;
3685
+ defs: {
3686
+ main: {
3687
+ type: string;
3688
+ description: string;
3689
+ parameters: {
3690
+ type: string;
3691
+ required: string[];
3692
+ properties: {
3693
+ did: {
3694
+ type: string;
3695
+ format: string;
3696
+ description: string;
3697
+ };
3698
+ };
3699
+ };
3700
+ input: {
3701
+ encoding: string;
3702
+ };
3703
+ output: {
3704
+ encoding: string;
3705
+ };
3706
+ };
3707
+ };
3708
+ };
3709
+ ComAtprotoTempPushBlob: {
3710
+ lexicon: number;
3711
+ id: string;
3712
+ defs: {
3713
+ main: {
3714
+ type: string;
3715
+ description: string;
3716
+ parameters: {
3717
+ type: string;
3718
+ required: string[];
3719
+ properties: {
3720
+ did: {
3721
+ type: string;
3722
+ format: string;
3723
+ description: string;
3724
+ };
3725
+ };
3726
+ };
3727
+ input: {
3728
+ encoding: string;
3729
+ };
3730
+ };
3731
+ };
3732
+ };
3733
+ ComAtprotoTempTransferAccount: {
3734
+ lexicon: number;
3735
+ id: string;
3736
+ defs: {
3737
+ main: {
3738
+ type: string;
3739
+ description: string;
3740
+ input: {
3741
+ encoding: string;
3742
+ schema: {
3743
+ type: string;
3744
+ required: string[];
3745
+ properties: {
3746
+ handle: {
3747
+ type: string;
3748
+ format: string;
3749
+ };
3750
+ did: {
3751
+ type: string;
3752
+ format: string;
3753
+ };
3754
+ plcOp: {
3755
+ type: string;
3756
+ };
3757
+ };
3758
+ };
3759
+ };
3760
+ output: {
3761
+ encoding: string;
3762
+ schema: {
3763
+ type: string;
3764
+ required: string[];
3765
+ properties: {
3766
+ accessJwt: {
3767
+ type: string;
3768
+ };
3769
+ refreshJwt: {
3770
+ type: string;
3771
+ };
3772
+ handle: {
3773
+ type: string;
3774
+ format: string;
3775
+ };
3776
+ did: {
3777
+ type: string;
3778
+ format: string;
3779
+ };
3780
+ };
3781
+ };
3782
+ };
3783
+ errors: {
3784
+ name: string;
3785
+ }[];
3786
+ };
3787
+ };
3788
+ };
3659
3789
  AppBskyActorDefs: {
3660
3790
  lexicon: number;
3661
3791
  id: string;
@@ -7214,6 +7344,7 @@ export declare const schemas: LexiconDoc[];
7214
7344
  export declare const lexicons: Lexicons;
7215
7345
  export declare const ids: {
7216
7346
  ComAtprotoAdminDefs: string;
7347
+ ComAtprotoAdminDeleteAccount: string;
7217
7348
  ComAtprotoAdminDisableAccountInvites: string;
7218
7349
  ComAtprotoAdminDisableInviteCodes: string;
7219
7350
  ComAtprotoAdminEmitModerationEvent: string;
@@ -7282,6 +7413,9 @@ export declare const ids: {
7282
7413
  ComAtprotoSyncRequestCrawl: string;
7283
7414
  ComAtprotoSyncSubscribeRepos: string;
7284
7415
  ComAtprotoTempFetchLabels: string;
7416
+ ComAtprotoTempImportRepo: string;
7417
+ ComAtprotoTempPushBlob: string;
7418
+ ComAtprotoTempTransferAccount: string;
7285
7419
  AppBskyActorDefs: string;
7286
7420
  AppBskyActorGetPreferences: string;
7287
7421
  AppBskyActorGetProfile: string;
@@ -0,0 +1,25 @@
1
+ import express from 'express';
2
+ import { HandlerAuth } from '@atproto/xrpc-server';
3
+ export interface QueryParams {
4
+ }
5
+ export interface InputSchema {
6
+ did: string;
7
+ [k: string]: unknown;
8
+ }
9
+ export interface HandlerInput {
10
+ encoding: 'application/json';
11
+ body: InputSchema;
12
+ }
13
+ export interface HandlerError {
14
+ status: number;
15
+ message?: string;
16
+ }
17
+ export declare type HandlerOutput = HandlerError | void;
18
+ export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
19
+ auth: HA;
20
+ params: QueryParams;
21
+ input: HandlerInput;
22
+ req: express.Request;
23
+ res: express.Response;
24
+ };
25
+ export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
@@ -0,0 +1,32 @@
1
+ /// <reference types="node" />
2
+ import express from 'express';
3
+ import stream from 'stream';
4
+ import { HandlerAuth } from '@atproto/xrpc-server';
5
+ export interface QueryParams {
6
+ did: string;
7
+ }
8
+ export declare type InputSchema = string | Uint8Array;
9
+ export interface HandlerInput {
10
+ encoding: 'application/vnd.ipld.car';
11
+ body: stream.Readable;
12
+ }
13
+ export interface HandlerSuccess {
14
+ encoding: 'text/plain';
15
+ body: Uint8Array | stream.Readable;
16
+ headers?: {
17
+ [key: string]: string;
18
+ };
19
+ }
20
+ export interface HandlerError {
21
+ status: number;
22
+ message?: string;
23
+ }
24
+ export declare type HandlerOutput = HandlerError | HandlerSuccess;
25
+ export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
26
+ auth: HA;
27
+ params: QueryParams;
28
+ input: HandlerInput;
29
+ req: express.Request;
30
+ res: express.Response;
31
+ };
32
+ export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
@@ -0,0 +1,25 @@
1
+ /// <reference types="node" />
2
+ import express from 'express';
3
+ import stream from 'stream';
4
+ import { HandlerAuth } from '@atproto/xrpc-server';
5
+ export interface QueryParams {
6
+ did: string;
7
+ }
8
+ export declare type InputSchema = string | Uint8Array;
9
+ export interface HandlerInput {
10
+ encoding: '*/*';
11
+ body: stream.Readable;
12
+ }
13
+ export interface HandlerError {
14
+ status: number;
15
+ message?: string;
16
+ }
17
+ export declare type HandlerOutput = HandlerError | void;
18
+ export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
19
+ auth: HA;
20
+ params: QueryParams;
21
+ input: HandlerInput;
22
+ req: express.Request;
23
+ res: express.Response;
24
+ };
25
+ export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
@@ -0,0 +1,42 @@
1
+ import express from 'express';
2
+ import { HandlerAuth } from '@atproto/xrpc-server';
3
+ export interface QueryParams {
4
+ }
5
+ export interface InputSchema {
6
+ handle: string;
7
+ did: string;
8
+ plcOp: {};
9
+ [k: string]: unknown;
10
+ }
11
+ export interface OutputSchema {
12
+ accessJwt: string;
13
+ refreshJwt: string;
14
+ handle: string;
15
+ did: string;
16
+ [k: string]: unknown;
17
+ }
18
+ export interface HandlerInput {
19
+ encoding: 'application/json';
20
+ body: InputSchema;
21
+ }
22
+ export interface HandlerSuccess {
23
+ encoding: 'application/json';
24
+ body: OutputSchema;
25
+ headers?: {
26
+ [key: string]: string;
27
+ };
28
+ }
29
+ export interface HandlerError {
30
+ status: number;
31
+ message?: string;
32
+ error?: 'InvalidHandle' | 'InvalidPassword' | 'InvalidInviteCode' | 'HandleNotAvailable' | 'UnsupportedDomain' | 'UnresolvableDid' | 'IncompatibleDidDoc';
33
+ }
34
+ export declare type HandlerOutput = HandlerError | HandlerSuccess;
35
+ export declare type HandlerReqCtx<HA extends HandlerAuth = never> = {
36
+ auth: HA;
37
+ params: QueryParams;
38
+ input: HandlerInput;
39
+ req: express.Request;
40
+ res: express.Response;
41
+ };
42
+ export declare type Handler<HA extends HandlerAuth = never> = (ctx: HandlerReqCtx<HA>) => Promise<HandlerOutput> | HandlerOutput;
package/dist/logger.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { subsystemLogger } from '@atproto/common';
2
2
  export declare const dbLogger: ReturnType<typeof subsystemLogger>;
3
+ export declare const cacheLogger: ReturnType<typeof subsystemLogger>;
3
4
  export declare const subLogger: ReturnType<typeof subsystemLogger>;
4
5
  export declare const labelerLogger: ReturnType<typeof subsystemLogger>;
5
6
  export declare const httpLogger: ReturnType<typeof subsystemLogger>;
package/dist/redis.d.ts CHANGED
@@ -4,6 +4,7 @@ export declare class Redis {
4
4
  driver: RedisDriver;
5
5
  namespace?: string;
6
6
  constructor(opts: RedisOptions);
7
+ withNamespace(namespace: string): Redis;
7
8
  readStreams(streams: StreamRef[], opts: {
8
9
  count: number;
9
10
  blockMs?: number;
@@ -17,7 +18,9 @@ export declare class Redis {
17
18
  trimStream(key: string, cursor: number | string): Promise<void>;
18
19
  streamLengths(keys: string[]): Promise<number[]>;
19
20
  get(key: string): Promise<string | null>;
20
- set(key: string, val: string | number): Promise<void>;
21
+ set(key: string, val: string | number, ttlMs?: number): Promise<void>;
22
+ getMulti(keys: string[]): Promise<{}>;
23
+ setMulti(vals: Record<string, string | number>, ttlMs?: number): Promise<void>;
21
24
  del(key: string): Promise<number>;
22
25
  expire(key: string, seconds: number): Promise<number>;
23
26
  zremrangebyscore(key: string, min: number, max: number): Promise<number>;
@@ -48,5 +51,11 @@ export declare type RedisOptions = ({
48
51
  }) & {
49
52
  password?: string;
50
53
  namespace?: string;
54
+ db?: number;
55
+ commandTimeout?: number;
56
+ };
57
+ export declare function addressParts(addr: string, defaultPort?: number): {
58
+ host: string;
59
+ port: number;
51
60
  };
52
61
  export {};
@@ -2,16 +2,19 @@ import { Database } from '../../db';
2
2
  import { ActorViews } from './views';
3
3
  import { ImageUriBuilder } from '../../image/uri';
4
4
  import { Actor } from '../../db/tables/actor';
5
- import { LabelCache } from '../../label-cache';
6
5
  import { TimeCidKeyset } from '../../db/pagination';
6
+ import { FromDb } from '../types';
7
+ import { GraphService } from '../graph';
8
+ import { LabelService } from '../label';
7
9
  export * from './types';
8
10
  export declare class ActorService {
9
11
  db: Database;
10
12
  imgUriBuilder: ImageUriBuilder;
11
- labelCache: LabelCache;
12
- constructor(db: Database, imgUriBuilder: ImageUriBuilder, labelCache: LabelCache);
13
- static creator(imgUriBuilder: ImageUriBuilder, labelCache: LabelCache): (db: Database) => ActorService;
13
+ private graph;
14
+ private label;
14
15
  views: ActorViews;
16
+ constructor(db: Database, imgUriBuilder: ImageUriBuilder, graph: FromDb<GraphService>, label: FromDb<LabelService>);
17
+ static creator(imgUriBuilder: ImageUriBuilder, graph: FromDb<GraphService>, label: FromDb<LabelService>): (db: Database) => ActorService;
15
18
  getActorDid(handleOrDid: string): Promise<string | null>;
16
19
  getActor(handleOrDid: string, includeSoftDeleted?: boolean): Promise<ActorResult | null>;
17
20
  getActors(handleOrDids: string[], includeSoftDeleted?: boolean): Promise<ActorResult[]>;
@@ -25,6 +28,17 @@ export declare class ActorService {
25
28
  cursor: any;
26
29
  }>;
27
30
  getRepoRev(did: string | null): Promise<string | null>;
31
+ all(opts?: {
32
+ batchSize?: number;
33
+ forever?: boolean;
34
+ cooldownMs?: number;
35
+ startFromDid?: string;
36
+ }): AsyncGenerator<{
37
+ did: string;
38
+ handle: string | null;
39
+ indexedAt: string;
40
+ takedownId: number | null;
41
+ }, void, unknown>;
28
42
  }
29
43
  declare type ActorResult = Actor;
30
44
  export declare class ListKeyset extends TimeCidKeyset<{
@@ -4,23 +4,23 @@ import { Actor } from '../../db/tables/actor';
4
4
  import { ImageUriBuilder } from '../../image/uri';
5
5
  import { LabelService, Labels } from '../label';
6
6
  import { BlockAndMuteState, GraphService } from '../graph';
7
- import { LabelCache } from '../../label-cache';
8
7
  import { ActorInfoMap, ProfileDetailHydrationState, ProfileHydrationState, ProfileInfoMap, ProfileViewMap } from './types';
9
8
  import { ListInfoMap } from '../graph/types';
9
+ import { FromDb } from '../types';
10
10
  export declare class ActorViews {
11
11
  private db;
12
12
  private imgUriBuilder;
13
- private labelCache;
14
- constructor(db: Database, imgUriBuilder: ImageUriBuilder, labelCache: LabelCache);
13
+ private graph;
14
+ private label;
15
15
  services: {
16
16
  label: LabelService;
17
17
  graph: GraphService;
18
18
  };
19
+ constructor(db: Database, imgUriBuilder: ImageUriBuilder, graph: FromDb<GraphService>, label: FromDb<LabelService>);
19
20
  profiles(results: (ActorResult | string)[], viewer: string | null, opts?: {
20
21
  includeSoftDeleted?: boolean;
21
22
  }): Promise<ActorInfoMap>;
22
23
  profilesBasic(results: (ActorResult | string)[], viewer: string | null, opts?: {
23
- omitLabels?: boolean;
24
24
  includeSoftDeleted?: boolean;
25
25
  }): Promise<ActorInfoMap>;
26
26
  profilesList(results: ActorResult[], viewer: string | null, opts?: {
@@ -49,9 +49,7 @@ export declare class ActorViews {
49
49
  labels: Labels;
50
50
  bam: BlockAndMuteState;
51
51
  }, viewer: string | null): ProfileViewMap;
52
- profileBasicPresentation(dids: string[], state: ProfileHydrationState, viewer: string | null, opts?: {
53
- omitLabels?: boolean;
54
- }): ProfileViewMap;
52
+ profileBasicPresentation(dids: string[], state: ProfileHydrationState, viewer: string | null): ProfileViewMap;
55
53
  }
56
54
  declare type ActorResult = Actor;
57
55
  export {};
@@ -6,20 +6,22 @@ import { LabelService } from '../label';
6
6
  import { ActorService } from '../actor';
7
7
  import { BlockAndMuteState, GraphService, ListInfoMap } from '../graph';
8
8
  import { FeedViews } from './views';
9
- import { LabelCache } from '../../label-cache';
9
+ import { FromDb } from '../types';
10
10
  export * from './types';
11
11
  export declare class FeedService {
12
12
  db: Database;
13
13
  imgUriBuilder: ImageUriBuilder;
14
- labelCache: LabelCache;
15
- constructor(db: Database, imgUriBuilder: ImageUriBuilder, labelCache: LabelCache);
14
+ private actor;
15
+ private label;
16
+ private graph;
16
17
  views: FeedViews;
17
18
  services: {
18
19
  label: LabelService;
19
20
  actor: ActorService;
20
21
  graph: GraphService;
21
22
  };
22
- static creator(imgUriBuilder: ImageUriBuilder, labelCache: LabelCache): (db: Database) => FeedService;
23
+ constructor(db: Database, imgUriBuilder: ImageUriBuilder, actor: FromDb<ActorService>, label: FromDb<LabelService>, graph: FromDb<GraphService>);
24
+ static creator(imgUriBuilder: ImageUriBuilder, actor: FromDb<ActorService>, label: FromDb<LabelService>, graph: FromDb<GraphService>): (db: Database) => FeedService;
23
25
  selectPostQb(): import("kysely/dist/cjs/parser/select-parser").QueryBuilderWithSelection<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "post">, "post", {}, "post.uri as uri" | "post.cid as cid" | import("kysely").AliasedRawBuilder<FeedItemType, "type"> | "post.uri as postUri" | "post.creator as originatorDid" | "post.creator as postAuthorDid" | "post.replyParent as replyParent" | "post.replyRoot as replyRoot" | "post.sortAt as sortAt">;
24
26
  selectFeedItemQb(): import("kysely/dist/cjs/parser/select-parser").QueryBuilderWithSelection<import("kysely/dist/cjs/parser/table-parser").From<import("../../db/database-schema").DatabaseSchemaType, "feed_item">, "post" | "feed_item", {
25
27
  type: "post" | "repost";
@@ -7,19 +7,20 @@ import { ViewBlocked, ViewNotFound, ViewRecord } from '../../lexicon/types/app/b
7
7
  import { PostEmbedViews, FeedGenInfo, FeedRow, MaybePostView, PostInfoMap, RecordEmbedViewRecord, PostBlocksMap, FeedHydrationState, ThreadgateInfoMap, ThreadgateInfo } from './types';
8
8
  import { Labels } from '../label';
9
9
  import { ImageUriBuilder } from '../../image/uri';
10
- import { LabelCache } from '../../label-cache';
11
10
  import { ActorInfoMap, ActorService } from '../actor';
12
11
  import { ListInfoMap, GraphService } from '../graph';
12
+ import { FromDb } from '../types';
13
13
  export declare class FeedViews {
14
14
  db: Database;
15
15
  imgUriBuilder: ImageUriBuilder;
16
- labelCache: LabelCache;
17
- constructor(db: Database, imgUriBuilder: ImageUriBuilder, labelCache: LabelCache);
18
- static creator(imgUriBuilder: ImageUriBuilder, labelCache: LabelCache): (db: Database) => FeedViews;
16
+ private actor;
17
+ private graph;
19
18
  services: {
20
19
  actor: ActorService;
21
20
  graph: GraphService;
22
21
  };
22
+ constructor(db: Database, imgUriBuilder: ImageUriBuilder, actor: FromDb<ActorService>, graph: FromDb<GraphService>);
23
+ static creator(imgUriBuilder: ImageUriBuilder, actor: FromDb<ActorService>, graph: FromDb<GraphService>): (db: Database) => FeedViews;
23
24
  formatFeedGeneratorView(info: FeedGenInfo, profiles: ActorInfoMap): GeneratorView | undefined;
24
25
  formatFeed(items: FeedRow[], state: FeedHydrationState, viewer: string | null, opts?: {
25
26
  usePostViewUnion?: boolean;
@@ -1,16 +1,15 @@
1
- import { Database, PrimaryDatabase } from '../db';
2
1
  import { ImageUriBuilder } from '../image/uri';
3
2
  import { ActorService } from './actor';
4
3
  import { FeedService } from './feed';
5
4
  import { GraphService } from './graph';
6
5
  import { ModerationService } from './moderation';
7
- import { LabelService } from './label';
6
+ import { LabelCacheOpts, LabelService } from './label';
8
7
  import { ImageInvalidator } from '../image/invalidator';
9
- import { LabelCache } from '../label-cache';
8
+ import { FromDb, FromDbPrimary } from './types';
10
9
  export declare function createServices(resources: {
11
10
  imgUriBuilder: ImageUriBuilder;
12
11
  imgInvalidator: ImageInvalidator;
13
- labelCache: LabelCache;
12
+ labelCacheOpts: LabelCacheOpts;
14
13
  }): Services;
15
14
  export declare type Services = {
16
15
  actor: FromDb<ActorService>;
@@ -19,6 +18,3 @@ export declare type Services = {
19
18
  moderation: FromDbPrimary<ModerationService>;
20
19
  label: FromDb<LabelService>;
21
20
  };
22
- declare type FromDb<T> = (db: Database) => T;
23
- declare type FromDbPrimary<T> = (db: PrimaryDatabase) => T;
24
- export {};
@@ -1,12 +1,18 @@
1
1
  import { Database } from '../../db';
2
2
  import { Label } from '../../lexicon/types/com/atproto/label/defs';
3
- import { LabelCache } from '../../label-cache';
3
+ import { ReadThroughCache } from '../../cache/read-through';
4
+ import { Redis } from '../../redis';
4
5
  export declare type Labels = Record<string, Label[]>;
6
+ export declare type LabelCacheOpts = {
7
+ redis: Redis;
8
+ staleTTL: number;
9
+ maxTTL: number;
10
+ };
5
11
  export declare class LabelService {
6
12
  db: Database;
7
- cache: LabelCache | null;
8
- constructor(db: Database, cache: LabelCache | null);
9
- static creator(cache: LabelCache | null): (db: Database) => LabelService;
13
+ cache: ReadThroughCache<Label[]> | null;
14
+ constructor(db: Database, cacheOpts: LabelCacheOpts | null);
15
+ static creator(cacheOpts: LabelCacheOpts | null): (db: Database) => LabelService;
10
16
  formatAndCreate(src: string, uri: string, cid: string | null, labels: {
11
17
  create?: string[];
12
18
  negate?: string[];
@@ -165,7 +165,6 @@ export declare class ModerationService {
165
165
  actor_sync: import("../../db/tables/actor-sync").ActorSync;
166
166
  notification: import("../../db/tables/notification").Notification;
167
167
  notification_push_token: import("../../db/tables/notification-push-token").NotificationPushToken;
168
- did_cache: import("../../db/tables/did-cache").DidCache;
169
168
  label: import("../../db/tables/label").Label;
170
169
  moderation_event: ModerationEvent;
171
170
  moderation_subject_status: import("../../db/tables/moderation").ModerationSubjectStatus;
@@ -0,0 +1,3 @@
1
+ import { Database, PrimaryDatabase } from '../db';
2
+ export declare type FromDb<T> = (db: Database) => T;
3
+ export declare type FromDbPrimary<T> = (db: PrimaryDatabase) => T;
@@ -0,0 +1,5 @@
1
+ import { PrimaryDatabase } from '../../db';
2
+ export declare const BEFORE_LAST_SEEN_DAYS = 30;
3
+ export declare const BEFORE_LATEST_UNREAD_DAYS = 180;
4
+ export declare const UNREAD_KEPT_COUNT = 500;
5
+ export declare const tidyNotifications: (db: PrimaryDatabase, did: string) => Promise<void>;