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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (235) 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 +27 -22
  11. package/dist/core/models/error.models.d.ts +14 -0
  12. package/dist/core/models/error.models.js +25 -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 +14 -14
  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 +1 -1
  26. package/dist/core/utils/confirm.utils.js +21 -20
  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 +34 -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/export/context/export-context-fetcher.d.ts +1 -1
  49. package/dist/export/context/export-context-fetcher.js +92 -62
  50. package/dist/export/context/export-context-fetcher.js.map +1 -1
  51. package/dist/export/export-manager.d.ts +2 -2
  52. package/dist/export/export-manager.js +46 -37
  53. package/dist/export/export-manager.js.map +1 -1
  54. package/dist/export/export.models.d.ts +21 -2
  55. package/dist/export/utils/export.utils.d.ts +1 -1
  56. package/dist/export/utils/export.utils.js +3 -2
  57. package/dist/export/utils/export.utils.js.map +1 -1
  58. package/dist/file/file-manager.d.ts +2 -2
  59. package/dist/file/file-manager.js +7 -7
  60. package/dist/file/file-manager.js.map +1 -1
  61. package/dist/import/comparers/asset-comparer.d.ts +2 -2
  62. package/dist/import/comparers/asset-comparer.js +12 -11
  63. package/dist/import/comparers/asset-comparer.js.map +1 -1
  64. package/dist/import/context/import-context-fetcher.d.ts +1 -1
  65. package/dist/import/context/import-context-fetcher.js +77 -73
  66. package/dist/import/context/import-context-fetcher.js.map +1 -1
  67. package/dist/import/import-manager.d.ts +1 -1
  68. package/dist/import/import-manager.js +59 -56
  69. package/dist/import/import-manager.js.map +1 -1
  70. package/dist/import/import.models.d.ts +6 -2
  71. package/dist/import/importers/assets-importer.d.ts +3 -3
  72. package/dist/import/importers/assets-importer.js +46 -43
  73. package/dist/import/importers/assets-importer.js.map +1 -1
  74. package/dist/import/importers/content-items-importer.d.ts +3 -3
  75. package/dist/import/importers/content-items-importer.js +28 -25
  76. package/dist/import/importers/content-items-importer.js.map +1 -1
  77. package/dist/import/importers/language-variant-importer.d.ts +3 -3
  78. package/dist/import/importers/language-variant-importer.js +45 -45
  79. package/dist/import/importers/language-variant-importer.js.map +1 -1
  80. package/dist/import/importers/workflow-importer.d.ts +3 -2
  81. package/dist/import/importers/workflow-importer.js +58 -54
  82. package/dist/import/importers/workflow-importer.js.map +1 -1
  83. package/dist/import/utils/import.utils.d.ts +1 -1
  84. package/dist/import/utils/import.utils.js +3 -2
  85. package/dist/import/utils/import.utils.js.map +1 -1
  86. package/dist/index.d.ts +11 -7
  87. package/dist/index.js +10 -8
  88. package/dist/index.js.map +1 -1
  89. package/dist/metadata.js +3 -3
  90. package/dist/metadata.js.map +1 -1
  91. package/dist/node/cli/actions/export-action.d.ts +1 -1
  92. package/dist/node/cli/actions/export-action.js +28 -23
  93. package/dist/node/cli/actions/export-action.js.map +1 -1
  94. package/dist/node/cli/actions/import-action.d.ts +1 -1
  95. package/dist/node/cli/actions/import-action.js +15 -12
  96. package/dist/node/cli/actions/import-action.js.map +1 -1
  97. package/dist/node/cli/actions/migrate-action.d.ts +1 -1
  98. package/dist/node/cli/actions/migrate-action.js +25 -22
  99. package/dist/node/cli/actions/migrate-action.js.map +1 -1
  100. package/dist/node/cli/app.js +13 -12
  101. package/dist/node/cli/app.js.map +1 -1
  102. package/dist/node/cli/args/args-fetcher.d.ts +1 -1
  103. package/dist/node/cli/args/args-fetcher.js +14 -13
  104. package/dist/node/cli/args/args-fetcher.js.map +1 -1
  105. package/dist/node/cli/args/args-setter.d.ts +1 -1
  106. package/dist/node/cli/args/args-setter.js +8 -6
  107. package/dist/node/cli/args/args-setter.js.map +1 -1
  108. package/dist/node/cli/cli.models.d.ts +2 -2
  109. package/dist/node/cli/commands.js +68 -56
  110. package/dist/node/cli/commands.js.map +1 -1
  111. package/dist/toolkit/elements-builder.d.ts +1 -1
  112. package/dist/toolkit/elements-builder.js +12 -12
  113. package/dist/toolkit/elements-builder.js.map +1 -1
  114. package/dist/toolkit/export.d.ts +2 -2
  115. package/dist/toolkit/export.js +8 -8
  116. package/dist/toolkit/export.js.map +1 -1
  117. package/dist/toolkit/file.d.ts +2 -1
  118. package/dist/toolkit/file.js +18 -16
  119. package/dist/toolkit/file.js.map +1 -1
  120. package/dist/toolkit/import.d.ts +1 -1
  121. package/dist/toolkit/import.js +12 -12
  122. package/dist/toolkit/import.js.map +1 -1
  123. package/dist/toolkit/migrate.d.ts +13 -4
  124. package/dist/toolkit/migrate.js +15 -13
  125. package/dist/toolkit/migrate.js.map +1 -1
  126. package/dist/translation/extraction/items-extraction.processor.d.ts +5 -4
  127. package/dist/translation/extraction/items-extraction.processor.js +73 -35
  128. package/dist/translation/extraction/items-extraction.processor.js.map +1 -1
  129. package/dist/translation/helpers/export-placeholder.utils.d.ts +11 -0
  130. package/dist/translation/helpers/export-placeholder.utils.js +11 -0
  131. package/dist/translation/helpers/export-placeholder.utils.js.map +1 -0
  132. package/dist/translation/helpers/rich-text.processor.d.ts +6 -6
  133. package/dist/translation/helpers/rich-text.processor.js +38 -38
  134. package/dist/translation/helpers/rich-text.processor.js.map +1 -1
  135. package/dist/translation/transforms/export-transforms.d.ts +2 -2
  136. package/dist/translation/transforms/export-transforms.js +93 -67
  137. package/dist/translation/transforms/export-transforms.js.map +1 -1
  138. package/dist/translation/transforms/import-transforms.d.ts +2 -2
  139. package/dist/translation/transforms/import-transforms.js +38 -40
  140. package/dist/translation/transforms/import-transforms.js.map +1 -1
  141. package/dist/zip/zip-manager.d.ts +4 -3
  142. package/dist/zip/zip-manager.js +9 -9
  143. package/dist/zip/zip-manager.js.map +1 -1
  144. package/dist/zip/zip-packager.d.ts +2 -2
  145. package/dist/zip/zip-packager.js +19 -17
  146. package/dist/zip/zip-packager.js.map +1 -1
  147. package/dist/zip/zip-transformer.d.ts +3 -2
  148. package/dist/zip/zip-transformer.js +16 -15
  149. package/dist/zip/zip-transformer.js.map +1 -1
  150. package/dist/zip/zip.models.d.ts +2 -2
  151. package/lib/core/config.ts +6 -6
  152. package/lib/core/helpers/workflow-helper.ts +190 -185
  153. package/lib/core/logs/loggers.ts +52 -52
  154. package/lib/core/models/core.models.ts +128 -119
  155. package/lib/core/models/error.models.ts +41 -0
  156. package/lib/core/models/log.models.ts +20 -20
  157. package/lib/core/models/migration.models.ts +54 -54
  158. package/lib/core/models/migration.schema.ts +108 -108
  159. package/lib/core/utils/array.utils.ts +43 -42
  160. package/lib/core/utils/binary-data.utils.ts +16 -16
  161. package/lib/core/utils/confirm.utils.ts +106 -105
  162. package/lib/core/utils/error.utils.ts +69 -72
  163. package/lib/core/utils/external-id.utils.ts +4 -4
  164. package/lib/core/utils/global.utils.ts +81 -75
  165. package/lib/core/utils/http.utils.ts +23 -23
  166. package/lib/core/utils/management-client-utils.ts +186 -186
  167. package/lib/core/utils/processing-utils.ts +82 -82
  168. package/lib/core/utils/run.utils.ts +50 -50
  169. package/lib/export/context/export-context-fetcher.ts +472 -447
  170. package/lib/export/export-manager.ts +233 -232
  171. package/lib/export/export.models.ts +71 -56
  172. package/lib/export/utils/export.utils.ts +9 -7
  173. package/lib/file/file-manager.ts +28 -28
  174. package/lib/import/comparers/asset-comparer.ts +107 -106
  175. package/lib/import/context/import-context-fetcher.ts +462 -462
  176. package/lib/import/import-manager.ts +243 -240
  177. package/lib/import/import.models.ts +69 -67
  178. package/lib/import/importers/assets-importer.ts +240 -236
  179. package/lib/import/importers/content-items-importer.ts +126 -122
  180. package/lib/import/importers/language-variant-importer.ts +324 -328
  181. package/lib/import/importers/workflow-importer.ts +372 -367
  182. package/lib/import/utils/import.utils.ts +9 -7
  183. package/lib/index.ts +12 -8
  184. package/lib/metadata.ts +3 -4
  185. package/lib/node/cli/actions/export-action.ts +43 -38
  186. package/lib/node/cli/actions/import-action.ts +32 -29
  187. package/lib/node/cli/actions/migrate-action.ts +49 -46
  188. package/lib/node/cli/app.ts +21 -21
  189. package/lib/node/cli/args/args-fetcher.ts +55 -54
  190. package/lib/node/cli/args/args-setter.ts +34 -32
  191. package/lib/node/cli/cli.models.ts +17 -17
  192. package/lib/node/cli/commands.ts +165 -153
  193. package/lib/toolkit/elements-builder.ts +69 -69
  194. package/lib/toolkit/export.ts +21 -21
  195. package/lib/toolkit/file.ts +59 -53
  196. package/lib/toolkit/import.ts +32 -32
  197. package/lib/toolkit/migrate.ts +60 -49
  198. package/lib/translation/extraction/items-extraction.processor.ts +203 -173
  199. package/lib/translation/helpers/export-placeholder.utils.ts +10 -0
  200. package/lib/translation/helpers/rich-text.processor.ts +311 -311
  201. package/lib/translation/transforms/export-transforms.ts +313 -279
  202. package/lib/translation/transforms/import-transforms.ts +188 -191
  203. package/lib/zip/zip-manager.ts +28 -27
  204. package/lib/zip/zip-packager.ts +75 -73
  205. package/lib/zip/zip-transformer.ts +112 -107
  206. package/lib/zip/zip.models.ts +7 -7
  207. package/package.json +91 -84
  208. package/dist/core/index.d.ts +0 -16
  209. package/dist/core/index.js +0 -17
  210. package/dist/core/index.js.map +0 -1
  211. package/dist/export/index.d.ts +0 -2
  212. package/dist/export/index.js +0 -3
  213. package/dist/export/index.js.map +0 -1
  214. package/dist/file/index.d.ts +0 -1
  215. package/dist/file/index.js +0 -2
  216. package/dist/file/index.js.map +0 -1
  217. package/dist/import/index.d.ts +0 -2
  218. package/dist/import/index.js +0 -3
  219. package/dist/import/index.js.map +0 -1
  220. package/dist/toolkit/index.d.ts +0 -5
  221. package/dist/toolkit/index.js +0 -6
  222. package/dist/toolkit/index.js.map +0 -1
  223. package/dist/translation/index.d.ts +0 -4
  224. package/dist/translation/index.js +0 -5
  225. package/dist/translation/index.js.map +0 -1
  226. package/dist/zip/index.d.ts +0 -4
  227. package/dist/zip/index.js +0 -5
  228. package/dist/zip/index.js.map +0 -1
  229. package/lib/core/index.ts +0 -18
  230. package/lib/export/index.ts +0 -2
  231. package/lib/file/index.ts +0 -1
  232. package/lib/import/index.ts +0 -2
  233. package/lib/toolkit/index.ts +0 -5
  234. package/lib/translation/index.ts +0 -4
  235. package/lib/zip/index.ts +0 -4
