@kontent-ai/migration-toolkit 3.0.1 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/core/logs/loggers.js +13 -11
  2. package/dist/core/logs/loggers.js.map +1 -1
  3. package/dist/core/models/core.models.d.ts +28 -28
  4. package/dist/core/models/error.models.js +2 -2
  5. package/dist/core/models/error.models.js.map +1 -1
  6. package/dist/core/models/log.models.d.ts +6 -6
  7. package/dist/core/models/migration.schema.d.ts +2 -2
  8. package/dist/core/utils/array.utils.d.ts +1 -2
  9. package/dist/core/utils/array.utils.js.map +1 -1
  10. package/dist/core/utils/confirm.utils.d.ts +9 -2
  11. package/dist/core/utils/confirm.utils.js +42 -4
  12. package/dist/core/utils/confirm.utils.js.map +1 -1
  13. package/dist/core/utils/error.utils.js +6 -0
  14. package/dist/core/utils/error.utils.js.map +1 -1
  15. package/dist/core/utils/external-id.utils.d.ts +2 -2
  16. package/dist/core/utils/global.utils.d.ts +1 -1
  17. package/dist/core/utils/global.utils.js +4 -4
  18. package/dist/core/utils/global.utils.js.map +1 -1
  19. package/dist/core/utils/http.utils.d.ts +1 -2
  20. package/dist/core/utils/http.utils.js.map +1 -1
  21. package/dist/core/utils/management-client-utils.d.ts +3 -3
  22. package/dist/core/utils/management-client-utils.js +1 -1
  23. package/dist/core/utils/management-client-utils.js.map +1 -1
  24. package/dist/core/utils/processing-utils.js +2 -2
  25. package/dist/core/utils/processing-utils.js.map +1 -1
  26. package/dist/export/export.models.d.ts +18 -18
  27. package/dist/import/comparers/asset-comparer.js +5 -2
  28. package/dist/import/comparers/asset-comparer.js.map +1 -1
  29. package/dist/import/context/import-context-fetcher.js.map +1 -1
  30. package/dist/import/import.models.d.ts +14 -14
  31. package/dist/import/importers/workflow-importer.d.ts +1 -1
  32. package/dist/import/importers/workflow-importer.js.map +1 -1
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.js +1 -1
  35. package/dist/index.js.map +1 -1
  36. package/dist/metadata.d.ts +0 -1
  37. package/dist/metadata.js +1 -2
  38. package/dist/metadata.js.map +1 -1
  39. package/dist/node/cli/actions/export-action.js +13 -14
  40. package/dist/node/cli/actions/export-action.js.map +1 -1
  41. package/dist/node/cli/actions/import-action.js +13 -4
  42. package/dist/node/cli/actions/import-action.js.map +1 -1
  43. package/dist/node/cli/actions/migrate-action.js +1 -1
  44. package/dist/node/cli/actions/migrate-action.js.map +1 -1
  45. package/dist/node/cli/cli.models.d.ts +4 -4
  46. package/dist/toolkit/file.d.ts +4 -4
  47. package/dist/toolkit/migrate.d.ts +6 -6
  48. package/dist/translation/extraction/items-extraction.processor.d.ts +8 -8
  49. package/dist/translation/extraction/items-extraction.processor.js +2 -3
  50. package/dist/translation/extraction/items-extraction.processor.js.map +1 -1
  51. package/dist/translation/transforms/import-transforms.js.map +1 -1
  52. package/lib/core/logs/loggers.ts +13 -15
  53. package/lib/core/models/core.models.ts +28 -28
  54. package/lib/core/models/error.models.ts +2 -2
  55. package/lib/core/models/log.models.ts +6 -6
  56. package/lib/core/models/migration.schema.ts +2 -2
  57. package/lib/core/utils/array.utils.ts +0 -2
  58. package/lib/core/utils/confirm.utils.ts +70 -5
  59. package/lib/core/utils/error.utils.ts +6 -0
  60. package/lib/core/utils/external-id.utils.ts +2 -2
  61. package/lib/core/utils/global.utils.ts +5 -9
  62. package/lib/core/utils/http.utils.ts +1 -2
  63. package/lib/core/utils/management-client-utils.ts +13 -13
  64. package/lib/core/utils/processing-utils.ts +3 -3
  65. package/lib/export/export.models.ts +18 -18
  66. package/lib/import/comparers/asset-comparer.ts +6 -2
  67. package/lib/import/context/import-context-fetcher.ts +3 -4
  68. package/lib/import/import.models.ts +14 -14
  69. package/lib/import/importers/workflow-importer.ts +1 -2
  70. package/lib/index.ts +2 -1
  71. package/lib/metadata.ts +1 -2
  72. package/lib/node/cli/actions/export-action.ts +14 -14
  73. package/lib/node/cli/actions/import-action.ts +15 -6
  74. package/lib/node/cli/actions/migrate-action.ts +1 -1
  75. package/lib/node/cli/cli.models.ts +4 -4
  76. package/lib/toolkit/file.ts +4 -4
  77. package/lib/toolkit/migrate.ts +6 -6
  78. package/lib/translation/extraction/items-extraction.processor.ts +10 -11
  79. package/lib/translation/transforms/import-transforms.ts +1 -2
  80. package/package.json +23 -30
