Skip to content

Latest commit

 

History

History
3658 lines (2142 loc) · 94 KB

File metadata and controls

3658 lines (2142 loc) · 94 KB

Back to README.md

@openmrs/esm-framework

Table of contents

API Functions

Breadcrumb Functions

Config Functions

Config Validation Functions

Date and Time Functions

Error Handling Functions

Extension Functions

Framework Functions

Navigation Functions

Offline Functions

Store Functions

UI Functions

Utility Functions

API Type aliases

CurrentPatient

Ƭ CurrentPatient: fhir.Patient | FetchResponse<fhir.Patient>

Defined in

packages/framework/esm-api/src/shared-api-objects/current-patient.ts:5


NullablePatient

Ƭ NullablePatient: fhir.Patient | null

Defined in

packages/framework/esm-react-utils/src/usePatient.ts:5


PatientUuid

Ƭ PatientUuid: string | null

Defined in

packages/framework/esm-api/src/shared-api-objects/current-patient.ts:19


Date and Time Type aliases

DateInput

Ƭ DateInput: string | number | Date

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:19


FormatDateMode

Ƭ FormatDateMode: "standard" | "wide"

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:140


FormatDateOptions

Ƭ FormatDateOptions: Object

Type declaration

Name Type Description
day boolean Whether to include the day number
mode FormatDateMode - standard: "03 Feb 2022" - wide: "03 — Feb — 2022"
time boolean | "for today" Whether the time should be included in the output always (true), never (false), or only when the input date is today (for today).
year boolean Whether to include the year

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:142


Offline Type aliases

KnownOmrsServiceWorkerMessages

Ƭ KnownOmrsServiceWorkerMessages: OnImportMapChangedMessage | ClearDynamicRoutesMessage | RegisterDynamicRouteMessage

Defined in

packages/framework/esm-offline/src/service-worker-messaging.ts:46


OfflineMode

Ƭ OfflineMode: "on" | "off" | "unavailable"

Defined in

packages/framework/esm-offline/src/mode.ts:38


OmrsOfflineCachingStrategy

Ƭ OmrsOfflineCachingStrategy: "network-only-or-cache-only" | "network-first"

Defined in

packages/framework/esm-offline/src/service-worker-http-headers.ts:18


OmrsOfflineHttpHeaderNames

Ƭ OmrsOfflineHttpHeaderNames: keyof OmrsOfflineHttpHeaders

Defined in

packages/framework/esm-offline/src/service-worker-http-headers.ts:45


OmrsOfflineHttpHeaders

Ƭ OmrsOfflineHttpHeaders: Object

Defines the keys of the custom headers which can be appended to an HTTP request. HTTP requests with these headers are handled in a special way by the SPA's service worker.

Type declaration

Name Type Description
x-omrs-offline-caching-strategy? OmrsOfflineCachingStrategy Instructs the service worker to use a specific caching strategy for this request.
x-omrs-offline-response-body? string If the client is offline and the request cannot be read from the cache (i.e. if there is no way to receive any kind of data for this request), the service worker will return a response with the body in this header.
x-omrs-offline-response-status? `${number}` If the client is offline and the request cannot be read from the cache (i.e. if there is no way to receive any kind of data for this request), the service worker will return a response with the status code defined in this header.

Defined in

packages/framework/esm-offline/src/service-worker-http-headers.ts:26


Other Type aliases

ConfigValue

Ƭ ConfigValue: string | number | boolean | void | any[] | object

Defined in

packages/framework/esm-config/src/types.ts:32


ExtensionSlotProps

Ƭ ExtensionSlotProps: ExtensionSlotBaseProps & React.HTMLAttributes<HTMLDivElement>

Defined in

packages/framework/esm-react-utils/src/ExtensionSlot.tsx:48


ProvidedConfig

Ƭ ProvidedConfig: Object

Type declaration

Name Type
config Config
source string

Defined in

packages/framework/esm-config/src/types.ts:60


SpaEnvironment

Ƭ SpaEnvironment: "production" | "development" | "test"

Defined in

packages/framework/esm-globals/src/types.ts:55


UpdateVisitPayload

Ƭ UpdateVisitPayload: NewVisitPayload & {}

Defined in

packages/framework/esm-api/src/types/visit-resource.ts:12


Validator

Ƭ Validator: (value: any) => void | string

Type declaration

▸ (value): void | string

Parameters
Name Type
value any
Returns

void | string

Defined in

packages/framework/esm-config/src/types.ts:67


ValidatorFunction

Ƭ ValidatorFunction: (value: any) => boolean

Type declaration

▸ (value): boolean

Parameters
Name Type
value any
Returns

boolean

Defined in

packages/framework/esm-config/src/types.ts:65


Store Type aliases

Actions

Ƭ Actions: Function | { [key: string]: Function; }

Defined in

packages/framework/esm-react-utils/src/createUseStore.ts:5


BoundActions

Ƭ BoundActions: Object

Index signature

▪ [key: string]: BoundAction

Defined in

packages/framework/esm-react-utils/src/createUseStore.ts:6


UI Type aliases

InlineNotificationType

Ƭ InlineNotificationType: "error" | "info" | "info-square" | "success" | "warning" | "warning-alt"

Defined in

packages/framework/esm-styleguide/src/notifications/notification.component.tsx:22


LayoutType

Ƭ LayoutType: "tablet" | "phone" | "desktop"

Defined in

packages/framework/esm-react-utils/src/useLayoutType.ts:4


ToastType

Ƭ ToastType: "error" | "info" | "info-square" | "success" | "warning" | "warning-alt"

Defined in

packages/framework/esm-styleguide/src/toasts/toast.component.tsx:26

API Variables

UserHasAccess

UserHasAccess: React.FC<UserHasAccessProps>

Defined in

packages/framework/esm-react-utils/src/UserHasAccess.tsx:9


defaultVisitCustomRepresentation

defaultVisitCustomRepresentation: string

Defined in

packages/framework/esm-api/src/shared-api-objects/visit-utils.ts:12


fhir

fhir: FhirClient

The fhir object is an instance of fhir.js that can be used to call FHIR-compliant OpenMRS APIs. See the docs for fhir.js for more info and example usage.

Defined in

packages/framework/esm-api/src/fhir.ts:42


fhirBaseUrl

