@kontent-ai/migration-toolkit 1.5.0 → 2.0.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.
Files changed (59) hide show
  1. package/dist/es2022/core/models/migration.models.d.ts +4 -5
  2. package/dist/es2022/core/models/migration.schema.d.ts +46 -233
  3. package/dist/es2022/core/models/migration.schema.js +7 -22
  4. package/dist/es2022/core/models/migration.schema.js.map +1 -1
  5. package/dist/es2022/core/utils/binary-data.utils.d.ts +1 -0
  6. package/dist/es2022/core/utils/binary-data.utils.js.map +1 -1
  7. package/dist/es2022/export/export-manager.d.ts +1 -1
  8. package/dist/es2022/export/export-manager.js +6 -5
  9. package/dist/es2022/export/export-manager.js.map +1 -1
  10. package/dist/es2022/export/export.models.d.ts +4 -3
  11. package/dist/es2022/import/comparers/asset-comparer.js +2 -2
  12. package/dist/es2022/import/comparers/asset-comparer.js.map +1 -1
  13. package/dist/es2022/import/import.models.d.ts +2 -2
  14. package/dist/es2022/import/importers/assets-importer.js +15 -7
  15. package/dist/es2022/import/importers/assets-importer.js.map +1 -1
  16. package/dist/es2022/import/importers/language-variant-importer.js +4 -4
  17. package/dist/es2022/import/importers/language-variant-importer.js.map +1 -1
  18. package/dist/es2022/metadata.js +2 -2
  19. package/dist/es2022/toolkit/file.js +3 -2
  20. package/dist/es2022/toolkit/file.js.map +1 -1
  21. package/dist/es2022/translation/extraction/items-extraction.processor.d.ts +2 -2
  22. package/dist/es2022/translation/extraction/items-extraction.processor.js +10 -4
  23. package/dist/es2022/translation/extraction/items-extraction.processor.js.map +1 -1
  24. package/dist/es2022/translation/helpers/rich-text.processor.d.ts +2 -0
  25. package/dist/es2022/translation/helpers/rich-text.processor.js +56 -1
  26. package/dist/es2022/translation/helpers/rich-text.processor.js.map +1 -1
  27. package/dist/es2022/translation/transforms/export-transforms.js +131 -83
  28. package/dist/es2022/translation/transforms/export-transforms.js.map +1 -1
  29. package/dist/es2022/translation/transforms/import-transforms.js +22 -19
  30. package/dist/es2022/translation/transforms/import-transforms.js.map +1 -1
  31. package/dist/es2022/zip/zip-manager.d.ts +1 -0
  32. package/dist/es2022/zip/zip-manager.js +1 -1
  33. package/dist/es2022/zip/zip-manager.js.map +1 -1
  34. package/dist/es2022/zip/zip-packager.js +2 -1
  35. package/dist/es2022/zip/zip-packager.js.map +1 -1
  36. package/dist/es2022/zip/zip-transformer.d.ts +1 -1
  37. package/dist/es2022/zip/zip-transformer.js +3 -3
  38. package/dist/es2022/zip/zip-transformer.js.map +1 -1
  39. package/dist/es2022/zip/zip.models.d.ts +1 -0
  40. package/lib/core/models/migration.models.ts +12 -15
  41. package/lib/core/models/migration.schema.ts +11 -36
  42. package/lib/core/utils/binary-data.utils.ts +1 -0
  43. package/lib/export/export-manager.ts +22 -21
  44. package/lib/export/export.models.ts +18 -17
  45. package/lib/import/comparers/asset-comparer.ts +2 -2
  46. package/lib/import/import.models.ts +17 -17
  47. package/lib/import/importers/assets-importer.ts +25 -16
  48. package/lib/import/importers/language-variant-importer.ts +13 -13
  49. package/lib/metadata.ts +2 -2
  50. package/lib/toolkit/file.ts +3 -2
  51. package/lib/translation/extraction/items-extraction.processor.ts +16 -9
  52. package/lib/translation/helpers/rich-text.processor.ts +81 -1
  53. package/lib/translation/transforms/export-transforms.ts +143 -103
  54. package/lib/translation/transforms/import-transforms.ts +27 -31
  55. package/lib/zip/zip-manager.ts +2 -1
  56. package/lib/zip/zip-packager.ts +4 -3
  57. package/lib/zip/zip-transformer.ts +4 -4
  58. package/lib/zip/zip.models.ts +1 -0
  59. package/package.json +14 -13
