@vendure/elasticsearch-plugin 1.2.2 → 1.3.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/lib/src/{graphql-schema-extensions.d.ts → api/api-extensions.d.ts} +1 -1
- package/lib/src/{graphql-schema-extensions.js → api/api-extensions.js} +107 -56
- package/lib/src/api/api-extensions.js.map +1 -0
- package/lib/src/{custom-mappings.resolver.d.ts → api/custom-mappings.resolver.d.ts} +1 -1
- package/lib/src/{custom-mappings.resolver.js → api/custom-mappings.resolver.js} +1 -1
- package/lib/src/api/custom-mappings.resolver.js.map +1 -0
- package/lib/src/api/custom-script-fields.resolver.d.ts +12 -0
- package/lib/src/api/custom-script-fields.resolver.js +50 -0
- package/lib/src/api/custom-script-fields.resolver.js.map +1 -0
- package/lib/src/{elasticsearch-resolver.d.ts → api/elasticsearch-resolver.d.ts} +9 -6
- package/lib/src/{elasticsearch-resolver.js → api/elasticsearch-resolver.js} +27 -3
- package/lib/src/api/elasticsearch-resolver.js.map +1 -0
- package/lib/src/build-elastic-body.js +56 -41
- package/lib/src/build-elastic-body.js.map +1 -1
- package/lib/src/constants.d.ts +0 -1
- package/lib/src/constants.js +1 -2
- package/lib/src/constants.js.map +1 -1
- package/lib/src/elasticsearch.service.d.ts +11 -2
- package/lib/src/elasticsearch.service.js +139 -68
- package/lib/src/elasticsearch.service.js.map +1 -1
- package/lib/src/{elasticsearch-index.service.d.ts → indexing/elasticsearch-index.service.d.ts} +1 -1
- package/lib/src/{elasticsearch-index.service.js → indexing/elasticsearch-index.service.js} +0 -0
- package/lib/src/indexing/elasticsearch-index.service.js.map +1 -0
- package/lib/src/{indexer.controller.d.ts → indexing/indexer.controller.d.ts} +24 -10
- package/lib/src/{indexer.controller.js → indexing/indexer.controller.js} +221 -266
- package/lib/src/indexing/indexer.controller.js.map +1 -0
- package/lib/src/{indexing-utils.d.ts → indexing/indexing-utils.d.ts} +2 -2
- package/lib/src/{indexing-utils.js → indexing/indexing-utils.js} +3 -59
- package/lib/src/indexing/indexing-utils.js.map +1 -0
- package/lib/src/options.d.ts +203 -32
- package/lib/src/options.js +5 -0
- package/lib/src/options.js.map +1 -1
- package/lib/src/plugin.d.ts +4 -2
- package/lib/src/plugin.js +31 -11
- package/lib/src/plugin.js.map +1 -1
- package/lib/src/types.d.ts +51 -13
- package/package.json +4 -4
- package/lib/src/custom-mappings.resolver.js.map +0 -1
- package/lib/src/elasticsearch-index.service.js.map +0 -1
- package/lib/src/elasticsearch-resolver.js.map +0 -1
- package/lib/src/graphql-schema-extensions.js.map +0 -1
- package/lib/src/indexer.controller.js.map +0 -1
- package/lib/src/indexing-utils.js.map +0 -1
|
@@ -4,83 +4,134 @@ exports.generateSchemaExtensions = void 0;
|
|
|
4
4
|
const apollo_server_core_1 = require("apollo-server-core");
|
|
5
5
|
function generateSchemaExtensions(options) {
|
|
6
6
|
const customMappingTypes = generateCustomMappingTypes(options);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
input
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
7
|
+
const inputExtensions = Object.entries(options.extendSearchInputType || {});
|
|
8
|
+
return apollo_server_core_1.gql `
|
|
9
|
+
extend type SearchResponse {
|
|
10
|
+
prices: SearchResponsePriceData!
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
extend type SearchResult {
|
|
14
|
+
inStock: Boolean
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
type SearchResponsePriceData {
|
|
18
|
+
range: PriceRange!
|
|
19
|
+
rangeWithTax: PriceRange!
|
|
20
|
+
buckets: [PriceRangeBucket!]!
|
|
21
|
+
bucketsWithTax: [PriceRangeBucket!]!
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type PriceRangeBucket {
|
|
25
|
+
to: Int!
|
|
26
|
+
count: Int!
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
extend input SearchInput {
|
|
30
|
+
priceRange: PriceRangeInput
|
|
31
|
+
priceRangeWithTax: PriceRangeInput
|
|
32
|
+
inStock: Boolean
|
|
33
|
+
${inputExtensions.map(([name, type]) => `${name}: ${type}`).join('\n ')}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
input PriceRangeInput {
|
|
37
|
+
min: Int!
|
|
38
|
+
max: Int!
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
${customMappingTypes ? customMappingTypes : ''}
|
|
35
42
|
`;
|
|
36
43
|
}
|
|
37
44
|
exports.generateSchemaExtensions = generateSchemaExtensions;
|
|
38
45
|
function generateCustomMappingTypes(options) {
|
|
46
|
+
var _a, _b;
|
|
39
47
|
const productMappings = Object.entries(options.customProductMappings || {});
|
|
40
48
|
const variantMappings = Object.entries(options.customProductVariantMappings || {});
|
|
49
|
+
const searchInputTypeExtensions = Object.entries(options.extendSearchInputType || {});
|
|
50
|
+
const scriptProductFields = Object.entries(((_a = options.searchConfig) === null || _a === void 0 ? void 0 : _a.scriptFields) || {}).filter(([, scriptField]) => scriptField.context !== 'variant');
|
|
51
|
+
const scriptVariantFields = Object.entries(((_b = options.searchConfig) === null || _b === void 0 ? void 0 : _b.scriptFields) || {}).filter(([, scriptField]) => scriptField.context !== 'product');
|
|
52
|
+
let sdl = ``;
|
|
53
|
+
if (scriptProductFields.length || scriptVariantFields.length) {
|
|
54
|
+
if (scriptProductFields.length) {
|
|
55
|
+
sdl += `
|
|
56
|
+
type CustomProductScriptFields {
|
|
57
|
+
${scriptProductFields.map(([name, def]) => `${name}: ${def.graphQlType}`)}
|
|
58
|
+
}
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
if (scriptVariantFields.length) {
|
|
62
|
+
sdl += `
|
|
63
|
+
type CustomProductVariantScriptFields {
|
|
64
|
+
${scriptVariantFields.map(([name, def]) => `${name}: ${def.graphQlType}`)}
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
}
|
|
68
|
+
if (scriptProductFields.length && scriptVariantFields.length) {
|
|
69
|
+
sdl += `
|
|
70
|
+
union CustomScriptFields = CustomProductScriptFields | CustomProductVariantScriptFields
|
|
71
|
+
|
|
72
|
+
extend type SearchResult {
|
|
73
|
+
customScriptFields: CustomScriptFields!
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
else if (scriptProductFields.length) {
|
|
78
|
+
sdl += `
|
|
79
|
+
extend type SearchResult {
|
|
80
|
+
customScriptFields: CustomProductScriptFields!
|
|
81
|
+
}
|
|
82
|
+
`;
|
|
83
|
+
}
|
|
84
|
+
else if (scriptVariantFields.length) {
|
|
85
|
+
sdl += `
|
|
86
|
+
extend type SearchResult {
|
|
87
|
+
customScriptFields: CustomProductVariantScriptFields!
|
|
88
|
+
}
|
|
89
|
+
`;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
41
92
|
if (productMappings.length || variantMappings.length) {
|
|
42
|
-
let sdl = ``;
|
|
43
93
|
if (productMappings.length) {
|
|
44
|
-
sdl += `
|
|
45
|
-
type CustomProductMappings {
|
|
46
|
-
${productMappings.map(([name, def]) => `${name}: ${def.graphQlType}`)}
|
|
47
|
-
}
|
|
94
|
+
sdl += `
|
|
95
|
+
type CustomProductMappings {
|
|
96
|
+
${productMappings.map(([name, def]) => `${name}: ${def.graphQlType}`)}
|
|
97
|
+
}
|
|
48
98
|
`;
|
|
49
99
|
}
|
|
50
100
|
if (variantMappings.length) {
|
|
51
|
-
sdl += `
|
|
52
|
-
type CustomProductVariantMappings {
|
|
53
|
-
${variantMappings.map(([name, def]) => `${name}: ${def.graphQlType}`)}
|
|
54
|
-
}
|
|
101
|
+
sdl += `
|
|
102
|
+
type CustomProductVariantMappings {
|
|
103
|
+
${variantMappings.map(([name, def]) => `${name}: ${def.graphQlType}`)}
|
|
104
|
+
}
|
|
55
105
|
`;
|
|
56
106
|
}
|
|
57
107
|
if (productMappings.length && variantMappings.length) {
|
|
58
|
-
sdl += `
|
|
59
|
-
union CustomMappings = CustomProductMappings | CustomProductVariantMappings
|
|
60
|
-
|
|
61
|
-
extend type SearchResult {
|
|
62
|
-
customMappings: CustomMappings!
|
|
63
|
-
}
|
|
108
|
+
sdl += `
|
|
109
|
+
union CustomMappings = CustomProductMappings | CustomProductVariantMappings
|
|
110
|
+
|
|
111
|
+
extend type SearchResult {
|
|
112
|
+
customMappings: CustomMappings!
|
|
113
|
+
}
|
|
64
114
|
`;
|
|
65
115
|
}
|
|
66
116
|
else if (productMappings.length) {
|
|
67
|
-
sdl += `
|
|
68
|
-
extend type SearchResult {
|
|
69
|
-
customMappings: CustomProductMappings!
|
|
70
|
-
}
|
|
117
|
+
sdl += `
|
|
118
|
+
extend type SearchResult {
|
|
119
|
+
customMappings: CustomProductMappings!
|
|
120
|
+
}
|
|
71
121
|
`;
|
|
72
122
|
}
|
|
73
123
|
else if (variantMappings.length) {
|
|
74
|
-
sdl += `
|
|
75
|
-
extend type SearchResult {
|
|
76
|
-
customMappings: CustomProductVariantMappings!
|
|
77
|
-
}
|
|
124
|
+
sdl += `
|
|
125
|
+
extend type SearchResult {
|
|
126
|
+
customMappings: CustomProductVariantMappings!
|
|
127
|
+
}
|
|
78
128
|
`;
|
|
79
129
|
}
|
|
80
|
-
return apollo_server_core_1.gql `
|
|
81
|
-
${sdl}
|
|
82
|
-
`;
|
|
83
130
|
}
|
|
84
|
-
return
|
|
131
|
+
return sdl.length
|
|
132
|
+
? apollo_server_core_1.gql `
|
|
133
|
+
${sdl}
|
|
134
|
+
`
|
|
135
|
+
: undefined;
|
|
85
136
|
}
|
|
86
|
-
//# sourceMappingURL=
|
|
137
|
+
//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C;SACL;QACD,IAAI,eAAe,CAAC,MAAM,EAAE;YACxB,GAAG,IAAI;;kBAED,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,GAAG,IAAI,KAAK,GAAG,CAAC,WAAW,EAAE,CAAC;;aAExE,CAAC;SACL;QACD,IAAI,eAAe,CAAC,MAAM,IAAI,eAAe,CAAC,MAAM,EAAE;YAClD,GAAG,IAAI;;;;;;aAMN,CAAC;SACL;aAAM,IAAI,eAAe,CAAC,MAAM,EAAE;YAC/B,GAAG,IAAI;;;;aAIN,CAAC;SACL;aAAM,IAAI,eAAe,CAAC,MAAM,EAAE;YAC/B,GAAG,IAAI;;;;aAIN,CAAC;SACL;KACJ;IACD,OAAO,GAAG,CAAC,MAAM;QACb,CAAC,CAAC,wBAAG,CAAA;gBACG,GAAG;WACR;QACH,CAAC,CAAC,SAAS,CAAC;AACpB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DeepRequired } from '@vendure/common/lib/shared-types';
|
|
2
|
-
import { ElasticsearchOptions } from '
|
|
2
|
+
import { ElasticsearchOptions } from '../options';
|
|
3
3
|
/**
|
|
4
4
|
* This resolver is only required if both customProductMappings and customProductVariantMappings are
|
|
5
5
|
* defined, since this particular configuration will result in a union type for the
|
|
@@ -15,7 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.CustomMappingsResolver = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const graphql_1 = require("@nestjs/graphql");
|
|
18
|
-
const constants_1 = require("
|
|
18
|
+
const constants_1 = require("../constants");
|
|
19
19
|
/**
|
|
20
20
|
* This resolver is only required if both customProductMappings and customProductVariantMappings are
|
|
21
21
|
* defined, since this particular configuration will result in a union type for the
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-mappings.resolver.js","sourceRoot":"","sources":["../../../src/api/custom-mappings.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,6CAAyD;AAGzD,4CAAsD;AAGtD;;;;GAIG;AAEH,IAAa,sBAAsB,GAAnC,MAAa,sBAAsB;IAC/B,YAAoD,OAA2C;QAA3C,YAAO,GAAP,OAAO,CAAoC;IAAG,CAAC;IAGnG,aAAa,CAAC,KAAU;QACpB,MAAM,oBAAoB,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;QAC7E,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAClE,CAAC,CAAC,uBAAuB;YACzB,CAAC,CAAC,8BAA8B,CAAC;IACzC,CAAC;CACJ,CAAA;AANG;IADC,sBAAY,EAAE;;;;2DAMd;AATQ,sBAAsB;IADlC,kBAAQ,CAAC,gBAAgB,CAAC;IAEV,WAAA,eAAM,CAAC,kCAAsB,CAAC,CAAA;;GADlC,sBAAsB,CAUlC;AAVY,wDAAsB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DeepRequired } from '@vendure/common/lib/shared-types';
|
|
2
|
+
import { ElasticsearchOptions } from '../options';
|
|
3
|
+
/**
|
|
4
|
+
* This resolver is only required if scriptFields are defined for both products and product variants.
|
|
5
|
+
* This particular configuration will result in a union type for the
|
|
6
|
+
* `SearchResult.customScriptFields` GraphQL field.
|
|
7
|
+
*/
|
|
8
|
+
export declare class CustomScriptFieldsResolver {
|
|
9
|
+
private options;
|
|
10
|
+
constructor(options: DeepRequired<ElasticsearchOptions>);
|
|
11
|
+
__resolveType(value: any): string;
|
|
12
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.CustomScriptFieldsResolver = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
18
|
+
const constants_1 = require("../constants");
|
|
19
|
+
/**
|
|
20
|
+
* This resolver is only required if scriptFields are defined for both products and product variants.
|
|
21
|
+
* This particular configuration will result in a union type for the
|
|
22
|
+
* `SearchResult.customScriptFields` GraphQL field.
|
|
23
|
+
*/
|
|
24
|
+
let CustomScriptFieldsResolver = class CustomScriptFieldsResolver {
|
|
25
|
+
constructor(options) {
|
|
26
|
+
this.options = options;
|
|
27
|
+
}
|
|
28
|
+
__resolveType(value) {
|
|
29
|
+
var _a;
|
|
30
|
+
const productScriptFields = Object.entries(((_a = this.options.searchConfig) === null || _a === void 0 ? void 0 : _a.scriptFields) || {})
|
|
31
|
+
.filter(([, scriptField]) => scriptField.context !== 'variant')
|
|
32
|
+
.map(([k]) => k);
|
|
33
|
+
return Object.keys(value).every(k => productScriptFields.includes(k))
|
|
34
|
+
? 'CustomProductScriptFields'
|
|
35
|
+
: 'CustomProductVariantScriptFields';
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
__decorate([
|
|
39
|
+
graphql_1.ResolveField(),
|
|
40
|
+
__metadata("design:type", Function),
|
|
41
|
+
__metadata("design:paramtypes", [Object]),
|
|
42
|
+
__metadata("design:returntype", String)
|
|
43
|
+
], CustomScriptFieldsResolver.prototype, "__resolveType", null);
|
|
44
|
+
CustomScriptFieldsResolver = __decorate([
|
|
45
|
+
graphql_1.Resolver('CustomScriptFields'),
|
|
46
|
+
__param(0, common_1.Inject(constants_1.ELASTIC_SEARCH_OPTIONS)),
|
|
47
|
+
__metadata("design:paramtypes", [Object])
|
|
48
|
+
], CustomScriptFieldsResolver);
|
|
49
|
+
exports.CustomScriptFieldsResolver = CustomScriptFieldsResolver;
|
|
50
|
+
//# sourceMappingURL=custom-script-fields.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-script-fields.resolver.js","sourceRoot":"","sources":["../../../src/api/custom-script-fields.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,6CAAyD;AAGzD,4CAAsD;AAGtD;;;;GAIG;AAEH,IAAa,0BAA0B,GAAvC,MAAa,0BAA0B;IACnC,YAAoD,OAA2C;QAA3C,YAAO,GAAP,OAAO,CAAoC;IAAG,CAAC;IAGnG,aAAa,CAAC,KAAU;;QACpB,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,CAAC,CAAA,MAAA,IAAI,CAAC,OAAO,CAAC,YAAY,0CAAE,YAAY,KAAI,EAAE,CAAC;aACpF,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,KAAK,SAAS,CAAC;aAC9D,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QACrB,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YACjE,CAAC,CAAC,2BAA2B;YAC7B,CAAC,CAAC,kCAAkC,CAAC;IAC7C,CAAC;CACJ,CAAA;AARG;IADC,sBAAY,EAAE;;;;+DAQd;AAXQ,0BAA0B;IADtC,kBAAQ,CAAC,oBAAoB,CAAC;IAEd,WAAA,eAAM,CAAC,kCAAsB,CAAC,CAAA;;GADlC,0BAA0B,CAYtC;AAZY,gEAA0B"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Job as GraphQLJob, QuerySearchArgs, SearchResponse } from '@vendure/common/lib/generated-types';
|
|
2
2
|
import { Omit } from '@vendure/common/lib/omit';
|
|
3
|
-
import { Collection, FacetValue, RequestContext, SearchResolver } from '@vendure/core';
|
|
4
|
-
import { ElasticsearchService } from '
|
|
5
|
-
import { ElasticSearchInput, SearchPriceData } from '
|
|
6
|
-
export declare class ShopElasticSearchResolver implements
|
|
3
|
+
import { Collection, FacetValue, RequestContext, SearchJobBufferService, SearchResolver } from '@vendure/core';
|
|
4
|
+
import { ElasticsearchService } from '../elasticsearch.service';
|
|
5
|
+
import { ElasticSearchInput, SearchPriceData } from '../types';
|
|
6
|
+
export declare class ShopElasticSearchResolver implements Pick<SearchResolver, 'search'> {
|
|
7
7
|
private elasticsearchService;
|
|
8
8
|
constructor(elasticsearchService: ElasticsearchService);
|
|
9
9
|
search(ctx: RequestContext, args: QuerySearchArgs): Promise<Omit<SearchResponse, 'facetValues' | 'collections'>>;
|
|
@@ -11,11 +11,14 @@ export declare class ShopElasticSearchResolver implements Omit<SearchResolver, '
|
|
|
11
11
|
input: ElasticSearchInput;
|
|
12
12
|
}): Promise<SearchPriceData>;
|
|
13
13
|
}
|
|
14
|
-
export declare class AdminElasticSearchResolver implements
|
|
14
|
+
export declare class AdminElasticSearchResolver implements Pick<SearchResolver, 'search' | 'reindex'> {
|
|
15
15
|
private elasticsearchService;
|
|
16
|
-
|
|
16
|
+
private searchJobBufferService;
|
|
17
|
+
constructor(elasticsearchService: ElasticsearchService, searchJobBufferService: SearchJobBufferService);
|
|
17
18
|
search(ctx: RequestContext, args: QuerySearchArgs): Promise<Omit<SearchResponse, 'facetValues' | 'collections'>>;
|
|
18
19
|
reindex(ctx: RequestContext): Promise<GraphQLJob>;
|
|
20
|
+
pendingSearchIndexUpdates(...args: any[]): Promise<any>;
|
|
21
|
+
runPendingSearchIndexUpdates(...args: any[]): Promise<any>;
|
|
19
22
|
}
|
|
20
23
|
export declare class EntityElasticSearchResolver implements Pick<SearchResolver, 'facetValues' | 'collections'> {
|
|
21
24
|
private elasticsearchService;
|
|
@@ -16,7 +16,7 @@ exports.EntityElasticSearchResolver = exports.AdminElasticSearchResolver = expor
|
|
|
16
16
|
const graphql_1 = require("@nestjs/graphql");
|
|
17
17
|
const generated_types_1 = require("@vendure/common/lib/generated-types");
|
|
18
18
|
const core_1 = require("@vendure/core");
|
|
19
|
-
const elasticsearch_service_1 = require("
|
|
19
|
+
const elasticsearch_service_1 = require("../elasticsearch.service");
|
|
20
20
|
let ShopElasticSearchResolver = class ShopElasticSearchResolver {
|
|
21
21
|
constructor(elasticsearchService) {
|
|
22
22
|
this.elasticsearchService = elasticsearchService;
|
|
@@ -54,8 +54,9 @@ ShopElasticSearchResolver = __decorate([
|
|
|
54
54
|
], ShopElasticSearchResolver);
|
|
55
55
|
exports.ShopElasticSearchResolver = ShopElasticSearchResolver;
|
|
56
56
|
let AdminElasticSearchResolver = class AdminElasticSearchResolver {
|
|
57
|
-
constructor(elasticsearchService) {
|
|
57
|
+
constructor(elasticsearchService, searchJobBufferService) {
|
|
58
58
|
this.elasticsearchService = elasticsearchService;
|
|
59
|
+
this.searchJobBufferService = searchJobBufferService;
|
|
59
60
|
}
|
|
60
61
|
async search(ctx, args) {
|
|
61
62
|
const result = await this.elasticsearchService.search(ctx, args.input, false);
|
|
@@ -66,6 +67,14 @@ let AdminElasticSearchResolver = class AdminElasticSearchResolver {
|
|
|
66
67
|
async reindex(ctx) {
|
|
67
68
|
return this.elasticsearchService.reindex(ctx);
|
|
68
69
|
}
|
|
70
|
+
async pendingSearchIndexUpdates(...args) {
|
|
71
|
+
return this.searchJobBufferService.getPendingSearchUpdates();
|
|
72
|
+
}
|
|
73
|
+
async runPendingSearchIndexUpdates(...args) {
|
|
74
|
+
// Intentionally not awaiting this method call
|
|
75
|
+
this.searchJobBufferService.runPendingSearchUpdates();
|
|
76
|
+
return { success: true };
|
|
77
|
+
}
|
|
69
78
|
};
|
|
70
79
|
__decorate([
|
|
71
80
|
graphql_1.Query(),
|
|
@@ -84,9 +93,24 @@ __decorate([
|
|
|
84
93
|
__metadata("design:paramtypes", [core_1.RequestContext]),
|
|
85
94
|
__metadata("design:returntype", Promise)
|
|
86
95
|
], AdminElasticSearchResolver.prototype, "reindex", null);
|
|
96
|
+
__decorate([
|
|
97
|
+
graphql_1.Query(),
|
|
98
|
+
core_1.Allow(generated_types_1.Permission.UpdateCatalog, generated_types_1.Permission.UpdateProduct),
|
|
99
|
+
__metadata("design:type", Function),
|
|
100
|
+
__metadata("design:paramtypes", [Object]),
|
|
101
|
+
__metadata("design:returntype", Promise)
|
|
102
|
+
], AdminElasticSearchResolver.prototype, "pendingSearchIndexUpdates", null);
|
|
103
|
+
__decorate([
|
|
104
|
+
graphql_1.Mutation(),
|
|
105
|
+
core_1.Allow(generated_types_1.Permission.UpdateCatalog, generated_types_1.Permission.UpdateProduct),
|
|
106
|
+
__metadata("design:type", Function),
|
|
107
|
+
__metadata("design:paramtypes", [Object]),
|
|
108
|
+
__metadata("design:returntype", Promise)
|
|
109
|
+
], AdminElasticSearchResolver.prototype, "runPendingSearchIndexUpdates", null);
|
|
87
110
|
AdminElasticSearchResolver = __decorate([
|
|
88
111
|
graphql_1.Resolver('SearchResponse'),
|
|
89
|
-
__metadata("design:paramtypes", [elasticsearch_service_1.ElasticsearchService
|
|
112
|
+
__metadata("design:paramtypes", [elasticsearch_service_1.ElasticsearchService,
|
|
113
|
+
core_1.SearchJobBufferService])
|
|
90
114
|
], AdminElasticSearchResolver);
|
|
91
115
|
exports.AdminElasticSearchResolver = AdminElasticSearchResolver;
|
|
92
116
|
let EntityElasticSearchResolver = class EntityElasticSearchResolver {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elasticsearch-resolver.js","sourceRoot":"","sources":["../../../src/api/elasticsearch-resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAwF;AACxF,yEAK6C;AAE7C,wCAQuB;AAEvB,oEAAgE;AAIhE,IAAa,yBAAyB,GAAtC,MAAa,yBAAyB;IAClC,YAAoB,oBAA0C;QAA1C,yBAAoB,GAApB,oBAAoB,CAAsB;IAAG,CAAC;IAIlE,KAAK,CAAC,MAAM,CACD,GAAmB,EAClB,IAAqB;QAE7B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC7E,wEAAwE;QACvE,MAAc,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACnC,OAAO,MAAM,CAAC;IAClB,CAAC;IAGD,KAAK,CAAC,MAAM,CACD,GAAmB,EAChB,MAAqC;QAE/C,OAAO,IAAI,CAAC,oBAAoB,CAAC,UAAU,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IACnE,CAAC;CACJ,CAAA;AAjBG;IAFC,eAAK,EAAE;IACP,YAAK,CAAC,4BAAU,CAAC,MAAM,CAAC;IAEpB,WAAA,UAAG,EAAE,CAAA;IACL,WAAA,cAAI,EAAE,CAAA;;qCADK,qBAAc;;uDAO7B;AAGD;IADC,sBAAY,EAAE;IAEV,WAAA,UAAG,EAAE,CAAA;IACL,WAAA,gBAAM,EAAE,CAAA;;qCADG,qBAAc;;uDAI7B;AArBQ,yBAAyB;IADrC,kBAAQ,CAAC,gBAAgB,CAAC;qCAEmB,4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AAA,gBAAM,EAAE,CAAA;;qCADG,qBAAc;;8DAK7B;AAnBQ,2BAA2B;IADvC,kBAAQ,CAAC,gBAAgB,CAAC;qCAEmB,4CAAoB;GADrD,2BAA2B,CAoBvC;AApBY,kEAA2B"}
|
|
@@ -7,7 +7,7 @@ const core_1 = require("@vendure/core");
|
|
|
7
7
|
* Given a SearchInput object, returns the corresponding Elasticsearch body.
|
|
8
8
|
*/
|
|
9
9
|
function buildElasticBody(input, searchConfig, channelId, languageCode, enabledOnly = false) {
|
|
10
|
-
const { term, facetValueIds, facetValueOperator, collectionId, collectionSlug, groupByProduct, skip, take, sort, priceRangeWithTax, priceRange, facetValueFilters, } = input;
|
|
10
|
+
const { term, facetValueIds, facetValueOperator, collectionId, collectionSlug, groupByProduct, skip, take, sort, priceRangeWithTax, priceRange, facetValueFilters, inStock, } = input;
|
|
11
11
|
const query = {
|
|
12
12
|
bool: {},
|
|
13
13
|
};
|
|
@@ -69,11 +69,20 @@ function buildElasticBody(input, searchConfig, channelId, languageCode, enabledO
|
|
|
69
69
|
}
|
|
70
70
|
if (priceRange) {
|
|
71
71
|
ensureBoolFilterExists(query);
|
|
72
|
-
query.bool.filter = query.bool.filter.concat(createPriceFilters(priceRange, false
|
|
72
|
+
query.bool.filter = query.bool.filter.concat(createPriceFilters(priceRange, false));
|
|
73
73
|
}
|
|
74
74
|
if (priceRangeWithTax) {
|
|
75
75
|
ensureBoolFilterExists(query);
|
|
76
|
-
query.bool.filter = query.bool.filter.concat(createPriceFilters(priceRangeWithTax, true
|
|
76
|
+
query.bool.filter = query.bool.filter.concat(createPriceFilters(priceRangeWithTax, true));
|
|
77
|
+
}
|
|
78
|
+
if (inStock !== undefined) {
|
|
79
|
+
ensureBoolFilterExists(query);
|
|
80
|
+
if (groupByProduct) {
|
|
81
|
+
query.bool.filter.push({ term: { productInStock: inStock } });
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
query.bool.filter.push({ term: { inStock } });
|
|
85
|
+
}
|
|
77
86
|
}
|
|
78
87
|
const sortArray = [];
|
|
79
88
|
if (sort) {
|
|
@@ -83,19 +92,23 @@ function buildElasticBody(input, searchConfig, channelId, languageCode, enabledO
|
|
|
83
92
|
});
|
|
84
93
|
}
|
|
85
94
|
if (sort.price) {
|
|
86
|
-
const priceField =
|
|
95
|
+
const priceField = 'price';
|
|
87
96
|
sortArray.push({ [priceField]: { order: sort.price === generated_types_1.SortOrder.ASC ? 'asc' : 'desc' } });
|
|
88
97
|
}
|
|
89
98
|
}
|
|
90
|
-
|
|
91
|
-
|
|
99
|
+
const scriptFields = createScriptFields(searchConfig.scriptFields, input, groupByProduct);
|
|
100
|
+
const body = Object.assign({ query: searchConfig.mapQuery
|
|
92
101
|
? searchConfig.mapQuery(query, input, searchConfig, channelId, enabledOnly)
|
|
93
|
-
: query,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
: query, sort: sortArray, from: skip || 0, size: take || 10, track_total_hits: searchConfig.totalItemsMaxSize }, (scriptFields !== undefined
|
|
103
|
+
? {
|
|
104
|
+
_source: true,
|
|
105
|
+
script_fields: scriptFields,
|
|
106
|
+
}
|
|
107
|
+
: undefined));
|
|
108
|
+
if (groupByProduct) {
|
|
109
|
+
body.collapse = { field: `productId` };
|
|
110
|
+
}
|
|
111
|
+
return body;
|
|
99
112
|
}
|
|
100
113
|
exports.buildElasticBody = buildElasticBody;
|
|
101
114
|
function ensureBoolFilterExists(query) {
|
|
@@ -103,37 +116,39 @@ function ensureBoolFilterExists(query) {
|
|
|
103
116
|
query.bool.filter = [];
|
|
104
117
|
}
|
|
105
118
|
}
|
|
106
|
-
function
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
{
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
function createScriptFields(scriptFields, input, groupByProduct) {
|
|
120
|
+
if (scriptFields) {
|
|
121
|
+
const fields = Object.keys(scriptFields);
|
|
122
|
+
if (fields.length) {
|
|
123
|
+
const result = {};
|
|
124
|
+
for (const name of fields) {
|
|
125
|
+
const scriptField = scriptFields[name];
|
|
126
|
+
if (scriptField.context === 'product' && groupByProduct === true) {
|
|
127
|
+
result[name] = scriptField.scriptFn(input);
|
|
128
|
+
}
|
|
129
|
+
if (scriptField.context === 'variant' && groupByProduct === false) {
|
|
130
|
+
result[name] = scriptField.scriptFn(input);
|
|
131
|
+
}
|
|
132
|
+
if (scriptField.context === 'both' || scriptField.context === undefined) {
|
|
133
|
+
result[name] = scriptField.scriptFn(input);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
}
|
|
125
138
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
139
|
+
return undefined;
|
|
140
|
+
}
|
|
141
|
+
function createPriceFilters(range, withTax) {
|
|
142
|
+
const withTaxFix = withTax ? 'WithTax' : '';
|
|
143
|
+
return [
|
|
144
|
+
{
|
|
145
|
+
range: {
|
|
146
|
+
['price' + withTaxFix]: {
|
|
147
|
+
gte: range.min,
|
|
148
|
+
lte: range.max,
|
|
134
149
|
},
|
|
135
150
|
},
|
|
136
|
-
|
|
137
|
-
|
|
151
|
+
},
|
|
152
|
+
];
|
|
138
153
|
}
|
|
139
154
|
//# sourceMappingURL=build-elastic-body.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-elastic-body.js","sourceRoot":"","sources":["../../src/build-elastic-body.ts"],"names":[],"mappings":";;;AAAA,yEAA2G;AAC3G,wCAAiE;AAKjE;;GAEG;AACH,SAAgB,gBAAgB,CAC5B,KAAyB,EACzB,YAAwC,EACxC,SAAa,EACb,YAA0B,EAC1B,cAAuB,KAAK;IAE5B,MAAM,EACF,IAAI,EACJ,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,iBAAiB,EACjB,UAAU,EACV,iBAAiB,
|
|
1
|
+
{"version":3,"file":"build-elastic-body.js","sourceRoot":"","sources":["../../src/build-elastic-body.ts"],"names":[],"mappings":";;;AAAA,yEAA2G;AAC3G,wCAAiE;AAKjE;;GAEG;AACH,SAAgB,gBAAgB,CAC5B,KAAyB,EACzB,YAAwC,EACxC,SAAa,EACb,YAA0B,EAC1B,cAAuB,KAAK;IAE5B,MAAM,EACF,IAAI,EACJ,aAAa,EACb,kBAAkB,EAClB,YAAY,EACZ,cAAc,EACd,cAAc,EACd,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,OAAO,GACV,GAAG,KAAK,CAAC;IACV,MAAM,KAAK,GAAQ;QACf,IAAI,EAAE,EAAE;KACX,CAAC;IACF,sBAAsB,CAAC,KAAK,CAAC,CAAC;IAC9B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IAChD,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,YAAY,EAAE,EAAE,CAAC,CAAC;IAEnD,IAAI,IAAI,EAAE;QACN,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG;YACd;gBACI,WAAW,EAAE;oBACT,KAAK,EAAE,IAAI;oBACX,IAAI,EAAE,YAAY,CAAC,cAAc;oBACjC,MAAM,EAAE;wBACJ,eAAe,YAAY,CAAC,WAAW,CAAC,WAAW,EAAE;wBACrD,sBAAsB,YAAY,CAAC,WAAW,CAAC,kBAAkB,EAAE;wBACnE,eAAe,YAAY,CAAC,WAAW,CAAC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OAAO,KAAK,SAAS,EAAE;oBACpE,MAAc,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;iBACvD;aACJ;YACD,OAAO,MAAM,CAAC;SACjB;KACJ;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAiB,EAAE,OAAgB;IAC3D,MAAM,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5C,OAAO;QACH;YACI,KAAK,EAAE;gBACH,CAAC,OAAO,GAAG,UAAU,CAAC,EAAE;oBACpB,GAAG,EAAE,KAAK,CAAC,GAAG;oBACd,GAAG,EAAE,KAAK,CAAC,GAAG;iBACjB;aACJ;SACJ;KACJ,CAAC;AACN,CAAC"}
|
package/lib/src/constants.d.ts
CHANGED
package/lib/src/constants.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loggerCtx = exports.
|
|
3
|
+
exports.loggerCtx = exports.VARIANT_INDEX_NAME = exports.ELASTIC_SEARCH_OPTIONS = void 0;
|
|
4
4
|
exports.ELASTIC_SEARCH_OPTIONS = Symbol('ELASTIC_SEARCH_OPTIONS');
|
|
5
5
|
exports.VARIANT_INDEX_NAME = 'variants';
|
|
6
|
-
exports.PRODUCT_INDEX_NAME = 'products';
|
|
7
6
|
exports.loggerCtx = 'ElasticsearchPlugin';
|
|
8
7
|
//# sourceMappingURL=constants.js.map
|
package/lib/src/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAC1D,QAAA,kBAAkB,GAAG,UAAU,CAAC;AAChC,QAAA,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,sBAAsB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAC1D,QAAA,kBAAkB,GAAG,UAAU,CAAC;AAChC,QAAA,SAAS,GAAG,qBAAqB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
|
|
2
2
|
import { Collection, CollectionService, ConfigService, DeepRequired, FacetValue, FacetValueService, Job, RequestContext, SearchService } from '@vendure/core';
|
|
3
|
-
import { ElasticsearchIndexService } from './elasticsearch-index.service';
|
|
3
|
+
import { ElasticsearchIndexService } from './indexing/elasticsearch-index.service';
|
|
4
4
|
import { ElasticsearchOptions } from './options';
|
|
5
5
|
import { ElasticSearchInput, ElasticSearchResponse, SearchPriceData } from './types';
|
|
6
6
|
export declare class ElasticsearchService implements OnModuleInit, OnModuleDestroy {
|
|
@@ -20,6 +20,7 @@ export declare class ElasticsearchService implements OnModuleInit, OnModuleDestr
|
|
|
20
20
|
* Perform a fulltext search according to the provided input arguments.
|
|
21
21
|
*/
|
|
22
22
|
search(ctx: RequestContext, input: ElasticSearchInput, enabledOnly?: boolean): Promise<Omit<ElasticSearchResponse, 'facetValues' | 'collections' | 'priceRange'>>;
|
|
23
|
+
totalHits(ctx: RequestContext, input: ElasticSearchInput, enabledOnly?: boolean): Promise<number>;
|
|
23
24
|
/**
|
|
24
25
|
* Return a list of all FacetValues which appear in the result set.
|
|
25
26
|
*/
|
|
@@ -34,6 +35,13 @@ export declare class ElasticsearchService implements OnModuleInit, OnModuleDestr
|
|
|
34
35
|
collection: Collection;
|
|
35
36
|
count: number;
|
|
36
37
|
}>>;
|
|
38
|
+
getDistinctBucketsOfField(ctx: RequestContext, input: ElasticSearchInput, enabledOnly: boolean | undefined, field: string, aggregation_max_size: number): Promise<Array<{
|
|
39
|
+
key: string;
|
|
40
|
+
doc_count: number;
|
|
41
|
+
total: {
|
|
42
|
+
value: number;
|
|
43
|
+
};
|
|
44
|
+
}>>;
|
|
37
45
|
priceRange(ctx: RequestContext, input: ElasticSearchInput): Promise<SearchPriceData>;
|
|
38
46
|
/**
|
|
39
47
|
* Rebuilds the full search index.
|
|
@@ -42,5 +50,6 @@ export declare class ElasticsearchService implements OnModuleInit, OnModuleDestr
|
|
|
42
50
|
private mapVariantToSearchResult;
|
|
43
51
|
private mapProductToSearchResult;
|
|
44
52
|
private getSearchResultAssets;
|
|
45
|
-
private addCustomMappings;
|
|
53
|
+
private static addCustomMappings;
|
|
54
|
+
private static addScriptMappings;
|
|
46
55
|
}
|