@reachv2/sdk 0.3.2 → 0.4.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/README.md +19 -7
- package/dist/client.d.ts +6 -0
- package/dist/client.js +9 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +3 -0
- package/dist/resources/accounts.d.ts +16 -4
- package/dist/resources/accounts.js +11 -6
- package/dist/resources/agent-api.d.ts +11 -31
- package/dist/resources/agent-api.js +16 -55
- package/dist/resources/auth.d.ts +25 -1
- package/dist/resources/auth.js +41 -0
- package/dist/resources/channel-admin.d.ts +94 -0
- package/dist/resources/channel-admin.js +155 -0
- package/dist/resources/data-sources.d.ts +5 -23
- package/dist/resources/data-sources.js +5 -43
- package/dist/resources/effect.d.ts +4 -10
- package/dist/resources/effect.js +4 -19
- package/dist/resources/email-channel.d.ts +87 -0
- package/dist/resources/email-channel.js +62 -0
- package/dist/resources/merchant.d.ts +87 -0
- package/dist/resources/merchant.js +143 -0
- package/dist/resources/publish-plans.d.ts +10 -1
- package/dist/resources/publish-plans.js +14 -1
- package/dist/types.d.ts +240 -1
- package/package.json +3 -2
|
@@ -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
|
|
8
|
-
*
|
|
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
|
|
6
|
-
*
|
|
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):指标字典 / 日快照 /
|
|
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
|
-
/**
|
|
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>;
|
package/dist/resources/effect.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { buildQuery } from "./query.js";
|
|
2
2
|
/**
|
|
3
|
-
* Effect 资源 — 效果追踪(P6.6):指标字典 / 日快照 /
|
|
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
|
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { RequestMethod, EmailMailbox, EmailMailboxCreateParams, EmailThreadList } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
export interface EmailSendParams {
|
|
4
|
+
to: string | string[];
|
|
5
|
+
subject: string;
|
|
6
|
+
text?: string;
|
|
7
|
+
html?: string;
|
|
8
|
+
cc?: string[];
|
|
9
|
+
bcc?: string[];
|
|
10
|
+
inReplyTo?: string | null;
|
|
11
|
+
references?: string[];
|
|
12
|
+
attachments?: unknown[];
|
|
13
|
+
conversationId?: string | null;
|
|
14
|
+
agentKey?: string;
|
|
15
|
+
idempotencyKey?: string | null;
|
|
16
|
+
}
|
|
17
|
+
export interface EmailPollParams {
|
|
18
|
+
limit?: number;
|
|
19
|
+
/** 默认 true */
|
|
20
|
+
storeAttachments?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface EmailInboundParams {
|
|
23
|
+
/** 原始邮件(RFC822 / 原始 source) */
|
|
24
|
+
source: string;
|
|
25
|
+
uid?: string | null;
|
|
26
|
+
storeAttachments?: boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* EmailChannelResource — 客服邮件通道(C9-1)。
|
|
30
|
+
*
|
|
31
|
+
* 端点:`/api/merchant/projects/:id/bots/:botId/channels/email/*`,
|
|
32
|
+
* 要求 `role=merchant` 的 JWT。邮箱凭证加密入库,对外永不返回密码。
|
|
33
|
+
*/
|
|
34
|
+
export declare class EmailChannelResource {
|
|
35
|
+
private request;
|
|
36
|
+
constructor(request: RequestFn);
|
|
37
|
+
private base;
|
|
38
|
+
/** 邮箱账号列表 */
|
|
39
|
+
listMailboxes(projectId: string, botId: string): Promise<{
|
|
40
|
+
mailboxes: EmailMailbox[];
|
|
41
|
+
}>;
|
|
42
|
+
/** 新增邮箱账号(SMTP/IMAP 凭证) */
|
|
43
|
+
createMailbox(projectId: string, botId: string, params: EmailMailboxCreateParams): Promise<{
|
|
44
|
+
mailbox: EmailMailbox;
|
|
45
|
+
binding: unknown;
|
|
46
|
+
}>;
|
|
47
|
+
/** 邮箱账号详情 */
|
|
48
|
+
getMailbox(projectId: string, botId: string, mailboxId: string): Promise<{
|
|
49
|
+
mailbox: EmailMailbox;
|
|
50
|
+
}>;
|
|
51
|
+
/** 更新邮箱账号(地址变更会同步通道绑定) */
|
|
52
|
+
updateMailbox(projectId: string, botId: string, mailboxId: string, patch: Partial<EmailMailboxCreateParams>): Promise<{
|
|
53
|
+
mailbox: EmailMailbox;
|
|
54
|
+
}>;
|
|
55
|
+
/** 删除邮箱账号(同时解绑通道) */
|
|
56
|
+
deleteMailbox(projectId: string, botId: string, mailboxId: string): Promise<{
|
|
57
|
+
success: boolean;
|
|
58
|
+
[key: string]: unknown;
|
|
59
|
+
}>;
|
|
60
|
+
/** 通过 SMTP 发信 */
|
|
61
|
+
sendMail(projectId: string, botId: string, mailboxId: string, params: EmailSendParams): Promise<{
|
|
62
|
+
success: boolean;
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
}>;
|
|
65
|
+
/** 立即通过 IMAP 拉取一次收件 */
|
|
66
|
+
pollMailbox(projectId: string, botId: string, mailboxId: string, params?: EmailPollParams): Promise<{
|
|
67
|
+
success: boolean;
|
|
68
|
+
[key: string]: unknown;
|
|
69
|
+
}>;
|
|
70
|
+
/** 投递原始邮件(调试 / 外部收信 webhook;幂等键 = Message-ID) */
|
|
71
|
+
inboundEmail(projectId: string, botId: string, mailboxId: string, params: EmailInboundParams): Promise<{
|
|
72
|
+
success: boolean;
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
}>;
|
|
75
|
+
/** 邮件线程列表(limit 默认 50,上限 200) */
|
|
76
|
+
listThreads(projectId: string, botId: string, mailboxId: string, params?: {
|
|
77
|
+
limit?: number;
|
|
78
|
+
threadKey?: string;
|
|
79
|
+
conversationId?: string;
|
|
80
|
+
}): Promise<EmailThreadList>;
|
|
81
|
+
/** 线程详情(含消息列表) */
|
|
82
|
+
getThread(projectId: string, botId: string, mailboxId: string, threadId: string): Promise<{
|
|
83
|
+
thread: Record<string, unknown>;
|
|
84
|
+
messages: unknown[];
|
|
85
|
+
}>;
|
|
86
|
+
}
|
|
87
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EmailChannelResource — 客服邮件通道(C9-1)。
|
|
3
|
+
*
|
|
4
|
+
* 端点:`/api/merchant/projects/:id/bots/:botId/channels/email/*`,
|
|
5
|
+
* 要求 `role=merchant` 的 JWT。邮箱凭证加密入库,对外永不返回密码。
|
|
6
|
+
*/
|
|
7
|
+
export class EmailChannelResource {
|
|
8
|
+
constructor(request) {
|
|
9
|
+
this.request = request;
|
|
10
|
+
}
|
|
11
|
+
base(projectId, botId) {
|
|
12
|
+
return `/api/merchant/projects/${encodeURIComponent(projectId)}/bots/${encodeURIComponent(botId)}/channels/email`;
|
|
13
|
+
}
|
|
14
|
+
/** 邮箱账号列表 */
|
|
15
|
+
listMailboxes(projectId, botId) {
|
|
16
|
+
return this.request("GET", `${this.base(projectId, botId)}/mailboxes`);
|
|
17
|
+
}
|
|
18
|
+
/** 新增邮箱账号(SMTP/IMAP 凭证) */
|
|
19
|
+
createMailbox(projectId, botId, params) {
|
|
20
|
+
return this.request("POST", `${this.base(projectId, botId)}/mailboxes`, params);
|
|
21
|
+
}
|
|
22
|
+
/** 邮箱账号详情 */
|
|
23
|
+
getMailbox(projectId, botId, mailboxId) {
|
|
24
|
+
return this.request("GET", `${this.base(projectId, botId)}/mailboxes/${encodeURIComponent(mailboxId)}`);
|
|
25
|
+
}
|
|
26
|
+
/** 更新邮箱账号(地址变更会同步通道绑定) */
|
|
27
|
+
updateMailbox(projectId, botId, mailboxId, patch) {
|
|
28
|
+
return this.request("PUT", `${this.base(projectId, botId)}/mailboxes/${encodeURIComponent(mailboxId)}`, patch);
|
|
29
|
+
}
|
|
30
|
+
/** 删除邮箱账号(同时解绑通道) */
|
|
31
|
+
deleteMailbox(projectId, botId, mailboxId) {
|
|
32
|
+
return this.request("DELETE", `${this.base(projectId, botId)}/mailboxes/${encodeURIComponent(mailboxId)}`);
|
|
33
|
+
}
|
|
34
|
+
/** 通过 SMTP 发信 */
|
|
35
|
+
sendMail(projectId, botId, mailboxId, params) {
|
|
36
|
+
return this.request("POST", `${this.base(projectId, botId)}/mailboxes/${encodeURIComponent(mailboxId)}/send`, params);
|
|
37
|
+
}
|
|
38
|
+
/** 立即通过 IMAP 拉取一次收件 */
|
|
39
|
+
pollMailbox(projectId, botId, mailboxId, params = {}) {
|
|
40
|
+
return this.request("POST", `${this.base(projectId, botId)}/mailboxes/${encodeURIComponent(mailboxId)}/poll`, params);
|
|
41
|
+
}
|
|
42
|
+
/** 投递原始邮件(调试 / 外部收信 webhook;幂等键 = Message-ID) */
|
|
43
|
+
inboundEmail(projectId, botId, mailboxId, params) {
|
|
44
|
+
return this.request("POST", `${this.base(projectId, botId)}/mailboxes/${encodeURIComponent(mailboxId)}/inbound`, params);
|
|
45
|
+
}
|
|
46
|
+
/** 邮件线程列表(limit 默认 50,上限 200) */
|
|
47
|
+
listThreads(projectId, botId, mailboxId, params = {}) {
|
|
48
|
+
const query = new URLSearchParams();
|
|
49
|
+
if (params.limit != null)
|
|
50
|
+
query.set("limit", String(params.limit));
|
|
51
|
+
if (params.threadKey)
|
|
52
|
+
query.set("threadKey", params.threadKey);
|
|
53
|
+
if (params.conversationId)
|
|
54
|
+
query.set("conversationId", params.conversationId);
|
|
55
|
+
const qs = query.toString();
|
|
56
|
+
return this.request("GET", `${this.base(projectId, botId)}/mailboxes/${encodeURIComponent(mailboxId)}/threads${qs ? `?${qs}` : ""}`);
|
|
57
|
+
}
|
|
58
|
+
/** 线程详情(含消息列表) */
|
|
59
|
+
getThread(projectId, botId, mailboxId, threadId) {
|
|
60
|
+
return this.request("GET", `${this.base(projectId, botId)}/mailboxes/${encodeURIComponent(mailboxId)}/threads/${encodeURIComponent(threadId)}`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { RequestMethod, MerchantDashboardStats, MerchantTicket, MerchantTicketUpdateParams, MerchantProject, MerchantBot, MerchantProjectCreateParams, MerchantBotCreateParams, MerchantLlmConfig, MerchantLlmConfigInput, MerchantChain, MerchantChainAddParams, MerchantChainList, MerchantTeamResult, MerchantTeamMemberAddParams, MerchantTeamInviteParams, MerchantTeamInviteResult, MerchantTeamRole, SimpleResult } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
/**
|
|
4
|
+
* MerchantResource — 商户域(客服工作台 / 商户控制台)。
|
|
5
|
+
*
|
|
6
|
+
* 端点:Server API `/api/merchant/*`,全部要求 `role=merchant` 的 JWT
|
|
7
|
+
* (邮箱/钱包注册后需先 `auth.merchantOnboard()` 或接受商户邀请,见 v0.4.0 说明)。
|
|
8
|
+
*
|
|
9
|
+
* 注意:商户域直接返回 db 行(snake_case),与网关 `/api/v1` 的 camelCase 不同。
|
|
10
|
+
*/
|
|
11
|
+
export declare class MerchantResource {
|
|
12
|
+
private request;
|
|
13
|
+
constructor(request: RequestFn);
|
|
14
|
+
/** 商户看板(项目/Bot/会话/文档/token 配额 + 近 14 天趋势) */
|
|
15
|
+
dashboard(): Promise<MerchantDashboardStats>;
|
|
16
|
+
/** 转人工工单列表(近期 200 条) */
|
|
17
|
+
listTickets(): Promise<{
|
|
18
|
+
tickets: MerchantTicket[];
|
|
19
|
+
}>;
|
|
20
|
+
/** 更新工单状态 / 处理人(resolved 会同步会话状态) */
|
|
21
|
+
updateTicket(id: string, params: MerchantTicketUpdateParams): Promise<MerchantTicket>;
|
|
22
|
+
/** 项目列表(含 bot_count / total_tokens / total_conversations 聚合) */
|
|
23
|
+
listProjects(): Promise<MerchantProject[]>;
|
|
24
|
+
/** 项目详情 */
|
|
25
|
+
getProject(projectId: string): Promise<MerchantProject>;
|
|
26
|
+
/** 新建项目(默认名「新项目」) */
|
|
27
|
+
createProject(params: MerchantProjectCreateParams): Promise<MerchantProject>;
|
|
28
|
+
/** 更新项目(name / description 等) */
|
|
29
|
+
updateProject(projectId: string, patch: Record<string, unknown>): Promise<MerchantProject>;
|
|
30
|
+
/** 项目下 Bot 列表 */
|
|
31
|
+
listBots(projectId: string): Promise<MerchantBot[]>;
|
|
32
|
+
/** 在项目下新建 Bot(type 由服务端固定为 support) */
|
|
33
|
+
createBot(projectId: string, params: MerchantBotCreateParams): Promise<MerchantBot>;
|
|
34
|
+
/** 更新 Bot(name / prompt / status 等) */
|
|
35
|
+
updateBot(projectId: string, botId: string, patch: Record<string, unknown>): Promise<MerchantBot>;
|
|
36
|
+
/** 读取 Bot 的 LLM 配置(未配置返回 null) */
|
|
37
|
+
getLlmConfig(projectId: string, botId: string): Promise<MerchantLlmConfig | null>;
|
|
38
|
+
/** 写入 Bot 的 LLM 配置(BYOK) */
|
|
39
|
+
setLlmConfig(projectId: string, botId: string, params: MerchantLlmConfigInput): Promise<SimpleResult & Record<string, unknown>>;
|
|
40
|
+
/** 重置回平台托管 LLM */
|
|
41
|
+
resetLlmConfig(projectId: string, botId: string): Promise<SimpleResult & Record<string, unknown>>;
|
|
42
|
+
/** 可用链列表(内置链 + 商户自定义链) */
|
|
43
|
+
listChains(): Promise<MerchantChainList>;
|
|
44
|
+
/** 添加自定义链 */
|
|
45
|
+
addChain(params: MerchantChainAddParams): Promise<{
|
|
46
|
+
success: boolean;
|
|
47
|
+
chain: MerchantChain;
|
|
48
|
+
}>;
|
|
49
|
+
/** 删除自定义链 */
|
|
50
|
+
removeChain(chainId: number): Promise<SimpleResult>;
|
|
51
|
+
/** 团队成员列表(owner + 成员 + 待接受邀请) */
|
|
52
|
+
getTeam(): Promise<MerchantTeamResult>;
|
|
53
|
+
/** 直接加人(目标账户需已注册;email 或 wallet 二选一) */
|
|
54
|
+
addTeamMember(params: MerchantTeamMemberAddParams): Promise<Record<string, unknown>>;
|
|
55
|
+
/** 生成邀请(邮箱未注册亦可;受邀者登录后接受) */
|
|
56
|
+
createTeamInvite(params: MerchantTeamInviteParams): Promise<MerchantTeamInviteResult>;
|
|
57
|
+
/** 撤销未接受的邀请 */
|
|
58
|
+
revokeTeamInvite(token: string): Promise<SimpleResult>;
|
|
59
|
+
/** 修改成员角色 */
|
|
60
|
+
updateTeamMemberRole(accountId: string, role: MerchantTeamRole): Promise<SimpleResult>;
|
|
61
|
+
/** 移除成员 */
|
|
62
|
+
removeTeamMember(accountId: string): Promise<SimpleResult>;
|
|
63
|
+
/** 当前账户在本商户的权限码 */
|
|
64
|
+
myPermissions(): Promise<{
|
|
65
|
+
permissions: string[];
|
|
66
|
+
}>;
|
|
67
|
+
/** 角色目录(RBAC) */
|
|
68
|
+
listRoles(): Promise<unknown>;
|
|
69
|
+
/** 可分配角色选项 */
|
|
70
|
+
roleOptions(): Promise<unknown>;
|
|
71
|
+
/** 成员及其角色 */
|
|
72
|
+
listMembers(): Promise<unknown>;
|
|
73
|
+
/** 修改成员角色集合 */
|
|
74
|
+
updateMemberRoles(userId: string, roles: string[]): Promise<unknown>;
|
|
75
|
+
/** 审计日志(action / resourceType / status / limit / offset) */
|
|
76
|
+
listAuditLogs(params?: {
|
|
77
|
+
action?: string;
|
|
78
|
+
resourceType?: string;
|
|
79
|
+
status?: string;
|
|
80
|
+
limit?: number;
|
|
81
|
+
offset?: number;
|
|
82
|
+
}): Promise<{
|
|
83
|
+
items: unknown[];
|
|
84
|
+
total: number;
|
|
85
|
+
}>;
|
|
86
|
+
}
|
|
87
|
+
export {};
|