@haus-tech/product-import-export-plugin 3.6.2 → 3.6.4

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 (30) hide show
  1. package/CHANGELOG.md +17 -34
  2. package/README.md +52 -2
  3. package/package.json +1 -3
  4. package/src/api/plugin.controller.d.ts +32 -2
  5. package/src/api/plugin.controller.js +30 -4
  6. package/src/api/plugin.controller.js.map +1 -1
  7. package/src/api/product-export.controller.d.ts +1 -0
  8. package/src/api/product-export.controller.js +17 -0
  9. package/src/api/product-export.controller.js.map +1 -1
  10. package/src/api/product-import.controller.js +1 -0
  11. package/src/api/product-import.controller.js.map +1 -1
  12. package/src/dashboard/export-configuration-panel.tsx +47 -3
  13. package/src/dashboard/import.tsx +2 -2
  14. package/src/dashboard/utils.ts +20 -3
  15. package/src/index.d.ts +1 -1
  16. package/src/product-import-export.plugin.js +24 -0
  17. package/src/product-import-export.plugin.js.map +1 -1
  18. package/src/providers/import-providers/product-importer.js +14 -4
  19. package/src/providers/import-providers/product-importer.js.map +1 -1
  20. package/src/services/product-export-queue.service.js +1 -1
  21. package/src/services/product-export-queue.service.js.map +1 -1
  22. package/src/services/product-export.service.d.ts +27 -7
  23. package/src/services/product-export.service.js +226 -48
  24. package/src/services/product-export.service.js.map +1 -1
  25. package/src/services/self-relation-custom-fields.d.ts +26 -0
  26. package/src/services/self-relation-custom-fields.js +67 -0
  27. package/src/services/self-relation-custom-fields.js.map +1 -0
  28. package/src/types.d.ts +29 -2
  29. package/src/ui/components/product-import.component.ts +1 -0
  30. package/README.mdx +0 -244
package/CHANGELOG.md CHANGED
@@ -1,58 +1,34 @@
1
- ## 3.6.0-next.2
1
+ ## 3.6.3
2
2
 
3
3
  ### 🩹 Fixes
4
4
 
