@atproto/ozone 0.0.2 → 0.0.4

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 (73) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/api/admin/listCommunicationTemplates.d.ts +3 -0
  3. package/dist/api/admin/updateCommunicationTemplate.d.ts +3 -0
  4. package/dist/communication-service/template.d.ts +18 -0
  5. package/dist/context.d.ts +3 -0
  6. package/dist/db/index.js +18 -1
  7. package/dist/db/index.js.map +3 -3
  8. package/dist/db/migrations/20240116T085607200Z-communication-template.d.ts +3 -0
  9. package/dist/db/migrations/index.d.ts +1 -0
  10. package/dist/db/schema/communication_template.d.ts +15 -0
  11. package/dist/db/schema/index.d.ts +2 -1
  12. package/dist/index.js +861 -240
  13. package/dist/index.js.map +3 -3
  14. package/dist/lexicon/index.d.ts +8 -0
  15. package/dist/lexicon/lexicons.d.ts +182 -0
  16. package/dist/lexicon/types/{app/bsky/unspecced/getPopular.d.ts → com/atproto/admin/createCommunicationTemplate.d.ts} +11 -9
  17. package/dist/lexicon/types/com/atproto/admin/defs.d.ts +13 -0
  18. package/dist/lexicon/types/com/atproto/admin/deleteCommunicationTemplate.d.ts +25 -0
  19. package/dist/lexicon/types/{app/bsky/moderation/getServices.d.ts → com/atproto/admin/listCommunicationTemplates.d.ts} +2 -3
  20. package/dist/lexicon/types/{app/bsky/moderation/getService.d.ts → com/atproto/admin/updateCommunicationTemplate.d.ts} +15 -5
  21. package/package.json +8 -8
  22. package/src/api/admin/createCommunicationTemplate.ts +37 -0
  23. package/src/api/admin/deleteCommunicationTemplate.ts +23 -0
  24. package/src/api/admin/listCommunicationTemplates.ts +31 -0
  25. package/src/api/admin/updateCommunicationTemplate.ts +40 -0
  26. package/src/api/index.ts +8 -0
  27. package/src/communication-service/template.ts +105 -0
  28. package/src/context.ts +12 -0
  29. package/src/db/migrations/20240116T085607200Z-communication-template.ts +23 -0
  30. package/src/db/migrations/index.ts +1 -0
  31. package/src/db/schema/communication_template.ts +18 -0
  32. package/src/db/schema/index.ts +3 -1
  33. package/src/lexicon/index.ts +48 -0
  34. package/src/lexicon/lexicons.ts +199 -0
  35. package/src/lexicon/types/com/atproto/admin/createCommunicationTemplate.ts +54 -0
  36. package/src/lexicon/types/com/atproto/admin/defs.ts +35 -0
  37. package/src/lexicon/types/com/atproto/admin/deleteCommunicationTemplate.ts +38 -0
  38. package/src/lexicon/types/com/atproto/admin/listCommunicationTemplates.ts +44 -0
  39. package/src/lexicon/types/com/atproto/admin/updateCommunicationTemplate.ts +57 -0
  40. package/tests/communication-templates.test.ts +131 -0
  41. package/dist/api/com/atproto/admin/emitModerationEvent.d.ts +0 -3
  42. package/dist/api/com/atproto/admin/getModerationEvent.d.ts +0 -3
  43. package/dist/api/com/atproto/admin/getRecord.d.ts +0 -3
  44. package/dist/api/com/atproto/admin/getRepo.d.ts +0 -3
  45. package/dist/api/com/atproto/admin/queryModerationEvents.d.ts +0 -3
  46. package/dist/api/com/atproto/admin/queryModerationStatuses.d.ts +0 -3
  47. package/dist/api/com/atproto/admin/searchRepos.d.ts +0 -3
  48. package/dist/api/com/atproto/admin/util.d.ts +0 -5
  49. package/dist/api/com/atproto/moderation/createReport.d.ts +0 -3
  50. package/dist/api/com/atproto/moderation/util.d.ts +0 -4
  51. package/dist/api/com/atproto/temp/fetchLabels.d.ts +0 -3
  52. package/dist/api/util.d.ts +0 -2
  53. package/dist/auth-verifier.d.ts +0 -47
  54. package/dist/config.d.ts +0 -42
  55. package/dist/daemon/config.d.ts +0 -23
  56. package/dist/lexicon/types/app/bsky/moderation/defs.d.ts +0 -49
  57. package/dist/lexicon/types/app/bsky/moderation/service.d.ts +0 -17
  58. package/dist/sequencer/index.d.ts +0 -2
  59. package/dist/sequencer/outbox.d.ts +0 -16
  60. package/dist/sequencer/sequencer.d.ts +0 -35
  61. package/dist/services/index.d.ts +0 -7
  62. package/dist/services/moderation/index.d.ts +0 -144
  63. package/dist/services/moderation/status.d.ts +0 -12
  64. package/dist/services/moderation/subject.d.ts +0 -60
  65. package/dist/services/moderation/types.d.ts +0 -19
  66. package/dist/services/moderation/views.d.ts +0 -42
  67. package/dist/services/types.d.ts +0 -2
  68. package/dist/util/date.d.ts +0 -1
  69. package/dist/util/debug.d.ts +0 -1
  70. package/dist/util/retry.d.ts +0 -3
  71. package/test.log +0 -0
  72. /package/dist/api/{label/queryLabels.d.ts → admin/createCommunicationTemplate.d.ts} +0 -0
  73. /package/dist/api/{label/subscribeLabels.d.ts → admin/deleteCommunicationTemplate.d.ts} +0 -0
