Skip to main content

Class: WorkflowExperienceImpl

A Workflow experience encapsulates the workflow manager and command context. It provides a simplified interface for interacting with the workflow manager. You should get an instance of this class from a Client you have constructed previously.

Implements​

Constructors​

Constructor​

new WorkflowExperienceImpl(client, experienceOptions): WorkflowExperienceImpl

Parameters​

client​

SpiffCommerceClient

experienceOptions​

ExperienceOptions

Returns​

WorkflowExperienceImpl

Properties​

cachedStepHandles​

readonly cachedStepHandles: Map<string, StepHandle<any>>


client​

readonly client: SpiffCommerceClient


debouncedSavedDesignUpdate​

debouncedSavedDesignUpdate: DebouncedFunc<() => Promise<void>>


graphQlClient​

readonly graphQlClient: GraphQlClientFunc


isReadOnly​

readonly isReadOnly: boolean


transaction​

readonly transaction: Transaction


workflowManager​

readonly workflowManager: WorkflowManager

Methods​

addEventListener()​

addEventListener(type, callback): void

Registers a callback function to be called when the specified event is raised. TODO: We should include a second param to pass information about the event?

Parameters​

type​

WorkflowExperienceEventType

The type of event to listen for.

callback​

(workflowExperience) => void

The function to call when the event occurs.

Returns​

void

Implementation of​

WorkflowExperience.addEventListener


assignCustomerDetails()​

assignCustomerDetails(details): Promise<void>

Attach specific details about the customer to the experience. This is useful for things like retargeting. From SpiffCommerce hosted experiences these details will be attached whenever the customer has provided & given permission.

Parameters​

details​

CustomerDetailsInput

The new customer details.

Returns​

Promise<void>

Implementation of​

WorkflowExperience.assignCustomerDetails


assignCustomerInternal()​

assignCustomerInternal(customer): void

Parameters​

customer​

Customer

Returns​

void


attachAddress()​

attachAddress(streetAddress?, apartment?, city?, country?, state?, postCode?): Promise<void>

Parameters​

streetAddress?​

string

apartment?​

string

city?​

string

country?​

string

state?​

string

postCode?​

string

Returns​

Promise<void>

Implementation of​

WorkflowExperience.attachAddress


attachCustomerDetails()​

attachCustomerDetails(details): Promise<void>

Attach specific details about the customer to the experience. This is useful for things like retargeting. Currently only email is supported. From SpiffCommerce hosted experiences these details will be attached whenever the customer has provided & given permission.

Parameters​

details​

The new customer details. Only email is supported.

email​

string

Returns​

Promise<void>

Deprecated​

Use assignCustomerDetails instead.

Implementation of​

WorkflowExperience.attachCustomerDetails


attachOrganization()​

attachOrganization(name): Promise<void>

Parameters​

name​

string

Returns​

Promise<void>

Implementation of​

WorkflowExperience.attachOrganization


attachRenderableSceneListener()​

attachRenderableSceneListener(cb): void

Attaches a listener to the scenes on a workflow experience. The scenes returned are a subset of the scenes configured in the workflow and are based on the current state of the experience. This is useful for building a navigation menu.

Parameters​

cb​

(scenes) => void

The callback to be called when the scenes change. The new scenes are passed as an argument.

Returns​

void

Implementation of​

WorkflowExperience.attachRenderableSceneListener


callEvent()​

callEvent(type): void

Parameters​

type​

WorkflowExperienceEventType

Returns​

void

Implementation of​

WorkflowExperience.callEvent


checkForPriceBreakChanges()​

checkForPriceBreakChanges(): void

Calculates the price break and fires the "PriceBreakChanged" event if required. This function is primarily intended for internal use.

Returns​

void

Implementation of​

WorkflowExperience.checkForPriceBreakChanges


clearProduct()​

clearProduct(): Promise<void>

Clear the product from this experience.

Returns​

Promise<void>

Implementation of​

WorkflowExperience.clearProduct


copy()​

copy(): Promise<WorkflowExperience>

Returns a copy of the currently loaded design as a new, seperated workflow experience with a fresh transaction.

Returns​

Promise<WorkflowExperience>

Implementation of​

WorkflowExperience.copy


copySelectionsViaGlobalConfiguration()​

copySelectionsViaGlobalConfiguration(bundle, experience, filter?): Promise<void>

Takes selections made by the user in another workflow and applies them to this workflow. For selections to be copied they must both have a matching global property configuration.

Parameters​

bundle​

Bundle

experience​

WorkflowExperience

The experience to take selections from.

filter?​

StepHandle<AnyStepData>[]

A list of steps to apply the selections to. If undefined all steps will be updated.

Returns​

Promise<void>

Implementation of​

WorkflowExperience.copySelectionsViaGlobalConfiguration


createPreviewImage()​

createPreviewImage(isThreeD?, resolution?): Promise<string>

Creates a data URL preview for the current design.

Parameters​

isThreeD?​

boolean

resolution?​

number

Returns​

Promise<string>

Implementation of​

WorkflowExperience.createPreviewImage


detachRenderableSceneListener()​

