@asstio-dev/storefront 0.13.0 → 0.14.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/dist/index.d.ts +1 -1
- package/dist/schema.d.ts +30 -0
- package/dist/seo/product.js +9 -1
- package/dist/seo/types.d.ts +4 -0
- package/package.json +1 -1
- package/src/schema.d.ts +30 -0
package/dist/index.d.ts
CHANGED
|
@@ -56,4 +56,4 @@ export { brandHead, collectionHead, productHead, toNextMetadata } from "./seo/he
|
|
|
56
56
|
export { gtinJsonLd } from "./gtin.js";
|
|
57
57
|
export { productJsonLd } from "./seo/product.js";
|
|
58
58
|
export { jsonLdScript } from "./seo/serialize.js";
|
|
59
|
-
export { SeoError, type BreadcrumbLink, type CollectionHeadOptions, type HeadOptions, type JsonLd, type NextMetadataLike, type ProductJsonLdOptions, type SchemaProperty, type SeoContext, type SeoHead, type SeoMeta, } from "./seo/types.js";
|
|
59
|
+
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";
|
package/dist/schema.d.ts
CHANGED
|
@@ -456,6 +456,7 @@ export interface components {
|
|
|
456
456
|
};
|
|
457
457
|
CartDto: {
|
|
458
458
|
currency: string;
|
|
459
|
+
delivery: null | components["schemas"]["DeliveryRangeDto"];
|
|
459
460
|
grandTotalInc: string;
|
|
460
461
|
lines: components["schemas"]["CartLineDto"][];
|
|
461
462
|
market: string;
|
|
@@ -467,6 +468,8 @@ export interface components {
|
|
|
467
468
|
warnings: components["schemas"]["WarningDto"][];
|
|
468
469
|
};
|
|
469
470
|
CartLineDto: {
|
|
471
|
+
availability: components["schemas"]["LineAvailability"];
|
|
472
|
+
delivery: null | components["schemas"]["DeliveryRangeDto"];
|
|
470
473
|
id: string;
|
|
471
474
|
image: null | components["schemas"]["MediaDescriptorDto"];
|
|
472
475
|
price: components["schemas"]["PriceDto"];
|
|
@@ -501,6 +504,7 @@ export interface components {
|
|
|
501
504
|
};
|
|
502
505
|
CheckoutCartDto: {
|
|
503
506
|
currency: string;
|
|
507
|
+
delivery: null | components["schemas"]["DeliveryRangeDto"];
|
|
504
508
|
grandTotalInc: string;
|
|
505
509
|
lines: components["schemas"]["CheckoutCartLineDto"][];
|
|
506
510
|
subtotalInc: string;
|
|
@@ -508,6 +512,8 @@ export interface components {
|
|
|
508
512
|
version: number | string;
|
|
509
513
|
};
|
|
510
514
|
CheckoutCartLineDto: {
|
|
515
|
+
availability: null | components["schemas"]["LineAvailability"];
|
|
516
|
+
delivery: null | components["schemas"]["DeliveryRangeDto"];
|
|
511
517
|
image: null | components["schemas"]["MediaDescriptorDto"];
|
|
512
518
|
lineTotalInc: string;
|
|
513
519
|
name: string;
|
|
@@ -568,6 +574,7 @@ export interface components {
|
|
|
568
574
|
attemptId: string;
|
|
569
575
|
order: null | components["schemas"]["CheckoutOrderRefDto"];
|
|
570
576
|
paymentStatus: null | string;
|
|
577
|
+
promisedDelivery: null | components["schemas"]["DeliveryRangeDto"];
|
|
571
578
|
status: string;
|
|
572
579
|
widget: null | components["schemas"]["CheckoutWidgetDto"];
|
|
573
580
|
};
|
|
@@ -611,6 +618,12 @@ export interface components {
|
|
|
611
618
|
slug: string;
|
|
612
619
|
url: string;
|
|
613
620
|
};
|
|
621
|
+
DeliveryRangeDto: {
|
|
622
|
+
/** Format: int32 */
|
|
623
|
+
max: number;
|
|
624
|
+
/** Format: int32 */
|
|
625
|
+
min: number;
|
|
626
|
+
};
|
|
614
627
|
DescriptionDto: {
|
|
615
628
|
html: string;
|
|
616
629
|
text: string;
|
|
@@ -649,6 +662,8 @@ export interface components {
|
|
|
649
662
|
facet: string;
|
|
650
663
|
values: components["schemas"]["FacetValueDto"][];
|
|
651
664
|
};
|
|
665
|
+
/** @enum {unknown} */
|
|
666
|
+
LineAvailability: "backorder" | "inStock";
|
|
652
667
|
ListingResponse: {
|
|
653
668
|
appliedFilters: components["schemas"]["AppliedFilterDto"][];
|
|
654
669
|
facets: components["schemas"]["FacetDto"][];
|
|
@@ -774,6 +789,7 @@ export interface components {
|
|
|
774
789
|
orderNumber: null | string;
|
|
775
790
|
/** Format: date-time */
|
|
776
791
|
placedAt: string;
|
|
792
|
+
promisedDelivery: null | components["schemas"]["DeliveryRangeDto"];
|
|
777
793
|
reference: string;
|
|
778
794
|
status: components["schemas"]["OrderStatusDto"];
|
|
779
795
|
test: boolean;
|
|
@@ -827,6 +843,7 @@ export interface components {
|
|
|
827
843
|
};
|
|
828
844
|
ProductCardDto: {
|
|
829
845
|
brand: null | components["schemas"]["BrandDto"];
|
|
846
|
+
buyable: boolean;
|
|
830
847
|
collections: string[];
|
|
831
848
|
id: string;
|
|
832
849
|
image: null | components["schemas"]["MediaDescriptorDto"];
|
|
@@ -897,6 +914,9 @@ export interface components {
|
|
|
897
914
|
importer: null | components["schemas"]["PartyDto"];
|
|
898
915
|
manufacturer: null | components["schemas"]["PartyDto"];
|
|
899
916
|
};
|
|
917
|
+
SellabilityDto: {
|
|
918
|
+
mode: components["schemas"]["SiteSellabilityMode"];
|
|
919
|
+
};
|
|
900
920
|
SeoDto: {
|
|
901
921
|
description: null | string;
|
|
902
922
|
title: string;
|
|
@@ -912,8 +932,11 @@ export interface components {
|
|
|
912
932
|
media: components["schemas"]["MediaDto"];
|
|
913
933
|
name: string;
|
|
914
934
|
preview: boolean;
|
|
935
|
+
sellability: components["schemas"]["SellabilityDto"];
|
|
915
936
|
urlPatterns: components["schemas"]["UrlPatternsDto"];
|
|
916
937
|
};
|
|
938
|
+
/** @enum {unknown} */
|
|
939
|
+
SiteSellabilityMode: "backorder" | "onHand";
|
|
917
940
|
SitemapEntryDto: {
|
|
918
941
|
alternateUrls: {
|
|
919
942
|
[key: string]: string;
|
|
@@ -1003,8 +1026,15 @@ export interface components {
|
|
|
1003
1026
|
collection: string;
|
|
1004
1027
|
product: string;
|
|
1005
1028
|
};
|
|
1029
|
+
/** @enum {unknown} */
|
|
1030
|
+
VariantAvailability: "backorder" | "inStock" | "unavailable";
|
|
1006
1031
|
VariantDto: {
|
|
1032
|
+
availability: components["schemas"]["VariantAvailability"];
|
|
1033
|
+
/** Format: int32 */
|
|
1034
|
+
availableUnits: number;
|
|
1035
|
+
backorderDelivery: null | components["schemas"]["DeliveryRangeDto"];
|
|
1007
1036
|
brand: null | components["schemas"]["BrandDto"];
|
|
1037
|
+
delivery: null | components["schemas"]["DeliveryRangeDto"];
|
|
1008
1038
|
gtin: null | string;
|
|
1009
1039
|
gtins: string[];
|
|
1010
1040
|
hasOwnImages: boolean;
|
package/dist/seo/product.js
CHANGED
|
@@ -3,7 +3,15 @@ import { jsonLdDescription, pickImages, productDescription, rejectRedirect, requ
|
|
|
3
3
|
import { SeoError } from "./types.js";
|
|
4
4
|
const PROPERTIES = ["size", "color", "material", "pattern"];
|
|
5
5
|
const IN_STOCK = "https://schema.org/InStock";
|
|
6
|
+
const BACK_ORDER = "https://schema.org/BackOrder";
|
|
6
7
|
const OUT_OF_STOCK = "https://schema.org/OutOfStock";
|
|
8
|
+
const SCHEMA_AVAILABILITY = { inStock: IN_STOCK, backorder: BACK_ORDER, unavailable: OUT_OF_STOCK };
|
|
9
|
+
/** Sellability C1 §6: the caller's answer, else the variant's own; a response from an API older than 0.14 has no
|
|
10
|
+
* `availability` and falls back to `inStock`. */
|
|
11
|
+
function availabilityOf(v, ctx) {
|
|
12
|
+
const state = ctx.availability?.(v) ?? v.availability ?? (v.inStock ? "inStock" : "unavailable");
|
|
13
|
+
return SCHEMA_AVAILABILITY[state] ?? OUT_OF_STOCK;
|
|
14
|
+
}
|
|
7
15
|
const brandNode = (label) => ({ "@type": "Brand", name: label });
|
|
8
16
|
/** Spec §4.12: absolute http(s), distinct per variant; checked for every emitted variant, single path included. */
|
|
9
17
|
function checkVariantUrls(variants, variantUrl) {
|
|
@@ -77,7 +85,7 @@ export function productJsonLd(p, ctx) {
|
|
|
77
85
|
"@type": "Offer",
|
|
78
86
|
price: v.price.amount,
|
|
79
87
|
priceCurrency: v.price.currency,
|
|
80
|
-
availability: v
|
|
88
|
+
availability: availabilityOf(v, ctx),
|
|
81
89
|
url,
|
|
82
90
|
...offerExtras(ctx),
|
|
83
91
|
});
|
package/dist/seo/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export type SiteDto = Schemas["SiteDto"];
|
|
|
4
4
|
export type MarketDto = Schemas["MarketDto"];
|
|
5
5
|
export type ProductDto = Schemas["ProductDto"];
|
|
6
6
|
export type VariantDto = Schemas["VariantDto"];
|
|
7
|
+
export type VariantAvailability = Schemas["VariantAvailability"];
|
|
7
8
|
export type CollectionListingResponse = Schemas["CollectionListingResponse"];
|
|
8
9
|
export type CollectionCrumbDto = Schemas["CollectionCrumbDto"];
|
|
9
10
|
export type BrandDetailDto = Schemas["BrandDetailDto"];
|
|
@@ -43,6 +44,9 @@ export type ProductJsonLdOptions = SeoContext & {
|
|
|
43
44
|
variants?: VariantDto[];
|
|
44
45
|
/** Overrides the GTIN per variant; return `undefined` to omit. Defaults to the variant's `gtin`. */
|
|
45
46
|
gtin?: (v: VariantDto) => string | undefined;
|
|
47
|
+
/** Sellability C1 §6: the availability for the quantity this page sells (e.g. a pair of the same lens needs two units).
|
|
48
|
+
* Return `undefined` to use the variant's own `availability` (its state for quantity 1). */
|
|
49
|
+
availability?: (v: VariantDto) => VariantAvailability | undefined;
|
|
46
50
|
seller?: {
|
|
47
51
|
name: string;
|
|
48
52
|
};
|
package/package.json
CHANGED
package/src/schema.d.ts
CHANGED
|
@@ -456,6 +456,7 @@ export interface components {
|
|
|
456
456
|
};
|
|
457
457
|
CartDto: {
|
|
458
458
|
currency: string;
|
|
459
|
+
delivery: null | components["schemas"]["DeliveryRangeDto"];
|
|
459
460
|
grandTotalInc: string;
|
|
460
461
|
lines: components["schemas"]["CartLineDto"][];
|
|
461
462
|
market: string;
|
|
@@ -467,6 +468,8 @@ export interface components {
|
|
|
467
468
|
warnings: components["schemas"]["WarningDto"][];
|
|
468
469
|
};
|
|
469
470
|
CartLineDto: {
|
|
471
|
+
availability: components["schemas"]["LineAvailability"];
|
|
472
|
+
delivery: null | components["schemas"]["DeliveryRangeDto"];
|
|
470
473
|
id: string;
|
|
471
474
|
image: null | components["schemas"]["MediaDescriptorDto"];
|
|
472
475
|
price: components["schemas"]["PriceDto"];
|
|
@@ -501,6 +504,7 @@ export interface components {
|
|
|
501
504
|
};
|
|
502
505
|
CheckoutCartDto: {
|
|
503
506
|
currency: string;
|
|
507
|
+
delivery: null | components["schemas"]["DeliveryRangeDto"];
|
|
504
508
|
grandTotalInc: string;
|
|
505
509
|
lines: components["schemas"]["CheckoutCartLineDto"][];
|
|
506
510
|
subtotalInc: string;
|
|
@@ -508,6 +512,8 @@ export interface components {
|
|
|
508
512
|
version: number | string;
|
|
509
513
|
};
|
|
510
514
|
CheckoutCartLineDto: {
|
|
515
|
+
availability: null | components["schemas"]["LineAvailability"];
|
|
516
|
+
delivery: null | components["schemas"]["DeliveryRangeDto"];
|
|
511
517
|
image: null | components["schemas"]["MediaDescriptorDto"];
|
|
512
518
|
lineTotalInc: string;
|
|
513
519
|
name: string;
|
|
@@ -568,6 +574,7 @@ export interface components {
|
|
|
568
574
|
attemptId: string;
|
|
569
575
|
order: null | components["schemas"]["CheckoutOrderRefDto"];
|
|
570
576
|
paymentStatus: null | string;
|
|
577
|
+
promisedDelivery: null | components["schemas"]["DeliveryRangeDto"];
|
|
571
578
|
status: string;
|
|
572
579
|
widget: null | components["schemas"]["CheckoutWidgetDto"];
|
|
573
580
|
};
|
|
@@ -611,6 +618,12 @@ export interface components {
|
|
|
611
618
|
slug: string;
|
|
612
619
|
url: string;
|
|
613
620
|
};
|
|
621
|
+
DeliveryRangeDto: {
|
|
622
|
+
/** Format: int32 */
|
|
623
|
+
max: number;
|
|
624
|
+
/** Format: int32 */
|
|
625
|
+
min: number;
|
|
626
|
+
};
|
|
614
627
|
DescriptionDto: {
|
|
615
628
|
html: string;
|
|
616
629
|
text: string;
|
|
@@ -649,6 +662,8 @@ export interface components {
|
|
|
649
662
|
facet: string;
|
|
650
663
|
values: components["schemas"]["FacetValueDto"][];
|
|
651
664
|
};
|
|
665
|
+
/** @enum {unknown} */
|
|
666
|
+
LineAvailability: "backorder" | "inStock";
|
|
652
667
|
ListingResponse: {
|
|
653
668
|
appliedFilters: components["schemas"]["AppliedFilterDto"][];
|
|
654
669
|
facets: components["schemas"]["FacetDto"][];
|
|
@@ -774,6 +789,7 @@ export interface components {
|
|
|
774
789
|
orderNumber: null | string;
|
|
775
790
|
/** Format: date-time */
|
|
776
791
|
placedAt: string;
|
|
792
|
+
promisedDelivery: null | components["schemas"]["DeliveryRangeDto"];
|
|
777
793
|
reference: string;
|
|
778
794
|
status: components["schemas"]["OrderStatusDto"];
|
|
779
795
|
test: boolean;
|
|
@@ -827,6 +843,7 @@ export interface components {
|
|
|
827
843
|
};
|
|
828
844
|
ProductCardDto: {
|
|
829
845
|
brand: null | components["schemas"]["BrandDto"];
|
|
846
|
+
buyable: boolean;
|
|
830
847
|
collections: string[];
|
|
831
848
|
id: string;
|
|
832
849
|
image: null | components["schemas"]["MediaDescriptorDto"];
|
|
@@ -897,6 +914,9 @@ export interface components {
|
|
|
897
914
|
importer: null | components["schemas"]["PartyDto"];
|
|
898
915
|
manufacturer: null | components["schemas"]["PartyDto"];
|
|
899
916
|
};
|
|
917
|
+
SellabilityDto: {
|
|
918
|
+
mode: components["schemas"]["SiteSellabilityMode"];
|
|
919
|
+
};
|
|
900
920
|
SeoDto: {
|
|
901
921
|
description: null | string;
|
|
902
922
|
title: string;
|
|
@@ -912,8 +932,11 @@ export interface components {
|
|
|
912
932
|
media: components["schemas"]["MediaDto"];
|
|
913
933
|
name: string;
|
|
914
934
|
preview: boolean;
|
|
935
|
+
sellability: components["schemas"]["SellabilityDto"];
|
|
915
936
|
urlPatterns: components["schemas"]["UrlPatternsDto"];
|
|
916
937
|
};
|
|
938
|
+
/** @enum {unknown} */
|
|
939
|
+
SiteSellabilityMode: "backorder" | "onHand";
|
|
917
940
|
SitemapEntryDto: {
|
|
918
941
|
alternateUrls: {
|
|
919
942
|
[key: string]: string;
|
|
@@ -1003,8 +1026,15 @@ export interface components {
|
|
|
1003
1026
|
collection: string;
|
|
1004
1027
|
product: string;
|
|
1005
1028
|
};
|
|
1029
|
+
/** @enum {unknown} */
|
|
1030
|
+
VariantAvailability: "backorder" | "inStock" | "unavailable";
|
|
1006
1031
|
VariantDto: {
|
|
1032
|
+
availability: components["schemas"]["VariantAvailability"];
|
|
1033
|
+
/** Format: int32 */
|
|
1034
|
+
availableUnits: number;
|
|
1035
|
+
backorderDelivery: null | components["schemas"]["DeliveryRangeDto"];
|
|
1007
1036
|
brand: null | components["schemas"]["BrandDto"];
|
|
1037
|
+
delivery: null | components["schemas"]["DeliveryRangeDto"];
|
|
1008
1038
|
gtin: null | string;
|
|
1009
1039
|
gtins: string[];
|
|
1010
1040
|
hasOwnImages: boolean;
|