@kontent-ai/migration-toolkit 1.0.1 → 1.2.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 (55) hide show
  1. package/README.md +1 -1
  2. package/dist/es2022/core/index.d.ts +1 -0
  3. package/dist/es2022/core/index.js +1 -0
  4. package/dist/es2022/core/index.js.map +1 -1
  5. package/dist/es2022/core/logs/loggers.js +1 -4
  6. package/dist/es2022/core/logs/loggers.js.map +1 -1
  7. package/dist/es2022/core/models/core.models.d.ts +9 -10
  8. package/dist/es2022/core/models/log.models.d.ts +2 -2
  9. package/dist/es2022/core/models/migration.models.d.ts +47 -133
  10. package/dist/es2022/core/models/migration.schema.d.ts +1240 -0
  11. package/dist/es2022/core/models/migration.schema.js +113 -0
  12. package/dist/es2022/core/models/migration.schema.js.map +1 -0
  13. package/dist/es2022/core/utils/confirm.utils.js +3 -3
  14. package/dist/es2022/core/utils/confirm.utils.js.map +1 -1
  15. package/dist/es2022/core/utils/error.utils.js +8 -2
  16. package/dist/es2022/core/utils/error.utils.js.map +1 -1
  17. package/dist/es2022/core/utils/global.utils.d.ts +4 -1
  18. package/dist/es2022/core/utils/global.utils.js +1 -3
  19. package/dist/es2022/core/utils/global.utils.js.map +1 -1
  20. package/dist/es2022/export/context/export-context-fetcher.js +11 -7
  21. package/dist/es2022/export/context/export-context-fetcher.js.map +1 -1
  22. package/dist/es2022/export/export-manager.js +3 -3
  23. package/dist/es2022/export/export-manager.js.map +1 -1
  24. package/dist/es2022/import/import-manager.js.map +1 -1
  25. package/dist/es2022/metadata.js +2 -2
  26. package/dist/es2022/node/cli/actions/export-action.js +2 -2
  27. package/dist/es2022/node/cli/actions/export-action.js.map +1 -1
  28. package/dist/es2022/node/cli/actions/import-action.js +2 -2
  29. package/dist/es2022/node/cli/actions/import-action.js.map +1 -1
  30. package/dist/es2022/toolkit/file.js +3 -3
  31. package/dist/es2022/toolkit/file.js.map +1 -1
  32. package/dist/es2022/translation/transforms/export-transforms.js.map +1 -1
  33. package/dist/es2022/zip/zip-transformer.js +9 -6
  34. package/dist/es2022/zip/zip-transformer.js.map +1 -1
  35. package/dist/es2022/zip/zip.models.d.ts +1 -1
  36. package/lib/core/index.ts +1 -0
  37. package/lib/core/logs/loggers.ts +1 -6
  38. package/lib/core/models/core.models.ts +11 -17
  39. package/lib/core/models/log.models.ts +7 -4
  40. package/lib/core/models/migration.models.ts +78 -158
  41. package/lib/core/models/migration.schema.ts +178 -0
  42. package/lib/core/utils/confirm.utils.ts +4 -4
  43. package/lib/core/utils/error.utils.ts +9 -6
  44. package/lib/core/utils/global.utils.ts +3 -3
  45. package/lib/export/context/export-context-fetcher.ts +23 -55
  46. package/lib/export/export-manager.ts +16 -20
  47. package/lib/import/import-manager.ts +2 -6
  48. package/lib/metadata.ts +2 -2
  49. package/lib/node/cli/actions/export-action.ts +2 -2
  50. package/lib/node/cli/actions/import-action.ts +2 -2
  51. package/lib/toolkit/file.ts +3 -9
  52. package/lib/translation/transforms/export-transforms.ts +1 -4
  53. package/lib/zip/zip-transformer.ts +25 -11
  54. package/lib/zip/zip.models.ts +1 -1
  55. package/package.json +10 -9
