@contentstack/cli-cm-import 1.5.11 → 1.6.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 (110) hide show
  1. package/README.md +6 -14
  2. package/bin/dev +17 -0
  3. package/bin/dev.cmd +3 -0
  4. package/bin/run +6 -0
  5. package/bin/run.cmd +3 -0
  6. package/lib/commands/cm/stacks/import.d.ts +10 -0
  7. package/lib/commands/cm/stacks/import.js +111 -0
  8. package/lib/config/index.d.ts +3 -0
  9. package/lib/config/index.js +372 -0
  10. package/lib/import/index.d.ts +1 -0
  11. package/lib/import/index.js +8 -0
  12. package/lib/import/module-importer.d.ts +13 -0
  13. package/lib/import/module-importer.js +70 -0
  14. package/lib/import/modules/assets.d.ts +63 -0
  15. package/lib/import/modules/assets.js +265 -0
  16. package/lib/import/modules/base-class.d.ts +69 -0
  17. package/lib/import/modules/base-class.js +165 -0
  18. package/lib/import/modules/index.d.ts +2 -0
  19. package/lib/import/modules/index.js +19 -0
  20. package/lib/import/modules/locales.d.ts +31 -0
  21. package/lib/import/modules/locales.js +152 -0
  22. package/lib/import/modules-js/assets.d.ts +33 -0
  23. package/lib/import/modules-js/assets.js +415 -0
  24. package/lib/import/modules-js/content-types.d.ts +33 -0
  25. package/lib/import/modules-js/content-types.js +176 -0
  26. package/lib/import/modules-js/custom-roles.d.ts +15 -0
  27. package/lib/import/modules-js/custom-roles.js +141 -0
  28. package/lib/import/modules-js/entries.d.ts +54 -0
  29. package/lib/import/modules-js/entries.js +1260 -0
  30. package/lib/import/modules-js/environments.d.ts +13 -0
  31. package/lib/import/modules-js/environments.js +85 -0
  32. package/lib/import/modules-js/extensions.d.ts +17 -0
  33. package/lib/import/modules-js/extensions.js +86 -0
  34. package/lib/import/modules-js/global-fields.d.ts +13 -0
  35. package/lib/import/modules-js/global-fields.js +109 -0
  36. package/lib/import/modules-js/index.d.ts +1 -0
  37. package/lib/import/modules-js/index.js +33 -0
  38. package/lib/import/modules-js/labels.d.ts +20 -0
  39. package/lib/import/modules-js/labels.js +148 -0
  40. package/lib/import/modules-js/locales.d.ts +24 -0
  41. package/lib/import/modules-js/locales.js +196 -0
  42. package/lib/import/modules-js/marketplace-apps.d.ts +60 -0
  43. package/lib/import/modules-js/marketplace-apps.js +409 -0
  44. package/lib/import/modules-js/webhooks.d.ts +17 -0
  45. package/lib/import/modules-js/webhooks.js +85 -0
  46. package/lib/import/modules-js/workflows.d.ts +18 -0
  47. package/lib/import/modules-js/workflows.js +132 -0
  48. package/lib/types/default-config.d.ts +130 -0
  49. package/lib/types/default-config.js +2 -0
  50. package/lib/types/import-config.d.ts +51 -0
  51. package/lib/types/import-config.js +2 -0
  52. package/lib/types/index.d.ts +30 -0
  53. package/lib/types/index.js +2 -0
  54. package/lib/utils/asset-helper.d.ts +4 -0
  55. package/lib/utils/asset-helper.js +387 -0
  56. package/lib/utils/backup-handler.d.ts +2 -0
  57. package/lib/utils/backup-handler.js +31 -0
  58. package/lib/utils/common-helper.d.ts +20 -0
  59. package/lib/utils/common-helper.js +244 -0
  60. package/lib/utils/content-type-helper.d.ts +49 -0
  61. package/lib/utils/content-type-helper.js +143 -0
  62. package/lib/utils/entries-helper.d.ts +4 -0
  63. package/lib/utils/entries-helper.js +252 -0
  64. package/lib/utils/extension-helper.d.ts +10 -0
  65. package/lib/utils/extension-helper.js +72 -0
  66. package/lib/utils/file-helper.d.ts +14 -0
  67. package/lib/utils/file-helper.js +140 -0
  68. package/lib/utils/import-config-handler.d.ts +3 -0
  69. package/lib/utils/import-config-handler.js +73 -0
  70. package/lib/utils/index.d.ts +12 -0
  71. package/lib/utils/index.js +29 -0
  72. package/lib/utils/interactive.d.ts +2 -0
  73. package/lib/utils/interactive.js +23 -0
  74. package/lib/utils/logger.d.ts +8 -0
  75. package/lib/utils/logger.js +154 -0
  76. package/lib/utils/login-handler.d.ts +8 -0
  77. package/lib/utils/login-handler.js +53 -0
  78. package/lib/utils/marketplace-app-helper.d.ts +4 -0
  79. package/lib/utils/marketplace-app-helper.js +31 -0
  80. package/messages/index.json +1 -7
  81. package/oclif.manifest.json +2 -2
  82. package/package.json +47 -21
  83. package/src/app.js +0 -217
  84. package/src/commands/cm/stacks/import.js +0 -161
  85. package/src/config/default.js +0 -352
  86. package/src/lib/import/assets.js +0 -495
  87. package/src/lib/import/content-types.js +0 -201
  88. package/src/lib/import/custom-roles.js +0 -169
  89. package/src/lib/import/entries.js +0 -1495
  90. package/src/lib/import/environments.js +0 -106
  91. package/src/lib/import/extensions.js +0 -108
  92. package/src/lib/import/global-fields.js +0 -135
  93. package/src/lib/import/labels.js +0 -175
  94. package/src/lib/import/locales.js +0 -216
  95. package/src/lib/import/marketplace-apps.js +0 -542
  96. package/src/lib/import/webhooks.js +0 -113
  97. package/src/lib/import/workflows.js +0 -166
  98. package/src/lib/util/extensionsUidReplace.js +0 -67
  99. package/src/lib/util/fs.js +0 -124
  100. package/src/lib/util/import-flags.js +0 -187
  101. package/src/lib/util/index.js +0 -222
  102. package/src/lib/util/log.js +0 -144
  103. package/src/lib/util/login.js +0 -58
  104. package/src/lib/util/lookupReplaceAssets.js +0 -366
  105. package/src/lib/util/lookupReplaceEntries.js +0 -250
  106. package/src/lib/util/marketplace-app-helper.js +0 -31
  107. package/src/lib/util/removeReferenceFields.js +0 -59
  108. package/src/lib/util/schemaTemplate.js +0 -38
  109. package/src/lib/util/supress-mandatory-fields.js +0 -34
  110. package/src/lib/util/upload.js +0 -56
