@spiffcommerce/core 0.8.0 → 0.8.1

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.
package/dist/types.d.ts CHANGED
@@ -1,1248 +1,1247 @@
1
- import { Workflow, StepAspect, Step, AnyStepData, FrameOffsets, PatternImageData, IServerModel, Asset, MaterialResource, AssetType, ColorDefinition, IllustrationStepData, Region, ILayout, CreateElementCommand as _CreateElementCommand1, IllustrationElement as _IllustrationElement1, LayoutsState as _LayoutsState1, VariantResource, CanvasCommand, LayoutData as _LayoutData1, DigitalContentStepData, FrameStepData, FrameElement as _FrameElement1, MaterialStepData, ModelStepData, ModuleStepData, PatchworkStepData, PatchworkOffsets, PictureStepData, QuestionStepData, ShapeStepData, FontData, GroupCommand, TextboxElement as _TextboxElement1, TextStepData as _TextStepData1, StepStorage, SerializableStep, CommandState, OptionResource, CommandContext as _CommandContext1, Point, ScaleAxis, UnitOfMeasurement, StepType, CommandContext, CreateElementCommand, FontAlignmentCommand, FontColorCommand, FrameElement, generate, IllustrationElement, LayoutData, ImageElement, LayoutElement, LayoutElementFactory, LayoutsState, PatchworkElement, TextboxElement, TextChangeCommand, TextStepData } from "@spiffcommerce/papyrus";
2
- import { ApolloClient } from "@apollo/client";
3
- import { ThreeDPreviewService as _ThreeDPreviewService1, SpiffCommerce3DPreviewService, ThreeDPreviewService } from "@spiffcommerce/preview";
4
- import { ReactNode, Dispatch, FunctionComponent, RefObject, PointerEvent, KeyboardEvent, MouseEvent } from "react";
5
- export const gatherVaryingStepAspects: (workflow: Workflow) => StepAspect[];
6
- export interface WorkflowScene {
7
- name: string;
8
- title: string;
9
- renderableSteps: Step<AnyStepData>[];
10
- silentSteps: Step<AnyStepData>[];
11
- }
12
- interface WorkflowScenesConfiguration {
13
- bulkScene: boolean;
14
- bulkSceneTitle: string;
15
- finishScene: boolean;
16
- finishSceneTitle: string;
17
- }
18
- /**
19
- * A queue promise is a container for a promise that can be
20
- * executed at a later time.
21
- */
22
- export abstract class QueueablePromise {
23
- readonly timestamp: number;
24
- abstract execute(): Promise<any>;
25
- }
26
- /**
27
- * A promise queue contains any number of QueuePromise objects. These objects are stored within a PromiseQueue and executed
28
- * as quickly as possible in order. This is ideal in situations where a specific operation should be
29
- * applied in an ordered way while still making.
30
- */
31
- export class PromiseQueue<T extends QueueablePromise> {
32
- /**
33
- * Constructs a new promise queue.
34
- * @param queueMaxSize An optional maximum size, when the max size is hit.
35
- * The older promises will be discarded.
36
- */
37
- constructor(queueMaxSize?: number);
38
- /**
39
- * Enqueue a new promise.
40
- * @param promise A new promise to add to the queue.
41
- */
42
- enqueue(promise: T): Promise<void>;
43
- /**
44
- * @returns Returns true when work is being actively processed by this queue.
45
- */
46
- hasActivePromise(): boolean;
47
- /**
48
- * @returns The number of unexecuted jobs remaining in the queue. Not including the active job.
49
- */
50
- getRemainingQueueSize(): number;
51
- /**
52
- * Finalize the queue, any jobs that come in while this is in progress will result
53
- * in the promise being extended.
54
- */
55
- finalize(): Promise<void>;
56
- }
57
- export class FrameService {
58
- minZoomScale: number;
59
- maxZoomScale: number;
60
- constructor(forceImageCover?: boolean);
61
- /**
62
- * When we want to connect a workflow manager to the state of the image cropper we
63
- * can pass it to this function. Inside we'll attach any required event listeners.
64
- * @param workflowManager The workflow manager to attach.
65
- * @param stepName The specific step we want to attach to within the manager.
66
- */
67
- connectWorkflowManager(workflowManager: WorkflowManager, stepName?: string): void;
68
- /**
69
- * Sets the elements that should be update when changes are made to
70
- * the cropper that owns this service.
71
- * @param targetElements A list of element Ids to track
72
- */
73
- setTargetElements(targetElements: string[]): void;
74
- /**
75
- * Gets the current calculated frame data
76
- * @returns A FrameData object or undefined if no frame has been set.
77
- */
78
- getFrameData(): FrameData | undefined;
79
- /**
80
- * Sets the current frame data
81
- * @param path The path to lookup in our frame data cache.
82
- */
83
- setFrameData(path: string): Promise<void>;
84
- /**
85
- * Gets the currently set image of the frame..
86
- * @returns A PatternImageData object, or undefined if no image is set.
87
- */
88
- getImageData(): PatternImageData | undefined;
89
- /**
90
- * Gets the current calculated offsets of the pattern within the frame.
91
- * @returns A FrameOffsets object or undefined if no offsets are defined.
92
- */
93
- getOffsets(): FrameOffsets | undefined;
94
- /**
95
- * Updates the frame offsets explicitly.
96
- */
97
- setOffsets(offsets: FrameOffsets): void;
98
- /**
99
- * Sets the zoom of the cropper that owns this service.
100
- * @param zoom The new zoom value.
101
- * @param cX The center of zoom on x axis
102
- * @param cY The center of zoom on Y axis
103
- * @param onComplete A function to call when zoom changes have been completed
104
- */
105
- setZoom(zoom: number, cX: number, cY: number, onComplete?: () => void): void;
106
- /**
107
- * Sets the image currently contained by this frame.
108
- * @param value The new image as an ImageData property
109
- */
110
- setPatternData(value: PatternImageData): void;
111
- /**
112
- * Modify the offsets of the frame.
113
- * @param value The new FrameOffsets object.
114
- * @param onComplete A callback, called when the modification is complete
115
- */
116
- updateOffsets(value: FrameOffsets, onComplete?: () => void): void;
117
- onFrameDataChanged(newListener: (frameData: FrameData | undefined) => void): void;
118
- /**
119
- * Append a new listener to zoom events on this frame.
120
- * @param newListener
121
- */
122
- onZoom(newListener: (zoomValue: number) => void): void;
123
- }
124
- declare class Poller {
125
- /**
126
- * Constructs a new polling service.
127
- * @param predicate An async function that returns true when polling has returned a successful result.
128
- * @param onSuccess The callback to be called when polling has returned a successful result.
129
- * @param onFailure The callback to be called when polling has returned a failed result.
130
- * @param interval The number of milliseconds to wait between each poll.
131
- * @param maxAttempts The maximum amount of times to check the condition.
132
- */
133
- constructor(predicate: () => Promise<boolean>, onSuccess: () => void, onFailure: () => void, interval?: number, maxAttempts?: number);
134
- }
135
- declare class Configuration {
136
- constructor();
137
- getServerUrl(): string;
138
- getServicesApiUrl(): string;
139
- getHubUrl(): string;
140
- setServerUrl(serverUrl: string): void;
141
- setServicesApiUrl(servicesApiUrl: string): void;
142
- setHubUrl(hubUrl: string): void;
143
- addServerUrlCallback(callback: () => void): void;
144
- }
145
- export const spiffCoreConfiguration: Configuration;
146
- declare class SwaggerServer implements ServerService {
147
- constructor();
148
- setUncachedOperations(operationIds: string[]): void;
149
- execute(operationName: string, parameters?: object): Promise<ServerResponse>;
150
- }
151
- export const server: SwaggerServer;
152
- declare class GraphQlManager {
153
- constructor();
154
- getShadowGraphqlClient(): ApolloClient<any>;
155
- }
156
- export const graphQlManager: GraphQlManager;
157
- declare class AssetService {
158
- constructor();
159
- /**
160
- * Allows for retrieving an asset, returns the option from a cache if possible.
161
- * @param server The server service for making the request.
162
- * @param id The asset key to be retrieved.
163
- */
164
- getLocalOrFromServer(assetKey: string): Promise<IServerModel<Asset>>;
165
- /**
166
- * Allows for retrieving amaterial, returns the option from a cache if possible.
167
- * @param server The server service for making the request.
168
- * @param id The option ID to be retrieved.
169
- */
170
- getMaterialLocalOrFromServer(id: string): Promise<IServerModel<MaterialResource>>;
171
- /**
172
- * Upload a user asset to the server. Using callbacks to notify important events.
173
- */
174
- uploadAssetWithProgress(file: FileInfo, assetType: AssetType, onProgress: (val: number) => void, onComplete: (asset: IServerModel<Asset>) => void, anonymous?: boolean, partnerId?: string): Promise<IServerModel<Asset>>;
175
- /**
176
- * Convert a File object for an image into a FileInfo.
177
- */
178
- loadImageAsFileInfo: (file: File) => Promise<FileInfo>;
179
- }
180
- export const assetService: AssetService;
181
- interface SVGCreateOpts {
182
- stepName?: string;
183
- src: string;
184
- objectURL: string;
185
- svg: {
186
- svg: string;
187
- colors: {
188
- [key: string]: ColorDefinition;
189
- };
190
- };
191
- }
192
- declare class IllustrationStepService implements StepService<IllustrationStepData> {
193
- getIllustrationBody(src: string): Promise<string>;
194
- getCreateElementCommand(id: string, region: Region, layout: ILayout, options: SVGCreateOpts): _CreateElementCommand1<_IllustrationElement1>;
195
- init(stepData: Step<IllustrationStepData>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
196
- availableColors(stepData: Step<IllustrationStepData>): {
197
- fill: string;
198
- stroke: string;
199
- }[];
200
- changeColorsCommand(svg: string, illustrationWidth: number, illustrationHeight: number, elements: string[], newFills: Map<string, string>): Promise<CanvasCommand>;
201
- changeColors(stepData: Step<IllustrationStepData>, elements: RegionElement[], workflowManager: WorkflowManager, getAllLayouts: () => _LayoutData1[], newFills: Map<string, string>): Promise<void>;
202
- selectVariant(stepData: Step<IllustrationStepData>, variant: VariantResource, elements: RegionElement[], setIsUpdating: (isUpdating: boolean) => void, workflowManager: WorkflowManager): void;
203
- }
204
- export const svgObjectURL: (svg: string) => Promise<string>;
205
- export const illustrationStepService: IllustrationStepService;
206
- declare class DigitalContentStepService implements StepService<DigitalContentStepData> {
207
- init(stepData: Step<DigitalContentStepData>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
208
- regenerateQRCode(elements: RegionElement[], uploading: boolean, assetKey: string, url: string, workflowManager: WorkflowManager, stepData: Step<DigitalContentStepData>, setUrl: (finalUrl: string) => void, commandDispatcher: (command: CanvasCommand) => void, setIsRegenerating: (state: boolean) => void): Promise<void>;
209
- }
210
- export const digitalContentStepService: DigitalContentStepService;
211
- interface FrameCreateOpts {
212
- stepName?: string;
213
- frameData: FrameData;
214
- disablePlaceholder?: boolean;
215
- focalBlur?: boolean;
216
- focalBlurStrength?: number;
217
- focalBlurRadius?: number;
218
- pattern?: any;
219
- }
220
- declare class FrameStepService implements StepService<FrameStepData> {
221
- init(stepData: Step<FrameStepData>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
222
- selectImage(stepData: Step<FrameStepData>, asset: IServerModel<Asset>, workflowManager: WorkflowManager): void;
223
- selectVariant(stepData: Step<FrameStepData>, variant: VariantResource | undefined, elements: RegionElement[], workflowManager: WorkflowManager, setFrameIsUpdating?: (status: boolean) => void): void;
224
- getCreateElementCommand(id: string, region: Region, layout: ILayout, options: FrameCreateOpts): _CreateElementCommand1<_FrameElement1>;
225
- loadPatternFromString(src: string, frameService: FrameService): Promise<void>;
226
- }
227
- export const frameStepService: FrameStepService;
228
- declare class MaterialStepService implements StepService<MaterialStepData> {
229
- init(stepData: Step<MaterialStepData>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<null | (() => Promise<void>)>;
230
- selectVariant(step: Step<MaterialStepData>, variant: VariantResource, workflowManager: WorkflowManager, setApplying: (status: boolean) => void): void;
231
- }
232
- export const materialStepService: MaterialStepService;
233
- declare class ModelStepService implements StepService<ModelStepData> {
234
- init(stepData: Step<ModelStepData>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<null | (() => Promise<void>)>;
235
- selectVariant(step: Step<ModelStepData>, variant: VariantResource, workflowManager: WorkflowManager, setApplying: (status: boolean) => void): void;
236
- }
237
- export const modelStepService: ModelStepService;
238
- declare class ModuleStepService implements StepService<ModuleStepData> {
239
- init(stepData: Step<ModuleStepData>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
240
- changeText(stepData: Step<ModuleStepData>, input: string, workflowManager: WorkflowManager, error: string, setError: (e: string) => void): void;
241
- }
242
- export const moduleStepService: ModuleStepService;
243
- declare class PatchworkStepService implements StepService<PatchworkStepData> {
244
- init(stepData: Step<PatchworkStepData>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
245
- recalculate(stepData: Step<PatchworkStepData>, elements: RegionElement[], workflowManager: WorkflowManager, setIsCalculating: (status: boolean) => void): void;
246
- selectVariant(stepData: Step<PatchworkStepData>, variant: VariantResource, elements: RegionElement[], workflowManager: WorkflowManager, setIsCalculating: (status: boolean) => void): void;
247
- /**
248
- * Constructs a preview SVG for a patchwork. Based on the configuration
249
- * of the given element.
250
- */
251
- constructPreviewSvg(stepData: Step<PatchworkStepData>, elements: RegionElement[], getAllLayouts: () => _LayoutData1[], offsets?: PatchworkOffsets): null | string;
252
- }
253
- export const patchworkStepService: PatchworkStepService;
254
- declare class PictureStepService implements StepService<PictureStepData> {
255
- init(stepData: Step<PictureStepData>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
256
- selectVariant(stepData: Step<PictureStepData>, variant: VariantResource, workflowManager: WorkflowManager, setIsUpdating: (status: boolean) => void): void;
257
- }
258
- export const pictureStepService: PictureStepService;
259
- declare class QuestionStepService implements StepService<QuestionStepData> {
260
- init(stepData: Step<QuestionStepData>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<null | (() => Promise<void>)>;
261
- selectVariant(stepData: Step<QuestionStepData>, variantId: string, workflowManager: WorkflowManager): void;
262
- }
263
- export const questionStepService: QuestionStepService;
264
- declare class ShapeStepService implements StepService<ShapeStepData> {
265
- colourOptions(stepData: Step<ShapeStepData>): {
266
- fill: string;
267
- stroke: string;
268
- }[];
269
- init(stepData: Step<ShapeStepData>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
270
- selectVariant(stepData: Step<ShapeStepData>, colourOption: ColorOption, elements: RegionElement[], workflowManager: WorkflowManager): void;
271
- }
272
- export const shapeStepService: ShapeStepService;
273
- type ToastCallback = (callbackOptions: {
274
- toastMessage: null | string;
275
- toastType: InformationMessageType | null;
276
- }) => void;
277
- declare class Toast {
278
- constructor();
279
- addToastCallback(callback: ToastCallback): void;
280
- setLatestToast(errorMessage: null | string, errorType: InformationMessageType | null): void;
281
- }
282
- export const toast: Toast;
283
- interface TextUpdateResult {
284
- command?: GroupCommand;
285
- helperText: string;
286
- errors: TextError[];
287
- }
288
- interface TextError {
289
- localizationKey: string;
290
- }
291
- declare class TextStepService implements StepService<_TextStepData1> {
292
- init(stepData: Step<_TextStepData1>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<CommandWithFollowup | null>;
293
- /**
294
- * @deprecated Only returns the first element. see findLayoutElements. A step can have multiple and we should return all of them!
295
- */
296
- findLayoutElement(workflowManager: WorkflowManager, step: Step<_TextStepData1>, getAllLayouts: () => any[]): _TextboxElement1;
297
- findLayoutElements(workflowManager: WorkflowManager, step: Step<_TextStepData1>, getAllLayouts: () => any[]): _TextboxElement1[];
298
- /**
299
- * Get the colors that can be used for a given text step.
300
- * @param stepData The text step to get colors for.
301
- * @returns A list of color objects containg fill, stroke and variant if available.
302
- */
303
- availableColors(stepData: Step<_TextStepData1>): ColorOption[];
304
- changeColor(stepData: Step<_TextStepData1>, newColor: ColorOption, elements: RegionElement[], workflowManager: WorkflowManager): void;
305
- /**
306
- * Given an element and a string, filters any characters from the string that are
307
- * not supported by the font of the given element.
308
- * @param layoutElement The element to use for glyph lookup.
309
- * @param text The text string to filter.
310
- * @returns A new string representing the passed string with unsupported characters removed.
311
- */
312
- filterUnsupportedCharacters: (layoutElement: _TextboxElement1 | undefined, text: string) => string;
313
- updateInputText(input: string, customiseAllText: boolean, elements: _TextboxElement1[], step: Step<_TextStepData1>, storage: TextStepStorage, workflowManager: WorkflowManager): TextUpdateResult;
314
- /**
315
- * @deprecated
316
- */
317
- changeInputTextWithRegion(step: Step<_TextStepData1>,
318
- /**
319
- * @deprecated
320
- */
321
- curFontSize: number,
322
- /**
323
- * @deprecated
324
- */
325
- curFontData: FontData, input: string, storage: TextStepStorage, workflowManager: WorkflowManager, customiseAllText: boolean, setError: (status: boolean) => void, setHelperText: (text: string) => void, setFlashRedError?: (status: boolean) => void): Promise<GroupCommand | undefined>;
326
- selectVariant(step: Step<_TextStepData1>, variant: VariantResource, storage: TextStepStorage, elements: RegionElement[], workflowManager: WorkflowManager, customiseAllText: boolean, setError: (status: boolean) => void, setHelperText: (text: string) => void): void;
327
- fontDataFromVariant(variant: VariantResource): Promise<FontData>;
328
- findOrCreateElements(workflowManager: WorkflowManager, step: Step<_TextStepData1>, getAllLayouts: () => any[]): Promise<_TextboxElement1[]>;
329
- textAlign: (stepData: _TextStepData1) => string;
330
- }
331
- export const textStepService: TextStepService;
332
- declare abstract class ModuleProduct {
333
- /**
334
- * Name used by class. Usually product or brand name.
335
- */
336
- abstract moduleName: string;
337
- /**
338
- * SVG with styled path positioned on a background image. To be displayed to user.
339
- */
340
- abstract svgPreview(text: string): string;
341
- /**
342
- * SVG with styled path positioned on a background image. To be submitted for print.
343
- */
344
- abstract svgPrint(text: string): string;
345
- }
346
- export interface EditedSteps {
347
- [stepName: string]: boolean;
348
- }
349
- export interface MandatorySteps {
350
- [stepName: string]: boolean;
351
- }
352
- export type StepElements = {
353
- [key: string]: RegionElement[];
354
- };
355
- type StepInitialised = {
356
- [key: string]: boolean;
357
- };
358
- type StepMetadata = FrameMetadata | IllustrationMetadata | ModuleMetadata | TextMetadata;
359
- export interface WorkflowStorage {
360
- [stepName: string]: StepStorage;
361
- }
362
- export interface WorkflowMetadata {
363
- [stepName: string]: StepMetadata;
364
- }
365
- export interface WorkflowSelections {
366
- [stepName: string]: {
367
- groupName?: string;
368
- optionName: string;
369
- selections: VariantResource[];
370
- };
371
- }
372
- export interface InformationResult {
373
- message: string;
374
- messageType: InformationMessageType;
375
- stepID: string;
376
- }
377
- export enum InformationMessageType {
378
- Error = "Error",
379
- Warning = "Warning"
380
- }
381
- /**
382
- * Services required for the operaiton of individual steps.
383
- */
384
- interface StepSpecificServices {
385
- frameService?: FrameService;
386
- module?: ModuleProduct;
387
- }
388
- type DesignCreationProgressUpdate = (message: string) => void;
389
- type ConfirmCallback = (isConfirmed: boolean) => void;
390
- type EditedCallback = (editedSteps: EditedSteps) => void;
391
- type ElementsCallback = (elements: StepElements) => void;
392
- type InformationResultCallback = (messages: InformationResult[]) => void;
393
- type InitCallback = (stepInitialised: StepInitialised) => void;
394
- type MakingAdjustmentsCallback = (makingAdjustments: string) => void;
395
- type MandatoryCallback = (mandatorySteps: MandatorySteps) => void;
396
- type MetadataCallback = (metadata: WorkflowMetadata) => void;
397
- type SelectionCallback = (callbackOptions: {
398
- invalidModelVariants: string[];
399
- selectionCost: number;
400
- selections: StepSelections;
401
- traversableScenes: WorkflowScene[];
402
- }) => void;
403
- type StepSpecificStorageCallback = (selections: StepStorage) => void;
404
- type StorageCallback = (storage: WorkflowStorage) => void;
405
- type UpdateCallback = (isUpdating: boolean) => void;
406
- type CurrentVariationRecordCallback = (variationRecord: null | VariationRecord) => void;
407
- type VariationRecordsCallback = (records: VariationRecord[]) => void;
408
- export interface WorkflowManager {
409
- addPoller: (poller: Poller) => void;
410
- addConfirmCallback: (callback: ConfirmCallback) => void;
411
- addCurrentVariationCallback: (callback: CurrentVariationRecordCallback) => void;
412
- addEditedCallback: (callback: EditedCallback) => void;
413
- addElementsCallback: (callback: ElementsCallback) => void;
414
- addInformationResultCallback: (callback: InformationResultCallback) => void;
415
- addInitCallback: (callback: InitCallback) => void;
416
- addMakingAdjustmentsCallback: (callback: MakingAdjustmentsCallback) => void;
417
- addMandatoryCallback: (callback: MandatoryCallback) => void;
418
- addMetadataCallback: (callback: MetadataCallback) => void;
419
- addSelectionCallback: (callback: SelectionCallback) => void;
420
- addStepSpecificStorageCallback: (callback: StepSpecificStorageCallback, stepName: string) => void;
421
- addStorageCallback: (callback: StorageCallback) => void;
422
- addUpdateCallback: (callback: UpdateCallback) => void;
423
- addVariationRecord: (variationRecord: Omit<VariationRecord, "recordNumber">) => VariationRecord;
424
- addVariationRecordsCallback: (callback: VariationRecordsCallback) => void;
425
- getCommandDispatcher: () => (command: CanvasCommand) => void;
426
- getCurrentVariationRecord: () => VariationRecord | undefined;
427
- getVariationRecords: () => VariationRecord[];
428
- getLayouts: () => ILayout[];
429
- getLayoutPreviewService: () => any;
430
- getPreviewService: () => _ThreeDPreviewService1 | undefined;
431
- getProductName: () => string | undefined;
432
- getProfanities: () => string[];
433
- getRegionElements: (stepName: string) => RegionElement[];
434
- getSerializedStep: (stepName: string, serializedSteps: SerializableStep[]) => SerializableStep | undefined;
435
- getStepSpecificServices: (stepName: string) => StepSpecificServices | undefined;
436
- getTransaction: () => Transaction;
437
- getWorkflow: () => Workflow;
438
- getWorkflowSelections: () => WorkflowSelections;
439
- markStepsAsInitialised: (stepNames: string[]) => void;
440
- markUpdateCompleted: (update: string) => void;
441
- markUpdatePending: (update: string) => void;
442
- outstandingRequestsPromise: () => Promise<void>;
443
- removeVariationRecord: (recordNumber: number) => VariationRecord[];
444
- reset: () => Promise<void>;
445
- setCurrentAdjustingStepId: (stepId: string) => void;
446
- setAllScenes: (config: WorkflowScenesConfiguration) => void;
447
- setCurrentVariationRecord: (variationRecord: null | VariationRecord) => void;
448
- setEditedStatus: (stepName: string, status: boolean) => void;
449
- setInformationResults: (results: InformationResult[]) => void;
450
- setMandatoryFulfilled: (stepName: string, status: boolean) => void;
451
- setSelectionsAndElements: (stepName: string, variants: VariantResource[], elements: RegionElement[]) => Promise<void>;
452
- setVariationRecords: (variationRecords: VariationRecord[]) => void;
453
- toggleDesignConfirmed: () => void;
454
- updateMetadata: (stepName: string, update: any) => void;
455
- updateStateWithServer: (getReducerState: () => CommandState) => void;
456
- updateStateWithServerImmediate: (getReducerState: () => CommandState) => Promise<void>;
457
- updateStorage: (stepName: string, update: StepStorage) => Promise<void>;
458
- }
459
- interface StepService<T extends AnyStepData> {
460
- /**
461
- * Initialize the given step, or reload from serialized data if present.
462
- */
463
- init(stepData: Step<T>, workflowManager: WorkflowManager, reducerState?: _LayoutsState1): Promise<any>;
464
- }
465
- interface FileInfo {
466
- /**
467
- * The name of the file.
468
- */
469
- name: string;
470
- /**
471
- * A blob object representing the
472
- * data of the file.
473
- */
474
- blob: Blob;
475
- }
476
- /**
477
- * A command along with a function to run afterwards.
478
- */
479
- interface CommandWithFollowup {
480
- command: CanvasCommand;
481
- followup: () => Promise<void>;
482
- }
483
- /**
484
- * The variant selections of a completed step.
485
- */
486
- interface SelectedVariants {
487
- [stepName: string]: {
488
- id: string;
489
- name: string;
490
- priceModifier: number;
491
- }[];
492
- }
493
- interface ExportedData {
494
- [name: string]: {
495
- value: string;
496
- priceModifier: number;
497
- };
498
- }
499
- export interface DesignCreationMessage {
500
- baseCost?: number;
501
- weight?: number;
502
- designProductId?: string;
503
- designProductVariantId?: string;
504
- event: string;
505
- exportedData: ExportedData;
506
- lineItemImageUrl: string;
507
- transactionId: string;
508
- metadata?: {
509
- [stepName: string]: string;
510
- };
511
- optionsCost: number;
512
- selectedVariants?: SelectedVariants;
513
- sku?: string;
514
- workflowViewerLink: string;
515
- }
516
- /**
517
- * Represents a transaction.
518
- */
519
- export interface Transaction {
520
- id: string;
521
- /**
522
- * User-supplied name for the associated design.
523
- */
524
- designName?: string;
525
- bulk?: boolean;
526
- /**
527
- * The workflow associated with this transaction.
528
- */
529
- workflowId?: string;
530
- /**
531
- * Temporary ID that grants write permission to the transaction.
532
- */
533
- transactionOwnerId?: string;
534
- /**
535
- * The current state of the design.
536
- */
537
- workflowState?: string;
538
- /**
539
- * URL to a partner-specific logo intended to display during the workflow experience.
540
- */
541
- customLogoLink?: string;
542
- /**
543
- * URL to a logo intended to display at the periphery of the workflow experience.
544
- */
545
- workflowFooterLogoLink?: string;
546
- /**
547
- * URL to the corresponding integration in the REST API.
548
- */
549
- restApiIntegrationLink?: string;
550
- /**
551
- * URL to redirect to when a workflow is finished.
552
- */
553
- callbackUrl?: string;
554
- /**
555
- * Product that this transaction belongs to.
556
- */
557
- product?: Product;
558
- /**
559
- * The line item corresponding to this transaction.
560
- */
561
- lineItem?: LineItem;
562
- /**
563
- * The external product variant ID representing the design product related
564
- * to this transaction, null unless the createDesignProduct flag was set
565
- * and the design was finalized using createDesign operation.
566
- */
567
- externalDesignProductVariantId?: string;
568
- /**
569
- * The external product id representing the design product related
570
- * to this transaction, null unless the createDesignProduct flag was set
571
- * and the design was finalized using createDesign operation.
572
- */
573
- externalDesignProductId?: string;
574
- priceModifierTotal?: number;
575
- /**
576
- * The amount of variations associated with this transaction.
577
- */
578
- variationsCount?: number;
579
- /**
580
- * URL to open the transaction in the workflow viewer.
581
- */
582
- workflowViewerLink?: string;
583
- bulkSourceUrl?: string;
584
- bulkEmailAddress?: string;
585
- lastSyncedAt?: string;
586
- }
587
- /**
588
- * Fields found in a variant within a line item resource.
589
- */
590
- interface LineItemVariant {
591
- currencyCode: string;
592
- optionName: string;
593
- priceModifier: number;
594
- stepName: string;
595
- variantName: string;
596
- }
597
- interface LineItem {
598
- id: string;
599
- transactionId?: string;
600
- previewImageUrl?: string;
601
- product: Product;
602
- quantity: number;
603
- metadata?: LineItemMetadata[];
604
- variants: LineItemVariant[];
605
- }
606
- interface LineItemMetadata {
607
- stepName: string;
608
- metadata: string;
609
- }
610
- interface ProductWorkflow {
611
- friendlyName: string;
612
- id: string;
613
- present?: boolean;
614
- imageUrl: string;
615
- workflowName: string;
616
- }
617
- interface Product {
618
- /**
619
- * ID of the partner owner.
620
- */
621
- partnerId?: string;
622
- /**
623
- * Whether a line item for this product is delivered as soon as the order is received.
624
- */
625
- autoprint: boolean;
626
- /**
627
- * Whether this product can be quickprinted.
628
- */
629
- canQuickprint?: boolean;
630
- /**
631
- * The internal identifier for this product.
632
- */
633
- id: string;
634
- /**
635
- * The human friendly name of the product.
636
- */
637
- name: string;
638
- /**
639
- * A URL to the image asset associated with this product.
640
- */
641
- imageUrl?: string;
642
- /**
643
- * A resource url for a 3D model used to represent this product
644
- * in the 3d editor. If not available we assume the product doesn't support 3D.
645
- */
646
- modelUrl?: string;
647
- /**
648
- * A URL for the image used as an overlay on any workflows
649
- * that incorporate a product overlay step.
650
- */
651
- overlayImageUrl?: string;
652
- /**
653
- * Words which can't be used in a workflow for this product.
654
- */
655
- profanities?: {
656
- id: string;
657
- createdAt: string;
658
- userId: string;
659
- word: string;
660
- }[];
661
- /**
662
- * The max characters that can be typed for quickprint.
663
- */
664
- quickprintMaxLength?: number;
665
- /**
666
- * The name of the module to use for quickprint.
667
- */
668
- quickprintModuleName?: string;
669
- /**
670
- * If true, the product should be displayed in the client as if it is available.
671
- * Should be displayed as if it is unavailable otherwise.
672
- */
673
- enabled: boolean;
674
- /**
675
- * Workflows which have been assigned to this product.
676
- */
677
- workflows?: ProductWorkflow[];
678
- /**
679
- * The base price of this product in sub units. Essentially the cost of the
680
- * product without any customisations applied.
681
- */
682
- basePrice?: number;
683
- /**
684
- * The weight of this product.
685
- */
686
- weight?: number;
687
- /**
688
- * When specified, represents a pre-rendered image of this product to be
689
- * displayed to customers while the 3D preview is loading.
690
- */
691
- preloadImageUrl?: string;
692
- }
693
- interface ColorOption {
694
- id?: string;
695
- fill?: string;
696
- stroke?: string;
697
- variant?: VariantResource;
698
- }
699
- /**
700
- * Represents a variation as seen in Google sheets.
701
- * Record number = row# - 1
702
- */
703
- export interface VariationRecord {
704
- recordNumber: number;
705
- transactionId: string;
706
- values: {
707
- stepName: string;
708
- aspect: string;
709
- value: string;
710
- }[];
711
- }
712
- export interface RegionElement {
713
- id: string;
714
- region?: Region;
715
- }
716
- interface FrameMetadata {
717
- image: string;
718
- }
719
- interface IllustrationMetadata {
720
- colors: string[];
721
- }
722
- interface ModuleMetadata {
723
- text: string;
724
- }
725
- interface TextMetadata {
726
- color?: string;
727
- text: string;
728
- }
729
- export interface SelectionStorage {
730
- selectedVariants?: VariantResource[];
731
- }
732
- interface TextStepStorage extends SelectionStorage {
733
- color?: string;
734
- defaultCleared?: boolean;
735
- inputText?: string;
736
- text?: string;
737
- }
738
- type StepSelections = {
739
- [key: string]: SelectionStorage;
740
- };
741
- interface ServerResponse {
742
- /**
743
- * Will contain error information if an error was recieved
744
- */
745
- errors?: string[];
746
- /**
747
- * The body of the response containing any return data.
748
- */
749
- body: object;
750
- headers: {
751
- "content-type": string;
752
- };
753
- }
754
- interface ServerService {
755
- /**
756
- * Sets the operation names that should be converted to their correspondingun-cached equivelants.
757
- */
758
- setUncachedOperations: (operationIds: string[]) => void;
759
- /**
760
- * Execute an operation against the server.
761
- */
762
- execute: (operationId: string, operationParameters?: object, anonymous?: boolean) => Promise<ServerResponse>;
763
- }
764
- interface FrameData {
765
- /**
766
- * The path data for a frame SVG
767
- */
768
- path: string;
769
- /**
770
- * The viewbox width
771
- */
772
- width: number;
773
- /**
774
- * The viewbox height.
775
- */
776
- height: number;
777
- }
778
- /**
779
- * Defines the different behaviors supported by the camera system
780
- * for control when viewing a product.
781
- */
782
- export enum ProductCameraRig {
783
- Orbit = 0,
784
- Pan = 1
785
- }
786
- export type LoadProgressEventData = {
787
- /**
788
- * The total load value of the scene, this is an average of all
789
- * 'in progress' loading events. when all events are fully loaded this value will be 100.
790
- */
791
- readonly loadValue: number;
792
- /**
793
- * This value is true when the base model and scene have been initialized.
794
- */
795
- readonly sceneInitialized: boolean;
796
- };
797
- declare class OptionService {
798
- /**
799
- * Returns a promise that resolves once all options required for a given workflow
800
- * have been loaded and cached ready for use.
801
- * @param workflow The workflow to load options for.
802
- */
803
- cacheRequiredOptions(workflow: Workflow): Promise<void>;
804
- /**
805
- * Allows for retrieving an option, returns the option from a cache if possible.
806
- * @param server The server service for making the request.
807
- * @param id The option ID to be retrieved.
808
- */
809
- getLocalOrFromServer(server: ServerService, id: string): Promise<IServerModel<OptionResource>>;
810
- /**
811
- * Returns an option from the cache, or null
812
- * @param id The ID to search for.
813
- */
814
- getLocalOrUndefined(id?: string): IServerModel<OptionResource>;
815
- getAssetTileImageForVariant(variant: VariantResource): Promise<string>;
816
- getDefaultVariant(option: OptionResource): VariantResource | undefined;
817
- getDisplayImageSource: (variant?: VariantResource) => undefined | string;
818
- /**
819
- * Returns the first variant marked as selected. This is used by most steps.
820
- */
821
- getSelectedVariant: (option: OptionResource | undefined, selectedVariantIds: string[]) => VariantResource | undefined;
822
- /**
823
- * Returns all selected variants. This is used by the question step as multiple selections can be made.
824
- */
825
- getSelectedVariants: (option: OptionResource | undefined, selectedVariantIds: string[]) => VariantResource[];
826
- }
827
- export const optionService: OptionService;
828
- export const CommandContextContext: import("react").Context<_CommandContext1>;
829
- export const useLayouts: () => {
830
- commandDispatcher: (command: CanvasCommand) => void;
831
- getLayoutById: (id: string) => _LayoutData1;
832
- getAllLayouts: () => _LayoutData1[];
833
- getReducerState: () => CommandState;
834
- lastUpdated: Date;
835
- flattenSequence: (sequenceId: string, initialState: _LayoutsState1) => void;
836
- };
837
- export type CommandDispatcher = (command: CanvasCommand) => void;
838
- export type LayoutGetter = (layoutId: string) => _LayoutData1;
839
- export type LayoutsGetter = () => _LayoutData1[];
840
- /**
841
- * Details about a guideline that can be drawn on the canvas.
842
- */
843
- interface SnapPoint {
844
- type: "x" | "y" | "rotation";
845
- value: number;
846
- svgNode?: ReactNode;
847
- anchorPoint: number;
848
- guidelineCoordinates?: Point[];
849
- }
850
- export enum ElementEventType {
851
- Translate = "Translate",
852
- Rotate = "Rotate",
853
- Resize = "Resize"
854
- }
855
- export enum KeyEvent {
856
- ControlLeft = "ControlLeft",
857
- ControlRight = "ControlRight",
858
- Equal = "Equal",
859
- MetaLeft = "MetaLeft",
860
- MetaRight = "MetaRight",
861
- Minus = "Minus",
862
- ArrowLeft = "ArrowLeft",
863
- ArrowRight = "ArrowRight",
864
- ArrowUp = "ArrowUp",
865
- ArrowDown = "ArrowDown",
866
- AltLeft = "AltLeft",
867
- AltRight = "AltRight",
868
- Delete = "Delete",
869
- Backspace = "Backspace"
870
- }
871
- type ElementEvent = {
872
- type: ElementEventType.Translate;
873
- } | {
874
- type: ElementEventType.Rotate;
875
- } | {
876
- type: ElementEventType.Resize;
877
- relativeAxis: ScaleAxis;
878
- screenAxis: ScaleAxis;
879
- };
880
- export enum EditorSubMenu {
881
- None = "None",
882
- FrameAdjustment = "FrameAdjustment",
883
- FinalizeDesign = "FinalizeDesign"
884
- }
885
- interface UIState {
886
- }
887
- /**
888
- * This context stores global state for
889
- */
890
- export interface AdvancedEditorState extends UIState {
891
- /**
892
- * The layout currently being displayed in the editor.
893
- */
894
- layoutId: string;
895
- /**
896
- * Returns the id of the currently selected element. Or undefined if no element is selected.
897
- */
898
- selectedElement?: string;
899
- /**
900
- * The current zoom level of the editor.
901
- */
902
- zoom: number;
903
- /**
904
- * The maxiumum zoom possible based on current canvas content.
905
- */
906
- maxZoom: number;
907
- /**
908
- * The current measurement system used for display of coordinates and dimensions.
909
- */
910
- units: UnitOfMeasurement;
911
- /**
912
- * The sub menu to be displayed to the user in place of the canvas.
913
- */
914
- subMenu: EditorSubMenu;
915
- /**
916
- * Any modifier keys that are currently pressed
917
- */
918
- activeModifierKeys: KeyEvent[];
919
- /**
920
- * WHether or not a meta key is pressed.
921
- */
922
- metaPressed: boolean;
923
- /**
924
- * Any active element event.
925
- */
926
- elementEvent?: ElementEvent;
927
- /**
928
- * If movement should assume that it's operating in a scrolled environment.
929
- * FIXME: Can we get rid of this somehow.
930
- */
931
- scrolledMovement: boolean;
932
- }
933
- export const getDefaultState: (getLayouts: LayoutsGetter, defaultZoom: number) => {
934
- layoutId: string;
935
- selectedElement: any;
936
- zoom: number;
937
- maxZoom: number;
938
- units: UnitOfMeasurement;
939
- subMenu: EditorSubMenu;
940
- activeModifierKeys: any[];
941
- metaPressed: boolean;
942
- elementEvent: any;
943
- scrolledMovement: boolean;
944
- };
945
- export const commandReducer: (state: AdvancedEditorState, command: UICommand) => AdvancedEditorState;
946
- export const AdvancedEditorContext: import("react").Context<{
947
- uiDispatcher: Dispatch<UICommand>;
948
- state: AdvancedEditorState;
949
- }>;
950
- export const AdvancedEditorStateProvider: FunctionComponent<{
951
- defaultZoom?: number;
952
- children: ReactNode;
953
- }>;
954
- export class UICommand {
955
- constructor(changes: Partial<AdvancedEditorState>);
956
- apply(state: AdvancedEditorState): {
957
- layoutId: string;
958
- selectedElement?: string;
959
- zoom: number;
960
- maxZoom: number;
961
- units: UnitOfMeasurement;
962
- subMenu: EditorSubMenu;
963
- activeModifierKeys: KeyEvent[];
964
- metaPressed: boolean;
965
- elementEvent?: ElementEvent;
966
- scrolledMovement: boolean;
967
- };
968
- }
969
- export const useEditorState: () => {
970
- uiDispatcher: Dispatch<UICommand>;
971
- state: AdvancedEditorState;
972
- };
973
- /**
974
- * The minimum zoom that can be applied to a canvas.
975
- */
976
- export const minZoom = 0.5;
977
- export const useEditorInteraction: (editorRef: RefObject<SVGRectElement>, interactionRef: RefObject<HTMLDivElement>, zoomableElementRef: RefObject<HTMLDivElement>, defaultAdjustmentZoom: number | undefined, mode: "adjustment" | "advanced", canvasDispatcher: CommandDispatcher, guidelinePrimaryColor?: string) => {
978
- guidelines: SnapPoint[];
979
- scale: number;
980
- zoomableElementRef: RefObject<HTMLDivElement>;
981
- setElementEvent: (newEvent: ElementEvent | undefined) => void;
982
- handleZoom: (_event: any, value: any) => void;
983
- handleKeyDown: (event: KeyboardEvent, adjustmentBoundary?: Region) => void;
984
- handleKeyUp: (event: KeyboardEvent) => void;
985
- handlePointerPressedBackground: () => void;
986
- handlePointerReleased: () => void;
987
- handlePointerMove: (e: PointerEvent, adjustmentBoundary?: Region) => void;
988
- handleScroll: () => void;
989
- handleSequenceStart: () => void;
990
- };
991
- export const EditorCore: FunctionComponent<{
992
- color?: string;
993
- editorRef: RefObject<SVGRectElement>;
994
- zoomableElementRef: RefObject<HTMLDivElement>;
995
- interactionElementRef: RefObject<HTMLDivElement>;
996
- guidelines: SnapPoint[];
997
- isMakingAdjustments?: boolean;
998
- viewmask?: {
999
- x: number;
1000
- y: number;
1001
- height: number;
1002
- width: number;
1003
- };
1004
- visibleLayoutId: string;
1005
- xTranslation: number;
1006
- yTranslation: number;
1007
- targetedElements?: string[];
1008
- borderRadius?: number;
1009
- handleContextMenu?: (e: any) => void;
1010
- handleKeyDown: (event: KeyboardEvent, adjustmentBoundary?: Region) => void;
1011
- handleKeyUp: (event: KeyboardEvent) => void;
1012
- handlePointerMove: (e: PointerEvent, adjustmentBoundary?: Region) => void;
1013
- handlePointerPressedBackground: () => void;
1014
- handlePointerReleased: () => void;
1015
- handleScroll: () => void;
1016
- onSequenceStart: () => void;
1017
- setElementEvent: (e: ElementEvent | undefined) => void;
1018
- onElementSelected: (elementId: string | undefined, event: PointerEvent) => void;
1019
- }>;
1020
- /**
1021
- * The advanced editor encapsulates the logic required to allow users to manipulate a design
1022
- * with more granular control such as toolbars, direct element manipulation, and more.
1023
- */
1024
- export const AdvancedEditor: FunctionComponent<{
1025
- color?: string;
1026
- guidelineColor?: string;
1027
- borderRadius?: number;
1028
- handleContextMenu?: (event: MouseEvent) => void;
1029
- onElementSelected?: (id: string | undefined, element: PointerEvent) => void;
1030
- }>;
1031
- interface StorageService {
1032
- /**
1033
- * Get a value.
1034
- * @param key The key to lookup the value with.
1035
- */
1036
- get(key: string): string | undefined;
1037
- /**
1038
- * Set a value.
1039
- * @param key The key to set.
1040
- * @param val The new value.
1041
- */
1042
- set(key: string, val: string): void;
1043
- /**
1044
- * Remove a value.
1045
- * @param key The key to remove, does nothing if the key doesn't exist.
1046
- */
1047
- remove(key: string): void;
1048
- getMap(key: string): Map<any, any> | undefined;
1049
- setMap(key: string, val: Map<any, any>): void;
1050
- }
1051
- export const persistenceService: StorageService;
1052
- /**
1053
- * A StepHandle allows for managing the state of a specific step in a workflow. This class
1054
- * abstracts away the complexities of dealing with a step directly and allows for using high level
1055
- * concepts instead of dealing with the underlying data structures.
1056
- */
1057
- interface StepHandle {
1058
- /**
1059
- * Gets the currently selected variant, or undefined if no variant is selected.
1060
- */
1061
- getCurrentVariant(): any;
1062
- /**
1063
- * Returns a list of valid variants for this step.
1064
- */
1065
- getAvailableVariants(): Promise<VariantResource[]>;
1066
- /**
1067
- * Selects a specific variant for this step.
1068
- */
1069
- selectVariant(variant: VariantResource): any;
1070
- }
1071
- /**
1072
- * A Workflow experience encapsulates the workflow manager and command context. It
1073
- * provides a simplified interface for interacting with the workflow manager. You
1074
- * should get an instance of this class from a Client you have constructed previously.
1075
- */
1076
- export interface WorkflowExperience {
1077
- /**
1078
- * State related to the design of the user.
1079
- */
1080
- getCommandContext(): CommandContext;
1081
- /**
1082
- * Returns true when the user may only view the design.
1083
- */
1084
- getIsReadOnly(): boolean;
1085
- /**
1086
- * Get the low level workflow amanager instance for this experience. Don't touch this unless you're willing to break things.
1087
- */
1088
- getWorkflowManager(): WorkflowManager;
1089
- /**
1090
- * Bulk workflow operation, used to update multiple variations at once.
1091
- */
1092
- updateVariationRecords(variationRecords: VariationRecord[]): Promise<void>;
1093
- /**
1094
- * Returns the step matching a given name, undefined if not found.
1095
- * @param id The id the step must match.
1096
- */
1097
- getStepById(id: string): StepHandle | undefined;
1098
- /**
1099
- * Returns the step matching a given name, undefined if not found.
1100
- * @param name The name the step must match.
1101
- */
1102
- getStepByName(name: string): StepHandle | undefined;
1103
- /**
1104
- * Returns all steps matching a specific type in the workflow. These steps
1105
- * may be across multiple scenes and may or may not be active based on condition state.
1106
- */
1107
- getStepsByType(type: StepType): StepHandle[];
1108
- /**
1109
- * Creates a data URL preview for the current design.
1110
- */
1111
- createPreviewImage(): Promise<string>;
1112
- /**
1113
- * To be called when the workflow experience is considered completed by the user.
1114
- * @param product
1115
- * @param onProgressUpdate Progress callback for finalizing the design.
1116
- * @param selections
1117
- * @param metadata
1118
- */
1119
- onDesignFinished(product: Product, onProgressUpdate: DesignCreationProgressUpdate, selections: WorkflowSelections, metadata?: WorkflowMetadata | undefined): Promise<DesignCreationMessage>;
1120
- }
1121
- /**
1122
- * Options that can be used during instantiation of the SpiffCommerce Javascript Client.
1123
- * Please refer to the documentation for more information.
1124
- */
1125
- interface ClientOptions {
1126
- /**
1127
- * When set to true, the client will treat the workflow as a bulk order
1128
- * containing multiple variations of the base design.
1129
- */
1130
- bulk?: boolean;
1131
- /**
1132
- * When set to true caching will be disabled. This is only useful for debugging. Don't use in production code!
1133
- */
1134
- useUncachedEndpoints?: boolean;
1135
- }
1136
- /**
1137
- * The Spiff Commerce Javascript Client. Required for
1138
- * creating workflow experiences.
1139
- */
1140
- export class Client {
1141
- constructor(options: ClientOptions);
1142
- /**
1143
- * Initialize the client from an integration product.
1144
- * @param integrationProductId The integration product to use.
1145
- */
1146
- initFromIntegrationProduct(integrationProductId: string): Promise<void>;
1147
- /**
1148
- * Initialize the client from an existing transaction.
1149
- * @param transactionId The id of the transaction
1150
- * @returns A promise resolving at initialization completion.
1151
- */
1152
- initFromTransaction(transactionId: string): Promise<void>;
1153
- /**
1154
- * Creates a new instance of WorkflowExperience. A high level wrapper for workflows.
1155
- * @param workflowId The id of the workflow to be run.
1156
- * @param workflowState An existing workflow state if available.
1157
- * @param previewServiceConstructor A function called during initialization. Takes a class implementing ThreeDPreviewService in return.
1158
- * @returns A workflow experience configured as requested.
1159
- */
1160
- getWorkflowExperience(workflowId?: string, workflowState?: string, previewServiceConstructor?: (workflow: Workflow) => _ThreeDPreviewService1): Promise<WorkflowExperience>;
1161
- /**
1162
- * @returns The preview service that was provided during construction.
1163
- */
1164
- getPreviewService(): _ThreeDPreviewService1;
1165
- /**
1166
- * @returns The product associated with this client.
1167
- */
1168
- getProduct(): Product;
1169
- /**
1170
- * @returns The transaction associated with this client.
1171
- */
1172
- getTransaction(): Transaction;
1173
- }
1174
- export class MockWorkflowManager implements WorkflowManager {
1175
- getVariationRecords(): VariationRecord[];
1176
- reset(): Promise<void>;
1177
- updateStateWithServer(_getReducerState: () => CommandState): void;
1178
- addVariationRecord(_variationRecord: Omit<VariationRecord, "recordNumber">): {
1179
- recordNumber: number;
1180
- transactionId: string;
1181
- values: any[];
1182
- };
1183
- getCurrentVariationRecord(): any;
1184
- removeVariationRecord(_recordNumber: number): any[];
1185
- outstandingRequestsPromise(): Promise<void>;
1186
- updateStateWithServerImmediate(_getReducerState: () => CommandState): Promise<void>;
1187
- addPoller(_poller: Poller): void;
1188
- addConfirmCallback(_callback: ConfirmCallback): void;
1189
- addCurrentVariationCallback(_callback: CurrentVariationRecordCallback): void;
1190
- addEditedCallback(_callback: EditedCallback): void;
1191
- addElementsCallback(_callback: ElementsCallback): void;
1192
- addInformationResultCallback(_callback: InformationResultCallback): void;
1193
- addInitCallback(_callback: InitCallback): void;
1194
- addMakingAdjustmentsCallback(_callback: MakingAdjustmentsCallback): void;
1195
- addMandatoryCallback(_callback: MandatoryCallback): void;
1196
- addMetadataCallback(_callback: MetadataCallback): void;
1197
- addSelectionCallback(_callback: SelectionCallback): void;
1198
- addStepSpecificStorageCallback(_callback: StepSpecificStorageCallback, _stepName: string): void;
1199
- addStorageCallback(_callback: StorageCallback): void;
1200
- addUpdateCallback(_callback: UpdateCallback): void;
1201
- addVariationRecordsCallback(_callback: VariationRecordsCallback): void;
1202
- getCommandDispatcher(): (_command: CanvasCommand) => void;
1203
- getLayouts(): any[];
1204
- getLayoutPreviewService(): {
1205
- getAll: () => Map<any, any>;
1206
- };
1207
- getPreviewService(): any;
1208
- getProductName(): string;
1209
- getProfanities(): any[];
1210
- getRegionElements(_stepName: string): any[];
1211
- getSerializedStep(_stepName: string, _serializedSteps: SerializableStep[]): any;
1212
- getStepSpecificServices(_stepName: string): any;
1213
- getTransaction(): {
1214
- id: string;
1215
- };
1216
- getWorkflow(): {
1217
- id: string;
1218
- name: string;
1219
- panels: any[];
1220
- steps: any[];
1221
- showModelOnFinishStep: boolean;
1222
- allowProofDownload: boolean;
1223
- introduction: string;
1224
- stepGroups: any[];
1225
- };
1226
- markStepsAsInitialised(_stepNames: string[]): void;
1227
- markUpdateCompleted(_update: string): void;
1228
- markUpdatePending(_update: string): void;
1229
- getWorkflowSelections(): {};
1230
- setCurrentAdjustingStepId(_stepId: string): void;
1231
- setAllScenes(_config: WorkflowScenesConfiguration): void;
1232
- setCurrentVariationRecord(_variationRecord: VariationRecord | null): void;
1233
- setEditedStatus(_stepName: string, _status: boolean): void;
1234
- setInformationResults(_results: InformationResult[]): void;
1235
- setMandatoryFulfilled(_stepName: string, _status: boolean): void;
1236
- setSelectionsAndElements(_stepName: string, _variants: VariantResource[], _elements: RegionElement[]): Promise<void>;
1237
- setVariationRecords(_variationRecords: VariationRecord[]): void;
1238
- toggleDesignConfirmed(): void;
1239
- updateMetadata(_stepName: string, _update: any): void;
1240
- updateStorage(_stepName: string, _update: StepStorage): Promise<void>;
1241
- }
1242
- export { CommandContext };
1243
- export { generate, CreateElementCommand, TextChangeCommand, FontAlignmentCommand, FontColorCommand, LayoutElementFactory };
1244
- export { LayoutElement, ImageElement, TextboxElement, TextStepData, FrameElement, PatchworkElement, IllustrationElement, LayoutData, LayoutsState };
1245
- export { SpiffCommerce3DPreviewService };
1246
- export { ThreeDPreviewService };
1
+ import { Workflow, StepAspect, Step, AnyStepData, FrameOffsets, PatternImageData, IServerModel, Asset, MaterialResource, AssetType, ColorDefinition, IllustrationStepData, Region, ILayout, CreateElementCommand, IllustrationElement, LayoutsState, VariantResource, CanvasCommand, LayoutData, DigitalContentStepData, FrameStepData, FrameElement, MaterialStepData, ModelStepData, ModuleStepData, PatchworkStepData, PatchworkOffsets, PictureStepData, QuestionStepData, ShapeStepData, FontData, GroupCommand, TextboxElement, TextStepData, StepStorage, SerializableStep, CommandState, OptionResource, CommandContext as _CommandContext1, Point, ScaleAxis, UnitOfMeasurement, StepType, CommandContext } from "@spiffcommerce/papyrus";
2
+ import { ApolloClient } from "@apollo/client";
3
+ import { ThreeDPreviewService as _ThreeDPreviewService1, SpiffCommerce3DPreviewService, ThreeDPreviewService } from "@spiffcommerce/preview";
4
+ import { ReactNode, Dispatch, FunctionComponent, RefObject, PointerEvent, KeyboardEvent, MouseEvent } from "react";
5
+ export const gatherVaryingStepAspects: (workflow: Workflow) => StepAspect[];
6
+ export interface WorkflowScene {
7
+ name: string;
8
+ title: string;
9
+ renderableSteps: Step<AnyStepData>[];
10
+ silentSteps: Step<AnyStepData>[];
11
+ }
12
+ interface WorkflowScenesConfiguration {
13
+ bulkScene: boolean;
14
+ bulkSceneTitle: string;
15
+ finishScene: boolean;
16
+ finishSceneTitle: string;
17
+ }
18
+ /**
19
+ * A queue promise is a container for a promise that can be
20
+ * executed at a later time.
21
+ */
22
+ export abstract class QueueablePromise {
23
+ readonly timestamp: number;
24
+ abstract execute(): Promise<any>;
25
+ }
26
+ /**
27
+ * A promise queue contains any number of QueuePromise objects. These objects are stored within a PromiseQueue and executed
28
+ * as quickly as possible in order. This is ideal in situations where a specific operation should be
29
+ * applied in an ordered way while still making.
30
+ */
31
+ export class PromiseQueue<T extends QueueablePromise> {
32
+ /**
33
+ * Constructs a new promise queue.
34
+ * @param queueMaxSize An optional maximum size, when the max size is hit.
35
+ * The older promises will be discarded.
36
+ */
37
+ constructor(queueMaxSize?: number);
38
+ /**
39
+ * Enqueue a new promise.
40
+ * @param promise A new promise to add to the queue.
41
+ */
42
+ enqueue(promise: T): Promise<void>;
43
+ /**
44
+ * @returns Returns true when work is being actively processed by this queue.
45
+ */
46
+ hasActivePromise(): boolean;
47
+ /**
48
+ * @returns The number of unexecuted jobs remaining in the queue. Not including the active job.
49
+ */
50
+ getRemainingQueueSize(): number;
51
+ /**
52
+ * Finalize the queue, any jobs that come in while this is in progress will result
53
+ * in the promise being extended.
54
+ */
55
+ finalize(): Promise<void>;
56
+ }
57
+ export class FrameService {
58
+ minZoomScale: number;
59
+ maxZoomScale: number;
60
+ constructor(forceImageCover?: boolean);
61
+ /**
62
+ * When we want to connect a workflow manager to the state of the image cropper we
63
+ * can pass it to this function. Inside we'll attach any required event listeners.
64
+ * @param workflowManager The workflow manager to attach.
65
+ * @param stepName The specific step we want to attach to within the manager.
66
+ */
67
+ connectWorkflowManager(workflowManager: WorkflowManager, stepName?: string): void;
68
+ /**
69
+ * Sets the elements that should be update when changes are made to
70
+ * the cropper that owns this service.
71
+ * @param targetElements A list of element Ids to track
72
+ */
73
+ setTargetElements(targetElements: string[]): void;
74
+ /**
75
+ * Gets the current calculated frame data
76
+ * @returns A FrameData object or undefined if no frame has been set.
77
+ */
78
+ getFrameData(): FrameData | undefined;
79
+ /**
80
+ * Sets the current frame data
81
+ * @param path The path to lookup in our frame data cache.
82
+ */
83
+ setFrameData(path: string): Promise<void>;
84
+ /**
85
+ * Gets the currently set image of the frame..
86
+ * @returns A PatternImageData object, or undefined if no image is set.
87
+ */
88
+ getImageData(): PatternImageData | undefined;
89
+ /**
90
+ * Gets the current calculated offsets of the pattern within the frame.
91
+ * @returns A FrameOffsets object or undefined if no offsets are defined.
92
+ */
93
+ getOffsets(): FrameOffsets | undefined;
94
+ /**
95
+ * Updates the frame offsets explicitly.
96
+ */
97
+ setOffsets(offsets: FrameOffsets): void;
98
+ /**
99
+ * Sets the zoom of the cropper that owns this service.
100
+ * @param zoom The new zoom value.
101
+ * @param cX The center of zoom on x axis
102
+ * @param cY The center of zoom on Y axis
103
+ * @param onComplete A function to call when zoom changes have been completed
104
+ */
105
+ setZoom(zoom: number, cX: number, cY: number, onComplete?: () => void): void;
106
+ /**
107
+ * Sets the image currently contained by this frame.
108
+ * @param value The new image as an ImageData property
109
+ */
110
+ setPatternData(value: PatternImageData): void;
111
+ /**
112
+ * Modify the offsets of the frame.
113
+ * @param value The new FrameOffsets object.
114
+ * @param onComplete A callback, called when the modification is complete
115
+ */
116
+ updateOffsets(value: FrameOffsets, onComplete?: () => void): void;
117
+ onFrameDataChanged(newListener: (frameData: FrameData | undefined) => void): void;
118
+ /**
119
+ * Append a new listener to zoom events on this frame.
120
+ * @param newListener
121
+ */
122
+ onZoom(newListener: (zoomValue: number) => void): void;
123
+ }
124
+ declare class Poller {
125
+ /**
126
+ * Constructs a new polling service.
127
+ * @param predicate An async function that returns true when polling has returned a successful result.
128
+ * @param onSuccess The callback to be called when polling has returned a successful result.
129
+ * @param onFailure The callback to be called when polling has returned a failed result.
130
+ * @param interval The number of milliseconds to wait between each poll.
131
+ * @param maxAttempts The maximum amount of times to check the condition.
132
+ */
133
+ constructor(predicate: () => Promise<boolean>, onSuccess: () => void, onFailure: () => void, interval?: number, maxAttempts?: number);
134
+ }
135
+ declare class Configuration {
136
+ constructor();
137
+ getServerUrl(): string;
138
+ getServicesApiUrl(): string;
139
+ getHubUrl(): string;
140
+ setServerUrl(serverUrl: string): void;
141
+ setServicesApiUrl(servicesApiUrl: string): void;
142
+ setHubUrl(hubUrl: string): void;
143
+ addServerUrlCallback(callback: () => void): void;
144
+ }
145
+ export const spiffCoreConfiguration: Configuration;
146
+ declare class SwaggerServer implements ServerService {
147
+ constructor();
148
+ setUncachedOperations(operationIds: string[]): void;
149
+ execute(operationName: string, parameters?: object): Promise<ServerResponse>;
150
+ }
151
+ export const server: SwaggerServer;
152
+ declare class GraphQlManager {
153
+ constructor();
154
+ getShadowGraphqlClient(): ApolloClient<any>;
155
+ }
156
+ export const graphQlManager: GraphQlManager;
157
+ declare class AssetService {
158
+ constructor();
159
+ /**
160
+ * Allows for retrieving an asset, returns the option from a cache if possible.
161
+ * @param server The server service for making the request.
162
+ * @param id The asset key to be retrieved.
163
+ */
164
+ getLocalOrFromServer(assetKey: string): Promise<IServerModel<Asset>>;
165
+ /**
166
+ * Allows for retrieving amaterial, returns the option from a cache if possible.
167
+ * @param server The server service for making the request.
168
+ * @param id The option ID to be retrieved.
169
+ */
170
+ getMaterialLocalOrFromServer(id: string): Promise<IServerModel<MaterialResource>>;
171
+ /**
172
+ * Upload a user asset to the server. Using callbacks to notify important events.
173
+ */
174
+ uploadAssetWithProgress(file: FileInfo, assetType: AssetType, onProgress: (val: number) => void, onComplete: (asset: IServerModel<Asset>) => void, anonymous?: boolean, partnerId?: string): Promise<IServerModel<Asset>>;
175
+ /**
176
+ * Convert a File object for an image into a FileInfo.
177
+ */
178
+ loadImageAsFileInfo: (file: File) => Promise<FileInfo>;
179
+ }
180
+ export const assetService: AssetService;
181
+ interface SVGCreateOpts {
182
+ stepName?: string;
183
+ src: string;
184
+ objectURL: string;
185
+ svg: {
186
+ svg: string;
187
+ colors: {
188
+ [key: string]: ColorDefinition;
189
+ };
190
+ };
191
+ }
192
+ declare class IllustrationStepService implements StepService<IllustrationStepData> {
193
+ getIllustrationBody(src: string): Promise<string>;
194
+ getCreateElementCommand(id: string, region: Region, layout: ILayout, options: SVGCreateOpts): CreateElementCommand<IllustrationElement>;
195
+ init(stepData: Step<IllustrationStepData>, workflowManager: WorkflowManager, reducerState?: LayoutsState): Promise<CommandWithFollowup | null>;
196
+ availableColors(stepData: Step<IllustrationStepData>): {
197
+ fill: string;
198
+ stroke: string;
199
+ }[];
200
+ changeColorsCommand(svg: string, illustrationWidth: number, illustrationHeight: number, elements: string[], newFills: Map<string, string>): Promise<CanvasCommand>;
201
+ changeColors(stepData: Step<IllustrationStepData>, elements: RegionElement[], workflowManager: WorkflowManager, getAllLayouts: () => LayoutData[], newFills: Map<string, string>): Promise<void>;
202
+ selectVariant(stepData: Step<IllustrationStepData>, variant: VariantResource, elements: RegionElement[], setIsUpdating: (isUpdating: boolean) => void, workflowManager: WorkflowManager): void;
203
+ }
204
+ export const svgObjectURL: (svg: string) => Promise<string>;
205
+ export const illustrationStepService: IllustrationStepService;
206
+ declare class DigitalContentStepService implements StepService<DigitalContentStepData> {
207
+ init(stepData: Step<DigitalContentStepData>, workflowManager: WorkflowManager, reducerState?: LayoutsState): Promise<CommandWithFollowup | null>;
208
+ regenerateQRCode(elements: RegionElement[], uploading: boolean, assetKey: string, url: string, workflowManager: WorkflowManager, stepData: Step<DigitalContentStepData>, setUrl: (finalUrl: string) => void, commandDispatcher: (command: CanvasCommand) => void, setIsRegenerating: (state: boolean) => void): Promise<void>;
209
+ }
210
+ export const digitalContentStepService: DigitalContentStepService;
211
+ interface FrameCreateOpts {
212
+ stepName?: string;
213
+ frameData: FrameData;
214
+ disablePlaceholder?: boolean;
215
+ focalBlur?: boolean;
216
+ focalBlurStrength?: number;
217
+ focalBlurRadius?: number;
218
+ pattern?: any;
219
+ }
220
+ declare class FrameStepService implements StepService<FrameStepData> {
221
+ init(stepData: Step<FrameStepData>, workflowManager: WorkflowManager, reducerState?: LayoutsState): Promise<CommandWithFollowup | null>;
222
+ selectImage(stepData: Step<FrameStepData>, asset: IServerModel<Asset>, workflowManager: WorkflowManager): void;
223
+ selectVariant(stepData: Step<FrameStepData>, variant: VariantResource | undefined, elements: RegionElement[], workflowManager: WorkflowManager, setFrameIsUpdating?: (status: boolean) => void): void;
224
+ getCreateElementCommand(id: string, region: Region, layout: ILayout, options: FrameCreateOpts): CreateElementCommand<FrameElement>;
225
+ loadPatternFromString(src: string, frameService: FrameService): Promise<void>;
226
+ }
227
+ export const frameStepService: FrameStepService;
228
+ declare class MaterialStepService implements StepService<MaterialStepData> {
229
+ init(stepData: Step<MaterialStepData>, workflowManager: WorkflowManager, reducerState?: LayoutsState): Promise<null | (() => Promise<void>)>;
230
+ selectVariant(step: Step<MaterialStepData>, variant: VariantResource, workflowManager: WorkflowManager, setApplying: (status: boolean) => void): void;
231
+ }
232
+ export const materialStepService: MaterialStepService;
233
+ declare class ModelStepService implements StepService<ModelStepData> {
234
+ init(stepData: Step<ModelStepData>, workflowManager: WorkflowManager, reducerState?: LayoutsState): Promise<null | (() => Promise<void>)>;
235
+ selectVariant(step: Step<ModelStepData>, variant: VariantResource, workflowManager: WorkflowManager, setApplying: (status: boolean) => void): void;
236
+ }
237
+ export const modelStepService: ModelStepService;
238
+ declare class ModuleStepService implements StepService<ModuleStepData> {
239
+ init(stepData: Step<ModuleStepData>, workflowManager: WorkflowManager, reducerState?: LayoutsState): Promise<CommandWithFollowup | null>;
240
+ changeText(stepData: Step<ModuleStepData>, input: string, workflowManager: WorkflowManager, error: string, setError: (e: string) => void): void;
241
+ }
242
+ export const moduleStepService: ModuleStepService;
243
+ declare class PatchworkStepService implements StepService<PatchworkStepData> {
244
+ init(stepData: Step<PatchworkStepData>, workflowManager: WorkflowManager, reducerState?: LayoutsState): Promise<CommandWithFollowup | null>;
245
+ recalculate(stepData: Step<PatchworkStepData>, elements: RegionElement[], workflowManager: WorkflowManager, setIsCalculating: (status: boolean) => void): void;
246
+ selectVariant(stepData: Step<PatchworkStepData>, variant: VariantResource, elements: RegionElement[], workflowManager: WorkflowManager, setIsCalculating: (status: boolean) => void): void;
247
+ /**
248
+ * Constructs a preview SVG for a patchwork. Based on the configuration
249
+ * of the given element.
250
+ */
251
+ constructPreviewSvg(stepData: Step<PatchworkStepData>, elements: RegionElement[], getAllLayouts: () => LayoutData[], offsets?: PatchworkOffsets): null | string;
252
+ }
253
+ export const patchworkStepService: PatchworkStepService;
254
+ declare class PictureStepService implements StepService<PictureStepData> {
255
+ init(stepData: Step<PictureStepData>, workflowManager: WorkflowManager, reducerState?: LayoutsState): Promise<CommandWithFollowup | null>;
256
+ selectVariant(stepData: Step<PictureStepData>, variant: VariantResource, workflowManager: WorkflowManager, setIsUpdating: (status: boolean) => void): void;
257
+ }
258
+ export const pictureStepService: PictureStepService;
259
+ declare class QuestionStepService implements StepService<QuestionStepData> {
260
+ init(stepData: Step<QuestionStepData>, workflowManager: WorkflowManager, reducerState?: LayoutsState): Promise<null | (() => Promise<void>)>;
261
+ selectVariant(stepData: Step<QuestionStepData>, variantId: string, workflowManager: WorkflowManager): void;
262
+ }
263
+ export const questionStepService: QuestionStepService;
264
+ declare class ShapeStepService implements StepService<ShapeStepData> {
265
+ colourOptions(stepData: Step<ShapeStepData>): {
266
+ fill: string;
267
+ stroke: string;
268
+ }[];
269
+ init(stepData: Step<ShapeStepData>, workflowManager: WorkflowManager, reducerState?: LayoutsState): Promise<CommandWithFollowup | null>;
270
+ selectVariant(stepData: Step<ShapeStepData>, colourOption: ColorOption, elements: RegionElement[], workflowManager: WorkflowManager): void;
271
+ }
272
+ export const shapeStepService: ShapeStepService;
273
+ type ToastCallback = (callbackOptions: {
274
+ toastMessage: null | string;
275
+ toastType: InformationMessageType | null;
276
+ }) => void;
277
+ declare class Toast {
278
+ constructor();
279
+ addToastCallback(callback: ToastCallback): void;
280
+ setLatestToast(errorMessage: null | string, errorType: InformationMessageType | null): void;
281
+ }
282
+ export const toast: Toast;
283
+ interface TextUpdateResult {
284
+ command?: GroupCommand;
285
+ helperText: string;
286
+ errors: TextError[];
287
+ }
288
+ interface TextError {
289
+ localizationKey: string;
290
+ }
291
+ declare class TextStepService implements StepService<TextStepData> {
292
+ init(stepData: Step<TextStepData>, workflowManager: WorkflowManager, reducerState?: LayoutsState): Promise<CommandWithFollowup | null>;
293
+ /**
294
+ * @deprecated Only returns the first element. see findLayoutElements. A step can have multiple and we should return all of them!
295
+ */
296
+ findLayoutElement(workflowManager: WorkflowManager, step: Step<TextStepData>, getAllLayouts: () => any[]): TextboxElement;
297
+ findLayoutElements(workflowManager: WorkflowManager, step: Step<TextStepData>, getAllLayouts: () => any[]): TextboxElement[];
298
+ /**
299
+ * Get the colors that can be used for a given text step.
300
+ * @param stepData The text step to get colors for.
301
+ * @returns A list of color objects containg fill, stroke and variant if available.
302
+ */
303
+ availableColors(stepData: Step<TextStepData>): ColorOption[];
304
+ changeColor(stepData: Step<TextStepData>, newColor: ColorOption, elements: RegionElement[], workflowManager: WorkflowManager): void;
305
+ /**
306
+ * Given an element and a string, filters any characters from the string that are
307
+ * not supported by the font of the given element.
308
+ * @param layoutElement The element to use for glyph lookup.
309
+ * @param text The text string to filter.
310
+ * @returns A new string representing the passed string with unsupported characters removed.
311
+ */
312
+ filterUnsupportedCharacters: (layoutElement: TextboxElement | undefined, text: string) => string;
313
+ updateInputText(input: string, customiseAllText: boolean, elements: TextboxElement[], step: Step<TextStepData>, storage: TextStepStorage, workflowManager: WorkflowManager): TextUpdateResult;
314
+ /**
315
+ * @deprecated
316
+ */
317
+ changeInputTextWithRegion(step: Step<TextStepData>,
318
+ /**
319
+ * @deprecated
320
+ */
321
+ curFontSize: number,
322
+ /**
323
+ * @deprecated
324
+ */
325
+ curFontData: FontData, input: string, storage: TextStepStorage, workflowManager: WorkflowManager, customiseAllText: boolean, setError: (status: boolean) => void, setHelperText: (text: string) => void, setFlashRedError?: (status: boolean) => void): Promise<GroupCommand | undefined>;
326
+ selectVariant(step: Step<TextStepData>, variant: VariantResource, storage: TextStepStorage, elements: RegionElement[], workflowManager: WorkflowManager, customiseAllText: boolean, setError: (status: boolean) => void, setHelperText: (text: string) => void): void;
327
+ fontDataFromVariant(variant: VariantResource): Promise<FontData>;
328
+ findOrCreateElements(workflowManager: WorkflowManager, step: Step<TextStepData>, getAllLayouts: () => any[]): Promise<TextboxElement[]>;
329
+ textAlign: (stepData: TextStepData) => string;
330
+ }
331
+ export const textStepService: TextStepService;
332
+ declare abstract class ModuleProduct {
333
+ /**
334
+ * Name used by class. Usually product or brand name.
335
+ */
336
+ abstract moduleName: string;
337
+ /**
338
+ * SVG with styled path positioned on a background image. To be displayed to user.
339
+ */
340
+ abstract svgPreview(text: string): string;
341
+ /**
342
+ * SVG with styled path positioned on a background image. To be submitted for print.
343
+ */
344
+ abstract svgPrint(text: string): string;
345
+ }
346
+ export interface EditedSteps {
347
+ [stepName: string]: boolean;
348
+ }
349
+ export interface MandatorySteps {
350
+ [stepName: string]: boolean;
351
+ }
352
+ export type StepElements = {
353
+ [key: string]: RegionElement[];
354
+ };
355
+ type StepInitialised = {
356
+ [key: string]: boolean;
357
+ };
358
+ type StepMetadata = FrameMetadata | IllustrationMetadata | ModuleMetadata | TextMetadata;
359
+ export interface WorkflowStorage {
360
+ [stepName: string]: StepStorage;
361
+ }
362
+ export interface WorkflowMetadata {
363
+ [stepName: string]: StepMetadata;
364
+ }
365
+ export interface WorkflowSelections {
366
+ [stepName: string]: {
367
+ groupName?: string;
368
+ optionName: string;
369
+ selections: VariantResource[];
370
+ };
371
+ }
372
+ export interface InformationResult {
373
+ message: string;
374
+ messageType: InformationMessageType;
375
+ stepID: string;
376
+ }
377
+ export enum InformationMessageType {
378
+ Error = "Error",
379
+ Warning = "Warning"
380
+ }
381
+ /**
382
+ * Services required for the operaiton of individual steps.
383
+ */
384
+ interface StepSpecificServices {
385
+ frameService?: FrameService;
386
+ module?: ModuleProduct;
387
+ }
388
+ type DesignCreationProgressUpdate = (message: string) => void;
389
+ type ConfirmCallback = (isConfirmed: boolean) => void;
390
+ type EditedCallback = (editedSteps: EditedSteps) => void;
391
+ type ElementsCallback = (elements: StepElements) => void;
392
+ type InformationResultCallback = (messages: InformationResult[]) => void;
393
+ type InitCallback = (stepInitialised: StepInitialised) => void;
394
+ type MakingAdjustmentsCallback = (makingAdjustments: string) => void;
395
+ type MandatoryCallback = (mandatorySteps: MandatorySteps) => void;
396
+ type MetadataCallback = (metadata: WorkflowMetadata) => void;
397
+ type SelectionCallback = (callbackOptions: {
398
+ invalidModelVariants: string[];
399
+ selectionCost: number;
400
+ selections: StepSelections;
401
+ traversableScenes: WorkflowScene[];
402
+ }) => void;
403
+ type StepSpecificStorageCallback = (selections: StepStorage) => void;
404
+ type StorageCallback = (storage: WorkflowStorage) => void;
405
+ type UpdateCallback = (isUpdating: boolean) => void;
406
+ type CurrentVariationRecordCallback = (variationRecord: null | VariationRecord) => void;
407
+ type VariationRecordsCallback = (records: VariationRecord[]) => void;
408
+ export interface WorkflowManager {
409
+ addPoller: (poller: Poller) => void;
410
+ addConfirmCallback: (callback: ConfirmCallback) => void;
411
+ addCurrentVariationCallback: (callback: CurrentVariationRecordCallback) => void;
412
+ addEditedCallback: (callback: EditedCallback) => void;
413
+ addElementsCallback: (callback: ElementsCallback) => void;
414
+ addInformationResultCallback: (callback: InformationResultCallback) => void;
415
+ addInitCallback: (callback: InitCallback) => void;
416
+ addMakingAdjustmentsCallback: (callback: MakingAdjustmentsCallback) => void;
417
+ addMandatoryCallback: (callback: MandatoryCallback) => void;
418
+ addMetadataCallback: (callback: MetadataCallback) => void;
419
+ addSelectionCallback: (callback: SelectionCallback) => void;
420
+ addStepSpecificStorageCallback: (callback: StepSpecificStorageCallback, stepName: string) => void;
421
+ addStorageCallback: (callback: StorageCallback) => void;
422
+ addUpdateCallback: (callback: UpdateCallback) => void;
423
+ addVariationRecord: (variationRecord: Omit<VariationRecord, "recordNumber">) => VariationRecord;
424
+ addVariationRecordsCallback: (callback: VariationRecordsCallback) => void;
425
+ getCommandDispatcher: () => (command: CanvasCommand) => void;
426
+ getCurrentVariationRecord: () => VariationRecord | undefined;
427
+ getVariationRecords: () => VariationRecord[];
428
+ getLayouts: () => ILayout[];
429
+ getLayoutPreviewService: () => any;
430
+ getPreviewService: () => _ThreeDPreviewService1 | undefined;
431
+ getProductName: () => string | undefined;
432
+ getProfanities: () => string[];
433
+ getRegionElements: (stepName: string) => RegionElement[];
434
+ getSerializedStep: (stepName: string, serializedSteps: SerializableStep[]) => SerializableStep | undefined;
435
+ getStepSpecificServices: (stepName: string) => StepSpecificServices | undefined;
436
+ getTransaction: () => Transaction;
437
+ getWorkflow: () => Workflow;
438
+ getWorkflowSelections: () => WorkflowSelections;
439
+ markStepsAsInitialised: (stepNames: string[]) => void;
440
+ markUpdateCompleted: (update: string) => void;
441
+ markUpdatePending: (update: string) => void;
442
+ outstandingRequestsPromise: () => Promise<void>;
443
+ removeVariationRecord: (recordNumber: number) => VariationRecord[];
444
+ reset: () => Promise<void>;
445
+ setCurrentAdjustingStepId: (stepId: string) => void;
446
+ setAllScenes: (config: WorkflowScenesConfiguration) => void;
447
+ setCurrentVariationRecord: (variationRecord: null | VariationRecord) => void;
448
+ setEditedStatus: (stepName: string, status: boolean) => void;
449
+ setInformationResults: (results: InformationResult[]) => void;
450
+ setMandatoryFulfilled: (stepName: string, status: boolean) => void;
451
+ setSelectionsAndElements: (stepName: string, variants: VariantResource[], elements: RegionElement[]) => Promise<void>;
452
+ setVariationRecords: (variationRecords: VariationRecord[]) => void;
453
+ toggleDesignConfirmed: () => void;
454
+ updateMetadata: (stepName: string, update: any) => void;
455
+ updateStateWithServer: (getReducerState: () => CommandState) => void;
456
+ updateStateWithServerImmediate: (getReducerState: () => CommandState) => Promise<void>;
457
+ updateStorage: (stepName: string, update: StepStorage) => Promise<void>;
458
+ }
459
+ interface StepService<T extends AnyStepData> {
460
+ /**
461
+ * Initialize the given step, or reload from serialized data if present.
462
+ */
463
+ init(stepData: Step<T>, workflowManager: WorkflowManager, reducerState?: LayoutsState): Promise<any>;
464
+ }
465
+ interface FileInfo {
466
+ /**
467
+ * The name of the file.
468
+ */
469
+ name: string;
470
+ /**
471
+ * A blob object representing the
472
+ * data of the file.
473
+ */
474
+ blob: Blob;
475
+ }
476
+ /**
477
+ * A command along with a function to run afterwards.
478
+ */
479
+ interface CommandWithFollowup {
480
+ command: CanvasCommand;
481
+ followup: () => Promise<void>;
482
+ }
483
+ /**
484
+ * The variant selections of a completed step.
485
+ */
486
+ interface SelectedVariants {
487
+ [stepName: string]: {
488
+ id: string;
489
+ name: string;
490
+ priceModifier: number;
491
+ }[];
492
+ }
493
+ interface ExportedData {
494
+ [name: string]: {
495
+ value: string;
496
+ priceModifier: number;
497
+ };
498
+ }
499
+ interface DesignCreationMessage {
500
+ baseCost?: number;
501
+ weight?: number;
502
+ designProductId?: string;
503
+ designProductVariantId?: string;
504
+ event: string;
505
+ exportedData: ExportedData;
506
+ lineItemImageUrl: string;
507
+ transactionId: string;
508
+ metadata?: {
509
+ [stepName: string]: string;
510
+ };
511
+ optionsCost: number;
512
+ selectedVariants?: SelectedVariants;
513
+ sku?: string;
514
+ workflowViewerLink: string;
515
+ }
516
+ /**
517
+ * Represents a transaction.
518
+ */
519
+ export interface Transaction {
520
+ id: string;
521
+ /**
522
+ * User-supplied name for the associated design.
523
+ */
524
+ designName?: string;
525
+ bulk?: boolean;
526
+ /**
527
+ * The workflow associated with this transaction.
528
+ */
529
+ workflowId?: string;
530
+ /**
531
+ * Temporary ID that grants write permission to the transaction.
532
+ */
533
+ transactionOwnerId?: string;
534
+ /**
535
+ * The current state of the design.
536
+ */
537
+ workflowState?: string;
538
+ /**
539
+ * URL to a partner-specific logo intended to display during the workflow experience.
540
+ */
541
+ customLogoLink?: string;
542
+ /**
543
+ * URL to a logo intended to display at the periphery of the workflow experience.
544
+ */
545
+ workflowFooterLogoLink?: string;
546
+ /**
547
+ * URL to the corresponding integration in the REST API.
548
+ */
549
+ restApiIntegrationLink?: string;
550
+ /**
551
+ * URL to redirect to when a workflow is finished.
552
+ */
553
+ callbackUrl?: string;
554
+ /**
555
+ * Product that this transaction belongs to.
556
+ */
557
+ product?: Product;
558
+ /**
559
+ * The line item corresponding to this transaction.
560
+ */
561
+ lineItem?: LineItem;
562
+ /**
563
+ * The external product variant ID representing the design product related
564
+ * to this transaction, null unless the createDesignProduct flag was set
565
+ * and the design was finalized using createDesign operation.
566
+ */
567
+ externalDesignProductVariantId?: string;
568
+ /**
569
+ * The external product id representing the design product related
570
+ * to this transaction, null unless the createDesignProduct flag was set
571
+ * and the design was finalized using createDesign operation.
572
+ */
573
+ externalDesignProductId?: string;
574
+ priceModifierTotal?: number;
575
+ /**
576
+ * The amount of variations associated with this transaction.
577
+ */
578
+ variationsCount?: number;
579
+ /**
580
+ * URL to open the transaction in the workflow viewer.
581
+ */
582
+ workflowViewerLink?: string;
583
+ bulkSourceUrl?: string;
584
+ bulkEmailAddress?: string;
585
+ lastSyncedAt?: string;
586
+ }
587
+ /**
588
+ * Fields found in a variant within a line item resource.
589
+ */
590
+ interface LineItemVariant {
591
+ currencyCode: string;
592
+ optionName: string;
593
+ priceModifier: number;
594
+ stepName: string;
595
+ variantName: string;
596
+ }
597
+ interface LineItem {
598
+ id: string;
599
+ transactionId?: string;
600
+ previewImageUrl?: string;
601
+ product: Product;
602
+ quantity: number;
603
+ metadata?: LineItemMetadata[];
604
+ variants: LineItemVariant[];
605
+ }
606
+ interface LineItemMetadata {
607
+ stepName: string;
608
+ metadata: string;
609
+ }
610
+ interface ProductWorkflow {
611
+ friendlyName: string;
612
+ id: string;
613
+ present?: boolean;
614
+ imageUrl: string;
615
+ workflowName: string;
616
+ }
617
+ interface Product {
618
+ /**
619
+ * ID of the partner owner.
620
+ */
621
+ partnerId?: string;
622
+ /**
623
+ * Whether a line item for this product is delivered as soon as the order is received.
624
+ */
625
+ autoprint: boolean;
626
+ /**
627
+ * Whether this product can be quickprinted.
628
+ */
629
+ canQuickprint?: boolean;
630
+ /**
631
+ * The internal identifier for this product.
632
+ */
633
+ id: string;
634
+ /**
635
+ * The human friendly name of the product.
636
+ */
637
+ name: string;
638
+ /**
639
+ * A URL to the image asset associated with this product.
640
+ */
641
+ imageUrl?: string;
642
+ /**
643
+ * A resource url for a 3D model used to represent this product
644
+ * in the 3d editor. If not available we assume the product doesn't support 3D.
645
+ */
646
+ modelUrl?: string;
647
+ /**
648
+ * A URL for the image used as an overlay on any workflows
649
+ * that incorporate a product overlay step.
650
+ */
651
+ overlayImageUrl?: string;
652
+ /**
653
+ * Words which can't be used in a workflow for this product.
654
+ */
655
+ profanities?: {
656
+ id: string;
657
+ createdAt: string;
658
+ userId: string;
659
+ word: string;
660
+ }[];
661
+ /**
662
+ * The max characters that can be typed for quickprint.
663
+ */
664
+ quickprintMaxLength?: number;
665
+ /**
666
+ * The name of the module to use for quickprint.
667
+ */
668
+ quickprintModuleName?: string;
669
+ /**
670
+ * If true, the product should be displayed in the client as if it is available.
671
+ * Should be displayed as if it is unavailable otherwise.
672
+ */
673
+ enabled: boolean;
674
+ /**
675
+ * Workflows which have been assigned to this product.
676
+ */
677
+ workflows?: ProductWorkflow[];
678
+ /**
679
+ * The base price of this product in sub units. Essentially the cost of the
680
+ * product without any customisations applied.
681
+ */
682
+ basePrice?: number;
683
+ /**
684
+ * The weight of this product.
685
+ */
686
+ weight?: number;
687
+ /**
688
+ * When specified, represents a pre-rendered image of this product to be
689
+ * displayed to customers while the 3D preview is loading.
690
+ */
691
+ preloadImageUrl?: string;
692
+ }
693
+ interface ColorOption {
694
+ id?: string;
695
+ fill?: string;
696
+ stroke?: string;
697
+ variant?: VariantResource;
698
+ }
699
+ /**
700
+ * Represents a variation as seen in Google sheets.
701
+ * Record number = row# - 1
702
+ */
703
+ export interface VariationRecord {
704
+ recordNumber: number;
705
+ transactionId: string;
706
+ values: {
707
+ stepName: string;
708
+ aspect: string;
709
+ value: string;
710
+ }[];
711
+ }
712
+ export interface RegionElement {
713
+ id: string;
714
+ region?: Region;
715
+ }
716
+ interface FrameMetadata {
717
+ image: string;
718
+ }
719
+ interface IllustrationMetadata {
720
+ colors: string[];
721
+ }
722
+ interface ModuleMetadata {
723
+ text: string;
724
+ }
725
+ interface TextMetadata {
726
+ color?: string;
727
+ text: string;
728
+ }
729
+ export interface SelectionStorage {
730
+ selectedVariants?: VariantResource[];
731
+ }
732
+ interface TextStepStorage extends SelectionStorage {
733
+ color?: string;
734
+ defaultCleared?: boolean;
735
+ inputText?: string;
736
+ text?: string;
737
+ }
738
+ type StepSelections = {
739
+ [key: string]: SelectionStorage;
740
+ };
741
+ interface ServerResponse {
742
+ /**
743
+ * Will contain error information if an error was recieved
744
+ */
745
+ errors?: string[];
746
+ /**
747
+ * The body of the response containing any return data.
748
+ */
749
+ body: object;
750
+ headers: {
751
+ "content-type": string;
752
+ };
753
+ }
754
+ interface ServerService {
755
+ /**
756
+ * Sets the operation names that should be converted to their correspondingun-cached equivelants.
757
+ */
758
+ setUncachedOperations: (operationIds: string[]) => void;
759
+ /**
760
+ * Execute an operation against the server.
761
+ */
762
+ execute: (operationId: string, operationParameters?: object, anonymous?: boolean) => Promise<ServerResponse>;
763
+ }
764
+ interface FrameData {
765
+ /**
766
+ * The path data for a frame SVG
767
+ */
768
+ path: string;
769
+ /**
770
+ * The viewbox width
771
+ */
772
+ width: number;
773
+ /**
774
+ * The viewbox height.
775
+ */
776
+ height: number;
777
+ }
778
+ /**
779
+ * Defines the different behaviors supported by the camera system
780
+ * for control when viewing a product.
781
+ */
782
+ export enum ProductCameraRig {
783
+ Orbit = 0,
784
+ Pan = 1
785
+ }
786
+ export type LoadProgressEventData = {
787
+ /**
788
+ * The total load value of the scene, this is an average of all
789
+ * 'in progress' loading events. when all events are fully loaded this value will be 100.
790
+ */
791
+ readonly loadValue: number;
792
+ /**
793
+ * This value is true when the base model and scene have been initialized.
794
+ */
795
+ readonly sceneInitialized: boolean;
796
+ };
797
+ declare class OptionService {
798
+ /**
799
+ * Returns a promise that resolves once all options required for a given workflow
800
+ * have been loaded and cached ready for use.
801
+ * @param workflow The workflow to load options for.
802
+ */
803
+ cacheRequiredOptions(workflow: Workflow): Promise<void>;
804
+ /**
805
+ * Allows for retrieving an option, returns the option from a cache if possible.
806
+ * @param server The server service for making the request.
807
+ * @param id The option ID to be retrieved.
808
+ */
809
+ getLocalOrFromServer(server: ServerService, id: string): Promise<IServerModel<OptionResource>>;
810
+ /**
811
+ * Returns an option from the cache, or null
812
+ * @param id The ID to search for.
813
+ */
814
+ getLocalOrUndefined(id?: string): IServerModel<OptionResource>;
815
+ getAssetTileImageForVariant(variant: VariantResource): Promise<string>;
816
+ getDefaultVariant(option: OptionResource): VariantResource | undefined;
817
+ getDisplayImageSource: (variant?: VariantResource) => undefined | string;
818
+ /**
819
+ * Returns the first variant marked as selected. This is used by most steps.
820
+ */
821
+ getSelectedVariant: (option: OptionResource | undefined, selectedVariantIds: string[]) => VariantResource | undefined;
822
+ /**
823
+ * Returns all selected variants. This is used by the question step as multiple selections can be made.
824
+ */
825
+ getSelectedVariants: (option: OptionResource | undefined, selectedVariantIds: string[]) => VariantResource[];
826
+ }
827
+ export const optionService: OptionService;
828
+ export const CommandContextContext: import("react").Context<_CommandContext1>;
829
+ export const useLayouts: () => {
830
+ commandDispatcher: (command: CanvasCommand) => void;
831
+ getLayoutById: (id: string) => LayoutData;
832
+ getAllLayouts: () => LayoutData[];
833
+ getReducerState: () => CommandState;
834
+ lastUpdated: Date;
835
+ flattenSequence: (sequenceId: string, initialState: LayoutsState) => void;
836
+ };
837
+ export type CommandDispatcher = (command: CanvasCommand) => void;
838
+ export type LayoutGetter = (layoutId: string) => LayoutData;
839
+ export type LayoutsGetter = () => LayoutData[];
840
+ /**
841
+ * Details about a guideline that can be drawn on the canvas.
842
+ */
843
+ interface SnapPoint {
844
+ type: "x" | "y" | "rotation";
845
+ value: number;
846
+ svgNode?: ReactNode;
847
+ anchorPoint: number;
848
+ guidelineCoordinates?: Point[];
849
+ }
850
+ export enum ElementEventType {
851
+ Translate = "Translate",
852
+ Rotate = "Rotate",
853
+ Resize = "Resize"
854
+ }
855
+ export enum KeyEvent {
856
+ ControlLeft = "ControlLeft",
857
+ ControlRight = "ControlRight",
858
+ Equal = "Equal",
859
+ MetaLeft = "MetaLeft",
860
+ MetaRight = "MetaRight",
861
+ Minus = "Minus",
862
+ ArrowLeft = "ArrowLeft",
863
+ ArrowRight = "ArrowRight",
864
+ ArrowUp = "ArrowUp",
865
+ ArrowDown = "ArrowDown",
866
+ AltLeft = "AltLeft",
867
+ AltRight = "AltRight",
868
+ Delete = "Delete",
869
+ Backspace = "Backspace"
870
+ }
871
+ type ElementEvent = {
872
+ type: ElementEventType.Translate;
873
+ } | {
874
+ type: ElementEventType.Rotate;
875
+ } | {
876
+ type: ElementEventType.Resize;
877
+ relativeAxis: ScaleAxis;
878
+ screenAxis: ScaleAxis;
879
+ };
880
+ export enum EditorSubMenu {
881
+ None = "None",
882
+ FrameAdjustment = "FrameAdjustment",
883
+ FinalizeDesign = "FinalizeDesign"
884
+ }
885
+ interface UIState {
886
+ }
887
+ /**
888
+ * This context stores global state for
889
+ */
890
+ export interface AdvancedEditorState extends UIState {
891
+ /**
892
+ * The layout currently being displayed in the editor.
893
+ */
894
+ layoutId: string;
895
+ /**
896
+ * Returns the id of the currently selected element. Or undefined if no element is selected.
897
+ */
898
+ selectedElement?: string;
899
+ /**
900
+ * The current zoom level of the editor.
901
+ */
902
+ zoom: number;
903
+ /**
904
+ * The maxiumum zoom possible based on current canvas content.
905
+ */
906
+ maxZoom: number;
907
+ /**
908
+ * The current measurement system used for display of coordinates and dimensions.
909
+ */
910
+ units: UnitOfMeasurement;
911
+ /**
912
+ * The sub menu to be displayed to the user in place of the canvas.
913
+ */
914
+ subMenu: EditorSubMenu;
915
+ /**
916
+ * Any modifier keys that are currently pressed
917
+ */
918
+ activeModifierKeys: KeyEvent[];
919
+ /**
920
+ * WHether or not a meta key is pressed.
921
+ */
922
+ metaPressed: boolean;
923
+ /**
924
+ * Any active element event.
925
+ */
926
+ elementEvent?: ElementEvent;
927
+ /**
928
+ * If movement should assume that it's operating in a scrolled environment.
929
+ * FIXME: Can we get rid of this somehow.
930
+ */
931
+ scrolledMovement: boolean;
932
+ }
933
+ export const getDefaultState: (getLayouts: LayoutsGetter, defaultZoom: number) => {
934
+ layoutId: string;
935
+ selectedElement: any;
936
+ zoom: number;
937
+ maxZoom: number;
938
+ units: UnitOfMeasurement;
939
+ subMenu: EditorSubMenu;
940
+ activeModifierKeys: any[];
941
+ metaPressed: boolean;
942
+ elementEvent: any;
943
+ scrolledMovement: boolean;
944
+ };
945
+ export const commandReducer: (state: AdvancedEditorState, command: UICommand) => AdvancedEditorState;
946
+ export const AdvancedEditorContext: import("react").Context<{
947
+ uiDispatcher: Dispatch<UICommand>;
948
+ state: AdvancedEditorState;
949
+ }>;
950
+ export const AdvancedEditorStateProvider: FunctionComponent<{
951
+ defaultZoom?: number;
952
+ children: ReactNode;
953
+ }>;
954
+ export class UICommand {
955
+ constructor(changes: Partial<AdvancedEditorState>);
956
+ apply(state: AdvancedEditorState): {
957
+ layoutId: string;
958
+ selectedElement?: string;
959
+ zoom: number;
960
+ maxZoom: number;
961
+ units: UnitOfMeasurement;
962
+ subMenu: EditorSubMenu;
963
+ activeModifierKeys: KeyEvent[];
964
+ metaPressed: boolean;
965
+ elementEvent?: ElementEvent;
966
+ scrolledMovement: boolean;
967
+ };
968
+ }
969
+ export const useEditorState: () => {
970
+ uiDispatcher: Dispatch<UICommand>;
971
+ state: AdvancedEditorState;
972
+ };
973
+ /**
974
+ * The minimum zoom that can be applied to a canvas.
975
+ */
976
+ export const minZoom = 0.5;
977
+ export const useEditorInteraction: (editorRef: RefObject<SVGRectElement>, interactionRef: RefObject<HTMLDivElement>, zoomableElementRef: RefObject<HTMLDivElement>, defaultAdjustmentZoom: number | undefined, mode: "adjustment" | "advanced", canvasDispatcher: CommandDispatcher, guidelinePrimaryColor?: string) => {
978
+ guidelines: SnapPoint[];
979
+ scale: number;
980
+ zoomableElementRef: RefObject<HTMLDivElement>;
981
+ setElementEvent: (newEvent: ElementEvent | undefined) => void;
982
+ handleZoom: (_event: any, value: any) => void;
983
+ handleKeyDown: (event: KeyboardEvent, adjustmentBoundary?: Region) => void;
984
+ handleKeyUp: (event: KeyboardEvent) => void;
985
+ handlePointerPressedBackground: () => void;
986
+ handlePointerReleased: () => void;
987
+ handlePointerMove: (e: PointerEvent, adjustmentBoundary?: Region) => void;
988
+ handleScroll: () => void;
989
+ handleSequenceStart: () => void;
990
+ };
991
+ export const EditorCore: FunctionComponent<{
992
+ color?: string;
993
+ editorRef: RefObject<SVGRectElement>;
994
+ zoomableElementRef: RefObject<HTMLDivElement>;
995
+ interactionElementRef: RefObject<HTMLDivElement>;
996
+ guidelines: SnapPoint[];
997
+ isMakingAdjustments?: boolean;
998
+ viewmask?: {
999
+ x: number;
1000
+ y: number;
1001
+ height: number;
1002
+ width: number;
1003
+ };
1004
+ visibleLayoutId: string;
1005
+ xTranslation: number;
1006
+ yTranslation: number;
1007
+ targetedElements?: string[];
1008
+ borderRadius?: number;
1009
+ handleContextMenu?: (e: any) => void;
1010
+ handleKeyDown: (event: KeyboardEvent, adjustmentBoundary?: Region) => void;
1011
+ handleKeyUp: (event: KeyboardEvent) => void;
1012
+ handlePointerMove: (e: PointerEvent, adjustmentBoundary?: Region) => void;
1013
+ handlePointerPressedBackground: () => void;
1014
+ handlePointerReleased: () => void;
1015
+ handleScroll: () => void;
1016
+ onSequenceStart: () => void;
1017
+ setElementEvent: (e: ElementEvent | undefined) => void;
1018
+ onElementSelected: (elementId: string | undefined, event: PointerEvent) => void;
1019
+ }>;
1020
+ /**
1021
+ * The advanced editor encapsulates the logic required to allow users to manipulate a design
1022
+ * with more granular control such as toolbars, direct element manipulation, and more.
1023
+ */
1024
+ export const AdvancedEditor: FunctionComponent<{
1025
+ color?: string;
1026
+ guidelineColor?: string;
1027
+ borderRadius?: number;
1028
+ handleContextMenu?: (event: MouseEvent) => void;
1029
+ onElementSelected?: (id: string | undefined, element: PointerEvent) => void;
1030
+ }>;
1031
+ interface StorageService {
1032
+ /**
1033
+ * Get a value.
1034
+ * @param key The key to lookup the value with.
1035
+ */
1036
+ get(key: string): string | undefined;
1037
+ /**
1038
+ * Set a value.
1039
+ * @param key The key to set.
1040
+ * @param val The new value.
1041
+ */
1042
+ set(key: string, val: string): void;
1043
+ /**
1044
+ * Remove a value.
1045
+ * @param key The key to remove, does nothing if the key doesn't exist.
1046
+ */
1047
+ remove(key: string): void;
1048
+ getMap(key: string): Map<any, any> | undefined;
1049
+ setMap(key: string, val: Map<any, any>): void;
1050
+ }
1051
+ export const persistenceService: StorageService;
1052
+ /**
1053
+ * A StepHandle allows for managing the state of a specific step in a workflow. This class
1054
+ * abstracts away the complexities of dealing with a step directly and allows for using high level
1055
+ * concepts instead of dealing with the underlying data structures.
1056
+ */
1057
+ interface StepHandle {
1058
+ /**
1059
+ * Gets the currently selected variant, or undefined if no variant is selected.
1060
+ */
1061
+ getCurrentVariant(): any;
1062
+ /**
1063
+ * Returns a list of valid variants for this step.
1064
+ */
1065
+ getAvailableVariants(): Promise<VariantResource[]>;
1066
+ /**
1067
+ * Selects a specific variant for this step.
1068
+ */
1069
+ selectVariant(variant: VariantResource): any;
1070
+ }
1071
+ /**
1072
+ * A Workflow experience encapsulates the workflow manager and command context. It
1073
+ * provides a simplified interface for interacting with the workflow manager. You
1074
+ * should get an instance of this class from a Client you have constructed previously.
1075
+ */
1076
+ export interface WorkflowExperience {
1077
+ /**
1078
+ * State related to the design of the user.
1079
+ */
1080
+ getCommandContext(): CommandContext;
1081
+ /**
1082
+ * Returns true when the user may only view the design.
1083
+ */
1084
+ getIsReadOnly(): boolean;
1085
+ /**
1086
+ * Get the low level workflow amanager instance for this experience. Don't touch this unless you're willing to break things.
1087
+ */
1088
+ getWorkflowManager(): WorkflowManager;
1089
+ /**
1090
+ * Bulk workflow operation, used to update multiple variations at once.
1091
+ */
1092
+ updateVariationRecords(variationRecords: VariationRecord[]): Promise<void>;
1093
+ /**
1094
+ * Returns the step matching a given name, undefined if not found.
1095
+ * @param id The id the step must match.
1096
+ */
1097
+ getStepById(id: string): StepHandle | undefined;
1098
+ /**
1099
+ * Returns the step matching a given name, undefined if not found.
1100
+ * @param name The name the step must match.
1101
+ */
1102
+ getStepByName(name: string): StepHandle | undefined;
1103
+ /**
1104
+ * Returns all steps matching a specific type in the workflow. These steps
1105
+ * may be across multiple scenes and may or may not be active based on condition state.
1106
+ */
1107
+ getStepsByType(type: StepType): StepHandle[];
1108
+ /**
1109
+ * Creates a data URL preview for the current design.
1110
+ */
1111
+ createPreviewImage(): Promise<string>;
1112
+ /**
1113
+ * To be called when the workflow experience is considered completed by the user.
1114
+ * @param product
1115
+ * @param onProgressUpdate Progress callback for finalizing the design.
1116
+ * @param selections
1117
+ * @param metadata
1118
+ */
1119
+ onDesignFinished(product: Product, onProgressUpdate: DesignCreationProgressUpdate, selections: WorkflowSelections, metadata?: WorkflowMetadata | undefined): Promise<DesignCreationMessage>;
1120
+ }
1121
+ /**
1122
+ * Options that can be used during instantiation of the SpiffCommerce Javascript Client.
1123
+ * Please refer to the documentation for more information.
1124
+ */
1125
+ interface ClientOptions {
1126
+ /**
1127
+ * When set to true, the client will treat the workflow as a bulk order
1128
+ * containing multiple variations of the base design.
1129
+ */
1130
+ bulk?: boolean;
1131
+ /**
1132
+ * When set to true caching will be disabled. This is only useful for debugging. Don't use in production code!
1133
+ */
1134
+ useUncachedEndpoints?: boolean;
1135
+ }
1136
+ /**
1137
+ * The Spiff Commerce Javascript Client. Required for
1138
+ * creating workflow experiences.
1139
+ */
1140
+ export class Client {
1141
+ constructor(options: ClientOptions);
1142
+ /**
1143
+ * Initialize the client from an integration product.
1144
+ * @param integrationProductId The integration product to use.
1145
+ */
1146
+ initFromIntegrationProduct(integrationProductId: string): Promise<void>;
1147
+ /**
1148
+ * Initialize the client from an existing transaction.
1149
+ * @param transactionId The id of the transaction
1150
+ * @returns A promise resolving at initialization completion.
1151
+ */
1152
+ initFromTransaction(transactionId: string): Promise<void>;
1153
+ /**
1154
+ * Creates a new instance of WorkflowExperience. A high level wrapper for workflows.
1155
+ * @param workflowId The id of the workflow to be run.
1156
+ * @param workflowState An existing workflow state if available.
1157
+ * @param previewServiceConstructor A function called during initialization. Takes a class implementing ThreeDPreviewService in return.
1158
+ * @returns A workflow experience configured as requested.
1159
+ */
1160
+ getWorkflowExperience(workflowId?: string, workflowState?: string, previewServiceConstructor?: (workflow: Workflow) => _ThreeDPreviewService1): Promise<WorkflowExperience>;
1161
+ /**
1162
+ * @returns The preview service that was provided during construction.
1163
+ */
1164
+ getPreviewService(): _ThreeDPreviewService1;
1165
+ /**
1166
+ * @returns The product associated with this client.
1167
+ */
1168
+ getProduct(): Product;
1169
+ /**
1170
+ * @returns The transaction associated with this client.
1171
+ */
1172
+ getTransaction(): Transaction;
1173
+ }
1174
+ export class MockWorkflowManager implements WorkflowManager {
1175
+ getVariationRecords(): VariationRecord[];
1176
+ reset(): Promise<void>;
1177
+ updateStateWithServer(_getReducerState: () => CommandState): void;
1178
+ addVariationRecord(_variationRecord: Omit<VariationRecord, "recordNumber">): {
1179
+ recordNumber: number;
1180
+ transactionId: string;
1181
+ values: any[];
1182
+ };
1183
+ getCurrentVariationRecord(): any;
1184
+ removeVariationRecord(_recordNumber: number): any[];
1185
+ outstandingRequestsPromise(): Promise<void>;
1186
+ updateStateWithServerImmediate(_getReducerState: () => CommandState): Promise<void>;
1187
+ addPoller(_poller: Poller): void;
1188
+ addConfirmCallback(_callback: ConfirmCallback): void;
1189
+ addCurrentVariationCallback(_callback: CurrentVariationRecordCallback): void;
1190
+ addEditedCallback(_callback: EditedCallback): void;
1191
+ addElementsCallback(_callback: ElementsCallback): void;
1192
+ addInformationResultCallback(_callback: InformationResultCallback): void;
1193
+ addInitCallback(_callback: InitCallback): void;
1194
+ addMakingAdjustmentsCallback(_callback: MakingAdjustmentsCallback): void;
1195
+ addMandatoryCallback(_callback: MandatoryCallback): void;
1196
+ addMetadataCallback(_callback: MetadataCallback): void;
1197
+ addSelectionCallback(_callback: SelectionCallback): void;
1198
+ addStepSpecificStorageCallback(_callback: StepSpecificStorageCallback, _stepName: string): void;
1199
+ addStorageCallback(_callback: StorageCallback): void;
1200
+ addUpdateCallback(_callback: UpdateCallback): void;
1201
+ addVariationRecordsCallback(_callback: VariationRecordsCallback): void;
1202
+ getCommandDispatcher(): (_command: CanvasCommand) => void;
1203
+ getLayouts(): any[];
1204
+ getLayoutPreviewService(): {
1205
+ getAll: () => Map<any, any>;
1206
+ };
1207
+ getPreviewService(): any;
1208
+ getProductName(): string;
1209
+ getProfanities(): any[];
1210
+ getRegionElements(_stepName: string): any[];
1211
+ getSerializedStep(_stepName: string, _serializedSteps: SerializableStep[]): any;
1212
+ getStepSpecificServices(_stepName: string): any;
1213
+ getTransaction(): {
1214
+ id: string;
1215
+ };
1216
+ getWorkflow(): {
1217
+ id: string;
1218
+ name: string;
1219
+ panels: any[];
1220
+ steps: any[];
1221
+ showModelOnFinishStep: boolean;
1222
+ allowProofDownload: boolean;
1223
+ introduction: string;
1224
+ stepGroups: any[];
1225
+ };
1226
+ markStepsAsInitialised(_stepNames: string[]): void;
1227
+ markUpdateCompleted(_update: string): void;
1228
+ markUpdatePending(_update: string): void;
1229
+ getWorkflowSelections(): {};
1230
+ setCurrentAdjustingStepId(_stepId: string): void;
1231
+ setAllScenes(_config: WorkflowScenesConfiguration): void;
1232
+ setCurrentVariationRecord(_variationRecord: VariationRecord | null): void;
1233
+ setEditedStatus(_stepName: string, _status: boolean): void;
1234
+ setInformationResults(_results: InformationResult[]): void;
1235
+ setMandatoryFulfilled(_stepName: string, _status: boolean): void;
1236
+ setSelectionsAndElements(_stepName: string, _variants: VariantResource[], _elements: RegionElement[]): Promise<void>;
1237
+ setVariationRecords(_variationRecords: VariationRecord[]): void;
1238
+ toggleDesignConfirmed(): void;
1239
+ updateMetadata(_stepName: string, _update: any): void;
1240
+ updateStorage(_stepName: string, _update: StepStorage): Promise<void>;
1241
+ }
1242
+ export { CommandContext };
1243
+ export * from "@spiffcommerce/papyrus";
1244
+ export { SpiffCommerce3DPreviewService };
1245
+ export { ThreeDPreviewService };
1247
1246
 
1248
1247
  //# sourceMappingURL=types.d.ts.map