@kontent-ai/migration-toolkit 2.9.1 → 3.0.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.
- package/README.md +19 -17
- package/dist/core/config.js +3 -3
- package/dist/core/config.js.map +1 -1
- package/dist/core/helpers/workflow-helper.d.ts +1 -1
- package/dist/core/helpers/workflow-helper.js +28 -26
- package/dist/core/helpers/workflow-helper.js.map +1 -1
- package/dist/core/logs/loggers.d.ts +1 -1
- package/dist/core/logs/loggers.js +15 -15
- package/dist/core/logs/loggers.js.map +1 -1
- package/dist/core/models/core.models.d.ts +27 -22
- package/dist/core/models/error.models.d.ts +14 -0
- package/dist/core/models/error.models.js +25 -0
- package/dist/core/models/error.models.js.map +1 -0
- package/dist/core/models/log.models.d.ts +2 -2
- package/dist/core/models/migration.models.d.ts +14 -14
- package/dist/core/models/migration.schema.d.ts +9 -9
- package/dist/core/models/migration.schema.js +28 -28
- package/dist/core/models/migration.schema.js.map +1 -1
- package/dist/core/utils/array.utils.d.ts +1 -1
- package/dist/core/utils/array.utils.js +4 -3
- package/dist/core/utils/array.utils.js.map +1 -1
- package/dist/core/utils/binary-data.utils.d.ts +1 -1
- package/dist/core/utils/binary-data.utils.js +6 -6
- package/dist/core/utils/binary-data.utils.js.map +1 -1
- package/dist/core/utils/confirm.utils.d.ts +1 -1
- package/dist/core/utils/confirm.utils.js +21 -20
- package/dist/core/utils/confirm.utils.js.map +1 -1
- package/dist/core/utils/error.utils.d.ts +1 -1
- package/dist/core/utils/error.utils.js +16 -14
- package/dist/core/utils/error.utils.js.map +1 -1
- package/dist/core/utils/external-id.utils.js +1 -1
- package/dist/core/utils/external-id.utils.js.map +1 -1
- package/dist/core/utils/global.utils.d.ts +3 -3
- package/dist/core/utils/global.utils.js +20 -18
- package/dist/core/utils/global.utils.js.map +1 -1
- package/dist/core/utils/http.utils.d.ts +2 -2
- package/dist/core/utils/http.utils.js +4 -4
- package/dist/core/utils/http.utils.js.map +1 -1
- package/dist/core/utils/management-client-utils.d.ts +4 -4
- package/dist/core/utils/management-client-utils.js +34 -34
- package/dist/core/utils/management-client-utils.js.map +1 -1
- package/dist/core/utils/processing-utils.d.ts +4 -4
- package/dist/core/utils/processing-utils.js +13 -13
- package/dist/core/utils/processing-utils.js.map +1 -1
- package/dist/core/utils/run.utils.d.ts +2 -2
- package/dist/core/utils/run.utils.js +7 -7
- package/dist/core/utils/run.utils.js.map +1 -1
- package/dist/export/context/export-context-fetcher.d.ts +1 -1
- package/dist/export/context/export-context-fetcher.js +92 -62
- package/dist/export/context/export-context-fetcher.js.map +1 -1
- package/dist/export/export-manager.d.ts +2 -2
- package/dist/export/export-manager.js +46 -37
- package/dist/export/export-manager.js.map +1 -1
- package/dist/export/export.models.d.ts +21 -2
- package/dist/export/utils/export.utils.d.ts +1 -1
- package/dist/export/utils/export.utils.js +3 -2
- package/dist/export/utils/export.utils.js.map +1 -1
- package/dist/file/file-manager.d.ts +2 -2
- package/dist/file/file-manager.js +7 -7
- package/dist/file/file-manager.js.map +1 -1
- package/dist/import/comparers/asset-comparer.d.ts +2 -2
- package/dist/import/comparers/asset-comparer.js +12 -11
- package/dist/import/comparers/asset-comparer.js.map +1 -1
- package/dist/import/context/import-context-fetcher.d.ts +1 -1
- package/dist/import/context/import-context-fetcher.js +77 -73
- package/dist/import/context/import-context-fetcher.js.map +1 -1
- package/dist/import/import-manager.d.ts +1 -1
- package/dist/import/import-manager.js +59 -56
- package/dist/import/import-manager.js.map +1 -1
- package/dist/import/import.models.d.ts +6 -2
- package/dist/import/importers/assets-importer.d.ts +3 -3
- package/dist/import/importers/assets-importer.js +46 -43
- package/dist/import/importers/assets-importer.js.map +1 -1
- package/dist/import/importers/content-items-importer.d.ts +3 -3
- package/dist/import/importers/content-items-importer.js +28 -25
- package/dist/import/importers/content-items-importer.js.map +1 -1
- package/dist/import/importers/language-variant-importer.d.ts +3 -3
- package/dist/import/importers/language-variant-importer.js +45 -45
- package/dist/import/importers/language-variant-importer.js.map +1 -1
- package/dist/import/importers/workflow-importer.d.ts +3 -2
- package/dist/import/importers/workflow-importer.js +58 -54
- package/dist/import/importers/workflow-importer.js.map +1 -1
- package/dist/import/utils/import.utils.d.ts +1 -1
- package/dist/import/utils/import.utils.js +3 -2
- package/dist/import/utils/import.utils.js.map +1 -1
- package/dist/index.d.ts +11 -7
- package/dist/index.js +10 -8
- package/dist/index.js.map +1 -1
- package/dist/metadata.js +3 -3
- package/dist/metadata.js.map +1 -1
- package/dist/node/cli/actions/export-action.d.ts +1 -1
- package/dist/node/cli/actions/export-action.js +28 -23
- package/dist/node/cli/actions/export-action.js.map +1 -1
- package/dist/node/cli/actions/import-action.d.ts +1 -1
- package/dist/node/cli/actions/import-action.js +15 -12
- package/dist/node/cli/actions/import-action.js.map +1 -1
- package/dist/node/cli/actions/migrate-action.d.ts +1 -1
- package/dist/node/cli/actions/migrate-action.js +25 -22
- package/dist/node/cli/actions/migrate-action.js.map +1 -1
- package/dist/node/cli/app.js +13 -12
- package/dist/node/cli/app.js.map +1 -1
- package/dist/node/cli/args/args-fetcher.d.ts +1 -1
- package/dist/node/cli/args/args-fetcher.js +14 -13
- package/dist/node/cli/args/args-fetcher.js.map +1 -1
- package/dist/node/cli/args/args-setter.d.ts +1 -1
- package/dist/node/cli/args/args-setter.js +8 -6
- package/dist/node/cli/args/args-setter.js.map +1 -1
- package/dist/node/cli/cli.models.d.ts +2 -2
- package/dist/node/cli/commands.js +68 -56
- package/dist/node/cli/commands.js.map +1 -1
- package/dist/toolkit/elements-builder.d.ts +1 -1
- package/dist/toolkit/elements-builder.js +12 -12
- package/dist/toolkit/elements-builder.js.map +1 -1
- package/dist/toolkit/export.d.ts +2 -2
- package/dist/toolkit/export.js +8 -8
- package/dist/toolkit/export.js.map +1 -1
- package/dist/toolkit/file.d.ts +2 -1
- package/dist/toolkit/file.js +18 -16
- package/dist/toolkit/file.js.map +1 -1
- package/dist/toolkit/import.d.ts +1 -1
- package/dist/toolkit/import.js +12 -12
- package/dist/toolkit/import.js.map +1 -1
- package/dist/toolkit/migrate.d.ts +13 -4
- package/dist/toolkit/migrate.js +15 -13
- package/dist/toolkit/migrate.js.map +1 -1
- package/dist/translation/extraction/items-extraction.processor.d.ts +5 -4
- package/dist/translation/extraction/items-extraction.processor.js +73 -35
- package/dist/translation/extraction/items-extraction.processor.js.map +1 -1
- package/dist/translation/helpers/export-placeholder.utils.d.ts +11 -0
- package/dist/translation/helpers/export-placeholder.utils.js +11 -0
- package/dist/translation/helpers/export-placeholder.utils.js.map +1 -0
- package/dist/translation/helpers/rich-text.processor.d.ts +6 -6
- package/dist/translation/helpers/rich-text.processor.js +38 -38
- package/dist/translation/helpers/rich-text.processor.js.map +1 -1
- package/dist/translation/transforms/export-transforms.d.ts +2 -2
- package/dist/translation/transforms/export-transforms.js +93 -67
- package/dist/translation/transforms/export-transforms.js.map +1 -1
- package/dist/translation/transforms/import-transforms.d.ts +2 -2
- package/dist/translation/transforms/import-transforms.js +38 -40
- package/dist/translation/transforms/import-transforms.js.map +1 -1
- package/dist/zip/zip-manager.d.ts +4 -3
- package/dist/zip/zip-manager.js +9 -9
- package/dist/zip/zip-manager.js.map +1 -1
- package/dist/zip/zip-packager.d.ts +2 -2
- package/dist/zip/zip-packager.js +19 -17
- package/dist/zip/zip-packager.js.map +1 -1
- package/dist/zip/zip-transformer.d.ts +3 -2
- package/dist/zip/zip-transformer.js +16 -15
- package/dist/zip/zip-transformer.js.map +1 -1
- package/dist/zip/zip.models.d.ts +2 -2
- package/lib/core/config.ts +6 -6
- package/lib/core/helpers/workflow-helper.ts +190 -185
- package/lib/core/logs/loggers.ts +52 -52
- package/lib/core/models/core.models.ts +128 -119
- package/lib/core/models/error.models.ts +41 -0
- package/lib/core/models/log.models.ts +20 -20
- package/lib/core/models/migration.models.ts +54 -54
- package/lib/core/models/migration.schema.ts +108 -108
- package/lib/core/utils/array.utils.ts +43 -42
- package/lib/core/utils/binary-data.utils.ts +16 -16
- package/lib/core/utils/confirm.utils.ts +106 -105
- package/lib/core/utils/error.utils.ts +69 -72
- package/lib/core/utils/external-id.utils.ts +4 -4
- package/lib/core/utils/global.utils.ts +81 -75
- package/lib/core/utils/http.utils.ts +23 -23
- package/lib/core/utils/management-client-utils.ts +186 -186
- package/lib/core/utils/processing-utils.ts +82 -82
- package/lib/core/utils/run.utils.ts +50 -50
- package/lib/export/context/export-context-fetcher.ts +472 -447
- package/lib/export/export-manager.ts +233 -232
- package/lib/export/export.models.ts +71 -56
- package/lib/export/utils/export.utils.ts +9 -7
- package/lib/file/file-manager.ts +28 -28
- package/lib/import/comparers/asset-comparer.ts +107 -106
- package/lib/import/context/import-context-fetcher.ts +462 -462
- package/lib/import/import-manager.ts +243 -240
- package/lib/import/import.models.ts +69 -67
- package/lib/import/importers/assets-importer.ts +240 -236
- package/lib/import/importers/content-items-importer.ts +126 -122
- package/lib/import/importers/language-variant-importer.ts +324 -328
- package/lib/import/importers/workflow-importer.ts +372 -367
- package/lib/import/utils/import.utils.ts +9 -7
- package/lib/index.ts +12 -8
- package/lib/metadata.ts +3 -4
- package/lib/node/cli/actions/export-action.ts +43 -38
- package/lib/node/cli/actions/import-action.ts +32 -29
- package/lib/node/cli/actions/migrate-action.ts +49 -46
- package/lib/node/cli/app.ts +21 -21
- package/lib/node/cli/args/args-fetcher.ts +55 -54
- package/lib/node/cli/args/args-setter.ts +34 -32
- package/lib/node/cli/cli.models.ts +17 -17
- package/lib/node/cli/commands.ts +165 -153
- package/lib/toolkit/elements-builder.ts +69 -69
- package/lib/toolkit/export.ts +21 -21
- package/lib/toolkit/file.ts +59 -53
- package/lib/toolkit/import.ts +32 -32
- package/lib/toolkit/migrate.ts +60 -49
- package/lib/translation/extraction/items-extraction.processor.ts +203 -173
- package/lib/translation/helpers/export-placeholder.utils.ts +10 -0
- package/lib/translation/helpers/rich-text.processor.ts +311 -311
- package/lib/translation/transforms/export-transforms.ts +313 -279
- package/lib/translation/transforms/import-transforms.ts +188 -191
- package/lib/zip/zip-manager.ts +28 -27
- package/lib/zip/zip-packager.ts +75 -73
- package/lib/zip/zip-transformer.ts +112 -107
- package/lib/zip/zip.models.ts +7 -7
- package/package.json +91 -84
- package/dist/core/index.d.ts +0 -16
- package/dist/core/index.js +0 -17
- package/dist/core/index.js.map +0 -1
- package/dist/export/index.d.ts +0 -2
- package/dist/export/index.js +0 -3
- package/dist/export/index.js.map +0 -1
- package/dist/file/index.d.ts +0 -1
- package/dist/file/index.js +0 -2
- package/dist/file/index.js.map +0 -1
- package/dist/import/index.d.ts +0 -2
- package/dist/import/index.js +0 -3
- package/dist/import/index.js.map +0 -1
- package/dist/toolkit/index.d.ts +0 -5
- package/dist/toolkit/index.js +0 -6
- package/dist/toolkit/index.js.map +0 -1
- package/dist/translation/index.d.ts +0 -4
- package/dist/translation/index.js +0 -5
- package/dist/translation/index.js.map +0 -1
- package/dist/zip/index.d.ts +0 -4
- package/dist/zip/index.js +0 -5
- package/dist/zip/index.js.map +0 -1
- package/lib/core/index.ts +0 -18
- package/lib/export/index.ts +0 -2
- package/lib/file/index.ts +0 -1
- package/lib/import/index.ts +0 -2
- package/lib/toolkit/index.ts +0 -5
- package/lib/translation/index.ts +0 -4
- package/lib/zip/index.ts +0 -4
|
@@ -1,169 +1,178 @@
|
|
|
1
1
|
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from
|
|
8
|
-
import type { MigrationElementType } from
|
|
2
|
+
AssetModels,
|
|
3
|
+
ContentItemModels,
|
|
4
|
+
ContentTypeElements,
|
|
5
|
+
LanguageVariantModels,
|
|
6
|
+
WorkflowModels,
|
|
7
|
+
} from "@kontent-ai/management-sdk";
|
|
8
|
+
import type { MigrationElementType } from "./migration.models.js";
|
|
9
9
|
|
|
10
10
|
export type LiteralUnion<T extends string> = T | (string & {});
|
|
11
|
-
export type TargetItemState =
|
|
12
|
-
export type CliAction =
|
|
13
|
-
export type EnvContext =
|
|
11
|
+
export type TargetItemState = "exists" | "doesNotExists";
|
|
12
|
+
export type CliAction = "export" | "import" | "migrate";
|
|
13
|
+
export type EnvContext = "browser" | "node";
|
|
14
14
|
|
|
15
15
|
export type MapiAction =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
export type MigrationItemType =
|
|
16
|
+
| "list"
|
|
17
|
+
| "view"
|
|
18
|
+
| "archive"
|
|
19
|
+
| "unpublish"
|
|
20
|
+
| "changeWorkflowStep"
|
|
21
|
+
| "publish"
|
|
22
|
+
| "upload"
|
|
23
|
+
| "create"
|
|
24
|
+
| "upsert"
|
|
25
|
+
| "schedulePublish"
|
|
26
|
+
| "scheduleUnpublish"
|
|
27
|
+
| "cancelScheduledPublish"
|
|
28
|
+
| "cancelScheduledUnpublish"
|
|
29
|
+
| "createNewVersion";
|
|
30
|
+
|
|
31
|
+
export type MigrationItemType = "exportItem";
|
|
32
32
|
|
|
33
33
|
export type MapiType =
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
export type LanguageVariantWorkflowStateValues =
|
|
47
|
-
export type LanguageVariantSchedulesStateValues =
|
|
34
|
+
| "contentType"
|
|
35
|
+
| "assetFolder"
|
|
36
|
+
| "asset"
|
|
37
|
+
| "contentTypeSnippet"
|
|
38
|
+
| "contentItem"
|
|
39
|
+
| "languageVariant"
|
|
40
|
+
| "language"
|
|
41
|
+
| "collection"
|
|
42
|
+
| "taxonomy"
|
|
43
|
+
| "binaryFile"
|
|
44
|
+
| "workflow";
|
|
45
|
+
|
|
46
|
+
export type LanguageVariantWorkflowStateValues = "published" | "archived" | "draft" | "scheduled";
|
|
47
|
+
export type LanguageVariantSchedulesStateValues = "scheduledPublish" | "scheduledUnpublish" | "n/a";
|
|
48
48
|
export type LanguageVariantWorkflowState =
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
| {
|
|
50
|
+
readonly workflowState: LanguageVariantWorkflowStateValues;
|
|
51
|
+
readonly scheduledState: LanguageVariantSchedulesStateValues;
|
|
52
|
+
}
|
|
53
|
+
| undefined;
|
|
54
54
|
|
|
55
55
|
export interface ItemInfo {
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
readonly title: string;
|
|
57
|
+
readonly itemType: MapiType | MigrationItemType;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export interface ErrorData {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
readonly message: string;
|
|
62
|
+
readonly requestData?: string;
|
|
63
|
+
readonly requestUrl?: string;
|
|
64
|
+
readonly isUnknownError: boolean;
|
|
65
|
+
readonly error: unknown;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
export interface ReferencedDataInMigrationItems {
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
readonly itemCodenames: ReadonlySet<string>;
|
|
70
|
+
readonly assetCodenames: ReadonlySet<string>;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
export interface ReferencedDataInLanguageVariants {
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
readonly itemIds: ReadonlySet<string>;
|
|
75
|
+
readonly assetIds: ReadonlySet<string>;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
78
|
+
type DataStateInSourceEnvironmentById<T extends Readonly<ContentItemModels.ContentItem> | Readonly<AssetModels.Asset>> = {
|
|
79
|
+
readonly id: string;
|
|
80
|
+
} & (
|
|
81
|
+
| {
|
|
82
|
+
readonly state: "exists";
|
|
83
|
+
readonly data: T;
|
|
84
|
+
}
|
|
85
|
+
| {
|
|
86
|
+
readonly state: "doesNotExists";
|
|
87
|
+
readonly data?: never;
|
|
88
|
+
}
|
|
89
|
+
| {
|
|
90
|
+
readonly state: "skip";
|
|
91
|
+
readonly data?: never;
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
export type ItemStateInSourceEnvironmentById = DataStateInSourceEnvironmentById<Readonly<ContentItemModels.ContentItem>>;
|
|
96
|
+
|
|
97
|
+
export type AssetStateInSourceEnvironmentById = DataStateInSourceEnvironmentById<Readonly<AssetModels.Asset>>;
|
|
89
98
|
|
|
90
99
|
export interface ItemStateInTargetEnvironmentByCodename {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
100
|
+
readonly state: TargetItemState;
|
|
101
|
+
readonly itemCodename: string;
|
|
102
|
+
readonly item: Readonly<ContentItemModels.ContentItem> | undefined;
|
|
103
|
+
readonly externalIdToUse: string;
|
|
95
104
|
}
|
|
96
105
|
|
|
97
106
|
export interface LanguageVariantStateData {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
107
|
+
readonly languageVariant: Readonly<LanguageVariantModels.ContentItemLanguageVariant> | undefined;
|
|
108
|
+
readonly workflow: Readonly<WorkflowModels.Workflow> | undefined;
|
|
109
|
+
readonly workflowState: LanguageVariantWorkflowState;
|
|
101
110
|
}
|
|
102
111
|
|
|
103
112
|
export interface LanguageVariantStateInTargetEnvironmentByCodename {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
113
|
+
readonly state: TargetItemState;
|
|
114
|
+
readonly itemCodename: string;
|
|
115
|
+
readonly languageCodename: string;
|
|
116
|
+
readonly publishedLanguageVariant: LanguageVariantStateData | undefined;
|
|
117
|
+
readonly draftLanguageVariant: LanguageVariantStateData | undefined;
|
|
109
118
|
}
|
|
110
119
|
|
|
111
120
|
export interface AssetStateInTargetEnvironmentByCodename {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
121
|
+
readonly state: TargetItemState;
|
|
122
|
+
readonly assetCodename: string;
|
|
123
|
+
readonly asset: Readonly<AssetModels.Asset> | undefined;
|
|
124
|
+
readonly externalIdToUse: string;
|
|
116
125
|
}
|
|
117
126
|
|
|
118
127
|
export interface PackageMetadata {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
128
|
+
readonly created: Date;
|
|
129
|
+
readonly environmentId: string;
|
|
130
|
+
readonly dataOverview: PackageDataOverview;
|
|
122
131
|
}
|
|
123
132
|
|
|
124
133
|
export interface PackageDataOverview {
|
|
125
|
-
|
|
126
|
-
|
|
134
|
+
readonly contentItemsCount: number;
|
|
135
|
+
readonly assetsCount: number;
|
|
127
136
|
}
|
|
128
137
|
|
|
129
138
|
export interface FlattenedContentTypeElement {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
139
|
+
readonly codename: string;
|
|
140
|
+
readonly id: string;
|
|
141
|
+
readonly type: MigrationElementType;
|
|
142
|
+
readonly element: Readonly<ContentTypeElements.ContentTypeElementModel>;
|
|
134
143
|
}
|
|
135
144
|
|
|
136
145
|
export interface FlattenedContentType {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
146
|
+
readonly contentTypeCodename: string;
|
|
147
|
+
readonly contentTypeId: string;
|
|
148
|
+
readonly elements: readonly FlattenedContentTypeElement[];
|
|
140
149
|
}
|
|
141
150
|
|
|
142
151
|
export interface OriginalManagementError {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
152
|
+
readonly response?: {
|
|
153
|
+
readonly status?: number;
|
|
154
|
+
readonly config?: {
|
|
155
|
+
readonly url?: string;
|
|
156
|
+
readonly data?: string;
|
|
157
|
+
};
|
|
158
|
+
readonly data?: {
|
|
159
|
+
readonly error_code?: number;
|
|
160
|
+
};
|
|
161
|
+
};
|
|
153
162
|
}
|
|
154
163
|
|
|
155
164
|
export type ItemProcessingResult<InputItem, OutputItem> =
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
165
|
+
| {
|
|
166
|
+
readonly state: "valid";
|
|
167
|
+
readonly inputItem: InputItem;
|
|
168
|
+
readonly outputItem: OutputItem;
|
|
169
|
+
}
|
|
170
|
+
| {
|
|
171
|
+
readonly state: "error";
|
|
172
|
+
readonly inputItem: InputItem;
|
|
173
|
+
readonly error: unknown;
|
|
174
|
+
}
|
|
175
|
+
| {
|
|
176
|
+
readonly state: "404";
|
|
177
|
+
readonly inputItem: InputItem;
|
|
178
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import chalk from "chalk";
|
|
2
|
+
|
|
3
|
+
export type MigrationToolkitErrorType =
|
|
4
|
+
| "confirmationRefused"
|
|
5
|
+
| "invalidZip"
|
|
6
|
+
| "invalidFolder"
|
|
7
|
+
| "unsupportedCommand"
|
|
8
|
+
| "importFailedForItem"
|
|
9
|
+
| "invalidElement"
|
|
10
|
+
| "exportFailedForItem"
|
|
11
|
+
| "missingContentType"
|
|
12
|
+
| "invalidEnvironment"
|
|
13
|
+
| "exitProgram"
|
|
14
|
+
| "missingItem"
|
|
15
|
+
| "findRequiredError"
|
|
16
|
+
| "missingWorkflowStep"
|
|
17
|
+
| "missingAsset"
|
|
18
|
+
| "missingTaxonomyTerm"
|
|
19
|
+
| "invalidValue"
|
|
20
|
+
| "invalidMultipleChoiceOption";
|
|
21
|
+
|
|
22
|
+
export class MigrationToolkitError extends Error {
|
|
23
|
+
constructor(
|
|
24
|
+
public readonly type: MigrationToolkitErrorType,
|
|
25
|
+
readonly message: string,
|
|
26
|
+
) {
|
|
27
|
+
super(message);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export class MissingItemError extends MigrationToolkitError {
|
|
32
|
+
constructor(public readonly id: string) {
|
|
33
|
+
super("missingItem", `Missing item with id '${chalk.red(id)}'`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class MissingAssetError extends MigrationToolkitError {
|
|
38
|
+
constructor(public readonly id: string) {
|
|
39
|
+
super("missingAsset", `Missing asset with id '${chalk.red(id)}'`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import type { MapiAction, MapiType, MigrationItemType } from
|
|
1
|
+
import type { MapiAction, MapiType, MigrationItemType } from "./core.models.js";
|
|
2
2
|
|
|
3
3
|
export type DebugType =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
| "error"
|
|
5
|
+
| "completed"
|
|
6
|
+
| "warning"
|
|
7
|
+
| "info"
|
|
8
|
+
| "errorData"
|
|
9
|
+
| "cancel"
|
|
10
|
+
| "process"
|
|
11
|
+
| "readFs"
|
|
12
|
+
| "skip"
|
|
13
|
+
| "writeFs"
|
|
14
|
+
| "download"
|
|
15
|
+
| MigrationItemType
|
|
16
|
+
| MapiType
|
|
17
|
+
| MapiAction;
|
|
18
18
|
|
|
19
19
|
export interface LogMessage {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
readonly type?: DebugType;
|
|
21
|
+
readonly message: string;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export interface LogSpinnerMessage extends LogMessage {
|
|
25
|
-
|
|
25
|
+
readonly prefix?: string;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export type LogData = (data: LogMessage) => void;
|
|
29
29
|
export type LogSpinnerData = (data: LogSpinnerMessage) => void;
|
|
30
30
|
|
|
31
31
|
export interface Logger {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
readonly logWithSpinnerAsync: <T>(func: (logData: LogSpinnerData) => Promise<T>) => Promise<T>;
|
|
33
|
+
readonly log: LogData;
|
|
34
34
|
}
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
import type { z } from
|
|
1
|
+
import type { z } from "zod";
|
|
2
2
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} from
|
|
3
|
+
MigrationAssetDescriptionSchema,
|
|
4
|
+
MigrationAssetSchema,
|
|
5
|
+
MigrationComponentSchema,
|
|
6
|
+
MigrationDataSchema,
|
|
7
|
+
MigrationElementSchema,
|
|
8
|
+
MigrationElementsSchema,
|
|
9
|
+
MigrationElementTypeSchema,
|
|
10
|
+
MigrationElementValueSchema,
|
|
11
|
+
MigrationItemSchema,
|
|
12
|
+
MigrationItemSystemSchema,
|
|
13
|
+
MigrationItemVersionSchema,
|
|
14
|
+
MigrationReferenceSchema,
|
|
15
|
+
MigrationUrlSlugModeSchema,
|
|
16
|
+
} from "./migration.schema.js";
|
|
17
17
|
|
|
18
18
|
export namespace MigrationElementModels {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
type MigrationElementDef<
|
|
20
|
+
TElementType extends MigrationElementType = MigrationElementType,
|
|
21
|
+
TValue extends MigrationElementValue = MigrationElementValue,
|
|
22
|
+
> = {
|
|
23
|
+
readonly value: TValue | undefined;
|
|
24
|
+
readonly type: TElementType;
|
|
25
|
+
};
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
export type TextElement = MigrationElementDef<"text", string>;
|
|
28
|
+
export type NumberElement = MigrationElementDef<"number", number>;
|
|
29
|
+
export type RichTextElement = MigrationElementDef<"rich_text", string> & Pick<MigrationElement, "components">;
|
|
30
|
+
export type MultipleChoiceElement = MigrationElementDef<"multiple_choice", MigrationReference[]>;
|
|
31
|
+
export type DateTimeElement = MigrationElementDef<"date_time", string> & Pick<MigrationElement, "display_timezone">;
|
|
32
|
+
export type AssetElement = MigrationElementDef<"asset", MigrationReference[]>;
|
|
33
|
+
export type LinkedItemsElement = MigrationElementDef<"modular_content", MigrationReference[]>;
|
|
34
|
+
export type TaxonomyElement = MigrationElementDef<"taxonomy", MigrationReference[]>;
|
|
35
|
+
export type UrlSlugElement = MigrationElementDef<"url_slug", string> & Pick<MigrationElement, "mode">;
|
|
36
|
+
export type CustomElement = MigrationElementDef<"custom", string>;
|
|
37
|
+
export type SubpagesElement = MigrationElementDef<"subpages", MigrationReference[]>;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export type MigrationReference<T extends string = string> = z.infer<typeof MigrationReferenceSchema> & {
|
|
41
|
-
|
|
41
|
+
readonly codename: T;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
export type MigrationItemSystem<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
TTypeCodenames extends string = string,
|
|
46
|
+
TLanguageCodenames extends string = string,
|
|
47
|
+
TCollectionCodenames extends string = string,
|
|
48
|
+
TWorkflowCodenames extends string = string,
|
|
49
49
|
> = z.infer<typeof MigrationItemSystemSchema> & {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
50
|
+
readonly codename: string;
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly language: MigrationReference<TLanguageCodenames>;
|
|
53
|
+
readonly type: MigrationReference<TTypeCodenames>;
|
|
54
|
+
readonly collection: MigrationReference<TCollectionCodenames>;
|
|
55
|
+
readonly workflow: MigrationReference<TWorkflowCodenames>;
|
|
56
56
|
};
|
|
57
57
|
export type MigrationUrlSlugMode = z.infer<typeof MigrationUrlSlugModeSchema>;
|
|
58
58
|
export type MigrationElementType = z.infer<typeof MigrationElementTypeSchema>;
|
|
59
59
|
export type MigrationComponent = z.infer<typeof MigrationComponentSchema>;
|
|
60
60
|
export type MigrationElementValue = z.infer<typeof MigrationElementValueSchema>;
|
|
61
61
|
export type MigrationElement = z.infer<typeof MigrationElementSchema>;
|
|
62
|
-
export type MigrationElementTransformData = Omit<MigrationElement,
|
|
62
|
+
export type MigrationElementTransformData = Omit<MigrationElement, "type">;
|
|
63
63
|
export type MigrationElements = z.infer<typeof MigrationElementsSchema>;
|
|
64
64
|
export type MigrationAssetDescription = z.infer<typeof MigrationAssetDescriptionSchema>;
|
|
65
65
|
export type MigrationAsset = z.infer<typeof MigrationAssetSchema>;
|
|
66
66
|
export type MigrationData = z.infer<typeof MigrationDataSchema>;
|
|
67
67
|
|
|
68
68
|
export type MigrationItemVersion<
|
|
69
|
-
|
|
70
|
-
|
|
69
|
+
TElements extends MigrationElements = MigrationElements,
|
|
70
|
+
TWorkflowStepCodenames extends string = string,
|
|
71
71
|
> = z.infer<typeof MigrationItemVersionSchema> & {
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
readonly elements: Readonly<TElements>;
|
|
73
|
+
readonly workflow_step: MigrationReference<TWorkflowStepCodenames>;
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
export type MigrationItem<
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
TElements extends MigrationElements = MigrationElements,
|
|
78
|
+
TSystem extends MigrationItemSystem = MigrationItemSystem,
|
|
79
|
+
TWorkflowStepCodenames extends string = string,
|
|
80
80
|
> = z.infer<typeof MigrationItemSchema> & {
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
readonly versions: Readonly<MigrationItemVersion<TElements, TWorkflowStepCodenames>[]>;
|
|
82
|
+
readonly system: TSystem;
|
|
83
83
|
};
|