@@ -20,23 +20,23 @@ import type { Logger } from "../core/models/log.models.js";
20
20
  import type { MigrationComponent, MigrationElementTransformData, MigrationUrlSlugMode } from "../core/models/migration.models.js";
21
21
  import type { ManagementClientConfig } from "../core/utils/management-client-utils.js";
22
22
 
23
- export interface ExportContextEnvironmentData {
23
+ export type ExportContextEnvironmentData = {
24
24
  readonly languages: readonly Readonly<LanguageModels.LanguageModel>[];
25
25
  readonly contentTypes: readonly Readonly<FlattenedContentType>[];
26
26
  readonly collections: readonly Readonly<CollectionModels.Collection>[];
27
27
  readonly assetFolders: readonly Readonly<AssetFolderModels.AssetFolder>[];
28
28
  readonly workflows: readonly Readonly<WorkflowModels.Workflow>[];
29
29
  readonly taxonomies: readonly Readonly<TaxonomyModels.Taxonomy>[];
30
- }
30
+ };
31
31
 
32
32
  export type ExportElementValue = string | number | SharedModels.ReferenceObject[] | undefined;
33
33
 
34
- export interface ExportElement {
34
+ export type ExportElement = {
35
35
  readonly value: ExportElementValue;
36
36
  readonly components: readonly MigrationComponent[];
37
37
  readonly urlSlugMode: MigrationUrlSlugMode | undefined;
38
38
  readonly displayTimezone: string | undefined;
39
- }
39
+ };
40
40
 