detachRenderableSceneListener(cb): void

Detaches a listener from the scenes on a workflow experience.

Parameters​

cb​

(scenes) => void

Returns​

void

Implementation of​

WorkflowExperience.detachRenderableSceneListener


getAdditionalProductPriceSubunits()​

getAdditionalProductPriceSubunits(disablePriceBreaks?): number | undefined

If an additional product is configured, returns the base price of that product. Returns undefined otherwise.

Parameters​

disablePriceBreaks?​

boolean

Whether to exclude price breaks from the calculation.

Returns​

number | undefined

Implementation of​

WorkflowExperience.getAdditionalProductPriceSubunits


getBasePriceSubunits()​

getBasePriceSubunits(includeAdditionalProduct?, disablePriceBreaks?): number

Returns the total cost in subunits for the base product.

Parameters​

includeAdditionalProduct?​

boolean

When true the additional product cost will be included in the total (if configured).

disablePriceBreaks?​

boolean

Whether to exclude price breaks from the calculation.

Returns​

number

Implementation of​

WorkflowExperience.getBasePriceSubunits


getBundle()​

getBundle(): Bundle | undefined

Get the bundle this experience is part of. May be undefined.

Returns​

Bundle | undefined

Implementation of​

WorkflowExperience.getBundle


getClient()​

getClient(): SpiffCommerceClient

Returns the client that was responsible for spawning this experience.

Returns​

SpiffCommerceClient

Implementation of​

WorkflowExperience.getClient


getCommandContext()​

getCommandContext(): CommandContext

State related to the design of the user.

Returns​

CommandContext

Implementation of​

WorkflowExperience.getCommandContext


getExportedStepData()​

getExportedStepData(): Promise<ExportedStepData[]>

Returns the metadata associated with this workflow experience. This is a combination of the metadata from the workflow, and the selections made by the user.

Returns​

Promise<ExportedStepData[]>

An array of ExportedStepData objects, each containing the step ID, title, and properties.

Implementation of​

WorkflowExperience.getExportedStepData


getIsReadOnly()​

getIsReadOnly(): boolean

Returns true when the user may only view the design.

Returns​

boolean

Implementation of​

WorkflowExperience.getIsReadOnly


getProduct()​

getProduct(): Product | undefined

Get the current product for this experience. May be undefined.

Returns​

Product | undefined

Implementation of​

WorkflowExperience.getProduct


getProfanityList()​

getProfanityList(): string[]

Get the current profanity list for this experience. May be empty.

Returns​

string[]

Implementation of​

WorkflowExperience.getProfanityList


getQuantity()​

getQuantity(): number

Get the quantity of this WorkflowExperience's Transaction.

Returns​

number

The amount that was, or will be, ordered.

Implementation of​

WorkflowExperience.getQuantity


getScenes()​

getScenes(): Scene[]

Returns a list of scenes that are configured in the workflow. Each scene contains a list of steps. See getStepsByScene to access these.

Returns​

Scene[]

Implementation of​

WorkflowExperience.getScenes


getSelectionPriceSubunits()​

getSelectionPriceSubunits(disablePriceBreaks?): number

Returns the total cost in subunits for all selections made on the design.

Parameters​

disablePriceBreaks?​

boolean

Whether to exclude price breaks from the calculation.

Returns​

number

Implementation of​

WorkflowExperience.getSelectionPriceSubunits


getSilentStepFailures()​

getSilentStepFailures(): SilentStepRedrawError | undefined

The silent steps (Product Overlay, Silent Illustration) which could not be drawn by the most recent background draw, or undefined if everything was drawn. The draw starts after each updateWorkflowConfiguration resolves, so this can briefly show the previous result. Failed steps are retried by every later update, and this is cleared as soon as a draw succeeds for them all. Listen for WorkflowExperienceEventType.SilentStepsFailed to be told when this changes to a failure.

Returns​

SilentStepRedrawError | undefined

Implementation of​

WorkflowExperience.getSilentStepFailures


getStepById()​

getStepById(id): StepHandle<any> | undefined

Returns the step matching a given name, undefined if not found.

Parameters​

id​

string

The id the step must match.

Returns​

StepHandle<any> | undefined

Implementation of​

WorkflowExperience.getStepById


getStepByName()​

getStepByName(name): IllustrationStepHandle | MaterialStepHandle | ModelStepHandle | PictureStepHandle | QuestionStepHandle | ShapeStepHandle | TextStepHandle | InformationStepHandle | DigitalContentStepHandle | ModuleStepHandle | ProductStepHandle | FrameStepHandle | undefined

Returns the step matching a given name, undefined if not found.

Parameters​

name​

string

The name the step must match.

Returns​

IllustrationStepHandle | MaterialStepHandle | ModelStepHandle | PictureStepHandle | QuestionStepHandle | ShapeStepHandle | TextStepHandle | InformationStepHandle | DigitalContentStepHandle | ModuleStepHandle | ProductStepHandle | FrameStepHandle | undefined

Implementation of​

WorkflowExperience.getStepByName


getSteps()​

getSteps(): StepHandle<AnyStepData>[]

