@haus-tech/product-import-export-plugin 3.0.3 → 3.0.5

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.
Files changed (52) hide show
  1. package/package.json +2 -2
  2. package/dist/api/plugin.controller.d.ts +0 -8
  3. package/dist/api/plugin.controller.js +0 -49
  4. package/dist/api/product-export.controller.d.ts +0 -14
  5. package/dist/api/product-export.controller.js +0 -117
  6. package/dist/api/product-import.controller.d.ts +0 -11
  7. package/dist/api/product-import.controller.js +0 -63
  8. package/dist/constants.d.ts +0 -2
  9. package/dist/constants.js +0 -5
  10. package/dist/helpers/generate-asset-hash.d.ts +0 -2
  11. package/dist/helpers/generate-asset-hash.js +0 -15
  12. package/dist/helpers/normalize-string.d.ts +0 -1
  13. package/dist/helpers/normalize-string.js +0 -16
  14. package/dist/helpers/remove-update-at-fields.d.ts +0 -5
  15. package/dist/helpers/remove-update-at-fields.js +0 -19
  16. package/dist/index.d.ts +0 -1
  17. package/dist/index.js +0 -17
  18. package/dist/product-import-export.plugin.d.ts +0 -13
  19. package/dist/product-import-export.plugin.js +0 -153
  20. package/dist/providers/import-providers/asset-importer.d.ts +0 -27
  21. package/dist/providers/import-providers/asset-importer.js +0 -138
  22. package/dist/providers/import-providers/import-parser.d.ts +0 -137
  23. package/dist/providers/import-providers/import-parser.js +0 -600
  24. package/dist/providers/import-providers/product-importer.d.ts +0 -48
  25. package/dist/providers/import-providers/product-importer.js +0 -753
  26. package/dist/services/extended-fast-importer.service.d.ts +0 -44
  27. package/dist/services/extended-fast-importer.service.js +0 -462
  28. package/dist/services/product-export.service.d.ts +0 -23
  29. package/dist/services/product-export.service.js +0 -344
  30. package/dist/services/product-import.service.d.ts +0 -22
  31. package/dist/services/product-import.service.js +0 -84
  32. package/dist/types.d.ts +0 -41
  33. package/dist/types.js +0 -2
  34. package/dist/ui/components/export-dialog.component.d.ts +0 -43
  35. package/dist/ui/components/export-dialog.component.html +0 -78
  36. package/dist/ui/components/export-dialog.component.js +0 -108
  37. package/dist/ui/components/export-dialog.component.ts +0 -142
  38. package/dist/ui/components/product-import.component.d.ts +0 -57
  39. package/dist/ui/components/product-import.component.html +0 -123
  40. package/dist/ui/components/product-import.component.js +0 -413
  41. package/dist/ui/components/product-import.component.ts +0 -550
  42. package/dist/ui/product-export.service.d.ts +0 -14
  43. package/dist/ui/product-export.service.js +0 -107
  44. package/dist/ui/product-export.service.ts +0 -107
  45. package/dist/ui/providers.d.ts +0 -2
  46. package/dist/ui/providers.js +0 -49
  47. package/dist/ui/providers.ts +0 -57
  48. package/dist/ui/routes.d.ts +0 -31
  49. package/dist/ui/routes.js +0 -12
  50. package/dist/ui/routes.ts +0 -11
  51. package/dist/ui/translations/en.json +0 -52
  52. package/dist/ui/translations/sv.json +0 -52
