@attlaz/client 1.103.0 → 1.105.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.
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Whether a vendor product is purchasable. Three states rather than a nullable boolean, because
3
+ * "we don't know" is a different fact from "it is out of stock" — most crawlers never report stock.
4
+ *
5
+ * Duplicated from apps-lib rather than imported, per the client's enum-duplication convention: the
6
+ * client must not depend on a server package.
7
+ */
8
+ export type StockStatus = 'in_stock' | 'out_of_stock' | 'unknown';
9
+ /**
10
+ * Read `stock_status` from an API record. An unrecognised or absent value is `unknown`, never
11
+ * `out_of_stock` — guessing the latter would make a consumer hide a product that is probably on sale.
12
+ */
13
+ export declare const parseStockStatus: (status: unknown) => StockStatus;
14
+ /**
15
+ * Convert a scraper's own boolean reading of stock into a status. Separate from parseStockStatus:
16
+ * that one reads the wire, this one is for callers holding a `boolean | null` of their own, where
17
+ * null genuinely means the source did not say.
18
+ */
19
+ export declare const stockStatusFromBoolean: (inStock: boolean | null) => StockStatus;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Read `stock_status` from an API record. An unrecognised or absent value is `unknown`, never
3
+ * `out_of_stock` — guessing the latter would make a consumer hide a product that is probably on sale.
4
+ */
5
+ export const parseStockStatus = (status) => {
6
+ if (status === 'in_stock' || status === 'out_of_stock' || status === 'unknown') {
7
+ return status;
8
+ }
9
+ return 'unknown';
10
+ };
11
+ /**
12
+ * Convert a scraper's own boolean reading of stock into a status. Separate from parseStockStatus:
13
+ * that one reads the wire, this one is for callers holding a `boolean | null` of their own, where
14
+ * null genuinely means the source did not say.
15
+ */
16
+ export const stockStatusFromBoolean = (inStock) => {
17
+ if (inStock === null) {
18
+ return 'unknown';
19
+ }
20
+ return inStock ? 'in_stock' : 'out_of_stock';
21
+ };
@@ -1,3 +1,4 @@
1
+ import { StockStatus } from './StockStatus.js';
1
2
  import { ApiRecord } from '../../Model/ApiRecord.js';
