@asteby/storefront 0.10.0 → 0.11.1

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/mock.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { aI as Shop, ao as Product, w as Collection, aP as Theme, a6 as Page, $ as Menu, b as Article, C as Cart, A as Address, y as Customer, a4 as Order, a9 as PaymentAttemptResult, z as CustomerCapabilities, av as PromotionAnnouncement, aH as ShippingRate, af as PaymentMethod } from './types-DdLzlxw4.cjs';
1
+ import { $ as IdentityRulesV1, aS as RegionFiscalId, Z as IdentityDocumentSpec, aQ as Region, b0 as Shop, aE as Product, x as Collection, b7 as Theme, am as Page, af as Menu, b as Article, C as Cart, A as Address, a5 as InvoiceRequest, z as Customer, ak as Order, ap as PaymentAttemptResult, a7 as InvoiceStage, B as CustomerCapabilities, aL as PromotionAnnouncement, a$ as ShippingRate, av as PaymentMethod } from './types-bsdlAumU.cjs';
2
2
  import './geo.cjs';
3
3
 
4
4
  /**
@@ -16,6 +16,17 @@ declare const MOCK_POSTAL_CENTROIDS: Record<string, {
16
16
  lng: number;
17
17
  }>;
18
18
 
19
+ /**
20
+ * Region fixture of the mock: Mexico exactly as `GET /storefront/region` publishes it (see `region-mx.seed.ts`),
21
+ * identity document `MX:csf` included, so a storefront can be built and tested without a server. It lives here,
22
+ * and only here: the real data belongs to the region package, and the engine in `fiscal-document` knows no country.
23
+ */
24
+
25
+ declare const MOCK_IDENTITY_DOCUMENT_MX_CSF: IdentityDocumentSpec;
26
+ declare const MOCK_CSF_RULES: IdentityRulesV1;
27
+ declare const MOCK_FISCAL_ID_MX: RegionFiscalId;
28
+ declare const MOCK_REGION_MX: Region;
29
+
19
30
  /**
20
31
  * In-memory implementation of the whole Storefront API v1 contract, exposed
21
32
  * as a `fetch` function. Use it to develop and test storefronts without OPS:
@@ -37,6 +48,13 @@ type MockStorefrontOptions = {
37
48
  * create the account straight away (`201`).
38
49
  */
39
50
  customerCapabilities?: Partial<CustomerCapabilities>;
51
+ /**
52
+ * Scopes the mock's `sk_`/`pk_` tokens do NOT have (e.g. `['customer:write']`), to rehearse an under-provisioned
53
+ * store. Routes needing one answer `403 insufficient_scope` with `required_scopes`; `GET /_token` lists them in
54
+ * `missing_scopes`; and `customer/capabilities` reports `password: false`, `unavailable_reason: 'missing_scope'`
55
+ * when `customer:write` is among them. Implies scope enforcement.
56
+ */
57
+ missingScopes?: string[];
40
58
  /** Failed password logins per email before `429 rate_limited` (default 5; a success or a reset clears the count). */
41
59
  maxLoginAttempts?: number;
42
60
  /** Discount codes → percentage off the subtotal (default `{ BIENVENIDA10: 10 }`). */
@@ -73,6 +91,11 @@ type MockStorefrontOptions = {
73
91
  shippingRates?: ShippingRate[];
74
92
  /** Methods served by `payment-methods` (default one builtin `mock`). */
75
93
  paymentMethods?: PaymentMethod[];
94
+ /**
95
+ * What `GET /storefront/region` serves (default `MOCK_REGION_MX`, with its `MX:csf` identity document). `null`: the
96
+ * organization has no region, the route answers `404` and invoice requests are not validated against a region.
97
+ */
98
+ region?: Region | null;
76
99
  };
