@salesforce/lds-drafts 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.
- package/dist/ldsDrafts.js +20 -14
- package/package.json +2 -2
package/dist/ldsDrafts.js
CHANGED
|
@@ -1648,7 +1648,7 @@ class DraftManager {
|
|
|
1648
1648
|
}
|
|
1649
1649
|
|
|
1650
1650
|
function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueue) {
|
|
1651
|
-
|
|
1651
|
+
const draftMetadata = {};
|
|
1652
1652
|
// setup existing store redirects when bootstrapping the environment
|
|
1653
1653
|
(async () => {
|
|
1654
1654
|
const mappings = await getDraftIdMappings(durableStore);
|
|
@@ -1678,7 +1678,6 @@ function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueu
|
|
|
1678
1678
|
if (queue.length === 0) {
|
|
1679
1679
|
return env.handleSuccessResponse(ingestAndBroadcastFunc, getResponseCacheKeysFunc);
|
|
1680
1680
|
}
|
|
1681
|
-
const ingestMetadata = {};
|
|
1682
1681
|
const cacheKeySet = getResponseCacheKeysFunc();
|
|
1683
1682
|
for (const possibleKey of cacheKeySet.keys()) {
|
|
1684
1683
|
const key = typeof possibleKey === 'string' ? possibleKey : '';
|
|
@@ -1691,37 +1690,44 @@ function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueu
|
|
|
1691
1690
|
// if this key is related to a draft then mark it mergeable so
|
|
1692
1691
|
// base environment revives it to staging store before ingestion
|
|
1693
1692
|
cacheKey.mergeable = true;
|
|
1694
|
-
|
|
1693
|
+
const existing = draftMetadata[key];
|
|
1694
|
+
if (existing === undefined) {
|
|
1695
|
+
draftMetadata[key] = { metadata, refCount: 1 };
|
|
1696
|
+
}
|
|
1697
|
+
else {
|
|
1698
|
+
draftMetadata[key] = { metadata, refCount: existing.refCount + 1 };
|
|
1699
|
+
}
|
|
1695
1700
|
}
|
|
1696
1701
|
break;
|
|
1697
1702
|
}
|
|
1698
1703
|
}
|
|
1699
1704
|
}
|
|
1700
|
-
draftMetadata = keys(ingestMetadata).length > 0 ? ingestMetadata : null;
|
|
1701
1705
|
return env.handleSuccessResponse(ingestAndBroadcastFunc, () => cacheKeySet);
|
|
1702
1706
|
};
|
|
1703
1707
|
const storePublish = function (key, data) {
|
|
1704
|
-
|
|
1705
|
-
// no drafts for this response
|
|
1706
|
-
return env.storePublish(key, data);
|
|
1707
|
-
}
|
|
1708
|
+
const draftMetadataForKey = draftMetadata[key];
|
|
1708
1709
|
for (const handler of handlers) {
|
|
1709
1710
|
if (handler.canHandlePublish(key)) {
|
|
1710
|
-
handler.applyDraftsToIncomingData(key, data,
|
|
1711
|
+
handler.applyDraftsToIncomingData(key, data, draftMetadataForKey && draftMetadataForKey.metadata, env.storePublish);
|
|
1711
1712
|
return;
|
|
1712
1713
|
}
|
|
1713
1714
|
}
|
|
1715
|
+
if (draftMetadataForKey !== undefined) {
|
|
1716
|
+
// WARNING: this code depends on the fact that RecordRepresentation
|
|
1717
|
+
// fields get published before the root record.
|
|
1718
|
+
if (draftMetadataForKey.refCount === 1) {
|
|
1719
|
+
delete draftMetadata[key];
|
|
1720
|
+
}
|
|
1721
|
+
else {
|
|
1722
|
+
draftMetadataForKey.refCount--;
|
|
1723
|
+
}
|
|
1724
|
+
}
|
|
1714
1725
|
// no handler could handle it so publish
|
|
1715
1726
|
env.storePublish(key, data);
|
|
1716
1727
|
};
|
|
1717
|
-
const storeBroadcast = function (rebuildSnapshot, snapshotAvailable) {
|
|
1718
|
-
draftMetadata = create(null);
|
|
1719
|
-
return env.storeBroadcast(rebuildSnapshot, snapshotAvailable);
|
|
1720
|
-
};
|
|
1721
1728
|
// note the makeEnvironmentUiApiRecordDraftAware will eventually go away once the adapters become draft aware
|
|
1722
1729
|
return create(env, {
|
|
1723
1730
|
storePublish: { value: storePublish },
|
|
1724
|
-
storeBroadcast: { value: storeBroadcast },
|
|
1725
1731
|
handleSuccessResponse: { value: handleSuccessResponse },
|
|
1726
1732
|
});
|
|
1727
1733
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-drafts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.109.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"description": "LDS Drafts",
|
|
6
6
|
"main": "dist/ldsDrafts.js",
|
|
@@ -26,6 +26,6 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@luvio/engine": "0.135.4",
|
|
28
28
|
"@luvio/environments": "0.135.4",
|
|
29
|
-
"@salesforce/lds-utils-adapters": "^1.
|
|
29
|
+
"@salesforce/lds-utils-adapters": "^1.109.0"
|
|
30
30
|
}
|
|
31
31
|
}
|