@asteby/storefront 0.2.0 → 0.4.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.
@@ -1,9 +1,12 @@
1
+ import { OpeningHours } from './geo.js';
2
+
1
3
  /**
2
4
  * Storefront API v1 contract types.
3
5
  *
4
6
  * Field names match the wire format exactly (snake_case). Money amounts are
5
7
  * decimal strings ("1899.00") so no precision is lost in transit.
6
8
  */
9
+
7
10
  type Money = {
8
11
  amount: string;
9
12
  currency_code: string;
@@ -125,6 +128,53 @@ type ShopBranch = {
125
128
  lat: number | null;
126
129
  lng: number | null;
127
130
  hours: string | null;
131
+ /**
132
+ * Structured hours. Optional: only present once the Storefront API ships
133
+ * `locations.v1`; today's API returns `hours` (free text) only.
134
+ */
135
+ opening_hours?: OpeningHours;
136
+ /** IANA time zone of the branch (e.g. `America/Mexico_City`). Comes with `locations.v1`. */
137
+ timezone?: string;
138
+ /** Human-readable hours, authoritative for display. Comes with `locations.v1`. */
139
+ opening_hours_text?: string;
140
+ /** Postal code of the branch. Comes with `locations.v1`. */
141
+ postal_code?: string | null;
142
+ /** What kind of place it is. Comes with `locations.v1`. */
143
+ kind?: LocationKind;
144
+ /** What can be done there (free-form keys such as `pickup`, `returns`, `repairs`). Comes with `locations.v1`. */
145
+ services?: string[];
146
+ /** Contact channels of the branch. Comes with `locations.v1`. */
147
+ contacts?: LocationContacts;
148
+ /** Pickup ("recoge en sucursal") terms. Comes with `locations.v1`. */
149
+ pickup?: LocationPickup;
150
+ };
151
+ type LocationKind = 'store' | 'warehouse' | 'pickup_point' | 'office' | (string & {});
152
+ type LocationContacts = {
153
+ phone: string | null;
154
+ email: string | null;
155
+ whatsapp: string | null;
156
+ };
157
+ /** `fee` is `null` when pickup is free. `prep_days`: days until the order is ready (0 = same day). */
158
+ type LocationPickup = {
159
+ enabled: boolean;
160
+ fee: Money | null;
161
+ prep_days: number;
162
+ };
163
+ /**
164
+ * A branch as served by `/storefront/locations` (`locations.v1`): a `ShopBranch`
165
+ * whose structured fields are always present. `distance_km` is set only when
166
+ * the answer is ordered by distance (`nearest`, or `list` with `postal_code`).
167
+ */
168
+ type Location = ShopBranch & Required<Pick<ShopBranch, 'kind' | 'services' | 'contacts' | 'pickup' | 'postal_code'>> & {
169
+ distance_km?: number | null;
170
+ };
171
+ /** Answer of `locations.nearest`: always ordered by distance, closest first. */
172
+ type NearestLocation = Location & {
173
+ distance_km: number;
174
+ };
175
+ type LocationListParams = {
176
+ /** Orders the branches by distance to the centroid of this postal code. */
177
+ postal_code?: string;
128
178
  };
129
179
  type ShopPolicies = {
130
180
  free_shipping_min: Money | null;
@@ -462,4 +512,4 @@ type StorefrontErrorBody = {
462
512
  };
463
513
  };
464
514
 
465
- export type { SelectedOption as $, Address as A, MenuItem as B, Cart as C, DeliveryInput as D, Money as E, Facet as F, MoneyRange as G, OrderLine as H, Image as I, PageInfo as J, PaymentMethod as K, PaymentMethods as L, Menu as M, PickupOption as N, Order as O, Page as P, Product as Q, ProductAttributeValue as R, ProductCategory as S, ProductConnection as T, ProductOption as U, ProductSort as V, ProductVariant as W, ReturnRequest as X, ReturnRequestInput as Y, SEO as Z, Section as _, AddressInput as a, ShippingRate as a0, Shop as a1, ShopBranch as a2, ShopContact as a3, ShopPolicies as a4, StockLevel as a5, StorefrontErrorBody as a6, StorefrontErrorCode as a7, Theme as a8, UnavailableRateProvider as a9, Article as b, CartBuyer as c, CartBuyerInput as d, CartCost as e, CartDelivery as f, CartDiscountCode as g, CartLine as h, CartLineInput as i, CartLineMerchandise as j, CartLineUpdateInput as k, CheckoutInfo as l, CheckoutInput as m, CheckoutPayment as n, CheckoutResult as o, Collection as p, Connection as q, Customer as r, CustomerIdentifier as s, CustomerSession as t, CustomerSessionInput as u, DeliveryMethod as v, DeliveryOptions as w, FacetValue as x, InvoiceRequest as y, InvoiceResult as z };
515
+ export type { ProductSort as $, Address as A, LocationContacts as B, Cart as C, DeliveryInput as D, LocationKind as E, Facet as F, LocationListParams as G, LocationPickup as H, Image as I, MenuItem as J, Money as K, Location as L, Menu as M, MoneyRange as N, NearestLocation as O, Order as P, OrderLine as Q, Page as R, PageInfo as S, PaymentMethod as T, PaymentMethods as U, PickupOption as V, Product as W, ProductAttributeValue as X, ProductCategory as Y, ProductConnection as Z, ProductOption as _, AddressInput as a, ProductVariant as a0, ReturnRequest as a1, ReturnRequestInput as a2, SEO as a3, Section as a4, SelectedOption as a5, ShippingRate as a6, Shop as a7, ShopBranch as a8, ShopContact as a9, ShopPolicies as aa, StockLevel as ab, StorefrontErrorBody as ac, StorefrontErrorCode as ad, Theme as ae, UnavailableRateProvider as af, Article as b, CartBuyer as c, CartBuyerInput as d, CartCost as e, CartDelivery as f, CartDiscountCode as g, CartLine as h, CartLineInput as i, CartLineMerchandise as j, CartLineUpdateInput as k, CheckoutInfo as l, CheckoutInput as m, CheckoutPayment as n, CheckoutResult as o, Collection as p, Connection as q, Customer as r, CustomerIdentifier as s, CustomerSession as t, CustomerSessionInput as u, DeliveryMethod as v, DeliveryOptions as w, FacetValue as x, InvoiceRequest as y, InvoiceResult as z };
@@ -1,9 +1,12 @@
1
+ import { OpeningHours } from './geo.cjs';
2
+
1
3
  /**
2
4
  * Storefront API v1 contract types.
3
5
  *
4
6
  * Field names match the wire format exactly (snake_case). Money amounts are
5
7
  * decimal strings ("1899.00") so no precision is lost in transit.
6
8
  */
9
+
7
10
  type Money = {
8
11
  amount: string;
9
12
  currency_code: string;
@@ -125,6 +128,53 @@ type ShopBranch = {
125
128
  lat: number | null;
126
129
  lng: number | null;
127
130
  hours: string | null;
131
+ /**
132
+ * Structured hours. Optional: only present once the Storefront API ships
133
+ * `locations.v1`; today's API returns `hours` (free text) only.
134
+ */
135
+ opening_hours?: OpeningHours;
136
+ /** IANA time zone of the branch (e.g. `America/Mexico_City`). Comes with `locations.v1`. */
137
+ timezone?: string;
138
+ /** Human-readable hours, authoritative for display. Comes with `locations.v1`. */
139
+ opening_hours_text?: string;
140
+ /** Postal code of the branch. Comes with `locations.v1`. */
141
+ postal_code?: string | null;
142
+ /** What kind of place it is. Comes with `locations.v1`. */
143
+ kind?: LocationKind;
144
+ /** What can be done there (free-form keys such as `pickup`, `returns`, `repairs`). Comes with `locations.v1`. */
145
+ services?: string[];
146
+ /** Contact channels of the branch. Comes with `locations.v1`. */
147
+ contacts?: LocationContacts;
148
+ /** Pickup ("recoge en sucursal") terms. Comes with `locations.v1`. */
149
+ pickup?: LocationPickup;
150
+ };
151
+ type LocationKind = 'store' | 'warehouse' | 'pickup_point' | 'office' | (string & {});
152
+ type LocationContacts = {
153
+ phone: string | null;
154
+ email: string | null;
155
+ whatsapp: string | null;
156
+ };
157
+ /** `fee` is `null` when pickup is free. `prep_days`: days until the order is ready (0 = same day). */
158
+ type LocationPickup = {
159
+ enabled: boolean;
160
+ fee: Money | null;
161
+ prep_days: number;
162
+ };
163
+ /**
164
+ * A branch as served by `/storefront/locations` (`locations.v1`): a `ShopBranch`
165
+ * whose structured fields are always present. `distance_km` is set only when
166
+ * the answer is ordered by distance (`nearest`, or `list` with `postal_code`).
167
+ */
168
+ type Location = ShopBranch & Required<Pick<ShopBranch, 'kind' | 'services' | 'contacts' | 'pickup' | 'postal_code'>> & {
169
+ distance_km?: number | null;
170
+ };
171
+ /** Answer of `locations.nearest`: always ordered by distance, closest first. */
172
+ type NearestLocation = Location & {
173
+ distance_km: number;
174
+ };
175
+ type LocationListParams = {
176
+ /** Orders the branches by distance to the centroid of this postal code. */
177
+ postal_code?: string;
128
178
  };
129
179
  type ShopPolicies = {
130
180
  free_shipping_min: Money | null;
@@ -462,4 +512,4 @@ type StorefrontErrorBody = {
462
512
  };
463
513
  };
464
514
 
465
- export type { SelectedOption as $, Address as A, MenuItem as B, Cart as C, DeliveryInput as D, Money as E, Facet as F, MoneyRange as G, OrderLine as H, Image as I, PageInfo as J, PaymentMethod as K, PaymentMethods as L, Menu as M, PickupOption as N, Order as O, Page as P, Product as Q, ProductAttributeValue as R, ProductCategory as S, ProductConnection as T, ProductOption as U, ProductSort as V, ProductVariant as W, ReturnRequest as X, ReturnRequestInput as Y, SEO as Z, Section as _, AddressInput as a, ShippingRate as a0, Shop as a1, ShopBranch as a2, ShopContact as a3, ShopPolicies as a4, StockLevel as a5, StorefrontErrorBody as a6, StorefrontErrorCode as a7, Theme as a8, UnavailableRateProvider as a9, Article as b, CartBuyer as c, CartBuyerInput as d, CartCost as e, CartDelivery as f, CartDiscountCode as g, CartLine as h, CartLineInput as i, CartLineMerchandise as j, CartLineUpdateInput as k, CheckoutInfo as l, CheckoutInput as m, CheckoutPayment as n, CheckoutResult as o, Collection as p, Connection as q, Customer as r, CustomerIdentifier as s, CustomerSession as t, CustomerSessionInput as u, DeliveryMethod as v, DeliveryOptions as w, FacetValue as x, InvoiceRequest as y, InvoiceResult as z };
515
+ export type { ProductSort as $, Address as A, LocationContacts as B, Cart as C, DeliveryInput as D, LocationKind as E, Facet as F, LocationListParams as G, LocationPickup as H, Image as I, MenuItem as J, Money as K, Location as L, Menu as M, MoneyRange as N, NearestLocation as O, Order as P, OrderLine as Q, Page as R, PageInfo as S, PaymentMethod as T, PaymentMethods as U, PickupOption as V, Product as W, ProductAttributeValue as X, ProductCategory as Y, ProductConnection as Z, ProductOption as _, AddressInput as a, ProductVariant as a0, ReturnRequest as a1, ReturnRequestInput as a2, SEO as a3, Section as a4, SelectedOption as a5, ShippingRate as a6, Shop as a7, ShopBranch as a8, ShopContact as a9, ShopPolicies as aa, StockLevel as ab, StorefrontErrorBody as ac, StorefrontErrorCode as ad, Theme as ae, UnavailableRateProvider as af, Article as b, CartBuyer as c, CartBuyerInput as d, CartCost as e, CartDelivery as f, CartDiscountCode as g, CartLine as h, CartLineInput as i, CartLineMerchandise as j, CartLineUpdateInput as k, CheckoutInfo as l, CheckoutInput as m, CheckoutPayment as n, CheckoutResult as o, Collection as p, Connection as q, Customer as r, CustomerIdentifier as s, CustomerSession as t, CustomerSessionInput as u, DeliveryMethod as v, DeliveryOptions as w, FacetValue as x, InvoiceRequest as y, InvoiceResult as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asteby/storefront",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "Typed client for the Storefront API v1 (catalog, cart, checkout, customer, content) using only global fetch — Node 20+, edge runtimes and browsers — plus an in-memory mock of the whole contract.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -37,6 +37,16 @@
37
37
  "default": "./dist/mock.cjs"
38
38
  }
39
39
  },
40
+ "./geo": {
41
+ "import": {
42
+ "types": "./dist/geo.d.ts",
43
+ "default": "./dist/geo.js"
44
+ },
45
+ "require": {
46
+ "types": "./dist/geo.d.cts",
47
+ "default": "./dist/geo.cjs"
48
+ }
49
+ },
40
50
  "./package.json": "./package.json"
41
51
  },
42
52
  "sideEffects": false,