@spiffcommerce/core 14.2.7-alpha.0 → 14.2.8-beta.0

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/index.d.mts CHANGED
@@ -1,7 +1,8 @@
1
1
  import * as _spiffcommerce_papyrus from '@spiffcommerce/papyrus';
2
- import { OptionResource, VariantResource, Step, AnyStepData, FrameOffsets, PatternImageData, Region, StepStorage, CanvasCommand, CommandContext, ILayout, LayoutState, SerializableStep, Workflow, CommandState, GlobalPropertyConfiguration, LayoutsState, Asset, MaterialResource, AssetType, StepType, GlobalPropertyConfigurationAspect, AspectType, Theme, StepAspect, FrameStepData, CreateElementCommand, FrameElement, IllustrationStepData, IllustrationElement, ColorDefinition, LayoutData, MaterialStepData, ModelStepData, TextStepData, TextboxElement, TextFillImage, FontData, GroupCommand, PictureStepData, QuestionStepData, ShapeStepData, ModuleStepData, DigitalContentStepData, FrameData as FrameData$1, BulkStepData } from '@spiffcommerce/papyrus';
2
+ import { OptionResource, VariantResource, Step, AnyStepData, FrameOffsets, PatternImageData, Region, SilentStepData, Placeable, StepStorage, CanvasCommand, CommandContext, ILayout, LayoutState, SerializableStep, Workflow, CommandState, GlobalPropertyConfiguration, LayoutsState, Asset, MaterialResource, AssetType, StepType, GlobalPropertyConfigurationAspect, AspectType, Theme, StepAspect, FrameStepData, CreateElementCommand, FrameElement, IllustrationStepData, IllustrationElement, ColorDefinition, LayoutData, MaterialStepData, ModelStepData, TextStepData, TextboxElement, TextFillImage, FontData, GroupCommand, PictureStepData, QuestionStepData, ShapeStepData, ModuleStepData, DigitalContentStepData, FrameData as FrameData$1, BulkStepData } from '@spiffcommerce/papyrus';
3
3
  export { Animatable, AnyStepData, Asset, AssetType, BringForwardCommand, BringToBackCommand, BringToFrontCommand, BulkStepData, CanvasCommand, ColorDefinition, ColorProfileProps, CommandContext, CommandState, CreateElementCommand, CreateLayoutCommand, DeleteElementCommand, DigitalContentStepData, FontAlignmentCommand, FontColorCommand, FontSizeCommand, FontSourceCommand, FrameElement, FrameStepData, GroupCommand, ILayout, IllustrationElement, IllustrationStepData, ImageElement, LayoutData, LayoutElement, LayoutElementFactory, LayoutElementType, LayoutsState, MaterialStepData, ModelStepData, ModuleStepData, MoveCommand, OptionResource, PictureStepData, QuestionStepData, ResizeCommand, RotateCommand, SendBackwardsCommand, ShapeStepData, Step, StepAspect, StepAspectType, StepStorage, StepType, TextChangeCommand, TextStepData, TextboxElement, Theme, UnitOfMeasurement, VariantResource, Workflow, WorkflowPanel, dataUrlFromExternalUrl, determineCorrectFontSizeAndLines, findElement, frameDataCache, generate, generateSVGWithUnknownColors, getAttributesFromArrayBuffer, getAxisAlignedBoundingBox, getFrameData, getSvgElement, loadFontFromDataUrl, loadFontFromExternalUrl, patternImageDataCache, registerJSDOM, rehydrateSerializedLayout } from '@spiffcommerce/papyrus';
4
- import { ApolloClient } from '@apollo/client/core';
4
+ import { ApolloClient, FetchResult } from '@apollo/client/core';
5
+ import * as lodash from 'lodash';
5
6
 
