@asteby/storefront 0.10.0 → 0.11.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 +149 -4
- package/dist/cli.js +665 -0
- package/dist/fiscal-document.cjs +659 -0
- package/dist/fiscal-document.cjs.map +1 -0
- package/dist/fiscal-document.d.cts +215 -0
- package/dist/fiscal-document.d.ts +215 -0
- package/dist/fiscal-document.js +641 -0
- package/dist/fiscal-document.js.map +1 -0
- package/dist/index.cjs +93 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +61 -5
- package/dist/index.d.ts +61 -5
- package/dist/index.js +91 -6
- package/dist/index.js.map +1 -1
- package/dist/mock.cjs +1072 -11
- package/dist/mock.cjs.map +1 -1
- package/dist/mock.d.cts +33 -2
- package/dist/mock.d.ts +33 -2
- package/dist/mock.js +1069 -12
- package/dist/mock.js.map +1 -1
- package/dist/mockup.d.cts +1 -1
- package/dist/mockup.d.ts +1 -1
- package/dist/node.cjs +243 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +100 -0
- package/dist/node.d.ts +100 -0
- package/dist/node.js +209 -0
- package/dist/node.js.map +1 -0
- package/dist/{types-DdLzlxw4.d.cts → types-C-Ley-Mt.d.cts} +293 -3
- package/dist/{types-COSwo4ND.d.ts → types-D7UJxrba.d.ts} +293 -3
- package/package.json +41 -3
package/dist/mock.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
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-C-Ley-Mt.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 {
|
|
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-D7UJxrba.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 };
|