@attlaz/client 1.86.0 → 1.88.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.
|
@@ -12,6 +12,9 @@ export declare class CrawlJob {
|
|
|
12
12
|
requestedAt: Date | null;
|
|
13
13
|
startedAt: Date | null;
|
|
14
14
|
finishedAt: Date | null;
|
|
15
|
+
/** Progress (populated by list endpoints): total pages and how many have been processed. */
|
|
16
|
+
total: number;
|
|
17
|
+
processed: number;
|
|
15
18
|
constructor(id: string, vendorId: string);
|
|
16
19
|
static parse(raw: ApiRecord): CrawlJob;
|
|
17
20
|
}
|
|
@@ -10,6 +10,9 @@ export class CrawlJob {
|
|
|
10
10
|
requestedAt;
|
|
11
11
|
startedAt;
|
|
12
12
|
finishedAt;
|
|
13
|
+
/** Progress (populated by list endpoints): total pages and how many have been processed. */
|
|
14
|
+
total = 0;
|
|
15
|
+
processed = 0;
|
|
13
16
|
constructor(id, vendorId) {
|
|
14
17
|
this.id = id;
|
|
15
18
|
this.vendorId = vendorId;
|
|
@@ -24,6 +27,8 @@ export class CrawlJob {
|
|
|
24
27
|
job.requestedAt = raw.requested_at ? new Date(raw.requested_at) : null;
|
|
25
28
|
job.startedAt = raw.started_at ? new Date(raw.started_at) : null;
|
|
26
29
|
job.finishedAt = raw.finished_at ? new Date(raw.finished_at) : null;
|
|
30
|
+
job.total = Number(raw.total ?? 0);
|
|
31
|
+
job.processed = Number(raw.processed ?? 0);
|
|
27
32
|
return job;
|
|
28
33
|
}
|
|
29
34
|
}
|
|
@@ -10,6 +10,17 @@ export declare class CrawlJobEndpoint extends Endpoint {
|
|
|
10
10
|
create(vendorId: string): Promise<CrawlJob>;
|
|
11
11
|
/** Update a crawl job's status ('started', 'finished', 'cancelled'). */
|
|
12
12
|
updateStatus(crawlJobId: string, status: CrawlJobStatus): Promise<CrawlJob>;
|
|
13
|
+
/** A vendor's crawl jobs (newest first), each with progress (`total` / `processed`). */
|
|
14
|
+
getByVendor(vendorId: string): Promise<CrawlJob[]>;
|
|
13
15
|
/** The crawl job with this id, or null. */
|
|
14
16
|
getById(crawlJobId: string): Promise<CrawlJob | null>;
|
|
17
|
+
/** Register the pages this crawl will process (idempotent server-side). */
|
|
18
|
+
registerPages(crawlJobId: string, urls: string[]): Promise<void>;
|
|
19
|
+
/** Mark pages as crawled (fetched). */
|
|
20
|
+
markPagesCrawled(crawlJobId: string, urls: string[]): Promise<void>;
|
|
21
|
+
/** Mark pages as parsed (terminal). The crawl auto-finishes once every page is terminal. */
|
|
22
|
+
markPagesParsed(crawlJobId: string, urls: string[]): Promise<void>;
|
|
23
|
+
/** Mark pages as failed (terminal, e.g. blocked/unfetchable). */
|
|
24
|
+
markPagesFailed(crawlJobId: string, urls: string[]): Promise<void>;
|
|
25
|
+
private postUrls;
|
|
15
26
|
}
|
|
@@ -24,9 +24,36 @@ export class CrawlJobEndpoint extends Endpoint {
|
|
|
24
24
|
}
|
|
25
25
|
return job;
|
|
26
26
|
}
|
|
27
|
+
/** A vendor's crawl jobs (newest first), each with progress (`total` / `processed`). */
|
|
28
|
+
async getByVendor(vendorId) {
|
|
29
|
+
const result = await this.requestCollection('/pulse/vendors/' + vendorId + '/crawl-jobs', CrawlJob.parse);
|
|
30
|
+
return result.getData();
|
|
31
|
+
}
|
|
27
32
|
/** The crawl job with this id, or null. */
|
|
28
33
|
async getById(crawlJobId) {
|
|
29
34
|
const result = await this.requestObject('/pulse/crawl-jobs/' + crawlJobId, null, CrawlJob.parse, 'GET');
|
|
30
35
|
return result.getData();
|
|
31
36
|
}
|
|
37
|
+
/** Register the pages this crawl will process (idempotent server-side). */
|
|
38
|
+
async registerPages(crawlJobId, urls) {
|
|
39
|
+
await this.postUrls(crawlJobId, '/pages', urls);
|
|
40
|
+
}
|
|
41
|
+
/** Mark pages as crawled (fetched). */
|
|
42
|
+
async markPagesCrawled(crawlJobId, urls) {
|
|
43
|
+
await this.postUrls(crawlJobId, '/pages/crawled', urls);
|
|
44
|
+
}
|
|
45
|
+
/** Mark pages as parsed (terminal). The crawl auto-finishes once every page is terminal. */
|
|
46
|
+
async markPagesParsed(crawlJobId, urls) {
|
|
47
|
+
await this.postUrls(crawlJobId, '/pages/parsed', urls);
|
|
48
|
+
}
|
|
49
|
+
/** Mark pages as failed (terminal, e.g. blocked/unfetchable). */
|
|
50
|
+
async markPagesFailed(crawlJobId, urls) {
|
|
51
|
+
await this.postUrls(crawlJobId, '/pages/failed', urls);
|
|
52
|
+
}
|
|
53
|
+
async postUrls(crawlJobId, path, urls) {
|
|
54
|
+
if (urls.length === 0) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
await this.requestObject('/pulse/crawl-jobs/' + crawlJobId + path, { urls }, (raw) => raw, 'POST');
|
|
58
|
+
}
|
|
32
59
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "1.
|
|
1
|
+
export declare const VERSION = "1.87.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "1.
|
|
1
|
+
export const VERSION = "1.87.0";
|