@vendure/elasticsearch-plugin 1.9.5 → 2.0.0-beta.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 +7 -7
- package/lib/src/api/api-extensions.js.map +1 -1
- package/lib/src/api/custom-mappings.resolver.js +3 -3
- package/lib/src/api/custom-mappings.resolver.js.map +1 -1
- package/lib/src/api/custom-script-fields.resolver.js +3 -3
- package/lib/src/api/custom-script-fields.resolver.js.map +1 -1
- package/lib/src/api/elasticsearch-resolver.js +28 -28
- 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 +1 -1
- package/lib/src/elasticsearch.health.js.map +1 -1
- package/lib/src/elasticsearch.service.js +28 -28
- 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 +22 -14
- package/lib/src/indexing/elasticsearch-index.service.js.map +1 -1
- package/lib/src/indexing/indexer.controller.d.ts +1 -1
- package/lib/src/indexing/indexer.controller.js +35 -32
- package/lib/src/indexing/indexer.controller.js.map +1 -1
- package/lib/src/indexing/indexing-utils.js +1 -1
- package/lib/src/indexing/indexing-utils.js.map +1 -1
- package/lib/src/indexing/mutable-request-context.js.map +1 -1
- package/lib/src/options.d.ts +1 -1
- package/lib/src/options.js +1 -1
- package/lib/src/options.js.map +1 -1
- package/lib/src/plugin.d.ts +2 -1
- package/lib/src/plugin.js +11 -10
- package/lib/src/plugin.js.map +1 -1
- package/lib/src/types.d.ts +47 -47
- package/package.json +33 -32
package/lib/src/plugin.js
CHANGED
|
@@ -45,7 +45,8 @@ function getCustomResolvers(options) {
|
|
|
45
45
|
* ## Installation
|
|
46
46
|
*
|
|
47
47
|
* **Requires Elasticsearch v7.0 < required Elasticsearch version < 7.10 **
|
|
48
|
-
* Elasticsearch version 7.10.2 will throw error due to incompatibility with elasticsearch-js client.
|
|
48
|
+
* Elasticsearch version 7.10.2 will throw error due to incompatibility with elasticsearch-js client.
|
|
49
|
+
* [Check here for more info](https://github.com/elastic/elasticsearch-js/issues/1519)
|
|
49
50
|
* `yarn add \@elastic/elasticsearch \@vendure/elasticsearch-plugin`
|
|
50
51
|
*
|
|
51
52
|
* or
|
|
@@ -211,7 +212,7 @@ let ElasticsearchPlugin = ElasticsearchPlugin_1 = class ElasticsearchPlugin {
|
|
|
211
212
|
* Set the plugin options.
|
|
212
213
|
*/
|
|
213
214
|
static init(options) {
|
|
214
|
-
this.options = options_1.mergeWithDefaults(options);
|
|
215
|
+
this.options = (0, options_1.mergeWithDefaults)(options);
|
|
215
216
|
return ElasticsearchPlugin_1;
|
|
216
217
|
}
|
|
217
218
|
/** @internal */
|
|
@@ -271,12 +272,12 @@ let ElasticsearchPlugin = ElasticsearchPlugin_1 = class ElasticsearchPlugin {
|
|
|
271
272
|
});
|
|
272
273
|
// TODO: Remove this buffering logic because because we have dedicated buffering based on #1137
|
|
273
274
|
const collectionModification$ = this.eventBus.ofType(core_1.CollectionModificationEvent);
|
|
274
|
-
const closingNotifier$ = collectionModification$.pipe(operators_1.debounceTime(50));
|
|
275
|
+
const closingNotifier$ = collectionModification$.pipe((0, operators_1.debounceTime)(50));
|
|
275
276
|
collectionModification$
|
|
276
|
-
.pipe(operators_1.buffer(closingNotifier$), operators_1.filter(events => 0 < events.length), operators_1.map(events => ({
|
|
277
|
+
.pipe((0, operators_1.buffer)(closingNotifier$), (0, operators_1.filter)(events => 0 < events.length), (0, operators_1.map)(events => ({
|
|
277
278
|
ctx: events[0].ctx,
|
|
278
279
|
ids: events.reduce((ids, e) => [...ids, ...e.productVariantIds], []),
|
|
279
|
-
})), operators_1.filter(e => 0 < e.ids.length))
|
|
280
|
+
})), (0, operators_1.filter)(e => 0 < e.ids.length))
|
|
280
281
|
.subscribe(events => {
|
|
281
282
|
return this.elasticsearchIndexService.updateVariantsById(events.ctx, events.ids);
|
|
282
283
|
});
|
|
@@ -286,10 +287,10 @@ let ElasticsearchPlugin = ElasticsearchPlugin_1 = class ElasticsearchPlugin {
|
|
|
286
287
|
// transactions to complete before a new job is added to the queue (assuming the SQL-based
|
|
287
288
|
// JobQueueStrategy).
|
|
288
289
|
// TODO: should be able to remove owing to f0fd6625
|
|
289
|
-
.pipe(operators_1.delay(1))
|
|
290
|
+
.pipe((0, operators_1.delay)(1))
|
|
290
291
|
.subscribe(event => {
|
|
291
292
|
const defaultTaxZone = event.ctx.channel.defaultTaxZone;
|
|
292
|
-
if (defaultTaxZone && core_1.idsAreEqual(defaultTaxZone.id, event.taxRate.zone.id)) {
|
|
293
|
+
if (defaultTaxZone && (0, core_1.idsAreEqual)(defaultTaxZone.id, event.taxRate.zone.id)) {
|
|
293
294
|
return this.elasticsearchService.reindex(event.ctx);
|
|
294
295
|
}
|
|
295
296
|
});
|
|
@@ -321,7 +322,7 @@ let ElasticsearchPlugin = ElasticsearchPlugin_1 = class ElasticsearchPlugin {
|
|
|
321
322
|
}
|
|
322
323
|
};
|
|
323
324
|
ElasticsearchPlugin = ElasticsearchPlugin_1 = __decorate([
|
|
324
|
-
core_1.VendurePlugin({
|
|
325
|
+
(0, core_1.VendurePlugin)({
|
|
325
326
|
imports: [core_1.PluginCommonModule],
|
|
326
327
|
providers: [
|
|
327
328
|
elasticsearch_index_service_1.ElasticsearchIndexService,
|
|
@@ -341,7 +342,7 @@ ElasticsearchPlugin = ElasticsearchPlugin_1 = __decorate([
|
|
|
341
342
|
elasticsearch_resolver_1.EntityElasticSearchResolver,
|
|
342
343
|
...getCustomResolvers(ElasticsearchPlugin_1.options),
|
|
343
344
|
],
|
|
344
|
-
schema: () => api_extensions_1.generateSchemaExtensions(ElasticsearchPlugin_1.options),
|
|
345
|
+
schema: () => (0, api_extensions_1.generateSchemaExtensions)(ElasticsearchPlugin_1.options),
|
|
345
346
|
},
|
|
346
347
|
shopApiExtensions: {
|
|
347
348
|
resolvers: () => [
|
|
@@ -351,7 +352,7 @@ ElasticsearchPlugin = ElasticsearchPlugin_1 = __decorate([
|
|
|
351
352
|
],
|
|
352
353
|
// `any` cast is there due to a strange error "Property '[Symbol.iterator]' is missing in type... URLSearchParams"
|
|
353
354
|
// which looks like possibly a TS/definitions bug.
|
|
354
|
-
schema: () => api_extensions_1.generateSchemaExtensions(ElasticsearchPlugin_1.options),
|
|
355
|
+
schema: () => (0, api_extensions_1.generateSchemaExtensions)(ElasticsearchPlugin_1.options),
|
|
355
356
|
},
|
|
356
357
|
}),
|
|
357
358
|
__metadata("design:paramtypes", [core_1.EventBus,
|
package/lib/src/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAEA,wCAkBuB;AACvB,8CAA0E;AAE1E,yDAAgE;AAChE,6EAAwE;AACxE,uFAAiF;AACjF,yEAIsC;AACtC,2CAAgE;AAChE,iEAAsE;AACtE,mEAA+D;AAC/D,wFAAmF;AACnF,sEAA+E;AAC/E,uCAAiG;AAEjG,SAAS,kBAAkB,CAAC,OAAoC;IAC5D,MAAM,qBAAqB,GACvB,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC,MAAM;QAC3D,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,4BAA4B,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACvE,MAAM,2BAA2B,GAC7B,CAAC;QACG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,MAAM,CACzD,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CACvC,CAAC,MAAM;QACZ,CAAC;YACG,MAAM,CAA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,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-beta.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-beta.0",
|
|
30
|
+
"@vendure/core": "^2.0.0-beta.0",
|
|
31
|
+
"rimraf": "^3.0.2",
|
|
32
|
+
"typescript": "4.9.5"
|
|
33
|
+
},
|
|
34
|
+
"gitHead": "041394503af30fbfcf98905e1a7ed0d58a30232f"
|
|
34
35
|
}
|