[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/react/adminStatistics.tsx from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```tsx
export { default } from './admin/component/statistics'

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/react/adminOtherExample.tsx from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```tsx
import type { FC } from 'react'
import React from 'react'
import { Layout, PageBlock } from 'vtex.styleguide'
import { useQuery } from 'react-apollo'

import tokenGQL from './admin/graphql/token.gql'

const AdminOtherExample: FC = () => {
  const { data: retrievedToken } = useQuery(tokenGQL)

  return (
    <Layout>
      <PageBlock
        title="Gerenciamento"
        subtitle="Tokens e Dados de Configuração"
        variation="full"
      >
        <p>Current token: {retrievedToken?.token}</p>
      </PageBlock>
    </Layout>
  )
}

export default AdminOtherExample

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/react/adminLinkForm.tsx from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```tsx
import React, { useState } from 'react'
import type { FC } from 'react'
import {
  Layout,
  PageBlock,
  PageHeader,
  Input,
  Button,
  Alert,
} from 'vtex.styleguide'
import { useMutation } from 'react-apollo'
import { useRuntime } from 'vtex.render-runtime'
import { FormattedMessage } from 'react-intl'

import CREATE_LINK from './admin/graphql/createLink.graphql'

const LinkForm: FC = () => {
  const [account, setAccount] = useState('')
  const [errorAccountField, setErrorAccountField] = useState('')
  const [showAlert, setShowAlert] = useState(false)

  const { navigate } = useRuntime()

  const [createLink, { loading }] = useMutation(CREATE_LINK)

  const handleSaveChange = async () => {
    if (account) {
      try {
        await createLink({
          variables: {
            accountApprover: account,
          },
        })

        navigate({
          page: 'admin.app.checkoutless-linksList',
        })
      } catch (e) {
        setShowAlert(true)
      }
    } else {
      setErrorAccountField('Required')
    }
  }

  return (
    <Layout
      pageHeader={
        <PageHeader
          title={<FormattedMessage id="checkoutless.linkForm.title" />}
          linkLabel={<FormattedMessage id="checkoutless.linksList.title" />}
          onLinkClick={() => navigate({ to: '/admin/app/kuikpay/links' })}
        />
      }
    >
      <PageBlock variation="full">
        {showAlert ? (
          <div className="mb5">
            <Alert
              autoClose={5000}
              type="error"
              onClose={() => setShowAlert(false)}
            >
              <FormattedMessage id="checkoutless.linkForm.linkExist" />
            </Alert>
          </div>
        ) : (
          <></>
        )}
        <div className="mb5">
          <Input
            label={<FormattedMessage id="checkoutless.linkForm.accountField" />}
            value={account}
            onChange={(e: any) => {
              setErrorAccountField('')
              setAccount(e.target.value)
            }}
            minLength={5}
            maxLength={128}
            required
            placeholder="Required"
            errorMessage={errorAccountField}
          />
        </div>
      </PageBlock>

      <div className="flex justify-end">
        <div className="pb7 pr7-s flex-row ">
          <Button
            variation="primary"
            onClick={handleSaveChange}
            isLoading={loading}
          >
            <FormattedMessage id="checkoutless.inputs.save-button" />
          </Button>
        </div>
      </div>
    </Layout>
  )
}

export default LinkForm

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/react/adminPaymentList.tsx from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```tsx
export { default } from './admin/component/PaymentList'

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/store/interfaces.json from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```json
{
  "kuikpay-button": {
    "component": "QuickpayButtonV2"
  },
  "kuikpay-quota-information": {
    "component": "KuikpayQuotaInformation",
    "render": "client"
  },
  "kuikpay-wrapper": {
    "component": "KuikpayWrapper"
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/types/address.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
type Address {
  id: ID!
  profile: String!
  country: String!
  state: String!
  city: String!
  street: String!
  number: String!
  postalCode: String!
  receiverName: String!
  geoCoordinates: Geocoordinates
  neighborhood: String
  reference: String
  isEqual: String
}

type GeneralAddressResponse {
  message: String!
  data: Address!
}

type Geocoordinates {
  latitude: String!
  longitude: String!
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/types/orders.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
type Order {
  id: String
  transaction: Transaction
}

type Transaction {
  RedirectResponseCollection: [RedirectResponseCollection]
}

type RedirectResponseCollection {
  redirectUrl: String
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/types/documents.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
type PaginatedDocumentResponse {
  count: Int!
  total: Int!
  current: Int!
  prev: Int!
  next: Int!
  data: [DocumentTypes]
}

type DocumentTypes {
  id: ID
  name: String
  type: String
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/types/users.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
type Auth {
  email: String!
  code: Int!
}

type PaginatedUserResponse {
  count: Int!
  total: Int!
  current: Int!
  prev: Int!
  next: Int!
  data: [User!]!
}

type User {
  accessToken: String
  addresses: [Address]
  cards: [Payments]
  email: String!
  habeasData: Boolean
  id_number: String!
  id_type: String!
  id: ID
  lastname: String!
  name: String!
  phone_code: String!
  phone_number: String!
  selectedAddress: Address
  selectedPayment: SelectedPayment
}

type GeneralUserResponse {
  message: String!
  data: User
}

type GeneralResponse {
  message: String!
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/types/orion.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
type AuthBnpl {
  message: String
  token: String
  sessionToken: String
  transactionId: String
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/types/products.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
type Products {
  sku: String
  quantity: Int
  price: Float
  category: String
  subcategory: String
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/types/accounts.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
type Visualization {
  type: String
  key: String
  secundaryKey: String
}

type Accounts {
  cvcRequired: Boolean
  paymentSystem: String
  buttonMessage: String
  visualization: [Visualization]
  PaymentMethod: [PaymentsMethods]
  isConfigured: Boolean
  styles: String
  text: String
  hasGoogleAnalytics: Boolean
  additionalData: [AdditionalData]
  habeasDataInformation: HabeasDataInformation
}

type AccountLink {
  approver: Boolean
  account: String
  status: String
  date: String
  id: String
}

type ResponseVisualization {
  visualization: [AdminVisualization]
}

type Remove {
  removed: Int
  id: String
}

type AdminVisualization {
  type: String
  key: String
}

type AdditionalData {
  key: String
  value: String
}

type Account {
  account: String
  paymentMethodId: String
  cvcRequired: Boolean
  isConfigured: Boolean
  buttonMessage: String
  visualization: [AdminVisualization]
  buttonText: String
  additionalData: [AdditionalData]
}

type HabeasDataInformation {
  url: String
  version: Int
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/types/metrics.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
type CategoryData {
  _id: String
  totalPrice: Float
  totalQuantity: Int
  category: String
}

type SubcategoryData {
  _id: String
  totalPrice: Float
  totalQuantity: Int
  subcategory: String
}

type PaginationCategory {
  total: Int
  current: Int
  next: Int
  prev: Int
  count: Int
  data: [CategoryData]
}

type PaginationSubcategory {
  total: Int
  current: Int
  next: Int
  prev: Int
  count: Int
  data: [SubcategoryData]
}

type CategoryMetrics {
  selectedPeriodCategory: PaginationCategory
  previousPeriodCategory: PaginationCategory
  currentDayCategory: Float
  currentDayVariationCategory: Float
  currentMonthCategory: Float
}

type SubcategoryMetrics {
  category: String
  selectedPeriodSubcategory: PaginationSubcategory
  previousPeriodSubcategory: PaginationSubcategory
  currentDaySubcategory: Float
  currentDayVariationSubcategory: Float
  currentMonthSubcategory: Float
}

type TicketAverageData {
  _id: String
  ticketAverage: Float
}

type TicketAverage {
  selectedPeriodTicket: [TicketAverageData]
  previousPeriodTicket: [TicketAverageData]
  currentDayTicket: Float
  currentDayVariationTicket: Float
  currentMonthTicket: Float
}

type CheckoutData {
  _id: String
  closedPurchases: Int
}

type Checkout {
  selectedPeriodCheckout: [CheckoutData]
  previousPeriodCheckout: [CheckoutData]
  currentDayCheckout: Float
  currentDayVariationCheckout: Float
  currentMonthCheckout: Float
}

type ButtonUsesData {
  _id: String
  use: Int
}

type ButtonUses {
  selectedPeriodButton: [ButtonUsesData]
  previousPeriodButton: [ButtonUsesData]
  currentDayButton: Float
  currentDayVariationButton: Float
  currentMonthButton: Float
}

type ConversionRateData {
  _id: String
  cr: Int
}

type ConversionRate {
  selectedPeriodCR: [ConversionRateData]
  previousPeriodCR: [ConversionRateData]
  currentDayCR: Float
  currentDayVariationCR: Float
  currentMonthCR: Float
}

type Categories {
  id: String
  name: String
  hasChildren: Boolean
  url: String
  children: [Categories]
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/types/countries.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
type PaginatedCountriesResponse {
  count: Int!
  total: Int!
  current: Int!
  prev: Int!
  next: Int!
  data: [Countries]
}

type Countries {
  id: String
  country: String
  iso: String
  phone: String
  postal_code_regex: String
  states: [States]
}

type States {
  state: String
  cities: [Cities]
}

type Cities {
  city_id: String
  city: String
}

type SearchCities {
  city: String
  state: String
  country: String
  phone: String
  iso: String
  postal_code: String
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/types/payments.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
type Payments {
  id: ID
  franchise: String
  number: String
  gateway: String
  bin: String
  cvv: String
  paymentSystem: String
  cardContent: [CardContent]
}

type CardContent {
  key: String
  value: String
}

type GeneralPaymentsResponse {
  message: String
  data: Payments
}

type PaymentsMethods {
  id: ID
  type: String
  isActive: Boolean
  paymentMethodName: String
  accountName: String
}

type SelectedPayment {
  card: Payments
  paymentMethod: String
}

type ValidateCredit {
  approvedCredit: Int
  maxInstallments: Int
}

type AdminPaymentsMethods {
  id: ID
  type: String
  isActive: Boolean
  paymentMethodName: String
  accountName: String
}

type PaymentProccess {
  status: Boolean
  message: String
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/types/ecommerce.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
type Ecommerce {
  event: String
  userEmail: String
  account: String
  products: [Products]
  product: Products
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/inputs/address.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
input AddressInput {
  addressId: String
  profileId: String
  country: String
  state: String
  city: String
  street: String
  number: String
  postalCode: String
  receiverName: String
  geoCoordinates: GeocoordinatesInput
  neighborhood: String
  reference: String
}

input ExternalAddressInput {
  addressId: String
  postalCode: String
  country: String
  state: String
  city: String
  street: String
  number: String
  geoCoordinates: GeocoordinatesInput
  neighborhood: String
  addressType: String
  receiverName: String
  reference: String
}

input GeocoordinatesInput {
  latitude: String
  longitude: String
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/inputs/orders.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
input OrderInput {
  items: [ItemInput]
  gifts: [GiftInput]
  offerings: [OfferingInput]
  payment: PaymentDataInput
  profile: ProfileInput
  shipping: ShippingInput
  account: AccountInput
  channel: String
  customData: CustomDataInput
  marketingData: MarketingDataInput
  ip: String!
}

input CustomDataInput {
  customApps: [CustomAppsInput]
}

input CustomAppsInput {
  id: String
  major: Int
  fields: [CustomFieldsInput]
}

input CustomFieldsInput {
  key: String
  value: String
}

input ShippingInput {
  addressId: String
  externalAddress: ExternalAddressInput
  logisticsInfo: [LogisticInfoInput]
}

input OfferingInput {
  id: String
  parentItemId: String
}

input GiftInput {
  id: String
  seller: String
  quantity: Int
}

input ItemInput {
  id: String
  quantity: Int
  seller: String
}

input DeliveryWindowInput {
  startDateUtc: String
  endDateUtc: String
}

input LogisticInfoInput {
  itemIndex: Int
  selectedSla: String
  selectedDeliveryChannel: String
  deliveryWindow: DeliveryWindowInput
}

input MarketingDataInput {
  coupon: String
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/inputs/users.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
input UserInput {
  name: String
  lastname: String
  phone_code: String
  phone_number: String
  selectedAddress: ID
  selectedPayment: ID
}

input ProfileInput {
  email: String
  habeasData: Boolean
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/inputs/pagination.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
input PaginationInput {
  limit: Int
  page: Int
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/inputs/products.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
input ProductsInput {
  sku: String
  quantity: Int
  price: Float
  category: String
  subcategory: String
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/inputs/accounts.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
input VisualizationInput {
  type: String
  key: String
}

input AccountInput {
  storePreferences: StorePreferencesInput
}

input StorePreferencesInput {
  currencyCode: String
  countryCode: String
  salesChannel: String
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/inputs/metrics.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
input DatesInput {
  from: String
  until: String
}

input FiltersInput {
  visualization: String
  selectedPeriod: DatesInput
  previousPeriod: DatesInput
}

input MetricsInput {
  filters: FiltersInput
  pagination: PaginationInput
  timezone: String
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/inputs/payment.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
input PaymentMethodsInput {
  type: String
  isActive: Boolean
  paymentMethodName: String
  accountName: String
}

input PaymentDataInput {
  cardId: String
  gateway: String
  token: String
  franchise: String
  number: String
  paymentMethod: String
  additionalData: [AdditionalDataInput]
  holderName: String
  expirationDate: String
  cardNumber: String
  cvv: String
  bin: String
  holderDocument: String
}

input AdditionalDataInput {
  key: String
  value: String
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/graphql/inputs/ecommerce.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
input DataInput {
  products: [ProductsInput]
}

input EcommerceInput {
  event: String
  userEmail: String
  account: String
  data: DataInput
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/index.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { IOClients } from '@vtex/api'

import { AddressService } from './checkout/address'
import { AuthService } from './checkout/auth'
import { CountriesService } from './checkout/countries'
import { DocumentsService } from './checkout/documents'
import { OrderService } from './checkout/orders'
import { PaymentsService } from './checkout/payments'
import { AccountsService } from './checkout/accounts'
import { UserService } from './checkout/user'
import { CreditService } from './checkout/credit'
import { EcommerceService } from './checkout/ecommerce'
import SchedulerClient from './checkout/scheduler'
import { CheckoutlessClient } from './admin/checkoutless'
import { CategoriesClient } from './admin/categories'
import { PaymentsClient } from './admin/payments'
import { MetricsService } from './admin/metrics'
import { OrionServices } from './orion'
import { PaymentGateway } from './admin/paymentGateway'

export class Clients extends IOClients {
  /*  ---- Checkout ---- */
  public get user() {
    return this.getOrSet('user', UserService)
  }

  public get auth() {
    return this.getOrSet('auth', AuthService)
  }

  public get address() {
    return this.getOrSet('address', AddressService)
  }

  public get payments() {
    return this.getOrSet('payments', PaymentsService)
  }

  public get orders() {
    return this.getOrSet('orders', OrderService)
  }

  public get countries() {
    return this.getOrSet('countries', CountriesService)
  }

  public get documents() {
    return this.getOrSet('documents', DocumentsService)
  }

  public get accounts() {
    return this.getOrSet('accounts', AccountsService)
  }

  public get credit() {
    return this.getOrSet('credit', CreditService)
  }

  public get ecommerce() {
    return this.getOrSet('ecommerce', EcommerceService)
  }

  public get scheduler() {
    return this.getOrSet('scheduler', SchedulerClient)
  }

  /*  ---- Admin ---- */
  public get checkoutless() {
    return this.getOrSet('checkoutless', CheckoutlessClient)
  }

  public get categories() {
    return this.getOrSet('categories', CategoriesClient)
  }

  public get paymentsClient() {
    return this.getOrSet('paymentsClient', PaymentsClient)
  }

  public get adminMetrics() {
    return this.getOrSet('adminMetrics', MetricsService)
  }

  public get paymentGateway() {
    return this.getOrSet('paymentGateway', PaymentGateway)
  }

  /*  ---- Orion ---- */

  public get orionServices() {
    return this.getOrSet('orionServices', OrionServices)
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/typings/payments.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export interface IPaymentSystem {
  id: string
  name: string
}

export interface ISalesChannels {
  id: string
}

export interface IPaymentRules {
  enabled: boolean
  id: string
  name: string
  paymentSystem: IPaymentSystem
  salesChannels: ISalesChannels[]
}

export interface IPayment {
  id: string
  paymentMethodName: string
  payment: string
  isActive: boolean
  type: string
  accountName: string
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/middlewares/scheduler.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
const CRON_EXPRESSION = '*/5 * * * *'

export async function scheduler(ctx: Context, next: () => Promise<unknown>) {
  try {
    const {
      // eslint-disable-next-line @typescript-eslint/no-shadow
      clients: { scheduler },
      vtex: { workspace, account },
    } = ctx

    const cron = await scheduler
      .getSchedule('schedulerMyCheckoutPing')
      .then((data) => {
        return data
      })
      .catch(() => {
        return null
      })

    if (!cron || cron.expression !== CRON_EXPRESSION) {
      const schedulerData = {
        id: `schedulerMyCheckoutPing`,
        scheduler: {
          expression: CRON_EXPRESSION,
          endDate: '2029-12-30T23:29:00',
        },
        request: {
          method: 'GET',
          uri: `https://${workspace}--${account}.myvtex.com/_v/api/mycheckout/healthcheck`,
          headers: {
            'cache-control': 'no-cache',
            pragma: 'no-cache',
          },
          body: null,
        },
      }

      await scheduler
        .createOrUpdateSchedule(schedulerData)
        .catch((error: Error) => {
          throw new Error(error.message)
        })
    }

    ctx.body = true
    ctx.status = 200
    ctx.set('Cache-Control', 'no-cache')
  } catch (e) {
    throw new Error(e.message)
  }

  await next()
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/middlewares/healthcheck.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export async function healthcheck(ctx: Context, next: () => Promise<any>) {
  ctx.status = 200
  ctx.body = 'OK'
  ctx.set('Cache-Control', 'no-cache')

  await next()
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/utils/config.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { pathOr, uniqBy } from 'ramda'

import type { IPaymentRules } from '../typings/payments'

export const buildPayments = (
  account: string,
  paymentsCreated: any[],
  paymentRules: IPaymentRules[]
) =>
  uniqBy(
    (e) => pathOr('', ['paymentSystem', 'id'], e),
    [
      ...paymentRules.filter(
        (ruler) =>
          ruler.enabled &&
          ruler?.paymentSystem?.name !== 'Kuikpay' &&
          ruler?.paymentSystem?.name !== 'PSE' &&
          ruler?.paymentSystem?.name !== 'Pago contra entrega'
      ),
    ]
  ).map((ruler) => {
    const payment = paymentsCreated.find(
      (p) => p.paymentMethodName === ruler.paymentSystem.id.toString()
    )

    return {
      id: pathOr('', ['id'], payment) as string,
      paymentMethodName: pathOr('', ['paymentSystem', 'id'], ruler) as string,
      payment: pathOr('', ['paymentSystem', 'name'], ruler) as string,
      isActive: pathOr(true, ['isActive'], payment) as boolean,
      type: pathOr(
        (ruler as any)?.type || 'store',
        ['type'],
        payment
      ) as unknown as string,
      accountName: account,
    }
  })

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/queries.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
/* ---- Checkout ---- */

export { getUser } from './checkout/user'

export { login, verifyCode } from './checkout/auth'

export { getAddress } from './checkout/address'

export { getPayments } from './checkout/payments'

export {
  getCountries,
  getCountry,
  getStateCities,
  getCities,
} from './checkout/countries'

export { getDocumentTypes } from './checkout/documents'

export { accounts } from './checkout/accounts'

export { validateCredit } from './checkout/credit'

/* ---- Admin ---- */

export { token } from './admin/token'

export { getLinksByAccount } from './admin/getLinksByAccount'

export { getAccount } from './admin/getAccount'

export { getCategories } from './admin/getCategories'

export { getPaymentsMethods } from './admin/getPaymentsMethods'

export {
  ticketAverage,
  checkout,
  button,
  conversionRate,
} from './admin/metrics'

export { getPaymentProcessStatus } from './checkout/orders'
export { getStyles } from './admin/getStyles'

/* ---- Orion ---- */
export * from './orion/queries'

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/mutations.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
/* ---- Checkout ---- */

export { createUser, updateUser } from './checkout/user'

export {
  createAddress,
  externalAddress,
  deleteAddress,
  updateAddress,
} from './checkout/address'

export { deletePayment } from './checkout/payments'

export { createOrder } from './checkout/orders'

export { ecommerce } from './checkout/ecommerce'

/* ---- admin ---- */

export { saveToken } from './admin/saveToken'

export { createLink } from './admin/createLink'

export { updateLink } from './admin/updateLink'

export { deleteLink } from './admin/deleteLink'

export { handleVisualization } from './admin/handleVisualization'

export { createPaymentMethod } from './admin/createPaymentsMethods'

export { updateStyles } from './admin/updateStyles'

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/base/base.restservice.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
/* eslint-disable @typescript-eslint/ban-types */
import type { InstanceOptions, IOContext, RequestConfig } from '@vtex/api'
import { ExternalClient } from '@vtex/api'

import { urlApi, urlApiQA } from './base.urls'

export class BaseRestService extends ExternalClient {
  constructor(ctx: IOContext, options?: InstanceOptions) {
    super(
      ctx.production
        ? `${urlApi}/${options?.baseURL}`
        : `${urlApiQA}/${options?.baseURL}`,
      ctx,
      {
        ...options,
        headers: {
          ...options?.headers,
          VtexIdclientAutCookie: ctx.authToken,
        },
      }
    )
  }

  protected get(endpoint: string, config?: RequestConfig) {
    return this.http.get(`/${endpoint}`, {
      ...config,
    })
  }

  protected post(endpoint: string, data: object, config?: RequestConfig) {
    return this.http.post(`/${endpoint}`, data, {
      ...config,
    })
  }

  protected put(endpoint: string, data: object, config?: RequestConfig) {
    return this.http.put(`/${endpoint}`, data, {
      ...config,
    })
  }

  protected delete(endpoint: string, config?: RequestConfig) {
    return this.http.delete(`/${endpoint}`, {
      ...config,
    })
  }

  protected headers(auth: string) {
    return {
      Authorization: `Bearer ${auth}`,
    }
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/base/base.urls.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export const urlApi =
  '' // Prod
export const urlApiQA =
  '' // QA

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/orion/index.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { InstanceOptions, IOContext } from '@vtex/api'
import { IOClient } from '@vtex/api'

import { AuthService } from './auth'

export class OrionServices extends IOClient {
  public auth: AuthService
  constructor(context: IOContext, options?: InstanceOptions) {
    super(context, options)
    this.auth = new AuthService(context, options)
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/orion/auth.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { InstanceOptions, IOContext } from '@vtex/api'

import { BaseRestService } from '../../base/base.restservice'

export class AuthService extends BaseRestService {
  constructor(
    context: IOContext,
    options?: InstanceOptions,
    private readonly name: string = 'auth'
  ) {
    super(context, options)
  }

  public login(authBnpl: {
    redirectUrl: string
    consumerId: string
    clientIp: string
    authCode: string
  }): Promise<unknown> {
    return this.post(`${this.name}/login`, authBnpl, {
      metric: `${this.name}-login`,
      timeout: 5000,
    })
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/admin/checkoutless.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { BaseRestService } from '../../base/base.restservice'

export class CheckoutlessClient extends BaseRestService {
  public create(accountData: {
    account: string
    paymentMethodId: string
    cvcRequired: boolean
    buttonMessage: string
    visualization: Array<{ type: string; key: string }>
  }) {
    return this.http.post('/accounts', accountData)
  }

  public findByAccount() {
    const { account } = this.context

    return this.http.get(`/accounts?an=${account}`)
  }

  public createLink(accountLinkData: {
    accountRequester: string
    accountApprover: string
  }) {
    return this.http.post('/accounts/links', accountLinkData)
  }

  public updateLink(id: string, status: string) {
    return this.http.put('/accounts/links', {
      id,
      status,
    })
  }

  public deleteLink(id: string) {
    return this.http.delete(`/accounts/links/${id}`)
  }

  public getLinksByAccount(account: string) {
    return this.http.get(`/accounts/links/${account}`)
  }

  public createVisualization(
    visualization: Array<{
      type: string
      key: string
    }>,
    account: string
  ) {
    return this.http.post(`/accounts?an=${account}`, {
      visualization,
      account,
    })
  }

  public updateStyles(
    {
      styles,
      buttonText,
      restore,
    }: { styles: string; buttonText: string; restore: boolean },
    account: string
  ) {
    return this.http.post(`/accounts/styles?an=${account}`, {
      styles,
      buttonText,
      restore,
    })
  }

  public getStyles(account: string) {
    return this.http.get(`/accounts/styles?an=${account}`)
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/admin/paymentGateway.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { InstanceOptions, IOContext } from '@vtex/api'
import { ExternalClient } from '@vtex/api'

export class PaymentGateway extends ExternalClient {
  constructor(ctx: IOContext, options?: InstanceOptions) {
    super(`https://${ctx.account}.vtexpayments.com.br`, ctx, {
      ...options,
      headers: {
        ...options?.headers,
        VtexIdclientAutCookie:
          ctx.storeUserAuthToken ?? ctx.adminUserAuthToken ?? ctx.authToken,
      },
    })
  }

  public getPaymentRules = (): Promise<any> =>
    this.http.get(`/api/pvt/rules`, {
      metric: 'get-payment-rules',
    })
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/admin/categories.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type {
  IOContext,
  InstanceOptions,
  SegmentData,
  RequestConfig,
} from '@vtex/api'
import { AppClient } from '@vtex/api'
import { stringify } from 'qs'

const inflightKey = ({ baseURL, url, params, headers }: RequestConfig) => {
  return `${baseURL}${url}${stringify(params, {
    arrayFormat: 'repeat',
    addQueryPrefix: true,
  })}&segmentToken=${headers['x-vtex-segment']}`
}

export class CategoriesClient extends AppClient {
  private basePath: string

  constructor(context: IOContext, options?: InstanceOptions) {
    super('vtex.catalog-api-proxy@0.x', context, options)
    this.basePath = context.sessionToken
      ? '/proxy/authenticated/catalog'
      : '/proxy/catalog'
  }

  public async getCategories() {
    const response = await this.get(`/pub/category/tree/3/`, {
      metric: 'search-categories',
    })

    return response
  }

  private get = <T = unknown>(url: string, config: RequestConfig = {}) => {
    const segmentData: SegmentData | undefined = (this.context as any).segment
    const { channel: salesChannel = '' } = segmentData ?? {}

    config.params = {
      ...config.params,
      ...(!!salesChannel && { sc: salesChannel }),
    }
    config.inflightKey = inflightKey

    return this.http.get<T>(`${this.basePath}${url}`, config)
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/admin/payments.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { BaseRestService } from '../../base/base.restservice'

export class PaymentsClient extends BaseRestService {
  public getPaymentsMethods() {
    const { account } = this.context

    return this.http.get(`/accounts/payment-methods?an=${account}`)
  }

  public createPaymentMethod(args: {
    type: string
    isActive: boolean
    paymentMethodName: string
  }) {
    return this.http.post(
      `/accounts/payment-methods?an=${this.context.account}`,
      args
    )
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/admin/metrics.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { InstanceOptions, IOContext } from '@vtex/api'

import { BaseRestService } from '../../base/base.restservice'

export class MetricsService extends BaseRestService {
  constructor(
    context: IOContext,
    options?: InstanceOptions,
    private readonly name: string = 'metrics'
  ) {
    super(context, options)
  }

  public categoryMetrics(data: unknown) {
    const { account } = this.context

    return this.post(
      `${this.name}/categories/category`,
      { data: { ...(data as JSON), account } },
      {
        metric: `${this.name}-get`,
      }
    )
  }

  public subcategoryMetrics(category: string, data: unknown) {
    const { account } = this.context

    return this.post(
      `${this.name}/categories/subcategory?c=${category || 'default'}`,
      { data: { ...(data as JSON), account } },
      {
        metric: `${this.name}-get`,
      }
    )
  }

  public ticketAverage(data: unknown) {
    const { account } = this.context

    return this.post(
      `${this.name}/ticket`,
      { data: { ...(data as JSON), account } },
      {
        metric: `${this.name}-get`,
      }
    )
  }

  public checkout(data: unknown) {
    const { account } = this.context

    return this.post(
      `${this.name}/checkout`,
      { data: { ...(data as JSON), account } },
      {
        metric: `${this.name}-get`,
      }
    )
  }

  public button(data: unknown) {
    const { account } = this.context

    return this.post(
      `${this.name}/button`,
      { data: { ...(data as JSON), account } },
      {
        metric: `${this.name}-get`,
      }
    )
  }

  public conversionRate(data: unknown) {
    const { account } = this.context

    return this.post(
      `${this.name}/conversion`,
      { data: { ...(data as JSON), account } },
      {
        metric: `${this.name}-get`,
      }
    )
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/checkout/credit.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { InstanceOptions, IOContext } from '@vtex/api'

import { BaseRestService } from '../../base/base.restservice'

export class CreditService extends BaseRestService {
  constructor(
    context: IOContext,
    options?: InstanceOptions,
    private readonly name: string = 'credit'
  ) {
    super(context, options)
  }

  public validateCredit(args: {
    email: string
    totals: number
  }): Promise<unknown> {
    return this.post(`credit-pay/validate-credit`, args, {
      metric: `${this.name}-validateCredit`,
    })
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/checkout/ecommerce.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { InstanceOptions, IOContext } from '@vtex/api'

import { BaseRestService } from '../../base/base.restservice'

export class EcommerceService
  extends BaseRestService
  implements IEcommerceService
{
  constructor(
    context: IOContext,
    options?: InstanceOptions,
    private readonly name: string = 'ecommerce'
  ) {
    super(context, options)
  }

  public log(args: EcommerceInput): Promise<unknown> {
    const { account } = this.context

    args.account = args.account ? args.account : account

    return this.post(`${this.name}`, args, {
      metric: `${this.name}-get`,
    })
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/checkout/scheduler.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { JanusClient } from '@vtex/api'
import type { InstanceOptions, IOContext } from '@vtex/api'

const routes = {
  scheduler: (workspace: string, account: string) =>
    `/api/scheduler/${workspace}/${account}?version=4`,
  getSchedule: (workspace: string, account: string, id: string) =>
    `/api/scheduler/${workspace}/${account}/${id}?version=4`,
}

export default class SchedulerClient extends JanusClient {
  constructor(ctx: IOContext, options?: InstanceOptions) {
    super(ctx, {
      ...options,
      headers: {
        ...options?.headers,
        VtexIdclientAutCookie: ctx.authToken,
      },
    })
  }

  public createOrUpdateSchedule = (schedulerData: SchedulerArgs) => {
    return this.http.put(
      routes.scheduler(this.context.workspace, this.context.account),
      schedulerData,
      { metric: 'mycheckout-scheduler-create' }
    )
  }

  public getSchedule = (id: string) => {
    return this.http.get(
      routes.getSchedule(this.context.workspace, this.context.account, id),
      { metric: 'mycheckout-scheduler-get' }
    )
  }

  public deleteSchedule = (id: string) => {
    return this.http.delete(
      routes.getSchedule(this.context.workspace, this.context.account, id),
      { metric: 'mycheckout-scheduler-delete' }
    )
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/checkout/orders.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { InstanceOptions, IOContext } from '@vtex/api'

import { BaseRestService } from '../../base/base.restservice'

export class OrderService extends BaseRestService {
  constructor(
    context: IOContext,
    options?: InstanceOptions,
    private readonly name: string = 'orders'
  ) {
    super(context, options)
  }

  public createOrder(args: OrderInput, hostname: string): Promise<unknown> {
    const { account } = this.context

    args.account.accountName = account
    args.account.hostname = hostname
    args.oms = 'vtex'

    return this.post(`${this.name}/v2`, args, {
      metric: `${this.name}-create`,
      headers: {
        debug: true,
      },
    })
  }

  public getPaymentProcessStatus(orderId: string): Promise<unknown> {
    const { account } = this.context

    return this.get(
      `${this.name}/payment-process?an=${account}&orderId=${orderId}`,
      {
        metric: `${this.name}-get`,
      }
    )
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/checkout/documents.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { InstanceOptions, IOContext } from '@vtex/api'

import { BaseRestService } from '../../base/base.restservice'

export class DocumentsService
  extends BaseRestService
  implements DocumentServiceImpl
{
  constructor(
    context: IOContext,
    options?: InstanceOptions,
    private readonly name: string = 'documents'
  ) {
    super(context, options)
  }

  public getDocumentTypes(): unknown {
    return this.get(`masters/${this.name}?limit=100`, {
      metric: `${this.name}-get`,
    })
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/checkout/accounts.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { InstanceOptions, IOContext } from '@vtex/api'

import { BaseRestService } from '../../base/base.restservice'

export class AccountsService extends BaseRestService {
  constructor(
    context: IOContext,
    options?: InstanceOptions,
    private readonly name: string = 'accounts'
  ) {
    super(context, options)
  }

  public accounts(): unknown {
    return this.get(`${this.name}/storefront?an=${this.context.account}`, {
      metric: `${this.name}-get`,
    })
  }

  public initConfig(): unknown {
    return this.post(`${this.name}/initConfig`, {})
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/checkout/payments.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { InstanceOptions, IOContext } from '@vtex/api'

import { BaseRestService } from '../../base/base.restservice'

export class PaymentsService extends BaseRestService implements IPayments {
  constructor(
    context: IOContext,
    options?: InstanceOptions,
    private readonly name: string = 'cards'
  ) {
    super(context, options)
  }

  public getPayments(
    email: User['email'],
    auth: string
  ): Payments[] | Promise<Payments[]> {
    const { account } = this.context

    return this.get(`users/${this.name}/${email}?an=${account}`, {
      headers: this.headers(auth),
      metric: `${this.name}-get`,
    })
  }

  public createPayment(args: Payments): Promise<unknown> {
    return this.post(`${this.name}/`, args, {
      metric: `${this.name}-create`,
    })
  }

  public async deletePayment(
    id: Payments['id'],
    auth: string
  ): Promise<unknown> {
    return (
      await this.delete(`users/${this.name}/${id}`, {
        headers: this.headers(auth),
        metric: `${this.name}-create`,
      })
    ).data
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/checkout/countries.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { InstanceOptions, IOContext } from '@vtex/api'

import { BaseRestService } from '../../base/base.restservice'

export class CountriesService
  extends BaseRestService
  implements CountriesServiceImpl
{
  constructor(
    context: IOContext,
    options?: InstanceOptions,
    private readonly name: string = 'countries'
  ) {
    super(context, options)
  }

  public getCountries(): unknown {
    return this.get(`masters/${this.name}`, {
      metric: `${this.name}-get`,
    })
  }

  public getCountry(id: string): unknown {
    return this.get(`${this.name}/${id}`, {
      metric: `${this.name}-get`,
    })
  }

  public async getStateCities(country: string, state: string) {
    return this.get(
      `masters/${this.name}/stateCities?country=${country}&state=${state}`,
      {
        metric: `${this.name}-get`,
      }
    )
  }

  public async getCities(city: string) {
    return this.get(`masters/${this.name}/cities?city=${city}`, {
      metric: `${this.name}-get`,
    })
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/checkout/user.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { InstanceOptions, IOContext } from '@vtex/api'

import { BaseRestService } from '../../base/base.restservice'

export class UserService extends BaseRestService implements IUser {
  constructor(
    context: IOContext,
    options?: InstanceOptions,
    private readonly name: string = 'users'
  ) {
    super(context, options)
  }

  public getUser(
    email: User['email'],
    _account: string,
    auth: string
  ): Promise<unknown> {
    const { account } = this.context
    const query = _account ? `?an=${_account}` : `?an=${account}`

    return this.get(`${this.name}/profiles/${email}${query}`, {
      headers: this.headers(auth),
      metric: `${this.name}-get`,
    })
  }

  public createUser(args: User): Promise<unknown> {
    const { account } = this.context

    return this.post(`${this.name}/profiles?an=${account}`, args, {
      metric: `${this.name}-create`,
    })
  }

  public updateUser(args: UserInput, auth: string): Promise<unknown> {
    return this.put(`${this.name}/profiles`, args, {
      headers: this.headers(auth),
      metric: `${this.name}-update`,
    })
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/checkout/auth.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { InstanceOptions, IOContext } from '@vtex/api'

import { BaseRestService } from '../../base/base.restservice'

export class AuthService extends BaseRestService implements IAuth {
  constructor(
    context: IOContext,
    options?: InstanceOptions,
    private readonly name: string = 'auth'
  ) {
    super(context, options)
  }

  public login(email: Auth['email'], origin: string): Promise<unknown> {
    const { account } = this.context

    return this.post(
      `users/${this.name}/${email}?an=${account}`,
      { origin },
      {
        metric: `${this.name}-login`,
        timeout: 5000,
      }
    )
  }

  public verifyCode(args: Auth): Promise<unknown> {
    const { account } = this.context

    return this.post(
      `users/${this.name}/verify/${args.email}?an=${account}`,
      args,
      {
        metric: `${this.name}-verifycode`,
      }
    )
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/clients/checkout/address.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { InstanceOptions, IOContext } from '@vtex/api'

import { BaseRestService } from '../../base/base.restservice'

export class AddressService extends BaseRestService {
  constructor(
    context: IOContext,
    options?: InstanceOptions,
    private readonly name: string = 'addresses'
  ) {
    super(context, options)
  }

  public getAddress(email: User['email'], auth: string): Promise<unknown> {
    const { account } = this.context

    return this.get(`users/${this.name}/${email}?an=${account}`, {
      headers: this.headers(auth),
      metric: `${this.name}-get`,
    })
  }

  public createAddress(args: never): Promise<unknown> {
    return this.post(`users/${this.name}/`, args, {
      metric: `${this.name}-create`,
    })
  }

  public externalAddress(args: never): Promise<unknown> {
    const { account } = this.context

    return this.post(`users/${this.name}/external?an=${account}`, args, {
      metric: `${this.name}-create`,
    })
  }

  public updateAddress(args: never, auth: string): Promise<unknown> {
    return this.put(`users/${this.name}/`, args, {
      headers: this.headers(auth),
      metric: `${this.name}-create`,
    })
  }

  public async deleteAddress(id: string, auth: string): Promise<unknown> {
    return (
      await this.delete(`users/${this.name}/${id}`, {
        headers: this.headers(auth),
        metric: `${this.name}-create`,
      })
    ).data
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/orion/auth.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export const authCookie = 'x-mycheckout-orion'

export const login = async (
  _: unknown,
  { authCode }: { authCode: string },
  { clients: { orionServices: OrionServicesClient }, cookies, request }: Context
) => {
  const origin = request.get('origin').split('://')
  const args = {
    redirectUrl: '',
    consumerId: '',
    clientIp: '',
    authCode,
  }

  args.redirectUrl = `${request.get('origin')}/`
  // TODO: investigar de donde obtener ORN
  args.consumerId = 'ORN'
  args.clientIp = request.get('x-forwarded-for')?.split(',')?.[0] || '127.0.0.1'

  const response = (await OrionServicesClient.auth.login(args)) as {
    token: string
    transactionId: string
  }

  cookies.set(
    authCookie,
    Buffer.from(`${response.transactionId}:${response.token}`).toString(
      'base64'
    ),
    {
      httpOnly: false,
      domain: origin[1],
      secure: origin[0] === 'https',
      expires: new Date(
        new Date().setTime(new Date().getTime() + 2 * 60 * 60 * 1000)
      ),
    }
  )

  return response
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/admin/getStyles.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export const getStyles = async (
  _: any,
  __: any,
  { clients: { checkoutless: CheckoutlessClient }, vtex: { account } }: Context
) => {
  return CheckoutlessClient.getStyles(account)
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/admin/getAccount.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export function getAccount(
  _: unknown,
  __: unknown,
  { clients: { checkoutless } }: Context
) {
  return checkoutless.findByAccount()
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/admin/getCategories.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export async function getCategories(
  _: unknown,
  __: unknown,
  { clients: { categories } }: Context
) {
  const theCategories = await categories.getCategories()

  return theCategories
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/admin/updateStyles.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export const updateStyles = async (
  _: any,
  {
    styles,
    buttonText,
    restore = false,
  }: {
    styles: string
    buttonText: string
    restore: boolean
  },
  { clients: { checkoutless: CheckoutlessClient }, vtex: { account } }: Context
) => {
  return CheckoutlessClient.updateStyles(
    { styles, buttonText, restore },
    account
  )
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/admin/getPaymentsMethods.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export async function getPaymentsMethods(
  _: unknown,
  __: unknown,
  { clients: { paymentsClient } }: Context
) {
  const paymentMethods = await paymentsClient.getPaymentsMethods()

  return paymentMethods
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/admin/getLinksByAccount.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export async function getLinksByAccount(
  _: unknown,
  __: unknown,
  { clients: { checkoutless }, vtex: { account } }: Context
) {
  const data = await checkoutless.getLinksByAccount(account)

  return data.map(
    (item: { accountApprover: string; accountRequester: string }) => ({
      ...item,
      account:
        account === item.accountApprover
          ? item.accountRequester
          : item.accountApprover,
      approver: account === item.accountApprover,
    })
  )
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/admin/handleVisualization.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
interface Arg {
  visualization: Array<{
    type: string
    key: string
  }>
}

export async function handleVisualization(
  _: unknown,
  { visualization }: Arg,
  { clients: { checkoutless }, vtex: { account } }: Context
) {
  const data = await checkoutless.createVisualization(visualization, account)

  return data
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/admin/deleteLink.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export async function deleteLink(
  _: unknown,
  { id }: { id: string },
  { clients: { checkoutless } }: Context
) {
  const data = await checkoutless.deleteLink(id)

  return {
    ...data,
    id,
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/admin/updateLink.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export async function updateLink(
  _: unknown,
  { id, status }: { id: string; status: string },
  { clients: { checkoutless }, vtex: { account } }: Context
) {
  const data = (await checkoutless.updateLink(id, status)) as unknown as {
    accountApprover: string
    accountRequester: string
  }

  return {
    ...data,
    account:
      account === data.accountApprover
        ? data.accountRequester
        : data.accountApprover,
    approver: account === data.accountApprover,
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/admin/createLink.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export async function createLink(
  _: unknown,
  { accountApprover }: { accountApprover: string },
  { clients: { checkoutless }, vtex: { account } }: Context
) {
  const data = (await checkoutless.createLink({
    accountRequester: account,
    accountApprover,
  })) as unknown as {
    accountApprover: string
    accountRequester: string
  }

  return {
    ...data,
    account:
      account === data.accountApprover
        ? data.accountRequester
        : data.accountApprover,
    approver: account === data.accountApprover,
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/admin/createPaymentsMethods.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
interface PaymentMethodsInput {
  type: string
  isActive: boolean
  paymentMethodName: string
}

export function createPaymentMethod(
  _: unknown,
  args: PaymentMethodsInput,
  { clients: { paymentsClient } }: Context
) {
  return paymentsClient.createPaymentMethod(args)
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/admin/saveToken.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { buildPayments } from '../../utils/config'
import { createPaymentMethod } from './createPaymentsMethods'
import type { IPayment, IPaymentRules } from '../../typings/payments'

const configPaymentsMethods = async (ctx: Context) => {
  const {
    clients: { paymentsClient, paymentGateway },
    vtex: { account },
  } = ctx

  const paymentsCreated: IPaymentRules[] =
    await paymentsClient.getPaymentsMethods()

  if (paymentsCreated?.length > 0) return

  const paymentRules: any[] = await paymentGateway.getPaymentRules()

  const paymentsRules = buildPayments(account, paymentsCreated, paymentRules)

  await Promise.all(
    paymentsRules.map(async (payment) => {
      await createPaymentMethod('', payment as IPayment, ctx)
    })
  )
}

export async function saveToken(
  _: unknown,
  {
    paymentMethodId,
    cvcRequired,
    buttonMessage,
    visualization,
  }: {
    paymentMethodId: string
    cvcRequired: boolean
    buttonMessage: string
    visualization: Array<{ type: string; key: string }>
  },
  ctx: Context
) {
  const {
    clients: { checkoutless },
    vtex: { account },
  } = ctx

  await checkoutless.create({
    account,
    paymentMethodId,
    cvcRequired,
    buttonMessage,
    visualization,
  })

  try {
    await configPaymentsMethods(ctx)
  } catch (error) {
    console.error('configPaymentsMethods', error)
  }

  return 'ok'
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/admin/token.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
/* eslint-disable @typescript-eslint/no-shadow */
export function token(_: unknown, __: unknown, ctx: Context) {
  return ctx.clients.vbase
    .getJSON<{ token: string }>('account.example', 'configs')
    .then(({ token }) => token)
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/admin/metrics.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export const categoryMetrics = async (
  _: unknown,
  { data }: { data: unknown },
  { clients: { adminMetrics: AdminMetricsClient } }: Context
) => {
  return AdminMetricsClient.categoryMetrics(data)
}

export const subcategoryMetrics = async (
  _: unknown,
  { category, data }: { category: string; data: unknown },
  { clients: { adminMetrics: AdminMetricsClient } }: Context
) => {
  return AdminMetricsClient.subcategoryMetrics(category, data)
}

export const ticketAverage = async (
  _: unknown,
  { data }: { data: unknown },
  { clients: { adminMetrics: AdminMetricsClient } }: Context
) => {
  return AdminMetricsClient.ticketAverage(data)
}

export const checkout = async (
  _: unknown,
  { data }: { data: unknown },
  { clients: { adminMetrics: AdminMetricsClient } }: Context
) => {
  return AdminMetricsClient.checkout(data)
}

export const button = async (
  _: unknown,
  { data }: { data: unknown },
  { clients: { adminMetrics: AdminMetricsClient } }: Context
) => {
  return AdminMetricsClient.button(data)
}

export const conversionRate = async (
  _: unknown,
  { data }: { data: unknown },
  { clients: { adminMetrics: AdminMetricsClient } }: Context
) => {
  return AdminMetricsClient.conversionRate(data)
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/checkout/credit.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export const validateCredit = (
  _: unknown,
  args: { email: string; totals: number },
  { clients: { credit: CreditClient } }: Context
) => {
  return CreditClient.validateCredit(args)
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/checkout/ecommerce.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export const sessionCookie = 'x-ecommerce-session'
const sessionMaxTime = 30 * 60 * 1000

export const ecommerce = async (
  _: unknown,
  { args }: { args: EcommerceInput },
  { clients: { ecommerce: EcommerceClient }, cookies, request }: Context
) => {
  const session = cookies.get(sessionCookie)

  if (session?.match(/^[a-z0-9]+$/i)) args.session = session
  const response = (await EcommerceClient.log(args)) as { session?: string }
  const origin = request.get('origin').split('://')

  if (response.session?.match(/^[a-z0-9]+$/i)) {
    cookies.set(sessionCookie, response.session, {
      httpOnly: false,
      domain: origin[1],
      overwrite: true,
      maxAge: sessionMaxTime,
    })
  }

  return response
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/checkout/orders.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export const createOrder = (
  _: unknown,
  { orderArgs }: { orderArgs: OrderInput },
  { clients: { orders: OrdersClient }, request }: Context
) => {
  if (
    orderArgs.payment?.additionalData &&
    orderArgs.payment.additionalData instanceof Array
  ) {
    orderArgs.payment.additionalData = orderArgs.payment.additionalData.reduce<
      Record<string, string>
    >((prev: Record<string, string>, item: { key: string; value: string }) => {
      return {
        ...prev,
        [item.key]: item.value,
      }
    }, {})
  }

  const origin = request.get('origin').split('://')

  return OrdersClient.createOrder(orderArgs, origin[1])
}

export const getPaymentProcessStatus = (
  _: unknown,
  { orderId }: { orderId: string },
  { clients: { orders: OrdersClient } }: Context
) => OrdersClient.getPaymentProcessStatus(orderId)

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/checkout/documents.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export const getDocumentTypes = async (
  _: unknown,
  __: unknown,
  { clients: { documents: DocumentsClient } }: Context
) => ((await DocumentsClient.getDocumentTypes()) as { data: unknown }).data

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/checkout/accounts.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export const accounts = async (
  _: unknown,
  __: unknown,
  { clients: { accounts: AccountsClient } }: Context
) => AccountsClient.accounts()

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/checkout/payments.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { authCookie } from './auth'

export const getPayments = (
  _: unknown,
  { email }: User,
  { clients: { payments: PaymentsClient }, cookies }: Context
) => PaymentsClient.getPayments(email, cookies.get(authCookie) as string)

export const deletePayment = (
  _: unknown,
  { id }: Payments,
  { clients: { payments: PaymentsClient }, cookies }: Context
) => PaymentsClient.deletePayment(id, cookies.get(authCookie) as string)

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/checkout/countries.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
export const getCountries = async (
  _: unknown,
  __: unknown,
  { clients: { countries: CountriesClient } }: Context
) => {
  const resp = await CountriesClient.getCountries()

  return {
    count: 1,
    total: 1,
    current: 1,
    prev: 1,
    next: 1,
    data: resp,
  }
}

export const getCountry = (
  _: unknown,
  { id }: Countries,
  { clients: { countries: CountriesClient } }: Context
) => CountriesClient.getCountry(id)

export const getStateCities = (
  _: unknown,
  { country, state }: { country: string; state: string },
  { clients: { countries: CountriesClient } }: Context
) => CountriesClient.getStateCities(country, state)

export const getCities = (
  _: unknown,
  { city }: { city: string },
  { clients: { countries: CountriesClient } }: Context
) => CountriesClient.getCities(city)

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/checkout/user.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { authCookie } from './auth'

export const formatCardContent = (cardContent: Record<string, string>) => {
  const newCardContent: Array<{ key: string; value: string }> = []

  for (const key in cardContent) {
    newCardContent.push({ key, value: cardContent[key] })
  }

  return newCardContent
}

const getDurationInMilliseconds = (start: [number, number]) => {
  const NS_PER_SEC = 1e9
  const NS_TO_MS = 1e6
  const diff = process.hrtime(start)

  return (diff[0] * NS_PER_SEC + diff[1]) / NS_TO_MS
}

export const getUser = async (
  _: unknown,
  { email }: { email: string },
  { clients: { user: UserClient }, cookies, vtex: { account, logger } }: Context
) => {
  const start = process.hrtime()

  logger.info(`[STARTED] ${start}`)
  const resp = (await UserClient.getUser(
    email,
    account,
    cookies.get(authCookie) as string
  )) as User

  const durationInMilliseconds = getDurationInMilliseconds(start)

  logger.info(`[FINISHED] ${durationInMilliseconds}`)
  resp.id_type = resp.documentType
  resp.id_number = resp.document
  resp.phone_code = resp.phoneCode
  resp.phone_number = resp.phoneNumber

  if (resp.selectedPayment?.card?.cardContent) {
    resp.selectedPayment.card.cardContent = formatCardContent(
      resp.selectedPayment.card.cardContent as Record<string, string>
    )

    resp.cards = resp.cards.map((card: { cardContent: unknown }) => {
      if (card?.cardContent) {
        return {
          ...card,
          cardContent: formatCardContent(
            card.cardContent as Record<string, string>
          ),
        }
      }

      return card
    })
  }

  return resp
}

export const updateUser = async (
  _: unknown,
  { userArgs }: { userArgs: UserInput },
  { clients: { user: UserClient }, cookies }: Context
) => {
  const resp = (await UserClient.updateUser(
    userArgs,
    cookies.get(authCookie) as string
  )) as { data: User } & User

  resp.id_type = resp.documentType
  resp.id_number = resp.document
  resp.phone_code = resp.phoneCode
  resp.phone_number = resp.phoneNumber

  if (resp.data.selectedPayment?.card?.cardContent) {
    resp.data.selectedPayment.card.cardContent = formatCardContent(
      resp.data.selectedPayment.card.cardContent as Record<string, string>
    )

    resp.data.cards = resp.data.cards.map((card: { cardContent: unknown }) => {
      if (card?.cardContent) {
        return {
          ...card,
          cardContent: formatCardContent(
            card.cardContent as Record<string, string>
          ),
        }
      }

      return card
    })
  }

  return resp
}

export const createUser = async (
  _: unknown,
  args: User,
  { clients: { user: UserClient } }: Context
) => {
  const resp = (await UserClient.createUser(args)) as User

  resp.id_type = resp.documentType
  resp.id_number = resp.document
  resp.phone_code = resp.phoneCode
  resp.phone_number = resp.phoneNumber

  return resp
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/checkout/auth.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { formatCardContent } from './user'

export const authCookie = 'x-checkoutless-auth'

export const login = (
  _: unknown,
  { email }: Auth,
  { clients: { auth: AuthClient }, origin }: Context
) => {
  const formatOrigin = origin.split('://')

  return AuthClient.login(email, formatOrigin[1])
}

export const verifyCode = async (
  _: unknown,
  { email, code }: Auth,
  { clients: { auth: AuthClient }, cookies, origin }: Context
) => {
  const response = (await AuthClient.verifyCode({ email, code })) as {
    data: {
      selectedPayment: {
        card: { cardContent: unknown }
      }
      accessToken: string
      cards: Array<{ cardContent: unknown }>
    }
  }

  const formatOrigin = origin.split('://')

  cookies.set(authCookie, response.data.accessToken, {
    httpOnly: false,
    domain: formatOrigin[1],
  })

  if (response.data.selectedPayment?.card?.cardContent) {
    response.data.selectedPayment.card.cardContent = formatCardContent(
      response.data.selectedPayment.card.cardContent as Record<string, string>
    )

    response.data.cards = response.data.cards.map(
      (card: { cardContent: unknown }) => {
        if (card?.cardContent) {
          return {
            ...card,
            cardContent: formatCardContent(
              card.cardContent as Record<string, string>
            ),
          }
        }

        return card
      }
    )
  }

  return response
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/resolvers/checkout/address.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { authCookie } from './auth'

export const getAddress = (
  _: unknown,
  { email }: User,
  { clients: { address: AddressClient }, cookies }: Context
) => AddressClient.getAddress(email, cookies.get(authCookie) as string)

export const createAddress = (
  _: unknown,
  args: unknown,
  { clients: { address: AddressClient } }: Context
) => AddressClient.createAddress(args as never)

export const externalAddress = (
  _: unknown,
  { args }: { args: unknown },
  { clients: { address: AddressClient } }: Context
) => AddressClient.externalAddress(args as never)

export const updateAddress = (
  _: unknown,
  args: unknown,
  { clients: { address: AddressClient }, cookies }: Context
) =>
  AddressClient.updateAddress(args as never, cookies.get(authCookie) as string)

export const deleteAddress = (
  _: unknown,
  { id }: { id: string },
  { clients: { address: AddressClient }, cookies }: Context
) => AddressClient.deleteAddress(id, cookies.get(authCookie) as string)

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/base/typings/orders.d.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
interface OrderInput {
  items: [ItemInput]
  payment: PaymentDataInput
  profile: ProfileInput
  shipping: ShippingInput
  account: AccountInput
  channel: string
  oms: string
  customApps: CustomDataInput
}

interface CustomDataInput {
  customApps: [CustomAppsInput]
}

interface CustomAppsInput {
  id: string
  major: number
  fields: [CustomFieldsInput]
}

interface CustomFieldsInput {
  key: string
  value: string
}

interface ShippingInput {
  addressId: string
  externalAddress: unknown
  logisticsInfo: [LogisticInfoInput]
}

interface ItemInput {
  id: string
  quantity: number
  seller: string
}

interface LogisticInfoInput {
  itemIndex: number
  selectedSla: string
  selectedDeliveryChannel: string
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/base/typings/addresses.d.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
interface IAddress {
  getAddress(email: User['email'], auth: string): unknown | Promise<unknown>
  createAddress(args: unknown): Promise<unknown>
  updateAddress(args: unknown, auth: string): Promise<GeneralAddressResponse>
  deleteAddress(id: string, auth: string): Promise<unknown>
}

interface GeneralAddressResponse {
  message: string
  data: unknown
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/base/typings/users.d.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
interface UserInput {
  name?: string
  lastname?: string
  phone_code?: string
  phone_number?: string
  selectedAddress?: string
  selectedPayment?: string
}

interface User {
  access_token?: string
  addresses?: unknown
  cards: Array<{ cardContent: unknown }>
  document: string
  documentType: string
  email: string
  id_number: string
  id_type: string
  id: string
  ip: string
  lastname: string
  name: string
  phone_code: string
  phone_number: string
  phoneCode: string
  phoneNumber: string
  selectedAddress?: unknown
  selectedPayment?: Payments
}

interface GeneralResponse {
  message: string
}

interface GeneralUserResponse {
  message: string
  data: User
}

interface ProfileInput {
  email: string
  habeasData: boolean
}

interface Auth {
  email: User['email']
  code: number
}

interface PaginatedUserResponse {
  count: number
  total: number
  current: number
  prev: number
  next: number
  data: User[]
}

interface IAuth {
  login(email: Auth['email'], origin: string): Promise<unknown>
  verifyCode(args: Auth): Promise<unknown>
}

interface IUser {
  getUser(
    email: User['email'],
    account: string,
    auth: string
  ): User | Promise<unknown>
  createUser(args: User): Promise<unknown>
  updateUser(args: UserInput, auth: string): Promise<unknown>
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/base/typings/ecommerce.d.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
interface DataInput {
  products: [ProductsInput]
}

interface EcommerceInput {
  event: string
  userEmail: string
  account: string
  data: DataInput
  session: string
}

interface IEcommerceService {
  log(args: EcommerceInput): unknown
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/base/typings/countries.d.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
interface PaginatedCountriesResponse {
  count: number
  total: number
  current: number
  prev: number
  next: number
  data: Countries[]
}

interface Countries {
  id: string
  country: string
  iso: string
  phone: string
  postal_code_regex: string
  states: States[]
}

interface States {
  state: string
  cities: Cities[]
}

interface Cities {
  city_id: string
  city: string
}

interface CountriesServiceImpl {
  getCountries(): unknown
  getCountry(id: string): unknown
  getStateCities(country: string, state: string): unknown
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/base/typings/payments.d.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
interface PaymentMethodsInput {
  type: string
  isActive: boolean
  paymentMethodName: string
  accountName: string
}

interface PaymentMethods {
  id: ID
  type: string
  isActive: boolean
  paymentMethodName: string
  accountName: string
}

interface PaymentDataInput {
  cardId?: string
  gateway: string
  paymentMethod: string
  token?: string
  franchise?: string
  number?: string
  bin?: string
  holderName?: string
  holderDocument?: string
  cvv?: string
  expirationDate?: string
  cardNumber?: string
  additionalData: Array<{ key: string; value: string }> | Record<string, string>
}

interface Payments {
  id: string
  email: User['email']
  franchise: string
  number: string
  ccToken: string
  bin?: string
  card: { cardContent: unknown }
}

interface IPayments {
  deletePayment(id: Payments['id'], auth: string): Promise<unknown>
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/base/typings/documents.d.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
interface PaginatedDocumentResponse {
  count: number
  total: number
  current: number
  prev: number
  next: number
  data: DocumentTypes[]
}

interface DocumentTypes {
  id: string
  name: string
  type: string
}

interface DocumentServiceImpl {
  getDocumentTypes(): unknown
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/base/typings/scheduler.d.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
interface SchedulerArgs {
  id: string
  scheduler: { expression: string; endDate: string }
  request: {
    uri: string
    method: string
    body: unknown
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/base/typings/products.d.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
interface ProductsInput {
  sku: string
  quantity: number
  price: number
  category: string
  subcategory: string
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/node/base/typings/accounts.d.ts from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```typescript
interface AccountInput {
  accountName: string
  hostname: string
  storePreferences: StorePreferencesInput
}

interface StorePreferencesInput {
  currencyCode: string
  countryCode: string
  salesChannel: string
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/react/fragments/address.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
fragment Address on Address {
  addressId
  addressType
  city
  complement
  country
  neighborhood
  number
  postalCode
  receiverName
  reference
  state
  street
  isDisposable
  geoCoordinates
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/react/fragments/orderForm.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
#import './address.graphql'
#import './item.graphql'

fragment OrderFormFragment on OrderForm {
  id
  items {
    ...ItemFragment
  }
  canEditData
  loggedIn
  userProfileId
  userType
  marketingData {
    coupon
    utmCampaign
    utmMedium
    utmSource
    utmiCampaign
    utmiPart
    utmiPage
  }
  totalizers {
    id
    name
    value
  }
  shipping {
    countries
    availableAddresses {
      ...Address
    }
    selectedAddress {
      ...Address
    }
    deliveryOptions {
      id
      deliveryChannel
      price
      estimate
      isSelected
    }
    pickupOptions {
      id
      address {
        ...Address
      }
      deliveryChannel
      price
      estimate
      isSelected
      friendlyName
      additionalInfo
      storeDistance
      transitTime
      businessHours {
        dayNumber
        closed
        closingTime
        openingTime
      }
    }
    isValid
  }
  paymentData {
    paymentSystems {
      id
      name
      groupName
      validator {
        regex
        mask
        cardCodeRegex
        cardCodeMask
        weights
        useCvv
        useExpirationDate
        useCardHolderName
        useBillingAddress
      }
      stringId
      requiresDocument
      isCustom
      description
      requiresAuthentication
      dueDate
    }
    payments {
      paymentSystem
      bin
      accountId
      tokenId
      installments
      referenceValue
      value
    }
    installmentOptions {
      paymentSystem
      installments {
        count
        hasInterestRate
        interestRate
        value
        total
      }
    }
    availableAccounts {
      accountId
      paymentSystem
      paymentSystemName
      cardNumber
      bin
    }
    isValid
  }
  clientProfileData {
    email
    firstName
    lastName
    document
    documentType
    phone
    isValid
  }
  clientPreferencesData {
    locale
    optInNewsletter
  }
  messages {
    couponMessages {
      code
    }
    generalMessages {
      code
      text
      status
    }
  }
  value
  allowManualPrice
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/react/fragments/item.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
#import './bundleItem.graphql'

fragment ItemFragment on Item {
  additionalInfo {
    brandName
  }
  attachments {
    name
    content
  }
  attachmentOfferings {
    name
    required
    schema
  }
  bundleItems {
    ...BundleItemFragment
  }
  parentAssemblyBinding
  parentItemIndex
  sellingPriceWithAssemblies
  options {
    assemblyId
    id
    quantity
    seller
    inputValues
    options {
      assemblyId
      id
      quantity
      seller
      inputValues
      options {
        assemblyId
        id
        quantity
        seller
        inputValues
      }
    }
  }
  availability
  detailUrl
  id
  imageUrls {
    at1x
    at2x
    at3x
  }
  listPrice
  manualPrice
  measurementUnit
  name
  offerings {
    id
    name
    price
    type
    attachmentOfferings {
      name
      required
      schema
    }
  }
  price
  priceTags {
    identifier
    isPercentual
    name
    rawValue
    value
  }
  productCategories
  productCategoryIds
  productRefId
  productId
  quantity
  seller
  sellingPrice
  skuName
  skuSpecifications {
    fieldName
    fieldValues
  }
  unitMultiplier
  uniqueId
  refId
  priceTags {
    identifier
    isPercentual
    rawValue
    value
    name
    ratesAndBenefitsIdentifier {
      description
      id
      featured
      name
      matchedParameters
    }
  }
  isGift
  priceDefinition {
    calculatedSellingPrice
    total
    sellingPrices {
      quantity
      value
    }
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/react/fragments/bundleItem.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
fragment BundleItemFragment on Item {
  additionalInfo {
    brandName
  }
  attachments {
    name
    content
  }
  attachmentOfferings {
    name
    required
    schema
  }
  availability
  detailUrl
  id
  imageUrls {
    at1x
    at2x
    at3x
  }
  listPrice
  measurementUnit
  name
  offerings {
    id
    name
    price
    type
    attachmentOfferings {
      name
      required
      schema
    }
  }
  price
  productCategories
  productCategoryIds
  productRefId
  productId
  quantity
  seller
  sellingPrice
  skuName
  skuSpecifications {
    fieldName
    fieldValues
  }
  unitMultiplier
  uniqueId
  refId
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/react/mutations/addItemOffering.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
# import '../fragments/orderForm.graphql'

mutation AddItemOffering($offeringInput: OfferingInput) {
  addItemOffering(offeringInput: $offeringInput) {
    ...OrderFormFragment
  }
}

```


[System] You are an expert VTEX IO developer. You specialize in building VTEX Store Framework apps, React components, GraphQL APIs, and Node.js services for e-commerce platforms.

[User] Show me the implementation of mycheckout-store-framework/react/mutations/removeItemOffering.graphql from the mycheckout-store-framework VTEX app.

[Assistant]
Here's the implementation:

```graphql
# import '../fragments/orderForm.graphql'

mutation RemoveItemOffering($offeringInput: OfferingInput) {
  removeItemOffering(offeringInput: $offeringInput) {
    ...OrderFormFragment
  }
}

```