5
- - **product-import-export-plugin:** poll exports list and restore featured asset on import ([644099a](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/644099a))
5
+ - **product-import-export-plugin:** secure REST API, stop leaking storage credentials ([#24](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/pull/24))
6
+
7
+ ## 3.6.2
6
8
 
7
- ## 3.6.0-next.1
9
+ This was a version bump only for product-import-export-plugin to align it with other projects, there were no code changes.
10
+
11
+ ## 3.6.1
8
12
 
9
13
  ### 🚀 Features
10
14
 
11
- - **product-import-export-plugin:** integrate active channel management into export and import components ([1d3eef1](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/1d3eef1))
15
+ - add custom changelog renderer to filter out prerelease versions ([4412746](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/4412746))
12
16
 
13
- ## 3.6.0-next.0
17
+ ## 3.6.0
14
18
 
15
19
  ### 🚀 Features
16
20
 
21
+ - **product-import-export-plugin:** integrate active channel management into export and import components ([1d3eef1](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/1d3eef1))
17
22
  - **product-import-export-plugin:** add installation ID and enhance e2e database management ([78eeffb](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/78eeffb))
18
23
  - **product-import-export-plugin:** add popover help for export asset options ([7aa8373](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/7aa8373))
19
24
  - **product-import-export-plugin:** implement export configuration panel and enhance export dialog ([d2e1f34](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/d2e1f34))
20
25
  - **product-import-export-plugin:** enhance product export functionality and update tests ([de56d44](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/de56d44))
21
26
  - **product-import-export-plugin:** update dependencies and enhance import/export functionality ([9c78665](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/9c78665))
22
-
23
- ### 🩹 Fixes
24
-
25
- - **product-import-export-plugin:** update dashboard and export settings screenshots ([2129b39](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/2129b39))
26
-
27
- ## 3.3.2-next.2
28
-
29
- ### 🚀 Features
30
-
31
27
  - **product-import-export-plugin:** enhance email notification and import/export functionality ([c133dc5](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/c133dc5))
32
-
33
- ## 3.3.2-next.1
34
-
35
- ### 🚀 Features
36
-
37
28
  - **product-import-export-plugin:** enforce import/export acceptance criteria and enhance documentation ([b1a93b6](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/b1a93b6))
38
29
  - **product-import-export-plugin:** update pre-version command and clean up export artifacts ([1cde024](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/1cde024))
39
-
40
- ## 3.3.2-next.0
41
-
42
- ### 🚀 Features
43
-
44
30
  - **product-import-export-plugin:** optimize asset handling and caching in product importer ([9d2888e](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/9d2888e))
45
31
  - **product-import-export-plugin:** enhance testing and export functionality ([1764eb2](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/1764eb2))
46
- - **product-import-export-plugin:** enforce import/export acceptance criteria (column-presence updates, multi-variant option requirements, no ProductID export option, clearer import CTA, and strict required relation custom-field validation)
47
-
48
- ## 3.3.1
49
-
50
- This was a version bump only for product-import-export-plugin to align it with other projects, there were no code changes.
51
-
52
- ## 3.3.1-next.0
53
-
54
- ### 🚀 Features
55
-
56
32
  - enhance file name validation for product export functionality ([f9d5a45](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/f9d5a45))
57
33
  - enhance export storage strategy configuration ([d589906](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/d589906))
58
34
  - abstract logic into separate strategies ([1c7d0c7](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/1c7d0c7))
@@ -61,8 +37,15 @@ This was a version bump only for product-import-export-plugin to align it with o
61
37
 
62
38
  ### 🩹 Fixes
63
39
 
40
+ - **plugins:** correct Vendure compatibility and add hub-required JSDoc ([ae089bd](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/ae089bd))
41
+ - **product-import-export-plugin:** poll exports list and restore featured asset on import ([644099a](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/644099a))
42
+ - **product-import-export-plugin:** update dashboard and export settings screenshots ([2129b39](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/2129b39))
64
43
  - correct file path handling and ensure consistent file name sanitization in product export ([03a5bb5](https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/commit/03a5bb5))
65
44
 
45
+ ## 3.3.1
46
+
47
+ This was a version bump only for product-import-export-plugin to align it with other projects, there were no code changes.
48
+
66
49
  ## 3.2.1
67
50
 
68
51
  This was a version bump only for product-import-export-plugin to align it with other projects, there were no code changes.
package/README.md CHANGED
@@ -1,4 +1,17 @@
1
- <!-- This file is generated from README.mdx by scripts/update-readmes.ts. Do not edit by hand. -->
1
+ ---
2
+ name: product-import-export-plugin
3
+ title: Product Import & Export
4
+ description: Vendure plugin for importing and exporting product data via CSV.
5
+ version: 3.6.3
6
+ tags:
7
+ - vendure
8
+ - plugin
9
+ - import
10
+ - export
11
+ - products
12
+ - csv
13
+ - bulk
14
+ ---
2
15
 
3
16
  # Product Import Export Plugin
4
17
 
@@ -74,6 +87,7 @@ Available import storage strategies:
74
87
  | `defaultExportAssetsAs` | `'url' \| 'json'` | `'url'` | Default asset export format |
75
88
  | `defaultExportFields` | `string[]` | See above | Fields that will be pre-selected in the export UI |
76
89
  | `requiredExportFields` | `string[]` | `['name', 'sku']` | Fields that must always be included |
90
+ | `customExportColumns` | `CustomExportColumn[]`| `undefined` | Extra CSV columns resolved per variant row. See [Custom export columns](#custom-export-columns) below. |
77
91
  | `storageStrategy` | `'s3' \| 'disk'` | `'disk'` | Where exported files are stored |
78
92
  | `s3Options` | `object` | `undefined` | S3 configuration (required when `storageStrategy` is `'s3'`) |
79
93
 
@@ -84,6 +98,39 @@ The plugin supports configurable storage for exported files:
84
98
  - **S3** – Stores export files in an S3-compatible bucket
85
99
  - **Disk (default)** – Saves files locally on the server
86
100
 
101
+ ### Custom export columns
102
+
103
+ Add columns to the exported CSV whose value is computed per variant row, for example a permalink built from the product slug and variant SKU.
104
+
105
+ ```typescript
106
+ export const config = {
107
+ plugins: [
108
+ ProductImportExportPlugin.init({
109
+ importOptions: {},
110
+ exportOptions: {
111
+ customExportColumns: [
112
+ {
113
+ name: 'permalink',
114
+ onExportStart: () => {
115
+ // Optional. Runs once per export job, before the first resolve() call.
116
+ // Use it to reset any per-export cache or counter.
117
+ },
118
+ resolve: (ctx, injector, product, variant) =>
119
+ `https://shop.example.com/${product.slug}?sku=${variant.sku}`,
120
+ },
121
+ ],
122
+ },
123
+ }),
124
+ ],
125
+ }
126
+ ```
127
+
128
+ - **`name`** – Must be non-empty, must not contain `:` (colon-suffixed headers are reserved for translated columns), must not collide with a built-in export field name, and must be unique among `customExportColumns` entries. These rules are validated when the plugin is initialised, so a misconfigured column fails fast at startup rather than mid-export.
129
+ - **`onExportStart`** – Optional. Awaited once per export job, before the first `resolve` call.
130
+ - **`resolve(ctx, injector, product, variant)`** – Called once per exported variant row. Its return value is written to the cell (`String(value)`, or an empty cell for `null`/`undefined`). Use `injector` to pull in Vendure services via DI.
131
+ - A custom column only appears in the export when its `name` is included in the selected export fields, both in the header row and in the request; otherwise it is skipped entirely.
132
+ - **Fail-soft** – If `resolve` throws, the plugin logs a warning and writes an empty cell for that row instead of failing the whole export.
133
+
87
134
  ## CSV Format for Import
88
135
 
89
136
  ### Required columns
@@ -107,7 +154,7 @@ The plugin supports configurable storage for exported files:
107
154
  | `variantAssets` | Same format as `assets` | `https://example.com/variant.jpg` |
108
155
  | `variantFacets` | Same format as `facets` | `Material:Cotton` |
109
156
  | `enabled` | `true` or `false` | `true` |
110
- | Custom fields | Column name = custom field name; value depends on field type | Add columns for any Product or ProductVariant custom fields defined in your Vendure config |
157
+ | Custom fields | Column name = custom field name; value depends on field type | Add columns for any Product or ProductVariant custom fields defined in your Vendure config. Relation custom fields export the related entity's id (`id\|id` for list fields), including fields that relate a product or variant to its own entity type. |
111
158
 
112
159
  #### Import behavior rules
113
160
 
@@ -185,6 +232,9 @@ The Admin UI offers basic import and export. Some features such as the export-al
185
232
  1. In the Admin UI or Dashboard, select products to export (or use bulk export).
186
233
  2. Configure export fields (assets, facets, custom fields, etc.).
187
234
  - For products with more than one variant, `optionGroups` and `optionValues` must be included.
