@salesforce/lds-runtime-mobile 1.107.0 → 1.108.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 (3) hide show
  1. package/dist/main.js +45 -9
  2. package/package.json +15 -15
  3. package/sfdc/main.js +45 -9
package/dist/main.js CHANGED
@@ -6762,18 +6762,51 @@ function filterToPredicates(where, recordType, alias, objectInfoMap, joins) {
6762
6762
  rightPath: `$.id`,
6763
6763
  };
6764
6764
  const childAlias = `${alias}_${field}`;
6765
- // 'RelationshipName' can be different from 'apiName'. For example, 'OwnerId' field
6766
- // in 'Account' has the 'Owner' as the 'RelationshipName', the api name in 'referenceToInfos' is 'User'
6767
- const childRecordType = fieldInfo.referenceToInfos[0].apiName;
6765
+ // Join can happen on polymorphic field too which has more than 1 `referenceToInfo`. If 'apiName' is undefined, it indicates a Join on polymorphic field.
6768
6766
  const join = {
6769
6767
  type: 'LEFT',
6770
6768
  alias: childAlias,
6771
6769
  to: alias,
6772
6770
  conditions: [path],
6773
- apiName: childRecordType,
6771
+ apiName: fieldInfo.referenceToInfos.length === 1
6772
+ ? fieldInfo.referenceToInfos[0].apiName
6773
+ : undefined,
6774
6774
  };
6775
6775
  joins.push(join);
6776
- predicates.push(...filterToPredicates(where[field], childRecordType, childAlias, objectInfoMap, joins));
6776
+ // 'RelationshipName' can be different from 'apiName'. For example, 'OwnerId' field
6777
+ // in 'Account' has the 'Owner' as the 'RelationshipName', the api name in 'referenceToInfos' is 'User'
6778
+ if (fieldInfo.referenceToInfos.length === 1) {
6779
+ const childRecordType = fieldInfo.referenceToInfos[0].apiName;
6780
+ predicates.push(...filterToPredicates(where[field], childRecordType, childAlias, objectInfoMap, joins));
6781
+ }
6782
+ else {
6783
+ // @W-12618378 polymorphic query sometimes does not work as expected on server. The GQL on certain entities could fail.
6784
+ const entityNames = keys$3(where[field]);
6785
+ const polyPredicatesGroups = entityNames
6786
+ .filter((entityName) => fieldInfo.referenceToInfos.some((referenceInfo) => referenceInfo.apiName === entityName))
6787
+ .map((entityName) => {
6788
+ return [
6789
+ {
6790
+ alias: childAlias,
6791
+ leftPath: '$.apiName',
6792
+ operator: '=',
6793
+ value: entityName,
6794
+ dataType: 'String',
6795
+ type: PredicateType.single,
6796
+ },
6797
+ ...filterToPredicates(where[field][entityName], entityName, childAlias, objectInfoMap, joins),
6798
+ ];
6799
+ });
6800
+ if (polyPredicatesGroups.length === 1) {
6801
+ predicates.push(...polyPredicatesGroups[0]);
6802
+ }
6803
+ else {
6804
+ // if polymorphic field has more than 1 entity like `{Owner: { User: {...} Group: {...}}}`, precidates for each entity(`User` and `Group`) should have
6805
+ // `and` operation. while at the base polymorphic field level (`Owner`), the group of compound predicates for each entity should have `or` operation.
6806
+ const polyCompoundPredicates = polyPredicatesGroups.map((polyEntityPredicates) => transformCompoundPredicate('and', polyEntityPredicates));
6807
+ predicates.push(transformCompoundPredicate('or', polyCompoundPredicates));
6808
+ }
6809
+ }
6777
6810
  }
