Skip to main content

foundation-utils

Home > @genesislcap/foundation-utils

foundation-utils package​

Classes​

Class

Description

DefaultErrorMap

DefaultServerRowDTOMapper

The default ServerRowDTOMapper.

DefaultShortcutManager

Default implementation of the ShortcutManager interface

FoundationShortcutListener

A custom element that listens for keyboard shortcuts.

InactivityDialog

InactivityManager

InactivityService

InMemoryDatabase

An in memory database of specific DatabaseRecord types.

NumberParser

RouteUtil

A singleton utility to observe and notify about route changes. It uses both polling and popstate events to detect changes.

SlottedStyles

A custom element that encapsulates a set of styles that can be applied to slotted elements.

Enumerations​

Enumeration

Description

FontStyle

An enum of possible font styles.

FontWeight

An enum of possible font weights.

PendingStateEvents

An enum that defines the names of the events that can be raised by the PendingState mixin.

Functions​

Function

Description

assureDesignSystem(module)

assureDesignSystem.

avoidTreeShaking(classes)

Explicitly prevents tree-shaking of custom element classes by referencing them.

Bundlers may incorrectly remove code that it thinks has no side effects, such as custom element definitions that are only referenced in templates. By passing these classes to avoidTreeShaking, we create a side effect that signals to the bundler to preserve the code.

createErrorMap(logger)

A factory to create the error map.

createLogger(name, options)

Creates a logger with the given name and options.

createObserver()

Creates a new event observer instance.

customNumberParser(value)

A Default Number Parser for deserializing objects.

decodeFromBase64(base64Value)

Decodes a value from base64.

decodeFromBase64WithPrefix(value)

Decodes a value from base64 with a prefix.

deepMerge(target, source)

Deep merges two objects, with source values taking precedence over target values. Arrays are replaced (not merged), and null/undefined values in source are preserved.

delay(ms)

Delay for a given number of milliseconds

encodeToBase64(value)

Encodes the given value to base64.

encodeToBase64WithPrefix(value)

Encodes the given value with a prefix to base64.

formatDateTimestamp(timestamp)

Formats [DATE] UNIX Timestamps (without time) to readable strings

formatDateTimeTimestamp(timestamp)

Formats [DATETIME] UNIX Timestamps (with time) to readable strings

formatDateTimeTimestampWithMilliseconds(timestamp)

Formats [DATETIME] UNIX Timestamps (with time and milliseconds) to readable strings

formatTimestamp(timestamp, withTime)

Formats [DATE|DATETIME] Unix Timestamps to readable strings

getAllElements(root)

Recursively gather all elements including those in shadow DOM

getCurrentDesignSystem(element, fallbackPrefix)

Get the current design system provider element and prefix by checking available providers. If no provider is found, falls back to the provided prefix.

getCurrentDesignSystemPrefix(element, fallbackPrefix)

Get the current design system prefix by checking available providers. If no provider is found, falls back to the provided prefix.

getDateFormatter(locale, options)

getFontMixin(family, style, weight)

Generates a CSS mixin for the specified font family, style, and weight.

getNumberFormatter(format, locale)

inIFrame()

Returns a boolean value indicating whether the current window is inside an iframe.

insertDocumentCSSRule(cssRule, styleElementId)

Inserts a CSS rule into the document by creating a new style element or using an existing one with the specified ID. Returns a function that can be called to remove the rule from the document.

insertDocumentLink(href)

Inserts a CSS link into the document if it doesn't already exist.

inSymphonyDesktop()

Returns a boolean value indicating whether the user is running the Symphony desktop app.

isDev()

Determines if the current environment is a development environment.

isFeatureActivated(feature)

JSONReplacer(key, value)

JSON replacer function.

JSONReviver(key, value)

JSON reviver function.

LifecycleMixin(Base)

(BETA) Mixin class to expose shouldRunConnect and shouldRunDisconnect

loadFontFaces(fontFaceRules, styleElementId)

Loads font faces by inserting a style element with the specified font face rules into the document.

mapGenesisJsonSchema(jsonSchemResponse)

Takes in a valid response from connect.getJsonSchema(resourceName) and maps it to a JsonSchema extended with the genesisType metadata for a field

mapJsonSchemaFieldToExprBuilderField([name, schema])

Maps fields contained in a JSON schema block enhanced with genesisType metadata to the field shape required by the expression builder component.

Only sets the properties that are *required*. Optional properties, such as defaultValue, must be explicitly set by the user separately.

noop(fn)

A no-operation function that executes an optional callback.

This is a lower-level utility function. For preventing tree-shaking of custom elements, prefer using avoidTreeShaking() which provides a more explicit API.

openPopup(urlNavigate, target, popUpWidth, popUpHeight)

Opens a new browser window with the specified URL, target, width, and height.

PendingState(Base)

The PendingState mixin.

reactive(object, deep)

(BETA) Converts a plain object to a reactive, observable object.

renderOnChange(target, name)

Defines a property changed handler that calls a render() method on the target as an internal observation enhancement.

resolveAfter(ms, valueCreator)

Resolve a promise after a timeout.

respondToVisibility(element, callback)