2
3
  /**
3
4
  * A competitor's product as tracked by Market Pulse — the `/pulse/vendors/:vendorId/products`
@@ -17,7 +18,7 @@ export declare class VendorProduct {
17
18
  price: number | null;
18
19
  originalPrice: number | null;
19
20
  shippingCost: number | null;
20
- isInStock: boolean | null;
21
+ stockStatus: StockStatus;
21
22
  properties: Record<string, unknown> | null;
22
23
  createdAt: Date | null;
23
24
  updatedAt: Date | null;
@@ -1,3 +1,4 @@
1
+ import { parseStockStatus } from './StockStatus.js';
1
2
  /**
2
3
  * A competitor's product as tracked by Market Pulse — the `/pulse/vendors/:vendorId/products`
3
4
  * resource. `identifier` is the product's stable id on the competitor's site (the upsert key).
@@ -16,7 +17,7 @@ export class VendorProduct {
16
17
  price = null;
17
18
  originalPrice = null;
18
19
  shippingCost = null;
19
- isInStock = null;
20
+ stockStatus = 'unknown';
20
21
  properties = null;
21
22
  createdAt = null;
22
23
  updatedAt = null;
@@ -46,7 +47,7 @@ export class VendorProduct {
46
47
  product.price = toNumber(raw.price);
47
48
  product.originalPrice = toNumber(raw.original_price);
48
49
  product.shippingCost = toNumber(raw.shipping_cost);
49
- product.isInStock = typeof raw.is_in_stock === 'boolean' ? raw.is_in_stock : null;
50
+ product.stockStatus = parseStockStatus(raw.stock_status);
50
51
  product.properties = raw.properties ?? null;
51
52
  product.createdAt = raw.created_at ? new Date(raw.created_at) : null;
52
53
  product.updatedAt = raw.updated_at ? new Date(raw.updated_at) : null;
@@ -1,3 +1,4 @@
1
+ import { StockStatus } from './StockStatus.js';
1
2
  import { ApiRecord } from '../../Model/ApiRecord.js';
2
3
  /**
3
4
  * One recorded price point of a competitor product — the `/pulse/vendor-products/:id/price-history`
@@ -10,7 +11,7 @@ export declare class VendorProductPriceHistoryEntry {
10
11
  price: number | null;
11
12
  originalPrice: number | null;
12
13
  shippingCost: number | null;
13
- isInStock: boolean | null;
14
+ stockStatus: StockStatus;
14
15
  isPromotion: boolean | null;
15
16
  recordedAt: Date | null;
16
17
  constructor(id: string, vendorProductId: string);
@@ -1,3 +1,4 @@
1
+ import { parseStockStatus } from './StockStatus.js';
1
2
  /**
2
3
  * One recorded price point of a competitor product — the `/pulse/vendor-products/:id/price-history`
3
4
  * resource. Written when a crawl finds a price that differs from the last recorded one, so the
@@ -9,7 +10,7 @@ export class VendorProductPriceHistoryEntry {
9
10
  price = null;
10
11
  originalPrice = null;
11
12
  shippingCost = null;
12
- isInStock = null;
13
+ stockStatus = 'unknown';
13
14
  isPromotion = null;
14
15
  recordedAt = null;
15
16
  constructor(id, vendorProductId) {
@@ -21,7 +22,7 @@ export class VendorProductPriceHistoryEntry {
21
22
  entry.price = toNumber(raw.price);
22
23
  entry.originalPrice = toNumber(raw.original_price);
23
24
  entry.shippingCost = toNumber(raw.shipping_cost);
24
- entry.isInStock = typeof raw.is_in_stock === 'boolean' ? raw.is_in_stock : null;
25
+ entry.stockStatus = parseStockStatus(raw.stock_status);
25
26
  entry.isPromotion = typeof raw.is_promotion === 'boolean' ? raw.is_promotion : null;
26
27
  entry.recordedAt = raw.recorded_at ? new Date(raw.recorded_at) : null;
27
28
  return entry;
@@ -62,7 +62,7 @@ export class VendorProductEndpoint extends Endpoint {
62
62
  price: product.price,
63
63
  originalPrice: product.originalPrice,
64
64
  shippingCost: product.shippingCost,
65
- isInStock: product.isInStock,
65
+ stockStatus: product.stockStatus,
66
66
  properties: product.properties,
67
67
  };
68
68
  const result = await this.requestObject(path('/pulse/vendors/:vendorId/products', { vendorId: product.vendorId }), body, VendorProduct.parse, 'POST');
@@ -76,7 +76,7 @@ export class VendorProductEndpoint extends Endpoint {
76
76
  { op: 'add', path: 'original_price', value: product.originalPrice },
77
77
  { op: 'add', path: 'brand', value: product.brand },
78
78
  { op: 'add', path: 'shipping_cost', value: product.shippingCost },
79
- { op: 'add', path: 'is_in_stock', value: product.isInStock },
79
+ { op: 'add', path: 'stock_status', value: product.stockStatus },
80
80
  { op: 'add', path: 'url', value: product.url },
81
81
  { op: 'add', path: 'gtin', value: product.gtin },
82
82
  { op: 'add', path: 'image', value: product.image },
@@ -11,6 +11,14 @@ export declare class AdapterConnectionEndpoint extends Endpoint {
11
11
  getConnectionByKey(projectId: string, connectionKey: string): Promise<AdapterConnection | null>;
12
12
  getConnectionConfiguration(connectionId: string): Promise<CollectionResult<AdapterConnectionConfigurationValue>>;
13
13
  saveConnection(projectId: string, connection: AdapterConnection): Promise<AdapterConnection>;
14
+ /**
15
+ * Writes the supplied configurations and leaves the rest of the connection alone — PATCH, since
16
+ * it is a partial update. A configuration the API does not let a client set (a provider token)
17
+ * is untouched rather than cleared.
18
+ *
19
+ * Needs an API that serves the PATCH route; it is also still registered as POST for clients
20
+ * released before the verb changed.
21
+ */
14
22
  saveConnectionConfiguration(connectionId: string, configuration: AdapterConnectionConfigurationValue[]): Promise<boolean>;
