@salesforce/lds-runtime-mobile 1.287.0-dev6 → 1.287.0-dev8
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 +78 -12
- package/dist/types/priming/SqlitePrimingStore.d.ts +2 -2
- package/package.json +18 -18
- package/sfdc/main.js +78 -12
- package/sfdc/types/priming/SqlitePrimingStore.d.ts +2 -2
package/dist/main.js
CHANGED
|
@@ -40,6 +40,8 @@ import eagerEvalValidAt from '@salesforce/gate/lds.eagerEvalValidAt';
|
|
|
40
40
|
import eagerEvalStaleWhileRevalidate from '@salesforce/gate/lds.eagerEvalStaleWhileRevalidate';
|
|
41
41
|
import eagerEvalDefaultCachePolicy from '@salesforce/gate/lds.eagerEvalDefaultCachePolicy';
|
|
42
42
|
import ldsPrimingGraphqlBatch from '@salesforce/gate/lds.primingGraphqlBatch';
|
|
43
|
+
import aggressiveTrimGate from '@salesforce/gate/lds.aggressiveTrim';
|
|
44
|
+
import aggressiveTrimLowLimitGate from '@salesforce/gate/lds.aggressiveTrimLowLimit';
|
|
43
45
|
import ldsMetadataRefreshEnabled from '@salesforce/gate/lds.metadataRefreshEnabled';
|
|
44
46
|
|
|
45
47
|
/**
|
|
@@ -13195,7 +13197,7 @@ function getDenormalizedKey(originalKey, recordId, luvio) {
|
|
|
13195
13197
|
}
|
|
13196
13198
|
return keyBuilderRecord(luvio, { recordId });
|
|
13197
13199
|
}
|
|
13198
|
-
function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecords, getStoreMetadata, getStore) {
|
|
13200
|
+
function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecords, getStoreMetadata, getStore, sqlStore) {
|
|
13199
13201
|
const getEntries = function (entries, segment) {
|
|
13200
13202
|
// this HOF only inspects records in the default segment
|
|
13201
13203
|
if (segment !== DefaultDurableSegment) {
|
|
@@ -13257,7 +13259,10 @@ function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecord
|
|
|
13257
13259
|
});
|
|
13258
13260
|
};
|
|
13259
13261
|
const denormalizeEntries = function (entries) {
|
|
13262
|
+
let hasEntries = false;
|
|
13263
|
+
let hasMetadata = false;
|
|
13260
13264
|
const putEntries = create$3(null);
|
|
13265
|
+
const putMetadata = create$3(null);
|
|
13261
13266
|
const keys$1 = keys$3(entries);
|
|
13262
13267
|
const putRecords = {};
|
|
13263
13268
|
const putRecordViews = {};
|
|
@@ -13300,6 +13305,7 @@ function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecord
|
|
|
13300
13305
|
putRecords[recordId] = true;
|
|
13301
13306
|
}
|
|
13302
13307
|
if (isStoreRecordError(record)) {
|
|
13308
|
+
hasEntries = true;
|
|
13303
13309
|
putEntries[recordKey] = value;
|
|
13304
13310
|
continue;
|
|
13305
13311
|
}
|
|
@@ -13312,24 +13318,43 @@ function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecord
|
|
|
13312
13318
|
}
|
|
13313
13319
|
const denormalizedRecord = buildDurableRecordRepresentation(record, storeRecords, recordEntries, store);
|
|
13314
13320
|
if (denormalizedRecord !== undefined) {
|
|
13321
|
+
hasEntries = true;
|
|
13315
13322
|
putEntries[recordKey] = {
|
|
13316
13323
|
data: denormalizedRecord,
|
|
13317
13324
|
metadata,
|
|
13318
13325
|
};
|
|
13326
|
+
// if undefined then it is pending
|
|
13327
|
+
// we should still update metadata on pending records
|
|
13328
|
+
}
|
|
13329
|
+
else {
|
|
13330
|
+
hasMetadata = true;
|
|
13331
|
+
metadata.expirationTimestamp = metadata.ingestionTimestamp;
|
|
13332
|
+
putMetadata[recordKey] = {
|
|
13333
|
+
metadata,
|
|
13334
|
+
};
|
|
13319
13335
|
}
|
|
13320
13336
|
}
|
|
13321
13337
|
else {
|
|
13338
|
+
hasEntries = true;
|
|
13322
13339
|
putEntries[key] = value;
|
|
13323
13340
|
}
|
|
13324
13341
|
}
|
|
13325
|
-
return putEntries;
|
|
13342
|
+
return { putEntries, putMetadata, hasEntries, hasMetadata };
|
|
13326
13343
|
};
|
|
13327
13344
|
const setEntries = function (entries, segment) {
|
|
13328
13345
|
if (segment !== DefaultDurableSegment) {
|
|
13329
13346
|
return durableStore.setEntries(entries, segment);
|
|
13330
13347
|
}
|
|
13331
|
-
const putEntries = denormalizeEntries(entries);
|
|
13332
|
-
|
|
13348
|
+
const { putEntries, putMetadata, hasEntries, hasMetadata } = denormalizeEntries(entries);
|
|
13349
|
+
const promises = [
|
|
13350
|
+
hasEntries ? durableStore.setEntries(putEntries, segment) : undefined,
|
|
13351
|
+
];
|
|
13352
|
+
if (sqlStore !== undefined && sqlStore.isBatchUpdateSupported()) {
|
|
13353
|
+
promises.push(hasMetadata && sqlStore !== undefined
|
|
13354
|
+
? durableStore.setMetadata(putMetadata, segment)
|
|
13355
|
+
: undefined);
|
|
13356
|
+
}
|
|
13357
|
+
return Promise.all(promises).then(() => { });
|
|
13333
13358
|
};
|
|
13334
13359
|
const batchOperations = function (operations) {
|
|
13335
13360
|
const operationsWithDenormedRecords = [];
|
|
@@ -13346,10 +13371,20 @@ function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecord
|
|
|
13346
13371
|
// this is determined by the plugin supporting update batch calls before it gets to this HOF.
|
|
13347
13372
|
// so we only need to check one entry to confirm this for performance
|
|
13348
13373
|
if (firstEntry.data !== undefined) {
|
|
13374
|
+
const { putEntries, putMetadata, hasMetadata } = denormalizeEntries(operation.entries);
|
|
13349
13375
|
operationsWithDenormedRecords.push({
|
|
13350
13376
|
...operation,
|
|
13351
|
-
entries:
|
|
13377
|
+
entries: putEntries,
|
|
13352
13378
|
});
|
|
13379
|
+
if (hasMetadata &&
|
|
13380
|
+
sqlStore !== undefined &&
|
|
13381
|
+
sqlStore.isBatchUpdateSupported() === true) {
|
|
13382
|
+
operationsWithDenormedRecords.push({
|
|
13383
|
+
...operation,
|
|
13384
|
+
entries: putMetadata,
|
|
13385
|
+
type: 'setMetadata',
|
|
13386
|
+
});
|
|
13387
|
+
}
|
|
13353
13388
|
}
|
|
13354
13389
|
else {
|
|
13355
13390
|
operationsWithDenormedRecords.push(operation);
|
|
@@ -13361,10 +13396,20 @@ function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecord
|
|
|
13361
13396
|
operationsWithDenormedRecords.push(operation);
|
|
13362
13397
|
continue;
|
|
13363
13398
|
}
|
|
13399
|
+
const { putEntries, putMetadata, hasMetadata } = denormalizeEntries(operation.entries);
|
|
13364
13400
|
operationsWithDenormedRecords.push({
|
|
13365
13401
|
...operation,
|
|
13366
|
-
entries:
|
|
13402
|
+
entries: putEntries,
|
|
13367
13403
|
});
|
|
13404
|
+
if (hasMetadata &&
|
|
13405
|
+
sqlStore !== undefined &&
|
|
13406
|
+
sqlStore.isBatchUpdateSupported() === true) {
|
|
13407
|
+
operationsWithDenormedRecords.push({
|
|
13408
|
+
...operation,
|
|
13409
|
+
entries: putMetadata,
|
|
13410
|
+
type: 'setMetadata',
|
|
13411
|
+
});
|
|
13412
|
+
}
|
|
13368
13413
|
}
|
|
13369
13414
|
return durableStore.batchOperations(operationsWithDenormedRecords);
|
|
13370
13415
|
};
|
|
@@ -16489,6 +16534,9 @@ class NimbusSqliteStore {
|
|
|
16489
16534
|
isEvalSupported() {
|
|
16490
16535
|
return true;
|
|
16491
16536
|
}
|
|
16537
|
+
isBatchUpdateSupported() {
|
|
16538
|
+
return this.supportsBatchUpdates;
|
|
16539
|
+
}
|
|
16492
16540
|
query(sql, params) {
|
|
16493
16541
|
return new Promise((resolve, reject) => {
|
|
16494
16542
|
this.plugin.query(sql, params, (result) => {
|
|
@@ -17907,6 +17955,20 @@ class SqlitePrimingStore {
|
|
|
17907
17955
|
async writeBatch(records, overwrite) {
|
|
17908
17956
|
const idsToPrime = new Set();
|
|
17909
17957
|
const written = [];
|
|
17958
|
+
if (overwrite === true) {
|
|
17959
|
+
// if overwrite is true we need to raise change notifications so use the batchOperations
|
|
17960
|
+
const operations = {};
|
|
17961
|
+
for (const { record, metadata } of records) {
|
|
17962
|
+
const key = keyBuilderRecord(this.getLuvio(), { recordId: record.id });
|
|
17963
|
+
idsToPrime.add(record.id);
|
|
17964
|
+
operations[key] = {
|
|
17965
|
+
data: record,
|
|
17966
|
+
metadata: { ...metadata, metadataVersion: DURABLE_METADATA_VERSION },
|
|
17967
|
+
};
|
|
17968
|
+
}
|
|
17969
|
+
await this.store.setEntries(operations, DefaultDurableSegment);
|
|
17970
|
+
return { written: Array.from(idsToPrime), conflicted: [], errors: [] };
|
|
17971
|
+
}
|
|
17910
17972
|
const statement = `${overwrite ? 'REPLACE' : 'INSERT or IGNORE'} INTO lds_data (key, data, metadata) VALUES ${records
|
|
17911
17973
|
.map((_) => `(?,?,?)`)
|
|
17912
17974
|
.join(',')} returning key;`;
|
|
@@ -18022,7 +18084,9 @@ function primingSessionFactory(config) {
|
|
|
18022
18084
|
return instrumentPrimingSession(session);
|
|
18023
18085
|
}
|
|
18024
18086
|
|
|
18025
|
-
const DEFAULT_MAX_RECORD_COUNT =
|
|
18087
|
+
const DEFAULT_MAX_RECORD_COUNT = aggressiveTrimLowLimitGate.isOpen({ fallback: false })
|
|
18088
|
+
? 20000
|
|
18089
|
+
: 200000;
|
|
18026
18090
|
const DEFAULT_MAX_BATCH_SIZE = 200;
|
|
18027
18091
|
async function aggressiveTrim(data, deallocateFn, options = {}) {
|
|
18028
18092
|
const maxStoreRecords = options.maxStoreRecords !== undefined ? options.maxStoreRecords : DEFAULT_MAX_RECORD_COUNT;
|
|
@@ -18133,9 +18197,11 @@ function getRuntime() {
|
|
|
18133
18197
|
// user id centric record ID generator
|
|
18134
18198
|
const { newRecordId, isGenerated } = recordIdGenerator(userId);
|
|
18135
18199
|
// non-draft-aware base services
|
|
18136
|
-
|
|
18137
|
-
|
|
18138
|
-
|
|
18200
|
+
let storeOptions = {};
|
|
18201
|
+
if (aggressiveTrimGate.isOpen({ fallback: false })) {
|
|
18202
|
+
storeOptions.customTrimPolicy = aggressiveTrim;
|
|
18203
|
+
}
|
|
18204
|
+
const store = new InMemoryStore(storeOptions);
|
|
18139
18205
|
lazyNetworkAdapter = platformNetworkAdapter(makeNetworkAdapterChunkRecordFields(NimbusNetworkAdapter, {
|
|
18140
18206
|
reportChunkCandidateUrlLength: reportChunkCandidateUrlLength,
|
|
18141
18207
|
}));
|
|
@@ -18162,7 +18228,7 @@ function getRuntime() {
|
|
|
18162
18228
|
let getIngestRecords;
|
|
18163
18229
|
let getIngestMetadata;
|
|
18164
18230
|
let getIngestStore;
|
|
18165
|
-
const recordDenormingStore = makeRecordDenormalizingDurableStore(lazyLuvio, lazyBaseDurableStore, () => (getIngestRecords !== undefined ? getIngestRecords() : {}), () => (getIngestMetadata !== undefined ? getIngestMetadata() : {}), () => (getIngestStore !== undefined ? getIngestStore() : undefined));
|
|
18231
|
+
const recordDenormingStore = makeRecordDenormalizingDurableStore(lazyLuvio, lazyBaseDurableStore, () => (getIngestRecords !== undefined ? getIngestRecords() : {}), () => (getIngestMetadata !== undefined ? getIngestMetadata() : {}), () => (getIngestStore !== undefined ? getIngestStore() : undefined), lazyBaseDurableStore);
|
|
18166
18232
|
const baseEnv = new Environment(store, lazyNetworkAdapter);
|
|
18167
18233
|
const gqlEnv = makeEnvironmentGraphqlAware(baseEnv);
|
|
18168
18234
|
const durableEnv = makeDurable(gqlEnv, {
|
|
@@ -18275,4 +18341,4 @@ register({
|
|
|
18275
18341
|
});
|
|
18276
18342
|
|
|
18277
18343
|
export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
|
|
18278
|
-
// version: 1.287.0-
|
|
18344
|
+
// version: 1.287.0-dev8-15cda7880
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { PrimingStore, RecordWithMetadata, WriteResult } from '@salesforce/lds-priming';
|
|
2
2
|
import type { Luvio } from '@luvio/engine';
|
|
3
|
-
import type {
|
|
3
|
+
import type { NimbusSqliteStore } from '@salesforce/lds-store-nimbus';
|
|
4
4
|
export declare class SqlitePrimingStore implements PrimingStore {
|
|
5
5
|
private readonly getLuvio;
|
|
6
6
|
private readonly store;
|
|
7
|
-
constructor(getLuvio: () => Luvio, store:
|
|
7
|
+
constructor(getLuvio: () => Luvio, store: NimbusSqliteStore);
|
|
8
8
|
readRecords(ids: string[]): Promise<RecordWithMetadata[]>;
|
|
9
9
|
writeRecords(records: RecordWithMetadata[], overwrite: boolean): Promise<WriteResult>;
|
|
10
10
|
private writeBatch;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-runtime-mobile",
|
|
3
|
-
"version": "1.287.0-
|
|
3
|
+
"version": "1.287.0-dev8",
|
|
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.287.0-
|
|
36
|
-
"@salesforce/lds-bindings": "^1.287.0-
|
|
37
|
-
"@salesforce/lds-instrumentation": "^1.287.0-
|
|
38
|
-
"@salesforce/lds-priming": "^1.287.0-
|
|
35
|
+
"@salesforce/lds-adapters-uiapi": "^1.287.0-dev8",
|
|
36
|
+
"@salesforce/lds-bindings": "^1.287.0-dev8",
|
|
37
|
+
"@salesforce/lds-instrumentation": "^1.287.0-dev8",
|
|
38
|
+
"@salesforce/lds-priming": "^1.287.0-dev8",
|
|
39
39
|
"@salesforce/user": "0.0.21",
|
|
40
40
|
"o11y": "250.7.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@salesforce/lds-adapters-graphql": "^1.287.0-
|
|
44
|
-
"@salesforce/lds-drafts": "^1.287.0-
|
|
45
|
-
"@salesforce/lds-drafts-adapters-uiapi": "^1.287.0-
|
|
46
|
-
"@salesforce/lds-graphql-eval": "^1.287.0-
|
|
47
|
-
"@salesforce/lds-network-adapter": "^1.287.0-
|
|
48
|
-
"@salesforce/lds-network-nimbus": "^1.287.0-
|
|
49
|
-
"@salesforce/lds-store-binary": "^1.287.0-
|
|
50
|
-
"@salesforce/lds-store-nimbus": "^1.287.0-
|
|
51
|
-
"@salesforce/lds-store-sql": "^1.287.0-
|
|
52
|
-
"@salesforce/lds-utils-adapters": "^1.287.0-
|
|
53
|
-
"@salesforce/nimbus-plugin-lds": "^1.287.0-
|
|
43
|
+
"@salesforce/lds-adapters-graphql": "^1.287.0-dev8",
|
|
44
|
+
"@salesforce/lds-drafts": "^1.287.0-dev8",
|
|
45
|
+
"@salesforce/lds-drafts-adapters-uiapi": "^1.287.0-dev8",
|
|
46
|
+
"@salesforce/lds-graphql-eval": "^1.287.0-dev8",
|
|
47
|
+
"@salesforce/lds-network-adapter": "^1.287.0-dev8",
|
|
48
|
+
"@salesforce/lds-network-nimbus": "^1.287.0-dev8",
|
|
49
|
+
"@salesforce/lds-store-binary": "^1.287.0-dev8",
|
|
50
|
+
"@salesforce/lds-store-nimbus": "^1.287.0-dev8",
|
|
51
|
+
"@salesforce/lds-store-sql": "^1.287.0-dev8",
|
|
52
|
+
"@salesforce/lds-utils-adapters": "^1.287.0-dev8",
|
|
53
|
+
"@salesforce/nimbus-plugin-lds": "^1.287.0-dev8",
|
|
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": "400 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": "400 kB",
|
|
71
71
|
"compressed": "150 kB"
|
|
72
72
|
}
|
|
73
73
|
}
|
package/sfdc/main.js
CHANGED
|
@@ -40,6 +40,8 @@ import eagerEvalValidAt from '@salesforce/gate/lds.eagerEvalValidAt';
|
|
|
40
40
|
import eagerEvalStaleWhileRevalidate from '@salesforce/gate/lds.eagerEvalStaleWhileRevalidate';
|
|
41
41
|
import eagerEvalDefaultCachePolicy from '@salesforce/gate/lds.eagerEvalDefaultCachePolicy';
|
|
42
42
|
import ldsPrimingGraphqlBatch from '@salesforce/gate/lds.primingGraphqlBatch';
|
|
43
|
+
import aggressiveTrimGate from '@salesforce/gate/lds.aggressiveTrim';
|
|
44
|
+
import aggressiveTrimLowLimitGate from '@salesforce/gate/lds.aggressiveTrimLowLimit';
|
|
43
45
|
import ldsMetadataRefreshEnabled from '@salesforce/gate/lds.metadataRefreshEnabled';
|
|
44
46
|
|
|
45
47
|
/**
|
|
@@ -13195,7 +13197,7 @@ function getDenormalizedKey(originalKey, recordId, luvio) {
|
|
|
13195
13197
|
}
|
|
13196
13198
|
return keyBuilderRecord(luvio, { recordId });
|
|
13197
13199
|
}
|
|
13198
|
-
function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecords, getStoreMetadata, getStore) {
|
|
13200
|
+
function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecords, getStoreMetadata, getStore, sqlStore) {
|
|
13199
13201
|
const getEntries = function (entries, segment) {
|
|
13200
13202
|
// this HOF only inspects records in the default segment
|
|
13201
13203
|
if (segment !== DefaultDurableSegment) {
|
|
@@ -13257,7 +13259,10 @@ function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecord
|
|
|
13257
13259
|
});
|
|
13258
13260
|
};
|
|
13259
13261
|
const denormalizeEntries = function (entries) {
|
|
13262
|
+
let hasEntries = false;
|
|
13263
|
+
let hasMetadata = false;
|
|
13260
13264
|
const putEntries = create$3(null);
|
|
13265
|
+
const putMetadata = create$3(null);
|
|
13261
13266
|
const keys$1 = keys$3(entries);
|
|
13262
13267
|
const putRecords = {};
|
|
13263
13268
|
const putRecordViews = {};
|
|
@@ -13300,6 +13305,7 @@ function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecord
|
|
|
13300
13305
|
putRecords[recordId] = true;
|
|
13301
13306
|
}
|
|
13302
13307
|
if (isStoreRecordError(record)) {
|
|
13308
|
+
hasEntries = true;
|
|
13303
13309
|
putEntries[recordKey] = value;
|
|
13304
13310
|
continue;
|
|
13305
13311
|
}
|
|
@@ -13312,24 +13318,43 @@ function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecord
|
|
|
13312
13318
|
}
|
|
13313
13319
|
const denormalizedRecord = buildDurableRecordRepresentation(record, storeRecords, recordEntries, store);
|
|
13314
13320
|
if (denormalizedRecord !== undefined) {
|
|
13321
|
+
hasEntries = true;
|
|
13315
13322
|
putEntries[recordKey] = {
|
|
13316
13323
|
data: denormalizedRecord,
|
|
13317
13324
|
metadata,
|
|
13318
13325
|
};
|
|
13326
|
+
// if undefined then it is pending
|
|
13327
|
+
// we should still update metadata on pending records
|
|
13328
|
+
}
|
|
13329
|
+
else {
|
|
13330
|
+
hasMetadata = true;
|
|
13331
|
+
metadata.expirationTimestamp = metadata.ingestionTimestamp;
|
|
13332
|
+
putMetadata[recordKey] = {
|
|
13333
|
+
metadata,
|
|
13334
|
+
};
|
|
13319
13335
|
}
|
|
13320
13336
|
}
|
|
13321
13337
|
else {
|
|
13338
|
+
hasEntries = true;
|
|
13322
13339
|
putEntries[key] = value;
|
|
13323
13340
|
}
|
|
13324
13341
|
}
|
|
13325
|
-
return putEntries;
|
|
13342
|
+
return { putEntries, putMetadata, hasEntries, hasMetadata };
|
|
13326
13343
|
};
|
|
13327
13344
|
const setEntries = function (entries, segment) {
|
|
13328
13345
|
if (segment !== DefaultDurableSegment) {
|
|
13329
13346
|
return durableStore.setEntries(entries, segment);
|
|
13330
13347
|
}
|
|
13331
|
-
const putEntries = denormalizeEntries(entries);
|
|
13332
|
-
|
|
13348
|
+
const { putEntries, putMetadata, hasEntries, hasMetadata } = denormalizeEntries(entries);
|
|
13349
|
+
const promises = [
|
|
13350
|
+
hasEntries ? durableStore.setEntries(putEntries, segment) : undefined,
|
|
13351
|
+
];
|
|
13352
|
+
if (sqlStore !== undefined && sqlStore.isBatchUpdateSupported()) {
|
|
13353
|
+
promises.push(hasMetadata && sqlStore !== undefined
|
|
13354
|
+
? durableStore.setMetadata(putMetadata, segment)
|
|
13355
|
+
: undefined);
|
|
13356
|
+
}
|
|
13357
|
+
return Promise.all(promises).then(() => { });
|
|
13333
13358
|
};
|
|
13334
13359
|
const batchOperations = function (operations) {
|
|
13335
13360
|
const operationsWithDenormedRecords = [];
|
|
@@ -13346,10 +13371,20 @@ function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecord
|
|
|
13346
13371
|
// this is determined by the plugin supporting update batch calls before it gets to this HOF.
|
|
13347
13372
|
// so we only need to check one entry to confirm this for performance
|
|
13348
13373
|
if (firstEntry.data !== undefined) {
|
|
13374
|
+
const { putEntries, putMetadata, hasMetadata } = denormalizeEntries(operation.entries);
|
|
13349
13375
|
operationsWithDenormedRecords.push({
|
|
13350
13376
|
...operation,
|
|
13351
|
-
entries:
|
|
13377
|
+
entries: putEntries,
|
|
13352
13378
|
});
|
|
13379
|
+
if (hasMetadata &&
|
|
13380
|
+
sqlStore !== undefined &&
|
|
13381
|
+
sqlStore.isBatchUpdateSupported() === true) {
|
|
13382
|
+
operationsWithDenormedRecords.push({
|
|
13383
|
+
...operation,
|
|
13384
|
+
entries: putMetadata,
|
|
13385
|
+
type: 'setMetadata',
|
|
13386
|
+
});
|
|
13387
|
+
}
|
|
13353
13388
|
}
|
|
13354
13389
|
else {
|
|
13355
13390
|
operationsWithDenormedRecords.push(operation);
|
|
@@ -13361,10 +13396,20 @@ function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecord
|
|
|
13361
13396
|
operationsWithDenormedRecords.push(operation);
|
|
13362
13397
|
continue;
|
|
13363
13398
|
}
|
|
13399
|
+
const { putEntries, putMetadata, hasMetadata } = denormalizeEntries(operation.entries);
|
|
13364
13400
|
operationsWithDenormedRecords.push({
|
|
13365
13401
|
...operation,
|
|
13366
|
-
entries:
|
|
13402
|
+
entries: putEntries,
|
|
13367
13403
|
});
|
|
13404
|
+
if (hasMetadata &&
|
|
13405
|
+
sqlStore !== undefined &&
|
|
13406
|
+
sqlStore.isBatchUpdateSupported() === true) {
|
|
13407
|
+
operationsWithDenormedRecords.push({
|
|
13408
|
+
...operation,
|
|
13409
|
+
entries: putMetadata,
|
|
13410
|
+
type: 'setMetadata',
|
|
13411
|
+
});
|
|
13412
|
+
}
|
|
13368
13413
|
}
|
|
13369
13414
|
return durableStore.batchOperations(operationsWithDenormedRecords);
|
|
13370
13415
|
};
|
|
@@ -16489,6 +16534,9 @@ class NimbusSqliteStore {
|
|
|
16489
16534
|
isEvalSupported() {
|
|
16490
16535
|
return true;
|
|
16491
16536
|
}
|
|
16537
|
+
isBatchUpdateSupported() {
|
|
16538
|
+
return this.supportsBatchUpdates;
|
|
16539
|
+
}
|
|
16492
16540
|
query(sql, params) {
|
|
16493
16541
|
return new Promise((resolve, reject) => {
|
|
16494
16542
|
this.plugin.query(sql, params, (result) => {
|
|
@@ -17907,6 +17955,20 @@ class SqlitePrimingStore {
|
|
|
17907
17955
|
async writeBatch(records, overwrite) {
|
|
17908
17956
|
const idsToPrime = new Set();
|
|
17909
17957
|
const written = [];
|
|
17958
|
+
if (overwrite === true) {
|
|
17959
|
+
// if overwrite is true we need to raise change notifications so use the batchOperations
|
|
17960
|
+
const operations = {};
|
|
17961
|
+
for (const { record, metadata } of records) {
|
|
17962
|
+
const key = keyBuilderRecord(this.getLuvio(), { recordId: record.id });
|
|
17963
|
+
idsToPrime.add(record.id);
|
|
17964
|
+
operations[key] = {
|
|
17965
|
+
data: record,
|
|
17966
|
+
metadata: { ...metadata, metadataVersion: DURABLE_METADATA_VERSION },
|
|
17967
|
+
};
|
|
17968
|
+
}
|
|
17969
|
+
await this.store.setEntries(operations, DefaultDurableSegment);
|
|
17970
|
+
return { written: Array.from(idsToPrime), conflicted: [], errors: [] };
|
|
17971
|
+
}
|
|
17910
17972
|
const statement = `${overwrite ? 'REPLACE' : 'INSERT or IGNORE'} INTO lds_data (key, data, metadata) VALUES ${records
|
|
17911
17973
|
.map((_) => `(?,?,?)`)
|
|
17912
17974
|
.join(',')} returning key;`;
|
|
@@ -18022,7 +18084,9 @@ function primingSessionFactory(config) {
|
|
|
18022
18084
|
return instrumentPrimingSession(session);
|
|
18023
18085
|
}
|
|
18024
18086
|
|
|
18025
|
-
const DEFAULT_MAX_RECORD_COUNT =
|
|
18087
|
+
const DEFAULT_MAX_RECORD_COUNT = aggressiveTrimLowLimitGate.isOpen({ fallback: false })
|
|
18088
|
+
? 20000
|
|
18089
|
+
: 200000;
|
|
18026
18090
|
const DEFAULT_MAX_BATCH_SIZE = 200;
|
|
18027
18091
|
async function aggressiveTrim(data, deallocateFn, options = {}) {
|
|
18028
18092
|
const maxStoreRecords = options.maxStoreRecords !== undefined ? options.maxStoreRecords : DEFAULT_MAX_RECORD_COUNT;
|
|
@@ -18133,9 +18197,11 @@ function getRuntime() {
|
|
|
18133
18197
|
// user id centric record ID generator
|
|
18134
18198
|
const { newRecordId, isGenerated } = recordIdGenerator(userId);
|
|
18135
18199
|
// non-draft-aware base services
|
|
18136
|
-
|
|
18137
|
-
|
|
18138
|
-
|
|
18200
|
+
let storeOptions = {};
|
|
18201
|
+
if (aggressiveTrimGate.isOpen({ fallback: false })) {
|
|
18202
|
+
storeOptions.customTrimPolicy = aggressiveTrim;
|
|
18203
|
+
}
|
|
18204
|
+
const store = new InMemoryStore(storeOptions);
|
|
18139
18205
|
lazyNetworkAdapter = platformNetworkAdapter(makeNetworkAdapterChunkRecordFields(NimbusNetworkAdapter, {
|
|
18140
18206
|
reportChunkCandidateUrlLength: reportChunkCandidateUrlLength,
|
|
18141
18207
|
}));
|
|
@@ -18162,7 +18228,7 @@ function getRuntime() {
|
|
|
18162
18228
|
let getIngestRecords;
|
|
18163
18229
|
let getIngestMetadata;
|
|
18164
18230
|
let getIngestStore;
|
|
18165
|
-
const recordDenormingStore = makeRecordDenormalizingDurableStore(lazyLuvio, lazyBaseDurableStore, () => (getIngestRecords !== undefined ? getIngestRecords() : {}), () => (getIngestMetadata !== undefined ? getIngestMetadata() : {}), () => (getIngestStore !== undefined ? getIngestStore() : undefined));
|
|
18231
|
+
const recordDenormingStore = makeRecordDenormalizingDurableStore(lazyLuvio, lazyBaseDurableStore, () => (getIngestRecords !== undefined ? getIngestRecords() : {}), () => (getIngestMetadata !== undefined ? getIngestMetadata() : {}), () => (getIngestStore !== undefined ? getIngestStore() : undefined), lazyBaseDurableStore);
|
|
18166
18232
|
const baseEnv = new Environment(store, lazyNetworkAdapter);
|
|
18167
18233
|
const gqlEnv = makeEnvironmentGraphqlAware(baseEnv);
|
|
18168
18234
|
const durableEnv = makeDurable(gqlEnv, {
|
|
@@ -18275,4 +18341,4 @@ register({
|
|
|
18275
18341
|
});
|
|
18276
18342
|
|
|
18277
18343
|
export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, registerReportObserver, reportGraphqlQueryParseError };
|
|
18278
|
-
// version: 1.287.0-
|
|
18344
|
+
// version: 1.287.0-dev8-15cda7880
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { PrimingStore, RecordWithMetadata, WriteResult } from '@salesforce/lds-priming';
|
|
2
2
|
import type { Luvio } from '@luvio/engine';
|
|
3
|
-
import type {
|
|
3
|
+
import type { NimbusSqliteStore } from '@salesforce/lds-store-nimbus';
|
|
4
4
|
export declare class SqlitePrimingStore implements PrimingStore {
|
|
5
5
|
private readonly getLuvio;
|
|
6
6
|
private readonly store;
|
|
7
|
-
constructor(getLuvio: () => Luvio, store:
|
|
7
|
+
constructor(getLuvio: () => Luvio, store: NimbusSqliteStore);
|
|
8
8
|
readRecords(ids: string[]): Promise<RecordWithMetadata[]>;
|
|
9
9
|
writeRecords(records: RecordWithMetadata[], overwrite: boolean): Promise<WriteResult>;
|
|
10
10
|
private writeBatch;
|