@attlaz/client 1.128.0 → 1.129.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.
@@ -25,7 +25,9 @@ export declare class CatalogProductWithMatches {
25
25
  priceProposal: PriceProposal | null;
26
26
  matches: MatchedVendorProduct[];
27
27
  constructor(id: string);
28
- /** Mean price of the matched competitor products; null when nothing matched. */
28
+ /** The matches a comparison rests on — every match except the unconfirmed suggestions. */
29
+ get countedMatches(): MatchedVendorProduct[];
30
+ /** Mean price of the counted competitor products; null when none is counted. */
29
31
  get matchesAveragePrice(): number | null;
30
32
  static parse(raw: ApiRecord): CatalogProductWithMatches;
31
33
  }
@@ -20,13 +20,18 @@ export class CatalogProductWithMatches {
20
20
  constructor(id) {
21
21
  this.id = id;
22
22
  }
23
- /** Mean price of the matched competitor products; null when nothing matched. */
23
+ /** The matches a comparison rests on — every match except the unconfirmed suggestions. */
24
+ get countedMatches() {
25
+ return this.matches.filter((match) => !match.isUnconfirmed);
26
+ }
27
+ /** Mean price of the counted competitor products; null when none is counted. */
24
28
  get matchesAveragePrice() {
25
- if (this.matches.length === 0) {
29
+ const counted = this.countedMatches;
30
+ if (counted.length === 0) {
26
31
  return null;
27
32
  }
28
- const total = this.matches.reduce((sum, match) => sum + match.price, 0);
29
- return total / this.matches.length;
33
+ const total = counted.reduce((sum, match) => sum + match.price, 0);
34
+ return total / counted.length;
30
35
  }
31
36
  static parse(raw) {
32
37
  const product = new CatalogProductWithMatches(raw.id);
@@ -14,6 +14,8 @@ export declare class MatchedVendorProduct {
14
14
  /** Id of the match record joining it to your product; null for an unreviewed direct hit. */
15
15
  matchId: string | null;
16
16
  matchJobId: string | null;
17
+ /** `accepted` counts in every comparison; `pending` is an unconfirmed suggestion. Null from an API that does not send it. */
18
+ matchStatus: string | null;
17
19
  vendor: Vendor | null;
18
20
  name: string;
19
21
  image: string | null;
@@ -31,5 +33,7 @@ export declare class MatchedVendorProduct {
31
33
  properties: Record<string, unknown> | null;
32
34
  updatedAt: Date | null;
33
35
  constructor(id: string);
36
+ /** A suggestion nobody has confirmed: shown on request, never part of a comparison. */
37
+ get isUnconfirmed(): boolean;
34
38
  static parse(raw: ApiRecord): MatchedVendorProduct;
35
39
  }
@@ -13,6 +13,8 @@ export class MatchedVendorProduct {
13
13
  /** Id of the match record joining it to your product; null for an unreviewed direct hit. */
14
14
  matchId = null;
15
15
  matchJobId = null;
16
+ /** `accepted` counts in every comparison; `pending` is an unconfirmed suggestion. Null from an API that does not send it. */
17
+ matchStatus = null;
16
18
  vendor = null;
17
19
  name = '';
18
20
  image = null;
@@ -32,10 +34,15 @@ export class MatchedVendorProduct {
32
34
  constructor(id) {
33
35
  this.id = id;
34
36
  }
37
+ /** A suggestion nobody has confirmed: shown on request, never part of a comparison. */
38
+ get isUnconfirmed() {
39
+ return this.matchStatus === 'pending';
40
+ }
35
41
  static parse(raw) {
36
42
  const product = new MatchedVendorProduct(raw.id);
37
43
  product.matchId = raw.match ?? null;
38
44
  product.matchJobId = raw.match_job ?? null;
45
+ product.matchStatus = raw.match_status ?? null;
39
46
  const vendor = raw.vendor;
40
47
  if (vendor !== null && typeof vendor === 'object') {
41
48
  product.vendor = Vendor.parse(vendor);
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A product's market position against the median price of its counted competitors, cheapest to most
3
+ * expensive. Mirrors apps-lib's `POSITION_BUCKETS`; the thresholds live server-side.
4
+ */
5
+ export declare const POSITION_BUCKETS: readonly ['very_sharp', 'sharp', 'market_rate', 'expensive', 'much_more_expensive'];
6
+ export type PositionBucket = typeof POSITION_BUCKETS[number];
@@ -0,0 +1,5 @@
1
+ /**
2
+ * A product's market position against the median price of its counted competitors, cheapest to most
3
+ * expensive. Mirrors apps-lib's `POSITION_BUCKETS`; the thresholds live server-side.
4
+ */
5
+ export const POSITION_BUCKETS = ['very_sharp', 'sharp', 'market_rate', 'expensive', 'much_more_expensive'];
@@ -1,3 +1,4 @@
1
+ import { PositionBucket } from './PositionBucket.js';
1
2
  /** Simple narrowing of the product list; `tags` filters on materialised tag values. */
2
3
  export type PulseCatalogProductFilters = {
3
4
  brand?: string;
@@ -5,4 +6,6 @@ export type PulseCatalogProductFilters = {
5
6
  search?: string;
6
7
  productGroup?: string;
7
8
  tags?: Record<string, string>;
9
+ positionBucket?: PositionBucket;
10
+ includePending?: boolean;
8
11
  };
@@ -33,6 +33,12 @@ export class PulseCatalogProductEndpoint extends Endpoint {
33
33
  queryString.set('tag[' + key + ']', value);
34
34
  }
35
35
  }
36
+ if (filters.positionBucket) {
37
+ queryString.set('position_bucket', filters.positionBucket);
38
+ }
39
+ if (filters.includePending) {
40
+ queryString.set('include_pending', 'true');
41
+ }
36
42
  if (filter !== null) {
37
43
  queryString.set('filter', JSON.stringify(filter));
38
44
  }
package/dist/index.d.ts CHANGED
@@ -116,6 +116,7 @@ export { ReviewMatchFilters } from './MarketPulse/Model/ReviewMatchFilters.js';
116
116
  export { ProductMatchEndpoint } from './MarketPulse/Service/ProductMatchEndpoint.js';
117
117
  export { PulseCatalogProductFilterOptions } from './MarketPulse/Model/PulseCatalogProductFilterOptions.js';
118
118
  export { PulseCatalogProductFilters } from './MarketPulse/Model/PulseCatalogProductFilters.js';
119
+ export { POSITION_BUCKETS, PositionBucket } from './MarketPulse/Model/PositionBucket.js';
119
120
  export { PulseCatalogProductEndpoint } from './MarketPulse/Service/PulseCatalogProductEndpoint.js';
120
121
  export { PriceAlertConfig } from './MarketPulse/Model/PriceAlertConfig.js';
121
122
  export { PriceAlertEvent } from './MarketPulse/Model/PriceAlertEvent.js';
package/dist/index.js CHANGED
@@ -94,6 +94,7 @@ export { ReviewMatch } from './MarketPulse/Model/ReviewMatch.js';
94
94
  export { TopCompetitor } from './MarketPulse/Model/TopCompetitor.js';
95
95
  export { PriceIndexSnapshotEntry } from './MarketPulse/Model/PriceIndexSnapshotEntry.js';
96
96
  export { ProductMatchEndpoint } from './MarketPulse/Service/ProductMatchEndpoint.js';
97
+ export { POSITION_BUCKETS } from './MarketPulse/Model/PositionBucket.js';
97
98
  export { PulseCatalogProductEndpoint } from './MarketPulse/Service/PulseCatalogProductEndpoint.js';
98
99
  export { PriceAlertConfig } from './MarketPulse/Model/PriceAlertConfig.js';
99
100
  export { PriceAlertEvent } from './MarketPulse/Model/PriceAlertEvent.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@attlaz/client",
3
- "version": "1.128.0",
3
+ "version": "1.129.0",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",