@attlaz/client 1.136.0 → 1.138.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.
@@ -1,5 +1,7 @@
1
1
  import { ApiRecord } from '../../Model/ApiRecord.js';
2
2
  export type CrawlJobStatus = 'pending' | 'started' | 'cancelled' | 'stopped' | 'finished';
3
+ /** Why a crawl ended `stopped`. Mirrors apps-lib's CrawlJobStopReason. */
4
+ export type CrawlJobStopReason = 'no_currency' | 'no_parser' | 'empty_listing' | 'all_pages_failed' | 'no_pages_registered' | 'never_dispatched' | 'already_running' | 'run_failed';
3
5
  /**
4
6
  * A Market Pulse crawl job: one run of scraping a vendor. Its lifecycle (pending → started →
5
7
  * finished) drives the vendor's "last scraped" timestamp (`finishedAt`) and, on finish, triggers
@@ -27,6 +29,11 @@ export declare class CrawlJob {
27
29
  total: number;
28
30
  processed: number;
29
31
  failed: number;
32
+ /**
33
+ * Why a `stopped` crawl stopped (populated by list endpoints). Null for any other status, and for a
34
+ * crawl stopped before reasons were recorded or by a writer that gave none.
35
+ */
36
+ stopReason: CrawlJobStopReason | null;
30
37
  constructor(id: string, vendorId: string);
31
38
  static parse(raw: ApiRecord): CrawlJob;
32
39
  }
