Skip to content

Commit

Permalink
Updates migration toolkit import
Browse files Browse the repository at this point in the history
  • Loading branch information
Enngage committed Jul 10, 2024
1 parent 344d49d commit 3a58da1
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 29 deletions.
2 changes: 1 addition & 1 deletion ts/migrate-from-other-systems/install_migration_toolkit.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Add the Migration toolkit to your app
npm i @kontent-ai-consulting/migration-toolkit --save-dev
npm i @kontent-ai/migration-toolkit --save-dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
MigrationAsset,
MigrationItem,
importAsync,
} from "@kontent-ai-consulting/migration-toolkit";
} from "@kontent-ai/migration-toolkit";

// 1. Map the exported content to MigrationItems
const migrationItems: MigrationItem[] = [];
Expand All @@ -13,8 +13,8 @@ const migrationAssets: MigrationAsset[] = [];
await importAsync({
data: {
assets: migrationAssets,
items: migrationItems
items: migrationItems,
},
environmentId: "KONTENT_AI_ENVIRONMENT_ID",
apiKey: "MANAGEMENT_API_KEY",
});
});
33 changes: 16 additions & 17 deletions ts/migrate-from-other-systems/migration_toolkit_import_data.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
import {
importAsync,
extractAsync // Only when importing from stored archives
} from "@kontent-ai-consulting/migration-toolkit";
importAsync,
extractAsync, // Only when importing from stored archives
} from "@kontent-ai/migration-toolkit";

// Import from migration objects directly
await importAsync({
data: {
assets: migrationAssets,
items: migrationItems
},
environmentId: "KONTENT_AI_ENVIRONMENT_ID",
apiKey: "MANAGEMENT_API_KEY",
data: {
assets: migrationAssets,
items: migrationItems,
},
environmentId: "KONTENT_AI_ENVIRONMENT_ID",
apiKey: "MANAGEMENT_API_KEY",
});

// Extract MigrationItem and MigrationAsset objects from archive
const { assets, items } = await extractAsync({
filename: 'core_content.zip'
filename: "core_content.zip",
});

// Import from stored migration objects
await importAsync({
environmentId: "KONTENT_AI_ENVIRONMENT_ID",
apiKey: "MANAGEMENT_API_KEY",
data: {
assets: assets,
items: items
}
environmentId: "KONTENT_AI_ENVIRONMENT_ID",
apiKey: "MANAGEMENT_API_KEY",
data: {
assets: assets,
items: items,
},
});

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MigrationAsset } from "@kontent-ai-consulting/migration-toolkit";
import { MigrationAsset } from "@kontent-ai/migration-toolkit";
import { readFileSync } from "fs"; // Only if loading local data

const coverAsset: MigrationAsset = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
MigrationElements,
MigrationItem,
elementsBuilder,
} from "@kontent-ai-consulting/migration-toolkit";
} from "@kontent-ai/migration-toolkit";

// Define the structure of your Kontent.ai content type
interface MovieType extends MigrationElements {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { MigrationItem } from "@kontent-ai/migration-toolkit";

const migrationItem: MigrationItem = {
// Variant's metadata
system: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import {
storeAsync,
} from "@kontent-ai-consulting/migration-toolkit";
import { storeAsync } from "@kontent-ai/migration-toolkit";

// Store your mapped data on the filesystem
await storeAsync({
data: {
assets: migrationAssets,
items: migrationItems
items: migrationItems,
},
filename: 'core_content.zip',
});
filename: "core_content.zip",
});

0 comments on commit 3a58da1

Please sign in to comment.