@kontent-ai/migration-toolkit 2.9.1 → 3.0.0-1

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 (239) hide show
  1. package/README.md +19 -17
  2. package/dist/core/config.js +3 -3
  3. package/dist/core/config.js.map +1 -1
  4. package/dist/core/helpers/workflow-helper.d.ts +1 -1
  5. package/dist/core/helpers/workflow-helper.js +28 -26
  6. package/dist/core/helpers/workflow-helper.js.map +1 -1
  7. package/dist/core/logs/loggers.d.ts +1 -1
  8. package/dist/core/logs/loggers.js +15 -15
  9. package/dist/core/logs/loggers.js.map +1 -1
  10. package/dist/core/models/core.models.d.ts +29 -22
  11. package/dist/core/models/error.models.d.ts +26 -0
  12. package/dist/core/models/error.models.js +104 -0
  13. package/dist/core/models/error.models.js.map +1 -0
  14. package/dist/core/models/log.models.d.ts +2 -2
  15. package/dist/core/models/migration.models.d.ts +17 -19
  16. package/dist/core/models/migration.schema.d.ts +9 -9
  17. package/dist/core/models/migration.schema.js +28 -28
  18. package/dist/core/models/migration.schema.js.map +1 -1
  19. package/dist/core/utils/array.utils.d.ts +1 -1
  20. package/dist/core/utils/array.utils.js +4 -3
  21. package/dist/core/utils/array.utils.js.map +1 -1
  22. package/dist/core/utils/binary-data.utils.d.ts +1 -1
  23. package/dist/core/utils/binary-data.utils.js +6 -6
  24. package/dist/core/utils/binary-data.utils.js.map +1 -1
  25. package/dist/core/utils/confirm.utils.d.ts +3 -1
  26. package/dist/core/utils/confirm.utils.js +92 -24
  27. package/dist/core/utils/confirm.utils.js.map +1 -1
  28. package/dist/core/utils/error.utils.d.ts +1 -1
  29. package/dist/core/utils/error.utils.js +16 -14
  30. package/dist/core/utils/error.utils.js.map +1 -1
  31. package/dist/core/utils/external-id.utils.js +1 -1
  32. package/dist/core/utils/external-id.utils.js.map +1 -1
  33. package/dist/core/utils/global.utils.d.ts +3 -3
  34. package/dist/core/utils/global.utils.js +20 -18
  35. package/dist/core/utils/global.utils.js.map +1 -1
  36. package/dist/core/utils/http.utils.d.ts +2 -2
  37. package/dist/core/utils/http.utils.js +4 -4
  38. package/dist/core/utils/http.utils.js.map +1 -1
  39. package/dist/core/utils/management-client-utils.d.ts +4 -4
  40. package/dist/core/utils/management-client-utils.js +37 -34
  41. package/dist/core/utils/management-client-utils.js.map +1 -1
  42. package/dist/core/utils/processing-utils.d.ts +4 -4
  43. package/dist/core/utils/processing-utils.js +13 -13
  44. package/dist/core/utils/processing-utils.js.map +1 -1
  45. package/dist/core/utils/run.utils.d.ts +2 -2
  46. package/dist/core/utils/run.utils.js +7 -7
  47. package/dist/core/utils/run.utils.js.map +1 -1
  48. package/dist/core/utils/try.utils.d.ts +14 -0
  49. package/dist/core/utils/try.utils.js +18 -0
  50. package/dist/core/utils/try.utils.js.map +1 -0
  51. package/dist/export/context/export-context-fetcher.d.ts +1 -1
  52. package/dist/export/context/export-context-fetcher.js +92 -62
  53. package/dist/export/context/export-context-fetcher.js.map +1 -1
  54. package/dist/export/export-manager.d.ts +2 -2
  55. package/dist/export/export-manager.js +73 -59
  56. package/dist/export/export-manager.js.map +1 -1
  57. package/dist/export/export.models.d.ts +21 -2
  58. package/dist/export/utils/export.utils.d.ts +1 -1
  59. package/dist/export/utils/export.utils.js +3 -2
  60. package/dist/export/utils/export.utils.js.map +1 -1
  61. package/dist/file/file-manager.d.ts +2 -2
  62. package/dist/file/file-manager.js +7 -7
  63. package/dist/file/file-manager.js.map +1 -1
  64. package/dist/import/comparers/asset-comparer.d.ts +2 -2
  65. package/dist/import/comparers/asset-comparer.js +12 -11
  66. package/dist/import/comparers/asset-comparer.js.map +1 -1
  67. package/dist/import/context/import-context-fetcher.d.ts +1 -1
  68. package/dist/import/context/import-context-fetcher.js +77 -73
  69. package/dist/import/context/import-context-fetcher.js.map +1 -1
  70. package/dist/import/import-manager.d.ts +1 -1
  71. package/dist/import/import-manager.js +59 -56
  72. package/dist/import/import-manager.js.map +1 -1
  73. package/dist/import/import.models.d.ts +6 -2
  74. package/dist/import/importers/assets-importer.d.ts +3 -3
  75. package/dist/import/importers/assets-importer.js +46 -43
  76. package/dist/import/importers/assets-importer.js.map +1 -1
  77. package/dist/import/importers/content-items-importer.d.ts +3 -3
  78. package/dist/import/importers/content-items-importer.js +28 -25
  79. package/dist/import/importers/content-items-importer.js.map +1 -1
  80. package/dist/import/importers/language-variant-importer.d.ts +3 -3
  81. package/dist/import/importers/language-variant-importer.js +45 -45
  82. package/dist/import/importers/language-variant-importer.js.map +1 -1
  83. package/dist/import/importers/workflow-importer.d.ts +3 -2
  84. package/dist/import/importers/workflow-importer.js +58 -54
  85. package/dist/import/importers/workflow-importer.js.map +1 -1
  86. package/dist/import/utils/import.utils.d.ts +1 -1
  87. package/dist/import/utils/import.utils.js +3 -2
  88. package/dist/import/utils/import.utils.js.map +1 -1
  89. package/dist/index.d.ts +11 -7
  90. package/dist/index.js +10 -8
  91. package/dist/index.js.map +1 -1
  92. package/dist/metadata.js +3 -3
  93. package/dist/metadata.js.map +1 -1
  94. package/dist/node/cli/actions/export-action.d.ts +1 -1
  95. package/dist/node/cli/actions/export-action.js +29 -23
  96. package/dist/node/cli/actions/export-action.js.map +1 -1
  97. package/dist/node/cli/actions/import-action.d.ts +1 -1
  98. package/dist/node/cli/actions/import-action.js +15 -12
  99. package/dist/node/cli/actions/import-action.js.map +1 -1
  100. package/dist/node/cli/actions/migrate-action.d.ts +1 -1
  101. package/dist/node/cli/actions/migrate-action.js +26 -22
  102. package/dist/node/cli/actions/migrate-action.js.map +1 -1
  103. package/dist/node/cli/app.js +13 -12
  104. package/dist/node/cli/app.js.map +1 -1
  105. package/dist/node/cli/args/args-fetcher.d.ts +1 -1
  106. package/dist/node/cli/args/args-fetcher.js +14 -13
  107. package/dist/node/cli/args/args-fetcher.js.map +1 -1
  108. package/dist/node/cli/args/args-setter.d.ts +1 -1
  109. package/dist/node/cli/args/args-setter.js +8 -6
  110. package/dist/node/cli/args/args-setter.js.map +1 -1
  111. package/dist/node/cli/cli.models.d.ts +2 -2
  112. package/dist/node/cli/commands.js +68 -56
  113. package/dist/node/cli/commands.js.map +1 -1
  114. package/dist/toolkit/elements-builder.d.ts +1 -1
  115. package/dist/toolkit/elements-builder.js +12 -12
  116. package/dist/toolkit/elements-builder.js.map +1 -1
  117. package/dist/toolkit/export.d.ts +2 -2
  118. package/dist/toolkit/export.js +8 -8
  119. package/dist/toolkit/export.js.map +1 -1
  120. package/dist/toolkit/file.d.ts +2 -1
  121. package/dist/toolkit/file.js +18 -16
  122. package/dist/toolkit/file.js.map +1 -1
  123. package/dist/toolkit/import.d.ts +1 -1
  124. package/dist/toolkit/import.js +12 -12
  125. package/dist/toolkit/import.js.map +1 -1
  126. package/dist/toolkit/migrate.d.ts +13 -4
  127. package/dist/toolkit/migrate.js +15 -13
  128. package/dist/toolkit/migrate.js.map +1 -1
  129. package/dist/translation/extraction/items-extraction.processor.d.ts +5 -4
  130. package/dist/translation/extraction/items-extraction.processor.js +73 -35
  131. package/dist/translation/extraction/items-extraction.processor.js.map +1 -1
  132. package/dist/translation/helpers/export-placeholder.utils.d.ts +11 -0
  133. package/dist/translation/helpers/export-placeholder.utils.js +11 -0
  134. package/dist/translation/helpers/export-placeholder.utils.js.map +1 -0
  135. package/dist/translation/helpers/rich-text.processor.d.ts +6 -6
  136. package/dist/translation/helpers/rich-text.processor.js +38 -38
  137. package/dist/translation/helpers/rich-text.processor.js.map +1 -1
  138. package/dist/translation/transforms/export-transforms.d.ts +2 -2
  139. package/dist/translation/transforms/export-transforms.js +93 -67
  140. package/dist/translation/transforms/export-transforms.js.map +1 -1
  141. package/dist/translation/transforms/import-transforms.d.ts +2 -2
  142. package/dist/translation/transforms/import-transforms.js +38 -40
  143. package/dist/translation/transforms/import-transforms.js.map +1 -1
  144. package/dist/zip/zip-manager.d.ts +4 -3
  145. package/dist/zip/zip-manager.js +9 -9
  146. package/dist/zip/zip-manager.js.map +1 -1
  147. package/dist/zip/zip-packager.d.ts +2 -2
  148. package/dist/zip/zip-packager.js +19 -17
  149. package/dist/zip/zip-packager.js.map +1 -1
  150. package/dist/zip/zip-transformer.d.ts +3 -2
  151. package/dist/zip/zip-transformer.js +16 -15
  152. package/dist/zip/zip-transformer.js.map +1 -1
  153. package/dist/zip/zip.models.d.ts +2 -2
  154. package/lib/core/config.ts +6 -6
  155. package/lib/core/helpers/workflow-helper.ts +190 -185
  156. package/lib/core/logs/loggers.ts +52 -52
  157. package/lib/core/models/core.models.ts +130 -119
  158. package/lib/core/models/error.models.ts +148 -0
  159. package/lib/core/models/log.models.ts +20 -20
  160. package/lib/core/models/migration.models.ts +54 -57
  161. package/lib/core/models/migration.schema.ts +108 -108
  162. package/lib/core/utils/array.utils.ts +43 -42
  163. package/lib/core/utils/binary-data.utils.ts +16 -16
  164. package/lib/core/utils/confirm.utils.ts +184 -106
  165. package/lib/core/utils/error.utils.ts +69 -72
  166. package/lib/core/utils/external-id.utils.ts +4 -4
  167. package/lib/core/utils/global.utils.ts +81 -75
  168. package/lib/core/utils/http.utils.ts +23 -23
  169. package/lib/core/utils/management-client-utils.ts +189 -186
  170. package/lib/core/utils/processing-utils.ts +82 -82
  171. package/lib/core/utils/run.utils.ts +50 -50
  172. package/lib/core/utils/try.utils.ts +30 -0
  173. package/lib/export/context/export-context-fetcher.ts +472 -447
  174. package/lib/export/export-manager.ts +250 -232
  175. package/lib/export/export.models.ts +71 -56
  176. package/lib/export/utils/export.utils.ts +9 -7
  177. package/lib/file/file-manager.ts +28 -28
  178. package/lib/import/comparers/asset-comparer.ts +107 -106
  179. package/lib/import/context/import-context-fetcher.ts +462 -462
  180. package/lib/import/import-manager.ts +243 -240
  181. package/lib/import/import.models.ts +69 -67
  182. package/lib/import/importers/assets-importer.ts +240 -236
  183. package/lib/import/importers/content-items-importer.ts +126 -122
  184. package/lib/import/importers/language-variant-importer.ts +324 -328
  185. package/lib/import/importers/workflow-importer.ts +372 -367
  186. package/lib/import/utils/import.utils.ts +9 -7
  187. package/lib/index.ts +12 -8
  188. package/lib/metadata.ts +3 -4
  189. package/lib/node/cli/actions/export-action.ts +44 -38
  190. package/lib/node/cli/actions/import-action.ts +32 -29
  191. package/lib/node/cli/actions/migrate-action.ts +50 -46
  192. package/lib/node/cli/app.ts +21 -21
  193. package/lib/node/cli/args/args-fetcher.ts +55 -54
  194. package/lib/node/cli/args/args-setter.ts +34 -32
  195. package/lib/node/cli/cli.models.ts +17 -17
  196. package/lib/node/cli/commands.ts +165 -153
  197. package/lib/toolkit/elements-builder.ts +69 -69
  198. package/lib/toolkit/export.ts +21 -21
  199. package/lib/toolkit/file.ts +59 -53
  200. package/lib/toolkit/import.ts +32 -32
  201. package/lib/toolkit/migrate.ts +60 -49
  202. package/lib/translation/extraction/items-extraction.processor.ts +203 -173
  203. package/lib/translation/helpers/export-placeholder.utils.ts +10 -0
  204. package/lib/translation/helpers/rich-text.processor.ts +311 -311
  205. package/lib/translation/transforms/export-transforms.ts +313 -279
  206. package/lib/translation/transforms/import-transforms.ts +188 -191
  207. package/lib/zip/zip-manager.ts +28 -27
  208. package/lib/zip/zip-packager.ts +75 -73
  209. package/lib/zip/zip-transformer.ts +112 -107
  210. package/lib/zip/zip.models.ts +7 -7
  211. package/package.json +91 -84
  212. package/dist/core/index.d.ts +0 -16
  213. package/dist/core/index.js +0 -17
  214. package/dist/core/index.js.map +0 -1
  215. package/dist/export/index.d.ts +0 -2
  216. package/dist/export/index.js +0 -3
  217. package/dist/export/index.js.map +0 -1
  218. package/dist/file/index.d.ts +0 -1
  219. package/dist/file/index.js +0 -2
  220. package/dist/file/index.js.map +0 -1
  221. package/dist/import/index.d.ts +0 -2
  222. package/dist/import/index.js +0 -3
  223. package/dist/import/index.js.map +0 -1
  224. package/dist/toolkit/index.d.ts +0 -5
  225. package/dist/toolkit/index.js +0 -6
  226. package/dist/toolkit/index.js.map +0 -1
  227. package/dist/translation/index.d.ts +0 -4
  228. package/dist/translation/index.js +0 -5
  229. package/dist/translation/index.js.map +0 -1
  230. package/dist/zip/index.d.ts +0 -4
  231. package/dist/zip/index.js +0 -5
  232. package/dist/zip/index.js.map +0 -1
  233. package/lib/core/index.ts +0 -18
  234. package/lib/export/index.ts +0 -2
  235. package/lib/file/index.ts +0 -1
  236. package/lib/import/index.ts +0 -2
  237. package/lib/toolkit/index.ts +0 -5
  238. package/lib/translation/index.ts +0 -4
  239. package/lib/zip/index.ts +0 -4
