@reachv2/sdk 0.3.3 → 0.5.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.
@@ -0,0 +1,142 @@
1
+ import { RequestMethod } from "../types.js";
2
+ type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
3
+ /** 席位档位套餐(`/api/billing/plans` 返回的 shared.Plan 行) */
4
+ export interface BillingPlan {
5
+ id: string;
6
+ name: string;
7
+ displayName?: string;
8
+ description?: string | null;
9
+ kind?: string;
10
+ seatCount?: number;
11
+ price?: number;
12
+ introPrice?: number | null;
13
+ introPeriods?: number;
14
+ interval?: string;
15
+ rail?: string;
16
+ llmTokensPerMonth?: number;
17
+ features?: unknown[];
18
+ active?: boolean;
19
+ [key: string]: unknown;
20
+ }
21
+ export interface BillingPlansResult {
22
+ plans: BillingPlan[];
23
+ }
24
+ /** 可购买 Token 包(`/api/billing/token-packs` 精简字段) */
25
+ export interface BillingTokenPack {
26
+ id: string;
27
+ name: string;
28
+ tokens: number;
29
+ price: number;
30
+ cryptoAmount?: number;
31
+ sortOrder?: number;
32
+ active?: boolean;
33
+ [key: string]: unknown;
34
+ }
35
+ export interface BillingTokenPacksResult {
36
+ tokenPacks: BillingTokenPack[];
37
+ }
38
+ /** `/api/billing/prices` 的展示价格项 */
39
+ export interface BillingPrice {
40
+ id: string;
41
+ name: string;
42
+ /** 展示用字符串,如 `$29` / `Free` */
43
+ price: string;
44
+ /** 最小货币单位(分) */
45
+ amount: number;
46
+ interval: string;
47
+ kind?: string;
48
+ seatCount?: number;
49
+ introPrice?: number | null;
50
+ introPeriods?: number;
51
+ features: unknown[];
52
+ }
53
+ export interface BillingPricesResult {
54
+ prices: Record<string, BillingPrice>;
55
+ }
56
+ /** Token 包购买结果(Stripe Checkout / 人工待开通 pending 单) */
57
+ export interface TokenPackCheckoutResult {
58
+ id?: string;
59
+ tenantId?: string;
60
+ packId?: string | null;
61
+ packName?: string;
62
+ tokens?: number;
63
+ amountUsd?: number;
64
+ paymentMethod?: string;
65
+ status?: string;
66
+ /** 支付通道未配置时为 true(单已落 pending,待运营开通) */
67
+ manual?: boolean;
68
+ paymentId?: string;
69
+ sessionUrl?: string;
70
+ rail?: string;
71
+ pack?: Pick<BillingTokenPack, "id" | "name" | "tokens" | "price">;
72
+ [key: string]: unknown;
73
+ }
74
+ /** 浏览器实例配额概览 */
75
+ export interface BrowserQuotaStatus {
76
+ /** 套餐基础实例数 */
77
+ base: number;
78
+ /** 加购实例数(有效期内 BrowserPack) */
79
+ pack: number;
80
+ total: number;
81
+ used: number;
82
+ remaining: number;
83
+ /** 最近一份加购包的到期时间(无加购为 null) */
84
+ packExpiresAt: string | null;
85
+ [key: string]: unknown;
86
+ }
87
+ /** 浏览器实例包购买流水(存量只读) */
88
+ export interface BrowserPackPurchase {
89
+ id: string;
90
+ tenantId?: string;
91
+ packId?: string | null;
92
+ packName?: string;
93
+ instanceCount?: number;
94
+ amountUsd?: number;
95
+ status?: string;
96
+ periodStart?: string | null;
97
+ periodEnd?: string | null;
98
+ createdAt?: string;
99
+ [key: string]: unknown;
100
+ }
101
+ export interface BrowserPackPurchasesResult {
102
+ purchases: BrowserPackPurchase[];
103
+ }
104
+ /**
105
+ * BillingResource — 社媒域计费(Server API `/api/billing/*`)。
106
+ *
107
+ * - 公开:`plans` / `token-packs` / `prices`(无需登录)
108
+ * - JWT:`token-packs/purchase`(`authenticate`)、`portal`
109
+ * - API Key 或 JWT(只读):`browser-packs/quota`、`browser-packs/purchases`(`authAny`)
110
+ *
111
+ * 注意:`POST /api/billing/checkout` 已退役(恒返回 410 PLATFORM_PLAN_RETIRED),未封装;
112
+ * 平台套餐新购走 `/api/seats`(不在 SDK 覆盖范围)。
113
+ */
114
+ export declare class BillingResource {
115
+ private request;
116
+ constructor(request: RequestFn);
117
+ /** 席位档位套餐列表(`{ plans }`,active + orderBy sortOrder) */
118
+ listPlans(): Promise<BillingPlansResult>;
119
+ /** 可购买 Token 包列表(`{ tokenPacks }`) */
120
+ listTokenPacks(): Promise<BillingTokenPacksResult>;
121
+ /** 套餐展示价格(`{ prices }`,按套餐名索引) */
122
+ getPrices(): Promise<BillingPricesResult>;
123
+ /**
124
+ * 购买 Token 包(Stripe 一次性 Checkout)。
125
+ * 支付通道未配置时返回 `manual: true` 的 pending 单,待运营手动开通。
126
+ */
127
+ purchaseTokenPack(packId: string): Promise<TokenPackCheckoutResult>;
128
+ /**
129
+ * Stripe Customer Portal 会话。
130
+ * 当前 Stripe SDK 未纳入服务端依赖 → 恒 503 `STRIPE_SDK_NOT_AVAILABLE`;
131
+ * 无有效平台订阅时 404 `No active subscription found`。
132
+ */
133
+ getPortal(): Promise<{
134
+ url?: string;
135
+ [key: string]: unknown;
136
+ }>;
137
+ /** 我的浏览器实例配额概览(基础 / 加购 / 总计 / 已用 / 剩余) */
138
+ getBrowserQuota(): Promise<BrowserQuotaStatus>;
139
+ /** 我的浏览器实例包购买流水(最近 50 条,存量只读) */
140
+ listBrowserPurchases(): Promise<BrowserPackPurchasesResult>;
141
+ }
142
+ export {};
@@ -0,0 +1,52 @@
1
+ /**
2
+ * BillingResource — 社媒域计费(Server API `/api/billing/*`)。
3
+ *
4
+ * - 公开:`plans` / `token-packs` / `prices`(无需登录)
5
+ * - JWT:`token-packs/purchase`(`authenticate`)、`portal`
6
+ * - API Key 或 JWT(只读):`browser-packs/quota`、`browser-packs/purchases`(`authAny`)
7
+ *
8
+ * 注意:`POST /api/billing/checkout` 已退役(恒返回 410 PLATFORM_PLAN_RETIRED),未封装;
9
+ * 平台套餐新购走 `/api/seats`(不在 SDK 覆盖范围)。
10
+ */
11
+ export class BillingResource {
12
+ constructor(request) {
13
+ this.request = request;
14
+ }
15
+ /** 席位档位套餐列表(`{ plans }`,active + orderBy sortOrder) */
16
+ listPlans() {
17
+ return this.request("GET", "/api/billing/plans");
18
+ }
19
+ /** 可购买 Token 包列表(`{ tokenPacks }`) */
20
+ listTokenPacks() {
21
+ return this.request("GET", "/api/billing/token-packs");
22
+ }
23
+ /** 套餐展示价格(`{ prices }`,按套餐名索引) */
24
+ getPrices() {
25
+ return this.request("GET", "/api/billing/prices");
26
+ }
27
+ /**
28
+ * 购买 Token 包(Stripe 一次性 Checkout)。
29
+ * 支付通道未配置时返回 `manual: true` 的 pending 单,待运营手动开通。
30
+ */
31
+ purchaseTokenPack(packId) {
32
+ return this.request("POST", "/api/billing/token-packs/purchase", {
33
+ packId,
34
+ });
35
+ }
36
+ /**
37
+ * Stripe Customer Portal 会话。
38
+ * 当前 Stripe SDK 未纳入服务端依赖 → 恒 503 `STRIPE_SDK_NOT_AVAILABLE`;
39
+ * 无有效平台订阅时 404 `No active subscription found`。
40
+ */
41
+ getPortal() {
42
+ return this.request("GET", "/api/billing/portal");
43
+ }
44
+ /** 我的浏览器实例配额概览(基础 / 加购 / 总计 / 已用 / 剩余) */
45
+ getBrowserQuota() {
46
+ return this.request("GET", "/api/billing/browser-packs/quota");
47
+ }
48
+ /** 我的浏览器实例包购买流水(最近 50 条,存量只读) */
49
+ listBrowserPurchases() {
50
+ return this.request("GET", "/api/billing/browser-packs/purchases");
51
+ }
52
+ }
@@ -0,0 +1,94 @@
1
+ import { RequestMethod, ChannelActionResult, SendTextParams, TelegramSendFileParams, DiscordDmParams, DiscordDmOptInParams, MerchantGroupList } from "../types.js";
2
+ type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
3
+ type GroupMemberOp = {
4
+ userId: string;
5
+ } & Record<string, unknown>;
6
+ type PinOp = {
7
+ messageId: string | number;
8
+ } & Record<string, unknown>;
9
+ type BroadcastParams = {
10
+ chatIds?: string[];
11
+ text?: string;
12
+ imageUrl?: string;
13
+ [key: string]: unknown;
14
+ };
15
+ /**
16
+ * ChannelAdminResource — 商户侧通道管理(客服工作台 / 群运营)。
17
+ *
18
+ * 端点:Server API `/api/merchant/projects/:id/bots/:botId/channels/*` 与 `.../groups/*`,
19
+ * 全部要求 `role=merchant` 的 JWT(见 v0.4.0 商户入驻说明)。
20
+ *
21
+ * 不含 Telegram `upload-send`(multipart/form-data 文件直传),该端点请直接用 fetch。
22
+ */
23
+ export declare class ChannelAdminResource {
24
+ private request;
25
+ constructor(request: RequestFn);
26
+ private botBase;
27
+ /** 该 Bot 的通道配置(telegram / whatsapp / web;botToken 已脱敏) */
28
+ listChannels(projectId: string, botId: string): Promise<Record<string, unknown>>;
29
+ /** 配置 Telegram Bot Token(立即启动 Bot 并回写状态) */
30
+ connectTelegram(projectId: string, botId: string, botToken: string): Promise<ChannelActionResult>;
31
+ /** 断开 Telegram(删除配置) */
32
+ disconnectTelegram(projectId: string, botId: string): Promise<ChannelActionResult>;
33
+ /** Telegram 已入群列表 */
34
+ listTelegramGroups(projectId: string, botId: string): Promise<MerchantGroupList>;
35
+ /** 重新扫描 Telegram 群组 */
36
+ rescanTelegramGroups(projectId: string, botId: string): Promise<ChannelActionResult>;
37
+ /** Telegram 发送文本(群/私聊 chatId) */
38
+ sendTelegramText(projectId: string, botId: string, params: SendTextParams): Promise<ChannelActionResult>;
39
+ /** Telegram 发送该 Bot 已上传的文档 */
40
+ sendTelegramFile(projectId: string, botId: string, params: TelegramSendFileParams): Promise<ChannelActionResult>;
41
+ /** 发起 WhatsApp 配对(返回 status / qr;进度轮询 whatsappStatus) */
42
+ pairWhatsApp(projectId: string, botId: string): Promise<ChannelActionResult>;
43
+ /** WhatsApp 配对状态(QR / 手机号 / 连接状态) */
44
+ whatsappStatus(projectId: string, botId: string): Promise<ChannelActionResult>;
45
+ /** 断开 WhatsApp(已配对凭证保留,重新配对可恢复) */
46
+ disconnectWhatsApp(projectId: string, botId: string): Promise<ChannelActionResult>;
47
+ /** WhatsApp 群列表 */
48
+ listWhatsAppGroups(projectId: string, botId: string): Promise<MerchantGroupList>;
49
+ /** WhatsApp 发送文本(群/私聊 jid) */
50
+ sendWhatsAppText(projectId: string, botId: string, params: SendTextParams): Promise<ChannelActionResult>;
51
+ /** 配置 Discord Bot Token */
52
+ connectDiscord(projectId: string, botId: string, botToken: string): Promise<ChannelActionResult>;
53
+ /** 断开 Discord */
54
+ disconnectDiscord(projectId: string, botId: string): Promise<ChannelActionResult>;
55
+ /** Discord 频道(群)列表 */
56
+ listDiscordGroups(projectId: string, botId: string): Promise<MerchantGroupList>;
57
+ /** Discord 发送文本(频道 chatId) */
58
+ sendDiscordText(projectId: string, botId: string, params: SendTextParams): Promise<ChannelActionResult>;
59
+ /** 读取 Discord DM opt-in 状态 */
60
+ getDiscordDmOptIn(projectId: string, botId: string, userId: string): Promise<ChannelActionResult>;
61
+ /** 写入 / 撤回 Discord DM opt-in */
62
+ setDiscordDmOptIn(projectId: string, botId: string, params: DiscordDmOptInParams): Promise<ChannelActionResult>;
63
+ /** Discord DM 资格(opt-in / 历史入站 / 同 guild) */
64
+ getDiscordDmEligibility(projectId: string, botId: string, userId: string): Promise<ChannelActionResult>;
65
+ /** 发送 Discord 1v1 私信(默认强制 opt-in 校验) */
66
+ sendDiscordDm(projectId: string, botId: string, params: DiscordDmParams): Promise<ChannelActionResult>;
67
+ /** 群列表(可按 platform 过滤) */
68
+ listGroups(projectId: string, botId: string, platform?: string): Promise<MerchantGroupList>;
69
+ /** 群成员 */
70
+ groupMembers(projectId: string, botId: string, groupId: string): Promise<Record<string, unknown>>;
71
+ /** 更新群配置 */
72
+ updateGroupConfig(projectId: string, botId: string, groupId: string, patch: Record<string, unknown>): Promise<Record<string, unknown>>;
73
+ /** 群成员操作(ban / unban / kick / mute / unmute) */
74
+ groupMemberOp(projectId: string, botId: string, groupId: string, op: "ban" | "unban" | "kick" | "mute" | "unmute", params: GroupMemberOp): Promise<Record<string, unknown>>;
75
+ /** 置顶 / 取消置顶消息 */
76
+ pinMessage(projectId: string, botId: string, groupId: string, params: PinOp, pinned?: boolean): Promise<Record<string, unknown>>;
77
+ /** Bot 级群发(同一 Bot 的多个 chatId) */
78
+ broadcast(projectId: string, botId: string, params: BroadcastParams): Promise<Record<string, unknown>>;
79
+ /** 项目内全部群(跨 Bot 视图) */
80
+ listProjectGroups(projectId: string): Promise<Record<string, unknown>>;
81
+ /** 项目级群发(创建异步任务) */
82
+ broadcastProject(projectId: string, params: BroadcastParams): Promise<Record<string, unknown>>;
83
+ /** 群发任务列表 */
84
+ listBroadcastJobs(projectId: string): Promise<Record<string, unknown>>;
85
+ /** 群发任务详情 */
86
+ getBroadcastJob(projectId: string, jobId: string): Promise<Record<string, unknown>>;
87
+ /** 群发任务目标与逐群结果 */
88
+ getBroadcastJobTargets(projectId: string, jobId: string): Promise<Record<string, unknown>>;
89
+ /** 取消群发任务 */
90
+ cancelBroadcastJob(projectId: string, jobId: string): Promise<Record<string, unknown>>;
91
+ /** 重试群发任务(仅失败目标) */
92
+ retryBroadcastJob(projectId: string, jobId: string): Promise<Record<string, unknown>>;
93
+ }
94
+ export {};
@@ -0,0 +1,155 @@
1
+ /**
2
+ * ChannelAdminResource — 商户侧通道管理(客服工作台 / 群运营)。
3
+ *
4
+ * 端点:Server API `/api/merchant/projects/:id/bots/:botId/channels/*` 与 `.../groups/*`,
5
+ * 全部要求 `role=merchant` 的 JWT(见 v0.4.0 商户入驻说明)。
6
+ *
7
+ * 不含 Telegram `upload-send`(multipart/form-data 文件直传),该端点请直接用 fetch。
8
+ */
9
+ export class ChannelAdminResource {
10
+ constructor(request) {
11
+ this.request = request;
12
+ }
13
+ botBase(projectId, botId) {
14
+ return `/api/merchant/projects/${encodeURIComponent(projectId)}/bots/${encodeURIComponent(botId)}`;
15
+ }
16
+ // ═══ 通道总览 ═══
17
+ /** 该 Bot 的通道配置(telegram / whatsapp / web;botToken 已脱敏) */
18
+ listChannels(projectId, botId) {
19
+ return this.request("GET", `${this.botBase(projectId, botId)}/channels`);
20
+ }
21
+ // ═══ Telegram ═══
22
+ /** 配置 Telegram Bot Token(立即启动 Bot 并回写状态) */
23
+ connectTelegram(projectId, botId, botToken) {
24
+ return this.request("POST", `${this.botBase(projectId, botId)}/channels/telegram`, { botToken });
25
+ }
26
+ /** 断开 Telegram(删除配置) */
27
+ disconnectTelegram(projectId, botId) {
28
+ return this.request("DELETE", `${this.botBase(projectId, botId)}/channels/telegram`);
29
+ }
30
+ /** Telegram 已入群列表 */
31
+ listTelegramGroups(projectId, botId) {
32
+ return this.request("GET", `${this.botBase(projectId, botId)}/channels/telegram/groups`);
33
+ }
34
+ /** 重新扫描 Telegram 群组 */
35
+ rescanTelegramGroups(projectId, botId) {
36
+ return this.request("POST", `${this.botBase(projectId, botId)}/channels/telegram/rescan`);
37
+ }
38
+ /** Telegram 发送文本(群/私聊 chatId) */
39
+ sendTelegramText(projectId, botId, params) {
40
+ return this.request("POST", `${this.botBase(projectId, botId)}/channels/telegram/send-text`, params);
41
+ }
42
+ /** Telegram 发送该 Bot 已上传的文档 */
43
+ sendTelegramFile(projectId, botId, params) {
44
+ return this.request("POST", `${this.botBase(projectId, botId)}/channels/telegram/send-file`, params);
45
+ }
46
+ // ═══ WhatsApp(Baileys 扫码配对) ═══
47
+ /** 发起 WhatsApp 配对(返回 status / qr;进度轮询 whatsappStatus) */
48
+ pairWhatsApp(projectId, botId) {
49
+ return this.request("POST", `${this.botBase(projectId, botId)}/channels/whatsapp`);
50
+ }
51
+ /** WhatsApp 配对状态(QR / 手机号 / 连接状态) */
52
+ whatsappStatus(projectId, botId) {
53
+ return this.request("GET", `${this.botBase(projectId, botId)}/channels/whatsapp/status`);
54
+ }
55
+ /** 断开 WhatsApp(已配对凭证保留,重新配对可恢复) */
56
+ disconnectWhatsApp(projectId, botId) {
57
+ return this.request("POST", `${this.botBase(projectId, botId)}/channels/whatsapp/disconnect`);
58
+ }
59
+ /** WhatsApp 群列表 */
60
+ listWhatsAppGroups(projectId, botId) {
61
+ return this.request("GET", `${this.botBase(projectId, botId)}/channels/whatsapp/groups`);
62
+ }
63
+ /** WhatsApp 发送文本(群/私聊 jid) */
64
+ sendWhatsAppText(projectId, botId, params) {
65
+ return this.request("POST", `${this.botBase(projectId, botId)}/channels/whatsapp/send-text`, params);
66
+ }
67
+ // ═══ Discord ═══
68
+ /** 配置 Discord Bot Token */
69
+ connectDiscord(projectId, botId, botToken) {
70
+ return this.request("POST", `${this.botBase(projectId, botId)}/channels/discord`, { botToken });
71
+ }
72
+ /** 断开 Discord */
73
+ disconnectDiscord(projectId, botId) {
74
+ return this.request("POST", `${this.botBase(projectId, botId)}/channels/discord/disconnect`);
75
+ }
76
+ /** Discord 频道(群)列表 */
77
+ listDiscordGroups(projectId, botId) {
78
+ return this.request("GET", `${this.botBase(projectId, botId)}/channels/discord/groups`);
79
+ }
80
+ /** Discord 发送文本(频道 chatId) */
81
+ sendDiscordText(projectId, botId, params) {
82
+ return this.request("POST", `${this.botBase(projectId, botId)}/channels/discord/send-text`, params);
83
+ }
84
+ /** 读取 Discord DM opt-in 状态 */
85
+ getDiscordDmOptIn(projectId, botId, userId) {
86
+ return this.request("GET", `${this.botBase(projectId, botId)}/channels/discord/dm/opt-in?userId=${encodeURIComponent(userId)}`);
87
+ }
88
+ /** 写入 / 撤回 Discord DM opt-in */
89
+ setDiscordDmOptIn(projectId, botId, params) {
90
+ return this.request("PUT", `${this.botBase(projectId, botId)}/channels/discord/dm/opt-in`, params);
91
+ }
92
+ /** Discord DM 资格(opt-in / 历史入站 / 同 guild) */
93
+ getDiscordDmEligibility(projectId, botId, userId) {
94
+ return this.request("GET", `${this.botBase(projectId, botId)}/channels/discord/dm/eligibility?userId=${encodeURIComponent(userId)}`);
95
+ }
96
+ /** 发送 Discord 1v1 私信(默认强制 opt-in 校验) */
97
+ sendDiscordDm(projectId, botId, params) {
98
+ return this.request("POST", `${this.botBase(projectId, botId)}/channels/discord/dm`, params);
99
+ }
100
+ // ═══ 群组管理(Bot 级) ═══
101
+ /** 群列表(可按 platform 过滤) */
102
+ listGroups(projectId, botId, platform) {
103
+ const qs = platform ? `?platform=${encodeURIComponent(platform)}` : "";
104
+ return this.request("GET", `${this.botBase(projectId, botId)}/groups${qs}`);
105
+ }
106
+ /** 群成员 */
107
+ groupMembers(projectId, botId, groupId) {
108
+ return this.request("GET", `${this.botBase(projectId, botId)}/groups/${encodeURIComponent(groupId)}/members`);
109
+ }
110
+ /** 更新群配置 */
111
+ updateGroupConfig(projectId, botId, groupId, patch) {
112
+ return this.request("PATCH", `${this.botBase(projectId, botId)}/groups/${encodeURIComponent(groupId)}/config`, patch);
113
+ }
114
+ /** 群成员操作(ban / unban / kick / mute / unmute) */
115
+ groupMemberOp(projectId, botId, groupId, op, params) {
116
+ return this.request("POST", `${this.botBase(projectId, botId)}/groups/${encodeURIComponent(groupId)}/member/${op}`, params);
117
+ }
118
+ /** 置顶 / 取消置顶消息 */
119
+ pinMessage(projectId, botId, groupId, params, pinned = true) {
120
+ return this.request("POST", `${this.botBase(projectId, botId)}/groups/${encodeURIComponent(groupId)}/${pinned ? "pin" : "unpin"}`, params);
121
+ }
122
+ /** Bot 级群发(同一 Bot 的多个 chatId) */
123
+ broadcast(projectId, botId, params) {
124
+ return this.request("POST", `${this.botBase(projectId, botId)}/groups/broadcast`, params);
125
+ }
126
+ // ═══ 项目级群发(跨 Bot) ═══
127
+ /** 项目内全部群(跨 Bot 视图) */
128
+ listProjectGroups(projectId) {
129
+ return this.request("GET", `/api/merchant/projects/${encodeURIComponent(projectId)}/groups`);
130
+ }
131
+ /** 项目级群发(创建异步任务) */
132
+ broadcastProject(projectId, params) {
133
+ return this.request("POST", `/api/merchant/projects/${encodeURIComponent(projectId)}/groups/broadcast`, params);
134
+ }
135
+ /** 群发任务列表 */
136
+ listBroadcastJobs(projectId) {
137
+ return this.request("GET", `/api/merchant/projects/${encodeURIComponent(projectId)}/groups/broadcast-jobs`);
138
+ }
139
+ /** 群发任务详情 */
140
+ getBroadcastJob(projectId, jobId) {
141
+ return this.request("GET", `/api/merchant/projects/${encodeURIComponent(projectId)}/groups/broadcast-jobs/${encodeURIComponent(jobId)}`);
142
+ }
143
+ /** 群发任务目标与逐群结果 */
144
+ getBroadcastJobTargets(projectId, jobId) {
145
+ return this.request("GET", `/api/merchant/projects/${encodeURIComponent(projectId)}/groups/broadcast-jobs/${encodeURIComponent(jobId)}/targets`);
146
+ }
147
+ /** 取消群发任务 */
148
+ cancelBroadcastJob(projectId, jobId) {
149
+ return this.request("POST", `/api/merchant/projects/${encodeURIComponent(projectId)}/groups/broadcast-jobs/${encodeURIComponent(jobId)}/cancel`);
150
+ }
151
+ /** 重试群发任务(仅失败目标) */
152
+ retryBroadcastJob(projectId, jobId) {
153
+ return this.request("POST", `/api/merchant/projects/${encodeURIComponent(projectId)}/groups/broadcast-jobs/${encodeURIComponent(jobId)}/retry`);
154
+ }
155
+ }
@@ -2,37 +2,19 @@ import { RequestMethod } from "../types.js";
2
2
  import { QueryParams } from "./query.js";
