arky-sdk 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 +11 -3
- package/dist/admin.cjs.map +1 -1
- package/dist/admin.js.map +1 -1
- package/dist/index.cjs +43 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +43 -9
- package/dist/index.js.map +1 -1
- package/dist/storefront.cjs +42 -8
- package/dist/storefront.cjs.map +1 -1
- package/dist/storefront.js +42 -8
- package/dist/storefront.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -219,11 +219,27 @@ var createStorefrontApi = (apiConfig, updateContactSession, lifecycle) => {
|
|
|
219
219
|
},
|
|
220
220
|
async get(params, options) {
|
|
221
221
|
await lifecycle.ensureVisitorSession();
|
|
222
|
+
const queryParams = Object.fromEntries(
|
|
223
|
+
Object.entries(
|
|
224
|
+
options?.params || {}
|
|
225
|
+
).filter(
|
|
226
|
+
([name]) => !["token", "cart_token"].includes(name.toLowerCase())
|
|
227
|
+
)
|
|
228
|
+
);
|
|
229
|
+
const headers = Object.fromEntries(
|
|
230
|
+
Object.entries(options?.headers || {}).filter(
|
|
231
|
+
([name]) => name.toLowerCase() !== "x-arky-cart-token"
|
|
232
|
+
)
|
|
233
|
+
);
|
|
222
234
|
return apiConfig.httpClient.get(
|
|
223
235
|
`${base}/carts/${params.id}`,
|
|
224
236
|
{
|
|
225
237
|
...options,
|
|
226
|
-
|
|
238
|
+
headers: {
|
|
239
|
+
...headers,
|
|
240
|
+
...params.token ? { "X-Arky-Cart-Token": params.token } : {}
|
|
241
|
+
},
|
|
242
|
+
params: Object.keys(queryParams).length > 0 ? queryParams : void 0
|
|
227
243
|
}
|
|
228
244
|
);
|
|
229
245
|
},
|
|
@@ -4095,7 +4111,8 @@ function createElements(stripe, config) {
|
|
|
4095
4111
|
amount: config.amount,
|
|
4096
4112
|
currency: normalizeCurrency(config.currency),
|
|
4097
4113
|
paymentMethodCreation: "manual",
|
|
4098
|
-
...config.appearance ? { appearance: config.appearance } : {}
|
|
4114
|
+
...config.appearance ? { appearance: config.appearance } : {},
|
|
4115
|
+
...config.setupFutureUsage ? { setupFutureUsage: config.setupFutureUsage } : {}
|
|
4099
4116
|
});
|
|
4100
4117
|
}
|
|
4101
4118
|
|
|
@@ -4564,7 +4581,7 @@ function initializeStoreCore(publishableKey, config, scopedClient) {
|
|
|
4564
4581
|
}
|
|
4565
4582
|
return result;
|
|
4566
4583
|
}
|
|
4567
|
-
async function
|
|
4584
|
+
async function mountPayment(target, options = {}) {
|
|
4568
4585
|
await loadSetup();
|
|
4569
4586
|
const publishableKey2 = currentStripePublishableKey();
|
|
4570
4587
|
if (!publishableKey2) {
|
|
@@ -4588,7 +4605,8 @@ function initializeStoreCore(publishableKey, config, scopedClient) {
|
|
|
4588
4605
|
connectedAccountId: currentStripeConnectedAccountId() || void 0,
|
|
4589
4606
|
amount,
|
|
4590
4607
|
currency: paymentCurrency,
|
|
4591
|
-
...options.appearance ? { appearance: options.appearance } : {}
|
|
4608
|
+
...options.appearance ? { appearance: options.appearance } : {},
|
|
4609
|
+
...options.setupFutureUsage ? { setupFutureUsage: options.setupFutureUsage } : {}
|
|
4592
4610
|
});
|
|
4593
4611
|
controller.mount(target);
|
|
4594
4612
|
setPaymentController(controller);
|
|
@@ -4669,8 +4687,16 @@ function initializeStoreCore(publishableKey, config, scopedClient) {
|
|
|
4669
4687
|
async function buildProductCartItem(item, source, productHint) {
|
|
4670
4688
|
try {
|
|
4671
4689
|
const product = productHint?.id === item.product_id ? productHint : await client.eshop.product.get({ id: item.product_id });
|
|
4672
|
-
const variant = product.variants.find(
|
|
4673
|
-
|
|
4690
|
+
const variant = product.variants.find(
|
|
4691
|
+
(candidate) => candidate.id === item.variant_id
|
|
4692
|
+
);
|
|
4693
|
+
if (!variant) {
|
|
4694
|
+
cart_status.setKey(
|
|
4695
|
+
"error",
|
|
4696
|
+
`Cart product ${item.product_id} references unavailable variant ${item.variant_id}.`
|
|
4697
|
+
);
|
|
4698
|
+
return null;
|
|
4699
|
+
}
|
|
4674
4700
|
return {
|
|
4675
4701
|
id: item.id || createId("product"),
|
|
4676
4702
|
product_id: product.id,
|
|
@@ -4684,7 +4710,14 @@ function initializeStoreCore(publishableKey, config, scopedClient) {
|
|
|
4684
4710
|
added_at: source.created_at ? source.created_at * 1e3 : Date.now(),
|
|
4685
4711
|
max_stock: availableStock(client, variant)
|
|
4686
4712
|
};
|
|
4687
|
-
} catch {
|
|
4713
|
+
} catch (error) {
|
|
4714
|
+
cart_status.setKey(
|
|
4715
|
+
"error",
|
|
4716
|
+
readErrorMessage(
|
|
4717
|
+
error,
|
|
4718
|
+
`Failed to load cart product ${item.product_id}.`
|
|
4719
|
+
)
|
|
4720
|
+
);
|
|
4688
4721
|
return null;
|
|
4689
4722
|
}
|
|
4690
4723
|
}
|
|
@@ -4723,6 +4756,7 @@ function initializeStoreCore(publishableKey, config, scopedClient) {
|
|
|
4723
4756
|
promo_code.set(response.promo_code || null);
|
|
4724
4757
|
quote.set(response.quote_snapshot || null);
|
|
4725
4758
|
const items = response.items || [];
|
|
4759
|
+
if (items.length > 0) await loadSetup();
|
|
4726
4760
|
const products = await Promise.all(
|
|
4727
4761
|
items.filter((item) => item.type === "product").map((item) => buildProductCartItem(item, response, options.productHint))
|
|
4728
4762
|
);
|
|
@@ -5641,7 +5675,7 @@ function initializeStoreCore(publishableKey, config, scopedClient) {
|
|
|
5641
5675
|
ready: payment_ready,
|
|
5642
5676
|
setController: setPaymentController,
|
|
5643
5677
|
getController: () => payment_controller.get(),
|
|
5644
|
-
|
|
5678
|
+
mount: mountPayment,
|
|
5645
5679
|
update: updatePaymentController,
|
|
5646
5680
|
destroy: destroyPaymentController
|
|
5647
5681
|
},
|
|
@@ -5796,7 +5830,7 @@ function initialize(publishableKey, options = {}) {
|
|
|
5796
5830
|
}
|
|
5797
5831
|
|
|
5798
5832
|
// src/index.ts
|
|
5799
|
-
var SDK_VERSION = "0.
|
|
5833
|
+
var SDK_VERSION = "0.11.0";
|
|
5800
5834
|
var SUPPORTED_FRAMEWORKS = [
|
|
5801
5835
|
"astro",
|
|
5802
5836
|
"react",
|