platform-types 1.10.763 → 1.10.764

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,10 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PRODUCT_MEDIA_INVALID_REASONS = exports.MAX_PRODUCT_PICTURE_ALT_CHARS = exports.PRODUCT_UPSERT_ERROR_CODES = exports.PRODUCT_UPSERT_ROW_ERROR_CODES = exports.PRODUCT_UPSERT_ROW_CAP = exports.PUBLIC_PRODUCT_BY_SLUG_ERROR_CODES = exports.PRODUCT_PUBLISH_OVERDUE_AFTER_MS = exports.PRODUCT_PUBLISH_AT_MAX_AHEAD_MS = exports.PRODUCT_POST_ERROR_CODES = exports.PRODUCT_IDENTITY_ERROR_CODES = exports.PRODUCT_EXPORT_ERROR_CODES = exports.PRODUCT_CATALOG_EXPORT_COLUMNS = exports.MAX_BASE_QUANTITY = exports.BASE_QUANTITY_DECIMAL_PLACES = void 0;
3
+ exports.PRODUCT_MEDIA_INVALID_REASONS = exports.MAX_PRODUCT_PICTURE_ALT_CHARS = exports.PRODUCT_UPSERT_ERROR_CODES = exports.PRODUCT_UPSERT_ROW_ERROR_CODES = exports.PRODUCT_UPSERT_ROW_CAP = exports.PUBLIC_PRODUCT_SUGGEST_ERROR_CODES = exports.PUBLIC_PRODUCT_BY_SLUG_ERROR_CODES = exports.PRODUCT_PUBLISH_OVERDUE_AFTER_MS = exports.PRODUCT_PUBLISH_AT_MAX_AHEAD_MS = exports.PRODUCT_POST_ERROR_CODES = exports.PRODUCT_IDENTITY_ERROR_CODES = exports.PRODUCT_EXPORT_ERROR_CODES = exports.PRODUCT_CATALOG_EXPORT_COLUMNS = exports.DISCOVERY_SORTS = exports.MAX_BASE_QUANTITY = exports.BASE_QUANTITY_DECIMAL_PLACES = void 0;
4
4
  /** Maximum decimal places in a canonical base quantity; inputs are exact, never rounded. */
5
5
  exports.BASE_QUANTITY_DECIMAL_PLACES = 6;
6
6
  /** Absolute base-quantity input bound; signed adjustments admit the negative of this value. */
7
7
  exports.MAX_BASE_QUANTITY = 1_000_000;
8
+ /**
9
+ * The `sort` values Web `GET /products?mode=discover` serves. `newest` is
10
+ * descending product id; name and price sorts are not served (no index can
11
+ * order them inside one bounded request).
12
+ */
13
+ exports.DISCOVERY_SORTS = ['newest'];
8
14
  /**
9
15
  * The CSV header of `GET /products?mode=export`, in file order.
10
16
  *
@@ -161,6 +167,12 @@ exports.PUBLIC_PRODUCT_BY_SLUG_ERROR_CODES = [
161
167
  'PRODUCT_NOT_FOUND',
162
168
  'PRODUCT_LOOKUP_INCOMPLETE',
163
169
  ];
170
+ /** Refusals of Web `GET /products?mode=suggest`: 400, 400, 503. */
171
+ exports.PUBLIC_PRODUCT_SUGGEST_ERROR_CODES = [
172
+ 'VALIDATION_FAILED',
173
+ 'INVALID_SUGGEST_QUERY',
174
+ 'PRODUCT_LOOKUP_INCOMPLETE',
175
+ ];
164
176
  /** Rows one `POST /products { mode: 'upsert' }` request takes; a longer file is sent in chunks. */
165
177
  exports.PRODUCT_UPSERT_ROW_CAP = 200;
166
178
  /**
@@ -28,7 +28,8 @@ declare global {
28
28
  * nothing with it and list everything the rest selects. `inOffer` and
29
29
  * `inStock` are the string `'true'`, as on that read.
30
30
  */
