@lingk/sync 1.1.3 → 1.1.5

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
@@ -5706,6 +5706,11 @@ module.exports =
5706
5706
  });
5707
5707
  };
5708
5708
 
5709
+ _this.downloadFile = function (e, file) {
5710
+ e.preventDefault();
5711
+ _this.props.downloadFileFromAws(file);
5712
+ };
5713
+
5709
5714
  _this.state = {
5710
5715
  meta: [],
5711
5716
  fileContents: [],
@@ -5718,6 +5723,8 @@ module.exports =
5718
5723
  _createClass(FlatFile, [{
5719
5724
  key: 'render',
5720
5725
  value: function render() {
5726
+ var _this2 = this;
5727
+
5721
5728
  var _state = this.state,
5722
5729
  meta = _state.meta,
5723
5730
  uploading = _state.uploading,
@@ -5822,9 +5829,19 @@ module.exports =
5822
5829
  return _react2.default.createElement(
5823
5830
  'li',
5824
5831
  { key: i, style: { listStyle: 'none' } },
5825
- f.name,
5826
- ' - ',
5827
- formatBytes(f.byteSize)
5832
+ _react2.default.createElement(
5833
+ 'a',
5834
+ { onClick: function onClick(e) {
5835
+ return _this2.downloadFile(e, f);
5836
+ } },
5837
+ f.name
5838
+ ),
5839
+ _react2.default.createElement(
5840
+ 'span',
5841
+ null,
5842
+ ' - ',
5843
+ formatBytes(f.byteSize)
5844
+ )
5828
5845
  );
5829
5846
  })
5830
5847
  )
@@ -6148,7 +6165,8 @@ module.exports =
6148
6165
  envCheckResult = _props.envCheckResult,
6149
6166
  clearCsvFields = _props.clearCsvFields,
6150
6167
  formValues = _props.formValues,
6151
- change = _props.change;
6168
+ change = _props.change,
6169
+ downloadFileFromAws = _props.downloadFileFromAws;
6152
6170
 
6153
6171
 
6154
6172
  var Button = inputs.Button;
@@ -6195,13 +6213,16 @@ module.exports =
6195
6213
  },
6196
6214
  checkOauthCreds: checkOauthCreds, envCheckResult: envCheckResult,
6197
6215
  checking: checking, inputs: inputs, formValues: formValues,
6198
- isWiz: _react2.default.Children.count(this.props.children) > 0 }) : isFlatFile ? _react2.default.createElement(_flatfile2.default, { wizard: wizard, onCheck: check, metadata: metadata,
6216
+ isWiz: _react2.default.Children.count(this.props.children) > 0
6217
+ }) : isFlatFile ? _react2.default.createElement(_flatfile2.default, { wizard: wizard, onCheck: check, metadata: metadata,
6199
6218
  checking: checking, setCsvFields: setCsvFields,
6200
6219
  providerType: providerType, inputs: inputs,
6201
6220
  accountKey: accountKey, tenantKey: tenantKey,
6202
- onDrop: clearCsvFields }) : isGoogle ? _react2.default.createElement(_google2.default, { config: config, creds: creds, onChange: this.onChange,
6221
+ onDrop: clearCsvFields, downloadFileFromAws: downloadFileFromAws
6222
+ }) : isGoogle ? _react2.default.createElement(_google2.default, { config: config, creds: creds, onChange: this.onChange,
6203
6223
  credsDisabledCheck: credsDisabledCheck, inputs: inputs,
6204
- onCheck: check }) : _react2.default.createElement(
6224
+ onCheck: check
6225
+ }) : _react2.default.createElement(
6205
6226
  'div',
6206
6227
  null,
6207
6228
  !noRootUrl && _react2.default.createElement(
@@ -50355,6 +50376,8 @@ module.exports =
50355
50376
  exports.clearCsvFields = clearCsvFields;
50356
50377
  exports.uploadFilesToS3 = uploadFilesToS3;
50357
50378
  exports.singleFileToS3 = singleFileToS3;
50379
+ exports.downloadFileFromAws = downloadFileFromAws;
50380
+ exports.downloadFileFromS3 = downloadFileFromS3;
50358
50381
  exports.getOauthUrl = getOauthUrl;
50359
50382
  exports.generateNewAdapterSecret = generateNewAdapterSecret;
50360
50383
  exports.createLingkExternalIds = createLingkExternalIds;
@@ -50690,6 +50713,57 @@ module.exports =
50690
50713
  });
