@spiffcommerce/core 0.9.9 → 0.9.11

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,4 +1,4 @@
1
- import { Workflow as _Workflow1, StepAspect as _StepAspect1, Step as _Step1, AnyStepData as _AnyStepData1, FrameOffsets, PatternImageData, IServerModel, Asset as _Asset1, MaterialResource, AssetType as _AssetType1, ColorDefinition as _ColorDefinition1, IllustrationStepData as _IllustrationStepData1, Region, ILayout as _ILayout1, CreateElementCommand as _CreateElementCommand1, IllustrationElement as _IllustrationElement1, LayoutsState as _LayoutsState1, VariantResource as _VariantResource1, CanvasCommand as _CanvasCommand1, LayoutData as _LayoutData1, DigitalContentStepData as _DigitalContentStepData1, FrameStepData as _FrameStepData1, FrameElement as _FrameElement1, MaterialStepData as _MaterialStepData1, ModelStepData as _ModelStepData1, ModuleStepData as _ModuleStepData1, PatchworkStepData as _PatchworkStepData1, PatchworkOffsets as _PatchworkOffsets1, PictureStepData as _PictureStepData1, QuestionStepData as _QuestionStepData1, ShapeStepData as _ShapeStepData1, FontData, GroupCommand as _GroupCommand1, OptionResource as _OptionResource1, TextboxElement as _TextboxElement1, TextStepData as _TextStepData1, StepStorage as _StepStorage1, SerializableStep, CommandState as _CommandState1, LayoutState, CommandContext as _CommandContext1, Point, ScaleAxis, UnitOfMeasurement as _UnitOfMeasurement1, StepType as _StepType1, Animatable, AnyStepData, Asset, AssetType, BringForwardCommand, BulkStepData, CanvasCommand, ColorDefinition, CommandContext, CommandState, CreateElementCommand, DeleteElementCommand, DigitalContentStepData, FontAlignmentCommand, FontColorCommand, FontSizeCommand, FontSourceCommand, FrameElement, FrameStepData, GroupCommand, ILayout, IllustrationElement, IllustrationStepData, ImageElement, LayoutData, LayoutElement, LayoutElementFactory, LayoutElementType, LayoutsState, MaterialStepData, ModelStepData, ModuleStepData, MoveCommand, OptionResource, PatchworkElement, PatchworkOffsets, PatchworkStepData, PictureStepData, QuestionStepData, ResizeCommand, RotateCommand, SendBackwardsCommand, ShapeStepData, Step, StepAspect, StepAspectType, StepStorage, StepType, TextChangeCommand, TextStepData, TextboxElement, UnitOfMeasurement, VariantResource, Workflow, dataUrlFromExternalUrl, findElement, frameDataCache, generate, generateSVGWithUnknownColors, getAttributesFromArrayBuffer, getFrameData, getSvgString, loadFontFromDataUrl, loadFontFromExternalUrl, patternImageDataCache, CreateLayoutCommand, rehydrateSerializedLayout, ColorProfileProps, WorkflowPanel, determineCorrectFontSizeAndLines, registerJSDOM } from "@spiffcommerce/papyrus";
1
+ import { Workflow as _Workflow1, StepAspect as _StepAspect1, Step as _Step1, AnyStepData as _AnyStepData1, FrameOffsets, PatternImageData, IServerModel, Asset as _Asset1, MaterialResource, AssetType as _AssetType1, ColorDefinition as _ColorDefinition1, IllustrationStepData as _IllustrationStepData1, Region, ILayout as _ILayout1, CreateElementCommand as _CreateElementCommand1, IllustrationElement as _IllustrationElement1, LayoutsState as _LayoutsState1, VariantResource as _VariantResource1, CanvasCommand as _CanvasCommand1, LayoutData as _LayoutData1, DigitalContentStepData as _DigitalContentStepData1, FrameStepData as _FrameStepData1, FrameElement as _FrameElement1, MaterialStepData as _MaterialStepData1, ModelStepData as _ModelStepData1, ModuleStepData as _ModuleStepData1, PatchworkStepData as _PatchworkStepData1, PatchworkOffsets as _PatchworkOffsets1, PictureStepData as _PictureStepData1, QuestionStepData as _QuestionStepData1, ShapeStepData as _ShapeStepData1, FontData, GroupCommand as _GroupCommand1, OptionResource as _OptionResource1, TextboxElement as _TextboxElement1, TextStepData as _TextStepData1, StepStorage as _StepStorage1, SerializableStep, CommandState as _CommandState1, CommandContext as _CommandContext1, LayoutState, Point, ScaleAxis, UnitOfMeasurement as _UnitOfMeasurement1, StepType as _StepType1, Animatable, AnyStepData, Asset, AssetType, BringForwardCommand, BulkStepData, CanvasCommand, ColorDefinition, CommandContext, CommandState, CreateElementCommand, DeleteElementCommand, DigitalContentStepData, FontAlignmentCommand, FontColorCommand, FontSizeCommand, FontSourceCommand, FrameElement, FrameStepData, GroupCommand, ILayout, IllustrationElement, IllustrationStepData, ImageElement, LayoutData, LayoutElement, LayoutElementFactory, LayoutElementType, LayoutsState, MaterialStepData, ModelStepData, ModuleStepData, MoveCommand, OptionResource, PatchworkElement, PatchworkOffsets, PatchworkStepData, PictureStepData, QuestionStepData, ResizeCommand, RotateCommand, SendBackwardsCommand, ShapeStepData, Step, StepAspect, StepAspectType, StepStorage, StepType, TextChangeCommand, TextStepData, TextboxElement, UnitOfMeasurement, VariantResource, Workflow, dataUrlFromExternalUrl, findElement, frameDataCache, generate, generateSVGWithUnknownColors, getAttributesFromArrayBuffer, getFrameData, getSvgString, loadFontFromDataUrl, loadFontFromExternalUrl, patternImageDataCache, CreateLayoutCommand, rehydrateSerializedLayout, ColorProfileProps, WorkflowPanel, determineCorrectFontSizeAndLines, registerJSDOM } from "@spiffcommerce/papyrus";
2
2
  import { ApolloClient } from "@apollo/client";
