API reference

Every export of @epilot/spark-sdk at a glance.

A complete map of the public surface. Follow the links for usage and examples.

Session & bridge

ExportSignatureDescription
initialize(options?: InitOptions) => Promise<SparkSession>Connect to the parent portal; resolves to the session. Idempotent.
getSession() => SparkSessionThe current session. Throws if not yet initialized.
isInitialized() => booleanWhether a session exists.
updateContentHeight(height: number) => voidReport content height so the portal resizes the iframe.
updateContentSize(size: { height?: number; width?: number }) => voidReport width and/or height.

Session & bridge

Entities

ExportSignatureDescription
getEntity(params: EntityGetParams) => Promise<EntityItem | undefined>Fetch one entity for the portal user.
searchEntities(params: EntitySearchParams) => Promise<EntityResponseWithHits>Search entities for the portal user.
getPortalClient() => ClientThe configured customer-portal client for operations the SDK doesn't wrap.

Entities

Use cases

ExportSignatureDescription
executeUseCase(params: ExecuteUseCaseParams) => Promise<ExecuteUseCaseResult>Run an Integration Hub use case via the portal proxy.

Use cases

Localization & custom events

ExportSignatureDescription
onLocaleUpdate(handler: (lang: string) => void) => UnsubscribeReact to portal language changes.
on<T>(event: string, handler: MessageHandler<T>) => UnsubscribeSubscribe to messages from the portal (supports *).
send(event: string, data?: Record<string, unknown>) => voidSend a message to the portal.

Localization · Custom events

Theming

ExportSignatureDescription
injectCSSVariables(css: string) => booleanInject/replace the portal theme <style>.
removeCSSVariables() => voidRemove the injected theme styles.
setThemeClass(theme: 'light' | 'dark') => voidSet the light/dark class on <html>.
removeThemeClass() => voidRemove both theme classes.

Theming

Low-level messaging

ExportDescription
sendMessageToParentPost a raw message to window.parent.
subscribeToParentMessagesListen for matching parent messages; returns an unsubscribe fn.
setTrustedParentOriginsRestrict trusted inbound/outbound origins.
SPARK_BRIDGE_SOURCEThe source tag stamped on outbound messages ('spark-bridge').

Custom events

Errors

ExportDescription
SparkErrorBase class for all SDK errors.
SparkTimeoutErrorA bridge request (or init) timed out.
SparkNotInitializedErrorUsed the SDK before initialize() resolved.

Errors

Types

TypeDescription
SparkSessionThe authenticated context: token, config, theme, lang…
InitOptionsOptions for initialize (timeout, apiBaseUrl, allowedParentOrigins).
RequestOptionsPer-request options (timeout).
ExecuteUseCaseParams / ExecuteUseCaseResultInput and result of executeUseCase.
MessageHandler<T>(data: T) => void event handler.
Unsubscribe() => void returned by subscriptions.
EntityItem, EntityGetParams, EntitySearchParams, EntityResponse, EntityResponseWithHits, EntitySlugEntity shapes re-exported from @epilot/customer-portal-client.

Session · Entities

Constants

ExportDescription
VERSIONThe SDK version string.

On this page