@@ -1,158 +1,170 @@
1
- import { argumentsSetter } from './args/args-setter.js';
1
+ import { argumentsSetter } from "./args/args-setter.js";
2
2
 
3
3
  export const cliArgs = argumentsSetter()
4
- .withCommand({
5
- name: 'export',
6
- description: 'Exports content (items & assets) from Kontent.ai environment',
7
- examples: [`kontent-ai-migration-toolkit export --sourceEnvironmentId=x --sourceApiKey=x --language=default --items=itemA,itemB`],
8
- options: [
9
- {
10
- name: `sourceApiKey`,
11
- description: `Api key used for request authorization`,
12
- type: 'string',
13
- isRequired: true
14
- },
15
- {
16
- name: `sourceEnvironmentId`,
17
- description: `Environment id of the source environment`,
18
- type: 'string',
19
- isRequired: true
20
- },
21
- {
22
- name: `language`,
23
- description: `Language codename of items to export`,
24
- type: 'string',
25
- isRequired: true
26
- },
27
- {
28
- name: `items`,
29
- description: `Comma separated item codenames to export`,
30
- type: 'string',
31
- isRequired: true
32
- },
33
- {
34
- name: `filename`,
35
- description: `Name of items file to export / import`,
36
- type: 'string',
37
- isRequired: false
38
- },
39
- {
40
- name: `assetsFilename`,
41
- description: `Name of assets file to export / import`,
42
- type: 'string',
43
- isRequired: false
44
- },
45
- {
46
- name: `baseUrl`,
47
- description: `Custom base URL`,
48
- type: 'string',
49
- isRequired: false
50
- }
51
- ]
52
- })
4
+ .withCommand({
5
+ name: "export",
6
+ description: "Exports content (items & assets) from Kontent.ai environment",
7
+ examples: [`kontent-ai-migration-toolkit export --sourceEnvironmentId=x --sourceApiKey=x --language=default --items=itemA,itemB`],
8
+ options: [
9
+ {
10
+ name: `sourceApiKey`,
11
+ description: `Api key used for request authorization`,
12
+ type: "string",
13
+ isRequired: true,
14
+ },
15
+ {
16
+ name: `sourceEnvironmentId`,
17
+ description: `Environment id of the source environment`,
18
+ type: "string",
19
+ isRequired: true,
20
+ },
21
+ {
22
+ name: `language`,
23
+ description: `Language codename of items to export`,
24
+ type: "string",
25
+ isRequired: true,
26
+ },
27
+ {
28
+ name: `items`,
29
+ description: `Comma separated item codenames to export`,
30
+ type: "string",
31
+ isRequired: true,
32
+ },
33
+ {
34
+ name: `filename`,
35
+ description: `Name of items file to export / import`,
36
+ type: "string",
37
+ isRequired: false,
38
+ },
39
+ {
40
+ name: `assetsFilename`,
41
+ description: `Name of assets file to export / import`,
42
+ type: "string",
43
+ isRequired: false,
44
+ },
45
+ {
46
+ name: `baseUrl`,
47
+ description: `Custom base URL`,
48
+ type: "string",
49
+ isRequired: false,
50
+ },
51
+ {
52
+ name: `skipMissingReferences`,
53
+ description: `When enabled, missing items and assets will be skipped instead of throwing errors`,
54
+ type: "boolean",
55
+ isRequired: false,
56
+ },
57
+ ],
58
+ })
53
59
 
