@atproto/bsky 0.0.15 → 0.0.17
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.
- package/CHANGELOG.md +18 -0
- package/dist/api/com/atproto/moderation/util.d.ts +4 -3
- package/dist/cache/read-through.d.ts +30 -0
- package/dist/config.d.ts +18 -0
- package/dist/context.d.ts +21 -6
- package/dist/daemon/config.d.ts +15 -0
- package/dist/daemon/context.d.ts +15 -0
- package/dist/daemon/index.d.ts +23 -0
- package/dist/daemon/logger.d.ts +3 -0
- package/dist/daemon/notifications.d.ts +18 -0
- package/dist/daemon/services.d.ts +11 -0
- package/dist/db/database-schema.d.ts +1 -2
- package/dist/db/index.js +41 -1
- package/dist/db/index.js.map +3 -3
- package/dist/db/migrations/20231003T202833377Z-create-moderation-subject-status.d.ts +3 -0
- package/dist/db/migrations/20231205T000257238Z-remove-did-cache.d.ts +3 -0
- package/dist/db/migrations/index.d.ts +2 -0
- package/dist/db/pagination.d.ts +2 -1
- package/dist/db/{periodic-moderation-action-reversal.d.ts → periodic-moderation-event-reversal.d.ts} +3 -5
- package/dist/db/tables/moderation.d.ts +24 -34
- package/dist/did-cache.d.ts +10 -7
- package/dist/feed-gen/types.d.ts +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +4370 -2758
- package/dist/index.js.map +3 -3
- package/dist/indexer/context.d.ts +2 -0
- package/dist/indexer/index.d.ts +1 -0
- package/dist/lexicon/index.d.ts +23 -18
- package/dist/lexicon/lexicons.d.ts +561 -412
- package/dist/lexicon/types/app/bsky/feed/defs.d.ts +1 -7
- package/dist/lexicon/types/app/bsky/graph/defs.d.ts +1 -0
- package/dist/lexicon/types/com/atproto/admin/defs.d.ts +114 -48
- package/dist/lexicon/types/com/atproto/admin/{resolveModerationReports.d.ts → deleteAccount.d.ts} +2 -13
- package/dist/lexicon/types/com/atproto/admin/{takeModerationAction.d.ts → emitModerationEvent.d.ts} +5 -6
- package/dist/lexicon/types/com/atproto/admin/{getModerationAction.d.ts → getModerationEvent.d.ts} +1 -1
- package/dist/lexicon/types/com/atproto/admin/{getModerationActions.d.ts → queryModerationEvents.d.ts} +5 -1
- package/dist/lexicon/types/com/atproto/admin/{getModerationReports.d.ts → queryModerationStatuses.d.ts} +12 -6
- package/dist/lexicon/types/com/atproto/admin/sendEmail.d.ts +1 -0
- package/dist/lexicon/types/com/atproto/{admin/getModerationReport.d.ts → temp/importRepo.d.ts} +10 -7
- package/dist/lexicon/types/com/atproto/temp/pushBlob.d.ts +25 -0
- package/dist/lexicon/types/com/atproto/{admin/reverseModerationAction.d.ts → temp/transferAccount.d.ts} +11 -5
- package/dist/logger.d.ts +1 -0
- package/dist/migrate-moderation-data.d.ts +1 -0
- package/dist/redis.d.ts +10 -1
- package/dist/services/actor/index.d.ts +18 -4
- package/dist/services/actor/views.d.ts +6 -8
- package/dist/services/feed/index.d.ts +7 -4
- package/dist/services/feed/util.d.ts +9 -1
- package/dist/services/feed/views.d.ts +11 -21
- package/dist/services/graph/index.d.ts +5 -29
- package/dist/services/graph/types.d.ts +1 -0
- package/dist/services/index.d.ts +3 -7
- package/dist/services/label/index.d.ts +10 -4
- package/dist/services/moderation/index.d.ts +134 -72
- package/dist/services/moderation/pagination.d.ts +36 -0
- package/dist/services/moderation/status.d.ts +13 -0
- package/dist/services/moderation/types.d.ts +35 -0
- package/dist/services/moderation/views.d.ts +18 -14
- package/dist/services/types.d.ts +3 -0
- package/dist/services/util/notification.d.ts +5 -0
- package/dist/services/util/post.d.ts +6 -6
- package/dist/util/debug.d.ts +1 -1
- package/dist/util/retry.d.ts +1 -6
- package/package.json +11 -11
- package/src/api/app/bsky/feed/getActorFeeds.ts +2 -1
- package/src/api/app/bsky/feed/getActorLikes.ts +1 -3
- package/src/api/app/bsky/feed/getAuthorFeed.ts +1 -3
- package/src/api/app/bsky/feed/getFeed.ts +9 -9
- package/src/api/app/bsky/feed/getFeedGenerator.ts +3 -0
- package/src/api/app/bsky/feed/getFeedGenerators.ts +2 -1
- package/src/api/app/bsky/feed/getListFeed.ts +1 -3
- package/src/api/app/bsky/feed/getPostThread.ts +15 -54
- package/src/api/app/bsky/feed/getPosts.ts +21 -18
- package/src/api/app/bsky/feed/getSuggestedFeeds.ts +2 -1
- package/src/api/app/bsky/feed/getTimeline.ts +1 -3
- package/src/api/app/bsky/feed/searchPosts.ts +20 -17
- package/src/api/app/bsky/graph/getList.ts +6 -3
- package/src/api/app/bsky/graph/getListBlocks.ts +3 -2
- package/src/api/app/bsky/graph/getListMutes.ts +2 -1
- package/src/api/app/bsky/graph/getLists.ts +2 -1
- package/src/api/app/bsky/unspecced/getPopularFeedGenerators.ts +3 -1
- package/src/api/blob-resolver.ts +6 -11
- package/src/api/com/atproto/admin/emitModerationEvent.ts +220 -0
- package/src/api/com/atproto/admin/{getModerationActions.ts → getModerationEvent.ts} +5 -11
- package/src/api/com/atproto/admin/getRecord.ts +1 -0
- package/src/api/com/atproto/admin/{getModerationReports.ts → queryModerationEvents.ts} +13 -16
- package/src/api/com/atproto/admin/queryModerationStatuses.ts +55 -0
- package/src/api/com/atproto/moderation/createReport.ts +9 -7
- package/src/api/com/atproto/moderation/util.ts +38 -20
- package/src/api/index.ts +8 -14
- package/src/auth.ts +29 -21
- package/src/auto-moderator/index.ts +26 -19
- package/src/cache/read-through.ts +151 -0
- package/src/config.ts +90 -1
- package/src/context.ts +11 -7
- package/src/daemon/config.ts +60 -0
- package/src/daemon/context.ts +27 -0
- package/src/daemon/index.ts +78 -0
- package/src/daemon/logger.ts +6 -0
- package/src/daemon/notifications.ts +54 -0
- package/src/daemon/services.ts +22 -0
- package/src/db/database-schema.ts +0 -2
- package/src/db/migrations/20231003T202833377Z-create-moderation-subject-status.ts +123 -0
- package/src/db/migrations/20231205T000257238Z-remove-did-cache.ts +14 -0
- package/src/db/migrations/index.ts +2 -0
- package/src/db/pagination.ts +26 -3
- package/src/db/{periodic-moderation-action-reversal.ts → periodic-moderation-event-reversal.ts} +50 -46
- package/src/db/tables/moderation.ts +35 -52
- package/src/did-cache.ts +33 -56
- package/src/feed-gen/bsky-team.ts +1 -1
- package/src/feed-gen/hot-classic.ts +1 -1
- package/src/feed-gen/index.ts +0 -4
- package/src/feed-gen/mutuals.ts +6 -2
- package/src/feed-gen/types.ts +1 -1
- package/src/index.ts +57 -17
- package/src/indexer/context.ts +5 -0
- package/src/indexer/index.ts +10 -7
- package/src/lexicon/index.ts +80 -67
- package/src/lexicon/lexicons.ts +698 -507
- package/src/lexicon/types/app/bsky/feed/defs.ts +1 -18
- package/src/lexicon/types/app/bsky/graph/defs.ts +1 -0
- package/src/lexicon/types/com/atproto/admin/defs.ts +276 -84
- package/src/lexicon/types/com/atproto/admin/{resolveModerationReports.ts → deleteAccount.ts} +2 -13
- package/src/lexicon/types/com/atproto/admin/{takeModerationAction.ts → emitModerationEvent.ts} +13 -11
- package/src/lexicon/types/com/atproto/admin/{getModerationReport.ts → getModerationEvent.ts} +1 -1
- package/src/lexicon/types/com/atproto/admin/{getModerationActions.ts → queryModerationEvents.ts} +8 -1
- package/src/lexicon/types/com/atproto/admin/{getModerationReports.ts → queryModerationStatuses.ts} +21 -14
- package/src/lexicon/types/com/atproto/admin/sendEmail.ts +1 -0
- package/src/lexicon/types/com/atproto/{admin/getModerationAction.ts → temp/importRepo.ts} +11 -7
- package/src/lexicon/types/com/atproto/temp/pushBlob.ts +39 -0
- package/src/lexicon/types/com/atproto/{admin/reverseModerationAction.ts → temp/transferAccount.ts} +18 -5
- package/src/logger.ts +2 -0
- package/src/migrate-moderation-data.ts +414 -0
- package/src/redis.ts +43 -3
- package/src/services/actor/index.ts +55 -7
- package/src/services/actor/views.ts +18 -21
- package/src/services/feed/index.ts +52 -19
- package/src/services/feed/util.ts +47 -19
- package/src/services/feed/views.ts +87 -13
- package/src/services/graph/index.ts +21 -3
- package/src/services/graph/types.ts +1 -0
- package/src/services/index.ts +14 -14
- package/src/services/indexing/index.ts +7 -10
- package/src/services/indexing/plugins/block.ts +2 -3
- package/src/services/indexing/plugins/feed-generator.ts +2 -3
- package/src/services/indexing/plugins/follow.ts +2 -3
- package/src/services/indexing/plugins/like.ts +2 -3
- package/src/services/indexing/plugins/list-block.ts +2 -3
- package/src/services/indexing/plugins/list-item.ts +2 -3
- package/src/services/indexing/plugins/list.ts +2 -3
- package/src/services/indexing/plugins/post.ts +16 -4
- package/src/services/indexing/plugins/repost.ts +2 -3
- package/src/services/indexing/plugins/thread-gate.ts +2 -3
- package/src/services/label/index.ts +68 -25
- package/src/services/moderation/index.ts +380 -395
- package/src/services/moderation/pagination.ts +96 -0
- package/src/services/moderation/status.ts +241 -0
- package/src/services/moderation/types.ts +49 -0
- package/src/services/moderation/views.ts +278 -329
- package/src/services/types.ts +4 -0
- package/src/services/util/notification.ts +70 -0
- package/src/util/debug.ts +2 -2
- package/src/util/retry.ts +1 -44
- package/tests/__snapshots__/feed-generation.test.ts.snap +322 -6
- package/tests/__snapshots__/indexing.test.ts.snap +0 -6
- package/tests/admin/__snapshots__/get-record.test.ts.snap +30 -132
- package/tests/admin/__snapshots__/get-repo.test.ts.snap +14 -60
- package/tests/admin/__snapshots__/moderation-events.test.ts.snap +146 -0
- package/tests/admin/__snapshots__/moderation-statuses.test.ts.snap +64 -0
- package/tests/admin/__snapshots__/moderation.test.ts.snap +0 -125
- package/tests/admin/get-record.test.ts +5 -9
- package/tests/admin/get-repo.test.ts +10 -12
- package/tests/admin/moderation-events.test.ts +221 -0
- package/tests/admin/moderation-statuses.test.ts +145 -0
- package/tests/admin/moderation.test.ts +512 -860
- package/tests/admin/repo-search.test.ts +3 -3
- package/tests/algos/hot-classic.test.ts +1 -2
- package/tests/auth.test.ts +1 -1
- package/tests/auto-moderator/fuzzy-matcher.test.ts +2 -1
- package/tests/auto-moderator/labeler.test.ts +19 -20
- package/tests/auto-moderator/takedowns.test.ts +61 -28
- package/tests/blob-resolver.test.ts +4 -2
- package/tests/daemon.test.ts +191 -0
- package/tests/did-cache.test.ts +20 -5
- package/tests/feed-generation.test.ts +57 -9
- package/tests/handle-invalidation.test.ts +1 -5
- package/tests/indexing.test.ts +20 -13
- package/tests/redis-cache.test.ts +231 -0
- package/tests/seeds/basic.ts +3 -0
- package/tests/subscription/repo.test.ts +4 -7
- package/tests/views/__snapshots__/block-lists.test.ts.snap +3 -9
- package/tests/views/__snapshots__/blocks.test.ts.snap +0 -9
- package/tests/views/__snapshots__/mute-lists.test.ts.snap +5 -5
- package/tests/views/__snapshots__/mutes.test.ts.snap +0 -3
- package/tests/views/__snapshots__/thread.test.ts.snap +0 -30
- package/tests/views/actor-search.test.ts +2 -3
- package/tests/views/author-feed.test.ts +42 -36
- package/tests/views/follows.test.ts +40 -35
- package/tests/views/list-feed.test.ts +17 -9
- package/tests/views/notifications.test.ts +13 -9
- package/tests/views/profile.test.ts +20 -19
- package/tests/views/thread.test.ts +117 -94
- package/tests/views/threadgating.test.ts +89 -19
- package/tests/views/timeline.test.ts +21 -13
- package/dist/api/com/atproto/admin/resolveModerationReports.d.ts +0 -3
- package/dist/api/com/atproto/admin/reverseModerationAction.d.ts +0 -3
- package/dist/api/com/atproto/admin/takeModerationAction.d.ts +0 -3
- package/dist/db/tables/did-cache.d.ts +0 -10
- package/dist/feed-gen/best-of-follows.d.ts +0 -29
- package/dist/feed-gen/whats-hot.d.ts +0 -29
- package/dist/feed-gen/with-friends.d.ts +0 -3
- package/dist/label-cache.d.ts +0 -19
- package/src/api/com/atproto/admin/getModerationAction.ts +0 -44
- package/src/api/com/atproto/admin/getModerationReport.ts +0 -43
- package/src/api/com/atproto/admin/resolveModerationReports.ts +0 -24
- package/src/api/com/atproto/admin/reverseModerationAction.ts +0 -115
- package/src/api/com/atproto/admin/takeModerationAction.ts +0 -156
- package/src/db/tables/did-cache.ts +0 -13
- package/src/feed-gen/best-of-follows.ts +0 -74
- package/src/feed-gen/whats-hot.ts +0 -101
- package/src/feed-gen/with-friends.ts +0 -39
- package/src/label-cache.ts +0 -90
- package/tests/admin/__snapshots__/get-moderation-action.test.ts.snap +0 -172
- package/tests/admin/__snapshots__/get-moderation-actions.test.ts.snap +0 -178
- package/tests/admin/__snapshots__/get-moderation-report.test.ts.snap +0 -177
- package/tests/admin/__snapshots__/get-moderation-reports.test.ts.snap +0 -307
- package/tests/admin/get-moderation-action.test.ts +0 -100
- package/tests/admin/get-moderation-actions.test.ts +0 -164
- package/tests/admin/get-moderation-report.test.ts +0 -100
- package/tests/admin/get-moderation-reports.test.ts +0 -332
- package/tests/algos/whats-hot.test.ts +0 -118
- package/tests/algos/with-friends.test.ts +0 -145
- /package/dist/api/com/atproto/admin/{getModerationAction.d.ts → emitModerationEvent.d.ts} +0 -0
- /package/dist/api/com/atproto/admin/{getModerationActions.d.ts → getModerationEvent.d.ts} +0 -0
- /package/dist/api/com/atproto/admin/{getModerationReport.d.ts → queryModerationEvents.d.ts} +0 -0
- /package/dist/api/com/atproto/admin/{getModerationReports.d.ts → queryModerationStatuses.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atproto/bsky
|
|
2
2
|
|
|
3
|
+
## 0.0.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`45352f9b`](https://github.com/bluesky-social/atproto/commit/45352f9b6d02aa405be94e9102424d983912ca5d)]:
|
|
8
|
+
- @atproto/api@0.7.0
|
|
9
|
+
|
|
10
|
+
## 0.0.16
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`3c0ef382`](https://github.com/bluesky-social/atproto/commit/3c0ef382c12a413cc971ae47ffb341236c545f60), [`378fc613`](https://github.com/bluesky-social/atproto/commit/378fc6132f621ca517897c9467ed5bba134b3776)]:
|
|
15
|
+
- @atproto/syntax@0.1.5
|
|
16
|
+
- @atproto/api@0.6.24
|
|
17
|
+
- @atproto/lexicon@0.3.1
|
|
18
|
+
- @atproto/repo@0.3.6
|
|
19
|
+
- @atproto/xrpc-server@0.4.2
|
|
20
|
+
|
|
3
21
|
## 0.0.15
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CID } from 'multiformats/cid';
|
|
2
2
|
import { AtUri } from '@atproto/syntax';
|
|
3
3
|
import { InputSchema as ReportInput } from '../../../../lexicon/types/com/atproto/moderation/createReport';
|
|
4
|
-
import { InputSchema as ActionInput } from '../../../../lexicon/types/com/atproto/admin/
|
|
4
|
+
import { InputSchema as ActionInput } from '../../../../lexicon/types/com/atproto/admin/emitModerationEvent';
|
|
5
5
|
declare type SubjectInput = ReportInput['subject'] | ActionInput['subject'];
|
|
6
6
|
export declare const getSubject: (subject: SubjectInput) => {
|
|
7
7
|
did: string;
|
|
@@ -12,6 +12,7 @@ export declare const getSubject: (subject: SubjectInput) => {
|
|
|
12
12
|
cid: CID;
|
|
13
13
|
did?: undefined;
|
|
14
14
|
};
|
|
15
|
-
export declare const getReasonType: (reasonType: ReportInput['reasonType']) =>
|
|
16
|
-
export declare const
|
|
15
|
+
export declare const getReasonType: (reasonType: ReportInput['reasonType']) => string | boolean;
|
|
16
|
+
export declare const getEventType: (type: string) => "com.atproto.admin.defs#modEventTakedown" | "com.atproto.admin.defs#modEventReverseTakedown" | "com.atproto.admin.defs#modEventComment" | "com.atproto.admin.defs#modEventReport" | "com.atproto.admin.defs#modEventLabel" | "com.atproto.admin.defs#modEventAcknowledge" | "com.atproto.admin.defs#modEventEscalate" | "com.atproto.admin.defs#modEventMute" | "com.atproto.admin.defs#modEventEmail";
|
|
17
|
+
export declare const getReviewState: (reviewState?: string) => "com.atproto.admin.defs#reviewOpen" | "com.atproto.admin.defs#reviewEscalated" | "com.atproto.admin.defs#reviewClosed" | undefined;
|
|
17
18
|
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Redis } from '../redis';
|
|
2
|
+
export declare type CacheItem<T> = {
|
|
3
|
+
val: T | null;
|
|
4
|
+
updatedAt: number;
|
|
5
|
+
};
|
|
6
|
+
export declare type CacheOptions<T> = {
|
|
7
|
+
staleTTL: number;
|
|
8
|
+
maxTTL: number;
|
|
9
|
+
fetchMethod: (key: string) => Promise<T | null>;
|
|
10
|
+
fetchManyMethod?: (keys: string[]) => Promise<Record<string, T | null>>;
|
|
11
|
+
};
|
|
12
|
+
export declare class ReadThroughCache<T> {
|
|
13
|
+
redis: Redis;
|
|
14
|
+
opts: CacheOptions<T>;
|
|
15
|
+
constructor(redis: Redis, opts: CacheOptions<T>);
|
|
16
|
+
private _fetchMany;
|
|
17
|
+
private fetchAndCache;
|
|
18
|
+
private fetchAndCacheMany;
|
|
19
|
+
get(key: string, opts?: {
|
|
20
|
+
revalidate?: boolean;
|
|
21
|
+
}): Promise<T | null>;
|
|
22
|
+
getMany(keys: string[], opts?: {
|
|
23
|
+
revalidate?: boolean;
|
|
24
|
+
}): Promise<Record<string, T>>;
|
|
25
|
+
set(key: string, val: T | null): Promise<void>;
|
|
26
|
+
setMany(vals: Record<string, T | null>): Promise<void>;
|
|
27
|
+
clearEntry(key: string): Promise<void>;
|
|
28
|
+
isExpired(result: CacheItem<T>): boolean;
|
|
29
|
+
isStale(result: CacheItem<T>): boolean;
|
|
30
|
+
}
|
package/dist/config.d.ts
CHANGED
|
@@ -9,9 +9,15 @@ export interface ServerConfigValues {
|
|
|
9
9
|
dbReplicaPostgresUrls?: string[];
|
|
10
10
|
dbReplicaTags?: Record<string, number[]>;
|
|
11
11
|
dbPostgresSchema?: string;
|
|
12
|
+
redisHost?: string;
|
|
13
|
+
redisSentinelName?: string;
|
|
14
|
+
redisSentinelHosts?: string[];
|
|
15
|
+
redisPassword?: string;
|
|
12
16
|
didPlcUrl: string;
|
|
13
17
|
didCacheStaleTTL: number;
|
|
14
18
|
didCacheMaxTTL: number;
|
|
19
|
+
labelCacheStaleTTL: number;
|
|
20
|
+
labelCacheMaxTTL: number;
|
|
15
21
|
handleResolveNameservers?: string[];
|
|
16
22
|
imgUriEndpoint?: string;
|
|
17
23
|
blobCacheLocation?: string;
|
|
@@ -21,6 +27,9 @@ export interface ServerConfigValues {
|
|
|
21
27
|
moderatorPassword?: string;
|
|
22
28
|
triagePassword?: string;
|
|
23
29
|
moderationPushUrl?: string;
|
|
30
|
+
rateLimitsEnabled: boolean;
|
|
31
|
+
rateLimitBypassKey?: string;
|
|
32
|
+
rateLimitBypassIps?: string[];
|
|
24
33
|
}
|
|
25
34
|
export declare class ServerConfig {
|
|
26
35
|
private cfg;
|
|
@@ -39,8 +48,14 @@ export declare class ServerConfig {
|
|
|
39
48
|
get dbReplicaPostgresUrl(): string[] | undefined;
|
|
40
49
|
get dbReplicaTags(): Record<string, number[]> | undefined;
|
|
41
50
|
get dbPostgresSchema(): string | undefined;
|
|
51
|
+
get redisHost(): string | undefined;
|
|
52
|
+
get redisSentinelName(): string | undefined;
|
|
53
|
+
get redisSentinelHosts(): string[] | undefined;
|
|
54
|
+
get redisPassword(): string | undefined;
|
|
42
55
|
get didCacheStaleTTL(): number;
|
|
43
56
|
get didCacheMaxTTL(): number;
|
|
57
|
+
get labelCacheStaleTTL(): number;
|
|
58
|
+
get labelCacheMaxTTL(): number;
|
|
44
59
|
get handleResolveNameservers(): string[] | undefined;
|
|
45
60
|
get didPlcUrl(): string;
|
|
46
61
|
get imgUriEndpoint(): string | undefined;
|
|
@@ -51,4 +66,7 @@ export declare class ServerConfig {
|
|
|
51
66
|
get moderatorPassword(): string | undefined;
|
|
52
67
|
get triagePassword(): string | undefined;
|
|
53
68
|
get moderationPushUrl(): string | undefined;
|
|
69
|
+
get rateLimitsEnabled(): boolean;
|
|
70
|
+
get rateLimitBypassKey(): string | undefined;
|
|
71
|
+
get rateLimitBypassIps(): string[] | undefined;
|
|
54
72
|
}
|
package/dist/context.d.ts
CHANGED
|
@@ -8,11 +8,11 @@ import { DatabaseCoordinator } from './db';
|
|
|
8
8
|
import { ServerConfig } from './config';
|
|
9
9
|
import { ImageUriBuilder } from './image/uri';
|
|
10
10
|
import { Services } from './services';
|
|
11
|
-
import
|
|
11
|
+
import DidRedisCache from './did-cache';
|
|
12
12
|
import { BackgroundQueue } from './background';
|
|
13
13
|
import { MountedAlgos } from './feed-gen/types';
|
|
14
|
-
import { LabelCache } from './label-cache';
|
|
15
14
|
import { NotificationServer } from './notifications';
|
|
15
|
+
import { Redis } from './redis';
|
|
16
16
|
export declare class AppContext {
|
|
17
17
|
private opts;
|
|
18
18
|
moderationPushAgent: AtpAgent | undefined;
|
|
@@ -23,8 +23,8 @@ export declare class AppContext {
|
|
|
23
23
|
services: Services;
|
|
24
24
|
signingKey: Keypair;
|
|
25
25
|
idResolver: IdResolver;
|
|
26
|
-
didCache:
|
|
27
|
-
|
|
26
|
+
didCache: DidRedisCache;
|
|
27
|
+
redis: Redis;
|
|
28
28
|
backgroundQueue: BackgroundQueue;
|
|
29
29
|
searchAgent?: AtpAgent;
|
|
30
30
|
algos: MountedAlgos;
|
|
@@ -37,8 +37,8 @@ export declare class AppContext {
|
|
|
37
37
|
get signingKey(): Keypair;
|
|
38
38
|
get plcClient(): plc.Client;
|
|
39
39
|
get idResolver(): IdResolver;
|
|
40
|
-
get didCache():
|
|
41
|
-
get
|
|
40
|
+
get didCache(): DidRedisCache;
|
|
41
|
+
get redis(): Redis;
|
|
42
42
|
get notifServer(): NotificationServer;
|
|
43
43
|
get searchAgent(): AtpAgent | undefined;
|
|
44
44
|
get authVerifier(): (reqCtx: {
|
|
@@ -63,6 +63,21 @@ export declare class AppContext {
|
|
|
63
63
|
aud: string | null;
|
|
64
64
|
};
|
|
65
65
|
}>;
|
|
66
|
+
get authOptionalVerifierAnyAudience(): (reqCtx: {
|
|
67
|
+
req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
68
|
+
res: import("express").Response<any, Record<string, any>>;
|
|
69
|
+
}) => Promise<{
|
|
70
|
+
credentials: {
|
|
71
|
+
did: string;
|
|
72
|
+
};
|
|
73
|
+
artifacts: {
|
|
74
|
+
aud: string | null;
|
|
75
|
+
};
|
|
76
|
+
} | {
|
|
77
|
+
credentials: {
|
|
78
|
+
did: null;
|
|
79
|
+
};
|
|
80
|
+
}>;
|
|
66
81
|
get authOptionalVerifier(): (reqCtx: {
|
|
67
82
|
req: import("express").Request<import("express-serve-static-core").ParamsDictionary, any, any, import("qs").ParsedQs, Record<string, any>>;
|
|
68
83
|
res: import("express").Response<any, Record<string, any>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface DaemonConfigValues {
|
|
2
|
+
version: string;
|
|
3
|
+
dbPostgresUrl: string;
|
|
4
|
+
dbPostgresSchema?: string;
|
|
5
|
+
notificationsDaemonFromDid?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class DaemonConfig {
|
|
8
|
+
private cfg;
|
|
9
|
+
constructor(cfg: DaemonConfigValues);
|
|
10
|
+
static readEnv(overrides?: Partial<DaemonConfigValues>): DaemonConfig;
|
|
11
|
+
get version(): string;
|
|
12
|
+
get dbPostgresUrl(): string;
|
|
13
|
+
get dbPostgresSchema(): string | undefined;
|
|
14
|
+
get notificationsDaemonFromDid(): string | undefined;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PrimaryDatabase } from '../db';
|
|
2
|
+
import { DaemonConfig } from './config';
|
|
3
|
+
import { Services } from './services';
|
|
4
|
+
export declare class DaemonContext {
|
|
5
|
+
private opts;
|
|
6
|
+
constructor(opts: {
|
|
7
|
+
db: PrimaryDatabase;
|
|
8
|
+
cfg: DaemonConfig;
|
|
9
|
+
services: Services;
|
|
10
|
+
});
|
|
11
|
+
get db(): PrimaryDatabase;
|
|
12
|
+
get cfg(): DaemonConfig;
|
|
13
|
+
get services(): Services;
|
|
14
|
+
}
|
|
15
|
+
export default DaemonContext;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PrimaryDatabase } from '../db';
|
|
2
|
+
import { DaemonConfig } from './config';
|
|
3
|
+
import { DaemonContext } from './context';
|
|
4
|
+
import { NotificationsDaemon } from './notifications';
|
|
5
|
+
export { DaemonConfig } from './config';
|
|
6
|
+
export type { DaemonConfigValues } from './config';
|
|
7
|
+
export declare class BskyDaemon {
|
|
8
|
+
ctx: DaemonContext;
|
|
9
|
+
notifications: NotificationsDaemon;
|
|
10
|
+
private dbStatsInterval;
|
|
11
|
+
private notifStatsInterval;
|
|
12
|
+
constructor(opts: {
|
|
13
|
+
ctx: DaemonContext;
|
|
14
|
+
notifications: NotificationsDaemon;
|
|
15
|
+
});
|
|
16
|
+
static create(opts: {
|
|
17
|
+
db: PrimaryDatabase;
|
|
18
|
+
cfg: DaemonConfig;
|
|
19
|
+
}): BskyDaemon;
|
|
20
|
+
start(): Promise<this>;
|
|
21
|
+
destroy(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export default BskyDaemon;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import DaemonContext from './context';
|
|
2
|
+
export declare class NotificationsDaemon {
|
|
3
|
+
private ctx;
|
|
4
|
+
ac: AbortController;
|
|
5
|
+
running: Promise<void> | undefined;
|
|
6
|
+
count: number;
|
|
7
|
+
lastDid: string | null;
|
|
8
|
+
constructor(ctx: DaemonContext);
|
|
9
|
+
run(opts?: RunOptions): void;
|
|
10
|
+
private tidyNotifications;
|
|
11
|
+
destroy(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
declare type RunOptions = {
|
|
14
|
+
forever?: boolean;
|
|
15
|
+
batchSize?: number;
|
|
16
|
+
startFromDid?: string;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PrimaryDatabase } from '../db';
|
|
2
|
+
import { ActorService } from '../services/actor';
|
|
3
|
+
import { ImageUriBuilder } from '../image/uri';
|
|
4
|
+
export declare function createServices(resources: {
|
|
5
|
+
imgUriBuilder: ImageUriBuilder;
|
|
6
|
+
}): Services;
|
|
7
|
+
export declare type Services = {
|
|
8
|
+
actor: FromDbPrimary<ActorService>;
|
|
9
|
+
};
|
|
10
|
+
declare type FromDbPrimary<T> = (db: PrimaryDatabase) => T;
|
|
11
|
+
export {};
|
|
@@ -24,13 +24,12 @@ import * as actorSync from './tables/actor-sync';
|
|
|
24
24
|
import * as record from './tables/record';
|
|
25
25
|
import * as notification from './tables/notification';
|
|
26
26
|
import * as notificationPushToken from './tables/notification-push-token';
|
|
27
|
-
import * as didCache from './tables/did-cache';
|
|
28
27
|
import * as moderation from './tables/moderation';
|
|
29
28
|
import * as label from './tables/label';
|
|
30
29
|
import * as algo from './tables/algo';
|
|
31
30
|
import * as viewParam from './tables/view-param';
|
|
32
31
|
import * as suggestedFollow from './tables/suggested-follow';
|
|
33
32
|
import * as suggestedFeed from './tables/suggested-feed';
|
|
34
|
-
export declare type DatabaseSchemaType = duplicateRecord.PartialDB & profile.PartialDB & profileAgg.PartialDB & post.PartialDB & postEmbed.PartialDB & postAgg.PartialDB & repost.PartialDB & threadGate.PartialDB & feedItem.PartialDB & follow.PartialDB & like.PartialDB & list.PartialDB & listItem.PartialDB & listMute.PartialDB & listBlock.PartialDB & mute.PartialDB & actorBlock.PartialDB & feedGenerator.PartialDB & subscription.PartialDB & actor.PartialDB & actorState.PartialDB & actorSync.PartialDB & record.PartialDB & notification.PartialDB & notificationPushToken.PartialDB &
|
|
33
|
+
export declare type DatabaseSchemaType = duplicateRecord.PartialDB & profile.PartialDB & profileAgg.PartialDB & post.PartialDB & postEmbed.PartialDB & postAgg.PartialDB & repost.PartialDB & threadGate.PartialDB & feedItem.PartialDB & follow.PartialDB & like.PartialDB & list.PartialDB & listItem.PartialDB & listMute.PartialDB & listBlock.PartialDB & mute.PartialDB & actorBlock.PartialDB & feedGenerator.PartialDB & subscription.PartialDB & actor.PartialDB & actorState.PartialDB & actorSync.PartialDB & record.PartialDB & notification.PartialDB & notificationPushToken.PartialDB & moderation.PartialDB & label.PartialDB & algo.PartialDB & viewParam.PartialDB & suggestedFollow.PartialDB & suggestedFeed.PartialDB;
|
|
35
34
|
export declare type DatabaseSchema = Kysely<DatabaseSchemaType>;
|
|
36
35
|
export default DatabaseSchema;
|
package/dist/db/index.js
CHANGED
|
@@ -33502,7 +33502,9 @@ __export(migrations_exports, {
|
|
|
33502
33502
|
_20230904T211011773Z: () => T211011773Z_block_lists_exports,
|
|
33503
33503
|
_20230906T222220386Z: () => T222220386Z_thread_gating_exports,
|
|
33504
33504
|
_20230920T213858047Z: () => T213858047Z_add_tags_to_post_exports,
|
|
33505
|
-
_20230929T192920807Z: () => T192920807Z_record_cursor_indexes_exports
|
|
33505
|
+
_20230929T192920807Z: () => T192920807Z_record_cursor_indexes_exports,
|
|
33506
|
+
_20231003T202833377Z: () => T202833377Z_create_moderation_subject_status_exports,
|
|
33507
|
+
_20231205T000257238Z: () => T000257238Z_remove_did_cache_exports
|
|
33506
33508
|
});
|
|
33507
33509
|
|
|
33508
33510
|
// src/db/migrations/20230309T045948368Z-init.ts
|
|
@@ -34001,6 +34003,43 @@ async function down28(db) {
|
|
|
34001
34003
|
await db.schema.dropIndex("follow_subject_cursor_idx").execute();
|
|
34002
34004
|
}
|
|
34003
34005
|
|
|
34006
|
+
// src/db/migrations/20231003T202833377Z-create-moderation-subject-status.ts
|
|
34007
|
+
var T202833377Z_create_moderation_subject_status_exports = {};
|
|
34008
|
+
__export(T202833377Z_create_moderation_subject_status_exports, {
|
|
34009
|
+
down: () => down29,
|
|
34010
|
+
up: () => up29
|
|
34011
|
+
});
|
|
34012
|
+
async function up29(db) {
|
|
34013
|
+
await db.schema.createTable("moderation_event").addColumn("id", "serial", (col) => col.primaryKey()).addColumn("action", "varchar", (col) => col.notNull()).addColumn("subjectType", "varchar", (col) => col.notNull()).addColumn("subjectDid", "varchar", (col) => col.notNull()).addColumn("subjectUri", "varchar").addColumn("subjectCid", "varchar").addColumn("comment", "text").addColumn("meta", "jsonb").addColumn("createdAt", "varchar", (col) => col.notNull()).addColumn("createdBy", "varchar", (col) => col.notNull()).addColumn("reversedAt", "varchar").addColumn("reversedBy", "varchar").addColumn("durationInHours", "integer").addColumn("expiresAt", "varchar").addColumn("reversedReason", "text").addColumn("createLabelVals", "varchar").addColumn("negateLabelVals", "varchar").addColumn("legacyRefId", "integer").execute();
|
|
34014
|
+
await db.schema.createTable("moderation_subject_status").addColumn("id", "serial", (col) => col.primaryKey()).addColumn("did", "varchar", (col) => col.notNull()).addColumn("recordPath", "varchar", (col) => col.notNull().defaultTo("")).addColumn("blobCids", "jsonb").addColumn("recordCid", "varchar").addColumn("reviewState", "varchar", (col) => col.notNull()).addColumn("comment", "varchar").addColumn("muteUntil", "varchar").addColumn("lastReviewedAt", "varchar").addColumn("lastReviewedBy", "varchar").addColumn("lastReportedAt", "varchar").addColumn("takendown", "boolean", (col) => col.defaultTo(false).notNull()).addColumn("suspendUntil", "varchar").addColumn("createdAt", "varchar", (col) => col.notNull()).addColumn("updatedAt", "varchar", (col) => col.notNull()).addUniqueConstraint("moderation_status_unique_idx", ["did", "recordPath"]).execute();
|
|
34015
|
+
await db.schema.createIndex("moderation_subject_status_blob_cids_idx").on("moderation_subject_status").using("gin").column("blobCids").execute();
|
|
34016
|
+
await db.schema.alterTable("record").dropConstraint("record_takedown_id_fkey").execute();
|
|
34017
|
+
await db.schema.alterTable("actor").dropConstraint("actor_takedown_id_fkey").execute();
|
|
34018
|
+
await db.schema.alterTable("actor").addForeignKeyConstraint("actor_takedown_id_fkey", ["takedownId"], "moderation_event", ["id"]).execute();
|
|
34019
|
+
await db.schema.alterTable("record").addForeignKeyConstraint("record_takedown_id_fkey", ["takedownId"], "moderation_event", ["id"]).execute();
|
|
34020
|
+
}
|
|
34021
|
+
async function down29(db) {
|
|
34022
|
+
await db.schema.dropTable("moderation_event").execute();
|
|
34023
|
+
await db.schema.dropTable("moderation_subject_status").execute();
|
|
34024
|
+
await db.schema.alterTable("record").dropConstraint("record_takedown_id_fkey").execute();
|
|
34025
|
+
await db.schema.alterTable("actor").dropConstraint("actor_takedown_id_fkey").execute();
|
|
34026
|
+
await db.schema.alterTable("actor").addForeignKeyConstraint("actor_takedown_id_fkey", ["takedownId"], "moderation_action", ["id"]).execute();
|
|
34027
|
+
await db.schema.alterTable("record").addForeignKeyConstraint("record_takedown_id_fkey", ["takedownId"], "moderation_action", ["id"]).execute();
|
|
34028
|
+
}
|
|
34029
|
+
|
|
34030
|
+
// src/db/migrations/20231205T000257238Z-remove-did-cache.ts
|
|
34031
|
+
var T000257238Z_remove_did_cache_exports = {};
|
|
34032
|
+
__export(T000257238Z_remove_did_cache_exports, {
|
|
34033
|
+
down: () => down30,
|
|
34034
|
+
up: () => up30
|
|
34035
|
+
});
|
|
34036
|
+
async function up30(db) {
|
|
34037
|
+
await db.schema.dropTable("did_cache").execute();
|
|
34038
|
+
}
|
|
34039
|
+
async function down30(db) {
|
|
34040
|
+
await db.schema.createTable("did_cache").addColumn("did", "varchar", (col) => col.primaryKey()).addColumn("doc", "jsonb", (col) => col.notNull()).addColumn("updatedAt", "bigint", (col) => col.notNull()).execute();
|
|
34041
|
+
}
|
|
34042
|
+
|
|
34004
34043
|
// src/db/migrations/provider.ts
|
|
34005
34044
|
var CtxMigrationProvider = class {
|
|
34006
34045
|
constructor(migrations, ctx) {
|
|
@@ -34022,6 +34061,7 @@ var CtxMigrationProvider = class {
|
|
|
34022
34061
|
// src/logger.ts
|
|
34023
34062
|
var import_pino_http = __toESM(require_logger());
|
|
34024
34063
|
var dbLogger = subsystemLogger("bsky:db");
|
|
34064
|
+
var cacheLogger = subsystemLogger("bsky:cache");
|
|
34025
34065
|
var subLogger = subsystemLogger("bsky:sub");
|
|
34026
34066
|
var labelerLogger = subsystemLogger("bsky:labeler");
|
|
34027
34067
|
var httpLogger = subsystemLogger("bsky");
|