6
7
  declare class OptionService {
7
8
  /**
@@ -262,6 +263,8 @@ declare abstract class ModuleProduct {
262
263
  abstract svgPrint(text: string, region: Region): string;
263
264
  }
264
265
 
266
+ interface SilentIllustrationStepData extends SilentStepData, Placeable {
267
+ }
265
268
  interface EditedSteps {
266
269
  [stepName: string]: boolean;
267
270
  }
@@ -322,6 +325,7 @@ type StepSpecificStorageCallback = (selections: StepStorage) => void;
322
325
  type StorageCallback = (storage: WorkflowStorage) => void;
323
326
  type CurrentVariationRecordCallback = (variationRecord: null | VariationRecord) => void;
324
327
  type VariationRecordsCallback = (records: VariationRecord[]) => void;
328
+ type StateMutationFunc = (options?: any) => Promise<FetchResult<any, Record<string, any>, Record<string, any>>>;
325
329
  interface WorkflowManager {
326
330
  addPoller: (poller: Poller) => void;
327
331
  addConfirmCallback: (callback: ConfirmCallback) => void;
@@ -407,7 +411,7 @@ interface WorkflowManager {
407
411
  */
408
412
  injectIntoPreviewService(previewService: any): Promise<void>;
409
413
  /**
410
- * Ejects the model of this product from the preview service.
414
+ * Ejects the model of this product from the preview service. This also sets the internal preview service to undefined.
411
415
  */
412
416
  ejectFromPreviewService(): void;
413
417
  }
@@ -1236,6 +1240,31 @@ interface Scene {
1236
1240
  */
1237
1241
  stepIds: string[];
1238
1242
  }
1243
+ /**
1244
+ * State related to a workflow experience.
1245
+ */
1246
+ interface ExperienceOptions {
1247
+ product: Product;
1248
+ transaction: Transaction;
1249
+ workflow?: Workflow;
1250
+ previewService?: any;
1251
+ modelContainer?: any;
1252
+ renderableContextService?: any;
1253
+ layouts: ILayout[];
1254
+ reloadedState?: LayoutsState;
1255
+ /**
1256
+ * When true the experience is intended to be immutable.
1257
+ */
1258
+ readOnly?: boolean;
1259
+ /**
1260
+ * A function that communicates state changes to the server.
1261
+ */
1262
+ stateMutationFunc: StateMutationFunc;
1263
+ /**
1264
+ * Should be set to true when the experience is loaded from an existing transaction.
1265
+ */
1266
+ isReloadedTransaction?: boolean;
1267
+ }
1239
1268
  /**
1240
1269
  * A Workflow experience encapsulates the workflow manager and command context. It
1241
1270
  * provides a simplified interface for interacting with the workflow manager. You
@@ -1363,6 +1392,50 @@ interface WorkflowExperience {
1363
1392
  [key: string]: string;
1364
1393
  }>;
1365
1394
  }
1395
+ declare class WorkflowExperienceImpl implements WorkflowExperience {
1396
+ readonly client: SpiffCommerceClient;
1397
+ readonly commandContext: CommandContext;
1398
+ readonly workflowManager: WorkflowManager;
1399
+ readonly isReadOnly: boolean;
1400
+ private renderableScenes;
1401
+ private renderableSceneCallbacks;
1402
+ constructor(client: SpiffCommerceClient, experienceOptions: ExperienceOptions);
1403
+ getClient(): SpiffCommerceClient;
1404
+ getIsReadOnly(): boolean;
1405
+ getCommandContext(): CommandContext;
1406
+ getWorkflowManager(): WorkflowManager;
1407
+ updateVariationRecords(variationRecords: VariationRecord[]): Promise<void>;
1408
+ createPreviewImage(isThreeD?: boolean, resolution?: number): Promise<string>;
1409
+ getStepById(id: string): TextStepHandle | FrameStepHandle | BulkStepHandle | ShapeStepHandle | IllustrationStepHandle | MaterialStepHandle | ModelStepHandle | PictureStepHandle | QuestionStepHandle | undefined;
1410
+ getSteps(): StepHandle<AnyStepData>[];
1411
+ getScenes(): Scene[];
1412
+ getSelectionPriceSubunits(): number;
1413
+ getBasePriceSubunits(): number;
1414
+ getTotalPriceSubunits(): number;
1415
+ getBulkStep(): BulkStepHandle | undefined;
1416
+ getStepByName(name: string): TextStepHandle | FrameStepHandle | BulkStepHandle | ShapeStepHandle | IllustrationStepHandle | MaterialStepHandle | ModelStepHandle | PictureStepHandle | QuestionStepHandle | undefined;
1417
+ getStepsByType(type: StepType): StepHandle<AnyStepData>[];
1418
+ getStepsByScene(scene: Scene): StepHandle<AnyStepData>[];
1419
+ attachCustomerDetails(details: {
1420
+ email: string;
1421
+ }): Promise<void>;
1422
+ assignCustomerDetails(details: CustomerDetailsInput): Promise<void>;
1423
+ attachRenderableSceneListener(cb: (scenes: RenderableScene[]) => void): void;
1424
+ detachRenderableSceneListener(cb: (scenes: RenderableScene[]) => void): void;
1425
+ debouncedSavedDesignUpdate: lodash.DebouncedFunc<() => Promise<void>>;
1426
+ save(title?: string): Promise<SavedDesign>;
1427
+ copy(): Promise<WorkflowExperience>;
1428
+ onDesignFinished(onProgressUpdate?: DesignCreationProgressUpdate): Promise<DesignCreationMessage>;
1429
+ /**
1430
+ * @param step The step to test against.
1431
+ * @returns Returns true when a valid handle is implemented for a given step type. Certain steps don't support handles, such as silent illustrations.
1432
+ */
1433
+ private stepHasHandle;
1434
+ private getCanvasObjectURLAsync;
1435
+ getExportedData(): Map<string, {
1436
+ [key: string]: string;
1437
+ }>;
1438
+ }
1366
1439
 
