@salesforce/lds-runtime-mobile 1.382.0 → 1.384.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
CHANGED
|
@@ -42973,6 +42973,16 @@ function reportAggressiveTrimTriggered(trimCount, beforeTrimRecordCount, totalRe
|
|
|
42973
42973
|
ldsMobileInstrumentation.trackValue(GARBAGE_COLLECTION_AGGRESSIVE_TRIM_TOTAL_RECORDS_BEFORE_TRIM, beforeTrimRecordCount);
|
|
42974
42974
|
ldsMobileInstrumentation.trackValue(GARBAGE_COLLECTION_AGGRESSIVE_TRIM_RECORDS_TRIMMED, totalRecordsTrimmed);
|
|
42975
42975
|
}
|
|
42976
|
+
/** One Store Cache Purge */
|
|
42977
|
+
const ONESTORE_CACHE_PURGING_RECORDS_PURGED = 'onestore-cache-purging-records-purged';
|
|
42978
|
+
const ONESTORE_CACHE_PURGING_RECORDS_ERROR = 'onestore-cache-purging-records-error';
|
|
42979
|
+
function reportOneStoreRecordsPurgedFromCache(recordsPurged) {
|
|
42980
|
+
ldsMobileInstrumentation.trackValue(ONESTORE_CACHE_PURGING_RECORDS_PURGED, recordsPurged);
|
|
42981
|
+
}
|
|
42982
|
+
function reportOneStoreCachePurgingError(error) {
|
|
42983
|
+
const errorMessage = normalizeError(error);
|
|
42984
|
+
ldsMobileInstrumentation.error(errorMessage, ONESTORE_CACHE_PURGING_RECORDS_ERROR);
|
|
42985
|
+
}
|
|
42976
42986
|
|
|
42977
42987
|
const QUICK_ACTION_HANDLER = 'QUICK_ACTION_HANDLER';
|
|
42978
42988
|
class QuickActionExecutionRepresentationHandler extends AbstractQuickActionHandler {
|
|
@@ -56253,7 +56263,7 @@ class CacheControlRequestRunner {
|
|
|
56253
56263
|
}
|
|
56254
56264
|
requestFromNetwork() {
|
|
56255
56265
|
const that = this;
|
|
56256
|
-
return async function* () {
|
|
56266
|
+
return (async function* () {
|
|
56257
56267
|
const result = await that.requestFromNetworkInternal();
|
|
56258
56268
|
if (result.isErr()) {
|
|
56259
56269
|
that.networkError = result;
|
|
@@ -56261,7 +56271,7 @@ class CacheControlRequestRunner {
|
|
|
56261
56271
|
that.networkData = result;
|
|
56262
56272
|
}
|
|
56263
56273
|
yield result;
|
|
56264
|
-
}();
|
|
56274
|
+
})();
|
|
56265
56275
|
}
|
|
56266
56276
|
writeToCache(cache, networkResult) {
|
|
56267
56277
|
return this.writeToCacheInternal(cache, networkResult);
|
|
@@ -57866,7 +57876,7 @@ function buildServiceDescriptor$5(luvio) {
|
|
|
57866
57876
|
},
|
|
57867
57877
|
};
|
|
57868
57878
|
}
|
|
57869
|
-
// version: 1.
|
|
57879
|
+
// version: 1.384.0-835fd13f44
|
|
57870
57880
|
|
|
57871
57881
|
/**
|
|
57872
57882
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -57892,7 +57902,7 @@ function buildServiceDescriptor$4(notifyRecordUpdateAvailable, getNormalizedLuvi
|
|
|
57892
57902
|
},
|
|
57893
57903
|
};
|
|
57894
57904
|
}
|
|
57895
|
-
// version: 1.
|
|
57905
|
+
// version: 1.384.0-835fd13f44
|
|
57896
57906
|
|
|
57897
57907
|
/*!
|
|
57898
57908
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -58777,7 +58787,7 @@ function buildGraphQLInputExtension(input) {
|
|
|
58777
58787
|
};
|
|
58778
58788
|
return prev;
|
|
58779
58789
|
}, {})) || {};
|
|
58780
|
-
const fragments = input.query.definitions.filter(
|
|
58790
|
+
const fragments = input.query.definitions.filter(isFragmentDefinition).reduce((prev, fragment) => {
|
|
58781
58791
|
prev[fragment.name.value] = fragment;
|
|
58782
58792
|
return prev;
|
|
58783
58793
|
}, {});
|
|
@@ -58787,6 +58797,47 @@ function buildGraphQLInputExtension(input) {
|
|
|
58787
58797
|
parentFieldSelection: void 0
|
|
58788
58798
|
});
|
|
58789
58799
|
}
|
|
58800
|
+
const TYPENAME_FIELD = {
|
|
58801
|
+
kind: Kind.FIELD,
|
|
58802
|
+
name: {
|
|
58803
|
+
kind: Kind.NAME,
|
|
58804
|
+
value: "__typename"
|
|
58805
|
+
}
|
|
58806
|
+
};
|
|
58807
|
+
function addTypenameToDocument(doc) {
|
|
58808
|
+
return visit(doc, {
|
|
58809
|
+
SelectionSet: {
|
|
58810
|
+
enter(node, _key, parent) {
|
|
58811
|
+
if (isOperationDefinition(parent)) {
|
|
58812
|
+
return;
|
|
58813
|
+
}
|
|
58814
|
+
const { selections } = node;
|
|
58815
|
+
if (!selections || selections.length === 0) {
|
|
58816
|
+
return;
|
|
58817
|
+
}
|
|
58818
|
+
const skip = selections.some((selection) => {
|
|
58819
|
+
return isField(selection) && (selection.name.value === "__typename" || selection.name.value.lastIndexOf("__", 0) === 0);
|
|
58820
|
+
});
|
|
58821
|
+
if (skip) {
|
|
58822
|
+
return;
|
|
58823
|
+
}
|
|
58824
|
+
return {
|
|
58825
|
+
...node,
|
|
58826
|
+
selections: [...selections, TYPENAME_FIELD]
|
|
58827
|
+
};
|
|
58828
|
+
}
|
|
58829
|
+
}
|
|
58830
|
+
});
|
|
58831
|
+
}
|
|
58832
|
+
function isOperationDefinition(parent) {
|
|
58833
|
+
return !!parent && !Array.isArray(parent) && parent.kind === Kind.OPERATION_DEFINITION;
|
|
58834
|
+
}
|
|
58835
|
+
function isField(node) {
|
|
58836
|
+
return node.kind === Kind.FIELD;
|
|
58837
|
+
}
|
|
58838
|
+
function isFragmentDefinition(node) {
|
|
58839
|
+
return node.kind === Kind.FRAGMENT_DEFINITION;
|
|
58840
|
+
}
|
|
58790
58841
|
|
|
58791
58842
|
/*!
|
|
58792
58843
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -58910,7 +58961,7 @@ class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheContro
|
|
|
58910
58961
|
if (augmentedQueryResult.isErr()) {
|
|
58911
58962
|
throw augmentedQueryResult.error;
|
|
58912
58963
|
}
|
|
58913
|
-
return augmentedQueryResult.value;
|
|
58964
|
+
return addTypenameToDocument(augmentedQueryResult.value);
|
|
58914
58965
|
}
|
|
58915
58966
|
buildWriteInput(data) {
|
|
58916
58967
|
const extensionResult = buildGraphQLInputExtension({
|
|
@@ -59004,7 +59055,7 @@ class HttpGraphQLNormalizedCacheControlCommand extends HttpNormalizedCacheContro
|
|
|
59004
59055
|
if (augmentedQueryResult.isErr()) {
|
|
59005
59056
|
throw augmentedQueryResult.error;
|
|
59006
59057
|
}
|
|
59007
|
-
return augmentedQueryResult.value;
|
|
59058
|
+
return addTypenameToDocument(augmentedQueryResult.value);
|
|
59008
59059
|
}
|
|
59009
59060
|
buildWriteInput(data) {
|
|
59010
59061
|
const extensionResult = buildGraphQLInputExtension({
|
|
@@ -59758,6 +59809,7 @@ class NimbusSqliteOneStoreCache {
|
|
|
59758
59809
|
}
|
|
59759
59810
|
}
|
|
59760
59811
|
|
|
59812
|
+
const PURGE_CACHE_DAYS = 30;
|
|
59761
59813
|
// TODO[@W-18753648]: These services depend on WebApis that aren't available in the worker.
|
|
59762
59814
|
// import { buildServiceDescriptor as buildNdJsonServiceDescriptor } from '@luvio/command-ndjson/v1';
|
|
59763
59815
|
// import { buildServiceDescriptor as buildStreamingCommandServiceDescriptor } from '@luvio/command-streaming/v1';
|
|
@@ -59806,6 +59858,48 @@ function initializeOneStore(sqliteStore) {
|
|
|
59806
59858
|
// buildSseCommandServiceDescriptor(),
|
|
59807
59859
|
];
|
|
59808
59860
|
setServices(services);
|
|
59861
|
+
purgeDurableCacheByDays(PURGE_CACHE_DAYS, sqliteStore);
|
|
59862
|
+
}
|
|
59863
|
+
/**
|
|
59864
|
+
* Manually purges the OneStore cache by days.
|
|
59865
|
+
* Until we have real cache eviction in one store.
|
|
59866
|
+
*
|
|
59867
|
+
* @param days - The number of days to purge the cache by.
|
|
59868
|
+
* @param sqliteStore - The SqliteStorePlugin to purge the cache from.
|
|
59869
|
+
*/
|
|
59870
|
+
async function purgeDurableCacheByDays(days, sqliteStore) {
|
|
59871
|
+
const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
|
|
59872
|
+
const cutoffTimestamp = Date.now() - days * MILLISECONDS_PER_DAY;
|
|
59873
|
+
try {
|
|
59874
|
+
// This has to be ran in a SELECT since the DELETE query may not support return on SQLite version in mobile
|
|
59875
|
+
const countQuery = `
|
|
59876
|
+
SELECT COUNT(*) FROM lds_one_store_data
|
|
59877
|
+
WHERE json_extract(metadata, '$.cacheControl.generatedTime') < ?
|
|
59878
|
+
`;
|
|
59879
|
+
const countResult = await queryAsync(sqliteStore, countQuery, [cutoffTimestamp]);
|
|
59880
|
+
const deleteCount = countResult.rows[0][0];
|
|
59881
|
+
if (deleteCount === 0) {
|
|
59882
|
+
reportOneStoreRecordsPurgedFromCache(0);
|
|
59883
|
+
return;
|
|
59884
|
+
}
|
|
59885
|
+
const deleteQuery = `
|
|
59886
|
+
DELETE FROM lds_one_store_data
|
|
59887
|
+
WHERE json_extract(metadata, '$.cacheControl.generatedTime') < ?
|
|
59888
|
+
`;
|
|
59889
|
+
await queryAsync(sqliteStore, deleteQuery, [cutoffTimestamp]);
|
|
59890
|
+
reportOneStoreRecordsPurgedFromCache(deleteCount);
|
|
59891
|
+
}
|
|
59892
|
+
catch (error) {
|
|
59893
|
+
reportOneStoreCachePurgingError(error);
|
|
59894
|
+
}
|
|
59895
|
+
}
|
|
59896
|
+
/**
|
|
59897
|
+
* Promisified wrapper for SqliteStorePlugin.query
|
|
59898
|
+
*/
|
|
59899
|
+
function queryAsync(sqliteStore, sql, params) {
|
|
59900
|
+
return new Promise((resolve, reject) => {
|
|
59901
|
+
sqliteStore.query(sql, params, (result) => resolve(result), (error) => reject(error));
|
|
59902
|
+
});
|
|
59809
59903
|
}
|
|
59810
59904
|
|
|
59811
59905
|
// so eslint doesn't complain about nimbus
|
|
@@ -60013,4 +60107,4 @@ register({
|
|
|
60013
60107
|
});
|
|
60014
60108
|
|
|
60015
60109
|
export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, ingest$1o as ingestDenormalizedRecordRepresentation, initializeOneStore, registerReportObserver, reportGraphqlQueryParseError };
|
|
60016
|
-
// version: 1.
|
|
60110
|
+
// version: 1.384.0-cb845692ac
|
|
@@ -22,3 +22,5 @@ export declare function reportPrimingConflict(resolutionType: string, recordCoun
|
|
|
22
22
|
export declare function reportChunkCandidateUrlLength(urlLength: number): void;
|
|
23
23
|
/** Garbage Collection */
|
|
24
24
|
export declare function reportAggressiveTrimTriggered(trimCount: number, beforeTrimRecordCount: number, totalRecordsTrimmed: number): void;
|
|
25
|
+
export declare function reportOneStoreRecordsPurgedFromCache(recordsPurged: number): void;
|
|
26
|
+
export declare function reportOneStoreCachePurgingError(error: unknown): void;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import { SqliteStorePlugin } from '@salesforce/nimbus-plugin-lds';
|
|
2
2
|
export declare function initializeOneStore(sqliteStore: SqliteStorePlugin): void;
|
|
3
|
+
/**
|
|
4
|
+
* Manually purges the OneStore cache by days.
|
|
5
|
+
* Until we have real cache eviction in one store.
|
|
6
|
+
*
|
|
7
|
+
* @param days - The number of days to purge the cache by.
|
|
8
|
+
* @param sqliteStore - The SqliteStorePlugin to purge the cache from.
|
|
9
|
+
*/
|
|
10
|
+
export declare function purgeDurableCacheByDays(days: number, sqliteStore: SqliteStorePlugin): Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-runtime-mobile",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.384.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,42 +32,42 @@
|
|
|
32
32
|
"release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-mobile"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@luvio/service-provisioner": "5.
|
|
36
|
-
"@salesforce/lds-adapters-uiapi": "^1.
|
|
37
|
-
"@salesforce/lds-bindings": "^1.
|
|
38
|
-
"@salesforce/lds-instrumentation": "^1.
|
|
39
|
-
"@salesforce/lds-luvio-service": "^1.
|
|
40
|
-
"@salesforce/lds-luvio-uiapi-records-service": "^1.
|
|
35
|
+
"@luvio/service-provisioner": "5.58.4",
|
|
36
|
+
"@salesforce/lds-adapters-uiapi": "^1.384.0",
|
|
37
|
+
"@salesforce/lds-bindings": "^1.384.0",
|
|
38
|
+
"@salesforce/lds-instrumentation": "^1.384.0",
|
|
39
|
+
"@salesforce/lds-luvio-service": "^1.384.0",
|
|
40
|
+
"@salesforce/lds-luvio-uiapi-records-service": "^1.384.0",
|
|
41
41
|
"@salesforce/user": "0.0.21",
|
|
42
42
|
"o11y": "250.7.0",
|
|
43
43
|
"o11y_schema": "256.126.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@luvio/command-aura-network": "5.
|
|
47
|
-
"@luvio/command-aura-normalized-cache-control": "5.
|
|
48
|
-
"@luvio/command-aura-resource-cache-control": "5.
|
|
49
|
-
"@luvio/command-fetch-network": "5.
|
|
50
|
-
"@luvio/command-http-normalized-cache-control": "5.
|
|
51
|
-
"@luvio/command-network": "5.
|
|
52
|
-
"@luvio/service-cache": "5.
|
|
53
|
-
"@luvio/service-cache-control": "5.
|
|
54
|
-
"@luvio/service-cache-inclusion-policy": "5.
|
|
55
|
-
"@luvio/service-fetch-network": "5.
|
|
56
|
-
"@luvio/service-instrument-command": "5.
|
|
57
|
-
"@luvio/service-instrumentation": "5.
|
|
58
|
-
"@luvio/service-pubsub": "5.
|
|
59
|
-
"@luvio/service-store": "5.
|
|
60
|
-
"@luvio/utils": "5.
|
|
61
|
-
"@salesforce/lds-adapters-graphql": "^1.
|
|
62
|
-
"@salesforce/lds-drafts": "^1.
|
|
63
|
-
"@salesforce/lds-durable-records": "^1.
|
|
64
|
-
"@salesforce/lds-network-adapter": "^1.
|
|
65
|
-
"@salesforce/lds-network-nimbus": "^1.
|
|
66
|
-
"@salesforce/lds-store-binary": "^1.
|
|
67
|
-
"@salesforce/lds-store-nimbus": "^1.
|
|
68
|
-
"@salesforce/lds-store-sql": "^1.
|
|
69
|
-
"@salesforce/lds-utils-adapters": "^1.
|
|
70
|
-
"@salesforce/nimbus-plugin-lds": "^1.
|
|
46
|
+
"@luvio/command-aura-network": "5.58.4",
|
|
47
|
+
"@luvio/command-aura-normalized-cache-control": "5.58.4",
|
|
48
|
+
"@luvio/command-aura-resource-cache-control": "5.58.4",
|
|
49
|
+
"@luvio/command-fetch-network": "5.58.4",
|
|
50
|
+
"@luvio/command-http-normalized-cache-control": "5.58.4",
|
|
51
|
+
"@luvio/command-network": "5.58.4",
|
|
52
|
+
"@luvio/service-cache": "5.58.4",
|
|
53
|
+
"@luvio/service-cache-control": "5.58.4",
|
|
54
|
+
"@luvio/service-cache-inclusion-policy": "5.58.4",
|
|
55
|
+
"@luvio/service-fetch-network": "5.58.4",
|
|
56
|
+
"@luvio/service-instrument-command": "5.58.4",
|
|
57
|
+
"@luvio/service-instrumentation": "5.58.4",
|
|
58
|
+
"@luvio/service-pubsub": "5.58.4",
|
|
59
|
+
"@luvio/service-store": "5.58.4",
|
|
60
|
+
"@luvio/utils": "5.58.4",
|
|
61
|
+
"@salesforce/lds-adapters-graphql": "^1.384.0",
|
|
62
|
+
"@salesforce/lds-drafts": "^1.384.0",
|
|
63
|
+
"@salesforce/lds-durable-records": "^1.384.0",
|
|
64
|
+
"@salesforce/lds-network-adapter": "^1.384.0",
|
|
65
|
+
"@salesforce/lds-network-nimbus": "^1.384.0",
|
|
66
|
+
"@salesforce/lds-store-binary": "^1.384.0",
|
|
67
|
+
"@salesforce/lds-store-nimbus": "^1.384.0",
|
|
68
|
+
"@salesforce/lds-store-sql": "^1.384.0",
|
|
69
|
+
"@salesforce/lds-utils-adapters": "^1.384.0",
|
|
70
|
+
"@salesforce/nimbus-plugin-lds": "^1.384.0",
|
|
71
71
|
"babel-plugin-dynamic-import-node": "^2.3.3",
|
|
72
72
|
"wait-for-expect": "^3.0.2"
|
|
73
73
|
},
|
package/sfdc/main.js
CHANGED
|
@@ -42973,6 +42973,16 @@ function reportAggressiveTrimTriggered(trimCount, beforeTrimRecordCount, totalRe
|
|
|
42973
42973
|
ldsMobileInstrumentation.trackValue(GARBAGE_COLLECTION_AGGRESSIVE_TRIM_TOTAL_RECORDS_BEFORE_TRIM, beforeTrimRecordCount);
|
|
42974
42974
|
ldsMobileInstrumentation.trackValue(GARBAGE_COLLECTION_AGGRESSIVE_TRIM_RECORDS_TRIMMED, totalRecordsTrimmed);
|
|
42975
42975
|
}
|
|
42976
|
+
/** One Store Cache Purge */
|
|
42977
|
+
const ONESTORE_CACHE_PURGING_RECORDS_PURGED = 'onestore-cache-purging-records-purged';
|
|
42978
|
+
const ONESTORE_CACHE_PURGING_RECORDS_ERROR = 'onestore-cache-purging-records-error';
|
|
42979
|
+
function reportOneStoreRecordsPurgedFromCache(recordsPurged) {
|
|
42980
|
+
ldsMobileInstrumentation.trackValue(ONESTORE_CACHE_PURGING_RECORDS_PURGED, recordsPurged);
|
|
42981
|
+
}
|
|
42982
|
+
function reportOneStoreCachePurgingError(error) {
|
|
42983
|
+
const errorMessage = normalizeError(error);
|
|
42984
|
+
ldsMobileInstrumentation.error(errorMessage, ONESTORE_CACHE_PURGING_RECORDS_ERROR);
|
|
42985
|
+
}
|
|
42976
42986
|
|
|
42977
42987
|
const QUICK_ACTION_HANDLER = 'QUICK_ACTION_HANDLER';
|
|
42978
42988
|
class QuickActionExecutionRepresentationHandler extends AbstractQuickActionHandler {
|
|
@@ -56253,7 +56263,7 @@ class CacheControlRequestRunner {
|
|
|
56253
56263
|
}
|
|
56254
56264
|
requestFromNetwork() {
|
|
56255
56265
|
const that = this;
|
|
56256
|
-
return async function* () {
|
|
56266
|
+
return (async function* () {
|
|
56257
56267
|
const result = await that.requestFromNetworkInternal();
|
|
56258
56268
|
if (result.isErr()) {
|
|
56259
56269
|
that.networkError = result;
|
|
@@ -56261,7 +56271,7 @@ class CacheControlRequestRunner {
|
|
|
56261
56271
|
that.networkData = result;
|
|
56262
56272
|
}
|
|
56263
56273
|
yield result;
|
|
56264
|
-
}();
|
|
56274
|
+
})();
|
|
56265
56275
|
}
|
|
56266
56276
|
writeToCache(cache, networkResult) {
|
|
56267
56277
|
return this.writeToCacheInternal(cache, networkResult);
|
|
@@ -57866,7 +57876,7 @@ function buildServiceDescriptor$5(luvio) {
|
|
|
57866
57876
|
},
|
|
57867
57877
|
};
|
|
57868
57878
|
}
|
|
57869
|
-
// version: 1.
|
|
57879
|
+
// version: 1.384.0-835fd13f44
|
|
57870
57880
|
|
|
57871
57881
|
/**
|
|
57872
57882
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -57892,7 +57902,7 @@ function buildServiceDescriptor$4(notifyRecordUpdateAvailable, getNormalizedLuvi
|
|
|
57892
57902
|
},
|
|
57893
57903
|
};
|
|
57894
57904
|
}
|
|
57895
|
-
// version: 1.
|
|
57905
|
+
// version: 1.384.0-835fd13f44
|
|
57896
57906
|
|
|
57897
57907
|
/*!
|
|
57898
57908
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -58777,7 +58787,7 @@ function buildGraphQLInputExtension(input) {
|
|
|
58777
58787
|
};
|
|
58778
58788
|
return prev;
|
|
58779
58789
|
}, {})) || {};
|
|
58780
|
-
const fragments = input.query.definitions.filter(
|
|
58790
|
+
const fragments = input.query.definitions.filter(isFragmentDefinition).reduce((prev, fragment) => {
|
|
58781
58791
|
prev[fragment.name.value] = fragment;
|
|
58782
58792
|
return prev;
|
|
58783
58793
|
}, {});
|
|
@@ -58787,6 +58797,47 @@ function buildGraphQLInputExtension(input) {
|
|
|
58787
58797
|
parentFieldSelection: void 0
|
|
58788
58798
|
});
|
|
58789
58799
|
}
|
|
58800
|
+
const TYPENAME_FIELD = {
|
|
58801
|
+
kind: Kind.FIELD,
|
|
58802
|
+
name: {
|
|
58803
|
+
kind: Kind.NAME,
|
|
58804
|
+
value: "__typename"
|
|
58805
|
+
}
|
|
58806
|
+
};
|
|
58807
|
+
function addTypenameToDocument(doc) {
|
|
58808
|
+
return visit(doc, {
|
|
58809
|
+
SelectionSet: {
|
|
58810
|
+
enter(node, _key, parent) {
|
|
58811
|
+
if (isOperationDefinition(parent)) {
|
|
58812
|
+
return;
|
|
58813
|
+
}
|
|
58814
|
+
const { selections } = node;
|
|
58815
|
+
if (!selections || selections.length === 0) {
|
|
58816
|
+
return;
|
|
58817
|
+
}
|
|
58818
|
+
const skip = selections.some((selection) => {
|
|
58819
|
+
return isField(selection) && (selection.name.value === "__typename" || selection.name.value.lastIndexOf("__", 0) === 0);
|
|
58820
|
+
});
|
|
58821
|
+
if (skip) {
|
|
58822
|
+
return;
|
|
58823
|
+
}
|
|
58824
|
+
return {
|
|
58825
|
+
...node,
|
|
58826
|
+
selections: [...selections, TYPENAME_FIELD]
|
|
58827
|
+
};
|
|
58828
|
+
}
|
|
58829
|
+
}
|
|
58830
|
+
});
|
|
58831
|
+
}
|
|
58832
|
+
function isOperationDefinition(parent) {
|
|
58833
|
+
return !!parent && !Array.isArray(parent) && parent.kind === Kind.OPERATION_DEFINITION;
|
|
58834
|
+
}
|
|
58835
|
+
function isField(node) {
|
|
58836
|
+
return node.kind === Kind.FIELD;
|
|
58837
|
+
}
|
|
58838
|
+
function isFragmentDefinition(node) {
|
|
58839
|
+
return node.kind === Kind.FRAGMENT_DEFINITION;
|
|
58840
|
+
}
|
|
58790
58841
|
|
|
58791
58842
|
/*!
|
|
58792
58843
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -58910,7 +58961,7 @@ class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheContro
|
|
|
58910
58961
|
if (augmentedQueryResult.isErr()) {
|
|
58911
58962
|
throw augmentedQueryResult.error;
|
|
58912
58963
|
}
|
|
58913
|
-
return augmentedQueryResult.value;
|
|
58964
|
+
return addTypenameToDocument(augmentedQueryResult.value);
|
|
58914
58965
|
}
|
|
58915
58966
|
buildWriteInput(data) {
|
|
58916
58967
|
const extensionResult = buildGraphQLInputExtension({
|
|
@@ -59004,7 +59055,7 @@ class HttpGraphQLNormalizedCacheControlCommand extends HttpNormalizedCacheContro
|
|
|
59004
59055
|
if (augmentedQueryResult.isErr()) {
|
|
59005
59056
|
throw augmentedQueryResult.error;
|
|
59006
59057
|
}
|
|
59007
|
-
return augmentedQueryResult.value;
|
|
59058
|
+
return addTypenameToDocument(augmentedQueryResult.value);
|
|
59008
59059
|
}
|
|
59009
59060
|
buildWriteInput(data) {
|
|
59010
59061
|
const extensionResult = buildGraphQLInputExtension({
|
|
@@ -59758,6 +59809,7 @@ class NimbusSqliteOneStoreCache {
|
|
|
59758
59809
|
}
|
|
59759
59810
|
}
|
|
59760
59811
|
|
|
59812
|
+
const PURGE_CACHE_DAYS = 30;
|
|
59761
59813
|
// TODO[@W-18753648]: These services depend on WebApis that aren't available in the worker.
|
|
59762
59814
|
// import { buildServiceDescriptor as buildNdJsonServiceDescriptor } from '@luvio/command-ndjson/v1';
|
|
59763
59815
|
// import { buildServiceDescriptor as buildStreamingCommandServiceDescriptor } from '@luvio/command-streaming/v1';
|
|
@@ -59806,6 +59858,48 @@ function initializeOneStore(sqliteStore) {
|
|
|
59806
59858
|
// buildSseCommandServiceDescriptor(),
|
|
59807
59859
|
];
|
|
59808
59860
|
setServices(services);
|
|
59861
|
+
purgeDurableCacheByDays(PURGE_CACHE_DAYS, sqliteStore);
|
|
59862
|
+
}
|
|
59863
|
+
/**
|
|
59864
|
+
* Manually purges the OneStore cache by days.
|
|
59865
|
+
* Until we have real cache eviction in one store.
|
|
59866
|
+
*
|
|
59867
|
+
* @param days - The number of days to purge the cache by.
|
|
59868
|
+
* @param sqliteStore - The SqliteStorePlugin to purge the cache from.
|
|
59869
|
+
*/
|
|
59870
|
+
async function purgeDurableCacheByDays(days, sqliteStore) {
|
|
59871
|
+
const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
|
|
59872
|
+
const cutoffTimestamp = Date.now() - days * MILLISECONDS_PER_DAY;
|
|
59873
|
+
try {
|
|
59874
|
+
// This has to be ran in a SELECT since the DELETE query may not support return on SQLite version in mobile
|
|
59875
|
+
const countQuery = `
|
|
59876
|
+
SELECT COUNT(*) FROM lds_one_store_data
|
|
59877
|
+
WHERE json_extract(metadata, '$.cacheControl.generatedTime') < ?
|
|
59878
|
+
`;
|
|
59879
|
+
const countResult = await queryAsync(sqliteStore, countQuery, [cutoffTimestamp]);
|
|
59880
|
+
const deleteCount = countResult.rows[0][0];
|
|
59881
|
+
if (deleteCount === 0) {
|
|
59882
|
+
reportOneStoreRecordsPurgedFromCache(0);
|
|
59883
|
+
return;
|
|
59884
|
+
}
|
|
59885
|
+
const deleteQuery = `
|
|
59886
|
+
DELETE FROM lds_one_store_data
|
|
59887
|
+
WHERE json_extract(metadata, '$.cacheControl.generatedTime') < ?
|
|
59888
|
+
`;
|
|
59889
|
+
await queryAsync(sqliteStore, deleteQuery, [cutoffTimestamp]);
|
|
59890
|
+
reportOneStoreRecordsPurgedFromCache(deleteCount);
|
|
59891
|
+
}
|
|
59892
|
+
catch (error) {
|
|
59893
|
+
reportOneStoreCachePurgingError(error);
|
|
59894
|
+
}
|
|
59895
|
+
}
|
|
59896
|
+
/**
|
|
59897
|
+
* Promisified wrapper for SqliteStorePlugin.query
|
|
59898
|
+
*/
|
|
59899
|
+
function queryAsync(sqliteStore, sql, params) {
|
|
59900
|
+
return new Promise((resolve, reject) => {
|
|
59901
|
+
sqliteStore.query(sql, params, (result) => resolve(result), (error) => reject(error));
|
|
59902
|
+
});
|
|
59809
59903
|
}
|
|
59810
59904
|
|
|
59811
59905
|
// so eslint doesn't complain about nimbus
|
|
@@ -60013,4 +60107,4 @@ register({
|
|
|
60013
60107
|
});
|
|
60014
60108
|
|
|
60015
60109
|
export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, ingest$1o as ingestDenormalizedRecordRepresentation, initializeOneStore, registerReportObserver, reportGraphqlQueryParseError };
|
|
60016
|
-
// version: 1.
|
|
60110
|
+
// version: 1.384.0-cb845692ac
|
|
@@ -22,3 +22,5 @@ export declare function reportPrimingConflict(resolutionType: string, recordCoun
|
|
|
22
22
|
export declare function reportChunkCandidateUrlLength(urlLength: number): void;
|
|
23
23
|
/** Garbage Collection */
|
|
24
24
|
export declare function reportAggressiveTrimTriggered(trimCount: number, beforeTrimRecordCount: number, totalRecordsTrimmed: number): void;
|
|
25
|
+
export declare function reportOneStoreRecordsPurgedFromCache(recordsPurged: number): void;
|
|
26
|
+
export declare function reportOneStoreCachePurgingError(error: unknown): void;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import { SqliteStorePlugin } from '@salesforce/nimbus-plugin-lds';
|
|
2
2
|
export declare function initializeOneStore(sqliteStore: SqliteStorePlugin): void;
|
|
3
|
+
/**
|
|
4
|
+
* Manually purges the OneStore cache by days.
|
|
5
|
+
* Until we have real cache eviction in one store.
|
|
6
|
+
*
|
|
7
|
+
* @param days - The number of days to purge the cache by.
|
|
8
|
+
* @param sqliteStore - The SqliteStorePlugin to purge the cache from.
|
|
9
|
+
*/
|
|
10
|
+
export declare function purgeDurableCacheByDays(days: number, sqliteStore: SqliteStorePlugin): Promise<void>;
|