package/README.md CHANGED
@@ -47,15 +47,16 @@ You may migrate content (items & asset) between Kontent.ai environments. For mig
47
47
 
48
48
  ## Configuration
49
49
 
50
- | Config | Value |
51
- | ----------------------- | ----------------------------------------------------------------------------------------------------- |
52
- | **sourceEnvironmentId** | Id of source environment **(required)** |
53
- | **sourceApiKey** | Management API key of source environment **(required)** |
54
- | **targetEnvironmentId** | Id of target environment **(required)** |
55
- | **targetApiKey** | Management API key of target environment **(required)** |
56
- | **language** | Codename of language that items will be exported in **(required)** |
57
- | **items** | Comma separated list of items that will be exported **(required)** |
58
- | force | Can be used to disable confirmation prompts. Available options: `true` & `false`. Defaults to `false` |
50
+ | Config | Value |
51
+ | ----------------------------- | ----------------------------------------------------------------------------------------------------- |
52
+ | **sourceEnvironmentId** | Id of source environment **(required)** |
53
+ | **sourceApiKey** | Management API key of source environment **(required)** |
54
+ | **targetEnvironmentId** | Id of target environment **(required)** |
55
+ | **targetApiKey** | Management API key of target environment **(required)** |
56
+ | **language** | Codename of language that items will be exported in **(required)** |
57
+ | **items** | Comma separated list of items that will be exported **(required)** |
58
+ | force | Can be used to disable confirmation prompts. Available options: `true` & `false`. Defaults to `false` |
59
+ | skipMissingReferences | When enabled, missing items and assets will be skipped instead of throwing errors. Missing references will be filtered out from exported data. Available options: `true` & `false`. Defaults to `false` |
59
60
 