Returns all steps in the workflow. Ordered by scene and appearance within their respective scenes.

Returns​

StepHandle<AnyStepData>[]

Implementation of​

WorkflowExperience.getSteps


getStepsByScene()​

getStepsByScene(scene): StepHandle<AnyStepData>[]

Returns all steps that are children of a given scene.

Parameters​

scene​

Scene

The scene you want the steps for.

Returns​

StepHandle<AnyStepData>[]

Implementation of​

WorkflowExperience.getStepsByScene


getStepsByType()​

getStepsByType(type): StepHandle<AnyStepData>[]

Returns all steps matching a specific type in the workflow. These steps may be across multiple scenes and may or may not be active based on condition state.

Parameters​

type​

StepType

Returns​

StepHandle<AnyStepData>[]

Implementation of​

WorkflowExperience.getStepsByType


getStepsConditionallyActive()​

getStepsConditionallyActive(): Promise<StepHandle<AnyStepData>[]>

Returns all steps in the workflow that are conditionally active. Ordered by scene and appearance within their respective scenes.

Returns​

Promise<StepHandle<AnyStepData>[]>

Implementation of​

WorkflowExperience.getStepsConditionallyActive


getTotalPriceSubunits()​

getTotalPriceSubunits(disablePriceBreaks?): number

A convenience function returning the sum of the selection and base price values.

Parameters​

disablePriceBreaks?​

boolean

Whether to exclude price breaks from the calculation.

Returns​

number

Implementation of​

WorkflowExperience.getTotalPriceSubunits


getTransaction()​

getTransaction(): Transaction

Get the current transaction for this experience.

Returns​

Transaction

Implementation of​

WorkflowExperience.getTransaction


getWorkflow()​

getWorkflow(): Workflow | undefined

Get the current workflow for this experience. May be undefined.

Returns​

Workflow | undefined

Implementation of​

WorkflowExperience.getWorkflow


getWorkflowManager()​

getWorkflowManager(): WorkflowManager

Get the low level workflow amanager instance for this experience. Don't touch this unless you're willing to break things.

Returns​

WorkflowManager

Implementation of​

WorkflowExperience.getWorkflowManager


onDesignFinished()​

onDesignFinished(capturePreviewImage?): Promise<DesignCreationMessage>

To be called when the workflow experience is considered completed by the user.

Parameters​

capturePreviewImage?​

boolean = true

When true a preview image will be generated for the design. Defaults to true.

Returns​

Promise<DesignCreationMessage>

Implementation of​

WorkflowExperience.onDesignFinished


priceBreakToBeApplied()​

priceBreakToBeApplied(): number

The price break percentage that is expected to be applied in price calculations.

Returns​

number

Implementation of​

WorkflowExperience.priceBreakToBeApplied


removeEventListener()​

removeEventListener(type, callback): void

Removes a previously registered callback.

Parameters​

type​

WorkflowExperienceEventType

The type of event.

callback​

(workflowExperience) => void

The function to remove.

Returns​

void

Implementation of​

WorkflowExperience.removeEventListener


save()​

save(title?): Promise<SavedDesign>

Saves this experience to storage. This may be local or remote depending on configuration.

Parameters​

title?​

string

The title for the saved design.

Returns​

Promise<SavedDesign>

Implementation of​

WorkflowExperience.save


setBundle()​

setBundle(bundle): void

Set the bundle this experience is part of. Can be cleared using undefined.

Parameters​

bundle​

Bundle

Returns​

void

Implementation of​

WorkflowExperience.setBundle


setProduct()​

setProduct(integrationProductId): Promise<void>

Set the current product for this experience.

Parameters​

integrationProductId​

string

Returns​

Promise<void>

Implementation of​

WorkflowExperience.setProduct


setQuantity()​

setQuantity(quantity): Promise<void>

Sets the quantity of this WorkflowExperience's Transaction.

Parameters​

quantity​

number

The amount that was, or will be, ordered.

Returns​

Promise<void>

A promise that resolves when the Transaction has been updated on the server.

Throws​

if the WorkflowExperience is read-only.

Throws​

if the value is below 1.

Implementation of​

WorkflowExperience.setQuantity


setWorkflow()​

setWorkflow(workflow): Promise<void>

Set the current workflow for this experience.

Parameters​

workflow​

Workflow

The new workflow to set.

Returns​

Promise<void>

Implementation of​

WorkflowExperience.setWorkflow


updateWorkflowConfiguration()​

updateWorkflowConfiguration(changes): Promise<void>

Updates the workflow configuration dynamically and regenerates affected structures. This allows for runtime changes to scenes, steps, panels, and their configurations.

Resolves as soon as the configuration has changed and the preview is updated. Silent steps (Product Overlay, Silent Illustration) are drawn afterwards in the background and appear when ready, so a slow image never holds up the update. Use WorkflowExperienceEventType.SilentStepsFailed to be told if any could not be drawn.

Parameters​

changes​

WorkflowUpdateRequest

Workflow update request specifying which items were added, changed, or removed

Returns​

Promise<void>

Implementation of​

WorkflowExperience.updateWorkflowConfiguration