@spiffcommerce/core 14.2.1-alpha.0 → 14.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2385 @@
1
+ import { Workflow as _Workflow1, StepAspect as _StepAspect1, Step as _Step1, AnyStepData as _AnyStepData1, Asset as _Asset1, Region, VariantResource as _VariantResource1, FrameOffsets, PatternImageData, DigitalContentStepData as _DigitalContentStepData1, LayoutsState as _LayoutsState1, CanvasCommand as _CanvasCommand1, FrameStepData as _FrameStepData1, ILayout as _ILayout1, CreateElementCommand as _CreateElementCommand1, FrameElement as _FrameElement1, ColorDefinition as _ColorDefinition1, IllustrationStepData as _IllustrationStepData1, IllustrationElement as _IllustrationElement1, LayoutData as _LayoutData1, MaterialStepData as _MaterialStepData1, ModelStepData as _ModelStepData1, ModuleStepData as _ModuleStepData1, PictureStepData as _PictureStepData1, QuestionStepData as _QuestionStepData1, ShapeStepData as _ShapeStepData1, FontData, GroupCommand as _GroupCommand1, OptionResource as _OptionResource1, TextboxElement as _TextboxElement1, TextFillImage, TextStepData as _TextStepData1, StepStorage as _StepStorage1, SerializableStep, CommandState as _CommandState1, CommandContext as _CommandContext1, LayoutState, GlobalPropertyConfiguration, MaterialResource, AssetType as _AssetType1, Point, ScaleAxis, UnitOfMeasurement as _UnitOfMeasurement1, StepType as _StepType1, BulkStepData as _BulkStepData1, FrameData as _FrameData1, AspectType, GlobalPropertyConfigurationAspect, Theme as _Theme1, Animatable, AnyStepData, Asset, AssetType, BringForwardCommand, BringToFrontCommand, BringToBackCommand, BulkStepData, CanvasCommand, ColorDefinition, CommandContext, CommandState, CreateElementCommand, DeleteElementCommand, DigitalContentStepData, FontAlignmentCommand, FontColorCommand, FontSizeCommand, FontSourceCommand, FrameElement, FrameStepData, GroupCommand, ILayout, IllustrationElement, IllustrationStepData, ImageElement, LayoutData, LayoutElement, LayoutElementFactory, LayoutElementType, LayoutsState, MaterialStepData, ModelStepData, ModuleStepData, MoveCommand, OptionResource, PictureStepData, QuestionStepData, ResizeCommand, RotateCommand, SendBackwardsCommand, ShapeStepData, Step, StepAspect, StepAspectType, StepStorage, StepType, TextChangeCommand, TextStepData, TextboxElement, UnitOfMeasurement, VariantResource, Workflow, dataUrlFromExternalUrl, findElement, frameDataCache, generate, generateSVGWithUnknownColors, getAttributesFromArrayBuffer, getFrameData, getSvgElement, loadFontFromDataUrl, loadFontFromExternalUrl, patternImageDataCache, CreateLayoutCommand, rehydrateSerializedLayout, ColorProfileProps, WorkflowPanel, determineCorrectFontSizeAndLines, registerJSDOM, getAxisAlignedBoundingBox, Theme } from "@spiffcommerce/papyrus";
2
+ import { ApolloClient } from "@apollo/client";
3
+ import React, { ReactNode, Dispatch, FunctionComponent, RefObject, PointerEvent, KeyboardEvent } from "react";
4
+ export const gatherVaryingStepAspects: (workflow: _Workflow1) => _StepAspect1[];
5
+ /**
6
+ * A renderable scene is a scene that can be displayed to the user. This is based on the workflow state.
7
+ */
8
+ export interface RenderableScene {
9
+ /**
10
+ * The id of the scene.
11
+ */
12
+ id: string;
13
+ /**
14
+ * The title of the scene.
15
+ */
16
+ title: string;
17
+ /**
18
+ * The id of each step inside the scene that can be rendered. This is based on the workflow state.
19
+ */
20
+ renderableSteps: string[];
21
+ }
22
+ /**
23
+ * Information parsed froma workflow structure that is relevant
24
+ * to a given scene.
25
+ */
26
+ export interface WorkflowScene {
27
+ /**
28
+ * A unique identifier for the scene.
29
+ */
30
+ name: string;
31
+ /**
32
+ * A human-readable title for the scene.
33
+ */
34
+ title: string;
35
+ /**
36
+ * Steps which can display to the user.
37
+ * But may be conditionally hidden based on workflow logic
38
+ */
39
+ renderableSteps: _Step1<_AnyStepData1>[];
40
+ /**
41
+ * Steps which don't display to the user.
42
+ * Their behavior is always silent & executed in the background.
43
+ */
44
+ silentSteps: _Step1<_AnyStepData1>[];
45
+ }
46
+ /**
47
+ * A queue promise is a container for a promise that can be
48
+ * executed at a later time.
49
+ */
50
+ export abstract class QueueablePromise {
51
+ readonly timestamp: number;
52
+ abstract execute(): Promise<any>;
53
+ }
54
+ /**
55
+ * A promise queue contains any number of QueuePromise objects. These objects are stored within a PromiseQueue and executed
56
+ * as quickly as possible in order. This is ideal in situations where a specific operation should be
57
+ * applied in an ordered way while still making.
58
+ */
59
+ export class PromiseQueue<T extends QueueablePromise> {
60
+ /**
61
+ * Constructs a new promise queue.
62
+ * @param queueMaxSize An optional maximum size, when the max size is hit.
63
+ * The older promises will be discarded.
64
+ */
65
+ constructor(queueMaxSize?: number);
66
+ /**
67
+ * Enqueue a new promise.
68
+ * @param promise A new promise to add to the queue.
69
+ */
70
+ enqueue(promise: T): void;
71
+ /**
72
+ * @returns Returns true when work is being actively processed by this queue.
73
+ */
74
+ hasActivePromise(): boolean;
75
+ /**
76
+ * @returns The number of unexecuted jobs remaining in the queue. Not including the active job.
77
+ */
78
+ getRemainingQueueSize(): number;
79
+ /**
80
+ * Finalize the queue, any jobs that come in while this is in progress will result
81
+ * in the promise being extended.
82
+ */
83
+ finalize(): Promise<void>;
84
+ }
85
+ /**
86
+ * A generic base class for custom errors that assigns the name
87
+ * of the error class automatically. All custom errors should extend this.
88
+ */
89
+ declare abstract class CustomError extends Error {
90
+ constructor(message: any);
91
+ }
92
+ /**
93
+ * A custom class for categorising errors related to workflow configuration.
94
+ */
95
+ declare abstract class ConfigurationError extends CustomError {
96
+ constructor(message: any);
97
+ }
98
+ /**
99
+ * Thrown when an option was expected but not found in the workflow configuration or
100
+ * the server returned a 404 for an option we expected.
101
+ */
102
+ export class OptionNotFoundError extends ConfigurationError {
103
+ readonly optionId: string;
104
+ constructor(step: _Step1<_AnyStepData1>);
105
+ }
106
+ /**
107
+ * Thrown when a layout is not found for a given region entity. This
108
+ * can occur when panels are deleted from a workflow but steps are still relying
109
+ * on the layout being present.
110
+ */
111
+ export class LayoutNotFoundError extends ConfigurationError {
112
+ readonly panelId: string;
113
+ constructor(region: Region);
114
+ }
115
+ /**
116
+ * Thrown when an asset is not found on a specific variant. This can occur when
117
+ * the asset wasn't configured in hub and the variant is loaded in a workflow.
118
+ */
119
+ export class AssetNotFoundError extends ConfigurationError {
120
+ readonly variant: _VariantResource1;
121
+ constructor(variant: _VariantResource1);
122
+ }
123
+ /**
124
+ * Thrown when a resource is not found linked to a specific asset. This
125
+ * can occur when generation of a resource fails or hasn't completed. Or may be
126
+ * a sign of a misconfiguration.
127
+ */
128
+ export class ResourceNotFoundError extends ConfigurationError {
129
+ readonly asset: _Asset1;
130
+ constructor(asset: _Asset1);
131
+ }
132
+ /**
133
+ * Thrown when configuration is missing when it was expected. More generic
134
+ * to cover remaining cases outside of the more specific ones such as options, variants & assets.
135
+ */
136
+ export class MisconfigurationError extends ConfigurationError {
137
+ readonly step: _Step1<_AnyStepData1>;
138
+ constructor(step: _Step1<_AnyStepData1>, message: string);
139
+ }
140
+ /**
141
+ * A custom class for categorising errors related to implementation of core.
142
+ */
143
+ declare abstract class ImplementationError extends CustomError {
144
+ constructor(message: any);
145
+ }
146
+ /**
147
+ * Thrown when we hit a case that we didn't expect to happen
148
+ */
149
+ export class UnhandledBehaviorError extends ImplementationError {
150
+ constructor(message: string);
151
+ }
152
+ /**
153
+ * Thrown when we fail to parse something that we expected to be valid
154
+ */
155
+ export class ParseError extends ImplementationError {
156
+ constructor(message: string);
157
+ }
158
+ /**
159
+ * Bounds the offsets for an image to the box, preventing
160
+ * the user from moving the image in a way that wouldn't be intended.
161
+ * @param newOffsets The new intended offsets for the image.
162
+ * @param frameData The current frame information
163
+ * @param borderWidth The width of the border added by the cropper.
164
+ * @param mustCover When true the image sgould be bounded in such a way that it covers the entire frame at all times.
165
+ */
166
+ export function getBoundedOffsets(newOffsets: FrameOffsets, frameData: FrameData, imageData: PatternImageData, mustCover?: boolean): FrameOffsets;
167
+ export class FrameService {
168
+ /**
169
+ * The calculated minimum zoom value, per frame.
170
+ */
171
+ minZoomScale: number[];
172
+ /**
173
+ * The calculated maximum zoom value. Note: This is calculated based on the first frame.
174
+ */
175
+ maxZoomScale: number[];
176
+ constructor(forceImageCover?: boolean);
177
+ /**
178
+ * When we want to connect a workflow manager to the state of the image cropper we
179
+ * can pass it to this function. Inside we'll attach any required event listeners.
180
+ * @param workflowManager The workflow manager to attach.
181
+ * @param stepName The specific step we want to attach to within the manager.
182
+ */
183
+ connectWorkflowManager(workflowManager: WorkflowManager, stepName?: string): void;
184
+ /**
185
+ * Sets the elements that should be update when changes are made to
186
+ * the cropper that owns this service.
187
+ * @param targetElements A list of element Ids to track
188
+ */
189
+ setTargetElements(targetElements: string[]): void;
190
+ /**
191
+ * Gets the current calculated frame data
192
+ * @returns A FrameData object or undefined if no frame has been set.
193
+ */
194
+ getFrameData(): FrameData[] | undefined;
195
+ /**
196
+ * Sets the current frame data. Note:
197
+ * @param paths The paths to lookup in our frame data cache.
198
+ */
199
+ setFrameData(paths: string[] | undefined): void;
200
+ /**
201
+ * Gets the currently set image of the frame..
202
+ * @returns A PatternImageData object, or undefined if no image is set.
203
+ */
204
+ getImageData(): PatternImageData | undefined;
205
+ /**
206
+ * Gets the current calculated offsets of the pattern within the frame.
207
+ * @returns A FrameOffsets object or undefined if no offsets are defined.
208
+ */
209
+ getOffsets(): FrameOffsets[] | undefined;
210
+ /**
211
+ * Updates the frame offsets explicitly.
212
+ */
213
+ setOffsets(offsets: FrameOffsets[]): void;
214
+ /**
215
+ * Sets the zoom of the cropper that owns this service.
216
+ * @param zoom The new zoom value, per frame.
217
+ * @param cX The center of zoom on x axis, per frame.
218
+ * @param cY The center of zoom on Y axis, per frame.
219
+ * @param onComplete A function to call when zoom changes have been completed
220
+ */
221
+ setZoom(zoom: number[], cX: number[], cY: number[], onComplete?: () => void): void;
222
+ /**
223
+ * Sets the image currently contained by this frame.
224
+ * @param value The new image as an ImageData property
225
+ */
226
+ setPatternData(value: PatternImageData): void;
227
+ /**
228
+ * Modify the offsets of the frame.
229
+ * @param value The new FrameOffsets objects.
230
+ * @param onComplete A callback, called when the modification is complete
231
+ * @param forceUpdate When true the offsets will be updated even if they haven't changed.
232
+ */
233
+ updateOffsets(value: FrameOffsets[], onComplete?: () => void, forceUpdate?: boolean): void;
234
+ onFrameDataChanged(newListener: (frameData: FrameData[] | undefined) => void): void;
235
+ /**
236
+ * Append a new listener to zoom events on this frame.
237
+ * @param newListener
238
+ */
239
+ onZoom(newListener: (zoomValue: number[]) => void): void;
240
+ }
241
+ declare class Poller {
242
+ /**
243
+ * Constructs a new polling service.
244
+ * @param predicate An async function that returns true when polling has returned a successful result.
245
+ * @param onSuccess The callback to be called when polling has returned a successful result.
246
+ * @param onFailure The callback to be called when polling has returned a failed result.
247
+ * @param interval The number of milliseconds to wait between each poll.
248
+ * @param maxAttempts The maximum amount of times to check the condition.
249
+ */
250
+ constructor(predicate: () => Promise<boolean>, onSuccess: () => void, onFailure: () => void, interval?: number, maxAttempts?: number);
251
+ }
252
+ declare class Configuration {
253
+ constructor();
254
+ getServerUrl(): string;
255
+ getServicesApiUrl(): string;
256
+ getHubUrl(): string;
257
+ setServerUrl(serverUrl: string): void;
258
+ setServicesApiUrl(servicesApiUrl: string): void;
259
+ setHubUrl(hubUrl: string): void;
260
+ addServerUrlCallback(callback: () => void): void;
261
+ }
262
+ export const spiffCoreConfiguration: Configuration;
263
+ export const shortenUrl: (longUrl: string) => Promise<string>;
264
+ declare class DigitalContentStepService implements StepService<_DigitalContentStepData1> {
265
+ init(stepData: _Step1<_DigitalContentStepData1>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
266
+ regenerateQRCode(elements: RegionElement[], uploading: boolean, assetKey: string, url: string, workflowManager: WorkflowManager, stepData: _Step1<_DigitalContentStepData1>, setUrl: (finalUrl: string) => void, commandDispatcher: (command: _CanvasCommand1) => void, setIsRegenerating: (state: boolean) => void): Promise<void>;
267
+ }
268
+ export const digitalContentStepService: DigitalContentStepService;
269
+ interface FrameCreateOpts {
270
+ stepName?: string;
271
+ frameData: FrameData;
272
+ disablePlaceholder?: boolean;
273
+ focalBlur?: boolean;
274
+ focalBlurStrength?: number;
275
+ focalBlurRadius?: number;
276
+ pattern?: any;
277
+ }
278
+ declare class FrameStepService implements StepService<_FrameStepData1> {
279
+ init(stepData: _Step1<_FrameStepData1>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
280
+ selectImage(stepData: _Step1<_FrameStepData1>, asset: _Asset1, workflowManager: WorkflowManager): void;
281
+ selectVariant(stepData: _Step1<_FrameStepData1>, variant: _VariantResource1 | undefined, elements: RegionElement[], workflowManager: WorkflowManager, setFrameIsUpdating?: (status: boolean) => void): Promise<void>;
282
+ getCreateElementCommand(id: string, region: Region, layout: _ILayout1, options: FrameCreateOpts): _CreateElementCommand1<_FrameElement1>;
283
+ loadPatternFromString(src: string, frameService: FrameService): Promise<void>;
284
+ }
285
+ export const frameStepService: FrameStepService;
286
+ interface SVGCreateOpts {
287
+ stepName?: string;
288
+ src: string;
289
+ objectURL: string;
290
+ svg: {
291
+ svg: string;
292
+ colors: {
293
+ [key: string]: _ColorDefinition1;
294
+ };
295
+ };
296
+ }
297
+ declare class IllustrationStepService implements StepService<_IllustrationStepData1> {
298
+ getIllustrationBody(src: string): Promise<string>;
299
+ getCreateElementCommand(id: string, region: Region, layout: _ILayout1, options: SVGCreateOpts): _CreateElementCommand1<_IllustrationElement1>;
300
+ getColors(stepData: _Step1<_IllustrationStepData1>, workflowManager: WorkflowManager): {
301
+ [key: string]: _ColorDefinition1;
302
+ } | never[];
303
+ init(stepData: _Step1<_IllustrationStepData1>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
304
+ availableColors(stepData: _Step1<_IllustrationStepData1>, workflowManager: WorkflowManager): Promise<{
305
+ fill: string | undefined;
306
+ stroke: string | undefined;
307
+ variant: _VariantResource1;
308
+ }[] | undefined>;
309
+ changeColorsCommand(svg: string, illustrationWidth: number, illustrationHeight: number, elements: string[], newFills: Map<string, string>): Promise<_CanvasCommand1>;
310
+ changeColors(stepData: _Step1<_IllustrationStepData1>, elements: RegionElement[], workflowManager: WorkflowManager, getAllLayouts: () => _LayoutData1[], newFills: Map<string, string>): Promise<void>;
311
+ selectVariant(stepData: _Step1<_IllustrationStepData1>, variant: _VariantResource1, elements: RegionElement[], setIsUpdating: (isUpdating: boolean) => void, workflowManager: WorkflowManager): Promise<void>;
312
+ }
313
+ export const illustrationStepService: IllustrationStepService;
314
+ declare class MaterialStepService implements StepService<_MaterialStepData1> {
315
+ init(stepData: _Step1<_MaterialStepData1>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<null | CommandWithFollowup>;
316
+ selectVariant(step: _Step1<_MaterialStepData1>, variant: _VariantResource1, workflowManager: WorkflowManager, setApplying: (status: boolean) => void): Promise<void>;
317
+ }
318
+ export const materialStepService: MaterialStepService;
319
+ declare class ModelStepService implements StepService<_ModelStepData1> {
320
+ init(stepData: _Step1<_ModelStepData1>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
321
+ selectVariant(step: _Step1<_ModelStepData1>, variant: _VariantResource1, workflowManager: WorkflowManager, setApplying: (status: boolean) => void): Promise<void>;
322
+ }
323
+ export const modelStepService: ModelStepService;
324
+ declare class ModuleStepService implements StepService<_ModuleStepData1> {
325
+ init(stepData: _Step1<_ModuleStepData1>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
326
+ changeText(stepData: _Step1<_ModuleStepData1>, input: string, workflowManager: WorkflowManager, error: string, setError: (e: string) => void): Promise<void>;
327
+ }
328
+ export const moduleStepService: ModuleStepService;
329
+ declare class PictureStepService implements StepService<_PictureStepData1> {
330
+ init(stepData: _Step1<_PictureStepData1>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
331
+ selectVariant(stepData: _Step1<_PictureStepData1>, variant: _VariantResource1, workflowManager: WorkflowManager, setIsUpdating: (status: boolean) => void): Promise<void>;
332
+ }
333
+ export const pictureStepService: PictureStepService;
334
+ declare class QuestionStepService implements StepService<_QuestionStepData1> {
335
+ init(stepData: _Step1<_QuestionStepData1>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
336
+ selectVariant(stepData: _Step1<_QuestionStepData1>, variantId: string, workflowManager: WorkflowManager): Promise<void>;
337
+ }
338
+ export const questionStepService: QuestionStepService;
339
+ declare class ShapeStepService implements StepService<_ShapeStepData1> {
340
+ availableColours(stepData: _Step1<_ShapeStepData1>): Promise<{
341
+ fill: string | undefined;
342
+ stroke: string | undefined;
343
+ variant: _VariantResource1;
344
+ }[]>;
345
+ init(stepData: _Step1<_ShapeStepData1>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
346
+ selectVariant(stepData: _Step1<_ShapeStepData1>, colourOption: ColorOption, elements: RegionElement[], workflowManager: WorkflowManager): Promise<void>;
347
+ }
348
+ export const shapeStepService: ShapeStepService;
349
+ type ToastCallback = (callbackOptions: {
350
+ toastMessage: null | string;
351
+ toastType: InformationMessageType | null;
352
+ }) => void;
353
+ declare class Toast {
354
+ constructor();
355
+ addToastCallback(callback: ToastCallback): void;
356
+ setLatestToast(errorMessage: null | string, errorType: InformationMessageType | null): void;
357
+ }
358
+ export const toast: Toast;
359
+ interface TextFillSpotColor {
360
+ profileName: string;
361
+ namedColor: string;
362
+ }
363
+ interface TextUpdateResult {
364
+ command?: _GroupCommand1;
365
+ helperText: string;
366
+ errors: TextError[];
367
+ }
368
+ interface TextError {
369
+ localizationKey: string;
370
+ }
371
+ declare class TextStepService implements StepService<_TextStepData1> {
372
+ init(stepData: _Step1<_TextStepData1>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
373
+ findLayoutElements(workflowManager: WorkflowManager, step: _Step1<_TextStepData1>): _TextboxElement1[];
374
+ /**
375
+ * Get the colors that can be used for a given text step.
376
+ * @param stepData The text step to get colors for.
377
+ * @returns A list of color objects containg fill, stroke and variant if available.
378
+ */
379
+ availableFillColors(stepData: _Step1<_TextStepData1>): ColorOption[];
380
+ changeFillColor(stepData: _Step1<_TextStepData1>, newColor: ColorOption, elements: RegionElement[], workflowManager: WorkflowManager): Promise<void>;
381
+ availableFillImages(stepData: _Step1<_TextStepData1>): Promise<TextFillImage[]>;
382
+ changeFillImage(stepData: _Step1<_TextStepData1>, fillImage: TextFillImage, elements: RegionElement[], workflowManager: WorkflowManager): Promise<void>;
383
+ /**
384
+ * Given an element and a string, filters any characters from the string that are
385
+ * not supported by the font of the given element.
386
+ * @param text The text string to filter.
387
+ * @param fontData An optional fontData object, when provided, we use the font table to determine glyphs that aren't provided and additionally strip these out also.
388
+ * @returns A new string representing the passed string with unsupported characters removed.
389
+ */
390
+ filterUnsupportedCharacters: (text: string, fontData?: FontData) => string;
391
+ getProcessedInput(input: string, stepData: _TextStepData1, customiseAllText: boolean): string;
392
+ updateInputText(input: string, elements: _TextboxElement1[], step: _Step1<_TextStepData1>, workflowManager: WorkflowManager): TextUpdateResult;
393
+ selectVariant(step: _Step1<_TextStepData1>, variant: _VariantResource1, workflowManager: WorkflowManager, setError: (status: boolean) => void, setHelperText: (text: string) => void): Promise<void>;
394
+ textAlign: (stepData: _TextStepData1) => string;
395
+ createTextFillSpotColor(colorOption: _OptionResource1, variant: _VariantResource1): TextFillSpotColor | undefined;
396
+ }
397
+ export const textStepService: TextStepService;
398
+ declare abstract class ModuleProduct {
399
+ /**
400
+ * Name used by class. Usually product or brand name.
401
+ */
402
+ abstract moduleName: string;
403
+ /**
404
+ * SVG with styled path positioned on a background image. To be displayed to user.
405
+ */
406
+ abstract svgPreview(text: string, region: Region): string;
407
+ /**
408
+ * SVG with styled path positioned on a background image. To be submitted for print.
409
+ */
410
+ abstract svgPrint(text: string, region: Region): string;
411
+ }
412
+ export interface EditedSteps {
413
+ [stepName: string]: boolean;
414
+ }
415
+ export interface MandatorySteps {
416
+ [stepName: string]: boolean;
417
+ }
418
+ export type StepElements = {
419
+ [key: string]: RegionElement[];
420
+ };
421
+ type StepInitialised = {
422
+ [key: string]: boolean;
423
+ };
424
+ type StepMetadata = FrameMetadata | IllustrationMetadata | ModuleMetadata | TextMetadata;
425
+ export interface WorkflowStorage {
426
+ [stepName: string]: _StepStorage1;
427
+ }
428
+ export interface WorkflowMetadata {
429
+ [stepName: string]: StepMetadata;
430
+ }
431
+ export interface WorkflowSelections {
432
+ [stepName: string]: {
433
+ selections: _VariantResource1[];
434
+ };
435
+ }
436
+ export interface InformationResult {
437
+ message: string;
438
+ messageType: InformationMessageType;
439
+ stepID: string;
440
+ }
441
+ export enum InformationMessageType {
442
+ Error = "Error",
443
+ Warning = "Warning",
444
+ Info = "Info"
445
+ }
446
+ /**
447
+ * Services required for the operaiton of individual steps.
448
+ */
449
+ interface StepSpecificServices {
450
+ frameService?: FrameService;
451
+ module?: ModuleProduct;
452
+ }
453
+ export type DesignCreationProgressUpdate = (message: string) => void;
454
+ type ConfirmCallback = (isConfirmed: boolean) => void;
455
+ type EditedCallback = (editedSteps: EditedSteps) => void;
456
+ type ElementsCallback = (elements: StepElements) => void;
457
+ type InformationResultCallback = (messages: InformationResult[]) => void;
458
+ type InitCallback = (stepInitialised: StepInitialised) => void;
459
+ type MakingAdjustmentsCallback = (makingAdjustments: string) => void;
460
+ type MandatoryCallback = (mandatorySteps: MandatorySteps) => void;
461
+ type MetadataCallback = (metadata: WorkflowMetadata) => void;
462
+ type SelectionCallback = (callbackOptions: {
463
+ invalidModelVariants: string[];
464
+ selectionCost: number;
465
+ selections: StepSelections;
466
+ traversableScenes: WorkflowScene[];
467
+ }) => void;
468
+ type StepSpecificStorageCallback = (selections: _StepStorage1) => void;
469
+ type StorageCallback = (storage: WorkflowStorage) => void;
470
+ type CurrentVariationRecordCallback = (variationRecord: null | VariationRecord) => void;
471
+ type VariationRecordsCallback = (records: VariationRecord[]) => void;
472
+ export interface WorkflowManager {
473
+ addPoller: (poller: Poller) => void;
474
+ addConfirmCallback: (callback: ConfirmCallback) => void;
475
+ addCurrentVariationCallback: (callback: CurrentVariationRecordCallback) => void;
476
+ addEditedCallback: (callback: EditedCallback) => void;
477
+ addElementsCallback: (callback: ElementsCallback) => void;
478
+ addInformationResultCallback: (callback: InformationResultCallback) => void;
479
+ addInitCallback: (callback: InitCallback) => void;
480
+ addMakingAdjustmentsCallback: (callback: MakingAdjustmentsCallback) => void;
481
+ addMandatoryCallback: (callback: MandatoryCallback) => void;
482
+ addMetadataCallback: (callback: MetadataCallback) => void;
483
+ addSelectionCallback: (callback: SelectionCallback) => void;
484
+ addStepSpecificStorageCallback: (callback: StepSpecificStorageCallback, stepName: string) => void;
485
+ addStorageCallback: (callback: StorageCallback) => void;
486
+ addVariationRecord: (variationRecord: Omit<VariationRecord, "recordNumber">) => VariationRecord;
487
+ addVariationRecordsCallback: (callback: VariationRecordsCallback) => void;
488
+ getCommandDispatcher: () => (command: _CanvasCommand1) => void;
489
+ getCurrentVariationRecord: () => VariationRecord | undefined;
490
+ getVariationRecords: () => VariationRecord[];
491
+ getCommandContext: () => _CommandContext1;
492
+ getLayouts: () => _ILayout1[];
493
+ getAllLayoutData: () => LayoutState[];
494
+ getLayoutPreviewService: () => any | undefined;
495
+ getPreviewService: () => any | undefined;
496
+ getProfanities: () => string[];
497
+ getRegionElements: (stepName: string) => RegionElement[];
498
+ getSerializedStep: (stepName: string, serializedSteps: SerializableStep[]) => SerializableStep | undefined;
499
+ getStepSpecificServices: (stepName: string) => StepSpecificServices | undefined;
500
+ getStepStorage: (stepName: string) => _StepStorage1 | undefined;
501
+ getMetadata: (stepName: string) => StepMetadata | undefined;
502
+ getWorkflowMetadata: () => WorkflowMetadata;
503
+ getInformationResults(): InformationResult[];
504
+ getTransaction: () => Transaction;
505
+ getTransactionCustomer: () => Customer | undefined;
506
+ setTransactionCustomer: (customer: Customer) => void;
507
+ /**
508
+ * @deprecated Use setTransactionCustomer instead.
509
+ */
510
+ setTransactionCustomerDetails: (details: {
511
+ email: string;
512
+ }) => void;
513
+ getWorkflow: () => _Workflow1;
514
+ getWorkflowSelections: () => WorkflowSelections;
515
+ getProduct: () => Product;
516
+ /**
517
+ * A promise resolving when the initial state of the workflow has completed loading.
518
+ */
519
+ getInitializationPromise: () => Promise<void>;
520
+ /**
521
+ * Returns true when the initial state of the workflow has been loaded and settled.
522
+ */
523
+ isInitialized(): boolean;
524
+ markStepsAsInitialised: (stepNames: string[]) => void;
525
+ getUpdatesPending: () => boolean;
526
+ markUpdateCompleted: (id: string) => void;
527
+ markUpdatePending: () => string;
528
+ outstandingRequestsPromise: () => Promise<void>;
529
+ removeVariationRecord: (recordNumber: number) => VariationRecord[];
530
+ reset: () => Promise<void>;
531
+ setCurrentAdjustingStepId: (stepId: string) => void;
532
+ /**
533
+ * Sets the given variation record. NOTE: This is also used to update existing variation records.
534
+ */
535
+ setCurrentVariationRecord: (variationRecord: null | VariationRecord) => void;
536
+ setEditedStatus: (stepName: string, status: boolean) => void;
537
+ setInformationResults: (results: InformationResult[]) => void;
538
+ setMandatoryFulfilled: (stepName: string, status: boolean) => void;
539
+ setSelectionsAndElements: (stepName: string, variants: _VariantResource1[], elements: RegionElement[], callback?: () => Promise<void>) => Promise<void>;
540
+ setVariationRecords: (variationRecords: VariationRecord[]) => void;
541
+ toggleDesignConfirmed: () => void;
542
+ updateMetadata: (stepName: string, update: any) => void;
543
+ /**
544
+ * @deprecated State updates are being pulled internally. This function will be removed in the future.
545
+ */
546
+ updateStateWithServerImmediate: (getReducerState: () => _CommandState1) => Promise<void>;
547
+ updateStorage: (stepName: string, update: _StepStorage1) => Promise<void>;
548
+ getModelContainer: () => any | undefined;
549
+ setModelContainer: (container: any) => void;
550
+ /**
551
+ * Injects the model of this product into the preview service.
552
+ * This also overwrites the internal preview service.
553
+ * @param previewService The preview service to inject into.
554
+ */
555
+ injectIntoPreviewService(previewService: any): Promise<void>;
556
+ /**
557
+ * Ejects the model of this product from the preview service.
558
+ */
559
+ ejectFromPreviewService(): void;
560
+ }
561
+ interface StepService<T extends _AnyStepData1> {
562
+ /**
563
+ * Initialize the given step, or reload from serialized data if present.
564
+ */
565
+ init(stepData: _Step1<T>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<any>;
566
+ }
567
+ interface FileInfo {
568
+ /**
569
+ * The name of the file.
570
+ */
571
+ name: string;
572
+ /**
573
+ * A blob object representing the
574
+ * data of the file.
575
+ */
576
+ blob: Blob;
577
+ }
578
+ /**
579
+ * A command along with a function to run afterwards.
580
+ */
581
+ interface CommandWithFollowup {
582
+ command?: _CanvasCommand1;
583
+ followup?: () => Promise<void>;
584
+ }
585
+ /**
586
+ * The variant selections of a completed step.
587
+ */
588
+ interface SelectedVariants {
589
+ [stepName: string]: {
590
+ id: string;
591
+ name: string;
592
+ priceModifier: number;
593
+ }[];
594
+ }
595
+ interface ExportedData {
596
+ [name: string]: {
597
+ value: string;
598
+ priceModifier: number;
599
+ };
600
+ }
601
+ export interface DesignCreationMessage {
602
+ baseCost?: number;
603
+ designProductId?: string;
604
+ designProductVariantId?: string;
605
+ event: string;
606
+ exportedData: ExportedData;
607
+ externalCartProductId?: string;
608
+ externalCartProductVariantId?: string;
609
+ lineItemImageUrl: string;
610
+ metadata?: {
611
+ [stepName: string]: string;
612
+ };
613
+ optionsCost: number;
614
+ processExecutionId?: string;
615
+ selectedVariants?: SelectedVariants;
616
+ sku?: string;
617
+ transactionId: string;
618
+ transactionOwnerId?: string;
619
+ weight?: number;
620
+ workflowViewerLink: string;
621
+ workflowViewerReadOnlyLink: string;
622
+ }
623
+ /**
624
+ * Represents a transaction.
625
+ */
626
+ export interface Transaction {
627
+ /**
628
+ * A unique identifier for this transaction. Useful for reloading and
629
+ * modifying state of the transaction.
630
+ */
631
+ id: string;
632
+ /**
633
+ * User-supplied name for the associated design.
634
+ */
635
+ designName?: string;
636
+ /**
637
+ * When true the transaction is a bulk transaction & will allow for modifying
638
+ * variations based on bulk configuration on the workflow.
639
+ */
640
+ bulk?: boolean;
641
+ /**
642
+ * The workflow associated with this transaction.
643
+ */
644
+ workflowId?: string;
645
+ /**
646
+ * Temporary ID that grants write permission to the transaction.
647
+ */
648
+ transactionOwnerId?: string;
649
+ /**
650
+ * The current state of the design.
651
+ */
652
+ workflowState?: string;
653
+ /**
654
+ * URL to a partner-specific logo intended to display during the workflow experience.
655
+ */
656
+ customLogoLink?: string;
657
+ /**
658
+ * URL to a logo intended to display at the periphery of the workflow experience.
659
+ */
660
+ workflowFooterLogoLink?: string;
661
+ /**
662
+ * URL to the corresponding integration in the REST API.
663
+ */
664
+ restApiIntegrationLink?: string;
665
+ /**
666
+ * URL to redirect to when a workflow is finished.
667
+ */
668
+ callbackUrl?: string;
669
+ /**
670
+ * Product that this transaction belongs to.
671
+ */
672
+ product?: Product;
673
+ /**
674
+ * The integration product related to this lineitem.
675
+ */
676
+ integrationProduct?: IntegrationProduct;
677
+ /**
678
+ * Whether this transaction has previously been ordered.
679
+ */
680
+ isOrdered?: boolean;
681
+ /**
682
+ * @deprecated use isOrdered to check whether transaction has been ordered instead.
683
+ */
684
+ lineItem?: LineItem;
685
+ /**
686
+ * The external product variant ID representing the design product related
687
+ * to this transaction, null unless the createDesignProduct flag was set
688
+ * and the design was finalized using createDesign operation.
689
+ */
690
+ /**@deprecated use externalCartProductVariantId instead of this moving forward */
691
+ externalDesignProductVariantId?: string;
692
+ /**
693
+ * The external product id representing the design product related
694
+ * to this transaction, null unless the createDesignProduct flag was set
695
+ * and the design was finalized using createDesign operation.
696
+ */
697
+ /**@deprecated use externalCartProductId instead of this moving forward. */
698
+ externalDesignProductId?: string;
699
+ /**
700
+ * The external product id representing the product related to the transaction.
701
+ * This value can hold any type of transaction such as design and standard products.
702
+ */
703
+ externalCartProductId?: string;
704
+ /**
705
+ * The external product variant id representing the product related to the transaction.
706
+ * This value can hold any type of transaction such as design and standard products.
707
+ */
708
+ externalCartProductVariantId?: string;
709
+ priceModifierTotal?: number;
710
+ /**
711
+ * The amount of variations associated with this transaction.
712
+ */
713
+ variationsCount?: number;
714
+ /**
715
+ * URL to open the transaction in the workflow viewer.
716
+ */
717
+ workflowViewerLink?: string;
718
+ workflowViewerReadOnlyLink?: string;
719
+ previewImageLink?: string;
720
+ bulkSourceUrl?: string;
721
+ bulkEmailAddress?: string;
722
+ lastSyncedAt?: string;
723
+ /**
724
+ * The users who have access to this transaction.
725
+ */
726
+ stakeholders?: Stakeholder[];
727
+ }
728
+ interface IntegrationProduct {
729
+ id: string;
730
+ externalProductId?: string;
731
+ integration?: Integration;
732
+ }
733
+ interface Integration {
734
+ id: string;
735
+ enabled: boolean;
736
+ externalIntegrationId?: string;
737
+ }
738
+ /**
739
+ * Fields found in a variant within a line item resource.
740
+ */
741
+ interface LineItemVariant {
742
+ currencyCode: string;
743
+ optionName: string;
744
+ priceModifier: number;
745
+ stepName: string;
746
+ variantName: string;
747
+ }
748
+ interface LineItem {
749
+ id: string;
750
+ transactionId?: string;
751
+ previewImageUrl?: string;
752
+ product: Product;
753
+ quantity: number;
754
+ metadata?: LineItemMetadata[];
755
+ variants: LineItemVariant[];
756
+ }
757
+ interface LineItemMetadata {
758
+ stepName: string;
759
+ metadata: string;
760
+ }
761
+ interface ProductWorkflow {
762
+ friendlyName: string;
763
+ id: string;
764
+ present?: boolean;
765
+ imageUrl: string;
766
+ workflowName: string;
767
+ }
768
+ interface Partner {
769
+ id?: string;
770
+ name?: string;
771
+ currencyCode?: string;
772
+ customerDetailsPromptMarkdown?: string;
773
+ }
774
+ interface Product {
775
+ /**
776
+ * ID of the partner owner.
777
+ */
778
+ partnerId?: string;
779
+ partner?: Partner;
780
+ /**
781
+ * Whether a line item for this product is delivered as soon as the order is received.
782
+ */
783
+ autoprint: boolean;
784
+ /**
785
+ * Whether this product can be quickprinted.
786
+ */
787
+ canQuickprint?: boolean;
788
+ /**
789
+ * The internal identifier for this product.
790
+ */
791
+ id: string;
792
+ /**
793
+ * The human friendly name of the product.
794
+ */
795
+ name: string;
796
+ /**
797
+ * A URL to the image asset associated with this product.
798
+ */
799
+ imageUrl?: string;
800
+ /**
801
+ * A resource url for a 3D model used to represent this product
802
+ * in the 3d editor. If not available we assume the product doesn't support 3D.
803
+ */
804
+ modelUrl?: string;
805
+ /**
806
+ * A URL for the image used as an overlay on any workflows
807
+ * that incorporate a product overlay step.
808
+ */
809
+ overlayImageUrl?: string;
810
+ /**
811
+ * Words which can't be used in a workflow for this product.
812
+ */
813
+ profanities?: {
814
+ id: string;
815
+ createdAt: string;
816
+ userId: string;
817
+ word: string;
818
+ }[];
819
+ /**
820
+ * The max characters that can be typed for quickprint.
821
+ */
822
+ quickprintMaxLength?: number;
823
+ /**
824
+ * The name of the module to use for quickprint.
825
+ */
826
+ quickprintModuleName?: string;
827
+ /**
828
+ * If true, the product should be displayed in the client as if it is available.
829
+ * Should be displayed as if it is unavailable otherwise.
830
+ */
831
+ enabled: boolean;
832
+ /**
833
+ * Workflows which have been assigned to this product.
834
+ */
835
+ workflows?: ProductWorkflow[];
836
+ /**
837
+ * The base price of this product in sub units. Essentially the cost of the
838
+ * product without any customisations applied.
839
+ */
840
+ basePrice?: number;
841
+ /**
842
+ * The weight of this product.
843
+ */
844
+ weight?: number;
845
+ /**
846
+ * When specified, represents a pre-rendered image of this product to be
847
+ * displayed to customers while the 3D preview is loading.
848
+ */
849
+ preloadImageUrl?: string;
850
+ /**
851
+ * When set the store owner has configured this product to prompt for
852
+ * customer details. In hosted experience, we'll offer to collect this information from the customer. In
853
+ * bespoke UIs created using the Core SDK you will need to check this flag and request the data accordingly.
854
+ * See attachCustomerDetails on the WorkflowExperience for how to supply us with the details you collect.
855
+ */
856
+ promptForCustomerDetails?: boolean;
857
+ /**
858
+ * Configuration for bulk creations
859
+ */
860
+ bulkConfiguration?: BulkConfiguration;
861
+ /**
862
+ * Configuration for conversion. Optional.
863
+ */
864
+ conversionConfiguration?: ConversionConfiguration;
865
+ integrationProducts?: IntegrationProduct[];
866
+ productTags?: ProductTag[];
867
+ }
868
+ interface ProductTag {
869
+ id: string;
870
+ name: string;
871
+ }
872
+ export interface ColorOption {
873
+ id?: string;
874
+ fill?: string;
875
+ stroke?: string;
876
+ variant?: _VariantResource1;
877
+ colorProfileAssetKey?: string;
878
+ }
879
+ /**
880
+ * Represents a variation as seen in Google sheets.
881
+ * Record number = row# - 1
882
+ */
883
+ export interface VariationRecord {
884
+ recordNumber: number;
885
+ transactionId: string;
886
+ values: {
887
+ stepName: string;
888
+ aspect: string;
889
+ value: string;
890
+ }[];
891
+ }
892
+ export interface RegionElement {
893
+ id: string;
894
+ region?: Region;
895
+ }
896
+ interface FrameMetadata {
897
+ image: string;
898
+ }
899
+ interface IllustrationMetadata {
900
+ colors: string[];
901
+ }
902
+ interface ModuleMetadata {
903
+ text: string;
904
+ }
905
+ interface TextMetadata {
906
+ color?: string;
907
+ text: string;
908
+ fillImage?: string;
909
+ }
910
+ export interface SelectionStorage {
911
+ selectedVariants?: _VariantResource1[];
912
+ }
913
+ export interface TextStepStorage extends SelectionStorage {
914
+ color?: string;
915
+ defaultCleared?: boolean;
916
+ inputText?: string;
917
+ text?: string;
918
+ customiseAllText?: boolean;
919
+ }
920
+ type StepSelections = {
921
+ [key: string]: SelectionStorage;
922
+ };
923
+ interface FrameData {
924
+ /**
925
+ * The path data for a frame SVG
926
+ */
927
+ path: string;
928
+ /**
929
+ * The viewbox width
930
+ */
931
+ width: number;
932
+ /**
933
+ * The viewbox height.
934
+ */
935
+ height: number;
936
+ }
937
+ /**
938
+ * Defines the different behaviors supported by the camera system
939
+ * for control when viewing a product.
940
+ */
941
+ export enum ProductCameraRig {
942
+ Orbit = 0,
943
+ Pan = 1
944
+ }
945
+ /**
946
+ * Defines the different strategies to use when calculating the total price
947
+ * when creating bulk designs.
948
+ */
949
+ export enum BulkPriceCalculationStrategy {
950
+ /** The total price should increase with the amount of variations. */
951
+ PerVariation = "PerVariation",
952
+ /** The total price should remain at the base price of the product. */
953
+ BaseProduct = "BaseProduct"
954
+ }
955
+ interface BulkConfiguration {
956
+ id: string;
957
+ name?: string;
958
+ sceneTitle: string;
959
+ stepTitle: string;
960
+ helpText?: string;
961
+ supportsGoogleSheet: boolean;
962
+ maxVariations: number;
963
+ pricingStrategy: BulkPriceCalculationStrategy;
964
+ }
965
+ /**
966
+ * Defines the locations at which a conversion attempt can take place.
967
+ */
968
+ export enum ConversionLocation {
969
+ /**
970
+ * The client should expose a flow for allowing the user to optionally input details at any point.
971
+ */
972
+ Manual = "Manual",
973
+ /**
974
+ * The client should show the conversion flow at the beginning of a workflow.
975
+ */
976
+ OnStart = "OnStart",
977
+ /**
978
+ * The client should allow the user to input details just before quiting the experience.
979
+ */
980
+ OnQuit = "OnQuit",
981
+ /**
982
+ * The client should ask the user for details prior to adding to cart.
983
+ */
984
+ OnEnd = "OnEnd"
985
+ }
986
+ /**
987
+ * The data configured to be requested.
988
+ */
989
+ export enum ConversionDataType {
990
+ Email = "Email",
991
+ FirstName = "FirstName",
992
+ LastName = "LastName",
993
+ Phone = "Phone"
994
+ }
995
+ export interface ConversionData {
996
+ type: ConversionDataType;
997
+ mandatory: boolean;
998
+ }
999
+ /**
1000
+ * The configuration for conversion, exposed on products currently.
1001
+ */
1002
+ export interface ConversionConfiguration {
1003
+ id: string;
1004
+ name?: string;
1005
+ locations: ConversionLocation[];
1006
+ requestedData: ConversionDataType[];
1007
+ requestedDataItems: ConversionData[];
1008
+ mandatory?: boolean;
1009
+ }
1010
+ /**
1011
+ * Someone who has used a workflow experience and entered their contact details.
1012
+ */
1013
+ export interface Customer {
1014
+ id?: string;
1015
+ emailAddress: string;
1016
+ firstName?: string;
1017
+ lastName?: string;
1018
+ phoneNumber?: string;
1019
+ loginToken?: string;
1020
+ partner?: Partner;
1021
+ stakeholders?: Stakeholder[];
1022
+ bundleStakeholders?: BundleStakeholder[];
1023
+ }
1024
+ export interface CustomerDetailsInput {
1025
+ emailAddress: string;
1026
+ firstName?: string;
1027
+ lastName?: string;
1028
+ phoneNumber?: string;
1029
+ }
1030
+ export enum StakeholderType {
1031
+ Owner = "Owner",
1032
+ Approver = "Approver",
1033
+ Editor = "Editor",
1034
+ Viewer = "Viewer"
1035
+ }
1036
+ export interface Stakeholder {
1037
+ id: string;
1038
+ type?: StakeholderType;
1039
+ transaction?: Transaction;
1040
+ customer?: Customer;
1041
+ }
1042
+ interface Bundle {
1043
+ id?: string;
1044
+ bundleOwnerId?: string;
1045
+ bundleStakeholders?: BundleStakeholder[];
1046
+ metadata?: {
1047
+ key: string;
1048
+ value: string;
1049
+ }[];
1050
+ name?: string;
1051
+ partner?: Partner;
1052
+ productCollection?: ProductCollection;
1053
+ transactions?: Transaction[];
1054
+ }
1055
+ interface BundleStakeholder {
1056
+ id: string;
1057
+ bundle?: Bundle;
1058
+ customer?: Customer;
1059
+ type?: StakeholderType;
1060
+ }
1061
+ interface BundleStakeholderInput {
1062
+ type: StakeholderType;
1063
+ customerDetails: CustomerDetailsInput;
1064
+ }
1065
+ type ProductCollection = {
1066
+ id: string;
1067
+ globalPropertyConfiguration?: GlobalPropertyConfiguration;
1068
+ name: string;
1069
+ products: Product[];
1070
+ };
1071
+ type GlobalPropertyState = {
1072
+ id: string;
1073
+ aspects: GlobalPropertyStateAspect[];
1074
+ };
1075
+ type GlobalPropertyStateAspect = {
1076
+ name: string;
1077
+ value: string;
1078
+ };
1079
+ interface StorageService {
1080
+ /**
1081
+ * Get a value.
1082
+ * @param key The key to lookup the value with.
1083
+ */
1084
+ get(key: string): string | undefined;
1085
+ /**
1086
+ * Set a value.
1087
+ * @param key The key to set.
1088
+ * @param val The new value.
1089
+ */
1090
+ set(key: string, val: string): void;
1091
+ /**
1092
+ * Remove a value.
1093
+ * @param key The key to remove, does nothing if the key doesn't exist.
1094
+ */
1095
+ remove(key: string): void;
1096
+ /**
1097
+ * Get a map from persistence.
1098
+ * @param key The key to search by.
1099
+ */
1100
+ getMap<K = any, V = any>(key: string): Map<K, V> | undefined;
1101
+ /**
1102
+ * St a map into persistence.
1103
+ * @param key The key to set the map at.
1104
+ * @param val The map to set.
1105
+ */
1106
+ setMap<K = any, V = any>(key: string, val: Map<K, V>): void;
1107
+ }
1108
+ export const persistenceService: StorageService;
1109
+ declare class GraphQlManager {
1110
+ constructor();
1111
+ getShadowGraphqlClient(): ApolloClient<any>;
1112
+ }
1113
+ export const graphQlManager: GraphQlManager;
1114
+ /**
1115
+ * An asset manager provides a way to create and
1116
+ * manage assets on the Spiff Commerce Platform.
1117
+ */
1118
+ interface AssetManager {
1119
+ /**
1120
+ * Uploads a file to the Spiff Commerce Platform.
1121
+ */
1122
+ uploadFile: (file: File, onProgress: (val: number) => void) => Promise<_Asset1>;
1123
+ }
1124
+ declare class AssetService implements AssetManager {
1125
+ /**
1126
+ * Allows for retrieving an asset, returns the option from a cache if possible.
1127
+ */
1128
+ getLocalOrFromServer(assetKey: string): Promise<_Asset1>;
1129
+ /**
1130
+ * Allows for retrieving amaterial, returns the option from a cache if possible.
1131
+ * @param id The option ID to be retrieved.
1132
+ */
1133
+ getMaterialLocalOrFromServer(id: string): Promise<MaterialResource>;
1134
+ /**
1135
+ * Upload a user asset to the server. Using callbacks to notify important events.
1136
+ * The asset will be stored via the persistence service for future access, if available.
1137
+ */
1138
+ uploadAssetWithProgress(file: FileInfo, assetType: _AssetType1, onProgress: (val: number) => void, anonymous?: boolean, temporary?: boolean): Promise<_Asset1>;
1139
+ uploadFile(file: File, onProgress: (val: number) => void): Promise<_Asset1>;
1140
+ removePersistedAsset(assetKey: string): void;
1141
+ getPersistedAssets(): PersistedAsset[];
1142
+ /**
1143
+ * Convert a File object for an image into a FileInfo.
1144
+ */
1145
+ loadImageAsFileInfo: (file: File) => Promise<FileInfo>;
1146
+ }
1147
+ interface PersistedAsset {
1148
+ assetKey: string;
1149
+ src: string;
1150
+ }
1151
+ export const assetService: AssetService;
1152
+ declare class OptionService {
1153
+ /**
1154
+ * Allows for retrieving an option, returns the option from a cache if possible.
1155
+ * @param id The option ID to be retrieved.
1156
+ */
1157
+ getOption(id: string): Promise<undefined | _OptionResource1>;
1158
+ getAssetTileImageForVariant(variant: _VariantResource1): Promise<string>;
1159
+ getDefaultVariant(option: _OptionResource1): _VariantResource1 | undefined;
1160
+ getDisplayImageSource: (variant?: _VariantResource1) => undefined | string;
1161
+ /**
1162
+ * Returns the first variant marked as selected. This is used by most steps.
1163
+ */
1164
+ getSelectedVariant: (option: _OptionResource1 | undefined, selectedVariantIds: string[]) => _VariantResource1 | undefined;
1165
+ }
1166
+ export const optionService: OptionService;
1167
+ export const CommandContextContext: import("react").Context<_CommandContext1>;
1168
+ export const useLayouts: () => {
1169
+ commandDispatcher: (command: _CanvasCommand1, leaveOffUndoStack: boolean) => void;
1170
+ getLayoutById: (id: string) => _LayoutData1;
1171
+ getAllLayouts: () => _LayoutData1[];
1172
+ getReducerState: () => _CommandState1;
1173
+ lastUpdated: Date;
1174
+ flattenSequence: (sequenceId: string, initialState: _LayoutsState1) => void;
1175
+ };
1176
+ export type CommandDispatcher = (command: _CanvasCommand1, leaveOffUndoStack: boolean) => void;
1177
+ export type LayoutGetter = (layoutId: string) => _LayoutData1;
1178
+ export type LayoutsGetter = () => _LayoutData1[];
1179
+ /**
1180
+ * Details about a guideline that can be drawn on the canvas.
1181
+ */
1182
+ interface SnapPoint {
1183
+ type: "x" | "y" | "rotation";
1184
+ value: number;
1185
+ svgNode?: ReactNode;
1186
+ anchorPoint: number;
1187
+ guidelineCoordinates?: Point[];
1188
+ }
1189
+ export enum ElementEventType {
1190
+ Translate = "Translate",
1191
+ Rotate = "Rotate",
1192
+ Resize = "Resize"
1193
+ }
1194
+ export enum KeyEvent {
1195
+ ControlLeft = "ControlLeft",
1196
+ ControlRight = "ControlRight",
1197
+ Equal = "Equal",
1198
+ MetaLeft = "MetaLeft",
1199
+ MetaRight = "MetaRight",
1200
+ Minus = "Minus",
1201
+ ArrowLeft = "ArrowLeft",
1202
+ ArrowRight = "ArrowRight",
1203
+ ArrowUp = "ArrowUp",
1204
+ ArrowDown = "ArrowDown",
1205
+ AltLeft = "AltLeft",
1206
+ AltRight = "AltRight",
1207
+ Delete = "Delete",
1208
+ Backspace = "Backspace"
1209
+ }
1210
+ type ElementEvent = {
1211
+ type: ElementEventType.Translate;
1212
+ } | {
1213
+ type: ElementEventType.Rotate;
1214
+ } | {
1215
+ type: ElementEventType.Resize;
1216
+ relativeAxis: ScaleAxis;
1217
+ screenAxis: ScaleAxis;
1218
+ };
1219
+ export enum EditorSubMenu {
1220
+ None = "None",
1221
+ FrameAdjustment = "FrameAdjustment",
1222
+ Variations = "Variations",
1223
+ FinalizeDesign = "FinalizeDesign",
1224
+ SavedDesigns = "SavedDesigns",
1225
+ ThreeDPreview = "ThreeDPreview",
1226
+ Panels = "Panels"
1227
+ }
1228
+ interface UIState {
1229
+ }
1230
+ /**
1231
+ * This context stores global state for
1232
+ */
1233
+ export interface AdvancedEditorState extends UIState {
1234
+ /**
1235
+ * The layout currently being displayed in the editor.
1236
+ */
1237
+ layoutId: string;
1238
+ /**
1239
+ * Returns the id of the currently selected element. Or undefined if no element is selected.
1240
+ */
1241
+ selectedElement?: string;
1242
+ /**
1243
+ * The current zoom level of the editor.
1244
+ */
1245
+ zoom: number;
1246
+ /**
1247
+ * The current x translation of the transform for the canvas.
1248
+ */
1249
+ xTranslation: number;
1250
+ /**
1251
+ * The current y translation of the transform for the canvas.
1252
+ */
1253
+ yTranslation: number;
1254
+ /**
1255
+ * The maxiumum zoom possible based on current canvas content.
1256
+ */
1257
+ maxZoom: number;
1258
+ /**
1259
+ * The current measurement system used for display of coordinates and dimensions.
1260
+ */
1261
+ units: _UnitOfMeasurement1;
1262
+ /**
1263
+ * The sub menu to be displayed to the user in place of the canvas.
1264
+ */
1265
+ subMenu: EditorSubMenu;
1266
+ /**
1267
+ * Any modifier keys that are currently pressed
1268
+ */
1269
+ activeModifierKeys: KeyEvent[];
1270
+ /**
1271
+ * WHether or not a meta key is pressed.
1272
+ */
1273
+ metaPressed: boolean;
1274
+ /**
1275
+ * Any active element event.
1276
+ */
1277
+ elementEvent?: ElementEvent;
1278
+ /**
1279
+ * If movement should assume that it's operating in a scrolled environment.
1280
+ * FIXME: Can we get rid of this somehow.
1281
+ */
1282
+ scrolledMovement: boolean;
1283
+ }
1284
+ export const getDefaultState: (getLayouts: LayoutsGetter, defaultZoom: number) => AdvancedEditorState;
1285
+ export const commandReducer: (state: AdvancedEditorState, command: UICommand) => AdvancedEditorState;
1286
+ export const AdvancedEditorContext: import("react").Context<{
1287
+ uiDispatcher: Dispatch<UICommand>;
1288
+ state: AdvancedEditorState;
1289
+ }>;
1290
+ export const AdvancedEditorStateProvider: FunctionComponent<{
1291
+ defaultZoom?: number;
1292
+ children: ReactNode;
1293
+ }>;
1294
+ export class UICommand {
1295
+ constructor(changes: Partial<AdvancedEditorState>);
1296
+ apply(state: AdvancedEditorState): {
1297
+ layoutId: string;
1298
+ selectedElement?: string | undefined;
1299
+ zoom: number;
1300
+ xTranslation: number;
1301
+ yTranslation: number;
1302
+ maxZoom: number;
1303
+ units: _UnitOfMeasurement1;
1304
+ subMenu: EditorSubMenu;
1305
+ activeModifierKeys: KeyEvent[];
1306
+ metaPressed: boolean;
1307
+ elementEvent?: ElementEvent | undefined;
1308
+ scrolledMovement: boolean;
1309
+ };
1310
+ }
1311
+ export const useEditorState: () => {
1312
+ uiDispatcher: Dispatch<UICommand>;
1313
+ state: AdvancedEditorState;
1314
+ };
1315
+ /**
1316
+ * The minimum zoom that can be applied to a canvas.
1317
+ */
1318
+ export const minZoom = 0.5;
1319
+ export const useEditorInteraction: (editorRef: RefObject<SVGRectElement>, interactionRef: RefObject<HTMLDivElement>, zoomableElementRef: RefObject<HTMLDivElement>, defaultAdjustmentZoom: number | undefined, mode: "adjustment" | "advanced", canvasDispatcher: CommandDispatcher, breakpoint: string, guidelinePrimaryColor?: string, onSequenceComplete?: () => void) => {
1320
+ guidelines: SnapPoint[];
1321
+ scale: number;
1322
+ zoomableElementRef: RefObject<HTMLDivElement>;
1323
+ setElementEvent: (newEvent: ElementEvent | undefined) => void;
1324
+ handleZoom: (_event: any, value: any) => void;
1325
+ handleKeyDown: (event: KeyboardEvent, adjustmentBoundary?: Region) => void;
1326
+ handleKeyUp: (event: KeyboardEvent) => void;
1327
+ handlePointerPressedBackground: (event: PointerEvent) => void;
1328
+ handlePointerReleased: () => void;
1329
+ handlePointerMove: (event: PointerEvent, adjustmentBoundary?: Region) => void;
1330
+ handleScroll: () => void;
1331
+ handleSequenceStart: () => void;
1332
+ };
1333
+ export const useShortcutCombination: (shortcutKeys: string[], onCombinationPressed: () => void, onCombinationReleased?: () => void) => void;
1334
+ export interface DesignInputStep {
1335
+ data: DesignInputStepData;
1336
+ name: string;
1337
+ }
1338
+ interface DesignInputStepData {
1339
+ }
1340
+ export const generateCommands: (designInputSteps: DesignInputStep[], workflow: _Workflow1, layouts: _ILayout1[], productOverlayImageUrl?: string) => Promise<_CanvasCommand1[]>;
1341
+ export const EditorCore: FunctionComponent<{
1342
+ isMobile: boolean;
1343
+ color?: string;
1344
+ outlineColor?: string;
1345
+ editorRef: RefObject<SVGRectElement>;
1346
+ zoomableElementRef: RefObject<HTMLDivElement>;
1347
+ interactionElementRef: RefObject<HTMLDivElement>;
1348
+ guidelines: SnapPoint[];
1349
+ isMakingAdjustments?: boolean;
1350
+ outlineArea?: {
1351
+ x?: number;
1352
+ y?: number;
1353
+ height?: number;
1354
+ width?: number;
1355
+ hidden?: boolean;
1356
+ };
1357
+ visibleLayoutId: string;
1358
+ xTranslation: number;
1359
+ yTranslation: number;
1360
+ targetedElements?: string[];
1361
+ borderRadius?: number;
1362
+ canvasFilter?: string;
1363
+ handleContextMenu?: (e: any) => void;
1364
+ onMouseMove?: (event: React.MouseEvent<SVGRectElement, MouseEvent>) => void;
1365
+ onContextMenuHandlePointerDown?: (event: PointerEvent) => void;
1366
+ handleKeyDown: (event: KeyboardEvent, adjustmentBoundary?: Region) => void;
1367
+ handleKeyUp: (event: KeyboardEvent) => void;
1368
+ handlePointerMove: (e: PointerEvent, adjustmentBoundary?: Region) => void;
1369
+ handlePointerPressedBackground: (event: PointerEvent) => void;
1370
+ handlePointerReleased: () => void;
1371
+ handleScroll: () => void;
1372
+ onSequenceStart: () => void;
1373
+ setElementEvent: (e: ElementEvent | undefined) => void;
1374
+ onElementSelected: (elementId: string | undefined, event: PointerEvent) => void;
1375
+ variationRecord: null | VariationRecord;
1376
+ workflow: _Workflow1;
1377
+ }>;
1378
+ /**
1379
+ * The advanced editor encapsulates the logic required to allow users to manipulate a design
1380
+ * with more granular control such as toolbars, direct element manipulation, and more.
1381
+ */
1382
+ export const AdvancedEditor: FunctionComponent<{
1383
+ borderRadius?: number;
1384
+ canvasFilter?: string;
1385
+ color?: string;
1386
+ guidelineColor?: string;
1387
+ handleContextMenu?: (event: React.MouseEvent) => void;
1388
+ hideEditableAreaRect?: boolean;
1389
+ isMobile: boolean;
1390
+ onContextMenuHandlePointerDown?: (event: PointerEvent) => void;
1391
+ onDragEnd?: () => void;
1392
+ onElementSelected?: (id: string | undefined, element: PointerEvent) => void;
1393
+ onMouseMove?: (event: React.MouseEvent<SVGRectElement, MouseEvent>) => void;
1394
+ outlineColor?: string;
1395
+ variationRecord: null | VariationRecord;
1396
+ workflow: _Workflow1;
1397
+ }>;
1398
+ /**
1399
+ * A wrapping component that provides a simple interface for interacting with a variant.
1400
+ */
1401
+ export class Variant {
1402
+ constructor(variant: _VariantResource1);
1403
+ getType(): _AssetType1 | undefined;
1404
+ /**
1405
+ * @returns The unique identifier for the variant.
1406
+ */
1407
+ getId(): string;
1408
+ /**
1409
+ * @returns The configured name of the variant. Generally a human readable value.
1410
+ */
1411
+ getName(): string;
1412
+ /**
1413
+ * @returns The price modifier for this variant. This is the amount that will be added to the base price of the product.
1414
+ */
1415
+ getPriceFormatted(locales?: Intl.LocalesArgument, options?: Intl.NumberFormatOptions | undefined): string;
1416
+ /**
1417
+ * @returns The price modifier for this variant. This is the amount that will be added to the base price of the product.
1418
+ * Presented in subunits of the currency of the option. For example, if the option is configured to use USD, the price modifier will be in cents.
1419
+ */
1420
+ getPrice(): number;
1421
+ /**
1422
+ * @returns The URL for the base asset resource configured on this variant
1423
+ */
1424
+ getAsset(): string | undefined;
1425
+ /**
1426
+ * @returns The URL for a thumbnail resource configured on this variant. When no thumbnail is configured explicitly we fall back to the base asset and see if a thumbnail is genererated for that.
1427
+ */
1428
+ getThumbnail(): string | undefined;
1429
+ /**
1430
+ * @returns The URL for the display image configured on this variant. Can be used for things like size charts.
1431
+ */
1432
+ getDisplayImage(): string | undefined;
1433
+ /**
1434
+ * @returns When this variant is configured to have a color, this will return the hex value for that color.
1435
+ */
1436
+ getColor(): string | undefined;
1437
+ /**
1438
+ * @returns True when the variant is the default for its containing option. False otherwise.
1439
+ */
1440
+ isDefault(): boolean;
1441
+ /**
1442
+ * @returns The underlying variant resource. Generally not needed but made available just incase.
1443
+ */
1444
+ getResource(): _VariantResource1;
1445
+ /**
1446
+ * @returns True when the variant is enabled. False otherwise.
1447
+ */
1448
+ isEnabled(): boolean;
1449
+ }
1450
+ /**
1451
+ * A StepHandle allows for managing the state of a specific step in a workflow. This class
1452
+ * abstracts away the complexities of dealing with a step directly and allows for using high level
1453
+ * concepts instead of dealing with the underlying data structures.
1454
+ */
1455
+ export abstract class StepHandle<T extends _AnyStepData1> {
1456
+ /**
1457
+ * Access to the workflow manager this step is contained by.
1458
+ */
1459
+ protected readonly manager: WorkflowManager;
1460
+ /**
1461
+ * The step metadata, useful for determining logic based on configuration.
1462
+ */
1463
+ protected readonly step: _Step1<T>;
1464
+ constructor(manager: WorkflowManager, step: _Step1<T>);
1465
+ /**
1466
+ * Set the current update state of this step. All step handles pointing to this step will
1467
+ * see this value.
1468
+ * @param value The new value
1469
+ */
1470
+ protected setUpdateState(value: boolean): void;
1471
+ /**
1472
+ * @returns Gets the current update state of this step. All step handles for this step will see this value.
1473
+ */
1474
+ protected getUpdateState(): boolean;
1475
+ /**
1476
+ * Gets the currently selected variant, or undefined if no variant is selected.
1477
+ */
1478
+ getCurrentVariant(): Variant | undefined;
1479
+ /**
1480
+ * @returns A list of valid variants for this step. Does not include disabled variants.
1481
+ */
1482
+ getAvailableVariants(): Variant[];
1483
+ /**
1484
+ * @returns A list of all variants for this step, including disabled ones.
1485
+ */
1486
+ getAllVariants(): Variant[];
1487
+ /**
1488
+ * Most step types have a base option type that variants can be selected for.
1489
+ * Selects a specific variant for this step. This will execute all required changes to
1490
+ * the design and update the metadata to include the new selection. Any conditions
1491
+ * that would be triggered will also be executed.
1492
+ */
1493
+ abstract selectVariant(variant: Variant): Promise<void>;
1494
+ /**
1495
+ * @returns A unique identifier for this step within the workflow.
1496
+ */
1497
+ getId(): string;
1498
+ /**
1499
+ * @returns The name of the step
1500
+ */
1501
+ getName(): string;
1502
+ /**
1503
+ * @returns A message that can accompany the step name in UI components. Used to describe the purpose of the step in more detail.
1504
+ */
1505
+ getHelpText(): string | undefined;
1506
+ /**
1507
+ * @returns The type of the step handle.
1508
+ */
1509
+ getType(): _StepType1;
1510
+ /**
1511
+ * @returns The underlying data for this step. Favor using the step handle methods instead of this.
1512
+ */
1513
+ getRaw(): _Step1<T>;
1514
+ /**
1515
+ * Fires any configured animations on the 3D preview for this step.
1516
+ * This includes camera & model animations. If the preview is unavailable
1517
+ * this function will do nothing.
1518
+ */
1519
+ executeAnimations(): void;
1520
+ }
1521
+ export class BulkStepHandle extends StepHandle<_BulkStepData1> {
1522
+ constructor(manager: WorkflowManager, step: _Step1<_BulkStepData1>);
1523
+ selectVariant(): Promise<void>;
1524
+ setDesignName(designName: string): Promise<void>;
1525
+ addVariationRecord(): VariationRecord;
1526
+ updateBulkIsConnected(bulkIsConnected: boolean): void;
1527
+ /**
1528
+ * Opens the bulk source in a seperate tab. This bulk source could be a google sheet or a csv file.
1529
+ */
1530
+ openBulkSourceUrl(): void;
1531
+ sendGoogleSheetLinkToEmail(email: string): Promise<void>;
1532
+ /**
1533
+ * Removes a variation from the bulk step.
1534
+ * @param recordNumber The record number of the variation to remove.
1535
+ */
1536
+ deleteVariationRecord(recordNumber: number): void;
1537
+ /**
1538
+ * @returns The aspects of each step that are modifiable from the bulk handle. These are configured in the workflow.
1539
+ */
1540
+ getAspects(): import("@spiffcommerce/papyrus").StepAspect[];
1541
+ }
1542
+ export class IllustrationStepHandle extends StepHandle<_IllustrationStepData1> {
1543
+ constructor(manager: WorkflowManager, step: _Step1<_IllustrationStepData1>);
1544
+ /**
1545
+ * Allows for select a vector from the available vectors configured on this steps base option.
1546
+ * @param variant The new vector variant to use for this step.
1547
+ * @returns A promise that can be awaited to know when the new vector asset has been updated on the design.
1548
+ */
1549
+ selectVariant(variant: Variant): Promise<void>;
1550
+ /**
1551
+ * Get colors for the illustration.
1552
+ * @returns A list of color definitions that are currently applied to the illustration.
1553
+ */
1554
+ getColors(): {
1555
+ [key: string]: import("@spiffcommerce/papyrus").ColorDefinition;
1556
+ } | undefined;
1557
+ /**
1558
+ * Set color for the illustration.
1559
+ */
1560
+ setColor(key: string, value: string): Promise<void>;
1561
+ getColorOption(): Promise<import("@spiffcommerce/papyrus").OptionResource | undefined>;
1562
+ getAvailableColors(): Promise<{
1563
+ fill: string | undefined;
1564
+ stroke: string | undefined;
1565
+ variant: import("@spiffcommerce/papyrus").VariantResource;
1566
+ }[] | undefined>;
1567
+ hasVaryingSelection(): boolean | undefined;
1568
+ hasVaryingColors(): boolean | undefined;
1569
+ isColorPickerEnabled(): boolean | undefined;
1570
+ }
1571
+ export class MaterialStepHandle extends StepHandle<_MaterialStepData1> {
1572
+ constructor(manager: WorkflowManager, step: _Step1<_MaterialStepData1>);
1573
+ selectVariant(variant: Variant): Promise<void>;
1574
+ }
1575
+ export class ModelStepHandle extends StepHandle<_ModelStepData1> {
1576
+ constructor(manager: WorkflowManager, step: _Step1<_ModelStepData1>);
1577
+ selectVariant(variant: Variant): Promise<void>;
1578
+ }
1579
+ export class PictureStepHandle extends StepHandle<_PictureStepData1> {
1580
+ constructor(manager: WorkflowManager, step: _Step1<_PictureStepData1>);
1581
+ /**
1582
+ * Allows the user to select an image variant from the available variants configured on this steps base option.
1583
+ * @param variant The new image variant to use.
1584
+ * @returns A promise that can be awaited to ensure the new image asset has been updated on the design.
1585
+ */
1586
+ selectVariant(variant: Variant): Promise<void>;
1587
+ }
1588
+ export class QuestionStepHandle extends StepHandle<_QuestionStepData1> {
1589
+ constructor(manager: WorkflowManager, step: _Step1<_QuestionStepData1>);
1590
+ selectVariant(variant: Variant): Promise<void>;
1591
+ /**
1592
+ * The way that this step expects to be rendered.
1593
+ */
1594
+ getDisplayType(): string | undefined;
1595
+ }
1596
+ export class ShapeStepHandle extends StepHandle<_ShapeStepData1> {
1597
+ constructor(manager: WorkflowManager, step: _Step1<_ShapeStepData1>);
1598
+ selectVariant(variant: Variant): Promise<void>;
1599
+ /**
1600
+ * Sets the color of the shape.
1601
+ * @param color The color option to use.
1602
+ * @returns A promise resolving when the color has changed in the design.
1603
+ * @deprecated The shape step can now pass through colors returned by getColors via selectVariant. Please swap setColor for selectVariant.
1604
+ */
1605
+ setColor(color: ColorOption): Promise<void>;
1606
+ /**
1607
+ * Get available colors for the shape.
1608
+ * @returns A list of color definitions that are currently applied to the illustration.
1609
+ */
1610
+ getColors(): Promise<{
1611
+ fill: string | undefined;
1612
+ stroke: string | undefined;
1613
+ variant: import("@spiffcommerce/papyrus").VariantResource;
1614
+ }[]>;
1615
+ }
1616
+ interface TextChangeResult {
1617
+ input: string;
1618
+ helperText?: string;
1619
+ errorText?: string;
1620
+ }
1621
+ export class TextStepHandle extends StepHandle<_TextStepData1> {
1622
+ constructor(manager: WorkflowManager, step: _Step1<_TextStepData1>);
1623
+ /**
1624
+ * Allows for select a font from the available fonts configured on this steps base option.
1625
+ * @param variant The font variant to use.
1626
+ */
1627
+ selectVariant(variant: Variant): Promise<void>;
1628
+ /**
1629
+ * @returns A list of colors that can be used to fill the text.
1630
+ */
1631
+ getAvailableFillColors(): ColorOption[];
1632
+ /**
1633
+ * Changes the fill of text related to this step to the new fill value.
1634
+ * @param fill A new fill value to use.
1635
+ */
1636
+ setFillColor(fill: ColorOption): Promise<void>;
1637
+ /**
1638
+ * Gets the color currently applied to the element.
1639
+ */
1640
+ getFillColor(): string;
1641
+ getAvailableFillImages(): Promise<TextFillImage[]>;
1642
+ setFillImage(fillImage: TextFillImage): Promise<void>;
1643
+ getFillImage(): TextFillImage | undefined;
1644
+ /**
1645
+ * When true & the step has replaceable text configured the user will be
1646
+ * abled to edit the entire text string including the non-replaceable text.
1647
+ * @param shouldCustomizeAll When true the user can configure the entire text string.
1648
+ */
1649
+ setFullTextCustomization(shouldCustomizeAll: boolean): TextChangeResult;
1650
+ /**
1651
+ * Changes the text value of text related to this step to a new value.
1652
+ * @param userInput Input from the user.
1653
+ */
1654
+ setText(userInput: string): TextChangeResult;
1655
+ /**
1656
+ * Gets the text currently applied to the elements of this step.
1657
+ */
1658
+ getText(): string;
1659
+ isReplaceable(): boolean | undefined;
1660
+ /**
1661
+ * Inform the step that now is the time to
1662
+ * clear default text if it should do so.
1663
+ * Returns a text change rwsult if a clear occurred.
1664
+ */
1665
+ clearDefaultTextIfNecessary(): TextChangeResult | undefined;
1666
+ hasVaryingText(): boolean | undefined;
1667
+ hasVaryingColor(): boolean | undefined;
1668
+ hasVaryingSelection(): boolean | undefined;
1669
+ hasColorPicker(): boolean | undefined;
1670
+ getRegions(): import("@spiffcommerce/papyrus").Region[];
1671
+ /**
1672
+ * Return the maximum characters allowed for
1673
+ * this step, or undefined if there is no limit.
1674
+ */
1675
+ getCharacterLimit(): number | undefined;
1676
+ /**
1677
+ * Return the remaining amount of characters that
1678
+ * the user is allowed to add, or undefined if there is no limit.
1679
+ */
1680
+ getCharactersRemaining(): number | undefined;
1681
+ }
1682
+ export const createDesign: (workflowManager: WorkflowManager, workflow: _Workflow1, layouts: _ILayout1[], getReducerState: () => _CommandState1, product: Product, transaction: Transaction, workflowSelections: WorkflowSelections, designName: string, onProgressUpdate: DesignCreationProgressUpdate, updateVariationRecords: (variationRecords: VariationRecord[]) => Promise<void>, variationRecords: VariationRecord[], createPreviewImage: (shouldRender3D?: boolean) => Promise<string>, workflowMetadata?: WorkflowMetadata) => Promise<DesignCreationMessage>;
1683
+ export interface SavedDesign {
1684
+ /**
1685
+ * The user's name for this saved design.
1686
+ */
1687
+ title: string;
1688
+ /**
1689
+ * A URL pointing to an image of the design. Typically a data URL
1690
+ */
1691
+ thumbnail?: string;
1692
+ /**
1693
+ * The ID of the transaction relating to this design.
1694
+ */
1695
+ transactionId: string;
1696
+ /**
1697
+ * The product ID for this transaction.
1698
+ */
1699
+ productId: string;
1700
+ /**
1701
+ * The integration product ID related to this order.
1702
+ */
1703
+ integrationProductId: string;
1704
+ /**
1705
+ * The name of the workflow annotated at time of save (may be different from current workflow name).
1706
+ */
1707
+ workflowName: string;
1708
+ /**
1709
+ * The ID of the workflow annotated at time of save.
1710
+ */
1711
+ workflowId: string;
1712
+ /**
1713
+ * The last edit that occured on this saved design.
1714
+ */
1715
+ lastEdited: Date;
1716
+ }
1717
+ /**
1718
+ * The design service exposes helper functionality wrapping important design management operations.
1719
+ * NOTE: In the future this interface should allow for storing/pulling designs from the server.
1720
+ */
1721
+ declare class DesignService {
1722
+ readonly localPersistenceKey = "designTransactions";
1723
+ /**
1724
+ * @param func The function to call when a design is saved.
1725
+ */
1726
+ attachSaveListener(func: (design: SavedDesign) => void): void;
1727
+ /**
1728
+ * @param func The function to remove from the list of listeners.
1729
+ */
1730
+ detachSaveListener(func: (design: SavedDesign) => void): void;
1731
+ /**
1732
+ * Gets the currently persisted designs.
1733
+ */
1734
+ getSavedDesigns(): Promise<SavedDesign[]>;
1735
+ /**
1736
+ * Search for a transaction that has been saved.
1737
+ * @param transactionId The id to search for.
1738
+ * @returns The transaction for the given id provided it has been saved. undefined if it doesn't exist.
1739
+ */
1740
+ getSavedDesignByTransaction(transactionId: string): Promise<SavedDesign | undefined>;
1741
+ /**
1742
+ * Saves a design to storage.
1743
+ * @param design The design to save.
1744
+ */
1745
+ addDesign(design: SavedDesign): Promise<void>;
1746
+ /**
1747
+ * Change the user's name of the given saved design.
1748
+ */
1749
+ renameDesign(transactionId: string, title: string): Promise<void>;
1750
+ /**
1751
+ * Removes a given design from storage.
1752
+ * @param transactionId
1753
+ */
1754
+ removeDesign(transactionId: string): Promise<void>;
1755
+ }
1756
+ export const designService: DesignService;
1757
+ /**
1758
+ * A scene is a collection of steps that can be used to group steps together.
1759
+ */
1760
+ interface Scene {
1761
+ /**
1762
+ * The unique identifier for the scene.
1763
+ */
1764
+ id?: string;
1765
+ /**
1766
+ * The name of the scene.
1767
+ */
1768
+ name: string;
1769
+ /**
1770
+ * The steps that are part of the scene. A list of ids. See getStepById.
1771
+ */
1772
+ stepIds: string[];
1773
+ }
1774
+ /**
1775
+ * A Workflow experience encapsulates the workflow manager and command context. It
1776
+ * provides a simplified interface for interacting with the workflow manager. You
1777
+ * should get an instance of this class from a Client you have constructed previously.
1778
+ */
1779
+ export interface WorkflowExperience {
1780
+ /**
1781
+ * Returns the client that was responsible for spawning this experience.
1782
+ */
1783
+ getClient(): SpiffCommerceClient;
1784
+ /**
1785
+ * State related to the design of the user.
1786
+ */
1787
+ getCommandContext(): CommandContext;
1788
+ /**
1789
+ * Returns true when the user may only view the design.
1790
+ */
1791
+ getIsReadOnly(): boolean;
1792
+ /**
1793
+ * Get the low level workflow amanager instance for this experience. Don't touch this unless you're willing to break things.
1794
+ */
1795
+ getWorkflowManager(): WorkflowManager;
1796
+ /**
1797
+ * Bulk workflow operation, used to update multiple variations at once.
1798
+ */
1799
+ updateVariationRecords(variationRecords: VariationRecord[]): Promise<void>;
1800
+ /**
1801
+ * Returns the step matching a given name, undefined if not found.
1802
+ * @param id The id the step must match.
1803
+ */
1804
+ getStepById(id: string): StepHandle<_AnyStepData1> | undefined;
1805
+ /**
1806
+ * Returns the bulk step, undefined if not found.
1807
+ */
1808
+ getBulkStep(): BulkStepHandle | undefined;
1809
+ /**
1810
+ * Returns the step matching a given name, undefined if not found.
1811
+ * @param name The name the step must match.
1812
+ */
1813
+ getStepByName(name: string): StepHandle<_AnyStepData1> | undefined;
1814
+ /**
1815
+ * Returns all steps matching a specific type in the workflow. These steps
1816
+ * may be across multiple scenes and may or may not be active based on condition state.
1817
+ */
1818
+ getStepsByType(type: _StepType1): StepHandle<_AnyStepData1>[];
1819
+ /**
1820
+ * Returns all steps that are children of a given scene.
1821
+ * @param scene The scene you want the steps for.
1822
+ */
1823
+ getStepsByScene(scene: Scene): StepHandle<_AnyStepData1>[];
1824
+ /**
1825
+ * Returns all steps in the workflow that are currently active. Ordered by scene and appearance within their respective scenes.
1826
+ */
1827
+ getSteps(): StepHandle<_AnyStepData1>[];
1828
+ /**
1829
+ * Returns a list of scenes that are configured in the workflow. Each scene
1830
+ * contains a list of steps. See getStepsByScene to access these.
1831
+ */
1832
+ getScenes(): Scene[];
1833
+ /**
1834
+ * Returns the total cost in subunits for all selections made on the design.
1835
+ */
1836
+ getSelectionPriceSubunits(): number;
1837
+ /**
1838
+ * Returns the total cost in subunits for the base product.
1839
+ */
1840
+ getBasePriceSubunits(): number;
1841
+ /**
1842
+ * A convenience function returning the sum of the selection and base price values.
1843
+ */
1844
+ getTotalPriceSubunits(): number;
1845
+ /**
1846
+ * Attach specific details about the customer to the experience. This is useful for things like retargeting. Currently only
1847
+ * email is supported. From SpiffCommerce hosted experiences these details will be attached whenever the customer has provided & given permission.
1848
+ * @param details The new customer details. Only email is supported.
1849
+ * @deprecated Use assignCustomerDetails instead.
1850
+ */
1851
+ attachCustomerDetails(details: {
1852
+ /**
1853
+ * An email used for things like sending a design to the user.
1854
+ */
1855
+ email: string;
1856
+ }): Promise<void>;
1857
+ /**
1858
+ * Attach specific details about the customer to the experience. This is useful for things like retargeting.
1859
+ * From SpiffCommerce hosted experiences these details will be attached whenever the customer has provided & given permission.
1860
+ * @param details The new customer details.
1861
+ */
1862
+ assignCustomerDetails(details: CustomerDetailsInput): Promise<void>;
1863
+ /**
1864
+ * Attaches a listener to the scenes on a workflow experience. The scenes returned are a subset of the scenes configured in the
1865
+ * workflow and are based on the current state of the experience. This is useful for building a navigation menu.
1866
+ * @param cb The callback to be called when the scenes change. The new scenes are passed as an argument.
1867
+ */
1868
+ attachRenderableSceneListener(cb: (scenes: RenderableScene[]) => void): void;
1869
+ /**
1870
+ * Detaches a listener from the scenes on a workflow experience.
1871
+ */
1872
+ detachRenderableSceneListener(cb: (scenes: RenderableScene[]) => void): void;
1873
+ /**
1874
+ * Saves this experience to storage. This may be local or remote depending
1875
+ * on configuration.
1876
+ * @param title The title for the saved design.
1877
+ */
1878
+ save(title: string): Promise<SavedDesign>;
1879
+ /**
1880
+ * Returns a copy of the currently loaded design as a new, seperated workflow experience with
1881
+ * a fresh transaction.
1882
+ */
1883
+ copy(): Promise<WorkflowExperience>;
1884
+ /**
1885
+ * Creates a data URL preview for the current design.
1886
+ */
1887
+ createPreviewImage(isThreeD?: boolean, resolution?: number): Promise<string>;
1888
+ /**
1889
+ * To be called when the workflow experience is considered completed by the user.
1890
+ * @param onProgressUpdate Progress callback for finalizing the design. Optional
1891
+ */
1892
+ onDesignFinished(onProgressUpdate?: DesignCreationProgressUpdate): Promise<DesignCreationMessage>;
1893
+ /**
1894
+ * Returns the metadata associated with this workflow experience.
1895
+ * This is a combination of the metadata from the workflow, and the selections made by the user.
1896
+ */
1897
+ getExportedData(): Map<string, {
1898
+ [key: string]: string;
1899
+ }>;
1900
+ }
1901
+ export enum FrameStep {
1902
+ SelectFrame = "SelectFrame",
1903
+ SelectImage = "SelectImage",
1904
+ Position = "Position"
1905
+ }
1906
+ export class FrameStepHandle extends StepHandle<_FrameStepData1> {
1907
+ constructor(manager: WorkflowManager, step: _Step1<_FrameStepData1>);
1908
+ selectVariant(variant: Variant): Promise<void>;
1909
+ onFrameDataChanged(callback: (frameData: _FrameData1[]) => void): void;
1910
+ selectImage(asset: _Asset1): void;
1911
+ getImageData(): PatternImageData | undefined;
1912
+ getCurrentFrameStep(frameData: _FrameData1, uploading?: any, imageUploadComplete?: any, variants?: _VariantResource1[]): FrameStep;
1913
+ getFrameService(): FrameService | undefined;
1914
+ hasOverlayImageKey(): string | undefined;
1915
+ hasOverlayImageUrl(): any;
1916
+ hasVaryingUpload(): boolean | undefined;
1917
+ hasVaryingSelection(): boolean | undefined;
1918
+ }
1919
+ /**
1920
+ * A GlobalPropertyHandle acts as an interface to global properties on our platform. Currently
1921
+ * bundles can return a handle for any global properties associated to the collection.
1922
+ */
1923
+ declare abstract class GlobalPropertyHandle {
1924
+ protected readonly bundle: _Bundle1;
1925
+ protected readonly property: GlobalPropertyConfigurationAspect;
1926
+ constructor(bundle: _Bundle1, property: GlobalPropertyConfigurationAspect);
1927
+ /**
1928
+ * @returns The name of the global property. This is the key used to store the property in the state.
1929
+ */
1930
+ getName(): string;
1931
+ /**
1932
+ * @returns A human friendly title.
1933
+ */
1934
+ getTitle(): string;
1935
+ /**
1936
+ * @returns A human friendly description.
1937
+ */
1938
+ getDescription(): string;
1939
+ /**
1940
+ * @returns The type of the global property. Use this to determine how to render the property.
1941
+ */
1942
+ getType(): AspectType;
1943
+ /**
1944
+ * @returns The underlying property data object.
1945
+ */
1946
+ getRawProperty(): GlobalPropertyConfigurationAspect;
1947
+ /**
1948
+ * Applies the global state to all shared steps, if the state is set.
1949
+ * @param targetExperiences Optionally filter the workflow experiences it should be applied to.
1950
+ */
1951
+ abstract applyGlobalState(targetExperiences?: WorkflowExperience[]): Promise<void>;
1952
+ /**
1953
+ * Returns all steps that share this property.
1954
+ * @param targetExperiences Optionally filter the steps to only those in the given experiences.
1955
+ */
1956
+ protected getSharedSteps(targetExperiences?: WorkflowExperience[]): import("stepHandles").StepHandle<import("index").AnyStepData>[];
1957
+ }
1958
+ interface GlobalPropertyStateManager {
1959
+ getGlobalPropertyState(): GlobalPropertyState | undefined;
1960
+ getAspect(name: string): string | undefined;
1961
+ setAspect(name: string, value: string): Promise<void>;
1962
+ }
1963
+ /**
1964
+ * A bundle serves as a container for a set of workflow experience.
1965
+ */
1966
+ interface _Bundle1 {
1967
+ /**
1968
+ * @returns The client that this bundle is associated with.
1969
+ */
1970
+ getClient(): SpiffCommerceClient;
1971
+ /**
1972
+ * @returns The id of the bundle entity in the Spiff Commerce system.
1973
+ */
1974
+ getId(): string;
1975
+ /**
1976
+ * @returns The name of the bundle.
1977
+ */
1978
+ getName(): string;
1979
+ /**
1980
+ * Set the name of the bundle.
1981
+ * @param name The new name for the bundle.
1982
+ * @returns A promise that resolves when the name has been updated in the Spiff Commerce system.
1983
+ */
1984
+ setName(name: string): Promise<void>;
1985
+ /**
1986
+ * @returns Custom metadata associated with this bundle.
1987
+ */
1988
+ getMetadata(): Map<string, string>;
1989
+ /**
1990
+ * Set custom metadata associated with this bundle.
1991
+ * @param metadata Updated map of metadata items.
1992
+ * @returns A promise that resolves when the metadata has been updated in the Spiff Commerce system.
1993
+ */
1994
+ setMetadata(metadata: Map<string, string>): Promise<void>;
1995
+ /**
1996
+ * Set the name and metadata for this bundle.
1997
+ * @param name The new name for the bundle.
1998
+ * @param metadata Updated map of metadata items.
1999
+ * @returns A promise that resolves when the name and metadata have been updated in the Spiff Commerce system.
2000
+ */
2001
+ setNameAndMetadata(name: string, metadata: Map<string, string>): Promise<void>;
2002
+ /**
2003
+ * Returns true when the bundle contains products that share global properties.
2004
+ */
2005
+ hasGlobalProperties(): boolean;
2006
+ /**
2007
+ * Get a handle to the global properties available within this bundle. Setting values
2008
+ * via this method will make selections on all bundles that share the property.
2009
+ */
2010
+ getGlobalProperties(): Promise<GlobalPropertyHandle[]>;
2011
+ /**
2012
+ * Get the low level state manager for this bundle. Don't use this unless you know what you're doing.
2013
+ */
2014
+ getGlobalPropertyStateManager(): GlobalPropertyStateManager;
2015
+ /**
2016
+ * Get the total in subunits for all global properties in this bundle.
2017
+ */
2018
+ getGlobalPropertyTotalSubunits(): Promise<number>;
2019
+ /**
2020
+ * Return the total in subunits for this bundle. This is the sum of the total for all individual transactions.
2021
+ */
2022
+ getTotalSubunits(): number;
2023
+ /**
2024
+ * Retrieves the product collection associated with this bundle.
2025
+ * If the bundle is not associated with a product collection, this method will return undefined.
2026
+ */
2027
+ getProductCollection(): ProductCollection | undefined;
2028
+ /**
2029
+ * Add another workflow experience to this bundle.
2030
+ * @param experience The workflow experience to add to this bundle.
2031
+ */
2032
+ addWorkflowExperience(experience: WorkflowExperience): Promise<void>;
2033
+ /**
2034
+ * Remove a workflow experience from this bundle.
2035
+ * @param experience The workflow experience to remove from this bundle.
2036
+ */
2037
+ removeWorkflowExperience(experience: WorkflowExperience): Promise<void>;
2038
+ /**
2039
+ * Returns all workflow experiences currently added to this bundle.
2040
+ */
2041
+ getWorkflowExperiences(): WorkflowExperience[];
2042
+ /**
2043
+ * Sort the list of workflow experiences. The sorting is performed locally, and then the order is updated in the Spiff Commerce system.
2044
+ * @returns A promise that resolves when the re-ordering of the workflow experiences has been updated in the Spiff Commerce system.
2045
+ * The sorting will occur immediately, but the promise will not resolve until the Spiff Commerce system has been updated.
2046
+ */
2047
+ sortWorkflowExperiences(sortFunc: (expA: WorkflowExperience, expB: WorkflowExperience) => number): Promise<void>;
2048
+ /**
2049
+ * @returns The number of workflow experiences in this bundle.
2050
+ */
2051
+ getWorkflowExperienceCount(): number;
2052
+ /**
2053
+ * Add a stakeholder to this bundle. If the stakeholder already exists, it will be updated. Write access to the bundle is required.
2054
+ * @param customerDetails The details of the customer to add. The emailAddress field is required.
2055
+ * @param stakeholderType The type of stakeholder to add. Defaults to Owner.
2056
+ */
2057
+ addStakeholder(customerDetails: CustomerDetailsInput, stakeholderType?: StakeholderType): Promise<void>;
2058
+ /**
2059
+ * Updates all stakeholders associated with this bundle. Write access to the bundle is required.
2060
+ * @param stakeholders An array of stakeholders to update. Unknown stakeholders will be added, and absent stakeholders will be removed.
2061
+ */
2062
+ updateStakeholders(stakeholders: BundleStakeholderInput[]): Promise<void>;
2063
+ /**
2064
+ * Retrieves all stakeholders associated with this bundle.
2065
+ */
2066
+ getAllStakeholders(): Promise<BundleStakeholder[]>;
2067
+ /**
2068
+ * Finalizes all experiences within the bundle. This will return a promise that resolves when all experiences have been finalized.
2069
+ * The promise resolves with a list of messages that indicate the status of each experience including
2070
+ * helpful details like what product to add to cart on supported e-commerce platforms.
2071
+ */
2072
+ finish(): Promise<DesignCreationMessage[]>;
2073
+ /**
2074
+ * Add an event listener to this bundle.
2075
+ * @param event The event to listen for. Currently only "conditional-global-properties-changed" is supported.
2076
+ * @param listener The listener to call when the event occurs.
2077
+ */
2078
+ addEventListener(event: BundleEvent, listener: () => void): void;
2079
+ /**
2080
+ * Remove a previously added event listener from this bundle.
2081
+ */
2082
+ removeEventListener(event: BundleEvent, listener: () => void): void;
2083
+ }
2084
+ type BundleEvent = "conditional-global-properties-changed";
2085
+ interface ExecutionResponse {
2086
+ id: string;
2087
+ completedAt?: string;
2088
+ failedAt?: string;
2089
+ }
2090
+ /**
2091
+ * A service containing functionality for interacting with the Spiff Commerce API to execute and inspect the result of process flows.
2092
+ */
2093
+ declare class FlowService {
2094
+ execute(id: string, inputs: FlowExecutionInput[], options?: {
2095
+ sleepTime: number;
2096
+ }): Promise<ExecutionResponse>;
2097
+ }
2098
+ /**
2099
+ * Handles preparing a flow input for transmission to the server.
2100
+ */
2101
+ declare abstract class FlowExecutionInput {
2102
+ protected readonly value: string;
2103
+ constructor(value: string);
2104
+ getRaw(): string;
2105
+ getValueForTransmission(): string;
2106
+ }
2107
+ /**
2108
+ * Represents the type of object being referenced by the input.
2109
+ */
2110
+ export const enum ObjectInputType {
2111
+ Transaction = "Transaction",
2112
+ Bundle = "Bundle",
2113
+ Product = "Product",
2114
+ Variant = "Variant",
2115
+ Option = "Option",
2116
+ LineItem = "LineItem",
2117
+ Asset = "Asset"
2118
+ }
2119
+ /**
2120
+ * Handles validation of spiffObject structure for transmission to the server.
2121
+ */
2122
+ export class ObjectInput extends FlowExecutionInput {
2123
+ constructor(id: string, type: ObjectInputType);
2124
+ static validUUID(uuid: string): RegExpMatchArray | null;
2125
+ }
2126
+ /**
2127
+ * Handles validation of text input for transmission to the server.
2128
+ */
2129
+ export class TextInput extends FlowExecutionInput {
2130
+ constructor(id: string);
2131
+ }
2132
+ export const getWorkflow: (id: string) => Promise<_Workflow1>;
2133
+ /**
2134
+ * Options that can be used during instantiation of the SpiffCommerce Javascript Client.
2135
+ * Please refer to the documentation for more information.
2136
+ */
2137
+ interface ClientOptions {
2138
+ /**
2139
+ * When set to true, the client will treat the workflow as a bulk order
2140
+ * containing multiple variations of the base design.
2141
+ * @deprecated Specify when calling getWorkflowExperience instead.
2142
+ */
2143
+ bulk?: boolean;
2144
+ /**
2145
+ * When provided, the client will use the provided application key to
2146
+ * authenticate with the SpiffCommerce API.
2147
+ */
2148
+ applicationKey?: string;
2149
+ }
2150
+ interface GetWorkflowOptionsBase {
2151
+ /**
2152
+ * An existing preview service to use, instead of creating a new one.
2153
+ */
2154
+ previewService?: any;
2155
+ }
2156
+ interface GetWorkflowFromTransactionOptions extends GetWorkflowOptionsBase {
2157
+ /** The existing Transaction to use. */
2158
+ transactionId: string;
2159
+ /** If set to true, the workflow will display in a read-only mode. */
2160
+ readOnly?: boolean;
2161
+ /** An existing workflow state, if available. */
2162
+ workflowState?: string;
2163
+ type: "transaction";
2164
+ }
2165
+ interface GetWorkflowFromIntegrationProductOptions extends GetWorkflowOptionsBase {
2166
+ /** The workflow to load. */
2167
+ workflowId: string;
2168
+ integrationProductId: string;
2169
+ /** An existing workflow state, if available. */
2170
+ workflowState?: string;
2171
+ bulk?: boolean;
2172
+ type: "integration";
2173
+ }
2174
+ interface GetWorkflowFromExternalProductOptions extends GetWorkflowOptionsBase {
2175
+ /** The workflow to load. */
2176
+ workflowId: string;
2177
+ /** The external ID associated with an integration. */
2178
+ externalIntegrationId: string;
2179
+ /** The ID of the product from the external system. */
2180
+ externalProductId: string;
2181
+ /** An existing workflow state, if available. */
2182
+ workflowState?: string;
2183
+ bulk?: boolean;
2184
+ type: "external";
2185
+ }
2186
+ export type GetWorkflowOptions = GetWorkflowFromTransactionOptions | GetWorkflowFromIntegrationProductOptions | GetWorkflowFromExternalProductOptions;
2187
+ /**
2188
+ * The Spiff Commerce Javascript Client. Required for
2189
+ * creating workflow experiences.
2190
+ */
2191
+ export class SpiffCommerceClient {
2192
+ constructor(options: ClientOptions);
2193
+ /**
2194
+ * @returns The asset manager allows for common operations related to assets
2195
+ * and the Spiff Commerce platform.
2196
+ */
2197
+ getAssetManager(): AssetManager;
2198
+ getCurrencyCode(): string;
2199
+ getFlowService(): FlowService;
2200
+ /**
2201
+ * Attempts to load persisted authentication information from local storage, and authenticate with the Spiff Commerce API.
2202
+ * @param bundleId The ID of the bundle you intend to load.
2203
+ * @returns An object containing the success status of the authentication attempt, and the type of stakeholder when successful.
2204
+ */
2205
+ authenticateBundleFromLocalStorage(bundleId: string): Promise<{
2206
+ stakeholderType?: StakeholderType;
2207
+ success: boolean;
2208
+ }>;
2209
+ /**
2210
+ * Attempts to load persisted authentication information from local storage, and authenticate with the Spiff Commerce API.
2211
+ * @param transactionId The ID of the transaction that the user is attempting to load.
2212
+ * @returns An object containing the following:
2213
+ * - `customLogoLink`: A link to a custom logo to display in the header.
2214
+ * - `transactionReadOnly`: Whether or not the transaction is read-only. Shadow will not accept any changes to the transaction if this is set to true.
2215
+ * - `stakeholderType`: The type of stakeholder that the user is authenticated as.
2216
+ * - `success`: Whether or not the authentication was successful.
2217
+ * @throws An error if the transaction is not found.
2218
+ */
2219
+ authenticateTransactionFromLocalStorage(transactionId: string): Promise<{
2220
+ customLogoLink?: string;
2221
+ transactionReadOnly?: boolean;
2222
+ stakeholderType?: StakeholderType;
2223
+ success: boolean;
2224
+ theme?: _Theme1;
2225
+ }>;
2226
+ clearCustomer(): void;
2227
+ clearCustomerForTransaction(transactionId: string): void;
2228
+ getStakeholderTypeForTransaction(transactionId: string): StakeholderType | undefined;
2229
+ getOrCreateCustomer(emailAddress: string): Promise<{
2230
+ customer: Customer;
2231
+ isAuthenticated: boolean;
2232
+ }>;
2233
+ /**
2234
+ * Generates a verification code for the given email address.
2235
+ * @param emailAddress The email address to generate a verification code for. The user will be sent an email with the verification code.
2236
+ */
2237
+ generateVerificationCode(emailAddress: string): Promise<void>;
2238
+ /**
2239
+ * Verifies the given email address with the given verification code.
2240
+ * @param emailAddress The email address to verify.
2241
+ * @param verificationCode The verification code to verify the email address with.
2242
+ * @returns True if the verification was successful, false otherwise.
2243
+ */
2244
+ verifyCode(emailAddress: string, verificationCode: string): Promise<boolean>;
2245
+ /**
2246
+ * @param collectionId Optional: The id of the product collection that the bundle can use.
2247
+ * @returns A bundle to be used for grouping and operating on large amounts of workflow experiences.
2248
+ */
2249
+ getNewBundle(collectionId?: string): Promise<_Bundle1>;
2250
+ /**
2251
+ * Retrieves an existing bundle from the API, by id.
2252
+ * @returns A bundle to be used for grouping and operating on large amounts of workflow experiences.
2253
+ */
2254
+ getExistingBundle(bundleId: string, previewServiceConstructor?: (workflow: _Workflow1, transactionId: string) => any): Promise<_Bundle1>;
2255
+ /**
2256
+ * Retrieves all existing bundle stakeholders from the API, for the currently authenticated customer.
2257
+ * @returns An array of bundle stakeholders.
2258
+ */
2259
+ getBundleStakeholders(): Promise<BundleStakeholder[]>;
2260
+ /**
2261
+ * Creates a new instance of WorkflowExperience. A high level wrapper for workflows.
2262
+ * @param workflowId The id of the workflow to be run. Deprecated: Provide options instead.
2263
+ * @param workflowState An existing workflow state if available. Deprecated: Provide options instead.
2264
+ * @param previewServiceConstructor A function called during initialization. Takes a class implementing ThreeDPreviewService in return.
2265
+ * @param options Options to configure loading the transaction and workflow.
2266
+ * @returns A workflow experience configured as requested.
2267
+ */
2268
+ getWorkflowExperience(workflowId?: string, workflowState?: string, previewServiceConstructor?: (workflow: _Workflow1) => any, options?: GetWorkflowOptions): Promise<WorkflowExperience>;
2269
+ /**
2270
+ * Initialize the client from an integration product.
2271
+ * @param integrationProductId The integration product to use.
2272
+ * @deprecated Use getWorkflowExperience to initialize the experience.
2273
+ */
2274
+ initFromIntegrationProduct(integrationProductId: string): Promise<void>;
2275
+ /**
2276
+ * Initialize the client from an existing transaction.
2277
+ * @param transactionId The id of the transaction
2278
+ * @returns A promise resolving at initialization completion.
2279
+ * @deprecated Use getWorkflowExperience to initialize the experience.
2280
+ */
2281
+ initFromTransaction(transactionId: string, readOnly?: boolean): Promise<void>;
2282
+ /**
2283
+ * @deprecated The value this returns will be changed whenever `getWorkflowExperience()` is called. Use `workflowExperience.getWorkflowManager().getPreviewService()` instead.
2284
+ * @returns The preview service that was provided during construction.
2285
+ */
2286
+ getPreviewService(): any;
2287
+ /**
2288
+ * @deprecated The value this returns will be changed whenever `getWorkflowExperience()` is called. Use `WorkflowManager.getProduct()` instead.
2289
+ * @returns The product associated with this client.
2290
+ */
2291
+ getProduct(): import("types").Product;
2292
+ /**
2293
+ * @deprecated The value this returns will be changed whenever `getWorkflowExperience()` is called. Use `WorkflowManager.getTransaction()` instead.
2294
+ * @returns The transaction associated with this client.
2295
+ */
2296
+ getTransaction(): Transaction;
2297
+ }
2298
+ export class MockWorkflowManager implements WorkflowManager {
2299
+ getInitializationPromise(): Promise<void>;
2300
+ getProduct: () => Product;
2301
+ isInitialized(): boolean;
2302
+ getCommandContext: () => _CommandContext1;
2303
+ getAllLayoutData: () => LayoutState[];
2304
+ getMetadata: (stepName: string) => StepMetadata | undefined;
2305
+ getWorkflowMetadata: () => WorkflowMetadata;
2306
+ getStepStorage: (stepName: string) => _StepStorage1 | undefined;
2307
+ getInformationResults(): InformationResult[];
2308
+ getVariationRecords(): VariationRecord[];
2309
+ reset(): Promise<void>;
2310
+ updateStateWithServer(_getReducerState: () => _CommandState1): void;
2311
+ addVariationRecord(_variationRecord: Omit<VariationRecord, "recordNumber">): {
2312
+ recordNumber: number;
2313
+ transactionId: string;
2314
+ values: never[];
2315
+ };
2316
+ getCurrentVariationRecord(): undefined;
2317
+ removeVariationRecord(_recordNumber: number): never[];
2318
+ outstandingRequestsPromise(): Promise<void>;
2319
+ updateStateWithServerImmediate(_getReducerState: () => _CommandState1): Promise<void>;
2320
+ addPoller(_poller: Poller): void;
2321
+ addConfirmCallback(_callback: ConfirmCallback): void;
2322
+ addCurrentVariationCallback(_callback: CurrentVariationRecordCallback): void;
2323
+ addEditedCallback(_callback: EditedCallback): void;
2324
+ addElementsCallback(_callback: ElementsCallback): void;
2325
+ addInformationResultCallback(_callback: InformationResultCallback): void;
2326
+ addInitCallback(_callback: InitCallback): void;
2327
+ addMakingAdjustmentsCallback(_callback: MakingAdjustmentsCallback): void;
2328
+ addMandatoryCallback(_callback: MandatoryCallback): void;
2329
+ addMetadataCallback(_callback: MetadataCallback): void;
2330
+ addSelectionCallback(_callback: SelectionCallback): void;
2331
+ addStepSpecificStorageCallback(_callback: StepSpecificStorageCallback, _stepName: string): void;
2332
+ addStorageCallback(_callback: StorageCallback): void;
2333
+ addVariationRecordsCallback(_callback: VariationRecordsCallback): void;
2334
+ getCommandDispatcher(): (_command: _CanvasCommand1) => void;
2335
+ getLayouts(): never[];
2336
+ getLayoutPreviewService(): {
2337
+ getAll: () => Map<any, any>;
2338
+ };
2339
+ getPreviewService(): undefined;
2340
+ setModelContainer: (container: any) => void;
2341
+ getModelContainer(): undefined;
2342
+ getProfanities(): never[];
2343
+ getRegionElements(_stepName: string): never[];
2344
+ getSerializedStep(_stepName: string, _serializedSteps: SerializableStep[]): undefined;
2345
+ getStepSpecificServices(_stepName: string): undefined;
2346
+ getTransaction(): {
2347
+ id: string;
2348
+ };
2349
+ getTransactionCustomer(): undefined;
2350
+ setTransactionCustomer(): void;
2351
+ setTransactionCustomerDetails(): void;
2352
+ getWorkflow(): {
2353
+ id: string;
2354
+ name: string;
2355
+ panels: never[];
2356
+ steps: never[];
2357
+ showModelOnFinishStep: boolean;
2358
+ allowProofDownload: boolean;
2359
+ introduction: string;
2360
+ stepGroups: never[];
2361
+ };
2362
+ markStepsAsInitialised(_stepNames: string[]): void;
2363
+ getUpdatesPending: () => boolean;
2364
+ markUpdateCompleted(_update: string): void;
2365
+ markUpdatePending(): string;
2366
+ getWorkflowSelections(): {};
2367
+ setCurrentAdjustingStepId(_stepId: string): void;
2368
+ setCurrentVariationRecord(_variationRecord: VariationRecord | null): void;
2369
+ setEditedStatus(_stepName: string, _status: boolean): void;
2370
+ setInformationResults(_results: InformationResult[]): void;
2371
+ setMandatoryFulfilled(_stepName: string, _status: boolean): void;
2372
+ setSelectionsAndElements(_stepName: string, _variants: _VariantResource1[], _elements: RegionElement[]): Promise<void>;
2373
+ setVariationRecords(_variationRecords: VariationRecord[]): void;
2374
+ toggleDesignConfirmed(): void;
2375
+ updateMetadata(_stepName: string, _update: any): void;
2376
+ updateStorage(_stepName: string, _update: _StepStorage1): Promise<void>;
2377
+ injectIntoPreviewService(_previewService: any): Promise<void>;
2378
+ ejectFromPreviewService(): void;
2379
+ }
2380
+ export const TransformWrapper: React.FunctionComponent;
2381
+ export { CommandContext };
2382
+ export { AssetType, BringForwardCommand, BringToFrontCommand, BringToBackCommand, CanvasCommand, CreateElementCommand, CreateLayoutCommand, DeleteElementCommand, FontAlignmentCommand, FontColorCommand, FontSizeCommand, FontSourceCommand, GroupCommand, LayoutElementFactory, LayoutElementType, MoveCommand, ResizeCommand, RotateCommand, SendBackwardsCommand, StepAspectType, StepType, TextChangeCommand, UnitOfMeasurement, dataUrlFromExternalUrl, findElement, frameDataCache, generate, getAxisAlignedBoundingBox, generateSVGWithUnknownColors, getAttributesFromArrayBuffer, rehydrateSerializedLayout, getFrameData, getSvgElement, loadFontFromDataUrl, loadFontFromExternalUrl, determineCorrectFontSizeAndLines, patternImageDataCache, registerJSDOM };
2383
+ export { Animatable, AnyStepData, Asset, BulkStepData, ColorProfileProps, ColorDefinition, CommandState, WorkflowPanel, DigitalContentStepData, FrameElement, FrameStepData, ILayout, IllustrationElement, IllustrationStepData, ImageElement, LayoutData, LayoutElement, LayoutsState, MaterialStepData, ModelStepData, ModuleStepData, OptionResource, PictureStepData, QuestionStepData, ShapeStepData, Step, StepAspect, StepStorage, TextStepData, TextboxElement, Theme, VariantResource, Workflow };
2384
+
2385
+ //# sourceMappingURL=types.d.ts.map