@reachv2/sdk 0.4.0 → 0.5.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/LICENSE +201 -0
- package/NOTICE +9 -0
- package/README.md +39 -7
- package/dist/client.d.ts +9 -0
- package/dist/client.js +8 -0
- package/dist/error.js +1 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +5 -0
- package/dist/resources/accounts.d.ts +36 -2
- package/dist/resources/accounts.js +32 -1
- package/dist/resources/auth.d.ts +3 -3
- package/dist/resources/auth.js +3 -3
- package/dist/resources/billing.d.ts +142 -0
- package/dist/resources/billing.js +52 -0
- package/dist/resources/browser.d.ts +21 -0
- package/dist/resources/browser.js +13 -0
- package/dist/resources/lightrag.d.ts +10 -1
- package/dist/resources/lightrag.js +10 -1
- package/dist/resources/quota.d.ts +30 -0
- package/dist/resources/quota.js +15 -0
- package/dist/resources/seo-geo.d.ts +30 -4
- package/dist/resources/seo-geo.js +2 -2
- package/dist/resources/shared-billing.d.ts +205 -0
- package/dist/resources/shared-billing.js +67 -0
- package/dist/types.d.ts +5 -6
- package/package.json +10 -6
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { RequestMethod } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
/** 席位档位套餐(`/api/billing/plans` 返回的 shared.Plan 行) */
|
|
4
|
+
export interface BillingPlan {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
displayName?: string;
|
|
8
|
+
description?: string | null;
|
|
9
|
+
kind?: string;
|
|
10
|
+
seatCount?: number;
|
|
11
|
+
price?: number;
|
|
12
|
+
introPrice?: number | null;
|
|
13
|
+
introPeriods?: number;
|
|
14
|
+
interval?: string;
|
|
15
|
+
rail?: string;
|
|
16
|
+
llmTokensPerMonth?: number;
|
|
17
|
+
features?: unknown[];
|
|
18
|
+
active?: boolean;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
export interface BillingPlansResult {
|
|
22
|
+
plans: BillingPlan[];
|
|
23
|
+
}
|
|
24
|
+
/** 可购买 Token 包(`/api/billing/token-packs` 精简字段) */
|
|
25
|
+
export interface BillingTokenPack {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
tokens: number;
|
|
29
|
+
price: number;
|
|
30
|
+
cryptoAmount?: number;
|
|
31
|
+
sortOrder?: number;
|
|
32
|
+
active?: boolean;
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}
|
|
35
|
+
export interface BillingTokenPacksResult {
|
|
36
|
+
tokenPacks: BillingTokenPack[];
|
|
37
|
+
}
|
|
38
|
+
/** `/api/billing/prices` 的展示价格项 */
|
|
39
|
+
export interface BillingPrice {
|
|
40
|
+
id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
/** 展示用字符串,如 `$29` / `Free` */
|
|
43
|
+
price: string;
|
|
44
|
+
/** 最小货币单位(分) */
|
|
45
|
+
amount: number;
|
|
46
|
+
interval: string;
|
|
47
|
+
kind?: string;
|
|
48
|
+
seatCount?: number;
|
|
49
|
+
introPrice?: number | null;
|
|
50
|
+
introPeriods?: number;
|
|
51
|
+
features: unknown[];
|
|
52
|
+
}
|
|
53
|
+
export interface BillingPricesResult {
|
|
54
|
+
prices: Record<string, BillingPrice>;
|
|
55
|
+
}
|
|
56
|
+
/** Token 包购买结果(Stripe Checkout / 人工待开通 pending 单) */
|
|
57
|
+
export interface TokenPackCheckoutResult {
|
|
58
|
+
id?: string;
|
|
59
|
+
tenantId?: string;
|
|
60
|
+
packId?: string | null;
|
|
61
|
+
packName?: string;
|
|
62
|
+
tokens?: number;
|
|
63
|
+
amountUsd?: number;
|
|
64
|
+
paymentMethod?: string;
|
|
65
|
+
status?: string;
|
|
66
|
+
/** 支付通道未配置时为 true(单已落 pending,待运营开通) */
|
|
67
|
+
manual?: boolean;
|
|
68
|
+
paymentId?: string;
|
|
69
|
+
sessionUrl?: string;
|
|
70
|
+
rail?: string;
|
|
71
|
+
pack?: Pick<BillingTokenPack, "id" | "name" | "tokens" | "price">;
|
|
72
|
+
[key: string]: unknown;
|
|
73
|
+
}
|
|
74
|
+
/** 浏览器实例配额概览 */
|
|
75
|
+
export interface BrowserQuotaStatus {
|
|
76
|
+
/** 套餐基础实例数 */
|
|
77
|
+
base: number;
|
|
78
|
+
/** 加购实例数(有效期内 BrowserPack) */
|
|
79
|
+
pack: number;
|
|
80
|
+
total: number;
|
|
81
|
+
used: number;
|
|
82
|
+
remaining: number;
|
|
83
|
+
/** 最近一份加购包的到期时间(无加购为 null) */
|
|
84
|
+
packExpiresAt: string | null;
|
|
85
|
+
[key: string]: unknown;
|
|
86
|
+
}
|
|
87
|
+
/** 浏览器实例包购买流水(存量只读) */
|
|
88
|
+
export interface BrowserPackPurchase {
|
|
89
|
+
id: string;
|
|
90
|
+
tenantId?: string;
|
|
91
|
+
packId?: string | null;
|
|
92
|
+
packName?: string;
|
|
93
|
+
instanceCount?: number;
|
|
94
|
+
amountUsd?: number;
|
|
95
|
+
status?: string;
|
|
96
|
+
periodStart?: string | null;
|
|
97
|
+
periodEnd?: string | null;
|
|
98
|
+
createdAt?: string;
|
|
99
|
+
[key: string]: unknown;
|
|
100
|
+
}
|
|
101
|
+
export interface BrowserPackPurchasesResult {
|
|
102
|
+
purchases: BrowserPackPurchase[];
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* BillingResource — 社媒域计费(Server API `/api/billing/*`)。
|
|
106
|
+
*
|
|
107
|
+
* - 公开:`plans` / `token-packs` / `prices`(无需登录)
|
|
108
|
+
* - JWT:`token-packs/purchase`(`authenticate`)、`portal`
|
|
109
|
+
* - API Key 或 JWT(只读):`browser-packs/quota`、`browser-packs/purchases`(`authAny`)
|
|
110
|
+
*
|
|
111
|
+
* 注意:`POST /api/billing/checkout` 已退役(恒返回 410 PLATFORM_PLAN_RETIRED),未封装;
|
|
112
|
+
* 平台套餐新购走 `/api/seats`(不在 SDK 覆盖范围)。
|
|
113
|
+
*/
|
|
114
|
+
export declare class BillingResource {
|
|
115
|
+
private request;
|
|
116
|
+
constructor(request: RequestFn);
|
|
117
|
+
/** 席位档位套餐列表(`{ plans }`,active + orderBy sortOrder) */
|
|
118
|
+
listPlans(): Promise<BillingPlansResult>;
|
|
119
|
+
/** 可购买 Token 包列表(`{ tokenPacks }`) */
|
|
120
|
+
listTokenPacks(): Promise<BillingTokenPacksResult>;
|
|
121
|
+
/** 套餐展示价格(`{ prices }`,按套餐名索引) */
|
|
122
|
+
getPrices(): Promise<BillingPricesResult>;
|
|
123
|
+
/**
|
|
124
|
+
* 购买 Token 包(Stripe 一次性 Checkout)。
|
|
125
|
+
* 支付通道未配置时返回 `manual: true` 的 pending 单,待运营手动开通。
|
|
126
|
+
*/
|
|
127
|
+
purchaseTokenPack(packId: string): Promise<TokenPackCheckoutResult>;
|
|
128
|
+
/**
|
|
129
|
+
* Stripe Customer Portal 会话。
|
|
130
|
+
* 当前 Stripe SDK 未纳入服务端依赖 → 恒 503 `STRIPE_SDK_NOT_AVAILABLE`;
|
|
131
|
+
* 无有效平台订阅时 404 `No active subscription found`。
|
|
132
|
+
*/
|
|
133
|
+
getPortal(): Promise<{
|
|
134
|
+
url?: string;
|
|
135
|
+
[key: string]: unknown;
|
|
136
|
+
}>;
|
|
137
|
+
/** 我的浏览器实例配额概览(基础 / 加购 / 总计 / 已用 / 剩余) */
|
|
138
|
+
getBrowserQuota(): Promise<BrowserQuotaStatus>;
|
|
139
|
+
/** 我的浏览器实例包购买流水(最近 50 条,存量只读) */
|
|
140
|
+
listBrowserPurchases(): Promise<BrowserPackPurchasesResult>;
|
|
141
|
+
}
|
|
142
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BillingResource — 社媒域计费(Server API `/api/billing/*`)。
|
|
3
|
+
*
|
|
4
|
+
* - 公开:`plans` / `token-packs` / `prices`(无需登录)
|
|
5
|
+
* - JWT:`token-packs/purchase`(`authenticate`)、`portal`
|
|
6
|
+
* - API Key 或 JWT(只读):`browser-packs/quota`、`browser-packs/purchases`(`authAny`)
|
|
7
|
+
*
|
|
8
|
+
* 注意:`POST /api/billing/checkout` 已退役(恒返回 410 PLATFORM_PLAN_RETIRED),未封装;
|
|
9
|
+
* 平台套餐新购走 `/api/seats`(不在 SDK 覆盖范围)。
|
|
10
|
+
*/
|
|
11
|
+
export class BillingResource {
|
|
12
|
+
constructor(request) {
|
|
13
|
+
this.request = request;
|
|
14
|
+
}
|
|
15
|
+
/** 席位档位套餐列表(`{ plans }`,active + orderBy sortOrder) */
|
|
16
|
+
listPlans() {
|
|
17
|
+
return this.request("GET", "/api/billing/plans");
|
|
18
|
+
}
|
|
19
|
+
/** 可购买 Token 包列表(`{ tokenPacks }`) */
|
|
20
|
+
listTokenPacks() {
|
|
21
|
+
return this.request("GET", "/api/billing/token-packs");
|
|
22
|
+
}
|
|
23
|
+
/** 套餐展示价格(`{ prices }`,按套餐名索引) */
|
|
24
|
+
getPrices() {
|
|
25
|
+
return this.request("GET", "/api/billing/prices");
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 购买 Token 包(Stripe 一次性 Checkout)。
|
|
29
|
+
* 支付通道未配置时返回 `manual: true` 的 pending 单,待运营手动开通。
|
|
30
|
+
*/
|
|
31
|
+
purchaseTokenPack(packId) {
|
|
32
|
+
return this.request("POST", "/api/billing/token-packs/purchase", {
|
|
33
|
+
packId,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Stripe Customer Portal 会话。
|
|
38
|
+
* 当前 Stripe SDK 未纳入服务端依赖 → 恒 503 `STRIPE_SDK_NOT_AVAILABLE`;
|
|
39
|
+
* 无有效平台订阅时 404 `No active subscription found`。
|
|
40
|
+
*/
|
|
41
|
+
getPortal() {
|
|
42
|
+
return this.request("GET", "/api/billing/portal");
|
|
43
|
+
}
|
|
44
|
+
/** 我的浏览器实例配额概览(基础 / 加购 / 总计 / 已用 / 剩余) */
|
|
45
|
+
getBrowserQuota() {
|
|
46
|
+
return this.request("GET", "/api/billing/browser-packs/quota");
|
|
47
|
+
}
|
|
48
|
+
/** 我的浏览器实例包购买流水(最近 50 条,存量只读) */
|
|
49
|
+
listBrowserPurchases() {
|
|
50
|
+
return this.request("GET", "/api/billing/browser-packs/purchases");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RequestMethod } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
export interface LiveSetCookiesParams {
|
|
4
|
+
/** 在线浏览器会话 ID */
|
|
5
|
+
sessionId: string;
|
|
6
|
+
/** Cookie 头字符串(`auth_token=...; ct0=...`)或 {name,value,domain,...} 数组 */
|
|
7
|
+
cookies: string | unknown[];
|
|
8
|
+
/** 可选平台编码,用于挑选期望的 Cookie 名 */
|
|
9
|
+
platform?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Browser 资源 — 浏览器实时会话(/api/browser/live/*)。
|
|
13
|
+
* 对应 MCP 工具 browser_live_set_cookies。
|
|
14
|
+
*/
|
|
15
|
+
export declare class BrowserResource {
|
|
16
|
+
private request;
|
|
17
|
+
constructor(request: RequestFn);
|
|
18
|
+
/** 向在线会话注入粘贴的 Cookie(免扫码登录;会话轮询登录态后自动保存) */
|
|
19
|
+
setLiveCookies(params: LiveSetCookiesParams): Promise<any>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser 资源 — 浏览器实时会话(/api/browser/live/*)。
|
|
3
|
+
* 对应 MCP 工具 browser_live_set_cookies。
|
|
4
|
+
*/
|
|
5
|
+
export class BrowserResource {
|
|
6
|
+
constructor(request) {
|
|
7
|
+
this.request = request;
|
|
8
|
+
}
|
|
9
|
+
/** 向在线会话注入粘贴的 Cookie(免扫码登录;会话轮询登录态后自动保存) */
|
|
10
|
+
setLiveCookies(params) {
|
|
11
|
+
return this.request("POST", "/api/browser/live/set-cookies", params);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -3,12 +3,21 @@ type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Pro
|
|
|
3
3
|
/**
|
|
4
4
|
* LightRAG Knowledge Base management.
|
|
5
5
|
*
|
|
6
|
-
* One botId = one
|
|
6
|
+
* One botId = one namespace in the platform RAG tenant (`reach`). External apps can:
|
|
7
7
|
* - Manage API keys for direct LightRAG service access
|
|
8
8
|
* - Insert/query/delete documents in the RAG vector store
|
|
9
9
|
*
|
|
10
10
|
* Per-user isolation: pass `namespace` to scope documents/queries to a specific user.
|
|
11
11
|
* Defaults to botId (shared knowledge).
|
|
12
|
+
*
|
|
13
|
+
* namespace 必须限定在 Bot 自有空间(2026-10-24 起网关强校验):
|
|
14
|
+
* - `botId`(默认,Bot 共享知识库)
|
|
15
|
+
* - `${botId}:<suffix>`(按用户/会话隔离的子空间)
|
|
16
|
+
* - 查询额外允许平台只读 `market` / `onchain`;其他值一律 403。
|
|
17
|
+
*
|
|
18
|
+
* Platform shared namespaces: Keel RAG 侧维护共享 namespace 白名单(默认 `market` / `onchain`,
|
|
19
|
+
* 用于跨租户只读的行情 / 链上知识)。查询时可直接作为 `namespace` 传入;
|
|
20
|
+
* 写入(insertDocument / insertDocuments)到这两个 namespace 会被 Keel 以只读拒绝。
|
|
12
21
|
*/
|
|
13
22
|
export declare class LightRAGResource {
|
|
14
23
|
private request;
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* LightRAG Knowledge Base management.
|
|
3
3
|
*
|
|
4
|
-
* One botId = one
|
|
4
|
+
* One botId = one namespace in the platform RAG tenant (`reach`). External apps can:
|
|
5
5
|
* - Manage API keys for direct LightRAG service access
|
|
6
6
|
* - Insert/query/delete documents in the RAG vector store
|
|
7
7
|
*
|
|
8
8
|
* Per-user isolation: pass `namespace` to scope documents/queries to a specific user.
|
|
9
9
|
* Defaults to botId (shared knowledge).
|
|
10
|
+
*
|
|
11
|
+
* namespace 必须限定在 Bot 自有空间(2026-10-24 起网关强校验):
|
|
12
|
+
* - `botId`(默认,Bot 共享知识库)
|
|
13
|
+
* - `${botId}:<suffix>`(按用户/会话隔离的子空间)
|
|
14
|
+
* - 查询额外允许平台只读 `market` / `onchain`;其他值一律 403。
|
|
15
|
+
*
|
|
16
|
+
* Platform shared namespaces: Keel RAG 侧维护共享 namespace 白名单(默认 `market` / `onchain`,
|
|
17
|
+
* 用于跨租户只读的行情 / 链上知识)。查询时可直接作为 `namespace` 传入;
|
|
18
|
+
* 写入(insertDocument / insertDocuments)到这两个 namespace 会被 Keel 以只读拒绝。
|
|
10
19
|
*/
|
|
11
20
|
export class LightRAGResource {
|
|
12
21
|
constructor(request) {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { RequestMethod } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
/** 单资源配额项 */
|
|
4
|
+
export interface QuotaEntry {
|
|
5
|
+
/** 本月额度(0 = 未配置/不限) */
|
|
6
|
+
limit: number;
|
|
7
|
+
used: number;
|
|
8
|
+
remaining: number;
|
|
9
|
+
allowed: boolean;
|
|
10
|
+
}
|
|
11
|
+
/** `/api/quota/summary` 的输出 key(前端契约) */
|
|
12
|
+
export type QuotaResourceKey = "copywriting" | "tts" | "video" | "poster";
|
|
13
|
+
export interface QuotaSummaryResult {
|
|
14
|
+
/** 当前生效套餐名(无套餐时为 free) */
|
|
15
|
+
plan: string;
|
|
16
|
+
quotas: Record<QuotaResourceKey, QuotaEntry>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* QuotaResource — 社媒域本月配额(Server API `/api/quota/*`)。
|
|
20
|
+
*
|
|
21
|
+
* `GET /api/quota/summary` 支持 API Key 或 JWT(`authAny`),按登录主体所属租户统计。
|
|
22
|
+
* 注意:与网关侧 `dashboard.quota()`(`/api/v1/quota`,crm 域)不是同一端点。
|
|
23
|
+
*/
|
|
24
|
+
export declare class QuotaResource {
|
|
25
|
+
private request;
|
|
26
|
+
constructor(request: RequestFn);
|
|
27
|
+
/** 本月各资源配额用量(copywriting / tts / video / poster) */
|
|
28
|
+
summary(): Promise<QuotaSummaryResult>;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* QuotaResource — 社媒域本月配额(Server API `/api/quota/*`)。
|
|
3
|
+
*
|
|
4
|
+
* `GET /api/quota/summary` 支持 API Key 或 JWT(`authAny`),按登录主体所属租户统计。
|
|
5
|
+
* 注意:与网关侧 `dashboard.quota()`(`/api/v1/quota`,crm 域)不是同一端点。
|
|
6
|
+
*/
|
|
7
|
+
export class QuotaResource {
|
|
8
|
+
constructor(request) {
|
|
9
|
+
this.request = request;
|
|
10
|
+
}
|
|
11
|
+
/** 本月各资源配额用量(copywriting / tts / video / poster) */
|
|
12
|
+
summary() {
|
|
13
|
+
return this.request("GET", "/api/quota/summary");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
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
|
+
/** 业务类型(P11.7b):决定生成哪套行业化 JSON-LD 模板;必须显式选择,不做推断 */
|
|
5
|
+
export type BrandBusinessType = "organization" | "local_business" | "software_saas" | "product_ecommerce" | "website";
|
|
6
|
+
/** 品牌档案创建入参(businessInfo 结构随 businessType 变化) */
|
|
7
|
+
export interface BrandProfileInput {
|
|
8
|
+
name: string;
|
|
9
|
+
slogan?: string;
|
|
10
|
+
description?: string;
|
|
11
|
+
keywords?: string[];
|
|
12
|
+
competitors?: string[];
|
|
13
|
+
homepage?: string;
|
|
14
|
+
author?: string;
|
|
15
|
+
socialLinks?: Record<string, string>;
|
|
16
|
+
styleGuide?: string;
|
|
17
|
+
/** 缺省 organization */
|
|
18
|
+
businessType?: BrandBusinessType;
|
|
19
|
+
/**
|
|
20
|
+
* 行业化结构化资料;缺失必填项允许保存(该模板不会生成),
|
|
21
|
+
* 非法值 / 未知字段返回 400 INVALID_INPUT。
|
|
22
|
+
*/
|
|
23
|
+
businessInfo?: Record<string, unknown>;
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/** 品牌档案更新入参(部分字段) */
|
|
27
|
+
export type BrandProfilePatch = Partial<BrandProfileInput> & {
|
|
28
|
+
status?: "active" | "archived";
|
|
29
|
+
};
|
|
4
30
|
/**
|
|
5
31
|
* SeoGeo 资源 — P-REACH 角色2 SEO/GEO 域:品牌档案 / 渠道集 / 内容矩阵 / GEO 资产。
|
|
6
32
|
* 端点走 Server API(/api/seo-geo/*),与社媒域 MCP seo_geo_* 工具同源。
|
|
@@ -13,12 +39,12 @@ export declare class SeoGeoResource {
|
|
|
13
39
|
catalog(): Promise<any>;
|
|
14
40
|
/** 品牌档案列表(可按 status/q 过滤) */
|
|
15
41
|
listBrands(params?: QueryParams): Promise<any>;
|
|
16
|
-
/**
|
|
17
|
-
createBrand(data:
|
|
42
|
+
/** 创建品牌档案(businessType / businessInfo 决定行业化 JSON-LD 模板) */
|
|
43
|
+
createBrand(data: BrandProfileInput): Promise<any>;
|
|
18
44
|
/** 品牌档案详情 */
|
|
19
45
|
getBrand(id: string): Promise<any>;
|
|
20
|
-
/**
|
|
21
|
-
updateBrand(id: string, patch:
|
|
46
|
+
/** 更新品牌档案(部分字段);换 businessType 未带 businessInfo 时旧资料会重置 */
|
|
47
|
+
updateBrand(id: string, patch: BrandProfilePatch): Promise<any>;
|
|
22
48
|
/** 删除品牌档案(被矩阵引用时 409) */
|
|
23
49
|
deleteBrand(id: string): Promise<any>;
|
|
24
50
|
/** 渠道集列表(可按 status/q 过滤) */
|
|
@@ -18,7 +18,7 @@ export class SeoGeoResource {
|
|
|
18
18
|
listBrands(params = {}) {
|
|
19
19
|
return this.request("GET", `/api/seo-geo/brands${buildQuery(params)}`);
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
21
|
+
/** 创建品牌档案(businessType / businessInfo 决定行业化 JSON-LD 模板) */
|
|
22
22
|
createBrand(data) {
|
|
23
23
|
return this.request("POST", "/api/seo-geo/brands", data);
|
|
24
24
|
}
|
|
@@ -26,7 +26,7 @@ export class SeoGeoResource {
|
|
|
26
26
|
getBrand(id) {
|
|
27
27
|
return this.request("GET", `/api/seo-geo/brands/${encodeURIComponent(id)}`);
|
|
28
28
|
}
|
|
29
|
-
/**
|
|
29
|
+
/** 更新品牌档案(部分字段);换 businessType 未带 businessInfo 时旧资料会重置 */
|
|
30
30
|
updateBrand(id, patch) {
|
|
31
31
|
return this.request("PUT", `/api/seo-geo/brands/${encodeURIComponent(id)}`, patch);
|
|
32
32
|
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { RequestMethod } from "../types.js";
|
|
2
|
+
type RequestFn = <T>(method: RequestMethod, path: string, body?: unknown) => Promise<T>;
|
|
3
|
+
/** 订阅关联的套餐摘要 */
|
|
4
|
+
export interface SharedSubscriptionPlanRef {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
displayName?: string;
|
|
8
|
+
llmTokensPerMonth?: number;
|
|
9
|
+
}
|
|
10
|
+
/** 平台/席位订阅行(`GET /api/shared/billing/subscriptions`) */
|
|
11
|
+
export interface SharedSubscription {
|
|
12
|
+
id: string;
|
|
13
|
+
tenantId: string;
|
|
14
|
+
planId?: string | null;
|
|
15
|
+
planName: string;
|
|
16
|
+
scope?: "platform" | "seat" | string;
|
|
17
|
+
seatNo?: number | null;
|
|
18
|
+
agentKey?: string;
|
|
19
|
+
status?: string;
|
|
20
|
+
rail?: string;
|
|
21
|
+
autoRenew?: boolean;
|
|
22
|
+
currentPeriodStart?: string | null;
|
|
23
|
+
currentPeriodEnd?: string | null;
|
|
24
|
+
amountUsd?: number | null;
|
|
25
|
+
plan?: SharedSubscriptionPlanRef;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
/** 单资源配额(`/subscriptions/current` → quota.resources) */
|
|
29
|
+
export interface SubscriptionQuotaResource {
|
|
30
|
+
quota: number;
|
|
31
|
+
used: number;
|
|
32
|
+
remaining: number | null;
|
|
33
|
+
}
|
|
34
|
+
/** 当前订阅 + 本月用量 + 统一 token 池 */
|
|
35
|
+
export interface SubscriptionUsage {
|
|
36
|
+
subscription: SharedSubscription | null;
|
|
37
|
+
quota: null | {
|
|
38
|
+
plan: {
|
|
39
|
+
name: string;
|
|
40
|
+
llmTokensPerMonth: number;
|
|
41
|
+
};
|
|
42
|
+
usage: Record<string, {
|
|
43
|
+
quantity: number;
|
|
44
|
+
tokensUsed: number;
|
|
45
|
+
}>;
|
|
46
|
+
resources: Record<string, SubscriptionQuotaResource>;
|
|
47
|
+
tokensUsedThisMonth: number;
|
|
48
|
+
tokensRemaining: number;
|
|
49
|
+
seats: {
|
|
50
|
+
active: number;
|
|
51
|
+
monthlyQuota: number;
|
|
52
|
+
tokenBalance: number;
|
|
53
|
+
pool: number;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export interface RecordUsageParams {
|
|
58
|
+
tenantId: string;
|
|
59
|
+
/** 资源类型,如 `llm_tokens` / `content:generate` / `tts:synthesize` */
|
|
60
|
+
resourceType: string;
|
|
61
|
+
quantity?: number;
|
|
62
|
+
tokensUsed?: number;
|
|
63
|
+
metadata?: Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
export interface UsageRecordResult {
|
|
66
|
+
id: string;
|
|
67
|
+
tenantId: string;
|
|
68
|
+
accountId?: string | null;
|
|
69
|
+
resourceType: string;
|
|
70
|
+
quantity: number;
|
|
71
|
+
tokensUsed?: number | null;
|
|
72
|
+
metadata?: Record<string, unknown>;
|
|
73
|
+
createdAt?: string;
|
|
74
|
+
[key: string]: unknown;
|
|
75
|
+
}
|
|
76
|
+
export interface SharedTokenPackPurchaseParams {
|
|
77
|
+
tenantId: string;
|
|
78
|
+
packId: string;
|
|
79
|
+
successUrl?: string;
|
|
80
|
+
cancelUrl?: string;
|
|
81
|
+
/** 用站内推广余额全额抵扣本人自购 */
|
|
82
|
+
usePartnerBalance?: boolean;
|
|
83
|
+
}
|
|
84
|
+
export interface SharedTokenPackPurchaseResult {
|
|
85
|
+
id?: string;
|
|
86
|
+
tenantId?: string;
|
|
87
|
+
packId?: string | null;
|
|
88
|
+
packName?: string;
|
|
89
|
+
tokens?: number;
|
|
90
|
+
amountUsd?: number;
|
|
91
|
+
paymentMethod?: string;
|
|
92
|
+
status?: string;
|
|
93
|
+
/** 支付通道未配置时为 true(pending 单待运营开通) */
|
|
94
|
+
manual?: boolean;
|
|
95
|
+
sessionUrl?: string;
|
|
96
|
+
paymentId?: string;
|
|
97
|
+
remark?: string;
|
|
98
|
+
[key: string]: unknown;
|
|
99
|
+
}
|
|
100
|
+
/** 已开放的加密收款通道(`{ enabled, chains }`) */
|
|
101
|
+
export interface CryptoMethodsResult {
|
|
102
|
+
enabled: boolean;
|
|
103
|
+
chains: Array<Record<string, unknown>>;
|
|
104
|
+
}
|
|
105
|
+
export interface CryptoOrderParams {
|
|
106
|
+
tenantId: string;
|
|
107
|
+
/** 商品类型:plan / seat / seat_add / token_pack / browser_pack */
|
|
108
|
+
kind: string;
|
|
109
|
+
targetId: string;
|
|
110
|
+
chain: string;
|
|
111
|
+
asset: string;
|
|
112
|
+
payerWallet?: string;
|
|
113
|
+
seatCount?: number;
|
|
114
|
+
taxCountry?: string;
|
|
115
|
+
}
|
|
116
|
+
/** 加密订单对外视图(不含 enginePaymentId / receipt 原文) */
|
|
117
|
+
export interface CryptoOrder {
|
|
118
|
+
orderId: string;
|
|
119
|
+
kind: string;
|
|
120
|
+
targetId: string;
|
|
121
|
+
targetName?: string;
|
|
122
|
+
chain: string;
|
|
123
|
+
chainId?: number | string;
|
|
124
|
+
assetSymbol: string;
|
|
125
|
+
assetAddress?: string;
|
|
126
|
+
decimals?: number;
|
|
127
|
+
payTo?: string;
|
|
128
|
+
amountWei?: string;
|
|
129
|
+
amountDisplay?: string;
|
|
130
|
+
amountUsd?: number;
|
|
131
|
+
seatCount?: number;
|
|
132
|
+
seatKind?: string | null;
|
|
133
|
+
periodStart?: string | null;
|
|
134
|
+
periodEnd?: string | null;
|
|
135
|
+
tax?: {
|
|
136
|
+
country: string | null;
|
|
137
|
+
rate: number;
|
|
138
|
+
amount: number;
|
|
139
|
+
inclusive: boolean;
|
|
140
|
+
};
|
|
141
|
+
pspFee?: number;
|
|
142
|
+
reserveAmount?: number;
|
|
143
|
+
netAmount?: number;
|
|
144
|
+
status: string;
|
|
145
|
+
txHash?: string | null;
|
|
146
|
+
creditedWei?: string | null;
|
|
147
|
+
expiresAt?: string;
|
|
148
|
+
createdAt?: string;
|
|
149
|
+
/** confirm 时订单已支付 */
|
|
150
|
+
alreadyPaid?: boolean;
|
|
151
|
+
/** confirm 时本次生效结果 */
|
|
152
|
+
activated?: unknown;
|
|
153
|
+
duplicate?: boolean;
|
|
154
|
+
[key: string]: unknown;
|
|
155
|
+
}
|
|
156
|
+
export interface CryptoOrderListResult {
|
|
157
|
+
orders: CryptoOrder[];
|
|
158
|
+
}
|
|
159
|
+
export interface CryptoOrderConfirmParams {
|
|
160
|
+
tenantId: string;
|
|
161
|
+
txHash: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* SharedBillingResource — 统一计费(Server API `/api/shared/billing/*`)。
|
|
165
|
+
*
|
|
166
|
+
* 鉴权:订阅 / 用量 / 加密收款端点均要求 **账户 JWT**(`requireAuth`)+ 租户成员
|
|
167
|
+
* (`tenantId` 显式传参,服务端用登录账号校验成员身份);`plans` / `token-packs` /
|
|
168
|
+
* `crypto/methods` 公开。
|
|
169
|
+
*
|
|
170
|
+
* 未封装:
|
|
171
|
+
* - `POST /subscriptions`(已退役,恒 410 PLATFORM_PLAN_RETIRED;新购走 `/api/seats`)
|
|
172
|
+
* - `POST /webhook` / `POST /payments-events`(Stripe/引擎回调,验签即认证,不属于 SDK 调用面)
|
|
173
|
+
*/
|
|
174
|
+
export declare class SharedBillingResource {
|
|
175
|
+
private request;
|
|
176
|
+
constructor(request: RequestFn);
|
|
177
|
+
/** 席位档位套餐列表(**裸数组**,与 `/api/billing/plans` 的 `{ plans }` 不同) */
|
|
178
|
+
listPlans(): Promise<Array<Record<string, unknown>>>;
|
|
179
|
+
/** 可购买 Token 包列表(**裸数组**,含 cryptoAmount / price 等全字段) */
|
|
180
|
+
listTokenPacks(): Promise<Array<Record<string, unknown>>>;
|
|
181
|
+
/** 租户平台订阅列表(含 plan 摘要,按创建时间倒序) */
|
|
182
|
+
listSubscriptions(tenantId: string): Promise<SharedSubscription[]>;
|
|
183
|
+
/** 当前订阅 + 本月用量 + 分资源配额 + 席位/token 池(无套餐且无席位时 subscription/quota 为 null) */
|
|
184
|
+
getCurrentSubscription(tenantId: string): Promise<SubscriptionUsage>;
|
|
185
|
+
/** 记录用量(统一账本;`llm_tokens` 的 token 数落在 quantity) */
|
|
186
|
+
recordUsage(params: RecordUsageParams): Promise<UsageRecordResult>;
|
|
187
|
+
/**
|
|
188
|
+
* 购买 Token 包(fiat Stripe Checkout;渠道未配置时落 pending 单并返回 `manual: true`)。
|
|
189
|
+
* `usePartnerBalance: true` 时用推广余额全额抵扣,成功即 completed。
|
|
190
|
+
*/
|
|
191
|
+
purchaseTokenPack(params: SharedTokenPackPurchaseParams): Promise<SharedTokenPackPurchaseResult>;
|
|
192
|
+
/** 已开放的加密收款通道(链 + 稳定币;未开放返回 `enabled: false`) */
|
|
193
|
+
listCryptoMethods(): Promise<CryptoMethodsResult>;
|
|
194
|
+
/** 创建加密订单(返回 payTo / amountWei / 过期时间,用户链上转账后用返回的 orderId confirm) */
|
|
195
|
+
createCryptoOrder(params: CryptoOrderParams): Promise<CryptoOrder>;
|
|
196
|
+
/** 我的加密订单列表(读取时惰性把超时 pending 单置 expired) */
|
|
197
|
+
listCryptoOrders(tenantId: string): Promise<CryptoOrderListResult>;
|
|
198
|
+
/** 加密订单详情 */
|
|
199
|
+
getCryptoOrder(orderId: string, tenantId: string): Promise<CryptoOrder>;
|
|
200
|
+
/** 取消待付款订单(仅 pending/expired 可取消,已支付不可) */
|
|
201
|
+
cancelCryptoOrder(orderId: string, tenantId: string): Promise<CryptoOrder>;
|
|
202
|
+
/** 提交链上 txHash 换取引擎回执并生效 */
|
|
203
|
+
confirmCryptoOrder(orderId: string, params: CryptoOrderConfirmParams): Promise<CryptoOrder>;
|
|
204
|
+
}
|
|
205
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SharedBillingResource — 统一计费(Server API `/api/shared/billing/*`)。
|
|
3
|
+
*
|
|
4
|
+
* 鉴权:订阅 / 用量 / 加密收款端点均要求 **账户 JWT**(`requireAuth`)+ 租户成员
|
|
5
|
+
* (`tenantId` 显式传参,服务端用登录账号校验成员身份);`plans` / `token-packs` /
|
|
6
|
+
* `crypto/methods` 公开。
|
|
7
|
+
*
|
|
8
|
+
* 未封装:
|
|
9
|
+
* - `POST /subscriptions`(已退役,恒 410 PLATFORM_PLAN_RETIRED;新购走 `/api/seats`)
|
|
10
|
+
* - `POST /webhook` / `POST /payments-events`(Stripe/引擎回调,验签即认证,不属于 SDK 调用面)
|
|
11
|
+
*/
|
|
12
|
+
export class SharedBillingResource {
|
|
13
|
+
constructor(request) {
|
|
14
|
+
this.request = request;
|
|
15
|
+
}
|
|
16
|
+
/** 席位档位套餐列表(**裸数组**,与 `/api/billing/plans` 的 `{ plans }` 不同) */
|
|
17
|
+
listPlans() {
|
|
18
|
+
return this.request("GET", "/api/shared/billing/plans");
|
|
19
|
+
}
|
|
20
|
+
/** 可购买 Token 包列表(**裸数组**,含 cryptoAmount / price 等全字段) */
|
|
21
|
+
listTokenPacks() {
|
|
22
|
+
return this.request("GET", "/api/shared/billing/token-packs");
|
|
23
|
+
}
|
|
24
|
+
/** 租户平台订阅列表(含 plan 摘要,按创建时间倒序) */
|
|
25
|
+
listSubscriptions(tenantId) {
|
|
26
|
+
return this.request("GET", `/api/shared/billing/subscriptions?tenantId=${encodeURIComponent(tenantId)}`);
|
|
27
|
+
}
|
|
28
|
+
/** 当前订阅 + 本月用量 + 分资源配额 + 席位/token 池(无套餐且无席位时 subscription/quota 为 null) */
|
|
29
|
+
getCurrentSubscription(tenantId) {
|
|
30
|
+
return this.request("GET", `/api/shared/billing/subscriptions/current?tenantId=${encodeURIComponent(tenantId)}`);
|
|
31
|
+
}
|
|
32
|
+
/** 记录用量(统一账本;`llm_tokens` 的 token 数落在 quantity) */
|
|
33
|
+
recordUsage(params) {
|
|
34
|
+
return this.request("POST", "/api/shared/billing/usage", params);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 购买 Token 包(fiat Stripe Checkout;渠道未配置时落 pending 单并返回 `manual: true`)。
|
|
38
|
+
* `usePartnerBalance: true` 时用推广余额全额抵扣,成功即 completed。
|
|
39
|
+
*/
|
|
40
|
+
purchaseTokenPack(params) {
|
|
41
|
+
return this.request("POST", "/api/shared/billing/token-packs/purchase", params);
|
|
42
|
+
}
|
|
43
|
+
/** 已开放的加密收款通道(链 + 稳定币;未开放返回 `enabled: false`) */
|
|
44
|
+
listCryptoMethods() {
|
|
45
|
+
return this.request("GET", "/api/shared/billing/crypto/methods");
|
|
46
|
+
}
|
|
47
|
+
/** 创建加密订单(返回 payTo / amountWei / 过期时间,用户链上转账后用返回的 orderId confirm) */
|
|
48
|
+
createCryptoOrder(params) {
|
|
49
|
+
return this.request("POST", "/api/shared/billing/crypto/orders", params);
|
|
50
|
+
}
|
|
51
|
+
/** 我的加密订单列表(读取时惰性把超时 pending 单置 expired) */
|
|
52
|
+
listCryptoOrders(tenantId) {
|
|
53
|
+
return this.request("GET", `/api/shared/billing/crypto/orders?tenantId=${encodeURIComponent(tenantId)}`);
|
|
54
|
+
}
|
|
55
|
+
/** 加密订单详情 */
|
|
56
|
+
getCryptoOrder(orderId, tenantId) {
|
|
57
|
+
return this.request("GET", `/api/shared/billing/crypto/orders/${encodeURIComponent(orderId)}?tenantId=${encodeURIComponent(tenantId)}`);
|
|
58
|
+
}
|
|
59
|
+
/** 取消待付款订单(仅 pending/expired 可取消,已支付不可) */
|
|
60
|
+
cancelCryptoOrder(orderId, tenantId) {
|
|
61
|
+
return this.request("POST", `/api/shared/billing/crypto/orders/${encodeURIComponent(orderId)}/cancel`, { tenantId });
|
|
62
|
+
}
|
|
63
|
+
/** 提交链上 txHash 换取引擎回执并生效 */
|
|
64
|
+
confirmCryptoOrder(orderId, params) {
|
|
65
|
+
return this.request("POST", `/api/shared/billing/crypto/orders/${encodeURIComponent(orderId)}/confirm`, params);
|
|
66
|
+
}
|
|
67
|
+
}
|