60
61
  ## Migrate CLI
61
62
 
@@ -100,14 +101,15 @@ you typically only use the `import` capabilities of this repository.
100
101
 
101
102
  ## Configuration
102
103
 
103
- | Config | Value |
104
- | ----------------------- | ------------------------------------------------------------------ |
105
- | **sourceEnvironmentId** | Id of Kontent.ai environment **(required)** |
106
- | **sourceApiKey** | Management API key of Kontent.ai environment **(required)** |
107
- | **language** | Codename of language that items will be exported in **(required)** |
108
- | **items** | Comma separated list of items that will be exported **(required)** |
109
- | filename | Name of the zip file |
110
- | baseUrl | Custom base URL for Kontent.ai API calls |
104
+ | Config | Value |
105
+ | ----------------------------- | --------------------------------------------------------------------------------------------------- |
106
+ | **sourceEnvironmentId** | Id of Kontent.ai environment **(required)** |
107
+ | **sourceApiKey** | Management API key of Kontent.ai environment **(required)** |
108
+ | **language** | Codename of language that items will be exported in **(required)** |
109
+ | **items** | Comma separated list of items that will be exported **(required)** |
110
+ | filename | Name of the zip file |
111
+ | baseUrl | Custom base URL for Kontent.ai API calls |
112
+ | skipMissingReferences | When enabled, missing items and assets will be skipped. Available options: `true` & `false`. Defaults to `false` |
111
113
 
112
114
  ## Export CLI
113
115
 
@@ -1,6 +1,6 @@
1
- import { libMetadata } from '../metadata.js';
1
+ import { libMetadata } from "../metadata.js";
2
2
  export const coreConfig = {
3
- kontentTrackingHeaderName: 'X-KC-SOURCE',
4
- kontentTrackingHeaderValue: `${libMetadata.name};${libMetadata.version}`
3
+ kontentTrackingHeaderName: "X-KC-SOURCE",
4
+ kontentTrackingHeaderValue: `${libMetadata.name};${libMetadata.version}`,
5
5
  };
6
6
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../lib/core/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,CAAC,MAAM,UAAU,GAAG;IACtB,yBAAyB,EAAE,aAAa;IACxC,0BAA0B,EAAE,GAAG,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,OAAO,EAAE;CAClE,CAAC"}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../lib/core/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,CAAC,MAAM,UAAU,GAAG;IACzB,yBAAyB,EAAE,aAAa;IACxC,0BAA0B,EAAE,GAAG,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,OAAO,EAAE;CAC/D,CAAC"}
@@ -1,4 +1,4 @@
1
- import type { WorkflowModels } from '@kontent-ai/management-sdk';
1
+ import type { WorkflowModels } from "@kontent-ai/management-sdk";
2
2
  export type WorkflowStep = {
3
3
  readonly codename: string;
4
4
  readonly id: string;
@@ -1,5 +1,6 @@
1
- import chalk from 'chalk';
2
- import { findRequired } from '../utils/array.utils.js';
1
+ import chalk from "chalk";
2
+ import { MigrationToolkitError } from "../models/error.models.js";
3
+ import { findRequired } from "../utils/array.utils.js";
3
4
  export function workflowHelper(workflows) {
4
5
  const mapContractToWorkflowSteps = (workflow, stepsContract) => {
5
6
  const allStepsContracts = [...workflow.steps, workflow.archivedStep, workflow.publishedStep, workflow.scheduledStep];
@@ -10,13 +11,13 @@ export function workflowHelper(workflows) {
10
11
  transitionsTo: m.transitions_to.map((transitionTo) => {
11
12
  const transitionStep = allStepsContracts.find((step) => step.id === transitionTo.step.id);
12
13
  if (!transitionStep) {
13
- throw Error(`Could not find transition step with id '${transitionTo.step.id}' in workflow '${workflow.codename}'`);
14
+ throw new MigrationToolkitError("missingWorkflowStep", `Could not find transition step with id '${transitionTo.step.id}' in workflow '${workflow.codename}'`);
14
15
  }
15
16
  return {
16
17
  codename: transitionStep.codename,
17
- id: transitionStep.id
18
+ id: transitionStep.id,
18
19
  };
19
- })
20
+ }),
20
21
  };
21
22
  });