3
3
  import { ReactNode, Dispatch, FunctionComponent, RefObject, PointerEvent, KeyboardEvent, MouseEvent } from "react";
4
4
  export const gatherVaryingStepAspects: (workflow: _Workflow1) => _StepAspect1[];
@@ -38,7 +38,7 @@ export class PromiseQueue<T extends QueueablePromise> {
38
38
  * Enqueue a new promise.
39
39
  * @param promise A new promise to add to the queue.
40
40
  */
41
- enqueue(promise: T): Promise<void>;
41
+ enqueue(promise: T): void;
42
42
  /**
43
43
  * @returns Returns true when work is being actively processed by this queue.
44
44
  */
@@ -348,7 +348,7 @@ declare class TextStepService implements StepService<_TextStepData1> {
348
348
  */
349
349
  filterUnsupportedCharacters: (text: string, fontData?: FontData) => string;
350
350
  updateInputText(input: string, elements: _TextboxElement1[], step: _Step1<_TextStepData1>, workflowManager: WorkflowManager): TextUpdateResult;
351
- selectVariant(step: _Step1<_TextStepData1>, variant: _VariantResource1, storage: TextStepStorage, elements: RegionElement[], workflowManager: WorkflowManager, setError: (status: boolean) => void, setHelperText: (text: string) => void): void;
351
+ selectVariant(step: _Step1<_TextStepData1>, variant: _VariantResource1, workflowManager: WorkflowManager, setError: (status: boolean) => void, setHelperText: (text: string) => void): void;
352
352
  textAlign: (stepData: _TextStepData1) => string;
353
353
  createTextFillSpotColor(colorOption: IServerModel<_OptionResource1>, variant: _VariantResource1): TextFillSpotColor | undefined;
354
354
  }
@@ -400,7 +400,8 @@ export interface InformationResult {
400
400
  }
401
401
  export enum InformationMessageType {
402
402
  Error = "Error",
403
- Warning = "Warning"
403
+ Warning = "Warning",
404
+ Info = "Info"
404
405
  }
405
406
  /**
406
407
  * Services required for the operaiton of individual steps.
@@ -449,6 +450,7 @@ export interface WorkflowManager {
449
450
  getCommandDispatcher: () => (command: _CanvasCommand1) => void;
450
451
  getCurrentVariationRecord: () => VariationRecord | undefined;
451
452
  getVariationRecords: () => VariationRecord[];
453
+ getCommandContext: () => _CommandContext1;
452
454
  getLayouts: () => _ILayout1[];
453
455
  getAllLayoutData: () => LayoutState[];
454
456
  getLayoutPreviewService: () => any;
@@ -1047,57 +1049,30 @@ export const AdvancedEditor: FunctionComponent<{
1047
1049
  handleContextMenu?: (event: MouseEvent) => void;
1048
1050
  onElementSelected?: (id: string | undefined, element: PointerEvent) => void;
1049
1051
  }>;
1050
- /**
1051
- * An abstract base class to be extended by step handles to implement type specific behavior.
1052
- */
1053
- declare abstract class StepHandleTypeContext<T> {
1054
- protected readonly manager: WorkflowManager;
1055
- protected readonly step: _Step1<T>;
1056
- constructor(manager: WorkflowManager, stepConfiguration: _Step1<T>);
1057
- }
1058
- interface TextChangeResult {
1059
- input: string;
1060
- helperText?: string;
1061
- errorText?: string;
1062
- }
1063
- declare class StepHandleTextContext extends StepHandleTypeContext<_TextStepData1> {
1064
- /**
1065
- * Changes the fill of text related to this step to the new fill value.
1066
- * @param fill A new fill value to use.
1067
- */
1068
- setFill(fill: ColorOption): Promise<void>;
1069
- /**
1070
- * Changes the text value of text related to this step to a new value.
1071
- * @param userInput Input from the user.
1072
- */
1073
- setText(userInput: string): TextChangeResult;
1074
- }
1075
1052
  /**
1076
1053
  * A StepHandle allows for managing the state of a specific step in a workflow. This class
1077
1054
  * abstracts away the complexities of dealing with a step directly and allows for using high level
1078
1055
  * concepts instead of dealing with the underlying data structures.
1079
1056
  */
1080
- interface StepHandle {
1057
+ declare abstract class StepHandle<T extends _AnyStepData1> {
1058
+ protected readonly manager: WorkflowManager;
1059
+ protected readonly step: _Step1<T>;
1060
+ constructor(manager: WorkflowManager, step: _Step1<T>);
1081
1061
  /**
1082
1062
  * Gets the currently selected variant, or undefined if no variant is selected.
1083
1063
  */
1084
- getCurrentVariant(): any;
1064
+ getCurrentVariant(): _VariantResource1;
1085
1065
  /**
1086
1066
  * Returns a list of valid variants for this step.
1087
1067
  */
1088
1068
  getAvailableVariants(): Promise<_VariantResource1[]>;
1089
1069
  /**
1090
- * Selects a specific variant for this step.
1070
+ * Most step types have a base option type that variants can be selected for.
1071
+ * Selects a specific variant for this step. This will execute all required changes to
1072
+ * the design and update the metadata to include the new selection. Any conditions
1073
+ * that would be triggered will also be executed.
1091
1074
  */
1092
- selectVariant(variant: _VariantResource1): any;
1093
- /**
1094
- * Get a handle to a class that exposes any functionality specific to this step type.
1095
- */
1096
- getTypeSpecificContext(): StepHandleTextContext | StepHandleIllustrationContext | StepHandleQuestionContext;
1097
- }
1098
- declare class StepHandleIllustrationContext extends StepHandleTypeContext<_IllustrationStepData1> {
1099
- }
1100
- declare class StepHandleQuestionContext extends StepHandleTypeContext<_QuestionStepData1> {
1075
+ abstract selectVariant(variant: _VariantResource1): Promise<void>;
1101
1076
  }
1102
1077
  /**
1103
1078
  * A Workflow experience encapsulates the workflow manager and command context. It
@@ -1125,17 +1100,17 @@ export interface WorkflowExperience {
1125
1100
  * Returns the step matching a given name, undefined if not found.
1126
1101
  * @param id The id the step must match.
1127
1102
  */
1128
- getStepById(id: string): StepHandle | undefined;
1103
+ getStepById(id: string): StepHandle<_AnyStepData1> | undefined;
1129
1104
  /**
1130
1105
  * Returns the step matching a given name, undefined if not found.
1131
1106
  * @param name The name the step must match.
1132
1107
  */
1133
- getStepByName(name: string): StepHandle | undefined;
1108
+ getStepByName(name: string): StepHandle<_AnyStepData1> | undefined;
1134
1109
  /**
1135
1110
  * Returns all steps matching a specific type in the workflow. These steps
1136
1111
  * may be across multiple scenes and may or may not be active based on condition state.
1137
1112
  */
1138
- getStepsByType(type: _StepType1): StepHandle[];
1113
+ getStepsByType(type: _StepType1): StepHandle<_AnyStepData1>[];
1139
1114
  /**
1140
1115
  * Creates a data URL preview for the current design.
1141
1116
  */
@@ -1210,6 +1185,7 @@ export class Client {
1210
1185
  getTransaction(): Transaction;
1211
1186
  }
1212
1187
  export class MockWorkflowManager implements WorkflowManager {
1188
+ getCommandContext: () => _CommandContext1;
1213
1189
  getAllLayoutData: () => LayoutState[];
1214
1190
  getMetadata: (stepName: string) => StepMetadata | undefined;
1215
1191
  getStepStorage: (stepName: string) => _StepStorage1 | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spiffcommerce/core",
3
- "version": "0.9.9",
3
+ "version": "0.9.11",
4
4
  "description": "Core client API for interacting with the Spiff Commerce backend.",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/main.js",
@@ -9,7 +9,7 @@
9
9
  "scripts": {
10
10
  "build": "parcel build",
11
11
  "dev": "ladle serve",
12
- "test": "jest && tsc --noEmit --isolatedModules",
12
+ "test": "jest && tsc --noEmit --isolatedModules --skipLibCheck",
13
13
  "prepare": "yarn run build"
14
14
  },
15
15
  "targets": {
@@ -79,7 +79,7 @@
79
79
  },
80
80
  "dependencies": {
81
81
  "@apollo/client": "^3.7.0",
82
- "@spiffcommerce/papyrus": "^1.5.4",
82
+ "@spiffcommerce/papyrus": "^1.5.5",
83
83
  "canvg": "https://github.com/spiffdev/canvg.git#03bcd151b12441e88ecb552bb658356f5bbe92c4",
84
84
  "cross-fetch": "^3.1.5",
85
85
  "graphql": "^16.6.0",