@kontent-ai/migration-toolkit 1.0.1 → 1.1.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.
- package/README.md +1 -1
- package/dist/es2022/core/index.d.ts +1 -0
- package/dist/es2022/core/index.js +1 -0
- package/dist/es2022/core/index.js.map +1 -1
- package/dist/es2022/core/models/migration.models.d.ts +35 -133
- package/dist/es2022/core/models/migration.schema.d.ts +1300 -0
- package/dist/es2022/core/models/migration.schema.js +114 -0
- package/dist/es2022/core/models/migration.schema.js.map +1 -0
- package/dist/es2022/core/utils/confirm.utils.js +3 -3
- package/dist/es2022/core/utils/confirm.utils.js.map +1 -1
- package/dist/es2022/core/utils/error.utils.js +8 -2
- package/dist/es2022/core/utils/error.utils.js.map +1 -1
- package/dist/es2022/core/utils/global.utils.d.ts +4 -1
- package/dist/es2022/core/utils/global.utils.js +1 -3
- package/dist/es2022/core/utils/global.utils.js.map +1 -1
- package/dist/es2022/export/context/export-context-fetcher.js +10 -6
- package/dist/es2022/export/context/export-context-fetcher.js.map +1 -1
- package/dist/es2022/export/export-manager.js +3 -3
- package/dist/es2022/export/export-manager.js.map +1 -1
- package/dist/es2022/import/import-manager.js.map +1 -1
- package/dist/es2022/metadata.js +2 -2
- package/dist/es2022/node/cli/actions/export-action.js +2 -2
- package/dist/es2022/node/cli/actions/export-action.js.map +1 -1
- package/dist/es2022/node/cli/actions/import-action.js +2 -2
- package/dist/es2022/node/cli/actions/import-action.js.map +1 -1
- package/dist/es2022/toolkit/file.js +3 -3
- package/dist/es2022/toolkit/file.js.map +1 -1
- package/dist/es2022/translation/transforms/export-transforms.js.map +1 -1
- package/dist/es2022/zip/zip-transformer.js +9 -6
- package/dist/es2022/zip/zip-transformer.js.map +1 -1
- package/dist/es2022/zip/zip.models.d.ts +1 -1
- package/lib/core/index.ts +1 -0
- package/lib/core/models/migration.models.ts +56 -159
- package/lib/core/models/migration.schema.ts +180 -0
- package/lib/core/utils/confirm.utils.ts +4 -4
- package/lib/core/utils/error.utils.ts +9 -6
- package/lib/core/utils/global.utils.ts +3 -3
- package/lib/export/context/export-context-fetcher.ts +9 -6
- package/lib/export/export-manager.ts +16 -20
- package/lib/import/import-manager.ts +2 -6
- package/lib/metadata.ts +2 -2
- package/lib/node/cli/actions/export-action.ts +2 -2
- package/lib/node/cli/actions/import-action.ts +2 -2
- package/lib/toolkit/file.ts +3 -9
- package/lib/translation/transforms/export-transforms.ts +1 -4
- package/lib/zip/zip-transformer.ts +25 -11
- package/lib/zip/zip.models.ts +1 -1
- package/package.json +10 -9
package/lib/toolkit/file.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { fileManager } from '../file/index.js';
|
|
2
|
-
import {
|
|
3
|
-
Logger,
|
|
4
|
-
executeWithTrackingAsync,
|
|
5
|
-
getDefaultZipFilename,
|
|
6
|
-
getDefaultLogger,
|
|
7
|
-
MigrationData
|
|
8
|
-
} from '../core/index.js';
|
|
2
|
+
import { Logger, executeWithTrackingAsync, defaultZipFilename, getDefaultLogger, MigrationData } from '../core/index.js';
|
|
9
3
|
import { zipManager } from '../zip/index.js';
|
|
10
4
|
import { libMetadata } from '../metadata.js';
|
|
11
5
|
|
|
@@ -22,7 +16,7 @@ export interface ExtractConfig {
|
|
|
22
16
|
|
|
23
17
|
export async function storeAsync(config: StoreConfig): Promise<void> {
|
|
24
18
|
const logger = config.logger ?? getDefaultLogger();
|
|
25
|
-
const filename
|
|
19
|
+
const filename = config.filename ?? defaultZipFilename;
|
|
26
20
|
|
|
27
21
|
await executeWithTrackingAsync<void>({
|
|
28
22
|
event: {
|
|
@@ -49,7 +43,7 @@ export async function storeAsync(config: StoreConfig): Promise<void> {
|
|
|
49
43
|
|
|
50
44
|
export async function extractAsync(config: ExtractConfig): Promise<MigrationData> {
|
|
51
45
|
const logger = config.logger ?? getDefaultLogger();
|
|
52
|
-
const filename
|
|
46
|
+
const filename = config.filename ?? defaultZipFilename;
|
|
53
47
|
|
|
54
48
|
return await executeWithTrackingAsync({
|
|
55
49
|
event: {
|
|
@@ -175,10 +175,7 @@ export const exportTransforms: Readonly<Record<MigrationElementType, ExportTrans
|
|
|
175
175
|
}
|
|
176
176
|
};
|
|
177
177
|
|
|
178
|
-
function findTaxonomy(
|
|
179
|
-
termId: string,
|
|
180
|
-
taxonomy: Readonly<TaxonomyModels.Taxonomy>
|
|
181
|
-
): Readonly<TaxonomyModels.Taxonomy> | undefined {
|
|
178
|
+
function findTaxonomy(termId: string, taxonomy: Readonly<TaxonomyModels.Taxonomy>): Readonly<TaxonomyModels.Taxonomy> | undefined {
|
|
182
179
|
if (taxonomy.id === termId) {
|
|
183
180
|
return taxonomy;
|
|
184
181
|
}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
import { FileBinaryData, ZipPackager } from './zip.models.js';
|
|
2
|
-
import { Logger, MigrationAsset, MigrationData, MigrationItem, getDefaultLogger, mapAsync } from '../core/index.js';
|
|
3
1
|
import chalk from 'chalk';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { FileBinaryData, ZipPackager } from './zip.models.js';
|
|
4
|
+
import {
|
|
5
|
+
Logger,
|
|
6
|
+
MigrationAsset,
|
|
7
|
+
MigrationData,
|
|
8
|
+
MigrationItem,
|
|
9
|
+
MigrationItemsSchema,
|
|
10
|
+
ZipMigrationAssetSchema,
|
|
11
|
+
ZipMigrationAssetsSchema,
|
|
12
|
+
getDefaultLogger,
|
|
13
|
+
mapAsync
|
|
14
|
+
} from '../core/index.js';
|
|
15
|
+
|
|
16
|
+
type ZipAssetRecord = z.infer<typeof ZipMigrationAssetSchema>;
|
|
8
17
|
|
|
9
18
|
export function zipTransformer(zip: ZipPackager, logger?: Logger) {
|
|
10
19
|
const loggerToUse: Logger = logger ?? getDefaultLogger();
|
|
@@ -51,18 +60,23 @@ export function zipTransformer(zip: ZipPackager, logger?: Logger) {
|
|
|
51
60
|
};
|
|
52
61
|
|
|
53
62
|
const parseItems = async () => {
|
|
54
|
-
const
|
|
55
|
-
|
|
63
|
+
const content = await zip.getFileContentAsync(filename);
|
|
64
|
+
|
|
65
|
+
if (!content) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return MigrationItemsSchema.parse(JSON.parse(content));
|
|
56
70
|
};
|
|
57
71
|
|
|
58
72
|
const parseAssets = async () => {
|
|
59
|
-
const
|
|
73
|
+
const content = await zip.getFileContentAsync(assetsFilename);
|
|
60
74
|
|
|
61
|
-
if (!
|
|
75
|
+
if (!content) {
|
|
62
76
|
return [];
|
|
63
77
|
}
|
|
64
78
|
|
|
65
|
-
const assetRecords = JSON.parse(
|
|
79
|
+
const assetRecords = ZipMigrationAssetsSchema.parse(JSON.parse(content));
|
|
66
80
|
|
|
67
81
|
return await mapAsync(assetRecords, async (assetRecord) => {
|
|
68
82
|
const binaryFile = await zip.getBinaryDataAsync(`${assetRecord._zipFilename}`);
|
package/lib/zip/zip.models.ts
CHANGED
|
@@ -4,7 +4,7 @@ export type FileBinaryData = Buffer | Blob;
|
|
|
4
4
|
export type ZipCompressionLevel = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
5
5
|
|
|
6
6
|
export type ZipPackager = {
|
|
7
|
-
addFile(filePath: string, data: string |
|
|
7
|
+
addFile(filePath: string, data: string | FileBinaryData): void;
|
|
8
8
|
addFolder(name: string): ZipPackager;
|
|
9
9
|
generateZipAsync(config: { logger?: Logger; compressionLevel?: ZipCompressionLevel }): Promise<FileBinaryData>;
|
|
10
10
|
getBinaryDataAsync(filePath: string): Promise<FileBinaryData | undefined>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kontent-ai/migration-toolkit",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.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,
|
|
@@ -59,29 +59,30 @@
|
|
|
59
59
|
"chalk": "5.3.0",
|
|
60
60
|
"dotenv": "16.4.5",
|
|
61
61
|
"jszip": "3.10.1",
|
|
62
|
-
"mime": "4.0.
|
|
62
|
+
"mime": "4.0.4",
|
|
63
63
|
"ora": "8.0.1",
|
|
64
64
|
"prompts": "2.4.2",
|
|
65
65
|
"yargs": "17.7.2",
|
|
66
|
-
"p-limit": "
|
|
67
|
-
"deep-equal": "2.2.3"
|
|
66
|
+
"p-limit": "6.1.0",
|
|
67
|
+
"deep-equal": "2.2.3",
|
|
68
|
+
"zod": "3.23.8"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
|
-
"@eslint/js": "9.
|
|
71
|
+
"@eslint/js": "9.7.0",
|
|
71
72
|
"@types/deep-equal": "1.0.4",
|
|
72
73
|
"@types/browser-or-node": "1.3.2",
|
|
73
74
|
"@types/bytes": "3.1.4",
|
|
74
75
|
"@types/eslint__js": "8.42.3",
|
|
75
|
-
"@types/node": "20.14.
|
|
76
|
+
"@types/node": "20.14.10",
|
|
76
77
|
"@types/prompts": "2.4.9",
|
|
77
78
|
"@types/yargs": "17.0.32",
|
|
78
|
-
"@typescript-eslint/eslint-plugin": "7.
|
|
79
|
-
"@typescript-eslint/parser": "7.
|
|
79
|
+
"@typescript-eslint/eslint-plugin": "7.16.0",
|
|
80
|
+
"@typescript-eslint/parser": "7.16.0",
|
|
80
81
|
"eslint": "8.57.0",
|
|
81
82
|
"standard-version": "9.5.0",
|
|
82
83
|
"tslib": "2.6.3",
|
|
83
84
|
"tsx": "4.16.2",
|
|
84
85
|
"typescript": "5.5.3",
|
|
85
|
-
"typescript-eslint": "7.
|
|
86
|
+
"typescript-eslint": "7.16.0"
|
|
86
87
|
}
|
|
87
88
|
}
|