@salesforce/lds-runtime-mobile 1.274.0 → 1.276.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 -41
  2. package/package.json +16 -16
  3. package/sfdc/main.js +45 -41
package/dist/main.js CHANGED
@@ -786,7 +786,7 @@ class DurableTTLStore {
786
786
  }
787
787
  }
788
788
 
789
- function flushInMemoryStoreValuesToDurableStore(store, durableStore, crossEnvironmentNotifier, durableStoreErrorHandler, redirects, additionalDurableStoreOperations = [], enableDurableMetadataRefresh = false) {
789
+ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStoreErrorHandler, redirects, additionalDurableStoreOperations = [], enableDurableMetadataRefresh = false) {
790
790
  const durableRecords = create$6(null);
791
791
  const refreshedDurableRecords = create$6(null);
792
792
  const evictedRecords = create$6(null);
@@ -826,21 +826,14 @@ function flushInMemoryStoreValuesToDurableStore(store, durableStore, crossEnviro
826
826
  segment: DefaultDurableSegment,
827
827
  });
828
828
  }
829
- if (keys$7(refreshedDurableRecords).length > 0) {
829
+ const refreshKeys = keys$7(refreshedDurableRecords);
830
+ if (refreshKeys.length > 0) {
830
831
  // publishes with only metadata updates
831
832
  durableStoreOperations.push({
832
833
  type: 'setMetadata',
833
834
  entries: refreshedDurableRecords,
834
835
  segment: DefaultDurableSegment,
835
836
  });
836
- if (crossEnvironmentNotifier !== undefined) {
837
- crossEnvironmentNotifier.notifyCrossEnvironments({
838
- data: {
839
- refreshedDurableRecords,
840
- },
841
- type: 'Update',
842
- });
843
- }
844
837
  }
845
838
  // redirects
846
839
  redirects.forEach((value, key) => {
@@ -1142,14 +1135,17 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1142
1135
  }
1143
1136
  // process metadata only refreshes
1144
1137
  if (metadataRefreshSegmentKeys.length > 0) {
1145
- const entries = await durableStore.getMetadata(metadataRefreshSegmentKeys, DefaultDurableSegment);
1146
- if (entries !== undefined) {
1147
- const entryKeys = keys$7(entries);
1148
- for (let i = 0, len = entryKeys.length; i < len; i++) {
1149
- const entryKey = entryKeys[i];
1150
- const { metadata } = entries[entryKey];
1151
- if (metadata !== undefined) {
1152
- environment.putStoreMetadata(entryKey, metadata, false);
1138
+ const filteredKeys = metadataRefreshSegmentKeys.filter((s) => environment.storeKeyExists(s));
1139
+ if (filteredKeys.length > 0) {
1140
+ const entries = await durableStore.getMetadata(filteredKeys, DefaultDurableSegment);
1141
+ if (entries !== undefined) {
1142
+ const entryKeys = keys$7(entries);
1143
+ for (let i = 0, len = entryKeys.length; i < len; i++) {
1144
+ const entryKey = entryKeys[i];
1145
+ const { metadata } = entries[entryKey];
1146
+ if (metadata !== undefined) {
1147
+ environment.putStoreMetadata(entryKey, metadata, false);
1148
+ }
1153
1149
  }
1154
1150
  }
1155
1151
  }
@@ -1172,15 +1168,6 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1172
1168
  }
1173
1169
  }
1174
1170
  });
1175
- let notifier;
1176
- const getCrossEnvironmentNotifier = function () {
1177
- validateNotDisposed();
1178
- return notifier;
1179
- };
1180
- const setCrossEnvironmentNotifier = function (crossEnvironmentNotifier) {
1181
- validateNotDisposed();
1182
- notifier = crossEnvironmentNotifier;
1183
- };
1184
1171
  const dispose = function () {
1185
1172
  validateNotDisposed();
1186
1173
  disposed = true;
@@ -1233,7 +1220,7 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1233
1220
  if (stagingStore === null) {
1234
1221
  return Promise.resolve();
1235
1222
  }
1236
- const promise = flushInMemoryStoreValuesToDurableStore(stagingStore, durableStore, getCrossEnvironmentNotifier(), durableStoreErrorHandler, new Map(pendingStoreRedirects), additionalDurableStoreOperations, enableDurableMetadataRefresh);
1223
+ const promise = flushInMemoryStoreValuesToDurableStore(stagingStore, durableStore, durableStoreErrorHandler, new Map(pendingStoreRedirects), additionalDurableStoreOperations, enableDurableMetadataRefresh);
1237
1224
  pendingStoreRedirects.clear();
1238
1225
  stagingStore = null;
1239
1226
  return promise;
@@ -1603,8 +1590,6 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1603
1590
  handleErrorResponse: { value: handleErrorResponse },
1604
1591
  getNotifyChangeStoreEntries: { value: getNotifyChangeStoreEntries },
1605
1592
  notifyStoreUpdateAvailable: { value: notifyStoreUpdateAvailable },
1606
- getCrossEnvironmentNotifier: { value: getCrossEnvironmentNotifier },
1607
- setCrossEnvironmentNotifier: { value: setCrossEnvironmentNotifier },
1608
1593
  });
1609
1594
  }
