@salesforce/lds-runtime-bridge 1.266.0-dev1 → 1.266.0-dev11

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.
@@ -900,6 +900,10 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
900
900
  }
901
901
  return {};
902
902
  };
903
+ const getIngestStagingStore = function () {
904
+ validateNotDisposed();
905
+ return stagingStore === null || stagingStore === void 0 ? void 0 : stagingStore.fallbackStringKeyInMemoryStore;
906
+ };
903
907
  const handleSuccessResponse = async function (ingestAndBroadcastFunc, getResponseCacheKeysFunc) {
904
908
  validateNotDisposed();
905
909
  const cacheKeyMap = getResponseCacheKeysFunc();
@@ -1092,6 +1096,7 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1092
1096
  applyCachePolicy: { value: applyCachePolicy },
1093
1097
  getIngestStagingStoreRecords: { value: getIngestStagingStoreRecords },
1094
1098
  getIngestStagingStoreMetadata: { value: getIngestStagingStoreMetadata },
1099
+ getIngestStagingStore: { value: getIngestStagingStore },
1095
1100
  handleSuccessResponse: { value: handleSuccessResponse },
1096
1101
  handleErrorResponse: { value: handleErrorResponse },
1097
1102
  getNotifyChangeStoreEntries: { value: getNotifyChangeStoreEntries },
@@ -3006,6 +3011,20 @@ function findFieldInfo(objectInfo, fieldName) {
3006
3011
  return values$1(objectInfo.fields).find((field) => field.apiName === fieldName ||
3007
3012
  (field.dataType === 'Reference' && field.relationshipName === fieldName));
3008
3013
  }
3014
+ async function readIngestionTimestampForKey(key, query) {
3015
+ let ingestionTimestamp = 0;
3016
+ const sql = `SELECT json_extract(metadata, '${JSON_EXTRACT_PATH_INGESTION_TIMESTAMP}') FROM lds_data WHERE key IS ?`;
3017
+ const results = await query(sql, [key]);
3018
+ const [timestamp] = results.rows.map((row) => row[0]);
3019
+ if (timestamp !== null) {
3020
+ const numericalTimestamp = Number(timestamp);
3021
+ if (isNaN(numericalTimestamp)) {
3022
+ return ingestionTimestamp;
3023
+ }
3024
+ ingestionTimestamp = numericalTimestamp;
3025
+ }
3026
+ return ingestionTimestamp;
3027
+ }
3009
3028
 
3010
3029
  function findSpanningField(name) {
3011
3030
  return (field) => {
@@ -3525,18 +3544,7 @@ async function fetchIngestionTimeStampFromDatabase(apiName, info, args, query) {
3525
3544
  const key = buildKeyStringForRecordQuery(operation,
3526
3545
  // join varables passed from query to the argument variables given from the AST
3527
3546
  { ...variableValues, ...args }, info.fieldNodes[0].arguments, apiName);
3528
- const sql = `
3529
- SELECT json_extract(metadata, '${JSON_EXTRACT_PATH_INGESTION_TIMESTAMP}')
3530
- FROM lds_data
3531
- WHERE key IS ?
3532
- `;
3533
- const results = await query(sql, [key]);
3534
- const [timestamp] = results.rows.map((row) => row[0]);
3535
- if (timestamp !== null && typeof timestamp === 'number') {
3536
- // adjust the timestamp to account for ingestion processing time
3537
- // 30s is used because this is the default record TTL
3538
- ingestionTimestamp = timestamp - 30000;
3539
- }
3547
+ return readIngestionTimestampForKey(key, query);
3540
3548
  }
3541
3549
  return ingestionTimestamp;
3542
3550
  }
@@ -3656,7 +3664,7 @@ function normalizeRecordFields(key, entry) {
3656
3664
  * @param normalizedRecord Record containing normalized field links
3657
3665
  * @param recordStore a store containing referenced record fields
3658
3666
  */
3659
- function buildDurableRecordRepresentation(normalizedRecord, records, pendingEntries) {
3667
+ function buildDurableRecordRepresentation(normalizedRecord, records, pendingEntries, store) {
3660
3668
  const fields = normalizedRecord.fields;
3661
3669
  const filteredFields = {};
3662
3670
  const links = {};
@@ -3683,6 +3691,19 @@ function buildDurableRecordRepresentation(normalizedRecord, records, pendingEntr
3683
3691
  if (ref !== undefined) {
3684
3692
  filteredFields[fieldName] = ref;
3685
3693
  }
3694
+ else {
3695
+ // if we have a store to read, try to find the field there too
3696
+ // The durable ingest staging store may pass through to L1, and
3697
+ // not all fields are necessarily published every time, so it is
3698
+ // important to check L1 and not just the fields being published,
3699
+ // otherwise we risk truncating the fields on the record.
3700
+ if (store) {
3701
+ ref = store.readEntry(__ref);
3702
+ if (ref !== undefined) {
3703
+ filteredFields[fieldName] = ref;
3704
+ }
3705
+ }
3706
+ }
3686
3707
  }
3687
3708
  // we want to preserve fields that are missing nodes
3688
3709
  if (filteredFields[fieldName] !== undefined || field.isMissing === true) {
@@ -3704,7 +3725,7 @@ function getDenormalizedKey(originalKey, recordId, luvio) {
3704
3725
  }
3705
3726
  return keyBuilderRecord(luvio, { recordId });
3706
3727
  }
3707
- function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecords, getStoreMetadata) {
3728
+ function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecords, getStoreMetadata, getStore) {
3708
3729
  const getEntries = function (entries, segment) {
3709
3730
  // this HOF only inspects records in the default segment
3710
3731
  if (segment !== DefaultDurableSegment) {
@@ -3772,6 +3793,7 @@ function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecord
3772
3793
  const putRecordViews = {};
3773
3794
  const storeRecords = getStoreRecords !== undefined ? getStoreRecords() : {};
3774
3795
  const storeMetadata = getStoreMetadata !== undefined ? getStoreMetadata() : {};
3796
+ const store = getStore();
3775
3797
  for (let i = 0, len = keys$1.length; i < len; i++) {
3776
3798
  const key = keys$1[i];
3777
3799
  let value = entries[key];
@@ -3818,7 +3840,7 @@ function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecord
3818
3840
  metadataVersion: DURABLE_METADATA_VERSION,
3819
3841
  };
3820
3842
  }
3821
- const denormalizedRecord = buildDurableRecordRepresentation(record, storeRecords, recordEntries);
3843
+ const denormalizedRecord = buildDurableRecordRepresentation(record, storeRecords, recordEntries, store);
3822
3844
  putEntries[recordKey] = {
3823
3845
  data: denormalizedRecord,
3824
3846
  metadata,
@@ -3911,6 +3933,7 @@ new CachedGraphQLSchema();
3911
3933
  let luvio;
3912
3934
  let getIngestRecords;
3913
3935
  let getIngestMetadata;
3936
+ let getIngestStore;
3914
3937
  // LdsSqliteStore plugin helper
3915
3938
  function getNimbusDurableStore() {
3916
3939
  const resolvedPlugin = __nimbus.plugins.LdsSqliteStore;
@@ -3922,7 +3945,7 @@ function getNimbusDurableStore() {
3922
3945
  * See TD-0153300 for moving RecordDenormalizingDurableStore out of lds-drafts
3923
3946
  */
3924
3947
  function createRecordDenormingStore(luvio, durableStore) {
3925
- const recordDenormingStore = makeRecordDenormalizingDurableStore(luvio, durableStore, () => getIngestRecords(), () => getIngestMetadata());
3948
+ const recordDenormingStore = makeRecordDenormalizingDurableStore(luvio, durableStore, () => getIngestRecords(), () => getIngestMetadata(), () => getIngestStore());
3926
3949
  return recordDenormingStore;
3927
3950
  }
3928
3951
  function getRuntime() {
@@ -3938,6 +3961,7 @@ function getRuntime() {
3938
3961
  // Set ingest records/metadata properties from durable environment
3939
3962
  getIngestRecords = durableEnv.getIngestStagingStoreRecords;
3940
3963
  getIngestMetadata = durableEnv.getIngestStagingStoreMetadata;
3964
+ getIngestStore = durableEnv.getIngestStagingStore;
3941
3965
  // Return new luvio instance
3942
3966
  luvio = new Luvio(durableEnv, {
3943
3967
  instrument: instrumentLuvio,
@@ -3963,4 +3987,4 @@ function ldsRuntimeBridge() {
3963
3987
  }
3964
3988
 
3965
3989
  export { ldsRuntimeBridge as default };
3966
- // version: 1.266.0-dev1-7286a1163
3990
+ // version: 1.266.0-dev11-133bca5b9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-bridge",
3
- "version": "1.266.0-dev1",
3
+ "version": "1.266.0-dev11",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS runtime for bridge.app.",
6
6
  "main": "dist/ldsRuntimeBridge.js",
@@ -34,17 +34,17 @@
34
34
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-bridge"
35
35
  },
36
36
  "dependencies": {
37
- "@salesforce/lds-adapters-uiapi": "^1.266.0-dev1",
38
- "@salesforce/lds-instrumentation": "^1.266.0-dev1",
37
+ "@salesforce/lds-adapters-uiapi": "^1.266.0-dev11",
38
+ "@salesforce/lds-instrumentation": "^1.266.0-dev11",
39
39
  "@salesforce/user": "0.0.21",
40
40
  "o11y": "244.0.0"
41
41
  },
42
42
  "devDependencies": {
43
- "@salesforce/lds-drafts-adapters-uiapi": "^1.266.0-dev1",
44
- "@salesforce/lds-network-aura": "^1.266.0-dev1",
45
- "@salesforce/lds-runtime-aura": "^1.266.0-dev1",
46
- "@salesforce/lds-store-nimbus": "^1.266.0-dev1",
47
- "@salesforce/nimbus-plugin-lds": "^1.266.0-dev1",
43
+ "@salesforce/lds-drafts-adapters-uiapi": "^1.266.0-dev11",
44
+ "@salesforce/lds-network-aura": "^1.266.0-dev11",
45
+ "@salesforce/lds-runtime-aura": "^1.266.0-dev11",
46
+ "@salesforce/lds-store-nimbus": "^1.266.0-dev11",
47
+ "@salesforce/nimbus-plugin-lds": "^1.266.0-dev11",
48
48
  "babel-plugin-dynamic-import-node": "^2.3.3"
49
49
  },
50
50
  "luvioBundlesize": [