6778
6811
  else {
6779
6812
  for (const [op, value] of entries$2(where[field])) {
@@ -7077,16 +7110,19 @@ function processCompoundPredicate(operator, filters, recordType, alias, objectIn
7077
7110
  const predicates = filters
7078
7111
  .map((filter) => filterToPredicates(filter, recordType, alias, objectInfoMap, joins))
7079
7112
  .reduce(flatten);
7080
- const diffCompoundPredicates = predicates
7113
+ return transformCompoundPredicate(operator, predicates);
7114
+ }
7115
+ function transformCompoundPredicate(operator, childPredicates) {
7116
+ const diffCompoundPredicates = childPredicates
7081
7117
  .filter(isCompoundPredicate)
7082
7118
  .filter((compoundPredicate) => compoundPredicate.operator !== operator);
7083
7119
  // flattens the child compound predicate if its operator is the same of its parent to improve the SQL efficiency.
7084
- const sameCompoundPredicates = predicates
7120
+ const sameCompoundPredicates = childPredicates
7085
7121
  .filter(isCompoundPredicate)
7086
7122
  .filter((compoundPredicate) => compoundPredicate.operator === operator)
7087
7123
  .map((pred) => pred.children)
7088
7124
  .reduce(flatten, []);
7089
- const singlePredicates = predicates.filter((p) => isSinglePredicate(p) || isNotPredicate(p));
7125
+ const singlePredicates = childPredicates.filter((p) => isSinglePredicate(p) || isNotPredicate(p));
7090
7126
  const children = [...diffCompoundPredicates, ...sameCompoundPredicates, ...singlePredicates];
7091
7127
  if (children.length === 1) {
7092
7128
  return children[0];
@@ -15323,4 +15359,4 @@ register({
15323
15359
  });
15324
15360
 
15325
15361
  export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
15326
- // version: 1.107.0-4546e0dc8
15362
+ // version: 1.108.0-ae43b5312
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.107.0",
3
+ "version": "1.108.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS runtime for mobile/hybrid environments.",
6
6
  "main": "dist/main.js",
@@ -32,10 +32,10 @@
32
32
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-mobile"
33
33
  },
34
34
  "dependencies": {
35
- "@salesforce/lds-adapters-uiapi": "^1.107.0",
36
- "@salesforce/lds-bindings": "^1.107.0",
37
- "@salesforce/lds-instrumentation": "^1.107.0",
38
- "@salesforce/lds-priming": "^1.107.0",
35
+ "@salesforce/lds-adapters-uiapi": "^1.108.0",
36
+ "@salesforce/lds-bindings": "^1.108.0",
37
+ "@salesforce/lds-instrumentation": "^1.108.0",
38
+ "@salesforce/lds-priming": "^1.108.0",
39
39
  "@salesforce/user": "0.0.12",
40
40
  "o11y": "244.0.0"
41
41
  },
@@ -43,16 +43,16 @@
43
43
  "@luvio/engine": "0.135.4",
44
44
  "@luvio/environments": "0.135.4",
45
45
  "@luvio/graphql-parser": "0.135.4",
46
- "@salesforce/lds-adapters-graphql": "^1.107.0",
47
- "@salesforce/lds-drafts": "^1.107.0",
48
- "@salesforce/lds-drafts-adapters-uiapi": "^1.107.0",
49
- "@salesforce/lds-graphql-eval": "^1.107.0",
50
- "@salesforce/lds-network-adapter": "^1.107.0",
51
- "@salesforce/lds-network-nimbus": "^1.107.0",
52
- "@salesforce/lds-store-binary": "^1.107.0",
53
- "@salesforce/lds-store-sql": "^1.107.0",
54
- "@salesforce/lds-utils-adapters": "^1.107.0",
55
- "@salesforce/nimbus-plugin-lds": "^1.107.0",
46
+ "@salesforce/lds-adapters-graphql": "^1.108.0",
47
+ "@salesforce/lds-drafts": "^1.108.0",
48
+ "@salesforce/lds-drafts-adapters-uiapi": "^1.108.0",
49
+ "@salesforce/lds-graphql-eval": "^1.108.0",
50
+ "@salesforce/lds-network-adapter": "^1.108.0",
51
+ "@salesforce/lds-network-nimbus": "^1.108.0",
52
+ "@salesforce/lds-store-binary": "^1.108.0",
53
+ "@salesforce/lds-store-sql": "^1.108.0",
54
+ "@salesforce/lds-utils-adapters": "^1.108.0",
55
+ "@salesforce/nimbus-plugin-lds": "^1.108.0",
56
56
  "babel-plugin-dynamic-import-node": "^2.3.3",
57
57
  "wait-for-expect": "^3.0.2"
58
58
  },
package/sfdc/main.js CHANGED
@@ -6762,18 +6762,51 @@ function filterToPredicates(where, recordType, alias, objectInfoMap, joins) {
6762
6762
  rightPath: `$.id`,
6763
6763
  };
6764
6764
  const childAlias = `${alias}_${field}`;
6765
- // 'RelationshipName' can be different from 'apiName'. For example, 'OwnerId' field
6766
- // in 'Account' has the 'Owner' as the 'RelationshipName', the api name in 'referenceToInfos' is 'User'
6767
- const childRecordType = fieldInfo.referenceToInfos[0].apiName;
6765
+ // Join can happen on polymorphic field too which has more than 1 `referenceToInfo`. If 'apiName' is undefined, it indicates a Join on polymorphic field.
6768
6766
  const join = {
6769
6767
  type: 'LEFT',
6770
6768
  alias: childAlias,
6771
6769
  to: alias,
6772
6770
  conditions: [path],
6773
- apiName: childRecordType,
6771
+ apiName: fieldInfo.referenceToInfos.length === 1
6772
+ ? fieldInfo.referenceToInfos[0].apiName
6773
+ : undefined,
6774
6774
  };
6775
6775
  joins.push(join);
6776
- predicates.push(...filterToPredicates(where[field], childRecordType, childAlias, objectInfoMap, joins));
6776
+ // 'RelationshipName' can be different from 'apiName'. For example, 'OwnerId' field
6777
+ // in 'Account' has the 'Owner' as the 'RelationshipName', the api name in 'referenceToInfos' is 'User'
6778
+ if (fieldInfo.referenceToInfos.length === 1) {
6779
+ const childRecordType = fieldInfo.referenceToInfos[0].apiName;
6780
+ predicates.push(...filterToPredicates(where[field], childRecordType, childAlias, objectInfoMap, joins));
6781
+ }
6782
+ else {
6783
+ // @W-12618378 polymorphic query sometimes does not work as expected on server. The GQL on certain entities could fail.
6784
+ const entityNames = keys$3(where[field]);
6785
+ const polyPredicatesGroups = entityNames
6786
+ .filter((entityName) => fieldInfo.referenceToInfos.some((referenceInfo) => referenceInfo.apiName === entityName))
6787
+ .map((entityName) => {
6788
+ return [
6789
+ {
6790
+ alias: childAlias,
6791
+ leftPath: '$.apiName',
6792
+ operator: '=',
6793
+ value: entityName,
6794
+ dataType: 'String',
6795
+ type: PredicateType.single,
6796
+ },
6797
+ ...filterToPredicates(where[field][entityName], entityName, childAlias, objectInfoMap, joins),
6798
+ ];
6799
+ });
6800
+ if (polyPredicatesGroups.length === 1) {
6801
+ predicates.push(...polyPredicatesGroups[0]);
6802
+ }
6803
+ else {
6804
+ // if polymorphic field has more than 1 entity like `{Owner: { User: {...} Group: {...}}}`, precidates for each entity(`User` and `Group`) should have
6805
+ // `and` operation. while at the base polymorphic field level (`Owner`), the group of compound predicates for each entity should have `or` operation.
6806
+ const polyCompoundPredicates = polyPredicatesGroups.map((polyEntityPredicates) => transformCompoundPredicate('and', polyEntityPredicates));
6807
+ predicates.push(transformCompoundPredicate('or', polyCompoundPredicates));
6808
+ }
6809
+ }
6777
6810
  }
6778
6811
  else {
6779
6812
  for (const [op, value] of entries$2(where[field])) {
@@ -7077,16 +7110,19 @@ function processCompoundPredicate(operator, filters, recordType, alias, objectIn
7077
7110
  const predicates = filters
7078
7111
  .map((filter) => filterToPredicates(filter, recordType, alias, objectInfoMap, joins))
7079
7112
  .reduce(flatten);
7080
- const diffCompoundPredicates = predicates
7113
+ return transformCompoundPredicate(operator, predicates);
7114
+ }
7115
+ function transformCompoundPredicate(operator, childPredicates) {
7116
+ const diffCompoundPredicates = childPredicates
7081
7117
  .filter(isCompoundPredicate)
7082
7118
  .filter((compoundPredicate) => compoundPredicate.operator !== operator);
7083
7119
  // flattens the child compound predicate if its operator is the same of its parent to improve the SQL efficiency.
7084
- const sameCompoundPredicates = predicates
7120
+ const sameCompoundPredicates = childPredicates
7085
7121
  .filter(isCompoundPredicate)
7086
7122
  .filter((compoundPredicate) => compoundPredicate.operator === operator)
7087
7123
  .map((pred) => pred.children)
7088
7124
  .reduce(flatten, []);
7089
- const singlePredicates = predicates.filter((p) => isSinglePredicate(p) || isNotPredicate(p));
7125
+ const singlePredicates = childPredicates.filter((p) => isSinglePredicate(p) || isNotPredicate(p));
7090
7126
  const children = [...diffCompoundPredicates, ...sameCompoundPredicates, ...singlePredicates];
7091
7127
  if (children.length === 1) {
7092
7128
  return children[0];
@@ -15323,4 +15359,4 @@ register({
15323
15359
  });
15324
15360
 
15325
15361
  export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
15326
- // version: 1.107.0-4546e0dc8
15362
+ // version: 1.108.0-ae43b5312