@lingk/sync 1.0.68 → 1.0.70

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
@@ -1527,10 +1527,15 @@ module.exports =
1527
1527
  // via parameter, dont change because its already "type"
1528
1528
  var nestedJoinKey = { property: rsc.joinKeyName };
1529
1529
  var joinKeyResource = rsc.joinKeyResource;
1530
- // is from a same resource (not via parameters)
1531
- if (sourceResource && sourceResource.name === rsc.joinKeyResource) {
1532
- nestedJoinKey = findNestedProp(rsc.joinKeyName, rsc.joinKeyParents, sourceResource);
1533
- joinKeyResource = sourceResource.type;
1530
+ var joinKeyIsParameter = false;
1531
+ if (sourceResource && rsc.joinKeyResource) {
1532
+ // is from a same resource (not via parameters)
1533
+ if (sourceResource.name === rsc.joinKeyResource) {
1534
+ nestedJoinKey = findNestedProp(rsc.joinKeyName, rsc.joinKeyParents, sourceResource);
1535
+ joinKeyResource = sourceResource.type;
1536
+ } else {
1537
+ joinKeyIsParameter = true;
1538
+ }
1534
1539
  }
1535
1540
 
1536
1541
  //make endpoint
@@ -1544,27 +1549,27 @@ module.exports =
1544
1549
  var nestedPrimaryKey = {};
1545
1550
  var primaryKeyResource = null;
1546
1551
  var primaryResourceProvider = null;
1547
- var primaryKeyResourceLabel = null;
1552
+ var primaryKeyIsParameter = false;
1548
1553
  if (rsc.parentNameAndProvider) {
1549
- (function () {
1550
- var primaryResourceProviderLast_Index = rsc.parentNameAndProvider.lastIndexOf('_');
1551
- primaryResourceProvider = rsc.parentNameAndProvider.substr(primaryResourceProviderLast_Index + 1, rsc.parentNameAndProvider.length);
1552
- var primaryResourceName = rsc.parentNameAndProvider.substr(0, primaryResourceProviderLast_Index);
1553
- var primaryDataSourceMetadata = primaryResourceProvider.toLowerCase() === targetProvider.toLowerCase() ? targetMetadata : sourceMetadata;
1554
- var primarySourceResource = primaryDataSourceMetadata.find(function (metaRsc) {
1555
- return metaRsc.name === primaryResourceName;
1556
- });
1554
+ var primaryResourceProviderLast_Index = rsc.parentNameAndProvider.lastIndexOf('_');
1555
+ primaryResourceProvider = rsc.parentNameAndProvider.substr(primaryResourceProviderLast_Index + 1, rsc.parentNameAndProvider.length);
1556
+ var primaryResourceName = rsc.parentNameAndProvider.substr(0, primaryResourceProviderLast_Index);
1557
+ var primaryDataSourceMetadata = primaryResourceProvider.toLowerCase() === targetProvider.toLowerCase() ? targetMetadata : sourceMetadata;
1558
+ var primarySourceResource = primaryDataSourceMetadata.find(function (metaRsc) {
1559
+ return metaRsc.name === rsc.primaryKeyResource;
1560
+ });
1557
1561
 
1558
- // via parameter, dont change because its already "type"
1559
- nestedPrimaryKey = { property: rsc.primaryKeyName };
1560
- primaryKeyResource = rsc.primaryKeyResource;
1561
- // is from a same resource (not via parameters)
1562
- if (primarySourceResource && primarySourceResource.name === rsc.primaryKeyResource) {
1562
+ if (primarySourceResource) {
1563
+ if (primaryResourceName === rsc.primaryKeyResource) {
1563
1564
  nestedPrimaryKey = findNestedProp(rsc.primaryKeyName, rsc.primaryKeyParents, primarySourceResource);
1564
1565
  primaryKeyResource = primarySourceResource.type;
1565
- primaryKeyResourceLabel = primarySourceResource.name;
1566
+ } else {
1567
+ // is from a different resource (parameter)
1568
+ primaryKeyIsParameter = true;
1569
+ nestedPrimaryKey = { property: rsc.primaryKeyName };
1570
+ primaryKeyResource = rsc.primaryKeyResource;
1566
1571
  }
1567
- })();
1572
+ }
1568
1573
  }
1569
1574
 
1570
1575
  if (sourceResource) {
@@ -1575,9 +1580,11 @@ module.exports =
1575
1580
  joinKeyName: nestedJoinKey.property,
1576
1581
  joinKeyResource: joinKeyResource,
1577
1582
  joinKeyParents: nestedJoinKey.parentsArray && nestedJoinKey.parentsArray.length > 0 ? nestedJoinKey.parentsArray : [],
1583
+ joinKeyIsParameter: joinKeyIsParameter,
1578
1584
  primaryKeyName: nestedPrimaryKey.property,
1579
1585
  primaryKeyResource: primaryKeyResource,
1580
1586
  primaryKeyParents: nestedPrimaryKey.parentsArray && nestedPrimaryKey.parentsArray.length > 0 ? nestedPrimaryKey.parentsArray : [],
1587
+ primaryKeyIsParameter: primaryKeyIsParameter,
1581
1588
  provider: rsc.provider.toLowerCase() + 'Reader',
1582
1589
  joinType: rsc.joinType,
1583
1590
  parameterFilters: rsc.parameterFilters ? rsc.parameterFilters.filter(function (pf) {
@@ -1586,7 +1593,7 @@ module.exports =
1586
1593
  level: rsc.level || (rscIndex === 0 ? 0 : 1),
1587
1594
  // THIS ONE IS ACTUALLY PARENT LABEL AND PROVIDER!
1588
1595
  // So we know what Account to join to (if they have the same Name)
1589
- parentNameAndProvider: primaryKeyResourceLabel && primaryResourceProvider ? primaryKeyResourceLabel + '_' + primaryResourceProvider.toLowerCase() : ''
1596
+ parentNameAndProvider: rsc.parentNameAndProvider
1590
1597
  };
1591
1598
  } else return null;
1592
1599
  });
@@ -3381,13 +3388,15 @@ module.exports =
3381
3388
  });
