@attlaz/client 1.130.0 → 1.131.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.
@@ -17,6 +17,8 @@ export declare class Competitor {
17
17
  type: string | null;
18
18
  /** ISO 4217 code this storefront quotes prices in. */
19
19
  currency: string | null;
20
+ /** Lowercase `#rrggbb` for this competitor's avatar and chart line; null = none chosen. */
21
+ color: string | null;
20
22
  matchCount: number;
21
23
  productCount: number;
22
24
  priceIndex: number;
@@ -16,6 +16,8 @@ export class Competitor {
16
16
  type = null;
17
17
  /** ISO 4217 code this storefront quotes prices in. */
18
18
  currency = null;
19
+ /** Lowercase `#rrggbb` for this competitor's avatar and chart line; null = none chosen. */
20
+ color = null;
19
21
  matchCount = 0;
20
22
  productCount = 0;
21
23
  priceIndex = 0;
@@ -33,6 +35,7 @@ export class Competitor {
33
35
  competitor.icon = raw.icon ?? null;
34
36
  competitor.type = raw.type ?? null;
35
37
  competitor.currency = raw.currency ?? null;
38
+ competitor.color = raw.color ?? null;
36
39
  competitor.matchCount = Number(raw.match_count ?? 0);
37
40
  competitor.productCount = Number(raw.product_count ?? 0);
38
41
  competitor.priceIndex = Number(raw.price_index ?? 0);
@@ -0,0 +1,20 @@
1
+ import { ApiRecord } from '../../Model/ApiRecord.js';
2
+ import { PositionBucket } from './PositionBucket.js';
3
+ /**
4
+ * One brand or category against the market — `/pulse/catalogs/:catalogId/market-positions/aggregate`:
5
+ * how much of it can be compared, and where the compared products stand.
6
+ */
7
+ export declare class MarketPositionGroup {
8
+ /** The brand or category; null for products without one. */
9
+ groupValue: string | null;
10
+ /** Every product in the group with a stored position, compared with a competitor or not. */
11
+ productCount: number;
12
+ /** Of those, the ones with at least one counted competitor; the average and buckets cover only these. */
13
+ comparedCount: number;
14
+ /** Active products whose barcode a tracked competitor also sells: what could be compared at all. */
15
+ matchableCount: number;
16
+ /** Our price against the median competitor price, averaged; −20 is 20% cheaper. Null when none compared. */
17
+ avgPriceVsMedianPct: number | null;
18
+ bucketCounts: Record<PositionBucket, number>;
19
+ static parse(raw: ApiRecord): MarketPositionGroup;
20
+ }
@@ -0,0 +1,31 @@
1
+ import { POSITION_BUCKETS } from './PositionBucket.js';
2
+ /**
3
+ * One brand or category against the market — `/pulse/catalogs/:catalogId/market-positions/aggregate`:
4
+ * how much of it can be compared, and where the compared products stand.
5
+ */
6
+ export class MarketPositionGroup {
7
+ /** The brand or category; null for products without one. */
8
+ groupValue = null;
9
+ /** Every product in the group with a stored position, compared with a competitor or not. */
10
+ productCount = 0;
11
+ /** Of those, the ones with at least one counted competitor; the average and buckets cover only these. */
12
+ comparedCount = 0;
13
+ /** Active products whose barcode a tracked competitor also sells: what could be compared at all. */
14
+ matchableCount = 0;
15
+ /** Our price against the median competitor price, averaged; −20 is 20% cheaper. Null when none compared. */
16
+ avgPriceVsMedianPct = null;
17
+ bucketCounts = { very_sharp: 0, sharp: 0, market_rate: 0, expensive: 0, much_more_expensive: 0 };
18
+ static parse(raw) {
19
+ const group = new MarketPositionGroup();
20
+ group.groupValue = raw.group_value ?? null;
21
+ group.productCount = Number(raw.product_count ?? 0);
22
+ group.comparedCount = Number(raw.compared_count ?? 0);
23
+ group.matchableCount = Number(raw.matchable_count ?? 0);
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);
25
+ const buckets = raw.bucket_counts ?? {};
26
+ for (const bucket of POSITION_BUCKETS) {
27
+ group.bucketCounts[bucket] = Number(buckets[bucket] ?? 0);
28
+ }
29
+ return group;
30
+ }
31
+ }
@@ -2,7 +2,7 @@ import { ApiRecord } from '../../Model/ApiRecord.js';
2
2
  import { PositionBucket } from './PositionBucket.js';
3
3
  /**
4
4
  * The catalog against the market — `/pulse/catalogs/:catalogId/market-positions/summary`: how many
5
- * products can be compared at all, where the compared ones stand, and how old the competitor prices
5
+ * products can be compared at all, where the compared ones stand, and how current the competitor prices
6
6
  * behind it are.
7
7
  */
8
8
  export declare class MarketPositionSummary {
@@ -11,8 +11,16 @@ export declare class MarketPositionSummary {
11
11
  comparedCount: number;
12
12
  bucketCounts: Record<PositionBucket, number>;
13
13
  computedAt: Date | null;
14
- /** When the counted competitor products were last seen by a crawl: the age of the prices compared. */
15
- pricesSeenFrom: Date | null;
16
- pricesSeenTo: Date | null;
14
+ /** Our price ÷ the median competitor price × 100, averaged over the compared products. 100 = equal. */
15
+ marketIndex: number | null;
16
+ /** By value: the sum of our prices ÷ the sum of the median competitor prices × 100. */
17
+ marketIndexByValue: number | null;
18
+ /** Active products whose barcode a tracked competitor also sells: the ones that can be compared. */
19
+ matchableCount: number;
20
+ /** The counted competitor prices, and how many of them a crawl saw within `recentDays`. */
21
+ competitorPriceCount: number;
22
+ recentCompetitorPriceCount: number;
23
+ recentDays: number;
24
+ priceHistoryFrom: Date | null;
17
25
  static parse(raw: ApiRecord): MarketPositionSummary;
18
26
  }
@@ -1,7 +1,7 @@
1
1
  import { POSITION_BUCKETS } from './PositionBucket.js';
2
2
  /**
3
3
  * The catalog against the market — `/pulse/catalogs/:catalogId/market-positions/summary`: how many
4
- * products can be compared at all, where the compared ones stand, and how old the competitor prices
4
+ * products can be compared at all, where the compared ones stand, and how current the competitor prices
5
5
  * behind it are.
6
6
  */
7
7
  export class MarketPositionSummary {
@@ -10,9 +10,17 @@ export class MarketPositionSummary {
10
10
  comparedCount = 0;
11
11
  bucketCounts = { very_sharp: 0, sharp: 0, market_rate: 0, expensive: 0, much_more_expensive: 0 };
12
12
  computedAt = null;
13
- /** When the counted competitor products were last seen by a crawl: the age of the prices compared. */
14
- pricesSeenFrom = null;
15
- pricesSeenTo = null;
13
+ /** Our price ÷ the median competitor price × 100, averaged over the compared products. 100 = equal. */
14
+ marketIndex = null;
15
+ /** By value: the sum of our prices ÷ the sum of the median competitor prices × 100. */
16
+ marketIndexByValue = null;
17
+ /** Active products whose barcode a tracked competitor also sells: the ones that can be compared. */
18
+ matchableCount = 0;
19
+ /** The counted competitor prices, and how many of them a crawl saw within `recentDays`. */
20
+ competitorPriceCount = 0;
21
+ recentCompetitorPriceCount = 0;
22
+ recentDays = 0;
23
+ priceHistoryFrom = null;
16
24
  static parse(raw) {
17
25
  const summary = new MarketPositionSummary();
18
26
  summary.productCount = Number(raw.product_count ?? 0);
@@ -22,8 +30,13 @@ export class MarketPositionSummary {
22
30
  summary.bucketCounts[bucket] = Number(buckets[bucket] ?? 0);
23
31
  }
24
32
  summary.computedAt = raw.computed_at ? new Date(raw.computed_at) : null;
25
- summary.pricesSeenFrom = raw.prices_seen_from ? new Date(raw.prices_seen_from) : null;
26
- summary.pricesSeenTo = raw.prices_seen_to ? new Date(raw.prices_seen_to) : null;
33
+ summary.marketIndex = raw.market_index === null || raw.market_index === undefined ? null : Number(raw.market_index);
34
+ summary.marketIndexByValue = raw.market_index_by_value === null || raw.market_index_by_value === undefined ? null : Number(raw.market_index_by_value);
35
+ summary.matchableCount = Number(raw.matchable_count ?? 0);
36
+ summary.competitorPriceCount = Number(raw.competitor_price_count ?? 0);
37
+ summary.recentCompetitorPriceCount = Number(raw.recent_competitor_price_count ?? 0);
38
+ summary.recentDays = Number(raw.recent_days ?? 0);
39
+ summary.priceHistoryFrom = raw.price_history_from ? new Date(raw.price_history_from) : null;
27
40
  return summary;
28
41
  }
29
42
  }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Who made a match's current decision. `user` is a person pressing accept or decline; `system` is the
3
+ * matcher (an exact barcode accept) or the sweep returning one to pending; `sibling_cascade` is the
4
+ * decline an accept applies to the other candidates for the same product.
5
+ */
6
+ export type MatchDecisionSource = 'user' | 'system' | 'sibling_cascade';
@@ -0,0 +1 @@
1
+ export {};
@@ -8,9 +8,9 @@ import { ApiRecord } from '../../Model/ApiRecord.js';
8
8
  */
9
9
  export declare class PriceIndexSnapshotEntry {
10
10
  date: string;
11
- competitorId: string;
11
+ competitorId: string | null;
12
12
  priceIndex: number;
13
13
  matchCount: number;
14
- constructor(date: string, competitorId: string);
14
+ constructor(date: string, competitorId: string | null);
15
15
  static parse(raw: ApiRecord): PriceIndexSnapshotEntry;
16
16
  }
@@ -7,6 +7,7 @@
7
7
  */
8
8
  export class PriceIndexSnapshotEntry {
9
9
  date;
10
+ // Null for the market line: every competitor together.
10
11
  competitorId;
11
12
  priceIndex = 0;
12
13
  matchCount = 0;
@@ -15,7 +16,7 @@ export class PriceIndexSnapshotEntry {
15
16
  this.competitorId = competitorId;
16
17
  }
17
18
  static parse(raw) {
18
- const entry = new PriceIndexSnapshotEntry(raw.date, raw.competitor);
19
+ const entry = new PriceIndexSnapshotEntry(raw.date, raw.competitor ?? null);
19
20
  entry.priceIndex = Number(raw.price_index ?? 0);
20
21
  entry.matchCount = Number(raw.match_count ?? 0);
21
22
  return entry;
@@ -1,4 +1,5 @@
1
1
  import { ApiRecord } from '../../Model/ApiRecord.js';
2
+ import { MatchDecisionSource } from './MatchDecisionSource.js';
2
3
  import { ProductMatchStatus } from './ProductMatch.js';
3
4
  /** One side of a match, reduced to what a reviewer needs to judge it. */
4
5
  export type ReviewProduct = {
@@ -40,6 +41,9 @@ export declare class ReviewMatch {
40
41
  status: ProductMatchStatus;
41
42
  confidence: number | null;
42
43
  createdAt: Date | null;
44
+ /** Who made the current decision; null only on rows that predate recording it. */
45
+ decisionSource: MatchDecisionSource | null;
46
+ decidedAt: Date | null;
43
47
  own: ReviewProduct;
44
48
  competitor: ReviewCompetitorProduct;
45
49
  constructor(matchId: string, own: ReviewProduct, competitor: ReviewCompetitorProduct);
@@ -10,6 +10,9 @@ export class ReviewMatch {
10
10
  status = 'pending';
11
11
  confidence = null;
12
12
  createdAt = null;
13
+ /** Who made the current decision; null only on rows that predate recording it. */
14
+ decisionSource = null;
15
+ decidedAt = null;
13
16
  own;
14
17
  competitor;
15
18
  constructor(matchId, own, competitor) {
@@ -37,6 +40,8 @@ export class ReviewMatch {
37
40
  match.status = raw.status ?? 'pending';
38
41
  match.confidence = raw.confidence ?? null;
39
42
  match.createdAt = raw.created_at ? new Date(raw.created_at) : null;
43
+ match.decisionSource = raw.decision_source ?? null;
44
+ match.decidedAt = raw.decided_at ? new Date(raw.decided_at) : null;
40
45
  return match;
41
46
  }
42
47
  static parseProduct(raw) {
@@ -1,7 +1,16 @@
1
- /** Narrows the review queue. Omitting `statuses` returns the pending ones. */
1
+ import { MatchDecisionSource } from './MatchDecisionSource.js';
2
+ /** Unknown confidence sorts last in both confidence orders. */
3
+ export type ReviewMatchOrder = 'newest' | 'confidence_desc' | 'confidence_asc';
4
+ /**
5
+ * Narrows the review queue. Omitting `statuses` returns the pending ones. `competitor`, `gtin` and
6
+ * `search` apply to the competitor product; `ownSearch` matches your own product's name, GTIN or SKU.
7
+ */
2
8
  export type ReviewMatchFilters = {
3
9
  statuses?: string[];
10
+ decisionSources?: MatchDecisionSource[];
4
11
  competitor?: string;
5
12
  gtin?: string;
6
13
  search?: string;
14
+ ownSearch?: string;
15
+ order?: ReviewMatchOrder;
7
16
  };
@@ -12,6 +12,8 @@ export declare class TopCompetitor {
12
12
  vendorName: string;
13
13
  vendorUrl: string;
14
14
  vendorIcon: string | null;
15
+ /** Lowercase `#rrggbb` for this competitor's avatar and chart line; null = none chosen. */
16
+ color: string | null;
15
17
  matchCount: number;
16
18
  productCount: number;
17
19
  priceIndex: number | null;
@@ -11,6 +11,8 @@ export class TopCompetitor {
11
11
  vendorName = '';
12
12
  vendorUrl = '';
13
13
  vendorIcon = null;
14
+ /** Lowercase `#rrggbb` for this competitor's avatar and chart line; null = none chosen. */
15
+ color = null;
14
16
  matchCount = 0;
15
17
  productCount = 0;
16
18
  priceIndex = null;
@@ -28,6 +30,7 @@ export class TopCompetitor {
28
30
  competitor.vendorName = raw.vendor_name ?? '';
29
31
  competitor.vendorUrl = raw.vendor_url ?? '';
30
32
  competitor.vendorIcon = raw.vendor_icon ?? null;
33
+ competitor.color = raw.color ?? null;
31
34
  competitor.matchCount = Number(raw.match_count ?? 0);
32
35
  competitor.productCount = Number(raw.product_count ?? 0);
33
36
  competitor.priceIndex = raw.price_index ?? null;
@@ -21,6 +21,15 @@ export class ProductMatchEndpoint extends Endpoint {
21
21
  if (filters.search) {
22
22
  queryString.set('search', filters.search);
23
23
  }
24
+ if (filters.ownSearch) {
25
+ queryString.set('own_search', filters.ownSearch);
26
+ }
27
+ if (filters.decisionSources && filters.decisionSources.length > 0) {
28
+ queryString.set('decision_source', filters.decisionSources.join(','));
29
+ }
30
+ if (filters.order) {
31
+ queryString.set('order', filters.order);
32
+ }
24
33
  queryString.addPagination(pagination);
25
34
  return await this.requestCollection(queryString, ReviewMatch.parse);
26
35
  }
@@ -1,6 +1,7 @@
1
1
  import { CatalogId } from '../../Catalog/Model/CatalogId.js';
2
2
  import { CollectionResult } from '../../Model/Result/CollectionResult.js';
3
3
  import { Endpoint } from '../../Service/Endpoint.js';
4
+ import { MarketPositionGroup } from '../Model/MarketPositionGroup.js';
4
5
  import { MarketPositionSummary } from '../Model/MarketPositionSummary.js';
5
6
  import { MarketSummaryEntry } from '../Model/MarketSummaryEntry.js';
6
7
  import { PriceIndexSnapshotEntry } from '../Model/PriceIndexSnapshotEntry.js';
@@ -12,8 +13,13 @@ import { TopCompetitor } from '../Model/TopCompetitor.js';
12
13
  * These are precomputed server-side; `CatalogProductEndpoint.recomputeStatistics` refreshes them.
13
14
  */
14
15
  export declare class PulseStatisticsEndpoint extends Endpoint {
15
- /** The catalog against the market: coverage, where the compared products stand, and the price date. */
16
- getMarketPositionSummary(catalogId: CatalogId | string): Promise<MarketPositionSummary>;
16
+ /**
17
+ * The catalog against the market: coverage, where the compared products stand, and the price date.
18
+ * Null when the API returns none, so a caller can tell "unavailable" from "nothing compared".
19
+ */
20
+ getMarketPositionSummary(catalogId: CatalogId | string): Promise<MarketPositionSummary | null>;
21
+ /** The catalog against the market per brand or per category, largest group first. */
22
+ getMarketPositionsBy(catalogId: CatalogId | string, groupBy: 'brand' | 'category'): Promise<CollectionResult<MarketPositionGroup>>;
17
23
  /** Headline figures (products tracked, matches, competitors …) against the previous period. */
18
24
  getAccountSummary(catalogId: CatalogId | string): Promise<CollectionResult<MarketSummaryEntry>>;
19
25
  /** Distribution of the catalog's products across price or profit segments. */
@@ -31,5 +37,6 @@ export declare class PulseStatisticsEndpoint extends Endpoint {
31
37
  group?: string;
32
38
  from?: string;
33
39
  to?: string;
40
+ includeMarket?: boolean;
34
41
  }): Promise<CollectionResult<PriceIndexSnapshotEntry>>;
35
42
  }
@@ -1,6 +1,7 @@
1
1
  import { path } from '../../Http/Data/Path.js';
2
2
  import { QueryString } from '../../Http/Data/QueryString.js';
3
3
  import { Endpoint } from '../../Service/Endpoint.js';
4
+ import { MarketPositionGroup } from '../Model/MarketPositionGroup.js';
4
5
  import { MarketPositionSummary } from '../Model/MarketPositionSummary.js';
5
6
  import { PriceIndexSnapshotEntry } from '../Model/PriceIndexSnapshotEntry.js';
6
7
  import { TopCompetitor } from '../Model/TopCompetitor.js';
@@ -9,10 +10,19 @@ import { TopCompetitor } from '../Model/TopCompetitor.js';
9
10
  * These are precomputed server-side; `CatalogProductEndpoint.recomputeStatistics` refreshes them.
10
11
  */
11
12
  export class PulseStatisticsEndpoint extends Endpoint {
12
- /** The catalog against the market: coverage, where the compared products stand, and the price date. */
13
+ /**
14
+ * The catalog against the market: coverage, where the compared products stand, and the price date.
15
+ * Null when the API returns none, so a caller can tell "unavailable" from "nothing compared".
16
+ */
13
17
  async getMarketPositionSummary(catalogId) {
14
18
  const result = await this.requestObject(path('/pulse/catalogs/:catalogId/market-positions/summary', { catalogId: catalogId.toString() }), null, MarketPositionSummary.parse, 'GET');
15
- return result.getData() ?? new MarketPositionSummary();
19
+ return result.getData();
20
+ }
21
+ /** The catalog against the market per brand or per category, largest group first. */
22
+ async getMarketPositionsBy(catalogId, groupBy) {
23
+ const queryString = new QueryString(path('/pulse/catalogs/:catalogId/market-positions/aggregate', { catalogId: catalogId.toString() }));
24
+ queryString.set('group_by', groupBy);
25
+ return await this.requestCollection(queryString, MarketPositionGroup.parse);
16
26
  }
17
27
  /** Headline figures (products tracked, matches, competitors …) against the previous period. */
18
28
  async getAccountSummary(catalogId) {
@@ -67,6 +77,9 @@ export class PulseStatisticsEndpoint extends Endpoint {
67
77
  if (options.to) {
68
78
  queryString.set('to', options.to);
69
79
  }
80
+ if (options.includeMarket) {
81
+ queryString.set('include_market', 'true');
82
+ }
70
83
  return await this.requestCollection(queryString, PriceIndexSnapshotEntry.parse);
71
84
  }
72
85
  }
package/dist/index.d.ts CHANGED
@@ -112,12 +112,14 @@ export { PriceIndexSnapshotEntry } from './MarketPulse/Model/PriceIndexSnapshotE
112
112
  export { MatchHistory } from './MarketPulse/Model/MatchHistory.js';
113
113
  export { MatchHistoryBucket } from './MarketPulse/Model/MatchHistoryBucket.js';
114
114
  export { MatchHistoryInterval } from './MarketPulse/Model/MatchHistoryInterval.js';
115
- export { ReviewMatchFilters } from './MarketPulse/Model/ReviewMatchFilters.js';
115
+ export { ReviewMatchFilters, ReviewMatchOrder } from './MarketPulse/Model/ReviewMatchFilters.js';
116
+ export { MatchDecisionSource } from './MarketPulse/Model/MatchDecisionSource.js';
116
117
  export { ProductMatchEndpoint } from './MarketPulse/Service/ProductMatchEndpoint.js';
117
118
  export { PulseCatalogProductFilterOptions } from './MarketPulse/Model/PulseCatalogProductFilterOptions.js';
118
119
  export { PulseCatalogProductFilters } from './MarketPulse/Model/PulseCatalogProductFilters.js';
119
120
  export { POSITION_BUCKETS, PositionBucket } from './MarketPulse/Model/PositionBucket.js';
120
121
  export { MarketPositionSummary } from './MarketPulse/Model/MarketPositionSummary.js';
122
+ export { MarketPositionGroup } from './MarketPulse/Model/MarketPositionGroup.js';
121
123
  export { PulseCatalogProductEndpoint } from './MarketPulse/Service/PulseCatalogProductEndpoint.js';
122
124
  export { PriceAlertConfig } from './MarketPulse/Model/PriceAlertConfig.js';
123
125
  export { PriceAlertEvent } from './MarketPulse/Model/PriceAlertEvent.js';
package/dist/index.js CHANGED
@@ -96,6 +96,7 @@ export { PriceIndexSnapshotEntry } from './MarketPulse/Model/PriceIndexSnapshotE
96
96
  export { ProductMatchEndpoint } from './MarketPulse/Service/ProductMatchEndpoint.js';
97
97
  export { POSITION_BUCKETS } from './MarketPulse/Model/PositionBucket.js';
98
98
  export { MarketPositionSummary } from './MarketPulse/Model/MarketPositionSummary.js';
99
+ export { MarketPositionGroup } from './MarketPulse/Model/MarketPositionGroup.js';
99
100
  export { PulseCatalogProductEndpoint } from './MarketPulse/Service/PulseCatalogProductEndpoint.js';
100
101
  export { PriceAlertConfig } from './MarketPulse/Model/PriceAlertConfig.js';
101
102
  export { PriceAlertEvent } from './MarketPulse/Model/PriceAlertEvent.js';
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.129.0";
1
+ export declare const VERSION = "1.130.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.129.0";
1
+ export const VERSION = "1.130.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@attlaz/client",
3
- "version": "1.130.0",
3
+ "version": "1.131.0",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",
@@ -57,14 +57,14 @@
57
57
  "devDependencies": {
58
58
  "@types/node": "^26.6.6",
59
59
  "@typescript/native": "npm:typescript@^7.0.2",
60
- "eslint": "^10.13.0",
60
+ "eslint": "^10.14.0",
61
61
  "eslint-config-attlaz-base": "^1.11.0",
62
62
  "eslint-import-resolver-typescript": "^4.4.5",
63
63
  "eslint-plugin-barrel-files": "^3.0.1",
64
64
  "eslint-plugin-import-x": "^4.17.1",
65
- "rimraf": "^6.1.3",
65
+ "rimraf": "^6.1.4",
66
66
  "typescript": "npm:@typescript/typescript6@^6.0.2",
67
- "vitest": "^5.0.5"
67
+ "vitest": "^5.1.0"
68
68
  },
69
69
  "directories": {
70
70
  "test": "test"