@kontent-ai/migration-toolkit 1.0.0 → 1.1.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 (56) hide show
  1. package/README.md +3 -7
  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/models/migration.models.d.ts +35 -133
  6. package/dist/es2022/core/models/migration.schema.d.ts +1300 -0
  7. package/dist/es2022/core/models/migration.schema.js +114 -0
  8. package/dist/es2022/core/models/migration.schema.js.map +1 -0
  9. package/dist/es2022/core/utils/confirm.utils.js +3 -3
  10. package/dist/es2022/core/utils/confirm.utils.js.map +1 -1
  11. package/dist/es2022/core/utils/error.utils.js +8 -2
  12. package/dist/es2022/core/utils/error.utils.js.map +1 -1
  13. package/dist/es2022/core/utils/global.utils.d.ts +4 -1
  14. package/dist/es2022/core/utils/global.utils.js +1 -3
  15. package/dist/es2022/core/utils/global.utils.js.map +1 -1
  16. package/dist/es2022/export/context/export-context-fetcher.js +10 -6
  17. package/dist/es2022/export/context/export-context-fetcher.js.map +1 -1
  18. package/dist/es2022/export/export-manager.js +3 -3
  19. package/dist/es2022/export/export-manager.js.map +1 -1
  20. package/dist/es2022/import/import-manager.js.map +1 -1
  21. package/dist/es2022/metadata.js +2 -2
  22. package/dist/es2022/node/cli/actions/export-action.js +2 -2
  23. package/dist/es2022/node/cli/actions/export-action.js.map +1 -1
  24. package/dist/es2022/node/cli/actions/import-action.js +2 -2
  25. package/dist/es2022/node/cli/actions/import-action.js.map +1 -1
  26. package/dist/es2022/node/cli/app.js +3 -0
  27. package/dist/es2022/node/cli/app.js.map +1 -1
  28. package/dist/es2022/node/cli/args/args-setter.js +3 -0
  29. package/dist/es2022/node/cli/args/args-setter.js.map +1 -1
  30. package/dist/es2022/node/cli/cli.models.d.ts +1 -0
  31. package/dist/es2022/toolkit/file.js +3 -3
  32. package/dist/es2022/toolkit/file.js.map +1 -1
  33. package/dist/es2022/translation/transforms/export-transforms.js.map +1 -1
  34. package/dist/es2022/zip/zip-transformer.js +9 -6
  35. package/dist/es2022/zip/zip-transformer.js.map +1 -1
  36. package/dist/es2022/zip/zip.models.d.ts +1 -1
  37. package/lib/core/index.ts +1 -0
  38. package/lib/core/models/migration.models.ts +56 -159
  39. package/lib/core/models/migration.schema.ts +180 -0
  40. package/lib/core/utils/confirm.utils.ts +4 -4
  41. package/lib/core/utils/error.utils.ts +9 -6
  42. package/lib/core/utils/global.utils.ts +3 -3
  43. package/lib/export/context/export-context-fetcher.ts +9 -6
  44. package/lib/export/export-manager.ts +16 -20
  45. package/lib/import/import-manager.ts +2 -6
  46. package/lib/metadata.ts +2 -2
  47. package/lib/node/cli/actions/export-action.ts +2 -2
  48. package/lib/node/cli/actions/import-action.ts +2 -2
  49. package/lib/node/cli/app.ts +4 -0
  50. package/lib/node/cli/args/args-setter.ts +3 -0
  51. package/lib/node/cli/cli.models.ts +1 -0
  52. package/lib/toolkit/file.ts +3 -9
  53. package/lib/translation/transforms/export-transforms.ts +1 -4
  54. package/lib/zip/zip-transformer.ts +25 -11
  55. package/lib/zip/zip.models.ts +1 -1
  56. package/package.json +10 -10
package/README.md CHANGED
@@ -11,19 +11,15 @@ environments.
11
11
 
12
12
  This library can only be used as a library both in `node.js` & `browser` or as a `CLI` utility.
13
13
 
14
- > [!CAUTION]
15
- > **This readme uses pre-release version of this library using `next` tag on NPM**. To install it you need to specify
16
- > version explicitely such as running `npm i @kontent-ai-consulting/migration-toolkit@1.0.0-24 -g`.
17
-
18
14
  # Getting started
