@kontent-ai/migration-toolkit 1.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.
Files changed (240) hide show
  1. package/.npmignore +13 -0
  2. package/LICENSE.md +9 -0
  3. package/README.md +272 -0
  4. package/dist/es2022/core/helpers/workflow-helper.d.ts +37 -0
  5. package/dist/es2022/core/helpers/workflow-helper.js +67 -0
  6. package/dist/es2022/core/helpers/workflow-helper.js.map +1 -0
  7. package/dist/es2022/core/index.d.ts +15 -0
  8. package/dist/es2022/core/index.js +16 -0
  9. package/dist/es2022/core/index.js.map +1 -0
  10. package/dist/es2022/core/logs/loggers.d.ts +2 -0
  11. package/dist/es2022/core/logs/loggers.js +69 -0
  12. package/dist/es2022/core/logs/loggers.js.map +1 -0
  13. package/dist/es2022/core/models/core.models.d.ts +91 -0
  14. package/dist/es2022/core/models/core.models.js +2 -0
  15. package/dist/es2022/core/models/core.models.js.map +1 -0
  16. package/dist/es2022/core/models/log.models.d.ts +15 -0
  17. package/dist/es2022/core/models/log.models.js +2 -0
  18. package/dist/es2022/core/models/log.models.js.map +1 -0
  19. package/dist/es2022/core/models/migration.models.d.ts +136 -0
  20. package/dist/es2022/core/models/migration.models.js +2 -0
  21. package/dist/es2022/core/models/migration.models.js.map +1 -0
  22. package/dist/es2022/core/utils/array.utils.d.ts +5 -0
  23. package/dist/es2022/core/utils/array.utils.js +27 -0
  24. package/dist/es2022/core/utils/array.utils.js.map +1 -0
  25. package/dist/es2022/core/utils/binary-data.utils.d.ts +5 -0
  26. package/dist/es2022/core/utils/binary-data.utils.js +21 -0
  27. package/dist/es2022/core/utils/binary-data.utils.js.map +1 -0
  28. package/dist/es2022/core/utils/confirm.utils.d.ts +31 -0
  29. package/dist/es2022/core/utils/confirm.utils.js +73 -0
  30. package/dist/es2022/core/utils/confirm.utils.js.map +1 -0
  31. package/dist/es2022/core/utils/error.utils.d.ts +4 -0
  32. package/dist/es2022/core/utils/error.utils.js +50 -0
  33. package/dist/es2022/core/utils/error.utils.js.map +1 -0
  34. package/dist/es2022/core/utils/external-id.utils.d.ts +5 -0
  35. package/dist/es2022/core/utils/external-id.utils.js +5 -0
  36. package/dist/es2022/core/utils/external-id.utils.js.map +1 -0
  37. package/dist/es2022/core/utils/global.utils.d.ts +14 -0
  38. package/dist/es2022/core/utils/global.utils.js +45 -0
  39. package/dist/es2022/core/utils/global.utils.js.map +1 -0
  40. package/dist/es2022/core/utils/http.utils.d.ts +3 -0
  41. package/dist/es2022/core/utils/http.utils.js +29 -0
  42. package/dist/es2022/core/utils/http.utils.js.map +1 -0
  43. package/dist/es2022/core/utils/management-client-utils.d.ts +19 -0
  44. package/dist/es2022/core/utils/management-client-utils.js +129 -0
  45. package/dist/es2022/core/utils/management-client-utils.js.map +1 -0
  46. package/dist/es2022/core/utils/processing-utils.d.ts +12 -0
  47. package/dist/es2022/core/utils/processing-utils.js +39 -0
  48. package/dist/es2022/core/utils/processing-utils.js.map +1 -0
  49. package/dist/es2022/core/utils/run.utils.d.ts +10 -0
  50. package/dist/es2022/core/utils/run.utils.js +37 -0
  51. package/dist/es2022/core/utils/run.utils.js.map +1 -0
  52. package/dist/es2022/export/context/export-context-fetcher.d.ts +4 -0
  53. package/dist/es2022/export/context/export-context-fetcher.js +289 -0
  54. package/dist/es2022/export/context/export-context-fetcher.js.map +1 -0
  55. package/dist/es2022/export/export-manager.d.ts +5 -0
  56. package/dist/es2022/export/export-manager.js +167 -0
  57. package/dist/es2022/export/export-manager.js.map +1 -0
  58. package/dist/es2022/export/export.models.d.ts +55 -0
  59. package/dist/es2022/export/export.models.js +2 -0
  60. package/dist/es2022/export/export.models.js.map +1 -0
  61. package/dist/es2022/export/index.d.ts +2 -0
  62. package/dist/es2022/export/index.js +3 -0
  63. package/dist/es2022/export/index.js.map +1 -0
  64. package/dist/es2022/export/utils/export.utils.d.ts +2 -0
  65. package/dist/es2022/export/utils/export.utils.js +5 -0
  66. package/dist/es2022/export/utils/export.utils.js.map +1 -0
  67. package/dist/es2022/file/file-manager.d.ts +5 -0
  68. package/dist/es2022/file/file-manager.js +29 -0
  69. package/dist/es2022/file/file-manager.js.map +1 -0
  70. package/dist/es2022/file/index.d.ts +1 -0
  71. package/dist/es2022/file/index.js +2 -0
  72. package/dist/es2022/file/index.js.map +1 -0
  73. package/dist/es2022/import/comparers/asset-comparer.d.ts +12 -0
  74. package/dist/es2022/import/comparers/asset-comparer.js +65 -0
  75. package/dist/es2022/import/comparers/asset-comparer.js.map +1 -0
  76. package/dist/es2022/import/context/import-context-fetcher.d.ts +4 -0
  77. package/dist/es2022/import/context/import-context-fetcher.js +235 -0
  78. package/dist/es2022/import/context/import-context-fetcher.js.map +1 -0
  79. package/dist/es2022/import/import-manager.d.ts +4 -0
  80. package/dist/es2022/import/import-manager.js +80 -0
  81. package/dist/es2022/import/import-manager.js.map +1 -0
  82. package/dist/es2022/import/import.models.d.ts +45 -0
  83. package/dist/es2022/import/import.models.js +2 -0
  84. package/dist/es2022/import/import.models.js.map +1 -0
  85. package/dist/es2022/import/importers/assets-importer.d.ts +10 -0
  86. package/dist/es2022/import/importers/assets-importer.js +175 -0
  87. package/dist/es2022/import/importers/assets-importer.js.map +1 -0
  88. package/dist/es2022/import/importers/content-items-importer.d.ts +10 -0
  89. package/dist/es2022/import/importers/content-items-importer.js +97 -0
  90. package/dist/es2022/import/importers/content-items-importer.js.map +1 -0
  91. package/dist/es2022/import/importers/language-variant-importer.d.ts +11 -0
  92. package/dist/es2022/import/importers/language-variant-importer.js +215 -0
  93. package/dist/es2022/import/importers/language-variant-importer.js.map +1 -0
  94. package/dist/es2022/import/importers/workflow-importer.d.ts +18 -0
  95. package/dist/es2022/import/importers/workflow-importer.js +122 -0
  96. package/dist/es2022/import/importers/workflow-importer.js.map +1 -0
  97. package/dist/es2022/import/index.d.ts +2 -0
  98. package/dist/es2022/import/index.js +3 -0
  99. package/dist/es2022/import/index.js.map +1 -0
  100. package/dist/es2022/import/utils/import.utils.d.ts +2 -0
  101. package/dist/es2022/import/utils/import.utils.js +5 -0
  102. package/dist/es2022/import/utils/import.utils.js.map +1 -0
  103. package/dist/es2022/index.d.ts +8 -0
  104. package/dist/es2022/index.js +10 -0
  105. package/dist/es2022/index.js.map +1 -0
  106. package/dist/es2022/metadata.d.ts +5 -0
  107. package/dist/es2022/metadata.js +6 -0
  108. package/dist/es2022/metadata.js.map +1 -0
  109. package/dist/es2022/node/cli/actions/export-action.d.ts +2 -0
  110. package/dist/es2022/node/cli/actions/export-action.js +40 -0
  111. package/dist/es2022/node/cli/actions/export-action.js.map +1 -0
  112. package/dist/es2022/node/cli/actions/import-action.d.ts +2 -0
  113. package/dist/es2022/node/cli/actions/import-action.js +29 -0
  114. package/dist/es2022/node/cli/actions/import-action.js.map +1 -0
  115. package/dist/es2022/node/cli/actions/migrate-action.d.ts +2 -0
  116. package/dist/es2022/node/cli/actions/migrate-action.js +47 -0
  117. package/dist/es2022/node/cli/actions/migrate-action.js.map +1 -0
  118. package/dist/es2022/node/cli/app.d.ts +2 -0
  119. package/dist/es2022/node/cli/app.js +27 -0
  120. package/dist/es2022/node/cli/app.js.map +1 -0
  121. package/dist/es2022/node/cli/args/args-fetcher.d.ts +2 -0
  122. package/dist/es2022/node/cli/args/args-fetcher.js +46 -0
  123. package/dist/es2022/node/cli/args/args-fetcher.js.map +1 -0
  124. package/dist/es2022/node/cli/args/args-setter.d.ts +2 -0
  125. package/dist/es2022/node/cli/args/args-setter.js +31 -0
  126. package/dist/es2022/node/cli/args/args-setter.js.map +1 -0
  127. package/dist/es2022/node/cli/cli.models.d.ts +24 -0
  128. package/dist/es2022/node/cli/cli.models.js +2 -0
  129. package/dist/es2022/node/cli/cli.models.js.map +1 -0
  130. package/dist/es2022/node/cli/commands.d.ts +1 -0
  131. package/dist/es2022/node/cli/commands.js +157 -0
  132. package/dist/es2022/node/cli/commands.js.map +1 -0
  133. package/dist/es2022/toolkit/elements-builder.d.ts +14 -0
  134. package/dist/es2022/toolkit/elements-builder.js +69 -0
  135. package/dist/es2022/toolkit/elements-builder.js.map +1 -0
  136. package/dist/es2022/toolkit/export.d.ts +3 -0
  137. package/dist/es2022/toolkit/export.js +21 -0
  138. package/dist/es2022/toolkit/export.js.map +1 -0
  139. package/dist/es2022/toolkit/file.d.ts +12 -0
  140. package/dist/es2022/toolkit/file.js +50 -0
  141. package/dist/es2022/toolkit/file.js.map +1 -0
  142. package/dist/es2022/toolkit/import.d.ts +2 -0
  143. package/dist/es2022/toolkit/import.js +21 -0
  144. package/dist/es2022/toolkit/import.js.map +1 -0
  145. package/dist/es2022/toolkit/index.d.ts +5 -0
  146. package/dist/es2022/toolkit/index.js +6 -0
  147. package/dist/es2022/toolkit/index.js.map +1 -0
  148. package/dist/es2022/toolkit/migrate.d.ts +21 -0
  149. package/dist/es2022/toolkit/migrate.js +39 -0
  150. package/dist/es2022/toolkit/migrate.js.map +1 -0
  151. package/dist/es2022/translation/extraction/items-extraction.processor.d.ts +24 -0
  152. package/dist/es2022/translation/extraction/items-extraction.processor.js +108 -0
  153. package/dist/es2022/translation/extraction/items-extraction.processor.js.map +1 -0
  154. package/dist/es2022/translation/helpers/rich-text.processor.d.ts +22 -0
  155. package/dist/es2022/translation/helpers/rich-text.processor.js +209 -0
  156. package/dist/es2022/translation/helpers/rich-text.processor.js.map +1 -0
  157. package/dist/es2022/translation/index.d.ts +4 -0
  158. package/dist/es2022/translation/index.js +5 -0
  159. package/dist/es2022/translation/index.js.map +1 -0
  160. package/dist/es2022/translation/transforms/export-transforms.d.ts +3 -0
  161. package/dist/es2022/translation/transforms/export-transforms.js +196 -0
  162. package/dist/es2022/translation/transforms/export-transforms.js.map +1 -0
  163. package/dist/es2022/translation/transforms/import-transforms.d.ts +7 -0
  164. package/dist/es2022/translation/transforms/import-transforms.js +183 -0
  165. package/dist/es2022/translation/transforms/import-transforms.js.map +1 -0
  166. package/dist/es2022/zip/index.d.ts +4 -0
  167. package/dist/es2022/zip/index.js +5 -0
  168. package/dist/es2022/zip/index.js.map +1 -0
  169. package/dist/es2022/zip/zip-manager.d.ts +6 -0
  170. package/dist/es2022/zip/zip-manager.js +27 -0
  171. package/dist/es2022/zip/zip-manager.js.map +1 -0
  172. package/dist/es2022/zip/zip-packager.d.ts +3 -0
  173. package/dist/es2022/zip/zip-packager.js +69 -0
  174. package/dist/es2022/zip/zip-packager.js.map +1 -0
  175. package/dist/es2022/zip/zip-transformer.d.ts +6 -0
  176. package/dist/es2022/zip/zip-transformer.js +82 -0
  177. package/dist/es2022/zip/zip-transformer.js.map +1 -0
  178. package/dist/es2022/zip/zip.models.d.ts +13 -0
  179. package/dist/es2022/zip/zip.models.js +2 -0
  180. package/dist/es2022/zip/zip.models.js.map +1 -0
  181. package/lib/core/helpers/workflow-helper.ts +104 -0
  182. package/lib/core/index.ts +17 -0
  183. package/lib/core/logs/loggers.ts +80 -0
  184. package/lib/core/models/core.models.ts +134 -0
  185. package/lib/core/models/log.models.ts +31 -0
  186. package/lib/core/models/migration.models.ts +165 -0
  187. package/lib/core/utils/array.utils.ts +49 -0
  188. package/lib/core/utils/binary-data.utils.ts +29 -0
  189. package/lib/core/utils/confirm.utils.ts +139 -0
  190. package/lib/core/utils/error.utils.ts +65 -0
  191. package/lib/core/utils/external-id.utils.ts +9 -0
  192. package/lib/core/utils/global.utils.ts +59 -0
  193. package/lib/core/utils/http.utils.ts +35 -0
  194. package/lib/core/utils/management-client-utils.ts +182 -0
  195. package/lib/core/utils/processing-utils.ts +71 -0
  196. package/lib/core/utils/run.utils.ts +51 -0
  197. package/lib/export/context/export-context-fetcher.ts +475 -0
  198. package/lib/export/export-manager.ts +249 -0
  199. package/lib/export/export.models.ts +87 -0
  200. package/lib/export/index.ts +2 -0
  201. package/lib/export/utils/export.utils.ts +10 -0
  202. package/lib/file/file-manager.ts +37 -0
  203. package/lib/file/index.ts +1 -0
  204. package/lib/import/comparers/asset-comparer.ts +113 -0
  205. package/lib/import/context/import-context-fetcher.ts +367 -0
  206. package/lib/import/import-manager.ts +103 -0
  207. package/lib/import/import.models.ts +84 -0
  208. package/lib/import/importers/assets-importer.ts +239 -0
  209. package/lib/import/importers/content-items-importer.ts +142 -0
  210. package/lib/import/importers/language-variant-importer.ts +342 -0
  211. package/lib/import/importers/workflow-importer.ts +159 -0
  212. package/lib/import/index.ts +2 -0
  213. package/lib/import/utils/import.utils.ts +10 -0
  214. package/lib/index.ts +9 -0
  215. package/lib/metadata.ts +6 -0
  216. package/lib/node/cli/actions/export-action.ts +45 -0
  217. package/lib/node/cli/actions/import-action.ts +34 -0
  218. package/lib/node/cli/actions/migrate-action.ts +52 -0
  219. package/lib/node/cli/app.ts +29 -0
  220. package/lib/node/cli/args/args-fetcher.ts +61 -0
  221. package/lib/node/cli/args/args-setter.ts +35 -0
  222. package/lib/node/cli/cli.models.ts +28 -0
  223. package/lib/node/cli/commands.ts +161 -0
  224. package/lib/toolkit/elements-builder.ts +84 -0
  225. package/lib/toolkit/export.ts +21 -0
  226. package/lib/toolkit/file.ts +70 -0
  227. package/lib/toolkit/import.ts +21 -0
  228. package/lib/toolkit/index.ts +5 -0
  229. package/lib/toolkit/migrate.ts +71 -0
  230. package/lib/translation/extraction/items-extraction.processor.ts +181 -0
  231. package/lib/translation/helpers/rich-text.processor.ts +300 -0
  232. package/lib/translation/index.ts +4 -0
  233. package/lib/translation/transforms/export-transforms.ts +253 -0
  234. package/lib/translation/transforms/import-transforms.ts +215 -0
  235. package/lib/zip/index.ts +4 -0
  236. package/lib/zip/zip-manager.ts +33 -0
  237. package/lib/zip/zip-packager.ts +86 -0
  238. package/lib/zip/zip-transformer.ts +105 -0
  239. package/lib/zip/zip.models.ts +12 -0
  240. package/package.json +88 -0