1367
1440
  /**
1368
1441
  * A GlobalPropertyHandle acts as an interface to global properties on our platform. Currently
@@ -1530,6 +1603,25 @@ interface Bundle {
1530
1603
  * Remove a previously added event listener from this bundle.
1531
1604
  */
1532
1605
  removeEventListener(event: BundleEvent, listener: () => void): void;
1606
+ /**
1607
+ * Retrieves the current preview service for this bundle, if one exists.
1608
+ * If a preview service was specified when calling client.getExistingBundle, this will return that service.
1609
+ * Call `setPreviewService` to update the preview service for this bundle.
1610
+ */
1611
+ getPreviewService(): any | undefined;
1612
+ /**
1613
+ * Set the preview service for this bundle. This will update the preview service for all workflow experiences in this bundle, and will
1614
+ * also automatically inject the preview service into any new workflow experiences that are added to this bundle.
1615
+ * If this method is called with no arguments or undefined, the preview service will be removed from this bundle.
1616
+ * @param previewService The preview service to use for this bundle.
1617
+ * @returns A promise that resolves when the preview service has been updated for all workflow experiences in this bundle.
1618
+ */
1619
+ setPreviewService(previewService?: any): Promise<void>;
1620
+ /**
1621
+ * Returns a promise that resolves when the bundle has been initialized.
1622
+ * This will resolve immediately if the bundle has no experiences, or if the bundle has already been initialized.
1623
+ */
1624
+ getInitializationPromise(): Promise<void>;
1533
1625
  }
1534
1626
  type BundleEvent = "conditional-global-properties-changed";
1535
1627
 