15
23
  getConnectionEvents(connectionId: string, pagination: CursorPagination): Promise<CollectionResult<AdapterConnectionEvent>>;
16
24
  /**
@@ -79,11 +79,19 @@ export class AdapterConnectionEndpoint extends Endpoint {
79
79
  throw error;
80
80
  }
81
81
  }
82
+ /**
83
+ * Writes the supplied configurations and leaves the rest of the connection alone — PATCH, since
84
+ * it is a partial update. A configuration the API does not let a client set (a provider token)
85
+ * is untouched rather than cleared.
86
+ *
87
+ * Needs an API that serves the PATCH route; it is also still registered as POST for clients
88
+ * released before the verb changed.
89
+ */
82
90
  async saveConnectionConfiguration(connectionId, configuration) {
83
91
  try {
84
92
  const url = path('/connections/:connectionId/configuration', { connectionId });
85
93
  const parser = (raw) => ({ saved: raw.saved });
86
- const result = await this.requestObject(url, { configuration: configuration }, parser, 'POST');
94
+ const result = await this.requestObject(url, { configuration: configuration }, parser, 'PATCH');
87
95
  const res = result.getData();
88
96
  if (res === null) {
89
97
  throw new Error('Unable to save connection configuration: wrong response from API');
package/dist/index.d.ts CHANGED
@@ -82,6 +82,7 @@ export { ResultError } from './Model/Result/ResultError.js';
82
82
  export { StorageInformation } from './Model/Storage/StorageInformation.js';
83
83
  export { StorageType } from './Model/Storage/StorageType.js';
84
84
  export { VendorProduct } from './MarketPulse/Model/VendorProduct.js';
85
+ export { StockStatus, parseStockStatus, stockStatusFromBoolean } from './MarketPulse/Model/StockStatus.js';
85
86
  export { VendorProductEndpoint } from './MarketPulse/Service/VendorProductEndpoint.js';
86
87
  export { CrawlJob, CrawlJobStatus } from './MarketPulse/Model/CrawlJob.js';
87
88
  export { CrawlJobEndpoint } from './MarketPulse/Service/CrawlJobEndpoint.js';
package/dist/index.js CHANGED
@@ -68,6 +68,7 @@ export { ResultError } from './Model/Result/ResultError.js';
68
68
  export { StorageInformation } from './Model/Storage/StorageInformation.js';
69
69
  export { StorageType } from './Model/Storage/StorageType.js';
70
70
  export { VendorProduct } from './MarketPulse/Model/VendorProduct.js';
71
+ export { parseStockStatus, stockStatusFromBoolean } from './MarketPulse/Model/StockStatus.js';
71
72
  export { VendorProductEndpoint } from './MarketPulse/Service/VendorProductEndpoint.js';
72
73
  export { CrawlJob } from './MarketPulse/Model/CrawlJob.js';
73
74
  export { CrawlJobEndpoint } from './MarketPulse/Service/CrawlJobEndpoint.js';
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "1.103.0";
1
+ export declare const VERSION = "1.104.0";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "1.103.0";
1
+ export const VERSION = "1.104.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@attlaz/client",
3
- "version": "1.103.0",
3
+ "version": "1.105.0",
4
4
  "description": "Javascript Client to access Attlaz API",
5
5
  "types": "./dist/index.d.ts",
6
6
  "main": "./dist/index.js",