@geoly-ai/social-hub-sdk 0.0.56 → 0.0.58
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 +234 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +101 -33
- package/dist/index.js.map +1 -1
- package/dist/index.test.js +252 -1
- package/dist/index.test.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -67,6 +67,12 @@ export type ListCalendarEntriesParams = {
|
|
|
67
67
|
export type UpdateCalendarEntryBody = {
|
|
68
68
|
plannedAt?: string;
|
|
69
69
|
status?: string;
|
|
70
|
+
/**
|
|
71
|
+
* 「谁来发这条内容」——防重复发帖的唯一闸门(方案 Block 0 · D1)。
|
|
72
|
+
* 改它会让服务端在同一事务里撤销/创建内部 job 并 append directive 指令,
|
|
73
|
+
* 因此这是**高风险写**,CLI 侧带 `--apply` 门。见 {@link CalendarEntryDeliveryMode}。
|
|
74
|
+
*/
|
|
75
|
+
deliveryMode?: CalendarEntryDeliveryMode;
|
|
70
76
|
permalink?: string;
|
|
71
77
|
failureReason?: string;
|
|
72
78
|
};
|
|
@@ -630,6 +636,13 @@ export type ListScheduledJobsParams = {
|
|
|
630
636
|
from?: string;
|
|
631
637
|
to?: string;
|
|
632
638
|
};
|
|
639
|
+
export type ListAccountRiskProfilesParams = {
|
|
640
|
+
/** 服务端上限 200;缺省 100。 */
|
|
641
|
+
limit?: number;
|
|
642
|
+
/** 翻页起始偏移量(offset,不是 cursor):每次 += limit。 */
|
|
643
|
+
offset?: number;
|
|
644
|
+
search?: string;
|
|
645
|
+
};
|
|
633
646
|
export type ListAccountsParams = {
|
|
634
647
|
limit?: number;
|
|
635
648
|
offset?: number;
|
|
@@ -990,7 +1003,19 @@ export declare class SocialHubClient {
|
|
|
990
1003
|
private teamBase;
|
|
991
1004
|
/** GET /health — no API key required. */
|
|
992
1005
|
getHealth(): Promise<HealthCheckJson>;
|
|
1006
|
+
/**
|
|
1007
|
+
* 绝对 URL 拼接的**唯一**入口:`path` 一律是站内相对路径(如 `/v1/teams/x/events`)。
|
|
1008
|
+
* 直接把相对路径交给 `fetch()` 在 Node 下会抛
|
|
1009
|
+
* `TypeError: Failed to parse URL from /v1/...`,所以新增请求方法必须走这里。
|
|
1010
|
+
*/
|
|
1011
|
+
private buildUrl;
|
|
1012
|
+
/** 鉴权 + 默认 Content-Type;调用方 headers 覆盖默认值(与历史行为一致)。 */
|
|
1013
|
+
private buildHeaders;
|
|
1014
|
+
/** 共享请求管线:统一 base-url 拼接、鉴权头与错误体解析,返回原始响应文本。 */
|
|
1015
|
+
private requestText;
|
|
993
1016
|
private fetchJson;
|
|
1017
|
+
/** 与 `fetchJson` 同一条 base-url/鉴权/错误处理路径,但返回文本(CSV 等非 JSON 响应)。 */
|
|
1018
|
+
private fetchText;
|
|
994
1019
|
appendEvent(teamId: string, body: {
|
|
995
1020
|
type: string;
|
|
996
1021
|
socialAccountId?: string;
|
|
@@ -1048,6 +1073,14 @@ export declare class SocialHubClient {
|
|
|
1048
1073
|
}): Promise<{
|
|
1049
1074
|
metrics?: Record<string, number | undefined>;
|
|
1050
1075
|
}>;
|
|
1076
|
+
/**
|
|
1077
|
+
* `GET .../calendar-entries` 的 URL —— {@link SocialHubClient.listCalendarEntries}
|
|
1078
|
+
* 与 {@link SocialHubClient.listCalendarEntriesTyped} 共用。
|
|
1079
|
+
*
|
|
1080
|
+
* 抽出来是为了让两个方法**不可能**漂移:将来加一个过滤参数只改一处,
|
|
1081
|
+
* 否则 typed 变体会静默少一个过滤条件,表现为「同样的参数却多返回了行」。
|
|
1082
|
+
*/
|
|
1083
|
+
private calendarEntriesUrl;
|
|
1051
1084
|
listCalendarEntries(teamId: string, params?: ListCalendarEntriesParams): Promise<{
|
|
1052
1085
|
items: unknown[];
|
|
1053
1086
|
}>;
|
|
@@ -1055,6 +1088,39 @@ export declare class SocialHubClient {
|
|
|
1055
1088
|
ok: boolean;
|
|
1056
1089
|
warning?: string;
|
|
1057
1090
|
}>;
|
|
1091
|
+
/**
|
|
1092
|
+
* 与 {@link SocialHubClient.listCalendarEntries} **同一个端点**,只是把返回体
|
|
1093
|
+
* 标成 {@link CalendarEntryListItemDto}。
|
|
1094
|
+
*
|
|
1095
|
+
* 为什么另开一个方法而不是收紧旧方法的返回类型:旧方法返回 `unknown[]`,既有调用方
|
|
1096
|
+
* 普遍在外面自己 `as` 成本地形状;把它改成具名类型会让那些断言从「无操作」变成
|
|
1097
|
+
* 「类型不兼容」,是一次纯粹为了好看的破坏性变更。新方法零风险,想要
|
|
1098
|
+
* `deliveryMode` / `directiveRevision` 的调用方直接用它。
|
|
1099
|
+
*
|
|
1100
|
+
* ⚠️ 运行时**不做校验**(SDK 不引 zod):老服务端不会回这两个字段,所以它们在
|
|
1101
|
+
* DTO 里是可选的——读到 `undefined` 一律按 `hub_managed` / 未知 revision 处理,
|
|
1102
|
+
* 不要当成 0。
|
|
1103
|
+
*/
|
|
1104
|
+
listCalendarEntriesTyped(teamId: string, params?: ListCalendarEntriesParams): Promise<{
|
|
1105
|
+
items: CalendarEntryListItemDto[];
|
|
1106
|
+
}>;
|
|
1107
|
+
/**
|
|
1108
|
+
* GET .../publishing-calendar-directives/:calendarEntryId/preflight?revision=N
|
|
1109
|
+
* —— 外部 agent 的 cron 到点后、**真正发帖前**必须调的只读校验(方案 §8 D5)。
|
|
1110
|
+
*
|
|
1111
|
+
* 这是整条链路上正文的**唯一出口**:directive 事件 payload 里只有身份 + 版本号。
|
|
1112
|
+
* 服务端在同一个只读快照里确认「条目仍 scheduled / 仍 external_agent / revision 仍是
|
|
1113
|
+
* 你手上那条 / 审核仍 passed」,四条全成立才把内容交出来。
|
|
1114
|
+
*
|
|
1115
|
+
* ⚠️ **业务拒绝是 HTTP 200 + `decision: "rejected"`,不是 4xx**——本方法不会为
|
|
1116
|
+
* `rejected` 抛错。调用方必须显式判 `decision`;`if (await preflight(...))` 这种写法
|
|
1117
|
+
* 会把每一次拒绝都当成放行。4xx/5xx 只留给请求本身或系统的错误。
|
|
1118
|
+
*
|
|
1119
|
+
* `revision` 必须是调用方手上那条 directive 的版本号,**不能省、不能猜**:服务端
|
|
1120
|
+
* 拒绝空值与非数字,而 revision 0 是每条条目的合法初始值,任何「默认值」都会放行
|
|
1121
|
+
* 真实条目。这里先在客户端挡一道,免得把明显非法的值打到网络上。
|
|
1122
|
+
*/
|
|
1123
|
+
preflightPublishingCalendarDirective(teamId: string, calendarEntryId: string, revision: number): Promise<PublishingCalendarPreflightResultDto>;
|
|
1058
1124
|
/**
|
|
1059
1125
|
* 归属桶(teams.kind='bucket':未配置/外部)。这些团队没有 membership、不出现
|
|
1060
1126
|
* 在 `listTeams()` 里,所以外部来源帖要回填进桶就只能先从这里拿到 UUID,
|
|
@@ -1367,6 +1433,10 @@ export declare class SocialHubClient {
|
|
|
1367
1433
|
}): Promise<unknown>;
|
|
1368
1434
|
listAccounts(teamId: string, params?: ListAccountsParams): Promise<{
|
|
1369
1435
|
items: unknown[];
|
|
1436
|
+
/** 满足过滤条件的总数(与 limit/offset 无关);翻页终止判据。 */
|
|
1437
|
+
total?: number;
|
|
1438
|
+
limit?: number;
|
|
1439
|
+
offset?: number;
|
|
1370
1440
|
}>;
|
|
1371
1441
|
createAccount(teamId: string, body: Record<string, unknown>): Promise<{
|
|
1372
1442
|
id: string;
|
|
@@ -1750,8 +1820,23 @@ export declare class SocialHubClient {
|
|
|
1750
1820
|
deleteSubredditSanction(teamId: string, id: string): Promise<{
|
|
1751
1821
|
ok: boolean;
|
|
1752
1822
|
}>;
|
|
1753
|
-
|
|
1823
|
+
/**
|
|
1824
|
+
* 列出团队下账号的风险画像。
|
|
1825
|
+
*
|
|
1826
|
+
* `limit` 上限 200(contracts `listAccountRiskProfilesQuerySchema`),所以账号数
|
|
1827
|
+
* 超过 200 的 team 必须用 `offset` 翻页,否则会**静默截断**。第二参数保留
|
|
1828
|
+
* `number` 形式只为兼容已发布包的老调用方(等价于 `{ limit }`)。
|
|
1829
|
+
*/
|
|
1830
|
+
listAccountRiskProfiles(teamId: string, paramsOrLimit?: number | ListAccountRiskProfilesParams): Promise<{
|
|
1754
1831
|
items: unknown[];
|
|
1832
|
+
/**
|
|
1833
|
+
* 满足过滤条件的总数(与 limit/offset 无关)。集合在翻页期间不变时可用作
|
|
1834
|
+
* 翻页终止判据;offset 分页不是快照分页,并发写入下 total 会漂移,
|
|
1835
|
+
* 同一行也可能重复出现或被跳过。
|
|
1836
|
+
*/
|
|
1837
|
+
total?: number;
|
|
1838
|
+
limit?: number;
|
|
1839
|
+
offset?: number;
|
|
1755
1840
|
}>;
|
|
1756
1841
|
getAccountRiskProfile(teamId: string, socialAccountId: string): Promise<unknown>;
|
|
1757
1842
|
upsertAccountRiskProfile(teamId: string, socialAccountId: string, body: Record<string, unknown>): Promise<unknown>;
|
|
@@ -3113,6 +3198,8 @@ export declare class SocialHubClient {
|
|
|
3113
3198
|
items: {
|
|
3114
3199
|
sourceId: string;
|
|
3115
3200
|
canonicalTopic: string;
|
|
3201
|
+
/** source **类型**展示名的 i18n key(registry 真源;不是模板的 displayName)。 */
|
|
3202
|
+
labelKey: string;
|
|
3116
3203
|
sourceDefinitionVersion: number;
|
|
3117
3204
|
payloadSchemaVersion: string;
|
|
3118
3205
|
activeTemplate: NotificationSourceTemplateDto | null;
|
|
@@ -3597,5 +3684,151 @@ export type NotificationPullResponseDto = {
|
|
|
3597
3684
|
* 与 contracts `compareNotificationSeq` 同口径;SDK 侧复刻是因为不能引 contracts。
|
|
3598
3685
|
*/
|
|
3599
3686
|
export declare function compareNotificationSeqStrings(left: string, right: string): number;
|
|
3687
|
+
/**
|
|
3688
|
+
* 这条日历条目由谁发布 —— **防重复发帖的唯一闸门**(方案 D1)。
|
|
3689
|
+
* - `hub_managed`(默认):Hub 同事务建内部 `publish_post` job,自己发;**不**产生指令事件。
|
|
3690
|
+
* - `external_agent`:**不**建内部 job,改由 `publishing-calendar-directive.v1` 事件
|
|
3691
|
+
* 驱动用户自己机器上的 agent 建 UTC 一次性 cron 去发。
|
|
3692
|
+
*
|
|
3693
|
+
* 两者互斥。老服务端不回这个字段 —— 读到 `undefined` 按 `hub_managed` 处理。
|
|
3694
|
+
*/
|
|
3695
|
+
export type CalendarEntryDeliveryMode = "hub_managed" | "external_agent";
|
|
3696
|
+
/** 指令变体:期望状态是「该有一个 cron」还是「不该有」。 */
|
|
3697
|
+
export type PublishingCalendarDirectiveKind = "upsert" | "cancel";
|
|
3698
|
+
/** cancel 的原因(枚举而非自由文本:agent 按它分流告警 vs 正常运营动作)。 */
|
|
3699
|
+
export type PublishingCalendarDirectiveCancelReason =
|
|
3700
|
+
/** 运营主动取消这条日历条目。 */
|
|
3701
|
+
"entry_cancelled"
|
|
3702
|
+
/** 条目行被删除(含 plan/account 级联)。 */
|
|
3703
|
+
| "entry_deleted"
|
|
3704
|
+
/** 审核由 passed 回退,内容不再允许发布。 */
|
|
3705
|
+
| "review_revoked"
|
|
3706
|
+
/** 条目改回 `hub_managed`,改由 Hub 内部发布。 */
|
|
3707
|
+
| "delivery_mode_changed"
|
|
3708
|
+
/** 关联草稿被解绑(`content_draft_id SET NULL`)。 */
|
|
3709
|
+
| "draft_detached";
|
|
3710
|
+
/**
|
|
3711
|
+
* preflight 的拒绝原因。**每一条都必须有本地处置动作**,不能笼统当成「失败重试」——
|
|
3712
|
+
* 其中大部分是终态(该删 cron),轮询重试只会把一条已经不该发的内容一直挂着。
|
|
3713
|
+
*/
|
|
3714
|
+
export type PublishingCalendarPreflightRejectionReason =
|
|
3715
|
+
/** 条目不存在、不属于本 team,或调用方品牌作用域看不到它。此时 `currentRevision` 恒为 null。 */
|
|
3716
|
+
"entry_not_found"
|
|
3717
|
+
/** 条目已不是 `scheduled`(取消/发布中/已发/失败)。删 cron。 */
|
|
3718
|
+
| "entry_not_scheduled"
|
|
3719
|
+
/** 条目已改回 `hub_managed`,Hub 自己发。删 cron。 */
|
|
3720
|
+
| "delivery_mode_not_external"
|
|
3721
|
+
/** 手上的 revision 比 Hub 当前的旧 —— 还有一条更新的指令在路上。 */
|
|
3722
|
+
| "revision_stale"
|
|
3723
|
+
/** 手上的 revision 比 Hub 当前的**新**。正常不该发生,一律不给内容。 */
|
|
3724
|
+
| "revision_unknown"
|
|
3725
|
+
/** 条目没绑草稿,或草稿行已不在。 */
|
|
3726
|
+
| "draft_detached"
|
|
3727
|
+
/** 当前草稿的 canonical review target 不存在、身份漂移,或状态不是 `passed`。 */
|
|
3728
|
+
| "review_not_passed"
|
|
3729
|
+
/**
|
|
3730
|
+
* 发布护栏判定当前不可发布(账号被封/受限、cluster 暂停等)。
|
|
3731
|
+
* **与其余 reason 不同:这条通常是暂时的,不要删 cron**,按原节奏重试即可。
|
|
3732
|
+
* 护栏评估本身失败不走这条(那是 5xx 系统故障)。
|
|
3733
|
+
*/
|
|
3734
|
+
| "guardrail_blocked";
|
|
3735
|
+
/** preflight 放行:**唯一**能拿到正文的分支。 */
|
|
3736
|
+
export type PublishingCalendarPreflightOkDto = {
|
|
3737
|
+
decision: "ok";
|
|
3738
|
+
calendarEntryId: string;
|
|
3739
|
+
publishingPlanId: string;
|
|
3740
|
+
/** 服务端当前 revision(ok 时必然 === 请求里那个)。 */
|
|
3741
|
+
revision: number;
|
|
3742
|
+
socialAccountId: string;
|
|
3743
|
+
subreddit: string;
|
|
3744
|
+
/** **Z 结尾的 UTC**;直接拿去建 UTC one-shot cron,不要先转本地时区。 */
|
|
3745
|
+
plannedAt: string;
|
|
3746
|
+
content: {
|
|
3747
|
+
contentDraftId: string;
|
|
3748
|
+
contentDraftVersion: number;
|
|
3749
|
+
title: string;
|
|
3750
|
+
body: string;
|
|
3751
|
+
};
|
|
3752
|
+
review: {
|
|
3753
|
+
targetId: string;
|
|
3754
|
+
/** 恒为 `passed` —— 没有第二种 ok。 */
|
|
3755
|
+
status: "passed";
|
|
3756
|
+
/** 服务端 canonical 内容 hash,可留痕对账。 */
|
|
3757
|
+
contentHash: string;
|
|
3758
|
+
};
|
|
3759
|
+
};
|
|
3760
|
+
export type PublishingCalendarPreflightRejectedDto = {
|
|
3761
|
+
decision: "rejected";
|
|
3762
|
+
calendarEntryId: string;
|
|
3763
|
+
reason: PublishingCalendarPreflightRejectionReason;
|
|
3764
|
+
/**
|
|
3765
|
+
* Hub 当前的 revision,**仅供诊断对账**。
|
|
3766
|
+
*
|
|
3767
|
+
* 🔴 绝不能拿它推进本地的「已见最高 revision」:收到 rev 5 的 cron 被判
|
|
3768
|
+
* `revision_stale/currentRevision=6` 后若把本地状态升到 6,随后真正到达的 rev 6
|
|
3769
|
+
* `upsert` 会被当成旧消息忽略 —— 结果是**一个 cron 都没有**。只等真实的指令。
|
|
3770
|
+
*
|
|
3771
|
+
* `entry_not_found` 时恒为 null(那个 reason 同时覆盖「真不存在」与「作用域看不到」)。
|
|
3772
|
+
*/
|
|
3773
|
+
currentRevision: number | null;
|
|
3774
|
+
};
|
|
3775
|
+
/**
|
|
3776
|
+
* preflight 判定结果。**业务拒绝走 200 + 本判别联合,不用 404/409**:
|
|
3777
|
+
* cron 路径要能无歧义分流每个 reason。判 `decision` 之前不要碰任何字段。
|
|
3778
|
+
*/
|
|
3779
|
+
export type PublishingCalendarPreflightResultDto = PublishingCalendarPreflightOkDto | PublishingCalendarPreflightRejectedDto;
|
|
3780
|
+
/**
|
|
3781
|
+
* `GET .../calendar-entries` 的行形状(含 joined labels)。
|
|
3782
|
+
*
|
|
3783
|
+
* 只被 {@link SocialHubClient.listCalendarEntriesTyped} 使用;旧的
|
|
3784
|
+
* `listCalendarEntries` 仍返回 `unknown[]`,故意不动。
|
|
3785
|
+
*/
|
|
3786
|
+
export type CalendarEntryListItemDto = {
|
|
3787
|
+
id: string;
|
|
3788
|
+
teamId: string;
|
|
3789
|
+
publishingPlanId: string;
|
|
3790
|
+
brandId: string;
|
|
3791
|
+
/** legacy;brand-first 建的计划为 null。 */
|
|
3792
|
+
campaignId: string | null;
|
|
3793
|
+
contentDraftId: string | null;
|
|
3794
|
+
socialAccountId: string;
|
|
3795
|
+
subreddit: string;
|
|
3796
|
+
plannedAt: string;
|
|
3797
|
+
status: CalendarEntryStatus;
|
|
3798
|
+
/** 见 {@link CalendarEntryDeliveryMode};老数据/老服务端缺省视为 `hub_managed`。 */
|
|
3799
|
+
deliveryMode?: CalendarEntryDeliveryMode;
|
|
3800
|
+
/**
|
|
3801
|
+
* 单调递增的指令版本,**高版本覆盖低版本**。只对 `external_agent` 有业务意义,
|
|
3802
|
+
* 但 `hub_managed` 也照常递增(改回外部时不会倒退)。缺省 = 老服务端,不是 0。
|
|
3803
|
+
*/
|
|
3804
|
+
directiveRevision?: number;
|
|
3805
|
+
publishedAt: string | null;
|
|
3806
|
+
permalink: string | null;
|
|
3807
|
+
failureReason: string | null;
|
|
3808
|
+
createdAt: string;
|
|
3809
|
+
/** 迁移 0149 起维护;更早的真实修改时间已不可考。 */
|
|
3810
|
+
updatedAt?: string;
|
|
3811
|
+
brandName: string;
|
|
3812
|
+
campaignName: string | null;
|
|
3813
|
+
socialAccountHandle: string | null;
|
|
3814
|
+
socialAccountPlatform: string;
|
|
3815
|
+
draftTitle: string | null;
|
|
3816
|
+
draftExcerpt: string | null;
|
|
3817
|
+
reviewGate?: {
|
|
3818
|
+
targetId: string | null;
|
|
3819
|
+
status: ReviewTargetStatus | null;
|
|
3820
|
+
contentVersion: number | null;
|
|
3821
|
+
/** target 是否对应当前草稿版本(canonical 全校验)。 */
|
|
3822
|
+
isCurrent: boolean;
|
|
3823
|
+
gateState: ReviewGateState;
|
|
3824
|
+
lastError: string | null;
|
|
3825
|
+
} | null;
|
|
3826
|
+
};
|
|
3827
|
+
/** 契约 `calendarEntryStatusSchema` 的镜像。 */
|
|
3828
|
+
export type CalendarEntryStatus = "draft" | "scheduled" | "exported" | "running" | "succeeded" | "failed" | "cancelled";
|
|
3829
|
+
/** 契约 `reviewTargetStatusSchema` 的镜像(审核 target 的原生状态)。 */
|
|
3830
|
+
export type ReviewTargetStatus = "pending" | "running" | "passed" | "needs_revision" | "blocked" | "degraded" | "superseded";
|
|
3831
|
+
/** 契约 `reviewGateStateSchema` 的镜像(日历条目上的审核门投影)。 */
|
|
3832
|
+
export type ReviewGateState = "passed" | "waiting" | "revision_required" | "blocked" | "stale" | "untracked";
|
|
3600
3833
|
export {};
|
|
3601
3834
|
//# sourceMappingURL=index.d.ts.map
|