package/README.md CHANGED
@@ -45,7 +45,7 @@ You may migrate content (items & asset) between Kontent.ai environments. For mig
45
45
  [Data Ops](https://github.com/kontent-ai/data-ops) instead.
46
46
 
47
47
  > [!CAUTION]
48
- > **We recommend migrating to test / dev environments first ** to ensure nothing unexpected happens..
48
+ > **We recommend migrating to test / dev environments first** to ensure nothing unexpected happens..
49
49
 
50
50
  ## Configuration
51
51
 
@@ -11,5 +11,6 @@ export * from './utils/management-client-utils.js';
11
11
  export * from './models/log.models.js';
12
12
  export * from './models/core.models.js';
13
13
  export * from './models/migration.models.js';
14
+ export * from './models/migration.schema.js';
14
15
  export * from './logs/loggers.js';
15
16
  export * from './helpers/workflow-helper.js';
@@ -11,6 +11,7 @@ export * from './utils/management-client-utils.js';
11
11
  export * from './models/log.models.js';
12
12
  export * from './models/core.models.js';
13
13
  export * from './models/migration.models.js';
14
+ export * from './models/migration.schema.js';
14
15
  export * from './logs/loggers.js';
15
16
  export * from './helpers/workflow-helper.js';
16
17
  //# sourceMappingURL=index.js.map
@@ -1 +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"}
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;AAC7C,cAAc,8BAA8B,CAAC;AAE7C,cAAc,mBAAmB,CAAC;AAClC,cAAc,8BAA8B,CAAC"}
@@ -52,10 +52,7 @@ function getLogDataMessage(data) {
52
52
  if (data.type === 'info') {
53
53
  typeColor = chalk.cyan;
54
54
  }
55
- else if (data.type === 'error' ||
56
- data.type === 'errorData' ||
57
- data.type === 'warning' ||
58
- data.type === 'cancel') {
55
+ else if (data.type === 'error' || data.type === 'errorData' || data.type === 'warning' || data.type === 'cancel') {
59
56
  typeColor = chalk.red;
60
57
  }
61
58
  else if (data.type === 'completed') {
@@ -1 +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,KAAK,CAAC,CAAC;QAEhC,OAAO,MAAM,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;YAC1C,0DAA0D;YAC1D,uDAAuD;YACvD,oEAAoE;YACpE,MAAM,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC,EAAE,EAAE;gBACxB,IAAI,CAAC,EAAE,CAAC;oBACJ,OAAO,CAAC,IAAI,GAAI,CAAa,EAAE,QAAQ,EAAE,IAAI,oBAAoB,CAAC;gBACtE,CAAC;YACL,CAAC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,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,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,WAAW,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACjH,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"}
@@ -3,14 +3,13 @@ import { MigrationElementType } from './migration.models.js';
3
3
  import { WorkflowStep } from '../helpers/workflow-helper.js';
4
4
  export type TargetItemState = 'exists' | 'doesNotExists';
5
5
  export type CliAction = 'export' | 'import' | 'migrate';
6
- export type GeneralItemType = 'exportedItem' | 'migrationItem';
7
- export type GeneralActionType = 'readFs' | 'skip' | 'writeFs' | 'download';
8
6
  export type EnvContext = 'browser' | 'node';
9
7
  export type MapiAction = 'list' | 'view' | 'archive' | 'unpublish' | 'changeWorkflowStep' | 'publish' | 'upload' | 'create' | 'upsert' | 'createNewVersion';
8
+ export type MigrationItemType = 'exportItem';
10
9
  export type MapiType = 'contentType' | 'asset' | 'contentTypeSnippet' | 'contentItem' | 'languageVariant' | 'language' | 'collection' | 'taxonomy' | 'binaryFile' | 'workflow';
11
10
  export interface ItemInfo {
12
11
  readonly title: string;
13
- readonly itemType: GeneralItemType | MapiType;
12
+ readonly itemType: MapiType | MigrationItemType;
14
13
  }
15
14
  export interface ErrorData {
16
15
  readonly message: string;
@@ -78,14 +77,14 @@ export interface FlattenedContentType {
78
77
  readonly elements: readonly FlattenedContentTypeElement[];
79
78
  }
80
79
  export interface OriginalManagementError {
81
- response?: {
82
- status?: number;
83
- config?: {
84
- url?: string;
85
- data?: string;
80
+ readonly response?: {
81
+ readonly status?: number;
82
+ readonly config?: {
83
+ readonly url?: string;
84
+ readonly data?: string;
86
85
  };
87
- data?: {
88
- error_code?: number;
86
+ readonly data?: {
87
+ readonly error_code?: number;
89
88
  };
90
89
  };
91
90
  }
@@ -1,5 +1,5 @@
1
- import { GeneralActionType, GeneralItemType, MapiAction, MapiType } from '../index.js';
2
- export type DebugType = 'error' | 'completed' | 'warning' | 'info' | 'errorData' | 'cancel' | 'process' | MapiType | GeneralActionType | MapiAction | GeneralItemType;
1
+ import { MigrationItemType, MapiAction, MapiType } from '../index.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,136 +1,50 @@
1
- export type MigrationElementType = 'text' | 'rich_text' | 'number' | 'multiple_choice' | 'date_time' | 'asset' | 'modular_content' | 'taxonomy' | 'url_slug' | 'custom' | 'subpages';
2
- export type MigrationUrlSlugMode = 'autogenerated' | 'custom';
3
- export interface MigrationRichTextElementValue {
4
- value: string;
5
- components: readonly MigrationComponent[];
6
- }
7
- export interface MigrationUrlSlugElementValue {
8
- value: string | undefined;
9
- mode: MigrationUrlSlugMode;
10
- }
11
- export interface MigrationComponent {
12
- system: {
13
- id: string;
14
- type: MigrationReference;
15
- };
16
- elements: MigrationElements;
17
- }
18
- export type MigrationElementValue = string | undefined | MigrationReference[] | number | MigrationRichTextElementValue | MigrationUrlSlugElementValue;
19
- export interface MigrationElement<TElementType extends MigrationElementType = MigrationElementType, TValue extends MigrationElementValue = MigrationElementValue> {
20
- /**
21
- * Value of the element
22
- */
23
- readonly value: TValue;
24
- /**
25
- * Type of the element
26
- */
27
- readonly type: TElementType;
28
- }
1
+ import { z } from 'zod';
2
+ import { MigrationComponentSchema, MigrationElementTypeSchema, MigrationElementValueSchema, MigrationReferenceSchema, MigrationUrlSlugElementValueSchema, MigrationUrlSlugModeSchema, MigrationRichTextElementValueSchema, MigrationElementSchema, MigrationElementsSchema, MigrationAssetDescriptionSchema, MigrationDataSchema, MigrationAssetSchema, MigrationItemVersionSchema, MigrationItemSchema, MigrationItemSystemSchema } from './migration.schema.js';
29
3
  export declare namespace MigrationElementModels {
30
- interface TextElement extends MigrationElement<'text', string | undefined> {
31
- }
32
- interface NumberElement extends MigrationElement<'number', number | undefined> {
33
- }
34
- interface RichTextElement extends MigrationElement<'rich_text', MigrationRichTextElementValue | undefined> {
35
- }
36
- interface MultipleChoiceElement extends MigrationElement<'multiple_choice', MigrationReference[] | undefined> {
37
- }
38
- interface DateTimeElement extends MigrationElement<'date_time', string | undefined> {
39
- }
40
- interface AssetElement extends MigrationElement<'asset', MigrationReference[] | undefined> {
41
- }
42
- interface LinkedItemsElement extends MigrationElement<'modular_content', MigrationReference[] | undefined> {
43
- }
44
- interface TaxonomyElement extends MigrationElement<'taxonomy', MigrationReference[] | undefined> {
45
- }
46
- interface UrlSlugElement extends MigrationElement<'url_slug', MigrationUrlSlugElementValue | undefined> {
47
- }
48
- interface CustomElement extends MigrationElement<'custom', string | undefined> {
49
- }
50
- interface SubpagesElement extends MigrationElement<'subpages', MigrationReference[] | undefined> {
51
- }
52
- }
53
- export interface MigrationElements {
54
- [elementCodename: string]: MigrationElement;
55
- }
56
- export interface MigrationItemVersion<TElements extends MigrationElements = MigrationElements> {
57
- readonly elements: TElements;
58
- readonly workflow_step: MigrationReference;
59
- }
60
- export interface MigrationItem<TElements extends MigrationElements = MigrationElements> {
61
- readonly system: {
62
- /**
63
- * Codename of the content item
64
- */
65
- readonly codename: string;
66
- /**
67
- * Name of the content item
68
- */
69
- readonly name: string;
70
- /**
71
- * Language of the language variant
72
- */
73
- readonly language: MigrationReference;
74
- /**
75
- * Content type of the item
76
- */
77
- readonly type: MigrationReference;
78
- /**
79
- * Collection of the item
80
- */
81
- readonly collection: MigrationReference;
82
- /**
83
- * Workflow of the item
84
- */
85
- readonly workflow: MigrationReference;
4
+ type MigrationElementDef<TElementType extends MigrationElementType = MigrationElementType, TValue extends MigrationElementValue = MigrationElementValue> = {
5
+ readonly value: TValue | undefined;
6
+ readonly type: TElementType;
86
7
  };
87
- readonly versions: MigrationItemVersion<TElements>[];
88
- }
89
- export interface MigrationReference {
90
- /**
91
- * Codename of the referenced object
92
- */
8
+ export type TextElement = MigrationElementDef<'text', string>;
9
+ export type NumberElement = MigrationElementDef<'number', number>;
10
+ export type RichTextElement = MigrationElementDef<'rich_text', MigrationRichTextElementValue>;
11
+ export type MultipleChoiceElement = MigrationElementDef<'multiple_choice', MigrationReference[]>;
12
+ export type DateTimeElement = MigrationElementDef<'date_time', string>;
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', MigrationUrlSlugElementValue>;
17
+ export type CustomElement = MigrationElementDef<'custom', string>;
18
+ export type SubpagesElement = MigrationElementDef<'subpages', MigrationReference[]>;
19
+ export {};
20
+ }
21
+ export type MigrationReference<T extends string = string> = z.infer<typeof MigrationReferenceSchema> & {
22
+ readonly codename: T;
23
+ };
24
+ export type MigrationItemSystem<TLanguage extends string = string, TType extends string = string, TCollection extends string = string, TWorkflow extends string = string> = z.infer<typeof MigrationItemSystemSchema> & {
93
25
  readonly codename: string;
94
- }
95
- export interface MigrationAssetDescription {
96
- readonly language: MigrationReference;
97
- readonly description?: string;
98
- }
99
- export interface MigrationAsset {
100
- /**
101
- * Codename of the asset
102
- */
103
- readonly codename: string;
104
- /**
105
- * Binary data of the asset
106
- */
107
- readonly binaryData: Buffer | Blob;
108
- /**
109
- * Filename of the asset, will be used as a filename in Kontent.ai after importing the asset
110
- */
111
- readonly filename: string;
112
- /**
113
- * Title of the asset
114
- */
115
- readonly title: string;
116
- /**
117
- * Optional
118
- * Collection of the asset
119
- */
120
- readonly collection?: MigrationReference;
121
- /**
122
- * Optional.
123
- * Descriptions of the assets
124
- */
125
- readonly descriptions?: readonly MigrationAssetDescription[];
126
- }
127
- export interface MigrationData {
128
- /**
129
- * Array of migration items to process (export / import)
130
- */
131
- readonly items: readonly MigrationItem[];
132
- /**
133
- * Array of migration assets to process
134
- */
135
- readonly assets: readonly MigrationAsset[];
136
- }
26
+ readonly name: string;
27
+ readonly language: MigrationReference<TLanguage>;
28
+ readonly type: MigrationReference<TType>;
29
+ readonly collection: MigrationReference<TCollection>;
30
+ readonly workflow: MigrationReference<TWorkflow>;
31
+ };
32
+ export type MigrationUrlSlugMode = z.infer<typeof MigrationUrlSlugModeSchema>;
33
+ export type MigrationElementType = z.infer<typeof MigrationElementTypeSchema>;
34
+ export type MigrationUrlSlugElementValue = z.infer<typeof MigrationUrlSlugElementValueSchema>;
35
+ export type MigrationRichTextElementValue = z.infer<typeof MigrationRichTextElementValueSchema>;
36
+ export type MigrationComponent = z.infer<typeof MigrationComponentSchema>;
37
+ export type MigrationElementValue = z.infer<typeof MigrationElementValueSchema>;
38
+ export type MigrationElement = z.infer<typeof MigrationElementSchema>;
39
+ export type MigrationElements = z.infer<typeof MigrationElementsSchema>;
40
+ export type MigrationAssetDescription = z.infer<typeof MigrationAssetDescriptionSchema>;
41
+ export type MigrationAsset = z.infer<typeof MigrationAssetSchema>;
42
+ export type MigrationData = z.infer<typeof MigrationDataSchema>;
43
+ export type MigrationItemVersion<TElements extends MigrationElements = MigrationElements, TWorkflowStepCodename extends string = string> = z.infer<typeof MigrationItemVersionSchema> & {
44
+ readonly elements: Readonly<TElements>;
45
+ readonly workflow_step: MigrationReference<TWorkflowStepCodename>;
46
+ };
47
+ export type MigrationItem<TElements extends MigrationElements = MigrationElements, TSystem extends MigrationItemSystem = MigrationItemSystem, TWorkflowStepCodename extends string = string> = z.infer<typeof MigrationItemSchema> & {
48
+ readonly versions: Readonly<MigrationItemVersion<TElements, TWorkflowStepCodename>[]>;
49
+ readonly system: TSystem;
50
+ };