41
41
  export type ExportTransformFunc = (data: {
42
42
  readonly typeElement: FlattenedContentTypeElement;
@@ -44,7 +44,7 @@ export type ExportTransformFunc = (data: {
44
44
  readonly context: ExportContext;
45
45
  }) => MigrationElementTransformData;
46
46
 
47
- export interface ExportContext {
47
+ export type ExportContext = {
48
48
  readonly environmentData: ExportContextEnvironmentData;
49
49
  readonly referencedData: ReferencedDataInLanguageVariants;
50
50
  readonly getItemStateInSourceEnvironment: (id: string) => ItemStateInSourceEnvironmentById;
@@ -52,23 +52,23 @@ export interface ExportContext {
52
52
  readonly exportItems: readonly ExportItem[];
53
53
  readonly getElement: GetFlattenedElementByIds;
54
54
  readonly exportContextOptions: ExportContextOptions;
55
- }
55
+ };
56
56
 
57
- export interface SourceExportItem {
57
+ export type SourceExportItem = {
58
58
  readonly itemCodename: string;
59
59
  readonly languageCodename: string;
60
- }
60
+ };
61
61
 
62
- export interface ExportContextOptions {
62
+ export type ExportContextOptions = {
63
63
  /**
64
64
  * When enabled, the export process will skip missing items and assets instead of throwing errors.
65
65
  * Missing references will be filtered out from the exported data.
66
66
  * Default: false
67
67
  */
68
68
  readonly skipMissingReferences?: boolean;
69
- }
69
+ };
70
70
 
71
- export interface ExportConfig extends ManagementClientConfig {
71
+ export type ExportConfig = ManagementClientConfig & {
72
72
  readonly exportItems: readonly SourceExportItem[];
73
73
  readonly logger?: Logger;
74
74
  /**
@@ -77,23 +77,23 @@ export interface ExportConfig extends ManagementClientConfig {
77
77
  * Default: false
78
78
  */
79
79
  readonly skipMissingReferences?: boolean;
80
- }
80
+ };
81
81
 
82
- export interface DefaultExportContextConfig {
82
+ export type DefaultExportContextConfig = {
83
83
  readonly logger: Logger;
84
84
  readonly exportItems: readonly SourceExportItem[];
85
85
  readonly managementClient: Readonly<ManagementClient>;
86
86
  readonly skipMissingReferences: boolean;
87
- }
87
+ };
88
88
 
89
89
  export type GetFlattenedElementByIds = (contentTypeId: string, elementId: string) => FlattenedContentTypeElement;
90
90
 
91
- export interface ExportItemVersion {
91
+ export type ExportItemVersion = {
92
92
  readonly workflowStepCodename: string;
93
93
  readonly languageVariant: Readonly<LanguageVariantModels.ContentItemLanguageVariant>;
94
- }
94
+ };
95
95
 
96
- export interface ExportItem {
96
+ export type ExportItem = {
97
97
  readonly requestItem: SourceExportItem;
98
98
  readonly versions: readonly ExportItemVersion[];
99
99
  readonly contentItem: Readonly<ContentItemModels.ContentItem>;
@@ -102,4 +102,4 @@ export interface ExportItem {
102
102
  readonly language: Readonly<LanguageModels.LanguageModel>;
103
103
  readonly workflow: Readonly<WorkflowModels.Workflow>;
104
104
  readonly contentType: Readonly<FlattenedContentType>;
105
- }
105
+ };
@@ -71,6 +71,10 @@ function areDescriptionsIdentical(data: {
71
71
  readonly targetAsset: Readonly<AssetModels.Asset>;
72
72
  readonly languages: readonly Readonly<LanguageModels.LanguageModel>[];
73
73
  }): boolean {
74
+ const languageComparer = (a: MigrationAssetDescription, b: MigrationAssetDescription) => {
75
+ return a.language.codename.localeCompare(b.language.codename);
76
+ };
77
+
74
78
  const sourceMigrationDescriptions = (data.migrationAsset.descriptions ?? [])
75
79
  .map<MigrationAssetDescription>((description) => {
76
80
  return {
@@ -80,8 +84,8 @@ function areDescriptionsIdentical(data: {
80
84
  },
81
85
  };
82
86
  })
83
- .toSorted();
84
- const targetMigrationDescriptions = mapToMigrationDescriptions(data).toSorted();
87
+ .toSorted(languageComparer);
88
+ const targetMigrationDescriptions = mapToMigrationDescriptions(data).toSorted(languageComparer);
85
89
 
86
90
  return deepEqual(sourceMigrationDescriptions, targetMigrationDescriptions);
87
91
  }
@@ -1,8 +1,7 @@
1
1
  import type { AssetModels, ContentItemModels, LanguageVariantModels } from "@kontent-ai/management-sdk";
2
2
  import chalk from "chalk";
3
3
  import { match } from "ts-pattern";
4
- import type { WorkflowStep } from "../../core/helpers/workflow-helper.js";
5
- import { workflowHelper as workflowHelperInit } from "../../core/helpers/workflow-helper.js";
4
+ import { type WorkflowStep, workflowHelper as workflowHelperInit } from "../../core/helpers/workflow-helper.js";
6
5
  import type {
7
6
  AssetStateInTargetEnvironmentByCodename,
8
7
  ItemStateInTargetEnvironmentByCodename,
@@ -23,11 +22,11 @@ import { runMapiRequestAsync } from "../../core/utils/run.utils.js";
23
22
  import { type ExtractItemByCodename, itemsExtractionProcessor } from "../../translation/extraction/items-extraction.processor.js";
24
23
  import type { GetFlattenedElementByCodenames, ImportContext, ImportContextConfig, ImportContextEnvironmentData } from "../import.models.js";
25
24
 
26
- interface LanguageVariantWrapper {
25
+ type LanguageVariantWrapper = {
27
26
  readonly draftLanguageVariant: Readonly<LanguageVariantModels.ContentItemLanguageVariant> | undefined;
28
27
  readonly publishedLanguageVariant: Readonly<LanguageVariantModels.ContentItemLanguageVariant> | undefined;
29
28
  readonly migrationItem: MigrationItem;
30
- }
29
+ };
31
30
 
32
31
  export async function importContextFetcherAsync(config: ImportContextConfig) {
33
32
  const getEnvironmentDataAsync = async (): Promise<ImportContextEnvironmentData> => {
@@ -29,20 +29,20 @@ import type {
29
29
  import type { ExternalIdGenerator } from "../core/utils/external-id.utils.js";
30
30
  import type { ManagementClientConfig } from "../core/utils/management-client-utils.js";
31
31
 
32
- export interface ImportContextConfig {
32
+ export type ImportContextConfig = {
33
33
  readonly logger: Logger;
34
34
  readonly managementClient: Readonly<ManagementClient>;
35
35
  readonly externalIdGenerator: ExternalIdGenerator;
36
36
  readonly migrationData: MigrationData;
37
- }
37
+ };
38
38
 
39
- export interface ImportContextEnvironmentData {
39
+ export type ImportContextEnvironmentData = {
40
40
  readonly languages: readonly Readonly<LanguageModels.LanguageModel>[];
41
41
  readonly assetFolders: readonly Readonly<AssetFolderModels.AssetFolder>[];
42
42
  readonly collections: readonly Readonly<CollectionModels.Collection>[];
43
43
  readonly workflows: readonly Readonly<WorkflowModels.Workflow>[];
44
44
  readonly types: readonly Readonly<FlattenedContentType>[];
45
- }
45
+ };
46
46
 
47
47
  export type GetFlattenedElementByCodenames = (
48
48
  contentTypeCodename: string,
@@ -50,12 +50,12 @@ export type GetFlattenedElementByCodenames = (
50
50
  expectedElementType: MigrationElementType,
51
51
  ) => FlattenedContentTypeElement;
52
52
 
53
- export interface CategorizedImportData {
53
+ export type CategorizedImportData = {
54
54
  readonly assets: readonly MigrationAsset[];
55
55
  readonly contentItems: readonly MigrationItem[];
56
- }
56
+ };
57
57
 
58
- export interface ImportContext {
58
+ export type ImportContext = {
59
59
  readonly categorizedImportData: CategorizedImportData;
60
60
  readonly referencedData: ReferencedDataInMigrationItems;
61
61
  readonly environmentData: ImportContextEnvironmentData;
@@ -66,7 +66,7 @@ export interface ImportContext {
66
66
  ) => LanguageVariantStateInTargetEnvironmentByCodename;
67
67
  readonly getAssetStateInTargetEnvironment: (assetCodename: string) => AssetStateInTargetEnvironmentByCodename;
68
68
  readonly getElement: GetFlattenedElementByCodenames;
69
- }
69
+ };
70
70
 
71
71
  export type ImportTransformFunc = (data: {
72
72
  readonly elementData: MigrationElementTransformData;
@@ -75,18 +75,18 @@ export type ImportTransformFunc = (data: {
75
75
  readonly migrationItems: readonly MigrationItem[];
76
76
  }) => LanguageVariantElements.ILanguageVariantElementBase;
77
77
 
78
- export interface ImportConfig extends ManagementClientConfig {
78
+ export type ImportConfig = ManagementClientConfig & {
79
79
  readonly data: MigrationData;
80
80
  readonly externalIdGenerator?: ExternalIdGenerator;
81
81
  readonly createReportFile?: boolean;
82
82
  readonly logger?: Logger;
83
- }
83
+ };
84
84
 
85
- export interface AssetToEdit {
85
+ export type AssetToEdit = {
86
86
  readonly migrationAsset: MigrationAsset;
87
87
  readonly targetAsset: Readonly<AssetModels.Asset>;
88
88
  readonly replaceBinaryFile: boolean;
89
- }
89
+ };
90
90
 
91
91
  export type ImportedItem = ItemProcessingResult<MigrationItem, Readonly<ContentItemModels.ContentItem>>;
92
92
  export type ImportedLanguageVariant = ItemProcessingResult<
@@ -96,9 +96,9 @@ export type ImportedLanguageVariant = ItemProcessingResult<
96
96
  export type EditedAsset = ItemProcessingResult<AssetToEdit, Readonly<AssetModels.Asset>>;
97
97
  export type ImportedAsset = ItemProcessingResult<MigrationAsset, Readonly<AssetModels.Asset>>;
98
98
 
99
- export interface ImportResult {
99
+ export type ImportResult = {
100
100
  readonly uploadedAssets: readonly ImportedAsset[];
101
101
  readonly editedAssets: readonly EditedAsset[];
102
102
  readonly contentItems: readonly ImportedItem[];
103
103
  readonly languageVariants: readonly ImportedLanguageVariant[];
104
- }
104
+ };
@@ -1,5 +1,4 @@
1
- import type { LanguageVariantModels, ManagementClient, WorkflowModels } from "@kontent-ai/management-sdk";
2
- import { SharedModels } from "@kontent-ai/management-sdk";
1
+ import { type LanguageVariantModels, type ManagementClient, SharedModels, type WorkflowModels } from "@kontent-ai/management-sdk";
3
2
  import { match } from "ts-pattern";
4
3
  import { type ShortestPathResult, type WorkflowStep, workflowHelper as workflowHelperInit } from "../../core/helpers/workflow-helper.js";
5
4
  import type { Logger, LogSpinnerData } from "../../core/models/log.models.js";
package/lib/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- // biome-ignore lint/performance/noBarrelFile: We need to export the public API
1
+ // biome-ignore lint/performance/noBarrelFile: Ok for Public API
2
2
  export { getDefaultLogger } from "./core/logs/loggers.js";
3
3
  export { MigrationToolkitError, MissingAssetError, MissingItemError } from "./core/models/error.models.js";
4
4
  export type { Logger, LogMessage, LogSpinnerData, LogSpinnerMessage } from "./core/models/log.models.js";
@@ -10,3 +10,4 @@ export { exportAsync } from "./toolkit/export.js";
10
10
  export { extractAsync, storeAsync } from "./toolkit/file.js";
11
11
  export { importAsync } from "./toolkit/import.js";
12
12
  export { migrateAsync } from "./toolkit/migrate.js";
13
+ export type { FileBinaryData } from "./zip/zip.models.js";
package/lib/metadata.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export const libMetadata = {
2
2
  name: "@kontent-ai/migration-toolkit",
3
- timestamp: "Fri, 13 Feb 2026 09:13:30 GMT",
4
- version: "3.0.1",
3
+ version: "3.1.1",
5
4
  };
@@ -1,6 +1,7 @@
1
1
  import { getDefaultLogger } from "../../../core/logs/loggers.js";
2
2
  import { confirmExportAsync } from "../../../core/utils/confirm.utils.js";
3
3
  import { defaultZipFilename } from "../../../core/utils/global.utils.js";
4
+ import type { SourceExportItem } from "../../../export/export.models.js";
4
5
  import { exportAsync } from "../../../toolkit/export.js";
5
6
  import { storeAsync } from "../../../toolkit/file.js";
6
7
  import type { CliArgumentsFetcher } from "../cli.models.js";
@@ -15,30 +16,29 @@ export async function exportActionAsync(cliFetcher: CliArgumentsFetcher): Promis
15
16
  const force = cliFetcher.getBooleanArgumentValue("force", false);
16
17
  const skipMissingReferences = cliFetcher.getBooleanArgumentValue("skipMissingReferences", false);
17
18
  const filename = cliFetcher.getOptionalArgumentValue("filename") ?? defaultZipFilename;
19
+ const exportItems: readonly SourceExportItem[] = items.map((item) => {
20
+ return {
21
+ itemCodename: item,
22
+ languageCodename: language,
23
+ };
24
+ });
18
25
 
19
26
  await confirmExportAsync({
20
27
  force,
21
28
  apiKey,
22
29
  environmentId,
23
30
  logger,
24
- dataToExport: {
25
- itemsCount: items.length,
26
- },
31
+ dataToExport: { exportItems },
27
32
  skipMissingReferences,
28
33
  });
29
34
 
30
35
  const exportedData = await exportAsync({
31
- logger,
32
- environmentId,
33
- apiKey,
34
- baseUrl,
35
- exportItems: items.map((m) => {
36
- return {
37
- itemCodename: m,
38
- languageCodename: language,
39
- };
40
- }),
41
- skipMissingReferences,
36
+ logger: logger,
37
+ environmentId: environmentId,
38
+ apiKey: apiKey,
39
+ baseUrl: baseUrl,
40
+ exportItems: exportItems,
41
+ skipMissingReferences: skipMissingReferences,
42
42
  });
43
43
 
44
44
  await storeAsync({
@@ -1,5 +1,5 @@
1
1
  import { getDefaultLogger } from "../../../core/logs/loggers.js";
2
- import { confirmImportAsync } from "../../../core/utils/confirm.utils.js";
2
+ import { confirmImportAsync, type ItemPreview } from "../../../core/utils/confirm.utils.js";
3
3
  import { defaultZipFilename } from "../../../core/utils/global.utils.js";
4
4
  import { extractAsync } from "../../../toolkit/file.js";
5
5
  import { importAsync } from "../../../toolkit/import.js";
@@ -14,16 +14,25 @@ export async function importActionAsync(argsFetcher: CliArgumentsFetcher): Promi
14
14
  const force = argsFetcher.getBooleanArgumentValue("force", false);
15
15
  const filename = argsFetcher.getOptionalArgumentValue("filename") ?? defaultZipFilename;
16
16
 
17
+ const importData = await extractAsync({
18
+ logger: log,
19
+ filename: filename,
20
+ });
21
+ const importItems: readonly ItemPreview[] = importData.items.map((item) => {
22
+ return {
23
+ itemCodename: item.system.codename,
24
+ languageCodename: item.system.language.codename,
25
+ };
26
+ });
27
+
17
28
  await confirmImportAsync({
18
29
  force: force,
19
30
  apiKey: apiKey,
20
31
  environmentId: environmentId,
21
32
  logger: log,
22
- });
23
-
24
- const importData = await extractAsync({
25
- logger: log,
26
- filename: filename,
33
+ dataToImport: {
34
+ importItems: importItems,
35
+ },
27
36
  });
28
37
 
29
38
  await importAsync({
@@ -34,7 +34,7 @@ export async function migrateActionAsync(argsFetcher: CliArgumentsFetcher): Prom
34
34
  },
35
35
  logger,
36
36
  dataToMigrate: {
37
- itemsCount: migrateItems.length,
37
+ migrateItems,
38
38
  },
39
39
  });
40
40
 
@@ -1,19 +1,19 @@
1
1
  import type { CliAction } from "../../core/models/core.models.js";
2
2
 
3
- export interface Command {
3
+ export type Command = {
4
4
  readonly name: string;
5
5
  readonly description: string;
6
6
  readonly options: readonly CommandOption[];
7
7
  readonly examples: string[];
8
- }
8
+ };
9
9
 
10
- export interface CommandOption {
10
+ export type CommandOption = {
11
11
  readonly name: string;
12
12
  readonly isRequired: boolean;
13
13
  readonly alias?: string;
14
14
  readonly description?: string;
15
15
  readonly type?: "boolean" | "number" | "string";
16
- }
16
+ };
17
17
 
18
18
  export type CliArgumentsSetter = {
19
19
  withCommand(command: Command): CliArgumentsSetter;
@@ -8,16 +8,16 @@ import { fileManager } from "../file/file-manager.js";
8
8
  import { libMetadata } from "../metadata.js";
9
9
  import { zipManager } from "../zip/zip-manager.js";
10
10
 
11
- export interface StoreConfig {
11
+ export type StoreConfig = {
12
12
  readonly data: MigrationData;
13
13
  readonly filename?: string;
14
14
  readonly logger?: Logger;
15
- }
15
+ };
16
16
 
17
- export interface ExtractConfig {
17
+ export type ExtractConfig = {
18
18
  readonly filename?: string;
19
19
  readonly logger?: Logger;
20
- }
20
+ };
21
21
 
22
22
  export async function storeAsync(config: StoreConfig): Promise<void> {
23
23
  const logger = config.logger ?? getDefaultLogger();
@@ -11,7 +11,7 @@ import { libMetadata } from "../metadata.js";
11
11
  import { exportAsync } from "./export.js";
12
12
  import { importAsync } from "./import.js";
13
13
 
14
- export interface MigrationSource extends ManagementClientConfig {
14
+ export type MigrationSource = ManagementClientConfig & {
15
15
  readonly items: readonly SourceExportItem[];
16
16
  /**
17
17
  * When enabled, the export process will skip missing items and assets instead of throwing errors.
@@ -19,20 +19,20 @@ export interface MigrationSource extends ManagementClientConfig {
19
19
  * Default: false
20
20
  */
21
21
  readonly skipMissingReferences?: boolean;
22
- }
22
+ };
23
23
 
24
- export interface MigrationConfig {
24
+ export type MigrationConfig = {
25
25
  readonly retryStrategy?: IRetryStrategyOptions;
26
26
  readonly externalIdGenerator?: ExternalIdGenerator;
27
27
  readonly logger?: Logger;
28
28
  readonly sourceEnvironment: MigrationSource;
29
29
  readonly targetEnvironment: ManagementClientConfig;
30
- }
30
+ };
31
31
 
32
- export interface MigrationResult {
32
+ export type MigrationResult = {
33
33
  readonly migrationData: MigrationData;
34
34
  readonly importResult: ImportResult;
35
- }
35
+ };
36
36
 
37
37
  export async function migrateAsync(config: MigrationConfig): Promise<MigrationResult> {
38
38
  const logger = config.logger ?? getDefaultLogger();
@@ -1,4 +1,3 @@
1
- import { isArray } from "node:util";
2
1
  import type { ElementModels } from "@kontent-ai/management-sdk";
3
2
  import { match, P } from "ts-pattern";
4
3
  import type { ReferencedDataInLanguageVariants, ReferencedDataInMigrationItems } from "../../core/models/core.models.js";
@@ -9,25 +8,25 @@ import type { GetFlattenedElementByIds } from "../../export/export.models.js";
9
8
  import type { GetFlattenedElementByCodenames } from "../../import/import.models.js";
10
9
  import { richTextProcessor } from "../helpers/rich-text.processor.js";
11
10
 
12
- export interface ExtractItemById {
11
+ export type ExtractItemById = {
13
12
  readonly elements: readonly Readonly<ElementModels.ContentItemElement>[];
14
13
  readonly contentTypeId: string;
15
- }
14
+ };
16
15
 
17
- export interface ExtractItemByCodename {
16
+ export type ExtractItemByCodename = {
18
17
  readonly elements: MigrationElements;
19
18
  readonly contentTypeCodename: string;
20
- }
19
+ };
21
20
 
22
- export interface ReferencedDataInMigrationItemsLocal {
21
+ export type ReferencedDataInMigrationItemsLocal = {
23
22
  readonly itemCodenames: Set<string>;
24
23
  readonly assetCodenames: Set<string>;
25
- }
24
+ };
26
25
 
27
- export interface ReferencedDataInLanguageVariantsLocal {
26
+ export type ReferencedDataInLanguageVariantsLocal = {
28
27
  readonly itemIds: Set<string>;
29
28
  readonly assetIds: Set<string>;
30
- }
29
+ };
31
30
 
32
31
  export function itemsExtractionProcessor() {
33
32
  const extractReferencedDataFromExtractItems = (
@@ -88,7 +87,7 @@ export function itemsExtractionProcessor() {
88
87
  });
89
88
  })
90
89
  .with(P.union("modular_content", "subpages"), () => {
91
- if (itemElement.value && isArray(itemElement.value)) {
90
+ if (itemElement.value && Array.isArray(itemElement.value)) {
92
91
  itemElement.value.forEach((value) => {
93
92
  if (value.id) {
94
93
  extractedIds.itemIds.add(value.id);
@@ -97,7 +96,7 @@ export function itemsExtractionProcessor() {
97
96
  }
98
97
  })
99
98
  .with("asset", () => {
100
- if (itemElement.value && isArray(itemElement.value)) {
99
+ if (itemElement.value && Array.isArray(itemElement.value)) {
101
100
  itemElement.value.forEach((value) => {
102
101
  if (value.id) {
103
102
  extractedIds.assetIds.add(value.id);
@@ -1,5 +1,4 @@
1
- import type { LanguageVariantElements, SharedContracts } from "@kontent-ai/management-sdk";
2
- import { LanguageVariantElementsBuilder } from "@kontent-ai/management-sdk";
1
+ import { type LanguageVariantElements, LanguageVariantElementsBuilder, type SharedContracts } from "@kontent-ai/management-sdk";
3
2
  import type { MigrationElementTransformData, MigrationElementType, MigrationItem } from "../../core/models/migration.models.js";
4
3
  import { parseAsMigrationReferencesArray } from "../../core/utils/array.utils.js";
5
4
  import { isString } from "../../core/utils/global.utils.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kontent-ai/migration-toolkit",
3
- "version": "3.0.1",
3
+ "version": "3.1.1",
4
4
  "description": "This program can be used to import content related data into Kontent.ai from various sources. The included functionality enables the content & asset export/import from Kontent.ai environments.",
5
5
  "preferGlobal": true,
6
6
  "private": false,
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "repository": {
11
11
  "type": "git",
12
- "url": "https://github.com/Kontent-ai/kontent-ai-migration-toolkit"
12
+ "url": "https://github.com/kontent-ai/migration-toolkit"
13
13
  },
14
14
  "engines": {
15
15
  "node": ">=20"
@@ -19,31 +19,25 @@
19
19
  "types": "./dist/index.d.ts",
20
20
  "type": "module",
21
21
  "scripts": {
22
+ "prepublishOnly": "npm run build",
23
+ "build": "npm run lint && npm run clean && tsc --p tsconfig.build.json && npm run update:version",
24
+ "lint": "npm run biome:check && npm run eslint",
22
25
  "test": "npm run test:unit",
23
- "release": "npm run lint && standard-version && npm run update:version",
24
- "release:major": "npm run lint && standard-version --release-as major && npm run update:version",
25
- "release:major:beta": "npm run lint && standard-version --prerelease --release-as major && npm run update:version",
26
- "release:beta": "standard-version --prerelease && npm run update:version",
27
- "prepublishOnly": "npm run lint && npm run build && npm run push:tags",
28
- "publish:beta": "npm publish --tag=next",
29
- "build": "npm run clean && npm run lint && tsc --p tsconfig.build.json",
26
+ "test:unit": "vitest run --config=vitest-unit.config.ts",
27
+ "test:integration": "vitest run --config=vitest-integration.config.ts",
28
+ "eslint": "eslint lib samples scripts tests",
29
+ "eslint:fix": "eslint lib samples scripts tests --fix",
30
+ "biome:check": "biome check",
31
+ "biome:fix": "biome check --write",
32
+ "biome:fix:unsafe": "biome check --write --unsafe",
33
+ "clean": "tsx scripts/clean.ts",
34
+ "update:version": "tsx ./scripts/version/update-version.ts && npm run biome:fix",
30
35
  "test:migrate": "cd scripts/test && tsx test-migrate.ts",
31
36
  "test:import": "cd scripts/test && tsx test-import.ts",
32
37
  "test:export": "cd scripts/test && tsx test-export.ts",
33
38
  "test:export:cli": "tsx lib/node/cli/app export --language=x --items=x --sourceEnvironmentId=x --sourceApiKey=x",
34
39
  "test:help": "tsx lib/node/cli/app --help",
35
- "test:help:command": "tsx lib/node/cli/app migrate --help",
36
- "test:unit": "vitest run --config=vitest.config.js",
37
- "lint": "npm run biome:check && npm run eslint",
38
- "lint:fix": "npm run biome:fix && npm run eslint:fix",
39
- "clean": "tsx scripts/clean.ts",
40
- "push:tags": "git push --tags",
41
- "update:version": "tsx ./scripts/version/update-version.ts",
42
- "biome:check": "biome check",
43
- "biome:fix": "biome check --write",
44
- "biome:fix:unsafe": "biome check --write --unsafe",
45
- "eslint": "eslint lib samples scripts tests",
46
- "eslint:fix": "eslint lib samples scripts tests --fix"
40
+ "test:help:command": "tsx lib/node/cli/app migrate --help"
47
41
  },
48
42
  "keywords": [
49
43
  "Kontent.ai",
@@ -56,7 +50,7 @@
56
50
  "license": "MIT",
57
51
  "dependencies": {
58
52
  "@kontent-ai-consulting/tools-analytics": "0.0.10",
59
- "@kontent-ai/management-sdk": "8.3.1",
53
+ "@kontent-ai/management-sdk": "8.4.0",
60
54
  "browser-or-node": "3.0.0",
61
55
  "buffer": "6.0.3",
62
56
  "bytes": "3.1.2",
@@ -73,21 +67,20 @@
73
67
  "zod": "4.3.6"
74
68
  },
75
69
  "devDependencies": {
76
- "@biomejs/biome": "2.3.7",
77
- "@kontent-ai/biome-config": "0.5.1",
78
- "@eslint/js": "9.39.1",
70
+ "@kontent-ai/biome-config": "0.7.0",
71
+ "@kontent-ai/eslint-config": "2.4.1",
72
+ "@biomejs/biome": "2.4.8",
73
+ "@eslint/js": "10.0.1",
79
74
  "@types/browser-or-node": "1.3.2",
80
75
  "@types/bytes": "3.1.5",
81
76
  "@types/deep-equal": "1.0.4",
82
- "@types/node": "25.2.3",
77
+ "@types/node": "25.5.0",
83
78
  "@types/prompts": "2.4.9",
84
79
  "@types/yargs": "17.0.35",
85
- "eslint": "9.39.1",
86
- "standard-version": "9.5.0",
80
+ "eslint": "10.1.0",
87
81
  "tslib": "2.8.1",
88
82
  "tsx": "4.21.0",
89
83
  "typescript": "5.9.3",
90
- "typescript-eslint": "8.48.0",
91
- "vitest": "4.0.18"
84
+ "vitest": "4.1.0"
92
85
  }
93
86
  }