54
- .withCommand({
55
- name: 'import',
56
- description: 'Imports content (items & assets) into Kontent.ai environment',
57
- examples: [
58
- `kontent-ai-migration-toolkit import --targetEnvironmentId=x --targetApiKey=x --filename=items.zip --assetsFilename=assets.zip`
59
- ],
60
- options: [
61
- {
62
- name: `targetApiKey`,
63
- description: `Api key used for request authorization`,
64
- type: 'string',
65
- isRequired: true
66
- },
67
- {
68
- name: `targetEnvironmentId`,
69
- description: `Environment id of the target environment`,
70
- type: 'string',
71
- isRequired: true
72
- },
73
- {
74
- name: `filename`,
75
- description: `Name of items file to export / import`,
76
- type: 'string',
77
- isRequired: false
78
- },
79
- {
80
- name: `assetsFilename`,
81
- description: `Name of assets file to export / import`,
82
- type: 'string',
83
- isRequired: false
84
- },
85
- {
86
- name: `baseUrl`,
87
- description: `Custom base URL`,
88
- type: 'string',
89
- isRequired: false
90
- }
91
- ]
92
- })
60
+ .withCommand({
61
+ name: "import",
62
+ description: "Imports content (items & assets) into Kontent.ai environment",
63
+ examples: [
64
+ `kontent-ai-migration-toolkit import --targetEnvironmentId=x --targetApiKey=x --filename=items.zip --assetsFilename=assets.zip`,
65
+ ],
66
+ options: [
67
+ {
68
+ name: `targetApiKey`,
69
+ description: `Api key used for request authorization`,
70
+ type: "string",
71
+ isRequired: true,
72
+ },
73
+ {
74
+ name: `targetEnvironmentId`,
75
+ description: `Environment id of the target environment`,
76
+ type: "string",
77
+ isRequired: true,
78
+ },
79
+ {
80
+ name: `filename`,
81
+ description: `Name of items file to export / import`,
82
+ type: "string",
83
+ isRequired: false,
84
+ },
85
+ {
86
+ name: `assetsFilename`,
87
+ description: `Name of assets file to export / import`,
88
+ type: "string",
89
+ isRequired: false,
90
+ },
91
+ {
92
+ name: `baseUrl`,
93
+ description: `Custom base URL`,
94
+ type: "string",
95
+ isRequired: false,
96
+ },
97
+ ],
98
+ })
93
99
 
