Skip to main content

foundation-utils

Home > @genesislcap/foundation-utils

foundation-utils package

Classes

Class

Description

DefaultErrorMap

DefaultServerRowDTOMapper

The default ServerRowDTOMapper.

InMemoryDatabase

An in memory database of specific DatabaseRecord types.

NumberParser

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.

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.

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

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.

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.

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

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.

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

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.

SOCKET_EXT

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

SSO_LIST_URL

SSO_LOGIN_URL

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.

Subscribe

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