@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,469 +1,469 @@
|
|
|
1
|
-
import type { AssetModels, ContentItemModels, LanguageVariantModels } from
|
|
2
|
-
import chalk from
|
|
3
|
-
import { match } from
|
|
1
|
+
import type { AssetModels, ContentItemModels, LanguageVariantModels } from "@kontent-ai/management-sdk";
|
|
2
|
+
import chalk from "chalk";
|
|
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
6
|
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
} from '../../core/index.js';
|
|
24
|
-
import type { ExtractItemByCodename } from '../../translation/index.js';
|
|
25
|
-
import { itemsExtractionProcessor } from '../../translation/index.js';
|
|
26
|
-
import type { GetFlattenedElementByCodenames, ImportContext, ImportContextConfig, ImportContextEnvironmentData } from '../import.models.js';
|
|
7
|
+
AssetStateInTargetEnvironmentByCodename,
|
|
8
|
+
ItemStateInTargetEnvironmentByCodename,
|
|
9
|
+
LanguageVariantSchedulesStateValues,
|
|
10
|
+
LanguageVariantStateData,
|
|
11
|
+
LanguageVariantStateInTargetEnvironmentByCodename,
|
|
12
|
+
LanguageVariantWorkflowState,
|
|
13
|
+
LanguageVariantWorkflowStateValues,
|
|
14
|
+
} from "../../core/models/core.models.js";
|
|
15
|
+
import { MigrationToolkitError } from "../../core/models/error.models.js";
|
|
16
|
+
import type { LogSpinnerData } from "../../core/models/log.models.js";
|
|
17
|
+
import type { MigrationItem } from "../../core/models/migration.models.js";
|
|
18
|
+
import { findRequired } from "../../core/utils/array.utils.js";
|
|
19
|
+
import { is404Error } from "../../core/utils/error.utils.js";
|
|
20
|
+
import { managementClientUtils } from "../../core/utils/management-client-utils.js";
|
|
21
|
+
import { processItemsAsync } from "../../core/utils/processing-utils.js";
|
|
22
|
+
import { runMapiRequestAsync } from "../../core/utils/run.utils.js";
|
|
23
|
+
import { type ExtractItemByCodename, itemsExtractionProcessor } from "../../translation/extraction/items-extraction.processor.js";
|
|
24
|
+
import type { GetFlattenedElementByCodenames, ImportContext, ImportContextConfig, ImportContextEnvironmentData } from "../import.models.js";
|
|
27
25
|
|
|
28
26
|
interface LanguageVariantWrapper {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
readonly draftLanguageVariant: Readonly<LanguageVariantModels.ContentItemLanguageVariant> | undefined;
|
|
28
|
+
readonly publishedLanguageVariant: Readonly<LanguageVariantModels.ContentItemLanguageVariant> | undefined;
|
|
29
|
+
readonly migrationItem: MigrationItem;
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
export async function importContextFetcherAsync(config: ImportContextConfig) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
33
|
+
const getEnvironmentDataAsync = async (): Promise<ImportContextEnvironmentData> => {
|
|
34
|
+
const mapiUtils = managementClientUtils(config.managementClient, config.logger);
|
|
35
|
+
|
|
36
|
+
return await config.logger.logWithSpinnerAsync(async (spinnerData) => {
|
|
37
|
+
spinnerData({ type: "info", message: `Loading environment data` });
|
|
38
|
+
|
|
39
|
+
const environmentData: ImportContextEnvironmentData = {
|
|
40
|
+
collections: await mapiUtils.getAllCollectionsAsync(spinnerData),
|
|
41
|
+
languages: await mapiUtils.getAllLanguagesAsync(spinnerData),
|
|
42
|
+
workflows: await mapiUtils.getAllWorkflowsAsync(spinnerData),
|
|
43
|
+
types: await mapiUtils.getFlattenedContentTypesAsync(spinnerData),
|
|
44
|
+
assetFolders: await mapiUtils.getAllAssetFoldersAsync(spinnerData),
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
spinnerData({ type: "info", message: `Environmental data loaded` });
|
|
48
|
+
|
|
49
|
+
return environmentData;
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const environmentData = await getEnvironmentDataAsync();
|
|
54
|
+
const workflowHelper = workflowHelperInit(environmentData.workflows);
|
|
55
|
+
|
|
56
|
+
const getElement = () => {
|
|
57
|
+
const getFlattenedElement: GetFlattenedElementByCodenames = (contentTypeCodename, elementCodename, sourceType) => {
|
|
58
|
+
const contentType = findRequired(
|
|
59
|
+
environmentData.types,
|
|
60
|
+
(type) => type.contentTypeCodename === contentTypeCodename,
|
|
61
|
+
`Content type with codename '${chalk.red(contentTypeCodename)}' was not found.`,
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const element = findRequired(
|
|
65
|
+
contentType.elements,
|
|
66
|
+
(element) => element.codename === elementCodename,
|
|
67
|
+
`Element type with codename '${chalk.red(elementCodename)}' was not found in content type '${chalk.red(
|
|
68
|
+
contentTypeCodename,
|
|
69
|
+
)}'. Available elements are '${contentType.elements.map((element) => chalk.yellow(element.codename)).join(", ")}'`,
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
if (sourceType !== element.type) {
|
|
73
|
+
throw new MigrationToolkitError(
|
|
74
|
+
"invalidElement",
|
|
75
|
+
`Element '${chalk.red(element.codename)}' in content type '${chalk.yellow(
|
|
76
|
+
contentType.contentTypeCodename,
|
|
77
|
+
)}' is of type '${chalk.red(element.type)}', but source type is '${chalk.yellow(sourceType)}'.`,
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return element;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
return getFlattenedElement;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const getLatestLanguageVariantAsync = async (
|
|
88
|
+
logSpinner: LogSpinnerData,
|
|
89
|
+
migrationItem: MigrationItem,
|
|
90
|
+
): Promise<Readonly<LanguageVariantModels.ContentItemLanguageVariant> | undefined> => {
|
|
91
|
+
try {
|
|
92
|
+
const latestLanguageVariant = await runMapiRequestAsync({
|
|
93
|
+
logger: config.logger,
|
|
94
|
+
func: async () =>
|
|
95
|
+
(
|
|
96
|
+
await config.managementClient
|
|
97
|
+
.viewLanguageVariant()
|
|
98
|
+
.byItemCodename(migrationItem.system.codename)
|
|
99
|
+
.byLanguageCodename(migrationItem.system.language.codename)
|
|
100
|
+
.toPromise()
|
|
101
|
+
).data,
|
|
102
|
+
action: "view",
|
|
103
|
+
type: "languageVariant",
|
|
104
|
+
logSpinner: logSpinner,
|
|
105
|
+
itemName: `latest -> codename -> ${migrationItem.system.codename} (${migrationItem.system.language.codename})`,
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
return latestLanguageVariant;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (!is404Error(error)) {
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const getPublishedLanguageVariantAsync = async (
|
|
119
|
+
logSpinner: LogSpinnerData,
|
|
120
|
+
migrationItem: MigrationItem,
|
|
121
|
+
): Promise<Readonly<LanguageVariantModels.ContentItemLanguageVariant> | undefined> => {
|
|
122
|
+
try {
|
|
123
|
+
const draftLanguageVariant = await runMapiRequestAsync({
|
|
124
|
+
logger: config.logger,
|
|
125
|
+
func: async () =>
|
|
126
|
+
(
|
|
127
|
+
await config.managementClient
|
|
128
|
+
.viewLanguageVariant()
|
|
129
|
+
.byItemCodename(migrationItem.system.codename)
|
|
130
|
+
.byLanguageCodename(migrationItem.system.language.codename)
|
|
131
|
+
.published()
|
|
132
|
+
.toPromise()
|
|
133
|
+
).data,
|
|
134
|
+
action: "view",
|
|
135
|
+
type: "languageVariant",
|
|
136
|
+
logSpinner: logSpinner,
|
|
137
|
+
itemName: `published -> codename -> ${migrationItem.system.codename} (${migrationItem.system.language.codename})`,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
return draftLanguageVariant;
|
|
141
|
+
} catch (error) {
|
|
142
|
+
if (!is404Error(error)) {
|
|
143
|
+
throw error;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return undefined;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const getLanguageVariantWrappersAsync = async (
|
|
151
|
+
migrationItems: readonly MigrationItem[],
|
|
152
|
+
): Promise<readonly LanguageVariantWrapper[]> => {
|
|
153
|
+
return (
|
|
154
|
+
await processItemsAsync<MigrationItem, LanguageVariantWrapper>({
|
|
155
|
+
action: "Fetching language variants",
|
|
156
|
+
logger: config.logger,
|
|
157
|
+
parallelLimit: 1,
|
|
158
|
+
items: migrationItems,
|
|
159
|
+
itemInfo: (item) => {
|
|
160
|
+
return {
|
|
161
|
+
itemType: "languageVariant",
|
|
162
|
+
title: `${item.system.codename} (${item.system.language.codename})`,
|
|
163
|
+
};
|
|
164
|
+
},
|
|
165
|
+
processAsync: async (item, logSpinner) => {
|
|
166
|
+
const latestLanguageVariant = await getLatestLanguageVariantAsync(logSpinner, item);
|
|
167
|
+
|
|
168
|
+
if (!latestLanguageVariant) {
|
|
169
|
+
// there is neither published or draft version as latest version does not exist at all
|
|
170
|
+
return "404";
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (workflowHelper.isPublishedStepById(latestLanguageVariant.workflow.stepIdentifier.id ?? "")) {
|
|
174
|
+
// if latest version is published, it means that there is no draft, but there is published version
|
|
175
|
+
return {
|
|
176
|
+
migrationItem: item,
|
|
177
|
+
draftLanguageVariant: undefined,
|
|
178
|
+
publishedLanguageVariant: latestLanguageVariant,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// if latest version is a draft version, check if there is published version as well
|
|
183
|
+
return {
|
|
184
|
+
migrationItem: item,
|
|
185
|
+
draftLanguageVariant: latestLanguageVariant,
|
|
186
|
+
publishedLanguageVariant: await getPublishedLanguageVariantAsync(logSpinner, item),
|
|
187
|
+
};
|
|
188
|
+
},
|
|
189
|
+
})
|
|
190
|
+
)
|
|
191
|
+
.filter((m) => m.state === "valid")
|
|
192
|
+
.map((m) => m.outputItem);
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const getContentItemsByCodenamesAsync = async (
|
|
196
|
+
itemCodenames: ReadonlySet<string>,
|
|
197
|
+
): Promise<readonly ContentItemModels.ContentItem[]> => {
|
|
198
|
+
return (
|
|
199
|
+
await processItemsAsync<string, Readonly<ContentItemModels.ContentItem>>({
|
|
200
|
+
action: "Fetching content items",
|
|
201
|
+
logger: config.logger,
|
|
202
|
+
parallelLimit: 1,
|
|
203
|
+
items: Array.from(itemCodenames),
|
|
204
|
+
itemInfo: (codename) => {
|
|
205
|
+
return {
|
|
206
|
+
itemType: "contentItem",
|
|
207
|
+
title: codename,
|
|
208
|
+
};
|
|
209
|
+
},
|
|
210
|
+
processAsync: async (codename, logSpinner) => {
|
|
211
|
+
try {
|
|
212
|
+
return await runMapiRequestAsync({
|
|
213
|
+
logger: config.logger,
|
|
214
|
+
func: async () => (await config.managementClient.viewContentItem().byItemCodename(codename).toPromise()).data,
|
|
215
|
+
action: "view",
|
|
216
|
+
type: "contentItem",
|
|
217
|
+
logSpinner: logSpinner,
|
|
218
|
+
itemName: `codename -> ${codename}`,
|
|
219
|
+
});
|
|
220
|
+
} catch (error) {
|
|
221
|
+
if (!is404Error(error)) {
|
|
222
|
+
throw error;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return "404";
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
})
|
|
229
|
+
)
|
|
230
|
+
.filter((m) => m.state === "valid")
|
|
231
|
+
.map((m) => m.outputItem);
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
const getAssetsByCodenamesAsync = async (assetCodenames: ReadonlySet<string>): Promise<readonly AssetModels.Asset[]> => {
|
|
235
|
+
return (
|
|
236
|
+
await processItemsAsync<string, Readonly<AssetModels.Asset>>({
|
|
237
|
+
action: "Fetching assets",
|
|
238
|
+
logger: config.logger,
|
|
239
|
+
parallelLimit: 1,
|
|
240
|
+
items: Array.from(assetCodenames),
|
|
241
|
+
itemInfo: (codename) => {
|
|
242
|
+
return {
|
|
243
|
+
itemType: "asset",
|
|
244
|
+
title: codename,
|
|
245
|
+
};
|
|
246
|
+
},
|
|
247
|
+
processAsync: async (codename, logSpinner) => {
|
|
248
|
+
try {
|
|
249
|
+
return await runMapiRequestAsync({
|
|
250
|
+
logger: config.logger,
|
|
251
|
+
func: async () => (await config.managementClient.viewAsset().byAssetCodename(codename).toPromise()).data,
|
|
252
|
+
action: "view",
|
|
253
|
+
type: "asset",
|
|
254
|
+
logSpinner: logSpinner,
|
|
255
|
+
itemName: `codename -> ${codename}`,
|
|
256
|
+
});
|
|
257
|
+
} catch (error) {
|
|
258
|
+
if (!is404Error(error)) {
|
|
259
|
+
throw error;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return "404";
|
|
263
|
+
}
|
|
264
|
+
},
|
|
265
|
+
})
|
|
266
|
+
)
|
|
267
|
+
.filter((m) => m.state === "valid")
|
|
268
|
+
.map((m) => m.outputItem);
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const getVariantState = (languageVariant: Readonly<LanguageVariantModels.ContentItemLanguageVariant>): LanguageVariantStateData => {
|
|
272
|
+
const variantWorkflowId = languageVariant.workflow.workflowIdentifier.id;
|
|
273
|
+
const variantStepId = languageVariant.workflow.stepIdentifier.id;
|
|
274
|
+
const { workflow, step } = workflowHelper.getWorkflowAndStep({
|
|
275
|
+
workflowMatcher: {
|
|
276
|
+
errorMessage: `Could not workflow with id '${chalk.red(variantWorkflowId)}' in target project`,
|
|
277
|
+
match: (workflow) => workflow.id === variantWorkflowId,
|
|
278
|
+
},
|
|
279
|
+
stepMatcher: {
|
|
280
|
+
errorMessage: `Could not workflow step with id '${chalk.red(variantStepId)}' in workflow '${chalk.yellow(
|
|
281
|
+
variantWorkflowId,
|
|
282
|
+
)}'`,
|
|
283
|
+
match: (step) => step.id === variantStepId,
|
|
284
|
+
},
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
return {
|
|
288
|
+
languageVariant: languageVariant,
|
|
289
|
+
workflow: workflow,
|
|
290
|
+
workflowState: getWorkflowState(step, languageVariant),
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
const getVariantStatesAsync = async (
|
|
295
|
+
migrationItems: readonly MigrationItem[],
|
|
296
|
+
): Promise<readonly LanguageVariantStateInTargetEnvironmentByCodename[]> => {
|
|
297
|
+
const variantWrappers = await getLanguageVariantWrappersAsync(migrationItems);
|
|
298
|
+
|
|
299
|
+
return migrationItems.map<LanguageVariantStateInTargetEnvironmentByCodename>((migrationItem) => {
|
|
300
|
+
const variantWrapper = variantWrappers.find(
|
|
301
|
+
(m) =>
|
|
302
|
+
m.migrationItem.system.codename === migrationItem.system.codename &&
|
|
303
|
+
m.migrationItem.system.language === migrationItem.system.language,
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
return {
|
|
307
|
+
itemCodename: migrationItem.system.codename,
|
|
308
|
+
languageCodename: migrationItem.system.language.codename,
|
|
309
|
+
draftLanguageVariant: variantWrapper?.draftLanguageVariant
|
|
310
|
+
? getVariantState(variantWrapper.draftLanguageVariant)
|
|
311
|
+
: undefined,
|
|
312
|
+
publishedLanguageVariant: variantWrapper?.publishedLanguageVariant
|
|
313
|
+
? getVariantState(variantWrapper.publishedLanguageVariant)
|
|
314
|
+
: undefined,
|
|
315
|
+
state: variantWrapper ? "exists" : "doesNotExists",
|
|
316
|
+
};
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
const getWorkflowState = (
|
|
321
|
+
step: Readonly<WorkflowStep>,
|
|
322
|
+
variant: Readonly<LanguageVariantModels.ContentItemLanguageVariant> | undefined,
|
|
323
|
+
): LanguageVariantWorkflowState => {
|
|
324
|
+
if (!variant) {
|
|
325
|
+
return undefined;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const getScheduledState = (): LanguageVariantSchedulesStateValues => {
|
|
329
|
+
return match(variant.schedule)
|
|
330
|
+
.returnType<LanguageVariantSchedulesStateValues>()
|
|
331
|
+
.when(
|
|
332
|
+
(schedule) => schedule.publishTime && schedule.publishDisplayTimezone,
|
|
333
|
+
() => "scheduledPublish",
|
|
334
|
+
)
|
|
335
|
+
.when(
|
|
336
|
+
(schedule) => schedule.unpublishTime && schedule.unpublishDisplayTimezone,
|
|
337
|
+
() => "scheduledUnpublish",
|
|
338
|
+
)
|
|
339
|
+
.otherwise(() => "n/a");
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
const getWorkflowState = (): LanguageVariantWorkflowStateValues => {
|
|
343
|
+
return match(step.codename)
|
|
344
|
+
.returnType<LanguageVariantWorkflowStateValues>()
|
|
345
|
+
.when(
|
|
346
|
+
(stepCodename) => workflowHelper.isPublishedStepByCodename(stepCodename),
|
|
347
|
+
() => "published",
|
|
348
|
+
)
|
|
349
|
+
.when(
|
|
350
|
+
(stepCodename) => workflowHelper.isArchivedStepByCodename(stepCodename),
|
|
351
|
+
() => "archived",
|
|
352
|
+
)
|
|
353
|
+
.otherwise(() => "draft");
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
return {
|
|
357
|
+
workflowState: getWorkflowState(),
|
|
358
|
+
scheduledState: getScheduledState(),
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
const getItemStatesAsync = async (itemCodenames: ReadonlySet<string>): Promise<readonly ItemStateInTargetEnvironmentByCodename[]> => {
|
|
363
|
+
const items = await getContentItemsByCodenamesAsync(itemCodenames);
|
|
364
|
+
|
|
365
|
+
return Array.from(itemCodenames).map<ItemStateInTargetEnvironmentByCodename>((codename) => {
|
|
366
|
+
const item = items.find((m) => m.codename === codename);
|
|
367
|
+
return {
|
|
368
|
+
itemCodename: codename,
|
|
369
|
+
item: item,
|
|
370
|
+
state: item ? "exists" : "doesNotExists",
|
|
371
|
+
externalIdToUse: config.externalIdGenerator.contentItemExternalId(codename),
|
|
372
|
+
};
|
|
373
|
+
});
|
|
374
|
+
};
|
|
375
|
+
|
|
376
|
+
const getAssetStatesAsync = async (
|
|
377
|
+
assetCodenames: ReadonlySet<string>,
|
|
378
|
+
): Promise<readonly AssetStateInTargetEnvironmentByCodename[]> => {
|
|
379
|
+
const assets = await getAssetsByCodenamesAsync(assetCodenames);
|
|
380
|
+
|
|
381
|
+
return Array.from(assetCodenames).map<AssetStateInTargetEnvironmentByCodename>((codename) => {
|
|
382
|
+
const asset = assets.find((m) => m.codename === codename);
|
|
383
|
+
return {
|
|
384
|
+
assetCodename: codename,
|
|
385
|
+
asset: asset,
|
|
386
|
+
state: asset ? "exists" : "doesNotExists",
|
|
387
|
+
externalIdToUse: config.externalIdGenerator.assetExternalId(codename),
|
|
388
|
+
};
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
const getImportContextAsync = async (): Promise<ImportContext> => {
|
|
393
|
+
const getElementByCodenames: GetFlattenedElementByCodenames = getElement();
|
|
394
|
+
|
|
395
|
+
const referencedData = itemsExtractionProcessor().extractReferencedItemsFromMigrationItems(
|
|
396
|
+
config.migrationData.items.reduce<ExtractItemByCodename[]>((items, item) => {
|
|
397
|
+
items.push(
|
|
398
|
+
...item.versions.map((version) => {
|
|
399
|
+
const extractionItem: ExtractItemByCodename = {
|
|
400
|
+
contentTypeCodename: item.system.type.codename,
|
|
401
|
+
elements: version.elements,
|
|
402
|
+
};
|
|
403
|
+
return extractionItem;
|
|
404
|
+
}),
|
|
405
|
+
);
|
|
406
|
+
|
|
407
|
+
return items;
|
|
408
|
+
}, []),
|
|
409
|
+
getElementByCodenames,
|
|
410
|
+
);
|
|
411
|
+
// fetch all items, including referenced items in content
|
|
412
|
+
const itemCodenamesToCheckInTargetEnv: ReadonlySet<string> = new Set<string>([
|
|
413
|
+
...referencedData.itemCodenames,
|
|
414
|
+
...config.migrationData.items.map((m) => m.system.codename),
|
|
415
|
+
]);
|
|
416
|
+
|
|
417
|
+
// fetch all assets, including referenced assets in content
|
|
418
|
+
const assetCodenamesToCheckInTargetEnv: ReadonlySet<string> = new Set<string>([
|
|
419
|
+
...referencedData.assetCodenames,
|
|
420
|
+
...config.migrationData.assets.map((m) => m.codename),
|
|
421
|
+
]);
|
|
422
|
+
|
|
423
|
+
// prepare state of objects in target environment
|
|
424
|
+
const itemStates: readonly ItemStateInTargetEnvironmentByCodename[] = await getItemStatesAsync(itemCodenamesToCheckInTargetEnv);
|
|
425
|
+
|
|
426
|
+
const variantStates: readonly LanguageVariantStateInTargetEnvironmentByCodename[] = await getVariantStatesAsync(
|
|
427
|
+
config.migrationData.items,
|
|
428
|
+
);
|
|
429
|
+
|
|
430
|
+
const assetStates: readonly AssetStateInTargetEnvironmentByCodename[] = await getAssetStatesAsync(assetCodenamesToCheckInTargetEnv);
|
|
431
|
+
|
|
432
|
+
return {
|
|
433
|
+
environmentData,
|
|
434
|
+
referencedData,
|
|
435
|
+
categorizedImportData: {
|
|
436
|
+
assets: config.migrationData.assets,
|
|
437
|
+
contentItems: config.migrationData.items,
|
|
438
|
+
},
|
|
439
|
+
getItemStateInTargetEnvironment: (itemCodename) => {
|
|
440
|
+
return findRequired(
|
|
441
|
+
itemStates,
|
|
442
|
+
(state) => state.itemCodename === itemCodename,
|
|
443
|
+
`Invalid state for item '${chalk.red(itemCodename)}'. It is expected that all item states will be initialized`,
|
|
444
|
+
);
|
|
445
|
+
},
|
|
446
|
+
getLanguageVariantStateInTargetEnvironment: (itemCodename, languageCodename) => {
|
|
447
|
+
return findRequired(
|
|
448
|
+
variantStates,
|
|
449
|
+
(state) => state.itemCodename === itemCodename && state.languageCodename === languageCodename,
|
|
450
|
+
`Invalid state for language variant '${chalk.red(itemCodename)}' in language '${chalk.red(
|
|
451
|
+
languageCodename,
|
|
452
|
+
)}'. It is expected that all variant states will be initialized`,
|
|
453
|
+
);
|
|
454
|
+
},
|
|
455
|
+
getAssetStateInTargetEnvironment: (assetCodename) => {
|
|
456
|
+
return findRequired(
|
|
457
|
+
assetStates,
|
|
458
|
+
(state) => state.assetCodename === assetCodename,
|
|
459
|
+
`Invalid state for asset '${chalk.red(assetCodename)}'. It is expected that all asset states will be initialized`,
|
|
460
|
+
);
|
|
461
|
+
},
|
|
462
|
+
getElement: getElementByCodenames,
|
|
463
|
+
};
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
return {
|
|
467
|
+
getImportContextAsync,
|
|
468
|
+
};
|
|
469
469
|
}
|