fhirBaseUrl: "/ws/fhir2/R4"

Defined in

packages/framework/esm-api/src/fhir.ts:5


getStartedVisit

getStartedVisit: BehaviorSubject<null | VisitItem>

Defined in

packages/framework/esm-api/src/shared-api-objects/visit-utils.ts:74


sessionEndpoint

sessionEndpoint: "/ws/rest/v1/session"

Defined in

packages/framework/esm-api/src/openmrs-fetch.ts:7


Config Validation Variables

validators

validators: Object

Type declaration

Name Type
inRange (min: number, max: number) => Validator
isUrl Validator
isUrlWithTemplateParameters (allowedTemplateParameters: string[]) => Validator

Defined in

packages/framework/esm-config/src/validators/validators.ts:58


Navigation Variables

ConfigurableLink

ConfigurableLink: React.FC<ConfigurableLinkProps>

A React link component which calls navigate when clicked

param The target path or URL. Supports interpolation. See navigate

param Inline elements within the link

param Any other valid props for an tag except href and onClick

Defined in

packages/framework/esm-react-utils/src/ConfigurableLink.tsx:32


Offline Variables

offlineUuidPrefix

offlineUuidPrefix: "OFFLINE+"

Defined in

packages/framework/esm-offline/src/uuid.ts:4


omrsOfflineCachingStrategyHttpHeaderName

omrsOfflineCachingStrategyHttpHeaderName: "x-omrs-offline-caching-strategy"

Defined in

packages/framework/esm-offline/src/service-worker-http-headers.ts:7


omrsOfflineResponseBodyHttpHeaderName

omrsOfflineResponseBodyHttpHeaderName: "x-omrs-offline-response-body"

Defined in

packages/framework/esm-offline/src/service-worker-http-headers.ts:3


omrsOfflineResponseStatusHttpHeaderName

omrsOfflineResponseStatusHttpHeaderName: "x-omrs-offline-response-status"

Defined in

packages/framework/esm-offline/src/service-worker-http-headers.ts:5


Other Variables

Extension

Extension: React.FC<ExtensionProps>

Represents the position in the DOM where each extension within an extension slot is rendered.

Renders once for each extension attached to that extension slot.

Usage of this component must have an ancestor <ExtensionSlot>, and must only be used once within that <ExtensionSlot>.

Defined in

packages/framework/esm-react-utils/src/Extension.tsx:23


ExtensionSlot

ExtensionSlot: React.FC<ExtensionSlotProps>

Defined in

packages/framework/esm-react-utils/src/ExtensionSlot.tsx:55


backendDependencies

backendDependencies: Object

Type declaration

Name Type
fhir2 string
webservices.rest string

Defined in

packages/framework/esm-api/src/openmrs-backend-dependencies.ts:1

API Functions

fetchCurrentPatient

fetchCurrentPatient(patientUuid, contentOverrides?): Promise<{ data: Patient }> | Promise<null>

Parameters

Name Type
patientUuid PatientUuid
contentOverrides? Partial<{ headers?: FetchHeaders ; id?: string ; patient?: string ; type: ResourceName }>

Returns

Promise<{ data: Patient }> | Promise<null>

Defined in

packages/framework/esm-api/src/shared-api-objects/current-patient.ts:21


getCurrentUser

getCurrentUser(): Observable<LoggedInUser>

The getCurrentUser function returns an observable that produces zero or more values, over time. It will produce zero values by default if the user is not logged in. And it will provide a first value when the logged in user is fetched from the server. Subsequent values will be produced whenever the user object is updated.

Returns

Observable<LoggedInUser>

An Observable that produces zero or more values (as described above). The values produced will be a user object (if includeAuthStatus is set to false) or an object with a session and authenticated property (if includeAuthStatus is set to true).

Example

import { getCurrentUser } from '@openmrs/esm-api'
const subscription = getCurrentUser().subscribe(
  user => console.log(user)
)
subscription.unsubscribe()
getCurrentUser({includeAuthStatus: true}).subscribe(
  data => console.log(data.authenticated)
)

Be sure to unsubscribe when your component unmounts

Otherwise your code will continue getting updates to the user object even after the UI component is gone from the screen. This is a memory leak and source of bugs.

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:57

getCurrentUser(opts): Observable<Session>

Parameters

Name Type
opts CurrentUserWithResponseOption

Returns

Observable<Session>

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:58

getCurrentUser(opts): Observable<LoggedInUser>

Parameters

Name Type
opts CurrentUserWithoutResponseOption

Returns

Observable<LoggedInUser>

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:61


getLocations

getLocations(): Observable<Location[]>

Returns

Observable<Location[]>

Defined in

packages/framework/esm-api/src/shared-api-objects/location.ts:14


getLoggedInUser

getLoggedInUser(): Promise<LoggedInUser>

Returns

Promise<LoggedInUser>

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:136


getSessionLocation

getSessionLocation(): Promise<undefined | SessionLocation>

Returns

Promise<undefined | SessionLocation>

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:145


getVisitTypes

getVisitTypes(): Observable<VisitType[]>

Returns

Observable<VisitType[]>

Defined in

packages/framework/esm-api/src/shared-api-objects/visit-type.ts:15


getVisitsForPatient

getVisitsForPatient(patientUuid, abortController, v?): Observable<FetchResponse<{ results: Visit[] }>>

Parameters

Name Type
patientUuid string
abortController AbortController
v? string

Returns

Observable<FetchResponse<{ results: Visit[] }>>

Defined in

packages/framework/esm-api/src/shared-api-objects/visit-utils.ts:20


makeUrl

makeUrl(path): string

Append path to the OpenMRS SPA base.

Example

makeUrl('/foo/bar');
// => '/openmrs/foo/bar'

Parameters

Name Type
path string

Returns

string

Defined in

packages/framework/esm-api/src/openmrs-fetch.ts:19


openmrsFetch

openmrsFetch<T>(path, fetchInit?): Promise<FetchResponse<T>>

The openmrsFetch function is a wrapper around the browser's built-in fetch function, with extra handling for OpenMRS-specific API behaviors, such as request headers, authentication, authorization, and the API urls.

Type parameters

Name Type
T any

Parameters

