@salesforce/lds-ads-bridge 1.340.0 → 1.342.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.
@@ -481,7 +481,7 @@ const callbacks$1 = [];
481
481
  function register(r) {
482
482
  callbacks$1.forEach((callback) => callback(r));
483
483
  }
484
- // version: 1.340.0-6f2e2f8197
484
+ // version: 1.342.0-651bed9637
485
485
 
486
486
  /**
487
487
  * Returns true if the value acts like a Promise, i.e. has a "then" function,
@@ -4495,6 +4495,7 @@ let relatedListsPredictionsEnabled = false;
4495
4495
  * Determines whether to include additional PDL strategies for Related Lists
4496
4496
  */
4497
4497
  let relatedListsPlusPredictionsEnabled = false;
4498
+ let recordRepresentationIngestionOverride = undefined;
4498
4499
  /**
4499
4500
  * Defines the configuration API and is exposed internally as well as externally.
4500
4501
  * Configuration for one store enabled REST adapters only.
@@ -4600,6 +4601,12 @@ const configurationForRestAdapters = {
4600
4601
  areRelatedListsPlusPredictionsEnabled: function () {
4601
4602
  return relatedListsPlusPredictionsEnabled === true;
4602
4603
  },
4604
+ setRecordRepresentationIngestionOverride: function (ingest) {
4605
+ recordRepresentationIngestionOverride = ingest;
4606
+ },
4607
+ getRecordRepresentationIngestionOverride: function () {
4608
+ return recordRepresentationIngestionOverride;
4609
+ },
4603
4610
  // createRecord
4604
4611
  getDraftAwareCreateRecordAdapter: configurableCreateRecordAdapter.getAdapter,
4605
4612
  setDraftAwareCreateRecordAdapter: configurableCreateRecordAdapter.setAdapter,
@@ -9475,6 +9482,63 @@ function isSpanningRecord(fieldValue) {
9475
9482
  function isStoreKeyRecordId(key) {
9476
9483
  return key.indexOf(RECORD_ID_PREFIX) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1;
9477
9484
  }
9485
+ /**
9486
+ * Returns a shallow copy of a record with its field values if it is a scalar and a reference and a
9487
+ * a RecordRepresentation with no field if the value if a spanning record.
9488
+ * It returns null if the record contains any pending field.
9489
+ */
9490
+ function getShallowRecordDenormalized(luvio, storeRecordId) {
9491
+ const recordNode = luvio.getNode(storeRecordId);
9492
+ if (!isGraphNode(recordNode)) {
9493
+ return null;
9494
+ }
9495
+ const fieldsCopy = {};
9496
+ const copy = {
9497
+ ...recordNode.retrieve(),
9498
+ fields: fieldsCopy,
9499
+ childRelationships: {},
9500
+ };
9501
+ const fieldsNode = recordNode.object('fields');
9502
+ const fieldNames = fieldsNode.keys();
9503
+ for (let i = 0, len = fieldNames.length; i < len; i++) {
9504
+ let fieldCopy;
9505
+ const fieldName = fieldNames[i];
9506
+ if (fieldsNode.isPending(fieldName) === true) {
9507
+ return null;
9508
+ }
9509
+ if (fieldsNode.isMissing(fieldName) === true) {
9510
+ continue;
9511
+ }
9512
+ const fieldObject = fieldsNode.object(fieldName);
9513
+ const { displayValue, value } = fieldObject.retrieve();
9514
+ if (fieldObject.isScalar('value')) {
9515
+ fieldCopy = {
9516
+ displayValue: displayValue,
9517
+ value: value,
9518
+ };
9519
+ }
9520
+ else {
9521
+ const spanningRecordLink = fieldObject.link('value');
9522
+ if (spanningRecordLink.isPending() === true) {
9523
+ return null;
9524
+ }
9525
+ const spanningRecordNode = spanningRecordLink.follow();
9526
+ if (!isGraphNode(spanningRecordNode)) {
9527
+ continue;
9528
+ }
9529
+ fieldCopy = {
9530
+ displayValue,
9531
+ value: {
9532
+ ...spanningRecordNode.retrieve(),
9533
+ fields: {},
9534
+ childRelationships: {},
9535
+ },
9536
+ };
9537
+ }
9538
+ fieldsCopy[fieldName] = fieldCopy;
9539
+ }
9540
+ return copy;
9541
+ }
9478
9542
  /**
9479
9543
  * Returns a shallow copy of a record with its field values if it is a scalar and a reference and a
9480
9544
  * a RecordRepresentation with no field if the value if a spanning record.
@@ -9606,8 +9670,9 @@ function isDMOEntity(record) {
9606
9670
  return record.apiName.endsWith(DMO_API_NAME_SUFFIX);
9607
9671
  }
9608
9672
  class AdsBridge {
9609
- constructor(luvio) {
9673
+ constructor(luvio, recordRepresentationIngestOverride) {
9610
9674
  this.luvio = luvio;
9675
+ this.recordRepresentationIngestOverride = recordRepresentationIngestOverride;
9611
9676
  this.isRecordEmitLocked = false;
9612
9677
  }
9613
9678
  /**
@@ -9652,7 +9717,10 @@ class AdsBridge {
9652
9717
  // Don't let incorrect ADS/RecordGVP recordTypeIds replace a valid record type in our store
9653
9718
  // with the master record type. See W-7302870 for details.
9654
9719
  fixRecordTypes(luvio, recordCopy);
9655
- luvio.storeIngest(INGEST_KEY, ingest$2c, recordCopy);
9720
+ const recordIngest = this.recordRepresentationIngestOverride !== undefined
9721
+ ? this.recordRepresentationIngestOverride
9722
+ : ingest$2c;
9723
+ luvio.storeIngest(INGEST_KEY, recordIngest, recordCopy);
9656
9724
  }
9657
9725
  }
9658
9726
  if (didIngestRecord === true) {
@@ -9726,7 +9794,9 @@ class AdsBridge {
9726
9794
  if (!isStoreKeyRecordId(storeRecordId)) {
9727
9795
  continue;
9728
9796
  }
9729
- const record = getShallowRecord(luvio, storeRecordId);
9797
+ const record = this.recordRepresentationIngestOverride !== undefined
9798
+ ? getShallowRecordDenormalized(luvio, storeRecordId)
9799
+ : getShallowRecord(luvio, storeRecordId);
9730
9800
  if (record === null) {
9731
9801
  continue;
9732
9802
  }
package/dist/adsBridge.js CHANGED
@@ -12,7 +12,7 @@
12
12
  * *******************************************************************************************
13
13
  */