3382
3389
 
3383
3390
  if (rsc.joinKeyName) {
3384
- // joinKeyName coming from parameter from another resource
3385
- deNestedJoinKey = { property: rsc.joinKeyName };
3386
- joinKeyResourceName = rsc.joinKeyResource;
3387
- __joinKeyResourceName = rsc.joinKeyResource;
3388
3391
 
3389
- // joinKeyName coming from field on this resource
3390
- if (rsc.resourceName === rsc.joinKeyResource) {
3392
+ if (rsc.joinKeyIsParameter) {
3393
+ // joinKeyName coming from parameter from another resource
3394
+ deNestedJoinKey = { property: rsc.joinKeyName };
3395
+ joinKeyResourceName = rsc.joinKeyResource;
3396
+ __joinKeyResourceName = rsc.joinKeyResource;
3397
+ } else {
3398
+ // joinKeyName coming from field on this resource
3399
+ //if(rsc.resourceName===rsc.joinKeyResource){
3391
3400
  var joinKeyResource = dataSourceMetadata.find(function (r) {
3392
3401
  return r.type === rsc.resourceName && r.name === rsc.resourceLabel;
3393
3402
  });
@@ -3396,6 +3405,7 @@ module.exports =
3396
3405
  joinKeyResourceName = joinKeyResource.name;
3397
3406
  __joinKeyResourceName = joinKeyResource.type;
3398
3407
  }
3408
+ //}
3399
3409
  }
3400
3410
  }
3401
3411
  } // end if dataSourceMetadata
@@ -3403,37 +3413,38 @@ module.exports =
3403
3413
  //get resource and primaryKey for parent resource for join
3404
3414
  var primaryResourceProviderLast_Index = rsc.parentNameAndProvider.lastIndexOf('_');
3405
3415
  var primaryResourceProvider = rsc.parentNameAndProvider.substr(primaryResourceProviderLast_Index + 1, rsc.parentNameAndProvider.length);