Name Type Description
path string A string url to make the request to. Note that the openmrs base url (by default /openmrs) will be automatically prepended to the URL, so there is no need to include it.
fetchInit FetchConfig A fetch init object. Note that the body property does not need to be JSON.stringify()ed because openmrsFetch will do that for you.

Returns

Promise<FetchResponse<T>>

A Promise that resolves with a Response object. Note that the openmrs version of the Response object has already downloaded the HTTP response body as json, and has an additional data property with the HTTP response json as a javascript object.

Example

import { openmrsFetch } from '@openmrs/esm-api'
const abortController = new AbortController();
openmrsFetch('/ws/rest/v1/session', {signal: abortController.signal})
  .then(response => {
    console.log(response.data.authenticated)
  })
  .catch(err => {
    console.error(err.status);
  })
abortController.abort();
openmrsFetch('/ws/rest/v1/session', {
  method: 'POST',
  body: {
    username: 'hi',
    password: 'there',
  }
})

Cancellation

To cancel a network request, use an AbortController. It is best practice to cancel your network requests when the user navigates away from a page while the request is pending request, to free up memory and network resources and to prevent race conditions.

Defined in

packages/framework/esm-api/src/openmrs-fetch.ts:72


openmrsObservableFetch

openmrsObservableFetch<T>(url, fetchInit?): Observable<FetchResponse<T>>

The openmrsObservableFetch function is a wrapper around openmrsFetch that returns an Observable instead of a promise. It exists in case using an Observable is preferred or more convenient than a promise.

Type parameters

Name
T

Parameters

Name Type Description
url string See openmrsFetch
fetchInit FetchConfig See openmrsFetch

Returns

Observable<FetchResponse<T>>

An Observable that produces exactly one Response object. The response object is exactly the same as for openmrsFetch.

Example

import { openmrsObservableFetch } from '@openmrs/esm-api'
const subscription = openmrsObservableFetch('/ws/rest/v1/session').subscribe(
  response => console.log(response.data),
  err => {throw err},
  () => console.log('finished')
)
subscription.unsubscribe()

Cancellation

To cancel the network request, simply call subscription.unsubscribe();

Defined in

packages/framework/esm-api/src/openmrs-fetch.ts:243


refetchCurrentUser

refetchCurrentUser(): void

The refetchCurrentUser function causes a network request to redownload the user. All subscribers to the current user will be notified of the new users once the new version of the user object is downloaded.

Returns

void

The same observable as returned by getCurrentUser.

Example

import { refetchCurrentUser } from '@openmrs/esm-api'
refetchCurrentUser()

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:115


saveVisit

saveVisit(payload, abortController): Observable<FetchResponse<any>>

Parameters

Name Type
payload NewVisitPayload
abortController AbortController

Returns

Observable<FetchResponse<any>>

Defined in

packages/framework/esm-api/src/shared-api-objects/visit-utils.ts:45


setSessionLocation

setSessionLocation(locationUuid, abortController): Promise<any>

Parameters

Name Type
locationUuid string
abortController AbortController

Returns

Promise<any>

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:157


toLocationObject

toLocationObject(openmrsRestForm): Location

Parameters

Name Type
openmrsRestForm any

Returns

Location

Defined in

packages/framework/esm-api/src/shared-api-objects/location.ts:7


toVisitTypeObject

toVisitTypeObject(openmrsRestForm): VisitType

Parameters

Name Type
openmrsRestForm any

Returns

VisitType

Defined in

packages/framework/esm-api/src/shared-api-objects/visit-type.ts:7


updateVisit

updateVisit(uuid, payload, abortController): Observable<any>

Parameters

Name Type
uuid string
payload NewVisitPayload
abortController AbortController

Returns

Observable<any>

Defined in

packages/framework/esm-api/src/shared-api-objects/visit-utils.ts:59


useCurrentPatient

useCurrentPatient(patientUuid?): [boolean, NullablePatient, PatientUuid, Error | null]

This React hook returns the current patient, as specified by the current route. It returns all the information needed to render a loading state, error state, and normal/success state.

deprecated Use usePatient instead.

Parameters

Name Type
patientUuid PatientUuid

Returns

[boolean, NullablePatient, PatientUuid, Error | null]

Defined in

packages/framework/esm-react-utils/src/useCurrentPatient.ts:83


useLocations

useLocations(): Location[]

Returns

Location[]

Defined in

packages/framework/esm-react-utils/src/useLocations.tsx:5


usePatient

usePatient(patientUuid?): Object

This React hook returns a patient object. If the patientUuid is provided as a parameter, then the patient for that UUID is returned. If the parameter is not provided, the patient UUID is obtained from the current route, and a route listener is set up to update the patient whenever the route changes.

Parameters

Name Type
patientUuid? string

Returns

Object

Name Type
error null | Error
isLoading boolean
patient NullablePatient
patientUuid null | string

Defined in

packages/framework/esm-react-utils/src/usePatient.ts:92


useSession

useSession(): null | Session

Returns

null | Session

Defined in

packages/framework/esm-react-utils/src/useSessionUser.tsx:5


useSessionUser

Const useSessionUser(): null | Session

deprecated

Returns

null | Session

Defined in

packages/framework/esm-react-utils/src/useSessionUser.tsx:21


useVisit

useVisit(patientUuid): VisitReturnType

This React hook returns a visit object. If the patientUuid is provided as a parameter, then the currentVisit, error and mutate function for that patient visit is returned.

Parameters

Name Type Description
patientUuid string Unique patient identifier string

Returns

VisitReturnType

Object {error isValidating, currentVisit, mutate}

Defined in

packages/framework/esm-react-utils/src/useVisit.ts:27


useVisitTypes

useVisitTypes(): VisitType[]

Returns

VisitType[]

Defined in

packages/framework/esm-react-utils/src/useVisitTypes.ts:5


userHasAccess

userHasAccess(requiredPrivilege, user): undefined | Privilege

Parameters

Name Type
requiredPrivilege string
user Object
user.privileges Privilege[]
user.roles Role[]

Returns

undefined | Privilege

Defined in

packages/framework/esm-api/src/shared-api-objects/current-user.ts:129


Breadcrumb Functions

filterBreadcrumbs

filterBreadcrumbs(list, path): BreadcrumbRegistration[]

Parameters

Name Type
list BreadcrumbRegistration[]
path string

Returns

BreadcrumbRegistration[]

Defined in

