@xiaohhhh1/canvas-agent 0.4.17 → 0.4.19
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.
|
@@ -50,6 +50,9 @@ export declare class FastMossIntegration {
|
|
|
50
50
|
lastCapture?: string;
|
|
51
51
|
}>;
|
|
52
52
|
close(): Promise<FastMossStatus>;
|
|
53
|
+
observations(): Promise<{
|
|
54
|
+
rows: Record<string, unknown>[];
|
|
55
|
+
}>;
|
|
53
56
|
switchAccount(): Promise<FastMossStatus>;
|
|
54
57
|
private loadRows;
|
|
55
58
|
private useLatestPage;
|
|
@@ -8,6 +8,8 @@ const FASTMOSS_HOME = "https://www.fastmoss.com/";
|
|
|
8
8
|
const FASTMOSS_SALES_RANK = "https://www.fastmoss.com/e-commerce/saleslist";
|
|
9
9
|
const MEMBERSHIP_RECHECK_MS = 5 * 60_000;
|
|
10
10
|
const PRODUCT_TABLE_TIMEOUT_MS = 45_000;
|
|
11
|
+
const PRODUCT_RANK_PAGE_SIZE = 10;
|
|
12
|
+
const PRODUCT_RANK_MAX_PAGES = 50;
|
|
11
13
|
export class FastMossIntegration {
|
|
12
14
|
context = null;
|
|
13
15
|
page = null;
|
|
@@ -171,7 +173,7 @@ export class FastMossIntegration {
|
|
|
171
173
|
const collected = new Map();
|
|
172
174
|
const pages = [];
|
|
173
175
|
let previousSignature = "";
|
|
174
|
-
for (let pageNumber = 1; pageNumber <=
|
|
176
|
+
for (let pageNumber = 1; pageNumber <= PRODUCT_RANK_MAX_PAGES; pageNumber += 1) {
|
|
175
177
|
const snapshot = await readVisibleTableSnapshot(this.page);
|
|
176
178
|
if (!snapshot.tables[0]?.rows.length || snapshot.signature === previousSignature)
|
|
177
179
|
break;
|
|
@@ -219,6 +221,10 @@ export class FastMossIntegration {
|
|
|
219
221
|
: "FastMoss 窗口已关闭;请先登录一次";
|
|
220
222
|
return this.status();
|
|
221
223
|
}
|
|
224
|
+
async observations() {
|
|
225
|
+
const rows = await this.loadRows();
|
|
226
|
+
return { rows };
|
|
227
|
+
}
|
|
222
228
|
async switchAccount() {
|
|
223
229
|
if (!this.context || !this.page || this.page.isClosed())
|
|
224
230
|
await this.start();
|
|
@@ -279,6 +285,8 @@ export class FastMossIntegration {
|
|
|
279
285
|
export function fastMossSalesRankUrl(market) {
|
|
280
286
|
const url = new URL(FASTMOSS_SALES_RANK);
|
|
281
287
|
url.searchParams.set("region", normalizeMarket(market));
|
|
288
|
+
url.searchParams.set("page", "1");
|
|
289
|
+
url.searchParams.set("pagesize", String(PRODUCT_RANK_PAGE_SIZE));
|
|
282
290
|
return url.toString();
|
|
283
291
|
}
|
|
284
292
|
function normalizeMarket(value) {
|
package/dist/server/http.js
CHANGED
|
@@ -131,6 +131,7 @@ export function startHttpServer() {
|
|
|
131
131
|
res.json({ ok: true });
|
|
132
132
|
}));
|
|
133
133
|
app.get("/agent/integrations/fastmoss/status", route(async (_req, res) => res.json({ ok: true, ...await fastmoss.inspect() })));
|
|
134
|
+
app.get("/agent/integrations/fastmoss/observations", route(async (_req, res) => res.json({ ok: true, ...await fastmoss.observations() })));
|
|
134
135
|
app.post("/agent/integrations/fastmoss/start", route(async (_req, res) => res.json({ ok: true, ...await fastmoss.start() })));
|
|
135
136
|
app.post("/agent/integrations/fastmoss/refresh", route(async (_req, res) => res.json({ ok: true, ...await fastmoss.inspect() })));
|
|
136
137
|
app.post("/agent/integrations/fastmoss/switch-account", route(async (_req, res) => res.json({ ok: true, ...await fastmoss.switchAccount() })));
|