14
14
  /* proxy-compat-disable */
15
- import { ingestRecord, keyBuilderRecord, keyBuilderObjectInfo } from 'force/ldsAdaptersUiapi';
15
+ import { ingestRecord, keyBuilderRecord, keyBuilderObjectInfo, getRecordIngestionOverride } from 'force/ldsAdaptersUiapi';
16
16
  import { withDefaultLuvio } from 'force/ldsEngine';
17
17
 
18
18
  const { push } = Array.prototype;
@@ -58,6 +58,63 @@ function isSpanningRecord(fieldValue) {
58
58
  function isStoreKeyRecordId(key) {
59
59
  return key.indexOf(RECORD_ID_PREFIX) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1;
60
60
  }
61
+ /**
62
+ * Returns a shallow copy of a record with its field values if it is a scalar and a reference and a
63
+ * a RecordRepresentation with no field if the value if a spanning record.
64
+ * It returns null if the record contains any pending field.
65
+ */
66
+ function getShallowRecordDenormalized(luvio, storeRecordId) {
67
+ const recordNode = luvio.getNode(storeRecordId);
68
+ if (!isGraphNode(recordNode)) {
69
+ return null;
70
+ }
71
+ const fieldsCopy = {};
72
+ const copy = {
73
+ ...recordNode.retrieve(),
74
+ fields: fieldsCopy,
75
+ childRelationships: {},
76
+ };
77
+ const fieldsNode = recordNode.object('fields');
78
+ const fieldNames = fieldsNode.keys();
79
+ for (let i = 0, len = fieldNames.length; i < len; i++) {
80
+ let fieldCopy;
81
+ const fieldName = fieldNames[i];
82
+ if (fieldsNode.isPending(fieldName) === true) {
83
+ return null;
84
+ }
85
+ if (fieldsNode.isMissing(fieldName) === true) {
86
+ continue;
87
+ }
88
+ const fieldObject = fieldsNode.object(fieldName);
89
+ const { displayValue, value } = fieldObject.retrieve();
90
+ if (fieldObject.isScalar('value')) {
91
+ fieldCopy = {
92
+ displayValue: displayValue,
93
+ value: value,
94
+ };
95
+ }
96
+ else {
97
+ const spanningRecordLink = fieldObject.link('value');
98
+ if (spanningRecordLink.isPending() === true) {
99
+ return null;
100
+ }
101
+ const spanningRecordNode = spanningRecordLink.follow();
102
+ if (!isGraphNode(spanningRecordNode)) {
103
+ continue;
104
+ }
105
+ fieldCopy = {
106
+ displayValue,
107
+ value: {
108
+ ...spanningRecordNode.retrieve(),
109
+ fields: {},
110
+ childRelationships: {},
111
+ },
112
+ };
113
+ }
114
+ fieldsCopy[fieldName] = fieldCopy;
115
+ }
116
+ return copy;
117
+ }
61
118
  /**
62
119
  * Returns a shallow copy of a record with its field values if it is a scalar and a reference and a
63
120
  * a RecordRepresentation with no field if the value if a spanning record.
@@ -189,8 +246,9 @@ function isDMOEntity(record) {
189
246
  return record.apiName.endsWith(DMO_API_NAME_SUFFIX);
190
247
  }
191
248
  class AdsBridge {
192
- constructor(luvio) {
249
+ constructor(luvio, recordRepresentationIngestOverride) {
193
250
  this.luvio = luvio;
251
+ this.recordRepresentationIngestOverride = recordRepresentationIngestOverride;
194
252
  this.isRecordEmitLocked = false;
195
253
  }
196
254
  /**
@@ -236,7 +294,10 @@ class AdsBridge {
236
294
  // Don't let incorrect ADS/RecordGVP recordTypeIds replace a valid record type in our store
237
295
  // with the master record type. See W-7302870 for details.
238
296
  fixRecordTypes(luvio, recordCopy);
239
- luvio.storeIngest(INGEST_KEY, ingestRecord, recordCopy);
297
+ const recordIngest = this.recordRepresentationIngestOverride !== undefined
298
+ ? this.recordRepresentationIngestOverride
299
+ : ingestRecord;
300
+ luvio.storeIngest(INGEST_KEY, recordIngest, recordCopy);
240
301
  }
241
302
  }
242
303
  if (didIngestRecord === true) {
@@ -314,7 +375,9 @@ class AdsBridge {
314
375
  if (!isStoreKeyRecordId(storeRecordId)) {
315
376
  continue;
316
377
  }
317
- const record = getShallowRecord(luvio, storeRecordId);
378
+ const record = this.recordRepresentationIngestOverride !== undefined
379
+ ? getShallowRecordDenormalized(luvio, storeRecordId)
380
+ : getShallowRecord(luvio, storeRecordId);
318
381
  if (record === null) {
319
382
  continue;
320
383
  }
@@ -348,7 +411,12 @@ let adsBridge;
348
411
  let callbacks = [];
349
412
  // create a new AdsBridge whenever the default Luvio is set/changed
350
413
  withDefaultLuvio((luvio) => {
351
- adsBridge = new AdsBridge(luvio);
414
+ /**
415
+ * Cache the current value of ingestion override on startup.
416
+ * This needs be set prior to loading of the ADS bridge.
417
+ */
418
+ const recordIngestionOverride = getRecordIngestionOverride();
419
+ adsBridge = new AdsBridge(luvio, recordIngestionOverride);
352
420
  for (let i = 0; i < callbacks.length; ++i) {
353
421
  callbacks[i](adsBridge);
354
422
  }
@@ -367,4 +435,4 @@ function withAdsBridge(callback) {
367
435
  }
368
436
 
369
437
  export { instrument, withAdsBridge };
370
- // version: 1.340.0-6f2e2f8197
438
+ // version: 1.342.0-651bed9637
@@ -1,4 +1,4 @@
1
- import type { Luvio } from '@luvio/engine';
1
+ import type { Luvio, ResourceIngest } from '@luvio/engine';
2
2
  import type { RecordRepresentation } from '@salesforce/lds-adapters-uiapi';
3
3
  interface AdsRecord {
4
4
  /**
@@ -43,9 +43,10 @@ type LdsRecordChangedCallback = (record: AdsRecordMap, objectMetadata: AdsObject
43
43
  export declare function isDMOEntity(record: RecordRepresentation): boolean;
44
44
  export default class AdsBridge {
45
45
  private luvio;
46
+ private recordRepresentationIngestOverride;
46
47
  private isRecordEmitLocked;
47
48
  private watchUnsubscribe;
48
- constructor(luvio: Luvio);
49
+ constructor(luvio: Luvio, recordRepresentationIngestOverride: ResourceIngest | undefined);
49
50
  /**
50
51
  * This setter invoked by recordLibrary to listen for records ingested by Luvio. The passed method
51
52
  * is invoked whenever a record is ingested. It may be via getRecord, getRecordUi, getListUi, ...
package/jest.config.js CHANGED
@@ -5,4 +5,40 @@ module.exports = {
5
5
 
6
6
  displayName: '@salesforce/lds-ads-bridge',
7
7
  roots: ['<rootDir>/src'],
8
+
9
+ moduleNameMapper: {
10
+ ...baseConfig.moduleNameMapper,
11
+ 'o11y/client': require.resolve('../lds-worker-api/src/standalone-stubs/o11y.ts'),
12
+ 'force/ldsBindings': '@salesforce/lds-bindings',
13
+ '@salesforce/user/Id': require.resolve(
14
+ '../lds-runtime-mobile/src/__mocks__/@salesforce/user/Id.js'
15
+ ),
16
+ '@salesforce/i18n/locale': require.resolve(
17
+ '../lds-runtime-mobile/src/__mocks__/@salesforce/i18n/locale.js'
18
+ ),
19
+ '@salesforce/i18n/firstDayOfWeek': require.resolve(
20
+ '../lds-runtime-mobile/src/__mocks__/@salesforce/i18n/firstDayOfWeek.js'
21
+ ),
22
+ '@salesforce/i18n/currency': require.resolve(
23
+ '../lds-runtime-mobile/src/__mocks__/@salesforce/i18n/currency.js'
24
+ ),
25
+ '@salesforce/i18n/timeZone': require.resolve(
26
+ '../lds-runtime-mobile/src/__mocks__/@salesforce/i18n/timeZone.js'
27
+ ),
28
+ 'lightning/i18nService': require.resolve(
29
+ '../lds-runtime-mobile/src/__mocks__/lightning/i18nService.js'
30
+ ),
31
+ 'lightning/i18nCldrOptions': require.resolve(
32
+ '../lds-runtime-mobile/src/__mocks__/lightning/i18nCldrOptions.js'
33
+ ),
34
+ '@salesforce/i18n/dateTime.shortDateFormat': require.resolve(
35
+ '../lds-runtime-mobile/src/__mocks__/@salesforce/i18n/dateTime.shortDateFormat.js'
36
+ ),
37
+ '@salesforce/i18n/dateTime.shortTimeFormat': require.resolve(
38
+ '../lds-runtime-mobile/src/__mocks__/@salesforce/i18n/dateTime.shortTimeFormat.js'
39
+ ),
40
+ '@salesforce/i18n/dateTime.shortDateTimeFormat': require.resolve(
41
+ '../lds-runtime-mobile/src/__mocks__/@salesforce/i18n/dateTime.shortDateTimeFormat.js'
42
+ ),
43
+ },
8
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-ads-bridge",
3
- "version": "1.340.0",
3
+ "version": "1.342.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "Bridge to sync data between LDS and ADS",
6
6
  "main": "dist/adsBridge.js",
@@ -30,8 +30,9 @@
30
30
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-ads-bridge"
31
31
  },
32
32
  "devDependencies": {
33
- "@salesforce/lds-adapters-uiapi": "^1.340.0",
34
- "@salesforce/lds-uiapi-record-utils-mobile": "^1.340.0"
33
+ "@salesforce/lds-adapters-uiapi": "^1.342.0",
34
+ "@salesforce/lds-runtime-mobile": "^1.342.0",
35
+ "@salesforce/lds-uiapi-record-utils-mobile": "^1.342.0"
35
36
  },
36
37
  "volta": {
37
38
  "extends": "../../package.json"
@@ -40,9 +41,9 @@
40
41
  {
41
42
  "path": "./dist/adsBridge.js",
42
43
  "maxSize": {
43
- "none": "14.6 kB",
44
- "min": "4.6 kB",
45
- "compressed": "3.9 kB"
44
+ "none": "17 kB",
45
+ "min": "5.5 kB",
46
+ "compressed": "4 kB"
46
47
  }
47
48
  }
48
49
  ]