50691
50714
  }
50692
50715
 
50716
+ function downloadFileFromAws(tenantId, appId, tenantKey, appKey, file) {
50717
+ return function (dispatch, getState, api) {
50718
+ var _getState5 = getState(),
50719
+ config = _getState5.config;
50720
+
50721
+ console.log(file);
50722
+ return api.get(tenantId + '/' + appId + '/downloadpolicy/' + file.fileHash, {
50723
+ endpoint: config.TRANS_API_URL
50724
+ }).then(function (d) {
50725
+ return (0, _axios2.default)({
50726
+ method: 'get',
50727
+ url: d
50728
+ });
50729
+ }).then(function (f) {
50730
+ var extension = file.name.substr(file.name.lastIndexOf('.') + 1, file.name.length);
50731
+ console.log(extension);
50732
+ var mime = 'data:text/plain;charset=utf-8,'; // csv
50733
+ if (extension === 'json') {
50734
+ mime = 'data:text/json;charset=utf-8,';
50735
+ } else if (extension === 'xls') {
50736
+ mime = 'application/vnd.ms-excel;';
50737
+ } else if (extension === 'xlsx') {
50738
+ mime = 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;';
50739
+ }
50740
+ // NEED TO DOWNLOAD DEPENDING ON TYPE, JSON VS XLS
50741
+ var element = document.createElement('a');
50742
+ element.setAttribute('href', mime + encodeURIComponent(f.data));
50743
+ element.setAttribute('download', file.name);
50744
+ element.style.display = 'none';
50745
+ document.body.appendChild(element);
50746
+ element.click();
50747
+ document.body.removeChild(element);
50748
+ });
50749
+ };
50750
+ }
50751
+
50752
+ function downloadFileFromS3(tenantKey, appKey, d, file) {
50753
+ var p = JSON.parse(atob(d.policy));
50754
+ console.log(p, file);
50755
+ var pFind = function pFind(s) {
50756
+ return p.conditions.find(function (pf) {
50757
+ return Object.keys(pf).includes(s);
50758
+ })[s];
50759
+ };
50760
+ return (0, _axios2.default)({
50761
+ method: 'get',
50762
+ url: 'https://' + pFind('bucket') + '.s3.amazonaws.com/' + tenantKey + '/' + appKey + '/' + file.fileHash,
50763
+ config: { headers: { 'Content-Type': 'multipart/form-data' } }
50764
+ });
50765
+ }
50766
+
50693
50767
  // "fake" credentials for demo purposes
50694
50768
  function isDemoCreds(creds, providerType) {
50695
50769
  if (creds && providerType) {
@@ -50714,8 +50788,8 @@ module.exports =
50714
50788
  mode: mode
50715
50789
  });
50716
50790
 
50717
- var _getState5 = getState(),
50718
- config = _getState5.config;
50791
+ var _getState6 = getState(),
50792
+ config = _getState6.config;
50719
50793
 
