@spiffcommerce/core 18.4.3 → 18.5.0-alpha.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.ts CHANGED
@@ -2211,6 +2211,12 @@ declare class SpiffCommerceClient {
2211
2211
  getAssetManager(): AssetManager;
2212
2212
  getCurrencyCode(): string;
2213
2213
  getFlowService(): FlowService;
2214
+ getIntegration(): Promise<{
2215
+ id: string;
2216
+ theme: Theme;
2217
+ partner: Partner;
2218
+ logo: string;
2219
+ }>;
2214
2220
  /**
2215
2221
  * Attempts to load persisted authentication information from local storage, and authenticate with the Spiff Commerce API.
2216
2222
  * @param bundleId The ID of the bundle you intend to load.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createHttpLink as gt, InMemoryCache as lt, ApolloClient as Bt, from as dt, gql as y } from "@apollo/client/core";
2
2
  import { fetch as qA, getAttributesFromArrayBuffer as De, AssetType as re, StepType as f, getFrameData as ZA, frameDataCache as wt, GroupCommand as G, UpdateFramePattern as fe, UpdateFrameThresholdSettingsCommand as Et, calculateOffsets as $A, LayoutElementType as v, generate as J, CreateElementCommand as L, generateSVGWithUnknownColors as Fe, svgObjectURL as pA, fetchAsString as q, DeleteElementCommand as Z, generateDefaultRectangleFrameSvg as ce, GetSVGDimensions as ht, patternImageDataCache as ge, fetchAsArrayBuffer as Ct, findElement as DA, modifySVGWithElementProperties as Qt, IllustrationColorCommand as OA, IllustrationCacheCommand as ut, getFontMetrics as mt, getPatternImageData as zA, FontAlignmentCommand as It, FontColorCommand as pt, FontImageFillCommand as kA, applyTextTransformations as KA, determineCorrectFontSizeAndLines as uA, FontSourceCommand as le, loadFont as _A, TextChangeCommand as Dt, FontSizeCommand as ft, createElementNS as Ft, createElement as lA, _loadFontExternalDataURL as Ae, UpdateWorkflowStateCommand as Be, CommandContext as Mt, createCanvas as fA, getSvgElement as Me, LayoutRenderingPurpose as ye, renderPapyrusComponentAsString as Ye, loadImage as Se, getDomParser as xe, toBase64 as de, getVariant as yt, generateFrameSVG as Yt, getDefaultVariant as NA, domParser as Pe, sanitizeSvgTree as Ne, traverse as St, xmlSerializer as He, CreateLayoutCommand as xt, AspectType as mA, rehydrateSerializedLayout as _ } from "@spiffcommerce/papyrus";
3
- import { AssetType as Ri, BringForwardCommand as Ui, BringToBackCommand as Gi, BringToFrontCommand as vi, CanvasCommand as ki, CommandContext as Ji, CreateElementCommand as bi, CreateLayoutCommand as Li, DeleteElementCommand as Ti, FontAlignmentCommand as Oi, FontColorCommand as zi, FontSizeCommand as Ki, FontSourceCommand as ji, GroupCommand as Vi, LayoutElementFactory as Wi, LayoutElementType as Xi, MoveCommand as qi, ResizeCommand as Zi, RotateCommand as $i, SendBackwardsCommand as _i, StepAspectType as As, StepType as es, TextChangeCommand as ts, UnitOfMeasurement as as, dataUrlFromExternalUrl as ns, determineCorrectFontSizeAndLines as is, findElement as ss, frameDataCache as os, generate as rs, generateSVGWithUnknownColors as cs, getAttributesFromArrayBuffer as gs, getAxisAlignedBoundingBox as ls, getFrameData as Bs, getSvgElement as ds, loadFont as ws, patternImageDataCache as Es, registerFetchImplementation as hs, registerWindowImplementation as Cs, rehydrateSerializedLayout as Qs, setCanvasModule as us } from "@spiffcommerce/papyrus";
3
+ import { AssetType as Ui, BringForwardCommand as Gi, BringToBackCommand as vi, BringToFrontCommand as ki, CanvasCommand as Ji, CommandContext as bi, CreateElementCommand as Li, CreateLayoutCommand as Ti, DeleteElementCommand as Oi, FontAlignmentCommand as zi, FontColorCommand as Ki, FontSizeCommand as ji, FontSourceCommand as Vi, GroupCommand as Wi, LayoutElementFactory as Xi, LayoutElementType as qi, MoveCommand as Zi, ResizeCommand as $i, RotateCommand as _i, SendBackwardsCommand as As, StepAspectType as es, StepType as ts, TextChangeCommand as as, UnitOfMeasurement as ns, dataUrlFromExternalUrl as is, determineCorrectFontSizeAndLines as ss, findElement as os, frameDataCache as rs, generate as cs, generateSVGWithUnknownColors as gs, getAttributesFromArrayBuffer as ls, getAxisAlignedBoundingBox as Bs, getFrameData as ds, getSvgElement as ws, loadFont as Es, patternImageDataCache as hs, registerFetchImplementation as Cs, registerWindowImplementation as Qs, rehydrateSerializedLayout as us, setCanvasModule as ms } from "@spiffcommerce/papyrus";
4
4
  import { setContext as Pt } from "@apollo/client/link/context";
5
5
  import { onError as Nt } from "@apollo/client/link/error";
6
6
  import { Pith as Re } from "pith";
@@ -6006,7 +6006,7 @@ class wA {
6006
6006
  case f.Model:
6007
6007
  return new za(A, e);
6008
6008
  case f.Frame:
6009
- return new hi(A, e);
6009
+ return new Ci(A, e);
6010
6010
  default:
6011
6011
  throw new k(`Step type ${e.type} not yet supported in Core SDK`);
6012
6012
  }
@@ -6701,7 +6701,7 @@ class EA {
6701
6701
  const A = HA(this.getCommandContext().getState());
6702
6702
  if (!A)
6703
6703
  throw new k("Internal state is undefined! Cannot copy experience!");
6704
- const e = JSON.stringify(A.transaction), t = this.getWorkflowManager().getWorkflow(), a = new wi({}), n = (s = this.getWorkflowManager().getTransaction().integrationProduct) == null ? void 0 : s.id;
6704
+ const e = JSON.stringify(A.transaction), t = this.getWorkflowManager().getWorkflow(), a = new Ei({}), n = (s = this.getWorkflowManager().getTransaction().integrationProduct) == null ? void 0 : s.id;
6705
6705
  if (!n)
6706
6706
  throw new k("Integration product id is undefined!");
6707
6707
  return await a.initFromIntegrationProduct(n), await a.getWorkflowExperience(t.id, e, void 0);
@@ -7419,7 +7419,7 @@ class mn extends ze {
7419
7419
  B.resize(s, o), await B.render(), this.onRender();
7420
7420
  }
7421
7421
  }
7422
- const Si = (c, A) => {
7422
+ const xi = (c, A) => {
7423
7423
  const e = [];
7424
7424
  return c.forEach((t) => {
7425
7425
  const a = A.steps.find((n) => n.stepName === t.stepName);
@@ -7430,7 +7430,7 @@ const Si = (c, A) => {
7430
7430
  }
7431
7431
  });
7432
7432
  }), e;
7433
- }, xi = async (c, A, e, t) => {
7433
+ }, Pi = async (c, A, e, t) => {
7434
7434
  let a = {
7435
7435
  serializableWorkflow: { steps: [] },
7436
7436
  layouts: {}
@@ -9446,6 +9446,24 @@ const _n = y`
9446
9446
  }
9447
9447
  }
9448
9448
  `, ii = y`
9449
+ query GetIntegrationWithPartnerAndLogo {
9450
+ currentIntegration {
9451
+ id
9452
+ logo
9453
+ theme {
9454
+ id
9455
+ configuration
9456
+ primaryColor
9457
+ secondaryColor
9458
+ textColor
9459
+ }
9460
+ partner {
9461
+ id
9462
+ name
9463
+ }
9464
+ }
9465
+ }
9466
+ `, si = y`
9449
9467
  ${GA(!1)}
9450
9468
  query GetWorkflowForTheme($id: String!) {
9451
9469
  workflow(id: $id) {
@@ -9467,7 +9485,7 @@ const _n = y`
9467
9485
  }
9468
9486
  }
9469
9487
  }
9470
- `, si = y`
9488
+ `, oi = y`
9471
9489
  query GetCustomer($emailAddress: String!) {
9472
9490
  customer(emailAddress: $emailAddress) {
9473
9491
  id
@@ -9477,7 +9495,7 @@ const _n = y`
9477
9495
  }
9478
9496
  }
9479
9497
  }
9480
- `, oi = y`
9498
+ `, ri = y`
9481
9499
  mutation CustomerCreate($details: CustomerDetailsInput!) {
9482
9500
  customerCreate(details: $details) {
9483
9501
  id
@@ -9487,7 +9505,7 @@ const _n = y`
9487
9505
  }
9488
9506
  }
9489
9507
  }
9490
- `, ri = y`
9508
+ `, ci = y`
9491
9509
  mutation CustomerAuthenticate($loginToken: String!) {
9492
9510
  customerAuthenticate(loginToken: $loginToken) {
9493
9511
  id
@@ -9514,11 +9532,11 @@ const _n = y`
9514
9532
  }
9515
9533
  }
9516
9534
  }
9517
- `, ci = y`
9535
+ `, gi = y`
9518
9536
  mutation CustomerGenerateVerificationCode($emailAddress: String!) {
9519
9537
  customerGenerateVerificationCode(emailAddress: $emailAddress)
9520
9538
  }
9521
- `, gi = y`
9539
+ `, li = y`
9522
9540
  mutation CustomerVerifyCode($emailAddress: String!, $verificationCode: String!) {
9523
9541
  customerVerifyCode(emailAddress: $emailAddress, verificationCode: $verificationCode) {
9524
9542
  id
@@ -9562,7 +9580,7 @@ const _n = y`
9562
9580
  (A = i.fontData) != null && A.assetUrl && await _A(i.fontData.assetUrl);
9563
9581
  }
9564
9582
  }
9565
- }, li = async (c, A) => {
9583
+ }, Bi = async (c, A) => {
9566
9584
  var a;
9567
9585
  const e = await N.getShadowGraphqlClient().query({
9568
9586
  query: ai(((a = A == null ? void 0 : A.assets) == null ? void 0 : a.metadata) || !1),
@@ -9582,7 +9600,7 @@ const _n = y`
9582
9600
  }), rA.set({ id: i.option.id }, Promise.resolve(i.option)));
9583
9601
  });
9584
9602
  }), t;
9585
- }, Bi = async (c, A) => {
9603
+ }, di = async (c, A) => {
9586
9604
  const t = (await A).find((a) => a.id === c);
9587
9605
  if (!t)
9588
9606
  throw new Error(`Workflow not found: ${c}`);
@@ -9591,11 +9609,11 @@ const _n = y`
9591
9609
  const e = c.map((s) => rA.get({ id: s, options: A })), t = c.filter((s, o) => e[o] === void 0);
9592
9610
  if (t.length === 0)
9593
9611
  return Promise.all(e);
9594
- const a = li(t, A), n = t.map(
9595
- (s) => rA.set({ id: s, options: A }, Bi(s, a))
9612
+ const a = Bi(t, A), n = t.map(
9613
+ (s) => rA.set({ id: s, options: A }, di(s, a))
9596
9614
  ), i = e.filter((s) => s !== void 0);
9597
9615
  return await Promise.all(i.concat(n));
9598
- }, QA = async (c, A) => (await ct([c], A))[0], di = (c) => c.sort((A, e) => A.index - e.index).map((A) => ({
9616
+ }, QA = async (c, A) => (await ct([c], A))[0], wi = (c) => c.sort((A, e) => A.index - e.index).map((A) => ({
9599
9617
  id: J(),
9600
9618
  panelId: A.name,
9601
9619
  name: A.name,
@@ -9610,9 +9628,9 @@ const _n = y`
9610
9628
  editableArea: A.editableArea
9611
9629
  })), TA = (c, A) => {
9612
9630
  const e = c.workflowState, t = e ? JSON.parse(e) : void 0;
9613
- return t ? Object.values(t.layouts).map((a) => a.layout) : di(A.panels);
9631
+ return t ? Object.values(t.layouts).map((a) => a.layout) : wi(A.panels);
9614
9632
  };
9615
- class wi {
9633
+ class Ei {
9616
9634
  constructor(A) {
9617
9635
  this.updateTransactionState = async (e) => {
9618
9636
  try {
@@ -9642,6 +9660,12 @@ class wi {
9642
9660
  throw new Error("Application key required to use Flow Service.");
9643
9661
  return new Xn();
9644
9662
  }
9663
+ async getIntegration() {
9664
+ return (await N.getShadowGraphqlClient().query({
9665
+ query: ii,
9666
+ errorPolicy: "all"
9667
+ })).data;
9668
+ }
9645
9669
  // TODO: Authentication functions should probably be moved to a separate class.
9646
9670
  /**
9647
9671
  * Attempts to load persisted authentication information from local storage, and authenticate with the Spiff Commerce API.
@@ -9725,7 +9749,7 @@ class wi {
9725
9749
  }
9726
9750
  }
9727
9751
  const r = (await e.query({
9728
- query: ii,
9752
+ query: si,
9729
9753
  errorPolicy: "all",
9730
9754
  variables: {
9731
9755
  id: a.workflowId
@@ -9761,7 +9785,7 @@ class wi {
9761
9785
  var i;
9762
9786
  this.customer = void 0;
9763
9787
  const e = N.getShadowGraphqlClient(), a = (await e.query({
9764
- query: si,
9788
+ query: oi,
9765
9789
  errorPolicy: "all",
9766
9790
  fetchPolicy: "no-cache",
9767
9791
  variables: {
@@ -9770,7 +9794,7 @@ class wi {
9770
9794
  })).data.customer;
9771
9795
  if (!a.id) {
9772
9796
  const o = (i = (await e.mutate({
9773
- mutation: oi,
9797
+ mutation: ri,
9774
9798
  errorPolicy: "all",
9775
9799
  fetchPolicy: "no-cache",
9776
9800
  variables: {
@@ -9802,7 +9826,7 @@ class wi {
9802
9826
  if (!a)
9803
9827
  return !1;
9804
9828
  const i = (s = (await e.mutate({
9805
- mutation: ri,
9829
+ mutation: ci,
9806
9830
  errorPolicy: "all",
9807
9831
  fetchPolicy: "no-cache",
9808
9832
  variables: {
@@ -9817,7 +9841,7 @@ class wi {
9817
9841
  */
9818
9842
  async generateVerificationCode(A) {
9819
9843
  await N.getShadowGraphqlClient().mutate({
9820
- mutation: ci,
9844
+ mutation: gi,
9821
9845
  variables: {
9822
9846
  emailAddress: A
9823
9847
  }
@@ -9832,7 +9856,7 @@ class wi {
9832
9856
  async verifyCode(A, e) {
9833
9857
  var n, i;
9834
9858
  const a = (n = (await N.getShadowGraphqlClient().mutate({
9835
- mutation: gi,
9859
+ mutation: li,
9836
9860
  errorPolicy: "all",
9837
9861
  fetchPolicy: "no-cache",
9838
9862
  variables: {
@@ -10163,7 +10187,10 @@ class wi {
10163
10187
  product: a.product,
10164
10188
  transaction: a,
10165
10189
  layouts: [],
10166
- stateMutationFunc: async (s) => this.updateTransactionState({ ...s, context: { transactionOwnerId: a.transactionOwnerId } })
10190
+ stateMutationFunc: async (s) => this.updateTransactionState({
10191
+ ...s,
10192
+ context: { transactionOwnerId: a.transactionOwnerId }
10193
+ })
10167
10194
  }, this.initialized = !0;
10168
10195
  }
10169
10196
  /**
@@ -10236,7 +10263,10 @@ class wi {
10236
10263
  product: l.product,
10237
10264
  transaction: l,
10238
10265
  layouts: [],
10239
- stateMutationFunc: async (d) => this.updateTransactionState({ ...d, context: { transactionOwnerId: l.transactionOwnerId } }),
10266
+ stateMutationFunc: async (d) => this.updateTransactionState({
10267
+ ...d,
10268
+ context: { transactionOwnerId: l.transactionOwnerId }
10269
+ }),
10240
10270
  readOnly: e
10241
10271
  }, this.initialized = !0;
10242
10272
  } catch {
@@ -10322,7 +10352,7 @@ class wi {
10322
10352
  e.set(A.partner.id, A.id), x.setMap("partnerCustomerIds", e);
10323
10353
  }
10324
10354
  }
10325
- class Pi {
10355
+ class Ni {
10326
10356
  getInitializationPromise() {
10327
10357
  return Promise.resolve();
10328
10358
  }
@@ -10447,8 +10477,8 @@ class Pi {
10447
10477
  setWorkflowStateSyncEnabled(A) {
10448
10478
  }
10449
10479
  }
10450
- var Ei = /* @__PURE__ */ ((c) => (c.SelectFrame = "SelectFrame", c.SelectImage = "SelectImage", c.Position = "Position", c))(Ei || {});
10451
- class hi extends W {
10480
+ var hi = /* @__PURE__ */ ((c) => (c.SelectFrame = "SelectFrame", c.SelectImage = "SelectImage", c.Position = "Position", c))(hi || {});
10481
+ class Ci extends W {
10452
10482
  constructor(A, e) {
10453
10483
  var t;
10454
10484
  super(A, e), this.frameService = (t = this.manager.getStepSpecificServices(this.getId())) == null ? void 0 : t.frameService;
@@ -10490,42 +10520,42 @@ class hi extends W {
10490
10520
  }
10491
10521
  export {
10492
10522
  $ as AssetNotFoundError,
10493
- Ri as AssetType,
10494
- Ui as BringForwardCommand,
10495
- Gi as BringToBackCommand,
10496
- vi as BringToFrontCommand,
10497
- ki as CanvasCommand,
10523
+ Ui as AssetType,
10524
+ Gi as BringForwardCommand,
10525
+ vi as BringToBackCommand,
10526
+ ki as BringToFrontCommand,
10527
+ Ji as CanvasCommand,
10498
10528
  Kn as CollectionProduct,
10499
- Ji as CommandContext,
10529
+ bi as CommandContext,
10500
10530
  ta as ConversionDataType,
10501
10531
  ea as ConversionLocation,
10502
- bi as CreateElementCommand,
10503
- Li as CreateLayoutCommand,
10504
- Ti as DeleteElementCommand,
10532
+ Li as CreateElementCommand,
10533
+ Ti as CreateLayoutCommand,
10534
+ Oi as DeleteElementCommand,
10505
10535
  CA as FlowExecutionNodeResult,
10506
10536
  qn as FlowExecutionResult,
10507
10537
  Xn as FlowService,
10508
- Oi as FontAlignmentCommand,
10509
- zi as FontColorCommand,
10510
- Ki as FontSizeCommand,
10511
- ji as FontSourceCommand,
10538
+ zi as FontAlignmentCommand,
10539
+ Ki as FontColorCommand,
10540
+ ji as FontSizeCommand,
10541
+ Vi as FontSourceCommand,
10512
10542
  Ba as FrameService,
10513
- Ei as FrameStep,
10514
- hi as FrameStepHandle,
10543
+ hi as FrameStep,
10544
+ Ci as FrameStepHandle,
10515
10545
  oe as GlobalPropertyHandle,
10516
- Vi as GroupCommand,
10546
+ Wi as GroupCommand,
10517
10547
  Ta as IllustrationStepHandle,
10518
10548
  PA as InformationMessageType,
10519
10549
  Xa as InformationStepHandle,
10520
10550
  _t as IntegrationType,
10521
- Wi as LayoutElementFactory,
10522
- Xi as LayoutElementType,
10551
+ Xi as LayoutElementFactory,
10552
+ qi as LayoutElementType,
10523
10553
  z as LayoutNotFoundError,
10524
10554
  Oa as MaterialStepHandle,
10525
10555
  MA as MisconfigurationError,
10526
- Pi as MockWorkflowManager,
10556
+ Ni as MockWorkflowManager,
10527
10557
  za as ModelStepHandle,
10528
- qi as MoveCommand,
10558
+ Zi as MoveCommand,
10529
10559
  rt as ObjectInput,
10530
10560
  $n as ObjectInputType,
10531
10561
  FA as OptionNotFoundError,
@@ -10538,63 +10568,63 @@ export {
10538
10568
  Ke as PromiseQueue,
10539
10569
  ja as QuestionStepHandle,
10540
10570
  ze as QueueablePromise,
10541
- Zi as ResizeCommand,
10571
+ $i as ResizeCommand,
10542
10572
  oA as ResourceNotFoundError,
10543
- $i as RotateCommand,
10544
- _i as SendBackwardsCommand,
10573
+ _i as RotateCommand,
10574
+ As as SendBackwardsCommand,
10545
10575
  Va as ShapeStepHandle,
10546
- wi as SpiffCommerceClient,
10576
+ Ei as SpiffCommerceClient,
10547
10577
  YA as StakeholderType,
10548
- As as StepAspectType,
10578
+ es as StepAspectType,
10549
10579
  W as StepHandle,
10550
- es as StepType,
10551
- ts as TextChangeCommand,
10580
+ ts as StepType,
10581
+ as as TextChangeCommand,
10552
10582
  Wa as TextStepHandle,
10553
10583
  Vn as Transform,
10554
10584
  jn as TransformCollection,
10555
10585
  k as UnhandledBehaviorError,
10556
- as as UnitOfMeasurement,
10586
+ ns as UnitOfMeasurement,
10557
10587
  X as Variant,
10558
10588
  EA as WorkflowExperienceImpl,
10559
10589
  O as assetService,
10560
10590
  en as createDesign,
10561
- ns as dataUrlFromExternalUrl,
10591
+ is as dataUrlFromExternalUrl,
10562
10592
  LA as designService,
10563
- is as determineCorrectFontSizeAndLines,
10593
+ ss as determineCorrectFontSizeAndLines,
10564
10594
  Ea as digitalContentStepService,
10565
- ss as findElement,
10566
- os as frameDataCache,
10595
+ os as findElement,
10596
+ rs as frameDataCache,
10567
10597
  VA as frameStepService,
10568
- rs as generate,
10598
+ cs as generate,
10569
10599
  hn as generateCommands,
10570
- cs as generateSVGWithUnknownColors,
10571
- xi as generateStateFromDesignInputSteps,
10572
- gs as getAttributesFromArrayBuffer,
10573
- ls as getAxisAlignedBoundingBox,
10600
+ gs as generateSVGWithUnknownColors,
10601
+ Pi as generateStateFromDesignInputSteps,
10602
+ ls as getAttributesFromArrayBuffer,
10603
+ Bs as getAxisAlignedBoundingBox,
10574
10604
  la as getBoundedOffsets,
10575
- Bs as getFrameData,
10576
- ds as getSvgElement,
10605
+ ds as getFrameData,
10606
+ ws as getSvgElement,
10577
10607
  QA as getWorkflow,
10578
10608
  ct as getWorkflows,
10579
10609
  N as graphQlManager,
10580
10610
  IA as illustrationStepService,
10581
- ws as loadFont,
10611
+ Es as loadFont,
10582
10612
  Ve as materialStepService,
10583
10613
  We as modelStepService,
10584
10614
  Ia as moduleStepService,
10585
10615
  j as optionService,
10586
- Es as patternImageDataCache,
10616
+ hs as patternImageDataCache,
10587
10617
  x as persistenceService,
10588
10618
  Xe as pictureStepService,
10589
10619
  qe as questionStepService,
10590
- hs as registerFetchImplementation,
10591
- Cs as registerWindowImplementation,
10592
- Qs as rehydrateSerializedLayout,
10593
- us as setCanvasModule,
10620
+ Cs as registerFetchImplementation,
10621
+ Qs as registerWindowImplementation,
10622
+ us as rehydrateSerializedLayout,
10623
+ ms as setCanvasModule,
10594
10624
  sA as shapeStepService,
10595
10625
  da as shortenUrl,
10596
10626
  yA as spiffCoreConfiguration,
10597
- Si as stepAspectValuesToDesignInputSteps,
10627
+ xi as stepAspectValuesToDesignInputSteps,
10598
10628
  K as textStepService,
10599
10629
  Ma as toast
10600
10630
  };