3
3
  type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
4
4
  /**
5
- * DataSources 资源 — 数据源适配器(指标明细/趋势/告警/定时同步)。
5
+ * DataSources 资源 — 数据源指标读取。
6
6
  * 端点走 Server API(/api/data-sources/*),与社媒域 MCP data_sources_* 工具同源。
7
- * 全部 authenticate(需 JWT 登录态);内置 effect_monitor 源拒绝改/删/同步(400)。
8
- * 创建入口不提供:P3.7.1 后无可创建的外部适配器(ADAPTERS 为空)。
7
+ * 全部 authenticate(需 JWT 登录态)。
8
+ *
9
+ * 说明(v0.4.0):用户侧 CRUD / 适配器 / 同步 / 告警 / 定时调度已于 2026-09-19 下线,
10
+ * 服务端仅保留 `metrics` / `trend`;其余方法调用必 404,已移除。
9
11
  */
10
12
  export declare class DataSourcesResource {
11
13
  private request;
12
14
  constructor(request: RequestFn);
13
- /** 数据源列表(含内置效果监测源) */
14
- list(): Promise<any>;
15
- /** 适配器类型注册表(type + meta.fields 驱动动态表单) */
16
- adapters(): Promise<any>;
17
- /** 数据源详情 */
18
- get(id: string): Promise<any>;
19
- /** 更新数据源(name/config/status) */
20
- update(id: string, patch: unknown): Promise<any>;
21
- /** 状态机 active/paused/archived */
22
- activate(id: string, status: "active" | "paused" | "archived"): Promise<any>;
23
- /** 删除数据源(连同指标与定时规则) */
24
- delete(id: string): Promise<any>;
25
- /** 手动拉取指标 */
26
- sync(id: string): Promise<any>;
27
15
  /** 指标明细(可按 metric/entity/from/to/limit 过滤) */
28
16
  metrics(id: string, params?: QueryParams): Promise<any>;
29
17
  /** 按天趋势聚合(metric/days) */
30
18
  trend(id: string, params?: QueryParams): Promise<any>;
31
- /** 告警记录(days) */
32
- alerts(id: string, params?: QueryParams): Promise<any>;
33
- /** 设置定时同步 {cron, timezone?} */
34
- setSchedule(id: string, data: unknown): Promise<any>;
35
- /** 移除定时同步 */
36
- removeSchedule(id: string): Promise<any>;
37
19
  }