94
- .withCommand({
95
- name: 'migrate',
96
- description: 'Migrates content (items & assets) from one Kontent.ai environment into another Kontent.ai environment',
97
- examples: [
98
- `kontent-ai-migration-toolkit migrate --targetEnvironmentId=x --targetApiKey=x --sourceEnvironmentId=x --sourceApiKey=x --language=default --items=itemA,itemB`
99
- ],
100
- options: [
101
- {
102
- name: `sourceApiKey`,
103
- description: `Api key used for request authorization`,
104
- type: 'string',
105
- isRequired: true
106
- },
107
- {
108
- name: `sourceEnvironmentId`,
109
- description: `Environment id of the source environment`,
110
- type: 'string',
111
- isRequired: true
112
- },
113
- {
114
- name: `language`,
115
- description: `Language codename of items to export`,
116
- type: 'string',
117
- isRequired: true
118
- },
119
- {
120
- name: `items`,
121
- description: `Comma separated item codenames to export`,
122
- type: 'string',
123
- isRequired: true
124
- },
125
- {
126
- name: `targetApiKey`,
127
- description: `Api key used for request authorization`,
128
- type: 'string',
129
- isRequired: true
130
- },
131
- {
132
- name: `targetEnvironmentId`,
133
- description: `Environment id of the target environment`,
134
- type: 'string',
135
- isRequired: true
136
- },
137
- {
138
- name: `baseUrl`,
139
- description: `Custom base URL`,
140
- type: 'string',
141
- isRequired: false
142
- }
143
- ]
144
- })
100
+ .withCommand({
101
+ name: "migrate",
102
+ description: "Migrates content (items & assets) from one Kontent.ai environment into another Kontent.ai environment",
103
+ examples: [
104
+ `kontent-ai-migration-toolkit migrate --targetEnvironmentId=x --targetApiKey=x --sourceEnvironmentId=x --sourceApiKey=x --language=default --items=itemA,itemB`,
105
+ ],
106
+ options: [
107
+ {
108
+ name: `sourceApiKey`,
109
+ description: `Api key used for request authorization`,
110
+ type: "string",
111
+ isRequired: true,
112
+ },
113
+ {
114
+ name: `sourceEnvironmentId`,
115
+ description: `Environment id of the source environment`,
116
+ type: "string",
117
+ isRequired: true,
118
+ },
119
+ {
120
+ name: `language`,
121
+ description: `Language codename of items to export`,
122
+ type: "string",
123
+ isRequired: true,
124
+ },
125
+ {
126
+ name: `items`,
127
+ description: `Comma separated item codenames to export`,
128
+ type: "string",
129
+ isRequired: true,
130
+ },
131
+ {
132
+ name: `targetApiKey`,
133
+ description: `Api key used for request authorization`,
134
+ type: "string",
135
+ isRequired: true,
136
+ },
137
+ {
138
+ name: `targetEnvironmentId`,
139
+ description: `Environment id of the target environment`,
140
+ type: "string",
141
+ isRequired: true,
142
+ },
143
+ {
144
+ name: `baseUrl`,
145
+ description: `Custom base URL`,
146
+ type: "string",
147
+ isRequired: false,
148
+ },
149
+ {
150
+ name: `skipMissingReferences`,
151
+ description: `When enabled, missing items and assets will be skipped instead of throwing errors`,
152
+ type: "boolean",
153
+ isRequired: false,
154
+ },
155
+ ],
156
+ })
145
157
 
