@lingk/sync 1.1.12 → 1.1.13

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/build/main.js CHANGED
@@ -5720,6 +5720,7 @@ module.exports =
5720
5720
 
5721
5721
  _this.setState({ uploading: true });
5722
5722
  setCsvFields(_this.state.meta, _this.state.fileContents, providerType).then(function () {
5723
+ console.log("SET META BACK");
5723
5724
  _this.setState({ meta: [], fileContents: [], uploading: false });
5724
5725
  });
5725
5726
  };
@@ -50689,7 +50690,7 @@ module.exports =
50689
50690
  data: { name: 'flatfile', resources: metadata, providerType: providerType, isSource: isSource }
50690
50691
  }).then(function (data) {
50691
50692
  d = data;
50692
- return dispatch(uploadFilesToS3(tenantKey, appKey, metadata, data, contents));
50693
+ return dispatch(uploadFilesToS3(tenantKey, appKey, envId, metadata, data, contents));
50693
50694
  }).then(function () {
50694
50695
  return dispatch(postCredentials(tenantId, appId, providerType, d.guids, mode, envId, 'FlatFile')).then(function () {
50695
50696
  dispatch({
@@ -50731,10 +50732,10 @@ module.exports =
50731
50732
  };
50732
50733
  }
50733
50734
 
50734
- function uploadFilesToS3(tenantKey, appKey, metadata, d, contents) {
50735
+ function uploadFilesToS3(tenantKey, appKey, envId, metadata, d, contents) {
50735
50736
  console.log("UPLOAD", metadata, contents);
50736
50737
  var args = contents.map(function (fileContent, i) {
50737
- return { tenantKey: tenantKey, appKey: appKey, fileContent: fileContent, d: d, fileName: metadata[i].type };
50738
+ return { tenantKey: tenantKey, appKey: appKey, envId: envId, fileContent: fileContent, d: d, fileName: metadata[i].name };
50738
50739
  });
50739
50740
  return function (dispatch, getState, api) {
50740
50741
  return Promise.all(args.map(singleFileToS3));
@@ -50744,15 +50745,15 @@ module.exports =
50744
50745
  function singleFileToS3(_ref) {
50745
50746
  var tenantKey = _ref.tenantKey,
50746
50747
  appKey = _ref.appKey,
50748
+ envId = _ref.envId,
50747
50749
  d = _ref.d,
50748
50750
  fileContent = _ref.fileContent,
50749
50751
  fileName = _ref.fileName;
50750
50752
 
50751
- if (!d.guids.files[fileName]) {
50752
- return function () {
50753
- return Promise.resolve(null);
50754
- };
50755
- }
50753
+ console.log(fileName, d);
50754
+ /*if(!d.guids.files[fileName]){
50755
+ return () => Promise.resolve(null)
50756
+ }*/
50756
50757
  var p = JSON.parse(atob(d.policy));
50757
50758
  console.log(p);
50758
50759
  var pFind = function pFind(s) {
@@ -50761,7 +50762,7 @@ module.exports =
50761
50762
  })[s];
50762
50763
  };
50763
50764
  var fd = new FormData();
50764
- fd.append('key', tenantKey + '/' + appKey + '/' + d.guids.files[fileName]);
50765
+ fd.append('key', tenantKey + '/' + appKey + '/' + envId + '/' + fileName);
50765
50766
  fd.append('policy', d.policy);
50766
50767
  fd.append('acl', pFind('acl'));
50767
50768
  fd.append('success_action_status', pFind('success_action_status'));
@@ -50778,43 +50779,53 @@ module.exports =
50778
50779
  });
50779
50780
  }
50780
50781
 
50781
- function downloadFileFromAws(tenantId, appId, tenantKey, appKey, file) {
50782
+ function downloadFileFromAws(tenantId, appId, tenantKey, appKey, envId, file) {
50783
+ console.log(file);
50782
50784
  return function (dispatch, getState, api) {
50783
50785
  var _getState5 = getState(),
50784
50786
  config = _getState5.config;
50785
50787
 
50786
- return api.get(tenantId + '/' + appId + '/downloadpolicy/' + file.fileHash, {
50788
+ return api.get(tenantId + '/' + appId + '/' + envId + '/downloadpolicy/' + file.name, {
50787
50789
  endpoint: config.TRANS_API_URL
50788
50790
  }).then(function (d) {
50789
- return (0, _axios2.default)({
50791
+ var element = document.createElement('a');
50792
+ element.setAttribute('href', d);
50793
+ element.style.display = 'none';
50794
+ document.body.appendChild(element);
50795
+ element.click();
50796
+ document.body.removeChild(element);
50797
+ });
50798
+ /*.then(d => {
50799
+ return axios({
50790
50800
  method: 'get',
50791
- url: d
50792
- });
50793
- }).then(function (f) {
50794
- var extension = file.name.substr(file.name.lastIndexOf('.') + 1, file.name.length);
50795
- var mime = 'data:text/plain;charset=utf-8,'; // csv
50796
- var data = f.data;
50797
- if (extension === 'json') {
50798
- console.log('json!!!!');
50799
- mime = 'data:text/json;charset=utf-8,';
50800
- data = encodeURIComponent(JSON.stringify(f.data));
50801
- } else if (extension === 'xls') {
50802
- mime = 'data:application/vnd.ms-excel;charset=utf-8,';
50803
- data = encodeURIComponent(f.data);
50804
- } else if (extension === 'xlsx') {
50805
- mime = 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8,';
50806
- data = encodeURIComponent(f.data);
50807
- }
50808
- console.log(data);
50801
+ url: d,
50802
+ })
50803
+ })
50804
+ .then((f)=>{
50805
+ const extension = file.name.substr(file.name.lastIndexOf('.')+1, file.name.length)
50806
+ let mime = 'data:text/plain;charset=utf-8,' // csv
50807
+ let data = f.data
50808
+ if(extension==='json'){
50809
+ console.log('json!!!!')
50810
+ mime = 'data:text/json;charset=utf-8,'
50811
+ data = encodeURIComponent(JSON.stringify(f.data))
50812
+ } else if(extension==='xls'){
50813
+ mime = 'data:application/vnd.ms-excel;charset=utf-8,'
50814
+ data = encodeURIComponent(f.data)
50815
+ } else if(extension==='xlsx'){
50816
+ mime = 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8,'
50817
+ data = encodeURIComponent(f.data)
50818
+ }
50819
+ console.log(data)
50809
50820
  // NEED TO DOWNLOAD DEPENDING ON TYPE, JSON VS XLS
50810
- var element = document.createElement('a');
50821
+ const element = document.createElement('a');
50811
50822
  element.setAttribute('href', mime + data);
50812
50823
  element.setAttribute('download', 'hi.xlsx');
50813
50824
  element.style.display = 'none';
50814
50825
  document.body.appendChild(element);
50815
50826
  element.click();
50816
50827
  document.body.removeChild(element);
50817
- });
50828
+ })*/
50818
50829
  };
50819
50830
  }
50820
50831
 
@@ -50828,7 +50839,7 @@ module.exports =
50828
50839
  };
50829
50840
  return (0, _axios2.default)({
50830
50841
  method: 'get',
50831
- url: 'https://' + pFind('bucket') + '.s3.amazonaws.com/' + tenantKey + '/' + appKey + '/' + file.fileHash,
50842
+ url: 'https://' + pFind('bucket') + '.s3.amazonaws.com/' + tenantKey + '/' + appKey + '/' + file.name,
50832
50843
  config: { headers: { 'Content-Type': 'multipart/form-data' } }
50833
50844
  });
50834
50845
  }
@@ -55354,16 +55365,16 @@ module.exports =
55354
55365
  accountId = _this$props3.accountId,
55355
55366
  tenantKey = _this$props3.tenantKey,
55356
55367
  accountKey = _this$props3.accountKey,
55357
- actions = _this$props3.actions;
55368
+ actions = _this$props3.actions,
55369
+ formValues = _this$props3.formValues;
55358
55370
 
55359
- return actions.downloadFileFromAws(tenantId, accountId, tenantKey, accountKey, file);
55371
+ return actions.downloadFileFromAws(tenantId, accountId, tenantKey, accountKey, formValues['environmentId'], file);
55360
55372
  };
55361
55373
 
55362
55374
  _this.state = {
55363
55375
  selectedProvider: null,
55364
55376
  sourceEnvChecking: null,
55365
- destinationEnvChecking: null,
55366
- selectedEnvironment: null
55377
+ destinationEnvChecking: null
55367
55378
  };
55368
55379
  _this.check = _this.check.bind(_this);
55369
55380
  _this.tryGetCredentialAndCheck = _this.tryGetCredentialAndCheck.bind(_this);
@@ -55452,20 +55463,23 @@ module.exports =
55452
55463
  if (_this2.props.formValues[mode + 'FileSchema']) {
55453
55464
  savedFileSchema = [].concat(_toConsumableArray(formValues[mode + 'FileSchema']));
55454
55465
  }
55455
- change(mode + 'FileSchema', {
55456
- resources: metadata.map(function (r) {
55457
- var existing = savedFileSchema.find(function (rsc) {
55458
- return r.name === rsc.name && r.type === rsc.type;
55459
- });
55460
- if (existing) return existing;
55461
- return Object.assign({}, r, {
55462
- filePattern: r.name,
55463
- delimiter: ','
55464
- });
55465
- })
55466
- });
55466
+ change(mode + 'FileSchema', metadata.map(function (r) {
55467
+ var existing = savedFileSchema.find(function (rsc) {
55468
+ return r.name === rsc.name && r.type === rsc.type;
55469
+ });
55470
+ if (existing) return existing;
55471
+ return Object.assign({}, r, {
55472
+ filePattern: r.name,
55473
+ delimiter: ','
55474
+ });
55475
+ }));
55467
55476
  })();
55468
55477
  }
55478
+
55479
+ var isFlat = metadata && metadata[0] && metadata[0].uploadedTime;
55480
+ if (isFlat) {
55481
+ change(mode + 'FileSchema', metadata);
55482
+ }
55469
55483
  });
