@vendure/elasticsearch-plugin 1.9.2 → 1.9.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/lib/src/api/api-extensions.js +89 -89
- package/package.json +4 -4
|
@@ -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 apollo_server_core_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 apollo_server_core_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}`)}
|
|
65
|
-
}
|
|
62
|
+
sdl += `
|
|
63
|
+
type CustomProductScriptFields {
|
|
64
|
+
${scriptProductFields.map(([name, def]) => `${name}: ${def.graphQlType}`)}
|
|
65
|
+
}
|
|
66
66
|
`;
|
|
67
67
|
}
|
|
68
68
|
if (scriptVariantFields.length) {
|
|
69
|
-
sdl += `
|
|
70
|
-
type CustomProductVariantScriptFields {
|
|
71
|
-
${scriptVariantFields.map(([name, def]) => `${name}: ${def.graphQlType}`)}
|
|
72
|
-
}
|
|
69
|
+
sdl += `
|
|
70
|
+
type CustomProductVariantScriptFields {
|
|
71
|
+
${scriptVariantFields.map(([name, def]) => `${name}: ${def.graphQlType}`)}
|
|
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}`)}
|
|
104
|
-
}
|
|
101
|
+
sdl += `
|
|
102
|
+
type CustomProductMappings {
|
|
103
|
+
${productMappings.map(([name, def]) => `${name}: ${def.graphQlType}`)}
|
|
104
|
+
}
|
|
105
105
|
`;
|
|
106
106
|
}
|
|
107
107
|
if (variantMappings.length) {
|
|
108
|
-
sdl += `
|
|
109
|
-
type CustomProductVariantMappings {
|
|
110
|
-
${variantMappings.map(([name, def]) => `${name}: ${def.graphQlType}`)}
|
|
111
|
-
}
|
|
108
|
+
sdl += `
|
|
109
|
+
type CustomProductVariantMappings {
|
|
110
|
+
${variantMappings.map(([name, def]) => `${name}: ${def.graphQlType}`)}
|
|
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
|
-
? apollo_server_core_1.gql `
|
|
144
|
-
${sdl}
|
|
143
|
+
? apollo_server_core_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": "1.9.
|
|
3
|
+
"version": "1.9.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"fast-deep-equal": "^3.1.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@vendure/common": "^1.9.
|
|
29
|
-
"@vendure/core": "^1.9.
|
|
28
|
+
"@vendure/common": "^1.9.4",
|
|
29
|
+
"@vendure/core": "^1.9.4",
|
|
30
30
|
"rimraf": "^3.0.2",
|
|
31
31
|
"typescript": "4.3.5"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "3d031edfff37581b44848ece021acbb7a472f43f"
|
|
34
34
|
}
|