@spiffcommerce/core 37.0.0 → 37.0.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/index.mjs CHANGED
@@ -14760,31 +14760,33 @@ class An {
14760
14760
  this.onGlobalPropertiesChanged.bind(this),
14761
14761
  o
14762
14762
  ), this.globalPropertyHandleService = new Nl(this), this.setPreviewService(a), this.initializationPromise = (async () => {
14763
- const c = this.bundleStateManager.getState();
14764
- if (c.integrationProductIds && c.integrationProductIds.length > 0) {
14765
- const d = await S.getShadowGraphqlClient().query({
14766
- query: Wn,
14767
- variables: {
14768
- ids: c.integrationProductIds
14769
- },
14770
- errorPolicy: "all",
14771
- fetchPolicy: "no-cache"
14772
- });
14773
- if (d.errors)
14774
- throw new Error(`Failed to fetch integration products for Bundle ${e.id}`);
14775
- const A = d.data.integrationProducts?.filter((h) => !!h.product?.id && c.integrationProductIds.includes(h.id)).map((h) => h.product.id);
14776
- c.integrationProductIds = [], c.productIds = Array.from(/* @__PURE__ */ new Set([...c.productIds || [], ...A || []]));
14777
- const u = JSON.stringify(c);
14778
- this.bundleStateManager.setState(u), await S.getShadowGraphqlClient().mutate({
14779
- mutation: de,
14780
- variables: {
14781
- id: this.id,
14782
- bundleStateData: u
14783
- },
14784
- context: {
14785
- bundleOwnerId: r
14786
- }
14787
- });
14763
+ if (!o?.readonly) {
14764
+ const c = this.bundleStateManager.getState();
14765
+ if (c.integrationProductIds && c.integrationProductIds.length > 0) {
14766
+ const d = await S.getShadowGraphqlClient().query({
14767
+ query: Wn,
14768
+ variables: {
14769
+ ids: c.integrationProductIds
14770
+ },
14771
+ errorPolicy: "all",
14772
+ fetchPolicy: "no-cache"
14773
+ });
14774
+ if (d.errors)
14775
+ throw new Error(`Failed to fetch integration products for Bundle ${e.id}`);
14776
+ const A = d.data.integrationProducts?.filter((h) => !!h.product?.id && c.integrationProductIds.includes(h.id)).map((h) => h.product.id);
14777
+ c.integrationProductIds = [], c.productIds = Array.from(/* @__PURE__ */ new Set([...c.productIds || [], ...A || []]));
14778
+ const u = JSON.stringify(c);
14779
+ this.bundleStateManager.setState(u), await S.getShadowGraphqlClient().mutate({
14780
+ mutation: de,
14781
+ variables: {
14782
+ id: this.id,
14783
+ bundleStateData: u
14784
+ },
14785
+ context: {
14786
+ bundleOwnerId: r
14787
+ }
14788
+ });
14789
+ }
14788
14790
  }
14789
14791
  return Promise.all([
14790
14792
  this.loadExistingWorkflowExperiences(
@@ -14797,27 +14799,27 @@ class An {
14797
14799
  ),
14798
14800
  this.globalPropertyStateManager.getInitializationPromise()
14799
14801
  ]).then(
14800
- () => new Promise((d, A) => {
14802
+ () => new Promise((c, d) => {
14801
14803
  if (o?.readonly) {
14802
- d([]);
14804
+ c([]);
14803
14805
  return;
14804
14806
  }
14805
14807
  console.log("Setting default global variants.");
14806
- const u = this.globalPropertyStateManager.getGlobalPropertyState();
14807
- u ? this.globalPropertyHandleService.getHandles().then((h) => {
14808
- const g = h.map(async (p) => {
14809
- if (p.getType() === z.ColorOption || p.getType() === z.Option) {
14810
- const m = p;
14811
- if (!u.aspects.find((y) => y.name === m.getName()))
14808
+ const A = this.globalPropertyStateManager.getGlobalPropertyState();
14809
+ A ? this.globalPropertyHandleService.getHandles().then((u) => {
14810
+ const h = u.map(async (g) => {
14811
+ if (g.getType() === z.ColorOption || g.getType() === z.Option) {
14812
+ const p = g;
14813
+ if (!A.aspects.find((f) => f.name === p.getName()))
14812
14814
  try {
14813
- return await m.initDefaultVariant();
14814
- } catch (y) {
14815
- console.error(`Failed to initialize default global variant - ${y}`);
14815
+ return await p.initDefaultVariant();
14816
+ } catch (f) {
14817
+ console.error(`Failed to initialize default global variant - ${f}`);
14816
14818
  }
14817
14819
  }
14818
14820
  });
14819
- Promise.all(g).then(d).catch(A);
14820
- }) : (console.log("Attempted to set global default variant before state was initialized."), d([]));
14821
+ Promise.all(h).then(c).catch(d);
14822
+ }) : (console.log("Attempted to set global default variant before state was initialized."), c([]));
14821
14823
  })
14822
14824
  );
14823
14825
  })(), this.initializationPromise.catch((c) => {
@@ -15428,29 +15430,31 @@ class An {
15428
15430
  async loadExistingWorkflowExperiences(t, e, a) {
15429
15431
  if (t.length === 0) return;
15430
15432
  const i = await this.client.getWorkflowExperiences(
15431
- t.map((s) => ({
15433
+ t.map((r) => ({
15432
15434
  type: "transaction",
15433
- transactionId: s
15435
+ transactionId: r
15434
15436
  })),
15435
15437
  e,
15436
15438
  void 0,
15437
15439
  a
15438
15440
  );
15439
- if (i.forEach((s) => s.setBundle(this)), i.forEach((s) => s.checkForPriceBreakChanges()), this.workflowExperiences = i, this.previewService)
15440
- for (const s of i)
15441
- await this.injectExperienceIntoPreviewService(s);
15442
- const r = this.getProductIds() || [], o = this.getProductCollection();
15443
- if (o && r.length > 0) {
15444
- await o.fetchProducts();
15445
- const s = o.getProducts(), l = [], c = [];
15446
- for (const A of r)
15447
- if (!s.find((h) => h.getId() === A)) {
15448
- for (const h of i)
15449
- h.getProduct()?.id === A && c.push(h);
15450
- l.push(A);
15451
- }
15452
- const d = [];
15453
- l.length > 0 && d.push(this.removeProductIds(l)), c.length > 0 && d.push(Promise.all(c.map((A) => A.clearProduct()))), d.length > 0 && await Promise.all(d);
15441
+ if (i.forEach((r) => r.setBundle(this)), i.forEach((r) => r.checkForPriceBreakChanges()), this.workflowExperiences = i, this.previewService)
15442
+ for (const r of i)
15443
+ await this.injectExperienceIntoPreviewService(r);
15444
+ if (!this.globalPropertyStateManager.getBundleOptions()?.readonly) {
15445
+ const r = this.getProductIds() || [], o = this.getProductCollection();
15446
+ if (o && r.length > 0) {
15447
+ await o.fetchProducts();
15448
+ const s = o.getProducts(), l = [], c = [];
15449
+ for (const A of r)
15450
+ if (!s.find((h) => h.getId() === A)) {
15451
+ for (const h of i)
15452
+ h.getProduct()?.id === A && c.push(h);
15453
+ l.push(A);
15454
+ }
15455
+ const d = [];
15456
+ l.length > 0 && d.push(this.removeProductIds(l)), c.length > 0 && d.push(Promise.all(c.map((A) => A.clearProduct()))), d.length > 0 && await Promise.all(d);
15457
+ }
15454
15458
  }
15455
15459
  }
15456
15460
  async updateBundle() {
@@ -16107,7 +16111,7 @@ class qd {
16107
16111
  } catch (a) {
16108
16112
  throw console.error(a), new pt("Critical - Unable to synchronize workflow state with server.");
16109
16113
  }
16110
- }, this.options = t, this.options.applicationKey && cr(this.options.applicationKey), console.debug("------------------------"), console.debug("Spiff Commerce Core SDK"), console.debug("Version: 37.0.0"), console.debug(`Application Key Provided: ${!!this.options.applicationKey}`), console.debug("------------------------");
16114
+ }, this.options = t, this.options.applicationKey && cr(this.options.applicationKey), console.debug("------------------------"), console.debug("Spiff Commerce Core SDK"), console.debug("Version: 37.0.1"), console.debug(`Application Key Provided: ${!!this.options.applicationKey}`), console.debug("------------------------");
16111
16115
  }
16112
16116
  configure(t) {
16113
16117
  Ct.setHubUrl(t.hubUrl), Ct.setServerUrl(t.serverUrl), Ct.setServicesApiUrl(t.servicesApiUrl), this.marketplaceThemeInstallId = t.marketplaceThemeInstallId, this.marketplaceThemeInstallConfigurationId = t.marketplaceThemeInstallConfigurationId, this.userPoolClientId = t.userPoolClientId, this.userPoolRegion = t.userPoolRegion, this.spiffRegion = t.spiffRegion, t.bearerAuthenticationToken && Ar(t.bearerAuthenticationToken), this.options.applicationKey && this.getIntegration(), this.spiffRegion && this.userPoolRegion && this.userPoolClientId && Lt.init(this.spiffRegion, this.userPoolRegion, this.userPoolClientId);