50720
50794
  return api.get(tenantId + '/' + appId + '/environments/' + envName + '/oauthurl/9090b61412a74d97ad9ed02c5fx7e705/' + orgType, {
50721
50795
  endpoint: config.SF_AGENT_API_URL
@@ -50732,9 +50806,9 @@ module.exports =
50732
50806
 
50733
50807
  function generateNewAdapterSecret(tenantId, accountId, envName, mode) {
50734
50808
  return function (dispatch, getState, api) {
50735
- var _getState6 = getState(),
50736
- config = _getState6.config,
50737
- wizard = _getState6.wizard;
50809
+ var _getState7 = getState(),
50810
+ config = _getState7.config,
50811
+ wizard = _getState7.wizard;
50738
50812
 
50739
50813
  var TRANS_API_URL = config.TRANS_API_URL;
50740
50814
 
@@ -50751,8 +50825,8 @@ module.exports =
50751
50825
 
50752
50826
  function createLingkExternalIds(tenantId, appId, bundles, mappings, metadata, envName) {
50753
50827
  return function (dispatch, getState, api) {
50754
- var _getState7 = getState(),
50755
- config = _getState7.config;
50828
+ var _getState8 = getState(),
50829
+ config = _getState8.config;
50756
50830
 
50757
50831
  var externalIdlessObjects = [];
50758
50832
  // only run for Salesforce
@@ -50790,8 +50864,8 @@ module.exports =
50790
50864
 
50791
50865
  function callAddCustomField(tenantId, appId, objectType, fieldName, completedCallback, envName) {
50792
50866
  return function (dispatch, getState, api) {
50793
- var _getState8 = getState(),
50794
- config = _getState8.config;
50867
+ var _getState9 = getState(),
50868
+ config = _getState9.config;
50795
50869
 
50796
50870
  return api.post(tenantId + '/' + appId + '/environments/' + envName + '/salesforceschema/field', {
50797
50871
  endpoint: config.SF_AGENT_API_URL,
@@ -50859,8 +50933,8 @@ module.exports =
50859
50933
 
50860
50934
  function callGetScenarioList(tenantId, appId, typeGuid, isGlobal, isOrgAdmin) {
50861
50935
  return function (dispatch, getState, api) {
50862
- var _getState9 = getState(),
50863
- config = _getState9.config;
50936
+ var _getState10 = getState(),
50937
+ config = _getState10.config;
50864
50938
 
50865
50939
  return api.get(tenantId + '/' + appId + '/scenarios/' + typeGuid, {
50866
50940
  endpoint: config.TRANS_API_URL
@@ -50885,8 +50959,8 @@ module.exports =
50885
50959
 
50886
50960
  function callCreateScenario(tenantId, appId, data) {
50887
50961
  return function (dispatch, getState, api) {
50888
- var _getState10 = getState(),
50889
- config = _getState10.config;
50962
+ var _getState11 = getState(),
50963
+ config = _getState11.config;
50890
50964
 
50891
50965
  return api.post(tenantId + '/' + appId + '/scenario', {
50892
50966
  endpoint: config.TRANS_API_URL,
@@ -50897,8 +50971,8 @@ module.exports =
50897
50971
 
50898
50972
  function callUpdateScenarioList(tenantId, appId, typeGuid, scenarios, isGlobal) {
50899
50973
  return function (dispatch, getState, api) {
50900
- var _getState11 = getState(),
50901
- config = _getState11.config;
50974
+ var _getState12 = getState(),
50975
+ config = _getState12.config;
50902
50976
 
50903
50977
  return api.post(tenantId + '/' + appId + '/scenarios/' + typeGuid + (isGlobal ? '/global' : ''), {
50904
50978
  endpoint: config.TRANS_API_URL,
@@ -50917,8 +50991,8 @@ module.exports =
50917
50991
 
50918
50992
  function callPostBundles(tenantId, appId, bundles, onGenerationError) {
50919
50993
  return function (dispatch, getState, api) {
50920
- var _getState12 = getState(),
50921
- config = _getState12.config;
50994
+ var _getState13 = getState(),
50995
+ config = _getState13.config;
50922
50996
 
50923
50997
  var data = { bundles: bundles };
50924
50998
  return api.post(tenantId + '/' + appId + '/bundle', {
@@ -50933,8 +51007,8 @@ module.exports =
50933
51007
 
50934
51008
  function callPostMapping(tenantId, appId, mappings, onGenerationError) {
50935
51009
  return function (dispatch, getState, api) {
50936
- var _getState13 = getState(),
50937
- config = _getState13.config;
51010
+ var _getState14 = getState(),
51011
+ config = _getState14.config;
50938
51012
 
50939
51013
  var data = { mappings: mappings };
50940
51014
  return api.post(tenantId + '/' + appId + '/schemamappings', {
@@ -50949,8 +51023,8 @@ module.exports =
50949
51023
 
50950
51024
  function callPostProductizedIntegration(tenantId, appId, schemaMappingGuid, bundlePackGuid, configuration, title, typeGuid, piGuid, onGenerationError) {
50951
51025
  return function (dispatch, getState, api) {
50952
- var _getState14 = getState(),
50953
- config = _getState14.config;
51026
+ var _getState15 = getState(),
51027
+ config = _getState15.config;
50954
51028
 
50955
51029
  var data = Object.assign({
50956
51030
  schemaMappingGuid: schemaMappingGuid,
@@ -50971,8 +51045,8 @@ module.exports =
50971
51045
 
50972
51046
  function callUpdateProductizedIntegration(tenantId, appId, schemaMappingGuid, bundlePackGuid, configuration, title, typeGuid, piGuid, onGenerationError) {
50973
51047
  return function (dispatch, getState, api) {
50974
- var _getState15 = getState(),
50975
- config = _getState15.config;
51048
+ var _getState16 = getState(),
51049
+ config = _getState16.config;
50976
51050
 
50977
51051
  var data = {
50978
51052
  schemaMappingGuid: schemaMappingGuid,
@@ -50993,8 +51067,8 @@ module.exports =
50993
51067
 
50994
51068
  function callGenerateRecipe(tenantId, appId, typeId, typeGuid, title, piGuid, mappingGuid, sourceMetadata, destinationMetadata, isManagedPackage, onGenerationError, envName, envId) {
50995
51069
  return function (dispatch, getState, api) {
50996
- var _getState16 = getState(),
50997
- config = _getState16.config;
51070
+ var _getState17 = getState(),
51071
+ config = _getState17.config;
50998
51072
 
50999
51073
  return api.post(tenantId + '/' + appId + '/productizedintegrations/' + piGuid + '/generate', {
51000
51074
  endpoint: config.TRANS_API_URL,
@@ -51013,8 +51087,8 @@ module.exports =
51013
51087
 
51014
51088
  function trySaveFileSchema(tenantId, appId, schema) {
51015
51089
  return function (dispatch, getState, api) {
51016
- var _getState17 = getState(),
51017
- config = _getState17.config;
51090
+ var _getState18 = getState(),
51091
+ config = _getState18.config;
51018
51092
 
51019
51093
  if (schema && schema.resources) {
51020
51094
  return api.post(tenantId + '/' + appId + '/fileschema', {
@@ -51101,8 +51175,8 @@ module.exports =
51101
51175
 
51102
51176
  function callPostEventContext(data, transBaseId) {
51103
51177
  return function (dispatch, getState, api) {
51104
- var _getState18 = getState(),
51105
- config = _getState18.config;
51178
+ var _getState19 = getState(),
51179
+ config = _getState19.config;
51106
51180
 
51107
51181
  var TRANS_API_URL = config.TRANS_API_URL;
51108
51182
 
@@ -51115,8 +51189,8 @@ module.exports =
51115
51189
 
51116
51190
  function callExecuteTransformer(transId) {
51117
51191
  return function (dispatch, getState, api) {
51118
- var _getState19 = getState(),
51119
- config = _getState19.config;
51192
+ var _getState20 = getState(),
51193
+ config = _getState20.config;
51120
51194
 
51121
51195
  var query = '';
51122
51196
  var d = new Date();
@@ -51136,8 +51210,8 @@ module.exports =
51136
51210
 
51137
51211
  function callLookupLogData(tenantId, externalExecutionId, index, onFinish, generatedRecipe, pi) {
51138
51212
  return function (dispatch, getState, api) {
51139
- var _getState20 = getState(),
51140
- config = _getState20.config;
51213
+ var _getState21 = getState(),
51214
+ config = _getState21.config;
51141
51215
 
51142
51216
  return api.get(tenantId + '/logs/transformers/externalExecutionId/' + externalExecutionId, {
51143
51217
  endpoint: config.TRANS_API_URL
@@ -51208,8 +51282,8 @@ module.exports =
51208
51282
 
51209
51283
  function callGetLogSteps(tenantId, externalExecutionId, index, onFinish, generatedRecipe, pi) {
51210
51284
  return function (dispatch, getState, api) {
51211
- var _getState21 = getState(),
51212
- config = _getState21.config;
51285
+ var _getState22 = getState(),
51286
+ config = _getState22.config;
51213
51287
 
51214
51288
  var TRANS_API_URL = config.TRANS_API_URL;
51215
51289
 
@@ -51248,8 +51322,8 @@ module.exports =
51248
51322
  };
51249
51323
  }
51250
51324
  return function (dispatch, getState, api) {
51251
- var _getState22 = getState(),
51252
- config = _getState22.config;
51325
+ var _getState23 = getState(),
51326
+ config = _getState23.config;
51253
51327
 
51254
51328
  return api.post(tenantId + '/createtrigger', {
51255
51329
  endpoint: config.TRANS_API_URL,
@@ -51286,8 +51360,8 @@ module.exports =
51286
51360
 
51287
51361
  if (piGuid && piGuid !== '_') {
51288
51362
  return function (dispatch, getState, api) {
51289
- var _getState23 = getState(),
51290
- config = _getState23.config;
51363
+ var _getState24 = getState(),
51364
+ config = _getState24.config;
51291
51365
 
51292
51366
  return api.get(tenantId + '/' + accountId + '/productizedintegrations/' + piGuid + '/versions', {
51293
51367
  endpoint: config.TRANS_API_URL
@@ -51360,8 +51434,8 @@ module.exports =
51360
51434
 
51361
51435
  function clearAdapterSecrets() {
51362
51436
  return function (dispatch, getState, api) {
51363
- var _getState24 = getState(),
51364
- wizard = _getState24.wizard;
51437
+ var _getState25 = getState(),
51438
+ wizard = _getState25.wizard;
51365
51439
 
51366
51440
  dispatch({
51367
51441
  type: types.SET_WIZARD_SAVED_CREDENTIALS,
@@ -51375,8 +51449,8 @@ module.exports =
51375
51449
 
51376
51450
  function setLoadedAdapterSecret(cred, mode) {
51377
51451
  return function (dispatch, getState, api) {
51378
- var _getState25 = getState(),
51379
- wizard = _getState25.wizard;
51452
+ var _getState26 = getState(),
51453
+ wizard = _getState26.wizard;
51380
51454
 
51381
51455
  dispatch({
51382
51456
  type: types.SET_WIZARD_SAVED_CREDENTIALS,
@@ -51387,8 +51461,8 @@ module.exports =
51387
51461
 
51388
51462
  function getCredentialForEnvironment(tenantId, appId, credentialType, envName, mode) {
51389
51463
  return function (dispatch, getState, api) {
51390
- var _getState26 = getState(),
51391
- config = _getState26.config;
51464
+ var _getState27 = getState(),
51465
+ config = _getState27.config;
51392
51466
 
51393
51467
  return api.get(tenantId + '/' + appId + '/credentials/' + credentialType + '/' + envName, {
51394
51468
  endpoint: config.TRANS_API_URL
@@ -51439,8 +51513,8 @@ module.exports =
51439
51513
  function callGetBundles(tenantId, accountId, bundlePackGuid) {
51440
51514
  if (bundlePackGuid) {
51441
51515
  return function (dispatch, getState, api) {
51442
- var _getState27 = getState(),
51443
- config = _getState27.config;
51516
+ var _getState28 = getState(),
51517
+ config = _getState28.config;
51444
51518
 
51445
51519
  return api.get(tenantId + '/' + accountId + '/bundle/' + bundlePackGuid, {
51446
51520
  endpoint: config.TRANS_API_URL
@@ -51457,8 +51531,8 @@ module.exports =
51457
51531
  function callGetMapping(tenantId, accountId, mappingGuid) {
51458
51532
  if (mappingGuid) {
51459
51533
  return function (dispatch, getState, api) {
51460
- var _getState28 = getState(),
51461
- config = _getState28.config;
51534
+ var _getState29 = getState(),
51535
+ config = _getState29.config;
51462
51536
 
51463
51537
  return api.get(tenantId + '/' + accountId + '/schemamappings/' + mappingGuid, {
51464
51538
  endpoint: config.TRANS_API_URL
@@ -51479,8 +51553,8 @@ module.exports =
51479
51553
  mode: mode
51480
51554
  });
51481
51555
 
51482
- var _getState29 = getState(),
51483
- config = _getState29.config;
51556
+ var _getState30 = getState(),
51557
+ config = _getState30.config;
51484
51558
 
51485
51559
  return api.post(tenantId + '/' + appId + '/environments/' + envId + '/credentials', {
51486
51560
  endpoint: config.TRANS_API_URL,
@@ -51495,8 +51569,8 @@ module.exports =
51495
51569
 
51496
51570
  function getEnvironments(tenantId, appId) {
51497
51571
  return function (dispatch, getState, api) {
51498
- var _getState30 = getState(),
51499
- config = _getState30.config;
51572
+ var _getState31 = getState(),
51573
+ config = _getState31.config;
51500
51574
 
51501
51575
  return api.get(tenantId + '/' + appId + '/environments', {
51502
51576
  endpoint: config.TRANS_API_URL
@@ -51516,8 +51590,8 @@ module.exports =
51516
51590
 
51517
51591
  function callGetTrigger(transBaseId, envId) {
51518
51592
  return function (dispatch, getState, api) {
51519
- var _getState31 = getState(),
51520
- config = _getState31.config;
51593
+ var _getState32 = getState(),
51594
+ config = _getState32.config;
51521
51595
 
51522
51596
  if (transBaseId) {
51523
51597
  return api.get('gettriggers/' + transBaseId, {
@@ -55205,6 +55279,17 @@ module.exports =
55205
55279
  actions.generateNewAdapterSecret(tenantId, accountId, envName, mode);
55206
55280
  };
55207
55281
 
55282
+ _this.downloadFileFromAws = function (file) {
55283
+ var _this$props3 = _this.props,
55284
+ tenantId = _this$props3.tenantId,
55285
+ accountId = _this$props3.accountId,
55286
+ tenantKey = _this$props3.tenantKey,
55287
+ accountKey = _this$props3.accountKey,
55288
+ actions = _this$props3.actions;
55289
+
55290
+ return actions.downloadFileFromAws(tenantId, accountId, tenantKey, accountKey, file);
55291
+ };
55292
+
55208
55293
  _this.state = {
55209
55294
  selectedProvider: null,
55210
55295
  sourceEnvChecking: null,
@@ -55586,6 +55671,7 @@ module.exports =
55586
55671
  setCsvFields: function setCsvFields(meta, contents, providerType) {
55587
55672
  return _this4.setCsvFields(meta, contents, m, providerType);
55588
55673
  },
55674
+ downloadFileFromAws: _this4.downloadFileFromAws,
55589
55675
  clearCsvFields: function clearCsvFields() {
55590
55676
  return _this4.clearCsvFields(m);
55591
55677
  },