@contentstack/cli-cm-import 1.5.11 → 1.7.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 (126) 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 +395 -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 +70 -0
  17. package/lib/import/modules/base-class.js +218 -0
  18. package/lib/import/modules/content-types.d.ts +56 -0
  19. package/lib/import/modules/content-types.js +186 -0
  20. package/lib/import/modules/custom-roles.d.ts +37 -0
  21. package/lib/import/modules/custom-roles.js +171 -0
  22. package/lib/import/modules/environments.d.ts +27 -0
  23. package/lib/import/modules/environments.js +106 -0
  24. package/lib/import/modules/extensions.d.ts +27 -0
  25. package/lib/import/modules/extensions.js +106 -0
  26. package/lib/import/modules/global-fields.d.ts +34 -0
  27. package/lib/import/modules/global-fields.js +99 -0
  28. package/lib/import/modules/index.d.ts +2 -0
  29. package/lib/import/modules/index.js +19 -0
  30. package/lib/import/modules/labels.d.ts +34 -0
  31. package/lib/import/modules/labels.js +171 -0
  32. package/lib/import/modules/locales.d.ts +31 -0
  33. package/lib/import/modules/locales.js +144 -0
  34. package/lib/import/modules/marketplace-apps.d.ts +51 -0
  35. package/lib/import/modules/marketplace-apps.js +297 -0
  36. package/lib/import/modules/webhooks.d.ts +27 -0
  37. package/lib/import/modules/webhooks.js +110 -0
  38. package/lib/import/modules-js/assets.d.ts +33 -0
  39. package/lib/import/modules-js/assets.js +415 -0
  40. package/lib/import/modules-js/content-types.d.ts +33 -0
  41. package/lib/import/modules-js/content-types.js +176 -0
  42. package/lib/import/modules-js/custom-roles.d.ts +15 -0
  43. package/lib/import/modules-js/custom-roles.js +143 -0
  44. package/lib/import/modules-js/entries.d.ts +54 -0
  45. package/lib/import/modules-js/entries.js +1260 -0
  46. package/lib/import/modules-js/environments.d.ts +13 -0
  47. package/lib/import/modules-js/environments.js +85 -0
  48. package/lib/import/modules-js/extensions.d.ts +18 -0
  49. package/lib/import/modules-js/extensions.js +86 -0
  50. package/lib/import/modules-js/global-fields.d.ts +13 -0
  51. package/lib/import/modules-js/global-fields.js +109 -0
  52. package/lib/import/modules-js/index.d.ts +1 -0
  53. package/lib/import/modules-js/index.js +33 -0
  54. package/lib/import/modules-js/labels.d.ts +20 -0
  55. package/lib/import/modules-js/labels.js +148 -0
  56. package/lib/import/modules-js/locales.d.ts +24 -0
  57. package/lib/import/modules-js/locales.js +196 -0
  58. package/lib/import/modules-js/marketplace-apps.d.ts +60 -0
  59. package/lib/import/modules-js/marketplace-apps.js +409 -0
  60. package/lib/import/modules-js/webhooks.d.ts +17 -0
  61. package/lib/import/modules-js/webhooks.js +85 -0
  62. package/lib/import/modules-js/workflows.d.ts +18 -0
  63. package/lib/import/modules-js/workflows.js +132 -0
  64. package/lib/types/default-config.d.ts +143 -0
  65. package/lib/types/default-config.js +2 -0
  66. package/lib/types/import-config.d.ts +52 -0
  67. package/lib/types/import-config.js +2 -0
  68. package/lib/types/index.d.ts +63 -0
  69. package/lib/types/index.js +4 -0
  70. package/lib/utils/asset-helper.d.ts +4 -0
  71. package/lib/utils/asset-helper.js +387 -0
  72. package/lib/utils/backup-handler.d.ts +2 -0
  73. package/lib/utils/backup-handler.js +31 -0
  74. package/lib/utils/common-helper.d.ts +20 -0
  75. package/lib/utils/common-helper.js +244 -0
  76. package/lib/utils/content-type-helper.d.ts +51 -0
  77. package/lib/utils/content-type-helper.js +145 -0
  78. package/lib/utils/entries-helper.d.ts +4 -0
  79. package/lib/utils/entries-helper.js +252 -0
  80. package/lib/utils/extension-helper.d.ts +5 -0
  81. package/lib/utils/extension-helper.js +84 -0
  82. package/lib/utils/file-helper.d.ts +14 -0
  83. package/lib/utils/file-helper.js +140 -0
  84. package/lib/utils/import-config-handler.d.ts +3 -0
  85. package/lib/utils/import-config-handler.js +73 -0
  86. package/lib/utils/index.d.ts +12 -0
  87. package/lib/utils/index.js +39 -0
  88. package/lib/utils/interactive.d.ts +7 -0
  89. package/lib/utils/interactive.js +88 -0
  90. package/lib/utils/logger.d.ts +8 -0
  91. package/lib/utils/logger.js +154 -0
  92. package/lib/utils/login-handler.d.ts +8 -0
  93. package/lib/utils/login-handler.js +53 -0
  94. package/lib/utils/marketplace-app-helper.d.ts +16 -0
  95. package/lib/utils/marketplace-app-helper.js +143 -0
  96. package/messages/index.json +1 -7
  97. package/oclif.manifest.json +2 -2
  98. package/package.json +46 -20
  99. package/src/app.js +0 -217
  100. package/src/commands/cm/stacks/import.js +0 -161
  101. package/src/config/default.js +0 -352
  102. package/src/lib/import/assets.js +0 -495
  103. package/src/lib/import/content-types.js +0 -201
  104. package/src/lib/import/custom-roles.js +0 -169
  105. package/src/lib/import/entries.js +0 -1495
  106. package/src/lib/import/environments.js +0 -106
  107. package/src/lib/import/extensions.js +0 -108
  108. package/src/lib/import/global-fields.js +0 -135
  109. package/src/lib/import/labels.js +0 -175
  110. package/src/lib/import/locales.js +0 -216
  111. package/src/lib/import/marketplace-apps.js +0 -542
  112. package/src/lib/import/webhooks.js +0 -113
  113. package/src/lib/import/workflows.js +0 -166
  114. package/src/lib/util/extensionsUidReplace.js +0 -67
  115. package/src/lib/util/fs.js +0 -124
  116. package/src/lib/util/import-flags.js +0 -187
  117. package/src/lib/util/index.js +0 -222
  118. package/src/lib/util/log.js +0 -144
  119. package/src/lib/util/login.js +0 -58
  120. package/src/lib/util/lookupReplaceAssets.js +0 -366
  121. package/src/lib/util/lookupReplaceEntries.js +0 -250
  122. package/src/lib/util/marketplace-app-helper.js +0 -31
  123. package/src/lib/util/removeReferenceFields.js +0 -59
  124. package/src/lib/util/schemaTemplate.js +0 -38
  125. package/src/lib/util/supress-mandatory-fields.js +0 -34
  126. 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
- });