packages/framework/esm-breadcrumbs/src/filter.ts:43


getBreadcrumbs

getBreadcrumbs(): BreadcrumbRegistration[]

Returns

BreadcrumbRegistration[]

Defined in

packages/framework/esm-breadcrumbs/src/db.ts:35


getBreadcrumbsFor

getBreadcrumbsFor(path): BreadcrumbRegistration[]

Parameters

Name Type
path string

Returns

BreadcrumbRegistration[]

Defined in

packages/framework/esm-breadcrumbs/src/filter.ts:66


registerBreadcrumb

registerBreadcrumb(breadcrumb): void

Parameters

Name Type
breadcrumb BreadcrumbSettings

Returns

void

Defined in

packages/framework/esm-breadcrumbs/src/db.ts:21


registerBreadcrumbs

registerBreadcrumbs(breadcrumbs): void

Parameters

Name Type
breadcrumbs BreadcrumbSettings[]

Returns

void

Defined in

packages/framework/esm-breadcrumbs/src/db.ts:25


Config Functions

defineConfigSchema

defineConfigSchema(moduleName, schema): void

This defines a configuration schema for a module. The schema tells the configuration system how the module can be configured. It specifies what makes configuration valid or invalid.

See Configuration System for more information about defining a config schema.

Parameters

Name Type Description
moduleName string Name of the module the schema is being defined for. Generally should be the one in which the defineConfigSchema call takes place.
schema ConfigSchema The config schema for the module

Returns

void

Defined in

packages/framework/esm-config/src/module-config/module-config.ts:193


defineExtensionConfigSchema

defineExtensionConfigSchema(extensionName, schema): void

This defines a configuration schema for an extension. When a schema is defined for an extension, that extension will receive the configuration corresponding to that schema, rather than the configuration corresponding to the module in which it is defined.

The schema tells the configuration system how the module can be configured. It specifies what makes configuration valid or invalid.

See Configuration System for more information about defining a config schema.

Parameters

Name Type Description
extensionName string Name of the extension the schema is being defined for. Should match the name of one of the extensions entries being returned by setupOpenMRS.
schema ConfigSchema The config schema for the extension

Returns

void

Defined in

packages/framework/esm-config/src/module-config/module-config.ts:218


getConfig

getConfig(moduleName): Promise<Config>

A promise-based way to access the config as soon as it is fully loaded. If it is already loaded, resolves the config in its present state.

In general you should use the Unistore-based API provided by getConfigStore, which allows creating a subscription so that you always have the latest config. If using React, just use useConfig.

This is a useful function if you need to get the config in the course of the execution of a function.

Parameters

Name Type Description
moduleName string The name of the module for which to look up the config

Returns

Promise<Config>

Defined in

packages/framework/esm-config/src/module-config/module-config.ts:254


provide

provide(config, sourceName?): void

Parameters

Name Type Default value
config Config undefined
sourceName string "provided"

Returns

void

Defined in

packages/framework/esm-config/src/module-config/module-config.ts:234


useConfig

useConfig(): Object

Use this React Hook to obtain your module's configuration.

Returns

Object

Name Type Description
constructor Function The initial value of Object.prototype.constructor is the standard built-in Object constructor.
hasOwnProperty (v: PropertyKey) => boolean Determines whether an object has a property with the specified name.
isPrototypeOf (v: Object) => boolean Determines whether an object exists in another object's prototype chain.
propertyIsEnumerable (v: PropertyKey) => boolean Determines whether a specified property is enumerable.
toLocaleString () => string Returns a date converted to a string using the current locale.
toString () => string Returns a string representation of an object.
valueOf () => Object Returns the primitive value of the specified object.

Defined in

packages/framework/esm-react-utils/src/useConfig.ts:163


Config Validation Functions

inRange

Const inRange(min, max): Validator

Verifies that the value is between the provided minimum and maximum

Parameters

Name Type Description
min number Minimum acceptable value
max number Maximum acceptable value

Returns

Validator

Defined in

packages/framework/esm-config/src/validators/validators.ts:10


isUrl

Const isUrl(value): string | void

Verifies that a string contains only the default URL template parameters.

category Navigation

Parameters

Name Type
value any

Returns

string | void

Defined in

packages/framework/esm-config/src/validators/validators.ts:56


isUrlWithTemplateParameters

Const isUrlWithTemplateParameters(allowedTemplateParameters): Validator

Verifies that a string contains only the default URL template parameters, plus any specified in allowedTemplateParameters.

category Navigation

Parameters

Name Type Description
allowedTemplateParameters string[] To be added to openmrsBase and openmrsSpaBase

Returns

Validator

Defined in

packages/framework/esm-config/src/validators/validators.ts:24


validator

validator(validationFunction, message): Validator

Parameters

Name Type
validationFunction ValidatorFunction
message string

Returns

Validator

Defined in

packages/framework/esm-config/src/validators/validator.ts:4


Date and Time Functions

formatDate

formatDate(date, options?): string

Formats the input date according to the current locale and the given options.

Default options:

  • mode: "standard",
  • time: "for today",
  • day: true,
  • year: true

If the date is today then "Today" is produced (in the locale language).

When time is included, it is appended with a comma and a space. This agrees with the output of Date.prototype.toLocaleString for most locales.

Parameters

Name Type
date Date
options? Partial<FormatDateOptions>

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:182


formatDatetime

formatDatetime(date, options?): string

Formats the input into a string showing the date and time, according to the current locale. The mode parameter is as described for formatDate.

This is created by concatenating the results of formatDate and formatTime with a comma and space. This agrees with the output of Date.prototype.toLocaleString for most locales.

Parameters

Name Type
date Date
options? Partial<Omit<FormatDateOptions, "time">>

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:249


formatTime

formatTime(date): string

Formats the input as a time, according to the current locale. 12-hour or 24-hour clock depends on locale.

Parameters

Name Type
date Date

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:233


isOmrsDateStrict

isOmrsDateStrict(omrsPayloadString): boolean

This function is STRICT on checking whether a date string is the openmrs format. The format should be YYYY-MM-DDTHH:mm:ss.SSSZZ

Parameters

Name Type
omrsPayloadString string

Returns

boolean

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:27


isOmrsDateToday

isOmrsDateToday(date): boolean

Parameters

Name Type Description
date DateInput Checks if the provided date is today.