1610
1595
 
@@ -12384,13 +12369,21 @@ function buildSyntheticRecordRepresentation(luvio, createOperation, userId, obje
12384
12369
  draftFields[DEFAULT_FIELD_LAST_MODIFIED_DATE] = { value: timestampString, displayValue: null };
12385
12370
  draftFields[DEFAULT_FIELD_OWNER_ID] = { value: userId, displayValue: null };
12386
12371
  draftFields[DEFAULT_FIELD_ID] = { value: recordId, displayValue: null };
12387
- if (objectInfo !== undefined) {
12388
- const allObjectFields = keys$3(objectInfo.fields);
12389
- allObjectFields.forEach((fieldName) => {
12390
- if (draftFields[fieldName] === undefined) {
12391
- draftFields[fieldName] = { value: null, displayValue: null };
12392
- }
12393
- });
12372
+ const allObjectFields = keys$3(objectInfo.fields);
12373
+ allObjectFields.forEach((fieldName) => {
12374
+ if (draftFields[fieldName] === undefined) {
12375
+ draftFields[fieldName] = { value: null, displayValue: null };
12376
+ }
12377
+ });
12378
+ // TODO [W-14915806]: lightning-record-form injects the `IsPersonAccount`
12379
+ // field for all `Account` and `PersonAccount` records. However, not all
12380
+ // orgs use person accounts, and if that field is not present in the object
12381
+ // info then it is not synthesized. We force it to be synthesized here to
12382
+ // ensure lightning-record-form will work correctly with draft-created
12383
+ // accounts.
12384
+ if ((apiName === 'Account' || apiName === 'PersonAccount') &&
12385
+ draftFields['IsPersonAccount'] === undefined) {
12386
+ draftFields['IsPersonAccount'] = { value: null, displayValue: null };
12394
12387
  }
12395
12388
  return {
12396
12389
  id: recordId,
@@ -16797,6 +16790,7 @@ function findReferenceFieldForSpanningField(fieldName, objectInfo) {
16797
16790
  function buildFieldUnionArray(existingRecord, incomingRecord, objectInfo) {
16798
16791
  const allFields = Array.from(new Set([...Object.keys(existingRecord.fields), ...Object.keys(incomingRecord.fields)]));
16799
16792
  const fieldUnion = [];
16793
+ let includesSpanningFields = false;
16800
16794
  allFields.forEach((fieldName) => {
16801
16795
  const objectInfoField = objectInfo.fields[fieldName];
16802
16796
  if (objectInfoField === undefined) {
@@ -16804,13 +16798,14 @@ function buildFieldUnionArray(existingRecord, incomingRecord, objectInfo) {
16804
16798
  const referenceField = findReferenceFieldForSpanningField(fieldName, objectInfo);
16805
16799
  if (referenceField !== undefined) {
16806
16800
  fieldUnion.push(`${fieldName}.Id`);
16801
+ includesSpanningFields = true;
16807
16802
  }
16808
16803
  }
16809
16804
  else {
16810
16805
  fieldUnion.push(fieldName);
16811
16806
  }
16812
16807
  });
16813
- return fieldUnion;
16808
+ return { fields: fieldUnion, includesSpanningFields };
16814
16809
  }
16815
16810
  /**
16816
16811
  * Merges (if possible) an incoming record from a priming session with an existing record in the durable store.
@@ -16842,7 +16837,7 @@ function mergeRecord(existingRecord, incomingRecord, objectInfo) {
16842
16837
  ok: false,
16843
16838
  code: 'conflict-drafts',
16844
16839
  hasDraft: true,
16845
- fieldUnion: buildFieldUnionArray(existingRecord, incomingRecord, objectInfo),
16840
+ fieldUnion: buildFieldUnionArray(existingRecord, incomingRecord, objectInfo).fields,
16846
16841
  };
16847
16842
  }
16848
16843
  // Check if incoming record's Etag is equal to the existing one
@@ -16904,10 +16899,19 @@ function mergeRecord(existingRecord, incomingRecord, objectInfo) {
16904
16899
  };
16905
16900
  }
16906
16901
  // If Etags do not match and the incoming record does not contain all fields, re-request the record
16902
+ const { fields, includesSpanningFields } = buildFieldUnionArray(existingRecord, incomingRecord, objectInfo);
16903
+ if (includesSpanningFields) {
16904
+ return {
16905
+ ok: false,
16906
+ code: 'conflict-spanning-record',
16907
+ fieldUnion: fields,
16908
+ hasDraft: false,
16909
+ };
16910
+ }
16907
16911
  return {
16908
16912
  ok: false,
16909
16913
  code: 'conflict-missing-fields',
16910
- fieldUnion: buildFieldUnionArray(existingRecord, incomingRecord, objectInfo),
16914
+ fieldUnion: fields,
16911
16915
  hasDraft: false,
16912
16916
  };
16913
16917
  }
@@ -17960,4 +17964,4 @@ register({
17960
17964
  });
17961
17965
 
17962
17966
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
17963
- // version: 1.274.0-67da496e8
17967
+ // version: 1.276.0-dcebc4076
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.274.0",
3
+ "version": "1.276.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,25 +32,25 @@
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.274.0",
36
- "@salesforce/lds-bindings": "^1.274.0",
37
- "@salesforce/lds-instrumentation": "^1.274.0",
38
- "@salesforce/lds-priming": "^1.274.0",
35
+ "@salesforce/lds-adapters-uiapi": "^1.276.0",
36
+ "@salesforce/lds-bindings": "^1.276.0",
37
+ "@salesforce/lds-instrumentation": "^1.276.0",
38
+ "@salesforce/lds-priming": "^1.276.0",
39
39
  "@salesforce/user": "0.0.21",
40
40
  "o11y": "244.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@salesforce/lds-adapters-graphql": "^1.274.0",
44
- "@salesforce/lds-drafts": "^1.274.0",
45
- "@salesforce/lds-drafts-adapters-uiapi": "^1.274.0",
46
- "@salesforce/lds-graphql-eval": "^1.274.0",
47
- "@salesforce/lds-network-adapter": "^1.274.0",
48
- "@salesforce/lds-network-nimbus": "^1.274.0",
49
- "@salesforce/lds-store-binary": "^1.274.0",
50
- "@salesforce/lds-store-nimbus": "^1.274.0",
51
- "@salesforce/lds-store-sql": "^1.274.0",
52
- "@salesforce/lds-utils-adapters": "^1.274.0",
53
- "@salesforce/nimbus-plugin-lds": "^1.274.0",
43
+ "@salesforce/lds-adapters-graphql": "^1.276.0",
44
+ "@salesforce/lds-drafts": "^1.276.0",
45
+ "@salesforce/lds-drafts-adapters-uiapi": "^1.276.0",
46
+ "@salesforce/lds-graphql-eval": "^1.276.0",
47
+ "@salesforce/lds-network-adapter": "^1.276.0",
48
+ "@salesforce/lds-network-nimbus": "^1.276.0",
49
+ "@salesforce/lds-store-binary": "^1.276.0",
50
+ "@salesforce/lds-store-nimbus": "^1.276.0",
51
+ "@salesforce/lds-store-sql": "^1.276.0",
52
+ "@salesforce/lds-utils-adapters": "^1.276.0",
53
+ "@salesforce/nimbus-plugin-lds": "^1.276.0",
54
54
  "babel-plugin-dynamic-import-node": "^2.3.3",
55
55
  "wait-for-expect": "^3.0.2"
56
56
  },
package/sfdc/main.js CHANGED
@@ -786,7 +786,7 @@ class DurableTTLStore {
786
786
  }
787
787
  }
788
788
 
789
- function flushInMemoryStoreValuesToDurableStore(store, durableStore, crossEnvironmentNotifier, durableStoreErrorHandler, redirects, additionalDurableStoreOperations = [], enableDurableMetadataRefresh = false) {
789
+ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStoreErrorHandler, redirects, additionalDurableStoreOperations = [], enableDurableMetadataRefresh = false) {
790
790
  const durableRecords = create$6(null);
791
791
  const refreshedDurableRecords = create$6(null);
792
792
  const evictedRecords = create$6(null);
@@ -826,21 +826,14 @@ function flushInMemoryStoreValuesToDurableStore(store, durableStore, crossEnviro
826
826
  segment: DefaultDurableSegment,
827
827
  });
828
828
  }
829
- if (keys$7(refreshedDurableRecords).length > 0) {
829
+ const refreshKeys = keys$7(refreshedDurableRecords);
830
+ if (refreshKeys.length > 0) {
830
831
  // publishes with only metadata updates
831
832
  durableStoreOperations.push({
832
833
  type: 'setMetadata',
833
834
  entries: refreshedDurableRecords,
834
835
  segment: DefaultDurableSegment,
835
836
  });
836
- if (crossEnvironmentNotifier !== undefined) {
837
- crossEnvironmentNotifier.notifyCrossEnvironments({
838
- data: {
839
- refreshedDurableRecords,
840
- },
841
- type: 'Update',
842
- });
843
- }
844
837
  }
845
838
  // redirects
846
839
  redirects.forEach((value, key) => {
@@ -1142,14 +1135,17 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1142
1135
  }
1143
1136
  // process metadata only refreshes
1144
1137
  if (metadataRefreshSegmentKeys.length > 0) {
1145
- const entries = await durableStore.getMetadata(metadataRefreshSegmentKeys, DefaultDurableSegment);
1146
- if (entries !== undefined) {
1147
- const entryKeys = keys$7(entries);
1148
- for (let i = 0, len = entryKeys.length; i < len; i++) {
1149
- const entryKey = entryKeys[i];
1150
- const { metadata } = entries[entryKey];
1151
- if (metadata !== undefined) {
1152
- environment.putStoreMetadata(entryKey, metadata, false);
1138
+ const filteredKeys = metadataRefreshSegmentKeys.filter((s) => environment.storeKeyExists(s));
1139
+ if (filteredKeys.length > 0) {
1140
+ const entries = await durableStore.getMetadata(filteredKeys, DefaultDurableSegment);
1141
+ if (entries !== undefined) {
1142
+ const entryKeys = keys$7(entries);
1143
+ for (let i = 0, len = entryKeys.length; i < len; i++) {
1144
+ const entryKey = entryKeys[i];
1145
+ const { metadata } = entries[entryKey];
1146
+ if (metadata !== undefined) {
1147
+ environment.putStoreMetadata(entryKey, metadata, false);
1148
+ }
1153
1149
  }
1154
1150
  }
1155
1151
  }
@@ -1172,15 +1168,6 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1172
1168
  }
1173
1169
  }
1174
1170
  });
1175
- let notifier;
1176
- const getCrossEnvironmentNotifier = function () {
1177
- validateNotDisposed();
1178
- return notifier;
1179
- };
1180
- const setCrossEnvironmentNotifier = function (crossEnvironmentNotifier) {
1181
- validateNotDisposed();
1182
- notifier = crossEnvironmentNotifier;
1183
- };
1184
1171
  const dispose = function () {
1185
1172
  validateNotDisposed();
1186
1173
  disposed = true;
@@ -1233,7 +1220,7 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1233
1220
  if (stagingStore === null) {
1234
1221
  return Promise.resolve();
1235
1222
  }
1236
- const promise = flushInMemoryStoreValuesToDurableStore(stagingStore, durableStore, getCrossEnvironmentNotifier(), durableStoreErrorHandler, new Map(pendingStoreRedirects), additionalDurableStoreOperations, enableDurableMetadataRefresh);
1223
+ const promise = flushInMemoryStoreValuesToDurableStore(stagingStore, durableStore, durableStoreErrorHandler, new Map(pendingStoreRedirects), additionalDurableStoreOperations, enableDurableMetadataRefresh);
1237
1224
  pendingStoreRedirects.clear();
1238
1225
  stagingStore = null;
1239
1226
  return promise;
@@ -1603,8 +1590,6 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1603
1590
  handleErrorResponse: { value: handleErrorResponse },
1604
1591
  getNotifyChangeStoreEntries: { value: getNotifyChangeStoreEntries },
1605
1592
  notifyStoreUpdateAvailable: { value: notifyStoreUpdateAvailable },
1606
- getCrossEnvironmentNotifier: { value: getCrossEnvironmentNotifier },
1607
- setCrossEnvironmentNotifier: { value: setCrossEnvironmentNotifier },
1608
1593
  });
1609
1594
  }
1610
1595
 
@@ -12384,13 +12369,21 @@ function buildSyntheticRecordRepresentation(luvio, createOperation, userId, obje
12384
12369
  draftFields[DEFAULT_FIELD_LAST_MODIFIED_DATE] = { value: timestampString, displayValue: null };
12385
12370
  draftFields[DEFAULT_FIELD_OWNER_ID] = { value: userId, displayValue: null };
12386
12371
  draftFields[DEFAULT_FIELD_ID] = { value: recordId, displayValue: null };
12387
- if (objectInfo !== undefined) {
12388
- const allObjectFields = keys$3(objectInfo.fields);
12389
- allObjectFields.forEach((fieldName) => {
12390
- if (draftFields[fieldName] === undefined) {
12391
- draftFields[fieldName] = { value: null, displayValue: null };
12392
- }
12393
- });
12372
+ const allObjectFields = keys$3(objectInfo.fields);
12373
+ allObjectFields.forEach((fieldName) => {
12374
+ if (draftFields[fieldName] === undefined) {
12375
+ draftFields[fieldName] = { value: null, displayValue: null };
12376
+ }
12377
+ });
12378
+ // TODO [W-14915806]: lightning-record-form injects the `IsPersonAccount`
12379
+ // field for all `Account` and `PersonAccount` records. However, not all
12380
+ // orgs use person accounts, and if that field is not present in the object
12381
+ // info then it is not synthesized. We force it to be synthesized here to
12382
+ // ensure lightning-record-form will work correctly with draft-created
12383
+ // accounts.
12384
+ if ((apiName === 'Account' || apiName === 'PersonAccount') &&
12385
+ draftFields['IsPersonAccount'] === undefined) {
12386
+ draftFields['IsPersonAccount'] = { value: null, displayValue: null };
12394
12387
  }
12395
12388
  return {
12396
12389
  id: recordId,
@@ -16797,6 +16790,7 @@ function findReferenceFieldForSpanningField(fieldName, objectInfo) {
16797
16790
  function buildFieldUnionArray(existingRecord, incomingRecord, objectInfo) {
16798
16791
  const allFields = Array.from(new Set([...Object.keys(existingRecord.fields), ...Object.keys(incomingRecord.fields)]));
16799
16792
  const fieldUnion = [];
16793
+ let includesSpanningFields = false;
16800
16794
  allFields.forEach((fieldName) => {
16801
16795
  const objectInfoField = objectInfo.fields[fieldName];
16802
16796
  if (objectInfoField === undefined) {
@@ -16804,13 +16798,14 @@ function buildFieldUnionArray(existingRecord, incomingRecord, objectInfo) {
16804
16798
  const referenceField = findReferenceFieldForSpanningField(fieldName, objectInfo);
16805
16799
  if (referenceField !== undefined) {
16806
16800
  fieldUnion.push(`${fieldName}.Id`);
16801
+ includesSpanningFields = true;
16807
16802
  }
16808
16803
  }
16809
16804
  else {
16810
16805
  fieldUnion.push(fieldName);
16811
16806
  }
16812
16807
  });
16813
- return fieldUnion;
16808
+ return { fields: fieldUnion, includesSpanningFields };
16814
16809
  }
16815
16810
  /**
16816
16811
  * Merges (if possible) an incoming record from a priming session with an existing record in the durable store.
@@ -16842,7 +16837,7 @@ function mergeRecord(existingRecord, incomingRecord, objectInfo) {
16842
16837
  ok: false,
16843
16838
  code: 'conflict-drafts',
16844
16839
  hasDraft: true,
16845
- fieldUnion: buildFieldUnionArray(existingRecord, incomingRecord, objectInfo),
16840
+ fieldUnion: buildFieldUnionArray(existingRecord, incomingRecord, objectInfo).fields,
16846
16841
  };
16847
16842
  }
16848
16843
  // Check if incoming record's Etag is equal to the existing one
@@ -16904,10 +16899,19 @@ function mergeRecord(existingRecord, incomingRecord, objectInfo) {
16904
16899
  };
16905
16900
  }
16906
16901
  // If Etags do not match and the incoming record does not contain all fields, re-request the record
16902
+ const { fields, includesSpanningFields } = buildFieldUnionArray(existingRecord, incomingRecord, objectInfo);
16903
+ if (includesSpanningFields) {
16904
+ return {
16905
+ ok: false,
16906
+ code: 'conflict-spanning-record',
16907
+ fieldUnion: fields,
16908
+ hasDraft: false,
16909
+ };
16910
+ }
16907
16911
  return {
16908
16912
  ok: false,
16909
16913
  code: 'conflict-missing-fields',
16910
- fieldUnion: buildFieldUnionArray(existingRecord, incomingRecord, objectInfo),
16914
+ fieldUnion: fields,
16911
16915
  hasDraft: false,
16912
16916
  };
16913
16917
  }
@@ -17960,4 +17964,4 @@ register({
17960
17964
  });
17961
17965
 
17962
17966
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
17963
- // version: 1.274.0-67da496e8
17967
+ // version: 1.276.0-dcebc4076