package/.npmignore ADDED
@@ -0,0 +1,13 @@
1
+ # Ignore everything
2
+ *
3
+
4
+ # But descend into directories
5
+
6
+ # Recursively allow files under subtree
7
+ !/lib/**
8
+ !/dist/**
9
+ !package.json
10
+ !.npmignore
11
+ !README.md
12
+
13
+
package/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Kontent s.r.o.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,272 @@
1
+ # Kontent.ai Migration Toolkit
2
+
3
+ The purpose of this tool is to facilitate _content migration_ to & from [Kontent.ai](https://kontent.ai) environments.
4
+ It can be used to simplify migration from external systems and also provides a built-in migration between kontent.ai
5
+ environments.
6
+
7
+ > [!TIP]
8
+ > This library aims to streamline the migration to / from Kontent.ai environments by providing an abstraction layer
9
+ > which handles creation / updates of content items, language variants, moving items through workflow, publishing,
10
+ > archiving, downloading binary data, uploading assets, `id` to `codename` translation and more.
11
+
12
+ This library can only be used as a library both in `node.js` & `browser` or as a `CLI` utility.
13
+
14
+ > [!CAUTION]
15
+ > **This readme uses pre-release version of this library using `next` tag on NPM**. To install it you need to specify
16
+ > version explicitely such as running `npm i @kontent-ai-consulting/migration-toolkit@1.0.0-24 -g`.
17
+
18
+ # Getting started
19
+
20
+ Use `--help` anytime to get information about available commands and their options.
21
+
22
+ ```bash
23
+ npx @kontent-ai-consulting/migration-toolkit --help
24
+
25
+ # you can also install the package globally, or locally
26
+ npm i @kontent-ai-consulting/migration-toolkit -g
27
+
28
+ # with the package installed, you can call the tool as follows
29
+ kontent-ai-migration-toolkit --help
30
+
31
+ # or check details of particular command
32
+ kontent-ai-migration-toolkit migrate --help
33
+ ```
34
+
35
+ ## Code examples
36
+
37
+ 1. [Import](https://github.com/Kontent-ai/kontent-ai-migration-toolkit/blob/main/samples/import-sample.ts)
38
+ 2. [Export](https://github.com/Kontent-ai/kontent-ai-migration-toolkit/blob/main/samples/export-sample.ts)
39
+ 3. [Migrate from external system](https://github.com/Kontent-ai/kontent-ai-migration-toolkit/blob/main/samples/migrate-from-external-system.ts)
40
+ 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)
41
+
42
+ > [!NOTE]
43
+ > You can run `kontent-ai-migration-toolkit` many times over without being worried that duplicate content items / assets
44
+ > are created.
45
+
46
+ # Migrate between Kontent.ai environments
47
+
48
+ You may migrate content (items & asset) between Kontent.ai environments. For migrating _Data model / structure_ see
49
+ [Data Ops](https://github.com/kontent-ai/data-ops) instead.
50
+
51
+ > [!CAUTION]
52
+ > **We recommend migrating to test / dev environments first ** to ensure nothing unexpected happens..
53
+
54
+ ## Configuration
55
+
56
+ | Config | Value |
57
+ | ----------------------- | ----------------------------------------------------------------------------------------------------- |
58
+ | **sourceEnvironmentId** | Id of source environment **(required)** |
59
+ | **sourceApiKey** | Management API key of source environment **(required)** |
60
+ | **targetEnvironmentId** | Id of target environment **(required)** |
61
+ | **targetApiKey** | Management API key of target environment **(required)** |
62
+ | **language** | Codename of language that items will be exported in **(required)** |
63
+ | **items** | Comma separated list of items that will be exported **(required)** |
64
+ | force | Can be used to disable confirmation prompts. Available options: `true` & `false`. Detaults to `false` |
65
+
66
+ ## Migrate CLI
67
+
68
+ ```bash
69
+ # Migrate from Kontent.ai environment into another Kontent.ai environment
70
+ kontent-ai-migration-toolkit migrate --targetEnvironmentId=x --targetApiKey=x --sourceEnvironmentId=x --sourceApiKey=x --language=default --items=itemA,itemB
71
+ ```
72
+
73
+ # Import
74
+
75
+ > [!CAUTION]
76
+ > **We do not recommended importing into a production environment directly without testing**. Instead you should first
77
+ > create a testing environment and run the script there to make sure everything works as you intended to.
78
+
79
+ > [!NOTE]
80
+ > When importing it is essential that the target project structure (i.e. `Content types`, `Taxonomies`, `Collections`,
81
+ > `Workflows`, `languages`...) are consistent with the ones defined in source environment. Any inconsistency in data
82
+ > such as referencing inexistent taxonomy term, incorrect element type and other inconsistencies may cause import to
83
+ > fail.
84
+
85
+ ## Configuration
86
+
87
+ | Config | Value |
88
+ | ----------------------- | ----------------------------------------------------------------------------------------------------- |
89
+ | **targetEnvironmentId** | Id of Kontent.ai environment **(required)** |
90
+ | **targetApiKey** | Management API key **(required)** |
91
+ | **filename** | Name of the zip file **(required)** |
92
+ | baseUrl | Custom base URL for Kontent.ai API calls |
93
+ | force | Can be used to disable confirmation prompts. Available options: `true` & `false`. Detaults to `false` |
94
+
95
+ ## Import CLI
96
+
97
+ ```bash
98
+ # Import into target environment
99
+ kontent-ai-migration-toolkit import --targetEnvironmentId=x --targetApiKey=x --filename=data.zip
100
+ ```
101
+
102
+ # Migrate from Kontent.ai
103
+
104
+ This library can also be used to export content items & assets from Kontent.ai environments. However, when migration
105
+ from 3rd party system you typically only use the `import` capabilities of this repository.
106
+
107
+ ## Configuration
108
+
109
+ | Config | Value |
110
+ | ----------------------- | ------------------------------------------------------------------ |
111
+ | **sourceEnvironmentId** | Id of Kontent.ai environment **(required)** |
112
+ | **sourceApiKey** | Management API key of Kontent.ai environment **(required)** |
113
+ | **language** | Codename of language that items will be exported in **(required)** |
114
+ | **items** | Comma separated list of items that will be exported **(required)** |
115
+ | filename | Name of the zip file |
116
+ | baseUrl | Custom base URL for Kontent.ai API calls |
117
+
118
+ ## Export CLI
119
+
120
+ ```bash
121
+ # Export from Kontent.ai environment
122
+ kontent-ai-migration-toolkit export --sourceEnvironmentId=x --sourceApiKey=x --language=default --items=itemA,itemB
123
+ ```
124
+
125
+ # Migrate from external systems
126
+
127
+ You can use this library when exporting from 3rd party systems (i.e. legacy CMS) as it will abstract your from using
128
+ Kontent.ai Management API directly.
129
+
130
+ The main focus is therefore on transforming the data you need to migrate into a format this library supports. The main
131
+ migration models are `MigrationItem` and `MigrationAsset`. For creating element values `elementsBuilder`.
132
+
133
+ See below example of using a strongly typed model and migrating a single item with an asset.
134
+
135
+ ```typescript
136
+ /**
137
+ * Optionally (but strongly recommended) you may define a migration model
138
+ * representing the content type you are trying to migrate into
139
+ */
140
+ interface ArticleElements extends MigrationElements {
141
+ title: MigrationElementModels.TextElement;
142
+ rating: MigrationElementModels.NumberElement;
143
+ related_pages: MigrationElementModels.LinkedItemsElement;
144
+ teaser_image: MigrationElementModels.AssetElement;
145
+ }
146
+
147
+ const migrationItem: MigrationItem<ArticleElements> = {
148
+ system: {
149
+ name: 'My article',
150
+ // codename is primary identifier - also used for validating whether asset exists in target env
151
+ codename: 'myArticle',
152
+ collection: {
153
+ // collection codename must match the collection in your target K.ai environment
154
+ codename: 'default'
155
+ },
156
+ language: {
157
+ // language codename must match the language in your target K.ai environment
158
+ codename: 'en_uk'
159
+ },
160
+ type: {
161
+ // type codename must match the content type codename in your target K.ai environment
162
+ codename: 'article'
163
+ }
164
+ },
165
+ elements: {
166
+ title: elementsBuilder.textElement({ value: 'Title of the article' }),
167
+ rating: elementsBuilder.numberElement({ value: 5 }),
168
+ related_pages: elementsBuilder.linkedItemsElement({
169
+ value: [
170
+ {
171
+ codename: 'pageA'
172
+ },
173
+ {
174
+ codename: 'pageB'
175
+ }
176
+ ]
177
+ }),
178
+ // assets are referenced by their codename
179
+ teaser_image: elementsBuilder.assetElement({ value: [{ codename: 'article_teaser' }] })
180
+ }
181
+ };
182
+
183
+ const migrationAsset: MigrationAsset = {
184
+ // codename of the asset - Used for validating whether asset exists in target env
185
+ codename: 'article_teaser',
186
+ // filename will be used in K.ai asset as a filename
187
+ filename: 'article_teaser.jpg',
188
+ // title will be used in K.ai asset as a title
189
+ title: 'Article teaser',
190
+ // binary data of the asset you want to upload
191
+ binaryData: <BinaryData>,
192
+ // collection assignment
193
+ collection: {
194
+ codename: 'teasers'
195
+ },
196
+ // description of asset in project languages
197
+ descriptions: [
198
+ {
199
+ description: 'Teaser of the article',
200
+ language: {
201
+ codename: 'en_uk'
202
+ }
203
+ }
204
+ ]
205
+ };
206
+ ```
207
+
208
+ Once you are happy with the data, you can import them to Kontent.ai using the `importAsync` function.
209
+
210
+ ```typescript
211
+ await importAsync({
212
+ environmentId: environmentId,
213
+ apiKey: apiKey,
214
+ data: {
215
+ assets: [migrationAsset],
216
+ items: [migrationItem]
217
+ }
218
+ });
219
+ ```
220
+
221
+ # Migration / import processing
222
+
223
+ ### How are content items imported?
224
+
225
+ The Migration Toolkit creates content items that are not present in target project. If the content item exists in target
226
+ project (based on item's `codename`) the item will be updated, otherwise it will be created. No duplicate items will be
227
+ created. The workflow of the item in target environment will be set to match the source environment.
228
+
229
+ ### How are assets imported?
230
+
231
+ If asset exists in target project (based on asset's `codename`), the asset upload will be skipped and not uploaded at
232
+ all. Otherwise the asset will be created in target environment.
233
+
234
+ ### How are referenced content items & asset handled?
235
+
236
+ If you have a reference to a content item or asset (i.e. in linked items element, asset element, rich text element...)
237
+ the migration toolkit first checks whether the referenced object exists (based on item or asset `codename`) and if it
238
+ does, successfuly sets the reference. If the object does not exist, it will be referenced by an `external_id` which
239
+ creates a placeholder for the item until it becomes available.
240
+
241
+ See the table below to learn how `external_id` is generated by default:
242
+
243
+ | Object type | Template | Sample `codename` of the object | Generated `external_id` |
244
+ | ---------------- | ------------------ | ------------------------------- | ----------------------- |
245
+ | **Asset** | `asset_{codename}` | my_file | `asset_my_file` |
246
+ | **Content item** | `item_{codename}` | article | `item_article` |
247
+
248
+ If you need to change the way `external_id` is created, you may supply a custom implementation of `externalIdGenerator`
249
+ within import / migrate functions.
250
+
251
+ ## Limitations
252
+
253
+ 1. Asset folder assignments are not preserved during migration because folders can be referenced only by id's and not
254
+ codenames.
255
+ 2. Assets element values are not preserved during migration because elements can be referenced only by id's and not
256
+ codenames.
257
+ 3. Language variants in `Scheduled` workflow step do not preserve their workflow status because the API does not provide
258
+ an information about scheduled times
259
+
260
+ ## FAQ
261
+
262
+ ### I'm getting `Header overflow` exception
263
+
264
+ The Node.js limits the maximum header size of HTTP requests. In some cases it may be required for you to increase this
265
+ limitation to be able to successfully fetch data from Kontent.ai. You can do so by using the `max-http-header-size`
266
+ option (https://nodejs.org/api/cli.html#--max-http-header-sizesize)
267
+
268
+ Example script call:
269
+
270
+ ```bash
271
+ node --max-http-header-size 150000 %USERPROFILE%\AppData\Roaming\npm\node_modules\kontent-ai-migration-toolkit\dist\cjs\lib\node\cli\app --action=export --apiKey=<key> --environmentId=<environmentId>
272
+ ```
@@ -0,0 +1,37 @@
1
+ import { WorkflowModels } from '@kontent-ai/management-sdk';
2
+ export type WorkflowStep = {
3
+ readonly codename: string;
4
+ readonly id: string;
5
+ };
6
+ type WorkflowMatcher = {
7
+ readonly match: (workflow: Readonly<WorkflowModels.Workflow>, index: number) => boolean;
8
+ readonly errorMessage: string;
9
+ };
10
+ type StepMatcher = {
11
+ readonly match: (step: WorkflowStep, index: number) => boolean;
12
+ readonly errorMessage: string;
13
+ };
14
+ export declare function workflowHelper(workflows: readonly Readonly<WorkflowModels.Workflow>[]): {
15
+ getWorkflowByCodename: (workflowCodename: string) => Readonly<WorkflowModels.Workflow>;
16
+ getWorkflowStepByCodename: (workflow: Readonly<WorkflowModels.Workflow>, stepCodename: string) => WorkflowStep;
17
+ getWorkflowAndStepByCodenames: (data: {
18
+ readonly workflowCodename: string;
19
+ readonly stepCodename: string;
20
+ }) => {
21
+ step: WorkflowStep;
22
+ workflow: Readonly<WorkflowModels.Workflow>;
23
+ };
24
+ getWorkflowStep: (workflow: Readonly<WorkflowModels.Workflow>, stepMatcher: StepMatcher) => WorkflowStep;
25
+ getWorkflowAndStep: (data: {
26
+ readonly workflowMatcher: WorkflowMatcher;
27
+ readonly stepMatcher: StepMatcher;
28
+ }) => {
29
+ step: WorkflowStep;
30
+ workflow: Readonly<WorkflowModels.Workflow>;
31
+ };
32
+ getWorkflow: (workflowMatcher: WorkflowMatcher) => Readonly<WorkflowModels.Workflow>;
33
+ isPublishedStepByCodename: (stepCodename: string) => boolean;
34
+ isArchivedStepByCodename: (stepCodename: string) => boolean;
35
+ isScheduledStepByCodename: (stepCodename: string) => boolean;
36
+ };
37
+ export {};
@@ -0,0 +1,67 @@
1
+ import chalk from 'chalk';
2
+ import { findRequired } from '../utils/array.utils.js';
3
+ export function workflowHelper(workflows) {
4
+ const getWorkflowStep = (workflow, stepMatcher) => {
5
+ return findRequired([...workflow.steps, workflow.archivedStep, workflow.publishedStep, workflow.scheduledStep], stepMatcher.match, stepMatcher.errorMessage);
6
+ };
7
+ const getWorkflow = (workflowMatcher) => {
8
+ return findRequired(workflows, workflowMatcher.match, workflowMatcher.errorMessage);
9
+ };
10
+ const getWorkflowByCodename = (workflowCodename) => {
11
+ return getWorkflow({
12
+ errorMessage: [
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(', ')}`
17
+ ].join(', '),
18
+ match: (workflow) => workflow.codename.toLowerCase() === workflowCodename.toLowerCase()
19
+ });
20
+ };
21
+ const getWorkflowStepByCodename = (workflow, stepCodename) => {
22
+ return getWorkflowStep(workflow, {
23
+ errorMessage: [
24
+ `Workflow step with codename '${chalk.red(stepCodename)}' does not exist in target project`,
25
+ `Step in workflow '${chalk.yellow(workflow.codename)}' are (${workflows.length}): ${workflows
26
+ .map((m) => chalk.cyan(m.codename))
27
+ .join(', ')}`
28
+ ].join(', '),
29
+ match: (step) => step.codename.toLowerCase() === stepCodename.toLowerCase()
30
+ });
31
+ };
32
+ const getWorkflowAndStep = (data) => {
33
+ const workflow = getWorkflow(data.workflowMatcher);
34
+ return {
35
+ workflow,
36
+ step: getWorkflowStep(workflow, data.stepMatcher)
37
+ };
38
+ };
39
+ const getWorkflowAndStepByCodenames = (data) => {
40
+ const workflow = getWorkflowByCodename(data.workflowCodename);
41
+ return {
42
+ workflow,
43
+ step: getWorkflowStepByCodename(workflow, data.stepCodename)
44
+ };
45
+ };
46
+ const isPublishedStepByCodename = (stepCodename) => {
47
+ return workflows.find((workflow) => workflow.publishedStep.codename === stepCodename) ? true : false;
48
+ };
49
+ const isArchivedStepByCodename = (stepCodename) => {
50
+ return workflows.find((workflow) => workflow.archivedStep.codename === stepCodename) ? true : false;
51
+ };
52
+ const isScheduledStepByCodename = (stepCodename) => {
53
+ return workflows.find((workflow) => workflow.scheduledStep.codename === stepCodename) ? true : false;
54
+ };
55
+ return {
56
+ getWorkflowByCodename,
57
+ getWorkflowStepByCodename,
58
+ getWorkflowAndStepByCodenames,
59
+ getWorkflowStep,
60
+ getWorkflowAndStep,
61
+ getWorkflow,
62
+ isPublishedStepByCodename,
63
+ isArchivedStepByCodename,
64
+ isScheduledStepByCodename
65
+ };
66
+ }
67
+ //# sourceMappingURL=workflow-helper.js.map
@@ -0,0 +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,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,aAAa,CAAC,EAC1F,WAAW,CAAC,KAAK,EACjB,WAAW,CAAC,Y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QAAQ,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IACzG,CAAC,CAAC;IAEF,OAAO;QACH,qBAAqB;QACrB,yBAAyB;QACzB,6BAA6B;QAC7B,eAAe;QACf,kBAAkB;QAClB,WAAW;QACX,yBAAyB;QACzB,wBAAwB;QACxB,yBAAyB;KAC5B,CAAC;AACN,CAAC"}
@@ -0,0 +1,15 @@
1
+ export * from './utils/global.utils.js';
2
+ export * from './utils/processing-utils.js';
3
+ export * from './utils/http.utils.js';
4
+ export * from './utils/confirm.utils.js';
5
+ export * from './utils/error.utils.js';
6
+ export * from './utils/run.utils.js';
7
+ export * from './utils/external-id.utils.js';
8
+ export * from './utils/binary-data.utils.js';
9
+ export * from './utils/array.utils.js';
10
+ export * from './utils/management-client-utils.js';
11
+ export * from './models/log.models.js';
12
+ export * from './models/core.models.js';
13
+ export * from './models/migration.models.js';
14
+ export * from './logs/loggers.js';
15
+ export * from './helpers/workflow-helper.js';
@@ -0,0 +1,16 @@
1
+ export * from './utils/global.utils.js';
2
+ export * from './utils/processing-utils.js';
3
+ export * from './utils/http.utils.js';
4
+ export * from './utils/confirm.utils.js';
5
+ export * from './utils/error.utils.js';
6
+ export * from './utils/run.utils.js';
7
+ export * from './utils/external-id.utils.js';
8
+ export * from './utils/binary-data.utils.js';
9
+ export * from './utils/array.utils.js';
10
+ export * from './utils/management-client-utils.js';
11
+ export * from './models/log.models.js';
12
+ export * from './models/core.models.js';
13
+ export * from './models/migration.models.js';
14
+ export * from './logs/loggers.js';
15
+ export * from './helpers/workflow-helper.js';
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,oCAAoC,CAAC;AAEnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAE7C,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { Logger } from '../models/log.models.js';
2
+ export declare function getDefaultLogger(): Logger;
@@ -0,0 +1,69 @@
1
+ import chalk from 'chalk';
2
+ import { getCurrentEnvironment } from '../utils/global.utils.js';
3
+ const originalWarn = console.warn;
4
+ export function getDefaultLogger() {
5
+ const currentEnv = getCurrentEnvironment();
6
+ if (currentEnv === 'node') {
7
+ return defaultNodeLogger;
8
+ }
9
+ if (currentEnv === 'browser') {
10
+ return defaultBrowserLogger;
11
+ }
12
+ throw Error(`Invalid environment`);
13
+ }
14
+ const defaultNodeLogger = {
15
+ log: (data) => console.log(getLogDataMessage(data)),
16
+ logWithSpinnerAsync: async (func) => {
17
+ const ora = await import('ora');
18
+ return await ora.oraPromise(async (spinner) => {
19
+ // patch global console to prevent disrupting ora instance
20
+ // this often happens when JS SDK logs console.warn for
21
+ // retried requests. Patching this ensures the flow is uninterrupted
22
+ global.console.warn = (m) => {
23
+ if (m) {
24
+ spinner.text = m?.toString() ?? 'Invalid warn value';
25
+ }
26
+ };
27
+ const result = await func((data) => {
28
+ // remember last used prefix. This is useful as we don't have to pass prefix to every single function
29
+ // calling the spinner
30
+ if (data.prefix) {
31
+ spinner.prefixText = data.prefix ?? '';
32
+ }
33
+ spinner.text = getLogDataMessage(data);
34
+ });
35
+ // restore original warn
36
+ global.console.warn = originalWarn;
37
+ return result;
38
+ }, {});
39
+ }
40
+ };
41
+ const defaultBrowserLogger = {
42
+ log: (data) => console.log(getLogDataMessage(data)),
43
+ logWithSpinnerAsync: async (func) => {
44
+ return await func((data) => {
45
+ const prefix = data.prefix ? `${data.prefix}: ` : '';
46
+ console.log(`${prefix}${getLogDataMessage(data)}`);
47
+ });
48
+ }
49
+ };
50
+ function getLogDataMessage(data) {
51
+ let typeColor = chalk.yellow;
52
+ if (data.type === 'info') {
53
+ typeColor = chalk.cyan;
54
+ }
55
+ else if (data.type === 'error' ||
56
+ data.type === 'errorData' ||
57
+ data.type === 'warning' ||
58
+ data.type === 'cancel') {
59
+ typeColor = chalk.red;
60
+ }
61
+ else if (data.type === 'completed') {
62
+ typeColor = chalk.green;
63
+ }
64
+ else if (data.type === 'skip') {
65
+ typeColor = chalk.gray;
66
+ }
67
+ return `${typeColor(data.type)}: ${data.message}`;
68
+ }
69
+ //# sourceMappingURL=loggers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loggers.js","sourceRoot":"","sources":["../../../../lib/core/logs/loggers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,MAAM,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;AAElC,MAAM,UAAU,gBAAgB;IAC5B,MAAM,UAAU,GAAG,qBAAqB,EAAE,CAAC;IAE3C,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;QACxB,OAAO,iBAAiB,CAAC;IAC7B,CAAC;IACD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,oBAAoB,CAAC;IAChC,CAAC;IACD,MAAM,KAAK,CAAC,qBAAqB,CAAC,CAAC;AACvC,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,KA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,EAAE,CAAC,CAAC;QACvD,CAAC,CAAC,CAAC;IACP,CAAC;CACJ,CAAC;AAEF,SAAS,iBAAiB,CAAC,IAAuB;IAC9C,IAAI,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC;IAE7B,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACvB,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC;IAC3B,CAAC;SAAM,IACH,IAAI,CAAC,IAAI,KAAK,OAAO;QACrB,IAAI,CAAC,IAAI,KAAK,WAAW;QACzB,IAAI,CAAC,IAAI,KAAK,SAAS;QACvB,IAAI,CAAC,IAAI,KAAK,QAAQ,EACxB,CAAC;QACC,SAAS,GAAG,KAAK,CAAC,GAAG,CAAC;IAC1B,CAAC;SAAM,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QACnC,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC;IAC5B,CAAC;SAAM,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC9B,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,OAAO,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;AACtD,CAAC"}
@@ -0,0 +1,91 @@
1
+ import { AssetModels, ContentItemModels, ContentTypeElements, LanguageVariantModels, WorkflowModels } from '@kontent-ai/management-sdk';
2
+ import { MigrationElementType } from './migration.models.js';
3
+ import { WorkflowStep } from '../helpers/workflow-helper.js';
4
+ export type TargetItemState = 'exists' | 'doesNotExists';
5
+ export type CliAction = 'export' | 'import' | 'migrate';
6
+ export type GeneralItemType = 'exportedItem' | 'migrationItem';
7
+ export type GeneralActionType = 'readFs' | 'skip' | 'writeFs' | 'download';
8
+ export type EnvContext = 'browser' | 'node';
9
+ export type MapiAction = 'list' | 'view' | 'archive' | 'unpublish' | 'changeWorkflowStep' | 'publish' | 'upload' | 'create' | 'upsert' | 'createNewVersion';
10
+ export type MapiType = 'contentType' | 'asset' | 'contentTypeSnippet' | 'contentItem' | 'languageVariant' | 'language' | 'collection' | 'taxonomy' | 'binaryFile' | 'workflow';
11
+ export interface ItemInfo {
12
+ readonly title: string;
13
+ readonly itemType: GeneralItemType | MapiType;
14
+ }
15
+ export interface ErrorData {
16
+ readonly message: string;
17
+ readonly requestData?: string;
18
+ readonly requestUrl?: string;
19
+ readonly isUnknownError: boolean;
20
+ readonly error: unknown;
21
+ }
22
+ export interface ReferencedDataInMigrationItems {
23
+ readonly itemCodenames: ReadonlySet<string>;
24
+ readonly assetCodenames: ReadonlySet<string>;
25
+ }
26
+ export interface ReferencedDataInLanguageVariants {
27
+ readonly itemIds: ReadonlySet<string>;
28
+ readonly assetIds: ReadonlySet<string>;
29
+ }
30
+ export interface ItemStateInSourceEnvironmentById {
31
+ readonly state: TargetItemState;
32
+ readonly id: string;
33
+ readonly item: Readonly<ContentItemModels.ContentItem> | undefined;
34
+ }
35
+ export interface AssetStateInSourceEnvironmentById {
36
+ readonly state: TargetItemState;
37
+ readonly id: string;
38
+ readonly asset: Readonly<AssetModels.Asset> | undefined;
39
+ }
40
+ export interface ItemStateInTargetEnvironmentByCodename {
41
+ readonly state: TargetItemState;
42
+ readonly itemCodename: string;
43
+ readonly item: Readonly<ContentItemModels.ContentItem> | undefined;
44
+ readonly externalIdToUse: string;
45
+ }
46
+ export interface LanguageVariantStateInTargetEnvironmentByCodename {
47
+ readonly state: TargetItemState;
48
+ readonly itemCodename: string;
49
+ readonly languageCodename: string;
50
+ readonly languageVariant: Readonly<LanguageVariantModels.ContentItemLanguageVariant> | undefined;
51
+ readonly workflow: Readonly<WorkflowModels.Workflow> | undefined;
52
+ readonly step: Readonly<WorkflowStep> | undefined;
53
+ }
54
+ export interface AssetStateInTargetEnvironmentByCodename {
55
+ readonly state: TargetItemState;
56
+ readonly assetCodename: string;
57
+ readonly asset: Readonly<AssetModels.Asset> | undefined;
58
+ readonly externalIdToUse: string;
59
+ }
60
+ export interface PackageMetadata {
61
+ readonly created: Date;
62
+ readonly environmentId: string;
63
+ readonly dataOverview: PackageDataOverview;
64
+ }
65
+ export interface PackageDataOverview {
66
+ readonly contentItemsCount: number;
67
+ readonly assetsCount: number;
68
+ }
69
+ export interface FlattenedContentTypeElement {
70
+ readonly codename: string;
71
+ readonly id: string;
72
+ readonly type: MigrationElementType;
73
+ readonly element: Readonly<ContentTypeElements.ContentTypeElementModel>;
74
+ }
75
+ export interface FlattenedContentType {
76
+ readonly contentTypeCodename: string;
77
+ readonly contentTypeId: string;
78
+ readonly elements: readonly FlattenedContentTypeElement[];
79
+ }
80
+ export interface OriginalManagementError {
81
+ response?: {
82
+ status?: number;
83
+ config?: {
84
+ url?: string;
85
+ data?: string;
86
+ };
87
+ data?: {
88
+ error_code?: number;
89
+ };
90
+ };
91
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=core.models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.models.js","sourceRoot":"","sources":["../../../../lib/core/models/core.models.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { GeneralActionType, GeneralItemType, MapiAction, MapiType } from '../index.js';
2
+ export type DebugType = 'error' | 'completed' | 'warning' | 'info' | 'errorData' | 'cancel' | 'process' | MapiType | GeneralActionType | MapiAction | GeneralItemType;
3
+ export interface LogMessage {
4
+ readonly type: DebugType;
5
+ readonly message: string;
6
+ }
7
+ export interface LogSpinnerMessage extends LogMessage {
8
+ readonly prefix?: string;
9
+ }
10
+ export type LogData = (data: LogMessage) => void;
11
+ export type LogSpinnerData = (data: LogSpinnerMessage) => void;
12
+ export interface Logger {
13
+ readonly logWithSpinnerAsync: <T>(func: (logData: LogSpinnerData) => Promise<T>) => Promise<T>;
14
+ readonly log: LogData;
15
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=log.models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"log.models.js","sourceRoot":"","sources":["../../../../lib/core/models/log.models.ts"],"names":[],"mappings":""}