22
23
  };
@@ -26,18 +27,18 @@ export function workflowHelper(workflows) {
26
27
  {
27
28
  codename: workflow.archivedStep.codename,
28
29
  id: workflow.archivedStep.id,
29
- transitionsTo: []
30
+ transitionsTo: [],
30
31
  },
31
32
  {
32
33
  codename: workflow.publishedStep.codename,
33
34
  id: workflow.publishedStep.id,
34
- transitionsTo: []
35
+ transitionsTo: [],
35
36
  },
36
37
  {
37
38
  codename: workflow.scheduledStep.codename,
38
39
  id: workflow.scheduledStep.id,
39
- transitionsTo: []
40
- }
40
+ transitionsTo: [],
41
+ },
41
42
  ];
42
43
  return findRequired(workflowSteps, stepMatcher.match, stepMatcher.errorMessage);
43
44
  };
@@ -48,9 +49,9 @@ export function workflowHelper(workflows) {
48
49
  return getWorkflow({
49
50
  errorMessage: [
50
51
  `Workflow with codename '${chalk.red(workflowCodename)}' does not exist in target project`,
51
- `Available workflows are (${workflows.length}): ${workflows.map((m) => chalk.cyan(m.codename)).join(', ')}`
52
- ].join(', '),
53
- match: (workflow) => workflow.codename.toLowerCase() === workflowCodename.toLowerCase()
52
+ `Available workflows are (${workflows.length}): ${workflows.map((m) => chalk.cyan(m.codename)).join(", ")}`,
53
+ ].join(", "),
54
+ match: (workflow) => workflow.codename.toLowerCase() === workflowCodename.toLowerCase(),
54
55
  });
55
56
  };
56
57
  const getWorkflowStepByCodename = (workflow, stepCodename) => {
@@ -59,9 +60,9 @@ export function workflowHelper(workflows) {
59
60
  `Workflow step with codename '${chalk.red(stepCodename)}' does not exist in target project`,
60
61
  `Steps in workflow '${chalk.yellow(workflow.codename)}' are (${workflow.steps.length}): ${workflow.steps
61
62
  .map((m) => chalk.cyan(m.codename))
62
- .join(', ')}`
63
- ].join(', '),
64
- match: (step) => step.codename.toLowerCase() === stepCodename.toLowerCase()
63
+ .join(", ")}`,
64
+ ].join(", "),
65
+ match: (step) => step.codename.toLowerCase() === stepCodename.toLowerCase(),
65
66
  });
66
67
  };
67
68
  const getWorkflowStepById = (workflow, stepId) => {
@@ -70,23 +71,23 @@ export function workflowHelper(workflows) {
70
71
  `Workflow step with codename '${chalk.red(stepId)}' does not exist in target project`,
71
72
  `Steps in workflow '${chalk.yellow(workflow.codename)}' are (${workflow.steps.length}): ${workflow.steps
72
73
  .map((m) => chalk.cyan(m.id))
73
- .join(', ')}`
74
- ].join(', '),
75
- match: (step) => step.id.toLowerCase() === stepId.toLowerCase()
74
+ .join(", ")}`,
75
+ ].join(", "),
76
+ match: (step) => step.id.toLowerCase() === stepId.toLowerCase(),
76
77
  });
77
78
  };
78
79
  const getWorkflowAndStep = (data) => {
79
80
  const workflow = getWorkflow(data.workflowMatcher);
80
81
  return {
81
82
  workflow,
82
- step: getWorkflowStep(workflow, data.stepMatcher)
83
+ step: getWorkflowStep(workflow, data.stepMatcher),
83
84
  };
84
85
  };
85
86
  const getWorkflowAndStepByCodenames = (data) => {
86
87
  const workflow = getWorkflowByCodename(data.workflowCodename);
87
88
  return {
88
89
  workflow,
89
- step: getWorkflowStepByCodename(workflow, data.stepCodename)
90
+ step: getWorkflowStepByCodename(workflow, data.stepCodename),
90
91
  };
91
92
  };
92
93
  const findShortestPathBetweenSteps = (workflow, startStep, endStep) => {
@@ -98,26 +99,27 @@ export function workflowHelper(workflows) {
98
99
  return getResult(node);
99
100
  }
100
101
  const newNodes = node.step.transitionsTo
102
+ // eslint-disable-next-line @typescript-eslint/no-loop-func
101
103
  .filter((s) => deque.find((n) => n.step.codename === s.codename) === undefined)
102
104
  .map((t) => ({
103
105
  parent: node,
104
- step: getWorkflowStepByCodename(workflow, t.codename)
106
+ step: getWorkflowStepByCodename(workflow, t.codename),
105
107
  }));
106
108
  deque = deque.concat(newNodes);
107
109
  }
108
110
  throw new Error(`Could not find the path from step (codename: ${startStep.codename}) to step (codename: ${endStep.codename}) in workflow (codename: ${workflow.codename})`);
