@pyqdeck/community-sdk 0.1.0 → 0.2.0

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/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { type HttpOptions, type RequestOptions } from "./http.js";
2
- import type { Comment, CommunityInfo, LinkInfo, LinkedResource, LocalImage, Member, MediaItem, Notification, NotificationType, OwnMember, Page, PageParams, Post, ProfileUpdate, ReportGroup, ReportReason, ReportTarget, TrendingTag, UploadTicket } from "./types.js";
2
+ import type { Comment, CommunityInfo, LinkInfo, LinkedResource, LocalImage, Member, MediaItem, ModerationEvent, ModerationEventFilter, PageMeta, Notification, NotificationType, OwnMember, Page, PageParams, Post, ProfileUpdate, ReportGroup, ReportReason, ReportTarget, TrendingTag, UploadTicket } from "./types.js";
3
3
  import { type FileUploader } from "./upload.js";
4
4
  export interface CommunityClientOptions extends HttpOptions {
5
5
  /** The community this client talks to (`beu`, `gate`, ...). Added to every path; one client per app (IR-SDK-12). */
@@ -150,6 +150,12 @@ export declare function createCommunityClient(options: CommunityClientOptions):
150
150
  closed: number;
151
151
  }>;
152
152
  };
153
+ moderation: {
154
+ events: (filter?: ModerationEventFilter, o?: RequestOptions) => Promise<{
155
+ items: ModerationEvent[];
156
+ page: PageMeta;
157
+ }>;
158
+ };
153
159
  links: {
154
160
  /** Destination host and safety verdict, so the app can show its own warning before opening a link. */
155
161
  resolve: (code: string, o?: RequestOptions) => Promise<LinkInfo>;
package/dist/client.js CHANGED
@@ -86,6 +86,18 @@ export function createCommunityClient(options) {
86
86
  queue: async (p = {}, o) => (await get("/reports", { ...p }, o)).data,
87
87
  resolve: async (input, o) => (await send("POST", "/reports/resolve", input, o)).data,
88
88
  };
89
+ // Moderators and admins only. The history of every content check, allowed results included.
90
+ const moderation = {
91
+ events: async (filter = {}, o) => {
92
+ const res = await http.call({
93
+ method: "GET",
94
+ path: `${root}/moderation/events`,
95
+ query: { ...filter, escalate: filter.escalate === undefined ? undefined : String(filter.escalate) },
96
+ ...o,
97
+ });
98
+ return { items: res.data, page: res.pagination };
99
+ },
100
+ };
89
101
  const links = {
90
102
  /** Destination host and safety verdict, so the app can show its own warning before opening a link. */
91
103
  resolve: async (code, o) => (await get(`/links/${enc(code)}`, undefined, o)).data,
@@ -168,6 +180,7 @@ export function createCommunityClient(options) {
168
180
  members,
169
181
  notifications,
170
182
  reports,
183
+ moderation,
171
184
  links,
172
185
  media,
173
186
  publishPost,
package/dist/http.d.ts CHANGED
@@ -19,9 +19,16 @@ interface Call extends RequestOptions {
19
19
  }
20
20
  export interface Envelope<T> {
21
21
  data: T;
22
+ /** Cursor lists send `nextCursor` and `hasMore`; the few offset lists (moderation history) send page numbers. */
22
23
  pagination?: {
23
24
  nextCursor?: string | null;
24
25
  hasMore?: boolean;
26
+ total?: number;
27
+ page?: number;
28
+ limit?: number;
29
+ totalPages?: number;
30
+ hasNext?: boolean;
31
+ hasPrev?: boolean;
25
32
  };
26
33
  }
27
34
  export declare class Http {
package/dist/types.d.ts CHANGED
@@ -81,6 +81,9 @@ export interface Comment {
81
81
  editedAt: string | null;
82
82
  createdAt: string;
83
83
  rawBody?: string;
84
+ /** Own comments and, for moderators, anyone's. */
85
+ heldReason?: "moderation" | "reports" | null;
86
+ removedReason?: string | null;
84
87
  hasPendingEdit?: boolean;
85
88
  }
86
89
  export interface Member extends Author {
@@ -179,6 +182,15 @@ export interface ReportGroup {
179
182
  reasons: ReportReason[];
180
183
  notes: string[];
181
184
  firstReportedAt: string;
185
+ /** What the reported thing is, so a moderator does not have to open it. Null if it no longer exists. */
186
+ preview: {
187
+ title: string;
188
+ snippet?: string;
189
+ authorUsername?: string | null;
190
+ /** The post to open (the post itself, or the post a comment belongs to). */
191
+ postId?: string;
192
+ status?: string;
193
+ } | null;
182
194
  }
183
195
  export interface LinkInfo {
184
196
  code: string;
@@ -188,6 +200,43 @@ export interface LinkInfo {
188
200
  /** What a tap would do: open at once, show the warning page, or refuse. */
189
201
  decision: "redirect" | "warn" | "blocked" | "gone" | "notfound";
190
202
  }
203
+ /** One result of the content check. The content itself is never stored, only who, where, the result and the scores. */
204
+ export interface ModerationEvent {
205
+ _id: string;
206
+ /** The member who submitted it. */
207
+ userId?: string;
208
+ /** Where it was submitted: media, post, comment or profile. */
209
+ source: string;
210
+ /** The checked thing: a media id for images. */
211
+ sourceId?: string;
212
+ action: "allow" | "review" | "reject";
213
+ /** The checker was unavailable, so there is no real verdict. */
214
+ degraded: boolean;
215
+ /** Sexual content involving minors: needs the child-safety process. */
216
+ escalate: boolean;
217
+ categories: string[];
218
+ scores: Record<string, number>;
219
+ /** Which checker decided, e.g. openai or profanity-filter. */
220
+ provider: string;
221
+ createdAt: string;
222
+ }
223
+ export interface PageMeta {
224
+ total: number;
225
+ page: number;
226
+ limit: number;
227
+ totalPages: number;
228
+ hasNext: boolean;
229
+ hasPrev: boolean;
230
+ }
231
+ export interface ModerationEventFilter {
232
+ page?: number;
233
+ limit?: number;
234
+ action?: "allow" | "review" | "reject";
235
+ source?: string;
236
+ sourceId?: string;
237
+ userId?: string;
238
+ escalate?: boolean;
239
+ }
191
240
  /** A cursor page. Pass `nextCursor` back to get the next one. */
192
241
  export interface Page<T> {
193
242
  items: T[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pyqdeck/community-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Typed client for the PYQDeck Community API (posts, comments, members, short links). No Clerk, React or cache inside: the app supplies the token and owns caching.",
5
5
  "keywords": [
6
6
  "pyqdeck",