Returns

boolean

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:64


parseDate

parseDate(dateString): Date

Utility function to parse an arbitrary string into a date. Uses dayjs(dateString).

Parameters

Name Type
dateString string

Returns

Date

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:136


toDateObjectStrict

toDateObjectStrict(omrsDateString): Date | null

Converts the object to a date object if it is a valid ISO date time string.

Parameters

Name Type
omrsDateString string

Returns

Date | null

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:71


toOmrsDateFormat

toOmrsDateFormat(date, format?): string

deprecated use formatDate(date) Formats the input as a date string. By default the format "YYYY-MMM-DD" is used.

Parameters

Name Type Default value
date DateInput undefined
format string "YYYY-MMM-DD"

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:128


toOmrsDayDateFormat

toOmrsDayDateFormat(date): string

deprecated use formatDate(date, "wide") Formats the input as a date string using the format "DD - MMM - YYYY".

Parameters

Name Type
date DateInput

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:112


toOmrsIsoString

toOmrsIsoString(date, toUTC?): string

Formats the input as a date time string using the format "YYYY-MM-DDTHH:mm:ss.SSSZZ".

Parameters

Name Type Default value
date DateInput undefined
toUTC boolean false

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:82


toOmrsTimeString

toOmrsTimeString(date): string

deprecated use formatTime Formats the input as a time string using the format "HH:mm A".

Parameters

Name Type
date DateInput

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:104


toOmrsTimeString24

toOmrsTimeString24(date): string

deprecated use formatTime Formats the input as a time string using the format "HH:mm".

Parameters

Name Type
date DateInput

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:96


toOmrsYearlessDateFormat

toOmrsYearlessDateFormat(date): string

deprecated use formatDate(date, "no year") Formats the input as a date string using the format "DD-MMM".

Parameters

Name Type
date DateInput

Returns

string

Defined in

packages/framework/esm-utils/src/omrs-dates.ts:120


Error Handling Functions

createErrorHandler

createErrorHandler(): (incomingErr: any) => void

Returns

fn

▸ (incomingErr): void

Parameters
Name Type
incomingErr any
Returns

void

Defined in

packages/framework/esm-error-handling/src/index.ts:24


reportError

reportError(err): void

Parameters

Name Type
err any

Returns

void

Defined in

packages/framework/esm-error-handling/src/index.ts:17


Extension Functions

attach

attach(slotName, extensionId): void

Attach an extension to an extension slot.

This will cause the extension to be rendered into the specified extension slot, unless it is removed by configuration. Using attach is an alternative to specifying the slot or slots in the extension declaration.

It is particularly useful when creating a slot into which you want to render an existing extension. This enables you to do so without modifying the extension's declaration, which may be impractical or inappropriate, for example if you are writing a module for a specific implementation.

Parameters

Name Type Description
slotName string a name uniquely identifying the slot
extensionId string an extension name, with an optional #-suffix to distinguish it from other instances of the same extension attached to the same slot.

Returns

void

Defined in

packages/framework/esm-extensions/src/extensions.ts:172


detach

detach(extensionSlotName, extensionId): void

Avoid using this. Extension attachments should be considered declarative.

Parameters

Name Type
extensionSlotName string
extensionId string

Returns

void

Defined in

packages/framework/esm-extensions/src/extensions.ts:203


detachAll

detachAll(extensionSlotName): void

Avoid using this. Extension attachments should be considered declarative.

Parameters

Name Type
extensionSlotName string

Returns

void

Defined in

packages/framework/esm-extensions/src/extensions.ts:227


getAssignedExtensions

getAssignedExtensions(slotName): AssignedExtension[]

Parameters

Name Type
slotName string

Returns

AssignedExtension[]

Defined in

packages/framework/esm-extensions/src/extensions.ts:328


getConnectedExtensions

getConnectedExtensions(assignedExtensions, online?): ConnectedExtension[]

Filters a list of extensions according to whether they support the current connectivity status.

Parameters

Name Type Default value Description
assignedExtensions AssignedExtension[] undefined The list of extensions to filter.
online null | boolean null Whether the app is currently online. If null, uses navigator.onLine.

Returns

ConnectedExtension[]

A list of extensions that should be rendered

Defined in

packages/framework/esm-extensions/src/extensions.ts:285


getExtensionNameFromId

getExtensionNameFromId(extensionId): string

Given an extension ID, which is a string uniquely identifying an instance of an extension within an extension slot, this returns the extension name.

example

getExtensionNameFromId("foo#bar")
 --> "foo"
getExtensionNameFromId("baz")
 --> "baz"

Parameters

Name Type
extensionId string

Returns

string

Defined in

packages/framework/esm-extensions/src/extensions.ts:116


getExtensionStore

Const getExtensionStore(): Store<ExtensionStore>

This returns a store that modules can use to get information about the state of the extension system.

Returns

Store<ExtensionStore>

Defined in

packages/framework/esm-extensions/src/store.ts:129


renderExtension

renderExtension(domElement, extensionSlotName, extensionSlotModuleName, extensionId, renderFunction?, additionalProps?): CancelLoading

Mounts into a DOM node (representing an extension slot) a lazy-loaded component from any frontend module that registered an extension component for this slot.

Parameters

Name Type
domElement HTMLElement
extensionSlotName string
extensionSlotModuleName string
extensionId string
renderFunction (lifecycle: Lifecycle) => Lifecycle
additionalProps Record<string, any>

Returns

CancelLoading

Defined in

packages/framework/esm-extensions/src/render.ts:17


useAssignedExtensionIds

useAssignedExtensionIds(slotName): string[]

Gets the assigned extension ids for a given extension slot name. Does not consider if offline or online.

deprecated Use useAssignedExtensions

Parameters

Name Type Description
slotName string The name of the slot to get the assigned IDs for.

Returns

string[]

Defined in

packages/framework/esm-react-utils/src/useAssignedExtensionIds.ts:13


useAssignedExtensions

useAssignedExtensions(slotName): AssignedExtension[]

Gets the assigned extensions for a given extension slot name. Does not consider if offline or online.

Parameters

Name Type Description
slotName string The name of the slot to get the assigned extensions for.

Returns

AssignedExtension[]

Defined in

packages/framework/esm-react-utils/src/useAssignedExtensions.ts:15


useConnectedExtensions