77
100
  type CartRecord = {
78
101
  id: string;
@@ -86,6 +109,9 @@ type CartRecord = {
86
109
  shipping_address: Address | null;
87
110
  delivery: Cart['delivery'];
88
111
  note: string | null;
112
+ /** Invoice asked for (`PUT /carts/:id/invoice`). */
113
+ invoice: InvoiceRequest | null;
114
+ checkedOut: boolean;
89
115
  updated_at: string;
90
116
  };
91
117
  type MockState = {
@@ -127,6 +153,11 @@ type MockState = {
127
153
  }>;
128
154
  /** `contact|sku` of accepted "notify me" subscriptions. */
129
155
  restock: Set<string>;
156
+ /** Invoice requested per order id. */
157
+ invoices: Map<string, {
158
+ stage: InvoiceStage;
159
+ request: InvoiceRequest;
160
+ }>;
130
161
  seq: number;
131
162
  };
132
163
  declare function createMockStorefront(options?: MockStorefrontOptions): {
@@ -141,4 +172,4 @@ declare function createMockStorefront(options?: MockStorefrontOptions): {
141
172
  };
142
173
  type MockStorefront = ReturnType<typeof createMockStorefront>;
143
174
 
144
- export { MOCK_CURRENCY, MOCK_CUSTOMER_EMAIL, MOCK_IMAGE_URL, MOCK_POSTAL_CENTROIDS, type MockImageUrl, type MockState, type MockStorefront, type MockStorefrontOptions, createMockStorefront };
175
+ export { MOCK_CSF_RULES, MOCK_CURRENCY, MOCK_CUSTOMER_EMAIL, MOCK_FISCAL_ID_MX, MOCK_IDENTITY_DOCUMENT_MX_CSF, MOCK_IMAGE_URL, MOCK_POSTAL_CENTROIDS, MOCK_REGION_MX, type MockImageUrl, type MockState, type MockStorefront, type MockStorefrontOptions, createMockStorefront };
package/dist/mock.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { aI as Shop, ao as Product, w as Collection, aP as Theme, a6 as Page, $ as Menu, b as Article, C as Cart, A as Address, y as Customer, a4 as Order, a9 as PaymentAttemptResult, z as CustomerCapabilities, av as PromotionAnnouncement, aH as ShippingRate, af as PaymentMethod } from './types-COSwo4ND.js';
1
+ import { $ as IdentityRulesV1, aS as RegionFiscalId, Z as IdentityDocumentSpec, aQ as Region, b0 as Shop, aE as Product, x as Collection, b7 as Theme, am as Page, af as Menu, b as Article, C as Cart, A as Address, a5 as InvoiceRequest, z as Customer, ak as Order, ap as PaymentAttemptResult, a7 as InvoiceStage, B as CustomerCapabilities, aL as PromotionAnnouncement, a$ as ShippingRate, av as PaymentMethod } from './types-B1E3GySa.js';
2
2
  import './geo.js';
3
3
 
4
4
  /**
@@ -16,6 +16,17 @@ declare const MOCK_POSTAL_CENTROIDS: Record<string, {
16
16
  lng: number;
17
17
  }>;
18
18
 
19
+ /**
20
+ * Region fixture of the mock: Mexico exactly as `GET /storefront/region` publishes it (see `region-mx.seed.ts`),
21
+ * identity document `MX:csf` included, so a storefront can be built and tested without a server. It lives here,
22
+ * and only here: the real data belongs to the region package, and the engine in `fiscal-document` knows no country.
23
+ */
24
+
25
+ declare const MOCK_IDENTITY_DOCUMENT_MX_CSF: IdentityDocumentSpec;
26
+ declare const MOCK_CSF_RULES: IdentityRulesV1;
27
+ declare const MOCK_FISCAL_ID_MX: RegionFiscalId;
28
+ declare const MOCK_REGION_MX: Region;
29
+
19
30
  /**
20
31
  * In-memory implementation of the whole Storefront API v1 contract, exposed
21
32
  * as a `fetch` function. Use it to develop and test storefronts without OPS:
@@ -37,6 +48,13 @@ type MockStorefrontOptions = {
37
48
  * create the account straight away (`201`).
38
49
  */
39
50
  customerCapabilities?: Partial<CustomerCapabilities>;
51
+ /**
52
+ * Scopes the mock's `sk_`/`pk_` tokens do NOT have (e.g. `['customer:write']`), to rehearse an under-provisioned
53
+ * store. Routes needing one answer `403 insufficient_scope` with `required_scopes`; `GET /_token` lists them in
54
+ * `missing_scopes`; and `customer/capabilities` reports `password: false`, `unavailable_reason: 'missing_scope'`
55
+ * when `customer:write` is among them. Implies scope enforcement.
56
+ */
57
+ missingScopes?: string[];
40
58
  /** Failed password logins per email before `429 rate_limited` (default 5; a success or a reset clears the count). */
41
59
  maxLoginAttempts?: number;
42
60
  /** Discount codes → percentage off the subtotal (default `{ BIENVENIDA10: 10 }`). */
@@ -73,6 +91,11 @@ type MockStorefrontOptions = {
73
91
  shippingRates?: ShippingRate[];
74
92
  /** Methods served by `payment-methods` (default one builtin `mock`). */
75
93
  paymentMethods?: PaymentMethod[];
94
+ /**
95
+ * What `GET /storefront/region` serves (default `MOCK_REGION_MX`, with its `MX:csf` identity document). `null`: the
96
+ * organization has no region, the route answers `404` and invoice requests are not validated against a region.
97
+ */
98
+ region?: Region | null;
76
99
  };
77
100
  type CartRecord = {
78
101
  id: string;
@@ -86,6 +109,9 @@ type CartRecord = {
86
109
  shipping_address: Address | null;
87
110
  delivery: Cart['delivery'];
88
111
  note: string | null;
112
+ /** Invoice asked for (`PUT /carts/:id/invoice`). */
113
+ invoice: InvoiceRequest | null;
114
+ checkedOut: boolean;
89
115
  updated_at: string;
90
116
  };
91
117
  type MockState = {
@@ -127,6 +153,11 @@ type MockState = {
127
153
  }>;
128
154
  /** `contact|sku` of accepted "notify me" subscriptions. */
129
155
  restock: Set<string>;
156
+ /** Invoice requested per order id. */
157
+ invoices: Map<string, {
158
+ stage: InvoiceStage;
159
+ request: InvoiceRequest;
160
+ }>;
130
161
  seq: number;
131
162
  };
132
163
  declare function createMockStorefront(options?: MockStorefrontOptions): {
@@ -141,4 +172,4 @@ declare function createMockStorefront(options?: MockStorefrontOptions): {
141
172
  };
142
173
  type MockStorefront = ReturnType<typeof createMockStorefront>;
143
174
 
144
- export { MOCK_CURRENCY, MOCK_CUSTOMER_EMAIL, MOCK_IMAGE_URL, MOCK_POSTAL_CENTROIDS, type MockImageUrl, type MockState, type MockStorefront, type MockStorefrontOptions, createMockStorefront };
175
+ export { MOCK_CSF_RULES, MOCK_CURRENCY, MOCK_CUSTOMER_EMAIL, MOCK_FISCAL_ID_MX, MOCK_IDENTITY_DOCUMENT_MX_CSF, MOCK_IMAGE_URL, MOCK_POSTAL_CENTROIDS, MOCK_REGION_MX, type MockImageUrl, type MockState, type MockStorefront, type MockStorefrontOptions, createMockStorefront };