@geoly-ai/social-hub-sdk 0.1.17 → 0.1.19

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/index.d.ts CHANGED
@@ -198,6 +198,8 @@ export type ListRedditPostSnapshotsParams = {
198
198
  draftStatus?: string;
199
199
  postType?: string;
200
200
  repostType?: string;
201
+ /** 账号类型:`internal` / `external`,可逗号分隔;proxy / 海外兼职 / 未知 / 空值在选了任一项时不命中。 */
202
+ accountType?: string;
201
203
  containsBrandKeyword?: "true" | "false" | "unset";
202
204
  primaryProduct?: string;
203
205
  /**
@@ -223,6 +225,8 @@ export type RedditPostSnapshotStatsParams = {
223
225
  draftStatus?: string;
224
226
  postType?: string;
225
227
  repostType?: string;
228
+ /** 账号类型:`internal` / `external`,可逗号分隔;proxy / 海外兼职 / 未知 / 空值在选了任一项时不命中。 */
229
+ accountType?: string;
226
230
  containsBrandKeyword?: "true" | "false" | "unset";
227
231
  primaryProduct?: string;
228
232
  /** 序列号闭区间(与列表同口径)。 */
@@ -1208,6 +1212,170 @@ export type UpdateSubredditMonitorConfigBody = {
1208
1212
  */
1209
1213
  fetchLimit: number;
1210
1214
  };
1215
+ /** 公开库端点前缀(供应商无关)。 */
1216
+ export declare const PUBLIC_REDDIT_BASE_PATH = "/v1/system/public-reddit";
1217
+ export declare const PUBLIC_REDDIT_PATHS: {
1218
+ readonly communities: "/v1/system/public-reddit/communities";
1219
+ readonly posts: "/v1/system/public-reddit/posts";
1220
+ readonly postCounts: "/v1/system/public-reddit/post-counts";
1221
+ readonly status: "/v1/system/public-reddit/status";
1222
+ };
1223
+ /**
1224
+ * 公开库错误码(服务端 `error.code`)。🔴 `DISABLED` / `POLICY_DENIED` / `AUTH_FAILED` 等
1225
+ * 都是「读不到」而**不是**「没有数据」,调用方绝不能把它们当成空结果。
1226
+ */
1227
+ export declare const PUBLIC_REDDIT_ERROR_CODES: {
1228
+ readonly DISABLED: "PUBLIC_REDDIT_DISABLED";
1229
+ readonly BUDGET_EXHAUSTED: "PUBLIC_REDDIT_BUDGET_EXHAUSTED";
1230
+ readonly DEGRADED: "PUBLIC_REDDIT_DEGRADED";
1231
+ readonly COUNT_TIMEOUT: "PUBLIC_REDDIT_COUNT_TIMEOUT";
1232
+ readonly RATE_LIMITED: "PUBLIC_REDDIT_RATE_LIMITED";
1233
+ readonly AUTH_FAILED: "PUBLIC_REDDIT_AUTH_FAILED";
1234
+ readonly POLICY_DENIED: "PUBLIC_REDDIT_POLICY_DENIED";
1235
+ readonly COMMUNITY_NOT_AVAILABLE: "PUBLIC_REDDIT_COMMUNITY_NOT_AVAILABLE";
1236
+ readonly SCOPE_TOO_LARGE: "PUBLIC_REDDIT_SCOPE_TOO_LARGE";
1237
+ readonly QUERY_REQUIRED: "PUBLIC_REDDIT_QUERY_REQUIRED";
1238
+ readonly INVALID_REQUEST: "PUBLIC_REDDIT_INVALID_REQUEST";
1239
+ readonly INVALID_WINDOW: "PUBLIC_REDDIT_INVALID_WINDOW";
1240
+ readonly INVALID_COMMUNITY: "PUBLIC_REDDIT_INVALID_COMMUNITY";
1241
+ readonly CURSOR_MISMATCH: "PUBLIC_REDDIT_CURSOR_MISMATCH";
1242
+ readonly CURSOR_RESET: "PUBLIC_REDDIT_CURSOR_RESET";
1243
+ readonly UNAVAILABLE: "PUBLIC_REDDIT_UNAVAILABLE";
1244
+ readonly BAD_UPSTREAM_RESPONSE: "PUBLIC_REDDIT_BAD_UPSTREAM_RESPONSE";
1245
+ };
1246
+ export type PublicRedditNamedWindow = "day" | "week" | "month" | "last_90d" | "last_360d" | "last_full_week";
1247
+ /** 窗口:命名窗口与显式 [from,to) 二选一(服务端校验互斥)。 */
1248
+ export type PublicRedditWindowParams = {
1249
+ window?: PublicRedditNamedWindow;
1250
+ from?: string;
1251
+ to?: string;
1252
+ };
1253
+ export type ListPublicRedditCommunitiesParams = {
1254
+ /** 数组按逗号拼接(与服务端 csv 形状一致)。 */
1255
+ industryKey?: string | string[];
1256
+ tierKey?: string | string[];
1257
+ poolKind?: string | string[];
1258
+ hasProfile?: boolean;
1259
+ limit?: number;
1260
+ /** Hub 令牌:原样回传上一页的 nextCursor。 */
1261
+ cursor?: string;
1262
+ };
1263
+ export type SearchPublicRedditPostsParams = PublicRedditWindowParams & {
1264
+ /** 必填、≤20 个;数组按逗号拼接。 */
1265
+ subreddit: string | string[];
1266
+ /** ⚠️ 会发往外部数据服务。 */
1267
+ query?: string;
1268
+ sort?: "created_at_desc";
1269
+ limit?: number;
1270
+ cursor?: string;
1271
+ includeBody?: boolean;
1272
+ };
1273
+ export type CountPublicRedditPostsBody = PublicRedditWindowParams & {
1274
+ subreddits: string[];
1275
+ /** 必填;⚠️ 会发往外部数据服务。 */
1276
+ query: string;
1277
+ artifactType?: "post" | "comment";
1278
+ };
1279
+ export type PublicRedditSourceMeta = {
1280
+ provider: "cyberredd";
1281
+ mode: "off" | "shadow" | "on";
1282
+ dataCutoff: string | null;
1283
+ resolvedWindow: {
1284
+ from: string;
1285
+ to: string;
1286
+ name: string | null;
1287
+ } | null;
1288
+ fetchedAt: string;
1289
+ cached: boolean;
1290
+ excludedCommunities: Array<{
1291
+ communityId: string;
1292
+ reason: string;
1293
+ }>;
1294
+ warnings: Array<{
1295
+ code: string;
1296
+ message?: string;
1297
+ }>;
1298
+ };
1299
+ export type PublicRedditCommunity = {
1300
+ communityId: string;
1301
+ name: string | null;
1302
+ url: string | null;
1303
+ industryKeys: string[] | null;
1304
+ tierKey: string | null;
1305
+ poolKind: string | null;
1306
+ hasProfile: boolean | null;
1307
+ dataCutoff: string | null;
1308
+ };
1309
+ export type PublicRedditPost = {
1310
+ upstreamId: string;
1311
+ redditPostId: string | null;
1312
+ communityId: string;
1313
+ title: string | null;
1314
+ bodyExcerpt: string | null;
1315
+ body?: string | null;
1316
+ authorName: string | null;
1317
+ createdAt: string | null;
1318
+ url: string | null;
1319
+ contentState: string | null;
1320
+ observationStatus: string | null;
1321
+ intent: string | null;
1322
+ sentiment: string | null;
1323
+ labelVocabulary: "cyberredd_v1";
1324
+ };
1325
+ export type ListPublicRedditCommunitiesResponse = {
1326
+ items: PublicRedditCommunity[];
1327
+ nextCursor: string | null;
1328
+ source: PublicRedditSourceMeta;
1329
+ };
1330
+ export type SearchPublicRedditPostsResponse = {
1331
+ items: PublicRedditPost[];
1332
+ nextCursor: string | null;
1333
+ source: PublicRedditSourceMeta;
1334
+ };
1335
+ export type CountPublicRedditPostsResponse = {
1336
+ artifactType: "post" | "comment";
1337
+ window: {
1338
+ from: string;
1339
+ to: string;
1340
+ name: string | null;
1341
+ };
1342
+ exact: boolean;
1343
+ /** exact=false 时为 null,绝不是部分和。 */
1344
+ total: number | null;
1345
+ communities: Array<{
1346
+ communityId: string;
1347
+ status: string;
1348
+ count: number | null;
1349
+ dataCutoff: string | null;
1350
+ windowCovered: boolean | null;
1351
+ }>;
1352
+ source: PublicRedditSourceMeta;
1353
+ };
1354
+ export type PublicRedditStatus = {
1355
+ mode: "off" | "shadow" | "on";
1356
+ capabilities: Array<"catalog" | "post_search" | "post_count">;
1357
+ configured: boolean;
1358
+ keyFingerprint: string | null;
1359
+ keyExpiresAt: string | null;
1360
+ credential: Record<string, unknown>;
1361
+ breaker: {
1362
+ state: string;
1363
+ openedAt: string | null;
1364
+ };
1365
+ budget: {
1366
+ windowSeconds: number;
1367
+ limit: number;
1368
+ used: number;
1369
+ };
1370
+ catalogIndex: {
1371
+ size: number | null;
1372
+ refreshedAt: string | null;
1373
+ };
1374
+ lastError: {
1375
+ code: string;
1376
+ at: string;
1377
+ } | null;
1378
+ };
1211
1379
  export type ListHotPostsParams = {
1212
1380
  limit?: number;
1213
1381
  offset?: number;
@@ -1681,6 +1849,57 @@ export type ScrapeUrlResponse = (ScrapeResponseCommon & {
1681
1849
  export declare const CONTENT_REVIEW_AUTHOR_RELATION_MISMATCH: "AUTHOR_RELATION_MISMATCH";
1682
1850
  /** 该错误是否为 {@link CONTENT_REVIEW_AUTHOR_RELATION_MISMATCH}(422 + 稳定 code)。 */
1683
1851
  export declare function isAuthorRelationMismatchError(error: unknown): error is SocialHubHttpError;
1852
+ /**
1853
+ * 页面周指标(周访客 / 周贡献)—— 与 contracts `OwnedSubredditWeeklyStats*` 同形。
1854
+ * SDK 不能 import contracts(private 包),所以这里手写镜像;改契约时同步这里。
1855
+ */
1856
+ export type OwnedSubredditWeeklyMetric = {
1857
+ /** 页面原文,如 "1.2K";从未命中为 null。 */
1858
+ text: string | null;
1859
+ /** 解析后的整数;原文解析不了为 null(此时 text 仍在)。 */
1860
+ num: number | null;
1861
+ observedAt: string | null;
1862
+ status: "ok" | "missing" | "stale";
1863
+ /** 与相邻上一 UTC 周的环比(%);前值缺失 / 为 0 / 不可解析为 null(⛔ 不是 0)。 */
1864
+ deltaPct: number | null;
1865
+ };
1866
+ export type OwnedSubredditWeeklyLastAttempt = {
1867
+ at: string;
1868
+ outcome: "ok" | "failed" | "not_visible" | "quota_skipped";
1869
+ reason: string | null;
1870
+ };
1871
+ export type OwnedSubredditWeeklyStats = {
1872
+ weekStart: string | null;
1873
+ visitors: OwnedSubredditWeeklyMetric;
1874
+ contributions: OwnedSubredditWeeklyMetric;
1875
+ lastAttempt: OwnedSubredditWeeklyLastAttempt | null;
1876
+ };
1877
+ export type OwnedSubredditWeeklyTrendMetricPoint = {
1878
+ text: string;
1879
+ num: number | null;
1880
+ observedAt: string;
1881
+ };
1882
+ export type OwnedSubredditWeeklyTrend = {
1883
+ ownedSubredditId: string;
1884
+ name: string;
1885
+ weeks: number;
1886
+ /** 长度恒为 weeks,旧 → 新;缺周的指标为 null(不压缩、不补 0)。 */
1887
+ points: Array<{
1888
+ weekStart: string;
1889
+ visitors: OwnedSubredditWeeklyTrendMetricPoint | null;
1890
+ contributions: OwnedSubredditWeeklyTrendMetricPoint | null;
1891
+ }>;
1892
+ lastAttempt: OwnedSubredditWeeklyLastAttempt | null;
1893
+ };
1894
+ export type OwnedSubredditWeeklyRefreshAccepted = {
1895
+ status: "queued";
1896
+ ownedSubredditId: string;
1897
+ subreddit: string;
1898
+ runId: string;
1899
+ businessDate: string;
1900
+ /** 下一业务日起点(同一板块下次允许再手动刷新的最早时刻)。 */
1901
+ nextAllowedAt: string;
1902
+ };
1684
1903
  export declare class SocialHubClient {
1685
1904
  private readonly opts;
1686
1905
  constructor(opts: SocialHubClientOptions);
@@ -2732,6 +2951,9 @@ export declare class SocialHubClient {
2732
2951
  items: unknown[];
2733
2952
  total: number;
2734
2953
  }>;
2954
+ /**
2955
+ * 评论样本列表。⚠️ 只含 Hub 内现有评论样本(非归档,约 5.7 万条);历史/归档评论已迁至 CyberRedd。
2956
+ */
2735
2957
  listRedditCommentSamples(params?: {
2736
2958
  postId?: string;
2737
2959
  subreddit?: string;
@@ -2761,6 +2983,7 @@ export declare class SocialHubClient {
2761
2983
  * (totalRelation=unavailable)。
2762
2984
  * ⚠️ 无过滤时是全表精确 count,属昂贵读——基线用途,**禁止轮询**。
2763
2985
  * 口径是库内 reddit_comment_samples 行数,不是 Reddit 线程真实评论总数。
2986
+ * ⚠️ 只含 Hub 内现有评论样本(非归档,约 5.7 万条);历史/归档评论已迁至 CyberRedd。
2764
2987
  */
2765
2988
  countRedditCommentSamples(params?: {
2766
2989
  postId?: string;
@@ -3191,6 +3414,17 @@ export declare class SocialHubClient {
3191
3414
  }>;
3192
3415
  }>;
3193
3416
  exportHotPostsCsv(params?: ListHotPostsParams): Promise<string>;
3417
+ /** GET /v1/system/public-reddit/communities — 公开库社区目录(只读;系统级,无 team 前缀)。 */
3418
+ listPublicRedditCommunities(params?: ListPublicRedditCommunitiesParams): Promise<ListPublicRedditCommunitiesResponse>;
3419
+ /** GET /v1/system/public-reddit/posts — 公开库帖子检索(必须带板块;query 会发往外部数据服务)。 */
3420
+ searchPublicRedditPosts(params: SearchPublicRedditPostsParams): Promise<SearchPublicRedditPostsResponse>;
3421
+ /**
3422
+ * POST /v1/system/public-reddit/post-counts — 公开库计数。
3423
+ * ⚠️ 昂贵读,禁止轮询;必须带 query;query 会发往外部数据服务。
3424
+ */
3425
+ countPublicRedditPosts(body: CountPublicRedditPostsBody): Promise<CountPublicRedditPostsResponse>;
3426
+ /** GET /v1/system/public-reddit/status — 开关/熔断/预算(仅 unrestricted admin)。 */
3427
+ getPublicRedditStatus(): Promise<PublicRedditStatus>;
3194
3428
  listKolIntents(params?: ListKolIntentsParams): Promise<{
3195
3429
  items: unknown[];
3196
3430
  total: number;
@@ -4122,6 +4356,24 @@ export declare class SocialHubClient {
4122
4356
  }): Promise<{
4123
4357
  items: unknown[];
4124
4358
  }>;
4359
+ /**
4360
+ * GET :id/weekly-stats — 板块页面周指标趋势(周访客 / 周贡献,默认 12 周,最多 52)。
4361
+ *
4362
+ * 返回长度恒为 `weeks` 的按周序列(旧 → 新);缺周的指标为 null —— ⛔ 不是 0。
4363
+ * 列表接口 `listOwnedSubreddits` 的每行另带 `weeklyStats`(当前值 + 环比)。
4364
+ */
4365
+ getOwnedSubredditWeeklyStats(ownedSubredditId: string, params?: {
4366
+ weeks?: number;
4367
+ }): Promise<OwnedSubredditWeeklyTrend>;
4368
+ /**
4369
+ * POST :id/weekly-stats/refresh — 手动刷新该板块的页面周指标(202 入队)。
4370
+ *
4371
+ * 每板块每业务日最多真实抓一次:当日已抓/已入队 → 409,`error.details.code` 为
4372
+ * `refresh_already_charged_today`,`details.nextAllowedAt` 是下一业务日起点;
4373
+ * 其余稳定码见 contracts `WEEKLY_STATS_REFRESH_REJECT_CODES`。
4374
+ * 仅 active 资产;写权限同其它写端点(真实登录 admin,拒 API Key)。
4375
+ */
4376
+ refreshOwnedSubredditWeeklyStats(ownedSubredditId: string): Promise<OwnedSubredditWeeklyRefreshAccepted>;
4125
4377
  /** GET :id — 单条资产详情(不可见时返 404,不返 403:避免变成枚举面)。 */
4126
4378
  getOwnedSubreddit(ownedSubredditId: string): Promise<unknown>;
4127
4379
  /**