@haus-tech/product-import-export-plugin 3.0.4 → 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.
- package/package.json +1 -1
- package/dist/api/plugin.controller.d.ts +0 -8
- package/dist/api/plugin.controller.js +0 -49
- package/dist/api/product-export.controller.d.ts +0 -14
- package/dist/api/product-export.controller.js +0 -117
- package/dist/api/product-import.controller.d.ts +0 -11
- package/dist/api/product-import.controller.js +0 -63
- package/dist/constants.d.ts +0 -2
- package/dist/constants.js +0 -5
- package/dist/helpers/generate-asset-hash.d.ts +0 -2
- package/dist/helpers/generate-asset-hash.js +0 -15
- package/dist/helpers/normalize-string.d.ts +0 -1
- package/dist/helpers/normalize-string.js +0 -16
- package/dist/helpers/remove-update-at-fields.d.ts +0 -5
- package/dist/helpers/remove-update-at-fields.js +0 -19
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -17
- package/dist/product-import-export.plugin.d.ts +0 -13
- package/dist/product-import-export.plugin.js +0 -153
- package/dist/providers/import-providers/asset-importer.d.ts +0 -31
- package/dist/providers/import-providers/asset-importer.js +0 -158
- package/dist/providers/import-providers/import-parser.d.ts +0 -137
- package/dist/providers/import-providers/import-parser.js +0 -600
- package/dist/providers/import-providers/product-importer.d.ts +0 -48
- package/dist/providers/import-providers/product-importer.js +0 -753
- package/dist/services/extended-fast-importer.service.d.ts +0 -44
- package/dist/services/extended-fast-importer.service.js +0 -462
- package/dist/services/product-export.service.d.ts +0 -23
- package/dist/services/product-export.service.js +0 -344
- package/dist/services/product-import.service.d.ts +0 -22
- package/dist/services/product-import.service.js +0 -84
- package/dist/types.d.ts +0 -41
- package/dist/types.js +0 -2
- package/dist/ui/components/export-dialog.component.d.ts +0 -43
- package/dist/ui/components/export-dialog.component.html +0 -78
- package/dist/ui/components/export-dialog.component.js +0 -108
- package/dist/ui/components/export-dialog.component.ts +0 -142
- package/dist/ui/components/product-import.component.d.ts +0 -57
- package/dist/ui/components/product-import.component.html +0 -123
- package/dist/ui/components/product-import.component.js +0 -413
- package/dist/ui/components/product-import.component.ts +0 -550
- package/dist/ui/product-export.service.d.ts +0 -14
- package/dist/ui/product-export.service.js +0 -107
- package/dist/ui/product-export.service.ts +0 -107
- package/dist/ui/providers.d.ts +0 -2
- package/dist/ui/providers.js +0 -49
- package/dist/ui/providers.ts +0 -57
- package/dist/ui/routes.d.ts +0 -31
- package/dist/ui/routes.js +0 -12
- package/dist/ui/routes.ts +0 -11
- package/dist/ui/translations/en.json +0 -52
- package/dist/ui/translations/sv.json +0 -52
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { RequestContext } from '@vendure/core';
|
|
2
|
-
import { PluginInitOptions } from '../types';
|
|
3
|
-
export declare class ProductImportExportPluginController {
|
|
4
|
-
private options;
|
|
5
|
-
constructor(options: PluginInitOptions);
|
|
6
|
-
getConfig(): PluginInitOptions;
|
|
7
|
-
getChannel(ctx: RequestContext): import("@vendure/core").Channel;
|
|
8
|
-
}
|
|
@@ -1,49 +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
|
-
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.ProductImportExportPluginController = void 0;
|
|
16
|
-
const core_1 = require("@vendure/core");
|
|
17
|
-
const common_1 = require("@nestjs/common");
|
|
18
|
-
const constants_1 = require("../constants");
|
|
19
|
-
let ProductImportExportPluginController = class ProductImportExportPluginController {
|
|
20
|
-
options;
|
|
21
|
-
constructor(options) {
|
|
22
|
-
this.options = options;
|
|
23
|
-
}
|
|
24
|
-
getConfig() {
|
|
25
|
-
return this.options;
|
|
26
|
-
}
|
|
27
|
-
getChannel(ctx) {
|
|
28
|
-
return ctx.channel;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
__decorate([
|
|
32
|
-
(0, common_1.Get)('config'),
|
|
33
|
-
__metadata("design:type", Function),
|
|
34
|
-
__metadata("design:paramtypes", []),
|
|
35
|
-
__metadata("design:returntype", void 0)
|
|
36
|
-
], ProductImportExportPluginController.prototype, "getConfig", null);
|
|
37
|
-
__decorate([
|
|
38
|
-
(0, common_1.Get)('channel'),
|
|
39
|
-
__param(0, (0, core_1.Ctx)()),
|
|
40
|
-
__metadata("design:type", Function),
|
|
41
|
-
__metadata("design:paramtypes", [core_1.RequestContext]),
|
|
42
|
-
__metadata("design:returntype", void 0)
|
|
43
|
-
], ProductImportExportPluginController.prototype, "getChannel", null);
|
|
44
|
-
ProductImportExportPluginController = __decorate([
|
|
45
|
-
(0, common_1.Controller)('product-import-export'),
|
|
46
|
-
__param(0, (0, common_1.Inject)(constants_1.PRODUCT_IMPORT_EXPORT_PLUGIN_OPTIONS)),
|
|
47
|
-
__metadata("design:paramtypes", [Object])
|
|
48
|
-
], ProductImportExportPluginController);
|
|
49
|
-
exports.ProductImportExportPluginController = ProductImportExportPluginController;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { RequestContext, ID } from '@vendure/core';
|
|
2
|
-
import { Response } from 'express';
|
|
3
|
-
import { ProductExportService } from '../services/product-export.service';
|
|
4
|
-
import { PluginInitOptions } from '../types';
|
|
5
|
-
export declare class ProductExportController {
|
|
6
|
-
private options;
|
|
7
|
-
private productExportService;
|
|
8
|
-
constructor(options: PluginInitOptions, productExportService: ProductExportService);
|
|
9
|
-
exportProducts(ctx: RequestContext, res: Response, fileName: string, customFields: string, exportAssetsAs: 'url' | 'json', selectedExportFields: string, selection: ID[]): Promise<void>;
|
|
10
|
-
getCustomFields(ctx: RequestContext, ids: string[]): Promise<{
|
|
11
|
-
name: string;
|
|
12
|
-
type: string;
|
|
13
|
-
}[]>;
|
|
14
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
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;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
|
-
};
|
|
34
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
35
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.ProductExportController = void 0;
|
|
39
|
-
const core_1 = require("@vendure/core");
|
|
40
|
-
const common_1 = require("@nestjs/common");
|
|
41
|
-
const product_export_service_1 = require("../services/product-export.service");
|
|
42
|
-
const fs = __importStar(require("fs"));
|
|
43
|
-
const fs_1 = require("fs");
|
|
44
|
-
const constants_1 = require("../constants");
|
|
45
|
-
let ProductExportController = class ProductExportController {
|
|
46
|
-
options;
|
|
47
|
-
productExportService;
|
|
48
|
-
constructor(options, productExportService) {
|
|
49
|
-
this.options = options;
|
|
50
|
-
this.productExportService = productExportService;
|
|
51
|
-
}
|
|
52
|
-
async exportProducts(ctx, res, fileName, customFields, exportAssetsAs, selectedExportFields, selection) {
|
|
53
|
-
try {
|
|
54
|
-
if (!selection ||
|
|
55
|
-
!Array.isArray(selection) ||
|
|
56
|
-
selection.length === 0 ||
|
|
57
|
-
!selectedExportFields) {
|
|
58
|
-
throw new common_1.UnprocessableEntityException('No products selected');
|
|
59
|
-
}
|
|
60
|
-
if (!fileName) {
|
|
61
|
-
if (this.options.exportOptions.defaultFileName &&
|
|
62
|
-
!this.options.exportOptions.defaultFileName.endsWith('.csv')) {
|
|
63
|
-
fileName = this.options.exportOptions.defaultFileName += '.csv';
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
fileName = this.options.exportOptions.defaultFileName || 'products_export.csv';
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else if (!fileName.endsWith('.csv')) {
|
|
70
|
-
fileName += '.csv';
|
|
71
|
-
}
|
|
72
|
-
const csv = await this.productExportService.createExportFile(ctx, selection, fileName, customFields, exportAssetsAs, selectedExportFields);
|
|
73
|
-
const readStream = fs.createReadStream(csv);
|
|
74
|
-
res.set({
|
|
75
|
-
'Content-Type': 'text/csv',
|
|
76
|
-
'Content-Disposition': `attachment; filename=${fileName}`,
|
|
77
|
-
});
|
|
78
|
-
readStream.on('end', async () => {
|
|
79
|
-
await fs_1.promises.unlink(csv);
|
|
80
|
-
});
|
|
81
|
-
readStream.pipe(res);
|
|
82
|
-
}
|
|
83
|
-
catch (e) {
|
|
84
|
-
throw new common_1.UnprocessableEntityException(e.message);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
async getCustomFields(ctx, ids) {
|
|
88
|
-
return this.productExportService.getCustomFields(ctx, ids);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
__decorate([
|
|
92
|
-
(0, common_1.Post)('export'),
|
|
93
|
-
__param(0, (0, core_1.Ctx)()),
|
|
94
|
-
__param(1, (0, common_1.Res)()),
|
|
95
|
-
__param(2, (0, common_1.Query)('fileName')),
|
|
96
|
-
__param(3, (0, common_1.Query)('customFields')),
|
|
97
|
-
__param(4, (0, common_1.Query)('exportAssetsAs')),
|
|
98
|
-
__param(5, (0, common_1.Query)('selectedExportFields')),
|
|
99
|
-
__param(6, (0, common_1.Body)()),
|
|
100
|
-
__metadata("design:type", Function),
|
|
101
|
-
__metadata("design:paramtypes", [core_1.RequestContext, Object, String, String, String, String, Array]),
|
|
102
|
-
__metadata("design:returntype", Promise)
|
|
103
|
-
], ProductExportController.prototype, "exportProducts", null);
|
|
104
|
-
__decorate([
|
|
105
|
-
(0, common_1.Post)('custom-fields'),
|
|
106
|
-
__param(0, (0, core_1.Ctx)()),
|
|
107
|
-
__param(1, (0, common_1.Body)()),
|
|
108
|
-
__metadata("design:type", Function),
|
|
109
|
-
__metadata("design:paramtypes", [core_1.RequestContext, Array]),
|
|
110
|
-
__metadata("design:returntype", Promise)
|
|
111
|
-
], ProductExportController.prototype, "getCustomFields", null);
|
|
112
|
-
ProductExportController = __decorate([
|
|
113
|
-
(0, common_1.Controller)('product-export'),
|
|
114
|
-
__param(0, (0, common_1.Inject)(constants_1.PRODUCT_IMPORT_EXPORT_PLUGIN_OPTIONS)),
|
|
115
|
-
__metadata("design:paramtypes", [Object, product_export_service_1.ProductExportService])
|
|
116
|
-
], ProductExportController);
|
|
117
|
-
exports.ProductExportController = ProductExportController;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="Multer" />
|
|
2
|
-
import { LanguageCode, RequestContext } from '@vendure/core';
|
|
3
|
-
import { Response } from 'express';
|
|
4
|
-
import { PluginInitOptions, UpdatingStrategy } from '../types';
|
|
5
|
-
import { ProductImportService } from '../services/product-import.service';
|
|
6
|
-
export declare class ProductImportController {
|
|
7
|
-
private options;
|
|
8
|
-
private service;
|
|
9
|
-
constructor(options: PluginInitOptions, service: ProductImportService);
|
|
10
|
-
updateProducts(ctx: RequestContext, file: Express.Multer.File, updateProductSlug: "true" | "false" | undefined, mainLanguage: LanguageCode, updatingStrategy: UpdatingStrategy, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
11
|
-
}
|
|
@@ -1,63 +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
|
-
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.ProductImportController = void 0;
|
|
16
|
-
const core_1 = require("@vendure/core");
|
|
17
|
-
const common_1 = require("@nestjs/common");
|
|
18
|
-
const platform_express_1 = require("@nestjs/platform-express");
|
|
19
|
-
const constants_1 = require("../constants");
|
|
20
|
-
const product_import_service_1 = require("../services/product-import.service");
|
|
21
|
-
let ProductImportController = class ProductImportController {
|
|
22
|
-
options;
|
|
23
|
-
service;
|
|
24
|
-
constructor(options, service) {
|
|
25
|
-
this.options = options;
|
|
26
|
-
this.service = service;
|
|
27
|
-
}
|
|
28
|
-
async updateProducts(ctx, file, updateProductSlug = this.options.importOptions.defaultOptions
|
|
29
|
-
?.updateProductSlug || 'true', mainLanguage, updatingStrategy, res) {
|
|
30
|
-
if (!file) {
|
|
31
|
-
return res.status(400).send('No file uploaded');
|
|
32
|
-
}
|
|
33
|
-
if (!mainLanguage) {
|
|
34
|
-
return res.status(400).send('No mainLanguage provided');
|
|
35
|
-
}
|
|
36
|
-
try {
|
|
37
|
-
this.service.processFile(ctx, file, updateProductSlug === 'true', mainLanguage, updatingStrategy);
|
|
38
|
-
return res.status(200).send('File uploaded successfully');
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
return res.status(500).send('Internal Server Error');
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
__decorate([
|
|
46
|
-
(0, common_1.Post)('/upload'),
|
|
47
|
-
(0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)('file')),
|
|
48
|
-
__param(0, (0, core_1.Ctx)()),
|
|
49
|
-
__param(1, (0, common_1.UploadedFile)()),
|
|
50
|
-
__param(2, (0, common_1.Body)('updateProductSlug')),
|
|
51
|
-
__param(3, (0, common_1.Body)('mainLanguage')),
|
|
52
|
-
__param(4, (0, common_1.Body)('updatingStrategy')),
|
|
53
|
-
__param(5, (0, common_1.Res)()),
|
|
54
|
-
__metadata("design:type", Function),
|
|
55
|
-
__metadata("design:paramtypes", [core_1.RequestContext, Object, String, String, String, Object]),
|
|
56
|
-
__metadata("design:returntype", Promise)
|
|
57
|
-
], ProductImportController.prototype, "updateProducts", null);
|
|
58
|
-
ProductImportController = __decorate([
|
|
59
|
-
(0, common_1.Controller)('product-import'),
|
|
60
|
-
__param(0, (0, common_1.Inject)(constants_1.PRODUCT_IMPORT_EXPORT_PLUGIN_OPTIONS)),
|
|
61
|
-
__metadata("design:paramtypes", [Object, product_import_service_1.ProductImportService])
|
|
62
|
-
], ProductImportController);
|
|
63
|
-
exports.ProductImportController = ProductImportController;
|
package/dist/constants.d.ts
DELETED
package/dist/constants.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.loggerCtx = exports.PRODUCT_IMPORT_EXPORT_PLUGIN_OPTIONS = void 0;
|
|
4
|
-
exports.PRODUCT_IMPORT_EXPORT_PLUGIN_OPTIONS = Symbol('PRODUCT_IMPORT_EXPORT_PLUGIN_OPTIONS');
|
|
5
|
-
exports.loggerCtx = 'ProductImportExportPlugin';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateAssetHash = void 0;
|
|
4
|
-
const crypto_1 = require("crypto");
|
|
5
|
-
function generateAssetHash(asset) {
|
|
6
|
-
const fileName = asset.source.split('/').pop();
|
|
7
|
-
// Filename can contain OrdinalSuffix, so we need to remove it
|
|
8
|
-
// Example: atterdal_mg_9678__03.jpg
|
|
9
|
-
// We need to remove the "__03" part
|
|
10
|
-
const fileNameWithoutOrdinalSuffix = fileName.replace(/__\d+/, '');
|
|
11
|
-
// const newSource = asset.source.replace(fileName, fileNameWithoutOrdinalSuffix)
|
|
12
|
-
const hash = (0, crypto_1.createHash)('md5').update(fileNameWithoutOrdinalSuffix).digest('hex');
|
|
13
|
-
return hash;
|
|
14
|
-
}
|
|
15
|
-
exports.generateAssetHash = generateAssetHash;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function normalizeString(input?: string, spaceReplacer?: string, languageCode?: string): string;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.normalizeString = void 0;
|
|
7
|
-
const slug_1 = __importDefault(require("slug"));
|
|
8
|
-
function normalizeString(input = '', spaceReplacer = '-', languageCode) {
|
|
9
|
-
return (0, slug_1.default)(input, {
|
|
10
|
-
replacement: spaceReplacer,
|
|
11
|
-
fallback: false,
|
|
12
|
-
locale: languageCode,
|
|
13
|
-
charmap: { å: 'a', ä: 'a', ö: 'o' },
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
exports.normalizeString = normalizeString;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.removeUpdatedAtFields = void 0;
|
|
4
|
-
function removeUpdatedAtFields(obj) {
|
|
5
|
-
if (Array.isArray(obj)) {
|
|
6
|
-
return obj.map((item) => removeUpdatedAtFields(item));
|
|
7
|
-
}
|
|
8
|
-
else if (typeof obj === 'object' && obj !== null) {
|
|
9
|
-
const newObj = {};
|
|
10
|
-
for (const key in obj) {
|
|
11
|
-
if (key !== 'updatedAt') {
|
|
12
|
-
newObj[key] = removeUpdatedAtFields(obj[key]);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return newObj;
|
|
16
|
-
}
|
|
17
|
-
return obj; // Return the value if it's not an object or array
|
|
18
|
-
}
|
|
19
|
-
exports.removeUpdatedAtFields = removeUpdatedAtFields;
|
package/dist/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './product-import-export.plugin';
|
package/dist/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./product-import-export.plugin"), exports);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Type } from '@vendure/core';
|
|
2
|
-
import { AdminUiExtension } from '@vendure/ui-devkit/compiler';
|
|
3
|
-
import { PluginInitOptions } from './types';
|
|
4
|
-
export declare class ProductImportExportPlugin {
|
|
5
|
-
static options: PluginInitOptions;
|
|
6
|
-
static init(options: PluginInitOptions): Type<ProductImportExportPlugin>;
|
|
7
|
-
static ui: AdminUiExtension;
|
|
8
|
-
}
|
|
9
|
-
declare module '@vendure/core/dist/entity/custom-entity-fields' {
|
|
10
|
-
interface CustomAssetFields {
|
|
11
|
-
hash: string;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
-
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;
|
|
22
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
-
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
|
-
var ProductImportExportPlugin_1;
|
|
32
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33
|
-
exports.ProductImportExportPlugin = void 0;
|
|
34
|
-
const core_1 = require("@vendure/core");
|
|
35
|
-
const path = __importStar(require("path"));
|
|
36
|
-
const lodash_1 = require("lodash");
|
|
37
|
-
const constants_1 = require("./constants");
|
|
38
|
-
/* Controllers */
|
|
39
|
-
const product_import_controller_1 = require("./api/product-import.controller");
|
|
40
|
-
const product_export_controller_1 = require("./api/product-export.controller");
|
|
41
|
-
const plugin_controller_1 = require("./api/plugin.controller");
|
|
42
|
-
/* Providers */
|
|
43
|
-
const product_importer_1 = require("./providers/import-providers/product-importer");
|
|
44
|
-
const import_parser_1 = require("./providers/import-providers/import-parser");
|
|
45
|
-
const asset_importer_1 = require("./providers/import-providers/asset-importer");
|
|
46
|
-
/* Services */
|
|
47
|
-
const product_import_service_1 = require("./services/product-import.service");
|
|
48
|
-
const extended_fast_importer_service_1 = require("./services/extended-fast-importer.service");
|
|
49
|
-
const product_export_service_1 = require("./services/product-export.service");
|
|
50
|
-
let ProductImportExportPlugin = ProductImportExportPlugin_1 = class ProductImportExportPlugin {
|
|
51
|
-
static options;
|
|
52
|
-
static init(options) {
|
|
53
|
-
// Setup import options
|
|
54
|
-
if (!options.importOptions.defaultOptions) {
|
|
55
|
-
options.importOptions.defaultOptions = {
|
|
56
|
-
updateProductSlug: true,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
// Setup export options
|
|
60
|
-
if (!options.exportOptions.defaultFileName) {
|
|
61
|
-
options.exportOptions.defaultFileName = 'products_export.csv';
|
|
62
|
-
}
|
|
63
|
-
if (!options.exportOptions.exportAssetsAsOptions) {
|
|
64
|
-
options.exportOptions.exportAssetsAsOptions = ['url', 'json'];
|
|
65
|
-
}
|
|
66
|
-
if (!options.exportOptions.defaultExportAssetsAs) {
|
|
67
|
-
options.exportOptions.defaultExportAssetsAs = 'url';
|
|
68
|
-
}
|
|
69
|
-
if (!options.exportOptions.defaultExportFields) {
|
|
70
|
-
options.exportOptions.defaultExportFields = [
|
|
71
|
-
'name',
|
|
72
|
-
'sku',
|
|
73
|
-
'slug',
|
|
74
|
-
'description',
|
|
75
|
-
'assets',
|
|
76
|
-
'facets',
|
|
77
|
-
'optionGroups',
|
|
78
|
-
'optionValues',
|
|
79
|
-
'price',
|
|
80
|
-
'taxCategory',
|
|
81
|
-
'stockOnHand',
|
|
82
|
-
'trackInventory',
|
|
83
|
-
'variantAssets',
|
|
84
|
-
'variantFacets',
|
|
85
|
-
];
|
|
86
|
-
}
|
|
87
|
-
if (options.exportOptions.defaultExportFields) {
|
|
88
|
-
options.exportOptions.defaultExportFields = (0, lodash_1.uniq)([
|
|
89
|
-
...options.exportOptions.defaultExportFields,
|
|
90
|
-
'name',
|
|
91
|
-
'sku',
|
|
92
|
-
]);
|
|
93
|
-
}
|
|
94
|
-
if (!options.exportOptions.requiredExportFields) {
|
|
95
|
-
options.exportOptions.requiredExportFields = ['name', 'sku'];
|
|
96
|
-
}
|
|
97
|
-
if (options.exportOptions.requiredExportFields) {
|
|
98
|
-
options.exportOptions.requiredExportFields = (0, lodash_1.uniq)([
|
|
99
|
-
...options.exportOptions.requiredExportFields,
|
|
100
|
-
'name',
|
|
101
|
-
'sku',
|
|
102
|
-
]);
|
|
103
|
-
}
|
|
104
|
-
this.options = options;
|
|
105
|
-
return ProductImportExportPlugin_1;
|
|
106
|
-
}
|
|
107
|
-
static ui = {
|
|
108
|
-
id: 'product-importer-ui',
|
|
109
|
-
extensionPath: path.join(__dirname, 'ui'),
|
|
110
|
-
translations: {
|
|
111
|
-
en: path.join(__dirname, 'ui/translations/en.json'),
|
|
112
|
-
sv: path.join(__dirname, 'ui/translations/sv.json'),
|
|
113
|
-
},
|
|
114
|
-
routes: [{ route: 'product-importer', filePath: 'routes.ts' }],
|
|
115
|
-
providers: ['providers.ts'],
|
|
116
|
-
};
|
|
117
|
-
};
|
|
118
|
-
ProductImportExportPlugin = ProductImportExportPlugin_1 = __decorate([
|
|
119
|
-
(0, core_1.VendurePlugin)({
|
|
120
|
-
imports: [core_1.PluginCommonModule],
|
|
121
|
-
providers: [
|
|
122
|
-
{
|
|
123
|
-
provide: constants_1.PRODUCT_IMPORT_EXPORT_PLUGIN_OPTIONS,
|
|
124
|
-
useFactory: () => ProductImportExportPlugin_1.options,
|
|
125
|
-
},
|
|
126
|
-
product_import_service_1.ProductImportService,
|
|
127
|
-
product_importer_1.ProductImporter,
|
|
128
|
-
extended_fast_importer_service_1.ExtendedFastImporterService,
|
|
129
|
-
import_parser_1.ImportParser,
|
|
130
|
-
asset_importer_1.ExtendedAssetImporter,
|
|
131
|
-
product_export_service_1.ProductExportService,
|
|
132
|
-
],
|
|
133
|
-
controllers: [
|
|
134
|
-
product_import_controller_1.ProductImportController,
|
|
135
|
-
product_export_controller_1.ProductExportController,
|
|
136
|
-
plugin_controller_1.ProductImportExportPluginController,
|
|
137
|
-
],
|
|
138
|
-
configuration: (config) => {
|
|
139
|
-
// Plugin-specific configuration
|
|
140
|
-
// such as custom fields, custom permissions,
|
|
141
|
-
// strategies etc. can be configured here by
|
|
142
|
-
// modifying the `config` object.
|
|
143
|
-
config.customFields.Asset.push({
|
|
144
|
-
name: 'hash',
|
|
145
|
-
type: 'string',
|
|
146
|
-
internal: true,
|
|
147
|
-
});
|
|
148
|
-
return config;
|
|
149
|
-
},
|
|
150
|
-
compatibility: '^2.0.0 || ^3.0.0',
|
|
151
|
-
})
|
|
152
|
-
], ProductImportExportPlugin);
|
|
153
|
-
exports.ProductImportExportPlugin = ProductImportExportPlugin;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { OnModuleInit } from '@nestjs/common';
|
|
2
|
-
import { Asset, AssetService, ChannelService, ConfigService, RequestContext, TransactionalConnection } from '@vendure/core';
|
|
3
|
-
import { JsonAsset } from '../../types';
|
|
4
|
-
/**
|
|
5
|
-
* @description
|
|
6
|
-
* This service creates new {@link Asset} entities based on string paths provided in the CSV
|
|
7
|
-
* import format. The source files are resolved by joining the value of `importExportOptions.importAssetsDir`
|
|
8
|
-
* with the asset path. This service is used internally by the {@link Importer} service.
|
|
9
|
-
*
|
|
10
|
-
* @docsCategory import-export
|
|
11
|
-
*/
|
|
12
|
-
export declare class ExtendedAssetImporter implements OnModuleInit {
|
|
13
|
-
private configService;
|
|
14
|
-
private assetService;
|
|
15
|
-
private connection;
|
|
16
|
-
private channelService;
|
|
17
|
-
private assetMap;
|
|
18
|
-
private defaultChannel;
|
|
19
|
-
/** @internal */
|
|
20
|
-
constructor(configService: ConfigService, assetService: AssetService, connection: TransactionalConnection, channelService: ChannelService);
|
|
21
|
-
onModuleInit(): Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
* @description
|
|
24
|
-
* Creates Asset entities for the given paths, using the assetMap cache to prevent the
|
|
25
|
-
* creation of duplicates.
|
|
26
|
-
*/
|
|
27
|
-
getAssets(assetPaths: JsonAsset[], ctx?: RequestContext): Promise<{
|
|
28
|
-
assets: Asset[];
|
|
29
|
-
errors: string[];
|
|
30
|
-
}>;
|
|
31
|
-
}
|