109
111
  };
110
112
  const isPublishedStepByCodename = (stepCodename) => {
111
- return workflows.find((workflow) => workflow.publishedStep.codename === stepCodename) ? true : false;
113
+ return workflows.some((workflow) => workflow.publishedStep.codename === stepCodename);
112
114
  };
113
115
  const isArchivedStepByCodename = (stepCodename) => {
114
- return workflows.find((workflow) => workflow.archivedStep.codename === stepCodename) ? true : false;
116
+ return workflows.some((workflow) => workflow.archivedStep.codename === stepCodename);
115
117
  };
116
118
  const isScheduledStepByCodename = (stepCodename) => {
117
- return workflows.find((workflow) => workflow.scheduledStep.codename === stepCodename) ? true : false;
119
+ return workflows.some((workflow) => workflow.scheduledStep.codename === stepCodename);
118
120
  };
119
121
  const isPublishedStepById = (stepId) => {
120
- return workflows.find((workflow) => workflow.publishedStep.id === stepId) ? true : false;
122
+ return workflows.some((workflow) => workflow.publishedStep.id === stepId);
121
123
  };
122
124
  return {
123
125
  getWorkflowByCodename,
@@ -131,7 +133,7 @@ export function workflowHelper(workflows) {
131
133
  isArchivedStepByCodename,
132
134
  isScheduledStepByCodename,
133
135
  isPublishedStepById,
134
- findShortestPathBetweenSteps
136
+ findShortestPathBetweenSteps,
135
137
  };
136
138
  }
137
139
  //# 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;AA0BvD,MAAM,UAAU,cAAc,CAAC,SAAuD;IAClF,MAAM,0BAA0B,GAAG,CAC/B,QAA2C,EAC3C,aAA8E,EACvD,EAAE;QACzB,MAAM,iBAAiB,GAAG,CAAC,GAAG,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,EAAE,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,aAAa,CAAC,CAAC;QAErH,OAAO,aAAa,CAAC,GAAG,CAAe,CAAC,CAAC,EAAE,EAAE;YACzC,OAAO;gBACH,QAAQ,EAAE,CAAC,CAAC,QAAQ;gBACpB,EAAE,EAAE,CAAC,CAAC,EAAE;gBACR,aAAa,EAAE,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,EAAE;oBACjD,MAAM,cAAc,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBAE1F,IAAI,CAAC,cAAc,EAAE,CAAC;wBAClB,MAAM,KAAK,CAAC,2CAA2C,YAAY,CAAC,IAAI,CAAC,EAAE,kBAAkB,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAC;oBACvH,CAAC;oBAED,OA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AA6B;QAC7B,mBAAmB;QACnB,eAAe;QACf,kBAAkB;QAClB,WAAW;QACX,yBAAyB;QACzB,wBAAwB;QACxB,yBAAyB;QACzB,mBAAmB;QACnB,4BAA4B;KAC5B,CAAC;AACH,CAAC"}
@@ -1,2 +1,2 @@
1
- import type { Logger } from '../models/log.models.js';
1
+ import type { Logger } from "../models/log.models.js";
2
2
  export declare function getDefaultLogger(): Logger;
@@ -1,31 +1,31 @@
1
- import chalk from 'chalk';
2
- import { match, P } from 'ts-pattern';
3
- import { getCurrentEnvironment } from '../utils/global.utils.js';
1
+ import chalk from "chalk";
2
+ import { match, P } from "ts-pattern";
3
+ import { getCurrentEnvironment } from "../utils/global.utils.js";
4
4
  const originalWarn = console.warn;
5
5
  export function getDefaultLogger() {
6
6
  return match(getCurrentEnvironment())
7
- .with('node', () => defaultNodeLogger)
8
- .with('browser', () => defaultBrowserLogger)
7
+ .with("node", () => defaultNodeLogger)
8
+ .with("browser", () => defaultBrowserLogger)
9
9
  .exhaustive();
10
10
  }
11
11
  const defaultNodeLogger = {
12
12
  log: (data) => console.log(getLogDataMessage(data)),
13
13
  logWithSpinnerAsync: async (func) => {
14
- const ora = await import('ora');
14
+ const ora = await import("ora");
15
15
  return await ora.oraPromise(async (spinner) => {
16
16
  // patch global console to prevent disrupting ora instance
17
17
  // this often happens when JS SDK logs console.warn for
18
18
  // retried requests. Patching this ensures the flow is uninterrupted
19
19
  global.console.warn = (m) => {
20
20
  if (m) {
21
- spinner.text = m?.toString() ?? 'Invalid warn value';
21
+ spinner.text = m?.toString() ?? "Invalid warn value";
22
22
  }
23
23
  };
24
24
  const result = await func((data) => {
25
25
  // remember last used prefix. This is useful as we don't have to pass prefix to every single function
26
26
  // calling the spinner
27
27
  if (data.prefix) {
28
- spinner.prefixText = data.prefix ?? '';
28
+ spinner.prefixText = data.prefix ?? "";
29
29
  }
30
30
  spinner.text = getLogDataMessage(data);
31
31
  });
@@ -33,16 +33,16 @@ const defaultNodeLogger = {
33
33
  global.console.warn = originalWarn;
34
34
  return result;
35
35
  }, {});
36
- }
36
+ },
37
37
  };
38
38
  const defaultBrowserLogger = {
39
39
  log: (data) => console.log(getLogDataMessage(data)),
40
40
  logWithSpinnerAsync: async (func) => {
41
41
  return await func((data) => {
42
- const prefix = data.prefix ? `${data.prefix}: ` : '';
42
+ const prefix = data.prefix ? `${data.prefix}: ` : "";
43
43
  console.log(`${prefix}${getLogDataMessage(data)}`);
44
44
  });
45
- }
45
+ },
46
46
  };