38
20
  export {};
@@ -1,42 +1,16 @@
1
1
  import { buildQuery } from "./query.js";
2
2
  /**
3
- * DataSources 资源 — 数据源适配器(指标明细/趋势/告警/定时同步)。
3
+ * DataSources 资源 — 数据源指标读取。
4
4
  * 端点走 Server API(/api/data-sources/*),与社媒域 MCP data_sources_* 工具同源。
5
- * 全部 authenticate(需 JWT 登录态);内置 effect_monitor 源拒绝改/删/同步(400)。
6
- * 创建入口不提供:P3.7.1 后无可创建的外部适配器(ADAPTERS 为空)。
5
+ * 全部 authenticate(需 JWT 登录态)。
6
+ *
7
+ * 说明(v0.4.0):用户侧 CRUD / 适配器 / 同步 / 告警 / 定时调度已于 2026-09-19 下线,
8
+ * 服务端仅保留 `metrics` / `trend`;其余方法调用必 404,已移除。
7
9
  */
8
10
  export class DataSourcesResource {
9
11
  constructor(request) {
10
12
  this.request = request;
11
13
  }
12
- /** 数据源列表(含内置效果监测源) */
13
- list() {
14
- return this.request("GET", "/api/data-sources");
15
- }
16
- /** 适配器类型注册表(type + meta.fields 驱动动态表单) */
17
- adapters() {
18
- return this.request("GET", "/api/data-sources/adapters");
19
- }
20
- /** 数据源详情 */
21
- get(id) {
22
- return this.request("GET", `/api/data-sources/${encodeURIComponent(id)}`);
23
- }
24
- /** 更新数据源(name/config/status) */
25
- update(id, patch) {
26
- return this.request("PUT", `/api/data-sources/${encodeURIComponent(id)}`, patch);
27
- }
28
- /** 状态机 active/paused/archived */
29
- activate(id, status) {
30
- return this.request("POST", `/api/data-sources/${encodeURIComponent(id)}/activate`, { status });
31
- }
32
- /** 删除数据源(连同指标与定时规则) */
33
- delete(id) {
34
- return this.request("DELETE", `/api/data-sources/${encodeURIComponent(id)}`);
35
- }
36
- /** 手动拉取指标 */
37
- sync(id) {
38
- return this.request("POST", `/api/data-sources/${encodeURIComponent(id)}/sync`);
39
- }
40
14
  /** 指标明细(可按 metric/entity/from/to/limit 过滤) */
41
15
  metrics(id, params = {}) {
42
16
  return this.request("GET", `/api/data-sources/${encodeURIComponent(id)}/metrics${buildQuery(params)}`);
@@ -45,16 +19,4 @@ export class DataSourcesResource {
45
19
  trend(id, params = {}) {
46
20
  return this.request("GET", `/api/data-sources/${encodeURIComponent(id)}/trend${buildQuery(params)}`);
47
21
  }
48
- /** 告警记录(days) */
49
- alerts(id, params = {}) {
50
- return this.request("GET", `/api/data-sources/${encodeURIComponent(id)}/alerts${buildQuery(params)}`);
51
- }
52
- /** 设置定时同步 {cron, timezone?} */
53
- setSchedule(id, data) {
54
- return this.request("POST", `/api/data-sources/${encodeURIComponent(id)}/schedule`, data);
55
- }
56
- /** 移除定时同步 */
57
- removeSchedule(id) {
58
- return this.request("POST", `/api/data-sources/${encodeURIComponent(id)}/schedule`, { remove: true });
59
- }
60
22
  }
@@ -2,9 +2,11 @@ import { RequestMethod } from "../types.js";
2
2
  import { QueryParams } from "./query.js";
3
3
  type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
4
4
  /**
5
- * Effect 资源 — 效果追踪(P6.6):指标字典 / 日快照 / 目标 / 汇总 ROI / 周报告警 / GEO 探针问题集。
5
+ * Effect 资源 — 效果追踪(P6.6):指标字典 / 日快照 / 汇总 ROI / 周报告警 / GEO 探针问题集。
6
6
  * 端点走 Server API(/api/effect/*),与社媒域 MCP effect_* 工具同源。
7
7
  * 读接口 authAny(API Key 可读),写接口 authenticate(需 JWT 登录态)。
8
+ *
9
+ * 说明(v0.4.0):`/api/effect/targets*` 在服务端未挂载(调用必 404),目标 CRUD 已移除。
8
10
  */
9
11
  export declare class EffectResource {
10
12
  private request;
@@ -21,15 +23,7 @@ export declare class EffectResource {
21
23
  writeMetrics(metrics: unknown[]): Promise<any>;
22
24
  /** 单指标按天趋势 */
23
25
  series(params?: QueryParams): Promise<any>;
24
- /** 目标列表(可按 module/status 过滤) */
25
- listTargets(params?: QueryParams): Promise<any>;
26
- /** 创建目标(module/scope/metric/period/targetValue/periodStart/periodEnd) */
27
- createTarget(data: unknown): Promise<any>;
28
- /** 更新目标(部分字段) */
29
- updateTarget(id: string, patch: unknown): Promise<any>;
30
- /** 删除目标 */
31
- deleteTarget(id: string): Promise<any>;
32
- /** 模块汇总(指标实际值 + 目标达成) */
26
+ /** 模块汇总(指标实际值) */
33
27
  summary(params?: QueryParams): Promise<any>;
34
28
  /** 成本-效果(转化 vs 用量) */
35
29
  roi(params?: QueryParams): Promise<any>;
@@ -1,8 +1,10 @@
1
1
  import { buildQuery } from "./query.js";
2
2
  /**
3
- * Effect 资源 — 效果追踪(P6.6):指标字典 / 日快照 / 目标 / 汇总 ROI / 周报告警 / GEO 探针问题集。
3
+ * Effect 资源 — 效果追踪(P6.6):指标字典 / 日快照 / 汇总 ROI / 周报告警 / GEO 探针问题集。
4
4
  * 端点走 Server API(/api/effect/*),与社媒域 MCP effect_* 工具同源。
5
5
  * 读接口 authAny(API Key 可读),写接口 authenticate(需 JWT 登录态)。
6
+ *
7
+ * 说明(v0.4.0):`/api/effect/targets*` 在服务端未挂载(调用必 404),目标 CRUD 已移除。
6
8
  */
7
9
  export class EffectResource {
8
10
  constructor(request) {
@@ -34,25 +36,8 @@ export class EffectResource {
34
36
  series(params = {}) {
35
37
  return this.request("GET", `/api/effect/series${buildQuery(params)}`);
36
38
  }
37
- // ── 目标 ──
38
- /** 目标列表(可按 module/status 过滤) */
39
- listTargets(params = {}) {
40
- return this.request("GET", `/api/effect/targets${buildQuery(params)}`);
41
- }
42
- /** 创建目标(module/scope/metric/period/targetValue/periodStart/periodEnd) */
43
- createTarget(data) {
44
- return this.request("POST", "/api/effect/targets", data);
45
- }
46
- /** 更新目标(部分字段) */
47
- updateTarget(id, patch) {
48
- return this.request("PUT", `/api/effect/targets/${encodeURIComponent(id)}`, patch);
49
- }
50
- /** 删除目标 */
51
- deleteTarget(id) {
52
- return this.request("DELETE", `/api/effect/targets/${encodeURIComponent(id)}`);
53
- }
54
39
  // ── 汇总 / ROI / 报告 / 告警 ──
55
- /** 模块汇总(指标实际值 + 目标达成) */
40
+ /** 模块汇总(指标实际值) */
56
41
  summary(params = {}) {
57
42
  return this.request("GET", `/api/effect/summary${buildQuery(params)}`);
58
43
  }