@salesforce/lds-runtime-mobile 1.108.0 → 1.109.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 +44 -17
  2. package/package.json +15 -15
  3. package/sfdc/main.js +44 -17
package/dist/main.js CHANGED
@@ -6048,7 +6048,7 @@ class DraftManager {
6048
6048
  }
6049
6049
 
6050
6050
  function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueue) {
6051
- let draftMetadata = null;
6051
+ const draftMetadata = {};
6052
6052
  // setup existing store redirects when bootstrapping the environment
6053
6053
  (async () => {
6054
6054
  const mappings = await getDraftIdMappings(durableStore);
@@ -6078,7 +6078,6 @@ function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueu
6078
6078
  if (queue.length === 0) {
6079
6079
  return env.handleSuccessResponse(ingestAndBroadcastFunc, getResponseCacheKeysFunc);
6080
6080
  }
6081
- const ingestMetadata = {};
6082
6081
  const cacheKeySet = getResponseCacheKeysFunc();
6083
6082
  for (const possibleKey of cacheKeySet.keys()) {
6084
6083
  const key = typeof possibleKey === 'string' ? possibleKey : '';
@@ -6091,37 +6090,44 @@ function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueu
6091
6090
  // if this key is related to a draft then mark it mergeable so
6092
6091
  // base environment revives it to staging store before ingestion
6093
6092
  cacheKey.mergeable = true;
6094
- ingestMetadata[key] = metadata;
6093
+ const existing = draftMetadata[key];
6094
+ if (existing === undefined) {
6095
+ draftMetadata[key] = { metadata, refCount: 1 };
6096
+ }
6097
+ else {
6098
+ draftMetadata[key] = { metadata, refCount: existing.refCount + 1 };
6099
+ }
6095
6100
  }
6096
6101
  break;
6097
6102
  }
6098
6103
  }
6099
6104
  }
6100
- draftMetadata = keys$4(ingestMetadata).length > 0 ? ingestMetadata : null;
6101
6105
  return env.handleSuccessResponse(ingestAndBroadcastFunc, () => cacheKeySet);
6102
6106
  };
6103
6107
  const storePublish = function (key, data) {
6104
- if (draftMetadata === null) {
6105
- // no drafts for this response
6106
- return env.storePublish(key, data);
6107
- }
6108
+ const draftMetadataForKey = draftMetadata[key];
6108
6109
  for (const handler of handlers) {
6109
6110
  if (handler.canHandlePublish(key)) {
6110
- handler.applyDraftsToIncomingData(key, data, draftMetadata[key], env.storePublish);
6111
+ handler.applyDraftsToIncomingData(key, data, draftMetadataForKey && draftMetadataForKey.metadata, env.storePublish);
6111
6112
  return;
6112
6113
  }
6113
6114
  }
6115
+ if (draftMetadataForKey !== undefined) {
6116
+ // WARNING: this code depends on the fact that RecordRepresentation
6117
+ // fields get published before the root record.
6118
+ if (draftMetadataForKey.refCount === 1) {
6119
+ delete draftMetadata[key];
6120
+ }
6121
+ else {
6122
+ draftMetadataForKey.refCount--;
6123
+ }
6124
+ }
6114
6125
  // no handler could handle it so publish
6115
6126
  env.storePublish(key, data);
6116
6127
  };
6117
- const storeBroadcast = function (rebuildSnapshot, snapshotAvailable) {
6118
- draftMetadata = create$4(null);
6119
- return env.storeBroadcast(rebuildSnapshot, snapshotAvailable);
6120
- };
6121
6128
  // note the makeEnvironmentUiApiRecordDraftAware will eventually go away once the adapters become draft aware
6122
6129
  return create$4(env, {
6123
6130
  storePublish: { value: storePublish },
6124
- storeBroadcast: { value: storeBroadcast },
6125
6131
  handleSuccessResponse: { value: handleSuccessResponse },
6126
6132
  });
6127
6133
  }
@@ -11211,6 +11217,9 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11211
11217
  }
11212
11218
  // assert that object infos and references exist
11213
11219
  const metaDataResult = await this.recordService.getRecordDraftMetadata(targetId, pendingAction);
11220
+ if (metaDataResult === undefined) {
11221
+ throw Error('No metadata for draft');
11222
+ }
11214
11223
  if (metaDataResult.ok === false) {
11215
11224
  switch (metaDataResult.status) {
11216
11225
  case 'missing-object-info':
@@ -11288,7 +11297,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11288
11297
  return undefined;
11289
11298
  }
11290
11299
  const status = await this.recordService.getRecordDraftMetadata(recordId, undefined);
11291
- return status.data;
11300
+ return status && status.data;
11292
11301
  }
