@plasmicpkgs/commerce-swell 0.0.257 → 0.0.258
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/cart/index.d.ts +3 -3
- package/dist/cart/use-add-item.d.ts +5 -5
- package/dist/cart/use-cart.d.ts +6 -6
- package/dist/cart/use-remove-item.d.ts +21 -21
- package/dist/cart/use-update-item.d.ts +33 -33
- package/dist/cart/utils/checkout-create.d.ts +2 -2
- package/dist/cart/utils/checkout-to-cart.d.ts +5 -5
- package/dist/cart/utils/index.d.ts +2 -2
- package/dist/commerce-swell.cjs.development.js +36 -35
- package/dist/commerce-swell.cjs.development.js.map +1 -1
- package/dist/commerce-swell.cjs.production.min.js +1 -1
- package/dist/commerce-swell.cjs.production.min.js.map +1 -1
- package/dist/commerce-swell.esm.js +36 -35
- package/dist/commerce-swell.esm.js.map +1 -1
- package/dist/const.d.ts +4 -4
- package/dist/fetcher.d.ts +3 -3
- package/dist/index.d.ts +7 -7
- package/dist/product/index.d.ts +2 -2
- package/dist/product/use-price.d.ts +2 -2
- package/dist/product/use-product.d.ts +7 -7
- package/dist/product/use-search.d.ts +15 -15
- package/dist/provider.d.ts +132 -81
- package/dist/registerCommerceProvider.d.ts +12 -12
- package/dist/registerable.d.ts +6 -6
- package/dist/site/use-brands.d.ts +5 -5
- package/dist/site/use-categories.d.ts +5 -5
- package/dist/swell.d.ts +9 -9
- package/dist/types/cart.d.ts +18 -18
- package/dist/types/checkout.d.ts +1 -1
- package/dist/types/common.d.ts +1 -1
- package/dist/types/customer.d.ts +1 -1
- package/dist/types/index.d.ts +12 -12
- package/dist/types/login.d.ts +8 -8
- package/dist/types/logout.d.ts +1 -1
- package/dist/types/page.d.ts +1 -1
- package/dist/types/product.d.ts +14 -14
- package/dist/types/signup.d.ts +1 -1
- package/dist/types/site.d.ts +8 -8
- package/dist/types/wishlist.d.ts +1 -1
- package/dist/types.d.ts +98 -98
- package/dist/utils/category-tree.d.ts +3 -3
- package/dist/utils/common.d.ts +2 -2
- package/dist/utils/customer-token.d.ts +3 -3
- package/dist/utils/fetch-swell-api.d.ts +2 -2
- package/dist/utils/get-categories.d.ts +4 -4
- package/dist/utils/get-checkout-id.d.ts +2 -2
- package/dist/utils/get-search-variables.d.ts +6 -6
- package/dist/utils/get-sort-variables.d.ts +2 -2
- package/dist/utils/get-vendors.d.ts +17 -17
- package/dist/utils/handle-fetch-response.d.ts +8 -8
- package/dist/utils/handle-login.d.ts +2 -2
- package/dist/utils/index.d.ts +8 -8
- package/dist/utils/normalize.d.ts +7 -7
- package/dist/utils/storage.d.ts +2 -2
- package/package.json +5 -5
package/dist/cart/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default as useCart } from './use-cart';
|
|
2
|
-
export { default as useAddItem } from './use-add-item';
|
|
3
|
-
export { default as useRemoveItem } from './use-remove-item';
|
|
1
|
+
export { default as useCart } from './use-cart';
|
|
2
|
+
export { default as useAddItem } from './use-add-item';
|
|
3
|
+
export { default as useRemoveItem } from './use-remove-item';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { MutationHook } from '@plasmicpkgs/commerce';
|
|
2
|
-
import { AddItemHook } from '../types/cart';
|
|
3
|
-
declare const _default: () => (input: import("@plasmicpkgs/commerce/dist/types/cart").CartItemBody) => import("@plasmicpkgs/commerce/dist/types/cart").Cart | Promise<import("@plasmicpkgs/commerce/dist/types/cart").Cart | undefined> | undefined;
|
|
4
|
-
export default _default;
|
|
5
|
-
export declare const handler: MutationHook<AddItemHook>;
|
|
1
|
+
import type { MutationHook } from '@plasmicpkgs/commerce';
|
|
2
|
+
import { AddItemHook } from '../types/cart';
|
|
3
|
+
declare const _default: () => (input: import("@plasmicpkgs/commerce/dist/types/cart").CartItemBody) => import("@plasmicpkgs/commerce/dist/types/cart").Cart | Promise<import("@plasmicpkgs/commerce/dist/types/cart").Cart | undefined> | undefined;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const handler: MutationHook<AddItemHook>;
|
package/dist/cart/use-cart.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
declare const _default
|
|
4
|
-
export default _default;
|
|
5
|
-
|
|
6
|
-
export declare const handler: SWRHook<GetCartHook>;
|
|
1
|
+
import type { CartType } from "@plasmicpkgs/commerce";
|
|
2
|
+
import { SWRHook, UseCart } from "@plasmicpkgs/commerce";
|
|
3
|
+
declare const _default: UseCart<typeof handler>;
|
|
4
|
+
export default _default;
|
|
5
|
+
type GetCartHook = CartType.GetCartHook;
|
|
6
|
+
export declare const handler: SWRHook<GetCartHook>;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import type { HookFetcherContext, MutationHookContext } from "@plasmicpkgs/commerce";
|
|
2
|
-
import { CartType } from "@plasmicpkgs/commerce";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
declare const _default: () => (input: {
|
|
9
|
-
id: string;
|
|
10
|
-
}) => Promise<CartType.Cart | null | undefined>;
|
|
11
|
-
export default _default;
|
|
12
|
-
export declare const handler: {
|
|
13
|
-
fetchOptions: {
|
|
14
|
-
query: string;
|
|
15
|
-
method: string;
|
|
16
|
-
};
|
|
17
|
-
fetcher({ input: { itemId }, options, fetch, }: HookFetcherContext<RemoveItemHook>): Promise<CartType.Cart>;
|
|
18
|
-
useHook: ({ fetch }: MutationHookContext<RemoveItemHook>) => () => (input: {
|
|
19
|
-
id: string;
|
|
20
|
-
}) => Promise<CartType.Cart | null | undefined>;
|
|
21
|
-
};
|
|
1
|
+
import type { HookFetcherContext, MutationHookContext } from "@plasmicpkgs/commerce";
|
|
2
|
+
import { CartType } from "@plasmicpkgs/commerce";
|
|
3
|
+
type Cart = CartType.Cart;
|
|
4
|
+
type LineItem = CartType.LineItem;
|
|
5
|
+
type RemoveItemHook = CartType.RemoveItemHook;
|
|
6
|
+
export type RemoveItemFn<T = any> = T extends LineItem ? (input?: RemoveItemActionInput<T>) => Promise<Cart | null | undefined> : (input: RemoveItemActionInput<T>) => Promise<Cart | null>;
|
|
7
|
+
export type RemoveItemActionInput<T = any> = T extends LineItem ? Partial<RemoveItemHook["actionInput"]> : RemoveItemHook["actionInput"];
|
|
8
|
+
declare const _default: () => (input: {
|
|
9
|
+
id: string;
|
|
10
|
+
}) => Promise<CartType.Cart | null | undefined>;
|
|
11
|
+
export default _default;
|
|
12
|
+
export declare const handler: {
|
|
13
|
+
fetchOptions: {
|
|
14
|
+
query: string;
|
|
15
|
+
method: string;
|
|
16
|
+
};
|
|
17
|
+
fetcher({ input: { itemId }, options, fetch, }: HookFetcherContext<RemoveItemHook>): Promise<CartType.Cart>;
|
|
18
|
+
useHook: ({ fetch }: MutationHookContext<RemoveItemHook>) => () => (input: {
|
|
19
|
+
id: string;
|
|
20
|
+
}) => Promise<CartType.Cart | null | undefined>;
|
|
21
|
+
};
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import type { HookFetcherContext, MutationHookContext } from "@plasmicpkgs/commerce";
|
|
2
|
-
import { CartType } from "@plasmicpkgs/commerce";
|
|
3
|
-
import { UpdateItemHook } from "../types/cart";
|
|
4
|
-
declare const _default: <T extends CartType.LineItem | undefined = undefined>(ctx?: {
|
|
5
|
-
item?: T | undefined;
|
|
6
|
-
wait?: number | undefined;
|
|
7
|
-
}) => ((input: (Partial<CartType.CartItemBody> & {
|
|
8
|
-
id: string;
|
|
9
|
-
}) | Partial<Partial<CartType.CartItemBody> & {
|
|
10
|
-
id: string;
|
|
11
|
-
}>) => Promise<CartType.Cart | null | undefined>) & {
|
|
12
|
-
clear(): void;
|
|
13
|
-
} & {
|
|
14
|
-
flush(): void;
|
|
15
|
-
};
|
|
16
|
-
export default _default;
|
|
17
|
-
|
|
18
|
-
export
|
|
19
|
-
export declare const handler: {
|
|
20
|
-
fetchOptions: {
|
|
21
|
-
query: string;
|
|
22
|
-
method: string;
|
|
23
|
-
};
|
|
24
|
-
fetcher({ input: { itemId, item }, options, fetch, }: HookFetcherContext<UpdateItemHook>): Promise<CartType.Cart>;
|
|
25
|
-
useHook: ({ fetch }: MutationHookContext<UpdateItemHook>) => <T extends CartType.LineItem | undefined = undefined>(ctx?: {
|
|
26
|
-
item?: T | undefined;
|
|
27
|
-
wait?: number | undefined;
|
|
28
|
-
}) => ((input: UpdateItemActionInput) => Promise<CartType.Cart | null | undefined>) & {
|
|
29
|
-
clear(): void;
|
|
30
|
-
} & {
|
|
31
|
-
flush(): void;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
1
|
+
import type { HookFetcherContext, MutationHookContext } from "@plasmicpkgs/commerce";
|
|
2
|
+
import { CartType } from "@plasmicpkgs/commerce";
|
|
3
|
+
import { UpdateItemHook } from "../types/cart";
|
|
4
|
+
declare const _default: <T extends CartType.LineItem | undefined = undefined>(ctx?: {
|
|
5
|
+
item?: T | undefined;
|
|
6
|
+
wait?: number | undefined;
|
|
7
|
+
}) => ((input: (Partial<CartType.CartItemBody> & {
|
|
8
|
+
id: string;
|
|
9
|
+
}) | Partial<Partial<CartType.CartItemBody> & {
|
|
10
|
+
id: string;
|
|
11
|
+
}>) => Promise<CartType.Cart | null | undefined>) & {
|
|
12
|
+
clear(): void;
|
|
13
|
+
} & {
|
|
14
|
+
flush(): void;
|
|
15
|
+
};
|
|
16
|
+
export default _default;
|
|
17
|
+
type LineItem = CartType.LineItem;
|
|
18
|
+
export type UpdateItemActionInput<T = any> = T extends LineItem ? Partial<UpdateItemHook["actionInput"]> : UpdateItemHook["actionInput"];
|
|
19
|
+
export declare const handler: {
|
|
20
|
+
fetchOptions: {
|
|
21
|
+
query: string;
|
|
22
|
+
method: string;
|
|
23
|
+
};
|
|
24
|
+
fetcher({ input: { itemId, item }, options, fetch, }: HookFetcherContext<UpdateItemHook>): Promise<CartType.Cart>;
|
|
25
|
+
useHook: ({ fetch }: MutationHookContext<UpdateItemHook>) => <T extends CartType.LineItem | undefined = undefined>(ctx?: {
|
|
26
|
+
item?: T | undefined;
|
|
27
|
+
wait?: number | undefined;
|
|
28
|
+
}) => ((input: UpdateItemActionInput) => Promise<CartType.Cart | null | undefined>) & {
|
|
29
|
+
clear(): void;
|
|
30
|
+
} & {
|
|
31
|
+
flush(): void;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const checkoutCreate: (fetch: any) => Promise<any>;
|
|
2
|
-
export default checkoutCreate;
|
|
1
|
+
export declare const checkoutCreate: (fetch: any) => Promise<any>;
|
|
2
|
+
export default checkoutCreate;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CartType } from '@plasmicpkgs/commerce';
|
|
2
|
-
import { CheckoutLineItemsAddPayload, CheckoutLineItemsRemovePayload, CheckoutLineItemsUpdatePayload } from '../../schema';
|
|
3
|
-
export
|
|
4
|
-
declare const checkoutToCart: (checkoutPayload?:
|
|
5
|
-
export default checkoutToCart;
|
|
1
|
+
import { CartType } from '@plasmicpkgs/commerce';
|
|
2
|
+
import { CheckoutLineItemsAddPayload, CheckoutLineItemsRemovePayload, CheckoutLineItemsUpdatePayload, Maybe } from '../../schema';
|
|
3
|
+
export type CheckoutPayload = CheckoutLineItemsAddPayload | CheckoutLineItemsUpdatePayload | CheckoutLineItemsRemovePayload;
|
|
4
|
+
declare const checkoutToCart: (checkoutPayload?: Maybe<CheckoutPayload>) => CartType.Cart;
|
|
5
|
+
export default checkoutToCart;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default as checkoutToCart } from './checkout-to-cart';
|
|
2
|
-
export { default as checkoutCreate } from './checkout-create';
|
|
1
|
+
export { default as checkoutToCart } from './checkout-to-cart';
|
|
2
|
+
export { default as checkoutCreate } from './checkout-create';
|
|
@@ -210,9 +210,9 @@ function _unsupportedIterableToArray(r, a) {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
/*
|
|
214
|
-
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
215
|
-
Changes: Removed store id and public key
|
|
213
|
+
/*
|
|
214
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
215
|
+
Changes: Removed store id and public key
|
|
216
216
|
*/
|
|
217
217
|
var SWELL_CHECKOUT_ID_COOKIE = 'SWELL_checkoutId';
|
|
218
218
|
var SWELL_CHECKOUT_URL_COOKIE = 'swell_checkoutUrl';
|
|
@@ -228,6 +228,7 @@ var normalizeProductOption = function normalizeProductOption(_ref2) {
|
|
|
228
228
|
var returnValues = values.map(function (value) {
|
|
229
229
|
var output = {
|
|
230
230
|
label: value.name
|
|
231
|
+
// id: value?.id || id,
|
|
231
232
|
};
|
|
232
233
|
if (displayName.match(/colou?r/gi)) {
|
|
233
234
|
output = _extends({}, output, {
|
|
@@ -363,15 +364,15 @@ function normalizeCart(_ref5) {
|
|
|
363
364
|
};
|
|
364
365
|
return cart;
|
|
365
366
|
}
|
|
366
|
-
/*
|
|
367
|
-
export function normalizeCustomer(customer: SwellCustomer): Customer {
|
|
368
|
-
const { first_name: firstName, last_name: lastName } = customer
|
|
369
|
-
return {
|
|
370
|
-
...customer,
|
|
371
|
-
firstName,
|
|
372
|
-
lastName,
|
|
373
|
-
}
|
|
374
|
-
}
|
|
367
|
+
/*
|
|
368
|
+
export function normalizeCustomer(customer: SwellCustomer): Customer {
|
|
369
|
+
const { first_name: firstName, last_name: lastName } = customer
|
|
370
|
+
return {
|
|
371
|
+
...customer,
|
|
372
|
+
firstName,
|
|
373
|
+
lastName,
|
|
374
|
+
}
|
|
375
|
+
}
|
|
375
376
|
*/
|
|
376
377
|
function normalizeLineItem(_ref6) {
|
|
377
378
|
var _product$id, _product$name, _variant$id, _variant$sku;
|
|
@@ -462,17 +463,17 @@ var handleFetchResponse = /*#__PURE__*/function () {
|
|
|
462
463
|
};
|
|
463
464
|
}();
|
|
464
465
|
|
|
465
|
-
/*
|
|
466
|
-
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
467
|
-
Changes: None
|
|
466
|
+
/*
|
|
467
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
468
|
+
Changes: None
|
|
468
469
|
*/
|
|
469
470
|
var getCheckoutId = function getCheckoutId(id) {
|
|
470
471
|
return id != null ? id : Cookies.get(SWELL_CHECKOUT_ID_COOKIE);
|
|
471
472
|
};
|
|
472
473
|
|
|
473
|
-
/*
|
|
474
|
-
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
475
|
-
Changes: None
|
|
474
|
+
/*
|
|
475
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
476
|
+
Changes: None
|
|
476
477
|
*/
|
|
477
478
|
var checkoutToCart = function checkoutToCart(checkoutPayload) {
|
|
478
479
|
if (!checkoutPayload) {
|
|
@@ -525,10 +526,11 @@ var checkoutCreate = /*#__PURE__*/function () {
|
|
|
525
526
|
};
|
|
526
527
|
}();
|
|
527
528
|
|
|
529
|
+
var _default = commerce.useCart;
|
|
528
530
|
var handler = {
|
|
529
531
|
fetchOptions: {
|
|
530
|
-
query:
|
|
531
|
-
method:
|
|
532
|
+
query: "cart",
|
|
533
|
+
method: "get"
|
|
532
534
|
},
|
|
533
535
|
fetcher: function fetcher(_ref) {
|
|
534
536
|
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
@@ -611,7 +613,7 @@ var handler$1 = {
|
|
|
611
613
|
useHook: function useHook(_ref2) {
|
|
612
614
|
var fetch = _ref2.fetch;
|
|
613
615
|
return function () {
|
|
614
|
-
var _useCart =
|
|
616
|
+
var _useCart = _default(),
|
|
615
617
|
mutate = _useCart.mutate;
|
|
616
618
|
return React.useCallback(/*#__PURE__*/function () {
|
|
617
619
|
var _addItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input) {
|
|
@@ -667,7 +669,7 @@ var handler$2 = {
|
|
|
667
669
|
useHook: function useHook(_ref2) {
|
|
668
670
|
var fetch = _ref2.fetch;
|
|
669
671
|
return function () {
|
|
670
|
-
var _useCart =
|
|
672
|
+
var _useCart = _default(),
|
|
671
673
|
mutate = _useCart.mutate;
|
|
672
674
|
return React.useCallback(/*#__PURE__*/function () {
|
|
673
675
|
var _removeItem = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input) {
|
|
@@ -760,7 +762,7 @@ var handler$3 = {
|
|
|
760
762
|
}
|
|
761
763
|
var _ctx = ctx,
|
|
762
764
|
item = _ctx.item;
|
|
763
|
-
var _useCart =
|
|
765
|
+
var _useCart = _default(),
|
|
764
766
|
mutate = _useCart.mutate;
|
|
765
767
|
return React.useCallback(debounce(/*#__PURE__*/function () {
|
|
766
768
|
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(input) {
|
|
@@ -868,8 +870,8 @@ var fetcher = /*#__PURE__*/function () {
|
|
|
868
870
|
|
|
869
871
|
var handler$4 = {
|
|
870
872
|
fetchOptions: {
|
|
871
|
-
query:
|
|
872
|
-
method:
|
|
873
|
+
query: "products",
|
|
874
|
+
method: "get"
|
|
873
875
|
},
|
|
874
876
|
fetcher: function fetcher(_ref) {
|
|
875
877
|
return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
@@ -905,7 +907,7 @@ var handler$4 = {
|
|
|
905
907
|
input = {};
|
|
906
908
|
}
|
|
907
909
|
return useData({
|
|
908
|
-
input: [[
|
|
910
|
+
input: [["id", input.id]],
|
|
909
911
|
swrOptions: _extends({
|
|
910
912
|
revalidateOnFocus: false
|
|
911
913
|
}, input.swrOptions)
|
|
@@ -1220,14 +1222,13 @@ var handler$7 = {
|
|
|
1220
1222
|
}
|
|
1221
1223
|
};
|
|
1222
1224
|
|
|
1223
|
-
/*
|
|
1224
|
-
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
1225
|
-
Changes: Added storeId and publicKey parameters
|
|
1225
|
+
/*
|
|
1226
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
1227
|
+
Changes: Added storeId and publicKey parameters
|
|
1226
1228
|
*/
|
|
1227
1229
|
var getSwellProvider = function getSwellProvider(storeId, publicKey) {
|
|
1228
|
-
//
|
|
1229
|
-
//
|
|
1230
|
-
// @ts-expect-error swell-js types are wrong
|
|
1230
|
+
// swell-js exports `init` as a named function; with esModuleInterop the
|
|
1231
|
+
// default import resolves it as a method on the namespace, so this typechecks.
|
|
1231
1232
|
swell.init(storeId, publicKey);
|
|
1232
1233
|
return {
|
|
1233
1234
|
locale: "en-us",
|
|
@@ -1254,9 +1255,9 @@ var getSwellProvider = function getSwellProvider(storeId, publicKey) {
|
|
|
1254
1255
|
};
|
|
1255
1256
|
};
|
|
1256
1257
|
|
|
1257
|
-
/*
|
|
1258
|
-
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
1259
|
-
Changes: None
|
|
1258
|
+
/*
|
|
1259
|
+
Forked from https://github.com/vercel/commerce/tree/main/packages/swell/src
|
|
1260
|
+
Changes: None
|
|
1260
1261
|
*/
|
|
1261
1262
|
var getCommerceProvider = function getCommerceProvider(storeId, publicKey) {
|
|
1262
1263
|
return commerce.getCommerceProvider(getSwellProvider(storeId, publicKey));
|