@kontent-ai/migration-toolkit 1.3.0 → 1.5.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 +79 -67
- package/dist/es2022/core/helpers/workflow-helper.d.ts +1 -0
- package/dist/es2022/core/helpers/workflow-helper.js +6 -4
- package/dist/es2022/core/helpers/workflow-helper.js.map +1 -1
- package/dist/es2022/core/logs/loggers.js +13 -22
- package/dist/es2022/core/logs/loggers.js.map +1 -1
- package/dist/es2022/core/models/core.models.d.ts +16 -6
- package/dist/es2022/core/models/migration.models.d.ts +9 -9
- package/dist/es2022/core/models/migration.schema.d.ts +247 -0
- package/dist/es2022/core/models/migration.schema.js +12 -2
- package/dist/es2022/core/models/migration.schema.js.map +1 -1
- package/dist/es2022/core/utils/array.utils.js.map +1 -1
- package/dist/es2022/core/utils/binary-data.utils.js +2 -6
- package/dist/es2022/core/utils/binary-data.utils.js.map +1 -1
- package/dist/es2022/core/utils/confirm.utils.js +10 -14
- package/dist/es2022/core/utils/confirm.utils.js.map +1 -1
- package/dist/es2022/core/utils/error.utils.js +35 -27
- package/dist/es2022/core/utils/error.utils.js.map +1 -1
- package/dist/es2022/core/utils/http.utils.js +7 -11
- package/dist/es2022/core/utils/http.utils.js.map +1 -1
- package/dist/es2022/core/utils/management-client-utils.d.ts +2 -1
- package/dist/es2022/core/utils/management-client-utils.js +12 -2
- package/dist/es2022/core/utils/management-client-utils.js.map +1 -1
- package/dist/es2022/core/utils/run.utils.js +12 -10
- package/dist/es2022/core/utils/run.utils.js.map +1 -1
- package/dist/es2022/export/context/export-context-fetcher.js +2 -1
- package/dist/es2022/export/context/export-context-fetcher.js.map +1 -1
- package/dist/es2022/export/export-manager.js +8 -0
- package/dist/es2022/export/export-manager.js.map +1 -1
- package/dist/es2022/export/export.models.d.ts +2 -1
- package/dist/es2022/import/comparers/asset-comparer.d.ts +2 -1
- package/dist/es2022/import/comparers/asset-comparer.js +9 -17
- package/dist/es2022/import/comparers/asset-comparer.js.map +1 -1
- package/dist/es2022/import/context/import-context-fetcher.js +120 -40
- package/dist/es2022/import/context/import-context-fetcher.js.map +1 -1
- package/dist/es2022/import/import.models.d.ts +2 -1
- package/dist/es2022/import/importers/assets-importer.js +12 -2
- package/dist/es2022/import/importers/assets-importer.js.map +1 -1
- package/dist/es2022/import/importers/language-variant-importer.js +95 -83
- package/dist/es2022/import/importers/language-variant-importer.js.map +1 -1
- package/dist/es2022/import/importers/workflow-importer.d.ts +41 -4
- package/dist/es2022/import/importers/workflow-importer.js +158 -17
- package/dist/es2022/import/importers/workflow-importer.js.map +1 -1
- package/dist/es2022/metadata.js +2 -2
- package/dist/es2022/node/cli/app.js +8 -12
- package/dist/es2022/node/cli/app.js.map +1 -1
- package/dist/es2022/node/cli/args/args-fetcher.js +9 -10
- package/dist/es2022/node/cli/args/args-fetcher.js.map +1 -1
- package/dist/es2022/toolkit/migrate.d.ts +1 -3
- package/dist/es2022/toolkit/migrate.js.map +1 -1
- package/dist/es2022/translation/extraction/items-extraction.processor.js +17 -17
- package/dist/es2022/translation/extraction/items-extraction.processor.js.map +1 -1
- package/dist/es2022/translation/transforms/export-transforms.js +1 -1
- package/dist/es2022/translation/transforms/export-transforms.js.map +1 -1
- package/dist/es2022/zip/zip-packager.js +13 -18
- package/dist/es2022/zip/zip-packager.js.map +1 -1
- package/dist/es2022/zip/zip-transformer.js +3 -1
- package/dist/es2022/zip/zip-transformer.js.map +1 -1
- package/lib/core/helpers/workflow-helper.ts +8 -8
- package/lib/core/logs/loggers.ts +14 -22
- package/lib/core/models/core.models.ts +23 -4
- package/lib/core/models/migration.models.ts +13 -12
- package/lib/core/models/migration.schema.ts +189 -178
- package/lib/core/utils/array.utils.ts +2 -10
- package/lib/core/utils/binary-data.utils.ts +2 -7
- package/lib/core/utils/confirm.utils.ts +18 -24
- package/lib/core/utils/error.utils.ts +50 -30
- package/lib/core/utils/http.utils.ts +14 -15
- package/lib/core/utils/management-client-utils.ts +188 -182
- package/lib/core/utils/run.utils.ts +27 -18
- package/lib/export/context/export-context-fetcher.ts +2 -1
- package/lib/export/export-manager.ts +14 -3
- package/lib/export/export.models.ts +3 -1
- package/lib/import/comparers/asset-comparer.ts +16 -24
- package/lib/import/context/import-context-fetcher.ts +179 -85
- package/lib/import/import.models.ts +2 -0
- package/lib/import/importers/assets-importer.ts +19 -12
- package/lib/import/importers/language-variant-importer.ts +125 -129
- package/lib/import/importers/workflow-importer.ts +228 -20
- package/lib/metadata.ts +2 -2
- package/lib/node/cli/app.ts +11 -12
- package/lib/node/cli/args/args-fetcher.ts +12 -14
- package/lib/toolkit/migrate.ts +1 -3
- package/lib/translation/extraction/items-extraction.processor.ts +93 -93
- package/lib/translation/transforms/export-transforms.ts +1 -1
- package/lib/zip/zip-packager.ts +26 -28
- package/lib/zip/zip-transformer.ts +3 -1
- package/package.json +14 -13
package/README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
# Kontent.ai Migration Toolkit
|
|
2
2
|
|
|
3
|
-
The purpose of this tool is to facilitate _content migration_ to & from [Kontent.ai](https://kontent.ai) environments.
|
|
4
|
-
|
|
5
|
-
environments.
|
|
3
|
+
The purpose of this tool is to facilitate _content migration_ to & from [Kontent.ai](https://kontent.ai) environments. It can be used to
|
|
4
|
+
simplify migration from external systems and also provides a built-in migration between kontent.ai environments.
|
|
6
5
|
|
|
7
6
|
> [!TIP]
|
|
8
|
-
> This library aims to streamline the migration to / from Kontent.ai environments by providing an abstraction layer
|
|
9
|
-
>
|
|
10
|
-
>
|
|
7
|
+
> This library aims to streamline the migration to / from Kontent.ai environments by providing an abstraction layer which handles creation /
|
|
8
|
+
> updates of content items, language variants, moving items through workflow, publishing, archiving, downloading binary data, uploading
|
|
9
|
+
> assets, `id` to `codename` translation and more.
|
|
11
10
|
|
|
12
11
|
This library can only be used as a library both in `node.js` & `browser` or as a `CLI` utility.
|
|
13
12
|
|
|
@@ -36,8 +35,7 @@ kontent-ai-migration-toolkit migrate --help
|
|
|
36
35
|
4. [Migrate content between Kontent.ai environments](https://github.com/Kontent-ai/kontent-ai-migration-toolkit/blob/main/samples/migrate-between-kontent-ai-environments.ts)
|
|
37
36
|
|
|
38
37
|
> [!NOTE]
|
|
39
|
-
> You can run `kontent-ai-migration-toolkit` many times over without being worried that duplicate content items / assets
|
|
40
|
-
> are created.
|
|
38
|
+
> You can run `kontent-ai-migration-toolkit` many times over without being worried that duplicate content items / assets are created.
|
|
41
39
|
|
|
42
40
|
# Migrate between Kontent.ai environments
|
|
43
41
|
|
|
@@ -69,14 +67,13 @@ kontent-ai-migration-toolkit migrate --targetEnvironmentId=x --targetApiKey=x --
|
|
|
69
67
|
# Import
|
|
70
68
|
|
|
71
69
|
> [!CAUTION]
|
|
72
|
-
> **We do not recommended importing into a production environment directly without testing**. Instead you should first
|
|
73
|
-
>
|
|
70
|
+
> **We do not recommended importing into a production environment directly without testing**. Instead you should first create a testing
|
|
71
|
+
> environment and run the script there to make sure everything works as you intended to.
|
|
74
72
|
|
|
75
73
|
> [!NOTE]
|
|
76
|
-
> When importing it is essential that the target project structure (i.e. `Content types`, `Taxonomies`, `Collections`,
|
|
77
|
-
> `
|
|
78
|
-
>
|
|
79
|
-
> fail.
|
|
74
|
+
> When importing it is essential that the target project structure (i.e. `Content types`, `Taxonomies`, `Collections`, `Workflows`,
|
|
75
|
+
> `languages`...) are consistent with the ones defined in source environment. Any inconsistency in data such as referencing inexistent
|
|
76
|
+
> taxonomy term, incorrect element type and other inconsistencies may cause import to fail.
|
|
80
77
|
|
|
81
78
|
## Configuration
|
|
82
79
|
|
|
@@ -97,8 +94,8 @@ kontent-ai-migration-toolkit import --targetEnvironmentId=x --targetApiKey=x --f
|
|
|
97
94
|
|
|
98
95
|
# Migrate from Kontent.ai
|
|
99
96
|
|
|
100
|
-
This library can also be used to export content items & assets from Kontent.ai environments. However, when migration
|
|
101
|
-
|
|
97
|
+
This library can also be used to export content items & assets from Kontent.ai environments. However, when migration from 3rd party system
|
|
98
|
+
you typically only use the `import` capabilities of this repository.
|
|
102
99
|
|
|
103
100
|
## Configuration
|
|
104
101
|
|
|
@@ -120,27 +117,38 @@ kontent-ai-migration-toolkit export --sourceEnvironmentId=x --sourceApiKey=x --l
|
|
|
120
117
|
|
|
121
118
|
# Migrate from external systems
|
|
122
119
|
|
|
123
|
-
You can use this library when exporting from 3rd party systems (i.e. legacy CMS) as it will abstract your from using
|
|
124
|
-
|
|
120
|
+
You can use this library when exporting from 3rd party systems (i.e. legacy CMS) as it will abstract your from using Kontent.ai Management
|
|
121
|
+
API directly.
|
|
125
122
|
|
|
126
|
-
The main focus is therefore on transforming the data you need to migrate into a format this library supports. The main
|
|
127
|
-
|
|
123
|
+
The main focus is therefore on transforming the data you need to migrate into a format this library supports. The main migration models are
|
|
124
|
+
`MigrationItem` and `MigrationAsset`. For creating element values `elementsBuilder`.
|
|
128
125
|
|
|
129
126
|
See below example of using a strongly typed model and migrating a single item with an asset.
|
|
130
127
|
|
|
131
128
|
```typescript
|
|
132
129
|
/**
|
|
133
|
-
* Optionally (but
|
|
134
|
-
* representing the
|
|
130
|
+
* Optionally (but highly recommended) you may define a migration model
|
|
131
|
+
* representing the environment you are trying to migrate into.
|
|
135
132
|
*/
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
133
|
+
type LanguageCodenames = 'default' | 'en';
|
|
134
|
+
type CollectionCodenames = 'default' | 'global';
|
|
135
|
+
type WorkflowCodenames = 'default' | 'custom';
|
|
136
|
+
type ContentTypeCodenames = 'article' | 'author';
|
|
137
|
+
type WorkflowStepCodenames = 'published' | 'archived' | 'draft';
|
|
138
|
+
type ContentTypeCodename<Codename extends ContentTypeCodenames> = Codename;
|
|
139
|
+
|
|
140
|
+
type ArticleItem = MigrationItem<
|
|
141
|
+
{
|
|
142
|
+
title: MigrationElementModels.TextElement;
|
|
143
|
+
rating: MigrationElementModels.NumberElement;
|
|
144
|
+
related_pages: MigrationElementModels.LinkedItemsElement;
|
|
145
|
+
teaser_image: MigrationElementModels.AssetElement;
|
|
146
|
+
},
|
|
147
|
+
MigrationItemSystem<ContentTypeCodename<'article'>, LanguageCodenames, CollectionCodenames, WorkflowCodenames>,
|
|
148
|
+
WorkflowStepCodenames
|
|
149
|
+
>;
|
|
150
|
+
|
|
151
|
+
const migrationItem: ArticleItem = {
|
|
144
152
|
system: {
|
|
145
153
|
name: 'My article',
|
|
146
154
|
// codename is primary identifier - also used for validating whether asset exists in target env
|
|
@@ -151,29 +159,39 @@ const migrationItem: MigrationItem<ArticleElements> = {
|
|
|
151
159
|
},
|
|
152
160
|
language: {
|
|
153
161
|
// language codename must match the language in your target K.ai environment
|
|
154
|
-
codename: '
|
|
162
|
+
codename: 'en'
|
|
155
163
|
},
|
|
156
164
|
type: {
|
|
157
165
|
// type codename must match the content type codename in your target K.ai environment
|
|
158
166
|
codename: 'article'
|
|
167
|
+
},
|
|
168
|
+
workflow: {
|
|
169
|
+
codename: 'default'
|
|
159
170
|
}
|
|
160
171
|
},
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
172
|
+
versions: [
|
|
173
|
+
{
|
|
174
|
+
workflow_step: {
|
|
175
|
+
codename: 'published'
|
|
176
|
+
},
|
|
177
|
+
elements: {
|
|
178
|
+
title: elementsBuilder.textElement({ value: 'Title of the article' }),
|
|
179
|
+
rating: elementsBuilder.numberElement({ value: 5 }),
|
|
180
|
+
related_pages: elementsBuilder.linkedItemsElement({
|
|
181
|
+
value: [
|
|
182
|
+
{
|
|
183
|
+
codename: 'pageA'
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
codename: 'pageB'
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
}),
|
|
190
|
+
// assets are referenced by their codename
|
|
191
|
+
teaser_image: elementsBuilder.assetElement({ value: [{ codename: 'article_teaser' }] })
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
]
|
|
177
195
|
};
|
|
178
196
|
|
|
179
197
|
const migrationAsset: MigrationAsset = {
|
|
@@ -218,21 +236,20 @@ await importAsync({
|
|
|
218
236
|
|
|
219
237
|
### How are content items imported?
|
|
220
238
|
|
|
221
|
-
The Migration Toolkit creates content items that are not present in target project. If the content item exists in target
|
|
222
|
-
|
|
223
|
-
|
|
239
|
+
The Migration Toolkit creates content items that are not present in target project. If the content item exists in target project (based on
|
|
240
|
+
item's `codename`) the item will be updated, otherwise it will be created. No duplicate items will be created. The workflow of the item in
|
|
241
|
+
target environment will be set to match the source environment.
|
|
224
242
|
|
|
225
243
|
### How are assets imported?
|
|
226
244
|
|
|
227
|
-
If asset exists in target project (based on asset's `codename`), the asset upload will be skipped and not uploaded at
|
|
228
|
-
|
|
245
|
+
If asset exists in target project (based on asset's `codename`), the asset upload will be skipped and not uploaded at all. Otherwise the
|
|
246
|
+
asset will be created in target environment.
|
|
229
247
|
|
|
230
248
|
### How are referenced content items & asset handled?
|
|
231
249
|
|
|
232
|
-
If you have a reference to a content item or asset (i.e. in linked items element, asset element, rich text element...)
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
creates a placeholder for the item until it becomes available.
|
|
250
|
+
If you have a reference to a content item or asset (i.e. in linked items element, asset element, rich text element...) the migration toolkit
|
|
251
|
+
first checks whether the referenced object exists (based on item or asset `codename`) and if it does, successfuly sets the reference. If the
|
|
252
|
+
object does not exist, it will be referenced by an `external_id` which creates a placeholder for the item until it becomes available.
|
|
236
253
|
|
|
237
254
|
See the table below to learn how `external_id` is generated by default:
|
|
238
255
|
|
|
@@ -241,25 +258,20 @@ See the table below to learn how `external_id` is generated by default:
|
|
|
241
258
|
| **Asset** | `asset_{codename}` | my_file | `asset_my_file` |
|
|
242
259
|
| **Content item** | `item_{codename}` | article | `item_article` |
|
|
243
260
|
|
|
244
|
-
If you need to change the way `external_id` is created, you may supply a custom implementation of `externalIdGenerator`
|
|
245
|
-
|
|
261
|
+
If you need to change the way `external_id` is created, you may supply a custom implementation of `externalIdGenerator` within import /
|
|
262
|
+
migrate functions.
|
|
246
263
|
|
|
247
264
|
## Limitations
|
|
248
265
|
|
|
249
|
-
1.
|
|
250
|
-
codenames.
|
|
251
|
-
2. Assets element values are not preserved during migration because elements can be referenced only by id's and not
|
|
252
|
-
codenames.
|
|
253
|
-
3. Language variants in `Scheduled` workflow step do not preserve their workflow status because the API does not provide
|
|
254
|
-
an information about scheduled times
|
|
266
|
+
1. Custom asset elements are not supported (= values of these elements are not exported or imported )
|
|
255
267
|
|
|
256
268
|
## FAQ
|
|
257
269
|
|
|
258
270
|
### I'm getting `Header overflow` exception
|
|
259
271
|
|
|
260
|
-
The Node.js limits the maximum header size of HTTP requests. In some cases it may be required for you to increase this
|
|
261
|
-
|
|
262
|
-
|
|
272
|
+
The Node.js limits the maximum header size of HTTP requests. In some cases it may be required for you to increase this limitation to be able
|
|
273
|
+
to successfully fetch data from Kontent.ai. You can do so by using the `max-http-header-size` option
|
|
274
|
+
(https://nodejs.org/api/cli.html#--max-http-header-sizesize)
|
|
263
275
|
|
|
264
276
|
Example script call:
|
|
265
277
|
|
|
@@ -33,5 +33,6 @@ export declare function workflowHelper(workflows: readonly Readonly<WorkflowMode
|
|
|
33
33
|
isPublishedStepByCodename: (stepCodename: string) => boolean;
|
|
34
34
|
isArchivedStepByCodename: (stepCodename: string) => boolean;
|
|
35
35
|
isScheduledStepByCodename: (stepCodename: string) => boolean;
|
|
36
|
+
isPublishedStepById: (stepId: string) => boolean;
|
|
36
37
|
};
|
|
37
38
|
export {};
|
|
@@ -11,9 +11,7 @@ export function workflowHelper(workflows) {
|
|
|
11
11
|
return getWorkflow({
|
|
12
12
|
errorMessage: [
|
|
13
13
|
`Workflow with codename '${chalk.red(workflowCodename)}' does not exist in target project`,
|
|
14
|
-
`Available workflows are (${workflows.length}): ${workflows
|
|
15
|
-
.map((m) => chalk.cyan(m.codename))
|
|
16
|
-
.join(', ')}`
|
|
14
|
+
`Available workflows are (${workflows.length}): ${workflows.map((m) => chalk.cyan(m.codename)).join(', ')}`
|
|
17
15
|
].join(', '),
|
|
18
16
|
match: (workflow) => workflow.codename.toLowerCase() === workflowCodename.toLowerCase()
|
|
19
17
|
});
|
|
@@ -52,6 +50,9 @@ export function workflowHelper(workflows) {
|
|
|
52
50
|
const isScheduledStepByCodename = (stepCodename) => {
|
|
53
51
|
return workflows.find((workflow) => workflow.scheduledStep.codename === stepCodename) ? true : false;
|
|
54
52
|
};
|
|
53
|
+
const isPublishedStepById = (stepId) => {
|
|
54
|
+
return workflows.find((workflow) => workflow.publishedStep.id === stepId) ? true : false;
|
|
55
|
+
};
|
|
55
56
|
return {
|
|
56
57
|
getWorkflowByCodename,
|
|
57
58
|
getWorkflowStepByCodename,
|
|
@@ -61,7 +62,8 @@ export function workflowHelper(workflows) {
|
|
|
61
62
|
getWorkflow,
|
|
62
63
|
isPublishedStepByCodename,
|
|
63
64
|
isArchivedStepByCodename,
|
|
64
|
-
isScheduledStepByCodename
|
|
65
|
+
isScheduledStepByCodename,
|
|
66
|
+
isPublishedStepById
|
|
65
67
|
};
|
|
66
68
|
}
|
|
67
69
|
//# sourceMappingURL=workflow-helper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workflow-helper.js","sourceRoot":"","sources":["../../../../lib/core/helpers/workflow-helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAgBvD,MAAM,UAAU,cAAc,CAAC,SAAuD;IAClF,MAAM,eAAe,GAAG,CAAC,QAA2C,EAAE,WAAwB,EAAgB,EAAE;QAC5G,OAAO,YAAY,CACf,CAAC,GAAG,QAAQ,CA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,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAC7F,CAAC,CAAC;IAEF,OAAO;QACH,qBAAqB;QACrB,yBAAyB;QACzB,6BAA6B;QAC7B,eAAe;QACf,kBAAkB;QAClB,WAAW;QACX,yBAAyB;QACzB,wBAAwB;QACxB,yBAAyB;QACzB,mBAAmB;KACtB,CAAC;AACN,CAAC"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { getCurrentEnvironment } from '../utils/global.utils.js';
|
|
3
|
+
import { match, P } from 'ts-pattern';
|
|
3
4
|
const originalWarn = console.warn;
|
|
4
5
|
export function getDefaultLogger() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (currentEnv === 'browser') {
|
|
10
|
-
return defaultBrowserLogger;
|
|
11
|
-
}
|
|
12
|
-
throw Error(`Invalid environment`);
|
|
6
|
+
return match(getCurrentEnvironment())
|
|
7
|
+
.with('node', () => defaultNodeLogger)
|
|
8
|
+
.with('browser', () => defaultBrowserLogger)
|
|
9
|
+
.exhaustive();
|
|
13
10
|
}
|
|
14
11
|
const defaultNodeLogger = {
|
|
15
12
|
log: (data) => console.log(getLogDataMessage(data)),
|
|
@@ -48,19 +45,13 @@ const defaultBrowserLogger = {
|
|
|
48
45
|
}
|
|
49
46
|
};
|
|
50
47
|
function getLogDataMessage(data) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
typeColor = chalk.green;
|
|
60
|
-
}
|
|
61
|
-
else if (data.type === 'skip') {
|
|
62
|
-
typeColor = chalk.gray;
|
|
63
|
-
}
|
|
64
|
-
return `${typeColor(data.type)}: ${data.message}`;
|
|
48
|
+
const color = match(data.type)
|
|
49
|
+
.returnType()
|
|
50
|
+
.with('info', () => chalk.cyan)
|
|
51
|
+
.with(P.union('error', 'errorData', 'warning', 'cancel'), () => chalk.red)
|
|
52
|
+
.with('completed', () => chalk.green)
|
|
53
|
+
.with('skip', () => chalk.gray)
|
|
54
|
+
.otherwise(() => chalk.yellow);
|
|
55
|
+
return `${color(data.type)}: ${data.message}`;
|
|
65
56
|
}
|
|
66
57
|
//# sourceMappingURL=loggers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loggers.js","sourceRoot":"","sources":["../../../../lib/core/logs/loggers.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"loggers.js","sourceRoot":"","sources":["../../../../lib/core/logs/loggers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;AAElC,MAAM,UAAU,gBAAgB;IAC5B,OAAO,KAAK,CAAC,qBAAqB,EAAE,CAAC;SAChC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,iBAAiB,CAAC;SACrC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC;SAC3C,UAAU,EAAE,CAAC;AACtB,CAAC;AAED,MAAM,iBAAiB,GAAW;IAC9B,GAAG,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACnD,mBAAmB,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;QAChC,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,CAAC;QAEhC,OAAO,MAAM,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YAC1C,0DAA0D;YAC1D,uDAAuD;YAC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G,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;SACzB,UAAU,EAAiB;SAC3B,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;SAC9B,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;SACzE,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC;SACpC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;SAC9B,SAAS,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAEnC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;AAClD,CAAC"}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { AssetModels, ContentItemModels, ContentTypeElements, LanguageVariantModels, WorkflowModels } from '@kontent-ai/management-sdk';
|
|
2
2
|
import { MigrationElementType } from './migration.models.js';
|
|
3
|
-
|
|
3
|
+
export type LiteralUnion<T extends string> = T | (string & {});
|
|
4
4
|
export type TargetItemState = 'exists' | 'doesNotExists';
|
|
5
5
|
export type CliAction = 'export' | 'import' | 'migrate';
|
|
6
6
|
export type EnvContext = 'browser' | 'node';
|
|
7
|
-
export type MapiAction = 'list' | 'view' | 'archive' | 'unpublish' | 'changeWorkflowStep' | 'publish' | 'upload' | 'create' | 'upsert' | 'createNewVersion';
|
|
7
|
+
export type MapiAction = 'list' | 'view' | 'archive' | 'unpublish' | 'changeWorkflowStep' | 'publish' | 'upload' | 'create' | 'upsert' | 'schedulePublish' | 'scheduleUnpublish' | 'cancelScheduledPublish' | 'cancelScheduledUnpublish' | 'createNewVersion';
|
|
8
8
|
export type MigrationItemType = 'exportItem';
|
|
9
|
-
export type MapiType = 'contentType' | 'asset' | 'contentTypeSnippet' | 'contentItem' | 'languageVariant' | 'language' | 'collection' | 'taxonomy' | 'binaryFile' | 'workflow';
|
|
9
|
+
export type MapiType = 'contentType' | 'assetFolder' | 'asset' | 'contentTypeSnippet' | 'contentItem' | 'languageVariant' | 'language' | 'collection' | 'taxonomy' | 'binaryFile' | 'workflow';
|
|
10
|
+
export type LanguageVariantWorkflowStateValues = 'published' | 'archived' | 'draft' | 'scheduled';
|
|
11
|
+
export type LanguageVariantSchedulesStateValues = 'scheduledPublish' | 'scheduledUnpublish' | 'n/a';
|
|
12
|
+
export type LanguageVariantWorkflowState = {
|
|
13
|
+
readonly workflowState: LanguageVariantWorkflowStateValues;
|
|
14
|
+
readonly scheduledState: LanguageVariantSchedulesStateValues;
|
|
15
|
+
} | undefined;
|
|
10
16
|
export interface ItemInfo {
|
|
11
17
|
readonly title: string;
|
|
12
18
|
readonly itemType: MapiType | MigrationItemType;
|
|
@@ -42,13 +48,17 @@ export interface ItemStateInTargetEnvironmentByCodename {
|
|
|
42
48
|
readonly item: Readonly<ContentItemModels.ContentItem> | undefined;
|
|
43
49
|
readonly externalIdToUse: string;
|
|
44
50
|
}
|
|
51
|
+
export interface LanguageVariantStateData {
|
|
52
|
+
readonly languageVariant: Readonly<LanguageVariantModels.ContentItemLanguageVariant> | undefined;
|
|
53
|
+
readonly workflow: Readonly<WorkflowModels.Workflow> | undefined;
|
|
54
|
+
readonly workflowState: LanguageVariantWorkflowState;
|
|
55
|
+
}
|
|
45
56
|
export interface LanguageVariantStateInTargetEnvironmentByCodename {
|
|
46
57
|
readonly state: TargetItemState;
|
|
47
58
|
readonly itemCodename: string;
|
|
48
59
|
readonly languageCodename: string;
|
|
49
|
-
readonly
|
|
50
|
-
readonly
|
|
51
|
-
readonly step: Readonly<WorkflowStep> | undefined;
|
|
60
|
+
readonly publishedLanguageVariant: LanguageVariantStateData | undefined;
|
|
61
|
+
readonly draftLanguageVariant: LanguageVariantStateData | undefined;
|
|
52
62
|
}
|
|
53
63
|
export interface AssetStateInTargetEnvironmentByCodename {
|
|
54
64
|
readonly state: TargetItemState;
|
|
@@ -21,13 +21,13 @@ export declare namespace MigrationElementModels {
|
|
|
21
21
|
export type MigrationReference<T extends string = string> = z.infer<typeof MigrationReferenceSchema> & {
|
|
22
22
|
readonly codename: T;
|
|
23
23
|
};
|
|
24
|
-
export type MigrationItemSystem<
|
|
24
|
+
export type MigrationItemSystem<TTypeCodenames extends string = string, TLanguageCodenames extends string = string, TCollectionCodenames extends string = string, TWorkflowCodenames extends string = string> = z.infer<typeof MigrationItemSystemSchema> & {
|
|
25
25
|
readonly codename: string;
|
|
26
26
|
readonly name: string;
|
|
27
|
-
readonly language: MigrationReference<
|
|
28
|
-
readonly type: MigrationReference<
|
|
29
|
-
readonly collection: MigrationReference<
|
|
30
|
-
readonly workflow: MigrationReference<
|
|
27
|
+
readonly language: MigrationReference<TLanguageCodenames>;
|
|
28
|
+
readonly type: MigrationReference<TTypeCodenames>;
|
|
29
|
+
readonly collection: MigrationReference<TCollectionCodenames>;
|
|
30
|
+
readonly workflow: MigrationReference<TWorkflowCodenames>;
|
|
31
31
|
};
|
|
32
32
|
export type MigrationUrlSlugMode = z.infer<typeof MigrationUrlSlugModeSchema>;
|
|
33
33
|
export type MigrationElementType = z.infer<typeof MigrationElementTypeSchema>;
|
|
@@ -40,11 +40,11 @@ export type MigrationElements = z.infer<typeof MigrationElementsSchema>;
|
|
|
40
40
|
export type MigrationAssetDescription = z.infer<typeof MigrationAssetDescriptionSchema>;
|
|
41
41
|
export type MigrationAsset = z.infer<typeof MigrationAssetSchema>;
|
|
42
42
|
export type MigrationData = z.infer<typeof MigrationDataSchema>;
|
|
43
|
-
export type MigrationItemVersion<TElements extends MigrationElements = MigrationElements,
|
|
43
|
+
export type MigrationItemVersion<TElements extends MigrationElements = MigrationElements, TWorkflowStepCodenames extends string = string> = z.infer<typeof MigrationItemVersionSchema> & {
|
|
44
44
|
readonly elements: Readonly<TElements>;
|
|
45
|
-
readonly workflow_step: MigrationReference<
|
|
45
|
+
readonly workflow_step: MigrationReference<TWorkflowStepCodenames>;
|
|
46
46
|
};
|
|
47
|
-
export type MigrationItem<TElements extends MigrationElements = MigrationElements, TSystem extends MigrationItemSystem = MigrationItemSystem,
|
|
48
|
-
readonly versions: Readonly<MigrationItemVersion<TElements,
|
|
47
|
+
export type MigrationItem<TElements extends MigrationElements = MigrationElements, TSystem extends MigrationItemSystem = MigrationItemSystem, TWorkflowStepCodenames extends string = string> = z.infer<typeof MigrationItemSchema> & {
|
|
48
|
+
readonly versions: Readonly<MigrationItemVersion<TElements, TWorkflowStepCodenames>[]>;
|
|
49
49
|
readonly system: TSystem;
|
|
50
50
|
};
|