@spiffcommerce/core 42.1.3 → 43.0.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/CHANGELOG.md CHANGED
@@ -14,6 +14,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
14
  - `Fixed` for any bug fixes.
15
15
  - `Security` in case of vulnerabilities.
16
16
 
17
+ ## [43.0.0] - 23-06-2026
18
+
19
+ ## Fixed
20
+
21
+ - The method `ProductCollection.fetchProductsFeed` now correctly performs full filtering using the available inputs when all products are loaded.
22
+
23
+ # Removed
24
+
25
+ - Removed the method `ProductCollection.filterProducts`.
26
+
17
27
  ## [42.1.0] - 18-06-2026
18
28
 
19
29
  ## Added
@@ -63744,22 +63744,28 @@ const PQ = (r, e) => {
63744
63744
  `, PL = ke`
63745
63745
  query GetProductCollectionForFilteredProducts(
63746
63746
  $id: String!
63747
- $filters: ProductCollectionProductFilterInput
63747
+ $productFilters: ProductCollectionProductFilterInput
63748
+ $productWorkflowFilters: MetafieldFilterListInput
63748
63749
  $tags: ProductCollectionProductTagFilterInput
63749
63750
  $sortKey: ProductCollectionProductSortKey
63750
63751
  $sortDescending: Boolean
63752
+ $quickSearch: String
63751
63753
  ) {
63752
63754
  productCollections(ids: [$id]) {
63753
63755
  id
63754
- productCollectionProducts(
63755
- filters: $filters
63756
+ productCollectionProductsFeed(
63757
+ filters: $productFilters
63758
+ workflowFilters: $productWorkflowFilters
63756
63759
  tags: $tags
63757
63760
  sortKey: $sortKey
63758
63761
  sortDescending: $sortDescending
63762
+ quickSearch: $quickSearch
63759
63763
  ) {
63760
- id
63761
- product {
63764
+ items {
63762
63765
  id
63766
+ product {
63767
+ id
63768
+ }
63763
63769
  }
63764
63770
  }
63765
63771
  }
@@ -68841,36 +68847,6 @@ class $T {
68841
68847
  ) || []
68842
68848
  ], this.collection.productCollectionProducts.length >= this.collection.total && (this.fullFetched = !0), this.collection.productCollectionProducts.filter((i) => !!i.product && (!e || e.includes(i.product.id))).map((i) => new xp(i));
68843
68849
  }
68844
- /**
68845
- * Returns a list of collections products matching the associated metafield/tag filters.
68846
- * @param filters A list of metafield filters to apply.
68847
- * @param tags An object of tag filters to apply.
68848
- */
68849
- async filterProducts(e, t, n, i) {
68850
- const a = await $e.getShadowGraphqlClient().query({
68851
- query: PL,
68852
- errorPolicy: "all",
68853
- variables: {
68854
- id: this.getId(),
68855
- filters: e ? {
68856
- link: "And",
68857
- metafields: e
68858
- } : void 0,
68859
- tags: t ? {
68860
- include: t.include ?? [],
68861
- exclude: t.exclude ?? []
68862
- } : void 0,
68863
- sortKey: n,
68864
- sortDescending: i
68865
- }
68866
- });
68867
- if (!a.data?.productCollections || a.data?.productCollections.length === 0)
68868
- throw new Error("Failed to filter product collection products.");
68869
- const s = this.getProducts(), o = a.data.productCollections[0].productCollectionProducts.map(
68870
- (l) => l.product.id
68871
- );
68872
- return s.filter((l) => o.includes(l.getId()));
68873
- }
68874
68850
  /**
68875
68851
  * Fetches a paginated feed of products.
68876
68852
  * @param offset The zero-based start index.
@@ -68884,64 +68860,69 @@ class $T {
68884
68860
  * @returns
68885
68861
  */
68886
68862
  async fetchProductsFeed(e, t, n, i, a, s, o, l) {
68863
+ const u = {
68864
+ id: this.getId(),
68865
+ productFilters: n ? {
68866
+ link: "And",
68867
+ metafields: n
68868
+ } : void 0,
68869
+ productWorkflowFilters: l ? {
68870
+ link: "And",
68871
+ metafields: l
68872
+ } : void 0,
68873
+ tags: i ? {
68874
+ include: i.include ?? [],
68875
+ exclude: i.exclude ?? []
68876
+ } : void 0,
68877
+ sortKey: a,
68878
+ sortDescending: s,
68879
+ quickSearch: o
68880
+ };
68887
68881
  if (this.fullFetched) {
68888
- let f = await (n ? this.filterProducts(n) : this.fetchProducts());
68889
- if (o) {
68890
- const d = o.toLowerCase();
68891
- f = f.filter((g) => g.getName().toLowerCase().includes(d));
68892
- }
68882
+ const d = await $e.getShadowGraphqlClient().query({
68883
+ query: PL,
68884
+ errorPolicy: "all",
68885
+ variables: u
68886
+ });
68887
+ if (!d.data?.productCollections || d.data?.productCollections.length === 0)
68888
+ throw new Error("Failed to filter product collection products.");
68889
+ const g = this.getProducts(), v = /* @__PURE__ */ new Map();
68890
+ for (const A of g)
68891
+ v.set(A.getId(), A);
68892
+ const y = d.data.productCollections[0].productCollectionProductsFeed.items.map((A) => v.get(A.product.id)).filter((A) => !!A);
68893
68893
  return {
68894
- total: f.length,
68895
- items: f.slice(e, e + t)
68894
+ total: y.length,
68895
+ items: y.slice(e, e + t)
68896
68896
  };
68897
68897
  }
68898
- const u = new AbortController(), { signal: c } = u, h = $e.getShadowGraphqlClient().watchQuery({
68898
+ const c = new AbortController(), { signal: h } = c, f = $e.getShadowGraphqlClient().watchQuery({
68899
68899
  query: RL,
68900
- variables: {
68901
- id: this.getId(),
68902
- limit: t,
68903
- offset: e,
68904
- productFilters: n ? {
68905
- link: "And",
68906
- metafields: n
68907
- } : void 0,
68908
- productWorkflowFilters: l ? {
68909
- link: "And",
68910
- metafields: l
68911
- } : void 0,
68912
- tags: i ? {
68913
- include: i.include ?? [],
68914
- exclude: i.exclude ?? []
68915
- } : void 0,
68916
- sortKey: a,
68917
- sortDescending: s,
68918
- quickSearch: o
68919
- },
68900
+ variables: { ...u, limit: t, offset: e },
68920
68901
  errorPolicy: "all",
68921
68902
  fetchPolicy: "cache-first",
68922
68903
  returnPartialData: !0,
68923
68904
  context: {
68924
68905
  fetchOptions: {
68925
- signal: c
68906
+ signal: h
68926
68907
  }
68927
68908
  }
68928
68909
  });
68929
- return new Promise((f) => {
68930
- let d = !1;
68931
- const g = h.subscribe({
68932
- next(v) {
68933
- if (d || v.partial && (!v.data.productCollections || v.data.productCollections.length === 0 || !v.data.productCollections[0].productCollectionProductsFeed?.items || v.data.productCollections[0].productCollectionProductsFeed?.items.length === 0))
68910
+ return new Promise((d) => {
68911
+ let g = !1;
68912
+ const v = f.subscribe({
68913
+ next(y) {
68914
+ if (g || y.partial && (!y.data.productCollections || y.data.productCollections.length === 0 || !y.data.productCollections[0].productCollectionProductsFeed?.items || y.data.productCollections[0].productCollectionProductsFeed?.items.length === 0))
68934
68915
  return;
68935
- u.abort(), d = !0, g.unsubscribe();
68936
- const y = v.data.productCollections?.[0].productCollectionProductsFeed?.items.filter((A) => !!A.product).map((A) => new xp(vo(A))) || [];
68937
- f({
68938
- items: y,
68916
+ c.abort(), g = !0, v.unsubscribe();
68917
+ const A = y.data.productCollections?.[0].productCollectionProductsFeed?.items.filter((x) => !!x.product).map((x) => new xp(vo(x))) || [];
68918
+ d({
68919
+ items: A,
68939
68920
  // Clone items because it could be cached data (immutable)
68940
- total: v.data.productCollections?.[0].productCollectionProductsFeed?.total ?? 0
68921
+ total: y.data.productCollections?.[0].productCollectionProductsFeed?.total ?? 0
68941
68922
  });
68942
68923
  },
68943
68924
  error() {
68944
- d || (d = !0, g.unsubscribe(), f({ items: [], total: 0 }));
68925
+ g || (g = !0, v.unsubscribe(), d({ items: [], total: 0 }));
68945
68926
  }
68946
68927
  });
68947
68928
  });
@@ -69670,7 +69651,9 @@ class sE {
69670
69651
  return [...this.workflowExperiences];
69671
69652
  }
69672
69653
  getTopLevelWorkflowExperiences() {
69673
- return console.log(`log: getting top level experiences: ${this.workflowExperiences}`), this.workflowExperiences.filter((e) => (console.log(`log: checking transaction ${e.getTransaction().id}, parent is ${e.getTransaction().parentTransaction}`), !e.getTransaction().parentTransaction));
69654
+ return console.log(`log: getting top level experiences: ${this.workflowExperiences}`), this.workflowExperiences.filter((e) => (console.log(
69655
+ `log: checking transaction ${e.getTransaction().id}, parent is ${e.getTransaction().parentTransaction}`
69656
+ ), !e.getTransaction().parentTransaction));
69674
69657
  }
69675
69658
  getChildWorkflowExperiences(e) {
69676
69659
  return this.workflowExperiences.filter(
@@ -71505,7 +71488,7 @@ class SV extends CV {
71505
71488
  });
71506
71489
  }
71507
71490
  async loadEventStreamCapability() {
71508
- const { EventStreamSerde: e } = await import("./index-Dq7iXZav.js");
71491
+ const { EventStreamSerde: e } = await import("./index-CX6jj1_G.js");
71509
71492
  return new e({
71510
71493
  marshaller: this.getEventStreamMarshaller(),
71511
71494
  serializer: this.serializer,
@@ -79068,7 +79051,7 @@ class LQ {
79068
79051
  } catch (n) {
79069
79052
  throw console.error(n), new lo("Critical - Unable to synchronize workflow state with server.");
79070
79053
  }
79071
- }, this.options = e, this.options.applicationKey && X4(this.options.applicationKey), console.debug("------------------------"), console.debug("Spiff Commerce Core SDK"), console.debug("Version: 42.1.2"), console.debug(`Application Key Provided: ${!!this.options.applicationKey}`), console.debug("------------------------");
79054
+ }, this.options = e, this.options.applicationKey && X4(this.options.applicationKey), console.debug("------------------------"), console.debug("Spiff Commerce Core SDK"), console.debug("Version: 42.1.3"), console.debug(`Application Key Provided: ${!!this.options.applicationKey}`), console.debug("------------------------");
79072
79055
  }
79073
79056
  configure(e) {
79074
79057
  mo.setHubUrl(e.hubUrl), mo.setServerUrl(e.serverUrl), mo.setServicesApiUrl(e.servicesApiUrl), this.marketplaceThemeInstallId = e.marketplaceThemeInstallId, this.marketplaceThemeInstallConfigurationId = e.marketplaceThemeInstallConfigurationId, this.userPoolClientId = e.userPoolClientId, this.userPoolRegion = e.userPoolRegion, this.spiffRegion = e.spiffRegion, e.bearerAuthenticationToken && K4(e.bearerAuthenticationToken), this.options.applicationKey && this.getIntegration(), this.spiffRegion && this.userPoolRegion && this.userPoolClientId && Of.init(this.spiffRegion, this.userPoolRegion, this.userPoolClientId);
@@ -79517,9 +79500,11 @@ class LQ {
79517
79500
  }, v = (await Promise.all([
79518
79501
  ...u.map(d),
79519
79502
  ...c.map(g)
79520
- ])).flat(), y = [
79503
+ ])).flat();
79504
+ let y = [
79521
79505
  ...new Set(v.map((W) => W.transaction.integrationProductId))
79522
79506
  ].filter((W) => !!W);
79507
+ y = y.filter((W) => !!W);
79523
79508
  let A = [...new Set(v.map((W) => W.workflowId))].filter((W) => !!W);
79524
79509
  A = A.filter((W) => !!W);
79525
79510
  const [x, k] = await Promise.all([
@@ -81162,4 +81147,4 @@ export {
81162
81147
  r7 as y,
81163
81148
  e7 as z
81164
81149
  };
81165
- //# sourceMappingURL=index-C1NpAqMF.js.map
81150
+ //# sourceMappingURL=index-Br-kAnEQ.js.map