235
+ - `id` (the Vendure product id) is available as a selectable export field. It is written after the translated `name`/`slug`/`description` columns, so it is never CSV column 0, since import treats column 0 positionally as a product id for by-id matching.
236
+ - If `customExportColumns` is configured, only the columns whose `name` is selected are written to the CSV.
237
+ - The job reports progress per page; the Dashboard job queue shows it.
188
238
  - `productId` is not available as a selectable export field.
189
239
  - If `customFields` are not selected, no custom-field columns are written to the CSV.
190
240
  3. Choose asset format: URL or JSON.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haus-tech/product-import-export-plugin",
3
- "version": "3.6.2",
3
+ "version": "3.6.4",
4
4
  "description": "A Vendure plugin for importing and exporting products using a CSV file",
5
5
  "author": "Haus Tech",
6
6
  "repository": {
@@ -36,7 +36,6 @@
36
36
  "src",
37
37
  "assets",
38
38
  "README.md",
39
- "README.mdx",
40
39
  "CHANGELOG.md"
41
40
  ],
42
41
  "scripts": {
@@ -48,7 +47,6 @@
48
47
  "dependencies": {
49
48
  "@aws-sdk/client-s3": "^3.744.0",
50
49
  "axios": "^1.16.1",
51
- "bottleneck": "^2.19.5",
52
50
  "fs-extra": "^11.2.0",
53
51
  "lodash": "^4.18.1"
54
52
  },
@@ -1,8 +1,38 @@
1
1
  import { RequestContext } from '@vendure/core';
2
2
  import { PluginInitOptions } from '../types';
3
+ /**
4
+ * The subset of plugin options that the admin UIs need. This is an explicit
5
+ * allow-list: the raw options object carries storage strategies (and therefore
6
+ * cloud credentials) and MUST never be serialized to a client.
7
+ */
8
+ export type PublicPluginConfig = {
9
+ importOptions: {
10
+ visibleOptions?: PluginInitOptions['importOptions']['visibleOptions'];
11
+ defaultOptions: {
12
+ updateProductSlug?: boolean;
13
+ restoreSoftDeleted?: boolean;
14
+ };
15
+ };
16
+ exportOptions: {
17
+ defaultFileName?: string;
18
+ exportAssetsAsOptions?: PluginInitOptions['exportOptions']['exportAssetsAsOptions'];
19
+ defaultExportAssetsAs?: PluginInitOptions['exportOptions']['defaultExportAssetsAs'];
20
+ defaultExportFields?: PluginInitOptions['exportOptions']['defaultExportFields'];
21
+ requiredExportFields?: PluginInitOptions['exportOptions']['requiredExportFields'];
22
+ customExportColumns?: Array<{
23
+ name: string;
24
+ }>;
25
+ };
26
+ };
27
+ export type PublicChannelInfo = {
28
+ code: string;
29
+ defaultLanguageCode: string;
30
+ availableLanguageCodes: string[];
31
+ };
32
+ export declare function toPublicPluginConfig(options: PluginInitOptions): PublicPluginConfig;
3
33
  export declare class ProductImportExportPluginController {
4
34
  private options;
5
35
  constructor(options: PluginInitOptions);
6
- getConfig(): PluginInitOptions;
7
- getChannel(ctx: RequestContext): import("@vendure/core").Channel;
36
+ getConfig(): PublicPluginConfig;
37
+ getChannel(ctx: RequestContext): PublicChannelInfo;
8
38
  }
@@ -13,34 +13,60 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.ProductImportExportPluginController = void 0;
16
+ exports.toPublicPluginConfig = toPublicPluginConfig;
16
17
  const core_1 = require("@vendure/core");
17
18
  const common_1 = require("@nestjs/common");
18
19
  const constants_1 = require("../constants");
20
+ function toPublicPluginConfig(options) {
21
+ const { importOptions, exportOptions } = options;
22
+ return {
23
+ importOptions: {
24
+ visibleOptions: importOptions?.visibleOptions,
25
+ // Pick fields one by one: the ImportOptions type also permits storage
26
+ // strategies inside defaultOptions, so a raw copy could leak credentials.
27
+ defaultOptions: {
28
+ updateProductSlug: importOptions?.defaultOptions?.updateProductSlug,
29
+ restoreSoftDeleted: importOptions?.defaultOptions?.restoreSoftDeleted,
30
+ },
31
+ },
32
+ exportOptions: {
33
+ defaultFileName: exportOptions?.defaultFileName,
34
+ exportAssetsAsOptions: exportOptions?.exportAssetsAsOptions,
35
+ defaultExportAssetsAs: exportOptions?.defaultExportAssetsAs,
36
+ defaultExportFields: exportOptions?.defaultExportFields,
37
+ requiredExportFields: exportOptions?.requiredExportFields,
38
+ customExportColumns: exportOptions?.customExportColumns?.map(({ name }) => ({ name })),
39
+ },
40
+ };
41
+ }
19
42
  let ProductImportExportPluginController = class ProductImportExportPluginController {
20
43
  options;
21
44
  constructor(options) {
22
45
  this.options = options;
23
46
  }
24
47
  getConfig() {
25
- return this.options;
48
+ return toPublicPluginConfig(this.options);
26
49
  }
27
50
  getChannel(ctx) {
28
- return ctx.channel;
51
+ const { code, defaultLanguageCode, availableLanguageCodes } = ctx.channel;
52
+ return { code, defaultLanguageCode, availableLanguageCodes };
29
53
  }
30
54
  };
31
55
  exports.ProductImportExportPluginController = ProductImportExportPluginController;
32
56
  __decorate([
33
57
  (0, common_1.Get)('config'),
58
+ (0, core_1.Allow)(core_1.Permission.ReadCatalog, core_1.Permission.ReadProduct),
34
59
  __metadata("design:type", Function),
35
60
  __metadata("design:paramtypes", []),
36
- __metadata("design:returntype", void 0)
61
+ __metadata("design:returntype", Object)
37
62
  ], ProductImportExportPluginController.prototype, "getConfig", null);
38
63
  __decorate([
39
64
  (0, common_1.Get)('channel'),
65
+ (0, core_1.Allow)(core_1.Permission.ReadCatalog, core_1.Permission.ReadProduct),
40
66
  __param(0, (0, core_1.Ctx)()),
41
67
  __metadata("design:type", Function),
42
68
  __metadata("design:paramtypes", [core_1.RequestContext]),
43
- __metadata("design:returntype", void 0)
69
+ __metadata("design:returntype", Object)
44
70
  ], ProductImportExportPluginController.prototype, "getChannel", null);
45
71
  exports.ProductImportExportPluginController = ProductImportExportPluginController = __decorate([
46
72
  (0, common_1.Controller)('product-import-export'),
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.controller.js","sourceRoot":"","sources":["../../../../../packages/product-import-export-plugin/src/api/plugin.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wCAAmD;AACnD,2CAAwD;AACxD,4CAAmE;AAI5D,IAAM,mCAAmC,GAAzC,MAAM,mCAAmC;IACoB;IAAlE,YAAkE,OAA0B;QAA1B,YAAO,GAAP,OAAO,CAAmB;IAAG,CAAC;IAGhG,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IAGD,UAAU,CAAQ,GAAmB;QACnC,OAAO,GAAG,CAAC,OAAO,CAAA;IACpB,CAAC;CACF,CAAA;AAZY,kFAAmC;AAI9C;IADC,IAAA,YAAG,EAAC,QAAQ,CAAC;;;;oEAGb;AAGD;IADC,IAAA,YAAG,EAAC,SAAS,CAAC;IACH,WAAA,IAAA,UAAG,GAAE,CAAA;;qCAAM,qBAAc;;qEAEpC;8CAXU,mCAAmC;IAD/C,IAAA,mBAAU,EAAC,uBAAuB,CAAC;IAErB,WAAA,IAAA,eAAM,EAAC,gDAAoC,CAAC,CAAA;;GAD9C,mCAAmC,CAY/C"}
1
+ {"version":3,"file":"plugin.controller.js","sourceRoot":"","sources":["../../../../../packages/product-import-export-plugin/src/api/plugin.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAkCA,oDAqBC;AAvDD,wCAAsE;AACtE,2CAAwD;AACxD,4CAAmE;AAgCnE,SAAgB,oBAAoB,CAAC,OAA0B;IAC7D,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,OAAO,CAAA;IAChD,OAAO;QACL,aAAa,EAAE;YACb,cAAc,EAAE,aAAa,EAAE,cAAc;YAC7C,sEAAsE;YACtE,0EAA0E;YAC1E,cAAc,EAAE;gBACd,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,iBAAiB;gBACnE,kBAAkB,EAAE,aAAa,EAAE,cAAc,EAAE,kBAAkB;aACtE;SACF;QACD,aAAa,EAAE;YACb,eAAe,EAAE,aAAa,EAAE,eAAe;YAC/C,qBAAqB,EAAE,aAAa,EAAE,qBAAqB;YAC3D,qBAAqB,EAAE,aAAa,EAAE,qBAAqB;YAC3D,mBAAmB,EAAE,aAAa,EAAE,mBAAmB;YACvD,oBAAoB,EAAE,aAAa,EAAE,oBAAoB;YACzD,mBAAmB,EAAE,aAAa,EAAE,mBAAmB,EAAE,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;SACvF;KACF,CAAA;AACH,CAAC;AAGM,IAAM,mCAAmC,GAAzC,MAAM,mCAAmC;IACoB;IAAlE,YAAkE,OAA0B;QAA1B,YAAO,GAAP,OAAO,CAAmB;IAAG,CAAC;IAIhG,SAAS;QACP,OAAO,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC3C,CAAC;IAID,UAAU,CAAQ,GAAmB;QACnC,MAAM,EAAE,IAAI,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,GAAG,GAAG,CAAC,OAAO,CAAA;QACzE,OAAO,EAAE,IAAI,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,CAAA;IAC9D,CAAC;CACF,CAAA;AAfY,kFAAmC;AAK9C;IAFC,IAAA,YAAG,EAAC,QAAQ,CAAC;IACb,IAAA,YAAK,EAAC,iBAAU,CAAC,WAAW,EAAE,iBAAU,CAAC,WAAW,CAAC;;;;oEAGrD;AAID;IAFC,IAAA,YAAG,EAAC,SAAS,CAAC;IACd,IAAA,YAAK,EAAC,iBAAU,CAAC,WAAW,EAAE,iBAAU,CAAC,WAAW,CAAC;IAC1C,WAAA,IAAA,UAAG,GAAE,CAAA;;qCAAM,qBAAc;;qEAGpC;8CAdU,mCAAmC;IAD/C,IAAA,mBAAU,EAAC,uBAAuB,CAAC;IAErB,WAAA,IAAA,eAAM,EAAC,gDAAoC,CAAC,CAAA;;GAD9C,mCAAmC,CAe/C"}
@@ -11,6 +11,7 @@ export declare class ProductExportController {
11
11
  private productExportQueueService;
12
12
  constructor(options: PluginInitOptions, exportStorageStrategy: ExportStorageStrategy, productExportService: ProductExportService, productExportQueueService: ProductExportQueueService);
13
13
  private validateExportFileName;
14
+ private validateNameFieldPresent;
14
15
  private validateOptionColumnsForMultiVariantExport;
15
16
  exportProducts(ctx: RequestContext, res: Response, fileName: string, customFields: string, exportAssetsAs: 'url' | 'json', selectedExportFields: string, selection: ID[]): Promise<void>;
16
17
  exportAllProducts(ctx: RequestContext, fileName: string, customFields: string, exportAssetsAs: 'url' | 'json', selectedExportFields: string): Promise<{
@@ -46,6 +46,15 @@ let ProductExportController = class ProductExportController {
46
46
  }
47
47
  return trimmed;
48
48
  }
49
+ validateNameFieldPresent(selectedExportFields) {
50
+ const selected = new Set(selectedExportFields
51
+ .split(',')
52
+ .map((field) => field.trim())
53
+ .filter(Boolean));
54
+ if (!selected.has('name')) {
55
+ throw new common_1.UnprocessableEntityException('name is a required export field');
56
+ }
57
+ }
49
58
  async validateOptionColumnsForMultiVariantExport(ctx, selectedExportFields, selectionIds) {
50
59
  const selected = new Set(selectedExportFields
51
60
  .split(',')
@@ -84,6 +93,7 @@ let ProductExportController = class ProductExportController {
84
93
  if (!customFields) {
85
94
  customFields = '';
86
95
  }
96
+ this.validateNameFieldPresent(selectedExportFields);
87
97
  await this.validateOptionColumnsForMultiVariantExport(ctx, selectedExportFields, selection);
88
98
  const job = await this.productExportQueueService.triggerExportWithSelection(ctx, fileName, customFields, exportAssetsAs, selectedExportFields, selection);
89
99
  if (!job || !job.id) {
@@ -114,6 +124,7 @@ let ProductExportController = class ProductExportController {
114
124
  if (!customFields) {
115
125
  customFields = '';
116
126
  }
127
+ this.validateNameFieldPresent(selectedExportFields);
117
128
  await this.validateOptionColumnsForMultiVariantExport(ctx, selectedExportFields);
118
129
  const job = await this.productExportQueueService.triggerExport(ctx, fileName, customFields, exportAssetsAs, selectedExportFields, true);
119
130
  return {
@@ -176,6 +187,7 @@ let ProductExportController = class ProductExportController {
176
187
  exports.ProductExportController = ProductExportController;
177
188
  __decorate([
178
189
  (0, common_1.Post)('export'),
190
+ (0, core_1.Allow)(core_1.Permission.UpdateCatalog, core_1.Permission.UpdateProduct),
179
191
  __param(0, (0, core_1.Ctx)()),
180
192
  __param(1, (0, common_1.Res)()),
181
193
  __param(2, (0, common_1.Query)('fileName')),
@@ -189,6 +201,7 @@ __decorate([
189
201
  ], ProductExportController.prototype, "exportProducts", null);
190
202
  __decorate([
191
203
  (0, common_1.Post)('export-all'),
204
+ (0, core_1.Allow)(core_1.Permission.UpdateCatalog, core_1.Permission.UpdateProduct),
192
205
  __param(0, (0, core_1.Ctx)()),
193
206
  __param(1, (0, common_1.Query)('fileName')),
194
207
  __param(2, (0, common_1.Query)('customFields')),
@@ -200,6 +213,7 @@ __decorate([
200
213
  ], ProductExportController.prototype, "exportAllProducts", null);
201
214
  __decorate([
202
215
  (0, common_1.Get)('download/:fileName'),
216
+ (0, core_1.Allow)(core_1.Permission.ReadCatalog, core_1.Permission.ReadProduct),
203
217
  __param(0, (0, core_1.Ctx)()),
204
218
  __param(1, (0, common_1.Res)()),
205
219
  __param(2, (0, common_1.Param)('fileName')),
@@ -209,6 +223,7 @@ __decorate([
209
223
  ], ProductExportController.prototype, "downloadExport", null);
210
224
  __decorate([
211
225
  (0, common_1.Delete)('delete/:fileName'),
226
+ (0, core_1.Allow)(core_1.Permission.UpdateCatalog, core_1.Permission.UpdateProduct),
212
227
  __param(0, (0, core_1.Ctx)()),
213
228
  __param(1, (0, common_1.Param)('fileName')),
214
229
  __metadata("design:type", Function),
@@ -217,6 +232,7 @@ __decorate([
217
232
  ], ProductExportController.prototype, "deleteExport", null);
218
233
  __decorate([
219
234
  (0, common_1.Post)('custom-fields'),
235
+ (0, core_1.Allow)(core_1.Permission.ReadCatalog, core_1.Permission.ReadProduct),
220
236
  __param(0, (0, core_1.Ctx)()),
221
237
  __param(1, (0, common_1.Body)()),
222
238
  __metadata("design:type", Function),
@@ -225,6 +241,7 @@ __decorate([
225
241
  ], ProductExportController.prototype, "getCustomFields", null);
226
242
  __decorate([
227
243
  (0, common_1.Get)('exported-files'),
244
+ (0, core_1.Allow)(core_1.Permission.ReadCatalog, core_1.Permission.ReadProduct),
228
245
  __param(0, (0, core_1.Ctx)()),
229
246
  __metadata("design:type", Function),
230
247
  __metadata("design:paramtypes", [core_1.RequestContext]),
@@ -1 +1 @@
1
- {"version":3,"file":"product-export.controller.js","sourceRoot":"","sources":["../../../../../packages/product-import-export-plugin/src/api/product-export.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wCAAuD;AACvD,2CAWuB;AAEvB,+EAAyE;AACzE,2FAAoF;AACpF,4CAA4F;AAKrF,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAEsB;IACb;IACjC;IACA;IAJV,YACwD,OAA0B,EACvC,qBAA4C,EAC7E,oBAA0C,EAC1C,yBAAoD;QAHN,YAAO,GAAP,OAAO,CAAmB;QACvC,0BAAqB,GAArB,qBAAqB,CAAuB;QAC7E,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,8BAAyB,GAAzB,yBAAyB,CAA2B;IAC3D,CAAC;IAEI,sBAAsB,CAAC,QAAgB;QAC7C,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAA;QAC/B,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;QACrC,CAAC;QAED,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YACpD,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;QACrC,CAAC;QAED,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;QACrC,CAAC;QAED,kDAAkD;QAClD,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;QACrC,CAAC;QAED,OAAO,O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AA;;qCAAlC,qBAAc;;2DAY5C;AAGK;IADL,IAAA,aAAI,EAAC,eAAe,CAAC;IACC,WAAA,IAAA,UAAG,GAAE,CAAA;IAAuB,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAvB,qBAAc;;8DAE/C;AAGK;IADL,IAAA,YAAG,EAAC,gBAAgB,CAAC;IACA,WAAA,IAAA,UAAG,GAAE,CAAA;;qCAAM,qBAAc;;6DAM9C;kCAzNU,uBAAuB;IADnC,IAAA,mBAAU,EAAC,gBAAgB,CAAC;IAGxB,WAAA,IAAA,eAAM,EAAC,gDAAoC,CAAC,CAAA;IAC5C,WAAA,IAAA,eAAM,EAAC,mCAAuB,CAAC,CAAA;qDACF,6CAAoB;QACf,wDAAyB;GALnD,uBAAuB,CAoOnC"}
1
+ {"version":3,"file":"product-export.controller.js","sourceRoot":"","sources":["../../../../../packages/product-import-export-plugin/src/api/product-export.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wCAA0E;AAC1E,2CAWuB;AAEvB,+EAAyE;AACzE,2FAAoF;AACpF,4CAA4F;AAKrF,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAEsB;IACb;IACjC;IACA;IAJV,YACwD,OAA0B,EACvC,qBAA4C,EAC7E,oBAA0C,EAC1C,yBAAoD;QAHN,YAAO,GAAP,OAAO,CAAmB;QACvC,0BAAqB,GAArB,qBAAqB,CAAuB;QAC7E,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,8BAAyB,GAAzB,yBAAyB,CAA2B;IAC3D,CAAC;IAEI,sBAAsB,CAAC,QAAgB;QAC7C,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAA;QAC/B,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;QACrC,CAAC;QAED,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,CA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AC,iBAAU,CAAC,WAAW,EAAE,iBAAU,CAAC,WAAW,CAAC;IAC/B,WAAA,IAAA,UAAG,GAAE,CAAA;IAAuB,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAvB,qBAAc;;8DAE/C;AAIK;IAFL,IAAA,YAAG,EAAC,gBAAgB,CAAC;IACrB,IAAA,YAAK,EAAC,iBAAU,CAAC,WAAW,EAAE,iBAAU,CAAC,WAAW,CAAC;IAChC,WAAA,IAAA,UAAG,GAAE,CAAA;;qCAAM,qBAAc;;6DAM9C;kCA9OU,uBAAuB;IADnC,IAAA,mBAAU,EAAC,gBAAgB,CAAC;IAGxB,WAAA,IAAA,eAAM,EAAC,gDAAoC,CAAC,CAAA;IAC5C,WAAA,IAAA,eAAM,EAAC,mCAAuB,CAAC,CAAA;qDACF,6CAAoB;QACf,wDAAyB;GALnD,uBAAuB,CAyPnC"}
@@ -45,6 +45,7 @@ let ProductImportController = class ProductImportController {
45
45
  exports.ProductImportController = ProductImportController;
46
46
  __decorate([
47
47
  (0, common_1.Post)('/upload'),
48
+ (0, core_1.Allow)(core_1.Permission.UpdateCatalog, core_1.Permission.UpdateProduct),
48
49
  (0, common_1.UseInterceptors)((0, platform_express_1.FileInterceptor)('file')),
49
50
  __param(0, (0, core_1.Ctx)()),
50
51
  __param(1, (0, common_1.UploadedFile)()),
@@ -1 +1 @@
1
- {"version":3,"file":"product-import.controller.js","sourceRoot":"","sources":["../../../../../packages/product-import-export-plugin/src/api/product-import.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wCAAiE;AACjE,2CAQuB;AAEvB,+DAA0D;AAC1D,4CAAmE;AAEnE,+EAAyE;AAGlE,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAEsB;IAC9C;IAFV,YACwD,OAA0B,EACxE,OAA6B;QADiB,YAAO,GAAP,OAAO,CAAmB;QACxE,YAAO,GAAP,OAAO,CAAsB;IACpC,CAAC;IAIE,AAAN,KAAK,CAAC,cAAc,CACX,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Ac;;6DA8B3B;kCAvCU,uBAAuB;IADnC,IAAA,mBAAU,EAAC,gBAAgB,CAAC;IAGxB,WAAA,IAAA,eAAM,EAAC,gDAAoC,CAAC,CAAA;6CAC5B,6CAAoB;GAH5B,uBAAuB,CAwCnC"}
1
+ {"version":3,"file":"product-import.controller.js","sourceRoot":"","sources":["../../../../../packages/product-import-export-plugin/src/api/product-import.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,wCAAoF;AACpF,2CAQuB;AAEvB,+DAA0D;AAC1D,4CAAmE;AAEnE,+EAAyE;AAGlE,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAEsB;IAC9C;IAFV,YACwD,OAA0B,EACxE,OAA6B;QADiB,YAAO,GAAP,OAAO,CAAmB;QACxE,YAAO,GAAP,OAAO,CAAsB;IACpC,CAAC;IAKE,AAAN,KAAK,CAAC,cAAc,CACX,GAAmB,EACV,IAAyB,EAEzC,oBAAuC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,cAAc;QAC9E,EAAE,iBAAyB,IAAI,MAAM,EACjB,YAA0B,EACtB,gBAAkC,EAE5D,GAAa;QAEb,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;QACjD,CAAC;QAED,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAA;QACzD,CAAC;QAED,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,OAAO,CAAC,WAAW,CAC5B,GAAG,EACH,IAAI,EACJ,iBAAiB,KAAK,MAAM,EAC5B,YAAY,EACZ,gBAAgB,CACjB,CAAA;YACD,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAA;QAC3D,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAE,KAAe,EAAE,OAAO,IAAI,uBAAuB,CAAC,CAAA;QACnF,CAAC;IACH,CAAC;CACF,CAAA;AAzCY,0DAAuB;AAS5B;IAHL,IAAA,aAAI,EAAC,SAAS,CAAC;IACf,IAAA,YAAK,EAAC,iBAAU,CAAC,aAAa,EAAE,iBAAU,CAAC,aAAa,CAAC;IACzD,IAAA,wBAAe,EAAC,IAAA,kCAAe,EAAC,MAAM,CAAC,CAAC;IAEtC,WAAA,IAAA,UAAG,GAAE,CAAA;IACL,WAAA,IAAA,qBAAY,GAAE,CAAA;IACd,WAAA,IAAA,aAAI,EAAC,mBAAmB,CAAC,CAAA;IAGzB,WAAA,IAAA,aAAI,EAAC,cAAc,CAAC,CAAA;IACpB,WAAA,IAAA,aAAI,EAAC,kBAAkB,CAAC,CAAA;IACxB,WAAA,IAAA,YAAG,GAAE,CAAA;;qCAPM,qBAAc;;6DA8B3B;kCAxCU,uBAAuB;IADnC,IAAA,mBAAU,EAAC,gBAAgB,CAAC;IAGxB,WAAA,IAAA,eAAM,EAAC,gDAAoC,CAAC,CAAA;6CAC5B,6CAAoB;GAH5B,uBAAuB,CAyCnC"}
@@ -34,6 +34,7 @@ const AVAILABLE_EXPORT_FIELDS: ExportFields = [
34
34
  'name',
35
35
  'slug',
36
36
  'description',
37
+ 'id',
37
38
  'assets',
38
39
  'facets',
39
40
  'optionGroups',
@@ -87,6 +88,8 @@ export const ExportConfigurationPanel = forwardRef<
87
88
  const [fileName, setFileName] = useState('')
88
89
  const [customFieldNames, setCustomFieldNames] = useState<string[]>([])
89
90
  const [selectedCustomFields, setSelectedCustomFields] = useState<string[]>([])
91
+ const [customColumnNames, setCustomColumnNames] = useState<string[]>([])
92
+ const [selectedCustomColumns, setSelectedCustomColumns] = useState<string[]>([])
90
93
  const [exportAssetsAs, setExportAssetsAs] = useState<'url' | 'json'>('url')
91
94
  const [selectedExportFields, setSelectedExportFields] = useState<ExportFields>([])
92
95
  const [toggleAllChecked, setToggleAllChecked] = useState(false)
@@ -129,6 +132,11 @@ export const ExportConfigurationPanel = forwardRef<
129
132
  setCustomFieldNames(names)
130
133
  setSelectedCustomFields([...names])
131
134
 
135
+ const columnNames: string[] =
136
+ configData.exportOptions?.customExportColumns?.map((c: { name: string }) => c.name) ?? []
137
+ setCustomColumnNames(columnNames)
138
+ setSelectedCustomColumns([...columnNames])
139
+
132
140
  const defaultAssets =
133
141
  configData.exportOptions?.defaultExportAssetsAs ||
134
142
  configData.exportOptions?.exportAssetsAsOptions?.[0] ||
@@ -157,8 +165,15 @@ export const ExportConfigurationPanel = forwardRef<
157
165
  const allCustom =
158
166
  customFieldNames.length === 0 ||
159
167
  customFieldNames.every((f) => selectedCustomFields.includes(f))
160
- return allStandard && allCustom
161
- }, [selectedExportFields, selectedCustomFields, customFieldNames])
168
+ const allCustomColumns = customColumnNames.every((c) => selectedCustomColumns.includes(c))
169
+ return allStandard && allCustom && allCustomColumns
170
+ }, [
171
+ selectedExportFields,
172
+ selectedCustomFields,
173
+ customFieldNames,
174
+ selectedCustomColumns,
175
+ customColumnNames,
176
+ ])
162
177
 
163
178
  useEffect(() => {
164
179
  setToggleAllChecked(derivedToggleAll)
@@ -170,6 +185,12 @@ export const ExportConfigurationPanel = forwardRef<
170
185
  )
171
186
  }
172
187
 
188
+ const toggleCustomColumn = (name: string) => {
189
+ setSelectedCustomColumns((prev) =>
190
+ prev.includes(name) ? prev.filter((c) => c !== name) : [...prev, name],
191
+ )
192
+ }
193
+
173
194
  const toggleExportField = (fieldName: ProductFields | VariantFields) => {
174
195
  if (MANDATORY_OPTION_FIELDS.includes(fieldName)) return
175
196
  setSelectedExportFields((prev) =>
@@ -182,9 +203,11 @@ export const ExportConfigurationPanel = forwardRef<
182
203
  if (checked) {
183
204
  setSelectedExportFields([...AVAILABLE_EXPORT_FIELDS])
184
205
  setSelectedCustomFields([...customFieldNames])
206
+ setSelectedCustomColumns([...customColumnNames])
185
207
  } else {
186
208
  setSelectedExportFields([...(config?.requiredExportFields || []), ...MANDATORY_OPTION_FIELDS])
187
209
  setSelectedCustomFields([])
210
+ setSelectedCustomColumns([])
188
211
  }
189
212
  }
190
213
 
@@ -206,7 +229,7 @@ export const ExportConfigurationPanel = forwardRef<
206
229
  )}&customFields=${encodeURIComponent(
207
230
  selectedCustomFields.join(','),
208
231
  )}&exportAssetsAs=${exportAssetsAs}&selectedExportFields=${encodeURIComponent(
209
- selectedExportFields.join(','),
232
+ [...selectedExportFields, ...selectedCustomColumns].join(','),
210
233
  )}`,
211
234
  {
212
235
  method: 'POST',
@@ -242,6 +265,7 @@ export const ExportConfigurationPanel = forwardRef<
242
265
  selectedCustomFields,
243
266
  exportAssetsAs,
244
267
  selectedExportFields,
268
+ selectedCustomColumns,
245
269
  onExportSuccess,
246
270
  ])
247
271
 
@@ -328,6 +352,26 @@ export const ExportConfigurationPanel = forwardRef<
328
352
  </div>
329
353
  </div>
330
354
  )}
355
+
356
+ {customColumnNames.length > 0 && (
357
+ <div className="space-y-2 pt-4 border-t">
358
+ <Label className="text-muted-foreground pb-2">Custom columns</Label>
359
+ <div className="grid grid-cols-1 sm:grid-cols-2 gap-2">
360
+ {customColumnNames.map((name) => (
361
+ <div key={name} className="flex items-center space-x-2">
362
+ <Checkbox
363
+ id={`${idPrefix}-custom-column-${name}`}
364
+ checked={selectedCustomColumns.includes(name)}
365
+ onCheckedChange={() => toggleCustomColumn(name)}
366
+ />
367
+ <Label htmlFor={`${idPrefix}-custom-column-${name}`} className="font-normal">
368
+ {name}
369
+ </Label>
370
+ </div>
371
+ ))}
372
+ </div>
373
+ </div>
374
+ )}
331
375
  </AccordionContent>
332
376
  </AccordionItem>
333
377
  </Accordion>
@@ -38,9 +38,9 @@ import {
38
38
  } from './utils'
39
39
 
40
40
  const TEMPLATE_URL =
41
- 'https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/blob/main/packages/product-import-export-plugin/README.mdx#csv-format-for-import'
41
+ 'https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/blob/main/packages/product-import-export-plugin/README.md#csv-format-for-import'
42
42
  const GUIDE_URL =
43
- 'https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/blob/main/packages/product-import-export-plugin/README.mdx'
43
+ 'https://github.com/WeAreHausTech/haus-tech-vendure-plugins-public/blob/main/packages/product-import-export-plugin/README.md'
44
44
 
45
45
  const MAX_SIZE_BYTES = 20 * 1024 * 1024
46
46
 
@@ -13,6 +13,7 @@ export type ValidateReturnType = {
13
13
  }
14
14
 
15
15
  export type ProductFields =
16
+ | 'id'
16
17
  | 'name'
17
18
  | 'slug'
18
19
  | 'description'
@@ -42,6 +43,7 @@ export interface PluginInitOptions {
42
43
  defaultExportAssetsAs?: 'url' | 'json'
43
44
  defaultExportFields?: ExportFields
44
45
  requiredExportFields?: ExportFields
46
+ customExportColumns?: Array<{ name: string }>
45
47
  }
46
48
  }
47
49
 
@@ -56,8 +58,23 @@ export const getServerLocation = (): string => {
56
58
  return origin
57
59
  }
58
60
 
59
- // Return vendure-token header if a non-default channel has been selected in the Dashboard
61
+ // Same localStorage keys as @vendure/dashboard's own API client (LS_KEY_SELECTED_CHANNEL_TOKEN /
62
+ // LS_KEY_SESSION_TOKEN). The plugin's REST routes require admin permissions, so every fetch must
63
+ // carry the session token too, not only cookies: on a server configured with tokenMethod 'bearer'
64
+ // there is no session cookie and credentials: 'include' alone would yield 403.
65
+ const LS_KEY_SELECTED_CHANNEL_TOKEN = 'vendure-selected-channel-token'
66
+ const LS_KEY_SESSION_TOKEN = 'vendure-session-token'
67
+
68
+ // Return vendure-token (if a non-default channel is selected) and Authorization headers
60
69
  export const getChannelHeader = (): Record<string, string> => {
61
- const token = localStorage.getItem('vendure-selected-channel-token')
62
- return token ? { 'vendure-token': token } : {}
70
+ const headers: Record<string, string> = {}
71
+ const channelToken = localStorage.getItem(LS_KEY_SELECTED_CHANNEL_TOKEN)
72
+ if (channelToken) {
73
+ headers['vendure-token'] = channelToken
74
+ }
75
+ const sessionToken = localStorage.getItem(LS_KEY_SESSION_TOKEN)
76
+ if (sessionToken) {
77
+ headers.authorization = `Bearer ${sessionToken}`
78
+ }
79
+ return headers
63
80
  }
package/src/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from './product-import-export.plugin';
2
- export type { PluginInitOptions, UpdatingStrategy, JsonAsset } from './types';
2
+ export type { PluginInitOptions, UpdatingStrategy, JsonAsset, CustomExportColumn } from './types';
3
3
  export * from './services/export-storage/export-storage-strategy';
4
4
  export * from './services/export-storage/local-export-storage-strategy';
5
5
  export * from './services/export-storage/s3-export-storage-strategy';