@vendure/elasticsearch-plugin 2.0.0-next.8 → 2.0.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/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/src/api/api-extensions.js +12 -8
- package/lib/src/api/api-extensions.js.map +1 -1
- package/lib/src/api/custom-mappings.resolver.js.map +1 -1
- package/lib/src/api/custom-script-fields.resolver.js.map +1 -1
- package/lib/src/api/elasticsearch-resolver.js +1 -1
- package/lib/src/api/elasticsearch-resolver.js.map +1 -1
- package/lib/src/build-elastic-body.js +4 -4
- package/lib/src/build-elastic-body.js.map +1 -1
- package/lib/src/elasticsearch.health.js.map +1 -1
- package/lib/src/elasticsearch.service.js +39 -25
- package/lib/src/elasticsearch.service.js.map +1 -1
- package/lib/src/indexing/elasticsearch-index.service.d.ts +11 -11
- package/lib/src/indexing/elasticsearch-index.service.js +20 -12
- package/lib/src/indexing/elasticsearch-index.service.js.map +1 -1
- package/lib/src/indexing/indexer.controller.d.ts +2 -2
- package/lib/src/indexing/indexer.controller.js +96 -70
- package/lib/src/indexing/indexer.controller.js.map +1 -1
- package/lib/src/indexing/indexing-utils.js +1 -1
- package/lib/src/indexing/mutable-request-context.js.map +1 -1
- package/lib/src/options.d.ts +17 -8
- package/lib/src/options.js.map +1 -1
- package/lib/src/plugin.d.ts +3 -2
- package/lib/src/plugin.js +4 -2
- package/lib/src/plugin.js.map +1 -1
- package/lib/src/types.d.ts +47 -47
- package/package.json +33 -32
package/lib/src/types.d.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { Coordinate, CurrencyCode, LanguageCode, PriceRange, SearchInput, SearchResponse, SearchResult } from '@vendure/common/lib/generated-types';
|
|
2
2
|
import { ID, JsonCompatible } from '@vendure/common/lib/shared-types';
|
|
3
3
|
import { Asset, SerializedRequestContext } from '@vendure/core';
|
|
4
|
-
export
|
|
4
|
+
export type ElasticSearchResult = SearchResult & {
|
|
5
5
|
inStock: boolean;
|
|
6
6
|
};
|
|
7
|
-
export
|
|
7
|
+
export type ElasticSearchInput = SearchInput & {
|
|
8
8
|
priceRange?: PriceRange;
|
|
9
9
|
priceRangeWithTax?: PriceRange;
|
|
10
10
|
inStock?: boolean;
|
|
11
11
|
[extendedInputField: string]: any;
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export type ElasticSearchResponse = SearchResponse & {
|
|
14
14
|
priceRange: SearchPriceData;
|
|
15
15
|
items: ElasticSearchResult[];
|
|
16
16
|
};
|
|
17
|
-
export
|
|
17
|
+
export type SearchPriceData = {
|
|
18
18
|
range: PriceRange;
|
|
19
19
|
rangeWithTax: PriceRange;
|
|
20
20
|
buckets: PriceRangeBucket[];
|
|
21
21
|
bucketsWithTax: PriceRangeBucket[];
|
|
22
22
|
};
|
|
23
|
-
export
|
|
23
|
+
export type PriceRangeBucket = {
|
|
24
24
|
to: number;
|
|
25
25
|
count: number;
|
|
26
26
|
};
|
|
@@ -36,17 +36,17 @@ export declare enum ElasticSearchSortMode {
|
|
|
36
36
|
/** Use the median of all values as sort value. Only applicable for number based array fields */
|
|
37
37
|
MEDIAN = "median"
|
|
38
38
|
}
|
|
39
|
-
export
|
|
39
|
+
export type ElasticSearchSortParameter = {
|
|
40
40
|
missing?: '_last' | '_first' | string;
|
|
41
41
|
mode?: ElasticSearchSortMode;
|
|
42
42
|
order: 'asc' | 'desc';
|
|
43
43
|
} & {
|
|
44
44
|
[key: string]: any;
|
|
45
45
|
};
|
|
46
|
-
export
|
|
46
|
+
export type ElasticSearchSortInput = Array<{
|
|
47
47
|
[key: string]: ElasticSearchSortParameter;
|
|
48
48
|
}>;
|
|
49
|
-
export
|
|
49
|
+
export type IndexItemAssets = {
|
|
50
50
|
productAssetId: ID | undefined;
|
|
51
51
|
productPreview: string;
|
|
52
52
|
productPreviewFocalPoint: Coordinate | undefined;
|
|
@@ -54,7 +54,7 @@ export declare type IndexItemAssets = {
|
|
|
54
54
|
productVariantPreview: string;
|
|
55
55
|
productVariantPreviewFocalPoint: Coordinate | undefined;
|
|
56
56
|
};
|
|
57
|
-
export
|
|
57
|
+
export type VariantIndexItem = Omit<SearchResult, 'score' | 'price' | 'priceWithTax' | 'productAsset' | 'productVariantAsset'> & IndexItemAssets & {
|
|
58
58
|
channelId: ID;
|
|
59
59
|
languageCode: LanguageCode;
|
|
60
60
|
price: number;
|
|
@@ -74,7 +74,7 @@ export declare type VariantIndexItem = Omit<SearchResult, 'score' | 'price' | 'p
|
|
|
74
74
|
inStock: boolean;
|
|
75
75
|
productInStock: boolean;
|
|
76
76
|
};
|
|
77
|
-
export
|
|
77
|
+
export type ProductIndexItem = IndexItemAssets & {
|
|
78
78
|
sku: string;
|
|
79
79
|
slug: string;
|
|
80
80
|
productId: ID;
|
|
@@ -98,7 +98,7 @@ export declare type ProductIndexItem = IndexItemAssets & {
|
|
|
98
98
|
priceWithTaxMax: number;
|
|
99
99
|
[customMapping: string]: any;
|
|
100
100
|
};
|
|
101
|
-
export
|
|
101
|
+
export type SearchHit<T> = {
|
|
102
102
|
_id: string;
|
|
103
103
|
_index: string;
|
|
104
104
|
_score: number;
|
|
@@ -106,7 +106,7 @@ export declare type SearchHit<T> = {
|
|
|
106
106
|
_type: string;
|
|
107
107
|
fields?: any;
|
|
108
108
|
};
|
|
109
|
-
export
|
|
109
|
+
export type SearchRequestBody = {
|
|
110
110
|
query?: any;
|
|
111
111
|
sort?: any[];
|
|
112
112
|
from?: number;
|
|
@@ -117,7 +117,7 @@ export declare type SearchRequestBody = {
|
|
|
117
117
|
_source?: boolean;
|
|
118
118
|
script_fields?: any;
|
|
119
119
|
};
|
|
120
|
-
export
|
|
120
|
+
export type SearchResponseBody<T = any> = {
|
|
121
121
|
hits: {
|
|
122
122
|
hits: Array<SearchHit<T>>;
|
|
123
123
|
total: {
|
|
@@ -149,17 +149,17 @@ export declare type SearchResponseBody<T = any> = {
|
|
|
149
149
|
};
|
|
150
150
|
};
|
|
151
151
|
};
|
|
152
|
-
export
|
|
153
|
-
export
|
|
152
|
+
export type BulkOperationType = 'index' | 'update' | 'delete';
|
|
153
|
+
export type BulkOperation = {
|
|
154
154
|
[operation in BulkOperationType]?: {
|
|
155
155
|
_id: string;
|
|
156
156
|
};
|
|
157
157
|
};
|
|
158
|
-
export
|
|
158
|
+
export type BulkOperationDoc<T> = T | {
|
|
159
159
|
doc: T;
|
|
160
160
|
doc_as_upsert?: boolean;
|
|
161
161
|
};
|
|
162
|
-
export
|
|
162
|
+
export type BulkResponseResult = {
|
|
163
163
|
[operation in BulkOperationType]?: {
|
|
164
164
|
_index: string;
|
|
165
165
|
_type: string;
|
|
@@ -177,7 +177,7 @@ export declare type BulkResponseResult = {
|
|
|
177
177
|
error?: any;
|
|
178
178
|
};
|
|
179
179
|
};
|
|
180
|
-
export
|
|
180
|
+
export type BulkResponseBody = {
|
|
181
181
|
took: number;
|
|
182
182
|
errors: boolean;
|
|
183
183
|
items: BulkResponseResult[];
|
|
@@ -187,14 +187,14 @@ export interface ReindexMessageResponse {
|
|
|
187
187
|
completed: number;
|
|
188
188
|
duration: number;
|
|
189
189
|
}
|
|
190
|
-
export
|
|
190
|
+
export type ReindexMessageData = {
|
|
191
191
|
ctx: SerializedRequestContext;
|
|
192
192
|
};
|
|
193
|
-
export
|
|
193
|
+
export type UpdateProductMessageData = {
|
|
194
194
|
ctx: SerializedRequestContext;
|
|
195
195
|
productId: ID;
|
|
196
196
|
};
|
|
197
|
-
export
|
|
197
|
+
export type UpdateVariantMessageData = {
|
|
198
198
|
ctx: SerializedRequestContext;
|
|
199
199
|
variantIds: ID[];
|
|
200
200
|
};
|
|
@@ -207,7 +207,7 @@ export interface ProductChannelMessageData {
|
|
|
207
207
|
productId: ID;
|
|
208
208
|
channelId: ID;
|
|
209
209
|
}
|
|
210
|
-
export
|
|
210
|
+
export type VariantChannelMessageData = {
|
|
211
211
|
ctx: SerializedRequestContext;
|
|
212
212
|
productVariantId: ID;
|
|
213
213
|
channelId: ID;
|
|
@@ -216,47 +216,47 @@ export interface UpdateAssetMessageData {
|
|
|
216
216
|
ctx: SerializedRequestContext;
|
|
217
217
|
asset: JsonCompatible<Required<Asset>>;
|
|
218
218
|
}
|
|
219
|
-
|
|
220
|
-
|
|
219
|
+
type Maybe<T> = T | undefined;
|
|
220
|
+
type NamedJobData<Type extends string, MessageData> = {
|
|
221
221
|
type: Type;
|
|
222
222
|
} & MessageData;
|
|
223
|
-
export
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
export
|
|
236
|
-
export
|
|
237
|
-
export
|
|
238
|
-
|
|
239
|
-
|
|
223
|
+
export type ReindexJobData = NamedJobData<'reindex', ReindexMessageData>;
|
|
224
|
+
type UpdateProductJobData = NamedJobData<'update-product', UpdateProductMessageData>;
|
|
225
|
+
type UpdateVariantsJobData = NamedJobData<'update-variants', UpdateVariantMessageData>;
|
|
226
|
+
type DeleteProductJobData = NamedJobData<'delete-product', UpdateProductMessageData>;
|
|
227
|
+
type DeleteVariantJobData = NamedJobData<'delete-variant', UpdateVariantMessageData>;
|
|
228
|
+
type UpdateVariantsByIdJobData = NamedJobData<'update-variants-by-id', UpdateVariantsByIdMessageData>;
|
|
229
|
+
type UpdateAssetJobData = NamedJobData<'update-asset', UpdateAssetMessageData>;
|
|
230
|
+
type DeleteAssetJobData = NamedJobData<'delete-asset', UpdateAssetMessageData>;
|
|
231
|
+
type AssignProductToChannelJobData = NamedJobData<'assign-product-to-channel', ProductChannelMessageData>;
|
|
232
|
+
type RemoveProductFromChannelJobData = NamedJobData<'remove-product-from-channel', ProductChannelMessageData>;
|
|
233
|
+
type AssignVariantToChannelJobData = NamedJobData<'assign-variant-to-channel', VariantChannelMessageData>;
|
|
234
|
+
type RemoveVariantFromChannelJobData = NamedJobData<'remove-variant-from-channel', VariantChannelMessageData>;
|
|
235
|
+
export type UpdateIndexQueueJobData = ReindexJobData | UpdateProductJobData | UpdateVariantsJobData | DeleteProductJobData | DeleteVariantJobData | UpdateVariantsByIdJobData | UpdateAssetJobData | DeleteAssetJobData | AssignProductToChannelJobData | RemoveProductFromChannelJobData | AssignVariantToChannelJobData | RemoveVariantFromChannelJobData;
|
|
236
|
+
export type GraphQlPrimitive = 'ID' | 'String' | 'Int' | 'Float' | 'Boolean';
|
|
237
|
+
export type PrimitiveTypeVariations<T extends GraphQlPrimitive> = T | `${T}!` | `[${T}!]` | `[${T}!]!`;
|
|
238
|
+
type GraphQlPermittedReturnType = PrimitiveTypeVariations<GraphQlPrimitive>;
|
|
239
|
+
type CustomMappingDefinition<Args extends any[], T extends GraphQlPermittedReturnType, R> = {
|
|
240
240
|
graphQlType: T;
|
|
241
241
|
public?: boolean;
|
|
242
242
|
valueFn: (...args: Args) => R;
|
|
243
243
|
};
|
|
244
|
-
|
|
244
|
+
type TypeVariationMap<GqlType extends GraphQlPrimitive, TsType> = {
|
|
245
245
|
[Key in PrimitiveTypeVariations<GqlType>]: Key extends `[${string}!]!` ? TsType[] : Key extends `[${string}!]` ? Maybe<TsType[]> : Key extends `${string}!` ? TsType : Maybe<TsType>;
|
|
246
246
|
};
|
|
247
|
-
|
|
248
|
-
export
|
|
247
|
+
type GraphQlTypeMap = TypeVariationMap<'ID', ID> & TypeVariationMap<'String', string> & TypeVariationMap<'Int', number> & TypeVariationMap<'Float', number> & TypeVariationMap<'Boolean', boolean>;
|
|
248
|
+
export type CustomMapping<Args extends any[]> = {
|
|
249
249
|
[Type in GraphQlPermittedReturnType]: CustomMappingDefinition<Args, Type, GraphQlTypeMap[Type]>;
|
|
250
250
|
}[GraphQlPermittedReturnType];
|
|
251
|
-
export
|
|
252
|
-
|
|
251
|
+
export type CustomScriptContext = 'product' | 'variant' | 'both';
|
|
252
|
+
type CustomScriptMappingDefinition<Args extends any[], T extends GraphQlPermittedReturnType> = {
|
|
253
253
|
graphQlType: T;
|
|
254
254
|
context: CustomScriptContext;
|
|
255
255
|
scriptFn: (...args: Args) => {
|
|
256
256
|
script: string;
|
|
257
257
|
};
|
|
258
258
|
};
|
|
259
|
-
export
|
|
259
|
+
export type CustomScriptMapping<Args extends any[]> = {
|
|
260
260
|
[Type in GraphQlPermittedReturnType]: CustomScriptMappingDefinition<Args, Type>;
|
|
261
261
|
}[GraphQlPermittedReturnType];
|
|
262
262
|
export {};
|
package/package.json
CHANGED
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
2
|
+
"name": "@vendure/elasticsearch-plugin",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"lib/**/*"
|
|
9
|
+
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"watch": "tsc -p ./tsconfig.build.json --watch",
|
|
12
|
+
"build": "rimraf lib && tsc -p ./tsconfig.build.json",
|
|
13
|
+
"lint": "eslint --fix .",
|
|
14
|
+
"test": "vitest --run",
|
|
15
|
+
"e2e": "cross-env PACKAGE=elasticsearch-plugin vitest --config ../../e2e-common/vitest.config.ts --run",
|
|
16
|
+
"e2e:watch": "cross-env PACKAGE=elasticsearch-plugin vitest --config ../../e2e-common/vitest.config.ts"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://www.vendure.io/",
|
|
19
|
+
"funding": "https://github.com/sponsors/michaelbromley",
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@elastic/elasticsearch": "~7.9.1",
|
|
25
|
+
"deepmerge": "^4.2.2",
|
|
26
|
+
"fast-deep-equal": "^3.1.3"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@vendure/common": "^2.0.0",
|
|
30
|
+
"@vendure/core": "^2.0.0",
|
|
31
|
+
"rimraf": "^3.0.2",
|
|
32
|
+
"typescript": "4.9.5"
|
|
33
|
+
},
|
|
34
|
+
"gitHead": "302bd68796e0136f70dd199369616d362c920ea4"
|
|
34
35
|
}
|