11293
11302
  isActionRecordAction(action) {
11294
11303
  return action.handler === this.handlerId;
@@ -11839,6 +11848,9 @@ class UiApiDraftRecordService {
11839
11848
  async getRecordDraftMetadata(recordId, incomingAction) {
11840
11849
  var _a;
11841
11850
  const recordOperations = (await this.queueToRecordOperations(incomingAction)).filter((x) => x.id === recordId);
11851
+ if (recordOperations.length === 0) {
11852
+ return undefined;
11853
+ }
11842
11854
  const objectInfoMap = new Map();
11843
11855
  const referenceMap = new Map();
11844
11856
  const missingReferenceKeys = new Set();
@@ -11873,7 +11885,7 @@ class UiApiDraftRecordService {
11873
11885
  continue;
11874
11886
  }
11875
11887
  // relax the check for record type ids as they will
11876
- // unlikley to be cached
11888
+ // unlikely to be cached
11877
11889
  if (fieldInfo.dataType !== 'Reference' || field === 'RecordTypeId') {
11878
11890
  continue;
11879
11891
  }
@@ -11935,6 +11947,9 @@ class UiApiDraftRecordService {
11935
11947
  }
11936
11948
  async synthesizeDraftRecord(recordId) {
11937
11949
  const metadata = await this.getRecordDraftMetadata(recordId, undefined);
11950
+ if (metadata === undefined) {
11951
+ return undefined;
11952
+ }
11938
11953
  const record = replayDraftsOnRecord(undefined, metadata.data);
11939
11954
  return record;
11940
11955
  }
@@ -12456,6 +12471,9 @@ class ContentDocumentCompositeRepresentationActionHandler extends AbstractResour
12456
12471
  pendingAction.metadata[CONTENT_DOCUMENT_LINK_DRAFT_ID_KEY] = contentDocumentLinkId;
12457
12472
  // assert that object infos and references exist
12458
12473
  const metaDataResult = await this.draftRecordService.getRecordDraftMetadata(targetId, pendingAction);
12474
+ if (metaDataResult === undefined) {
12475
+ throw Error('No metadata for draft');
12476
+ }
12459
12477
  if (metaDataResult.ok === false) {
12460
12478
  switch (metaDataResult.status) {
12461
12479
  case 'missing-object-info':
@@ -12502,18 +12520,27 @@ class ContentDocumentCompositeRepresentationActionHandler extends AbstractResour
12502
12520
  }
12503
12521
  // get the content doc
12504
12522
  const contentDocMetadata = await this.draftRecordService.getRecordDraftMetadata(contentDocumentId, undefined);
12523
+ if (contentDocMetadata === undefined) {
12524
+ return undefined;
12525
+ }
12505
12526
  const contentDocRecord = replayDraftsOnRecord(undefined, contentDocMetadata.data);
12506
12527
  if (contentDocRecord === undefined) {
12507
12528
  return undefined;
12508
12529
  }
12509
12530
  // get the contentDocLink to the user
12510
12531
  const contentDocLinkMetadata = await this.draftRecordService.getRecordDraftMetadata(contentDocumentLinkId, undefined);
12532
+ if (contentDocLinkMetadata === undefined) {
12533
+ return undefined;
12534
+ }
12511
12535
  const contentDocLink = replayDraftsOnRecord(undefined, contentDocLinkMetadata.data);
12512
12536
  if (contentDocLink === undefined) {
12513
12537
  return undefined;
12514
12538
  }
12515
12539
  // get the content version
12516
12540
  const contentVersionMetadata = await this.draftRecordService.getRecordDraftMetadata(contentVersionId, undefined);
12541
+ if (contentVersionMetadata === undefined) {
12542
+ return undefined;
12543
+ }
12517
12544
  const contentVersion = replayDraftsOnRecord(undefined, contentVersionMetadata.data);
12518
12545
  if (contentVersion === undefined) {
12519
12546
  return undefined;
@@ -15359,4 +15386,4 @@ register({
15359
15386
  });
15360
15387
 
15361
15388
  export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
15362
- // version: 1.108.0-ae43b5312
15389
+ // version: 1.109.0-d6ed43b2e
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.108.0",
3
+ "version": "1.109.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.108.0",
36
- "@salesforce/lds-bindings": "^1.108.0",
37
- "@salesforce/lds-instrumentation": "^1.108.0",
38
- "@salesforce/lds-priming": "^1.108.0",
35
+ "@salesforce/lds-adapters-uiapi": "^1.109.0",
36
+ "@salesforce/lds-bindings": "^1.109.0",
37
+ "@salesforce/lds-instrumentation": "^1.109.0",
38
+ "@salesforce/lds-priming": "^1.109.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.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",
46
+ "@salesforce/lds-adapters-graphql": "^1.109.0",
47
+ "@salesforce/lds-drafts": "^1.109.0",
48
+ "@salesforce/lds-drafts-adapters-uiapi": "^1.109.0",
49
+ "@salesforce/lds-graphql-eval": "^1.109.0",
50
+ "@salesforce/lds-network-adapter": "^1.109.0",
51
+ "@salesforce/lds-network-nimbus": "^1.109.0",
52
+ "@salesforce/lds-store-binary": "^1.109.0",
53
+ "@salesforce/lds-store-sql": "^1.109.0",
54
+ "@salesforce/lds-utils-adapters": "^1.109.0",
55
+ "@salesforce/nimbus-plugin-lds": "^1.109.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
@@ -6048,7 +6048,7 @@ class DraftManager {
6048
6048
  }
6049
6049
 
6050
6050
  function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueue) {
6051
- let draftMetadata = null;
6051
+ const draftMetadata = {};
6052
6052
  // setup existing store redirects when bootstrapping the environment
6053
6053
  (async () => {
6054
6054
  const mappings = await getDraftIdMappings(durableStore);
@@ -6078,7 +6078,6 @@ function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueu
6078
6078
  if (queue.length === 0) {
6079
6079
  return env.handleSuccessResponse(ingestAndBroadcastFunc, getResponseCacheKeysFunc);
6080
6080
  }
6081
- const ingestMetadata = {};
6082
6081
  const cacheKeySet = getResponseCacheKeysFunc();
6083
6082
  for (const possibleKey of cacheKeySet.keys()) {
6084
6083
  const key = typeof possibleKey === 'string' ? possibleKey : '';
@@ -6091,37 +6090,44 @@ function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueu
6091
6090
  // if this key is related to a draft then mark it mergeable so
6092
6091
  // base environment revives it to staging store before ingestion
6093
6092
  cacheKey.mergeable = true;
6094
- ingestMetadata[key] = metadata;
6093
+ const existing = draftMetadata[key];
6094
+ if (existing === undefined) {
6095
+ draftMetadata[key] = { metadata, refCount: 1 };
6096
+ }
6097
+ else {
6098
+ draftMetadata[key] = { metadata, refCount: existing.refCount + 1 };
6099
+ }
6095
6100
  }
6096
6101
  break;
6097
6102
  }
6098
6103
  }
6099
6104
  }
6100
- draftMetadata = keys$4(ingestMetadata).length > 0 ? ingestMetadata : null;
6101
6105
  return env.handleSuccessResponse(ingestAndBroadcastFunc, () => cacheKeySet);
6102
6106
  };
6103
6107
  const storePublish = function (key, data) {
6104
- if (draftMetadata === null) {
6105
- // no drafts for this response
6106
- return env.storePublish(key, data);
6107
- }
6108
+ const draftMetadataForKey = draftMetadata[key];
6108
6109
  for (const handler of handlers) {
6109
6110
  if (handler.canHandlePublish(key)) {
6110
- handler.applyDraftsToIncomingData(key, data, draftMetadata[key], env.storePublish);
6111
+ handler.applyDraftsToIncomingData(key, data, draftMetadataForKey && draftMetadataForKey.metadata, env.storePublish);
6111
6112
  return;
6112
6113
  }
6113
6114
  }
6115
+ if (draftMetadataForKey !== undefined) {
6116
+ // WARNING: this code depends on the fact that RecordRepresentation
6117
+ // fields get published before the root record.
6118
+ if (draftMetadataForKey.refCount === 1) {
6119
+ delete draftMetadata[key];
6120
+ }
6121
+ else {
6122
+ draftMetadataForKey.refCount--;
6123
+ }
6124
+ }
6114
6125
  // no handler could handle it so publish
6115
6126
  env.storePublish(key, data);
6116
6127
  };
6117
- const storeBroadcast = function (rebuildSnapshot, snapshotAvailable) {
6118
- draftMetadata = create$4(null);
6119
- return env.storeBroadcast(rebuildSnapshot, snapshotAvailable);
6120
- };
6121
6128
  // note the makeEnvironmentUiApiRecordDraftAware will eventually go away once the adapters become draft aware
6122
6129
  return create$4(env, {
6123
6130
  storePublish: { value: storePublish },
6124
- storeBroadcast: { value: storeBroadcast },
6125
6131
  handleSuccessResponse: { value: handleSuccessResponse },
6126
6132
  });
6127
6133
  }
@@ -11211,6 +11217,9 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11211
11217
  }
11212
11218
  // assert that object infos and references exist
11213
11219
  const metaDataResult = await this.recordService.getRecordDraftMetadata(targetId, pendingAction);
11220
+ if (metaDataResult === undefined) {
11221
+ throw Error('No metadata for draft');
11222
+ }
11214
11223
  if (metaDataResult.ok === false) {
11215
11224
  switch (metaDataResult.status) {
11216
11225
  case 'missing-object-info':
@@ -11288,7 +11297,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
11288
11297
  return undefined;
11289
11298
  }
11290
11299
  const status = await this.recordService.getRecordDraftMetadata(recordId, undefined);
11291
- return status.data;
11300
+ return status && status.data;
11292
11301
  }
11293
11302
  isActionRecordAction(action) {
11294
11303
  return action.handler === this.handlerId;
@@ -11839,6 +11848,9 @@ class UiApiDraftRecordService {
11839
11848
  async getRecordDraftMetadata(recordId, incomingAction) {
11840
11849
  var _a;
11841
11850
  const recordOperations = (await this.queueToRecordOperations(incomingAction)).filter((x) => x.id === recordId);
11851
+ if (recordOperations.length === 0) {
11852
+ return undefined;
11853
+ }
11842
11854
  const objectInfoMap = new Map();
11843
11855
  const referenceMap = new Map();
11844
11856
  const missingReferenceKeys = new Set();
@@ -11873,7 +11885,7 @@ class UiApiDraftRecordService {
11873
11885
  continue;
11874
11886
  }
11875
11887
  // relax the check for record type ids as they will
11876
- // unlikley to be cached
11888
+ // unlikely to be cached
11877
11889
  if (fieldInfo.dataType !== 'Reference' || field === 'RecordTypeId') {
11878
11890
  continue;
11879
11891
  }
@@ -11935,6 +11947,9 @@ class UiApiDraftRecordService {
11935
11947
  }
11936
11948
  async synthesizeDraftRecord(recordId) {
11937
11949
  const metadata = await this.getRecordDraftMetadata(recordId, undefined);
11950
+ if (metadata === undefined) {
11951
+ return undefined;
11952
+ }
11938
11953
  const record = replayDraftsOnRecord(undefined, metadata.data);
11939
11954
  return record;
11940
11955
  }
@@ -12456,6 +12471,9 @@ class ContentDocumentCompositeRepresentationActionHandler extends AbstractResour
12456
12471
  pendingAction.metadata[CONTENT_DOCUMENT_LINK_DRAFT_ID_KEY] = contentDocumentLinkId;
12457
12472
  // assert that object infos and references exist
12458
12473
  const metaDataResult = await this.draftRecordService.getRecordDraftMetadata(targetId, pendingAction);
12474
+ if (metaDataResult === undefined) {
12475
+ throw Error('No metadata for draft');
12476
+ }
12459
12477
  if (metaDataResult.ok === false) {
12460
12478
  switch (metaDataResult.status) {
12461
12479
  case 'missing-object-info':
@@ -12502,18 +12520,27 @@ class ContentDocumentCompositeRepresentationActionHandler extends AbstractResour
12502
12520
  }
12503
12521
  // get the content doc
12504
12522
  const contentDocMetadata = await this.draftRecordService.getRecordDraftMetadata(contentDocumentId, undefined);
12523
+ if (contentDocMetadata === undefined) {
12524
+ return undefined;
12525
+ }
12505
12526
  const contentDocRecord = replayDraftsOnRecord(undefined, contentDocMetadata.data);
12506
12527
  if (contentDocRecord === undefined) {
12507
12528
  return undefined;
12508
12529
  }
12509
12530
  // get the contentDocLink to the user
12510
12531
  const contentDocLinkMetadata = await this.draftRecordService.getRecordDraftMetadata(contentDocumentLinkId, undefined);
12532
+ if (contentDocLinkMetadata === undefined) {
12533
+ return undefined;
12534
+ }
12511
12535
  const contentDocLink = replayDraftsOnRecord(undefined, contentDocLinkMetadata.data);
12512
12536
  if (contentDocLink === undefined) {
12513
12537
  return undefined;
12514
12538
  }
12515
12539
  // get the content version
12516
12540
  const contentVersionMetadata = await this.draftRecordService.getRecordDraftMetadata(contentVersionId, undefined);
12541
+ if (contentVersionMetadata === undefined) {
12542
+ return undefined;
12543
+ }
12517
12544
  const contentVersion = replayDraftsOnRecord(undefined, contentVersionMetadata.data);
12518
12545
  if (contentVersion === undefined) {
12519
12546
  return undefined;
@@ -15359,4 +15386,4 @@ register({
15359
15386
  });
15360
15387
 
15361
15388
  export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
15362
- // version: 1.108.0-ae43b5312
15389
+ // version: 1.109.0-d6ed43b2e