@@ -1,21 +1,20 @@
1
- import {
2
- MigrationElementType,
3
- MigrationReference,
4
- MigrationRichTextElementValue,
5
- MigrationUrlSlugElementValue,
6
- findRequired,
7
- isNotUndefined
8
- } from '../../core/index.js';
9
1
  import { ContentTypeElements, TaxonomyModels } from '@kontent-ai/management-sdk';
10
- import { ExportTransformFunc, ExportContext, ExportElement } from '../../export/index.js';
11
- import { richTextProcessor } from '../helpers/rich-text.processor.js';
12
2
  import chalk from 'chalk';
3
+ import { MigrationElementTransformData, MigrationElementType, MigrationReference, findRequired, isNotUndefined } from '../../core/index.js';
4
+ import { ExportContext, ExportElement, ExportTransformFunc } from '../../export/index.js';
5
+ import { richTextProcessor } from '../helpers/rich-text.processor.js';
13
6
 
14
7
  export const exportTransforms: Readonly<Record<MigrationElementType, ExportTransformFunc>> = {
15
- text: (data) => data.exportElement.value?.toString(),
8
+ text: (data) => {
9
+ return {
10
+ value: data.exportElement.value?.toString()
11
+ };
12
+ },
16
13
  number: (data) => {
17
- if (!data.exportElement.value) {
18
- return undefined;
14
+ if (data.exportElement.value === undefined || data.exportElement.value === null) {
15
+ return {
16
+ value: undefined
17
+ };
19
18
  }
20
19
 
21
20
  if (Array.isArray(data.exportElement.value)) {
@@ -23,40 +22,55 @@ export const exportTransforms: Readonly<Record<MigrationElementType, ExportTrans
23
22
  }
24
23
 
25
24
  if (data.exportElement.value === 0) {
26
- return 0;
25
+ return {
26
+ value: 0
27
+ };
27
28
  }
28
29
 
29
- return +data.exportElement.value;
30
+ return {
31
+ value: +data.exportElement.value
32
+ };
33
+ },
34
+ date_time: (data) => {
35
+ return {
36
+ value: data.exportElement.value?.toString(),
37
+ display_timezone: data.exportElement.displayTimezone ?? undefined
38
+ };
30
39
  },
31
- date_time: (data) => data.exportElement.value?.toString(),
32
40
  rich_text: (data) => transformRichTextValue(data.exportElement, data.context),
33
41
  asset: (data) => {
34
42
  if (!data.exportElement.value) {
35
- return [];
43
+ return {
44
+ value: []
45
+ };
36
46
  }
37
47
 
38
48
  if (!Array.isArray(data.exportElement.value)) {
39
49
  throw Error(`Expected value to be an array`);
40
50
  }
41
51
 
42
- // translate asset id to codename
43
- return data.exportElement.value
44
- .map((m) => m.id)
45
- .filter(isNotUndefined)
46
- .map<MigrationReference>((id) => {
47
- const assetState = data.context.getAssetStateInSourceEnvironment(id);
48
-
49
- if (assetState.asset) {
50
- // reference asset by codename
51
- return { codename: assetState.asset.codename };
52
- } else {
53
- throw Error(`Missing asset with id '${chalk.red(id)}'`);
54
- }
55
- });
52
+ return {
53
+ // translate asset id to codename
54
+ value: data.exportElement.value
55
+ .map((m) => m.id)
56
+ .filter(isNotUndefined)
57
+ .map<MigrationReference>((id) => {
58
+ const assetState = data.context.getAssetStateInSourceEnvironment(id);
59
+
60
+ if (assetState.asset) {
61
+ // reference asset by codename
62
+ return { codename: assetState.asset.codename };
63
+ } else {
64
+ throw Error(`Missing asset with id '${chalk.red(id)}'`);
65
+ }
66
+ })
67
+ };
56
68
  },
57
69
  taxonomy: (data) => {
58
70
  if (!data.exportElement.value) {
59
- return [];
71
+ return {
72
+ value: []
73
+ };
60
74
  }
61
75
 
62
76
  if (!Array.isArray(data.exportElement.value)) {
@@ -73,57 +87,67 @@ export const exportTransforms: Readonly<Record<MigrationElementType, ExportTrans
73
87
  `Could not find taxonomy group with id '${chalk.red(taxonomyGroupId)}'`
74
88
  );
75
89
 
76
- // translate taxonomy term to codename
77
- return data.exportElement.value
78
- .map((m) => m.id)
79
- .filter(isNotUndefined)
80
- .map<MigrationReference>((id) => {
81
- const taxonomyTerm = findTaxonomy(id, taxonomy);
82
-
83
- if (taxonomyTerm) {
84
- // reference taxonomy term by codename
85
- return { codename: taxonomyTerm.codename };
86
- } else {
87
- throw Error(`Missing taxonomy term with id '${chalk.red(id)}'`);
88
- }
89
- });
90
+ return {
91
+ // translate taxonomy term to codename
92
+ value: data.exportElement.value
93
+ .map((m) => m.id)
94
+ .filter(isNotUndefined)
95
+ .map<MigrationReference>((id) => {
96
+ const taxonomyTerm = findTaxonomy(id, taxonomy);
97
+
98
+ if (taxonomyTerm) {
99
+ // reference taxonomy term by codename
100
+ return { codename: taxonomyTerm.codename };
101
+ } else {
102
+ throw Error(`Missing taxonomy term with id '${chalk.red(id)}'`);
103
+ }
104
+ })
105
+ };
90
106
  },
91
107
  modular_content: (data) => {
92
108
  if (!data.exportElement.value) {
93
- return [];
109
+ return {
110
+ value: []
111
+ };
94
112
  }
95
113
 
96
114
  if (!Array.isArray(data.exportElement.value)) {
97
115
  throw Error(`Expected value to be an array`);
98
116
  }
99
117
 
100
- // translate item id to codename
101
- return data.exportElement.value
102
- .map((m) => m.id)
103
- .filter(isNotUndefined)
104
- .map<MigrationReference>((id) => {
105
- const itemState = data.context.getItemStateInSourceEnvironment(id);
106
-
107
- if (itemState.item) {
108
- // reference item by codename
109
- return { codename: itemState.item.codename };
110
- } else {
111
- throw Error(`Missing item with id '${chalk.red(id)}'`);
112
- }
113
- });
118
+ return {
119
+ // translate item id to codename
120
+ value: data.exportElement.value
121
+ .map((m) => m.id)
122
+ .filter(isNotUndefined)
123
+ .map<MigrationReference>((id) => {
124
+ const itemState = data.context.getItemStateInSourceEnvironment(id);
125
+
126
+ if (itemState.item) {
127
+ // reference item by codename
128
+ return { codename: itemState.item.codename };
129
+ } else {
130
+ throw Error(`Missing item with id '${chalk.red(id)}'`);
131
+ }
132
+ })
133
+ };
134
+ },
135
+ custom: (data) => {
136
+ return {
137
+ value: data.exportElement.value?.toString()
138
+ };
114
139
  },
115
- custom: (data) => data.exportElement.value?.toString(),
116
140
  url_slug: (data) => {
117
- const urlSlugElementValue: MigrationUrlSlugElementValue = {
118
- mode: data.exportElement.urlSlugMode ?? 'autogenerated',
119
- value: data.exportElement.value?.toString() ?? undefined
141
+ return {
142
+ value: data.exportElement.value?.toString() ?? undefined,
143
+ mode: data.exportElement.urlSlugMode ?? 'autogenerated'
120
144
  };
121
-
122
- return urlSlugElementValue;
123
145
  },
124
146
  multiple_choice: (data) => {
125
147
  if (!data.exportElement.value) {
126
- return [];
148
+ return {
149
+ value: []
150
+ };
127
151
  }
128
152
 
129
153
  if (!Array.isArray(data.exportElement.value)) {
@@ -133,45 +157,51 @@ export const exportTransforms: Readonly<Record<MigrationElementType, ExportTrans
133
157
  // translate multiple choice option id to codename
134
158
  const multipleChoiceElement = data.typeElement.element as Readonly<ContentTypeElements.IMultipleChoiceElement>;
135
159
 
136
- return data.exportElement.value
137
- .map((m) => m.id)
138
- .filter(isNotUndefined)
139
- .map<MigrationReference>((id) => {
140
- const option = findRequired(
141
- multipleChoiceElement.options,
142
- (option) => option.id === id,
143
- `Could not find multiple choice element with option id '${chalk.red(id)}'`
144
- );
145
-
146
- if (!option.codename) {
147
- throw Error(`Invalid codename for multiple choice option '${chalk.red(option.name)}'`);
148
- }
149
-
150
- return { codename: option.codename };
151
- });
160
+ return {
161
+ value: data.exportElement.value
162
+ .map((m) => m.id)
163
+ .filter(isNotUndefined)
164
+ .map<MigrationReference>((id) => {
165
+ const option = findRequired(
166
+ multipleChoiceElement.options,
167
+ (option) => option.id === id,
168
+ `Could not find multiple choice element with option id '${chalk.red(id)}'`
169
+ );
170
+
171
+ if (!option.codename) {
172
+ throw Error(`Invalid codename for multiple choice option '${chalk.red(option.name)}'`);
173
+ }
174
+
175
+ return { codename: option.codename };
176
+ })
177
+ };
152
178
  },
153
179
  subpages: (data) => {
154
180
  if (!data.exportElement.value) {
155
- return [];
181
+ return {
182
+ value: []
183
+ };
156
184
  }
157
185
  if (!Array.isArray(data.exportElement.value)) {
158
186
  throw Error(`Expected value to be an array`);
159
187
  }
160
188
 
161
- // translate item id to codename
162
- return data.exportElement.value
163
- .map((m) => m.id)
164
- .filter(isNotUndefined)
165
- .map<MigrationReference>((id) => {
166
- const itemState = data.context.getItemStateInSourceEnvironment(id);
167
-
168
- if (itemState.item) {
169
- // reference item by codename
170
- return { codename: itemState.item.codename };
171
- } else {
172
- throw Error(`Missing item with id '${chalk.red(id)}'`);
173
- }
174
- });
189
+ return {
190
+ // translate item id to codename
191
+ value: data.exportElement.value
192
+ .map((m) => m.id)
193
+ .filter(isNotUndefined)
194
+ .map<MigrationReference>((id) => {
195
+ const itemState = data.context.getItemStateInSourceEnvironment(id);
196
+
197
+ if (itemState.item) {
198
+ // reference item by codename
199
+ return { codename: itemState.item.codename };
200
+ } else {
201
+ throw Error(`Missing item with id '${chalk.red(id)}'`);
202
+ }
203
+ })
204
+ };
175
205
  }
176
206
  };
177
207
 
@@ -191,10 +221,7 @@ function findTaxonomy(termId: string, taxonomy: Readonly<TaxonomyModels.Taxonomy
191
221
  return undefined;
192
222
  }
193
223
 
194
- function transformRichTextValue(
195
- exportElement: ExportElement | undefined,
196
- context: ExportContext
197
- ): MigrationRichTextElementValue | undefined {
224
+ function transformRichTextValue(exportElement: ExportElement | undefined, context: ExportContext): MigrationElementTransformData {
198
225
  if (!exportElement || !exportElement.value) {
199
226
  return {
200
227
  components: [],
@@ -243,6 +270,19 @@ function transformRichTextValue(
243
270
  };
244
271
  }).html;
245
272
 
273
+ // replace link asset ids with codenames
274
+ richTextHtml = richTextProcessor().processLinkAssetIds(richTextHtml, (id) => {
275
+ const assetInEnv = context.getAssetStateInSourceEnvironment(id).asset;
276
+
277
+ if (!assetInEnv) {
278
+ throw Error(`Failed to get asset with id '${chalk.red(id)}'`);
279
+ }
280
+
281
+ return {
282
+ codename: assetInEnv.codename
283
+ };
284
+ }).html;
285
+
246
286
  return {
247
287
  components: exportElement.components,
248
288
  value: richTextHtml
@@ -1,11 +1,5 @@
1
- import { SharedContracts, LanguageVariantElementsBuilder, LanguageVariantElements } from '@kontent-ai/management-sdk';
2
- import {
3
- parseAsMigrationReferencesArray,
4
- MigrationElementType,
5
- MigrationRichTextElementValue,
6
- MigrationItem,
7
- MigrationUrlSlugElementValue
8
- } from '../../core/index.js';
1
+ import { LanguageVariantElements, LanguageVariantElementsBuilder, SharedContracts } from '@kontent-ai/management-sdk';
2
+ import { MigrationElementTransformData, MigrationElementType, MigrationItem, parseAsMigrationReferencesArray } from '../../core/index.js';
9
3
  import { ImportContext, ImportTransformFunc } from '../../import/index.js';
10
4
  import { richTextProcessor } from '../helpers/rich-text.processor.js';
11
5
 
@@ -21,7 +15,7 @@ export const importTransforms: Readonly<Record<MigrationElementType, ImportTrans
21
15
  element: {
22
16
  codename: data.elementCodename
23
17
  },
24
- value: parseAsMigrationReferencesArray(data.value).map((m) => {
18
+ value: parseAsMigrationReferencesArray(data.elementData.value).map((m) => {
25
19
  return {
26
20
  codename: m.codename
27
21
  };
@@ -29,7 +23,7 @@ export const importTransforms: Readonly<Record<MigrationElementType, ImportTrans
29
23
  });
30
24
  },
31
25
  asset: (data) => {
32
- const assetReferences = parseAsMigrationReferencesArray(data.value)
26
+ const assetReferences = parseAsMigrationReferencesArray(data.elementData.value)
33
27
  .map((reference) => reference.codename)
34
28
  .map<Readonly<SharedContracts.IReferenceObjectContract>>((codename) => {
35
29
  const assetState = data.importContext.getAssetStateInTargetEnvironment(codename);
@@ -54,7 +48,7 @@ export const importTransforms: Readonly<Record<MigrationElementType, ImportTrans
54
48
  element: {
55
49
  codename: data.elementCodename
56
50
  },
57
- value: data.value?.toString() ?? ''
51
+ value: data.elementData.value?.toString() ?? ''
58
52
  });
59
53
  },
60
54
  date_time: (data) => {
@@ -62,11 +56,12 @@ export const importTransforms: Readonly<Record<MigrationElementType, ImportTrans
62
56
  element: {
63
57
  codename: data.elementCodename
64
58
  },
65
- value: data.value?.toString() ?? null
59
+ value: data.elementData.value?.toString() ?? null,
60
+ display_timezone: data.elementData.display_timezone ?? null
66
61
  });
67
62
  },
68
63
  modular_content: (data) => {
69
- const linkedItemReferences = parseAsMigrationReferencesArray(data.value)
64
+ const linkedItemReferences = parseAsMigrationReferencesArray(data.elementData.value)
70
65
  .map((reference) => reference.codename)
71
66
  .map<Readonly<SharedContracts.IReferenceObjectContract>>((codename) => {
72
67
  const itemState = data.importContext.getItemStateInTargetEnvironment(codename);
@@ -90,7 +85,7 @@ export const importTransforms: Readonly<Record<MigrationElementType, ImportTrans
90
85
  element: {
91
86
  codename: data.elementCodename
92
87
  },
93
- value: parseAsMigrationReferencesArray(data.value).map((m) => {
88
+ value: parseAsMigrationReferencesArray(data.elementData.value).map((m) => {
94
89
  return {
95
90
  codename: m.codename
96
91
  };
@@ -102,12 +97,10 @@ export const importTransforms: Readonly<Record<MigrationElementType, ImportTrans
102
97
  element: {
103
98
  codename: data.elementCodename
104
99
  },
105
- value: data.value ? +data.value : null
100
+ value: data.elementData ? +data.elementData : null
106
101
  });
107
102
  },
108
103
  rich_text: (data) => {
109
- const rteElementValue = data.value as MigrationRichTextElementValue;
110
-
111
104
  return elementsBuilder.richTextElement({
112
105
  element: {
113
106
  codename: data.elementCodename
@@ -115,11 +108,11 @@ export const importTransforms: Readonly<Record<MigrationElementType, ImportTrans
115
108
  components: mapComponents({
116
109
  importContext: data.importContext,
117
110
  migrationItems: data.migrationItems,
118
- rteValue: rteElementValue
111
+ elementData: data.elementData
119
112
  }),
120
113
  value:
121
114
  processImportRichTextHtmlValue({
122
- element: rteElementValue,
115
+ elementData: data.elementData,
123
116
  importContext: data.importContext,
124
117
  migrationItems: data.migrationItems
125
118
  }) ?? null
@@ -130,7 +123,7 @@ export const importTransforms: Readonly<Record<MigrationElementType, ImportTrans
130
123
  element: {
131
124
  codename: data.elementCodename
132
125
  },
133
- value: parseAsMigrationReferencesArray(data.value).map((m) => {
126
+ value: parseAsMigrationReferencesArray(data.elementData.value).map((m) => {
134
127
  return {
135
128
  codename: m.codename
136
129
  };
@@ -142,28 +135,26 @@ export const importTransforms: Readonly<Record<MigrationElementType, ImportTrans
142
135
  element: {
143
136
  codename: data.elementCodename
144
137
  },
145
- value: data.value?.toString() ?? null
138
+ value: data.elementData.value?.toString() ?? null
146
139
  });
147
140
  },
148
141
  url_slug: (data) => {
149
- const urlSlugElementValue = data.value as Readonly<MigrationUrlSlugElementValue>;
150
-
151
142
  return elementsBuilder.urlSlugElement({
152
143
  element: {
153
144
  codename: data.elementCodename
154
145
  },
155
- value: urlSlugElementValue.value?.toString() ?? '',
156
- mode: urlSlugElementValue.mode
146
+ value: data.elementData.value?.toString() ?? '',
147
+ mode: data.elementData.mode ?? 'autogenerated'
157
148
  });
158
149
  }
159
150
  };
160
151
 
161
152
  function mapComponents(data: {
162
- readonly rteValue: MigrationRichTextElementValue;
153
+ readonly elementData: MigrationElementTransformData;
163
154
  readonly importContext: ImportContext;
164
155
  readonly migrationItems: readonly MigrationItem[];
165
156
  }): LanguageVariantElements.IRichTextComponent[] {
166
- return data.rteValue.components.map((component) => {
157
+ return (data.elementData.components ?? []).map((component) => {
167
158
  const mappedComponent: Readonly<LanguageVariantElements.IRichTextComponent> = {
168
159
  id: component.system.id,
169
160
  type: {
@@ -174,7 +165,7 @@ function mapComponents(data: {
174
165
  elementCodename: key,
175
166
  importContext: data.importContext,
176
167
  migrationItems: data.migrationItems,
177
- value: element.value
168
+ elementData: element
178
169
  });
179
170
 
180
171
  return transformedElementValue;
@@ -186,15 +177,15 @@ function mapComponents(data: {
186
177
  }
187
178
 
188
179
  function processImportRichTextHtmlValue(data: {
189
- readonly element: MigrationRichTextElementValue;
180
+ readonly elementData: MigrationElementTransformData;
190
181
  readonly importContext: ImportContext;
191
182
  readonly migrationItems: readonly MigrationItem[];
192
183
  }): string | undefined {
193
- if (!data.element) {
184
+ if (!data.elementData) {
194
185
  return undefined;
195
186
  }
196
187
 
197
- let richTextHtml: string = data.element.value ?? '';
188
+ let richTextHtml: string = data.elementData.value?.toString() ?? '';
198
189
 
199
190
  // replace item codenames with existing codename or external_id
200
191
  richTextHtml = richTextProcessor().processItemCodenames(richTextHtml, (codename) => {
@@ -211,5 +202,10 @@ function processImportRichTextHtmlValue(data: {
211
202
  return data.importContext.getAssetStateInTargetEnvironment(codename);
212
203
  }).html;
213
204
 
205
+ // replace link asset codenames with existing codename or external_id
206
+ richTextHtml = richTextProcessor().processLinkAssetCodenames(richTextHtml, (codename) => {
207
+ return data.importContext.getAssetStateInTargetEnvironment(codename);
208
+ }).html;
209
+
214
210
  return richTextHtml;
215
211
  }
@@ -1,7 +1,8 @@
1
+ import { Buffer } from 'buffer';
1
2
  import JSZip from 'jszip';
2
3
  import { Logger, MigrationData, getDefaultLogger } from '../core/index.js';
3
- import { zipTransformer } from './zip-transformer.js';
4
4
  import { zipPackager } from './zip-packager.js';
5
+ import { zipTransformer } from './zip-transformer.js';
5
6
  import { FileBinaryData } from './zip.models.js';
6
7
 
7
8
  export function zipManager(logger?: Logger) {
@@ -1,8 +1,9 @@
1
- import JSZip from 'jszip';
1
+ import { Buffer } from 'buffer';
2
2
  import chalk from 'chalk';
3
- import { Logger, formatBytes, getCurrentEnvironment, exitProgram, getDefaultLogger } from '../core/index.js';
4
- import { FileBinaryData, ZipCompressionLevel, ZipPackager } from './zip.models.js';
3
+ import JSZip from 'jszip';
5
4
  import { match } from 'ts-pattern';
5
+ import { Logger, exitProgram, formatBytes, getCurrentEnvironment, getDefaultLogger } from '../core/index.js';
6
+ import { FileBinaryData, ZipCompressionLevel, ZipPackager } from './zip.models.js';
6
7
 
7
8
  type ZipOutputType = 'nodebuffer' | 'blob';
8
9
 
@@ -1,6 +1,5 @@
1
1
  import chalk from 'chalk';
2
2
  import { z } from 'zod';
3
- import { FileBinaryData, ZipPackager } from './zip.models.js';
4
3
  import {
5
4
  Logger,
6
5
  MigrationAsset,
@@ -12,6 +11,7 @@ import {
12
11
  getDefaultLogger,
13
12
  mapAsync
14
13
  } from '../core/index.js';
14
+ import { FileBinaryData, ZipPackager } from './zip.models.js';
15
15
 
16
16
  type ZipAssetRecord = z.infer<typeof ZipMigrationAssetSchema>;
17
17
 
@@ -52,8 +52,8 @@ export function zipTransformer(zip: ZipPackager, logger?: Logger) {
52
52
  folder: asset.folder
53
53
  });
54
54
 
55
- if (asset.binaryData) {
56
- codenameFolder.addFile(asset.filename, asset.binaryData);
55
+ if (asset.binary_data) {
56
+ codenameFolder.addFile(asset.filename, asset.binary_data);
57
57
  }
58
58
  });
59
59
 
@@ -93,7 +93,7 @@ export function zipTransformer(zip: ZipPackager, logger?: Logger) {
93
93
  title: assetRecord.title,
94
94
  descriptions: assetRecord.descriptions,
95
95
  folder: assetRecord.folder,
96
- binaryData: binaryFile
96
+ binary_data: binaryFile
97
97
  };
98
98
 
99
99
  return migrationAsset;
@@ -1,3 +1,4 @@
1
+ import { Buffer } from 'buffer';
1
2
  import { Logger } from '../core/index.js';
2
3
 
3
4
  export type FileBinaryData = Buffer | Blob;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontent-ai/migration-toolkit",
3
- "version": "1.5.0",
3
+ "version": "2.0.0",
4
4
  "description": "This program can be used to import content related data into Kontent.ai from various formats. Additionally, it can also be used to export Kontent.ai data using Delivery API.",
5
5
  "preferGlobal": true,
6
6
  "private": false,
@@ -53,37 +53,38 @@
53
53
  "license": "MIT",
54
54
  "dependencies": {
55
55
  "@kontent-ai-consulting/tools-analytics": "0.0.7",
56
- "@kontent-ai/management-sdk": "7.2.0",
56
+ "@kontent-ai/management-sdk": "7.4.0",
57
57
  "browser-or-node": "3.0.0",
58
58
  "bytes": "3.1.2",
59
59
  "chalk": "5.3.0",
60
60
  "dotenv": "16.4.5",
61
61
  "jszip": "3.10.1",
62
62
  "mime": "4.0.4",
63
- "ora": "8.0.1",
63
+ "ora": "8.1.0",
64
64
  "prompts": "2.4.2",
65
65
  "yargs": "17.7.2",
66
66
  "p-limit": "6.1.0",
67
67
  "deep-equal": "2.2.3",
68
68
  "zod": "3.23.8",
69
- "ts-pattern": "5.3.1"
69
+ "ts-pattern": "5.4.0",
70
+ "buffer": "6.0.3"
70
71
  },
71
72
  "devDependencies": {
72
- "@eslint/js": "9.9.0",
73
+ "@eslint/js": "9.11.1",
73
74
  "@types/deep-equal": "1.0.4",
74
75
  "@types/browser-or-node": "1.3.2",
75
76
  "@types/bytes": "3.1.4",
76
77
  "@types/eslint__js": "8.42.3",
77
- "@types/node": "22.3.0",
78
+ "@types/node": "22.7.4",
78
79
  "@types/prompts": "2.4.9",
79
80
  "@types/yargs": "17.0.33",
80
- "@typescript-eslint/eslint-plugin": "8.1.0",
81
- "@typescript-eslint/parser": "8.1.0",
82
- "eslint": "9.9.0",
81
+ "@typescript-eslint/eslint-plugin": "8.8.0",
82
+ "@typescript-eslint/parser": "8.8.0",
83
+ "eslint": "9.11.1",
83
84
  "standard-version": "9.5.0",
84
- "tslib": "2.6.3",
85
- "tsx": "4.17.0",
86
- "typescript": "5.5.4",
87
- "typescript-eslint": "8.1.0"
85
+ "tslib": "2.7.0",
86
+ "tsx": "4.19.1",
87
+ "typescript": "5.6.2",
88
+ "typescript-eslint": "8.8.0"
88
89
  }
89
90
  }