@reachv2/sdk 0.2.0 → 0.3.1
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 +40 -18
- package/dist/client.d.ts +8 -0
- package/dist/client.js +8 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -0
- package/dist/resources/auth.d.ts +7 -4
- package/dist/resources/auth.js +7 -4
- package/dist/resources/content-rules.d.ts +37 -0
- package/dist/resources/content-rules.js +59 -0
- package/dist/resources/data-sources.d.ts +38 -0
- package/dist/resources/data-sources.js +60 -0
- package/dist/resources/effect.d.ts +57 -0
- package/dist/resources/effect.js +104 -0
- package/dist/resources/query.d.ts +3 -0
- package/dist/resources/query.js +10 -0
- package/dist/resources/seo-geo.d.ts +65 -0
- package/dist/resources/seo-geo.js +112 -0
- package/dist/types.d.ts +22 -15
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @reachv2/sdk
|
|
2
2
|
|
|
3
|
-
Reach(reach.codes)统一平台的官方 TypeScript SDK —— 由 aiservicer SDK(crm 域,18 资源)与 aiops-saas SDK(social 域,5 资源)合并而来(P2.4
|
|
3
|
+
Reach(reach.codes)统一平台的官方 TypeScript SDK —— 由 aiservicer SDK(crm 域,18 资源)与 aiops-saas SDK(social 域,5 资源)合并而来(P2.4),现统一为 **27 个资源类 / 203 个资源方法**。一个客户端覆盖客服 / 销售引导、社群维护与社媒运营全部资源(含效果追踪、SEO/GEO、内容规则与数据源)。
|
|
4
4
|
|
|
5
5
|
- 运行时:Node.js >= 18(ESM)
|
|
6
6
|
- 类型:完整 TypeScript 类型定义(自带 `dist/index.d.ts`)
|
|
@@ -8,7 +8,7 @@ Reach(reach.codes)统一平台的官方 TypeScript SDK —— 由 aiservicer
|
|
|
8
8
|
|
|
9
9
|
## 文档
|
|
10
10
|
|
|
11
|
-
- **[API Reference](docs/API-REFERENCE.md)**(P2.6,v0.
|
|
11
|
+
- **[API Reference](docs/API-REFERENCE.md)**(P2.6,v0.3.0 补 P-REACH 四域):全部 27 个资源类 + `ReachClient` 共 **203 个资源方法**(另含 `ReachClient.setToken` / `request`)的签名 / 端点 / 参数 / 返回类型 / 错误 / 示例,与 `sdk/src` 源码一一对应。
|
|
12
12
|
|
|
13
13
|
## 安装
|
|
14
14
|
|
|
@@ -42,21 +42,25 @@ const { reply, transaction } = await client.agents.chat("bot-xxx", {
|
|
|
42
42
|
const post = await client.content.generate("AI trends", "twitter", "professional");
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
### 方式二:JWT
|
|
45
|
+
### 方式二:JWT 登录(邮箱 + 密码,图形验证码可选)
|
|
46
46
|
|
|
47
47
|
```ts
|
|
48
48
|
const client = new ReachClient({ baseUrl: "https://reach.codes", apiKey: "reach-xxx" });
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
const
|
|
50
|
+
// 1) 取图形验证码(算式图):{ captchaId, image, expiresIn },image 为 data:image/svg+xml;base64
|
|
51
|
+
const { captchaId, image } = await client.auth.getCaptcha();
|
|
52
|
+
const svg = Buffer.from(image.replace(/^data:image\/svg\+xml;base64,/, ""), "base64").toString("utf-8");
|
|
53
|
+
const m = svg.match(/(\d+)\s*([+-])\s*(\d+)/)!;
|
|
53
54
|
const answer = m[2] === "+" ? Number(m[1]) + Number(m[3]) : Number(m[1]) - Number(m[3]);
|
|
54
55
|
|
|
55
|
-
|
|
56
|
-
client.
|
|
56
|
+
// 2) 登录:返回 { accessToken, refreshToken, account }
|
|
57
|
+
const { accessToken } = await client.auth.login("user@example.com", "password", { token: captchaId, answer });
|
|
58
|
+
client.setToken(accessToken); // SDK 不会自动接线,需手动 setToken 切换为 JWT 模式
|
|
57
59
|
```
|
|
58
60
|
|
|
59
|
-
> **JWT
|
|
61
|
+
> **JWT 续期**:`accessToken` 默认 2h(`JWT_ACCESS_TTL`),`refreshToken` 30d(`JWT_REFRESH_TTL_SEC`)。
|
|
62
|
+
> SDK 未封装 refresh;过期后用 `await client.request("POST", "/api/auth/refresh", { refreshToken })` 轮换并 `setToken`。
|
|
63
|
+
> 启用 MFA 的账户 `login` 返回 `{ mfaRequired: true, account }`(不带 token),需携带 `mfaCode`(TOTP/恢复码)重试。
|
|
60
64
|
|
|
61
65
|
## 认证方式
|
|
62
66
|
|
|
@@ -73,10 +77,12 @@ client.setToken(jwt); // SDK 不会自动接线,需手动 setToken 切换为 J
|
|
|
73
77
|
Reach 将自身能力以 **MCP(Model Context Protocol)** 形式对外开放(Streamable HTTP,路径 `/mcp`),
|
|
74
78
|
让支持 MCP 的客户端(Claude Desktop / Cursor / 自研 Agent)可直接调用 crm + social 域工具。
|
|
75
79
|
|
|
76
|
-
- 端点:`https://reach.codes/mcp`(探活:`GET https://reach.codes/mcp/health`)
|
|
77
|
-
- 鉴权:`X-API-Key: reach-xxx` 或 `Authorization: Bearer
|
|
78
|
-
-
|
|
79
|
-
|
|
80
|
+
- 端点:`https://reach.codes/mcp`(探活:`GET https://reach.codes/mcp/health`,返回 `{ status, tools, publicMode, domains }`)
|
|
81
|
+
- 鉴权:`X-API-Key: reach-xxx` 或 `Authorization: Bearer <key>`(复用 REST API Key,租户隔离由此 Key 决定)
|
|
82
|
+
- 权限(读 / 写门禁):只读 Key(scope 不含 `write` / `all` / `*`)**只能调用读工具**(工具名按 `_` 分词命中
|
|
83
|
+
`list` / `get` / `status` / `query` / `summary` / `check` / `history` / `usage` … 即视为读,未命中一律按写拒绝);
|
|
84
|
+
写工具需 `write` / `all` / `*` scope,否则 `tools/call` 返回 JSON-RPC `-32001 requires a write-scoped API key`
|
|
85
|
+
- 工具规模:**269**(crm 87 + social 182),按域白名单裁剪(当前 `crm` / `social`),`tools/list` 返回实际可用集合
|
|
80
86
|
|
|
81
87
|
会话按 MCP Streamable HTTP 规范:先 `initialize` 取得 `mcp-session-id`,
|
|
82
88
|
再发 `notifications/initialized`,之后 `tools/call`,结束时 `DELETE` 会话。
|
|
@@ -158,6 +164,15 @@ const client = new ReachClient({
|
|
|
158
164
|
| `client.tts` | 文本转语音(synthesize/voices/history) | Server |
|
|
159
165
|
| `client.accounts` | 社媒账号矩阵(list/connect) | Server |
|
|
160
166
|
|
|
167
|
+
### social 域 — P-REACH(效果 / SEO-GEO / 内容规则 / 数据源,v0.3.0 新增)
|
|
168
|
+
|
|
169
|
+
| 资源 | 主要能力 | API 域 |
|
|
170
|
+
|------|----------|--------|
|
|
171
|
+
| `client.effect` | **效果追踪(EffectResource)**:指标字典、日快照、目标、汇总/ROI/归因/周报、告警、GEO 探针问题集(22 方法) | Server |
|
|
172
|
+
| `client.seoGeo` | **SEO/GEO 域(SeoGeoResource)**:品牌档案 / 渠道集 / 内容矩阵(草稿→发布→回采)/ GEO 资产(24 方法) | Server |
|
|
173
|
+
| `client.contentRules` | **内容规则引擎(ContentRulesResource)**:规则 CRUD + 发布前打分/优化 + 发布后效果/GEO 评估 + 记录趋势(12 方法) | Server |
|
|
174
|
+
| `client.dataSources` | **数据源适配器(DataSourcesResource)**:明细/趋势/告警/定时同步(12 方法;无创建入口,内置源只读) | Server |
|
|
175
|
+
|
|
161
176
|
> crm 客服指标(原 `client.analytics`)与社媒运营看板(原 `client.dashboard`)已统一为 `client.dashboard`(DashboardApi);AgentX(原 `client.agentx`)与社媒 Agent 市场已统一为 `client.agents`(AgentApi)。
|
|
162
177
|
|
|
163
178
|
## 统一入口说明
|
|
@@ -176,18 +191,25 @@ const client = new ReachClient({
|
|
|
176
191
|
```bash
|
|
177
192
|
cd sdk
|
|
178
193
|
npm install
|
|
179
|
-
npm run build # tsc → dist
|
|
180
|
-
npm test # node --test test
|
|
194
|
+
npm run build # clean + tsc → dist
|
|
195
|
+
npm test # node --test,覆盖 test/*.test.mjs
|
|
181
196
|
```
|
|
182
197
|
|
|
198
|
+
| 测试文件 | 覆盖 |
|
|
199
|
+
|----------|------|
|
|
200
|
+
| `test/client.test.mjs` | ReachClient 核心行为:构造校验(`MISSING_AUTH`)、认证 Header、双 base 路由、body 序列化、错误语义 |
|
|
201
|
+
| `test/resources.test.mjs` | **全量** 27 资源类 203 方法的 method / path / body 断言(要求每个方法至少被一条用例覆盖) |
|
|
202
|
+
| `test/smoke.test.mjs` | 导出面 + 资源方法面快照 |
|
|
203
|
+
|
|
204
|
+
> 测试跑 **`dist/` 产物**,改完 `src/` 必须先 `npm run build`。
|
|
205
|
+
|
|
183
206
|
## 发布流程(维护者)
|
|
184
207
|
|
|
185
208
|
```bash
|
|
186
209
|
cd sdk
|
|
187
210
|
npm version <minor> --no-git-tag-version # 小版本递增,紧贴 API 变更
|
|
188
|
-
npm
|
|
189
|
-
npm pack
|
|
190
|
-
npm publish # token 在 ~/.npmrc(reachv2 组织)
|
|
211
|
+
npm publish # prepublishOnly 自动执行 build + test;产物仅含 dist(package.json files 字段)
|
|
212
|
+
# 可选:npm pack 本地检查 tarball 内容
|
|
191
213
|
cd .. && git add sdk/package.json sdk/package-lock.json
|
|
192
214
|
git commit -m "chore(sdk): 发布 @reachv2/sdk@<version>"
|
|
193
215
|
```
|
package/dist/client.d.ts
CHANGED
|
@@ -18,6 +18,10 @@ import { AbiResource } from "./resources/abis.js";
|
|
|
18
18
|
import { ContentResource } from "./resources/content.js";
|
|
19
19
|
import { TtsResource } from "./resources/tts.js";
|
|
20
20
|
import { AccountsResource } from "./resources/accounts.js";
|
|
21
|
+
import { EffectResource } from "./resources/effect.js";
|
|
22
|
+
import { SeoGeoResource } from "./resources/seo-geo.js";
|
|
23
|
+
import { ContentRulesResource } from "./resources/content-rules.js";
|
|
24
|
+
import { DataSourcesResource } from "./resources/data-sources.js";
|
|
21
25
|
import { DashboardApi } from "./resources/dashboard-api.js";
|
|
22
26
|
import { HealthResource } from "./resources/health.js";
|
|
23
27
|
import { TenantsResource } from "./resources/tenants.js";
|
|
@@ -48,6 +52,10 @@ export declare class ReachClient {
|
|
|
48
52
|
content: ContentResource;
|
|
49
53
|
tts: TtsResource;
|
|
50
54
|
accounts: AccountsResource;
|
|
55
|
+
effect: EffectResource;
|
|
56
|
+
seoGeo: SeoGeoResource;
|
|
57
|
+
contentRules: ContentRulesResource;
|
|
58
|
+
dataSources: DataSourcesResource;
|
|
51
59
|
tenants: TenantsResource;
|
|
52
60
|
team: TeamResource;
|
|
53
61
|
health: HealthResource;
|
package/dist/client.js
CHANGED
|
@@ -18,6 +18,10 @@ import { AbiResource } from "./resources/abis.js";
|
|
|
18
18
|
import { ContentResource } from "./resources/content.js";
|
|
19
19
|
import { TtsResource } from "./resources/tts.js";
|
|
20
20
|
import { AccountsResource } from "./resources/accounts.js";
|
|
21
|
+
import { EffectResource } from "./resources/effect.js";
|
|
22
|
+
import { SeoGeoResource } from "./resources/seo-geo.js";
|
|
23
|
+
import { ContentRulesResource } from "./resources/content-rules.js";
|
|
24
|
+
import { DataSourcesResource } from "./resources/data-sources.js";
|
|
21
25
|
import { DashboardApi } from "./resources/dashboard-api.js";
|
|
22
26
|
import { HealthResource } from "./resources/health.js";
|
|
23
27
|
import { TenantsResource } from "./resources/tenants.js";
|
|
@@ -53,6 +57,10 @@ export class ReachClient {
|
|
|
53
57
|
this.content = new ContentResource(this.requestServer.bind(this));
|
|
54
58
|
this.tts = new TtsResource(this.requestServer.bind(this));
|
|
55
59
|
this.accounts = new AccountsResource(this.requestServer.bind(this));
|
|
60
|
+
this.effect = new EffectResource(this.requestServer.bind(this));
|
|
61
|
+
this.seoGeo = new SeoGeoResource(this.requestServer.bind(this));
|
|
62
|
+
this.contentRules = new ContentRulesResource(this.requestServer.bind(this));
|
|
63
|
+
this.dataSources = new DataSourcesResource(this.requestServer.bind(this));
|
|
56
64
|
this.tenants = new TenantsResource(this.requestServer.bind(this));
|
|
57
65
|
this.team = new TeamResource(this.requestServer.bind(this));
|
|
58
66
|
this.health = new HealthResource(this.requestServer.bind(this));
|
package/dist/index.d.ts
CHANGED
|
@@ -20,8 +20,12 @@ export { AbiResource } from "./resources/abis.js";
|
|
|
20
20
|
export { ContentResource } from "./resources/content.js";
|
|
21
21
|
export { TtsResource } from "./resources/tts.js";
|
|
22
22
|
export { AccountsResource } from "./resources/accounts.js";
|
|
23
|
+
export { EffectResource } from "./resources/effect.js";
|
|
24
|
+
export { SeoGeoResource } from "./resources/seo-geo.js";
|
|
25
|
+
export { ContentRulesResource } from "./resources/content-rules.js";
|
|
26
|
+
export { DataSourcesResource } from "./resources/data-sources.js";
|
|
23
27
|
export { HealthResource } from "./resources/health.js";
|
|
24
28
|
export { TenantsResource } from "./resources/tenants.js";
|
|
25
29
|
export { TeamResource } from "./resources/team.js";
|
|
26
|
-
export type { ReachClientConfig, BotType, AgentType, BotStatus, ChannelType, ChannelStatus, KnowledgeStatus, Pagination, PaginatedResponse, Project, ProjectCreateParams, ProjectUpdateParams, TransactionBotConfig, Bot, BotStats, BotCreateParams, BotUpdateParams, KnowledgeDoc, KnowledgeRecommendation, Channel, ChannelConfigureParams, Conversation, Message, ChatParams, ChatResponse, ChatToolDefinition, ChatToolFunction, DashboardData, BotMetrics, TxIntent, TxStep, PreparedTransaction, ContractInfo, ContractMethod, SimulationResult, DecodedCalldata, ProtocolSummary, ProtocolRegistryEntry, ChainDeployment, ProtocolAction, ParamHint,
|
|
30
|
+
export type { ReachClientConfig, BotType, AgentType, BotStatus, ChannelType, ChannelStatus, KnowledgeStatus, Pagination, PaginatedResponse, Project, ProjectCreateParams, ProjectUpdateParams, TransactionBotConfig, Bot, BotStats, BotCreateParams, BotUpdateParams, KnowledgeDoc, KnowledgeRecommendation, Channel, ChannelConfigureParams, Conversation, Message, ChatParams, ChatResponse, ChatToolDefinition, ChatToolFunction, DashboardData, BotMetrics, TxIntent, TxStep, PreparedTransaction, ContractInfo, ContractMethod, SimulationResult, DecodedCalldata, ProtocolSummary, ProtocolRegistryEntry, ChainDeployment, ProtocolAction, ParamHint, WalletNonce, WalletLoginParams, AuthAccount, AuthResult, MfaRequiredResult, CaptchaResponse, CaptchaAnswer, AgentXAgent, AgentXAgentDetail, AgentXMarketplaceResult, AgentXSubscriptionPlans, AgentXSubscriptionCheck, AgentXAgentContext, AgentXPublishParams, AgentXPublishResult, AgentXSkill, AgentXSkillCreateParams, AgentXAgentStatus, AgentXAgentUsage, AgentXSubscriptionDetail, AgentXSubscriptionList, ServerChatParams, ServerChatResponse, ChatUsage, ChatUsageSummary, AgentSummary, AgentListResult, AgentListParams, AgentChainInfo, AgentActionType, AgentCapabilities, AgentChatParams, AgentChatResult, LightRAGKeyInfo, LightRAGDocumentParams, LightRAGQueryParams, LightRAGQueryResult, LightRAGBatchItem, LightRAGBatchError, LightRAGBatchResult, GlobalAnalytics, AdminDashboard, AdminMerchant, AdminMerchantDetail, AdminBillingRecord, AdminCreateBillingParams, LlmSettings, LlmUpdateParams, ConversationTask, ConversationTaskStatus, ConversationSession, ConversationCapabilities, ConversationMessage, OrchestrationTaskParams, OrchestrateParams, OrchestratedTaskResult, OrchestrateResult, ScheduledTask, ScheduledTaskStatus, ScheduledTaskTriggerType, MonitorConnectorKind, EnterpriseDoc, MonitorConnector, MonitorEvent, MerchantAbi, MerchantAbiCreateParams, SimpleResult, TenantType, TenantMemberRole, TenantMemberStatus, Tenant, TenantMemberInfo, TenantInvite, PublicInviteInfo, InviteAcceptResult, MemberRoleUpdateResult, TransferOwnerResult, TeamMemberItem, TeamInviteResult, HealthInfo, } from "./types.js";
|
|
27
31
|
export type { ApiKeyInfo, ApiKeyCreated } from "./resources/api-key.js";
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,10 @@ export { AbiResource } from "./resources/abis.js";
|
|
|
20
20
|
export { ContentResource } from "./resources/content.js";
|
|
21
21
|
export { TtsResource } from "./resources/tts.js";
|
|
22
22
|
export { AccountsResource } from "./resources/accounts.js";
|
|
23
|
+
export { EffectResource } from "./resources/effect.js";
|
|
24
|
+
export { SeoGeoResource } from "./resources/seo-geo.js";
|
|
25
|
+
export { ContentRulesResource } from "./resources/content-rules.js";
|
|
26
|
+
export { DataSourcesResource } from "./resources/data-sources.js";
|
|
23
27
|
export { HealthResource } from "./resources/health.js";
|
|
24
28
|
export { TenantsResource } from "./resources/tenants.js";
|
|
25
29
|
export { TeamResource } from "./resources/team.js";
|
package/dist/resources/auth.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import { RequestMethod,
|
|
1
|
+
import { RequestMethod, WalletNonce, WalletLoginParams, AuthResult, CaptchaResponse, CaptchaAnswer } from "../types.js";
|
|
2
2
|
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
3
|
export declare class AuthResource {
|
|
4
4
|
private request;
|
|
5
5
|
constructor(request: RequestFn);
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* 获取钱包签名挑战(nonce)。
|
|
8
|
+
* 服务端签发后存 Redis 10 分钟一次性;签名对象即返回的 nonce 字符串本体。
|
|
9
|
+
*/
|
|
10
|
+
getChallenge(wallet: string): Promise<WalletNonce>;
|
|
11
|
+
/** 钱包签名登录(server 契约:{ wallet, nonce, signature }) */
|
|
9
12
|
walletLogin(params: WalletLoginParams): Promise<AuthResult>;
|
|
10
13
|
/**
|
|
11
14
|
* 获取图形验证码(login/register 前置,可选)。
|
package/dist/resources/auth.js
CHANGED
|
@@ -2,11 +2,14 @@ export class AuthResource {
|
|
|
2
2
|
constructor(request) {
|
|
3
3
|
this.request = request;
|
|
4
4
|
}
|
|
5
|
-
/**
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
/**
|
|
6
|
+
* 获取钱包签名挑战(nonce)。
|
|
7
|
+
* 服务端签发后存 Redis 10 分钟一次性;签名对象即返回的 nonce 字符串本体。
|
|
8
|
+
*/
|
|
9
|
+
getChallenge(wallet) {
|
|
10
|
+
return this.request("POST", "/api/auth/wallet-nonce", { wallet });
|
|
8
11
|
}
|
|
9
|
-
/**
|
|
12
|
+
/** 钱包签名登录(server 契约:{ wallet, nonce, signature }) */
|
|
10
13
|
walletLogin(params) {
|
|
11
14
|
return this.request("POST", "/api/auth/wallet-login", params);
|
|
12
15
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RequestMethod } from "../types.js";
|
|
2
|
+
import { QueryParams } from "./query.js";
|
|
3
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
4
|
+
/**
|
|
5
|
+
* ContentRules 资源 — 通用内容规则引擎(发布前 SEO/GEO/合规/品牌打分 + 发布后效果评估)。
|
|
6
|
+
* 端点走 Server API(/api/content-rules/*),与社媒域 MCP content_rules_* / seo_geo_optimize 工具同源。
|
|
7
|
+
* 列表/记录 authAny(API Key 可读),写与评估 authenticate(需 JWT 登录态)。
|
|
8
|
+
*/
|
|
9
|
+
export declare class ContentRulesResource {
|
|
10
|
+
private request;
|
|
11
|
+
constructor(request: RequestFn);
|
|
12
|
+
/** 规则列表(内置模板 + 自定义;可按 status/category/q 过滤) */
|
|
13
|
+
list(params?: QueryParams): Promise<any>;
|
|
14
|
+
/** 创建自定义规则(condition.items 打分项) */
|
|
15
|
+
create(data: unknown): Promise<any>;
|
|
16
|
+
/** 规则详情 */
|
|
17
|
+
get(id: string): Promise<any>;
|
|
18
|
+
/** 更新规则(内置模板锁定 severity/condition) */
|
|
19
|
+
update(id: string, patch: unknown): Promise<any>;
|
|
20
|
+
/** 状态机 active/archived */
|
|
21
|
+
activate(id: string, status: "active" | "archived"): Promise<any>;
|
|
22
|
+
/** 删除规则(需 archived 且非内置) */
|
|
23
|
+
delete(id: string): Promise<any>;
|
|
24
|
+
/** 发布前打分(可传 ruleIds 子集;persist 默认落库) */
|
|
25
|
+
evaluate(data: unknown): Promise<any>;
|
|
26
|
+
/** SEO/GEO LLM 优化闭环(打分 → 改写 → 复评) */
|
|
27
|
+
optimize(data: unknown): Promise<any>;
|
|
28
|
+
/** 发布后效果评估(effect 规则 × 内置效果监测源指标) */
|
|
29
|
+
evaluateEffect(data?: unknown): Promise<any>;
|
|
30
|
+
/** 收录 + AI 引用(GEO)效果评估(品牌维度) */
|
|
31
|
+
evaluateSeoGeo(data?: unknown): Promise<any>;
|
|
32
|
+
/** 打分历史(ruleId/stepId/siteCode/passed/page) */
|
|
33
|
+
records(params?: QueryParams): Promise<any>;
|
|
34
|
+
/** 打分趋势聚合(days 默认 30) */
|
|
35
|
+
recordsTrend(params?: QueryParams): Promise<any>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { buildQuery } from "./query.js";
|
|
2
|
+
/**
|
|
3
|
+
* ContentRules 资源 — 通用内容规则引擎(发布前 SEO/GEO/合规/品牌打分 + 发布后效果评估)。
|
|
4
|
+
* 端点走 Server API(/api/content-rules/*),与社媒域 MCP content_rules_* / seo_geo_optimize 工具同源。
|
|
5
|
+
* 列表/记录 authAny(API Key 可读),写与评估 authenticate(需 JWT 登录态)。
|
|
6
|
+
*/
|
|
7
|
+
export class ContentRulesResource {
|
|
8
|
+
constructor(request) {
|
|
9
|
+
this.request = request;
|
|
10
|
+
}
|
|
11
|
+
/** 规则列表(内置模板 + 自定义;可按 status/category/q 过滤) */
|
|
12
|
+
list(params = {}) {
|
|
13
|
+
return this.request("GET", `/api/content-rules${buildQuery(params)}`);
|
|
14
|
+
}
|
|
15
|
+
/** 创建自定义规则(condition.items 打分项) */
|
|
16
|
+
create(data) {
|
|
17
|
+
return this.request("POST", "/api/content-rules", data);
|
|
18
|
+
}
|
|
19
|
+
/** 规则详情 */
|
|
20
|
+
get(id) {
|
|
21
|
+
return this.request("GET", `/api/content-rules/${encodeURIComponent(id)}`);
|
|
22
|
+
}
|
|
23
|
+
/** 更新规则(内置模板锁定 severity/condition) */
|
|
24
|
+
update(id, patch) {
|
|
25
|
+
return this.request("PUT", `/api/content-rules/${encodeURIComponent(id)}`, patch);
|
|
26
|
+
}
|
|
27
|
+
/** 状态机 active/archived */
|
|
28
|
+
activate(id, status) {
|
|
29
|
+
return this.request("POST", `/api/content-rules/${encodeURIComponent(id)}/activate`, { status });
|
|
30
|
+
}
|
|
31
|
+
/** 删除规则(需 archived 且非内置) */
|
|
32
|
+
delete(id) {
|
|
33
|
+
return this.request("DELETE", `/api/content-rules/${encodeURIComponent(id)}`);
|
|
34
|
+
}
|
|
35
|
+
/** 发布前打分(可传 ruleIds 子集;persist 默认落库) */
|
|
36
|
+
evaluate(data) {
|
|
37
|
+
return this.request("POST", "/api/content-rules/evaluate", data);
|
|
38
|
+
}
|
|
39
|
+
/** SEO/GEO LLM 优化闭环(打分 → 改写 → 复评) */
|
|
40
|
+
optimize(data) {
|
|
41
|
+
return this.request("POST", "/api/content-rules/optimize", data);
|
|
42
|
+
}
|
|
43
|
+
/** 发布后效果评估(effect 规则 × 内置效果监测源指标) */
|
|
44
|
+
evaluateEffect(data = {}) {
|
|
45
|
+
return this.request("POST", "/api/content-rules/evaluate-effect", data);
|
|
46
|
+
}
|
|
47
|
+
/** 收录 + AI 引用(GEO)效果评估(品牌维度) */
|
|
48
|
+
evaluateSeoGeo(data = {}) {
|
|
49
|
+
return this.request("POST", "/api/content-rules/evaluate-seo-geo", data);
|
|
50
|
+
}
|
|
51
|
+
/** 打分历史(ruleId/stepId/siteCode/passed/page) */
|
|
52
|
+
records(params = {}) {
|
|
53
|
+
return this.request("GET", `/api/content-rules/records${buildQuery(params)}`);
|
|
54
|
+
}
|
|
55
|
+
/** 打分趋势聚合(days 默认 30) */
|
|
56
|
+
recordsTrend(params = {}) {
|
|
57
|
+
return this.request("GET", `/api/content-rules/records/trend${buildQuery(params)}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RequestMethod } from "../types.js";
|
|
2
|
+
import { QueryParams } from "./query.js";
|
|
3
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
4
|
+
/**
|
|
5
|
+
* DataSources 资源 — 数据源适配器(指标明细/趋势/告警/定时同步)。
|
|
6
|
+
* 端点走 Server API(/api/data-sources/*),与社媒域 MCP data_sources_* 工具同源。
|
|
7
|
+
* 全部 authenticate(需 JWT 登录态);内置 effect_monitor 源拒绝改/删/同步(400)。
|
|
8
|
+
* 创建入口不提供:P3.7.1 后无可创建的外部适配器(ADAPTERS 为空)。
|
|
9
|
+
*/
|
|
10
|
+
export declare class DataSourcesResource {
|
|
11
|
+
private request;
|
|
12
|
+
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
|
+
/** 指标明细(可按 metric/entity/from/to/limit 过滤) */
|
|
28
|
+
metrics(id: string, params?: QueryParams): Promise<any>;
|
|
29
|
+
/** 按天趋势聚合(metric/days) */
|
|
30
|
+
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
|
+
}
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { buildQuery } from "./query.js";
|
|
2
|
+
/**
|
|
3
|
+
* DataSources 资源 — 数据源适配器(指标明细/趋势/告警/定时同步)。
|
|
4
|
+
* 端点走 Server API(/api/data-sources/*),与社媒域 MCP data_sources_* 工具同源。
|
|
5
|
+
* 全部 authenticate(需 JWT 登录态);内置 effect_monitor 源拒绝改/删/同步(400)。
|
|
6
|
+
* 创建入口不提供:P3.7.1 后无可创建的外部适配器(ADAPTERS 为空)。
|
|
7
|
+
*/
|
|
8
|
+
export class DataSourcesResource {
|
|
9
|
+
constructor(request) {
|
|
10
|
+
this.request = request;
|
|
11
|
+
}
|
|
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
|
+
/** 指标明细(可按 metric/entity/from/to/limit 过滤) */
|
|
41
|
+
metrics(id, params = {}) {
|
|
42
|
+
return this.request("GET", `/api/data-sources/${encodeURIComponent(id)}/metrics${buildQuery(params)}`);
|
|
43
|
+
}
|
|
44
|
+
/** 按天趋势聚合(metric/days) */
|
|
45
|
+
trend(id, params = {}) {
|
|
46
|
+
return this.request("GET", `/api/data-sources/${encodeURIComponent(id)}/trend${buildQuery(params)}`);
|
|
47
|
+
}
|
|
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
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { RequestMethod } from "../types.js";
|
|
2
|
+
import { QueryParams } from "./query.js";
|
|
3
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
4
|
+
/**
|
|
5
|
+
* Effect 资源 — 效果追踪(P6.6):指标字典 / 日快照 / 目标 / 汇总 ROI / 周报告警 / GEO 探针问题集。
|
|
6
|
+
* 端点走 Server API(/api/effect/*),与社媒域 MCP effect_* 工具同源。
|
|
7
|
+
* 读接口 authAny(API Key 可读),写接口 authenticate(需 JWT 登录态)。
|
|
8
|
+
*/
|
|
9
|
+
export declare class EffectResource {
|
|
10
|
+
private request;
|
|
11
|
+
constructor(request: RequestFn);
|
|
12
|
+
/** 有效指标字典(平台默认 + 租户覆盖),可按 module 过滤 */
|
|
13
|
+
listDefs(params?: QueryParams): Promise<any>;
|
|
14
|
+
/** 新增/覆盖租户指标定义 {module, metricKey, name, unit?, direction?, agg?, source?, enabled?} */
|
|
15
|
+
upsertDef(data: unknown): Promise<any>;
|
|
16
|
+
/** 删除租户自定义指标定义(平台默认不可删) */
|
|
17
|
+
deleteDef(id: string): Promise<any>;
|
|
18
|
+
/** 维度可配置聚合查询(groupBy/fn/filters) */
|
|
19
|
+
queryMetrics(params?: QueryParams): Promise<any>;
|
|
20
|
+
/** 批量写入日快照(幂等 upsert,单次上限 500 行) */
|
|
21
|
+
writeMetrics(metrics: unknown[]): Promise<any>;
|
|
22
|
+
/** 单指标按天趋势 */
|
|
23
|
+
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
|
+
/** 模块汇总(指标实际值 + 目标达成) */
|
|
33
|
+
summary(params?: QueryParams): Promise<any>;
|
|
34
|
+
/** 成本-效果(转化 vs 用量) */
|
|
35
|
+
roi(params?: QueryParams): Promise<any>;
|
|
36
|
+
/** 对象级归因链 */
|
|
37
|
+
attribution(params?: QueryParams): Promise<any>;
|
|
38
|
+
/** 周报(默认上一个完整自然周,含环比) */
|
|
39
|
+
report(params?: QueryParams): Promise<any>;
|
|
40
|
+
/** 效果告警记录 */
|
|
41
|
+
listAlerts(params?: QueryParams): Promise<any>;
|
|
42
|
+
/** 立即评估告警(目标未达成 / 指标异常;参数走 query) */
|
|
43
|
+
evaluateAlerts(params?: QueryParams): Promise<any>;
|
|
44
|
+
/** GEO 问题集列表(可按 brandProfileId/enabled 过滤) */
|
|
45
|
+
listGeoPrompts(params?: QueryParams): Promise<any>;
|
|
46
|
+
/** 按品牌关键词自动派生问题集(幂等) */
|
|
47
|
+
deriveGeoPrompts(data?: unknown): Promise<any>;
|
|
48
|
+
/** 人工新增问题 {brandProfileId, text} */
|
|
49
|
+
createGeoPrompt(data: unknown): Promise<any>;
|
|
50
|
+
/** 改问题文本 / 启停 */
|
|
51
|
+
updateGeoPrompt(id: string, patch: unknown): Promise<any>;
|
|
52
|
+
/** 删人工问题(自动派生只能停用) */
|
|
53
|
+
deleteGeoPrompt(id: string): Promise<any>;
|
|
54
|
+
/** 立即执行一轮 GEO 探针 {day?}(默认昨日 UTC,同日快照) */
|
|
55
|
+
runGeoProbe(data?: unknown): Promise<any>;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { buildQuery } from "./query.js";
|
|
2
|
+
/**
|
|
3
|
+
* Effect 资源 — 效果追踪(P6.6):指标字典 / 日快照 / 目标 / 汇总 ROI / 周报告警 / GEO 探针问题集。
|
|
4
|
+
* 端点走 Server API(/api/effect/*),与社媒域 MCP effect_* 工具同源。
|
|
5
|
+
* 读接口 authAny(API Key 可读),写接口 authenticate(需 JWT 登录态)。
|
|
6
|
+
*/
|
|
7
|
+
export class EffectResource {
|
|
8
|
+
constructor(request) {
|
|
9
|
+
this.request = request;
|
|
10
|
+
}
|
|
11
|
+
// ── 指标字典 ──
|
|
12
|
+
/** 有效指标字典(平台默认 + 租户覆盖),可按 module 过滤 */
|
|
13
|
+
listDefs(params = {}) {
|
|
14
|
+
return this.request("GET", `/api/effect/defs${buildQuery(params)}`);
|
|
15
|
+
}
|
|
16
|
+
/** 新增/覆盖租户指标定义 {module, metricKey, name, unit?, direction?, agg?, source?, enabled?} */
|
|
17
|
+
upsertDef(data) {
|
|
18
|
+
return this.request("POST", "/api/effect/defs", data);
|
|
19
|
+
}
|
|
20
|
+
/** 删除租户自定义指标定义(平台默认不可删) */
|
|
21
|
+
deleteDef(id) {
|
|
22
|
+
return this.request("DELETE", `/api/effect/defs/${encodeURIComponent(id)}`);
|
|
23
|
+
}
|
|
24
|
+
// ── 日快照事实表 ──
|
|
25
|
+
/** 维度可配置聚合查询(groupBy/fn/filters) */
|
|
26
|
+
queryMetrics(params = {}) {
|
|
27
|
+
return this.request("GET", `/api/effect/metrics${buildQuery(params)}`);
|
|
28
|
+
}
|
|
29
|
+
/** 批量写入日快照(幂等 upsert,单次上限 500 行) */
|
|
30
|
+
writeMetrics(metrics) {
|
|
31
|
+
return this.request("POST", "/api/effect/metrics", { metrics });
|
|
32
|
+
}
|
|
33
|
+
/** 单指标按天趋势 */
|
|
34
|
+
series(params = {}) {
|
|
35
|
+
return this.request("GET", `/api/effect/series${buildQuery(params)}`);
|
|
36
|
+
}
|
|
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
|
+
// ── 汇总 / ROI / 报告 / 告警 ──
|
|
55
|
+
/** 模块汇总(指标实际值 + 目标达成) */
|
|
56
|
+
summary(params = {}) {
|
|
57
|
+
return this.request("GET", `/api/effect/summary${buildQuery(params)}`);
|
|
58
|
+
}
|
|
59
|
+
/** 成本-效果(转化 vs 用量) */
|
|
60
|
+
roi(params = {}) {
|
|
61
|
+
return this.request("GET", `/api/effect/roi${buildQuery(params)}`);
|
|
62
|
+
}
|
|
63
|
+
/** 对象级归因链 */
|
|
64
|
+
attribution(params = {}) {
|
|
65
|
+
return this.request("GET", `/api/effect/attribution${buildQuery(params)}`);
|
|
66
|
+
}
|
|
67
|
+
/** 周报(默认上一个完整自然周,含环比) */
|
|
68
|
+
report(params = {}) {
|
|
69
|
+
return this.request("GET", `/api/effect/report${buildQuery(params)}`);
|
|
70
|
+
}
|
|
71
|
+
/** 效果告警记录 */
|
|
72
|
+
listAlerts(params = {}) {
|
|
73
|
+
return this.request("GET", `/api/effect/alerts${buildQuery(params)}`);
|
|
74
|
+
}
|
|
75
|
+
/** 立即评估告警(目标未达成 / 指标异常;参数走 query) */
|
|
76
|
+
evaluateAlerts(params = {}) {
|
|
77
|
+
return this.request("POST", `/api/effect/alerts/evaluate${buildQuery(params)}`, {});
|
|
78
|
+
}
|
|
79
|
+
// ── GEO 探针问题集 / 手动执行 ──
|
|
80
|
+
/** GEO 问题集列表(可按 brandProfileId/enabled 过滤) */
|
|
81
|
+
listGeoPrompts(params = {}) {
|
|
82
|
+
return this.request("GET", `/api/effect/geo/prompts${buildQuery(params)}`);
|
|
83
|
+
}
|
|
84
|
+
/** 按品牌关键词自动派生问题集(幂等) */
|
|
85
|
+
deriveGeoPrompts(data = {}) {
|
|
86
|
+
return this.request("POST", "/api/effect/geo/prompts/derive", data);
|
|
87
|
+
}
|
|
88
|
+
/** 人工新增问题 {brandProfileId, text} */
|
|
89
|
+
createGeoPrompt(data) {
|
|
90
|
+
return this.request("POST", "/api/effect/geo/prompts", data);
|
|
91
|
+
}
|
|
92
|
+
/** 改问题文本 / 启停 */
|
|
93
|
+
updateGeoPrompt(id, patch) {
|
|
94
|
+
return this.request("PUT", `/api/effect/geo/prompts/${encodeURIComponent(id)}`, patch);
|
|
95
|
+
}
|
|
96
|
+
/** 删人工问题(自动派生只能停用) */
|
|
97
|
+
deleteGeoPrompt(id) {
|
|
98
|
+
return this.request("DELETE", `/api/effect/geo/prompts/${encodeURIComponent(id)}`);
|
|
99
|
+
}
|
|
100
|
+
/** 立即执行一轮 GEO 探针 {day?}(默认昨日 UTC,同日快照) */
|
|
101
|
+
runGeoProbe(data = {}) {
|
|
102
|
+
return this.request("POST", "/api/effect/geo/run", data);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function buildQuery(params) {
|
|
2
|
+
const qs = new URLSearchParams();
|
|
3
|
+
for (const [k, v] of Object.entries(params || {})) {
|
|
4
|
+
if (v === undefined || v === null || v === "")
|
|
5
|
+
continue;
|
|
6
|
+
qs.set(k, String(v));
|
|
7
|
+
}
|
|
8
|
+
const s = qs.toString();
|
|
9
|
+
return s ? `?${s}` : "";
|
|
10
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { RequestMethod } from "../types.js";
|
|
2
|
+
import { QueryParams } from "./query.js";
|
|
3
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
4
|
+
/**
|
|
5
|
+
* SeoGeo 资源 — P-REACH 角色2 SEO/GEO 域:品牌档案 / 渠道集 / 内容矩阵 / GEO 资产。
|
|
6
|
+
* 端点走 Server API(/api/seo-geo/*),与社媒域 MCP seo_geo_* 工具同源。
|
|
7
|
+
* 列表/目录 authAny(API Key 可读),详情与写操作 authenticate(需 JWT 登录态)。
|
|
8
|
+
*/
|
|
9
|
+
export declare class SeoGeoResource {
|
|
10
|
+
private request;
|
|
11
|
+
constructor(request: RequestFn);
|
|
12
|
+
/** SEO/GEO 可收录渠道目录(siteCode/name/category/article/tags) */
|
|
13
|
+
catalog(): Promise<any>;
|
|
14
|
+
/** 品牌档案列表(可按 status/q 过滤) */
|
|
15
|
+
listBrands(params?: QueryParams): Promise<any>;
|
|
16
|
+
/** 创建品牌档案 */
|
|
17
|
+
createBrand(data: unknown): Promise<any>;
|
|
18
|
+
/** 品牌档案详情 */
|
|
19
|
+
getBrand(id: string): Promise<any>;
|
|
20
|
+
/** 更新品牌档案(部分字段) */
|
|
21
|
+
updateBrand(id: string, patch: unknown): Promise<any>;
|
|
22
|
+
/** 删除品牌档案(被矩阵引用时 409) */
|
|
23
|
+
deleteBrand(id: string): Promise<any>;
|
|
24
|
+
/** 渠道集列表(可按 status/q 过滤) */
|
|
25
|
+
listChannelSets(params?: QueryParams): Promise<any>;
|
|
26
|
+
/** 创建渠道集 {name, channels: siteCode[]} */
|
|
27
|
+
createChannelSet(data: unknown): Promise<any>;
|
|
28
|
+
/** 渠道集详情 */
|
|
29
|
+
getChannelSet(id: string): Promise<any>;
|
|
30
|
+
/** 更新渠道集(channels 全量替换) */
|
|
31
|
+
updateChannelSet(id: string, patch: unknown): Promise<any>;
|
|
32
|
+
/** 删除渠道集(被矩阵引用时 409) */
|
|
33
|
+
deleteChannelSet(id: string): Promise<any>;
|
|
34
|
+
/** 矩阵计划列表(可按 status/q 过滤) */
|
|
35
|
+
listPlans(params?: QueryParams): Promise<any>;
|
|
36
|
+
/** 创建矩阵计划(按渠道集生成任务行) */
|
|
37
|
+
createPlan(data: unknown): Promise<any>;
|
|
38
|
+
/** 矩阵详情(含任务行) */
|
|
39
|
+
getPlan(id: string): Promise<any>;
|
|
40
|
+
/** 更新矩阵(换渠道集会镜像任务行) */
|
|
41
|
+
updatePlan(id: string, patch: unknown): Promise<any>;
|
|
42
|
+
/** 任务同步(补齐渠道集新增渠道,add-only) */
|
|
43
|
+
syncPlan(id: string): Promise<any>;
|
|
44
|
+
/** 生成单任务优化草稿(打分 → LLM 改写 → 复评) */
|
|
45
|
+
draftTask(planId: string, taskId: string): Promise<any>;
|
|
46
|
+
/** 批量生成草稿 {includeFailed?} */
|
|
47
|
+
draftAll(id: string, params?: {
|
|
48
|
+
includeFailed?: boolean;
|
|
49
|
+
}): Promise<any>;
|
|
50
|
+
/** 一步执行(批量生成 + 发布){publish?} */
|
|
51
|
+
runPlan(id: string, params?: {
|
|
52
|
+
publish?: boolean;
|
|
53
|
+
}): Promise<any>;
|
|
54
|
+
/** 一键发布(ready 草稿 → 发布计划编排) */
|
|
55
|
+
publishPlan(id: string): Promise<any>;
|
|
56
|
+
/** 人工渠道发布回采 {postUrl, publishedAt?} */
|
|
57
|
+
recordPublish(taskId: string, data: unknown): Promise<any>;
|
|
58
|
+
/** 删除单任务行 */
|
|
59
|
+
deleteTask(taskId: string): Promise<any>;
|
|
60
|
+
/** 删除矩阵(级联任务) */
|
|
61
|
+
deletePlan(id: string): Promise<any>;
|
|
62
|
+
/** 生成可部署 GEO 资产(robots.txt / llms.txt / JSON-LD) */
|
|
63
|
+
geoAssets(brandProfileId: string): Promise<any>;
|
|
64
|
+
}
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { buildQuery } from "./query.js";
|
|
2
|
+
/**
|
|
3
|
+
* SeoGeo 资源 — P-REACH 角色2 SEO/GEO 域:品牌档案 / 渠道集 / 内容矩阵 / GEO 资产。
|
|
4
|
+
* 端点走 Server API(/api/seo-geo/*),与社媒域 MCP seo_geo_* 工具同源。
|
|
5
|
+
* 列表/目录 authAny(API Key 可读),详情与写操作 authenticate(需 JWT 登录态)。
|
|
6
|
+
*/
|
|
7
|
+
export class SeoGeoResource {
|
|
8
|
+
constructor(request) {
|
|
9
|
+
this.request = request;
|
|
10
|
+
}
|
|
11
|
+
// ── 渠道目录 ──
|
|
12
|
+
/** SEO/GEO 可收录渠道目录(siteCode/name/category/article/tags) */
|
|
13
|
+
catalog() {
|
|
14
|
+
return this.request("GET", "/api/seo-geo/catalog");
|
|
15
|
+
}
|
|
16
|
+
// ── 品牌档案 ──
|
|
17
|
+
/** 品牌档案列表(可按 status/q 过滤) */
|
|
18
|
+
listBrands(params = {}) {
|
|
19
|
+
return this.request("GET", `/api/seo-geo/brands${buildQuery(params)}`);
|
|
20
|
+
}
|
|
21
|
+
/** 创建品牌档案 */
|
|
22
|
+
createBrand(data) {
|
|
23
|
+
return this.request("POST", "/api/seo-geo/brands", data);
|
|
24
|
+
}
|
|
25
|
+
/** 品牌档案详情 */
|
|
26
|
+
getBrand(id) {
|
|
27
|
+
return this.request("GET", `/api/seo-geo/brands/${encodeURIComponent(id)}`);
|
|
28
|
+
}
|
|
29
|
+
/** 更新品牌档案(部分字段) */
|
|
30
|
+
updateBrand(id, patch) {
|
|
31
|
+
return this.request("PUT", `/api/seo-geo/brands/${encodeURIComponent(id)}`, patch);
|
|
32
|
+
}
|
|
33
|
+
/** 删除品牌档案(被矩阵引用时 409) */
|
|
34
|
+
deleteBrand(id) {
|
|
35
|
+
return this.request("DELETE", `/api/seo-geo/brands/${encodeURIComponent(id)}`);
|
|
36
|
+
}
|
|
37
|
+
// ── 渠道集 ──
|
|
38
|
+
/** 渠道集列表(可按 status/q 过滤) */
|
|
39
|
+
listChannelSets(params = {}) {
|
|
40
|
+
return this.request("GET", `/api/seo-geo/channel-sets${buildQuery(params)}`);
|
|
41
|
+
}
|
|
42
|
+
/** 创建渠道集 {name, channels: siteCode[]} */
|
|
43
|
+
createChannelSet(data) {
|
|
44
|
+
return this.request("POST", "/api/seo-geo/channel-sets", data);
|
|
45
|
+
}
|
|
46
|
+
/** 渠道集详情 */
|
|
47
|
+
getChannelSet(id) {
|
|
48
|
+
return this.request("GET", `/api/seo-geo/channel-sets/${encodeURIComponent(id)}`);
|
|
49
|
+
}
|
|
50
|
+
/** 更新渠道集(channels 全量替换) */
|
|
51
|
+
updateChannelSet(id, patch) {
|
|
52
|
+
return this.request("PUT", `/api/seo-geo/channel-sets/${encodeURIComponent(id)}`, patch);
|
|
53
|
+
}
|
|
54
|
+
/** 删除渠道集(被矩阵引用时 409) */
|
|
55
|
+
deleteChannelSet(id) {
|
|
56
|
+
return this.request("DELETE", `/api/seo-geo/channel-sets/${encodeURIComponent(id)}`);
|
|
57
|
+
}
|
|
58
|
+
// ── 内容矩阵 ──
|
|
59
|
+
/** 矩阵计划列表(可按 status/q 过滤) */
|
|
60
|
+
listPlans(params = {}) {
|
|
61
|
+
return this.request("GET", `/api/seo-geo/matrix${buildQuery(params)}`);
|
|
62
|
+
}
|
|
63
|
+
/** 创建矩阵计划(按渠道集生成任务行) */
|
|
64
|
+
createPlan(data) {
|
|
65
|
+
return this.request("POST", "/api/seo-geo/matrix", data);
|
|
66
|
+
}
|
|
67
|
+
/** 矩阵详情(含任务行) */
|
|
68
|
+
getPlan(id) {
|
|
69
|
+
return this.request("GET", `/api/seo-geo/matrix/${encodeURIComponent(id)}`);
|
|
70
|
+
}
|
|
71
|
+
/** 更新矩阵(换渠道集会镜像任务行) */
|
|
72
|
+
updatePlan(id, patch) {
|
|
73
|
+
return this.request("PUT", `/api/seo-geo/matrix/${encodeURIComponent(id)}`, patch);
|
|
74
|
+
}
|
|
75
|
+
/** 任务同步(补齐渠道集新增渠道,add-only) */
|
|
76
|
+
syncPlan(id) {
|
|
77
|
+
return this.request("POST", `/api/seo-geo/matrix/${encodeURIComponent(id)}/sync`, {});
|
|
78
|
+
}
|
|
79
|
+
/** 生成单任务优化草稿(打分 → LLM 改写 → 复评) */
|
|
80
|
+
draftTask(planId, taskId) {
|
|
81
|
+
return this.request("POST", `/api/seo-geo/matrix/${encodeURIComponent(planId)}/tasks/${encodeURIComponent(taskId)}/draft`, {});
|
|
82
|
+
}
|
|
83
|
+
/** 批量生成草稿 {includeFailed?} */
|
|
84
|
+
draftAll(id, params = {}) {
|
|
85
|
+
return this.request("POST", `/api/seo-geo/matrix/${encodeURIComponent(id)}/draft-all`, params);
|
|
86
|
+
}
|
|
87
|
+
/** 一步执行(批量生成 + 发布){publish?} */
|
|
88
|
+
runPlan(id, params = {}) {
|
|
89
|
+
return this.request("POST", `/api/seo-geo/matrix/${encodeURIComponent(id)}/run`, params);
|
|
90
|
+
}
|
|
91
|
+
/** 一键发布(ready 草稿 → 发布计划编排) */
|
|
92
|
+
publishPlan(id) {
|
|
93
|
+
return this.request("POST", `/api/seo-geo/matrix/${encodeURIComponent(id)}/publish`, {});
|
|
94
|
+
}
|
|
95
|
+
/** 人工渠道发布回采 {postUrl, publishedAt?} */
|
|
96
|
+
recordPublish(taskId, data) {
|
|
97
|
+
return this.request("POST", `/api/seo-geo/matrix/tasks/${encodeURIComponent(taskId)}/publish-back`, data);
|
|
98
|
+
}
|
|
99
|
+
/** 删除单任务行 */
|
|
100
|
+
deleteTask(taskId) {
|
|
101
|
+
return this.request("DELETE", `/api/seo-geo/matrix/tasks/${encodeURIComponent(taskId)}`);
|
|
102
|
+
}
|
|
103
|
+
/** 删除矩阵(级联任务) */
|
|
104
|
+
deletePlan(id) {
|
|
105
|
+
return this.request("DELETE", `/api/seo-geo/matrix/${encodeURIComponent(id)}`);
|
|
106
|
+
}
|
|
107
|
+
// ── GEO 资产 ──
|
|
108
|
+
/** 生成可部署 GEO 资产(robots.txt / llms.txt / JSON-LD) */
|
|
109
|
+
geoAssets(brandProfileId) {
|
|
110
|
+
return this.request("GET", `/api/seo-geo/geo-assets${buildQuery({ brandProfileId })}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -270,27 +270,34 @@ export interface ParamHint {
|
|
|
270
270
|
source: "user_input" | "derived" | "user_address" | "computed";
|
|
271
271
|
computeHint?: string;
|
|
272
272
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
timestamp: number;
|
|
273
|
+
/** 钱包登录 nonce(10 分钟一次性;签名对象即该 nonce 字符串本体) */
|
|
274
|
+
export interface WalletNonce {
|
|
276
275
|
nonce: string;
|
|
277
276
|
}
|
|
277
|
+
/** 钱包签名登录入参(server 契约:签名对象为 nonce) */
|
|
278
278
|
export interface WalletLoginParams {
|
|
279
|
-
|
|
280
|
-
signature: string;
|
|
281
|
-
timestamp: number;
|
|
279
|
+
wallet: string;
|
|
282
280
|
nonce: string;
|
|
281
|
+
signature: string;
|
|
282
|
+
}
|
|
283
|
+
/** 账户公开信息(server `publicAccount` 投影) */
|
|
284
|
+
export interface AuthAccount {
|
|
285
|
+
id: string;
|
|
286
|
+
email: string | null;
|
|
287
|
+
wallet: string | null;
|
|
288
|
+
mfaEnabled: boolean;
|
|
289
|
+
status: string;
|
|
283
290
|
}
|
|
291
|
+
/** 登录 / 注册 / 钱包登录成功:server 统一返回 { accessToken, refreshToken, account } */
|
|
284
292
|
export interface AuthResult {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
};
|
|
293
|
+
accessToken: string;
|
|
294
|
+
refreshToken: string;
|
|
295
|
+
account: AuthAccount;
|
|
296
|
+
}
|
|
297
|
+
/** MFA 账户未携带 mfaCode 时的响应(不签发 token,校验后重调原端点) */
|
|
298
|
+
export interface MfaRequiredResult {
|
|
299
|
+
mfaRequired: true;
|
|
300
|
+
account: AuthAccount;
|
|
294
301
|
}
|
|
295
302
|
/** 图形验证码(login/register 前置,可选):image 为 data URI,算式恒为非负结果 */
|
|
296
303
|
export interface CaptchaResponse {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reachv2/sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Reach unified REST API client library for TypeScript — crm 域(AgentApi/Project/Bot/Knowledge/Channel/Conversation/Transaction/Auth/Chat/ApiKey/LightRAG/Orchestration/ScheduledTasks/Internal/Abis/Admin)+ social 域(Content/Tts/Accounts
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Reach unified REST API client library for TypeScript — crm 域(AgentApi/Project/Bot/Knowledge/Channel/Conversation/Transaction/Auth/Chat/ApiKey/LightRAG/Orchestration/ScheduledTasks/Internal/Abis/Admin)+ social 域(Content/Tts/Accounts/Effect 效果追踪/SeoGeo SEO-GEO 矩阵/ContentRules 内容规则引擎/DataSources 数据源)+ 统一 DashboardApi(crm/social 看板)+ 统一租户成员模型(Tenants/Team/Health,G-1~G-3)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|