@asteby/storefront 0.9.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 +181 -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 +111 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +76 -5
- package/dist/index.d.ts +76 -5
- package/dist/index.js +109 -6
- package/dist/index.js.map +1 -1
- package/dist/mock.cjs +1185 -11
- package/dist/mock.cjs.map +1 -1
- package/dist/mock.d.cts +51 -2
- package/dist/mock.d.ts +51 -2
- package/dist/mock.js +1182 -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-CSMuPSQA.d.cts → types-C-Ley-Mt.d.cts} +333 -3
- package/dist/{types-iGGZ9EiC.d.ts → types-D7UJxrba.d.ts} +333 -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:
|
|
@@ -31,6 +42,21 @@ type MockStorefrontOptions = {
|
|
|
31
42
|
imageUrl?: MockImageUrl;
|
|
32
43
|
/** OTP code accepted by `/customer/session` (default `000000`). */
|
|
33
44
|
otpCode?: string;
|
|
45
|
+
/**
|
|
46
|
+
* What `GET /customer/capabilities` reports (default `{ password: true, email_verification: true, otp_channels: ['email'] }`).
|
|
47
|
+
* `password: false` makes register / login / password routes answer `403`; `email_verification: false` makes `register`
|
|
48
|
+
* create the account straight away (`201`).
|
|
49
|
+
*/
|
|
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[];
|
|
58
|
+
/** Failed password logins per email before `429 rate_limited` (default 5; a success or a reset clears the count). */
|
|
59
|
+
maxLoginAttempts?: number;
|
|
34
60
|
/** Discount codes → percentage off the subtotal (default `{ BIENVENIDA10: 10 }`). */
|
|
35
61
|
discountCodes?: Record<string, number>;
|
|
36
62
|
/** Flat shipping rate (default 149). Free from `shop.policies.free_shipping_min`. */
|
|
@@ -65,6 +91,11 @@ type MockStorefrontOptions = {
|
|
|
65
91
|
shippingRates?: ShippingRate[];
|
|
66
92
|
/** Methods served by `payment-methods` (default one builtin `mock`). */
|
|
67
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;
|
|
68
99
|
};
|
|
69
100
|
type CartRecord = {
|
|
70
101
|
id: string;
|
|
@@ -78,6 +109,9 @@ type CartRecord = {
|
|
|
78
109
|
shipping_address: Address | null;
|
|
79
110
|
delivery: Cart['delivery'];
|
|
80
111
|
note: string | null;
|
|
112
|
+
/** Invoice asked for (`PUT /carts/:id/invoice`). */
|
|
113
|
+
invoice: InvoiceRequest | null;
|
|
114
|
+
checkedOut: boolean;
|
|
81
115
|
updated_at: string;
|
|
82
116
|
};
|
|
83
117
|
type MockState = {
|
|
@@ -96,6 +130,16 @@ type MockState = {
|
|
|
96
130
|
customer_id: string | null;
|
|
97
131
|
})[];
|
|
98
132
|
otps: Map<string, string>;
|
|
133
|
+
/** Email → password (plain text: it is a mock). The seed customer starts without one. */
|
|
134
|
+
passwords: Map<string, string>;
|
|
135
|
+
/** Registrations waiting for their code, by email. */
|
|
136
|
+
pendingRegistrations: Map<string, {
|
|
137
|
+
password: string;
|
|
138
|
+
first_name: string | null;
|
|
139
|
+
last_name: string | null;
|
|
140
|
+
}>;
|
|
141
|
+
/** Consecutive failed password logins by email. */
|
|
142
|
+
loginFailures: Map<string, number>;
|
|
99
143
|
sessions: Map<string, string>;
|
|
100
144
|
idempotency: Map<string, {
|
|
101
145
|
status: number;
|
|
@@ -109,6 +153,11 @@ type MockState = {
|
|
|
109
153
|
}>;
|
|
110
154
|
/** `contact|sku` of accepted "notify me" subscriptions. */
|
|
111
155
|
restock: Set<string>;
|
|
156
|
+
/** Invoice requested per order id. */
|
|
157
|
+
invoices: Map<string, {
|
|
158
|
+
stage: InvoiceStage;
|
|
159
|
+
request: InvoiceRequest;
|
|
160
|
+
}>;
|
|
112
161
|
seq: number;
|
|
113
162
|
};
|
|
114
163
|
declare function createMockStorefront(options?: MockStorefrontOptions): {
|
|
@@ -123,4 +172,4 @@ declare function createMockStorefront(options?: MockStorefrontOptions): {
|
|
|
123
172
|
};
|
|
124
173
|
type MockStorefront = ReturnType<typeof createMockStorefront>;
|
|
125
174
|
|
|
126
|
-
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:
|
|
@@ -31,6 +42,21 @@ type MockStorefrontOptions = {
|
|
|
31
42
|
imageUrl?: MockImageUrl;
|
|
32
43
|
/** OTP code accepted by `/customer/session` (default `000000`). */
|
|
33
44
|
otpCode?: string;
|
|
45
|
+
/**
|
|
46
|
+
* What `GET /customer/capabilities` reports (default `{ password: true, email_verification: true, otp_channels: ['email'] }`).
|
|
47
|
+
* `password: false` makes register / login / password routes answer `403`; `email_verification: false` makes `register`
|
|
48
|
+
* create the account straight away (`201`).
|
|
49
|
+
*/
|
|
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[];
|
|
58
|
+
/** Failed password logins per email before `429 rate_limited` (default 5; a success or a reset clears the count). */
|
|
59
|
+
maxLoginAttempts?: number;
|
|
34
60
|
/** Discount codes → percentage off the subtotal (default `{ BIENVENIDA10: 10 }`). */
|
|
35
61
|
discountCodes?: Record<string, number>;
|
|
36
62
|
/** Flat shipping rate (default 149). Free from `shop.policies.free_shipping_min`. */
|
|
@@ -65,6 +91,11 @@ type MockStorefrontOptions = {
|
|
|
65
91
|
shippingRates?: ShippingRate[];
|
|
66
92
|
/** Methods served by `payment-methods` (default one builtin `mock`). */
|
|
67
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;
|
|
68
99
|
};
|
|
69
100
|
type CartRecord = {
|
|
70
101
|
id: string;
|
|
@@ -78,6 +109,9 @@ type CartRecord = {
|
|
|
78
109
|
shipping_address: Address | null;
|
|
79
110
|
delivery: Cart['delivery'];
|
|
80
111
|
note: string | null;
|
|
112
|
+
/** Invoice asked for (`PUT /carts/:id/invoice`). */
|
|
113
|
+
invoice: InvoiceRequest | null;
|
|
114
|
+
checkedOut: boolean;
|
|
81
115
|
updated_at: string;
|
|
82
116
|
};
|
|
83
117
|
type MockState = {
|
|
@@ -96,6 +130,16 @@ type MockState = {
|
|
|
96
130
|
customer_id: string | null;
|
|
97
131
|
})[];
|
|
98
132
|
otps: Map<string, string>;
|
|
133
|
+
/** Email → password (plain text: it is a mock). The seed customer starts without one. */
|
|
134
|
+
passwords: Map<string, string>;
|
|
135
|
+
/** Registrations waiting for their code, by email. */
|
|
136
|
+
pendingRegistrations: Map<string, {
|
|
137
|
+
password: string;
|
|
138
|
+
first_name: string | null;
|
|
139
|
+
last_name: string | null;
|
|
140
|
+
}>;
|
|
141
|
+
/** Consecutive failed password logins by email. */
|
|
142
|
+
loginFailures: Map<string, number>;
|
|
99
143
|
sessions: Map<string, string>;
|
|
100
144
|
idempotency: Map<string, {
|
|
101
145
|
status: number;
|
|
@@ -109,6 +153,11 @@ type MockState = {
|
|
|
109
153
|
}>;
|
|
110
154
|
/** `contact|sku` of accepted "notify me" subscriptions. */
|
|
111
155
|
restock: Set<string>;
|
|
156
|
+
/** Invoice requested per order id. */
|
|
157
|
+
invoices: Map<string, {
|
|
158
|
+
stage: InvoiceStage;
|
|
159
|
+
request: InvoiceRequest;
|
|
160
|
+
}>;
|
|
112
161
|
seq: number;
|
|
113
162
|
};
|
|
114
163
|
declare function createMockStorefront(options?: MockStorefrontOptions): {
|
|
@@ -123,4 +172,4 @@ declare function createMockStorefront(options?: MockStorefrontOptions): {
|
|
|
123
172
|
};
|
|
124
173
|
type MockStorefront = ReturnType<typeof createMockStorefront>;
|
|
125
174
|
|
|
126
|
-
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 };
|