55470
55484
  }
55471
55485
  }, {
@@ -55561,7 +55575,7 @@ module.exports =
55561
55575
  }
55562
55576
  }, {
55563
55577
  key: 'setCsvFields',
55564
- value: function setCsvFields(metadata, contents, mode, providerType) {
55578
+ value: function setCsvFields(meta, contents, mode, providerType) {
55565
55579
  var _this4 = this;
55566
55580
 
55567
55581
  var _props7 = this.props,
@@ -55569,12 +55583,11 @@ module.exports =
55569
55583
  accountId = _props7.accountId,
55570
55584
  tenantKey = _props7.tenantKey,
55571
55585
  accountKey = _props7.accountKey,
55572
- wizard = _props7.wizard,
55573
55586
  actions = _props7.actions,
55574
55587
  formValues = _props7.formValues;
55588
+ //let meta = wizard[`${mode}Metadata`] || []
55589
+ //meta = meta.concat(metadata)
55575
55590
 
55576
- var meta = wizard[mode + 'Metadata'] || [];
55577
- meta = meta.concat(metadata);
55578
55591
  return actions.setCsvFields(tenantId, accountId, tenantKey, accountKey, meta, contents, mode, providerType, mode === 'source', formValues['environmentId']).then(function (d) {
55579
55592
  // get the new list of files
55580
55593
  return _this4.check(mode, null, d, null, '');
@@ -55737,7 +55750,7 @@ module.exports =
55737
55750
  return _this5.generateNewAdapterSecret(m);
55738
55751
  },
55739
55752
  seeFields: _this5.seeFields.bind(_this5),
55740
- fileSchema: wizard[m + 'Metadata'],
55753
+ fileSchema: formValues[m + 'FileSchema'],
55741
55754
  check: function check(actualCreds, extraQuery) {
55742
55755
  _this5.check(m, null, actualCreds, null, extraQuery);
55743
55756
  }, change: change,