@sixtyninecommerce/client 0.3.0 → 0.4.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/README.md +117 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +5 -1
- package/dist/client.js.map +1 -1
- package/dist/commerce/branding.d.ts +6 -0
- package/dist/commerce/branding.d.ts.map +1 -0
- package/dist/commerce/branding.js +138 -0
- package/dist/commerce/branding.js.map +1 -0
- package/dist/commerce/checkout.d.ts +4 -1
- package/dist/commerce/checkout.d.ts.map +1 -1
- package/dist/commerce/checkout.js +24 -2
- package/dist/commerce/checkout.js.map +1 -1
- package/dist/commerce/customer.d.ts +6 -1
- package/dist/commerce/customer.d.ts.map +1 -1
- package/dist/commerce/customer.js +31 -1
- package/dist/commerce/customer.js.map +1 -1
- package/dist/commerce/index.d.ts +2 -2
- package/dist/commerce/index.d.ts.map +1 -1
- package/dist/commerce/index.js +13 -1
- package/dist/commerce/index.js.map +1 -1
- package/dist/commerce/payments.d.ts +8 -0
- package/dist/commerce/payments.d.ts.map +1 -0
- package/dist/commerce/payments.js +30 -0
- package/dist/commerce/payments.js.map +1 -0
- package/dist/commerce/pickup-location-parser.d.ts +6 -0
- package/dist/commerce/pickup-location-parser.d.ts.map +1 -0
- package/dist/commerce/pickup-location-parser.js +97 -0
- package/dist/commerce/pickup-location-parser.js.map +1 -0
- package/dist/commerce/products.d.ts.map +1 -1
- package/dist/commerce/products.js +67 -6
- package/dist/commerce/products.js.map +1 -1
- package/dist/commerce/queries.d.ts +27 -15
- package/dist/commerce/queries.d.ts.map +1 -1
- package/dist/commerce/queries.js +259 -112
- package/dist/commerce/queries.js.map +1 -1
- package/dist/commerce/quotes.d.ts +10 -0
- package/dist/commerce/quotes.d.ts.map +1 -0
- package/dist/commerce/quotes.js +33 -0
- package/dist/commerce/quotes.js.map +1 -0
- package/dist/commerce/reviews.d.ts +2 -1
- package/dist/commerce/reviews.d.ts.map +1 -1
- package/dist/commerce/reviews.js +9 -0
- package/dist/commerce/reviews.js.map +1 -1
- package/dist/commerce/stock-notifications.d.ts +7 -0
- package/dist/commerce/stock-notifications.d.ts.map +1 -0
- package/dist/commerce/stock-notifications.js +48 -0
- package/dist/commerce/stock-notifications.js.map +1 -0
- package/dist/commerce/subscriptions.d.ts +6 -0
- package/dist/commerce/subscriptions.d.ts.map +1 -1
- package/dist/commerce/subscriptions.js +41 -13
- package/dist/commerce/subscriptions.js.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +12 -0
- package/dist/constants.js.map +1 -1
- package/dist/content/items.d.ts +2 -1
- package/dist/content/items.d.ts.map +1 -1
- package/dist/content/items.js +20 -0
- package/dist/content/items.js.map +1 -1
- package/dist/content/menus.d.ts.map +1 -1
- package/dist/content/menus.js +25 -7
- package/dist/content/menus.js.map +1 -1
- package/dist/credit/credit-status.d.ts +6 -0
- package/dist/credit/credit-status.d.ts.map +1 -0
- package/dist/credit/credit-status.js +26 -0
- package/dist/credit/credit-status.js.map +1 -0
- package/dist/credit/index.d.ts +4 -0
- package/dist/credit/index.d.ts.map +1 -0
- package/dist/credit/index.js +5 -0
- package/dist/credit/index.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/media/video.d.ts +4 -1
- package/dist/media/video.d.ts.map +1 -1
- package/dist/media/video.js +20 -1
- package/dist/media/video.js.map +1 -1
- package/dist/navigation/routes.js +2 -2
- package/dist/navigation/routes.js.map +1 -1
- package/dist/seo/ai.d.ts +17 -0
- package/dist/seo/ai.d.ts.map +1 -0
- package/dist/seo/ai.js +32 -0
- package/dist/seo/ai.js.map +1 -0
- package/dist/seo/alternates.d.ts +4 -0
- package/dist/seo/alternates.d.ts.map +1 -0
- package/dist/seo/alternates.js +29 -0
- package/dist/seo/alternates.js.map +1 -0
- package/dist/seo/canonical.d.ts +4 -0
- package/dist/seo/canonical.d.ts.map +1 -0
- package/dist/seo/canonical.js +49 -0
- package/dist/seo/canonical.js.map +1 -0
- package/dist/seo/index.d.ts +9 -0
- package/dist/seo/index.d.ts.map +1 -0
- package/dist/seo/index.js +54 -0
- package/dist/seo/index.js.map +1 -0
- package/dist/seo/json-ld.d.ts +25 -0
- package/dist/seo/json-ld.d.ts.map +1 -0
- package/dist/seo/json-ld.js +113 -0
- package/dist/seo/json-ld.js.map +1 -0
- package/dist/seo/meta-tags.d.ts +58 -0
- package/dist/seo/meta-tags.d.ts.map +1 -0
- package/dist/seo/meta-tags.js +194 -0
- package/dist/seo/meta-tags.js.map +1 -0
- package/dist/seo/metadata-parser.d.ts +31 -0
- package/dist/seo/metadata-parser.d.ts.map +1 -0
- package/dist/seo/metadata-parser.js +180 -0
- package/dist/seo/metadata-parser.js.map +1 -0
- package/dist/seo/metadata-types.d.ts +63 -0
- package/dist/seo/metadata-types.d.ts.map +1 -0
- package/dist/seo/metadata-types.js +2 -0
- package/dist/seo/metadata-types.js.map +1 -0
- package/dist/seo/robots.d.ts +21 -0
- package/dist/seo/robots.d.ts.map +1 -0
- package/dist/seo/robots.js +39 -0
- package/dist/seo/robots.js.map +1 -0
- package/dist/seo/types.d.ts +54 -0
- package/dist/seo/types.d.ts.map +1 -0
- package/dist/seo/types.js +2 -0
- package/dist/seo/types.js.map +1 -0
- package/dist/seo/url-builder.d.ts +11 -0
- package/dist/seo/url-builder.d.ts.map +1 -0
- package/dist/seo/url-builder.js +40 -0
- package/dist/seo/url-builder.js.map +1 -0
- package/dist/types.d.ts +397 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +11 -9
package/README.md
CHANGED
|
@@ -26,6 +26,65 @@ const client = await createStorefrontClient({
|
|
|
26
26
|
const product = await client.commerce.getProduct('blue-shirt');
|
|
27
27
|
const results = await client.commerce.searchProducts({ term: 'shirt' });
|
|
28
28
|
|
|
29
|
+
// Collections (hierarchical taxonomies, auto-synced to facet values)
|
|
30
|
+
// Filter by a collection and get descendants automatically via the
|
|
31
|
+
// FacetValue bridge (`coll--{channelCode}--{id}`) on the server:
|
|
32
|
+
const byCollection = await client.commerce.searchProducts({
|
|
33
|
+
collectionSlug: 'wines',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Canonical + hreflang for <head> tags
|
|
37
|
+
const product = await client.commerce.getProduct('chateau-x');
|
|
38
|
+
const { canonical, alternates } = client.seo.metaFor({
|
|
39
|
+
kind: 'product',
|
|
40
|
+
slug: product.slug,
|
|
41
|
+
translations: product.translations,
|
|
42
|
+
collections: product.collections,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Full structured head metadata, JSON-LD, robots, hreflang merge.
|
|
46
|
+
const tags = client.seo.metaTagsFor({
|
|
47
|
+
kind: 'product',
|
|
48
|
+
product: {
|
|
49
|
+
slug: product.slug,
|
|
50
|
+
translations: product.translations,
|
|
51
|
+
collections: product.collections,
|
|
52
|
+
},
|
|
53
|
+
metadata: product.metadata ?? null,
|
|
54
|
+
extras: {
|
|
55
|
+
name: product.name,
|
|
56
|
+
description: product.description,
|
|
57
|
+
sku: product.variants[0]?.sku,
|
|
58
|
+
price: { amount: '29.99', currency: 'EUR' },
|
|
59
|
+
availability: 'https://schema.org/InStock',
|
|
60
|
+
featuredAsset: product.featuredAsset,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
// tags.title / tags.description / tags.canonical / tags.robots
|
|
64
|
+
// tags.openGraph: [{ property, content }]
|
|
65
|
+
// tags.twitter: [{ name, content }]
|
|
66
|
+
// tags.hreflang: [{ rel, hreflang, href }]
|
|
67
|
+
// tags.jsonLd: [{ '@type': 'Product' }, { '@type': 'BreadcrumbList' }, ...]
|
|
68
|
+
|
|
69
|
+
// Per-bot AI directives — render in <head> and attach as X-Robots-Tag headers.
|
|
70
|
+
const bots = client.seo.robotsDirectiveFor({
|
|
71
|
+
kind: 'product',
|
|
72
|
+
metadata: product.metadata ?? null,
|
|
73
|
+
});
|
|
74
|
+
// bots.metaTags: [{ name: 'GPTBot', content: 'noindex, nofollow' }, ...]
|
|
75
|
+
// bots.xRobotsHeaders: [{ name: 'X-Robots-Tag', value: 'GPTBot: noindex, nofollow' }, ...]
|
|
76
|
+
|
|
77
|
+
// AI summary + llms.txt rendering for AI agents
|
|
78
|
+
const summary = client.seo.aiSummaryFor({ kind: 'product', metadata: product.metadata ?? null });
|
|
79
|
+
const llmsLine = client.seo.llmsTxtEntryFor({
|
|
80
|
+
kind: 'product',
|
|
81
|
+
product: { slug: product.slug, collections: product.collections },
|
|
82
|
+
metadata: product.metadata ?? null,
|
|
83
|
+
url: tags.canonical,
|
|
84
|
+
name: product.name,
|
|
85
|
+
description: product.description,
|
|
86
|
+
});
|
|
87
|
+
|
|
29
88
|
// Cart
|
|
30
89
|
await client.commerce.addToCart(product.variants[0].id, 1);
|
|
31
90
|
const order = await client.commerce.getActiveOrder();
|
|
@@ -79,13 +138,70 @@ const data = await client.graphql(`query { activeChannel { id } }`);
|
|
|
79
138
|
|
|
80
139
|
| Module | Description |
|
|
81
140
|
|--------|-------------|
|
|
82
|
-
| `commerce` | Products, collections, search, cart, checkout, customer auth |
|
|
141
|
+
| `commerce` | Products, collections, property trees, search, cart, checkout, customer auth |
|
|
83
142
|
| `content` | CMS resolve, content items, assets, forms, content strings, menus |
|
|
84
143
|
| `navigation` | Unified route manifest, route lookup |
|
|
85
144
|
| `pricing` | Price formatting, tier lookup, order validation (pure functions) |
|
|
86
145
|
| `media` | CDN URLs, preset URLs, responsive image data (pure functions) |
|
|
87
146
|
| `currency` | Exchange rates, currency conversion |
|
|
88
147
|
|
|
148
|
+
## Price Lists & Volume Pricing
|
|
149
|
+
|
|
150
|
+
Every variant fragment returned by `commerce.getProduct`, `searchProducts`, `getCollection`, `getMyFavorites`, and `getProductRecommendations` already includes the price-list metadata:
|
|
151
|
+
|
|
152
|
+
| Field | Meaning |
|
|
153
|
+
|---|---|
|
|
154
|
+
| `price` / `priceWithTax` | The actual price the visitor will pay (already discounted) |
|
|
155
|
+
| `retailPrice` / `retailPriceWithTax` | The undiscounted list price (use for `<s>` strikethrough) |
|
|
156
|
+
| `priceListName` | Human label of the winning price list (e.g. "Wholesale", "Buy 5+ deal") |
|
|
157
|
+
| `priceTiers` | `[{ minQuantity, price, priceWithTax, discountLabel }]` — full ladder for upsells |
|
|
158
|
+
|
|
159
|
+
Three audiences see populated values:
|
|
160
|
+
|
|
161
|
+
1. **Logged-in customers** with a customer-direct or group assignment
|
|
162
|
+
2. **Logged-in customers** in a channel that has a price list with `appliesToAllCustomers = true`
|
|
163
|
+
3. **Anonymous (guest) visitors** in a channel that has a price list with `appliesToAllCustomers = true`
|
|
164
|
+
|
|
165
|
+
Resolution priority is contract → customer-direct → group → channel-wide → retail (first match wins, not lowest price).
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
// Render a "Buy 5 for €1,249" upsell on the product page
|
|
169
|
+
const product = await client.commerce.getProduct(slug);
|
|
170
|
+
const variant = product.variants[0];
|
|
171
|
+
const nextTier = client.pricing.getTierForQuantity(variant.priceTiers ?? [], 5);
|
|
172
|
+
if (nextTier) {
|
|
173
|
+
// nextTier.priceWithTax · nextTier.minQuantity · nextTier.discountLabel
|
|
174
|
+
}
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Product Documents
|
|
178
|
+
|
|
179
|
+
`commerce.getProduct(slug)` and `commerce.getProductById(id)` return a `documents: PublicProductDocument[]` field with downloadable files attached to the product (manuals, spec sheets, data sheets, certificates). The list is **already filtered by the current customer's visibility** before it leaves the server — the storefront just renders what it gets.
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
const product = await client.commerce.getProduct('drill-pro-2000');
|
|
183
|
+
for (const doc of product.documents ?? []) {
|
|
184
|
+
// <a href={doc.fileUrl} download={doc.fileName}>{doc.title}</a>
|
|
185
|
+
// {doc.description}
|
|
186
|
+
// {doc.fileMimeType} · {formatFileSize(doc.fileSize)}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
| Field | Notes |
|
|
191
|
+
|---|---|
|
|
192
|
+
| `title`, `description` | Resolved for the active language; fall back to the channel default |
|
|
193
|
+
| `fileUrl` | **Already absolute.** Public docs use the channel CDN URL; non-public docs are short-lived presigned R2 URLs (default 15min). Don't pass through any media helper |
|
|
194
|
+
| `fileMimeType`, `fileSize`, `fileName` | Use for the meta line and the `download` attribute |
|
|
195
|
+
| `requiresAuth` | `true` when the URL is presigned. Storefront pages with any `requiresAuth: true` doc must not be cached publicly — set `Cache-Control: private, no-store` on those responses |
|
|
196
|
+
| `position` | Display order — render in this order |
|
|
197
|
+
|
|
198
|
+
Two language modes are transparent to the storefront — the resolver picks the right row before responding:
|
|
199
|
+
|
|
200
|
+
- **Universal**: one file used regardless of the active language (covers English-only docs and multi-lingual single PDFs).
|
|
201
|
+
- **Localized**: per-language title/description with optional per-locale file. Falls back to channel default, then to any sibling translation that has a file.
|
|
202
|
+
|
|
203
|
+
Visibility is gated server-side: `PUBLIC` (everyone), `AUTHENTICATED` (logged-in only), `CUSTOMER_GROUP` (allowlist of customer groups). Anonymous visitors only ever see PUBLIC docs.
|
|
204
|
+
|
|
89
205
|
## Tree-Shakeable Imports
|
|
90
206
|
|
|
91
207
|
```typescript
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAmB3E,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,gBAAgB,CAAC,CAiC3B"}
|
package/dist/client.js
CHANGED
|
@@ -2,22 +2,26 @@ import { createCommerceModule } from './commerce/index.js';
|
|
|
2
2
|
import { createContentModule } from './content/index.js';
|
|
3
3
|
import { createStoreContext } from './core/context.js';
|
|
4
4
|
import { createHttpClient } from './core/http.js';
|
|
5
|
+
import { createCreditModule } from './credit/index.js';
|
|
5
6
|
import { createCurrencyModule } from './currency/index.js';
|
|
6
7
|
import { createMediaModule } from './media/index.js';
|
|
7
8
|
import { createNavigationModule } from './navigation/index.js';
|
|
8
9
|
import { createPricingModule } from './pricing/index.js';
|
|
10
|
+
import { createSeoModule } from './seo/index.js';
|
|
9
11
|
export async function createStorefrontClient(config) {
|
|
10
12
|
const ctx = await createStoreContext(config);
|
|
11
13
|
const http = createHttpClient(ctx);
|
|
12
14
|
return {
|
|
13
15
|
context: ctx,
|
|
14
16
|
maintenanceMode: ctx.channel.customFields.maintenanceMode === true,
|
|
15
|
-
commerce: createCommerceModule(http),
|
|
17
|
+
commerce: createCommerceModule(http, ctx),
|
|
16
18
|
content: createContentModule(http, ctx),
|
|
17
19
|
navigation: createNavigationModule(http),
|
|
18
20
|
pricing: createPricingModule(ctx),
|
|
19
21
|
media: createMediaModule(ctx),
|
|
20
22
|
currency: createCurrencyModule(http),
|
|
23
|
+
credit: createCreditModule(http),
|
|
24
|
+
seo: createSeoModule(ctx),
|
|
21
25
|
setLanguage(code) {
|
|
22
26
|
ctx.languageCode = code;
|
|
23
27
|
},
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MA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iBAAiB,CAAC,GAAG,CAAC;QAC7B,QAAQ,EAAE,oBAAoB,CAAC,IAAI,CAAC;QACpC,MAAM,EAAE,kBAAkB,CAAC,IAAI,CAAC;QAChC,GAAG,EAAE,eAAe,CAAC,GAAG,CAAC;QAEzB,WAAW,CAAC,IAAY;YACtB,GAAG,CAAC,YAAY,GAAG,IAAI,CAAC;QAC1B,CAAC;QACD,WAAW;YACT,OAAO,GAAG,CAAC,YAAY,CAAC;QAC1B,CAAC;QACD,YAAY,CAAC,KAAa;YACxB,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC;QACxB,CAAC;QACD,cAAc;YACZ,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC;QACvB,CAAC;QACD,OAAO,CAAc,KAAa,EAAE,SAAmC;YACrE,OAAO,IAAI,CAAC,OAAO,CAAI,KAAK,EAAE,SAAS,CAAC,CAAC;QAC3C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HttpClient } from '../core/http.js';
|
|
2
|
+
import type { BrandingInfo, RequestOptions, StoreContext } from '../types.js';
|
|
3
|
+
export declare function createBrandingMethods(http: HttpClient, ctx: StoreContext): {
|
|
4
|
+
getBranding(options?: RequestOptions): Promise<BrandingInfo>;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=branding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branding.d.ts","sourceRoot":"","sources":["../../src/commerce/branding.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EAGV,YAAY,EAEZ,cAAc,EACd,YAAY,EACb,MAAM,aAAa,CAAC;AAmBrB,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY;0BAEzC,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;EA+FrE"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { makeAssetUrl } from '../media/urls.js';
|
|
2
|
+
import { GET_BRANDING } from './queries.js';
|
|
3
|
+
export function createBrandingMethods(http, ctx) {
|
|
4
|
+
return {
|
|
5
|
+
async getBranding(options) {
|
|
6
|
+
const cf = ctx.channel.customFields;
|
|
7
|
+
const channelAssetIds = [
|
|
8
|
+
readString(cf.logoAssetId),
|
|
9
|
+
readString(cf.darkLogoAssetId),
|
|
10
|
+
readString(cf.coverAssetId),
|
|
11
|
+
readString(cf.faviconAssetId),
|
|
12
|
+
].filter((id) => typeof id === 'string' && id !== '');
|
|
13
|
+
const uniqueIds = [...new Set(channelAssetIds)];
|
|
14
|
+
const data = await http.graphql(GET_BRANDING, { ids: uniqueIds }, options);
|
|
15
|
+
const channelAssetsById = new Map(data.brandingAssets.map((a) => [a.id, a]));
|
|
16
|
+
const toRef = (asset) => {
|
|
17
|
+
if (!asset)
|
|
18
|
+
return null;
|
|
19
|
+
return {
|
|
20
|
+
id: asset.id,
|
|
21
|
+
url: makeAssetUrl(ctx.cdnUrl, asset.source),
|
|
22
|
+
preview: asset.preview ? makeAssetUrl(ctx.cdnUrl, asset.preview) : null,
|
|
23
|
+
mimeType: asset.mimeType ?? null,
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const channelRef = (id) => toRef(id ? channelAssetsById.get(id) : undefined);
|
|
27
|
+
const fonts = data.fontResources.map((f) => ({
|
|
28
|
+
id: f.id,
|
|
29
|
+
identifier: f.identifier,
|
|
30
|
+
kind: f.kind,
|
|
31
|
+
family: f.family,
|
|
32
|
+
weights: f.weights,
|
|
33
|
+
files: f.files.map((file) => toRef(file)).filter((r) => r !== null),
|
|
34
|
+
}));
|
|
35
|
+
const localeStrategy = readString(cf.urlLocaleStrategy);
|
|
36
|
+
return {
|
|
37
|
+
identity: {
|
|
38
|
+
storeCode: ctx.channel.code,
|
|
39
|
+
businessName: readString(cf.businessName),
|
|
40
|
+
businessDescription: readString(cf.businessDescription),
|
|
41
|
+
websiteUrl: readString(cf.websiteUrl),
|
|
42
|
+
logoLight: channelRef(readString(cf.logoAssetId)),
|
|
43
|
+
logoDark: channelRef(readString(cf.darkLogoAssetId)),
|
|
44
|
+
cover: channelRef(readString(cf.coverAssetId)),
|
|
45
|
+
favicon: channelRef(readString(cf.faviconAssetId)),
|
|
46
|
+
},
|
|
47
|
+
theme: {
|
|
48
|
+
primaryColor: readString(cf.primaryColor),
|
|
49
|
+
},
|
|
50
|
+
fonts,
|
|
51
|
+
contact: {
|
|
52
|
+
email: readString(cf.contactEmail),
|
|
53
|
+
phone: readString(cf.contactPhone),
|
|
54
|
+
},
|
|
55
|
+
legal: {
|
|
56
|
+
name: readString(cf.legalName),
|
|
57
|
+
vatNumber: readString(cf.vatNumber),
|
|
58
|
+
registrationNumber: readString(cf.registrationNumber),
|
|
59
|
+
address: {
|
|
60
|
+
line1: readString(cf.addressLine1),
|
|
61
|
+
line2: readString(cf.addressLine2),
|
|
62
|
+
city: readString(cf.city),
|
|
63
|
+
postalCode: readString(cf.postalCode),
|
|
64
|
+
province: readString(cf.province),
|
|
65
|
+
country: readString(cf.country),
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
social: parseSocialLinks(readString(cf.socialLinks)),
|
|
69
|
+
storefront: {
|
|
70
|
+
url: readString(cf.storefrontUrl),
|
|
71
|
+
cdnUrl: ctx.cdnUrl,
|
|
72
|
+
urlLocaleStrategy: isLocaleStrategy(localeStrategy) ? localeStrategy : 'none',
|
|
73
|
+
urlLocalePrefixDefault: cf.urlLocalePrefixDefault === true,
|
|
74
|
+
commercePathPrefix: readString(cf.commercePathPrefix),
|
|
75
|
+
commercePathPrefixTranslations: parsePrefixTranslations(readString(cf.commercePathPrefixTranslations)),
|
|
76
|
+
maintenanceMode: cf.maintenanceMode === true,
|
|
77
|
+
defaultLanguage: data.activeChannel.defaultLanguageCode,
|
|
78
|
+
defaultCurrency: data.activeChannel.defaultCurrencyCode,
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function readString(value) {
|
|
85
|
+
if (typeof value !== 'string')
|
|
86
|
+
return null;
|
|
87
|
+
const trimmed = value.trim();
|
|
88
|
+
return trimmed === '' ? null : trimmed;
|
|
89
|
+
}
|
|
90
|
+
function isLocaleStrategy(value) {
|
|
91
|
+
return value === 'path-prefix' || value === 'subdomain' || value === 'none';
|
|
92
|
+
}
|
|
93
|
+
function parseSocialLinks(value) {
|
|
94
|
+
if (!value)
|
|
95
|
+
return {};
|
|
96
|
+
try {
|
|
97
|
+
const parsed = JSON.parse(value);
|
|
98
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
99
|
+
return {};
|
|
100
|
+
const result = {};
|
|
101
|
+
const allowed = [
|
|
102
|
+
'facebook',
|
|
103
|
+
'instagram',
|
|
104
|
+
'twitter',
|
|
105
|
+
'linkedin',
|
|
106
|
+
'youtube',
|
|
107
|
+
'tiktok',
|
|
108
|
+
];
|
|
109
|
+
for (const key of allowed) {
|
|
110
|
+
const v = parsed[key];
|
|
111
|
+
if (typeof v === 'string' && v.trim() !== '')
|
|
112
|
+
result[key] = v.trim();
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return {};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function parsePrefixTranslations(value) {
|
|
121
|
+
if (!value)
|
|
122
|
+
return null;
|
|
123
|
+
try {
|
|
124
|
+
const parsed = JSON.parse(value);
|
|
125
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
126
|
+
return null;
|
|
127
|
+
const result = {};
|
|
128
|
+
for (const [k, v] of Object.entries(parsed)) {
|
|
129
|
+
if (typeof v === 'string')
|
|
130
|
+
result[k] = v;
|
|
131
|
+
}
|
|
132
|
+
return Object.keys(result).length > 0 ? result : null;
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=branding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branding.js","sourceRoot":"","sources":["../../src/commerce/branding.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAShD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAkB5C,MAAM,UAAU,qBAAqB,CAAC,IAAgB,EAAE,GAAiB;IACvE,OAAO;QACL,KAAK,CAAC,WAAW,CAAC,OAAwB;YACxC,MAAM,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,YAAY,CAAC;YACpC,MAAM,eAAe,GAAG;gBACtB,UAAU,CAAC,EAAE,CAAC,WAAW,CAAC;gBAC1B,UAAU,CAAC,EAAE,CAAC,eAAe,CAAC;gBAC9B,UAAU,CAAC,EAAE,CAAC,YAAY,CAAC;gBAC3B,UAAU,CAAC,EAAE,CAAC,cAAc,CAAC;aAC9B,CAAC,MAAM,CAAC,CAAC,EAAE,EAAgB,EAAE,CAAC,OAAO,EAAE,KAAK,QAAQ,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;YACpE,MAAM,SAAS,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;YAEhD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAS5B,YAAY,EAAE,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,OAAO,CAAC,CAAC;YAE9C,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAC/B,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAC1C,CAAC;YACF,MAAM,KAAK,GAAG,CAAC,KAA0C,EAA2B,EAAE;gBACpF,IAAI,CAAC,KAAK;oBAAE,OAAO,IAAI,CAAC;gBAC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,CAAC;IACxD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from '../core/http.js';
|
|
2
|
-
import type { AddressInput, CustomerInput, Order, PaymentInput, PaymentMethod, ShippingMethod } from '../types.js';
|
|
2
|
+
import type { AddressInput, CustomerInput, Order, PaymentInput, PaymentMethod, PickupLocation, PickupLocationSearchInput, ShippingMethod } from '../types.js';
|
|
3
3
|
export declare function createCheckoutMethods(http: HttpClient): {
|
|
4
4
|
setCustomerForOrder(input: CustomerInput): Promise<Order>;
|
|
5
5
|
setShippingAddress(input: AddressInput): Promise<Order>;
|
|
@@ -9,5 +9,8 @@ export declare function createCheckoutMethods(http: HttpClient): {
|
|
|
9
9
|
getEligiblePaymentMethods(): Promise<PaymentMethod[]>;
|
|
10
10
|
transitionToArrangingPayment(): Promise<Order>;
|
|
11
11
|
addPayment(input: PaymentInput): Promise<Order>;
|
|
12
|
+
findPickupLocations(input: PickupLocationSearchInput): Promise<PickupLocation[]>;
|
|
13
|
+
selectPickupLocation(location: PickupLocation): Promise<Order>;
|
|
14
|
+
getActivePickupLocation(): Promise<PickupLocation | null>;
|
|
12
15
|
};
|
|
13
16
|
//# sourceMappingURL=checkout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/commerce/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,KAAK,EACL,YAAY,EACZ,aAAa,EACb,cAAc,EACf,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/commerce/checkout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,KAAK,EACL,YAAY,EACZ,aAAa,EACb,cAAc,EACd,yBAAyB,EACzB,cAAc,EACf,MAAM,aAAa,CAAC;AAyCrB,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU;+BAEjB,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC;8BAK/B,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC;6BAO9B,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC;kCAOxB,OAAO,CAAC,cAAc,EAAE,CAAC;2BAOhC,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC;iCAOnB,OAAO,CAAC,aAAa,EAAE,CAAC;oCAOrB,OAAO,CAAC,KAAK,CAAC;sBAK5B,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC;+BAYpB,yBAAyB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;mCAiBjD,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC;+BAYnC,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;EAOlE"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { MutationError } from '../errors.js';
|
|
2
|
-
import {
|
|
2
|
+
import { normalizePickupLocationInput, parseOptionalPickupLocation, parsePickupLocations, } from './pickup-location-parser.js';
|
|
3
|
+
import { ACTIVE_ORDER_PICKUP_LOCATION, ADD_PAYMENT, ELIGIBLE_PAYMENT_METHODS, ELIGIBLE_SHIPPING_METHODS, PICKUP_LOCATIONS, SET_ACTIVE_ORDER_PICKUP_LOCATION, SET_BILLING_ADDRESS, SET_CUSTOMER, SET_SHIPPING_ADDRESS, SET_SHIPPING_METHOD, TRANSITION_TO_ARRANGING_PAYMENT, } from './queries.js';
|
|
3
4
|
function unwrapResult(data, field) {
|
|
4
5
|
const result = data[field];
|
|
5
6
|
if (!result) {
|
|
6
7
|
throw new MutationError('UNKNOWN_ERROR', `No result from ${field}`);
|
|
7
8
|
}
|
|
8
9
|
if ('errorCode' in result) {
|
|
9
|
-
|
|
10
|
+
const transitionError = typeof result.transitionError === 'string' && result.transitionError.length > 0
|
|
11
|
+
? result.transitionError
|
|
12
|
+
: null;
|
|
13
|
+
const message = transitionError ?? result.message;
|
|
14
|
+
throw new MutationError(result.errorCode, message, result);
|
|
10
15
|
}
|
|
11
16
|
return result;
|
|
12
17
|
}
|
|
@@ -50,6 +55,23 @@ export function createCheckoutMethods(http) {
|
|
|
50
55
|
const data = await http.graphql(ADD_PAYMENT, { input });
|
|
51
56
|
return unwrapResult(data, 'addPaymentToOrder');
|
|
52
57
|
},
|
|
58
|
+
async findPickupLocations(input) {
|
|
59
|
+
const data = await http.graphql(PICKUP_LOCATIONS, {
|
|
60
|
+
input,
|
|
61
|
+
});
|
|
62
|
+
return parsePickupLocations(data.pickupLocations);
|
|
63
|
+
},
|
|
64
|
+
async selectPickupLocation(location) {
|
|
65
|
+
const normalized = normalizePickupLocationInput(location);
|
|
66
|
+
const data = await http.graphql(SET_ACTIVE_ORDER_PICKUP_LOCATION, {
|
|
67
|
+
location: normalized,
|
|
68
|
+
});
|
|
69
|
+
return unwrapResult(data, 'setActiveOrderPickupLocation');
|
|
70
|
+
},
|
|
71
|
+
async getActivePickupLocation() {
|
|
72
|
+
const data = await http.graphql(ACTIVE_ORDER_PICKUP_LOCATION);
|
|
73
|
+
return parseOptionalPickupLocation(data.activeOrderPickupLocation);
|
|
74
|
+
},
|
|
53
75
|
};
|
|
54
76
|
}
|
|
55
77
|
//# sourceMappingURL=checkout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../src/commerce/checkout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../src/commerce/checkout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAW7C,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AAK,CAAC,mBAAmB,CAAC,KAAgC;YACxD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAA+B,gBAAgB,EAAE;gBAC9E,KAAK;aACN,CAAC,CAAC;YACH,OAAO,oBAAoB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACpD,CAAC;QAYD,KAAK,CAAC,oBAAoB,CAAC,QAAwB;YACjD,MAAM,UAAU,GAAG,4BAA4B,CAAC,QAAQ,CAAC,CAAC;YAC1D,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAA0B,gCAAgC,EAAE;gBACzF,QAAQ,EAAE,UAAU;aACrB,CAAC,CAAC;YACH,OAAO,YAAY,CAAC,IAAI,EAAE,8BAA8B,CAAC,CAAC;QAC5D,CAAC;QAMD,KAAK,CAAC,uBAAuB;YAC3B,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAC7B,4BAA4B,CAC7B,CAAC;YACF,OAAO,2BAA2B,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;QACrE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from '../core/http.js';
|
|
2
|
-
import type { ActiveChannel, AddressInput, Country, Customer, CustomerAddress, Order, OrderListOptions, OrderSummary, PaginatedList, RegisterInput, UpdateAddressInput, UpdateCustomerInput } from '../types.js';
|
|
2
|
+
import type { ActiveChannel, AddressInput, Country, Customer, CustomerAddress, Order, OrderListOptions, OrderSummary, PaginatedList, RegisterInput, ReorderSkipped, UpdateAddressInput, UpdateCustomerInput } from '../types.js';
|
|
3
3
|
export declare function createCustomerMethods(http: HttpClient): {
|
|
4
4
|
login(email: string, password: string): Promise<{
|
|
5
5
|
id: string;
|
|
@@ -30,6 +30,11 @@ export declare function createCustomerMethods(http: HttpClient): {
|
|
|
30
30
|
deleteAddress(id: string): Promise<void>;
|
|
31
31
|
getAvailableCountries(): Promise<Country[]>;
|
|
32
32
|
getOrderByCode(code: string): Promise<Order>;
|
|
33
|
+
reorder(orderCode: string): Promise<{
|
|
34
|
+
order: Order;
|
|
35
|
+
addedLines: number;
|
|
36
|
+
skipped: ReorderSkipped[];
|
|
37
|
+
}>;
|
|
33
38
|
getActiveChannel(): Promise<ActiveChannel>;
|
|
34
39
|
};
|
|
35
40
|
//# sourceMappingURL=customer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customer.d.ts","sourceRoot":"","sources":["../../src/commerce/customer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,eAAe,EACf,KAAK,EACL,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"customer.d.ts","sourceRoot":"","sources":["../../src/commerce/customer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,eAAe,EACf,KAAK,EACL,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,aAAa,CAAC;AAmCrB,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,UAAU;iBAI/B,MAAM,YAAY,MAAM,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;oBAKnE,aAAa,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;cAKnD,OAAO,CAAC,IAAI,CAAC;yBAKpB,MAAM,aACF,MAAM,GAChB,OAAO,CAAC;QAA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EMAIL_UPDATE, REQUEST_PASSWORD_RESET, RESET_PASSWORD, UPDATE_ADDRESS, UPDATE_CUSTOMER, UPDATE_EMAIL, UPDATE_PASSWORD, VERIFY_ACCOUNT, } from './queries.js';
|
|
2
|
+
import { ADD_TO_CART, AVAILABLE_COUNTRIES, CREATE_ADDRESS, DELETE_ADDRESS, GET_ACTIVE_CHANNEL, GET_CURRENT_CUSTOMER, GET_CUSTOMER_ORDERS, LOGIN, LOGOUT, ORDER_BY_CODE, REFRESH_VERIFICATION, REGISTER, REQUEST_EMAIL_UPDATE, REQUEST_PASSWORD_RESET, RESET_PASSWORD, UPDATE_ADDRESS, UPDATE_CUSTOMER, UPDATE_EMAIL, UPDATE_PASSWORD, VERIFY_ACCOUNT, } from './queries.js';
|
|
3
3
|
function unwrapResult(data, field) {
|
|
4
4
|
const result = data[field];
|
|
5
5
|
if (!result) {
|
|
@@ -113,6 +113,36 @@ export function createCustomerMethods(http) {
|
|
|
113
113
|
const data = await http.graphql(ORDER_BY_CODE, { code });
|
|
114
114
|
return data.orderByCode;
|
|
115
115
|
},
|
|
116
|
+
async reorder(orderCode) {
|
|
117
|
+
const previous = await this.getOrderByCode(orderCode);
|
|
118
|
+
const skipped = [];
|
|
119
|
+
let addedLines = 0;
|
|
120
|
+
let activeOrder = null;
|
|
121
|
+
for (const line of previous.lines) {
|
|
122
|
+
const variantId = line.productVariant.id;
|
|
123
|
+
const quantity = line.quantity;
|
|
124
|
+
const data = await http.graphql(ADD_TO_CART, {
|
|
125
|
+
variantId,
|
|
126
|
+
quantity,
|
|
127
|
+
});
|
|
128
|
+
const result = data.addItemToOrder;
|
|
129
|
+
if (result && 'errorCode' in result) {
|
|
130
|
+
skipped.push({
|
|
131
|
+
variantId,
|
|
132
|
+
quantity,
|
|
133
|
+
errorCode: String(result.errorCode),
|
|
134
|
+
message: String(result.message ?? ''),
|
|
135
|
+
});
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
activeOrder = result;
|
|
139
|
+
addedLines += 1;
|
|
140
|
+
}
|
|
141
|
+
if (!activeOrder) {
|
|
142
|
+
throw new MutationError('REORDER_NO_LINES_ADDED', `Could not add any line from order ${orderCode}`, { skipped });
|
|
143
|
+
}
|
|
144
|
+
return { order: activeOrder, addedLines, skipped };
|
|
145
|
+
},
|
|
116
146
|
async getActiveChannel() {
|
|
117
147
|
const data = await http.graphql(GET_ACTIVE_CHANNEL);
|
|
118
148
|
return data.activeChannel;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"customer.js","sourceRoot":"","sources":["../../src/commerce/customer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"customer.js","sourceRoot":"","sources":["../../src/commerce/customer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAgB7C,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,EACL,MAAM,EACN,aAAa,EACb,oBAAoB,EACpB,QAAQ,EACR,oBAAoB,EACpB,sBAAsB,EACtB,cAAc,EACd,cAAc,EACd,eAAe,EACf,YAAY,EACZ,eAAe,EACf,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,SAAS,YAAY,CAAC,IAA6B,EAAE,KAAa;IAChE,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAwC,CAAC;IAClE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,aAAa,CAAC,eAAe,EAAE,kBAAkB,KAAK,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,IAAI,WAAW,IAAI,MAAM,EAAE,CAAC;QAC1B,MAAM,IAAI,aAAa,CAAC,MAAM,CAAC,SAAmB,EAAE,MAAM,CAAC,OAAiB,EAAE,MAAM,CAAC,CAAC;IACxF,CAAC;IACD,OAAO,MAAM,CAA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AwB,EACxB,qCAAqC,SAAS,EAAE,EAChD,EAAE,OAAO,EAAE,CACZ,CAAC;YACJ,CAAC;YACD,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC;QACrD,CAAC;QAED,KAAK,CAAC,gBAAgB;YACpB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CAAmC,kBAAkB,CAAC,CAAC;YACtF,OAAO,IAAI,CAAC,aAAa,CAAC;QAC5B,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/commerce/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { HttpClient } from '../core/http.js';
|
|
2
|
-
import type { CommerceModule } from '../types.js';
|
|
3
|
-
export declare function createCommerceModule(http: HttpClient): CommerceModule;
|
|
2
|
+
import type { CommerceModule, StoreContext } from '../types.js';
|
|
3
|
+
export declare function createCommerceModule(http: HttpClient, ctx: StoreContext): CommerceModule;
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commerce/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/commerce/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAkBhE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,YAAY,GAAG,cAAc,CAoCxF"}
|
package/dist/commerce/index.js
CHANGED
|
@@ -1,41 +1,53 @@
|
|
|
1
1
|
import { createAgeVerificationMethods } from './age-verification.js';
|
|
2
|
+
import { createBrandingMethods } from './branding.js';
|
|
2
3
|
import { createCartMethods } from './cart.js';
|
|
3
4
|
import { createCheckoutMethods } from './checkout.js';
|
|
4
5
|
import { createCustomerMethods } from './customer.js';
|
|
5
6
|
import { createFavoritesMethods } from './favorites.js';
|
|
7
|
+
import { createPaymentMethods } from './payments.js';
|
|
6
8
|
import { createProductMethods } from './products.js';
|
|
9
|
+
import { createQuotesMethods } from './quotes.js';
|
|
7
10
|
import { createRecommendationsMethods } from './recommendations.js';
|
|
8
11
|
import { createReviewMethods } from './reviews.js';
|
|
9
12
|
import { createSearchMethods } from './search.js';
|
|
10
13
|
import { createShippingMethods } from './shipping.js';
|
|
14
|
+
import { createStockNotificationsMethods } from './stock-notifications.js';
|
|
11
15
|
import { createSubscriptionsMethods } from './subscriptions.js';
|
|
12
16
|
import { createVatValidationMethods } from './vat-validation.js';
|
|
13
|
-
export function createCommerceModule(http) {
|
|
17
|
+
export function createCommerceModule(http, ctx) {
|
|
14
18
|
const products = createProductMethods(http);
|
|
15
19
|
const search = createSearchMethods(http);
|
|
16
20
|
const cart = createCartMethods(http);
|
|
17
21
|
const checkout = createCheckoutMethods(http);
|
|
22
|
+
const payments = createPaymentMethods(http);
|
|
18
23
|
const customer = createCustomerMethods(http);
|
|
19
24
|
const favorites = createFavoritesMethods(http);
|
|
20
25
|
const recommendations = createRecommendationsMethods(http);
|
|
21
26
|
const reviews = createReviewMethods(http);
|
|
22
27
|
const ageVerification = createAgeVerificationMethods(http);
|
|
23
28
|
const subscriptions = createSubscriptionsMethods(http);
|
|
29
|
+
const quotes = createQuotesMethods(http);
|
|
24
30
|
const vatValidation = createVatValidationMethods(http);
|
|
25
31
|
const shipping = createShippingMethods(http);
|
|
32
|
+
const stockNotifications = createStockNotificationsMethods(http);
|
|
33
|
+
const branding = createBrandingMethods(http, ctx);
|
|
26
34
|
return {
|
|
27
35
|
...products,
|
|
28
36
|
...search,
|
|
29
37
|
...cart,
|
|
30
38
|
...checkout,
|
|
39
|
+
...payments,
|
|
31
40
|
...customer,
|
|
32
41
|
...favorites,
|
|
33
42
|
...recommendations,
|
|
34
43
|
...reviews,
|
|
35
44
|
...ageVerification,
|
|
36
45
|
...subscriptions,
|
|
46
|
+
...quotes,
|
|
37
47
|
...vatValidation,
|
|
38
48
|
...shipping,
|
|
49
|
+
...stockNotifications,
|
|
50
|
+
...branding,
|
|
39
51
|
};
|
|
40
52
|
}
|
|
41
53
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commerce/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AAEjE,MAAM,UAAU,oBAAoB,CAAC,IAAgB;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commerce/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,qBAAqB,EAAE,MAAM,e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IAAI,CAAC,CAAC;IAC3D,MAAM,OAAO,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,eAAe,GAAG,4BAA4B,CAAC,IAAI,CAAC,CAAC;IAC3D,MAAM,aAAa,GAAG,0BAA0B,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACzC,MAAM,aAAa,GAAG,0BAA0B,CAAC,IAAI,CAAC,CAAC;IACvD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,kBAAkB,GAAG,+BAA+B,CAAC,IAAI,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,qBAAqB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAElD,OAAO;QACL,GAAG,QAAQ;QACX,GAAG,MAAM;QACT,GAAG,IAAI;QACP,GAAG,QAAQ;QACX,GAAG,QAAQ;QACX,GAAG,QAAQ;QACX,GAAG,SAAS;QACZ,GAAG,eAAe;QAClB,GAAG,OAAO;QACV,GAAG,eAAe;QAClB,GAAG,aAAa;QAChB,GAAG,MAAM;QACT,GAAG,aAAa;QAChB,GAAG,QAAQ;QACX,GAAG,kBAAkB;QACrB,GAAG,QAAQ;KACZ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HttpClient } from '../core/http.js';
|
|
2
|
+
import type { CreateMolliePaymentIntentInput, MolliePaymentIntentResult, MolliePaymentMethod, MolliePaymentMethodsInput, RequestOptions, StripePaymentIntentResult } from '../types.js';
|
|
3
|
+
export declare function createPaymentMethods(http: HttpClient): {
|
|
4
|
+
createStripePaymentIntent(options?: RequestOptions): Promise<StripePaymentIntentResult>;
|
|
5
|
+
getMolliePaymentMethods(input: MolliePaymentMethodsInput, options?: RequestOptions): Promise<MolliePaymentMethod[]>;
|
|
6
|
+
createMolliePaymentIntent(input: CreateMolliePaymentIntentInput, options?: RequestOptions): Promise<MolliePaymentIntentResult>;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=payments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payments.d.ts","sourceRoot":"","sources":["../../src/commerce/payments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,KAAK,EACV,8BAA8B,EAC9B,yBAAyB,EACzB,mBAAmB,EACnB,yBAAyB,EACzB,cAAc,EACd,yBAAyB,EAC1B,MAAM,aAAa,CAAC;AAOrB,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,UAAU;wCAEP,cAAc,GAAG,OAAO,CAAC,yBAAyB,CAAC;mCAiBpF,yBAAyB,YACtB,cAAc,GACvB,OAAO,CAAC,mBAAmB,EAAE,CAAC;qCAUxB,8BAA8B,YAC3B,cAAc,GACvB,OAAO,CAAC,yBAAyB,CAAC;EAcxC"}
|