[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 easy-setup/node/middlewares/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { BenefitsMiddleware } from './BenefitsMiddleware'
import { BrandsMiddleware } from './BrandsMiddleware'
import { CategoriesMiddleware } from './CategoriesMiddleware'
import { CollectionsMiddleware } from './CollectionsMiddleware'
import { FieldsMiddleware } from './FieldsMiddleware'
import { LogisticsMiddleware } from './LogisticsMiddleware'
import { PaymentsMiddleware } from './PaymentsMiddleware'
import { PopulateMiddleware } from './PopulateMiddleware'
import { PricingMiddleware } from './PricingMiddleware'
import { ProductsMiddleware } from './ProductsMiddleware'
import { TaxesMiddleware } from './TaxesMiddleware'
import { UsersMiddleware } from './UsersMiddleware'
import { OrganizationsMiddleware } from './OrganizationsMiddleware'
import { ResellerMiddleware } from './ResellerMiddleware'
import { CheckoutMiddleware } from './CheckoutMiddleware'

export {
  PopulateMiddleware,
  UsersMiddleware,
  BrandsMiddleware,
  BenefitsMiddleware,
  CategoriesMiddleware,
  CollectionsMiddleware,
  FieldsMiddleware,
  ProductsMiddleware,
  PricingMiddleware,
  PaymentsMiddleware,
  TaxesMiddleware,
  LogisticsMiddleware,
  OrganizationsMiddleware,
  CheckoutMiddleware,
  ResellerMiddleware,
}

```


[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 easy-setup/node/utils/errors.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { AxiosError } from 'axios'

import type { CreateOrUpdateSchemaResponse } from '../clients/MasterdataClient'

export const throwIfNotModified = (error: AxiosError) => {
  // 304 means document was not updated therefore we do not treat as an error
  if (error.response?.status !== 304) throw error
}

export const returnDocumentIdOrTrhow = (error: AxiosError) => {
  throwIfNotModified(error)

  return error.response?.headers?.['x-vtex-document-id'] ?? ''
}

export const returnMessageOrThrow = (
  error: AxiosError
): CreateOrUpdateSchemaResponse => {
  throwIfNotModified(error)

  return { Message: 'Not Modified' }
}

export const returnDataIfConflictOrThrow = (data: any) => (
  error: AxiosError
) => {
  // If SKU already exists catalog API will return 409
  if (error.response?.status === 409) return data
  throw error
}

```


[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 easy-setup/node/utils/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
export async function sleep(delay_ms = 1000) {
  return new Promise<boolean>(resolve => {
    setTimeout(() => {
      resolve(true)
    }, delay_ms)
  })
}

export async function delayPromise<T = unknown>(
  promise: Promise<T>,
  delay_ms = 1000
) {
  return new Promise<T>(resolve => {
    setTimeout(() => resolve(promise), delay_ms)
  })
}

```


[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 easy-setup/node/clients/CatalogClient/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

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

import type { SpecificationField } from '../../dataSources/fieldsData'
import type { IGroupResponse } from '../../dataSources/groupData'
import { returnDataIfConflictOrThrow } from '../../utils/errors'
import type {
  AssociateSKUAttachmentData,
  AssociateSKUAttachmentResponse,
  CreateAttachmentData,
  CreateAttachmentResponse,
  CreateProductData,
  CreateProductResponse,
  CreateSKUFileData,
  CreateSKUFileResponse,
  IBrand,
  ICollectionPayload,
  ICollectionResponse,
  ISKUPayload,
  ISubCollectionPayload,
  ISubCollectionResponse,
} from './types'

export default class CatalogClient extends ExternalClient {
  constructor(context: IOContext, options?: InstanceOptions) {
    super(`http://${context.account}.vtexcommercestable.com.br`, context, {
      ...options,
      headers: {
        Accept: 'application/json',
        'Cache-Control': 'no-cache',
        'Content-Type': 'application/json',
        VtexIdclientAutcookie: context.adminUserAuthToken as string,
        'X-Vtex-Use-Https': 'true',
      },
    })
  }

  public async createBrand(BrandPayload: IBrand): Promise<IOResponse<IBrand>> {
    try {
      return await this.http.post('/api/catalog/pvt/brand', BrandPayload)
    } catch (error) {
      const {
        response: { data, status },
        headers,
      } = error

      return {
        data,
        headers,
        status,
      }
    }
  }

  public createCollection(
    collectionPayload: ICollectionPayload
  ): Promise<IOResponse<ICollectionResponse>> {
    return this.http.post('/api/catalog/pvt/collection', collectionPayload)
  }

  public createSubCollection(
    subCollectionPayload: ISubCollectionPayload
  ): Promise<IOResponse<ISubCollectionResponse>> {
    return this.http.post(
      '/api/catalog/pvt/subcollection',
      subCollectionPayload
    )
  }

  public setBrandSubCollection(
    subCollectionId: number,
    BrandSubCollectionData: any
  ): Promise<IOResponse<ISubCollectionResponse>> {
    return this.http.post(
      `/api/catalog/pvt/subcollection/${subCollectionId}/brand`,
      BrandSubCollectionData
    )
  }

  public async createCategory(categoryPayload: any): Promise<IOResponse<any>> {
    try {
      return await this.http.post(`/api/catalog/pvt/category`, categoryPayload)
    } catch (error) {
      const {
        response: { data, status },
        headers,
      } = error

      return {
        data,
        headers,
        status,
      }
    }
  }

  public createSkuSpecificationGroup = (groupData: any) =>
    this.post<IGroupResponse>(
      'api/catalog_system/pvt/specification/group',
      groupData
    )

  public createSkuSpecificationField = (
    specificationField: SpecificationField
  ) =>
    this.post('/api/catalog_system/pvt/specification/field', specificationField)

  public createSkuSpecificationFieldValue = (fieldValue: any) =>
    this.post('/api/catalog_system/pvt/specification/fieldValue', fieldValue)

  public createProduct = (
    data: CreateProductData
  ): Promise<CreateProductResponse> =>
    this.post<CreateProductResponse>('/api/catalog/pvt/product', data)

  /* public createSKU = (
      data: ISKUPayload
    ): Promise<ISKUPayload> =>
      this.post<ISKUPayload>('/api/catalog/pvt/stockkeepingunit', data)
  */

  public async createSKU(
    skuPayLoad: ISKUPayload
  ): Promise<IOResponse<ISKUPayload>> {
    try {
      return await this.http.post(
        `/api/catalog/pvt/stockkeepingunit`,
        skuPayLoad
      )
    } catch (error) {
      const {
        response: { data, status },
        headers,
      } = error

      console.log(
        `${skuPayLoad.Id}-RefId:${skuPayLoad.RefId}-ProductId:${skuPayLoad.ProductId}`
      )
      console.log(error)

      return {
        data,
        headers,
        status,
      }
    }
  }

  public createSKUFile = (skuId: string | number, data: CreateSKUFileData) =>
    this.post<CreateSKUFileResponse>(
      `/api/catalog/pvt/stockkeepingunit/${skuId}/file`,
      data
    )

  public setSkuSubscription = (data: AssociateSKUAttachmentData) =>
    this.post<AssociateSKUAttachmentResponse>(
      '/api/catalog/pvt/skuattachment',
      data
    )

  public createAttachment = (data: CreateAttachmentData) =>
    this.post<CreateAttachmentResponse>(`/api/catalog/pvt/attachment`, data)

  private post = <T = any>(url: string, data: any) =>
    this.http.post<T>(url, data).catch<T>(returnDataIfConflictOrThrow(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 easy-setup/node/clients/PricingClient/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

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

export default class PricingClient extends ExternalClient {
  constructor(context: IOContext, options?: InstanceOptions) {
    super(`http://${context.account}.myvtex.com/api/pricing`, context, {
      ...options,
      headers: {
        ...options?.headers,
        Accept: 'application/vnd.vtex.pricing.v3+json',
        'Cache-Control': 'no-cache',
        'Content-Type': 'application/json',
        'X-Vtex-Use-Https': 'true',
        VtexIdclientAutcookie: context.adminUserAuthToken ?? '',
      },
    })
  }

  public addPrice(skuId: string | number, pricePayload: any) {
    return this.http.put<any>(`/prices/${skuId}`, pricePayload)
  }

  public createPriceTable = (tradePolicyId: string) =>
    this.http.put(`/tables/${tradePolicyId}`)

  public addPriceTableRules = (data: UpdatePriceTableData) =>
    this.http.put(`/pipeline/catalog/${data.tradePolicyId}`, data)
}

export interface UpdatePriceTableData {
  tradePolicyId: string
  rules: Rule[]
}

export interface Rule {
  id: number
  tradePolicyId: string
  percentualModifier: number
  dateRangeStatus: null
  context: Context
}

export interface Context {
  categories: Record<string, never>
  brands: Record<string, never>
  markupRange: null
  dateRange: null
}

```


[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 easy-setup/node/clients/CheckoutClient/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

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

import type { IOrderFormConfiguration, IOrderConfiguration } from './types'

export default class CheckoutClient extends ExternalClient {
  constructor(context: IOContext, options?: InstanceOptions) {
    super(`http://${context.account}.vtexcommercestable.com.br`, context, {
      ...options,
      headers: {
        Accept: 'application/json',
        'Cache-Control': 'no-cache',
        'Content-Type': 'application/json',
        VtexIdclientAutcookie: context.adminUserAuthToken as string,
        'X-Vtex-Use-Https': 'true',
      },
    })
  }

  public async getOrderFormConfiguration(): Promise<
    IOResponse<IOrderFormConfiguration>
  > {
    try {
      return this.http.getRaw('/api/checkout/pvt/configuration/orderForm')
    } catch (error) {
      const {
        response: { data, status },
        headers,
      } = error

      return {
        data,
        headers,
        status,
      }
    }
  }

  public async getOrderConfiguration(): Promise<
    IOResponse<IOrderConfiguration>
  > {
    try {
      return this.http.getRaw('/api/checkout/pvt/configuration/order')
    } catch (error) {
      const {
        response: { data, status },
        headers,
      } = error

      return {
        data,
        headers,
        status,
      }
    }
  }

  public async updateOrderFormConfiguration(
    OrderFormConfigurationPayload: IOrderFormConfiguration
  ): Promise<IOResponse<IOrderFormConfiguration>> {
    try {
      return this.http.post(
        '/api/checkout/pvt/configuration/orderForm',
        OrderFormConfigurationPayload
      )
    } catch (error) {
      const {
        response: { data, status },
        headers,
      } = error

      return {
        data,
        headers,
        status,
      }
    }
  }

  public async updateOrderConfiguration(
    OrderConfigurationPayload: IOrderConfiguration
  ): Promise<IOResponse<IOrderConfiguration>> {
    try {
      return this.http.post(
        '/api/checkout/pvt/configuration/order',
        OrderConfigurationPayload
      )
    } catch (error) {
      const {
        response: { data, status },
        headers,
      } = error

      return {
        data,
        headers,
        status,
      }
    }
  }
}