47
47
  function getLogDataMessage(data) {
48
48
  if (!data.type) {
@@ -50,10 +50,10 @@ function getLogDataMessage(data) {
50
50
  }
51
51
  const color = match(data.type)
52
52
  .returnType()
53
- .with('info', () => chalk.cyan)
54
- .with(P.union('error', 'errorData', 'warning', 'cancel'), () => chalk.red)
55
- .with('completed', () => chalk.green)
56
- .with('skip', () => chalk.gray)
53
+ .with("info", () => chalk.cyan)
54
+ .with(P.union("error", "errorData", "warning", "cancel"), () => chalk.red)
55
+ .with("completed", () => chalk.green)
56
+ .with("skip", () => chalk.gray)
57
57
  .otherwise(() => chalk.yellow);
58
58
  return `${color(data.type)}: ${data.message}`;
59
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"loggers.js","sourceRoot":"","sources":["../../../lib/core/logs/loggers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,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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C,CAAC;IAEhC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC;AAC/C,CAAC"}
@@ -1,14 +1,14 @@
1
- import type { AssetModels, ContentItemModels, ContentTypeElements, LanguageVariantModels, WorkflowModels } from '@kontent-ai/management-sdk';
2
- import type { MigrationElementType } from './migration.models.js';
1
+ import type { AssetModels, ContentItemModels, ContentTypeElements, LanguageVariantModels, WorkflowModels } from "@kontent-ai/management-sdk";
2
+ import type { MigrationElementType } from "./migration.models.js";
3
3
  export type LiteralUnion<T extends string> = T | (string & {});
4
- export type TargetItemState = 'exists' | 'doesNotExists';
5
- export type CliAction = 'export' | 'import' | 'migrate';
6
- export type EnvContext = 'browser' | 'node';
7
- export type MapiAction = 'list' | 'view' | 'archive' | 'unpublish' | 'changeWorkflowStep' | 'publish' | 'upload' | 'create' | 'upsert' | 'schedulePublish' | 'scheduleUnpublish' | 'cancelScheduledPublish' | 'cancelScheduledUnpublish' | 'createNewVersion';
8
- export type MigrationItemType = 'exportItem';
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';
4
+ export type TargetItemState = "exists" | "doesNotExists";
5
+ export type CliAction = "export" | "import" | "migrate";
6
+ export type EnvContext = "browser" | "node";
7
+ export type MapiAction = "list" | "view" | "archive" | "unpublish" | "changeWorkflowStep" | "publish" | "upload" | "create" | "upsert" | "schedulePublish" | "scheduleUnpublish" | "cancelScheduledPublish" | "cancelScheduledUnpublish" | "createNewVersion";
8
+ export type MigrationItemType = "exportItem";
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
12
  export type LanguageVariantWorkflowState = {
13
13
  readonly workflowState: LanguageVariantWorkflowStateValues;
14
14
  readonly scheduledState: LanguageVariantSchedulesStateValues;
@@ -32,16 +32,20 @@ export interface ReferencedDataInLanguageVariants {
32
32
  readonly itemIds: ReadonlySet<string>;
33
33
  readonly assetIds: ReadonlySet<string>;
34
34
  }
35
- export interface ItemStateInSourceEnvironmentById {
36
- readonly state: TargetItemState;
37
- readonly id: string;
38
- readonly item: Readonly<ContentItemModels.ContentItem> | undefined;
39
- }
40
- export interface AssetStateInSourceEnvironmentById {
41
- readonly state: TargetItemState;
35
+ type DataStateInSourceEnvironmentById<T extends Readonly<ContentItemModels.ContentItem> | Readonly<AssetModels.Asset>> = {
42
36
  readonly id: string;
43
- readonly asset: Readonly<AssetModels.Asset> | undefined;
44
- }
37
+ } & ({
38
+ readonly state: "exists";
39
+ readonly data: T;
40
+ } | {
41
+ readonly state: "doesNotExists";
42
+ readonly data?: never;
43
+ } | {
44
+ readonly state: "skip";
45
+ readonly data?: never;
46
+ });
47
+ export type ItemStateInSourceEnvironmentById = DataStateInSourceEnvironmentById<Readonly<ContentItemModels.ContentItem>>;
48
+ export type AssetStateInSourceEnvironmentById = DataStateInSourceEnvironmentById<Readonly<AssetModels.Asset>>;
45
49
  export interface ItemStateInTargetEnvironmentByCodename {
46
50
  readonly state: TargetItemState;
47
51
  readonly itemCodename: string;
@@ -99,14 +103,15 @@ export interface OriginalManagementError {
99
103
  };
100
104
  }
101
105
  export type ItemProcessingResult<InputItem, OutputItem> = {
102
- readonly state: 'valid';
106
+ readonly state: "valid";
103
107
  readonly inputItem: InputItem;
104
108
  readonly outputItem: OutputItem;
105
109
  } | {
106
- readonly state: 'error';
110
+ readonly state: "error";
107
111
  readonly inputItem: InputItem;
108
112
  readonly error: unknown;
109
113
  } | {
110
- readonly state: '404';
114
+ readonly state: "404";
111
115
  readonly inputItem: InputItem;
112
116
  };
117
+ export {};
@@ -0,0 +1,14 @@
1
+ export type MigrationToolkitErrorType = "confirmationRefused" | "invalidZip" | "invalidFolder" | "unsupportedCommand" | "importFailedForItem" | "invalidElement" | "exportFailedForItem" | "missingContentType" | "invalidEnvironment" | "exitProgram" | "missingItem" | "findRequiredError" | "missingWorkflowStep" | "missingAsset" | "missingTaxonomyTerm" | "invalidValue" | "invalidMultipleChoiceOption";
2
+ export declare class MigrationToolkitError extends Error {
3
+ readonly type: MigrationToolkitErrorType;
4
+ readonly message: string;
5
+ constructor(type: MigrationToolkitErrorType, message: string);
6
+ }
7
+ export declare class MissingItemError extends MigrationToolkitError {
8
+ readonly id: string;
9
+ constructor(id: string);
10
+ }
11
+ export declare class MissingAssetError extends MigrationToolkitError {
12
+ readonly id: string;
13
+ constructor(id: string);
14
+ }
@@ -0,0 +1,25 @@
1
+ import chalk from "chalk";
2
+ export class MigrationToolkitError extends Error {
3
+ type;
4
+ message;
5
+ constructor(type, message) {
6
+ super(message);
7
+ this.type = type;
8
+ this.message = message;
9
+ }
10
+ }
11
+ export class MissingItemError extends MigrationToolkitError {
12
+ id;
13
+ constructor(id) {
14
+ super("missingItem", `Missing item with id '${chalk.red(id)}'`);
15
+ this.id = id;
16
+ }
17
+ }
18
+ export class MissingAssetError extends MigrationToolkitError {
19
+ id;
20
+ constructor(id) {
21
+ super("missingAsset", `Missing asset with id '${chalk.red(id)}'`);
22
+ this.id = id;
23
+ }
24
+ }
25
+ //# sourceMappingURL=error.models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.models.js","sourceRoot":"","sources":["../../../lib/core/models/error.models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAqB1B,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAE9B;IACP;IAFV,YACiB,IAA+B,EACtC,OAAe;QAExB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAA2B;QACtC,YAAO,GAAP,OAAO,CAAQ;IAGzB,CAAC;CACD;AAED,MAAM,OAAO,gBAAiB,SAAQ,qBAAqB;IAC9B;IAA5B,YAA4B,EAAU;QACrC,KAAK,CAAC,aAAa,EAAE,yBAAyB,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QADrC,OAAE,GAAF,EAAE,CAAQ;IAEtC,CAAC;CACD;AAED,MAAM,OAAO,iBAAkB,SAAQ,qBAAqB;IAC/B;IAA5B,YAA4B,EAAU;QACrC,KAAK,CAAC,cAAc,EAAE,0BAA0B,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;QADvC,OAAE,GAAF,EAAE,CAAQ;IAEtC,CAAC;CACD"}
@@ -1,5 +1,5 @@
1
- import type { MapiAction, MapiType, MigrationItemType } from '../index.js';
2
- export type DebugType = 'error' | 'completed' | 'warning' | 'info' | 'errorData' | 'cancel' | 'process' | 'readFs' | 'skip' | 'writeFs' | 'download' | MigrationItemType | MapiType | MapiAction;
1
+ import type { MapiAction, MapiType, MigrationItemType } from "./core.models.js";
2
+ export type DebugType = "error" | "completed" | "warning" | "info" | "errorData" | "cancel" | "process" | "readFs" | "skip" | "writeFs" | "download" | MigrationItemType | MapiType | MapiAction;
3
3
  export interface LogMessage {
4
4
  readonly type?: DebugType;
5
5
  readonly message: string;
@@ -1,21 +1,21 @@
1
- import type { z } from 'zod';
2
- import type { MigrationAssetDescriptionSchema, MigrationAssetSchema, MigrationComponentSchema, MigrationDataSchema, MigrationElementSchema, MigrationElementsSchema, MigrationElementTypeSchema, MigrationElementValueSchema, MigrationItemSchema, MigrationItemSystemSchema, MigrationItemVersionSchema, MigrationReferenceSchema, MigrationUrlSlugModeSchema } from './migration.schema.js';
1
+ import type { z } from "zod";
2
+ import type { MigrationAssetDescriptionSchema, MigrationAssetSchema, MigrationComponentSchema, MigrationDataSchema, MigrationElementSchema, MigrationElementsSchema, MigrationElementTypeSchema, MigrationElementValueSchema, MigrationItemSchema, MigrationItemSystemSchema, MigrationItemVersionSchema, MigrationReferenceSchema, MigrationUrlSlugModeSchema } from "./migration.schema.js";
3
3
  export declare namespace MigrationElementModels {
4
4
  type MigrationElementDef<TElementType extends MigrationElementType = MigrationElementType, TValue extends MigrationElementValue = MigrationElementValue> = {
5
5
  readonly value: TValue | undefined;
6
6
  readonly type: TElementType;
7
7
  };
8
- export type TextElement = MigrationElementDef<'text', string>;
9
- export type NumberElement = MigrationElementDef<'number', number>;
10
- export type RichTextElement = MigrationElementDef<'rich_text', string> & Pick<MigrationElement, 'components'>;
11
- export type MultipleChoiceElement = MigrationElementDef<'multiple_choice', MigrationReference[]>;
12
- export type DateTimeElement = MigrationElementDef<'date_time', string> & Pick<MigrationElement, 'display_timezone'>;
13
- export type AssetElement = MigrationElementDef<'asset', MigrationReference[]>;
14
- export type LinkedItemsElement = MigrationElementDef<'modular_content', MigrationReference[]>;
15
- export type TaxonomyElement = MigrationElementDef<'taxonomy', MigrationReference[]>;
16
- export type UrlSlugElement = MigrationElementDef<'url_slug', string> & Pick<MigrationElement, 'mode'>;
17
- export type CustomElement = MigrationElementDef<'custom', string>;
18
- export type SubpagesElement = MigrationElementDef<'subpages', MigrationReference[]>;
8
+ export type TextElement = MigrationElementDef<"text", string>;
9
+ export type NumberElement = MigrationElementDef<"number", number>;
10
+ export type RichTextElement = MigrationElementDef<"rich_text", string> & Pick<MigrationElement, "components">;
11
+ export type MultipleChoiceElement = MigrationElementDef<"multiple_choice", MigrationReference[]>;
12
+ export type DateTimeElement = MigrationElementDef<"date_time", string> & Pick<MigrationElement, "display_timezone">;
13
+ export type AssetElement = MigrationElementDef<"asset", MigrationReference[]>;
14
+ export type LinkedItemsElement = MigrationElementDef<"modular_content", MigrationReference[]>;
15
+ export type TaxonomyElement = MigrationElementDef<"taxonomy", MigrationReference[]>;
16
+ export type UrlSlugElement = MigrationElementDef<"url_slug", string> & Pick<MigrationElement, "mode">;
17
+ export type CustomElement = MigrationElementDef<"custom", string>;
18
+ export type SubpagesElement = MigrationElementDef<"subpages", MigrationReference[]>;
19
19
  export {};
20
20
  }
21
21
  export type MigrationReference<T extends string = string> = z.infer<typeof MigrationReferenceSchema> & {
@@ -34,7 +34,7 @@ export type MigrationElementType = z.infer<typeof MigrationElementTypeSchema>;
34
34
  export type MigrationComponent = z.infer<typeof MigrationComponentSchema>;
35
35
  export type MigrationElementValue = z.infer<typeof MigrationElementValueSchema>;
36
36
  export type MigrationElement = z.infer<typeof MigrationElementSchema>;
37
- export type MigrationElementTransformData = Omit<MigrationElement, 'type'>;
37
+ export type MigrationElementTransformData = Omit<MigrationElement, "type">;
38
38
  export type MigrationElements = z.infer<typeof MigrationElementsSchema>;
39
39
  export type MigrationAssetDescription = z.infer<typeof MigrationAssetDescriptionSchema>;
40
40
  export type MigrationAsset = z.infer<typeof MigrationAssetSchema>;
@@ -1,9 +1,9 @@
1
- import { Buffer as BufferProxy } from 'buffer';
2
- import { z } from 'zod';
1
+ import { Buffer as BufferProxy } from "buffer";
2
+ import { z } from "zod";
3
3
  interface Elements {
4
4
  readonly [key: string]: Element;
5
5
  }
6
- type UrlSlugMode = 'autogenerated' | 'custom';
6
+ type UrlSlugMode = "autogenerated" | "custom";
7
7
  type Reference = {
8
8
  readonly codename: string;
9
9
  };
@@ -22,7 +22,7 @@ type Element = {
22
22
  readonly components?: readonly Component[];
23
23
  readonly mode?: UrlSlugMode;
24
24
  };
25
- type ElementType = 'text' | 'rich_text' | 'number' | 'multiple_choice' | 'date_time' | 'asset' | 'modular_content' | 'taxonomy' | 'url_slug' | 'custom' | 'subpages';
25
+ type ElementType = "text" | "rich_text" | "number" | "multiple_choice" | "date_time" | "asset" | "modular_content" | "taxonomy" | "url_slug" | "custom" | "subpages";
26
26
  export declare const MigrationUrlSlugModeSchema: z.ZodReadonly<z.ZodEnum<{
27
27
  autogenerated: "autogenerated";
28
28
  custom: "custom";
@@ -165,7 +165,7 @@ export declare const MigrationAssetDescriptionSchema: z.ZodReadonly<z.ZodObject<
165
165
  export declare const MigrationAssetSchema: z.ZodReadonly<z.ZodObject<{
166
166
  codename: z.ZodString;
167
167
  filename: z.ZodString;
168
- title: z.ZodString;
168
+ title: z.ZodOptional<z.ZodString>;
169
169
  collection: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
170
170
  codename: z.ZodReadonly<z.ZodString>;
171
171
  }, z.core.$strict>>>;
@@ -183,7 +183,7 @@ export declare const MigrationAssetSchema: z.ZodReadonly<z.ZodObject<{
183
183
  export declare const ZipMigrationAssetSchema: z.ZodReadonly<z.ZodObject<{
184
184
  codename: z.ZodString;
185
185
  filename: z.ZodString;
186
- title: z.ZodString;
186
+ title: z.ZodOptional<z.ZodString>;
187
187
  collection: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
188
188
  codename: z.ZodReadonly<z.ZodString>;
189
189
  }, z.core.$strict>>>;
@@ -201,7 +201,7 @@ export declare const ZipMigrationAssetSchema: z.ZodReadonly<z.ZodObject<{
201
201
  export declare const MigrationAssetsSchema: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
202
202
  codename: z.ZodString;
203
203
  filename: z.ZodString;
204
- title: z.ZodString;
204
+ title: z.ZodOptional<z.ZodString>;
205
205
  collection: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
206
206
  codename: z.ZodReadonly<z.ZodString>;
207
207
  }, z.core.$strict>>>;
@@ -219,7 +219,7 @@ export declare const MigrationAssetsSchema: z.ZodReadonly<z.ZodArray<z.ZodReadon
219
219
  export declare const ZipMigrationAssetsSchema: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
220
220
  codename: z.ZodString;
221
221
  filename: z.ZodString;
222
- title: z.ZodString;
222
+ title: z.ZodOptional<z.ZodString>;
223
223
  collection: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
224
224
  codename: z.ZodReadonly<z.ZodString>;
225
225
  }, z.core.$strict>>>;
@@ -298,7 +298,7 @@ export declare const MigrationDataSchema: z.ZodReadonly<z.ZodObject<{
298
298
  assets: z.ZodReadonly<z.ZodArray<z.ZodReadonly<z.ZodObject<{
299
299
  codename: z.ZodString;
300
300
  filename: z.ZodString;
301
- title: z.ZodString;
301
+ title: z.ZodOptional<z.ZodString>;
302
302
  collection: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
303
303
  codename: z.ZodReadonly<z.ZodString>;
304
304
  }, z.core.$strict>>>;