@@ -25,6 +25,11 @@ export class CrawlJob {
25
25
  total = 0;
26
26
  processed = 0;
27
27
  failed = 0;
28
+ /**
29
+ * Why a `stopped` crawl stopped (populated by list endpoints). Null for any other status, and for a
30
+ * crawl stopped before reasons were recorded or by a writer that gave none.
31
+ */
32
+ stopReason = null;
28
33
  constructor(id, vendorId) {
29
34
  this.id = id;
30
35
  this.vendorId = vendorId;
@@ -43,6 +48,7 @@ export class CrawlJob {
43
48
  job.total = Number(raw.total ?? 0);
44
49
  job.processed = Number(raw.processed ?? 0);
45
50
  job.failed = Number(raw.failed ?? 0);
51
+ job.stopReason = typeof raw.stop_reason === 'string' ? raw.stop_reason : null;
46
52
  return job;
47
53
  }
48
54
  }
@@ -13,8 +13,6 @@ export declare class MarketPositionGroup {
13
13
  comparedCount: number;
14
14
  /** Products with at least one accepted match: what can be compared at all. */
15
15
  matchedCount: number;
16
- /** @deprecated Counts by barcode alone, which is not how matching decides; use `matchedCount`. */
17
- matchableCount: number;
18
16
  /** Our price against the median competitor price, averaged; −20 is 20% cheaper. Null when none compared. */
19
17
  avgPriceVsMedianPct: number | null;
20
18
  bucketCounts: Record<PositionBucket, number>;
@@ -12,8 +12,6 @@ export class MarketPositionGroup {
12
12
  comparedCount = 0;
13
13
  /** Products with at least one accepted match: what can be compared at all. */
14
14
  matchedCount = 0;
15
- /** @deprecated Counts by barcode alone, which is not how matching decides; use `matchedCount`. */
16
- matchableCount = 0;
17
15
  /** Our price against the median competitor price, averaged; −20 is 20% cheaper. Null when none compared. */
18
16
  avgPriceVsMedianPct = null;
19
17
  bucketCounts = { very_sharp: 0, sharp: 0, market_rate: 0, expensive: 0, much_more_expensive: 0 };
@@ -23,7 +21,6 @@ export class MarketPositionGroup {
23
21
  group.productCount = Number(raw.product_count ?? 0);
24
22
  group.comparedCount = Number(raw.compared_count ?? 0);
25
23
  group.matchedCount = Number(raw.matched_count ?? 0);
26
- group.matchableCount = Number(raw.matchable_count ?? 0);
27
24
  group.avgPriceVsMedianPct = raw.avg_price_vs_median_pct === null || raw.avg_price_vs_median_pct === undefined ? null : Number(raw.avg_price_vs_median_pct);
28
25
  const buckets = raw.bucket_counts ?? {};
29
26
  for (const bucket of POSITION_BUCKETS) {
@@ -22,12 +22,6 @@ export declare class MarketPositionSummary {
22
22
  matchedCount: number;
23
23
  /** Products with suggestions waiting in Match review and no accepted match yet. */
24
24
  awaitingReviewCount: number;
25
- /** @deprecated Counts by barcode alone, which is not how matching decides; use `matchedCount`. */
26
- matchableCount: number;
27
- /** The counted competitor prices, and how many of them a crawl saw within `recentDays`. */
28
- competitorPriceCount: number;
29
- recentCompetitorPriceCount: number;
30
- recentDays: number;
31
25
  priceHistoryFrom: Date | null;
32
26
  static parse(raw: ApiRecord): MarketPositionSummary;
33
27
  }
@@ -21,12 +21,6 @@ export class MarketPositionSummary {
21
21
  matchedCount = 0;
22
22
  /** Products with suggestions waiting in Match review and no accepted match yet. */
23
23
  awaitingReviewCount = 0;
24
- /** @deprecated Counts by barcode alone, which is not how matching decides; use `matchedCount`. */
25
- matchableCount = 0;
26
- /** The counted competitor prices, and how many of them a crawl saw within `recentDays`. */
27
- competitorPriceCount = 0;
28
- recentCompetitorPriceCount = 0;
29
- recentDays = 0;
30
24
  priceHistoryFrom = null;
31
25
  static parse(raw) {
32
26
  const summary = new MarketPositionSummary();
@@ -41,10 +35,6 @@ export class MarketPositionSummary {
41
35
  summary.marketIndexByValue = raw.market_index_by_value === null || raw.market_index_by_value === undefined ? null : Number(raw.market_index_by_value);
42
36
  summary.matchedCount = Number(raw.matched_count ?? 0);
43
37
  summary.awaitingReviewCount = Number(raw.awaiting_review_count ?? 0);
44
- summary.matchableCount = Number(raw.matchable_count ?? 0);
45
- summary.competitorPriceCount = Number(raw.competitor_price_count ?? 0);
46
- summary.recentCompetitorPriceCount = Number(raw.recent_competitor_price_count ?? 0);
47
- summary.recentDays = Number(raw.recent_days ?? 0);
48
38
  summary.priceHistoryFrom = raw.price_history_from ? new Date(raw.price_history_from) : null;
49
39
  return summary;
50
40
  }
@@ -1,6 +1,6 @@
1
1
  import { CatalogId } from '../../Catalog/Model/CatalogId.js';
2
2
  import { CursorPagination } from '../../Model/Pagination/CursorPagination.js';
3
- import { CrawlJob, CrawlJobStatus } from '../Model/CrawlJob.js';
3
+ import { CrawlJob, CrawlJobStatus, CrawlJobStopReason } from '../Model/CrawlJob.js';
4
4
  import { CrawlJobPage } from '../Model/CrawlJobPage.js';
5
5
  import { CollectionResult } from '../../Model/Result/CollectionResult.js';
6
6
  import { Endpoint } from '../../Service/Endpoint.js';
@@ -18,8 +18,12 @@ export declare class CrawlJobEndpoint extends Endpoint {
18
18
  * silence about them is not evidence they are gone.
19
19
  */
20
20
  create(vendorId: string, isPartial?: boolean): Promise<CrawlJob>;
21
- /** Update a crawl job's status ('started', 'finished', 'cancelled'). */
22
- updateStatus(crawlJobId: string, status: CrawlJobStatus): Promise<CrawlJob>;
21
+ /**
22
+ * Update a crawl job's status ('started', 'finished', 'cancelled', 'stopped').
23
+ *
24
+ * @param reason Why it stopped; accepted with 'stopped' only, and shown with the crawl.
25
+ */
26
+ updateStatus(crawlJobId: string, status: CrawlJobStatus, reason?: CrawlJobStopReason | null): Promise<CrawlJob>;
23
27
  /**
24
28
  * A single vendor's crawl jobs, newest first.
25
29
  *
@@ -24,9 +24,13 @@ export class CrawlJobEndpoint extends Endpoint {
24
24
  }
25
25
  return job;
26
26
  }
27
- /** Update a crawl job's status ('started', 'finished', 'cancelled'). */
28
- async updateStatus(crawlJobId, status) {
29
- const result = await this.requestObject(path('/pulse/crawl-jobs/:crawlJobId', { crawlJobId }), { status }, CrawlJob.parse, 'PATCH');
27
+ /**
28
+ * Update a crawl job's status ('started', 'finished', 'cancelled', 'stopped').
29
+ *
30
+ * @param reason Why it stopped; accepted with 'stopped' only, and shown with the crawl.
31
+ */
32
+ async updateStatus(crawlJobId, status, reason = null) {
33
+ const result = await this.requestObject(path('/pulse/crawl-jobs/:crawlJobId', { crawlJobId }), reason === null ? { status } : { status, reason }, CrawlJob.parse, 'PATCH');
30
34
  const job = result.getData();
31
35
  if (job === null) {
32
36
  throw new Error('Unable to update crawl job: empty response');
package/dist/index.d.ts CHANGED
@@ -88,7 +88,7 @@ export { StorageType } from './Model/Storage/StorageType.js';
88
88
  export { VendorProduct } from './MarketPulse/Model/VendorProduct.js';
89
89
  export { StockStatus, parseStockStatus, stockStatusFromBoolean } from './MarketPulse/Model/StockStatus.js';
90
90
  export { VendorProductEndpoint } from './MarketPulse/Service/VendorProductEndpoint.js';
91
- export { CrawlJob, CrawlJobStatus } from './MarketPulse/Model/CrawlJob.js';
91
+ export { CrawlJob, CrawlJobStatus, CrawlJobStopReason } from './MarketPulse/Model/CrawlJob.js';
92
92
  export { CrawlJobPage, CrawlJobPageStatus } from './MarketPulse/Model/CrawlJobPage.js';
93
93
  export { CrawlJobEndpoint } from './MarketPulse/Service/CrawlJobEndpoint.js';
94
94
  export { VendorProductPriceHistoryEntry } from './MarketPulse/Model/VendorProductPriceHistoryEntry.js';
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.135.0";
1
+ export declare const VERSION = "1.137.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.135.0";
1
+ export const VERSION = "1.137.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@attlaz/client",
3
- "version": "1.136.0",
3
+ "version": "1.138.0",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",