19
15
 
20
16
  Use `--help` anytime to get information about available commands and their options.
21
17
 
22
18
  ```bash
23
- npx @kontent-ai-consulting/migration-toolkit --help
19
+ npx @kontent-ai/migration-toolkit@latest --help
24
20
 
25
21
  # you can also install the package globally, or locally
26
- npm i @kontent-ai-consulting/migration-toolkit -g
22
+ npm i @kontent-ai/migration-toolkit -g
27
23
 
28
24
  # with the package installed, you can call the tool as follows
29
25
  kontent-ai-migration-toolkit --help
@@ -49,7 +45,7 @@ You may migrate content (items & asset) between Kontent.ai environments. For mig
49
45
  [Data Ops](https://github.com/kontent-ai/data-ops) instead.
50
46
 
51
47
  > [!CAUTION]
52
- > **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..
53
49
 
54
50
  ## Configuration
55
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"}
@@ -1,136 +1,38 @@
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, BaseMigrationItemSchema, BaseMigrationItemVersionSchema } 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;
6
+ readonly type: TElementType;
86
7
  };
8
+ export type TextElement = MigrationElementDef<'text', string | undefined>;
9
+ export type NumberElement = MigrationElementDef<'number', number | undefined>;
10
+ export type RichTextElement = MigrationElementDef<'rich_text', MigrationRichTextElementValue | undefined>;
11
+ export type MultipleChoiceElement = MigrationElementDef<'multiple_choice', MigrationReference[] | undefined>;
12
+ export type DateTimeElement = MigrationElementDef<'date_time', string | undefined>;
13
+ export type AssetElement = MigrationElementDef<'asset', MigrationReference[] | undefined>;
14
+ export type LinkedItemsElement = MigrationElementDef<'modular_content', MigrationReference[] | undefined>;
15
+ export type TaxonomyElement = MigrationElementDef<'taxonomy', MigrationReference[] | undefined>;
16
+ export type UrlSlugElement = MigrationElementDef<'url_slug', MigrationUrlSlugElementValue | undefined>;
17
+ export type CustomElement = MigrationElementDef<'custom', string | undefined>;
18
+ export type SubpagesElement = MigrationElementDef<'subpages', MigrationReference[] | undefined>;
19
+ export {};
20
+ }
21
+ export type MigrationReference = z.infer<typeof MigrationReferenceSchema>;
22
+ export type MigrationUrlSlugMode = z.infer<typeof MigrationUrlSlugModeSchema>;
23
+ export type MigrationElementType = z.infer<typeof MigrationElementTypeSchema>;
24
+ export type MigrationUrlSlugElementValue = z.infer<typeof MigrationUrlSlugElementValueSchema>;
25
+ export type MigrationRichTextElementValue = z.infer<typeof MigrationRichTextElementValueSchema>;
26
+ export type MigrationComponent = z.infer<typeof MigrationComponentSchema>;
27
+ export type MigrationElementValue = z.infer<typeof MigrationElementValueSchema>;
28
+ export type MigrationElement = z.infer<typeof MigrationElementSchema>;
29
+ export type MigrationElements = z.infer<typeof MigrationElementsSchema>;
30
+ export type MigrationAssetDescription = z.infer<typeof MigrationAssetDescriptionSchema>;
31
+ export type MigrationAsset = z.infer<typeof MigrationAssetSchema>;
32
+ export type MigrationData = z.infer<typeof MigrationDataSchema>;
33
+ export type MigrationItemVersion<TElements extends MigrationElements = MigrationElements> = z.infer<typeof BaseMigrationItemVersionSchema> & {
34
+ readonly elements: TElements;
35
+ };
36
+ export type MigrationItem<TElements extends MigrationElements = MigrationElements> = z.infer<typeof BaseMigrationItemSchema> & {
87
37
  readonly versions: MigrationItemVersion<TElements>[];
88
- }
89
- export interface MigrationReference {
90
- /**
91
- * Codename of the referenced object
92
- */
93
- 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
- }
38
+ };