Broadleaf Microservices
  • v1.0.0-latest-prod

Utilities Exports Bundle

The collection of service exports. This collection of exports includes various utilities used throughout the admin.

Export Package Name: utils

How to pull in the module and its components
import { utils } from '@broadleaf/admin-components';

const { axios } = utils;
Component Name Description

axios

A utility helper class that uses the Axios library to create a new HTTP client instance with a custom configuration.

Environment

A utility helper class that provides methods for resolving environment properties.

log

A utility helper class that implements a simple logging library that extends `console’s logging methods using level-based logging and filtering, except the class adds custom decorations to the log statements.

mapper

A utility helper class that takes in a source object and a set of mappings, and returns the result of applying the mappings to the source object.


Paging Utilities

Export Sub-Package Name: PagingUtils

How to pull in the module and its components
import { utils } from '@broadleaf/admin-components';

const { addPagingHandler } = utils.PagingUtils;
Component Name Description

addPagingHandler

A function to add a new paging handler to handle new Pageable types.

getPageablePaging

A function to convert a Pageable into a paging structure. If an initial paging state exists, the new structure will be merged with the existing structure.

getNextPaging

A function that gets the paging state for the next page.

getPrevPaging

A function that gets the paging state for the previous page.

NO_PAGING

The paging state object when there is no pagination.


Request Utilities

Export Sub-Package Name: RequestUtils

How to pull in the module and its components
import { utils } from '@broadleaf/admin-components';

const { request } = utils.RequestUtils;
Component Name Description

request

A function that issues a compiled Axios request using the given request configuration and context.

del

A function that creates a delete Axios request using the given request configuration and context.

get

A function that creates a get Axios request using the given request configuration and context.

patch

A function that creates a patch Axios request using the given request configuration and context.

post

A function that creates a post Axios request using the given request configuration and context.

put

A function that creates a put Axios request using the given request configuration and context.

compileRequest

A function that creates and returns a configured metadata endpoint using the given request configuration and context.

mergeRequestConfigs

A function that merges a set of configurations or configuration functions into a single merged request configuration.

mergeContextParams

A function that merges a set of context parameters or context parameter functions into a single merged request configuration.

withContextRequestHeader

A function that returns the provided configuration with the X-Context-Request header defined. This header will be generated based on the current set of context parameters. In particular, this function will consider the parameters context.tracking and context.contextState.

withLocaleHeaders

A function that returns the provided configuration with the Accept-Language or X-Ignore-Translations headers defined.

namedTemplateReducer

A reducer function that maps state object data to an object according to a named template.