@asstio-dev/storefront 0.42.0 → 0.44.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.
package/README.md CHANGED
@@ -10,8 +10,8 @@ npm install @asstio-dev/storefront
10
10
  ```
11
11
 
12
12
  Setting a shop up in the first place — the Asstio-side MCP calls, the API key kinds, CORS, the filter and
13
- price model — is one document: [`docs/PUBLIC_STOREFRONT_ONBOARDING.md`](../../docs/PUBLIC_STOREFRONT_ONBOARDING.md),
14
- served publicly at <https://api.storefront.asstio.com/docs/onboarding>. This file is only about using the
13
+ price model — starts at [`docs/PUBLIC_STOREFRONT_ONBOARDING.md`](../../docs/PUBLIC_STOREFRONT_ONBOARDING.md) (with the checkout and
14
+ contract-reference parts beside it), served publicly at <https://api.storefront.asstio.com/docs/onboarding>. This file is only about using the
15
15
  package.
16
16
 
17
17
  ```ts
@@ -178,6 +178,22 @@ for (const a of product.attributes) {
178
178
  }
179
179
  ```
180
180
 
181
+ A variant has its own `attributes[]` of the same shape, holding only what that variant has of its own (a shade, a
182
+ strength): it inherits nothing, is always an array and is `[]` on a single product. Read the selected variant's list
183
+ first and the product's after it. The merchant maps these in Asstio, so branch on `type` and, if you want a special
184
+ widget, on a `key` you have seen in a response. `facetKey` and `valueKeys` are always `null` on a variant, and a value is
185
+ free text the platform does not validate:
186
+
187
+ ```ts
188
+ const own = variant.attributes ?? []; // [] when the variant has none
189
+ const isSwatch = (a: (typeof own)[number]) =>
190
+ a.key === "storefront-color" && /^#[0-9a-f]{6}(,#[0-9a-f]{6})*$/i.test(a.value ?? "");
191
+ for (const a of own) {
192
+ if (isSwatch(a)) renderSwatch(a.value!.split(",")); // several colours are comma-separated
193
+ else renderRow(a.label, a.value ?? a.values?.join(", ")); // anything else, a free-text colour included
194
+ }
195
+ ```
196
+
181
197
  `facetKey` and `valueKeys` turn an attribute's values into filter links — `filter[facetKey]=valueKeys[i]`, aligned
182
198
  index-for-index with `values` (or carrying the single `value`'s key). `valueKeys` is absent entirely when any one
183
199
  value has no key of its own: a list is either fully linkable or not linkable at all.
package/dist/index.d.ts CHANGED
@@ -65,3 +65,4 @@ export { trackSearchEvents, type SearchEvent, type SearchEventsResponse } from "
65
65
  export { AnalyticsError, type Ga4Ecommerce, type Ga4Item, type Ga4ItemOptions, type Ga4ItemSource, type Ga4Purchase, type Ga4SharedOptions, type ProductFacts, type SelectedVariant, } from "./analytics/types.js";
66
66
  export { SeoError, type BreadcrumbLink, type CollectionHeadOptions, type HeadOptions, type JsonLd, type NextMetadataLike, type ProductJsonLdOptions, type SchemaProperty, type SeoContext, type SeoHead, type SeoMeta, type VariantAvailability, } from "./seo/types.js";
67
67
  export { readVariantParam, redirectTarget, VARIANT_PARAM, variantQueryForApi, variantUrl, type QueryInput, type VariantParam, } from "./variant.js";
68
+ export { sortOptions, type SortOption } from "./sort.js";
package/dist/index.js CHANGED
@@ -56,3 +56,4 @@ export { trackSearchEvents } from "./analytics/events.js";
56
56
  export { AnalyticsError, } from "./analytics/types.js";
57
57
  export { SeoError, } from "./seo/types.js";
58
58
  export { readVariantParam, redirectTarget, VARIANT_PARAM, variantQueryForApi, variantUrl, } from "./variant.js";
59
+ export { sortOptions } from "./sort.js";
package/dist/schema.d.ts CHANGED
@@ -1193,6 +1193,16 @@ export interface components {
1193
1193
  street: null | string;
1194
1194
  url: null | string;
1195
1195
  };
1196
+ PlacementDto: {
1197
+ available: boolean;
1198
+ /** Format: date-time */
1199
+ firstLiveAt: null | string;
1200
+ /** Format: float */
1201
+ popular: number | string;
1202
+ /** Format: int64 */
1203
+ popularGen: number | string;
1204
+ reason: string;
1205
+ };
1196
1206
  PriceBasisDto: {
1197
1207
  currency: string;
1198
1208
  source: string;
@@ -1231,6 +1241,8 @@ export interface components {
1231
1241
  image: null | components["schemas"]["MediaDescriptorDto"];
1232
1242
  name: string;
1233
1243
  offer: components["schemas"]["OfferDto"];
1244
+ /** @description Preview keys only: why the card stands where it does (reason pinned, keepVisible or base). Absent otherwise. */
1245
+ placement?: components["schemas"]["PlacementDto"];
1234
1246
  priceFrom: null | components["schemas"]["PriceFromDto"];
1235
1247
  priceTo: null | components["schemas"]["PriceFromDto"];
1236
1248
  primaryCategory: null | components["schemas"]["CategoryRefDto"];
@@ -1296,6 +1308,82 @@ export interface components {
1296
1308
  max: null | string;
1297
1309
  min: null | string;
1298
1310
  };
1311
+ RankingCorrectionCoverageDto: {
1312
+ asstio: string;
1313
+ local: string;
1314
+ };
1315
+ RankingEvidenceDto: {
1316
+ /** Format: date-time */
1317
+ computedAt: null | string;
1318
+ correctionCoverage: components["schemas"]["RankingCorrectionCoverageDto"];
1319
+ /** Format: date */
1320
+ coverageStart: null | string;
1321
+ /** Format: int32 */
1322
+ eventCount: number | string;
1323
+ /** Format: int32 */
1324
+ familyCount: number | string;
1325
+ /** Format: int32 */
1326
+ halfLifeDays: number | string;
1327
+ identity: components["schemas"]["RankingEvidenceIdentityDto"];
1328
+ index: components["schemas"]["RankingEvidenceIndexDto"];
1329
+ /** Format: int64 */
1330
+ liveGeneration: number | null | string;
1331
+ newest: components["schemas"]["RankingNewestDto"];
1332
+ /** Format: date-time */
1333
+ observedAt: null | string;
1334
+ policyRevision: null | string;
1335
+ /** Format: date-time */
1336
+ publishedAt: null | string;
1337
+ /** Format: int64 */
1338
+ publishedGeneration: number | null | string;
1339
+ /** Format: int64 */
1340
+ publishingGeneration: number | null | string;
1341
+ returnsDeducted: boolean;
1342
+ siteZeroDemand: boolean;
1343
+ sources: components["schemas"]["RankingEvidenceSourceDto"][];
1344
+ state: string;
1345
+ /** Format: int32 */
1346
+ unmappedLines: number | string;
1347
+ };
1348
+ RankingEvidenceIdentityDto: {
1349
+ asstio: string;
1350
+ local: string;
1351
+ };
1352
+ RankingEvidenceIndexDto: {
1353
+ /** Format: int64 */
1354
+ epoch: number | string;
1355
+ /** Format: int64 */
1356
+ generation: number | null | string;
1357
+ name: string;
1358
+ };
1359
+ RankingEvidenceSourceDto: {
1360
+ initialWalkDone: boolean;
1361
+ /** Format: date-time */
1362
+ lastCompleteScanAt: null | string;
1363
+ lastError: null | string;
1364
+ /** Format: date-time */
1365
+ projectionAt: null | string;
1366
+ /** Format: double */
1367
+ queueAgeSeconds: null | number | string;
1368
+ /** Format: int32 */
1369
+ scanWindowDays: number | null | string;
1370
+ source: string;
1371
+ /** Format: date-time */
1372
+ upstreamCaughtUpAt: null | string;
1373
+ upstreamObservation: null | string;
1374
+ /** Format: date-time */
1375
+ upstreamSweepAt: null | string;
1376
+ upstreamSweepError: null | string;
1377
+ };
1378
+ RankingNewestDto: {
1379
+ /** Format: date-time */
1380
+ bootstrappedAt: null | string;
1381
+ historySource: string;
1382
+ /** Format: int64 */
1383
+ knownDates: number | string;
1384
+ /** Format: int64 */
1385
+ unknownDates: number | string;
1386
+ };
1299
1387
  RelatedGroupDto: {
1300
1388
  key: string;
1301
1389
  label: string;
@@ -1487,10 +1575,29 @@ export interface components {
1487
1575
  total: number | string;
1488
1576
  type: string;
1489
1577
  };
1578
+ SortBaseDto: {
1579
+ applied: string;
1580
+ requested: string;
1581
+ };
1490
1582
  SortDto: {
1583
+ /** @description The sort menu: the configured keys minus price keys this context cannot query, minus popular on a search and while it is not usable, minus newest while no product has a known date, plus selected when a fallback landed outside it. */
1491
1584
  available: components["schemas"]["SortOptionDto"][];
1585
+ /** @description Only when selected is recommended on a site with a ranking configuration: the order recommended is built on (requested: the collection's sort or the site default; applied: after every fallback, relevance on a search). Null otherwise. */
1586
+ base: null | components["schemas"]["SortBaseDto"];
1587
+ /** @description Preview keys only, on a site with a ranking configuration: whether popular is usable for the request's index, and why. Absent otherwise. */
1588
+ evidence?: components["schemas"]["RankingEvidenceDto"];
1589
+ /** @description Every refusal on the way to the applied key, in order (empty on a site without a ranking configuration). Reasons: POPULAR_IN_SEARCH, POPULAR_PUBLISHING, POPULAR_BINDING_UNAVAILABLE, POPULAR_STALE, POPULAR_BOOTSTRAPPING, POPULAR_SOURCE_ERROR, POPULAR_MISSING, POPULAR_NO_ORDERS, POPULAR_DISABLED, NEWEST_UNKNOWN, PRICE_NOT_QUERYABLE, SEARCH_RELEVANCE, INDEX_PENDING_REBUILD. On an index built before the ranking fields, an explicit newest runs on the product's creation date and reports one step from newest to newest with NEWEST_UNKNOWN. */
1590
+ fallback: components["schemas"]["SortFallbackDto"][];
1591
+ /** @description The request's sort when the site accepts it; null when it was omitted or unknown (SORT_UNKNOWN warning). */
1592
+ requested: null | string;
1593
+ /** @description The applied sort key: on a site with a ranking configuration, recommended for an omitted or recommended request (a legacy site answers relevance for an omitted request); otherwise the key the order was built on after every fallback. Always one of available. */
1492
1594
  selected: string;
1493
1595
  };
1596
+ SortFallbackDto: {
1597
+ from: string;
1598
+ reason: string;
1599
+ to: string;
1600
+ };
1494
1601
  SortOptionDto: {
1495
1602
  key: string;
1496
1603
  label: string;
package/dist/sort.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import type { components } from "./schema";
2
+ /** One entry of a sort menu: the key to send as `sort`, its label, and whether it is the order the listing was built on. */
3
+ export type SortOption = {
4
+ key: string;
5
+ label: string;
6
+ selected: boolean;
7
+ };
8
+ /**
9
+ * The sort menu of a listing (spec 2026-11-03 §9.6), in the API's order. `selected` marks `sort.selected`, the key the
10
+ * order was actually built on after every fallback; the API keeps it inside `available`, so a fallback that landed
11
+ * outside the configured menu is still listed and marked. Labels are localized by the API; do not invent your own.
12
+ */
13
+ export declare function sortOptions(listing: {
14
+ sort: components["schemas"]["SortDto"];
15
+ }): SortOption[];
package/dist/sort.js ADDED
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The sort menu of a listing (spec 2026-11-03 §9.6), in the API's order. `selected` marks `sort.selected`, the key the
3
+ * order was actually built on after every fallback; the API keeps it inside `available`, so a fallback that landed
4
+ * outside the configured menu is still listed and marked. Labels are localized by the API; do not invent your own.
5
+ */
6
+ export function sortOptions(listing) {
7
+ const { available, selected } = listing.sort;
8
+ return available.map((o) => ({ key: o.key, label: o.label, selected: o.key === selected }));
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asstio-dev/storefront",
3
- "version": "0.42.0",
3
+ "version": "0.44.0",
4
4
  "description": "Typed client for the Asstio Storefront API (generated from OpenAPI).",
5
5
  "repository": {
6
6
  "type": "git",
package/src/schema.d.ts CHANGED
@@ -1193,6 +1193,16 @@ export interface components {
1193
1193
  street: null | string;
1194
1194
  url: null | string;
1195
1195
  };
1196
+ PlacementDto: {
1197
+ available: boolean;
1198
+ /** Format: date-time */
1199
+ firstLiveAt: null | string;
1200
+ /** Format: float */
1201
+ popular: number | string;
1202
+ /** Format: int64 */
1203
+ popularGen: number | string;
1204
+ reason: string;
1205
+ };
1196
1206
  PriceBasisDto: {
1197
1207
  currency: string;
1198
1208
  source: string;
@@ -1231,6 +1241,8 @@ export interface components {
1231
1241
  image: null | components["schemas"]["MediaDescriptorDto"];
1232
1242
  name: string;
1233
1243
  offer: components["schemas"]["OfferDto"];
1244
+ /** @description Preview keys only: why the card stands where it does (reason pinned, keepVisible or base). Absent otherwise. */
1245
+ placement?: components["schemas"]["PlacementDto"];
1234
1246
  priceFrom: null | components["schemas"]["PriceFromDto"];
1235
1247
  priceTo: null | components["schemas"]["PriceFromDto"];
1236
1248
  primaryCategory: null | components["schemas"]["CategoryRefDto"];
@@ -1296,6 +1308,82 @@ export interface components {
1296
1308
  max: null | string;
1297
1309
  min: null | string;
1298
1310
  };
1311
+ RankingCorrectionCoverageDto: {
1312
+ asstio: string;
1313
+ local: string;
1314
+ };
1315
+ RankingEvidenceDto: {
1316
+ /** Format: date-time */
1317
+ computedAt: null | string;
1318
+ correctionCoverage: components["schemas"]["RankingCorrectionCoverageDto"];
1319
+ /** Format: date */
1320
+ coverageStart: null | string;
1321
+ /** Format: int32 */
1322
+ eventCount: number | string;
1323
+ /** Format: int32 */
1324
+ familyCount: number | string;
1325
+ /** Format: int32 */
1326
+ halfLifeDays: number | string;
1327
+ identity: components["schemas"]["RankingEvidenceIdentityDto"];
1328
+ index: components["schemas"]["RankingEvidenceIndexDto"];
1329
+ /** Format: int64 */
1330
+ liveGeneration: number | null | string;
1331
+ newest: components["schemas"]["RankingNewestDto"];
1332
+ /** Format: date-time */
1333
+ observedAt: null | string;
1334
+ policyRevision: null | string;
1335
+ /** Format: date-time */
1336
+ publishedAt: null | string;
1337
+ /** Format: int64 */
1338
+ publishedGeneration: number | null | string;
1339
+ /** Format: int64 */
1340
+ publishingGeneration: number | null | string;
1341
+ returnsDeducted: boolean;
1342
+ siteZeroDemand: boolean;
1343
+ sources: components["schemas"]["RankingEvidenceSourceDto"][];
1344
+ state: string;
1345
+ /** Format: int32 */
1346
+ unmappedLines: number | string;
1347
+ };
1348
+ RankingEvidenceIdentityDto: {
1349
+ asstio: string;
1350
+ local: string;
1351
+ };
1352
+ RankingEvidenceIndexDto: {
1353
+ /** Format: int64 */
1354
+ epoch: number | string;
1355
+ /** Format: int64 */
1356
+ generation: number | null | string;
1357
+ name: string;
1358
+ };
1359
+ RankingEvidenceSourceDto: {
1360
+ initialWalkDone: boolean;
1361
+ /** Format: date-time */
1362
+ lastCompleteScanAt: null | string;
1363
+ lastError: null | string;
1364
+ /** Format: date-time */
1365
+ projectionAt: null | string;
1366
+ /** Format: double */
1367
+ queueAgeSeconds: null | number | string;
1368
+ /** Format: int32 */
1369
+ scanWindowDays: number | null | string;
1370
+ source: string;
1371
+ /** Format: date-time */
1372
+ upstreamCaughtUpAt: null | string;
1373
+ upstreamObservation: null | string;
1374
+ /** Format: date-time */
1375
+ upstreamSweepAt: null | string;
1376
+ upstreamSweepError: null | string;
1377
+ };
1378
+ RankingNewestDto: {
1379
+ /** Format: date-time */
1380
+ bootstrappedAt: null | string;
1381
+ historySource: string;
1382
+ /** Format: int64 */
1383
+ knownDates: number | string;
1384
+ /** Format: int64 */
1385
+ unknownDates: number | string;
1386
+ };
1299
1387
  RelatedGroupDto: {
1300
1388
  key: string;
1301
1389
  label: string;
@@ -1487,10 +1575,29 @@ export interface components {
1487
1575
  total: number | string;
1488
1576
  type: string;
1489
1577
  };
1578
+ SortBaseDto: {
1579
+ applied: string;
1580
+ requested: string;
1581
+ };
1490
1582
  SortDto: {
1583
+ /** @description The sort menu: the configured keys minus price keys this context cannot query, minus popular on a search and while it is not usable, minus newest while no product has a known date, plus selected when a fallback landed outside it. */
1491
1584
  available: components["schemas"]["SortOptionDto"][];
1585
+ /** @description Only when selected is recommended on a site with a ranking configuration: the order recommended is built on (requested: the collection's sort or the site default; applied: after every fallback, relevance on a search). Null otherwise. */
1586
+ base: null | components["schemas"]["SortBaseDto"];
1587
+ /** @description Preview keys only, on a site with a ranking configuration: whether popular is usable for the request's index, and why. Absent otherwise. */
1588
+ evidence?: components["schemas"]["RankingEvidenceDto"];
1589
+ /** @description Every refusal on the way to the applied key, in order (empty on a site without a ranking configuration). Reasons: POPULAR_IN_SEARCH, POPULAR_PUBLISHING, POPULAR_BINDING_UNAVAILABLE, POPULAR_STALE, POPULAR_BOOTSTRAPPING, POPULAR_SOURCE_ERROR, POPULAR_MISSING, POPULAR_NO_ORDERS, POPULAR_DISABLED, NEWEST_UNKNOWN, PRICE_NOT_QUERYABLE, SEARCH_RELEVANCE, INDEX_PENDING_REBUILD. On an index built before the ranking fields, an explicit newest runs on the product's creation date and reports one step from newest to newest with NEWEST_UNKNOWN. */
1590
+ fallback: components["schemas"]["SortFallbackDto"][];
1591
+ /** @description The request's sort when the site accepts it; null when it was omitted or unknown (SORT_UNKNOWN warning). */
1592
+ requested: null | string;
1593
+ /** @description The applied sort key: on a site with a ranking configuration, recommended for an omitted or recommended request (a legacy site answers relevance for an omitted request); otherwise the key the order was built on after every fallback. Always one of available. */
1492
1594
  selected: string;
1493
1595
  };
1596
+ SortFallbackDto: {
1597
+ from: string;
1598
+ reason: string;
1599
+ to: string;
1600
+ };
1494
1601
  SortOptionDto: {
1495
1602
  key: string;
1496
1603
  label: string;