@@ -1,144 +0,0 @@
1
- import { CID } from 'multiformats/cid';
2
- import { AtUri } from '@atproto/syntax';
3
- import { Database } from '../../db';
4
- import { ModerationViews } from './views';
5
- import { Main as StrongRef } from '../../lexicon/types/com/atproto/repo/strongRef';
6
- import { RepoRef, RepoBlobRef } from '../../lexicon/types/com/atproto/admin/defs';
7
- import { ModEventType, ModerationEventRow, ModerationSubjectStatusRow, ReversibleModerationEvent } from './types';
8
- import { ModerationEvent } from '../../db/schema/moderation_event';
9
- import AtpAgent from '@atproto/api';
10
- import { Label } from '../../lexicon/types/com/atproto/label/defs';
11
- import { ModSubject, RecordSubject, RepoSubject } from './subject';
12
- export declare class ModerationService {
13
- db: Database;
14
- appviewAgent: AtpAgent;
15
- constructor(db: Database, appviewAgent: AtpAgent);
16
- static creator(appviewAgent: AtpAgent): (db: Database) => ModerationService;
17
- views: ModerationViews;
18
- getEvent(id: number): Promise<ModerationEventRow | undefined>;
19
- getEventOrThrow(id: number): Promise<ModerationEventRow>;
20
- getEvents(opts: {
21
- subject?: string;
22
- createdBy?: string;
23
- limit: number;
24
- cursor?: string;
25
- includeAllUserRecords: boolean;
26
- types: ModerationEvent['action'][];
27
- sortDirection?: 'asc' | 'desc';
28
- }): Promise<{
29
- cursor?: string;
30
- events: ModerationEventRow[];
31
- }>;
32
- getReport(id: number): Promise<ModerationEventRow | undefined>;
33
- getCurrentStatus(subject: {
34
- did: string;
35
- } | {
36
- uri: AtUri;
37
- } | {
38
- cids: CID[];
39
- }): Promise<{
40
- did: string;
41
- id: number;
42
- createdAt: string;
43
- updatedAt: string;
44
- reviewState: "com.atproto.admin.defs#reviewOpen" | "com.atproto.admin.defs#reviewEscalated" | "com.atproto.admin.defs#reviewClosed";
45
- blobCids: string[] | null;
46
- comment: string | null;
47
- lastReportedAt: string | null;
48
- lastReviewedAt: string | null;
49
- muteUntil: string | null;
50
- lastReviewedBy: string | null;
51
- takendown: boolean;
52
- suspendUntil: string | null;
53
- recordPath: string;
54
- recordCid: string | null;
55
- }[]>;
56
- logEvent(info: {
57
- event: ModEventType;
58
- subject: ModSubject;
59
- createdBy: string;
60
- createdAt?: Date;
61
- }): Promise<ModerationEventRow>;
62
- getLastReversibleEventForSubject(subject: ReversalSubject): Promise<{
63
- id: number;
64
- createdBy: string;
65
- createdAt: string;
66
- comment: string | null;
67
- createLabelVals: string | null;
68
- negateLabelVals: string | null;
69
- durationInHours: number | null;
70
- action: "com.atproto.admin.defs#modEventTakedown" | "com.atproto.admin.defs#modEventAcknowledge" | "com.atproto.admin.defs#modEventEscalate" | "com.atproto.admin.defs#modEventComment" | "com.atproto.admin.defs#modEventLabel" | "com.atproto.admin.defs#modEventReport" | "com.atproto.admin.defs#modEventMute" | "com.atproto.admin.defs#modEventReverseTakedown" | "com.atproto.admin.defs#modEventEmail";
71
- subjectType: "com.atproto.admin.defs#repoRef" | "com.atproto.repo.strongRef";
72
- subjectDid: string;
73
- subjectUri: string | null;
74
- subjectCid: string | null;
75
- meta: Record<string, string | boolean> | null;
76
- expiresAt: string | null;
77
- legacyRefId: number | null;
78
- } | null | undefined>;
79
- getSubjectsDueForReversal(): Promise<ReversalSubject[]>;
80
- isSubjectSuspended(did: string): Promise<boolean>;
81
- revertState({ createdBy, createdAt, comment, action, subject, }: ReversibleModerationEvent): Promise<ModerationEventRow>;
82
- takedownRepo(subject: RepoSubject, takedownId: number): Promise<void>;
83
- reverseTakedownRepo(subject: RepoSubject): Promise<void>;
84
- takedownRecord(subject: RecordSubject, takedownId: number): Promise<void>;
85
- reverseTakedownRecord(subject: RecordSubject): Promise<void>;
86
- report(info: {
87
- reasonType: NonNullable<ModerationEventRow['meta']>['reportType'];
88
- reason?: string;
89
- subject: ModSubject;
90
- reportedBy: string;
91
- createdAt?: Date;
92
- }): Promise<ModerationEventRow>;
93
- getSubjectStatuses({ cursor, limit, takendown, reviewState, reviewedAfter, reviewedBefore, reportedAfter, reportedBefore, includeMuted, ignoreSubjects, sortDirection, lastReviewedBy, sortField, subject, }: {
94
- cursor?: string;
95
- limit?: number;
96
- takendown?: boolean;
97
- reviewedBefore?: string;
98
- reviewState?: ModerationSubjectStatusRow['reviewState'];
99
- reviewedAfter?: string;
100
- reportedAfter?: string;
101
- reportedBefore?: string;
102
- includeMuted?: boolean;
103
- subject?: string;
104
- ignoreSubjects?: string[];
105
- sortDirection: 'asc' | 'desc';
106
- lastReviewedBy?: string;
107
- sortField: 'lastReviewedAt' | 'lastReportedAt';
108
- }): Promise<{
109
- statuses: {
110
- handle: string;
111
- did: string;
112
- id: number;
113
- createdAt: string;
114
- updatedAt: string;
115
- reviewState: "com.atproto.admin.defs#reviewOpen" | "com.atproto.admin.defs#reviewEscalated" | "com.atproto.admin.defs#reviewClosed";
116
- blobCids: string[] | null;
117
- comment: string | null;
118
- lastReportedAt: string | null;
119
- lastReviewedAt: string | null;
120
- muteUntil: string | null;
121
- lastReviewedBy: string | null;
122
- takendown: boolean;
123
- suspendUntil: string | null;
124
- recordPath: string;
125
- recordCid: string | null;
126
- }[];
127
- cursor: string | undefined;
128
- }>;
129
- isSubjectTakendown(subject: ModSubject): Promise<boolean>;
130
- formatAndCreateLabels(src: string, uri: string, cid: string | null, labels: {
131
- create?: string[];
132
- negate?: string[];
133
- }): Promise<Label[]>;
134
- createLabels(labels: Label[]): Promise<void>;
135
- }
136
- export declare type TakedownSubjects = {
137
- did: string;
138
- subjects: (RepoRef | RepoBlobRef | StrongRef)[];
139
- };
140
- export declare type ReversalSubject = {
141
- subject: ModSubject;
142
- reverseSuspend: boolean;
143
- reverseMute: boolean;
144
- };
@@ -1,12 +0,0 @@
1
- import { AtUri } from '@atproto/syntax';
2
- import { Database } from '../../db';
3
- import { ModerationSubjectStatus } from '../../db/schema/moderation_subject_status';
4
- import { ModerationEventRow } from './types';
5
- export declare const adjustModerationSubjectStatus: (db: Database, moderationEvent: ModerationEventRow, blobCids?: string[]) => Promise<import("kysely").InsertResult | null>;
6
- declare type ModerationSubjectStatusFilter = Pick<ModerationSubjectStatus, 'did'> | Pick<ModerationSubjectStatus, 'did' | 'recordPath'> | Pick<ModerationSubjectStatus, 'did' | 'recordPath' | 'recordCid'>;
7
- export declare const getModerationSubjectStatus: (db: Database, filters: ModerationSubjectStatusFilter) => Promise<{} | undefined>;
8
- export declare const getStatusIdentifierFromSubject: (subject: string | AtUri) => {
9
- did: string;
10
- recordPath: string;
11
- };
12
- export {};
@@ -1,60 +0,0 @@
1
- import { AtUri } from '@atproto/syntax';
2
- import { InputSchema as ReportInput } from '../../lexicon/types/com/atproto/moderation/createReport';
3
- import { InputSchema as ActionInput } from '../../lexicon/types/com/atproto/admin/emitModerationEvent';
4
- import { ModerationEventRow, ModerationSubjectStatusRow } from './types';
5
- import { RepoRef } from '../../lexicon/types/com/atproto/admin/defs';
6
- import { Main as StrongRef } from '../../lexicon/types/com/atproto/repo/strongRef';
7
- declare type SubjectInput = ReportInput['subject'] | ActionInput['subject'];
8
- export declare const subjectFromInput: (subject: SubjectInput, blobs?: string[]) => ModSubject;
9
- export declare const subjectFromEventRow: (row: ModerationEventRow) => ModSubject;
10
- export declare const subjectFromStatusRow: (row: ModerationSubjectStatusRow) => ModSubject;
11
- declare type SubjectInfo = {
12
- subjectType: 'com.atproto.admin.defs#repoRef' | 'com.atproto.repo.strongRef';
13
- subjectDid: string;
14
- subjectUri: string | null;
15
- subjectCid: string | null;
16
- };
17
- export interface ModSubject {
18
- did: string;
19
- recordPath: string | undefined;
20
- blobCids?: string[];
21
- isRepo(): this is RepoSubject;
22
- isRecord(): this is RecordSubject;
23
- info(): SubjectInfo;
24
- lex(): RepoRef | StrongRef;
25
- }
26
- export declare class RepoSubject implements ModSubject {
27
- did: string;
28
- blobCids: undefined;
29
- recordPath: undefined;
30
- constructor(did: string);
31
- isRepo(): boolean;
32
- isRecord(): boolean;
33
- isWeakRecord(): boolean;
34
- info(): {
35
- subjectType: "com.atproto.admin.defs#repoRef";
36
- subjectDid: string;
37
- subjectUri: null;
38
- subjectCid: null;
39
- };
40
- lex(): RepoRef;
41
- }
42
- export declare class RecordSubject implements ModSubject {
43
- uri: string;
44
- cid: string;
45
- blobCids?: string[] | undefined;
46
- parsedUri: AtUri;
47
- did: string;
48
- recordPath: string;
49
- constructor(uri: string, cid: string, blobCids?: string[] | undefined);
50
- isRepo(): boolean;
51
- isRecord(): boolean;
52
- info(): {
53
- subjectType: "com.atproto.repo.strongRef";
54
- subjectDid: string;
55
- subjectUri: string;
56
- subjectCid: string;
57
- };
58
- lex(): StrongRef;
59
- }
60
- export {};
@@ -1,19 +0,0 @@
1
- import { Selectable } from 'kysely';
2
- import { ModerationEvent } from '../../db/schema/moderation_event';
3
- import { ModerationSubjectStatus } from '../../db/schema/moderation_subject_status';
4
- import { ComAtprotoAdminDefs } from '@atproto/api';
5
- import { ModSubject } from './subject';
6
- export declare type ModerationEventRow = Selectable<ModerationEvent>;
7
- export declare type ReversibleModerationEvent = Pick<ModerationEventRow, 'createdBy' | 'comment' | 'action'> & {
8
- createdAt?: Date;
9
- subject: ModSubject;
10
- };
11
- export declare type ModerationEventRowWithHandle = ModerationEventRow & {
12
- subjectHandle?: string | null;
13
- creatorHandle?: string | null;
14
- };
15
- export declare type ModerationSubjectStatusRow = Selectable<ModerationSubjectStatus>;
16
- export declare type ModerationSubjectStatusRowWithHandle = ModerationSubjectStatusRow & {
17
- handle: string | null;
18
- };
19
- export declare type ModEventType = ComAtprotoAdminDefs.ModEventTakedown | ComAtprotoAdminDefs.ModEventAcknowledge | ComAtprotoAdminDefs.ModEventEscalate | ComAtprotoAdminDefs.ModEventComment | ComAtprotoAdminDefs.ModEventLabel | ComAtprotoAdminDefs.ModEventReport | ComAtprotoAdminDefs.ModEventMute | ComAtprotoAdminDefs.ModEventReverseTakedown;
@@ -1,42 +0,0 @@
1
- import AtpAgent from '@atproto/api';
2
- import { BlobRef } from '@atproto/lexicon';
3
- import { Database } from '../../db';
4
- import { ModEventView, RepoView, RepoViewDetail, RecordView, RecordViewDetail, ReportViewDetail, BlobView, SubjectStatusView, ModEventViewDetail, AccountView } from '../../lexicon/types/com/atproto/admin/defs';
5
- import { OutputSchema as ReportOutput } from '../../lexicon/types/com/atproto/moderation/createReport';
6
- import { Label } from '../../lexicon/types/com/atproto/label/defs';
7
- import { ModerationEventRowWithHandle, ModerationSubjectStatusRowWithHandle } from './types';
8
- export declare class ModerationViews {
9
- private db;
10
- private appviewAgent;
11
- constructor(db: Database, appviewAgent: AtpAgent);
12
- getAccoutInfosByDid(dids: string[]): Promise<Map<string, AccountView>>;
13
- repos(dids: string[]): Promise<Map<string, RepoView>>;
14
- formatEvent(event: ModerationEventRowWithHandle): ModEventView;
15
- eventDetail(result: ModerationEventRowWithHandle): Promise<ModEventViewDetail>;
16
- repoDetail(did: string): Promise<RepoViewDetail | undefined>;
17
- fetchRecords(subjects: RecordSubject[]): Promise<Map<string, {
18
- uri: string;
19
- cid: string;
20
- value: Record<string, unknown>;
21
- indexedAt: string;
22
- }>>;
23
- records(subjects: RecordSubject[]): Promise<Map<string, RecordView>>;
24
- recordDetail(subject: RecordSubject): Promise<RecordViewDetail | undefined>;
25
- formatReport(report: ModerationEventRowWithHandle): ReportOutput;
26
- subject(subject: string): Promise<SubjectView>;
27
- blob(blobs: BlobRef[]): Promise<BlobView[]>;
28
- labels(subject: string, includeNeg?: boolean): Promise<Label[]>;
29
- getSubjectStatus(subjects: string[]): Promise<Map<string, ModerationSubjectStatusRowWithHandle>>;
30
- formatSubjectStatus(status: ModerationSubjectStatusRowWithHandle): SubjectStatusView;
31
- }
32
- declare type RecordSubject = {
33
- uri: string;
34
- cid?: string;
35
- };
36
- declare type SubjectView = ModEventViewDetail['subject'] & ReportViewDetail['subject'];
37
- export declare function getSelfLabels(details: {
38
- uri: string | null;
39
- cid: string | null;
40
- record: Record<string, unknown> | null;
41
- }): Label[];
42
- export {};
@@ -1,2 +0,0 @@
1
- import { Database } from '../db';
2
- export declare type FromDb<T> = (db: Database) => T;
@@ -1 +0,0 @@
1
- export declare function addHoursToDate(hours: number, startingDate?: Date): Date;
@@ -1 +0,0 @@
1
- export declare const debugCatch: <Func extends (...args: any[]) => any>(fn: Func) => (...args: Parameters<Func>) => Promise<ReturnType<Func>>;
@@ -1,3 +0,0 @@
1
- import { RetryOptions } from '@atproto/common';
2
- export declare function retryHttp<T>(fn: () => Promise<T>, opts?: RetryOptions): Promise<T>;
3
- export declare function retryableHttp(err: unknown): boolean;
package/test.log DELETED
Binary file