useConnectedExtensions(slotName): ConnectedExtension[]

Gets the assigned extension for a given extension slot name. Considers if offline or online.

Parameters

Name Type Description
slotName string The name of the slot to get the assigned extensions for.

Returns

ConnectedExtension[]

Defined in

packages/framework/esm-react-utils/src/useConnectedExtensions.ts:15


useExtensionSlotMeta

useExtensionSlotMeta<T>(extensionSlotName): Object

Extract meta data from all extension for a given extension slot.

Type parameters

Name Type
T ExtensionMeta

Parameters

Name Type
extensionSlotName string

Returns

Object

Defined in

packages/framework/esm-react-utils/src/useExtensionSlotMeta.ts:10


useExtensionStore

Const useExtensionStore(): T

Returns

T

Defined in

packages/framework/esm-react-utils/src/useExtensionStore.ts:5

Const useExtensionStore(actions): T & BoundActions

Parameters

Name Type
actions Actions

Returns

T & BoundActions

Defined in

packages/framework/esm-react-utils/src/useExtensionStore.ts:5

Const useExtensionStore(actions?): T & BoundActions

Parameters

Name Type
actions? Actions

Returns

T & BoundActions

Defined in

packages/framework/esm-react-utils/src/useExtensionStore.ts:5


Framework Functions

getAsyncExtensionLifecycle

Const getAsyncExtensionLifecycle<T>(lazy, options): () => Promise<ReactAppOrParcel<any>>

deprecated Use getAsyncLifecycle instead.

Type parameters

Name
T

Parameters

Name Type
lazy () => Promise<{ default: ComponentType<T> }>
options ComponentDecoratorOptions

Returns

fn

▸ (): Promise<ReactAppOrParcel<any>>

Returns

Promise<ReactAppOrParcel<any>>

Defined in

packages/framework/esm-react-utils/src/getLifecycle.ts:39


getAsyncLifecycle

getAsyncLifecycle<T>(lazy, options): () => Promise<ReactAppOrParcel<any>>

Type parameters

Name
T

Parameters

Name Type
lazy () => Promise<{ default: ComponentType<T> }>
options ComponentDecoratorOptions

Returns

fn

▸ (): Promise<ReactAppOrParcel<any>>

Returns

Promise<ReactAppOrParcel<any>>

Defined in

packages/framework/esm-react-utils/src/getLifecycle.ts:21


getLifecycle

getLifecycle<T>(Component, options): ReactAppOrParcel<any>

Type parameters

Name
T

Parameters

Name Type
Component ComponentType<T>
options ComponentDecoratorOptions

Returns

ReactAppOrParcel<any>

Defined in

packages/framework/esm-react-utils/src/getLifecycle.ts:10


getSyncLifecycle

getSyncLifecycle<T>(Component, options): () => Promise<ReactAppOrParcel<any>>

Type parameters

Name
T

Parameters

Name Type
Component ComponentType<T>
options ComponentDecoratorOptions

Returns

fn

▸ (): Promise<ReactAppOrParcel<any>>

Returns

Promise<ReactAppOrParcel<any>>

Defined in

packages/framework/esm-react-utils/src/getLifecycle.ts:29


Navigation Functions

interpolateString

interpolateString(template, params): string

Interpolates values of params into the template string.

Useful for additional template parameters in URLs.

Example usage:

navigate({
 to: interpolateString(
   config.links.patientChart,
   { patientUuid: patient.uuid }
 )
});

Parameters

Name Type Description
template string With optional params wrapped in ${ }
params object Values to interpolate into the string template

Returns

string

Defined in

packages/framework/esm-config/src/navigation/interpolate-string.ts:41


interpolateUrl

interpolateUrl(template): string

Interpolates a string with openmrsBase and openmrsSpaBase.

Useful for accepting ${openmrsBase} or ${openmrsSpaBase} template parameters in configurable URLs.

Parameters

Name Type Description
template string A string to interpolate

Returns

string

Defined in

packages/framework/esm-config/src/navigation/interpolate-string.ts:15


navigate

navigate(to): void

Calls location.assign for non-SPA paths and navigateToUrl for SPA paths

Example usage:

const config = getConfig();
const submitHandler = () => {
  navigate({ to: config.links.submitSuccess });
};

Parameters

Name Type Description
to NavigateOptions The target path or URL. Supports templating with 'openmrsBase' and 'openmrsSpaBase'. For example, ${openmrsSpaBase}/home will resolve to /openmrs/spa/home for implementations using the standard OpenMRS and SPA base paths.

Returns

void

Defined in

packages/framework/esm-config/src/navigation/navigate.ts:29


Offline Functions

beginEditSynchronizationItem

beginEditSynchronizationItem(id): Promise<void>

Triggers an edit flow for the given synchronization item. If this is not possible, throws an error.

Parameters

Name Type Description
id number The ID of the synchronization item to be edited.

Returns

Promise<void>

Defined in

packages/framework/esm-offline/src/sync.ts:355


canBeginEditSynchronizationItemsOfType

canBeginEditSynchronizationItemsOfType(type): boolean

Returns whether editing synchronization items of the given type is supported by the currently registered synchronization handlers.

Parameters

Name Type Description
type string The identifying type of the synchronization item which should be edited.

Returns

boolean

Defined in

packages/framework/esm-offline/src/sync.ts:345


deleteSynchronizationItem

deleteSynchronizationItem(id): Promise<void>

Deletes a queued up sync item with the given ID.

Parameters

Name Type Description
id number The ID of the synchronization item to be deleted.

Returns

Promise<void>

Defined in

packages/framework/esm-offline/src/sync.ts:375


generateOfflineUuid

generateOfflineUuid(): string

Generates a UUID-like string which is used for uniquely identifying objects while offline.

Returns

string

Defined in

packages/framework/esm-offline/src/uuid.ts:7


getCurrentOfflineMode

getCurrentOfflineMode(): OfflineModeResult

Returns

OfflineModeResult

Defined in

packages/framework/esm-offline/src/mode.ts:49


getOfflinePatientDataStore

getOfflinePatientDataStore(): Store<OfflinePatientDataSyncStore>

Returns

Store<OfflinePatientDataSyncStore>

Defined in

packages/framework/esm-offline/src/offline-patient-data.ts:86


getSynchronizationItem

