@salesforce/lds-runtime-mobile 1.383.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.383.0-d85dce8db1
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.383.0-d85dce8db1
57905
+ // version: 1.384.0-835fd13f44
57896
57906
 
57897
57907
  /*!
57898
57908
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -59799,6 +59809,7 @@ class NimbusSqliteOneStoreCache {
59799
59809
  }
59800
59810
  }
59801
59811
 
59812
+ const PURGE_CACHE_DAYS = 30;
59802
59813
  // TODO[@W-18753648]: These services depend on WebApis that aren't available in the worker.
59803
59814
  // import { buildServiceDescriptor as buildNdJsonServiceDescriptor } from '@luvio/command-ndjson/v1';
59804
59815
  // import { buildServiceDescriptor as buildStreamingCommandServiceDescriptor } from '@luvio/command-streaming/v1';
@@ -59847,6 +59858,48 @@ function initializeOneStore(sqliteStore) {
59847
59858
  // buildSseCommandServiceDescriptor(),
59848
59859
  ];
59849
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
+ });
59850
59903
  }
59851
59904
 
59852
59905
  // so eslint doesn't complain about nimbus
@@ -60054,4 +60107,4 @@ register({
60054
60107
  });
60055
60108
 
60056
60109
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, ingest$1o as ingestDenormalizedRecordRepresentation, initializeOneStore, registerReportObserver, reportGraphqlQueryParseError };
60057
- // version: 1.383.0-b9875fc4e1
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.383.0",
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.58.0",
36
- "@salesforce/lds-adapters-uiapi": "^1.383.0",
37
- "@salesforce/lds-bindings": "^1.383.0",
38
- "@salesforce/lds-instrumentation": "^1.383.0",
39
- "@salesforce/lds-luvio-service": "^1.383.0",
40
- "@salesforce/lds-luvio-uiapi-records-service": "^1.383.0",
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.58.0",
47
- "@luvio/command-aura-normalized-cache-control": "5.58.0",
48
- "@luvio/command-aura-resource-cache-control": "5.58.0",
49
- "@luvio/command-fetch-network": "5.58.0",
50
- "@luvio/command-http-normalized-cache-control": "5.58.0",
51
- "@luvio/command-network": "5.58.0",
52
- "@luvio/service-cache": "5.58.0",
53
- "@luvio/service-cache-control": "5.58.0",
54
- "@luvio/service-cache-inclusion-policy": "5.58.0",
55
- "@luvio/service-fetch-network": "5.58.0",
56
- "@luvio/service-instrument-command": "5.58.0",
57
- "@luvio/service-instrumentation": "5.58.0",
58
- "@luvio/service-pubsub": "5.58.0",
59
- "@luvio/service-store": "5.58.0",
60
- "@luvio/utils": "5.58.0",
61
- "@salesforce/lds-adapters-graphql": "^1.383.0",
62
- "@salesforce/lds-drafts": "^1.383.0",
63
- "@salesforce/lds-durable-records": "^1.383.0",
64
- "@salesforce/lds-network-adapter": "^1.383.0",
65
- "@salesforce/lds-network-nimbus": "^1.383.0",
66
- "@salesforce/lds-store-binary": "^1.383.0",
67
- "@salesforce/lds-store-nimbus": "^1.383.0",
68
- "@salesforce/lds-store-sql": "^1.383.0",
69
- "@salesforce/lds-utils-adapters": "^1.383.0",
70
- "@salesforce/nimbus-plugin-lds": "^1.383.0",
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.383.0-d85dce8db1
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.383.0-d85dce8db1
57905
+ // version: 1.384.0-835fd13f44
57896
57906
 
57897
57907
  /*!
57898
57908
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -59799,6 +59809,7 @@ class NimbusSqliteOneStoreCache {
59799
59809
  }
59800
59810
  }
59801
59811
 
59812
+ const PURGE_CACHE_DAYS = 30;
59802
59813
  // TODO[@W-18753648]: These services depend on WebApis that aren't available in the worker.
59803
59814
  // import { buildServiceDescriptor as buildNdJsonServiceDescriptor } from '@luvio/command-ndjson/v1';
59804
59815
  // import { buildServiceDescriptor as buildStreamingCommandServiceDescriptor } from '@luvio/command-streaming/v1';
@@ -59847,6 +59858,48 @@ function initializeOneStore(sqliteStore) {
59847
59858
  // buildSseCommandServiceDescriptor(),
59848
59859
  ];
59849
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
+ });
59850
59903
  }
59851
59904
 
59852
59905
  // so eslint doesn't complain about nimbus
@@ -60054,4 +60107,4 @@ register({
60054
60107
  });
60055
60108
 
60056
60109
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, ingest$1o as ingestDenormalizedRecordRepresentation, initializeOneStore, registerReportObserver, reportGraphqlQueryParseError };
60057
- // version: 1.383.0-b9875fc4e1
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>;