Setup an IntersectionObserver which will activate a callback function when an element becomes visible on screen

sync(binding, conversionType, eventName, keyAttr)

Creates a synchronization directive that binds a data source to an HTML element,

toElementStyles(styles)

toElementStyles.

visitObject(object, deep, visitor, data, traversed)

(BETA) Visit object utility.

whenElse(binding, trueTemplateOrTemplateBinding, falseTemplateOrTemplateBinding)

Directive that allows supplying an "else" template to the traditional https://www.fast.design/docs/api/fast-element.when/#when-function directive

Interfaces​

Interface

Description

Database

Represents a database with basic CRUD operations.

DatabaseRecord

Represents a database record.

DesignSystemModule

DesignSystemModule.

DTOMapper

ErrorMap

InactivityConfig

InactivityDialogOptions

InactivityEvents

InactivityManagerConfig

JSONSerializer

An interface representing a JSON serializer.

JSONSerializerConfig

Configuration options for the JSONSerializer Config instance.

Logger

A logger that extends the Consola logger.

LoggerOptions

Options for creating a logger.

ObjectVisitor

(BETA)

Observer

Represents an event observer that manages the subscription and publication of events.

ServerRowDTOMapper

A mapper for converting between server row DTOs and entities. Provides methods to get/set a ServerRow DTO entity mapping.

ShortcutDefinition

A definition of a keyboard shortcut

ShortcutManager

Interface of a manager for keyboard shortcuts

ShortcutRegistrationResult

A result of registering a keyboard shortcut

UUID

An interface for generating UUIDs.

UUIDConfig

A configuration object for customizing UUID generation.

Namespaces​

Namespace

Description

DatabaseAccessResult

Namespace for database access result types.

DatabaseEvent

Namespace for database events.

Genesis

Variables​

Variable

Description

ACCEPT_TERMS_URL

activeColorScheme

A design token that represents the active color scheme (light or dark).

API_HOST

The Genesis Server URL (WebSocket or HTTP).

BUILDER

The builder aka file bundler.

CHANGE_PASSWORD_URL

DEFAULT_ORGANISATION

The default Organisation value, used in auth/login flow [genesislcap-foundation-login](https://link-to-docs).

DEFAULT_PASSWORD

The default Password value, used in auth/login flow [genesislcap-foundation-login](https://link-to-docs).

DEFAULT_USER

The default Username value, used in auth/login flow [genesislcap-foundation-login](https://link-to-docs).

defaultEventMap

A map that associates specific HTML element tags with their corresponding default event names.

defaultJSONSerializerConfig

A Default JSONSerializer Config for serializing and deserializing functions.

defaultLoggerOptions

The default logger options.

ENVIRONMENT_LEVEL

FORCE_HTTP

The path to a JSON config file for the HTTP mode.

FORGOT_PASSWORD_URL

GENESIS_SOCKET_URL

Genesis Socket URL

HTTP_CONFIG

Configuration settings for HTTP, used in http connect flow [genesislcap-foundation-comms.HttpConnectConfig](https://link-to-docs).

JSONSerializer

A DI token for the JSON serializer.

layoutCacheDocument

Stored on the layout's internal cache to signify that the document is not part of the DOM

logger

Logger for the foundation-utils package

LOGIN_DETAILS_URL

LOGIN_REFRESH_URL

LOGIN_URL

LOGOUT_URL

POPUP_DEFAULT_HEIGHT

The default height (in pixels) for pop-up windows.

POPUP_DEFAULT_WIDTH

The default width (in pixels) for pop-up windows.

PUBLIC_PATH

The public path.

RESET_PASSWORD_URL

ResourceType

An object that defines two resource types: "local" and "remote".

ServerRowDTOMapper

A DI token used to obtain a ServerRowDTOMapper instance.

ShortcutManager

A dependency injection token for the ShortcutManager interface.

SOCKET_EXT

The sub-path used for WebSocket connections when API_HOST is not set

SSO_LIST_URL

SSO_LOGIN_URL

stringArrayConverter

A that converts between comma-separated string attributes and string | string[] properties.

TypeRampValues

An object containing type ramp values.

UUID

A dependency injection token for the UUID interface.

Type Aliases​

Type Alias

Description

ConstructableLifecycleHandler

ConstructablePendingState

A mixin that provides functionality for raising pending-state events.

ConversionType

Represents the possible types of value conversion for data synchronization.

DesignSystemResource

DesignSystemResource.

ErrorDetailMap

ErrorMapLogger

EventName

Represents the possible event names for data synchronization.

Listener

Creates an observer that facilitates the subscription and publication of events.

PendingStateErrorEvent

A custom event that represents a pending-state-error event.

PendingStateEvent

A custom event that represents a pending-state event.

Publish

Publishes an event of a specific type to all subscribed listeners.

ResourceType

A type that represents the resource types defined by the ResourceType object.

ServerRowDTO

The data for a server row DTO.

ServerRowEntity

The data for a server row entity.

ShortcutExecutionStatus

A type which represents the disabled status and tooltip of an item

Subscribe

Subscribes a listener function to receive events of a specific type.