@reachv2/sdk 0.2.0 → 0.3.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 CHANGED
@@ -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.2.0 扩展统一租户):全部 23 个资源类 + `ReachClient` 共 **136 个方法**的签名 / 端点 / 参数 / 返回类型 / 错误 / 示例,与 `sdk/src` 源码一一对应。
11
+ - **[API Reference](docs/API-REFERENCE.md)**(P2.6,v0.2.0 扩展统一租户):全部 27 个资源类 + `ReachClient` 共 **203 个资源方法**(另含 `ReachClient.setToken` / `request`)的签名 / 端点 / 参数 / 返回类型 / 错误 / 示例,与 `sdk/src` 源码一一对应。
12
12
 
13
13
  ## 安装
14
14
 
@@ -158,6 +158,15 @@ const client = new ReachClient({
158
158
  | `client.tts` | 文本转语音(synthesize/voices/history) | Server |
159
159
  | `client.accounts` | 社媒账号矩阵(list/connect) | Server |
160
160
 
161
+ ### social 域 — P-REACH(效果 / SEO-GEO / 内容规则 / 数据源,v0.2.0 新增)
162
+
163
+ | 资源 | 主要能力 | API 域 |
164
+ |------|----------|--------|
165
+ | `client.effect` | **效果追踪(EffectResource)**:指标字典、日快照、目标、汇总/ROI/归因/周报、告警、GEO 探针问题集(22 方法) | Server |
166
+ | `client.seoGeo` | **SEO/GEO 域(SeoGeoResource)**:品牌档案 / 渠道集 / 内容矩阵(草稿→发布→回采)/ GEO 资产(24 方法) | Server |
167
+ | `client.contentRules` | **内容规则引擎(ContentRulesResource)**:规则 CRUD + 发布前打分/优化 + 发布后效果/GEO 评估 + 记录趋势(12 方法) | Server |
168
+ | `client.dataSources` | **数据源适配器(DataSourcesResource)**:明细/趋势/告警/定时同步(12 方法;无创建入口,内置源只读) | Server |
169
+
161
170
  > crm 客服指标(原 `client.analytics`)与社媒运营看板(原 `client.dashboard`)已统一为 `client.dashboard`(DashboardApi);AgentX(原 `client.agentx`)与社媒 Agent 市场已统一为 `client.agents`(AgentApi)。
162
171
 
163
172
  ## 统一入口说明
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,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/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";
@@ -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,3 @@
1
+ /** 社媒域资源共用 query 构造:过滤 undefined/null/''(避免 ?module=undefined 触达后端枚举校验)。 */
2
+ export type QueryParams = Record<string, string | number | boolean | undefined | null>;
3
+ export declare function buildQuery(params?: QueryParams): string;
@@ -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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@reachv2/sdk",
3
- "version": "0.2.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)+ 统一 DashboardApi(crm/social 看板)+ 统一租户成员模型(Tenants/Team/Health,G-1~G-3)",
3
+ "version": "0.3.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/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",