Merge branch 'swellstores-swell'

This commit is contained in:
okbel 2021-05-26 17:41:31 -03:00
commit cca5480094
71 changed files with 16620 additions and 15 deletions

View File

@ -1,5 +1,5 @@
# Available providers: bigcommerce, shopify
COMMERCE_PROVIDER=bigcommerce
# Available providers: bigcommerce, shopify, swell
COMMERCE_PROVIDER=
BIGCOMMERCE_STOREFRONT_API_URL=
BIGCOMMERCE_STOREFRONT_API_TOKEN=
@ -10,3 +10,6 @@ BIGCOMMERCE_CHANNEL_ID=
NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN=
NEXT_PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN=
NEXT_PUBLIC_SWELL_STORE_ID=
NEXT_PUBLIC_SWELL_PUBLIC_KEY=

View File

@ -7,7 +7,7 @@ const fs = require('fs')
const merge = require('deepmerge')
const prettier = require('prettier')
const PROVIDERS = ['bigcommerce', 'shopify']
const PROVIDERS = ['bigcommerce', 'shopify', 'swell']
function getProviderName() {
return (

View File

@ -0,0 +1,5 @@
SWELL_STORE_DOMAIN=
SWELL_STOREFRONT_ACCESS_TOKEN=
NEXT_PUBLIC_SWELL_STORE_ID=
NEXT_PUBLIC_SWELL_PUBLIC_KEY=

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1,20 @@
import createApiHandler, { SwellApiHandler } from '../utils/create-api-handler'
import { SWELL_CHECKOUT_URL_COOKIE } from '../../const'
import { getConfig } from '..'
const checkoutApi: SwellApiHandler<any> = async (req, res, config) => {
config = getConfig()
const { cookies } = req
const checkoutUrl = cookies[SWELL_CHECKOUT_URL_COOKIE]
if (checkoutUrl) {
res.redirect(checkoutUrl)
} else {
res.redirect('/cart')
}
}
export default createApiHandler(checkoutApi, {}, {})

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1 @@
export default function () {}

View File

@ -0,0 +1,50 @@
import type { CommerceAPIConfig } from '@commerce/api'
import {
SWELL_CHECKOUT_ID_COOKIE,
SWELL_CUSTOMER_TOKEN_COOKIE,
SWELL_COOKIE_EXPIRE,
} from '../const'
import fetchApi from './utils/fetch-swell-api'
export interface SwellConfig extends CommerceAPIConfig {
fetch: any
}
export class Config {
private config: SwellConfig
constructor(config: SwellConfig) {
this.config = config
}
getConfig(userConfig: Partial<SwellConfig> = {}) {
return Object.entries(userConfig).reduce<SwellConfig>(
(cfg, [key, value]) => Object.assign(cfg, { [key]: value }),
{ ...this.config }
)
}
setConfig(newConfig: Partial<SwellConfig>) {
Object.assign(this.config, newConfig)
}
}
const config = new Config({
locale: 'en-US',
commerceUrl: '',
apiToken: ''!,
cartCookie: SWELL_CHECKOUT_ID_COOKIE,
cartCookieMaxAge: SWELL_COOKIE_EXPIRE,
fetch: fetchApi,
customerCookie: SWELL_CUSTOMER_TOKEN_COOKIE,
})
export function getConfig(userConfig?: Partial<SwellConfig>) {
return config.getConfig(userConfig)
}
export function setConfig(newConfig: Partial<SwellConfig>) {
return config.setConfig(newConfig)
}

View File

@ -0,0 +1,25 @@
import { Page } from '../../schema'
import { SwellConfig, getConfig } from '..'
export type GetPageResult<T extends { page?: any } = { page?: Page }> = T
export type PageVariables = {
id: string
}
async function getPage({
url,
variables,
config,
preview,
}: {
url?: string
variables: PageVariables
config?: SwellConfig
preview?: boolean
}): Promise<GetPageResult> {
config = getConfig(config)
return {}
}
export default getPage

View File

@ -0,0 +1,58 @@
import type { NextApiHandler, NextApiRequest, NextApiResponse } from 'next'
import { SwellConfig, getConfig } from '..'
export type SwellApiHandler<
T = any,
H extends SwellHandlers = {},
Options extends {} = {}
> = (
req: NextApiRequest,
res: NextApiResponse<SwellApiResponse<T>>,
config: SwellConfig,
handlers: H,
// Custom configs that may be used by a particular handler
options: Options
) => void | Promise<void>
export type SwellHandler<T = any, Body = null> = (options: {
req: NextApiRequest
res: NextApiResponse<SwellApiResponse<T>>
config: SwellConfig
body: Body
}) => void | Promise<void>
export type SwellHandlers<T = any> = {
[k: string]: SwellHandler<T, any>
}
export type SwellApiResponse<T> = {
data: T | null
errors?: { message: string; code?: string }[]
}
export default function createApiHandler<
T = any,
H extends SwellHandlers = {},
Options extends {} = {}
>(
handler: SwellApiHandler<T, H, Options>,
handlers: H,
defaultOptions: Options
) {
return function getApiHandler({
config,
operations,
options,
}: {
config?: SwellConfig
operations?: Partial<H>
options?: Options extends {} ? Partial<Options> : never
} = {}): NextApiHandler {
const ops = { ...operations, ...handlers }
const opts = { ...defaultOptions, ...options }
return function apiHandler(req, res) {
return handler(req, res, getConfig(config), ops, opts)
}
}
}

View File

@ -0,0 +1,7 @@
import { swellConfig } from '../..'
const fetchApi = async (query: string, method: string, variables: [] = []) => {
const { swell } = swellConfig
return swell[query][method](...variables)
}
export default fetchApi

View File

@ -0,0 +1,2 @@
import zeitFetch from '@vercel/fetch'
export default zeitFetch()

View File

@ -0,0 +1,28 @@
import type { NextApiRequest, NextApiResponse } from 'next'
export default function isAllowedMethod(
req: NextApiRequest,
res: NextApiResponse,
allowedMethods: string[]
) {
const methods = allowedMethods.includes('OPTIONS')
? allowedMethods
: [...allowedMethods, 'OPTIONS']
if (!req.method || !methods.includes(req.method)) {
res.status(405)
res.setHeader('Allow', methods.join(', '))
res.end()
return false
}
if (req.method === 'OPTIONS') {
res.status(200)
res.setHeader('Allow', methods.join(', '))
res.setHeader('Content-Length', '0')
res.end()
return false
}
return true
}

View File

@ -0,0 +1,2 @@
export type WishlistItem = { product: any; id: number }
export default function () {}

View File

@ -0,0 +1,74 @@
import { useCallback } from 'react'
import type { MutationHook } from '@commerce/utils/types'
import { CommerceError, ValidationError } from '@commerce/utils/errors'
import useCustomer from '../customer/use-customer'
import {
CustomerAccessTokenCreateInput,
CustomerUserError,
Mutation,
MutationCheckoutCreateArgs,
} from '../schema'
import useLogin, { UseLogin } from '@commerce/auth/use-login'
import { setCustomerToken } from '../utils'
export default useLogin as UseLogin<typeof handler>
const getErrorMessage = ({ code, message }: CustomerUserError) => {
switch (code) {
case 'UNIDENTIFIED_CUSTOMER':
message = 'Cannot find an account that matches the provided credentials'
break
}
return message
}
export const handler: MutationHook<null, {}, CustomerAccessTokenCreateInput> = {
fetchOptions: {
query: 'account',
method: 'login',
},
async fetcher({ input: { email, password }, options, fetch }) {
if (!(email && password)) {
throw new CommerceError({
message:
'A first name, last name, email and password are required to login',
})
}
const { customerAccessTokenCreate } = await fetch<
Mutation,
MutationCheckoutCreateArgs
>({
...options,
variables: [email, password],
})
const errors = customerAccessTokenCreate?.customerUserErrors
if (errors && errors.length) {
throw new ValidationError({
message: getErrorMessage(errors[0]),
})
}
const customerAccessToken = customerAccessTokenCreate?.customerAccessToken
const accessToken = customerAccessToken?.accessToken
if (accessToken) {
setCustomerToken(accessToken)
}
return null
},
useHook: ({ fetch }) => () => {
const { revalidate } = useCustomer()
return useCallback(
async function login(input) {
const data = await fetch({ input })
await revalidate()
return data
},
[fetch, revalidate]
)
},
}

View File

@ -0,0 +1,36 @@
import { useCallback } from 'react'
import type { MutationHook } from '@commerce/utils/types'
import useLogout, { UseLogout } from '@commerce/auth/use-logout'
import useCustomer from '../customer/use-customer'
import { getCustomerToken, setCustomerToken } from '../utils/customer-token'
export default useLogout as UseLogout<typeof handler>
export const handler: MutationHook<null> = {
fetchOptions: {
query: 'account',
method: 'logout',
},
async fetcher({ options, fetch }) {
await fetch({
...options,
variables: {
customerAccessToken: getCustomerToken(),
},
})
setCustomerToken(null)
return null
},
useHook: ({ fetch }) => () => {
const { mutate } = useCustomer()
return useCallback(
async function logout() {
const data = await fetch()
await mutate(null, false)
return data
},
[fetch, mutate]
)
},
}

View File

@ -0,0 +1,65 @@
import { useCallback } from 'react'
import type { MutationHook } from '@commerce/utils/types'
import { CommerceError } from '@commerce/utils/errors'
import useSignup, { UseSignup } from '@commerce/auth/use-signup'
import useCustomer from '../customer/use-customer'
import { CustomerCreateInput } from '../schema'
import handleLogin from '../utils/handle-login'
export default useSignup as UseSignup<typeof handler>
export const handler: MutationHook<
null,
{},
CustomerCreateInput,
CustomerCreateInput
> = {
fetchOptions: {
query: 'account',
method: 'create',
},
async fetcher({
input: { firstName, lastName, email, password },
options,
fetch,
}) {
if (!(firstName && lastName && email && password)) {
throw new CommerceError({
message:
'A first name, last name, email and password are required to signup',
})
}
const data = await fetch({
...options,
variables: {
first_name: firstName,
last_name: lastName,
email,
password,
},
})
try {
const loginData = await fetch({
query: 'account',
method: 'login',
variables: [email, password],
})
handleLogin(loginData)
} catch (error) {}
return data
},
useHook: ({ fetch }) => () => {
const { revalidate } = useCustomer()
return useCallback(
async function signup(input) {
const data = await fetch({ input })
await revalidate()
return data
},
[fetch, revalidate]
)
},
}

View File

@ -0,0 +1,3 @@
export { default as useCart } from './use-cart'
export { default as useAddItem } from './use-add-item'
export { default as useRemoveItem } from './use-remove-item'

View File

@ -0,0 +1,59 @@
import type { MutationHook } from '@commerce/utils/types'
import { CommerceError } from '@commerce/utils/errors'
import useAddItem, { UseAddItem } from '@commerce/cart/use-add-item'
import useCart from './use-cart'
import { Cart, CartItemBody } from '../types'
import { checkoutToCart } from './utils'
import { getCheckoutId } from '../utils'
import { useCallback } from 'react'
export default useAddItem as UseAddItem<typeof handler>
export const handler: MutationHook<Cart, {}, CartItemBody> = {
fetchOptions: {
query: 'cart',
method: 'addItem',
},
async fetcher({ input: item, options, fetch }) {
if (
item.quantity &&
(!Number.isInteger(item.quantity) || item.quantity! < 1)
) {
throw new CommerceError({
message: 'The item quantity has to be a valid integer greater than 0',
})
}
const variables: {
product_id: string
variant_id?: string
checkoutId?: string
quantity?: number
} = {
checkoutId: getCheckoutId(),
product_id: item.productId,
quantity: item.quantity,
}
if (item.productId !== item.variantId) {
variables.variant_id = item.variantId
}
const response = await fetch({
...options,
variables,
})
return checkoutToCart(response) as any
},
useHook: ({ fetch }) => () => {
const { mutate } = useCart()
return useCallback(
async function addItem(input) {
const data = await fetch({ input })
await mutate(data, false)
return data
},
[fetch, mutate]
)
},
}

View File

@ -0,0 +1,37 @@
import useCart, { UseCart } from '@commerce/cart/use-cart'
import { Cart } from '@commerce/types'
import { SWRHook } from '@commerce/utils/types'
import { useMemo } from 'react'
import { normalizeCart } from '../utils/normalize'
import { checkoutCreate, checkoutToCart } from './utils'
export default useCart as UseCart<typeof handler>
export const handler: SWRHook<Cart | null, {}, any, { isEmpty?: boolean }> = {
fetchOptions: {
query: 'cart',
method: 'get',
},
async fetcher({ fetch }) {
const cart = await checkoutCreate(fetch)
return cart ? normalizeCart(cart) : null
},
useHook: ({ useData }) => (input) => {
const response = useData({
swrOptions: { revalidateOnFocus: false, ...input?.swrOptions },
})
return useMemo(
() =>
Object.create(response, {
isEmpty: {
get() {
return (response.data?.lineItems.length ?? 0) <= 0
},
enumerable: true,
},
}),
[response]
)
},
}

View File

@ -0,0 +1,71 @@
import { useCallback } from 'react'
import type {
MutationHookContext,
HookFetcherContext,
} from '@commerce/utils/types'
import { ValidationError } from '@commerce/utils/errors'
import useRemoveItem, {
RemoveItemInput as RemoveItemInputBase,
UseRemoveItem,
} from '@commerce/cart/use-remove-item'
import useCart from './use-cart'
import { checkoutToCart } from './utils'
import { Cart, LineItem } from '../types'
import { RemoveCartItemBody } from '@commerce/types'
export type RemoveItemFn<T = any> = T extends LineItem
? (input?: RemoveItemInput<T>) => Promise<Cart | null>
: (input: RemoveItemInput<T>) => Promise<Cart | null>
export type RemoveItemInput<T = any> = T extends LineItem
? Partial<RemoveItemInputBase>
: RemoveItemInputBase
export default useRemoveItem as UseRemoveItem<typeof handler>
export const handler = {
fetchOptions: {
query: 'cart',
method: 'removeItem',
},
async fetcher({
input: { itemId },
options,
fetch,
}: HookFetcherContext<RemoveCartItemBody>) {
const response = await fetch({
...options,
variables: [itemId],
})
return checkoutToCart(response)
},
useHook: ({
fetch,
}: MutationHookContext<Cart | null, RemoveCartItemBody>) => <
T extends LineItem | undefined = undefined
>(
ctx: { item?: T } = {}
) => {
const { item } = ctx
const { mutate } = useCart()
const removeItem: RemoveItemFn<LineItem> = async (input) => {
const itemId = input?.id ?? item?.id
if (!itemId) {
throw new ValidationError({
message: 'Invalid input used for this operation',
})
}
const data = await fetch({ input: { itemId } })
await mutate(data, false)
return data
}
return useCallback(removeItem as RemoveItemFn<T>, [fetch, mutate])
},
}

View File

@ -0,0 +1,95 @@
import { useCallback } from 'react'
import debounce from 'lodash.debounce'
import type {
HookFetcherContext,
MutationHookContext,
} from '@commerce/utils/types'
import { ValidationError } from '@commerce/utils/errors'
import useUpdateItem, {
UpdateItemInput as UpdateItemInputBase,
UseUpdateItem,
} from '@commerce/cart/use-update-item'
import useCart from './use-cart'
import { handler as removeItemHandler } from './use-remove-item'
import type { Cart, LineItem, UpdateCartItemBody } from '../types'
import { checkoutToCart } from './utils'
export type UpdateItemInput<T = any> = T extends LineItem
? Partial<UpdateItemInputBase<LineItem>>
: UpdateItemInputBase<LineItem>
export default useUpdateItem as UseUpdateItem<typeof handler>
export const handler = {
fetchOptions: {
query: 'cart',
method: 'updateItem',
},
async fetcher({
input: { itemId, item },
options,
fetch,
}: HookFetcherContext<UpdateCartItemBody>) {
if (Number.isInteger(item.quantity)) {
// Also allow the update hook to remove an item if the quantity is lower than 1
if (item.quantity! < 1) {
return removeItemHandler.fetcher({
options: removeItemHandler.fetchOptions,
input: { itemId },
fetch,
})
}
} else if (item.quantity) {
throw new ValidationError({
message: 'The item quantity has to be a valid integer',
})
}
const response = await fetch({
...options,
variables: [itemId, { quantity: item.quantity }],
})
return checkoutToCart(response)
},
useHook: ({
fetch,
}: MutationHookContext<Cart | null, UpdateCartItemBody>) => <
T extends LineItem | undefined = undefined
>(
ctx: {
item?: T
wait?: number
} = {}
) => {
const { item } = ctx
const { mutate, data: cartData } = useCart() as any
return useCallback(
debounce(async (input: UpdateItemInput<T>) => {
const itemId = cartData.lineItems[0].id
const productId = cartData.lineItems[0].productId
const variantId = cartData.lineItems[0].variant.id
if (!itemId || !productId) {
throw new ValidationError({
message: 'Invalid input used for this operation',
})
}
const data = await fetch({
input: {
item: {
productId,
variantId,
quantity: input.quantity,
},
itemId,
},
})
await mutate(data, false)
return data
}, ctx.wait ?? 500),
[fetch, mutate]
)
},
}

View File

@ -0,0 +1,28 @@
import { SWELL_CHECKOUT_URL_COOKIE } from '../../const'
import Cookies from 'js-cookie'
export const checkoutCreate = async (fetch: any) => {
const cart = await fetch({
query: 'cart',
method: 'get',
})
if (!cart) {
const cart = await fetch({
query: 'cart',
method: 'setItems',
variables: [[]],
})
}
const checkoutUrl = cart?.checkout_url
if (checkoutUrl) {
Cookies.set(SWELL_CHECKOUT_URL_COOKIE, checkoutUrl)
}
return cart
}
export default checkoutCreate

View File

@ -0,0 +1,26 @@
import { Cart } from '../../types'
import { CommerceError } from '@commerce/utils/errors'
import {
CheckoutLineItemsAddPayload,
CheckoutLineItemsRemovePayload,
CheckoutLineItemsUpdatePayload,
Maybe,
} from '../../schema'
import { normalizeCart } from '../../utils'
export type CheckoutPayload =
| CheckoutLineItemsAddPayload
| CheckoutLineItemsUpdatePayload
| CheckoutLineItemsRemovePayload
const checkoutToCart = (checkoutPayload?: Maybe<CheckoutPayload>): Cart => {
if (!checkoutPayload) {
throw new CommerceError({
message: 'Invalid response from Swell',
})
}
return normalizeCart(checkoutPayload as any)
}
export default checkoutToCart

View File

@ -0,0 +1,33 @@
import { HookFetcherFn } from '@commerce/utils/types'
import { Cart } from '@commerce/types'
// import { checkoutCreate, checkoutToCart } from '.'
import { FetchCartInput } from '@commerce/cart/use-cart'
import { data } from 'autoprefixer'
import { normalizeCart } from '../../utils'
const fetcher: HookFetcherFn<Cart | null, FetchCartInput> = async ({
options,
// input: { cartId: checkoutId },
fetch,
}) => {
let checkout
// if (checkoutId) {
const data = await fetch({
query: 'cart',
method: 'get',
// variables: { category: categoryId },
})
// checkout = data.node
// }
// if (checkout?.completedAt || !checkoutId) {
// checkout = await checkoutCreate(fetch)
// }
// TODO: Fix this type
// return checkoutToCart({ checkout } as any)
return normalizeCart(data)
}
export default fetcher

View File

@ -0,0 +1,2 @@
export { default as checkoutToCart } from './checkout-to-cart'
export { default as checkoutCreate } from './checkout-create'

View File

@ -0,0 +1,6 @@
{
"provider": "swell",
"features": {
"wishlist": false
}
}

View File

@ -0,0 +1,37 @@
import { getConfig, SwellConfig } from '../api'
type Variables = {
first?: number
}
type ReturnType = {
pages: Page[]
}
export type Page = {
id: string
name: string
url: string
sort_order?: number
body: string
}
const getAllPages = async (options?: {
variables?: Variables
config: SwellConfig
preview?: boolean
}): Promise<ReturnType> => {
let { config, variables = { first: 250 } } = options ?? {}
config = getConfig(config)
const { locale, fetch } = config
const data = await fetch('content', 'list', ['pages'])
const pages =
data?.results?.map(({ slug, ...rest }: { slug: string }) => ({
url: `/${locale}/${slug}`,
...rest,
})) ?? []
return { pages }
}
export default getAllPages

View File

@ -0,0 +1,33 @@
import { getConfig, SwellConfig } from '../api'
import { Page } from './get-all-pages'
type Variables = {
id: string
}
export type GetPageResult<T extends { page?: any } = { page?: Page }> = T
const getPage = async (options: {
variables: Variables
config: SwellConfig
preview?: boolean
}): Promise<GetPageResult> => {
let { config, variables } = options ?? {}
config = getConfig(config)
const { locale } = config
const { id } = variables
const result = await config.fetch('content', 'get', ['pages', id])
const page = result
return {
page: page
? {
...page,
url: `/${locale}/${page.slug}`,
}
: null,
}
}
export default getPage

View File

@ -0,0 +1,31 @@
import getCategories, { Category } from '../utils/get-categories'
import getVendors, { Brands } from '../utils/get-vendors'
import { getConfig, SwellConfig } from '../api'
export type GetSiteInfoResult<
T extends { categories: any[]; brands: any[] } = {
categories: Category[]
brands: Brands
}
> = T
const getSiteInfo = async (options?: {
variables?: any
config: SwellConfig
preview?: boolean
}): Promise<GetSiteInfoResult> => {
let { config } = options ?? {}
config = getConfig(config)
const categories = await getCategories(config)
const brands = await getVendors(config)
return {
categories,
brands,
}
}
export default getSiteInfo

13
framework/swell/const.ts Normal file
View File

@ -0,0 +1,13 @@
export const SWELL_CHECKOUT_ID_COOKIE = 'SWELL_checkoutId'
export const SWELL_CHECKOUT_URL_COOKIE = 'swell_checkoutUrl'
export const SWELL_CUSTOMER_TOKEN_COOKIE = 'swell_customerToken'
export const STORE_DOMAIN = process.env.NEXT_PUBLIC_SWELL_STORE_DOMAIN
export const SWELL_COOKIE_EXPIRE = 30
export const SWELL_STORE_ID = process.env.NEXT_PUBLIC_SWELL_STORE_ID
export const SWELL_PUBLIC_KEY = process.env.NEXT_PUBLIC_SWELL_PUBLIC_KEY

View File

@ -0,0 +1 @@
export { default as useCustomer } from './use-customer'

View File

@ -0,0 +1,50 @@
import useCustomer, { UseCustomer } from '@commerce/customer/use-customer'
import { Customer } from '@commerce/types'
import { SWRHook } from '@commerce/utils/types'
import { normalizeCustomer } from '../utils/normalize'
export default useCustomer as UseCustomer<typeof handler>
export const handler: SWRHook<Customer | null> = {
fetchOptions: {
query: 'account',
method: 'get',
},
async fetcher({ options, fetch }) {
const data = await fetch<any | null>({
...options,
})
return data ? normalizeCustomer(data) : null
},
useHook: ({ useData }) => (input) => {
return useData({
swrOptions: {
revalidateOnFocus: false,
...input?.swrOptions,
},
})
},
}
// const handler = (): { data: Customer } => {
// const swell = getContext();
// const response = swell.account.get();
// const { firstName, lastName, email, company, customerGroupId, notes, phone,
// entityId, addressCount, attributeCount, storeCredit } = response;
// return {
// data: {
// firstName,
// lastName,
// email,
// company,
// customerGroupId,
// notes,
// phone,
// entityId,
// addressCount,
// attributeCount,
// storeCredit
// }
// }
// }
// export default handler;

View File

@ -0,0 +1,28 @@
import { Fetcher } from '@commerce/utils/types'
import { handleFetchResponse } from './utils'
import { swellConfig } from './index'
import { CommerceError } from '@commerce/utils/errors'
const fetcher: Fetcher = async ({ method = 'get', variables, query }) => {
const { swell } = swellConfig
async function callSwell() {
if (Array.isArray(variables)) {
const arg1 = variables[0]
const arg2 = variables[1]
const response = await swell[query!][method](arg1, arg2)
return handleFetchResponse(response)
} else {
const response = await swell[query!][method](variables)
return handleFetchResponse(response)
}
}
if (query && query in swell) {
return await callSwell()
} else {
throw new CommerceError({ message: 'Invalid query argument!' })
}
}
export default fetcher

47
framework/swell/index.tsx Normal file
View File

@ -0,0 +1,47 @@
import * as React from 'react'
import swell from 'swell-js'
import { ReactNode } from 'react'
import {
CommerceConfig,
CommerceProvider as CoreCommerceProvider,
useCommerce as useCoreCommerce,
} from '@commerce'
import { swellProvider, SwellProvider } from './provider'
import {
SWELL_CHECKOUT_ID_COOKIE,
SWELL_STORE_ID,
SWELL_PUBLIC_KEY,
} from './const'
swell.init(SWELL_STORE_ID, SWELL_PUBLIC_KEY)
export { swellProvider }
export type { SwellProvider }
export const swellConfig: any = {
locale: 'en-us',
cartCookie: SWELL_CHECKOUT_ID_COOKIE,
swell,
}
export type SwellConfig = Partial<CommerceConfig>
export type SwellProps = {
children?: ReactNode
locale: string
} & SwellConfig
export function CommerceProvider({ children, ...config }: SwellProps) {
return (
<CoreCommerceProvider
// TODO: Fix this type
provider={swellProvider as any}
config={{ ...swellConfig, ...config }}
>
{children}
</CoreCommerceProvider>
)
}
export const useCommerce = () => useCoreCommerce()

View File

@ -0,0 +1,8 @@
const commerce = require('./commerce.config.json')
module.exports = {
commerce,
images: {
domains: ['cdn.schema.io'],
},
}

View File

@ -0,0 +1,28 @@
import { CollectionEdge } from '../schema'
import { getConfig, SwellConfig } from '../api'
const getAllCollections = async (options?: {
variables?: any
config: SwellConfig
preview?: boolean
}) => {
let { config, variables = { limit: 25 } } = options ?? {}
config = getConfig(config)
const response = await config.fetch('categories', 'list', { variables })
const edges = response.results ?? []
const categories = edges.map(
({ node: { id: entityId, title: name, handle } }: CollectionEdge) => ({
entityId,
name,
path: `/${handle}`,
})
)
return {
categories,
}
}
export default getAllCollections

View File

@ -0,0 +1,39 @@
import { SwellProduct } from '../types'
import { getConfig, SwellConfig } from '../api'
type ProductPath = {
path: string
}
export type ProductPathNode = {
node: ProductPath
}
type ReturnType = {
products: ProductPathNode[]
}
const getAllProductPaths = async (options?: {
variables?: any
config?: SwellConfig
preview?: boolean
}): Promise<ReturnType> => {
let { config, variables = [{ limit: 100 }] } = options ?? {}
config = getConfig(config)
const { results } = await config.fetch('products', 'list', [
{
limit: variables.first,
},
])
return {
products: results?.map(({ slug: handle }: SwellProduct) => ({
node: {
path: `/${handle}`,
},
})),
}
}
export default getAllProductPaths

View File

@ -0,0 +1,36 @@
import { getConfig, SwellConfig } from '../api'
import { normalizeProduct } from '../utils/normalize'
import { Product } from '@commerce/types'
import { SwellProduct } from '../types'
type Variables = {
first?: number
field?: string
}
type ReturnType = {
products: Product[]
}
const getAllProducts = async (options: {
variables?: Variables
config?: SwellConfig
preview?: boolean
}): Promise<ReturnType> => {
let { config, variables = { first: 250 } } = options ?? {}
config = getConfig(config)
const { results } = await config.fetch('products', 'list', [
{
limit: variables.first,
},
])
const products = results.map((product: SwellProduct) =>
normalizeProduct(product)
)
return {
products,
}
}
export default getAllProducts

View File

@ -0,0 +1,32 @@
import { GraphQLFetcherResult } from '@commerce/api'
import { getConfig, SwellConfig } from '../api'
import { normalizeProduct } from '../utils'
type Variables = {
slug: string
}
type ReturnType = {
product: any
}
const getProduct = async (options: {
variables: Variables
config: SwellConfig
preview?: boolean
}): Promise<ReturnType> => {
let { config, variables } = options ?? {}
config = getConfig(config)
const product = await config.fetch('products', 'get', [variables.slug])
if (product && product.variants) {
product.variants = product.variants?.results
}
return {
product: product ? normalizeProduct(product) : null,
}
}
export default getProduct

View File

@ -0,0 +1,2 @@
export * from '@commerce/product/use-price'
export { default } from '@commerce/product/use-price'

View File

@ -0,0 +1,71 @@
import { SWRHook } from '@commerce/utils/types'
import useSearch, { UseSearch } from '@commerce/product/use-search'
import { normalizeProduct } from '../utils'
import { Product } from '@commerce/types'
import { SwellProduct } from '../types'
export default useSearch as UseSearch<typeof handler>
export type SearchProductsInput = {
search?: string
categoryId?: string
brandId?: string
sort?: string
}
export type SearchProductsData = {
products: Product[]
found: boolean
}
export const handler: SWRHook<
SearchProductsData,
SearchProductsInput,
SearchProductsInput
> = {
fetchOptions: {
query: 'products', // String(Math.random()),
method: 'list',
},
async fetcher({ input, options, fetch }) {
const sortMap = new Map([
['latest-desc', ''],
['price-asc', 'price_asc'],
['price-desc', 'price_desc'],
['trending-desc', 'popularity'],
])
const { categoryId, search, sort = 'latest-desc' } = input
const mappedSort = sortMap.get(sort)
const { results, count: found } = await fetch({
query: 'products',
method: 'list',
variables: { category: categoryId, search, sort: mappedSort },
})
const products = results.map((product: SwellProduct) =>
normalizeProduct(product)
)
return {
products,
found,
}
},
useHook: ({ useData }) => (input = {}) => {
return useData({
input: [
['search', input.search],
['categoryId', input.categoryId],
['brandId', input.brandId],
['sort', input.sort],
],
swrOptions: {
revalidateOnFocus: false,
...input.swrOptions,
},
})
},
}

View File

@ -0,0 +1,31 @@
import { SWELL_CHECKOUT_URL_COOKIE, STORE_DOMAIN } from './const'
import { handler as useCart } from './cart/use-cart'
import { handler as useAddItem } from './cart/use-add-item'
import { handler as useUpdateItem } from './cart/use-update-item'
import { handler as useRemoveItem } from './cart/use-remove-item'
import { handler as useCustomer } from './customer/use-customer'
import { handler as useSearch } from './product/use-search'
import { handler as useLogin } from './auth/use-login'
import { handler as useLogout } from './auth/use-logout'
import { handler as useSignup } from './auth/use-signup'
import fetcher from './fetcher'
export const swellProvider = {
locale: 'en-us',
cartCookie: SWELL_CHECKOUT_URL_COOKIE,
storeDomain: STORE_DOMAIN,
fetcher,
cart: { useCart, useAddItem, useUpdateItem, useRemoveItem },
customer: { useCustomer },
products: { useSearch },
auth: { useLogin, useLogout, useSignup },
features: {
wishlist: false,
},
}
export type SwellProvider = typeof swellProvider

5002
framework/swell/schema.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

1
framework/swell/swell-js.d.ts vendored Normal file
View File

@ -0,0 +1 @@
declare module 'swell-js'

122
framework/swell/types.ts Normal file
View File

@ -0,0 +1,122 @@
import * as Core from '@commerce/types'
import { CheckoutLineItem } from './schema'
export type SwellImage = {
file: {
url: String
height: Number
width: Number
}
id: string
}
export type CartLineItem = {
id: string
product: SwellProduct
price: number
variant: {
name: string | null
sku: string | null
id: string
}
quantity: number
}
export type SwellCart = {
id: string
account_id: number
currency: string
tax_included_total: number
sub_total: number
grand_total: number
discount_total: number
quantity: number
items: CartLineItem[]
date_created: string
discounts?: { id: number; amount: number }[] | null
// TODO: add missing fields
}
export type SwellVariant = {
id: string
option_value_ids: string[]
name: string
price?: number
stock_status?: string
}
export interface ProductOptionValue {
label: string
hexColors?: string[]
id: string
}
export type ProductOptions = {
id: string
name: string
variant: boolean
values: ProductOptionValue[]
required: boolean
active: boolean
attribute_id: string
}
export interface SwellProduct {
id: string
description: string
name: string
slug: string
currency: string
price: number
images: any[]
options: any[]
variants: any[]
}
export interface SwellCustomer extends Core.Customer {
first_name: string
last_name: string
}
export type SwellCheckout = {
id: string
webUrl: string
lineItems: CheckoutLineItem[]
}
export interface Cart extends Core.Cart {
id: string
lineItems: LineItem[]
}
export interface LineItem extends Core.LineItem {
options?: any[]
}
/**
* Cart mutations
*/
export type OptionSelections = {
option_id: number
option_value: number | string
}
export type CartItemBody = Core.CartItemBody & {
productId: string // The product id is always required for BC
optionSelections?: OptionSelections
}
export type GetCartHandlerBody = Core.GetCartHandlerBody
export type AddCartItemBody = Core.AddCartItemBody<CartItemBody>
export type AddCartItemHandlerBody = Core.AddCartItemHandlerBody<CartItemBody>
export type UpdateCartItemBody = Core.UpdateCartItemBody<CartItemBody>
export type UpdateCartItemHandlerBody = Core.UpdateCartItemHandlerBody<CartItemBody>
export type RemoveCartItemBody = Core.RemoveCartItemBody
export type RemoveCartItemHandlerBody = Core.RemoveCartItemHandlerBody

View File

@ -0,0 +1,21 @@
import Cookies, { CookieAttributes } from 'js-cookie'
import { SWELL_COOKIE_EXPIRE, SWELL_CUSTOMER_TOKEN_COOKIE } from '../const'
export const getCustomerToken = () => Cookies.get(SWELL_CUSTOMER_TOKEN_COOKIE)
export const setCustomerToken = (
token: string | null,
options?: CookieAttributes
) => {
if (!token) {
Cookies.remove(SWELL_CUSTOMER_TOKEN_COOKIE)
} else {
Cookies.set(
SWELL_CUSTOMER_TOKEN_COOKIE,
token,
options ?? {
expires: SWELL_COOKIE_EXPIRE,
}
)
}
}

View File

@ -0,0 +1,20 @@
import { SwellConfig } from '../api'
export type Category = {
entityId: string
name: string
path: string
}
const getCategories = async (config: SwellConfig): Promise<Category[]> => {
const data = await config.fetch('categories', 'get')
return (
data.results.map(({ id: entityId, name, slug }: any) => ({
entityId,
name,
path: `/${slug}`,
})) ?? []
)
}
export default getCategories

View File

@ -0,0 +1,8 @@
import Cookies from 'js-cookie'
import { SWELL_CHECKOUT_ID_COOKIE } from '../const'
const getCheckoutId = (id?: string) => {
return id ?? Cookies.get(SWELL_CHECKOUT_ID_COOKIE)
}
export default getCheckoutId

View File

@ -0,0 +1,27 @@
import getSortVariables from './get-sort-variables'
import type { SearchProductsInput } from '../product/use-search'
export const getSearchVariables = ({
brandId,
search,
categoryId,
sort,
}: SearchProductsInput) => {
let query = ''
if (search) {
query += `product_type:${search} OR title:${search} OR tag:${search}`
}
if (brandId) {
query += `${search ? ' AND ' : ''}vendor:${brandId}`
}
return {
categoryId,
query,
...getSortVariables(sort, !!categoryId),
}
}
export default getSearchVariables

View File

@ -0,0 +1,32 @@
const getSortVariables = (sort?: string, isCategory = false) => {
let output = {}
switch (sort) {
case 'price-asc':
output = {
sortKey: 'PRICE',
reverse: false,
}
break
case 'price-desc':
output = {
sortKey: 'PRICE',
reverse: true,
}
break
case 'trending-desc':
output = {
sortKey: 'BEST_SELLING',
reverse: false,
}
break
case 'latest-desc':
output = {
sortKey: isCategory ? 'CREATED' : 'CREATED_AT',
reverse: true,
}
break
}
return output
}
export default getSortVariables

View File

@ -0,0 +1,27 @@
import { SwellConfig } from '../api'
export type BrandNode = {
name: string
path: string
}
export type BrandEdge = {
node: BrandNode
}
export type Brands = BrandEdge[]
const getVendors = async (config: SwellConfig) => {
const vendors: [string] =
(await config.fetch('attributes', 'get', ['brand']))?.values ?? []
return [...new Set(vendors)].map((v) => ({
node: {
entityId: v,
name: v,
path: `brands/${v}`,
},
}))
}
export default getVendors

View File

@ -0,0 +1,19 @@
import { CommerceError } from '@commerce/utils/errors'
type SwellFetchResponse = {
error: {
message: string
code?: string
}
}
const handleFetchResponse = async (res: SwellFetchResponse) => {
if (res) {
if (res.error) {
throw new CommerceError(res.error)
}
return res
}
}
export default handleFetchResponse

View File

@ -0,0 +1,39 @@
import { ValidationError } from '@commerce/utils/errors'
import { setCustomerToken } from './customer-token'
const getErrorMessage = ({
code,
message,
}: {
code: string
message: string
}) => {
switch (code) {
case 'UNIDENTIFIED_CUSTOMER':
message = 'Cannot find an account that matches the provided credentials'
break
}
return message
}
const handleLogin = (data: any) => {
const response = data.customerAccessTokenCreate
const errors = response?.customerUserErrors
if (errors && errors.length) {
throw new ValidationError({
message: getErrorMessage(errors[0]),
})
}
const customerAccessToken = response?.customerAccessToken
const accessToken = customerAccessToken?.accessToken
if (accessToken) {
setCustomerToken(accessToken)
}
return customerAccessToken
}
export default handleLogin

View File

@ -0,0 +1,9 @@
export { default as handleFetchResponse } from './handle-fetch-response'
export { default as getSearchVariables } from './get-search-variables'
export { default as getSortVariables } from './get-sort-variables'
export { default as getVendors } from './get-vendors'
export { default as getCategories } from './get-categories'
export { default as getCheckoutId } from './get-checkout-id'
export * from './normalize'
export * from './customer-token'

View File

@ -0,0 +1,219 @@
import { Product, Customer } from '@commerce/types'
import { MoneyV2, ProductOption } from '../schema'
import type {
Cart,
CartLineItem,
SwellCustomer,
SwellProduct,
SwellImage,
SwellVariant,
ProductOptionValue,
SwellCart,
LineItem,
} from '../types'
const money = ({ amount, currencyCode }: MoneyV2) => {
return {
value: +amount,
currencyCode,
}
}
type normalizedProductOption = {
__typename?: string
id: string
displayName: string
values: ProductOptionValue[]
}
const normalizeProductOption = ({
id,
name: displayName = '',
values = [],
}: ProductOption) => {
let returnValues = values.map((value) => {
let output: any = {
label: value.name,
id: value?.id || id,
}
if (displayName.match(/colou?r/gi)) {
output = {
...output,
hexColors: [value.name],
}
}
return output
})
return {
__typename: 'MultipleChoiceOption',
id,
displayName,
values: returnValues,
}
}
const normalizeProductImages = (images: SwellImage[]) => {
if (!images || images.length < 1) {
return [{ url: '/' }]
}
return images?.map(({ file, ...rest }: SwellImage) => ({
url: file?.url + '',
height: Number(file?.height),
width: Number(file?.width),
...rest,
}))
}
const normalizeProductVariants = (
variants: SwellVariant[],
productOptions: normalizedProductOption[]
) => {
return variants?.map(
({ id, name, price, option_value_ids: optionValueIds = [] }) => {
const values = name
.split(',')
.map((i) => ({ name: i.trim(), label: i.trim() }))
const options = optionValueIds.map((id) => {
const matchingOption = productOptions.find((option) => {
return option.values.find(
(value: ProductOptionValue) => value.id == id
)
})
return normalizeProductOption({
id,
name: matchingOption?.displayName ?? '',
values,
})
})
return {
id,
name,
// sku: sku ?? id,
price: price ?? null,
listPrice: price ?? null,
// requiresShipping: true,
options,
}
}
)
}
export function normalizeProduct(swellProduct: SwellProduct): Product {
const {
id,
name,
description,
images,
options,
slug,
variants,
price: value,
currency: currencyCode,
} = swellProduct
// ProductView accesses variants for each product
const emptyVariants = [{ options: [], id, name }]
const productOptions = options
? options.map((o) => normalizeProductOption(o))
: []
const productVariants = variants
? normalizeProductVariants(variants, productOptions)
: []
const productImages = normalizeProductImages(images)
const product = {
...swellProduct,
description,
id,
vendor: '',
path: `/${slug}`,
images: productImages,
variants:
productVariants && productVariants.length
? productVariants
: emptyVariants,
options: productOptions,
price: {
value,
currencyCode,
},
}
return product
}
export function normalizeCart({
id,
account_id,
date_created,
currency,
tax_included_total,
items,
sub_total,
grand_total,
discounts,
}: SwellCart) {
const cart: Cart = {
id: id,
customerId: account_id + '',
email: '',
createdAt: date_created,
currency: { code: currency },
taxesIncluded: tax_included_total > 0,
lineItems: items?.map(normalizeLineItem) ?? [],
lineItemsSubtotalPrice: +sub_total,
subtotalPrice: +sub_total,
totalPrice: grand_total,
discounts: discounts?.map((discount) => ({ value: discount.amount })),
}
return cart
}
export function normalizeCustomer(customer: SwellCustomer): Customer {
const { first_name: firstName, last_name: lastName } = customer
return {
...customer,
firstName,
lastName,
}
}
function normalizeLineItem({
id,
product,
price,
variant,
quantity,
}: CartLineItem): LineItem {
const item = {
id,
variantId: variant?.id,
productId: product.id ?? '',
name: product?.name ?? '',
quantity,
variant: {
id: variant?.id ?? '',
sku: variant?.sku ?? '',
name: variant?.name!,
image: {
url:
product?.images && product.images.length > 0
? product?.images[0].file.url
: '/',
},
requiresShipping: false,
price: price,
listPrice: price,
},
path: '',
discounts: [],
options: [
{
value: variant?.name,
},
],
}
return item
}

View File

@ -0,0 +1,13 @@
export const getCheckoutIdFromStorage = (token: string) => {
if (window && window.sessionStorage) {
return window.sessionStorage.getItem(token)
}
return null
}
export const setCheckoutIdInStorage = (token: string, id: string | number) => {
if (window && window.sessionStorage) {
return window.sessionStorage.setItem(token, id + '')
}
}

View File

@ -0,0 +1,13 @@
import { useCallback } from 'react'
export function emptyHook() {
const useEmptyHook = async (options = {}) => {
return useCallback(async function () {
return Promise.resolve()
}, [])
}
return useEmptyHook
}
export default emptyHook

View File

@ -0,0 +1,17 @@
import { useCallback } from 'react'
type Options = {
includeProducts?: boolean
}
export function emptyHook(options?: Options) {
const useEmptyHook = async ({ id }: { id: string | number }) => {
return useCallback(async function () {
return Promise.resolve()
}, [])
}
return useEmptyHook
}
export default emptyHook

View File

@ -0,0 +1,46 @@
// TODO: replace this hook and other wishlist hooks with a handler, or remove them if
// Swell doesn't have a wishlist
import { HookFetcher } from '@commerce/utils/types'
import { Product } from '../schema'
const defaultOpts = {}
export type Wishlist = {
items: [
{
product_id: number
variant_id: number
id: number
product: Product
}
]
}
export interface UseWishlistOptions {
includeProducts?: boolean
}
export interface UseWishlistInput extends UseWishlistOptions {
customerId?: number
}
export const fetcher: HookFetcher<Wishlist | null, UseWishlistInput> = () => {
return null
}
export function extendHook(
customFetcher: typeof fetcher,
// swrOptions?: SwrOptions<Wishlist | null, UseWishlistInput>
swrOptions?: any
) {
const useWishlist = ({ includeProducts }: UseWishlistOptions = {}) => {
return { data: null }
}
useWishlist.extend = extendHook
return useWishlist
}
export default extendHook(fetcher)

View File

@ -7,6 +7,7 @@ const {
const provider = commerce.provider || getProviderName()
const isBC = provider === 'bigcommerce'
const isShopify = provider === 'shopify'
const isSwell = provider === 'swell'
module.exports = withCommerceConfig({
commerce,
@ -16,7 +17,7 @@ module.exports = withCommerceConfig({
},
rewrites() {
return [
(isBC || isShopify) && {
(isBC || isShopify || isSwell) && {
source: '/checkout',
destination: '/api/bigcommerce/checkout',
},

View File

@ -42,6 +42,7 @@
"react-merge-refs": "^1.1.0",
"react-ticker": "^1.2.2",
"shopify-buy": "^2.11.0",
"swell-js": "^4.0.0-next.0",
"swr": "^0.4.0",
"tabbable": "^5.1.5",
"tailwindcss": "^2.0.4"

View File

@ -76,7 +76,7 @@ export default function Search({
const { data } = useSearch({
search: typeof q === 'string' ? q : '',
categoryId: activeCategory?.entityId,
brandId: activeBrand?.entityId,
brandId: (activeBrand as any)?.entityId,
sort: typeof sort === 'string' ? sort : '',
})

View File

@ -22,8 +22,8 @@
"@components/*": ["components/*"],
"@commerce": ["framework/commerce"],
"@commerce/*": ["framework/commerce/*"],
"@framework": ["framework/shopify"],
"@framework/*": ["framework/shopify/*"]
"@framework": ["framework/bigcommerce"],
"@framework/*": ["framework/bigcommerce/*"]
}
},
"include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],

123
yarn.lock
View File

@ -401,6 +401,13 @@
dependencies:
regenerator-runtime "^0.13.4"
"@babel/runtime@7.4.5":
version "7.4.5"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.4.5.tgz#582bb531f5f9dc67d2fcb682979894f75e253f12"
integrity sha512-TuI4qpWZP6lGOGIuGWtp9sPluqYICmbk8T/1vpSysqJxRPkudh/ofFWyqdcMsDf2s7KvDL4/YHgKyvcS3g9CJQ==
dependencies:
regenerator-runtime "^0.13.2"
"@babel/runtime@^7.0.0":
version "7.12.13"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.12.13.tgz#0a21452352b02542db0ffb928ac2d3ca7cb6d66d"
@ -408,6 +415,13 @@
dependencies:
regenerator-runtime "^0.13.4"
"@babel/runtime@^7.12.13", "@babel/runtime@^7.13.10":
version "7.13.10"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.13.10.tgz#47d42a57b6095f4468da440388fdbad8bebf0d7d"
integrity sha512-4QPkjJq6Ns3V/RgpEahRk+AGfL0eO6RHHtTWoNNr5mO49G6B5+X6d6THgWEAvTrznU5xYpbAlVKRYcsCgh/Akw==
dependencies:
regenerator-runtime "^0.13.4"
"@babel/template@^7.12.13":
version "7.12.13"
resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.12.13.tgz#530265be8a2589dbb37523844c5bcb55947fb327"
@ -1326,6 +1340,14 @@ argparse@^1.0.7:
dependencies:
sprintf-js "~1.0.2"
array-includes-with-glob@^3.0.6:
version "3.0.16"
resolved "https://registry.yarnpkg.com/array-includes-with-glob/-/array-includes-with-glob-3.0.16.tgz#fdf2bf1e914cb9b95bd2a866194ede0ab3225d7b"
integrity sha512-uFwmmz78W4WzmMsLKojbCA2q5EbqugWFMm5zDyO+SSR6eW1rqzoxramiTCJYq1o/NZijt1szOJMA29JHZuU34A==
dependencies:
"@babel/runtime" "^7.13.10"
matcher "^4.0.0"
array-union@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d"
@ -2327,7 +2349,7 @@ deep-is@~0.1.3:
resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34"
integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=
deepmerge@^4.2.2:
deepmerge@4.2.2, deepmerge@^4.2.2:
version "4.2.2"
resolved "https://registry.yarnpkg.com/deepmerge/-/deepmerge-4.2.2.tgz#44d2ea3679b8f4d4ffba33f03d865fc1e7bf4955"
integrity sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==
@ -2686,6 +2708,11 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
escape-string-regexp@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==
escodegen@^1.8.0:
version "1.14.3"
resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-1.14.3.tgz#4e7b81fba61581dc97582ed78cab7f0e8d63f503"
@ -3621,7 +3648,7 @@ isobject@^4.0.0:
resolved "https://registry.yarnpkg.com/isobject/-/isobject-4.0.0.tgz#3f1c9155e73b192022a80819bacd0343711697b0"
integrity sha512-S/2fF5wH8SJA/kmwr6HYhK/RI/OkhD84k8ntalo0iJjZikgq1XFvR5M8NPT1x5F7fBwCG3qHfnzeP/Vh/ZxCUA==
isomorphic-fetch@^3.0.0:
isomorphic-fetch@3.0.0, isomorphic-fetch@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-3.0.0.tgz#0267b005049046d2421207215d45d6a262b8b8b4"
integrity sha512-qvUtwJ3j6qwsF3jLxkZ72qCgjMysPzDfeV240JHiGZsANBYd+EEuu35v7dfrJ9Up0Ak07D7GGSkGhCHTqg/5wA==
@ -3925,6 +3952,16 @@ lodash._reinterpolate@^3.0.0:
resolved "https://registry.yarnpkg.com/lodash._reinterpolate/-/lodash._reinterpolate-3.0.0.tgz#0ccf2d89166af03b3663c796538b75ac6e114d9d"
integrity sha1-DM8tiRZq8Ds2Y8eWU4t1rG4RTZ0=
lodash.camelcase@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6"
integrity sha1-soqmKIorn8ZRA1x3EfZathkDMaY=
lodash.clonedeep@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"
integrity sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=
lodash.debounce@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
@ -3945,6 +3982,11 @@ lodash.isboolean@^3.0.3:
resolved "https://registry.yarnpkg.com/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz#6c2e171db2a257cd96802fd43b01b20d5f5870f6"
integrity sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY=
lodash.isdate@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/lodash.isdate/-/lodash.isdate-4.0.1.tgz#35a543673b9d76110de4114b32cc577048a7f366"
integrity sha1-NaVDZzuddhEN5BFLMsxXcEin82Y=
lodash.isinteger@^4.0.4:
version "4.0.4"
resolved "https://registry.yarnpkg.com/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz#619c0af3d03f8b04c31f5882840b77b11cd68343"
@ -3975,6 +4017,11 @@ lodash.random@^3.2.0:
resolved "https://registry.yarnpkg.com/lodash.random/-/lodash.random-3.2.0.tgz#96e24e763333199130d2c9e2fd57f91703cc262d"
integrity sha1-luJOdjMzGZEw0sni/Vf5FwPMJi0=
lodash.snakecase@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz#39d714a35357147837aefd64b5dcbb16becd8f8d"
integrity sha1-OdcUo1NXFHg3rv1ktdy7Fr7Nj40=
lodash.sortby@^4.7.0:
version "4.7.0"
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
@ -4010,16 +4057,21 @@ lodash.topath@^4.5.2:
resolved "https://registry.yarnpkg.com/lodash.topath/-/lodash.topath-4.5.2.tgz#3616351f3bba61994a0931989660bd03254fd009"
integrity sha1-NhY1Hzu6YZlKCTGYlmC9AyVP0Ak=
lodash.uniq@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=
lodash@4.17.21, lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
lodash@^4.17.13, lodash@^4.17.15, lodash@^4.17.19, lodash@^4.17.20, lodash@~4.17.20:
version "4.17.20"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
integrity sha512-PlhdFcillOINfeV7Ni6oF1TAEayyZBoZ8bcshTHqOYJYlrqzRK5hagpagky5o4HfCzzd1TRkXPMFq6cKk9rGmA==
lodash@^4.17.21:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
log-symbols@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-1.0.2.tgz#376ff7b58ea3086a0f09facc74617eca501e1a18"
@ -4161,6 +4213,13 @@ map-obj@^4.0.0:
resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.1.0.tgz#b91221b542734b9f14256c0132c897c5d7256fd5"
integrity sha512-glc9y00wgtwcDmp7GaE/0b0OnxpNJsVf3ael/An6Fe2Q51LLwN1er6sdomLRzz5h0+yMpiYLhWYF5R7HeqVd4g==
matcher@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/matcher/-/matcher-4.0.0.tgz#a42a05a09aaed92e2d241eb91fddac689461ea51"
integrity sha512-S6x5wmcDmsDRRU/c2dkccDwQPXoFczc5+HpQ2lON8pnvHlnvHAHj5WlLVvw6n6vNyHuVugYrFohYxbS+pvFpKQ==
dependencies:
escape-string-regexp "^4.0.0"
md5.js@^1.3.4:
version "1.3.5"
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"
@ -4554,11 +4613,33 @@ object-inspect@^1.9.0:
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.9.0.tgz#c90521d74e1127b67266ded3394ad6116986533a"
integrity sha512-i3Bp9iTqwhaLZBxGkRfo5ZbE07BQRT7MGu8+nNgwW9ItGp1TzCTw2DLEoWwjClxBjOFI/hWljTAmYGCEwmtnOw==
object-keys-normalizer@1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/object-keys-normalizer/-/object-keys-normalizer-1.0.1.tgz#db178dbba5e4c7b18b40837c8ef83365ee9348e7"
integrity sha1-2xeNu6Xkx7GLQIN8jvgzZe6TSOc=
dependencies:
lodash.camelcase "^4.3.0"
lodash.snakecase "^4.1.1"
object-keys@^1.0.12, object-keys@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e"
integrity sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==
object-merge-advanced@12.0.3:
version "12.0.3"
resolved "https://registry.yarnpkg.com/object-merge-advanced/-/object-merge-advanced-12.0.3.tgz#e03c19aa33cf88da6b32187e4907b487668808d9"
integrity sha512-xQIf2Vup1rpKiHr2tQca5jyNYgT4O0kNxOfAp3ZNonm2hS+5yaJgI0Czdk/QMy52bcRwQKX3uc3H8XtAiiYfVA==
dependencies:
"@babel/runtime" "^7.12.13"
array-includes-with-glob "^3.0.6"
lodash.clonedeep "^4.5.0"
lodash.includes "^4.3.0"
lodash.isdate "^4.0.1"
lodash.isplainobject "^4.0.6"
lodash.uniq "^4.5.0"
util-nonempty "^3.0.6"
object-path@^0.11.4:
version "0.11.5"
resolved "https://registry.yarnpkg.com/object-path/-/object-path-0.11.5.tgz#d4e3cf19601a5140a55a16ad712019a9c50b577a"
@ -5406,6 +5487,11 @@ purgecss@^3.1.3:
postcss "^8.2.1"
postcss-selector-parser "^6.0.2"
qs@6.7.0:
version "6.7.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc"
integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==
querystring-es3@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73"
@ -5572,7 +5658,7 @@ reduce-css-calc@^2.1.8:
css-unit-converter "^1.1.1"
postcss-value-parser "^3.3.0"
regenerator-runtime@^0.13.4:
regenerator-runtime@^0.13.2, regenerator-runtime@^0.13.4:
version "0.13.7"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55"
integrity sha512-a54FxoJDIr27pgf7IgeQGxmqUNYrcV338lf/6gH456HZ/PhX+5BcwHXG9ajESmwe6WRO0tAzRUrRmNONWgkrew==
@ -6212,6 +6298,19 @@ supports-color@^7.1.0:
dependencies:
has-flag "^4.0.0"
swell-js@^4.0.0-next.0:
version "4.0.0-next.0"
resolved "https://registry.yarnpkg.com/swell-js/-/swell-js-4.0.0-next.0.tgz#870599372e3c9eafefeafc2c63863c4032d8be6b"
integrity sha512-OQ1FLft3ruKpQw5P0TiCzs/X2Ma95+Qz+I2Xzs4KC6v+zVaFVUGNs80dQdtjfInisWoFC7iFZF2AITgellVGAg==
dependencies:
"@babel/runtime" "7.4.5"
deepmerge "4.2.2"
isomorphic-fetch "3.0.0"
lodash "4.17.21"
object-keys-normalizer "1.0.1"
object-merge-advanced "12.0.3"
qs "6.7.0"
swr@^0.4.0:
version "0.4.2"
resolved "https://registry.yarnpkg.com/swr/-/swr-0.4.2.tgz#4a9ed5e9948088af145c79d716d294cb99712a29"
@ -6531,6 +6630,14 @@ util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1:
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=
util-nonempty@^3.0.6:
version "3.0.8"
resolved "https://registry.yarnpkg.com/util-nonempty/-/util-nonempty-3.0.8.tgz#0e53820a29e2c6cdcc3ecece52bc7fdd193c9b2b"
integrity sha512-eB6dfVQWEBMT7i9EgWigvJiHUlW/iaq/Wg6pcWviwKsPWFwgprPVilZHkTAhzmXgv9LnGOLjrszm/HvIHpbeQw==
dependencies:
"@babel/runtime" "^7.13.10"
lodash.isplainobject "^4.0.6"
util@0.10.3:
version "0.10.3"
resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9"