@salesforce/lds-runtime-mobile 1.284.0 → 1.286.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/main.js +122 -22
- package/dist/types/trim/AggressiveTrim.d.ts +7 -0
- package/package.json +19 -19
- package/sfdc/main.js +122 -22
- package/sfdc/types/trim/AggressiveTrim.d.ts +7 -0
package/dist/main.js
CHANGED
|
@@ -5514,10 +5514,6 @@ class DurableDraftQueue {
|
|
|
5514
5514
|
switch (result) {
|
|
5515
5515
|
case ProcessActionResult.BLOCKED_ON_ERROR:
|
|
5516
5516
|
this.state = DraftQueueState.Error;
|
|
5517
|
-
await this.notifyChangedListeners({
|
|
5518
|
-
type: DraftQueueEventType.QueueStateChanged,
|
|
5519
|
-
state: this.state,
|
|
5520
|
-
});
|
|
5521
5517
|
return Promise.reject();
|
|
5522
5518
|
default:
|
|
5523
5519
|
return Promise.resolve();
|
|
@@ -5663,6 +5659,10 @@ class DurableDraftQueue {
|
|
|
5663
5659
|
if (status === DraftActionStatus.Error) {
|
|
5664
5660
|
this.state = DraftQueueState.Error;
|
|
5665
5661
|
this.processingAction = undefined;
|
|
5662
|
+
this.notifyChangedListeners({
|
|
5663
|
+
type: DraftQueueEventType.ActionFailed,
|
|
5664
|
+
action: action,
|
|
5665
|
+
});
|
|
5666
5666
|
return ProcessActionResult.BLOCKED_ON_ERROR;
|
|
5667
5667
|
}
|
|
5668
5668
|
if (id === this.uploadingActionId) {
|
|
@@ -12743,6 +12743,21 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
|
|
|
12743
12743
|
}
|
|
12744
12744
|
return fields;
|
|
12745
12745
|
}
|
|
12746
|
+
getRedirectMappings(action) {
|
|
12747
|
+
if (action.data.method === 'post' && action.response.status === 204) {
|
|
12748
|
+
return undefined;
|
|
12749
|
+
}
|
|
12750
|
+
return super.getRedirectMappings(action);
|
|
12751
|
+
}
|
|
12752
|
+
async handleActionCompleted(completedAction, queueOperations, allHandlers) {
|
|
12753
|
+
if (completedAction.response.status === 204 && completedAction.data.method === 'post') {
|
|
12754
|
+
// if we get a 204 it means the record creation was successful but we don't have the record to ingest
|
|
12755
|
+
// remove the synthesized draft and do not try to ingest the response
|
|
12756
|
+
await this.evictKey(completedAction.tag);
|
|
12757
|
+
return;
|
|
12758
|
+
}
|
|
12759
|
+
return super.handleActionCompleted(completedAction, queueOperations, allHandlers);
|
|
12760
|
+
}
|
|
12746
12761
|
async fetchReferenceRecord(referenceFields) {
|
|
12747
12762
|
const promises = referenceFields.map(async (referenceFieldInfo) => {
|
|
12748
12763
|
const apiName = await this.identifyApiName(referenceFieldInfo.id, referenceFieldInfo.field);
|
|
@@ -16493,11 +16508,17 @@ class NimbusSqliteStore {
|
|
|
16493
16508
|
return this.getTable(segment).getAll(segment);
|
|
16494
16509
|
}
|
|
16495
16510
|
setEntries(entries, segment) {
|
|
16511
|
+
if (keys(entries).length === 0) {
|
|
16512
|
+
return Promise.resolve();
|
|
16513
|
+
}
|
|
16496
16514
|
const table = this.getTable(segment);
|
|
16497
16515
|
const upsertOperation = table.entriesToUpsertOperations(entries, segment);
|
|
16498
16516
|
return this.batchOperationAsPromise([upsertOperation]);
|
|
16499
16517
|
}
|
|
16500
16518
|
setMetadata(entries, segment) {
|
|
16519
|
+
if (keys(entries).length === 0) {
|
|
16520
|
+
return Promise.resolve();
|
|
16521
|
+
}
|
|
16501
16522
|
const table = this.getTable(segment);
|
|
16502
16523
|
let operation;
|
|
16503
16524
|
if (this.supportsBatchUpdates) {
|
|
@@ -16514,32 +16535,41 @@ class NimbusSqliteStore {
|
|
|
16514
16535
|
batchOperations(operations) {
|
|
16515
16536
|
const sqliteOperations = operations.reduce((acc, cur) => {
|
|
16516
16537
|
if (cur.type === 'setEntries') {
|
|
16517
|
-
|
|
16518
|
-
|
|
16538
|
+
if (keys(cur.entries).length > 0) {
|
|
16539
|
+
const table = this.getTable(cur.segment);
|
|
16540
|
+
acc.push(table.entriesToUpsertOperations(cur.entries, cur.segment));
|
|
16541
|
+
}
|
|
16519
16542
|
}
|
|
16520
16543
|
else if (cur.type === 'setMetadata') {
|
|
16521
|
-
|
|
16522
|
-
|
|
16523
|
-
|
|
16524
|
-
|
|
16525
|
-
|
|
16526
|
-
|
|
16527
|
-
|
|
16528
|
-
|
|
16529
|
-
|
|
16530
|
-
|
|
16544
|
+
if (keys(cur.entries).length > 0) {
|
|
16545
|
+
const table = this.getTable(cur.segment);
|
|
16546
|
+
if (this.supportsBatchUpdates) {
|
|
16547
|
+
acc.push(table.metadataToUpdateOperations(cur.entries, cur.segment));
|
|
16548
|
+
}
|
|
16549
|
+
else {
|
|
16550
|
+
const upsert = table.entriesToUpsertOperations(cur.entries, cur.segment);
|
|
16551
|
+
// manually set the context type on the upsert so notifications do not notify rebuilds without
|
|
16552
|
+
// plugin updates
|
|
16553
|
+
upsert.context.type = 'setMetadata';
|
|
16554
|
+
acc.push(upsert);
|
|
16555
|
+
}
|
|
16531
16556
|
}
|
|
16532
16557
|
}
|
|
16533
16558
|
else {
|
|
16534
|
-
|
|
16559
|
+
if (cur.ids.length > 0) {
|
|
16560
|
+
acc.push(this.idsToDeleteOperation(cur.ids, cur.segment));
|
|
16561
|
+
}
|
|
16535
16562
|
}
|
|
16536
16563
|
return acc;
|
|
16537
16564
|
}, []);
|
|
16538
|
-
return
|
|
16565
|
+
return sqliteOperations.length === 0
|
|
16566
|
+
? Promise.resolve()
|
|
16567
|
+
: this.batchOperationAsPromise(sqliteOperations);
|
|
16539
16568
|
}
|
|
16540
16569
|
evictEntries(entryIds, segment) {
|
|
16541
|
-
|
|
16542
|
-
|
|
16570
|
+
return entryIds.length === 0
|
|
16571
|
+
? Promise.resolve()
|
|
16572
|
+
: this.batchOperationAsPromise([this.idsToDeleteOperation(entryIds, segment)]);
|
|
16543
16573
|
}
|
|
16544
16574
|
registerOnChangedListener(listener) {
|
|
16545
16575
|
let unsubscribeId = undefined;
|
|
@@ -17998,6 +18028,74 @@ function primingSessionFactory(config) {
|
|
|
17998
18028
|
return instrumentPrimingSession(session);
|
|
17999
18029
|
}
|
|
18000
18030
|
|
|
18031
|
+
const DEFAULT_MAX_RECORD_COUNT = 80000;
|
|
18032
|
+
const DEFAULT_MAX_BATCH_SIZE = 200;
|
|
18033
|
+
async function aggressiveTrim(data, deallocateFn, options = {}) {
|
|
18034
|
+
const maxStoreRecords = options.maxStoreRecords !== undefined ? options.maxStoreRecords : DEFAULT_MAX_RECORD_COUNT;
|
|
18035
|
+
const batchSize = options.batchSize !== undefined ? options.batchSize : DEFAULT_MAX_BATCH_SIZE;
|
|
18036
|
+
let deallocatedCount = 0;
|
|
18037
|
+
const { pendingTrimKeys, retainedIds, storeRecords } = data;
|
|
18038
|
+
const storeKeyLength = keys$1(storeRecords).length;
|
|
18039
|
+
if (storeKeyLength <= maxStoreRecords) {
|
|
18040
|
+
return { deallocatedCount, trimKeysSkipped: pendingTrimKeys };
|
|
18041
|
+
}
|
|
18042
|
+
const overFlowSize = storeKeyLength - maxStoreRecords;
|
|
18043
|
+
if (overFlowSize <= 0) {
|
|
18044
|
+
return { deallocatedCount, trimKeysSkipped: pendingTrimKeys };
|
|
18045
|
+
}
|
|
18046
|
+
const trimKeys = new Set();
|
|
18047
|
+
for (const key of pendingTrimKeys) {
|
|
18048
|
+
if (storeKeyLength - trimKeys.size <= maxStoreRecords) {
|
|
18049
|
+
break;
|
|
18050
|
+
}
|
|
18051
|
+
if ((retainedIds[key] === undefined && storeRecords[key] !== undefined) ||
|
|
18052
|
+
(retainedIds[key] !== undefined && retainedIds[key] <= 1)) {
|
|
18053
|
+
trimKeys.add(key);
|
|
18054
|
+
}
|
|
18055
|
+
}
|
|
18056
|
+
const batches = batchKeys(trimKeys, batchSize).map((batch) => {
|
|
18057
|
+
return () => batchToPromise(batch, deallocateFn);
|
|
18058
|
+
});
|
|
18059
|
+
for (const batch of batches) {
|
|
18060
|
+
// execute each batch between ticks
|
|
18061
|
+
const count = await batch();
|
|
18062
|
+
deallocatedCount = deallocatedCount + count;
|
|
18063
|
+
}
|
|
18064
|
+
const trimKeysSkipped = makeSetFilteredFromDifference(pendingTrimKeys, (key) => trimKeys.has(key) === false);
|
|
18065
|
+
return {
|
|
18066
|
+
deallocatedCount,
|
|
18067
|
+
trimKeysSkipped,
|
|
18068
|
+
};
|
|
18069
|
+
}
|
|
18070
|
+
function batchToPromise(batch, deallocateFn) {
|
|
18071
|
+
return new Promise((resolve) => {
|
|
18072
|
+
let count = 0;
|
|
18073
|
+
batch.forEach((key) => {
|
|
18074
|
+
deallocateFn(key);
|
|
18075
|
+
count++;
|
|
18076
|
+
});
|
|
18077
|
+
resolve(count);
|
|
18078
|
+
});
|
|
18079
|
+
}
|
|
18080
|
+
function batchKeys(keys, batchSize) {
|
|
18081
|
+
const keyArray = Array.from(keys);
|
|
18082
|
+
const batches = [];
|
|
18083
|
+
for (let i = 0, len = keyArray.length; i < len; i += batchSize) {
|
|
18084
|
+
const batch = keyArray.slice(i, i + batchSize);
|
|
18085
|
+
batches.push(batch);
|
|
18086
|
+
}
|
|
18087
|
+
return batches;
|
|
18088
|
+
}
|
|
18089
|
+
function makeSetFilteredFromDifference(setToFilter, diff) {
|
|
18090
|
+
let filteredSet = new Set();
|
|
18091
|
+
setToFilter.forEach((t) => {
|
|
18092
|
+
if (diff(t)) {
|
|
18093
|
+
filteredSet.add(t);
|
|
18094
|
+
}
|
|
18095
|
+
});
|
|
18096
|
+
return filteredSet;
|
|
18097
|
+
}
|
|
18098
|
+
|
|
18001
18099
|
// so eslint doesn't complain about nimbus
|
|
18002
18100
|
/* global __nimbus */
|
|
18003
18101
|
function setupObserver() {
|
|
@@ -18041,7 +18139,9 @@ function getRuntime() {
|
|
|
18041
18139
|
// user id centric record ID generator
|
|
18042
18140
|
const { newRecordId, isGenerated } = recordIdGenerator(userId);
|
|
18043
18141
|
// non-draft-aware base services
|
|
18044
|
-
const store = new InMemoryStore(
|
|
18142
|
+
const store = new InMemoryStore({
|
|
18143
|
+
customTrimPolicy: aggressiveTrim,
|
|
18144
|
+
});
|
|
18045
18145
|
lazyNetworkAdapter = platformNetworkAdapter(makeNetworkAdapterChunkRecordFields(NimbusNetworkAdapter, {
|
|
18046
18146
|
reportChunkCandidateUrlLength: reportChunkCandidateUrlLength,
|
|
18047
18147
|
}));
|
|
@@ -18181,4 +18281,4 @@ register({
|
|
|
18181
18281
|
});
|
|
18182
18282
|
|
|
18183
18283
|
export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
|
|
18184
|
-
// version: 1.
|
|
18284
|
+
// version: 1.286.0-09e7e5207
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TrimTaskData, DeallocationFunction, TrimResult } from '@luvio/engine';
|
|
2
|
+
type TrimOptions = {
|
|
3
|
+
batchSize?: number;
|
|
4
|
+
maxStoreRecords?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare function aggressiveTrim(data: TrimTaskData, deallocateFn: DeallocationFunction, options?: TrimOptions): Promise<TrimResult>;
|
|
7
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-runtime-mobile",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.286.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.
|
|
36
|
-
"@salesforce/lds-bindings": "^1.
|
|
37
|
-
"@salesforce/lds-instrumentation": "^1.
|
|
38
|
-
"@salesforce/lds-priming": "^1.
|
|
35
|
+
"@salesforce/lds-adapters-uiapi": "^1.286.0",
|
|
36
|
+
"@salesforce/lds-bindings": "^1.286.0",
|
|
37
|
+
"@salesforce/lds-instrumentation": "^1.286.0",
|
|
38
|
+
"@salesforce/lds-priming": "^1.286.0",
|
|
39
39
|
"@salesforce/user": "0.0.21",
|
|
40
|
-
"o11y": "
|
|
40
|
+
"o11y": "250.7.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@salesforce/lds-adapters-graphql": "^1.
|
|
44
|
-
"@salesforce/lds-drafts": "^1.
|
|
45
|
-
"@salesforce/lds-drafts-adapters-uiapi": "^1.
|
|
46
|
-
"@salesforce/lds-graphql-eval": "^1.
|
|
47
|
-
"@salesforce/lds-network-adapter": "^1.
|
|
48
|
-
"@salesforce/lds-network-nimbus": "^1.
|
|
49
|
-
"@salesforce/lds-store-binary": "^1.
|
|
50
|
-
"@salesforce/lds-store-nimbus": "^1.
|
|
51
|
-
"@salesforce/lds-store-sql": "^1.
|
|
52
|
-
"@salesforce/lds-utils-adapters": "^1.
|
|
53
|
-
"@salesforce/nimbus-plugin-lds": "^1.
|
|
43
|
+
"@salesforce/lds-adapters-graphql": "^1.286.0",
|
|
44
|
+
"@salesforce/lds-drafts": "^1.286.0",
|
|
45
|
+
"@salesforce/lds-drafts-adapters-uiapi": "^1.286.0",
|
|
46
|
+
"@salesforce/lds-graphql-eval": "^1.286.0",
|
|
47
|
+
"@salesforce/lds-network-adapter": "^1.286.0",
|
|
48
|
+
"@salesforce/lds-network-nimbus": "^1.286.0",
|
|
49
|
+
"@salesforce/lds-store-binary": "^1.286.0",
|
|
50
|
+
"@salesforce/lds-store-nimbus": "^1.286.0",
|
|
51
|
+
"@salesforce/lds-store-sql": "^1.286.0",
|
|
52
|
+
"@salesforce/lds-utils-adapters": "^1.286.0",
|
|
53
|
+
"@salesforce/nimbus-plugin-lds": "^1.286.0",
|
|
54
54
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
55
55
|
"wait-for-expect": "^3.0.2"
|
|
56
56
|
},
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"path": "./dist/main.js",
|
|
60
60
|
"maxSize": {
|
|
61
61
|
"none": "800 kB",
|
|
62
|
-
"min": "
|
|
62
|
+
"min": "323.2 kB",
|
|
63
63
|
"compressed": "150 kB"
|
|
64
64
|
}
|
|
65
65
|
},
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"path": "./sfdc/main.js",
|
|
68
68
|
"maxSize": {
|
|
69
69
|
"none": "800 kB",
|
|
70
|
-
"min": "
|
|
70
|
+
"min": "323.2 kB",
|
|
71
71
|
"compressed": "150 kB"
|
|
72
72
|
}
|
|
73
73
|
}
|
package/sfdc/main.js
CHANGED
|
@@ -5514,10 +5514,6 @@ class DurableDraftQueue {
|
|
|
5514
5514
|
switch (result) {
|
|
5515
5515
|
case ProcessActionResult.BLOCKED_ON_ERROR:
|
|
5516
5516
|
this.state = DraftQueueState.Error;
|
|
5517
|
-
await this.notifyChangedListeners({
|
|
5518
|
-
type: DraftQueueEventType.QueueStateChanged,
|
|
5519
|
-
state: this.state,
|
|
5520
|
-
});
|
|
5521
5517
|
return Promise.reject();
|
|
5522
5518
|
default:
|
|
5523
5519
|
return Promise.resolve();
|
|
@@ -5663,6 +5659,10 @@ class DurableDraftQueue {
|
|
|
5663
5659
|
if (status === DraftActionStatus.Error) {
|
|
5664
5660
|
this.state = DraftQueueState.Error;
|
|
5665
5661
|
this.processingAction = undefined;
|
|
5662
|
+
this.notifyChangedListeners({
|
|
5663
|
+
type: DraftQueueEventType.ActionFailed,
|
|
5664
|
+
action: action,
|
|
5665
|
+
});
|
|
5666
5666
|
return ProcessActionResult.BLOCKED_ON_ERROR;
|
|
5667
5667
|
}
|
|
5668
5668
|
if (id === this.uploadingActionId) {
|
|
@@ -12743,6 +12743,21 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
|
|
|
12743
12743
|
}
|
|
12744
12744
|
return fields;
|
|
12745
12745
|
}
|
|
12746
|
+
getRedirectMappings(action) {
|
|
12747
|
+
if (action.data.method === 'post' && action.response.status === 204) {
|
|
12748
|
+
return undefined;
|
|
12749
|
+
}
|
|
12750
|
+
return super.getRedirectMappings(action);
|
|
12751
|
+
}
|
|
12752
|
+
async handleActionCompleted(completedAction, queueOperations, allHandlers) {
|
|
12753
|
+
if (completedAction.response.status === 204 && completedAction.data.method === 'post') {
|
|
12754
|
+
// if we get a 204 it means the record creation was successful but we don't have the record to ingest
|
|
12755
|
+
// remove the synthesized draft and do not try to ingest the response
|
|
12756
|
+
await this.evictKey(completedAction.tag);
|
|
12757
|
+
return;
|
|
12758
|
+
}
|
|
12759
|
+
return super.handleActionCompleted(completedAction, queueOperations, allHandlers);
|
|
12760
|
+
}
|
|
12746
12761
|
async fetchReferenceRecord(referenceFields) {
|
|
12747
12762
|
const promises = referenceFields.map(async (referenceFieldInfo) => {
|
|
12748
12763
|
const apiName = await this.identifyApiName(referenceFieldInfo.id, referenceFieldInfo.field);
|
|
@@ -16493,11 +16508,17 @@ class NimbusSqliteStore {
|
|
|
16493
16508
|
return this.getTable(segment).getAll(segment);
|
|
16494
16509
|
}
|
|
16495
16510
|
setEntries(entries, segment) {
|
|
16511
|
+
if (keys(entries).length === 0) {
|
|
16512
|
+
return Promise.resolve();
|
|
16513
|
+
}
|
|
16496
16514
|
const table = this.getTable(segment);
|
|
16497
16515
|
const upsertOperation = table.entriesToUpsertOperations(entries, segment);
|
|
16498
16516
|
return this.batchOperationAsPromise([upsertOperation]);
|
|
16499
16517
|
}
|
|
16500
16518
|
setMetadata(entries, segment) {
|
|
16519
|
+
if (keys(entries).length === 0) {
|
|
16520
|
+
return Promise.resolve();
|
|
16521
|
+
}
|
|
16501
16522
|
const table = this.getTable(segment);
|
|
16502
16523
|
let operation;
|
|
16503
16524
|
if (this.supportsBatchUpdates) {
|
|
@@ -16514,32 +16535,41 @@ class NimbusSqliteStore {
|
|
|
16514
16535
|
batchOperations(operations) {
|
|
16515
16536
|
const sqliteOperations = operations.reduce((acc, cur) => {
|
|
16516
16537
|
if (cur.type === 'setEntries') {
|
|
16517
|
-
|
|
16518
|
-
|
|
16538
|
+
if (keys(cur.entries).length > 0) {
|
|
16539
|
+
const table = this.getTable(cur.segment);
|
|
16540
|
+
acc.push(table.entriesToUpsertOperations(cur.entries, cur.segment));
|
|
16541
|
+
}
|
|
16519
16542
|
}
|
|
16520
16543
|
else if (cur.type === 'setMetadata') {
|
|
16521
|
-
|
|
16522
|
-
|
|
16523
|
-
|
|
16524
|
-
|
|
16525
|
-
|
|
16526
|
-
|
|
16527
|
-
|
|
16528
|
-
|
|
16529
|
-
|
|
16530
|
-
|
|
16544
|
+
if (keys(cur.entries).length > 0) {
|
|
16545
|
+
const table = this.getTable(cur.segment);
|
|
16546
|
+
if (this.supportsBatchUpdates) {
|
|
16547
|
+
acc.push(table.metadataToUpdateOperations(cur.entries, cur.segment));
|
|
16548
|
+
}
|
|
16549
|
+
else {
|
|
16550
|
+
const upsert = table.entriesToUpsertOperations(cur.entries, cur.segment);
|
|
16551
|
+
// manually set the context type on the upsert so notifications do not notify rebuilds without
|
|
16552
|
+
// plugin updates
|
|
16553
|
+
upsert.context.type = 'setMetadata';
|
|
16554
|
+
acc.push(upsert);
|
|
16555
|
+
}
|
|
16531
16556
|
}
|
|
16532
16557
|
}
|
|
16533
16558
|
else {
|
|
16534
|
-
|
|
16559
|
+
if (cur.ids.length > 0) {
|
|
16560
|
+
acc.push(this.idsToDeleteOperation(cur.ids, cur.segment));
|
|
16561
|
+
}
|
|
16535
16562
|
}
|
|
16536
16563
|
return acc;
|
|
16537
16564
|
}, []);
|
|
16538
|
-
return
|
|
16565
|
+
return sqliteOperations.length === 0
|
|
16566
|
+
? Promise.resolve()
|
|
16567
|
+
: this.batchOperationAsPromise(sqliteOperations);
|
|
16539
16568
|
}
|
|
16540
16569
|
evictEntries(entryIds, segment) {
|
|
16541
|
-
|
|
16542
|
-
|
|
16570
|
+
return entryIds.length === 0
|
|
16571
|
+
? Promise.resolve()
|
|
16572
|
+
: this.batchOperationAsPromise([this.idsToDeleteOperation(entryIds, segment)]);
|
|
16543
16573
|
}
|
|
16544
16574
|
registerOnChangedListener(listener) {
|
|
16545
16575
|
let unsubscribeId = undefined;
|
|
@@ -17998,6 +18028,74 @@ function primingSessionFactory(config) {
|
|
|
17998
18028
|
return instrumentPrimingSession(session);
|
|
17999
18029
|
}
|
|
18000
18030
|
|
|
18031
|
+
const DEFAULT_MAX_RECORD_COUNT = 80000;
|
|
18032
|
+
const DEFAULT_MAX_BATCH_SIZE = 200;
|
|
18033
|
+
async function aggressiveTrim(data, deallocateFn, options = {}) {
|
|
18034
|
+
const maxStoreRecords = options.maxStoreRecords !== undefined ? options.maxStoreRecords : DEFAULT_MAX_RECORD_COUNT;
|
|
18035
|
+
const batchSize = options.batchSize !== undefined ? options.batchSize : DEFAULT_MAX_BATCH_SIZE;
|
|
18036
|
+
let deallocatedCount = 0;
|
|
18037
|
+
const { pendingTrimKeys, retainedIds, storeRecords } = data;
|
|
18038
|
+
const storeKeyLength = keys$1(storeRecords).length;
|
|
18039
|
+
if (storeKeyLength <= maxStoreRecords) {
|
|
18040
|
+
return { deallocatedCount, trimKeysSkipped: pendingTrimKeys };
|
|
18041
|
+
}
|
|
18042
|
+
const overFlowSize = storeKeyLength - maxStoreRecords;
|
|
18043
|
+
if (overFlowSize <= 0) {
|
|
18044
|
+
return { deallocatedCount, trimKeysSkipped: pendingTrimKeys };
|
|
18045
|
+
}
|
|
18046
|
+
const trimKeys = new Set();
|
|
18047
|
+
for (const key of pendingTrimKeys) {
|
|
18048
|
+
if (storeKeyLength - trimKeys.size <= maxStoreRecords) {
|
|
18049
|
+
break;
|
|
18050
|
+
}
|
|
18051
|
+
if ((retainedIds[key] === undefined && storeRecords[key] !== undefined) ||
|
|
18052
|
+
(retainedIds[key] !== undefined && retainedIds[key] <= 1)) {
|
|
18053
|
+
trimKeys.add(key);
|
|
18054
|
+
}
|
|
18055
|
+
}
|
|
18056
|
+
const batches = batchKeys(trimKeys, batchSize).map((batch) => {
|
|
18057
|
+
return () => batchToPromise(batch, deallocateFn);
|
|
18058
|
+
});
|
|
18059
|
+
for (const batch of batches) {
|
|
18060
|
+
// execute each batch between ticks
|
|
18061
|
+
const count = await batch();
|
|
18062
|
+
deallocatedCount = deallocatedCount + count;
|
|
18063
|
+
}
|
|
18064
|
+
const trimKeysSkipped = makeSetFilteredFromDifference(pendingTrimKeys, (key) => trimKeys.has(key) === false);
|
|
18065
|
+
return {
|
|
18066
|
+
deallocatedCount,
|
|
18067
|
+
trimKeysSkipped,
|
|
18068
|
+
};
|
|
18069
|
+
}
|
|
18070
|
+
function batchToPromise(batch, deallocateFn) {
|
|
18071
|
+
return new Promise((resolve) => {
|
|
18072
|
+
let count = 0;
|
|
18073
|
+
batch.forEach((key) => {
|
|
18074
|
+
deallocateFn(key);
|
|
18075
|
+
count++;
|
|
18076
|
+
});
|
|
18077
|
+
resolve(count);
|
|
18078
|
+
});
|
|
18079
|
+
}
|
|
18080
|
+
function batchKeys(keys, batchSize) {
|
|
18081
|
+
const keyArray = Array.from(keys);
|
|
18082
|
+
const batches = [];
|
|
18083
|
+
for (let i = 0, len = keyArray.length; i < len; i += batchSize) {
|
|
18084
|
+
const batch = keyArray.slice(i, i + batchSize);
|
|
18085
|
+
batches.push(batch);
|
|
18086
|
+
}
|
|
18087
|
+
return batches;
|
|
18088
|
+
}
|
|
18089
|
+
function makeSetFilteredFromDifference(setToFilter, diff) {
|
|
18090
|
+
let filteredSet = new Set();
|
|
18091
|
+
setToFilter.forEach((t) => {
|
|
18092
|
+
if (diff(t)) {
|
|
18093
|
+
filteredSet.add(t);
|
|
18094
|
+
}
|
|
18095
|
+
});
|
|
18096
|
+
return filteredSet;
|
|
18097
|
+
}
|
|
18098
|
+
|
|
18001
18099
|
// so eslint doesn't complain about nimbus
|
|
18002
18100
|
/* global __nimbus */
|
|
18003
18101
|
function setupObserver() {
|
|
@@ -18041,7 +18139,9 @@ function getRuntime() {
|
|
|
18041
18139
|
// user id centric record ID generator
|
|
18042
18140
|
const { newRecordId, isGenerated } = recordIdGenerator(userId);
|
|
18043
18141
|
// non-draft-aware base services
|
|
18044
|
-
const store = new InMemoryStore(
|
|
18142
|
+
const store = new InMemoryStore({
|
|
18143
|
+
customTrimPolicy: aggressiveTrim,
|
|
18144
|
+
});
|
|
18045
18145
|
lazyNetworkAdapter = platformNetworkAdapter(makeNetworkAdapterChunkRecordFields(NimbusNetworkAdapter, {
|
|
18046
18146
|
reportChunkCandidateUrlLength: reportChunkCandidateUrlLength,
|
|
18047
18147
|
}));
|
|
@@ -18181,4 +18281,4 @@ register({
|
|
|
18181
18281
|
});
|
|
18182
18282
|
|
|
18183
18283
|
export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
|
|
18184
|
-
// version: 1.
|
|
18284
|
+
// version: 1.286.0-09e7e5207
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TrimTaskData, DeallocationFunction, TrimResult } from '@luvio/engine';
|
|
2
|
+
type TrimOptions = {
|
|
3
|
+
batchSize?: number;
|
|
4
|
+
maxStoreRecords?: number;
|
|
5
|
+
};
|
|
6
|
+
export declare function aggressiveTrim(data: TrimTaskData, deallocateFn: DeallocationFunction, options?: TrimOptions): Promise<TrimResult>;
|
|
7
|
+
export {};
|