@salesforce/lds-worker-api 1.285.0 → 1.287.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.
|
@@ -1074,4 +1074,4 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
1074
1074
|
}
|
|
1075
1075
|
|
|
1076
1076
|
export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
|
|
1077
|
-
// version: 1.
|
|
1077
|
+
// version: 1.287.0-f2fda24df
|
|
@@ -521,6 +521,25 @@ class StoreKeySet {
|
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
523
|
|
|
524
|
+
function defaultTrimPolicy(data, deallocateFn) {
|
|
525
|
+
return new Promise((resolve) => {
|
|
526
|
+
let deallocatedCount = 0;
|
|
527
|
+
const { pendingTrimKeys, retainedIds, metadata } = data;
|
|
528
|
+
const now = Date.now();
|
|
529
|
+
pendingTrimKeys.forEach((key) => {
|
|
530
|
+
const recordExpiration = metadata[key];
|
|
531
|
+
if (retainedIds[key] !== undefined ||
|
|
532
|
+
recordExpiration === undefined ||
|
|
533
|
+
(recordExpiration !== undefined && recordExpiration.expirationTimestamp >= now)) {
|
|
534
|
+
return;
|
|
535
|
+
}
|
|
536
|
+
deallocateFn(key);
|
|
537
|
+
deallocatedCount++;
|
|
538
|
+
});
|
|
539
|
+
resolve({ deallocatedCount });
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
|
|
524
543
|
const Serialized_StringKey_Version = '1';
|
|
525
544
|
function hasOverlappingIds$1(snapshot, visitedIds) {
|
|
526
545
|
const { length: len } = visitedIds;
|
|
@@ -589,6 +608,7 @@ class StringKeyInMemoryStore {
|
|
|
589
608
|
if (options.initialData) {
|
|
590
609
|
this.deserialize(options.initialData, options.resetInitialDataTtls);
|
|
591
610
|
}
|
|
611
|
+
this.trimPolicy = options.customTrimPolicy || defaultTrimPolicy;
|
|
592
612
|
}
|
|
593
613
|
// interface methods
|
|
594
614
|
readEntry(key) {
|
|
@@ -962,22 +982,15 @@ class StringKeyInMemoryStore {
|
|
|
962
982
|
scheduleTrim() {
|
|
963
983
|
if (this.trimTask === null) {
|
|
964
984
|
this.trimTask = () => {
|
|
965
|
-
const { metadata, retainedIds,
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
recordExpiration === undefined ||
|
|
972
|
-
(recordExpiration !== undefined &&
|
|
973
|
-
recordExpiration.expirationTimestamp >= now)) {
|
|
974
|
-
return;
|
|
985
|
+
const { metadata, pendingTrimKeys, retainedIds, records: storeRecords, dealloc, } = this;
|
|
986
|
+
return this.trimPolicy({ metadata, pendingTrimKeys, retainedIds, storeRecords }, dealloc.bind(this)).then((result) => {
|
|
987
|
+
this.pendingTrimKeys.clear();
|
|
988
|
+
const { trimKeysSkipped } = result;
|
|
989
|
+
if (trimKeysSkipped !== undefined) {
|
|
990
|
+
this.pendingTrimKeys = trimKeysSkipped;
|
|
975
991
|
}
|
|
976
|
-
|
|
977
|
-
deallocCount++;
|
|
992
|
+
return result;
|
|
978
993
|
});
|
|
979
|
-
pendingTrimKeys.clear();
|
|
980
|
-
return deallocCount;
|
|
981
994
|
};
|
|
982
995
|
this.scheduler(this.trimTask, () => {
|
|
983
996
|
this.trimTask = null;
|
|
@@ -1716,7 +1729,7 @@ class InMemoryStore {
|
|
|
1716
1729
|
deallocCount++;
|
|
1717
1730
|
});
|
|
1718
1731
|
pendingTrims.clear();
|
|
1719
|
-
return deallocCount;
|
|
1732
|
+
return Promise.resolve({ deallocatedCount: deallocCount });
|
|
1720
1733
|
};
|
|
1721
1734
|
this.scheduler(this.trimTask, () => {
|
|
1722
1735
|
this.trimTask = null;
|
|
@@ -4049,7 +4062,7 @@ function createResourceParamsImpl(config, configMetadata) {
|
|
|
4049
4062
|
}
|
|
4050
4063
|
return resourceParams;
|
|
4051
4064
|
}
|
|
4052
|
-
// engine version: 0.154.
|
|
4065
|
+
// engine version: 0.154.16-5cc35392
|
|
4053
4066
|
|
|
4054
4067
|
/**
|
|
4055
4068
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -4177,7 +4190,7 @@ function withDefaultLuvio(callback) {
|
|
|
4177
4190
|
}
|
|
4178
4191
|
callbacks.push(callback);
|
|
4179
4192
|
}
|
|
4180
|
-
// version: 1.
|
|
4193
|
+
// version: 1.287.0-f2fda24df
|
|
4181
4194
|
|
|
4182
4195
|
// TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
|
|
4183
4196
|
function instrumentAdapter$1(createFunction, _metadata) {
|
|
@@ -15685,7 +15698,7 @@ function gql(literals, ...subs) {
|
|
|
15685
15698
|
}
|
|
15686
15699
|
return superResult;
|
|
15687
15700
|
}
|
|
15688
|
-
// version: 1.
|
|
15701
|
+
// version: 1.287.0-f2fda24df
|
|
15689
15702
|
|
|
15690
15703
|
function unwrap(data) {
|
|
15691
15704
|
// The lwc-luvio bindings import a function from lwc called "unwrap".
|
|
@@ -16610,7 +16623,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
|
|
|
16610
16623
|
const { apiFamily, name } = metadata;
|
|
16611
16624
|
return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
|
|
16612
16625
|
}
|
|
16613
|
-
// version: 1.
|
|
16626
|
+
// version: 1.287.0-f2fda24df
|
|
16614
16627
|
|
|
16615
16628
|
/**
|
|
16616
16629
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -16709,7 +16722,7 @@ var TypeCheckShapes;
|
|
|
16709
16722
|
TypeCheckShapes[TypeCheckShapes["Integer"] = 3] = "Integer";
|
|
16710
16723
|
TypeCheckShapes[TypeCheckShapes["Unsupported"] = 4] = "Unsupported";
|
|
16711
16724
|
})(TypeCheckShapes || (TypeCheckShapes = {}));
|
|
16712
|
-
// engine version: 0.154.
|
|
16725
|
+
// engine version: 0.154.16-5cc35392
|
|
16713
16726
|
|
|
16714
16727
|
const { keys: ObjectKeys$3, create: ObjectCreate$3 } = Object;
|
|
16715
16728
|
|
|
@@ -44151,7 +44164,7 @@ withDefaultLuvio((luvio) => {
|
|
|
44151
44164
|
throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
|
|
44152
44165
|
throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
|
|
44153
44166
|
});
|
|
44154
|
-
// version: 1.
|
|
44167
|
+
// version: 1.287.0-52ee1d50a
|
|
44155
44168
|
|
|
44156
44169
|
var ldsIdempotencyWriteDisabled = {
|
|
44157
44170
|
isOpen: function (e) {
|
|
@@ -62140,6 +62153,74 @@ function primingSessionFactory(config) {
|
|
|
62140
62153
|
return instrumentPrimingSession(session);
|
|
62141
62154
|
}
|
|
62142
62155
|
|
|
62156
|
+
const DEFAULT_MAX_RECORD_COUNT = 80000;
|
|
62157
|
+
const DEFAULT_MAX_BATCH_SIZE = 200;
|
|
62158
|
+
async function aggressiveTrim(data, deallocateFn, options = {}) {
|
|
62159
|
+
const maxStoreRecords = options.maxStoreRecords !== undefined ? options.maxStoreRecords : DEFAULT_MAX_RECORD_COUNT;
|
|
62160
|
+
const batchSize = options.batchSize !== undefined ? options.batchSize : DEFAULT_MAX_BATCH_SIZE;
|
|
62161
|
+
let deallocatedCount = 0;
|
|
62162
|
+
const { pendingTrimKeys, retainedIds, storeRecords } = data;
|
|
62163
|
+
const storeKeyLength = keys$1$1(storeRecords).length;
|
|
62164
|
+
if (storeKeyLength <= maxStoreRecords) {
|
|
62165
|
+
return { deallocatedCount, trimKeysSkipped: pendingTrimKeys };
|
|
62166
|
+
}
|
|
62167
|
+
const overFlowSize = storeKeyLength - maxStoreRecords;
|
|
62168
|
+
if (overFlowSize <= 0) {
|
|
62169
|
+
return { deallocatedCount, trimKeysSkipped: pendingTrimKeys };
|
|
62170
|
+
}
|
|
62171
|
+
const trimKeys = new Set();
|
|
62172
|
+
for (const key of pendingTrimKeys) {
|
|
62173
|
+
if (storeKeyLength - trimKeys.size <= maxStoreRecords) {
|
|
62174
|
+
break;
|
|
62175
|
+
}
|
|
62176
|
+
if ((retainedIds[key] === undefined && storeRecords[key] !== undefined) ||
|
|
62177
|
+
(retainedIds[key] !== undefined && retainedIds[key] <= 1)) {
|
|
62178
|
+
trimKeys.add(key);
|
|
62179
|
+
}
|
|
62180
|
+
}
|
|
62181
|
+
const batches = batchKeys(trimKeys, batchSize).map((batch) => {
|
|
62182
|
+
return () => batchToPromise(batch, deallocateFn);
|
|
62183
|
+
});
|
|
62184
|
+
for (const batch of batches) {
|
|
62185
|
+
// execute each batch between ticks
|
|
62186
|
+
const count = await batch();
|
|
62187
|
+
deallocatedCount = deallocatedCount + count;
|
|
62188
|
+
}
|
|
62189
|
+
const trimKeysSkipped = makeSetFilteredFromDifference(pendingTrimKeys, (key) => trimKeys.has(key) === false);
|
|
62190
|
+
return {
|
|
62191
|
+
deallocatedCount,
|
|
62192
|
+
trimKeysSkipped,
|
|
62193
|
+
};
|
|
62194
|
+
}
|
|
62195
|
+
function batchToPromise(batch, deallocateFn) {
|
|
62196
|
+
return new Promise((resolve) => {
|
|
62197
|
+
let count = 0;
|
|
62198
|
+
batch.forEach((key) => {
|
|
62199
|
+
deallocateFn(key);
|
|
62200
|
+
count++;
|
|
62201
|
+
});
|
|
62202
|
+
resolve(count);
|
|
62203
|
+
});
|
|
62204
|
+
}
|
|
62205
|
+
function batchKeys(keys, batchSize) {
|
|
62206
|
+
const keyArray = Array.from(keys);
|
|
62207
|
+
const batches = [];
|
|
62208
|
+
for (let i = 0, len = keyArray.length; i < len; i += batchSize) {
|
|
62209
|
+
const batch = keyArray.slice(i, i + batchSize);
|
|
62210
|
+
batches.push(batch);
|
|
62211
|
+
}
|
|
62212
|
+
return batches;
|
|
62213
|
+
}
|
|
62214
|
+
function makeSetFilteredFromDifference(setToFilter, diff) {
|
|
62215
|
+
let filteredSet = new Set();
|
|
62216
|
+
setToFilter.forEach((t) => {
|
|
62217
|
+
if (diff(t)) {
|
|
62218
|
+
filteredSet.add(t);
|
|
62219
|
+
}
|
|
62220
|
+
});
|
|
62221
|
+
return filteredSet;
|
|
62222
|
+
}
|
|
62223
|
+
|
|
62143
62224
|
// so eslint doesn't complain about nimbus
|
|
62144
62225
|
/* global __nimbus */
|
|
62145
62226
|
function setupObserver() {
|
|
@@ -62183,7 +62264,9 @@ function getRuntime() {
|
|
|
62183
62264
|
// user id centric record ID generator
|
|
62184
62265
|
const { newRecordId, isGenerated } = recordIdGenerator(userId);
|
|
62185
62266
|
// non-draft-aware base services
|
|
62186
|
-
const store = new InMemoryStore(
|
|
62267
|
+
const store = new InMemoryStore({
|
|
62268
|
+
customTrimPolicy: aggressiveTrim,
|
|
62269
|
+
});
|
|
62187
62270
|
lazyNetworkAdapter = platformNetworkAdapter(makeNetworkAdapterChunkRecordFields(NimbusNetworkAdapter, {
|
|
62188
62271
|
reportChunkCandidateUrlLength: reportChunkCandidateUrlLength,
|
|
62189
62272
|
}));
|
|
@@ -62320,7 +62403,7 @@ register$1({
|
|
|
62320
62403
|
id: '@salesforce/lds-network-adapter',
|
|
62321
62404
|
instrument: instrument$2,
|
|
62322
62405
|
});
|
|
62323
|
-
// version: 1.
|
|
62406
|
+
// version: 1.287.0-f2fda24df
|
|
62324
62407
|
|
|
62325
62408
|
const { create: create$3, keys: keys$3 } = Object;
|
|
62326
62409
|
const { stringify: stringify$1, parse: parse$1 } = JSON;
|
|
@@ -82369,7 +82452,7 @@ register$1({
|
|
|
82369
82452
|
configuration: { ...configurationForGraphQLAdapters$1 },
|
|
82370
82453
|
instrument: instrument$1,
|
|
82371
82454
|
});
|
|
82372
|
-
// version: 1.
|
|
82455
|
+
// version: 1.287.0-52ee1d50a
|
|
82373
82456
|
|
|
82374
82457
|
// On core the unstable adapters are re-exported with different names,
|
|
82375
82458
|
// we want to match them here.
|
|
@@ -84625,7 +84708,7 @@ withDefaultLuvio((luvio) => {
|
|
|
84625
84708
|
unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
|
|
84626
84709
|
graphQLImperative = ldsAdapter;
|
|
84627
84710
|
});
|
|
84628
|
-
// version: 1.
|
|
84711
|
+
// version: 1.287.0-52ee1d50a
|
|
84629
84712
|
|
|
84630
84713
|
var gqlApi = /*#__PURE__*/Object.freeze({
|
|
84631
84714
|
__proto__: null,
|
|
@@ -85363,7 +85446,7 @@ const callbacks$1 = [];
|
|
|
85363
85446
|
function register(r) {
|
|
85364
85447
|
callbacks$1.forEach((callback) => callback(r));
|
|
85365
85448
|
}
|
|
85366
|
-
// version: 1.
|
|
85449
|
+
// version: 1.287.0-f2fda24df
|
|
85367
85450
|
|
|
85368
85451
|
/**
|
|
85369
85452
|
* Returns true if the value acts like a Promise, i.e. has a "then" function,
|
|
@@ -90315,4 +90398,4 @@ const { luvio } = getRuntime();
|
|
|
90315
90398
|
setDefaultLuvio({ luvio });
|
|
90316
90399
|
|
|
90317
90400
|
export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
|
|
90318
|
-
// version: 1.
|
|
90401
|
+
// version: 1.287.0-f2fda24df
|
|
@@ -527,6 +527,25 @@
|
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
529
|
|
|
530
|
+
function defaultTrimPolicy(data, deallocateFn) {
|
|
531
|
+
return new Promise((resolve) => {
|
|
532
|
+
let deallocatedCount = 0;
|
|
533
|
+
const { pendingTrimKeys, retainedIds, metadata } = data;
|
|
534
|
+
const now = Date.now();
|
|
535
|
+
pendingTrimKeys.forEach((key) => {
|
|
536
|
+
const recordExpiration = metadata[key];
|
|
537
|
+
if (retainedIds[key] !== undefined ||
|
|
538
|
+
recordExpiration === undefined ||
|
|
539
|
+
(recordExpiration !== undefined && recordExpiration.expirationTimestamp >= now)) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
deallocateFn(key);
|
|
543
|
+
deallocatedCount++;
|
|
544
|
+
});
|
|
545
|
+
resolve({ deallocatedCount });
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
|
|
530
549
|
const Serialized_StringKey_Version = '1';
|
|
531
550
|
function hasOverlappingIds$1(snapshot, visitedIds) {
|
|
532
551
|
const { length: len } = visitedIds;
|
|
@@ -595,6 +614,7 @@
|
|
|
595
614
|
if (options.initialData) {
|
|
596
615
|
this.deserialize(options.initialData, options.resetInitialDataTtls);
|
|
597
616
|
}
|
|
617
|
+
this.trimPolicy = options.customTrimPolicy || defaultTrimPolicy;
|
|
598
618
|
}
|
|
599
619
|
// interface methods
|
|
600
620
|
readEntry(key) {
|
|
@@ -968,22 +988,15 @@
|
|
|
968
988
|
scheduleTrim() {
|
|
969
989
|
if (this.trimTask === null) {
|
|
970
990
|
this.trimTask = () => {
|
|
971
|
-
const { metadata, retainedIds,
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
recordExpiration === undefined ||
|
|
978
|
-
(recordExpiration !== undefined &&
|
|
979
|
-
recordExpiration.expirationTimestamp >= now)) {
|
|
980
|
-
return;
|
|
991
|
+
const { metadata, pendingTrimKeys, retainedIds, records: storeRecords, dealloc, } = this;
|
|
992
|
+
return this.trimPolicy({ metadata, pendingTrimKeys, retainedIds, storeRecords }, dealloc.bind(this)).then((result) => {
|
|
993
|
+
this.pendingTrimKeys.clear();
|
|
994
|
+
const { trimKeysSkipped } = result;
|
|
995
|
+
if (trimKeysSkipped !== undefined) {
|
|
996
|
+
this.pendingTrimKeys = trimKeysSkipped;
|
|
981
997
|
}
|
|
982
|
-
|
|
983
|
-
deallocCount++;
|
|
998
|
+
return result;
|
|
984
999
|
});
|
|
985
|
-
pendingTrimKeys.clear();
|
|
986
|
-
return deallocCount;
|
|
987
1000
|
};
|
|
988
1001
|
this.scheduler(this.trimTask, () => {
|
|
989
1002
|
this.trimTask = null;
|
|
@@ -1722,7 +1735,7 @@
|
|
|
1722
1735
|
deallocCount++;
|
|
1723
1736
|
});
|
|
1724
1737
|
pendingTrims.clear();
|
|
1725
|
-
return deallocCount;
|
|
1738
|
+
return Promise.resolve({ deallocatedCount: deallocCount });
|
|
1726
1739
|
};
|
|
1727
1740
|
this.scheduler(this.trimTask, () => {
|
|
1728
1741
|
this.trimTask = null;
|
|
@@ -4055,7 +4068,7 @@
|
|
|
4055
4068
|
}
|
|
4056
4069
|
return resourceParams;
|
|
4057
4070
|
}
|
|
4058
|
-
// engine version: 0.154.
|
|
4071
|
+
// engine version: 0.154.16-5cc35392
|
|
4059
4072
|
|
|
4060
4073
|
/**
|
|
4061
4074
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -4183,7 +4196,7 @@
|
|
|
4183
4196
|
}
|
|
4184
4197
|
callbacks.push(callback);
|
|
4185
4198
|
}
|
|
4186
|
-
// version: 1.
|
|
4199
|
+
// version: 1.287.0-f2fda24df
|
|
4187
4200
|
|
|
4188
4201
|
// TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
|
|
4189
4202
|
function instrumentAdapter$1(createFunction, _metadata) {
|
|
@@ -15691,7 +15704,7 @@
|
|
|
15691
15704
|
}
|
|
15692
15705
|
return superResult;
|
|
15693
15706
|
}
|
|
15694
|
-
// version: 1.
|
|
15707
|
+
// version: 1.287.0-f2fda24df
|
|
15695
15708
|
|
|
15696
15709
|
function unwrap(data) {
|
|
15697
15710
|
// The lwc-luvio bindings import a function from lwc called "unwrap".
|
|
@@ -16616,7 +16629,7 @@
|
|
|
16616
16629
|
const { apiFamily, name } = metadata;
|
|
16617
16630
|
return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
|
|
16618
16631
|
}
|
|
16619
|
-
// version: 1.
|
|
16632
|
+
// version: 1.287.0-f2fda24df
|
|
16620
16633
|
|
|
16621
16634
|
/**
|
|
16622
16635
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -16715,7 +16728,7 @@
|
|
|
16715
16728
|
TypeCheckShapes[TypeCheckShapes["Integer"] = 3] = "Integer";
|
|
16716
16729
|
TypeCheckShapes[TypeCheckShapes["Unsupported"] = 4] = "Unsupported";
|
|
16717
16730
|
})(TypeCheckShapes || (TypeCheckShapes = {}));
|
|
16718
|
-
// engine version: 0.154.
|
|
16731
|
+
// engine version: 0.154.16-5cc35392
|
|
16719
16732
|
|
|
16720
16733
|
const { keys: ObjectKeys$3, create: ObjectCreate$3 } = Object;
|
|
16721
16734
|
|
|
@@ -44157,7 +44170,7 @@
|
|
|
44157
44170
|
throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
|
|
44158
44171
|
throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
|
|
44159
44172
|
});
|
|
44160
|
-
// version: 1.
|
|
44173
|
+
// version: 1.287.0-52ee1d50a
|
|
44161
44174
|
|
|
44162
44175
|
var ldsIdempotencyWriteDisabled = {
|
|
44163
44176
|
isOpen: function (e) {
|
|
@@ -62146,6 +62159,74 @@
|
|
|
62146
62159
|
return instrumentPrimingSession(session);
|
|
62147
62160
|
}
|
|
62148
62161
|
|
|
62162
|
+
const DEFAULT_MAX_RECORD_COUNT = 80000;
|
|
62163
|
+
const DEFAULT_MAX_BATCH_SIZE = 200;
|
|
62164
|
+
async function aggressiveTrim(data, deallocateFn, options = {}) {
|
|
62165
|
+
const maxStoreRecords = options.maxStoreRecords !== undefined ? options.maxStoreRecords : DEFAULT_MAX_RECORD_COUNT;
|
|
62166
|
+
const batchSize = options.batchSize !== undefined ? options.batchSize : DEFAULT_MAX_BATCH_SIZE;
|
|
62167
|
+
let deallocatedCount = 0;
|
|
62168
|
+
const { pendingTrimKeys, retainedIds, storeRecords } = data;
|
|
62169
|
+
const storeKeyLength = keys$1$1(storeRecords).length;
|
|
62170
|
+
if (storeKeyLength <= maxStoreRecords) {
|
|
62171
|
+
return { deallocatedCount, trimKeysSkipped: pendingTrimKeys };
|
|
62172
|
+
}
|
|
62173
|
+
const overFlowSize = storeKeyLength - maxStoreRecords;
|
|
62174
|
+
if (overFlowSize <= 0) {
|
|
62175
|
+
return { deallocatedCount, trimKeysSkipped: pendingTrimKeys };
|
|
62176
|
+
}
|
|
62177
|
+
const trimKeys = new Set();
|
|
62178
|
+
for (const key of pendingTrimKeys) {
|
|
62179
|
+
if (storeKeyLength - trimKeys.size <= maxStoreRecords) {
|
|
62180
|
+
break;
|
|
62181
|
+
}
|
|
62182
|
+
if ((retainedIds[key] === undefined && storeRecords[key] !== undefined) ||
|
|
62183
|
+
(retainedIds[key] !== undefined && retainedIds[key] <= 1)) {
|
|
62184
|
+
trimKeys.add(key);
|
|
62185
|
+
}
|
|
62186
|
+
}
|
|
62187
|
+
const batches = batchKeys(trimKeys, batchSize).map((batch) => {
|
|
62188
|
+
return () => batchToPromise(batch, deallocateFn);
|
|
62189
|
+
});
|
|
62190
|
+
for (const batch of batches) {
|
|
62191
|
+
// execute each batch between ticks
|
|
62192
|
+
const count = await batch();
|
|
62193
|
+
deallocatedCount = deallocatedCount + count;
|
|
62194
|
+
}
|
|
62195
|
+
const trimKeysSkipped = makeSetFilteredFromDifference(pendingTrimKeys, (key) => trimKeys.has(key) === false);
|
|
62196
|
+
return {
|
|
62197
|
+
deallocatedCount,
|
|
62198
|
+
trimKeysSkipped,
|
|
62199
|
+
};
|
|
62200
|
+
}
|
|
62201
|
+
function batchToPromise(batch, deallocateFn) {
|
|
62202
|
+
return new Promise((resolve) => {
|
|
62203
|
+
let count = 0;
|
|
62204
|
+
batch.forEach((key) => {
|
|
62205
|
+
deallocateFn(key);
|
|
62206
|
+
count++;
|
|
62207
|
+
});
|
|
62208
|
+
resolve(count);
|
|
62209
|
+
});
|
|
62210
|
+
}
|
|
62211
|
+
function batchKeys(keys, batchSize) {
|
|
62212
|
+
const keyArray = Array.from(keys);
|
|
62213
|
+
const batches = [];
|
|
62214
|
+
for (let i = 0, len = keyArray.length; i < len; i += batchSize) {
|
|
62215
|
+
const batch = keyArray.slice(i, i + batchSize);
|
|
62216
|
+
batches.push(batch);
|
|
62217
|
+
}
|
|
62218
|
+
return batches;
|
|
62219
|
+
}
|
|
62220
|
+
function makeSetFilteredFromDifference(setToFilter, diff) {
|
|
62221
|
+
let filteredSet = new Set();
|
|
62222
|
+
setToFilter.forEach((t) => {
|
|
62223
|
+
if (diff(t)) {
|
|
62224
|
+
filteredSet.add(t);
|
|
62225
|
+
}
|
|
62226
|
+
});
|
|
62227
|
+
return filteredSet;
|
|
62228
|
+
}
|
|
62229
|
+
|
|
62149
62230
|
// so eslint doesn't complain about nimbus
|
|
62150
62231
|
/* global __nimbus */
|
|
62151
62232
|
function setupObserver() {
|
|
@@ -62189,7 +62270,9 @@
|
|
|
62189
62270
|
// user id centric record ID generator
|
|
62190
62271
|
const { newRecordId, isGenerated } = recordIdGenerator(userId);
|
|
62191
62272
|
// non-draft-aware base services
|
|
62192
|
-
const store = new InMemoryStore(
|
|
62273
|
+
const store = new InMemoryStore({
|
|
62274
|
+
customTrimPolicy: aggressiveTrim,
|
|
62275
|
+
});
|
|
62193
62276
|
lazyNetworkAdapter = platformNetworkAdapter(makeNetworkAdapterChunkRecordFields(NimbusNetworkAdapter, {
|
|
62194
62277
|
reportChunkCandidateUrlLength: reportChunkCandidateUrlLength,
|
|
62195
62278
|
}));
|
|
@@ -62326,7 +62409,7 @@
|
|
|
62326
62409
|
id: '@salesforce/lds-network-adapter',
|
|
62327
62410
|
instrument: instrument$2,
|
|
62328
62411
|
});
|
|
62329
|
-
// version: 1.
|
|
62412
|
+
// version: 1.287.0-f2fda24df
|
|
62330
62413
|
|
|
62331
62414
|
const { create: create$3, keys: keys$3 } = Object;
|
|
62332
62415
|
const { stringify: stringify$1, parse: parse$1 } = JSON;
|
|
@@ -82375,7 +82458,7 @@
|
|
|
82375
82458
|
configuration: { ...configurationForGraphQLAdapters$1 },
|
|
82376
82459
|
instrument: instrument$1,
|
|
82377
82460
|
});
|
|
82378
|
-
// version: 1.
|
|
82461
|
+
// version: 1.287.0-52ee1d50a
|
|
82379
82462
|
|
|
82380
82463
|
// On core the unstable adapters are re-exported with different names,
|
|
82381
82464
|
// we want to match them here.
|
|
@@ -84631,7 +84714,7 @@
|
|
|
84631
84714
|
unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
|
|
84632
84715
|
graphQLImperative = ldsAdapter;
|
|
84633
84716
|
});
|
|
84634
|
-
// version: 1.
|
|
84717
|
+
// version: 1.287.0-52ee1d50a
|
|
84635
84718
|
|
|
84636
84719
|
var gqlApi = /*#__PURE__*/Object.freeze({
|
|
84637
84720
|
__proto__: null,
|
|
@@ -85369,7 +85452,7 @@
|
|
|
85369
85452
|
function register(r) {
|
|
85370
85453
|
callbacks$1.forEach((callback) => callback(r));
|
|
85371
85454
|
}
|
|
85372
|
-
// version: 1.
|
|
85455
|
+
// version: 1.287.0-f2fda24df
|
|
85373
85456
|
|
|
85374
85457
|
/**
|
|
85375
85458
|
* Returns true if the value acts like a Promise, i.e. has a "then" function,
|
|
@@ -90340,4 +90423,4 @@
|
|
|
90340
90423
|
exports.subscribeToAdapter = subscribeToAdapter;
|
|
90341
90424
|
|
|
90342
90425
|
}));
|
|
90343
|
-
// version: 1.
|
|
90426
|
+
// version: 1.287.0-f2fda24df
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-worker-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.287.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "dist/standalone/es/lds-worker-api.js",
|
|
@@ -35,19 +35,19 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@oat-sa/rollup-plugin-wildcard-external": "^1.0.0",
|
|
38
|
-
"@salesforce/lds-adapters-graphql": "^1.
|
|
39
|
-
"@salesforce/lds-adapters-uiapi": "^1.
|
|
40
|
-
"@salesforce/lds-default-luvio": "^1.
|
|
41
|
-
"@salesforce/lds-drafts": "^1.
|
|
42
|
-
"@salesforce/lds-graphql-parser": "^1.
|
|
43
|
-
"@salesforce/lds-luvio-engine": "^1.
|
|
44
|
-
"@salesforce/lds-priming": "^1.
|
|
45
|
-
"@salesforce/lds-runtime-mobile": "^1.
|
|
46
|
-
"@salesforce/nimbus-plugin-lds": "^1.
|
|
38
|
+
"@salesforce/lds-adapters-graphql": "^1.287.0",
|
|
39
|
+
"@salesforce/lds-adapters-uiapi": "^1.287.0",
|
|
40
|
+
"@salesforce/lds-default-luvio": "^1.287.0",
|
|
41
|
+
"@salesforce/lds-drafts": "^1.287.0",
|
|
42
|
+
"@salesforce/lds-graphql-parser": "^1.287.0",
|
|
43
|
+
"@salesforce/lds-luvio-engine": "^1.287.0",
|
|
44
|
+
"@salesforce/lds-priming": "^1.287.0",
|
|
45
|
+
"@salesforce/lds-runtime-mobile": "^1.287.0",
|
|
46
|
+
"@salesforce/nimbus-plugin-lds": "^1.287.0",
|
|
47
47
|
"ajv": "^8.11.0",
|
|
48
48
|
"glob": "^7.1.5",
|
|
49
49
|
"nimbus-types": "^2.0.0-alpha1",
|
|
50
|
-
"o11y": "
|
|
50
|
+
"o11y": "250.7.0",
|
|
51
51
|
"o11y_schema": "248.40.0",
|
|
52
52
|
"wait-for-expect": "^3.0.2"
|
|
53
53
|
},
|