146
- .withOption({
147
- alias: `f`,
148
- name: `force`,
149
- description: `When enabled, confirmation is not required`,
150
- type: 'boolean',
151
- isRequired: false
152
- })
153
- .withOption({
154
- alias: `h`,
155
- name: `help`,
156
- description: `Show help`,
157
- isRequired: false
158
- });
158
+ .withOption({
159
+ alias: `f`,
160
+ name: `force`,
161
+ description: `When enabled, confirmation is not required`,
162
+ type: "boolean",
163
+ isRequired: false,
164
+ })
165
+ .withOption({
166
+ alias: `h`,
167
+ name: `help`,
168
+ description: `Show help`,
169
+ isRequired: false,
170
+ });
@@ -1,72 +1,72 @@
1
- import type { MigrationElementModels } from '../core/index.js';
1
+ import type { MigrationElementModels } from "../core/models/migration.models.js";
2
2
 
3
3
  export const elementsBuilder = {
4
- textElement: (data: Omit<MigrationElementModels.TextElement, 'type'>): MigrationElementModels.TextElement => {
5
- return {
6
- ...data,
7
- type: 'text'
8
- };
9
- },
10
- assetElement: (data: Omit<MigrationElementModels.AssetElement, 'type'>): MigrationElementModels.AssetElement => {
11
- return {
12
- ...data,
13
- type: 'asset'
14
- };
15
- },
16
- customElement: (data: Omit<MigrationElementModels.CustomElement, 'type'>): MigrationElementModels.CustomElement => {
17
- return {
18
- ...data,
19
- type: 'custom'
20
- };
21
- },
22
- dateTimeElement: (data: Omit<MigrationElementModels.DateTimeElement, 'type'>): MigrationElementModels.DateTimeElement => {
23
- return {
24
- ...data,
25
- type: 'date_time'
26
- };
27
- },
28
- linkedItemsElement: (data: Omit<MigrationElementModels.LinkedItemsElement, 'type'>): MigrationElementModels.LinkedItemsElement => {
29
- return {
30
- ...data,
31
- type: 'modular_content'
32
- };
33
- },
34
- multipleChoiceElement: (
35
- data: Omit<MigrationElementModels.MultipleChoiceElement, 'type'>
36
- ): MigrationElementModels.MultipleChoiceElement => {
37
- return {
38
- ...data,
39
- type: 'multiple_choice'
40
- };
41
- },
42
- numberElement: (data: Omit<MigrationElementModels.NumberElement, 'type'>): MigrationElementModels.NumberElement => {
43
- return {
44
- ...data,
45
- type: 'number'
46
- };
47
- },
48
- richTextElement: (data: Omit<MigrationElementModels.RichTextElement, 'type'>): MigrationElementModels.RichTextElement => {
49
- return {
50
- ...data,
51
- type: 'rich_text'
52
- };
53
- },
54
- subpagesElement: (data: Omit<MigrationElementModels.SubpagesElement, 'type'>): MigrationElementModels.SubpagesElement => {
55
- return {
56
- ...data,
57
- type: 'subpages'
58
- };
59
- },
60
- taxonomyElement: (data: Omit<MigrationElementModels.TaxonomyElement, 'type'>): MigrationElementModels.TaxonomyElement => {
61
- return {
62
- ...data,
63
- type: 'taxonomy'
64
- };
65
- },
66
- urlSlugElement: (data: Omit<MigrationElementModels.UrlSlugElement, 'type'>): MigrationElementModels.UrlSlugElement => {
67
- return {
68
- ...data,
69
- type: 'url_slug'
70
- };
71
- }
4
+ textElement: (data: Omit<MigrationElementModels.TextElement, "type">): MigrationElementModels.TextElement => {
5
+ return {
6
+ ...data,
7
+ type: "text",
8
+ };
9
+ },
10
+ assetElement: (data: Omit<MigrationElementModels.AssetElement, "type">): MigrationElementModels.AssetElement => {
11
+ return {
12
+ ...data,
13
+ type: "asset",
14
+ };
15
+ },
16
+ customElement: (data: Omit<MigrationElementModels.CustomElement, "type">): MigrationElementModels.CustomElement => {
17
+ return {
18
+ ...data,
19
+ type: "custom",
20
+ };
21
+ },
22
+ dateTimeElement: (data: Omit<MigrationElementModels.DateTimeElement, "type">): MigrationElementModels.DateTimeElement => {
23
+ return {
24
+ ...data,
25
+ type: "date_time",
26
+ };
27
+ },
28
+ linkedItemsElement: (data: Omit<MigrationElementModels.LinkedItemsElement, "type">): MigrationElementModels.LinkedItemsElement => {
29
+ return {
30
+ ...data,
31
+ type: "modular_content",
32
+ };
33
+ },
34
+ multipleChoiceElement: (
35
+ data: Omit<MigrationElementModels.MultipleChoiceElement, "type">,
36
+ ): MigrationElementModels.MultipleChoiceElement => {
37
+ return {
38
+ ...data,
39
+ type: "multiple_choice",
40
+ };
41
+ },
42
+ numberElement: (data: Omit<MigrationElementModels.NumberElement, "type">): MigrationElementModels.NumberElement => {
43
+ return {
44
+ ...data,
45
+ type: "number",
46
+ };
47
+ },
48
+ richTextElement: (data: Omit<MigrationElementModels.RichTextElement, "type">): MigrationElementModels.RichTextElement => {
49
+ return {
50
+ ...data,
51
+ type: "rich_text",
52
+ };
53
+ },
54
+ subpagesElement: (data: Omit<MigrationElementModels.SubpagesElement, "type">): MigrationElementModels.SubpagesElement => {
55
+ return {
56
+ ...data,
57
+ type: "subpages",
58
+ };
59
+ },
60
+ taxonomyElement: (data: Omit<MigrationElementModels.TaxonomyElement, "type">): MigrationElementModels.TaxonomyElement => {
61
+ return {
62
+ ...data,
63
+ type: "taxonomy",
64
+ };
65
+ },
66
+ urlSlugElement: (data: Omit<MigrationElementModels.UrlSlugElement, "type">): MigrationElementModels.UrlSlugElement => {
67
+ return {
68
+ ...data,
69
+ type: "url_slug",
70
+ };
71
+ },
72
72
  };
