@marteye/studiojs 1.1.47-beta.0 → 1.1.47
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.esm.js +18 -19
- package/dist/index.js +18 -19
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -761,31 +761,25 @@ function buildExcludeFilters(filters) {
|
|
|
761
761
|
excludeFilters.push(`productCode = "${filters.excludedProductCodes[0]}"`);
|
|
762
762
|
}
|
|
763
763
|
else {
|
|
764
|
-
excludeFilters.push(
|
|
764
|
+
excludeFilters.push(filters.excludedProductCodes
|
|
765
765
|
.map((code) => `productCode = "${code}"`)
|
|
766
|
-
.join(" OR ")
|
|
766
|
+
.join(" OR "));
|
|
767
767
|
}
|
|
768
768
|
}
|
|
769
769
|
return excludeFilters;
|
|
770
770
|
}
|
|
771
771
|
function buildFilterExpression(filters) {
|
|
772
|
-
let
|
|
772
|
+
let fixedClauses = [];
|
|
773
|
+
let alternativeGroups = [];
|
|
773
774
|
if (filters.dateStart)
|
|
774
|
-
|
|
775
|
+
fixedClauses.push(`saleDate >= "${filters.dateStart}"`);
|
|
775
776
|
if (filters.dateEnd)
|
|
776
|
-
|
|
777
|
+
fixedClauses.push(`saleDate <= "${filters.dateEnd}"`);
|
|
777
778
|
if (filters.productCodes && filters.productCodes.length > 0) {
|
|
778
|
-
|
|
779
|
-
clauses.push(`productCode = "${filters.productCodes[0]}"`);
|
|
780
|
-
}
|
|
781
|
-
else {
|
|
782
|
-
clauses.push(`(${filters.productCodes
|
|
783
|
-
.map((code) => `productCode = "${code}"`)
|
|
784
|
-
.join(" OR ")})`);
|
|
785
|
-
}
|
|
779
|
+
alternativeGroups.push(filters.productCodes.map((code) => `productCode = "${code}"`));
|
|
786
780
|
}
|
|
787
781
|
if (filters.boughtOnlineOnly) {
|
|
788
|
-
|
|
782
|
+
fixedClauses.push(`@boughtOnline = true`);
|
|
789
783
|
}
|
|
790
784
|
let breedClauses = [];
|
|
791
785
|
for (let breed of filters.cattleBreeds || []) {
|
|
@@ -794,13 +788,18 @@ function buildFilterExpression(filters) {
|
|
|
794
788
|
for (let breed of filters.sheepBreeds || []) {
|
|
795
789
|
breedClauses.push(`breedOfSheep = "${breed}"`);
|
|
796
790
|
}
|
|
797
|
-
if (breedClauses.length
|
|
798
|
-
|
|
791
|
+
if (breedClauses.length > 0) {
|
|
792
|
+
alternativeGroups.push(breedClauses);
|
|
799
793
|
}
|
|
800
|
-
|
|
801
|
-
|
|
794
|
+
let expandedBranches = alternativeGroups.reduce((branches, alternatives) => branches.flatMap((branch) => alternatives.map((alternative) => [...branch, alternative])), [[]]);
|
|
795
|
+
let expressions = expandedBranches
|
|
796
|
+
.map((branch) => [...fixedClauses, ...branch].filter(Boolean))
|
|
797
|
+
.filter((branch) => branch.length > 0)
|
|
798
|
+
.map((branch) => branch.join(" AND "));
|
|
799
|
+
if (expressions.length === 0) {
|
|
800
|
+
return undefined;
|
|
802
801
|
}
|
|
803
|
-
return
|
|
802
|
+
return expressions.join(" OR ");
|
|
804
803
|
}
|
|
805
804
|
async function resolveList(customerLists, marketId, listIdOrSlug, options) {
|
|
806
805
|
let identifierType = (options === null || options === void 0 ? void 0 : options.identifierType) || "auto";
|
package/dist/index.js
CHANGED
|
@@ -765,31 +765,25 @@ function buildExcludeFilters(filters) {
|
|
|
765
765
|
excludeFilters.push(`productCode = "${filters.excludedProductCodes[0]}"`);
|
|
766
766
|
}
|
|
767
767
|
else {
|
|
768
|
-
excludeFilters.push(
|
|
768
|
+
excludeFilters.push(filters.excludedProductCodes
|
|
769
769
|
.map((code) => `productCode = "${code}"`)
|
|
770
|
-
.join(" OR ")
|
|
770
|
+
.join(" OR "));
|
|
771
771
|
}
|
|
772
772
|
}
|
|
773
773
|
return excludeFilters;
|
|
774
774
|
}
|
|
775
775
|
function buildFilterExpression(filters) {
|
|
776
|
-
let
|
|
776
|
+
let fixedClauses = [];
|
|
777
|
+
let alternativeGroups = [];
|
|
777
778
|
if (filters.dateStart)
|
|
778
|
-
|
|
779
|
+
fixedClauses.push(`saleDate >= "${filters.dateStart}"`);
|
|
779
780
|
if (filters.dateEnd)
|
|
780
|
-
|
|
781
|
+
fixedClauses.push(`saleDate <= "${filters.dateEnd}"`);
|
|
781
782
|
if (filters.productCodes && filters.productCodes.length > 0) {
|
|
782
|
-
|
|
783
|
-
clauses.push(`productCode = "${filters.productCodes[0]}"`);
|
|
784
|
-
}
|
|
785
|
-
else {
|
|
786
|
-
clauses.push(`(${filters.productCodes
|
|
787
|
-
.map((code) => `productCode = "${code}"`)
|
|
788
|
-
.join(" OR ")})`);
|
|
789
|
-
}
|
|
783
|
+
alternativeGroups.push(filters.productCodes.map((code) => `productCode = "${code}"`));
|
|
790
784
|
}
|
|
791
785
|
if (filters.boughtOnlineOnly) {
|
|
792
|
-
|
|
786
|
+
fixedClauses.push(`@boughtOnline = true`);
|
|
793
787
|
}
|
|
794
788
|
let breedClauses = [];
|
|
795
789
|
for (let breed of filters.cattleBreeds || []) {
|
|
@@ -798,13 +792,18 @@ function buildFilterExpression(filters) {
|
|
|
798
792
|
for (let breed of filters.sheepBreeds || []) {
|
|
799
793
|
breedClauses.push(`breedOfSheep = "${breed}"`);
|
|
800
794
|
}
|
|
801
|
-
if (breedClauses.length
|
|
802
|
-
|
|
795
|
+
if (breedClauses.length > 0) {
|
|
796
|
+
alternativeGroups.push(breedClauses);
|
|
803
797
|
}
|
|
804
|
-
|
|
805
|
-
|
|
798
|
+
let expandedBranches = alternativeGroups.reduce((branches, alternatives) => branches.flatMap((branch) => alternatives.map((alternative) => [...branch, alternative])), [[]]);
|
|
799
|
+
let expressions = expandedBranches
|
|
800
|
+
.map((branch) => [...fixedClauses, ...branch].filter(Boolean))
|
|
801
|
+
.filter((branch) => branch.length > 0)
|
|
802
|
+
.map((branch) => branch.join(" AND "));
|
|
803
|
+
if (expressions.length === 0) {
|
|
804
|
+
return undefined;
|
|
806
805
|
}
|
|
807
|
-
return
|
|
806
|
+
return expressions.join(" OR ");
|
|
808
807
|
}
|
|
809
808
|
async function resolveList(customerLists, marketId, listIdOrSlug, options) {
|
|
810
809
|
let identifierType = (options === null || options === void 0 ? void 0 : options.identifierType) || "auto";
|