```


[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 easy-setup/node/clients/MasterdataClient/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { IOResponse } from '@vtex/api'
import { MasterData } from '@vtex/api'

import {
  returnDocumentIdOrTrhow,
  returnMessageOrThrow,
} from '../../utils/errors'
import type {
  IMasterdataNewDocument,
  IMasterdataClientDocumentPayload,
} from './types'

export interface CreateOrUpdateInput {
  dataEntity: string
  fields: Record<string, unknown>
  id?: string
  schema?: string
}

export interface CreateSchemaInput {
  dataEntity: string
  schemaName: string
  schemaBody: Record<string, unknown>
}

export interface CreateOrUpdateSchemaResponse {
  Message: string
}

export default class MasterdataClient extends MasterData {
  /**
   * Add MasterData Document
   * @param clientDocumentPayload Document Payload
   */
  public async add(
    clientDocumentPayload: IMasterdataClientDocumentPayload
  ): Promise<IOResponse<IMasterdataNewDocument>> {
    try {
      return await this.http.post(`/documents`, clientDocumentPayload, {
        metric: 'masterdata-CL-add',
      })
    } catch (error) {
      const {
        response: { data, status },
        headers,
      } = error

      return {
        headers,
        status,
        data,
      }
    }
  }

  /**
   * Add or Update MasterData Document
   * @param clientDocumentPayload Document Payload
   */
  public async addOrUpdateDocument(
    clientDocumentPayload: IMasterdataClientDocumentPayload
  ): Promise<IOResponse<IMasterdataNewDocument>> {
    try {
      return await this.http.put('/documents', clientDocumentPayload, {
        metric: 'masterdata-CL-addOrUpdateDocument',
      })
    } catch (error) {
      const {
        response: { data, status },
        headers,
      } = error

      return {
        status,
        data: data || `${clientDocumentPayload.email} - duplicated entry`,
        headers,
      }
    }
  }

  public create = (data: CreateOrUpdateInput) =>
    this.createOrUpdateEntireDocument(data)
      .then(({ DocumentId }) => DocumentId)
      .catch<string>(returnDocumentIdOrTrhow)

  public createSchema = (schema: CreateSchemaInput) =>
    this.createOrUpdateSchema<CreateOrUpdateSchemaResponse>(schema).catch(
      returnMessageOrThrow
    )
}

```