3406
- var primaryResourceName = rsc.parentNameAndProvider.substr(0, primaryResourceProviderLast_Index);
3407
- var primaryDataSourceMetadata = primaryResourceProvider === DP.toLowerCase() ? DM : primaryResourceProvider === SP.toLowerCase() ? SM : null;
3416
+ var primaryDataSourceMetadata = primaryResourceProvider.toLowerCase() === DP.toLowerCase() ? DM : primaryResourceProvider.toLowerCase() === SP.toLowerCase() ? SM : null;
3408
3417
 
3409
3418
  var deNestedPrimaryKey = {};
3410
3419
  var primaryKeyResourceName = null;
3411
3420
  var __primaryKeyResourceName = null;
3412
3421
  if (primaryDataSourceMetadata) {
3413
3422
  if (rsc.primaryKeyName) {
3414
- (function () {
3423
+
3424
+ if (rsc.primaryKeyIsParameter) {
3415
3425
  //primaryKeyName coming from parameter (another resource)
3416
3426
  deNestedPrimaryKey = { property: rsc.primaryKeyName };
3417
3427
  primaryKeyResourceName = rsc.primaryKeyResource;
3418
3428
  __primaryKeyResourceName = rsc.primaryKeyResource;
3419
-
3420
- // primaryKeyName coming from resource IN THIS BUNDLE
3421
- // FIND ITS BY THE LABEL, NOT THE NAME!!! THIS IS HOW IT IS SAVED.
3422
- var primaryKeyResourceResource = bundle.resources.find(function (r) {
3423
- return primaryResourceName === r.resourceLabel;
3424
- });
3425
- if (primaryKeyResourceResource) {
3426
- //if(primaryResourceName===rsc.primaryKeyResource){
3427
- var rscPrimaryResource = primaryDataSourceMetadata.find(function (r) {
3428
- return r.name === primaryKeyResourceResource.resourceLabel;
3429
+ } else {
3430
+ (function () {
3431
+ // primaryKeyName coming from resource IN THIS BUNDLE
3432
+ var primaryKeyResourceResource = bundle.resources.find(function (r) {
3433
+ return rsc.primaryKeyResource === r.resourceName;
3429
3434
  });
3430
- if (rscPrimaryResource) {
3431
- deNestedPrimaryKey = deNest(rsc.primaryKeyName, rsc.primaryKeyParents, rscPrimaryResource);
3432
- primaryKeyResourceName = rscPrimaryResource.name;
3433
- __primaryKeyResourceName = rscPrimaryResource.type;
3435
+ if (primaryKeyResourceResource) {
3436
+ //if(primaryResourceName===rsc.primaryKeyResource){
3437
+ var rscPrimaryResource = primaryDataSourceMetadata.find(function (r) {
3438
+ return r.name === primaryKeyResourceResource.resourceLabel;
3439
+ });
3440
+ if (rscPrimaryResource) {
3441
+ deNestedPrimaryKey = deNest(rsc.primaryKeyName, rsc.primaryKeyParents, rscPrimaryResource);
3442
+ primaryKeyResourceName = rscPrimaryResource.name;
3443
+ __primaryKeyResourceName = rscPrimaryResource.type;
3444
+ }
3434
3445
  }
3435
- }
3436
- })();
3446
+ })();
3447
+ }
3437
3448
  }
3438
3449
  }
3439
3450
 
@@ -3445,8 +3456,9 @@ module.exports =
3445
3456
  }, deNestedJoinKey.property && { joinKeyName: deNestedJoinKey.property }, deNestedJoinKey.__property && { __joinKeyName: deNestedJoinKey.__property }, joinKeyResourceName && { joinKeyResource: joinKeyResourceName }, __joinKeyResourceName && { __joinKeyResource: __joinKeyResourceName }, deNestedJoinKey.parentsArray && deNestedJoinKey.parentsArray.length > 0 && { joinKeyParents: deNestedJoinKey.parentsArray }, deNestedPrimaryKey.property && { primaryKeyName: deNestedPrimaryKey.property }, deNestedPrimaryKey.__property && { __primaryKeyName: deNestedPrimaryKey.__property }, primaryKeyResourceName && { primaryKeyResource: primaryKeyResourceName }, __primaryKeyResourceName && { __primaryKeyResource: __primaryKeyResourceName }, deNestedPrimaryKey.parentsArray && deNestedPrimaryKey.parentsArray.length > 0 && { primaryKeyParents: deNestedPrimaryKey.parentsArray }, {
3446
3457
  joinType: rsc.joinType || 'LEFT JOIN'
3447
3458
  }, rscResource.parentRef && { parentRef: rscResource.parentRef }, rsc.parameterFilters && { parameterFilters: rsc.parameterFilters }, {
3448
- level: rsc.level || (rscIndex === 0 ? 0 : 1)
3449
- }, primaryResourceName && primaryResourceProvider && { parentNameAndProvider: primaryResourceName + '_' + primaryResourceProvider.toLowerCase() }));
3459
+ level: rsc.level || (rscIndex === 0 ? 0 : 1),
3460
+ parentNameAndProvider: rsc.parentNameAndProvider
3461
+ }));
3450
3462
  //console.log(resources[resources.length-1])
