@usereactify/search 5.59.0-beta.4 → 5.59.0-beta.6
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 +15 -0
- package/dist/package.json +1 -1
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.d.ts +3 -11
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js +3 -13
- package/dist/src/components/ReactifySearchProvider/ReactifySearchProvider.js.map +1 -1
- package/dist/src/components/Sensor/SensorCollectionWeighted.d.ts +1 -0
- package/dist/src/components/Sensor/{SensorCuratedPageSearch.js → SensorCollectionWeighted.js} +4 -4
- package/dist/src/components/Sensor/SensorCollectionWeighted.js.map +1 -0
- package/dist/src/components/Sensor/SensorSearchTerm.js +6 -18
- package/dist/src/components/Sensor/SensorSearchTerm.js.map +1 -1
- package/dist/src/components/Sensor/SensorSearchWeighted.d.ts +1 -0
- package/dist/src/components/Sensor/{SensorCuratedPageCollection.js → SensorSearchWeighted.js} +5 -4
- package/dist/src/components/Sensor/SensorSearchWeighted.js.map +1 -0
- package/dist/src/components/Sensor/Sensors.js +21 -19
- package/dist/src/components/Sensor/Sensors.js.map +1 -1
- package/dist/src/components/Sensor/index.d.ts +2 -2
- package/dist/src/components/Sensor/index.js +5 -7
- package/dist/src/components/Sensor/index.js.map +1 -1
- package/dist/src/components/Suggestions/Suggestions.js +1 -2
- package/dist/src/components/Suggestions/Suggestions.js.map +1 -1
- package/dist/src/hooks/useConfig.d.ts +1 -1
- package/dist/src/hooks/useConfig.js +7 -7
- package/dist/src/hooks/useConfig.js.map +1 -1
- package/dist/src/hooks/useReactifySearchContext.d.ts +3 -17
- package/dist/src/hooks/useReactifySearchContext.js.map +1 -1
- package/dist/src/types/config.d.ts +1 -0
- package/dist/src/types/config.js.map +1 -1
- package/dist/src/utility/curation.js +4 -33
- package/dist/src/utility/curation.js.map +1 -1
- package/dist/src/utility/filters.js +3 -4
- package/dist/src/utility/filters.js.map +1 -1
- package/dist/src/utility/liquid.d.ts +0 -6
- package/dist/src/utility/liquid.js +0 -15
- package/dist/src/utility/liquid.js.map +1 -1
- package/dist/src/utility/props.d.ts +8 -5
- package/dist/src/utility/props.js +17 -29
- package/dist/src/utility/props.js.map +1 -1
- package/dist/src/utility/queries.d.ts +6 -4
- package/dist/src/utility/queries.js +26 -57
- package/dist/src/utility/queries.js.map +1 -1
- package/dist/src/utility/sortOption.js +3 -6
- package/dist/src/utility/sortOption.js.map +1 -1
- package/package.json +1 -1
- package/dist/src/components/Sensor/SensorCuratedPageCollection.d.ts +0 -1
- package/dist/src/components/Sensor/SensorCuratedPageCollection.js.map +0 -1
- package/dist/src/components/Sensor/SensorCuratedPageSearch.d.ts +0 -1
- package/dist/src/components/Sensor/SensorCuratedPageSearch.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Config, ConfigCuration, ConfigRedirect, ReactivesearchResultProps } from "../types";
|
|
3
|
-
export type ReactifySearchMode = "search" | "collection" | "instant-search"
|
|
3
|
+
export type ReactifySearchMode = "search" | "collection" | "instant-search";
|
|
4
4
|
export declare const ReactifySearchContext: React.Context<{
|
|
5
5
|
config: Config;
|
|
6
6
|
options: {
|
|
@@ -17,6 +17,7 @@ export declare const ReactifySearchContext: React.Context<{
|
|
|
17
17
|
includeFields?: Array<string>;
|
|
18
18
|
excludeFields?: Array<string>;
|
|
19
19
|
query?: Record<string, string>;
|
|
20
|
+
configBaseUrl?: string;
|
|
20
21
|
preload?: {
|
|
21
22
|
config: Config;
|
|
22
23
|
state: unknown;
|
|
@@ -28,14 +29,6 @@ export declare const ReactifySearchContext: React.Context<{
|
|
|
28
29
|
collectionHandle: string;
|
|
29
30
|
} | {
|
|
30
31
|
mode: "instant-search";
|
|
31
|
-
} | {
|
|
32
|
-
mode: "curated-page";
|
|
33
|
-
variation: "collection";
|
|
34
|
-
handle: string;
|
|
35
|
-
} | {
|
|
36
|
-
mode: "curated-page";
|
|
37
|
-
variation: "search";
|
|
38
|
-
searchTerm: string;
|
|
39
32
|
});
|
|
40
33
|
search: {
|
|
41
34
|
searchTerm: string;
|
|
@@ -72,6 +65,7 @@ export declare const useReactifySearchContext: () => {
|
|
|
72
65
|
includeFields?: Array<string>;
|
|
73
66
|
excludeFields?: Array<string>;
|
|
74
67
|
query?: Record<string, string>;
|
|
68
|
+
configBaseUrl?: string;
|
|
75
69
|
preload?: {
|
|
76
70
|
config: Config;
|
|
77
71
|
state: unknown;
|
|
@@ -83,14 +77,6 @@ export declare const useReactifySearchContext: () => {
|
|
|
83
77
|
collectionHandle: string;
|
|
84
78
|
} | {
|
|
85
79
|
mode: "instant-search";
|
|
86
|
-
} | {
|
|
87
|
-
mode: "curated-page";
|
|
88
|
-
variation: "collection";
|
|
89
|
-
handle: string;
|
|
90
|
-
} | {
|
|
91
|
-
mode: "curated-page";
|
|
92
|
-
variation: "search";
|
|
93
|
-
searchTerm: string;
|
|
94
80
|
});
|
|
95
81
|
search: {
|
|
96
82
|
searchTerm: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useReactifySearchContext.js","sourceRoot":"","sources":["../../../src/hooks/useReactifySearchContext.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0C;AAM7B,QAAA,qBAAqB,GAAG,eAAK,CAAC,aAAa,
|
|
1
|
+
{"version":3,"file":"useReactifySearchContext.js","sourceRoot":"","sources":["../../../src/hooks/useReactifySearchContext.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAA0C;AAM7B,QAAA,qBAAqB,GAAG,eAAK,CAAC,aAAa,CAsDtD,SAAS,CAAC,CAAC;AAEN,MAAM,wBAAwB,GAAG,GAAG,EAAE;IAC3C,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,6BAAqB,CAAC,CAAC;IAClD,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;IAC3F,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AANW,QAAA,wBAAwB,4BAMnC","sourcesContent":["import React, { useContext } from \"react\";\n\nimport { Config, ConfigCuration, ConfigRedirect, ReactivesearchResultProps } from \"../types\";\n\nexport type ReactifySearchMode = \"search\" | \"collection\" | \"instant-search\";\n\nexport const ReactifySearchContext = React.createContext<\n | {\n config: Config;\n options: {\n clientId: string;\n mode: ReactifySearchMode;\n index: string;\n shopifyPermanentDomain: string;\n market?: string;\n filtersHandle?: string;\n credentials?: string;\n onRedirect?: (type: \"redirect\" | \"search\", url: string) => void;\n theme: Record<string, unknown>;\n additionalComponentIds?: Array<string>;\n includeFields?: Array<string>;\n excludeFields?: Array<string>;\n query?: Record<string, string>;\n configBaseUrl?: string;\n preload?: {\n config: Config;\n state: unknown;\n };\n } & (\n | {\n mode: \"search\";\n }\n | {\n mode: \"collection\";\n collectionHandle: string;\n }\n | {\n mode: \"instant-search\";\n }\n );\n search: {\n searchTerm: string;\n setSearchTerm: React.Dispatch<React.SetStateAction<string>>;\n showInstantSearchResults: boolean;\n setShowInstantSearchResults: React.Dispatch<React.SetStateAction<boolean>>;\n searchRedirect: ConfigRedirect | undefined;\n };\n sortby: {\n sortOption: string;\n setSortOption: React.Dispatch<React.SetStateAction<string>>;\n };\n results: {\n results: ReactivesearchResultProps[\"data\"];\n setResults: React.Dispatch<React.SetStateAction<ReactivesearchResultProps[\"data\"]>>;\n resultStats?: ReactivesearchResultProps[\"resultStats\"];\n setResultStats: React.Dispatch<React.SetStateAction<ReactivesearchResultProps[\"resultStats\"] | undefined>>;\n };\n curation: ConfigCuration | undefined;\n }\n | undefined\n>(undefined);\n\nexport const useReactifySearchContext = () => {\n const context = useContext(ReactifySearchContext);\n if (!context) {\n throw new Error(\"useReactifySearchContext must be used within a ReactifySearchProvider\");\n }\n return context;\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/types/config.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Antonym,\n Callout,\n Curation,\n FilterFacet,\n FilterGroup,\n Market,\n MerchandisingCalloutAutofillBehaviour,\n Redirect,\n Relevance,\n SearchableField,\n Sort,\n Synonym,\n} from \"./firestore\";\n\n// when exposed as config, most resources have the `enabled` and `keywords` attributes removed\n// curation boosting groupings and sortings both have a json encoded elastic query added to them\n\nexport type Config = {\n index: string;\n endpoint: string;\n cluster: string;\n version: string;\n key: string;\n cache: {\n enabled: boolean;\n seconds: number;\n };\n merchandising: {\n calloutAutofillBehaviour: MerchandisingCalloutAutofillBehaviour;\n };\n sort: Array<ConfigSort>;\n fields: Array<ConfigField>;\n searchableFields: Array<ConfigSeachableField>;\n filters: Array<ConfigFilter>;\n redirects: Array<ConfigRedirect>;\n curations: Array<ConfigCuration>;\n antonyms: Array<ConfigAntonym>;\n synonyms: Array<ConfigSynonym>;\n callouts: Array<ConfigCallout>;\n markets: Array<Market>;\n suggestions: {\n exclude: Array<string>;\n };\n sensors: {\n search: Array<unknown>;\n collection: Array<unknown>;\n };\n};\n\nexport type ConfigAntonym = Omit<Antonym, \"enabled\">;\nexport type ConfigSynonym = Omit<Synonym, \"enabled\">;\nexport type ConfigCallout = Omit<Callout, \"enabled\">;\nexport type ConfigSort = Omit<Sort, \"enabled\">;\nexport type ConfigField = Omit<Relevance, \"enabled\">;\nexport type ConfigSeachableField = Omit<SearchableField, \"enabled\">;\nexport type ConfigRedirect = Omit<Redirect, \"enabled\" | \"keywords\">;\nexport type ConfigFilter = Omit<FilterGroup, \"enabled\" | \"keywords\"> & {\n options: Omit<FilterFacet, \"enabled\">[];\n};\nexport type ConfigFilterFacet = Omit<FilterFacet, \"enabled\">;\nexport type ConfigCuration = Omit<\n Curation,\n \"keywords\" | \"boosting\" | \"longRunningTask\" | \"callouts\"\n> & {\n boosting: {\n groupings: Array<\n NonNullable<NonNullable<Curation[\"boosting\"]>[\"groupings\"]>[0] & { query: string }\n >;\n sortings: Array<\n NonNullable<NonNullable<Curation[\"boosting\"]>[\"sortings\"]>[0] & { query: string }\n >;\n };\n};\n\n"]}
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/types/config.ts"],"names":[],"mappings":"","sourcesContent":["import {\n Antonym,\n Callout,\n Curation,\n FilterFacet,\n FilterGroup,\n Market,\n MerchandisingCalloutAutofillBehaviour,\n Redirect,\n Relevance,\n SearchableField,\n Sort,\n Synonym,\n} from \"./firestore\";\n\n// when exposed as config, most resources have the `enabled` and `keywords` attributes removed\n// curation boosting groupings and sortings both have a json encoded elastic query added to them\n\nexport type Config = {\n index: string;\n endpoint: string;\n cluster: string;\n version: string;\n key: string;\n cache: {\n enabled: boolean;\n seconds: number;\n };\n merchandising: {\n calloutAutofillBehaviour: MerchandisingCalloutAutofillBehaviour;\n };\n sort: Array<ConfigSort>;\n fields: Array<ConfigField>;\n searchableFields: Array<ConfigSeachableField>;\n filters: Array<ConfigFilter>;\n redirects: Array<ConfigRedirect>;\n curations: Array<ConfigCuration>;\n antonyms: Array<ConfigAntonym>;\n synonyms: Array<ConfigSynonym>;\n callouts: Array<ConfigCallout>;\n markets: Array<Market>;\n suggestions: {\n exclude: Array<string>;\n };\n sensors: {\n search: Array<unknown>;\n collection: Array<unknown>;\n };\n featureFlags: string[];\n};\n\nexport type ConfigAntonym = Omit<Antonym, \"enabled\">;\nexport type ConfigSynonym = Omit<Synonym, \"enabled\">;\nexport type ConfigCallout = Omit<Callout, \"enabled\">;\nexport type ConfigSort = Omit<Sort, \"enabled\">;\nexport type ConfigField = Omit<Relevance, \"enabled\">;\nexport type ConfigSeachableField = Omit<SearchableField, \"enabled\">;\nexport type ConfigRedirect = Omit<Redirect, \"enabled\" | \"keywords\">;\nexport type ConfigFilter = Omit<FilterGroup, \"enabled\" | \"keywords\"> & {\n options: Omit<FilterFacet, \"enabled\">[];\n};\nexport type ConfigFilterFacet = Omit<FilterFacet, \"enabled\">;\nexport type ConfigCuration = Omit<\n Curation,\n \"keywords\" | \"boosting\" | \"longRunningTask\" | \"callouts\"\n> & {\n boosting: {\n groupings: Array<\n NonNullable<NonNullable<Curation[\"boosting\"]>[\"groupings\"]>[0] & { query: string }\n >;\n sortings: Array<\n NonNullable<NonNullable<Curation[\"boosting\"]>[\"sortings\"]>[0] & { query: string }\n >;\n };\n};\n\n"]}
|
|
@@ -3,11 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getCuration = void 0;
|
|
4
4
|
const getCuration = (options) => {
|
|
5
5
|
var _a;
|
|
6
|
-
const handleOrSearchTerm = options.provider.mode === "collection"
|
|
7
|
-
? options.provider.collectionHandle
|
|
8
|
-
: options.provider.mode === "curated-page" && options.provider.variation === "collection"
|
|
9
|
-
? options.provider.handle
|
|
10
|
-
: (_a = options.searchTerm) !== null && _a !== void 0 ? _a : "";
|
|
6
|
+
const handleOrSearchTerm = options.provider.mode === "collection" ? options.provider.collectionHandle : (_a = options.searchTerm) !== null && _a !== void 0 ? _a : "";
|
|
11
7
|
const normalisedHandleOrSearchTerm = handleOrSearchTerm.toLowerCase().trim();
|
|
12
8
|
const globalCuration = options.config.curations.find((curation) => {
|
|
13
9
|
if (options.provider.mode === "search" || options.provider.mode === "instant-search") {
|
|
@@ -20,18 +16,6 @@ const getCuration = (options) => {
|
|
|
20
16
|
return curation.id === `global_${options.provider.market}_collection`;
|
|
21
17
|
return curation.id === "global_collection";
|
|
22
18
|
}
|
|
23
|
-
if (options.provider.mode === "curated-page") {
|
|
24
|
-
if (options.provider.variation === "search") {
|
|
25
|
-
if (options.provider.market)
|
|
26
|
-
return curation.id === `global_${options.provider.market}_search`;
|
|
27
|
-
return curation.id === "global_search";
|
|
28
|
-
}
|
|
29
|
-
if (options.provider.variation === "collection") {
|
|
30
|
-
if (options.provider.market)
|
|
31
|
-
return curation.id === `global_${options.provider.market}_collection`;
|
|
32
|
-
return curation.id === "global_collection";
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
19
|
return false;
|
|
36
20
|
});
|
|
37
21
|
const findCuration = () => {
|
|
@@ -45,30 +29,17 @@ const getCuration = (options) => {
|
|
|
45
29
|
if ("collection" === options.provider.mode) {
|
|
46
30
|
return "collection" === curation.type && normalisedHandleOrSearchTerm === normalisedCollectionHandle;
|
|
47
31
|
}
|
|
48
|
-
if ("curated-page" === options.provider.mode) {
|
|
49
|
-
if (options.provider.variation === "search") {
|
|
50
|
-
return "search" === curation.type && normalisedHandleOrSearchTerm === normalisedSearchTerm;
|
|
51
|
-
}
|
|
52
|
-
if (options.provider.variation === "collection") {
|
|
53
|
-
return "collection" === curation.type && normalisedHandleOrSearchTerm === normalisedCollectionHandle;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
32
|
return false;
|
|
57
33
|
});
|
|
58
34
|
const curationsMatchingMarketOrNoMarket = curationsMatchingQuery
|
|
59
35
|
.filter((curation) => {
|
|
60
36
|
var _a, _b, _c;
|
|
61
37
|
if (options.provider.market) {
|
|
62
|
-
if (((_a = curation.markets) === null || _a === void 0 ? void 0 : _a.length) === 0)
|
|
38
|
+
if (((_a = curation.markets) === null || _a === void 0 ? void 0 : _a.length) === 0)
|
|
63
39
|
return true;
|
|
64
|
-
|
|
65
|
-
else {
|
|
66
|
-
return (_b = curation.markets) === null || _b === void 0 ? void 0 : _b.includes(options.provider.market);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
return ((_c = curation.markets) === null || _c === void 0 ? void 0 : _c.length) === 0;
|
|
40
|
+
return (_b = curation.markets) === null || _b === void 0 ? void 0 : _b.includes(options.provider.market);
|
|
71
41
|
}
|
|
42
|
+
return ((_c = curation.markets) === null || _c === void 0 ? void 0 : _c.length) === 0;
|
|
72
43
|
})
|
|
73
44
|
.sort((curationA, curationB) => {
|
|
74
45
|
var _a, _b, _c, _d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"curation.js","sourceRoot":"","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CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;;YAC7B,OAAO,CAAC,MAAA,MAAA,SAAS,CAAC,OAAO,0CAAE,MAAM,mCAAI,CAAC,CAAC,GAAG,CAAC,MAAA,MAAA,SAAS,CAAC,OAAO,0CAAE,MAAM,mCAAI,CAAC,CAAC,CAAC;QAC7E,CAAC,CAAC,CAAC;QAEL,OAAO,iCAAiC,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,YAAY,EAAE,CAAC;IAEhC,MAAM,iBAAiB,GAAG,CAAC,QAAwB,EAAE,EAAE;QACrD,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,MAAM,gBAAgB,GAAG,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC;QAErG,IAAI,gBAAgB,EAAE,CAAC;YACrB,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,MAAM,0BAA0B,GAAG,gCAC9B,QAAQ,KACX,QAAQ,EAAE,cAAc,CAAC,QAAQ,GAChB,CAAC;QAEpB,OAAO,0BAA0B,CAAC;IACpC,CAAC,CAAC;IAEF,IAAI,QAAQ,EAAE,CAAC;QACb,OAAO,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,cAAc,CAAC;IACxB,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AAnFW,QAAA,WAAW,eAmFtB","sourcesContent":["import { ReactifySearchProviderProps } from \"../components\";\nimport { Config, ConfigCuration } from \"../types\";\n\nexport const getCuration = (options: {\n provider: ReactifySearchProviderProps;\n config: Config;\n searchTerm?: string;\n}): ConfigCuration | undefined => {\n const handleOrSearchTerm =\n options.provider.mode === \"collection\" ? options.provider.collectionHandle : options.searchTerm ?? \"\";\n\n const normalisedHandleOrSearchTerm = handleOrSearchTerm.toLowerCase().trim();\n\n const globalCuration = options.config.curations.find((curation) => {\n if (options.provider.mode === \"search\" || options.provider.mode === \"instant-search\") {\n if (options.provider.market) return curation.id === `global_${options.provider.market}_search`;\n return curation.id === \"global_search\";\n }\n if (options.provider.mode === \"collection\") {\n if (options.provider.market) return curation.id === `global_${options.provider.market}_collection`;\n return curation.id === \"global_collection\";\n }\n return false;\n });\n\n const findCuration = () => {\n const curationsMatchingQuery = options.config.curations.filter((curation) => {\n const normalisedSearchTerm = curation.searchTerm?.toLowerCase().trim();\n const normalisedCollectionHandle = curation.collectionHandle?.toLowerCase().trim();\n\n if (\"instant-search\" === options.provider.mode || \"search\" === options.provider.mode) {\n return \"search\" === curation.type && normalisedHandleOrSearchTerm === normalisedSearchTerm;\n }\n\n if (\"collection\" === options.provider.mode) {\n return \"collection\" === curation.type && normalisedHandleOrSearchTerm === normalisedCollectionHandle;\n }\n\n return false;\n });\n\n const curationsMatchingMarketOrNoMarket = curationsMatchingQuery\n .filter((curation) => {\n if (options.provider.market) {\n if (curation.markets?.length === 0) return true;\n return curation.markets?.includes(options.provider.market);\n }\n return curation.markets?.length === 0;\n })\n .sort((curationA, curationB) => {\n return (curationB.markets?.length ?? 0) - (curationA.markets?.length ?? 0);\n });\n\n return curationsMatchingMarketOrNoMarket[0];\n };\n\n const curation = findCuration();\n\n const addGlobalBoosting = (curation: ConfigCuration) => {\n if (!globalCuration) {\n return curation;\n }\n\n const curationHasRules = !!curation.boosting.groupings.length || !!curation.boosting.sortings.length;\n\n if (curationHasRules) {\n return curation;\n }\n\n const curationWithGlobalBoosting = {\n ...curation,\n boosting: globalCuration.boosting,\n } as ConfigCuration;\n\n return curationWithGlobalBoosting;\n };\n\n if (curation) {\n return addGlobalBoosting(curation);\n }\n\n if (globalCuration) {\n return globalCuration;\n }\n\n return undefined;\n};\n"]}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getFilterStack = void 0;
|
|
4
4
|
const getFilterStack = (options) => {
|
|
5
5
|
// select filters by type
|
|
6
|
-
const filterType = options.provider.mode
|
|
6
|
+
const filterType = options.provider.mode;
|
|
7
7
|
const matchingFilterss = options.config.filters.filter((filter) => filter.type === filterType);
|
|
8
8
|
// select filter stack by handle if provided
|
|
9
9
|
if (options.provider.filtersHandle) {
|
|
@@ -13,9 +13,8 @@ const getFilterStack = (options) => {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
// select filter stack by collection if provided
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
const collectionHandle = options.provider.mode === "collection" ? options.provider.collectionHandle : options.provider.handle;
|
|
16
|
+
if (options.provider.mode === "collection" && options.provider.collectionHandle) {
|
|
17
|
+
const collectionHandle = options.provider.collectionHandle;
|
|
19
18
|
const matchingFilters = matchingFilterss.find((filterStack) => { var _a; return (_a = filterStack.collections) === null || _a === void 0 ? void 0 : _a.includes(collectionHandle || ""); });
|
|
20
19
|
if (matchingFilters) {
|
|
21
20
|
return matchingFilters;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../src/utility/filters.ts"],"names":[],"mappings":";;;AAGO,MAAM,cAAc,GAAG,CAAC,OAG9B,EAAE,EAAE;IACH,yBAAyB;IACzB,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../../src/utility/filters.ts"],"names":[],"mappings":";;;AAGO,MAAM,cAAc,GAAG,CAAC,OAG9B,EAAE,EAAE;IACH,yBAAyB;IACzB,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC;IACzC,MAAM,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CACpD,CAAC,MAAM,EAAE,EAAE,CAAC,MA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AG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IAE5C,OAAO,eAAe,CAAC;AACzB,CAAC,CAAA;AAnDY,QAAA,cAAc,kBAmD1B","sourcesContent":["import { ReactifySearchProviderProps } from \"../components\";\nimport { Config } from \"../types\";\n\nexport const getFilterStack = (options: {\n provider: ReactifySearchProviderProps;\n config: Config;\n}) => {\n // select filters by type\n const filterType = options.provider.mode;\n const matchingFilterss = options.config.filters.filter(\n (filter) => filter.type === filterType\n );\n\n // select filter stack by handle if provided\n if (options.provider.filtersHandle) {\n const matchingFilters = matchingFilterss.find(\n (filterStack) => options.provider.filtersHandle === filterStack.handle\n );\n if (matchingFilters) {\n return matchingFilters;\n }\n }\n\n // select filter stack by collection if provided\n if (options.provider.mode === \"collection\" && options.provider.collectionHandle) {\n const collectionHandle = options.provider.collectionHandle;\n const matchingFilters = matchingFilterss.find((filterStack) =>\n filterStack.collections?.includes(collectionHandle || \"\")\n );\n if (matchingFilters) {\n return matchingFilters;\n }\n }\n\n // select filter with \"default\" handle\n let matchingFilters = matchingFilterss.find(\n (filterStack) => filterStack.handle === \"default\"\n );\n if (matchingFilters) {\n return matchingFilters;\n }\n\n // select any filter with \"default\" handle\n matchingFilters = options.config.filters.find(\n (filterStack) => filterStack.handle === \"default\"\n );\n if (matchingFilters) {\n return matchingFilters;\n }\n\n // select any available filter as a last resort\n matchingFilters = options.config.filters[0];\n\n return matchingFilters;\n}"]}
|
|
@@ -4,16 +4,10 @@ export declare class ReactifySearchLiquidFactory {
|
|
|
4
4
|
providerProps: Omit<ReactifySearchProviderProps, "shopifyPermanentDomain"> & {
|
|
5
5
|
shopifyPermanentDomain?: string;
|
|
6
6
|
collectionHandle?: string;
|
|
7
|
-
variation?: "collection" | "search";
|
|
8
|
-
handle?: string;
|
|
9
|
-
searchTerm?: string;
|
|
10
7
|
};
|
|
11
8
|
constructor(providerProps: Omit<ReactifySearchProviderProps, "shopifyPermanentDomain"> & {
|
|
12
9
|
shopifyPermanentDomain?: string;
|
|
13
10
|
collectionHandle?: string;
|
|
14
|
-
variation?: "collection" | "search";
|
|
15
|
-
handle?: string;
|
|
16
|
-
searchTerm?: string;
|
|
17
11
|
});
|
|
18
12
|
getProvider(): React.FC<{
|
|
19
13
|
children?: React.ReactNode | undefined;
|
|
@@ -47,21 +47,6 @@ class ReactifySearchLiquidFactory {
|
|
|
47
47
|
throw new Error("Cannot determine collectionHandle from URL");
|
|
48
48
|
return Object.assign(Object.assign({}, baseProps), { mode: "collection", collectionHandle });
|
|
49
49
|
}
|
|
50
|
-
if (this.providerProps.mode === "curated-page") {
|
|
51
|
-
const variation = this.providerProps.variation;
|
|
52
|
-
if (variation === "collection") {
|
|
53
|
-
const handle = this.providerProps.handle;
|
|
54
|
-
if (!handle)
|
|
55
|
-
throw new Error("Handle is required for curated-page collection mode");
|
|
56
|
-
return Object.assign(Object.assign({}, baseProps), { mode: "curated-page", variation: "collection", handle });
|
|
57
|
-
}
|
|
58
|
-
if (variation === "search") {
|
|
59
|
-
const searchTerm = this.providerProps.searchTerm;
|
|
60
|
-
if (!searchTerm)
|
|
61
|
-
throw new Error("SearchTerm is required for curated-page search mode");
|
|
62
|
-
return Object.assign(Object.assign({}, baseProps), { mode: "curated-page", variation: "search", searchTerm });
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
50
|
return baseProps;
|
|
66
51
|
}
|
|
67
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liquid.js","sourceRoot":"","sources":["../../../src/utility/liquid.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,wGAGqE;AAErE,MAAa,2BAA2B;IACtC,YACS,
|
|
1
|
+
{"version":3,"file":"liquid.js","sourceRoot":"","sources":["../../../src/utility/liquid.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,wGAGqE;AAErE,MAAa,2BAA2B;IACtC,YACS,aAGN;QAHM,kBAAa,GAAb,aAAa,CAGnB;IAC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AC;QAEpE,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;YAC7C,MAAM,gBAAgB,GACpB,MAAA,IAAI,CAAC,aAAa,CAAC,gBAAgB,mCAAI,MAAA,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,0CAAG,CAAC,CAAC,CAAC;YAClF,IAAI,CAAC,gBAAgB;gBAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;YACrF,uCAAY,SAAS,KAAE,IAAI,EAAE,YAAY,EAAE,gBAAgB,IAAG;QAChE,CAAC;QAGD,OAAO,SAAwC,CAAC;IAClD,CAAC;CACF;AAjED,kEAiEC","sourcesContent":["import React from \"react\";\n\nimport {\n ReactifySearchProvider,\n ReactifySearchProviderProps,\n} from \"../components/ReactifySearchProvider/ReactifySearchProvider\";\n\nexport class ReactifySearchLiquidFactory {\n constructor(\n public providerProps: Omit<ReactifySearchProviderProps, \"shopifyPermanentDomain\"> & {\n shopifyPermanentDomain?: string;\n collectionHandle?: string;\n }\n ) {}\n\n getProvider() {\n const providerProps = this.getProviderProps();\n\n const provider: React.FC<{\n children?: React.ReactNode | undefined;\n }> = (props) => (\n <ReactifySearchProvider {...providerProps}>{props.children}</ReactifySearchProvider>\n );\n\n return provider;\n }\n\n getMountNode() {\n const mountNode = document.getElementById(`reactify-mount-${this.providerProps.mode}`);\n if (!mountNode) {\n throw new Error(`Cannot find mount node with ID \"reactify-mount-${this.providerProps.mode}\"`);\n }\n\n return mountNode;\n }\n\n getData() {\n const dataNode = document.getElementById(\"reactify-data\");\n if (!dataNode) {\n throw new Error(`Cannot find data node with ID \"reactify-data\"`);\n }\n\n try {\n const data = JSON.parse(dataNode.innerHTML);\n\n return data;\n } catch {\n throw new Error(\n `Cannot parse the data node with ID \"reactify-data\", check your liquid formatting`\n );\n }\n }\n\n getProviderProps(): ReactifySearchProviderProps {\n const shopifyPermanentDomain =\n this.providerProps.shopifyPermanentDomain ?? (window as any)?.Shopify?.shop;\n\n if (!shopifyPermanentDomain)\n throw new Error(\"Cannot determine shopifyPermanentDomain from window\");\n\n const baseProps = { ...this.providerProps, shopifyPermanentDomain };\n\n if (this.providerProps.mode === \"collection\") {\n const collectionHandle =\n this.providerProps.collectionHandle ?? window.location.pathname.split(\"/\")?.[2];\n if (!collectionHandle) throw new Error(\"Cannot determine collectionHandle from URL\");\n return { ...baseProps, mode: \"collection\", collectionHandle };\n }\n\n\n return baseProps as ReactifySearchProviderProps;\n }\n}\n"]}
|
|
@@ -229,7 +229,7 @@ export declare const getPropsSensorCollection: (options: GeneratePropsSensorOpti
|
|
|
229
229
|
};
|
|
230
230
|
} | null;
|
|
231
231
|
} | null;
|
|
232
|
-
export declare const
|
|
232
|
+
export declare const getPropsSensorCollectionWeighted: ({ provider, config }: GeneratePropsSensorOptions) => {
|
|
233
233
|
source: import("react").ComponentClass<import("@usereactify/search-internals/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any>;
|
|
234
234
|
componentId: string;
|
|
235
235
|
customQuery: () => {
|
|
@@ -305,7 +305,9 @@ export declare const getPropsSensorCuratedPageCollection: ({ provider, config }:
|
|
|
305
305
|
};
|
|
306
306
|
};
|
|
307
307
|
} | null;
|
|
308
|
-
export declare const
|
|
308
|
+
export declare const getPropsSensorSearchWeighted: ({ provider, config, searchTerm, }: GeneratePropsSensorOptions & {
|
|
309
|
+
searchTerm?: string;
|
|
310
|
+
}) => {
|
|
309
311
|
source: import("react").ComponentClass<import("@usereactify/search-internals/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any>;
|
|
310
312
|
componentId: string;
|
|
311
313
|
customQuery: () => {
|
|
@@ -409,11 +411,12 @@ export declare const getPropsSensorCuratedPageSearch: ({ provider, config }: Gen
|
|
|
409
411
|
};
|
|
410
412
|
};
|
|
411
413
|
};
|
|
412
|
-
|
|
414
|
+
must: {
|
|
413
415
|
match: {
|
|
414
416
|
[x: string]: {
|
|
415
417
|
query: string;
|
|
416
418
|
fuzziness: number;
|
|
419
|
+
analyzer: string;
|
|
417
420
|
};
|
|
418
421
|
};
|
|
419
422
|
};
|
|
@@ -426,7 +429,7 @@ export declare const getPropsSensorCuratedPageSearch: ({ provider, config }: Gen
|
|
|
426
429
|
boost_mode: string;
|
|
427
430
|
};
|
|
428
431
|
};
|
|
429
|
-
}
|
|
432
|
+
};
|
|
430
433
|
} | null;
|
|
431
434
|
export declare const getPropsSensorPublished: (options: GeneratePropsSensorOptions) => {
|
|
432
435
|
source: import("react").ComponentClass<import("@usereactify/search-internals/lib/components/basic/ReactiveComponent").ReactiveComponentProps, any>;
|
|
@@ -520,7 +523,7 @@ export declare const getPropsBase: (options: GeneratePropsBase) => {
|
|
|
520
523
|
transformResponse: (response: any) => Promise<any>;
|
|
521
524
|
headers: {
|
|
522
525
|
"x-reactify-shop": string;
|
|
523
|
-
"x-reactify-mode": "search" | "collection" | "instant-search"
|
|
526
|
+
"x-reactify-mode": "search" | "collection" | "instant-search";
|
|
524
527
|
"x-reactify-client-id": string | undefined;
|
|
525
528
|
"x-reactify-client-version": string;
|
|
526
529
|
};
|
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getPropsFilterSlider = exports.getPropsFilterRange = exports.getPropsFilterList = exports.getPropsShared = exports.getPropsReact = exports.getPropsResults = exports.getPropsBase = exports.getPropsSensorSort = exports.getPropsSensorInventoryAvailable = exports.getPropsSensorPublished = exports.
|
|
15
|
+
exports.getPropsFilterSlider = exports.getPropsFilterRange = exports.getPropsFilterList = exports.getPropsShared = exports.getPropsReact = exports.getPropsResults = exports.getPropsBase = exports.getPropsSensorSort = exports.getPropsSensorInventoryAvailable = exports.getPropsSensorPublished = exports.getPropsSensorSearchWeighted = exports.getPropsSensorCollectionWeighted = exports.getPropsSensorCollection = exports.getPropsSensorCustom = exports.getPropsSensors = exports.getPropsFilterGroupOption = exports.getPropsFilterGroup = void 0;
|
|
16
16
|
const search_internals_1 = require("@usereactify/search-internals");
|
|
17
17
|
const components_1 = require("../components");
|
|
18
18
|
const curation_1 = require("./curation");
|
|
@@ -59,17 +59,11 @@ const getPropsSensors = (options) => {
|
|
|
59
59
|
(0, exports.getPropsSensorPublished)(options),
|
|
60
60
|
(0, exports.getPropsSensorInventoryAvailable)(options),
|
|
61
61
|
(0, exports.getPropsSensorSort)(options),
|
|
62
|
-
(0, exports.getPropsSensorCuratedPageCollection)(options),
|
|
63
|
-
(0, exports.getPropsSensorCuratedPageSearch)(options),
|
|
64
62
|
].filter(Boolean);
|
|
65
63
|
};
|
|
66
64
|
exports.getPropsSensors = getPropsSensors;
|
|
67
65
|
const getPropsSensorCustom = (options) => {
|
|
68
|
-
const sensorType = options.provider.mode === "collection"
|
|
69
|
-
? "collection"
|
|
70
|
-
: options.provider.mode === "curated-page" && options.provider.variation === "collection"
|
|
71
|
-
? "collection"
|
|
72
|
-
: "search";
|
|
66
|
+
const sensorType = options.provider.mode === "collection" ? "collection" : "search";
|
|
73
67
|
const sensors = sensorType === "collection" ? options.config.sensors.collection : options.config.sensors.search;
|
|
74
68
|
return sensors.map((sensor, index) => ({
|
|
75
69
|
source: search_internals_1.ReactiveComponent,
|
|
@@ -153,18 +147,16 @@ const getPropsSensorCollection = (options) => {
|
|
|
153
147
|
};
|
|
154
148
|
};
|
|
155
149
|
exports.getPropsSensorCollection = getPropsSensorCollection;
|
|
156
|
-
const
|
|
157
|
-
if (provider.mode !== "
|
|
150
|
+
const getPropsSensorCollectionWeighted = ({ provider, config }) => {
|
|
151
|
+
if (provider.mode !== "collection")
|
|
158
152
|
return null;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const handle = provider.handle;
|
|
153
|
+
const handle = provider.collectionHandle;
|
|
154
|
+
const curation = (0, curation_1.getCuration)({ provider, config });
|
|
162
155
|
return {
|
|
163
156
|
source: search_internals_1.ReactiveComponent,
|
|
164
|
-
componentId: "
|
|
157
|
+
componentId: "SensorCollectionWeighted",
|
|
165
158
|
customQuery: () => {
|
|
166
159
|
var _a;
|
|
167
|
-
const curation = config.curations.find((curation) => curation.collectionHandle === handle);
|
|
168
160
|
const function_score = (0, queries_1.generateCollectionFunctionScore)({
|
|
169
161
|
collectionHandle: handle,
|
|
170
162
|
boostingRules: (_a = curation === null || curation === void 0 ? void 0 : curation.boostings) !== null && _a !== void 0 ? _a : [],
|
|
@@ -175,33 +167,30 @@ const getPropsSensorCuratedPageCollection = ({ provider, config }) => {
|
|
|
175
167
|
},
|
|
176
168
|
};
|
|
177
169
|
};
|
|
178
|
-
exports.
|
|
179
|
-
const
|
|
180
|
-
if (provider.mode !== "
|
|
170
|
+
exports.getPropsSensorCollectionWeighted = getPropsSensorCollectionWeighted;
|
|
171
|
+
const getPropsSensorSearchWeighted = ({ provider, config, searchTerm, }) => {
|
|
172
|
+
if (provider.mode !== "search" && provider.mode !== "instant-search")
|
|
181
173
|
return null;
|
|
182
|
-
if (
|
|
174
|
+
if (!searchTerm)
|
|
183
175
|
return null;
|
|
184
|
-
const searchTerm = provider.searchTerm;
|
|
185
176
|
return {
|
|
186
177
|
source: search_internals_1.ReactiveComponent,
|
|
187
|
-
componentId: "
|
|
178
|
+
componentId: "SensorSearchWeighted",
|
|
188
179
|
customQuery: () => {
|
|
189
180
|
var _a;
|
|
190
|
-
const curation =
|
|
191
|
-
if (!curation)
|
|
192
|
-
return null;
|
|
181
|
+
const curation = (0, curation_1.getCuration)({ provider, config, searchTerm });
|
|
193
182
|
const function_score = (0, queries_1.generateSearchFunctionScore)({
|
|
194
183
|
searchTerm: searchTerm,
|
|
195
184
|
searchableFields: config.searchableFields,
|
|
196
|
-
boostingRules: (_a = curation.boostings) !== null && _a !== void 0 ? _a : [],
|
|
197
|
-
markets: curation.markets,
|
|
185
|
+
boostingRules: (_a = curation === null || curation === void 0 ? void 0 : curation.boostings) !== null && _a !== void 0 ? _a : [],
|
|
186
|
+
markets: (curation === null || curation === void 0 ? void 0 : curation.markets) || [],
|
|
198
187
|
market: provider.market,
|
|
199
188
|
});
|
|
200
189
|
return { query: { function_score } };
|
|
201
190
|
},
|
|
202
191
|
};
|
|
203
192
|
};
|
|
204
|
-
exports.
|
|
193
|
+
exports.getPropsSensorSearchWeighted = getPropsSensorSearchWeighted;
|
|
205
194
|
const getPropsSensorPublished = (options) => {
|
|
206
195
|
return {
|
|
207
196
|
source: search_internals_1.ReactiveComponent,
|
|
@@ -385,8 +374,7 @@ const getPropsResults = (options) => {
|
|
|
385
374
|
};
|
|
386
375
|
exports.getPropsResults = getPropsResults;
|
|
387
376
|
const getPropsReact = (options, filterGroupOption) => {
|
|
388
|
-
const
|
|
389
|
-
const sensorIds = (0, components_1.SENSOR_IDS)(options.provider.mode, options.config, variation);
|
|
377
|
+
const sensorIds = (0, components_1.SENSOR_IDS)(options.provider.mode, options.config);
|
|
390
378
|
const reactProp = (() => {
|
|
391
379
|
var _a, _b, _c;
|
|
392
380
|
if (filterGroupOption === null || filterGroupOption === void 0 ? void 0 : filterGroupOption.settingsShowEmptyValues) {
|