@@ -1,24 +1,24 @@
1
- import type { MigrationData } from '../core/index.js';
2
- import { executeWithTrackingAsync } from '../core/index.js';
3
- import type { ExportConfig } from '../export/index.js';
4
- import { exportManager } from '../export/index.js';
5
- import { libMetadata } from '../metadata.js';
1
+ import type { MigrationData } from "../core/models/migration.models.js";
2
+ import { executeWithTrackingAsync } from "../core/utils/global.utils.js";
3
+ import type { ExportConfig } from "../export/export.models.js";
4
+ import { exportManager } from "../export/export-manager.js";
5
+ import { libMetadata } from "../metadata.js";
6
6
 
7
7
  export async function exportAsync(config: ExportConfig): Promise<MigrationData> {
8
- return await executeWithTrackingAsync({
9
- event: {
10
- tool: 'migrationToolkit',
11
- package: {
12
- name: libMetadata.name,
13
- version: libMetadata.version
14
- },
15
- action: 'export',
16
- relatedEnvironmentId: undefined,
17
- details: {}
18
- },
19
- func: async () => {
20
- return await exportManager(config).exportAsync();
21
- },
22
- logger: config.logger
23
- });
8
+ return await executeWithTrackingAsync({
9
+ event: {
10
+ tool: "migrationToolkit",
11
+ package: {
12
+ name: libMetadata.name,
13
+ version: libMetadata.version,
14
+ },
15
+ action: "export",
16
+ relatedEnvironmentId: undefined,
17
+ details: {},
18
+ },
19
+ func: async () => {
20
+ return await exportManager(config).exportAsync();
21
+ },
22
+ logger: config.logger,
23
+ });
24
24
  }
