@haus-tech/product-import-export-plugin 2.2.5 → 3.0.1

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.
@@ -147,7 +147,7 @@ ProductImportExportPlugin = ProductImportExportPlugin_1 = __decorate([
147
147
  });
148
148
  return config;
149
149
  },
150
- compatibility: '^2.0.0',
150
+ compatibility: '^2.0.0 || ^3.0.0',
151
151
  })
152
152
  ], ProductImportExportPlugin);
153
153
  exports.ProductImportExportPlugin = ProductImportExportPlugin;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { ConfigService, ChannelService, FacetService, FacetValueService, TaxCategoryService, ID, ImportProgress, LanguageCode, RequestContext, OnProgressFn, ParsedFacet, ProductService, TransactionalConnection, TranslatableSaver, AssetService, Asset, ProductOptionGroupService } from '@vendure/core';
2
+ import { ConfigService, ChannelService, FacetService, FacetValueService, TaxCategoryService, ID, ImportProgress, LanguageCode, RequestContext, OnProgressFn, ParsedFacet, ProductService, Product, TransactionalConnection, TranslatableSaver, AssetService, Asset, ProductOptionGroupService } from '@vendure/core';
3
3
  import { Stream } from 'stream';
4
4
  import { Observable } from 'rxjs';
5
5
  import { ExtendedFastImporterService } from '../../services/extended-fast-importer.service';
@@ -43,5 +43,6 @@ export declare class ProductImporter {
43
43
  */
44
44
  private getMatchingTaxCategoryId;
45
45
  private getTranslationByCodeOrFirst;
46
+ getProduct(ctx: RequestContext, id: ID): Promise<Product>;
46
47
  createFacetAndValue(facet: ParsedFacet, facetCode: string, valueCode: string): Promise<ID>;
47
48
  }
@@ -282,21 +282,8 @@ let ProductImporter = class ProductImporter {
282
282
  checkExistingProduct = { id: foundVariants[0].productId };
283
283
  }
284
284
  }
285
- const existingProduct = checkExistingProduct
286
- ? await this.connection.getRepository(ctx, core_1.Product).findOne({
287
- where: { id: checkExistingProduct?.id },
288
- withDeleted: true,
289
- relations: [
290
- 'facetValues',
291
- 'facetValues.facet',
292
- 'optionGroups',
293
- 'optionGroups.options',
294
- 'variants',
295
- 'variants.facetValues',
296
- 'assets',
297
- 'featuredAsset',
298
- ],
299
- })
285
+ const existingProduct = checkExistingProduct?.id
286
+ ? (await this.getProduct(ctx, checkExistingProduct.id))
300
287
  : undefined;
301
288
  try {
302
289
  if (existingProduct?.deletedAt) {
@@ -494,18 +481,7 @@ let ProductImporter = class ProductImporter {
494
481
  }
495
482
  }
496
483
  if (existingProduct) {
497
- const productAfterUpdate = (await this.connection.getRepository(ctx, core_1.Product).findOne({
498
- where: { id: createdProductId },
499
- relations: [
500
- 'facetValues',
501
- 'facetValues.facet',
502
- 'optionGroups',
503
- 'optionGroups.options',
504
- 'variants',
505
- 'variants.facetValues',
506
- 'assets',
507
- ],
508
- })); // We know that the product exists, so we can safely cast it to Product
484
+ const productAfterUpdate = (await this.getProduct(ctx, createdProductId)); // We know that the product exists, so we can safely cast it to Product
509
485
  const existingProductHash = (0, crypto_1.createHash)('md5')
510
486
  .update(JSON.stringify((0, remove_update_at_fields_1.removeUpdatedAtFields)(existingProduct)))
511
487
  .digest('hex');
@@ -702,6 +678,22 @@ let ProductImporter = class ProductImporter {
702
678
  }
703
679
  return translation;
704
680
  }
681
+ async getProduct(ctx, id) {
682
+ const product = (await this.connection.getRepository(ctx, core_1.Product).findOne({
683
+ where: { id: id },
684
+ relations: [
685
+ 'facetValues',
686
+ 'facetValues.facet',
687
+ 'optionGroups',
688
+ 'optionGroups.options',
689
+ 'variants',
690
+ 'variants.facetValues',
691
+ 'assets',
692
+ 'featuredAsset',
693
+ ],
694
+ }));
695
+ return product;
696
+ }
705
697
  async createFacetAndValue(facet, facetCode, valueCode) {
706
698
  const facetId = await this.fastImporter.createFacet({
707
699
  code: facetCode,
@@ -7,6 +7,8 @@ declare const _default: {
7
7
  };
8
8
  data: {
9
9
  breadcrumb: import("rxjs").BehaviorSubject<import("@vendure/admin-ui/core").BreadcrumbValue> | ((data: any) => any);
10
+ locationId: string | undefined;
11
+ description: string | undefined;
10
12
  };
11
13
  component: typeof import("@vendure/admin-ui/core").AngularRouteComponent;
12
14
  title?: string | import("@angular/core").Type<import("@angular/router").Resolve<string>> | import("@angular/router").ResolveFn<string> | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haus-tech/product-import-export-plugin",
3
- "version": "2.2.5",
3
+ "version": "3.0.1",
4
4
  "description": "A Vendure plugin for importing and exporting products using a CSV file",
5
5
  "author": "Haus Tech",
6
6
  "repository": {