@@ -1,38 +0,0 @@
1
- module.exports = {
2
- content_type: {
3
- title: 'Seed',
4
- uid: '',
5
- schema: [
6
- {
7
- display_name: 'Title',
8
- uid: 'title',
9
- data_type: 'text',
10
- field_metadata: {
11
- _default: true,
12
- },
13
- unique: false,
14
- mandatory: true,
15
- multiple: false,
16
- },
17
- {
18
- display_name: 'URL',
19
- uid: 'url',
20
- data_type: 'text',
21
- field_metadata: {
22
- _default: true,
23
- },
24
- unique: false,
25
- multiple: false,
26
- },
27
- ],
28
- options: {
29
- title: 'title',
30
- publishable: true,
31
- is_page: true,
32
- singleton: false,
33
- sub_title: ['url'],
34
- url_pattern: '/:title',
35
- url_prefix: '/',
36
- },
37
- },
38
- };
@@ -1,34 +0,0 @@
1
- /*!
2
- * Contentstack Import
3
- * Copyright (c) 2019 Contentstack LLC
4
- * MIT Licensed
5
- */
6
-
7
- var supress = (module.exports = function (schema, flag) {
8
- for (var i in schema) {
9
- if (schema[i].data_type === 'group' || schema[i].data_type === 'global_field') {
10
- supress(schema[i].schema, flag);
11
- } else if (schema[i].data_type === 'blocks') {
12
- for (var block in schema[i].blocks) {
13
- supress(schema[i].blocks[block].schema, flag);
14
- }
15
- } else if (schema[i].data_type === 'reference') {
16
- flag.references = true;
17
- } else if (schema[i].data_type === 'json' && schema[i].field_metadata.rich_text_type) {
18
- flag.jsonRte = true
19
- if (schema[i].field_metadata.embed_entry === true)
20
- flag.jsonRteEmbeddedEntries = true;
21
- }
22
-
23
- if (
24
- (schema[i].hasOwnProperty('mandatory') && schema[i].mandatory) ||
25
- (schema[i].hasOwnProperty('unique') && schema[i].unique)
26
- ) {
27
- if (schema[i].uid !== 'title') {
28
- schema[i].unique = false;
29
- schema[i].mandatory = false;
30
- flag.suppressed = true;
31
- }
32
- }
33
- }
34
- });
@@ -1,56 +0,0 @@
1
- /*!
2
- * Contentstack Import
3
- * Copyright (c) 2019 Contentstack LLC
4
- * MIT Licensed
5
- */
6
-
7
- 'use strict';
8
-
9
- const debug = require('debug')('util:requests');
10
- const MAX_RETRY_LIMIT = 5;
11
- const Bluebird = require('bluebird');
12
-
13
- const util = require('./index');
14
- const config = util.getConfig();
15
- const { managementSDKClient } = require('@contentstack/cli-utilities');
16
-
17
- function validate(req) {
18
- if (typeof req !== 'object') {
19
- throw new Error(`Invalid params passed for request\n${JSON.stringify(arguments)}`);
20
- }
21
- }
22
-
23
- const upload = (module.exports = function (req, fsPath, RETRY) {
24
- return new Bluebird(function (resolve, reject) {
25
- try {
26
- managementSDKClient(config)
27
- .then((APIClient) => {
28
- validate(req);
29
- if (typeof RETRY !== 'number') {
30
- RETRY = 1;
31
- } else if (RETRY > MAX_RETRY_LIMIT) {
32
- return reject(new Error('Max retry limit exceeded!'));
33
- }
34
-
35
- req.upload = fsPath;
36
- const stackAPIClient = APIClient.stack({
37
- api_key: config.target_stack,
38
- management_token: config.management_token,
39
- });
40
- stackAPIClient
41
- .asset()
42
- .create(req)
43
- .then((response) => {
44
- return resolve(response);
45
- })
46
- .catch((error) => {
47
- return reject(error);
48
- });
49
- })
50
- .catch(reject);
51
- } catch (error) {
52
- debug(error);
53
- return reject(error);
54
- }
55
- });
56
- });