[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 easy-setup/node/clients/BenefitClient/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

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

export default class BenefitClient extends ExternalClient {
  constructor(context: IOContext, options?: InstanceOptions) {
    super(
      `http://${context.account}.vtexcommercestable.com.br/api/rnb/pvt`,
      context,
      {
        ...options,
        headers: {
          Accept: 'application/json',
          'Cache-Control': 'no-cache',
          'Content-Type': 'application/json',
          VtexIdclientAutcookie: context.adminUserAuthToken as string,
          'X-Vtex-Use-Https': 'true',
        },
      }
    )
  }

  public getCollection(collectionName: string) {
    return this.http.get(`/collections/${collectionName}`)
  }

  public addBenefit = (data: unknown) =>
    this.http.post('/calculatorconfiguration/', 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 easy-setup/node/clients/GatewayClient/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

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

export default class GatewayClient extends ExternalClient {
  constructor(context: IOContext, options?: InstanceOptions) {
    super(
      `http://${context.account}.vtexcommercestable.com.br/api/payments/pvt`,
      context,
      {
        ...options,
        headers: {
          Accept: 'application/json',
          'Cache-Control': 'no-cache',
          'Content-Type': 'application/json',
          VtexIdclientAutcookie: context.adminUserAuthToken as string,
          'X-Vtex-Use-Https': 'true',
        },
      }
    )
  }

  public addPayment(paymentPayload: any) {
    return this.http.post<any>(
      `/${paymentPayload.type}/${paymentPayload.id}/config`,
      paymentPayload
    )
  }

  public addAffiliation = (data: any) => this.post('/affiliations', data)

  public addPaymentCondition = (data: any) => this.post('/rules', data)

  private post = <T = any>(url: string, data: T) =>
    this.http.post<T>(url, data).catch<T>((error: AxiosError) => {
      if (
        error.response?.status !== 400 &&
        error.response?.statusText !== 'Bad Request' &&
        error.response?.data.error.code !== 400 &&
        error.response?.data.error.message !==
          'Affiliation name is already used'
      ) {
        throw error
      }

      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 easy-setup/node/clients/CreditClient/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

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

import type {
  ICreditAccountPayload,
  OpenOrChangeAccountRequest,
  OpenOrChangeAccountResponse,
} from './types'

export default class CreditClient extends ExternalClient {
  constructor(context: IOContext, options?: InstanceOptions) {
    super(`http://${context.account}.vtexcommercestable.com.br`, context, {
      ...options,
      headers: {
        Accept: 'application/json',
        'Cache-Control': 'no-cache',
        'Content-Type': 'application/json',
        VtexIdclientAutcookie: context.adminUserAuthToken as string,
        'X-Vtex-Use-Https': 'true',
      },
    })
  }

  public async openAccount(
    CreditAccountPayload: ICreditAccountPayload
  ): Promise<IOResponse<string>> {
    try {
      return this.http.post('/api/creditcontrol/accounts', CreditAccountPayload)
    } catch (error) {
      const {
        response: { data, status },
        headers,
      } = error

      return {
        data,
        headers,
        status,
      }
    }
  }

  public openOrChangeAccount = (data: OpenOrChangeAccountRequest) =>
    this.http.put<OpenOrChangeAccountResponse>(
      `/api/creditcontrol/accounts/${data.id}`,
      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 easy-setup/node/clients/LogisticsClient/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

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

import type { ISKUPayload } from '../CatalogClient/types'
import type {
  CreateOrUpdateCarrierData,
  IDockPayload,
  IFreightValuePayload,
  IInventoryPayload,
  IWarehousePayload,
} from './types'

export default class LogisticsClient extends ExternalClient {
  constructor(context: IOContext, options?: InstanceOptions) {
    super(
      `http://${context.account}.vtexcommercestable.com.br/api/logistics/pvt`,
      context,
      {
        ...(options ?? {}),
        headers: {
          ...(options?.headers ?? {}),
          Accept: 'application/json',
          'Cache-Control': 'no-cache',
          'Content-Type': 'application/json',
          VtexIdclientAutcookie: context?.adminUserAuthToken ?? '',
          'X-Vtex-Use-Https': 'true',
        },
      }
    )
  }

  public async setFreightValues(
    carrierId: string,
    FreightValuePayload: IFreightValuePayload
  ): Promise<IOResponse<string>> {
    try {
      return this.http.post(
        `/configuration/freights/${carrierId}/values/update`,
        [FreightValuePayload]
      )
    } catch (error) {
      const {
        response: { data, status },
        headers,
      } = error

      return {
        data,
        headers,
        status,
      }
    }
  }

  public async updateDock(
    DockPayload: IDockPayload
  ): Promise<IOResponse<boolean>> {
    try {
      return this.http.post('/configuration/docks', DockPayload)
    } catch (error) {
      const {
        response: { data, status },
        headers,
      } = error

      return {
        data,
        headers,
        status,
      }
    }
  }

  public async setInventory(
    SKU: ISKUPayload,
    InventoryPayload: IInventoryPayload
  ): Promise<IOResponse<boolean>> {
    try {
      return this.http.put(
        `/inventory/skus/${SKU.Id}/warehouses/1_1`,
        InventoryPayload
      )
    } catch (error) {
      const {
        response: { data, status },
        headers,
      } = error

      return {
        data,
        headers,
        status,
      }
    }
  }

  public async updateWarehouse(
    WarehousePayload: IWarehousePayload
  ): Promise<IOResponse<boolean>> {
    try {
      return this.http.post('/configuration/warehouses', WarehousePayload)
    } catch (error) {
      const {
        response: { data, status },
        headers,
      } = error

      return {
        data,
        headers,
        status,
      }
    }
  }

  public createOrUpdateCarrier = (data: CreateOrUpdateCarrierData) =>
    this.http.post(`/configuration/carriers`, 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 easy-setup/node/clients/CatalogClient/types/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
export interface ICollectionResponse {
  Id: number
  Name: string
  Description: any
  Searchable: boolean
  Highlight: boolean
  DateFrom: string
  DateTo: string
  TotalProducts: number
  Type: string
}
export interface ICollectionPayload {
  Name: string
  Searchable: boolean
  Highlight: boolean
  DateFrom: string
  DateTo: string
}

export interface ISubCollectionResponse {
  Id: number
  CollectionId: number
  Name: string
  Type: string
  PreSale: boolean
  Release: boolean
}

export interface ISubCollectionPayload {
  CollectionId: number
  Name: string
  Type: string
  PreSale: boolean
  Release: boolean
}

export interface IBrand {
  Active: boolean
  AdWordsRemarketingCode: string
  Id: number
  Keywords: string
  LinkId: string
  LomadeeCampaignCode: string
  MenuHome: boolean
  Name: string
  Score: string | null
  SiteTitle: string
  Text: string
}

export interface ISKUPayload {
  Id: number
  ProductId: string
  IsActive: boolean
  Name: string
  RefId: string
  Height: number
  Length: number
  Width: number
  WeightKg: number
  PackagedHeight: number
  PackagedLength: number
  PackagedWidth: number
  PackagedWeightKg: number
  ModalId: number
  CubicWeight: number
  IsKit: boolean
  CreationDate: any
  RewardValue: any
  EstimatedDateArrival: any
  ManufacturerCode: string
  CommercialConditionId: number
  MeasurementUnit: string
  UnitMultiplier: number
  ModalType: any
  KitItensSellApart: boolean
}

export interface ISKUKitPayload {
  StockKeepingUnitParent: number
  StockKeepingUnitId: number
  Quantity: number
  UnitPrice: number
}

export interface CreateProductData {
  Id: number
  Name: string
  DepartmentId: number
  CategoryId: number
  BrandId: number
  LinkId: string
  RefId: string
  IsVisible: boolean
  Description: string
  DescriptionShort: string
  ReleaseDate: string
  KeyWords: string
  Title: string
  IsActive: boolean
  TaxCode: string | null
  MetaTagDescription: string
  SupplierId: number | null
  ShowWithoutStock: boolean
  AdWordsRemarketingCode: null
  LomadeeCampaignCode: null
  Score: number | null
}

export interface CreateProductResponse {
  Id: number
  Name: string
  DepartmentId: number
  CategoryId: number
  BrandId: number
  LinkId: string
  RefId: string
  IsVisible: boolean
  Description: string
  DescriptionShort: string
  ReleaseDate: string
  KeyWords: string
  Title: string
  IsActive: boolean
  TaxCode: string | null
  MetaTagDescription: string
  SupplierId: number | null
  ShowWithoutStock: boolean
  AdWordsRemarketingCode: null
  LomadeeCampaignCode: null
  Score: number | null
}

export interface AssociateSKUAttachmentData {
  AttachmentId: number
  SkuId: number
}

export interface AssociateSKUAttachmentResponse {
  Id: number
  AttachmentId: number
  SkuId: number
}

export interface CreateSKUFileData {
  IsMain: boolean
  Label: string
  Name: string
  Text: string | null
  Url: string
}

export interface CreateSKUFileResponse {
  Id: number
  SkuId: number
  Name: string
  IsMain: boolean
  Label: string
}

export interface CreateAttachmentData {
  Name: string
  IsRequired: boolean
  IsActive: boolean
  Domains: Domain[]
}

export interface Domain {
  FieldName: string
  MaxCaracters: string
  DomainValues: string
}

export interface CreateAttachmentResponse extends CreateAttachmentData {
  Id: number
}

```


[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 easy-setup/node/clients/CheckoutClient/types/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
export interface IOrderFormConfiguration {
  paymentConfiguration: IPaymentConfiguration
  taxConfiguration: ITaxConfiguration
  minimumQuantityAccumulatedForItems: number
  decimalDigitsPrecision: number
  minimumValueAccumulated: number
  apps: IApps[]
  allowMultipleDeliveries: boolean
  allowManualPrice: boolean
  maxNumberOfWhiteLabelSellers: number
  maskFirstPurchaseData: boolean
  recaptchaValidation: boolean
  maskStateOnAddress: boolean
}

export interface IPaymentConfiguration {
  requiresAuthenticationForPreAuthorizedPaymentOption: boolean
  allowInstallmentsMerge: boolean
  blockPaymentSession: boolean
  paymentSystemToCheckFirstInstallment: boolean
  defaultPaymentSystemToApplyOnUserOrderForm: boolean
}

export interface ITaxConfiguration {
  url: string
  authorizationHeader: string
  allowExecutionAfterErrors: boolean
  integratedAuthentication: boolean
  appId: string
}

export interface IApps {
  fields: string[]
  id: string
  major: number
}

export interface IOrderConfiguration {
  erpEndpoint: string
  workflowName: string
  shortageTimeoutCancellation: number
  allowOrderEdition: 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 easy-setup/node/clients/MasterdataClient/types/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
export interface IMasterdataDocument {
  id: string
  accountId: string
  accountName: string
  dataEntityId: string
}

export interface IMasterdataNewDocument {
  Id: string
  Href: string
}

export interface IMasterdataClientDocumentPayload {
  id: string
  email: string
  document: string
  firstName: string
  lastName: string
  priceTables: string
  isOrgAdmin?: boolean
  organizationId?: string
}

export interface IMasterdataClientDocument {
  userId: string
  email: string
  document: string
  firstName: string
  lastName: string
  priceTables: 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 easy-setup/node/clients/CreditClient/types/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
export interface ICreditAccountPayload {
  id: string
  balance: number
  document: string
  status: string
  documentType: string
  creditLimit: number
  updatedAt: string
  createdAt: string
  description: string
  availableCredit: number
  preAuthorizedCredit: number
  email: string
  tolerance: number
  availableBalance: number
}

export interface OpenOrChangeAccountRequest {
  email: string
  creditLimit?: number
  document?: string
  id: string
}

export interface OpenOrChangeAccountResponse {
  id: string
  balance: number
  document: string
  status: string
  documentType: string
  creditLimit: number
  updatedAt: string
  createdAt: string
  description: string
  availableCredit: number
  preAuthorizedCredit: number
  email: string
  tolerance: number
  availableBalance: number
}

```


[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 easy-setup/node/clients/LogisticsClient/types/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
export interface IInventoryPayload {
  unlimitedQuantity: boolean
  dateUtcOnBalanceSystem: any
  quantity: number
}

export interface IFreightValuePayload {
  absoluteMoneyCost: string
  country: string
  maxVolume: number
  operationType: number
  pricePercent: number
  pricePercentByWeight: number
  timeCost: string
  weightEnd: number
  weightStart: number
  zipCodeEnd: string
  zipCodeStart: string
  polygon: string
}

export interface IDockPayload {
  pickupStoreInfo: IPickupStoreInfo
  storeId: any
  pickupInStoreInfo: IPickupInStoreInfo
  deliveryFromStoreInfo: IDeliveryFromStoreInfo
  address: IAddress
  location: any
  id: string
  name: string
  priority: number
  dockTimeFake: string
  timeFakeOverhead: string
  salesChannels: [string]
  freightTableIds: [string]
  wmsEndPoint: any
  isActive: boolean
}

interface IPickupStoreInfo {
  isPickupStore: boolean
  storeId: any
  friendlyName: any
  address: IAddress
  additionalInfo: any
  dockId: any
  distance: any
  businessHours: any
  pickupHolidays: any
  sellerId: any
  isThirdPartyPickup: boolean
}

interface IPickupInStoreInfo {
  isActice: boolean
  additionalInfo: any
}

interface IDeliveryFromStoreInfo {
  isActice: boolean
  deliveryRadius: number
  deliveryFee: number
  deliveryTime: string
  maximumWeight: number
}

interface IAddress {
  postalCode: string
  country: ICountry
  city: string
  state: string
  neighborhood: string
  street: string
  number: string
  complement: any
  reference: any
  location: any
}

interface ICountry {
  acronym: string
  name: string
}

export interface IWarehousePayload {
  id: string
  name: string
  warehouseDocks: any
  pickupPointIds: []
  priority: number
  isActive: boolean
}

export interface CreateOrUpdateCarrierData {
  id: string
  slaType: string
  name: string
  scheduledDelivery: boolean
  maxRangeDelivery: number
  dayOfWeekForDelivery: null
  dayOfWeekBlockeds: any[]
  freightValue: any[]
  factorCubicWeight: null
  freightTableProcessStatus: number
  freightTableValueError: null
  modals: any[]
  onlyItemsWithDefinedModal: boolean
  deliveryOnWeekends: boolean
  carrierSchedule: any[]
  maxDimension: MaxDimension
  exclusiveToDeliveryPoints: boolean
  minimunCubicWeight: number
  isPolygon: boolean
  numberOfItemsPerShipment: null
}

export interface MaxDimension {
  weight: number
  height: number
  width: number
  length: number
  maxSumDimension: number
}

```


[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 easy-setup/node/middlewares/CollectionsMiddleware/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { ISubCollectionResponse } from '../../clients/CatalogClient/types'
import {
  BrandSubCollectionData,
  CollectionData,
  SubCollectionData,
} from './data/collectionData'

export async function CollectionsMiddleware(
  ctx: PopulateContext,
  next: () => Promise<any>
) {
  const {
    clients: { catalogClient },
    state: { resources },
    response: { body },
  } = ctx

  try {
    if (!resources.includes('empty') && !resources.includes('collections')) {
      throw new Error('resource not set')
    }

    const collectionItems: any = await Promise.all(
      CollectionData.map((collectionData: any) =>
        catalogClient.createCollection(collectionData)
      )
    )

    const subCollectionItems: any = await Promise.all(
      collectionItems.map((collectionItem: ISubCollectionResponse) =>
        catalogClient.createSubCollection(SubCollectionData(collectionItem.Id))
      )
    )

    const brandSubCollectionItems: any = await Promise.all(
      subCollectionItems.map((subCollectionItem: any) =>
        catalogClient.setBrandSubCollection(
          subCollectionItem.Id,
          BrandSubCollectionData
        )
      )
    )

    ctx.response.body = {
      ...body,
      Collections: {
        results: {
          brandSubCollections: brandSubCollectionItems,
          collections: collectionItems,
          subCollections: subCollectionItems,
        },
        status: 'OK',
      },
    }
  } catch (error) {
    ctx.response.body = {
      ...body,
      Collections: {
        error: error.message,
        status: 'ERROR',
      },
    }
  }

  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 easy-setup/node/middlewares/CheckoutMiddleware/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { CustomData } from './data/customData'

export async function CheckoutMiddleware(
  ctx: PopulateContext,
  next: () => Promise<any>
) {
  const {
    clients: { checkoutClient },
    state: { resources },
    response: { body },
  } = ctx

  try {
    if (!resources.includes('empty') && !resources.includes('checkout')) {
      throw new Error('resource not set')
    }

    const orderFormConfigPayload = await checkoutClient.getOrderFormConfiguration()

    orderFormConfigPayload.data.minimumValueAccumulated = 5000
    orderFormConfigPayload.data.apps = CustomData
    const orderFormConfigResponse = await checkoutClient.updateOrderFormConfiguration(
      orderFormConfigPayload.data
    )

    const orderConfigPayload = await checkoutClient.getOrderConfiguration()

    orderConfigPayload.data.allowOrderEdition = true
    const orderConfigResponse = await checkoutClient.updateOrderConfiguration(
      orderConfigPayload.data
    )

    ctx.response.body = {
      ...body,
      Checkout: {
        result: {
          orderFormConfigResponse,
          orderConfigResponse,
        },
        status: 'OK',
      },
    }
  } catch (error) {
    // console.log('CHECKOUT', error)
    ctx.response.body = {
      ...body,
      Checkout: {
        error: error.message,
        status: 'ERROR',
      },
    }
  }

  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 easy-setup/node/middlewares/UsersMiddleware/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { Users } from './data/users'
import { CreditData } from './data/credit'

export async function UsersMiddleware(
  ctx: PopulateContext,
  next: () => Promise<any>
) {
  const {
    clients: { masterdataClient, creditClient },
    state: { resources },
    response: { body },
  } = ctx

  try {
    if (!resources.includes('empty') && !resources.includes('users')) {
      throw new Error('resource not set')
    }

    const users = await Promise.all(
      Users.map(fields => masterdataClient.create({ dataEntity: 'CL', fields }))
    )

    const credit = await Promise.all(
      CreditData.map(creditData => creditClient.openOrChangeAccount(creditData))
    )

    ctx.response.body = {
      ...body,
      Users: {
        users,
        credit,
        status: 'OK',
      },
    }
  } catch (error) {
    ctx.response.body = {
      ...body,
      User: {
        error: error.message,
        status: 'ERROR',
      },
    }
  }

  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 easy-setup/node/middlewares/ProductsMiddleware/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import {
  AttachmentData,
  SubscriptionData,
} from '../../dataSources/attachmentData'
import { ImagesData } from '../../dataSources/imageData'
import { ProductData } from '../../dataSources/productData'
import { SKUData } from '../../dataSources/skuData'
import { sleep } from '../../utils/index'

export async function ProductsMiddleware(
  ctx: PopulateContext,
  next: () => Promise<any>
) {
  const {
    clients: { catalogClient },
    state: { resources },
    response: { body },
  } = ctx

  try {
    if (!resources.includes('empty') && !resources.includes('products')) {
      throw new Error('resource not set')
    }

    const subscriptionSkus = [
      880260,
      880270,
      880280,
      880290,
      880300,
      880310,
      880320,
      // 880390,
    ]

    const products = await Promise.all(
      ProductData.map(product => catalogClient.createProduct(product))
    )

    for await (const sku of SKUData) {
      await catalogClient.createSKU(sku)
      await sleep(100)
    }

    const attachments = await Promise.all(
      [AttachmentData, SubscriptionData].map(attachment =>
        catalogClient.createAttachment(attachment)
      )
    )

    const productSkusAttachments = await Promise.all(
      subscriptionSkus.map(SkuId =>
        catalogClient.setSkuSubscription({
          SkuId,
          AttachmentId: SubscriptionData.Id,
        })
      )
    )

    const productSkuImages = await Promise.all(
      SKUData.map(({ ProductId: SKUProductId, Id: SkuId }) =>
        ImagesData.filter(
          ({ ProductId }) => String(ProductId) === SKUProductId
        ).map(({ ImageData }) => catalogClient.createSKUFile(SkuId, ImageData))
      )
    )

    // await this.setSpecifications(product.CategoryId)

    ctx.response.body = {
      ...body,
      Products: {
        results: {
          products,
          // productSkus,
          attachments,
          productSkusAttachments,
          productSkuImages,
        },
        status: 'OK',
      },
    }
  } catch (error) {
    ctx.response.body = {
      ...body,
      Products: {
        error: error.message,
        status: 'ERROR',
      },
    }
  }

  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 easy-setup/node/middlewares/CategoriesMiddleware/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { CategoriesData } from './data'

export async function CategoriesMiddleware(
  ctx: PopulateContext,
  next: () => Promise<any>
) {
  const {
    clients: { catalogClient },
    state: { resources },
    response: { body },
  } = ctx

  try {
    if (!resources.includes('empty') && !resources.includes('categories')) {
      throw new Error('resource not set')
    }

    let delay = 0
    const delayIncrement = 500
    const results = await Promise.all(
      CategoriesData.map((categoryData: any) => {
        delay += delayIncrement
        // console.log('timeout...')

        return new Promise(resolve => setTimeout(resolve, delay)).then(() =>
          catalogClient.createCategory(categoryData)
        )
      })
    )

    ctx.response.body = {
      ...body,
      Categories: {
        results,
        status: 'OK',
      },
    }
  } catch (error) {
    ctx.response.body = {
      ...body,
      Categories: {
        error: error.message,
        status: 'ERROR',
      },
    }
  }

  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 easy-setup/node/middlewares/LogisticsMiddleware/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { SKUData } from '../SkuMiddleware/data/skuData'
import {
  CarrierData,
  DockData,
  FreightValueData,
  InventoryData,
  WarehouseData,
} from './data/logisticsData'

export async function LogisticsMiddleware(
  ctx: PopulateContext,
  next: () => Promise<any>
) {
  const {
    clients: { logisticsClient },
    state: { resources },
    response: { body },
  } = ctx

  try {
    if (!resources.includes('empty') && !resources.includes('logistics')) {
      throw new Error('resource not set')
    }

    const carrier = await logisticsClient.createOrUpdateCarrier(CarrierData)

    const loadingDocks = await Promise.all(
      DockData.map(dockData => logisticsClient.updateDock(dockData))
    )

    const warehouse = await logisticsClient.updateWarehouse(WarehouseData)

    const inventory = await Promise.all(
      SKUData.map(skuData =>
        logisticsClient.setInventory(skuData, InventoryData)
      )
    )

    const freightValues = await Promise.all(
      FreightValueData.map(freightValueData => {
        return logisticsClient.setFreightValues(
          CarrierData.id,
          freightValueData
        )
      })
    )

    ctx.response.body = {
      ...body,
      Logistics: {
        result: {
          loadingDocks,
          warehouse,
          carrier,
          inventory,
          freightValues,
        },
        status: 'OK',
      },
    }
  } catch (error) {
    ctx.response.body = {
      ...body,
      Logistics: {
        error: error.message,
        status: 'ERROR',
      },
    }
  }

  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 easy-setup/node/middlewares/ResellerMiddleware/reseller.schema.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
export default {
  title: 'Revenda',
  type: 'object',
  properties: {
    email: {
      type: 'string',
      format: 'email',
      title: 'Email',
    },
    stateRegistration: {
      type: 'string',
      maxLength: 750,
      title: 'State Registration',
    },
    homePhone: {
      type: 'string',
      title: 'Mobile',
    },
    corporateDocument: {
      type: 'string',
      maxLength: 14,
      title: 'EIN #: ',
    },
    phone: {
      type: 'string',
      title: 'Phone',
    },
    lastName: {
      type: 'string',
      maxLength: 750,
      title: 'Last Name',
    },
    tradeName: {
      type: 'string',
      maxLength: 750,
      title: 'Trade Name',
    },
    corporateName: {
      type: 'string',
      maxLength: 750,
      title: 'Company Name',
    },
    firstName: {
      type: 'string',
      maxLength: 750,
      title: 'First Name',
    },
    streetType: {
      type: 'string',
      title: 'Stree Type',
      enum: ['Street', 'Avenue', 'Boulevard', 'Road', 'Junction'],
    },
    city: {
      type: 'string',
      maxLength: 750,
      title: 'City',
    },
    reference: {
      type: 'string',
      maxLength: 750,
      title: 'Reference',
    },
    street: {
      type: 'string',
      title: 'Street',
    },
    state: {
      type: 'string',
      title: 'State',
      enum: [
        'Alabama',
        'Alaska',
        'American Samoa',
        'Arizona',
        'Arkansas',
        'California',
        'Colorado',
        'Connecticut',
        'Delaware',
        'District Of Columbia',
        'Federated States Of Micronesia',
        'Florida',
        'Georgia',
        'Guam',
        'Hawaii',
        'Idaho',
        'Illinois',
        'Indiana',
        'Iowa',
        'Kansas',
        'Kentucky',
        'Louisiana',
        'Maine',
        'Marshall Islands',
        'Maryland',
        'Massachusetts',
        'Michigan',
        'Minnesota',
        'Mississippi',
        'Missouri',
        'Montana',
        'Nebraska',
        'Nevada',
        'New Hampshire',
        'New Jersey',
        'New Mexico',
        'New York',
        'North Carolina',
        'North Dakota',
        'Northern Mariana Islands',
        'Ohio',
        'Oklahoma',
        'Oregon',
        'Palau',
        'Pennsylvania',
        'Puerto Rico',
        'Rhode Island',
        'South Carolina',
        'South Dakota',
        'Tennessee',
        'Texas',
        'Utah',
        'Vermont',
        'Virgin Islands',
        'Virginia',
        'Washington',
        'West Virginia',
        'Wisconsin',
        'Wyoming',
      ],
    },
    complement: {
      type: 'string',
      maxLength: 750,
      title: 'Complement',
    },
    neighborhood: {
      type: 'string',
      maxLength: 750,
      title: 'Neighborhood',
    },
    number: {
      type: 'string',
      maxLength: 750,
      title: 'Number',
    },
    postalCode: {
      type: 'string',
      maxLength: 9,
      title: 'Zip Code',
    },
    upload: {
      type: 'string',
      maxLength: 99999,
      title: 'Operating Agreement',
    },
  },
  required: [
    'email',
    'stateRegistration',
    'corporateDocument',
    'tradeName',
    'corporateName',
    'firstName',
    'lastName',
    'city',
    'street',
    'state',
    'postalCode',
  ],
  'v-security': {
    allowGetAll: true,
    publicWrite: [
      'email',
      'firstName',
      'lastName',
      'homePhone',
      'corporateName',
      'corporateDocument',
      'stateRegistration',
      'tradeName',
      'city',
      'street',
      'state',
      'neighborhood',
      'number',
      'postalCode',
    ],
    publicRead: [
      'email',
      'stateRegistration',
      'homePhone',
      'corporateDocument',
      'phone',
      'lastName',
      'tradeName',
      'corporateName',
      'firstName',
      'city',
      'street',
      'state',
      'streetType',
      'neighborhood',
      'number',
      'postalCode',
      'upload',
      'complement',
      'reference',
    ],
    publicJsonSchema: true,
  },
  'v-triggers': [
    {
      name: 'insert-customer-table',
      active: true,
      condition: '',
      action: {
        type: 'save',
        dataEntity: 'CL',
        json: {
          id: '{!id}',
          approved: 'false',
          firstName: '{!firstName}',
          lastName: '{!lastName}',
          email: '{!email}',
          homePhone: '{!homePhone}',
          isCorporate: 'true',
          corporateName: '{!corporateName}',
          tradeName: '{!tradeName}',
          stateRegistration: '{!stateRegistration}',
          corporateDocument: '{!corporateDocument}',
          isOrgAdmin: 'true',
        },
      },
    },
    {
      name: 'insert-address-table',
      active: true,
      condition: '',
      action: {
        type: 'save',
        dataEntity: 'AD',
        json: {
          userId: '{!id}',
          city: '{!city}',
          reference: '{!reference}',
          street: '{!street}',
          state: '{!state}',
          streetType: '{!streetType}',
          neighborhood: '{!neighborhood}',
          addressName: 'Principal',
          number: '{!number}',
          country: 'USA',
          postalCode: '{!postalCode}',
          complement: '{!complement}',
          upload: '{!upload}',
        },
      },
    },
  ],
}

```


[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 easy-setup/node/middlewares/ResellerMiddleware/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import schemaBody from './reseller.schema'

export interface CreateSchemaInput {
  dataEntity: string
  schemaName: string
  schemaBody: Record<string, unknown>
}

export interface CreateOrUpdateSchemaResponse {
  Message: string
}

export async function ResellerMiddleware(
  ctx: PopulateContext,
  next: () => Promise<any>
) {
  const {
    clients: { masterdata },
    state: { resources },
    response: { body },
  } = ctx

  try {
    if (!resources.includes('empty') && !resources.includes('reseller')) {
      throw new Error('resource not set')
    }

    const result = await masterdata
      .createOrUpdateSchema<CreateOrUpdateSchemaResponse>({
        dataEntity: 'Reseller',
        schemaName: 'v2',
        schemaBody,
      })
      .catch(error => {
        // 304 means schema was not updated therefore we do not treat as an error
        if (error.response.status !== 304) throw error

        return { Message: 'Not Modified' }
      })

    ctx.response.body = {
      ...body,
      Reseller: {
        result,
        status: 'OK',
      },
    }
  } catch (error) {
    ctx.response.body = {
      ...body,
      Reseller: {
        error: error.message,
        status: 'ERROR',
      },
    }
  }

  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 easy-setup/node/middlewares/FieldsMiddleware/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { SpecificationField } from '../../dataSources/fieldsData'
import { FieldsData } from '../../dataSources/fieldsData'
import { FieldValuesData } from '../../dataSources/fieldValuesData'
import { GroupData } from '../../dataSources/groupData'

export async function FieldsMiddleware(
  ctx: PopulateContext,
  next: () => Promise<any>
) {
  const {
    clients: { catalogClient },
    state: { resources },
    response: { body },
  } = ctx

  try {
    if (!resources.includes('empty') && !resources.includes('fields')) {
      throw new Error('resource not set')
    }

    const groupResponse = await catalogClient.createSkuSpecificationGroup(
      GroupData
    )

    if (groupResponse) {
      const fields = await Promise.all(
        FieldsData(groupResponse.Id).map(
          async (specificationField: SpecificationField) => {
            return {
              fieldId: await catalogClient.createSkuSpecificationField(
                specificationField
              ),
              ...specificationField,
            }
          }
        )
      )

      const fieldValues = await Promise.all(
        fields.map(fieldResponse => {
          const fieldValuesData = FieldValuesData(
            fieldResponse.fieldId as number
          ).filter(
            fieldValue => fieldValue.CategoryId === fieldResponse.CategoryId
          )

          if (fieldValuesData.length > 0) {
            return Promise.all(
              fieldValuesData[0].FieldValues.map(FieldValueData =>
                catalogClient.createSkuSpecificationFieldValue(FieldValueData)
              )
            )
          }

          return {}
        })
      )

      ctx.response.body = {
        ...body,
        Fields: {
          results: {
            fields,
            fieldValues,
          },
          status: 'OK',
        },
      }
    }
  } catch (error) {
    ctx.response.body = {
      ...body,
      Fields: {
        error: error.message,
        status: 'ERROR',
      },
    }
  }

  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 easy-setup/node/middlewares/BrandsMiddleware/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { IBrand } from '../../clients/CatalogClient/types'
import { BrandData } from './data/brandData'

export async function BrandsMiddleware(
  ctx: PopulateContext,
  next: () => Promise<any>
) {
  const {
    clients: { catalogClient },
    state: { resources },
    response: { body },
  } = ctx

  try {
    if (!resources.includes('empty') && !resources.includes('brands')) {
      throw new Error('resource not set')
    }

    const results = await Promise.all(
      BrandData.map((brandData: IBrand) => catalogClient.createBrand(brandData))
    )

    ctx.response.body = {
      ...body,
      Brands: {
        results,
        status: 'OK',
      },
    }
  } catch (error) {
    ctx.response.body = {
      ...body,
      Brands: {
        error: error.message,
        status: 'ERROR',
      },
    }
  }

  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 easy-setup/node/middlewares/OrganizationsMiddleware/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { CreateSchemaInput } from '../../clients/MasterdataClient'
import { john, steven } from '../UsersMiddleware/data/users'

export async function OrganizationsMiddleware(
  ctx: PopulateContext,
  next: () => Promise<any>
) {
  const {
    vtex: { account },
    clients: { masterdataClient: md },
    state: { resources },
    response: { body },
  } = ctx

  try {
    if (!resources.includes('empty') && !resources.includes('organizations')) {
      throw new Error('resource not set')
    }

    const permissionSchema: CreateSchemaInput = {
      dataEntity: 'BusinessPermission',
      schemaName: 'business-permission-schema-v1',
      schemaBody: {
        properties: {
          name: {
            type: 'string',
          },
          label: {
            type: 'string',
          },
        },
        'v-default-fields': ['name', 'label', 'id'],
        required: ['name'],
        'v-indexed': ['name'],
        'v-security': {
          allowGetAll: true,
          publicRead: ['name', 'label', 'id'],
          publicWrite: ['name', 'label'],
          publicFilter: ['name', 'id'],
        },
      },
    }

    const roleSchema: CreateSchemaInput = {
      dataEntity: 'BusinessRole',
      schemaName: 'business-role-schema-v1',
      schemaBody: {
        properties: {
          name: {
            type: 'string',
          },
          label: {
            type: 'string',
          },
          permissions: {
            type: 'string',
          },
        },
        'v-default-fields': ['name', 'label', 'id', 'permissions'],
        required: ['name'],
        'v-indexed': ['name'],
        'v-security': {
          allowGetAll: true,
          publicRead: ['name', 'label', 'permissions', 'id'],
          publicWrite: ['name', 'label', 'permissions'],
          publicFilter: ['name', 'id'],
        },
      },
    }

    const organizationSchema: CreateSchemaInput = {
      dataEntity: 'BusinessOrganization',
      schemaName: 'business-organization-schema-v1',
      schemaBody: {
        properties: {
          name: {
            type: 'string',
          },
          telephone: {
            type: 'string',
          },
          address: {
            type: 'string',
          },
          email: {
            type: 'string',
          },
        },
        'v-default-fields': ['name', 'telephone', 'id', 'address', 'email'],
        required: ['name', 'telephone'],
        'v-indexed': ['name', 'telephone', 'email'],
        'v-security': {
          allowGetAll: true,
          publicRead: ['name', 'telephone', 'id', 'address', 'email'],
          publicWrite: ['name', 'telephone', 'address', 'email'],
          publicFilter: ['name', 'telephone', 'id', 'email'],
        },
      },
    }

    const userOrganizationSchema: CreateSchemaInput = {
      dataEntity: 'UserOrganization',
      schemaName: 'user-organization-schema-v1',
      schemaBody: {
        properties: {
          email: {
            type: 'string',
          },
          businessOrganizationId: {
            type: 'string',
            link: `http://api.vtex.com/${account}/dataentities/BusinessOrganization/schemas/business-organization-schema-v1`,
          },
          roleId: {
            type: 'string',
            link: `http://api.vtex.com/${account}/dataentities/BusinessRole/schemas/business-role-schema-v1`,
          },
          status: {
            type: 'string',
          },
        },
        'v-default-fields': [
          'email',
          'id',
          'businessOrganizationId',
          'roleId',
          'status',
        ],
        required: ['email', 'businessOrganizationId', 'roleId', 'status'],
        'v-indexed': ['email', 'businessOrganizationId', 'roleId', 'status'],
        'v-security': {
          allowGetAll: true,
          publicRead: [
            'email',
            'id',
            'businessOrganizationId',
            'businessOrganizationId_linked',
            'roleId',
            'roleId_linked',
            'status',
          ],
          publicWrite: [
            'id',
            'email',
            'businessOrganizationId',
            'roleId',
            'status',
          ],
          publicFilter: [
            'email',
            'id',
            'businessOrganizationId',
            'roleId',
            'status',
          ],
        },
        'v-triggers': [
          {
            name: 'organization-assignment-accept-email',
            active: true,
            condition: 'status=APPROVED',
            action: {
              type: 'email',
              provider: 'default',
              subject: 'Organization Assignment Acceptance',
              to: ['{!email}'],
              replyTo: 'noreply@company.com',
              body:
                'You have been assigned to {!businessOrganizationId_linked.name}.',
            },
          },
          {
            name: 'organization-assignment-decline-email',
            active: true,
            condition: 'status=DECLINED',
            action: {
              type: 'email',
              provider: 'default',
              subject: 'Organization Assignment Decline',
              to: ['{!email}'],
              replyTo: 'noreply@company.com',
              body:
                'You have left the organization {!businessOrganizationId_linked.name}.',
            },
          },
        ],
      },
    }

    const schemas = [
      permissionSchema,
      roleSchema,
      organizationSchema,
      userOrganizationSchema,
    ]

    const results = await Promise.all(schemas.map(md.createSchema))

    const viewPricesPermissionId = await md.create({
      dataEntity: permissionSchema.dataEntity,
      schema: permissionSchema.schemaName,
      fields: {
        id: 'f43a0146-6299-43b4-af46-310ee19b0284',
        name: 'view_prices',
        label: 'View Prices',
      },
    })

    const roleId = await md.create({
      dataEntity: roleSchema.dataEntity,
      schema: roleSchema.schemaName,
      fields: {
        id: 'c7a03457-ae36-46d2-bc7e-9c24ae37fe9e',
        name: 'sales_manager',
        label: 'Sales Manager',
        permissions: JSON.stringify([viewPricesPermissionId]),
      },
    })

    const businessOrganizationId = await md.create({
      dataEntity: organizationSchema.dataEntity,
      schema: organizationSchema.schemaName,
      fields: {
        id: 'bf6297a1-99be-4459-8e5e-c1f28b270684',
        name: 'abCorp',
        telephone: '11999876543',
        address: 'Av. Faria Lima 1440',
        email: 'abcorp@example.com',
      },
    })

    await md.create({
      dataEntity: userOrganizationSchema.dataEntity,
      schema: userOrganizationSchema.schemaName,
      fields: {
        id: '3d6a3c0c-8a62-4623-8f71-9f144814a7eb',
        email: john.email,
        businessOrganizationId,
        roleId,
        status: 'APPROVED',
      },
    })

    await md.create({
      dataEntity: userOrganizationSchema.dataEntity,
      schema: userOrganizationSchema.schemaName,
      fields: {
        id: '404a97d2-7f91-42c7-9d8b-51be848acaeb',
        email: steven.email,
        businessOrganizationId,
        roleId,
        status: 'APPROVED',
      },
    })

    ctx.response.body = {
      ...body,
      Organizations: {
        results,
        status: 'OK',
      },
    }
  } catch (error) {
    ctx.response.body = {
      ...body,
      Organizations: {
        error: error.message,
        status: 'ERROR',
      },
    }
  }

  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 easy-setup/node/middlewares/OrganizationsMiddleware/userOrganization.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { AxiosError } from 'axios'

export interface CreateUserOrganizationFields {
  id: string
  email: string
  businessOrganizationId: string
  roleId: string
  status: string
}

export async function createUserOrganization(
  ctx: PopulateContext,
  fields: CreateUserOrganizationFields
): Promise<string> {
  const {
    clients: { masterdata },
  } = ctx

  const dataEntity = 'UserOrganization'
  const schema = 'user-organization-schema-v1'

  return masterdata
    .createOrUpdateEntireDocument({
      dataEntity,
      schema,
      fields,
    })
    .then<string>(({ DocumentId }) => DocumentId)
    .catch<string>(error => {
      // 304 means schema was not updated therefore we do not treat as an error
      if (error.response.status !== 304 || !error.isAxiosError) throw error
      const axiosError = error as AxiosError

      return axiosError.response?.headers?.['x-vtex-document-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 easy-setup/node/middlewares/PricingMiddleware/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import {
  FixedPrice,
  PriceData,
  PriceTableData,
} from '../../dataSources/priceData'
import { sleep } from '../../utils'
import { SKUData } from '../SkuMiddleware/data/skuData'

export async function PricingMiddleware(
  ctx: PopulateContext,
  next: () => Promise<void>
) {
  const {
    clients: { pricingClient },
    state: { resources },
    response: { body },
  } = ctx

  try {
    if (!resources.includes('empty') && !resources.includes('prices')) {
      throw new Error('resource not set')
    }

    const RATE_LIMIT_MS = 1000 / 40

    for await (const priceTable of PriceTableData) {
      await pricingClient.createPriceTable(priceTable.tradePolicyId)

      await sleep(RATE_LIMIT_MS)

      await pricingClient.addPriceTableRules(priceTable)

      await sleep(RATE_LIMIT_MS)
    }

    for await (const sku of SKUData) {
      if (sku.Id === 880100) {
        await pricingClient.addPrice(sku.Id, FixedPrice)
      } else if (sku.Id === 880320 || sku.Id === 880321) {
        await pricingClient.addPrice(sku.Id, FixedPrice)
      } else {
        await pricingClient.addPrice(sku.Id, PriceData)
      }

      await sleep(RATE_LIMIT_MS)
    }

    ctx.response.body = {
      ...body,
      Prices: {
        status: 'OK',
      },
    }
  } catch (error) {
    ctx.response.body = {
      ...body,
      Prices: {
        error: error.message,
        status: 'ERROR',
      },
    }
  }

  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 easy-setup/node/middlewares/PaymentsMiddleware/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import {
  AffiliationData,
  PaymentConditionData,
  PromissoryData,
} from '../../dataSources/paymentData'

export async function PaymentsMiddleware(
  ctx: PopulateContext,
  next: () => Promise<any>
) {
  const {
    clients: { gatewayClient },
    state: { resources },
    response: { body },
  } = ctx

  try {
    if (!resources.includes('empty') && !resources.includes('payments')) {
      throw new Error('resource not set')
    }

    const payment = await gatewayClient.addPayment(PromissoryData)

    const affiliations = await Promise.all(
      AffiliationData.map((affiliation: any) => {
        return gatewayClient.addAffiliation(affiliation)
      })
    )

    const paymentCondition = await Promise.all(
      affiliations.map((affiliation: any, index: number) => {
        const payload = PaymentConditionData(affiliation.id)[index]

        return gatewayClient.addPaymentCondition(payload)
      })
    )

    ctx.response.body = {
      ...body,
      Payments: {
        result: {
          payment,
          affiliations,
          paymentCondition,
        },
        status: 'OK',
      },
    }
  } catch (error) {
    ctx.response.body = {
      ...body,
      Payments: {
        error: error.message,
        status: 'ERROR',
      },
    }
  }

  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 easy-setup/node/middlewares/BenefitsMiddleware/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { BenefitData } from '../../dataSources/benefitsData'

export async function BenefitsMiddleware(
  ctx: PopulateContext,
  next: () => Promise<unknown>
) {
  const {
    clients: { benefitClient },
    state: { resources },
    response: { body },
  } = ctx

  try {
    if (!resources.includes('empty') && !resources.includes('benefits')) {
      throw new Error('resource not set')
    }

    const collections = await benefitClient.getCollection('_')
    const benefitPayload = BenefitData(collections[0])

    const benefits = await benefitClient.addBenefit(benefitPayload)

    ctx.response.body = {
      ...body,
      Benefits: {
        result: {
          benefits,
        },
        status: 'OK',
      },
    }
  } catch (error) {
    ctx.response.body = {
      ...body,
      Benefits: {
        error: error.message,
        status: 'ERROR',
      },
    }
  }

  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 easy-setup/node/middlewares/TaxesMiddleware/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { TaxData } from '../../dataSources/benefitsData'

export async function TaxesMiddleware(
  ctx: PopulateContext,
  next: () => Promise<any>
) {
  const {
    clients: { benefitClient },
    state: { resources },
    response: { body },
  } = ctx

  try {
    if (!resources.includes('empty') && !resources.includes('taxes')) {
      throw new Error('resource not set')
    }

    const taxes = await Promise.all(
      TaxData.map(taxItem => {
        return benefitClient.addBenefit(taxItem)
      })
    )

    ctx.response.body = {
      ...body,
      Taxes: {
        result: {
          taxes,
        },
        status: 'OK',
      },
    }
  } catch (error) {
    ctx.response.body = {
      ...body,
      Taxes: {
        error: error.message,
        status: 'ERROR',
      },
    }
  }

  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 easy-setup/node/middlewares/PopulateMiddleware/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import { json } from 'co-body'

export async function PopulateMiddleware(
  ctx: PopulateContext,
  next: () => Promise<any>
) {
  ctx.set('Cache-Control', 'no-cache')
  // ctx.state.appKey = ctx.req.headers['x-vtex-api-appkey']
  // ctx.state.appToken = ctx.req.headers['x-vtex-api-apptoken']

  try {
    const { resources } = await json(ctx)

    // console.log({ resources })

    ctx.state.resources = resources || ['empty']

    // If there's empty setup, remove all others
    if (
      ctx.state.resources.includes('empty') &&
      ctx.state.resources.length > 1
    ) {
      ctx.state.resources = ['empty']
    }
  } catch (error) {
    ctx.response.body = { error }
  }

  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 easy-setup/node/middlewares/CollectionsMiddleware/data/collectionData.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type {
  ICollectionPayload,
  ISubCollectionPayload,
} from '../../../clients/CatalogClient/types'

const BrandSubCollectionData = {
  BrandId: 9280,
}

const CollectionData: ICollectionPayload[] = [
  {
    DateFrom: '2010-01-01T00:00:00',
    DateTo: '2070-01-01T00:00:00',
    Highlight: false,
    Name: 'All',
    Searchable: true,
  },
]

const SubCollectionData = (collectionId: number): ISubCollectionPayload => ({
  CollectionId: collectionId,
  Name: 'Brand',
  PreSale: false,
  Release: false,
  Type: 'Inclusive',
})

export { BrandSubCollectionData, CollectionData, SubCollectionData }

```


[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 easy-setup/node/middlewares/CheckoutMiddleware/data/customData.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { IApps } from '../../../clients/CheckoutClient/types'

export const CustomData: IApps[] = [
  {
    fields: ['poNumber'],
    id: 'profile',
    major: 1,
  },
  {
    fields: ['test', 'abc'],
    id: 'custom-prices',
    major: 1,
  },
]

```


[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 easy-setup/node/middlewares/UsersMiddleware/data/credit.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type { ICreditAccountPayload } from '../../../clients/CreditClient/types'
import { chris, john, steven } from './users'

export const CreditData: ICreditAccountPayload[] = [
  {
    id: '00000000191_CPF',
    balance: 0.0,
    document: '00000000191',
    status: 'Open',
    documentType: 'CPF',
    creditLimit: 50000000.0,
    updatedAt: new Date().toISOString(),
    createdAt: new Date().toISOString(),
    description: '',
    availableCredit: 0.0,
    preAuthorizedCredit: 0.0,
    email: john.email,
    tolerance: 1.0,
    availableBalance: 0.0,
  },
  {
    id: '90750680008_CPF',
    balance: 0.0,
    document: '90750680008',
    status: 'Open',
    documentType: 'CPF',
    creditLimit: 50000000.0,
    updatedAt: new Date().toISOString(),
    createdAt: new Date().toISOString(),
    description: '',
    availableCredit: 0.0,
    preAuthorizedCredit: 0.0,
    email: steven.email,
    tolerance: 1.0,
    availableBalance: 0.0,
  },
  {
    id: '45854060000_CPF',
    balance: 0.0,
    document: '45854060000',
    status: 'Open',
    documentType: 'CPF',
    creditLimit: 50000000.0,
    updatedAt: new Date().toISOString(),
    createdAt: new Date().toISOString(),
    description: '',
    availableCredit: 0.0,
    preAuthorizedCredit: 0.0,
    email: chris.email,
    tolerance: 1.0,
    availableBalance: 0.0,
  },
]

```


[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 easy-setup/node/middlewares/UsersMiddleware/data/users.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
export interface User extends Record<string, unknown> {
  id: string
  email: string
  document: string
  firstName: string
  lastName: string
  priceTables: string
  isOrgAdmin: boolean
  organizationId?: string
}

export const john: User = {
  id: '461dde1b-2dbd-4ddb-8eba-f33a4f2b000b',
  email: 'john@email.com',
  document: '00000000191',
  firstName: 'John',
  lastName: 'Doe',
  priceTables: 'platinum',
  isOrgAdmin: true,
  organizationId: 'bf6297a1-99be-4459-8e5e-c1f28b270684',
}

export const steven: User = {
  id: 'aea191a3-e63f-48c6-87f3-cf63044d15c7',
  email: 'steven@email.com',
  document: '90750680008',
  firstName: 'Steven',
  lastName: 'Doe',
  priceTables: 'gold',
  isOrgAdmin: false,
  organizationId: 'bf6297a1-99be-4459-8e5e-c1f28b270684',
}

export const chris: User = {
  id: 'f5767052-b6b1-4652-87fc-7ccccfe53d71',
  email: 'chris@email.com',
  document: '45854060000',
  firstName: 'Chris',
  lastName: 'Doe',
  priceTables: 'silver',
  isOrgAdmin: false,
}

export const Users = [john, steven, chris]

```


[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 easy-setup/node/middlewares/CategoriesMiddleware/data/index.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
const CategoriesData = [
  {
    Id: 9281,
    Name: 'Apparel',
    Keywords: 'Apparel',
    Title: 'Apparel',
    Description: 'Apparel',
    AdWordsRemarketingCode: null,
    LomadeeCampaignCode: null,
    FatherCategoryId: null,
    GlobalCategoryId: 222,
    ShowInStoreFront: true,
    IsActive: true,
    ActiveStoreFrontLink: true,
    ShowBrandFilter: true,
    Score: null,
    StockKeepingUnitSelectionMode: 'SPECIFICATION',
  },
  {
    Id: 9282,
    Name: 'Food and beverage',
    Keywords: 'Food and beverage',
    Title: 'Food and beverage',
    Description: 'Food and beverage',
    AdWordsRemarketingCode: null,
    LomadeeCampaignCode: null,
    FatherCategoryId: null,
    GlobalCategoryId: 222,
    ShowInStoreFront: true,
    IsActive: true,
    ActiveStoreFrontLink: true,
    ShowBrandFilter: true,
    Score: null,
    StockKeepingUnitSelectionMode: 'SPECIFICATION',
  },
  {
    Id: 9283,
    Name: 'Sporting',
    Keywords: 'Sporting',
    Title: 'Sporting',
    Description: 'Sporting',
    AdWordsRemarketingCode: null,
    LomadeeCampaignCode: null,
    FatherCategoryId: null,
    GlobalCategoryId: 222,
    ShowInStoreFront: true,
    IsActive: true,
    ActiveStoreFrontLink: true,
    ShowBrandFilter: true,
    Score: null,
    StockKeepingUnitSelectionMode: 'SPECIFICATION',
  },
  {
    Id: 9284,
    Name: 'Agribusiness',
    Keywords: 'Agribusiness',
    Title: 'Agribusiness',
    Description: 'Agribusiness',
    AdWordsRemarketingCode: null,
    LomadeeCampaignCode: null,
    FatherCategoryId: null,
    GlobalCategoryId: 222,
    ShowInStoreFront: true,
    IsActive: true,
    ActiveStoreFrontLink: true,
    ShowBrandFilter: true,
    Score: null,
    StockKeepingUnitSelectionMode: 'SPECIFICATION',
  },
  {
    Id: 9285,
    Name: 'Home Appliance',
    Keywords: 'Home Appliance',
    Title: 'Home Appliance',
    Description: 'Home Appliance',
    AdWordsRemarketingCode: null,
    LomadeeCampaignCode: null,
    FatherCategoryId: null,
    GlobalCategoryId: 222,
    ShowInStoreFront: true,
    IsActive: true,
    ActiveStoreFrontLink: true,
    ShowBrandFilter: true,
    Score: null,
    StockKeepingUnitSelectionMode: 'SPECIFICATION',
  },
  {
    Id: 9286,
    Name: 'Computer & Software',
    Keywords: 'Computer & Software',
    Title: 'Computer & Software',
    Description: 'Computer & Software',
    AdWordsRemarketingCode: null,
    LomadeeCampaignCode: null,
    FatherCategoryId: null,
    GlobalCategoryId: 222,
    ShowInStoreFront: true,
    IsActive: true,
    ActiveStoreFrontLink: true,
    ShowBrandFilter: true,
    Score: null,
    StockKeepingUnitSelectionMode: 'SPECIFICATION',
  },
  {
    Id: 9287,
    Name: 'Power tools',
    Keywords: 'Power tools',
    Title: 'Power tools',
    Description: 'Power tools',
    AdWordsRemarketingCode: null,
    LomadeeCampaignCode: null,
    FatherCategoryId: null,
    GlobalCategoryId: 222,
    ShowInStoreFront: true,
    IsActive: true,
    ActiveStoreFrontLink: true,
    ShowBrandFilter: true,
    Score: null,
    StockKeepingUnitSelectionMode: 'SPECIFICATION',
  },
]

export { CategoriesData }

```


[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 easy-setup/node/middlewares/LogisticsMiddleware/data/logisticsData.ts from the easy-setup VTEX app.

[Assistant]
Here's the implementation:

```typescript
import type {
  CreateOrUpdateCarrierData,
  IDockPayload,
  IFreightValuePayload,
  IInventoryPayload,
  IWarehousePayload,
} from '../../../clients/LogisticsClient/types'

export const InventoryData: IInventoryPayload = {
  unlimitedQuantity: true,
  dateUtcOnBalanceSystem: null,
  quantity: 0,
}

export const CarrierData: CreateOrUpdateCarrierData = {
  id: '13942e4',
  slaType: 'Normal',
  name: 'Normal Delivery',
  scheduledDelivery: false,
  maxRangeDelivery: 0,
  dayOfWeekForDelivery: null,
  dayOfWeekBlockeds: [],
  freightValue: [],
  factorCubicWeight: null,
  freightTableProcessStatus: 1,
  freightTableValueError: null,
  modals: [],
  onlyItemsWithDefinedModal: false,
  deliveryOnWeekends: false,
  carrierSchedule: [],
  maxDimension: {
    weight: 0,
    height: 0,
    width: 0,
    length: 0,
    maxSumDimension: 0,
  },
  exclusiveToDeliveryPoints: false,
  minimunCubicWeight: 0,
  isPolygon: false,
  numberOfItemsPerShipment: null,
}

export const DockData: IDockPayload[] = [
  {
    pickupStoreInfo: {
      isPickupStore: false,
      storeId: null,
      friendlyName: null,
      address: {
        postalCode: '04538-132',
        country: {
          acronym: 'BRA',
          name: 'Brazil',
        },
        city: 'São Paulo',
        state: 'SP',
        neighborhood: 'Itaim Bibi',
        street: 'Avenida Brigadeiro Faria Lima',
        number: '4440',
        complement: null,
        reference: null,
        location: null,
      },
      additionalInfo: null,
      dockId: null,
      distance: null,
      businessHours: null,
      pickupHolidays: null,
      sellerId: null,
      isThirdPartyPickup: false,
    },
    storeId: null,
    pickupInStoreInfo: {
      isActice: false,
      additionalInfo: null,
    },
    deliveryFromStoreInfo: {
      isActice: false,
      deliveryRadius: 0,
      deliveryFee: 0,
      deliveryTime: '00:00:00',
      maximumWeight: 0,
    },
    address: {
      postalCode: '04538-132',
      country: {
        acronym: 'BRA',
        name: 'Brazil',
      },
      city: 'São Paulo',
      state: 'SP',
      neighborhood: 'Itaim Bibi',
      street: 'Avenida Brigadeiro Faria Lima',
      number: '4440',
      complement: null,
      reference: null,
      location: null,
    },
    location: null,
    id: '1',
    name: 'Main Dock',
    priority: 1,
    dockTimeFake: '00:00:00',
    timeFakeOverhead: '00:00:00',
    salesChannels: ['1'],
    freightTableIds: [CarrierData.id],
    wmsEndPoint: null,
    isActive: true,
  },
  {
    pickupStoreInfo: {
      isPickupStore: false,
      storeId: null,
      friendlyName: null,
      address: {
        postalCode: '10017',
        country: {
          acronym: 'USA',
          name: 'United States of America',
        },
        city: 'New York',
        state: 'NY',
        neighborhood: '',
        street: '49th St',
        number: '12E',
        complement: null,
        reference: null,
        location: null,
      },
      additionalInfo: null,
      dockId: null,
      distance: null,
      businessHours: null,
      pickupHolidays: null,
      sellerId: null,
      isThirdPartyPickup: false,
    },
    storeId: null,
    pickupInStoreInfo: {
      isActice: false,
      additionalInfo: null,
    },
    deliveryFromStoreInfo: {
      isActice: false,
      deliveryRadius: 0,
      deliveryFee: 0,
      deliveryTime: '00:00:00',
      maximumWeight: 0,
    },
    address: {
      postalCode: '10017',
      country: {
        acronym: 'USA',
        name: 'United States of America',
      },
      city: 'New York',
      state: 'NY',
      neighborhood: '',
      street: '49th St',
      number: '12E',
      complement: null,
      reference: null,
      location: null,
    },
    location: null,
    id: '2',
    name: 'Alternative Dock',
    priority: 1,
    dockTimeFake: '00:00:00',
    timeFakeOverhead: '00:00:00',
    salesChannels: ['1'],
    freightTableIds: [CarrierData.id],
    wmsEndPoint: null,
    isActive: true,
  },
]

export const FreightValueData: IFreightValuePayload[] = [
  {
    absoluteMoneyCost: '10.00',
    country: 'BRA',
    maxVolume: 1000000000,
    operationType: 1,
    pricePercent: 0,
    pricePercentByWeight: 0,
    timeCost: '2.00:00:00',
    weightEnd: 100000,
    weightStart: 1,
    zipCodeEnd: '99999999',
    zipCodeStart: '0',
    polygon: '',
  },
  {
    absoluteMoneyCost: '10.00',
    country: 'USA',
    maxVolume: 1000000000,
    operationType: 1,
    pricePercent: 0,
    pricePercentByWeight: 0,
    timeCost: '2.00:00:00',
    weightEnd: 100000,
    weightStart: 1,
    zipCodeEnd: '99999999',
    zipCodeStart: '0',
    polygon: '',
  },
]

export const WarehouseData: IWarehousePayload = {
  id: '1_1',
  name: 'Inventory',
  warehouseDocks: [
    {
      dockId: '1',
      time: '00:00:00',
      cost: 0.0,
    },
    {
      dockId: '2',
      time: '00:00:00',
      cost: 0.0,
    },
  ],
  pickupPointIds: [],
  priority: 0,
  isActive: true,
}

```