getSynchronizationItem<T>(id): Promise<SyncItem<T> | undefined>

Returns a queued sync item with the given ID or undefined if no such item exists.

Type parameters

Name Type
T any

Parameters

Name Type Description
id number The ID of the requested sync item.

Returns

Promise<SyncItem<T> | undefined>

Defined in

packages/framework/esm-offline/src/sync.ts:334


getSynchronizationItems

getSynchronizationItems<T>(type): Promise<T[]>

Returns all currently queued up sync items of the currently signed in user.

Type parameters

Name
T

Parameters

Name Type Description
type string The identifying type of the synchronization items to be returned.

Returns

Promise<T[]>

Defined in

packages/framework/esm-offline/src/sync.ts:325


isOfflineUuid

isOfflineUuid(uuid): boolean

Checks whether the given string has the format of an offline UUID generated by generateOfflineUuid

Parameters

Name Type
uuid string

Returns

boolean

Defined in

packages/framework/esm-offline/src/uuid.ts:12


loadPersistedPatientDataSyncState

loadPersistedPatientDataSyncState(): Promise<void>

Returns

Promise<void>

Defined in

packages/framework/esm-offline/src/offline-patient-data.ts:200


messageOmrsServiceWorker

messageOmrsServiceWorker(message): Promise<MessageServiceWorkerResult<any>>

Sends the specified message to the application's service worker.

Parameters

Name Type Description
message KnownOmrsServiceWorkerMessages The message to be sent.

Returns

Promise<MessageServiceWorkerResult<any>>

A promise which completes when the message has been successfully processed by the Service Worker.

Defined in

packages/framework/esm-offline/src/service-worker-messaging.ts:11


queueSynchronizationItem

queueSynchronizationItem<T>(type, content, descriptor?): Promise<number>

Enqueues a new item in the sync queue and associates the item with the currently signed in user.

Type parameters

Name
T

Parameters

Name Type Description
type string The identifying type of the synchronization item.
content T The actual data to be synchronized.
descriptor? QueueItemDescriptor An optional descriptor providing additional metadata about the sync item.

Returns

Promise<number>

Defined in

packages/framework/esm-offline/src/sync.ts:293


registerOfflinePatientHandler

registerOfflinePatientHandler(identifier, handler): void

Attempts to add the specified patient handler registration to the list of offline patient handlers.

Parameters

Name Type Description
identifier string A key which uniquely identifies the registration.
handler OfflinePatientDataSyncHandler The patient handler registration to be registered.

Returns

void

true if the registration was successfully made; false if another registration with the same identifier has already been registered before.

Defined in

packages/framework/esm-offline/src/offline-patient-data.ts:97


setupOfflineSync

setupOfflineSync<T>(type, dependsOn, process, options?): void

Registers a new synchronization handler which is able to synchronize data of a specific type.

Type parameters

Name
T

Parameters

Name Type Description
type string The identifying type of the synchronization items which can be handled by this handler.
dependsOn string[] An array of other sync item types which must be synchronized before this handler can synchronize its own data. Items of these types are effectively dependencies of the data synchronized by this handler.
process ProcessSyncItem<T> A function which, when invoked, performs the actual client-server synchronization of the given item (which is the actual data to be synchronized).
options SetupOfflineSyncOptions<T> Additional options which can optionally be provided when setting up a synchronization callback for a specific synchronization item type.

Returns

void

Defined in

packages/framework/esm-offline/src/sync.ts:390


subscribeConnectivity

subscribeConnectivity(cb): () => void

Parameters

Name Type
cb (ev: ConnectivityChangedEvent) => void

Returns

fn

▸ (): void

Returns

void

Defined in

packages/framework/esm-globals/src/events.ts:24


subscribeConnectivityChanged

subscribeConnectivityChanged(cb): () => void

Parameters

Name Type
cb (ev: ConnectivityChangedEvent) => void

Returns

fn

▸ (): void

Returns

void

Defined in

packages/framework/esm-globals/src/events.ts:14


subscribePrecacheStaticDependencies

subscribePrecacheStaticDependencies(cb): () => void

Parameters

Name Type
cb (data: PrecacheStaticDependenciesEvent) => void

Returns

fn

▸ (): void

Returns

void

Defined in

packages/framework/esm-globals/src/events.ts:45


syncOfflinePatientData

syncOfflinePatientData(patientUuid): Promise<void>

Notifies all registered offline patient handlers that a new patient must be made available offline.

Parameters

Name Type
patientUuid string

Returns

Promise<void>

A promise which resolves once all registered handlers have finished synchronizing.

Defined in

packages/framework/esm-offline/src/offline-patient-data.ts:112


useConnectivity

useConnectivity(): boolean

Returns

boolean

Defined in

packages/framework/esm-react-utils/src/useConnectivity.ts:5


Store Functions

createGlobalStore

createGlobalStore<TState>(name, initialState): Store<TState>

Creates a Unistore store.

Type parameters

Name
TState

Parameters

Name Type Description
name string A name by which the store can be looked up later. Must be unique across the entire application.
initialState TState An object which will be the initial state of the store.

Returns

Store<TState>

The newly created store.

Defined in

packages/framework/esm-state/src/state.ts:19


createUseStore

createUseStore<T>(store): () => T(actions: Actions) => T & BoundActions(actions?: Actions) => T & BoundActions

Avoid this; generally prefer to have clients use useStore(yourStore)

Type parameters

Name
T

Parameters

Name Type
store Store<T>

Returns

fn

▸ (): T

Returns

T

▸ (actions): T & BoundActions

Parameters
Name Type
actions Actions
Returns

T & BoundActions

▸ (actions?): T & BoundActions

Parameters
Name Type
actions? Actions
Returns

T & BoundActions

Defined in

packages/framework/esm-react-utils/src/createUseStore.ts:23


getAppState

getAppState(): Store<AppState>

Returns

Store<AppState>

The store named app.

Defined in

packages/framework/esm-state/src/state.ts:86


getGlobalStore

getGlobalStore<TState>(name, fallbackState?): Store<TState>

Returns the existing store named name, or creates a new store named name if none exists.

Type parameters

Name Type
TState any

Parameters

Name Type Description
name string The name of the store to look up.
fallbackState? TState The initial value of the new store if no store named name exists.

Returns

Store<TState>

