@vendure/elasticsearch-plugin 2.3.2 → 2.3.4
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/README.md +9 -9
- package/lib/src/api/api-extensions.js +89 -89
- package/package.json +4 -4
- package/LICENSE +0 -9
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# Vendure Elasticsearch Plugin
|
|
2
|
-
|
|
3
|
-
The `ElasticsearchPlugin` uses Elasticsearch to power the Vendure product search.
|
|
4
|
-
|
|
5
|
-
**Requires Elasticsearch v7.0 or higher.**
|
|
6
|
-
|
|
7
|
-
`npm install @vendure/elasticsearch-plugin`
|
|
8
|
-
|
|
9
|
-
For documentation, see [docs.vendure.io/reference/core-plugins/elasticsearch-plugin/](https://docs.vendure.io/reference/core-plugins/elasticsearch-plugin/)
|
|
1
|
+
# Vendure Elasticsearch Plugin
|
|
2
|
+
|
|
3
|
+
The `ElasticsearchPlugin` uses Elasticsearch to power the Vendure product search.
|
|
4
|
+
|
|
5
|
+
**Requires Elasticsearch v7.0 or higher.**
|
|
6
|
+
|
|
7
|
+
`npm install @vendure/elasticsearch-plugin`
|
|
8
|
+
|
|
9
|
+
For documentation, see [docs.vendure.io/reference/core-plugins/elasticsearch-plugin/](https://docs.vendure.io/reference/core-plugins/elasticsearch-plugin/)
|
|
@@ -6,46 +6,46 @@ function generateSchemaExtensions(options) {
|
|
|
6
6
|
const customMappingTypes = generateCustomMappingTypes(options);
|
|
7
7
|
const inputExtensions = Object.entries(options.extendSearchInputType || {});
|
|
8
8
|
const sortExtensions = options.extendSearchSortType || [];
|
|
9
|
-
const sortExtensionGql = `
|
|
10
|
-
extend input SearchResultSortParameter {
|
|
11
|
-
${sortExtensions.map(key => `${key}: SortOrder`).join('\n ')}
|
|
9
|
+
const sortExtensionGql = `
|
|
10
|
+
extend input SearchResultSortParameter {
|
|
11
|
+
${sortExtensions.map(key => `${key}: SortOrder`).join('\n ')}
|
|
12
12
|
}`;
|
|
13
|
-
return (0, graphql_tag_1.gql) `
|
|
14
|
-
extend type SearchResponse {
|
|
15
|
-
prices: SearchResponsePriceData!
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
extend type SearchResult {
|
|
19
|
-
inStock: Boolean
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type SearchResponsePriceData {
|
|
23
|
-
range: PriceRange!
|
|
24
|
-
rangeWithTax: PriceRange!
|
|
25
|
-
buckets: [PriceRangeBucket!]!
|
|
26
|
-
bucketsWithTax: [PriceRangeBucket!]!
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
type PriceRangeBucket {
|
|
30
|
-
to: Int!
|
|
31
|
-
count: Int!
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
extend input SearchInput {
|
|
35
|
-
priceRange: PriceRangeInput
|
|
36
|
-
priceRangeWithTax: PriceRangeInput
|
|
37
|
-
inStock: Boolean
|
|
38
|
-
${inputExtensions.map(([name, type]) => `${name}: ${type}`).join('\n ')}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
${sortExtensions.length > 0 ? sortExtensionGql : ''}
|
|
42
|
-
|
|
43
|
-
input PriceRangeInput {
|
|
44
|
-
min: Int!
|
|
45
|
-
max: Int!
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
${customMappingTypes ? customMappingTypes : ''}
|
|
13
|
+
return (0, graphql_tag_1.gql) `
|
|
14
|
+
extend type SearchResponse {
|
|
15
|
+
prices: SearchResponsePriceData!
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
extend type SearchResult {
|
|
19
|
+
inStock: Boolean
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type SearchResponsePriceData {
|
|
23
|
+
range: PriceRange!
|
|
24
|
+
rangeWithTax: PriceRange!
|
|
25
|
+
buckets: [PriceRangeBucket!]!
|
|
26
|
+
bucketsWithTax: [PriceRangeBucket!]!
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type PriceRangeBucket {
|
|
30
|
+
to: Int!
|
|
31
|
+
count: Int!
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
extend input SearchInput {
|
|
35
|
+
priceRange: PriceRangeInput
|
|
36
|
+
priceRangeWithTax: PriceRangeInput
|
|
37
|
+
inStock: Boolean
|
|
38
|
+
${inputExtensions.map(([name, type]) => `${name}: ${type}`).join('\n ')}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
${sortExtensions.length > 0 ? sortExtensionGql : ''}
|
|
42
|
+
|
|
43
|
+
input PriceRangeInput {
|
|
44
|
+
min: Int!
|
|
45
|
+
max: Int!
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
${customMappingTypes ? customMappingTypes : ''}
|
|
49
49
|
`;
|
|
50
50
|
}
|
|
51
51
|
exports.generateSchemaExtensions = generateSchemaExtensions;
|
|
@@ -59,89 +59,89 @@ function generateCustomMappingTypes(options) {
|
|
|
59
59
|
let sdl = '';
|
|
60
60
|
if (scriptProductFields.length || scriptVariantFields.length) {
|
|
61
61
|
if (scriptProductFields.length) {
|
|
62
|
-
sdl += `
|
|
63
|
-
type CustomProductScriptFields {
|
|
64
|
-
${scriptProductFields.map(([name, def]) => `${name}: ${def.graphQlType}`).join('\n')}
|
|
65
|
-
}
|
|
62
|
+
sdl += `
|
|
63
|
+
type CustomProductScriptFields {
|
|
64
|
+
${scriptProductFields.map(([name, def]) => `${name}: ${def.graphQlType}`).join('\n')}
|
|
65
|
+
}
|
|
66
66
|
`;
|
|
67
67
|
}
|
|
68
68
|
if (scriptVariantFields.length) {
|
|
69
|
-
sdl += `
|
|
70
|
-
type CustomProductVariantScriptFields {
|
|
71
|
-
${scriptVariantFields.map(([name, def]) => `${name}: ${def.graphQlType}`).join('\n')}
|
|
72
|
-
}
|
|
69
|
+
sdl += `
|
|
70
|
+
type CustomProductVariantScriptFields {
|
|
71
|
+
${scriptVariantFields.map(([name, def]) => `${name}: ${def.graphQlType}`).join('\n')}
|
|
72
|
+
}
|
|
73
73
|
`;
|
|
74
74
|
}
|
|
75
75
|
if (scriptProductFields.length && scriptVariantFields.length) {
|
|
76
|
-
sdl += `
|
|
77
|
-
union CustomScriptFields = CustomProductScriptFields | CustomProductVariantScriptFields
|
|
78
|
-
|
|
79
|
-
extend type SearchResult {
|
|
80
|
-
customScriptFields: CustomScriptFields!
|
|
81
|
-
}
|
|
76
|
+
sdl += `
|
|
77
|
+
union CustomScriptFields = CustomProductScriptFields | CustomProductVariantScriptFields
|
|
78
|
+
|
|
79
|
+
extend type SearchResult {
|
|
80
|
+
customScriptFields: CustomScriptFields!
|
|
81
|
+
}
|
|
82
82
|
`;
|
|
83
83
|
}
|
|
84
84
|
else if (scriptProductFields.length) {
|
|
85
|
-
sdl += `
|
|
86
|
-
extend type SearchResult {
|
|
87
|
-
customScriptFields: CustomProductScriptFields!
|
|
88
|
-
}
|
|
85
|
+
sdl += `
|
|
86
|
+
extend type SearchResult {
|
|
87
|
+
customScriptFields: CustomProductScriptFields!
|
|
88
|
+
}
|
|
89
89
|
`;
|
|
90
90
|
}
|
|
91
91
|
else if (scriptVariantFields.length) {
|
|
92
|
-
sdl += `
|
|
93
|
-
extend type SearchResult {
|
|
94
|
-
customScriptFields: CustomProductVariantScriptFields!
|
|
95
|
-
}
|
|
92
|
+
sdl += `
|
|
93
|
+
extend type SearchResult {
|
|
94
|
+
customScriptFields: CustomProductVariantScriptFields!
|
|
95
|
+
}
|
|
96
96
|
`;
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
if (productMappings.length || variantMappings.length) {
|
|
100
100
|
if (productMappings.length) {
|
|
101
|
-
sdl += `
|
|
102
|
-
type CustomProductMappings {
|
|
103
|
-
${productMappings.map(([name, def]) => `${name}: ${def.graphQlType}`).join('\n')}
|
|
104
|
-
}
|
|
101
|
+
sdl += `
|
|
102
|
+
type CustomProductMappings {
|
|
103
|
+
${productMappings.map(([name, def]) => `${name}: ${def.graphQlType}`).join('\n')}
|
|
104
|
+
}
|
|
105
105
|
`;
|
|
106
106
|
}
|
|
107
107
|
if (variantMappings.length) {
|
|
108
|
-
sdl += `
|
|
109
|
-
type CustomProductVariantMappings {
|
|
110
|
-
${variantMappings.map(([name, def]) => `${name}: ${def.graphQlType}`).join('\n')}
|
|
111
|
-
}
|
|
108
|
+
sdl += `
|
|
109
|
+
type CustomProductVariantMappings {
|
|
110
|
+
${variantMappings.map(([name, def]) => `${name}: ${def.graphQlType}`).join('\n')}
|
|
111
|
+
}
|
|
112
112
|
`;
|
|
113
113
|
}
|
|
114
114
|
if (productMappings.length && variantMappings.length) {
|
|
115
|
-
sdl += `
|
|
116
|
-
union CustomMappings = CustomProductMappings | CustomProductVariantMappings
|
|
117
|
-
|
|
118
|
-
extend type SearchResult {
|
|
119
|
-
customMappings: CustomMappings! @deprecated(reason: "Use customProductMappings or customProductVariantMappings")
|
|
120
|
-
customProductMappings: CustomProductMappings!
|
|
121
|
-
customProductVariantMappings: CustomProductVariantMappings!
|
|
122
|
-
}
|
|
115
|
+
sdl += `
|
|
116
|
+
union CustomMappings = CustomProductMappings | CustomProductVariantMappings
|
|
117
|
+
|
|
118
|
+
extend type SearchResult {
|
|
119
|
+
customMappings: CustomMappings! @deprecated(reason: "Use customProductMappings or customProductVariantMappings")
|
|
120
|
+
customProductMappings: CustomProductMappings!
|
|
121
|
+
customProductVariantMappings: CustomProductVariantMappings!
|
|
122
|
+
}
|
|
123
123
|
`;
|
|
124
124
|
}
|
|
125
125
|
else if (productMappings.length) {
|
|
126
|
-
sdl += `
|
|
127
|
-
extend type SearchResult {
|
|
128
|
-
customMappings: CustomProductMappings! @deprecated(reason: "Use customProductMappings or customProductVariantMappings")
|
|
129
|
-
customProductMappings: CustomProductMappings!
|
|
130
|
-
}
|
|
126
|
+
sdl += `
|
|
127
|
+
extend type SearchResult {
|
|
128
|
+
customMappings: CustomProductMappings! @deprecated(reason: "Use customProductMappings or customProductVariantMappings")
|
|
129
|
+
customProductMappings: CustomProductMappings!
|
|
130
|
+
}
|
|
131
131
|
`;
|
|
132
132
|
}
|
|
133
133
|
else if (variantMappings.length) {
|
|
134
|
-
sdl += `
|
|
135
|
-
extend type SearchResult {
|
|
136
|
-
customMappings: CustomProductVariantMappings! @deprecated(reason: "Use customProductMappings or customProductVariantMappings")
|
|
137
|
-
customProductVariantMappings: CustomProductVariantMappings!
|
|
138
|
-
}
|
|
134
|
+
sdl += `
|
|
135
|
+
extend type SearchResult {
|
|
136
|
+
customMappings: CustomProductVariantMappings! @deprecated(reason: "Use customProductMappings or customProductVariantMappings")
|
|
137
|
+
customProductVariantMappings: CustomProductVariantMappings!
|
|
138
|
+
}
|
|
139
139
|
`;
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
return sdl.length
|
|
143
|
-
? (0, graphql_tag_1.gql) `
|
|
144
|
-
${sdl}
|
|
143
|
+
? (0, graphql_tag_1.gql) `
|
|
144
|
+
${sdl}
|
|
145
145
|
`
|
|
146
146
|
: undefined;
|
|
147
147
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vendure/elasticsearch-plugin",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"fast-deep-equal": "^3.1.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@vendure/common": "^2.3.
|
|
30
|
-
"@vendure/core": "^2.3.
|
|
29
|
+
"@vendure/common": "^2.3.4",
|
|
30
|
+
"@vendure/core": "^2.3.4",
|
|
31
31
|
"rimraf": "^5.0.5",
|
|
32
32
|
"typescript": "5.3.3"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "4f4c3ae5f5505fc475c22baebcd774c1fc5a4713"
|
|
35
35
|
}
|
package/LICENSE
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
The MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 Michael Bromley
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
-
|
|
7
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|