@contentstack/cli-cm-import 1.7.0 → 1.7.1

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.
package/README.md CHANGED
@@ -47,7 +47,7 @@ $ npm install -g @contentstack/cli-cm-import
47
47
  $ csdx COMMAND
48
48
  running command...
49
49
  $ csdx (--version)
50
- @contentstack/cli-cm-import/1.7.0 linux-x64 node-v18.17.0
50
+ @contentstack/cli-cm-import/1.7.1 linux-x64 node-v18.17.0
51
51
  $ csdx --help [COMMAND]
52
52
  USAGE
53
53
  $ csdx COMMAND
@@ -291,7 +291,19 @@ class ImportMarketplaceApps extends base_class_1.default {
291
291
  if ((0, isEmpty_1.default)(app) || (0, isEmpty_1.default)(payload) || !uid) {
292
292
  return Promise.resolve();
293
293
  }
294
- await (0, utils_1.updateAppConfig)(this.sdkClient, this.importConfig, app, payload);
294
+ // TODO migrate this HTTP API call into SDK
295
+ // NOTE Use updateAppConfig(this.sdkClient, this.importConfig, app, payload) utility when migrating to SDK call;
296
+ return this.httpClient
297
+ .put(`${this.developerHubBaseUrl}/installations/${uid}`, payload)
298
+ .then(({ data }) => {
299
+ if (data.message) {
300
+ (0, utils_1.log)(this.importConfig, (0, utils_1.formatError)(data.message), 'success');
301
+ }
302
+ else {
303
+ (0, utils_1.log)(this.importConfig, `${app.manifest.name} app config updated successfully.!`, 'success');
304
+ }
305
+ })
306
+ .catch((error) => (0, utils_1.log)(this.importConfig, (0, utils_1.formatError)(error), 'error'));
295
307
  }
296
308
  }
297
309
  exports.default = ImportMarketplaceApps;
@@ -786,10 +786,15 @@ module.exports = class ImportEntries {
786
786
  return new Promise((resolve, reject) => {
787
787
  if (schema.field_rules) {
788
788
  let fieldRuleLength = schema.field_rules.length;
789
+ const fieldDatatypeMap = {};
790
+ for (let i = 0; i < schema.schema.length; i++) {
791
+ const field = schema.schema[i].uid;
792
+ fieldDatatypeMap[field] = schema.schema[i].data_type;
793
+ }
789
794
  for (let k = 0; k < fieldRuleLength; k++) {
790
795
  let fieldRuleConditionLength = schema.field_rules[k].conditions.length;
791
796
  for (let i = 0; i < fieldRuleConditionLength; i++) {
792
- if (schema.field_rules[k].conditions[i].operand_field === 'reference') {
797
+ if (fieldDatatypeMap[schema.field_rules[k].conditions[i].operand_field] === 'reference') {
793
798
  let fieldRulesValue = schema.field_rules[k].conditions[i].value;
794
799
  let fieldRulesArray = fieldRulesValue.split('.');
795
800
  let updatedValue = [];
@@ -824,6 +829,7 @@ module.exports = class ImportEntries {
824
829
  })
825
830
  .catch((error) => {
826
831
  log(this.config, `failed to update the field rules ${formatError(error)}`);
832
+ return reject(error);
827
833
  });
828
834
  });
829
835
  }
@@ -142,7 +142,9 @@ module.exports = class ImportMarketplaceApps {
142
142
  listOfNewMeta.push(..._.map(app.ui_location && app.ui_location.locations, 'meta').flat());
143
143
  }
144
144
  for (const { extension_uid, name, path, uid, data_type } of _.filter(listOfOldMeta, 'name')) {
145
- const meta = _.find(listOfNewMeta, { name, path }) || _.find(listOfNewMeta, { name: this.appNameMapping[name], path }) || _.find(listOfNewMeta, { name, uid, data_type });
145
+ const meta = _.find(listOfNewMeta, { name, path }) ||
146
+ _.find(listOfNewMeta, { name: this.appNameMapping[name], path }) ||
147
+ _.find(listOfNewMeta, { name, uid, data_type });
146
148
  if (meta) {
147
149
  extensionUidMapp[extension_uid] = meta.extension_uid;
148
150
  }
@@ -386,15 +388,13 @@ module.exports = class ImportMarketplaceApps {
386
388
  if (_.isEmpty(app) || _.isEmpty(payload) || !uid) {
387
389
  return Promise.resolve();
388
390
  }
389
- let installation = this.client
390
- .organization(this.config.org_uid)
391
- .app(app.manifest.uid)
392
- .installation(uid);
393
- installation = Object.assign(installation, payload);
394
- return installation
395
- .update()
396
- .then(async (data) => {
397
- if (data) {
391
+ return this.httpClient
392
+ .put(`${this.developerHubBaseUrl}/installations/${uid}`, payload)
393
+ .then(({ data }) => {
394
+ if (data.message) {
395
+ log(this.config, formatError(data.message), 'success');
396
+ }
397
+ else {
398
398
  log(this.config, `${app.manifest.name} app config updated successfully.!`, 'success');
399
399
  }
400
400
  })
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.7.0",
2
+ "version": "1.7.1",
3
3
  "commands": {
4
4
  "cm:stacks:import": {
5
5
  "id": "cm:stacks:import",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@contentstack/cli-cm-import",
3
3
  "description": "Contentstack CLI plugin to import content into stack",
4
- "version": "1.7.0",
4
+ "version": "1.7.1",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "dependencies": {