3451
3463
  }
3452
3464
  }); // end bundle.resource.forEach
@@ -19645,7 +19657,6 @@ module.exports =
19645
19657
  return !p.readOnly;
19646
19658
  }).map(function (field, i) {
19647
19659
  return _react2.default.createElement(_nestedField2.default, { key: i, field: field,
19648
- selectedField: selectedField,
19649
19660
  filteredMappings: mappings, parents: [],
19650
19661
  onExpand: function onExpand(ex) {
19651
19662
  return _this4.setState({ destinationExpanded: ex });
@@ -24779,6 +24790,28 @@ module.exports =
24779
24790
  change('resourceGroups', resourceGroups);
24780
24791
  this.assignAllParents(groupIndex);
24781
24792
  }
24793
+
24794
+ /*addIntelligentMapping = () => {
24795
+ // only do for different providers
24796
+ // lowercase, remove spaces, compare labels only
24797
+ const group = {}
24798
+ const i=0; const sk=0; const rsc=0; const step=0;
24799
+ const map = {
24800
+ isExternalKeyMapping:true,
24801
+ resourceFromName:group.sourceKeysObjects[i],
24802
+ __resourceFromName:group.__sourceKeysObjects[i],
24803
+ propertyFromName:sk,
24804
+ __propertyFromName:group.__sourceKeys[i],
24805
+ resourceToName:group.name,
24806
+ __resourceToName:group.__name,
24807
+ propertyToName:group.destinationKeys[i],
24808
+ __propertyToName:group.__destinationKeys[i],
24809
+ propertyFromParents:group.sourceKeysParents[i],
24810
+ propertyToParents:group.destinationKeysParents[i],
24811
+ ...rsc.provider.toLowerCase()===step.destinationProvider.toLowerCase() && {dataSourceIsDestinationEntity: true}
24812
+ }
24813
+ }*/
24814
+
24782
24815
  }, {
24783
24816
  key: 'newEntityKeyPress',
24784
24817
  value: function newEntityKeyPress(e) {
@@ -25240,9 +25273,13 @@ module.exports =
25240
25273
  'div',
25241
25274
  { className: 'fields-expander' },
25242
25275
  field.object && field.object.properties.map(function (nestedField, i) {
25243
- return _react2.default.createElement(NestedField, { key: i, field: nestedField, selectedField: selectedField,
25244
- filteredMappings: filteredMappings, parents: parents.concat(field.label),
25245
- click: click, onExpand: onExpand, expanded: expanded, showApiNames: showApiNames,
25276
+ return _react2.default.createElement(NestedField, { key: i, field: nestedField,
25277
+ selectedField: selectedField,
25278
+ filteredMappings: filteredMappings,
25279
+ parents: parents.concat(field.label),
25280
+ click: click, onExpand: onExpand,
25281
+ expanded: expanded,
25282
+ showApiNames: showApiNames,
25246
25283
  isDestination: isDestination
25247
25284
  });
25248
25285
  })