@spiffcommerce/core 14.3.1 → 14.5.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/main.js +4 -3
- package/dist/module.js +36 -35
- package/dist/types.d.ts +98 -12
- package/package.json +2 -2
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import { Workflow as _Workflow1, StepAspect as _StepAspect1, Step as _Step1, AnyStepData as _AnyStepData1, Asset as _Asset1, Region, VariantResource as _VariantResource1, FrameOffsets, PatternImageData, DigitalContentStepData as _DigitalContentStepData1, LayoutsState as _LayoutsState1, CanvasCommand as _CanvasCommand1, FrameStepData as _FrameStepData1, ILayout as _ILayout1, CreateElementCommand as _CreateElementCommand1, FrameElement as _FrameElement1, ColorDefinition as _ColorDefinition1, IllustrationStepData as _IllustrationStepData1, IllustrationElement as _IllustrationElement1, LayoutData as _LayoutData1, MaterialStepData as _MaterialStepData1, ModelStepData as _ModelStepData1, ModuleStepData as _ModuleStepData1, PictureStepData as _PictureStepData1, QuestionStepData as _QuestionStepData1, ShapeStepData as _ShapeStepData1, FontData, GroupCommand as _GroupCommand1, OptionResource as _OptionResource1, TextboxElement as _TextboxElement1, TextFillImage, TextStepData as _TextStepData1, StepStorage as _StepStorage1, SerializableStep, CommandState as _CommandState1, CommandContext as _CommandContext1, LayoutState, GlobalPropertyConfiguration, MaterialResource, AssetType as _AssetType1, Point, ScaleAxis, UnitOfMeasurement as _UnitOfMeasurement1, StepType as _StepType1, BulkStepData as _BulkStepData1, FrameData as _FrameData1, AspectType, GlobalPropertyConfigurationAspect, Theme as _Theme1, Animatable, AnyStepData, Asset, AssetType, BringForwardCommand, BringToFrontCommand, BringToBackCommand, BulkStepData, CanvasCommand, ColorDefinition, CommandContext, CommandState, CreateElementCommand, DeleteElementCommand, DigitalContentStepData, FontAlignmentCommand, FontColorCommand, FontSizeCommand, FontSourceCommand, FrameElement, FrameStepData, GroupCommand, ILayout, IllustrationElement, IllustrationStepData, ImageElement, LayoutData, LayoutElement, LayoutElementFactory, LayoutElementType, LayoutsState, MaterialStepData, ModelStepData, ModuleStepData, MoveCommand, OptionResource, PictureStepData, QuestionStepData, ResizeCommand, RotateCommand, SendBackwardsCommand, ShapeStepData, Step, StepAspect, StepAspectType, StepStorage, StepType, TextChangeCommand, TextStepData, TextboxElement, UnitOfMeasurement, VariantResource, Workflow, dataUrlFromExternalUrl, findElement, frameDataCache, generate, generateSVGWithUnknownColors, getAttributesFromArrayBuffer, getFrameData, getSvgElement, loadFontFromDataUrl, loadFontFromExternalUrl, patternImageDataCache, CreateLayoutCommand, rehydrateSerializedLayout, ColorProfileProps, WorkflowPanel, determineCorrectFontSizeAndLines, registerJSDOM, getAxisAlignedBoundingBox, Theme } from "@spiffcommerce/papyrus";
|
|
1
|
+
import { Workflow as _Workflow1, StepAspect as _StepAspect1, Step as _Step1, AnyStepData as _AnyStepData1, Asset as _Asset1, Region, VariantResource as _VariantResource1, FrameOffsets, PatternImageData, DigitalContentStepData as _DigitalContentStepData1, LayoutsState as _LayoutsState1, CanvasCommand as _CanvasCommand1, FrameStepData as _FrameStepData1, ILayout as _ILayout1, CreateElementCommand as _CreateElementCommand1, FrameElement as _FrameElement1, ColorDefinition as _ColorDefinition1, IllustrationStepData as _IllustrationStepData1, IllustrationElement as _IllustrationElement1, LayoutData as _LayoutData1, MaterialStepData as _MaterialStepData1, ModelStepData as _ModelStepData1, ModuleStepData as _ModuleStepData1, PictureStepData as _PictureStepData1, QuestionStepData as _QuestionStepData1, ShapeStepData as _ShapeStepData1, FontData, GroupCommand as _GroupCommand1, OptionResource as _OptionResource1, TextboxElement as _TextboxElement1, TextFillImage, TextStepData as _TextStepData1, SilentStepData, Placeable, StepStorage as _StepStorage1, SerializableStep, CommandState as _CommandState1, CommandContext as _CommandContext1, LayoutState, GlobalPropertyConfiguration, MaterialResource, AssetType as _AssetType1, Point, ScaleAxis, UnitOfMeasurement as _UnitOfMeasurement1, StepType as _StepType1, BulkStepData as _BulkStepData1, FrameData as _FrameData1, AspectType, GlobalPropertyConfigurationAspect, Theme as _Theme1, Animatable, AnyStepData, Asset, AssetType, BringForwardCommand, BringToFrontCommand, BringToBackCommand, BulkStepData, CanvasCommand, ColorDefinition, CommandContext, CommandState, CreateElementCommand, DeleteElementCommand, DigitalContentStepData, FontAlignmentCommand, FontColorCommand, FontSizeCommand, FontSourceCommand, FrameElement, FrameStepData, GroupCommand, ILayout, IllustrationElement, IllustrationStepData, ImageElement, LayoutData, LayoutElement, LayoutElementFactory, LayoutElementType, LayoutsState, MaterialStepData, ModelStepData, ModuleStepData, MoveCommand, OptionResource, PictureStepData, QuestionStepData, ResizeCommand, RotateCommand, SendBackwardsCommand, ShapeStepData, Step, StepAspect, StepAspectType, StepStorage, StepType, TextChangeCommand, TextStepData, TextboxElement, UnitOfMeasurement, VariantResource, Workflow, dataUrlFromExternalUrl, findElement, frameDataCache, generate, generateSVGWithUnknownColors, getAttributesFromArrayBuffer, getFrameData, getSvgElement, loadFontFromDataUrl, loadFontFromExternalUrl, patternImageDataCache, CreateLayoutCommand, rehydrateSerializedLayout, ColorProfileProps, WorkflowPanel, determineCorrectFontSizeAndLines, registerJSDOM, getAxisAlignedBoundingBox, Theme } from "@spiffcommerce/papyrus";
|
|
2
|
+
import { DefaultContext, OperationVariables } from "@apollo/client/core/types";
|
|
3
|
+
import { MutationFunctionOptions } from "@apollo/client/react/types/types";
|
|
4
|
+
import { ApolloCache, FetchResult } from "@apollo/client/core";
|
|
2
5
|
import { ApolloClient } from "@apollo/client";
|
|
3
6
|
import React, { ReactNode, Dispatch, FunctionComponent, RefObject, PointerEvent, KeyboardEvent } from "react";
|
|
4
7
|
export const gatherVaryingStepAspects: (workflow: _Workflow1) => _StepAspect1[];
|
|
@@ -409,6 +412,8 @@ declare abstract class ModuleProduct {
|
|
|
409
412
|
*/
|
|
410
413
|
abstract svgPrint(text: string, region: Region): string;
|
|
411
414
|
}
|
|
415
|
+
export interface SilentIllustrationStepData extends SilentStepData, Placeable {
|
|
416
|
+
}
|
|
412
417
|
export interface EditedSteps {
|
|
413
418
|
[stepName: string]: boolean;
|
|
414
419
|
}
|
|
@@ -469,6 +474,7 @@ type StepSpecificStorageCallback = (selections: _StepStorage1) => void;
|
|
|
469
474
|
type StorageCallback = (storage: WorkflowStorage) => void;
|
|
470
475
|
type CurrentVariationRecordCallback = (variationRecord: null | VariationRecord) => void;
|
|
471
476
|
type VariationRecordsCallback = (records: VariationRecord[]) => void;
|
|
477
|
+
export type StateMutationFunc = (options?: MutationFunctionOptions<any, OperationVariables, DefaultContext, ApolloCache<any>> | undefined) => Promise<FetchResult<any, Record<string, any>, Record<string, any>>>;
|
|
472
478
|
export interface WorkflowManager {
|
|
473
479
|
addPoller: (poller: Poller) => void;
|
|
474
480
|
addConfirmCallback: (callback: ConfirmCallback) => void;
|
|
@@ -771,7 +777,7 @@ interface Partner {
|
|
|
771
777
|
currencyCode?: string;
|
|
772
778
|
customerDetailsPromptMarkdown?: string;
|
|
773
779
|
}
|
|
774
|
-
interface Product {
|
|
780
|
+
export interface Product {
|
|
775
781
|
/**
|
|
776
782
|
* ID of the partner owner.
|
|
777
783
|
*/
|
|
@@ -1039,7 +1045,7 @@ export interface Stakeholder {
|
|
|
1039
1045
|
transaction?: Transaction;
|
|
1040
1046
|
customer?: Customer;
|
|
1041
1047
|
}
|
|
1042
|
-
interface
|
|
1048
|
+
interface _Bundle1 {
|
|
1043
1049
|
id?: string;
|
|
1044
1050
|
bundleOwnerId?: string;
|
|
1045
1051
|
bundleStakeholders?: BundleStakeholder[];
|
|
@@ -1054,7 +1060,7 @@ interface Bundle {
|
|
|
1054
1060
|
}
|
|
1055
1061
|
interface BundleStakeholder {
|
|
1056
1062
|
id: string;
|
|
1057
|
-
bundle?:
|
|
1063
|
+
bundle?: _Bundle1;
|
|
1058
1064
|
customer?: Customer;
|
|
1059
1065
|
type?: StakeholderType;
|
|
1060
1066
|
}
|
|
@@ -1511,6 +1517,8 @@ export abstract class StepHandle<T extends _AnyStepData1> {
|
|
|
1511
1517
|
* @returns The underlying data for this step. Favor using the step handle methods instead of this.
|
|
1512
1518
|
*/
|
|
1513
1519
|
getRaw(): _Step1<T>;
|
|
1520
|
+
getTags(): string[];
|
|
1521
|
+
hasTag(tag: string): boolean;
|
|
1514
1522
|
/**
|
|
1515
1523
|
* Fires any configured animations on the 3D preview for this step.
|
|
1516
1524
|
* This includes camera & model animations. If the preview is unavailable
|
|
@@ -1771,6 +1779,31 @@ interface Scene {
|
|
|
1771
1779
|
*/
|
|
1772
1780
|
stepIds: string[];
|
|
1773
1781
|
}
|
|
1782
|
+
/**
|
|
1783
|
+
* State related to a workflow experience.
|
|
1784
|
+
*/
|
|
1785
|
+
interface ExperienceOptions {
|
|
1786
|
+
product: Product;
|
|
1787
|
+
transaction: Transaction;
|
|
1788
|
+
workflow?: _Workflow1;
|
|
1789
|
+
previewService?: any;
|
|
1790
|
+
modelContainer?: any;
|
|
1791
|
+
renderableContextService?: any;
|
|
1792
|
+
layouts: _ILayout1[];
|
|
1793
|
+
reloadedState?: LayoutsState;
|
|
1794
|
+
/**
|
|
1795
|
+
* When true the experience is intended to be immutable.
|
|
1796
|
+
*/
|
|
1797
|
+
readOnly?: boolean;
|
|
1798
|
+
/**
|
|
1799
|
+
* A function that communicates state changes to the server.
|
|
1800
|
+
*/
|
|
1801
|
+
stateMutationFunc: StateMutationFunc;
|
|
1802
|
+
/**
|
|
1803
|
+
* Should be set to true when the experience is loaded from an existing transaction.
|
|
1804
|
+
*/
|
|
1805
|
+
isReloadedTransaction?: boolean;
|
|
1806
|
+
}
|
|
1774
1807
|
/**
|
|
1775
1808
|
* A Workflow experience encapsulates the workflow manager and command context. It
|
|
1776
1809
|
* provides a simplified interface for interacting with the workflow manager. You
|
|
@@ -1898,6 +1931,42 @@ export interface WorkflowExperience {
|
|
|
1898
1931
|
[key: string]: string;
|
|
1899
1932
|
}>;
|
|
1900
1933
|
}
|
|
1934
|
+
export class WorkflowExperienceImpl implements WorkflowExperience {
|
|
1935
|
+
readonly client: SpiffCommerceClient;
|
|
1936
|
+
readonly commandContext: CommandContext;
|
|
1937
|
+
readonly workflowManager: WorkflowManager;
|
|
1938
|
+
readonly isReadOnly: boolean;
|
|
1939
|
+
constructor(client: SpiffCommerceClient, experienceOptions: ExperienceOptions);
|
|
1940
|
+
getClient(): SpiffCommerceClient;
|
|
1941
|
+
getIsReadOnly(): boolean;
|
|
1942
|
+
getCommandContext(): CommandContext;
|
|
1943
|
+
getWorkflowManager(): WorkflowManager;
|
|
1944
|
+
updateVariationRecords(variationRecords: VariationRecord[]): Promise<void>;
|
|
1945
|
+
createPreviewImage(isThreeD?: boolean, resolution?: number): Promise<string>;
|
|
1946
|
+
getStepById(id: string): BulkStepHandle | import("index").IllustrationStepHandle | import("index").MaterialStepHandle | import("index").ModelStepHandle | import("index").PictureStepHandle | import("index").QuestionStepHandle | import("index").ShapeStepHandle | import("index").TextStepHandle | import("index").FrameStepHandle | undefined;
|
|
1947
|
+
getSteps(): StepHandle<_AnyStepData1>[];
|
|
1948
|
+
getScenes(): Scene[];
|
|
1949
|
+
getSelectionPriceSubunits(): number;
|
|
1950
|
+
getBasePriceSubunits(): number;
|
|
1951
|
+
getTotalPriceSubunits(): number;
|
|
1952
|
+
getBulkStep(): BulkStepHandle | undefined;
|
|
1953
|
+
getStepByName(name: string): BulkStepHandle | import("index").IllustrationStepHandle | import("index").MaterialStepHandle | import("index").ModelStepHandle | import("index").PictureStepHandle | import("index").QuestionStepHandle | import("index").ShapeStepHandle | import("index").TextStepHandle | import("index").FrameStepHandle | undefined;
|
|
1954
|
+
getStepsByType(type: _StepType1): StepHandle<_AnyStepData1>[];
|
|
1955
|
+
getStepsByScene(scene: Scene): StepHandle<_AnyStepData1>[];
|
|
1956
|
+
attachCustomerDetails(details: {
|
|
1957
|
+
email: string;
|
|
1958
|
+
}): Promise<void>;
|
|
1959
|
+
assignCustomerDetails(details: CustomerDetailsInput): Promise<void>;
|
|
1960
|
+
attachRenderableSceneListener(cb: (scenes: RenderableScene[]) => void): void;
|
|
1961
|
+
detachRenderableSceneListener(cb: (scenes: RenderableScene[]) => void): void;
|
|
1962
|
+
debouncedSavedDesignUpdate: import("lodash").DebouncedFunc<() => Promise<void>>;
|
|
1963
|
+
save(title?: string): Promise<SavedDesign>;
|
|
1964
|
+
copy(): Promise<WorkflowExperience>;
|
|
1965
|
+
onDesignFinished(onProgressUpdate?: DesignCreationProgressUpdate): Promise<DesignCreationMessage>;
|
|
1966
|
+
getExportedData(): Map<string, {
|
|
1967
|
+
[key: string]: string;
|
|
1968
|
+
}>;
|
|
1969
|
+
}
|
|
1901
1970
|
export enum FrameStep {
|
|
1902
1971
|
SelectFrame = "SelectFrame",
|
|
1903
1972
|
SelectImage = "SelectImage",
|
|
@@ -1921,9 +1990,9 @@ export class FrameStepHandle extends StepHandle<_FrameStepData1> {
|
|
|
1921
1990
|
* bundles can return a handle for any global properties associated to the collection.
|
|
1922
1991
|
*/
|
|
1923
1992
|
declare abstract class GlobalPropertyHandle {
|
|
1924
|
-
protected readonly bundle:
|
|
1993
|
+
protected readonly bundle: Bundle;
|
|
1925
1994
|
protected readonly property: GlobalPropertyConfigurationAspect;
|
|
1926
|
-
constructor(bundle:
|
|
1995
|
+
constructor(bundle: Bundle, property: GlobalPropertyConfigurationAspect);
|
|
1927
1996
|
/**
|
|
1928
1997
|
* @returns The name of the global property. This is the key used to store the property in the state.
|
|
1929
1998
|
*/
|
|
@@ -1963,7 +2032,7 @@ interface GlobalPropertyStateManager {
|
|
|
1963
2032
|
/**
|
|
1964
2033
|
* A bundle serves as a container for a set of workflow experience.
|
|
1965
2034
|
*/
|
|
1966
|
-
interface
|
|
2035
|
+
export interface Bundle {
|
|
1967
2036
|
/**
|
|
1968
2037
|
* @returns The client that this bundle is associated with.
|
|
1969
2038
|
*/
|
|
@@ -2035,6 +2104,11 @@ interface _Bundle1 {
|
|
|
2035
2104
|
* @param experience The workflow experience to remove from this bundle.
|
|
2036
2105
|
*/
|
|
2037
2106
|
removeWorkflowExperience(experience: WorkflowExperience): Promise<void>;
|
|
2107
|
+
/**
|
|
2108
|
+
* Remove a workflow experience from this bundle by transaction.
|
|
2109
|
+
* @param transaction The transaction to remove from this bundle.
|
|
2110
|
+
*/
|
|
2111
|
+
removeWorkflowExperienceByTransaction(transaction: Transaction): Promise<void>;
|
|
2038
2112
|
/**
|
|
2039
2113
|
* Returns all workflow experiences currently added to this bundle.
|
|
2040
2114
|
*/
|
|
@@ -2075,11 +2149,11 @@ interface _Bundle1 {
|
|
|
2075
2149
|
* @param event The event to listen for. Currently only "conditional-global-properties-changed" is supported.
|
|
2076
2150
|
* @param listener The listener to call when the event occurs.
|
|
2077
2151
|
*/
|
|
2078
|
-
addEventListener(event:
|
|
2152
|
+
addEventListener(event: BundleEventType, listener: (e: BundleEvent) => void): void;
|
|
2079
2153
|
/**
|
|
2080
2154
|
* Remove a previously added event listener from this bundle.
|
|
2081
2155
|
*/
|
|
2082
|
-
removeEventListener(event:
|
|
2156
|
+
removeEventListener(event: BundleEventType, listener: (e: BundleEvent) => void): void;
|
|
2083
2157
|
/**
|
|
2084
2158
|
* Retrieves the current preview service for this bundle, if one exists.
|
|
2085
2159
|
* If a preview service was specified when calling client.getExistingBundle, this will return that service.
|
|
@@ -2100,7 +2174,19 @@ interface _Bundle1 {
|
|
|
2100
2174
|
*/
|
|
2101
2175
|
getInitializationPromise(): Promise<void>;
|
|
2102
2176
|
}
|
|
2103
|
-
type
|
|
2177
|
+
type BundleEventType = "conditional-global-properties-changed" | "workflow-experience-hover-enter" | "workflow-experience-hover-exit";
|
|
2178
|
+
type BundleEventData = ConditionalGlobalPropertiesChangedEventData | WorkflowExperienceHoverEventData;
|
|
2179
|
+
type BundleEvent = {
|
|
2180
|
+
bundle: Bundle;
|
|
2181
|
+
data: BundleEventData;
|
|
2182
|
+
event: BundleEventType;
|
|
2183
|
+
};
|
|
2184
|
+
interface ConditionalGlobalPropertiesChangedEventData {
|
|
2185
|
+
globalProperties: GlobalPropertyHandle[];
|
|
2186
|
+
}
|
|
2187
|
+
interface WorkflowExperienceHoverEventData {
|
|
2188
|
+
workflowExperience: WorkflowExperience;
|
|
2189
|
+
}
|
|
2104
2190
|
interface ExecutionResponse {
|
|
2105
2191
|
id: string;
|
|
2106
2192
|
completedAt?: string;
|
|
@@ -2265,14 +2351,14 @@ export class SpiffCommerceClient {
|
|
|
2265
2351
|
* @param collectionId Optional: The id of the product collection that the bundle can use.
|
|
2266
2352
|
* @returns A bundle to be used for grouping and operating on large amounts of workflow experiences.
|
|
2267
2353
|
*/
|
|
2268
|
-
getNewBundle(collectionId?: string): Promise<
|
|
2354
|
+
getNewBundle(collectionId?: string): Promise<Bundle>;
|
|
2269
2355
|
/**
|
|
2270
2356
|
* Retrieves an existing bundle from the API, by id.
|
|
2271
2357
|
* @param bundleId The id of the bundle to retrieve.
|
|
2272
2358
|
* @param previewService Optional: A reference to an existing preview service to use. This can be assigned manually later.
|
|
2273
2359
|
* @returns A bundle to be used for grouping and operating on large amounts of workflow experiences.
|
|
2274
2360
|
*/
|
|
2275
|
-
getExistingBundle(bundleId: string, previewService?: any): Promise<
|
|
2361
|
+
getExistingBundle(bundleId: string, previewService?: any): Promise<Bundle>;
|
|
2276
2362
|
/**
|
|
2277
2363
|
* Retrieves all existing bundle stakeholders from the API, for the currently authenticated customer.
|
|
2278
2364
|
* @returns An array of bundle stakeholders.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spiffcommerce/core",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.5.0",
|
|
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",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
89
|
"@apollo/client": "^3.7.0",
|
|
90
|
-
"@spiffcommerce/papyrus": "4.0
|
|
90
|
+
"@spiffcommerce/papyrus": "4.1.0",
|
|
91
91
|
"cross-fetch": "^3.1.5",
|
|
92
92
|
"graphql": "^16.6.0",
|
|
93
93
|
"lodash.clonedeep": "^4.5.0",
|