31
- type CollectionQuery = Omit<PublicProductDiscoverInput, 'mode' | 'startKey'>;
31
+ /** A stored discovery query: the filters only — never `sort` (a collection answers in discovery order). */
32
+ type CollectionQuery = Omit<PublicProductDiscoverInput, 'mode' | 'startKey' | 'sort'>;
32
33
  interface Collection {
33
34
  storeId: string;
34
35
  /** `COL` + at least six digits, minted by the api. */
package/dist/product.d.ts CHANGED
@@ -2,6 +2,13 @@
2
2
  export declare const BASE_QUANTITY_DECIMAL_PLACES = 6;
3
3
  /** Absolute base-quantity input bound; signed adjustments admit the negative of this value. */
4
4
  export declare const MAX_BASE_QUANTITY = 1000000;
5
+ /**
6
+ * The `sort` values Web `GET /products?mode=discover` serves. `newest` is
7
+ * descending product id; name and price sorts are not served (no index can
8
+ * order them inside one bounded request).
9
+ */
10
+ export declare const DISCOVERY_SORTS: readonly ["newest"];
11
+ export type DiscoverySort = (typeof DISCOVERY_SORTS)[number];
5
12
  declare global {
6
13
  type ProductUnitsErrorCode = 'UNIT_REVISION_STALE' | 'UNIT_FACTOR_INVALID' | 'UNIT_FACTOR_MISMATCH' | 'UNIT_INCOMPATIBLE_DIMENSION' | 'UNIT_QUANTITY_UNREPRESENTABLE' | 'UNIT_QUANTITY_NOT_WHOLE';
7
14
  type ProductUnit = 'each' | 'gram' | 'kilogram' | 'millilitre' | 'litre' | 'metre';
@@ -247,23 +254,72 @@ declare global {
247
254
  * while no product carries it.
248
255
  */
249
256
  tagId?: string;
250
- /** Only products with a promo window open now. */
257
+ /**
258
+ * Only products on offer at the caller's own price: a promo window open now
259
+ * on the one price slot the caller is priced at (a guest's is the store
260
+ * default list). A promo on another list does not count.
261
+ */
251
262
  inOffer?: 'true';
252
263
  /** Only products the online stock authority can sell now; services always pass. */
253
264
  inStock?: 'true';
254
265
  /** Only products explicitly marked as new; an absent flag does not pass. */
255
266
  isNew?: 'true';
256
- /** The previous response's `LastEvaluatedKey`, under the SAME filters; else 400 INVALID_CURSOR. */
267
+ /**
268
+ * A member of `DISCOVERY_SORTS`. `newest` = descending product id (mint
269
+ * order), on every filter combination. A well-formed value the api does not
270
+ * serve is 400 `DISCOVERY_SORT_UNSUPPORTED` ({@link DiscoverySortRefusal});
271
+ * one not matching `^[a-z_]{1,32}$` is 400 `INVALID_DISCOVERY_QUERY`. An
272
+ * empty value is absent. Bound into the cursor when present.
273
+ */
274
+ sort?: string;
275
+ /** The previous response's `LastEvaluatedKey`, under the SAME filters and sort; else 400 INVALID_CURSOR. */
257
276
  startKey?: string;
258
277
  }
259
278
  /** One page of a discovery walk; `data` can be empty while `LastEvaluatedKey` is set. */
260
279
  interface PublicProductDiscoverResponse {
261
280
  message: string;
262
- /** Public price/projection and online stock, in index order. */
281
+ /** Public price/projection and online stock, in `sort` order, else index order. */
263
282
  data: PublicProduct[];
283
+ /** The sort applied — present only when the request carried one. */
284
+ sort?: (typeof DISCOVERY_SORTS)[number];
264
285
  /** Present while rows remain; absent means the walk is complete. */
265
286
  LastEvaluatedKey?: string;
266
287
  }
288
+ /** Anonymous Web GET /products typeahead; the tenant comes from the public store context. */
289
+ interface PublicProductSuggestInput {
290
+ mode: 'suggest';
291
+ /** Trimmed, 2–64 chars, at least one search term after the split; else 400 INVALID_SUGGEST_QUERY. */
292
+ q: string;
293
+ /** Integer 1–10, default 8; anything else 400 INVALID_SUGGEST_QUERY. */
294
+ limit?: string;
295
+ }
296
+ /** Why a suggestion matched; drives ranking and the storefront's highlight. */
297
+ type PublicProductSuggestMatch = 'barcode' | 'sku' | 'name' | 'text';
298
+ /** One typeahead row: identity and display only — never a price, stock or offer flag. */
299
+ type PublicProductSuggestion = Pick<PublicProduct, 'slug' | 'sku' | 'thumbnailUrl'> & {
300
+ productId: string;
301
+ name: string;
302
+ /** Why it matched; drives ranking and the storefront's highlight. */
303
+ match: PublicProductSuggestMatch;
304
+ };
305
+ interface PublicProductSuggestResponse {
306
+ message: string;
307
+ /** Ranked barcode > sku > name > text, ties newest first; never more than `limit`. No cursor. */
308
+ data: PublicProductSuggestion[];
309
+ /**
310
+ * Present when the text walk stopped with catalogue rows unread (page
311
+ * budget, the soft deadline or a full `limit`): a better match may exist.
312
+ */
313
+ truncated?: true;
314
+ }
315
+ /** Refusals of Web `GET /products?mode=discover`. */
316
+ type DiscoveryErrorCode = 'INVALID_DISCOVERY_QUERY' | 'INVALID_CURSOR' | 'DISCOVERY_SORT_UNSUPPORTED';
317
+ /** 400 body for a well-formed `sort` the api does not serve; `supportedSorts` lists what it does. */
318
+ interface DiscoverySortRefusal {
319
+ message: string;
320
+ error: 'DISCOVERY_SORT_UNSUPPORTED';
321
+ supportedSorts: (typeof DISCOVERY_SORTS)[number][];
322
+ }
267
323
  /** Write shape for product create/update — carries the transient picture-removal control. */
268
324
  type ProductUpsertInput = Omit<Partial<Product>, 'pictures' | 'thumbnailUrl' | 'publishAt' | 'units' | 'unitRevisionGeneration'> & {
269
325
  /** Omitted preserves the declaration; null clears it only when the product is unused. */
@@ -1519,6 +1575,9 @@ export declare const PRODUCT_PUBLISH_OVERDUE_AFTER_MS: number;
1519
1575
  */
1520
1576
  export declare const PUBLIC_PRODUCT_BY_SLUG_ERROR_CODES: readonly ["VALIDATION_FAILED", "INVALID_SLUG", "PRODUCT_NOT_FOUND", "PRODUCT_LOOKUP_INCOMPLETE"];
1521
1577
  export type PublicProductBySlugErrorCode = (typeof PUBLIC_PRODUCT_BY_SLUG_ERROR_CODES)[number];
1578
+ /** Refusals of Web `GET /products?mode=suggest`: 400, 400, 503. */
1579
+ export declare const PUBLIC_PRODUCT_SUGGEST_ERROR_CODES: readonly ["VALIDATION_FAILED", "INVALID_SUGGEST_QUERY", "PRODUCT_LOOKUP_INCOMPLETE"];
1580
+ export type PublicProductSuggestErrorCode = (typeof PUBLIC_PRODUCT_SUGGEST_ERROR_CODES)[number];
1522
1581
  /** Rows one `POST /products { mode: 'upsert' }` request takes; a longer file is sent in chunks. */
1523
1582
  export declare const PRODUCT_UPSERT_ROW_CAP = 200;
1524
1583
  /**
package/dist/product.js CHANGED
@@ -2,6 +2,12 @@
2
2
  export const BASE_QUANTITY_DECIMAL_PLACES = 6;
3
3
  /** Absolute base-quantity input bound; signed adjustments admit the negative of this value. */
4
4
  export const MAX_BASE_QUANTITY = 1_000_000;
5
+ /**
6
+ * The `sort` values Web `GET /products?mode=discover` serves. `newest` is
7
+ * descending product id; name and price sorts are not served (no index can
8
+ * order them inside one bounded request).
9
+ */
10
+ export const DISCOVERY_SORTS = ['newest'];
5
11
  /**
6
12
  * The CSV header of `GET /products?mode=export`, in file order.
7
13
  *
@@ -158,6 +164,12 @@ export const PUBLIC_PRODUCT_BY_SLUG_ERROR_CODES = [
158
164
  'PRODUCT_NOT_FOUND',
159
165
  'PRODUCT_LOOKUP_INCOMPLETE',
160
166
  ];
167
+ /** Refusals of Web `GET /products?mode=suggest`: 400, 400, 503. */
168
+ export const PUBLIC_PRODUCT_SUGGEST_ERROR_CODES = [
169
+ 'VALIDATION_FAILED',
170
+ 'INVALID_SUGGEST_QUERY',
171
+ 'PRODUCT_LOOKUP_INCOMPLETE',
172
+ ];
161
173
  /** Rows one `POST /products { mode: 'upsert' }` request takes; a longer file is sent in chunks. */
162
174
  export const PRODUCT_UPSERT_ROW_CAP = 200;
163
175
  /**
@@ -663,11 +663,12 @@ declare global {
663
663
  * The codes a catalogue operation answers through its public web route's own core, as that
664
664
  * route does: 404 `PRODUCT_NOT_FOUND` / `PRODUCT_GROUP_NOT_FOUND` / `COLLECTION_NOT_FOUND`,
665
665
  * 400 `INVALID_CURSOR` / `INVALID_DISCOVERY_QUERY` / `INVALID_UPDATED_AT` (an `incomes`
666
- * `updatedAt` that is not digits within the safe-integer range), 409 `CURSOR_STALE` (a
666
+ * `updatedAt` that is not digits within the safe-integer range) / `DISCOVERY_SORT_UNSUPPORTED`
667
+ * (a `products` read with a well-formed `sort` the api does not serve), 409 `CURSOR_STALE` (a
667
668
  * collection that changed between the reads bracketing a page) and 503
668
669
  * `PRODUCT_LOOKUP_INCOMPLETE`.
669
670
  */
670
- type StorefrontPreviewCatalogueErrorCode = 'PRODUCT_NOT_FOUND' | 'PRODUCT_GROUP_NOT_FOUND' | 'COLLECTION_NOT_FOUND' | 'INVALID_CURSOR' | 'INVALID_DISCOVERY_QUERY' | 'INVALID_UPDATED_AT' | 'CURSOR_STALE' | 'PRODUCT_LOOKUP_INCOMPLETE';
671
+ type StorefrontPreviewCatalogueErrorCode = 'PRODUCT_NOT_FOUND' | 'PRODUCT_GROUP_NOT_FOUND' | 'COLLECTION_NOT_FOUND' | 'INVALID_CURSOR' | 'INVALID_DISCOVERY_QUERY' | 'INVALID_UPDATED_AT' | 'DISCOVERY_SORT_UNSUPPORTED' | 'CURSOR_STALE' | 'PRODUCT_LOOKUP_INCOMPLETE';
671
672
  interface StorefrontPreviewReadFailure {
672
673
  message: string;
673
674
  error: StorefrontPreviewReadErrorCode | StorefrontPreviewCatalogueErrorCode;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "platform-types",
3
- "version": "1.10.763",
3
+ "version": "1.10.764",
4
4
  "description": "Shared wire and entity contracts for the platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",