@@ -1,68 +1,74 @@
1
- import { Buffer as BufferProxy } from 'buffer';
2
- import type { Logger, MigrationData } from '../core/index.js';
3
- import { defaultZipFilename, executeWithTrackingAsync, getDefaultLogger } from '../core/index.js';
4
- import { fileManager } from '../file/index.js';
5
- import { libMetadata } from '../metadata.js';
6
- import { zipManager } from '../zip/index.js';
1
+ import { Buffer as BufferProxy } from "buffer";
2
+ import { getDefaultLogger } from "../core/logs/loggers.js";
3
+ import { MigrationToolkitError } from "../core/models/error.models.js";
4
+ import type { Logger } from "../core/models/log.models.js";
5
+ import type { MigrationData } from "../core/models/migration.models.js";
6
+ import { defaultZipFilename, executeWithTrackingAsync } from "../core/utils/global.utils.js";
7
+ import { fileManager } from "../file/file-manager.js";
8
+ import { libMetadata } from "../metadata.js";
9
+ import { zipManager } from "../zip/zip-manager.js";
7
10
 
8
11
  export interface StoreConfig {
9
- readonly data: MigrationData;
10
- readonly filename?: string;
11
- readonly logger?: Logger;
12
+ readonly data: MigrationData;
13
+ readonly filename?: string;
14
+ readonly logger?: Logger;
12
15
  }