The found or newly created store.

Defined in

packages/framework/esm-state/src/state.ts:56


subscribeTo

subscribeTo<T, U>(store, select, handle): Unsubscribe

Type parameters

Name
T
U

Parameters

Name Type
store Store<T>
select (state: T) => U
handle (subState: U) => void

Returns

Unsubscribe

Defined in

packages/framework/esm-state/src/state.ts:90


useStore

useStore<T, U>(store): T

Type parameters

Name
T
U

Parameters

Name Type
store Store<T>

Returns

T

Defined in

packages/framework/esm-react-utils/src/useStore.ts:23

useStore<T, U>(store, select): U

Type parameters

Name
T
U

Parameters

Name Type
store Store<T>
select (state: T) => U

Returns

U

Defined in

packages/framework/esm-react-utils/src/useStore.ts:24

useStore<T, U>(store, select, actions): T & BoundActions

Type parameters

Name
T
U

Parameters

Name Type
store Store<T>
select undefined
actions Actions

Returns

T & BoundActions

Defined in

packages/framework/esm-react-utils/src/useStore.ts:25

useStore<T, U>(store, select, actions): U & BoundActions

Type parameters

Name
T
U

Parameters

Name Type
store Store<T>
select (state: T) => U
actions Actions

Returns

U & BoundActions

Defined in

packages/framework/esm-react-utils/src/useStore.ts:30


useStoreWithActions

useStoreWithActions<T>(store, actions): T & BoundActions

Type parameters

Name
T

Parameters

Name Type
store Store<T>
actions Actions

Returns

T & BoundActions

Defined in

packages/framework/esm-react-utils/src/useStore.ts:52


UI Functions

showModal

showModal(extensionId, props?, onClose?): () => void

Shows the provided extension component in a modal dialog.

Parameters

Name Type Description
extensionId string The id of the extension to show.
props Record<string, any> The optional props to provide to the extension.
onClose () => void The optional notification to receive when the modal is closed.

Returns

fn

The dispose function to force closing the modal dialog.

▸ (): void

Returns

void

Defined in

packages/framework/esm-styleguide/src/modals/index.tsx:164


showNotification

showNotification(notification): void

Displays an inline notification in the UI.

Parameters

Name Type Description
notification NotificationDescriptor The description of the notification to display.

Returns

void

Defined in

packages/framework/esm-styleguide/src/notifications/index.tsx:41


showToast

showToast(toast): void

Displays a toast notification in the UI.

Parameters

Name Type Description
toast ToastDescriptor The description of the toast to display.

Returns

void

Defined in

packages/framework/esm-styleguide/src/toasts/index.tsx:35


subscribeNotificationShown

subscribeNotificationShown(cb): () => void

Parameters

Name Type
cb (data: ShowNotificationEvent) => void

Returns

fn

▸ (): void

Returns

void

Defined in

packages/framework/esm-globals/src/events.ts:93


subscribeToastShown

subscribeToastShown(cb): () => void

Parameters

Name Type
cb (data: ShowToastEvent) => void

Returns

fn

▸ (): void

Returns

void

Defined in

packages/framework/esm-globals/src/events.ts:102


useBodyScrollLock

useBodyScrollLock(active): void

Parameters

Name Type
active boolean

Returns

void

Defined in

packages/framework/esm-react-utils/src/useBodyScrollLock.ts:4


useLayoutType

useLayoutType(): LayoutType

Returns

LayoutType

Defined in

packages/framework/esm-react-utils/src/useLayoutType.ts:23


useOnClickOutside

useOnClickOutside<T>(handler, active?): RefObject<T>

Type parameters

Name Type
T extends HTMLElement = HTMLElement

Parameters

Name Type Default value
handler (event: Event) => void undefined
active boolean true

Returns

RefObject<T>

Defined in

packages/framework/esm-react-utils/src/useOnClickOutside.tsx:4


usePagination

usePagination<T>(data?, resultsPerPage?): Object

Type parameters

Name
T

Parameters

Name Type Default value
data T[] []
resultsPerPage number defaultResultsPerPage

Returns

Object

Name Type
currentPage number
paginated boolean
results T[]
showNextButton boolean
showPreviousButton boolean
totalPages number
goTo (page: number) => void
goToNext () => void
goToPrevious () => void

Defined in

packages/framework/esm-react-utils/src/usePagination.ts:6


Utility Functions

age

age(dateString): string

Gets a human readable age represention of the provided date string.

Parameters

Name Type Description
dateString string The stringified date.

Returns

string

A human-readable string version of the age.

Defined in

packages/framework/esm-utils/src/age-helpers.tsx:39


daysIntoYear

daysIntoYear(date): number

Gets the number of days in the year of the given date.

Parameters

Name Type Description
date Date The date to compute the days within the year.

Returns

number

The number of days.

Defined in

packages/framework/esm-utils/src/age-helpers.tsx:8


isSameDay

isSameDay(firstDate, secondDate): boolean

Checks if two dates are representing the same day.

Parameters

Name Type Description
firstDate Date The first date.
secondDate Date The second date.

Returns

boolean

True if both are located on the same day.

Defined in

packages/framework/esm-utils/src/age-helpers.tsx:25


isVersionSatisfied

isVersionSatisfied(requiredVersion, installedVersion): boolean

Parameters

Name Type
requiredVersion string
installedVersion string

Returns

boolean

Defined in

packages/framework/esm-utils/src/version.ts:22


retry

retry<T>(fn, options?): Promise<T>

Executes the specified function and retries executing on failure with a custom backoff strategy defined by the options.

If not configured otherwise, this function uses the following default options:

  • Retries 5 times beyond the initial attempt.
  • Uses an exponential backoff starting with an initial delay of 1000ms.

throws Rethrows the final error of running fn when the function stops retrying.

Type parameters

Name
T

Parameters

Name Type Description
fn () => Promise<T> The function to be executed and retried on failure.
options RetryOptions Additional options which configure the retry behavior.

Returns

Promise<T>

The result of successfully executing fn.

Defined in

packages/framework/esm-utils/src/retry.ts:40


translateFrom

translateFrom(moduleName, key, fallback?, options?): string

Parameters

Name Type
moduleName string
key string
fallback? string
options? object

Returns

string

Defined in

packages/framework/esm-utils/src/translate.ts:4