@@ -1711,9 +1803,11 @@ declare class SpiffCommerceClient {
1711
1803
  getNewBundle(collectionId?: string): Promise<Bundle>;
1712
1804
  /**
1713
1805
  * Retrieves an existing bundle from the API, by id.
1806
+ * @param bundleId The id of the bundle to retrieve.
1807
+ * @param previewService Optional: A reference to an existing preview service to use. This can be assigned manually later.
1714
1808
  * @returns A bundle to be used for grouping and operating on large amounts of workflow experiences.
1715
1809
  */
1716
- getExistingBundle(bundleId: string, previewServiceConstructor?: (workflow: Workflow, transactionId: string) => any): Promise<Bundle>;
1810
+ getExistingBundle(bundleId: string, previewService?: any): Promise<Bundle>;
1717
1811
  /**
1718
1812
  * Retrieves all existing bundle stakeholders from the API, for the currently authenticated customer.
1719
1813
  * @returns An array of bundle stakeholders.
@@ -2357,4 +2451,4 @@ interface StepAspectValue {
2357
2451
  declare const stepAspectValuesToDesignInputSteps: (stepAspectValues: StepAspectValue[], workflow: Workflow) => DesignInputStep[];
2358
2452
  declare const generateStateFromDesignInputSteps: (designInputSteps: DesignInputStep[], workflow: Workflow, layouts: ILayout[], productOverlayImageUrl?: string) => Promise<LayoutsState>;
2359
2453
 
2360
- export { AssetNotFoundError, BulkPriceCalculationStrategy, BulkStepHandle, ColorOption, ConversionConfiguration, ConversionData, ConversionDataType, ConversionLocation, Customer, CustomerDetailsInput, DesignCreationMessage, DesignCreationProgressUpdate, DesignInputStep, EditedSteps, FrameService, FrameStep, FrameStepHandle, GetWorkflowOptions, IllustrationStepHandle, InformationMessageType, InformationResult, LayoutNotFoundError, MandatorySteps, MaterialStepHandle, MisconfigurationError, MockWorkflowManager, ModelStepHandle, ObjectInput, ObjectInputType, OptionNotFoundError, ParseError, PictureStepHandle, ProductCameraRig, PromiseQueue, QuestionStepHandle, QueueablePromise, RegionElement, RenderableScene, ResourceNotFoundError, SavedDesign, SelectionStorage, ShapeStepHandle, SpiffCommerceClient, Stakeholder, StakeholderType, StepElements, StepHandle, TextInput, TextStepHandle, TextStepStorage, Transaction, UnhandledBehaviorError, Variant, VariationRecord, WorkflowExperience, WorkflowManager, WorkflowMetadata, WorkflowScene, WorkflowSelections, WorkflowStorage, assetService, createDesign, designService, digitalContentStepService, frameStepService, gatherVaryingStepAspects, generateCommands, generateStateFromDesignInputSteps, getBoundedOffsets, getWorkflow, graphQlManager, illustrationStepService, materialStepService, modelStepService, moduleStepService, optionService, persistenceService, pictureStepService, questionStepService, shapeStepService, shortenUrl, spiffCoreConfiguration, stepAspectValuesToDesignInputSteps, textStepService, toast };
2454
+ export { AssetNotFoundError, BulkPriceCalculationStrategy, BulkStepHandle, Bundle, ColorOption, ConversionConfiguration, ConversionData, ConversionDataType, ConversionLocation, Customer, CustomerDetailsInput, DesignCreationMessage, DesignCreationProgressUpdate, DesignInputStep, EditedSteps, FrameService, FrameStep, FrameStepHandle, GetWorkflowOptions, IllustrationStepHandle, InformationMessageType, InformationResult, LayoutNotFoundError, MandatorySteps, MaterialStepHandle, MisconfigurationError, MockWorkflowManager, ModelStepHandle, ObjectInput, ObjectInputType, OptionNotFoundError, ParseError, PictureStepHandle, Product, ProductCameraRig, PromiseQueue, QuestionStepHandle, QueueablePromise, RegionElement, RenderableScene, ResourceNotFoundError, SavedDesign, SelectionStorage, ShapeStepHandle, SilentIllustrationStepData, SpiffCommerceClient, Stakeholder, StakeholderType, StateMutationFunc, StepElements, StepHandle, TextInput, TextStepHandle, TextStepStorage, Transaction, UnhandledBehaviorError, Variant, VariationRecord, WorkflowExperience, WorkflowExperienceImpl, WorkflowManager, WorkflowMetadata, WorkflowScene, WorkflowSelections, WorkflowStorage, assetService, createDesign, designService, digitalContentStepService, frameStepService, gatherVaryingStepAspects, generateCommands, generateStateFromDesignInputSteps, getBoundedOffsets, getWorkflow, graphQlManager, illustrationStepService, materialStepService, modelStepService, moduleStepService, optionService, persistenceService, pictureStepService, questionStepService, shapeStepService, shortenUrl, spiffCoreConfiguration, stepAspectValuesToDesignInputSteps, textStepService, toast };