@@ -1,108 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.ExportDialogComponent = void 0;
13
- const core_1 = require("@angular/core");
14
- const forms_1 = require("@angular/forms");
15
- const core_2 = require("@vendure/admin-ui/core");
16
- const lodash_1 = require("lodash");
17
- let ExportDialogComponent = class ExportDialogComponent {
18
- fileNameElement;
19
- resolveWith;
20
- selection = [];
21
- fileName = '';
22
- customFields = [];
23
- selectedFields = [];
24
- exportAssetsAs = 'url';
25
- selectedExportFields = [];
26
- availableExportFields = [
27
- 'productId',
28
- 'name',
29
- 'slug',
30
- 'description',
31
- 'assets',
32
- 'facets',
33
- 'optionGroups',
34
- 'sku',
35
- 'optionValues',
36
- 'price',
37
- 'taxCategory',
38
- 'stockOnHand',
39
- 'trackInventory',
40
- 'variantAssets',
41
- 'variantFacets',
42
- ];
43
- config;
44
- ngOnInit() {
45
- this.selectedFields = [...this.customFields];
46
- if (this.config.defaultExportAssetsAs?.includes(this.config.defaultExportAssetsAs)) {
47
- this.exportAssetsAs = this.config.defaultExportAssetsAs;
48
- }
49
- else {
50
- this.exportAssetsAs = this.config.exportAssetsAsOptions?.[0] || 'url';
51
- }
52
- this.selectedExportFields = (0, lodash_1.uniq)([
53
- ...(this.config.defaultExportFields || []),
54
- ...(this.config.requiredExportFields || []),
55
- ]);
56
- }
57
- ngAfterViewInit() {
58
- if (this.fileNameElement) {
59
- setTimeout(() => {
60
- this.fileNameElement.nativeElement.focus();
61
- }, 0);
62
- }
63
- }
64
- export() {
65
- this.fileName = this.fileName?.trim();
66
- this.resolveWith({
67
- result: true,
68
- fileName: this.fileName,
69
- selectedFields: this.selectedFields,
70
- exportAssetsAs: this.exportAssetsAs,
71
- selectedExportFields: this.selectedExportFields,
72
- });
73
- }
74
- cancel() {
75
- this.resolveWith({ result: false });
76
- }
77
- toggleFieldSelection(fieldName) {
78
- const index = this.selectedFields.indexOf(fieldName);
79
- if (index > -1) {
80
- this.selectedFields.splice(index, 1);
81
- }
82
- else {
83
- this.selectedFields.push(fieldName);
84
- }
85
- }
86
- toggleExportFieldSelection(fieldName) {
87
- const index = this.selectedExportFields.indexOf(fieldName);
88
- if (index > -1) {
89
- this.selectedExportFields.splice(index, 1);
90
- }
91
- else {
92
- this.selectedExportFields.push(fieldName);
93
- }
94
- }
95
- };
96
- __decorate([
97
- (0, core_1.ViewChild)('fileNameInput', { static: false }),
98
- __metadata("design:type", core_1.ElementRef)
99
- ], ExportDialogComponent.prototype, "fileNameElement", void 0);
100
- ExportDialogComponent = __decorate([
101
- (0, core_1.Component)({
102
- selector: 'vdr-export-dialog',
103
- templateUrl: './export-dialog.component.html',
104
- standalone: true,
105
- imports: [core_2.SharedModule, forms_1.FormsModule],
106
- })
107
- ], ExportDialogComponent);
108
- exports.ExportDialogComponent = ExportDialogComponent;
@@ -1,142 +0,0 @@
1
- import { Component, ViewChild, ElementRef, AfterViewInit, OnInit } from '@angular/core'
2
- import { Dialog } from '@vendure/admin-ui/core'
3
- import { FormsModule } from '@angular/forms'
4
- import { SharedModule } from '@vendure/admin-ui/core'
5
- import { uniq } from 'lodash'
6
-
7
- type ProductFields =
8
- | 'productId'
9
- | 'name'
10
- | 'slug'
11
- | 'description'
12
- | 'assets'
13
- | 'facets'
14
- | 'optionGroups'
15
-
16
- type VariantFields =
17
- | 'sku'
18
- | 'optionValues'
19
- | 'price'
20
- | 'taxCategory'
21
- | 'stockOnHand'
22
- | 'trackInventory'
23
- | 'variantAssets'
24
- | 'variantFacets'
25
-
26
- type ExportFields = Array<ProductFields | VariantFields>
27
- interface PluginInitOptions {
28
- defaultFileName?: string
29
- exportAssetsAsOptions?: Array<'url' | 'json'>
30
- defaultExportAssetsAs?: 'url' | 'json'
31
- defaultExportFields?: ExportFields
32
- requiredExportFields?: ExportFields
33
- }
34
-
35
- @Component({
36
- selector: 'vdr-export-dialog',
37
- templateUrl: './export-dialog.component.html',
38
- standalone: true,
39
- imports: [SharedModule, FormsModule],
40
- })
41
- export class ExportDialogComponent
42
- implements
43
- Dialog<{
44
- result: boolean
45
- fileName?: string
46
- selectedFields?: string[]
47
- exportAssetsAs?: 'url' | 'json'
48
- selectedExportFields?: ExportFields
49
- }>,
50
- AfterViewInit,
51
- OnInit
52
- {
53
- @ViewChild('fileNameInput', { static: false }) fileNameElement: ElementRef<HTMLInputElement>
54
-
55
- resolveWith: (result?: {
56
- result: boolean
57
- fileName?: string
58
- selectedFields?: string[]
59
- exportAssetsAs?: 'url' | 'json'
60
- selectedExportFields?: ExportFields
61
- }) => void
62
- selection: any[] = []
63
- fileName: string = ''
64
- customFields: string[] = []
65
- selectedFields: string[] = []
66
- exportAssetsAs: 'url' | 'json' = 'url'
67
- selectedExportFields: ExportFields = []
68
- availableExportFields: ExportFields = [
69
- 'productId',
70
- 'name',
71
- 'slug',
72
- 'description',
73
- 'assets',
74
- 'facets',
75
- 'optionGroups',
76
- 'sku',
77
- 'optionValues',
78
- 'price',
79
- 'taxCategory',
80
- 'stockOnHand',
81
- 'trackInventory',
82
- 'variantAssets',
83
- 'variantFacets',
84
- ]
85
-
86
- config: PluginInitOptions
87
-
88
- ngOnInit(): void {
89
- this.selectedFields = [...this.customFields]
90
- if (this.config.defaultExportAssetsAs?.includes(this.config.defaultExportAssetsAs)) {
91
- this.exportAssetsAs = this.config.defaultExportAssetsAs
92
- } else {
93
- this.exportAssetsAs = this.config.exportAssetsAsOptions?.[0] || 'url'
94
- }
95
-
96
- this.selectedExportFields = uniq([
97
- ...(this.config.defaultExportFields || []),
98
- ...(this.config.requiredExportFields || []),
99
- ])
100
- }
101
-
102
- ngAfterViewInit(): void {
103
- if (this.fileNameElement) {
104
- setTimeout(() => {
105
- this.fileNameElement.nativeElement.focus()
106
- }, 0)
107
- }
108
- }
109
-
110
- export() {
111
- this.fileName = this.fileName?.trim()
112
- this.resolveWith({
113
- result: true,
114
- fileName: this.fileName,
115
- selectedFields: this.selectedFields,
116
- exportAssetsAs: this.exportAssetsAs,
117
- selectedExportFields: this.selectedExportFields,
118
- })
119
- }
120
-
121
- cancel() {
122
- this.resolveWith({ result: false })
123
- }
124
-
125
- toggleFieldSelection(fieldName: string) {
126
- const index = this.selectedFields.indexOf(fieldName)
127
- if (index > -1) {
128
- this.selectedFields.splice(index, 1)
129
- } else {
130
- this.selectedFields.push(fieldName)
131
- }
132
- }
133
-
134
- toggleExportFieldSelection(fieldName: ProductFields | VariantFields) {
135
- const index = this.selectedExportFields.indexOf(fieldName)
136
- if (index > -1) {
137
- this.selectedExportFields.splice(index, 1)
138
- } else {
139
- this.selectedExportFields.push(fieldName)
140
- }
141
- }
142
- }
@@ -1,57 +0,0 @@
1
- import { ElementRef, ChangeDetectorRef, OnInit } from '@angular/core';
2
- import { NotificationService, LocalStorageService } from '@vendure/admin-ui/core';
3
- import { TranslateService } from '@ngx-translate/core';
4
- import { AdminUiConfig } from '@vendure/common/lib/shared-types';
5
- import { Channel, LanguageCode } from '@vendure/core';
6
- type UpdatingStrategy = 'replace' | 'merge';
7
- type ImportOptions = {
8
- updateProductSlug?: string;
9
- };
10
- type ValidateReturnType = {
11
- isValid: boolean;
12
- langCodes?: (string | undefined)[];
13
- clearFile?: boolean;
14
- };
15
- export interface PluginInitOptions {
16
- visibleOptions?: Array<keyof ImportOptions>;
17
- defaultOptions?: ImportOptions;
18
- }
19
- export declare class ProductImportComponent implements OnInit {
20
- private notificationService;
21
- private cd;
22
- private translate;
23
- private localStorageService;
24
- serverPath: string;
25
- validateFile: File | null;
26
- selectedFile: File | null;
27
- updateProductSlug: boolean;
28
- selectedMainLanguage: LanguageCode | undefined;
29
- availableLanguages: LanguageCode[];
30
- updatingStrategy: UpdatingStrategy;
31
- fileUploadElement: ElementRef<HTMLInputElement>;
32
- config: PluginInitOptions;
33
- appConfig: AdminUiConfig;
34
- currentChannel: Channel;
35
- constructor(notificationService: NotificationService, cd: ChangeDetectorRef, translate: TranslateService, localStorageService: LocalStorageService);
36
- ngOnInit(): Promise<void>;
37
- doValidation(file: File): void;
38
- onMainLanguageChange(): void;
39
- onFileSelected(event: Event): void;
40
- clearFile(): void;
41
- validateCsvStructure(file: File): Promise<ValidateReturnType>;
42
- uploadFile(): Promise<void>;
43
- splitLines(text: string): string[];
44
- checkifJson(text: string): {
45
- startsWithJson: boolean;
46
- endsWithJson: boolean;
47
- startChar: string;
48
- endChar: string;
49
- isJson?: boolean;
50
- };
51
- getRequestHeaders(): Record<string, string>;
52
- checkTranslatabeColumns(lines: string[], columns: string[], header: string[], languageCodes: (string | undefined)[]): {
53
- errorRows: number[];
54
- errorColumns: string[];
55
- };
56
- }
57
- export {};
@@ -1,123 +0,0 @@
1
- <!-- product-import.component.html -->
2
- <vdr-page-block>
3
- <vdr-card [title]="'product-import.card.title' | translate">
4
- <div class="form-grid">
5
- <vdr-form-field [label]="'product-import.card.description' | translate">
6
- <input type="file" (change)="onFileSelected($event)" class="file-input" #fileUpload />
7
-
8
- <div class="file-upload" style="display: flex; align-items: center; gap: 8px">
9
- <button *ngIf="selectedFile" class="button-small" (click)="fileUpload.click()">
10
- <clr-icon shape="file"></clr-icon>
11
- {{ selectedFile?.name }}
12
- </button>
13
-
14
- <button class="button primary" *ngIf="!selectedFile" (click)="fileUpload.click()">
15
- {{ 'product-import.card.button-select' | translate }}
16
- </button>
17
- <button
18
- class="button primary"
19
- *ngIf="selectedFile"
20
- (click)="uploadFile()"
21
- [disabled]="!selectedMainLanguage"
22
- >
23
- {{ 'product-import.card.button-upload' | translate }}
24
- </button>
25
- </div>
26
- </vdr-form-field>
27
- </div>
28
- <div
29
- class="form-grid"
30
- *ngIf="selectedFile"
31
- style="margin-top: 24px; border-top: 1px solid #cdcdcd"
32
- >
33
- <div
34
- class="input-row"
35
- style="margin-top: 16px"
36
- *ngIf="config.visibleOptions?.includes('updateProductSlug')"
37
- >
38
- <label>
39
- <input
40
- type="checkBox"
41
- name="updateProductSlug"
42
- value="url"
43
- [(ngModel)]="updateProductSlug"
44
- style="width: fit-content"
45
- />
46
- {{ 'product-import.card.update-product-slugs' | translate }}
47
- </label>
48
- </div>
49
-
50
- <div class="input-row" style="margin-top: 16px">
51
- <div>{{ 'product-import.card.select-main-language' | translate }}</div>
52
- <div *ngFor="let lang of availableLanguages">
53
- <label>
54
- <input
55
- type="radio"
56
- name="selectedMainLanguage"
57
- [value]="lang"
58
- [(ngModel)]="selectedMainLanguage"
59
- style="width: fit-content"
60
- (change)="onMainLanguageChange(lang)"
61
- />
62
- {{ lang }}
63
- </label>
64
- </div>
65
- <div
66
- style="
67
- margin-top: 8px;
68
- padding-top: 8px;
69
- font-style: italic;
70
- font-size: 12px;
71
- line-height: 1.4;
72
- "
73
- >
74
- <clr-icon shape="info-circle" size="16" class="is-info"></clr-icon>
75
- {{ 'product-import.card.main-language-info' | translate }}
76
- </div>
77
- </div>
78
-
79
- <div class="input-row" style="margin-top: 16px">
80
- <div>{{ 'product-import.card.updating-strategy' | translate }}</div>
81
- <div>
82
- <label>
83
- <input
84
- type="radio"
85
- name="updatingStrategy"
86
- value="merge"
87
- [(ngModel)]="updatingStrategy"
88
- style="width: fit-content"
89
- />
90
- {{ 'product-import.card.merge' | translate }}
91
- </label>
92
- </div>
93
- <div>
94
- <label>
95
- <input
96
- type="radio"
97
- name="updatingStrategy"
98
- value="replace"
99
- [(ngModel)]="updatingStrategy"
100
- style="width: fit-content"
101
- />
102
- {{ 'product-import.card.overwrite' | translate }}<br />
103
- <span *ngIf="updatingStrategy === 'replace'" style="color: red; font-size: 12px">{{
104
- 'product-import.card.overwrite-warning' | translate
105
- }}</span>
106
- </label>
107
- </div>
108
- </div>
109
- </div>
110
- </vdr-card>
111
- </vdr-page-block>
112
-
113
- <style>
114
- .form-grid {
115
- display: grid;
116
- grid-template-columns: 1fr 1fr;
117
- grid-gap: 1rem;
118
- }
119
-
120
- .file-input {
121
- display: none;
122
- }
123
- </style>