@salesforce/lds-runtime-mobile 1.309.0 → 1.311.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 +47 -18
  2. package/package.json +18 -18
  3. package/sfdc/main.js +47 -18
package/dist/main.js CHANGED
@@ -7796,14 +7796,22 @@ function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fie
7796
7796
  if (fieldInfo !== undefined) {
7797
7797
  const { dataType } = fieldInfo;
7798
7798
  recordFields[fieldName].displayValue = formatDisplayValue(draftField, dataType);
7799
+ // for a DateTime field, we are going to convert the string to an ISOString value.
7799
7800
  if (dataType === 'DateTime' &&
7800
7801
  draftField !== null &&
7801
7802
  typeof draftField === 'string') {
7802
- try {
7803
- recordFields[fieldName].value = new Date(draftField).toISOString();
7803
+ // if it is empty string, then convert it to null.
7804
+ if (draftField === '') {
7805
+ recordFields[fieldName].value = null;
7804
7806
  }
7805
- catch (e) {
7806
- throw Error('date field value not valid');
7807
+ else {
7808
+ // attempt to convert it to ISO string value
7809
+ try {
7810
+ recordFields[fieldName].value = new Date(draftField).toISOString();
7811
+ }
7812
+ catch (e) {
7813
+ throw Error('date field value not valid');
7814
+ }
7807
7815
  }
7808
7816
  }
7809
7817
  }
@@ -10779,6 +10787,11 @@ function singlePredicateToSql(predicate, defaultAlias, isChildNotPredicate = fal
10779
10787
  let { alias, leftPath, operator, value, dataType, isCaseSensitive } = predicate;
10780
10788
  let binding = [];
10781
10789
  let boundValue = extractPredicateValue(value, dataType);
10790
+ // using != does not include null values
10791
+ // using IS NOT predicate will include null values as null also is not the value
10792
+ if (operator === '!=') {
10793
+ operator = 'IS NOT';
10794
+ }
10782
10795
  // Handles boolean type field
10783
10796
  if (dataType === 'Boolean') {
10784
10797
  if (boundValue === null) {
@@ -10794,13 +10807,8 @@ function singlePredicateToSql(predicate, defaultAlias, isChildNotPredicate = fal
10794
10807
  boundValue = 0;
10795
10808
  }
10796
10809
  }
10797
- if (boundValue === null) {
10798
- if (operator === '=') {
10799
- operator = 'IS';
10800
- }
10801
- else if (operator === '!=') {
10802
- operator = 'IS NOT';
10803
- }
10810
+ if (boundValue === null && operator === '=') {
10811
+ operator = 'IS';
10804
10812
  }
10805
10813
  alias = !alias ? defaultAlias : alias;
10806
10814
  let sql;
@@ -10952,7 +10960,13 @@ function extractPredicateValue(value, dataType) {
10952
10960
  return value;
10953
10961
  }
10954
10962
  if (typeof value !== 'object') {
10955
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
10963
+ // GraphQL server treats empty string value as null
10964
+ if (typeof value === 'string' && value.length === 0) {
10965
+ return null;
10966
+ }
10967
+ else if (typeof value === 'string' ||
10968
+ typeof value === 'number' ||
10969
+ typeof value === 'boolean') {
10956
10970
  return value;
10957
10971
  }
10958
10972
  else {
@@ -18266,7 +18280,11 @@ class PrimingSession extends EventEmitter {
18266
18280
  const unavailableTypes = apiNames.filter((x) => !objectInfoMap[x]);
18267
18281
  const availableTypes = apiNames.filter((x) => objectInfoMap[x]);
18268
18282
  const unavilableBatches = batches.filter((x) => unavailableTypes.includes(x.type));
18269
- const availableBatches = batches.filter((x) => !unavailableTypes.includes(x.type));
18283
+ const availableBatches = batches
18284
+ .filter((x) => !unavailableTypes.includes(x.type))
18285
+ .map((x) => {
18286
+ return { ...x, objectInfo: objectInfoMap[x.type] };
18287
+ });
18270
18288
  const unavailableIds = unavilableBatches.reduce((acc, x) => {
18271
18289
  acc.push(...x.ids);
18272
18290
  return acc;
@@ -18288,7 +18306,7 @@ const requiredFieldMap = {
18288
18306
  Id: 'Id',
18289
18307
  LastModifiedById: 'LastModifiedById { value }',
18290
18308
  LastModifiedDate: 'LastModifiedDate { value }',
18291
- RecordTypeId: 'RecordTypeId { value }',
18309
+ RecordTypeId: 'RecordTypeId(fallback: true) { value }',
18292
18310
  SystemModstamp: 'SystemModstamp { value }',
18293
18311
  WeakEtag: 'WeakEtag',
18294
18312
  };
@@ -18355,9 +18373,10 @@ class RecordLoaderGraphQL {
18355
18373
  missingIds: batchInput.ids,
18356
18374
  };
18357
18375
  }
18376
+ const objectInfo = batchInput.objectInfo;
18358
18377
  const seenRecords = new Set(batchInput.ids);
18359
18378
  const records = data.uiapi.query[batchInput.type].edges.map((edge) => {
18360
- const record = this.generateDurableRecordRepresentation(edge.node);
18379
+ const record = this.generateDurableRecordRepresentation(edge.node, objectInfo);
18361
18380
  seenRecords.delete(record.id);
18362
18381
  return record;
18363
18382
  });
@@ -18408,7 +18427,7 @@ class RecordLoaderGraphQL {
18408
18427
  }
18409
18428
  `;
18410
18429
  }
18411
- generateDurableRecordRepresentation(node) {
18430
+ generateDurableRecordRepresentation(node, objectInfo) {
18412
18431
  const standardRecordFields = new Set(Object.keys(requiredFieldMap).map((x) => `${requiredPrefix}${x}`));
18413
18432
  const id = node[`${requiredPrefix}Id`];
18414
18433
  const recordTypeId = node[`${requiredPrefix}RecordTypeId`].value;
@@ -18423,6 +18442,16 @@ class RecordLoaderGraphQL {
18423
18442
  }, {});
18424
18443
  fields['Id'] = { value: id, displayValue: null };
18425
18444
  fields['RecordTypeId'] = { value: recordTypeId, displayValue: null };
18445
+ let recordTypeInfo = null;
18446
+ if (recordTypeId !== null &&
18447
+ objectInfo.recordTypeInfos &&
18448
+ objectInfo.recordTypeInfos[recordTypeId]) {
18449
+ const appliedRecordTypeInfo = objectInfo.recordTypeInfos[recordTypeId];
18450
+ // ui-api only applies the record type if its not the default type, otherwise it sets it to null
18451
+ if (appliedRecordTypeInfo.defaultRecordTypeMapping === false) {
18452
+ recordTypeInfo = appliedRecordTypeInfo;
18453
+ }
18454
+ }
18426
18455
  return {
18427
18456
  apiName: node[`${requiredPrefix}ApiName`],
18428
18457
  childRelationships: {},
@@ -18437,7 +18466,7 @@ class RecordLoaderGraphQL {
18437
18466
  ? node[`${requiredPrefix}LastModifiedDate`].value
18438
18467
  : null,
18439
18468
  recordTypeId,
18440
- recordTypeInfo: null,
18469
+ recordTypeInfo: recordTypeInfo,
18441
18470
  systemModstamp: node[`${requiredPrefix}SystemModstamp`] &&
18442
18471
  node[`${requiredPrefix}SystemModstamp`].value
18443
18472
  ? node[`${requiredPrefix}SystemModstamp`].value
@@ -19180,4 +19209,4 @@ register({
19180
19209
  });
19181
19210
 
19182
19211
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
19183
- // version: 1.309.0-e7611a7fb5
19212
+ // version: 1.311.0-167623b638
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.309.0",
3
+ "version": "1.311.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,27 +32,27 @@
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-mobile": "^1.309.0",
36
- "@salesforce/lds-bindings": "^1.309.0",
37
- "@salesforce/lds-instrumentation": "^1.309.0",
38
- "@salesforce/lds-priming": "^1.309.0",
35
+ "@salesforce/lds-adapters-uiapi-mobile": "^1.311.0",
36
+ "@salesforce/lds-bindings": "^1.311.0",
37
+ "@salesforce/lds-instrumentation": "^1.311.0",
38
+ "@salesforce/lds-priming": "^1.311.0",
39
39
  "@salesforce/user": "0.0.21",
40
40
  "o11y": "250.7.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@salesforce/lds-adapters-graphql": "^1.309.0",
44
- "@salesforce/lds-drafts": "^1.309.0",
45
- "@salesforce/lds-drafts-adapters-uiapi": "^1.309.0",
46
- "@salesforce/lds-durable-records": "^1.309.0",
47
- "@salesforce/lds-graphql-eval": "^1.309.0",
48
- "@salesforce/lds-graphql-local-evaluation": "^1.309.0",
49
- "@salesforce/lds-network-adapter": "^1.309.0",
50
- "@salesforce/lds-network-nimbus": "^1.309.0",
51
- "@salesforce/lds-store-binary": "^1.309.0",
52
- "@salesforce/lds-store-nimbus": "^1.309.0",
53
- "@salesforce/lds-store-sql": "^1.309.0",
54
- "@salesforce/lds-utils-adapters": "^1.309.0",
55
- "@salesforce/nimbus-plugin-lds": "^1.309.0",
43
+ "@salesforce/lds-adapters-graphql": "^1.311.0",
44
+ "@salesforce/lds-drafts": "^1.311.0",
45
+ "@salesforce/lds-drafts-adapters-uiapi": "^1.311.0",
46
+ "@salesforce/lds-durable-records": "^1.311.0",
47
+ "@salesforce/lds-graphql-eval": "^1.311.0",
48
+ "@salesforce/lds-graphql-local-evaluation": "^1.311.0",
49
+ "@salesforce/lds-network-adapter": "^1.311.0",
50
+ "@salesforce/lds-network-nimbus": "^1.311.0",
51
+ "@salesforce/lds-store-binary": "^1.311.0",
52
+ "@salesforce/lds-store-nimbus": "^1.311.0",
53
+ "@salesforce/lds-store-sql": "^1.311.0",
54
+ "@salesforce/lds-utils-adapters": "^1.311.0",
55
+ "@salesforce/nimbus-plugin-lds": "^1.311.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
@@ -7796,14 +7796,22 @@ function buildRecordFieldValueRepresentationsFromDraftFields(luvio, apiName, fie
7796
7796
  if (fieldInfo !== undefined) {
7797
7797
  const { dataType } = fieldInfo;
7798
7798
  recordFields[fieldName].displayValue = formatDisplayValue(draftField, dataType);
7799
+ // for a DateTime field, we are going to convert the string to an ISOString value.
7799
7800
  if (dataType === 'DateTime' &&
7800
7801
  draftField !== null &&
7801
7802
  typeof draftField === 'string') {
7802
- try {
7803
- recordFields[fieldName].value = new Date(draftField).toISOString();
7803
+ // if it is empty string, then convert it to null.
7804
+ if (draftField === '') {
7805
+ recordFields[fieldName].value = null;
7804
7806
  }
7805
- catch (e) {
7806
- throw Error('date field value not valid');
7807
+ else {
7808
+ // attempt to convert it to ISO string value
7809
+ try {
7810
+ recordFields[fieldName].value = new Date(draftField).toISOString();
7811
+ }
7812
+ catch (e) {
7813
+ throw Error('date field value not valid');
7814
+ }
7807
7815
  }
7808
7816
  }
7809
7817
  }
@@ -10779,6 +10787,11 @@ function singlePredicateToSql(predicate, defaultAlias, isChildNotPredicate = fal
10779
10787
  let { alias, leftPath, operator, value, dataType, isCaseSensitive } = predicate;
10780
10788
  let binding = [];
10781
10789
  let boundValue = extractPredicateValue(value, dataType);
10790
+ // using != does not include null values
10791
+ // using IS NOT predicate will include null values as null also is not the value
10792
+ if (operator === '!=') {
10793
+ operator = 'IS NOT';
10794
+ }
10782
10795
  // Handles boolean type field
10783
10796
  if (dataType === 'Boolean') {
10784
10797
  if (boundValue === null) {
@@ -10794,13 +10807,8 @@ function singlePredicateToSql(predicate, defaultAlias, isChildNotPredicate = fal
10794
10807
  boundValue = 0;
10795
10808
  }
10796
10809
  }
10797
- if (boundValue === null) {
10798
- if (operator === '=') {
10799
- operator = 'IS';
10800
- }
10801
- else if (operator === '!=') {
10802
- operator = 'IS NOT';
10803
- }
10810
+ if (boundValue === null && operator === '=') {
10811
+ operator = 'IS';
10804
10812
  }
10805
10813
  alias = !alias ? defaultAlias : alias;
10806
10814
  let sql;
@@ -10952,7 +10960,13 @@ function extractPredicateValue(value, dataType) {
10952
10960
  return value;
10953
10961
  }
10954
10962
  if (typeof value !== 'object') {
10955
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
10963
+ // GraphQL server treats empty string value as null
10964
+ if (typeof value === 'string' && value.length === 0) {
10965
+ return null;
10966
+ }
10967
+ else if (typeof value === 'string' ||
10968
+ typeof value === 'number' ||
10969
+ typeof value === 'boolean') {
10956
10970
  return value;
10957
10971
  }
10958
10972
  else {
@@ -18266,7 +18280,11 @@ class PrimingSession extends EventEmitter {
18266
18280
  const unavailableTypes = apiNames.filter((x) => !objectInfoMap[x]);
18267
18281
  const availableTypes = apiNames.filter((x) => objectInfoMap[x]);
18268
18282
  const unavilableBatches = batches.filter((x) => unavailableTypes.includes(x.type));
18269
- const availableBatches = batches.filter((x) => !unavailableTypes.includes(x.type));
18283
+ const availableBatches = batches
18284
+ .filter((x) => !unavailableTypes.includes(x.type))
18285
+ .map((x) => {
18286
+ return { ...x, objectInfo: objectInfoMap[x.type] };
18287
+ });
18270
18288
  const unavailableIds = unavilableBatches.reduce((acc, x) => {
18271
18289
  acc.push(...x.ids);
18272
18290
  return acc;
@@ -18288,7 +18306,7 @@ const requiredFieldMap = {
18288
18306
  Id: 'Id',
18289
18307
  LastModifiedById: 'LastModifiedById { value }',
18290
18308
  LastModifiedDate: 'LastModifiedDate { value }',
18291
- RecordTypeId: 'RecordTypeId { value }',
18309
+ RecordTypeId: 'RecordTypeId(fallback: true) { value }',
18292
18310
  SystemModstamp: 'SystemModstamp { value }',
18293
18311
  WeakEtag: 'WeakEtag',
18294
18312
  };
@@ -18355,9 +18373,10 @@ class RecordLoaderGraphQL {
18355
18373
  missingIds: batchInput.ids,
18356
18374
  };
18357
18375
  }
18376
+ const objectInfo = batchInput.objectInfo;
18358
18377
  const seenRecords = new Set(batchInput.ids);
18359
18378
  const records = data.uiapi.query[batchInput.type].edges.map((edge) => {
18360
- const record = this.generateDurableRecordRepresentation(edge.node);
18379
+ const record = this.generateDurableRecordRepresentation(edge.node, objectInfo);
18361
18380
  seenRecords.delete(record.id);
18362
18381
  return record;
18363
18382
  });
@@ -18408,7 +18427,7 @@ class RecordLoaderGraphQL {
18408
18427
  }
18409
18428
  `;
18410
18429
  }
18411
- generateDurableRecordRepresentation(node) {
18430
+ generateDurableRecordRepresentation(node, objectInfo) {
18412
18431
  const standardRecordFields = new Set(Object.keys(requiredFieldMap).map((x) => `${requiredPrefix}${x}`));
18413
18432
  const id = node[`${requiredPrefix}Id`];
18414
18433
  const recordTypeId = node[`${requiredPrefix}RecordTypeId`].value;
@@ -18423,6 +18442,16 @@ class RecordLoaderGraphQL {
18423
18442
  }, {});
18424
18443
  fields['Id'] = { value: id, displayValue: null };
18425
18444
  fields['RecordTypeId'] = { value: recordTypeId, displayValue: null };
18445
+ let recordTypeInfo = null;
18446
+ if (recordTypeId !== null &&
18447
+ objectInfo.recordTypeInfos &&
18448
+ objectInfo.recordTypeInfos[recordTypeId]) {
18449
+ const appliedRecordTypeInfo = objectInfo.recordTypeInfos[recordTypeId];
18450
+ // ui-api only applies the record type if its not the default type, otherwise it sets it to null
18451
+ if (appliedRecordTypeInfo.defaultRecordTypeMapping === false) {
18452
+ recordTypeInfo = appliedRecordTypeInfo;
18453
+ }
18454
+ }
18426
18455
  return {
18427
18456
  apiName: node[`${requiredPrefix}ApiName`],
18428
18457
  childRelationships: {},
@@ -18437,7 +18466,7 @@ class RecordLoaderGraphQL {
18437
18466
  ? node[`${requiredPrefix}LastModifiedDate`].value
18438
18467
  : null,
18439
18468
  recordTypeId,
18440
- recordTypeInfo: null,
18469
+ recordTypeInfo: recordTypeInfo,
18441
18470
  systemModstamp: node[`${requiredPrefix}SystemModstamp`] &&
18442
18471
  node[`${requiredPrefix}SystemModstamp`].value
18443
18472
  ? node[`${requiredPrefix}SystemModstamp`].value
@@ -19180,4 +19209,4 @@ register({
19180
19209
  });
19181
19210
 
19182
19211
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
19183
- // version: 1.309.0-e7611a7fb5
19212
+ // version: 1.311.0-167623b638