13
16
 
14
17
  export interface ExtractConfig {
15
- readonly filename?: string;
16
- readonly logger?: Logger;
18
+ readonly filename?: string;
19
+ readonly logger?: Logger;
17
20
  }
18
21
 
19
22
  export async function storeAsync(config: StoreConfig): Promise<void> {
20
- const logger = config.logger ?? getDefaultLogger();
21
- const filename = config.filename ?? defaultZipFilename;
23
+ const logger = config.logger ?? getDefaultLogger();
24
+ const filename = config.filename ?? defaultZipFilename;
22
25
 
23
- await executeWithTrackingAsync<void>({
24
- event: {
25
- tool: 'migrationToolkit',
26
- package: {
27
- name: libMetadata.name,
28
- version: libMetadata.version
29
- },
30
- action: 'store',
31
- relatedEnvironmentId: undefined,
32
- details: {}
33
- },
34
- func: async () => {
35
- const zipData = await zipManager(logger).createZipAsync(config.data);
26
+ await executeWithTrackingAsync<void>({
27
+ event: {
28
+ tool: "migrationToolkit",
29
+ package: {
30
+ name: libMetadata.name,
31
+ version: libMetadata.version,
32
+ },
33
+ action: "store",
34
+ relatedEnvironmentId: undefined,
35
+ details: {},
36
+ },
37
+ func: async () => {
38
+ const zipData = await zipManager(logger).createZipAsync(config.data);
36
39
 
37
- if (zipData instanceof BufferProxy) {
38
- await fileManager(logger).writeFileAsync(filename, zipData);
39
- } else {
40
- throw Error(`Cannot store '${filename}' on File system because the provided zip is not a Buffer`);
41
- }
42
- },
43
- logger: config.logger
44
- });
40
+ if (zipData instanceof BufferProxy) {
41
+ await fileManager(logger).writeFileAsync(filename, zipData);
42
+ } else {
43
+ throw new MigrationToolkitError(
44
+ "invalidZip",
45
+ `Cannot store '${filename}' on File system because the provided zip is not a Buffer`,
46
+ );
47
+ }
48
+ },
49
+ logger: config.logger,
50
+ });
45
51
  }
46
52
 
47
53
  export async function extractAsync(config: ExtractConfig): Promise<MigrationData> {
48
- const logger = config.logger ?? getDefaultLogger();
49
- const filename = config.filename ?? defaultZipFilename;
54
+ const logger = config.logger ?? getDefaultLogger();
55
+ const filename = config.filename ?? defaultZipFilename;
50
56
 
51
- return await executeWithTrackingAsync({
52
- event: {
53
- tool: 'migrationToolkit',
54
- package: {
55
- name: libMetadata.name,
56
- version: libMetadata.version
57
- },
58
- action: 'extract',
59
- relatedEnvironmentId: undefined,
60
- details: {}
61
- },
62
- func: async () => {
63
- const fileData = await fileManager(logger).loadFileAsync(filename);
64
- return await zipManager(logger).parseZipAsync(fileData);
65
- },
66
- logger: config.logger
67
- });
57
+ return await executeWithTrackingAsync({
58
+ event: {
59
+ tool: "migrationToolkit",
60
+ package: {
61
+ name: libMetadata.name,
62
+ version: libMetadata.version,
63
+ },
64
+ action: "extract",
65
+ relatedEnvironmentId: undefined,
66
+ details: {},
67
+ },
68
+ func: async () => {
69
+ const fileData = await fileManager(logger).loadFileAsync(filename);
70
+ return await zipManager(logger).parseZipAsync(fileData);
71
+ },
72
+ logger: config.logger,
73
+ });
68
74
  }