@salesforce/lds-ads-bridge 1.361.0 → 1.362.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/ads-bridge-perf.js +61 -21
- package/dist/adsBridge.js +4 -4
- package/package.json +5 -5
- package/src/__tests__/ads-bridge.spec.ts +38 -0
- package/src/ads-bridge.ts +6 -6
package/dist/ads-bridge-perf.js
CHANGED
|
@@ -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.
|
|
484
|
+
// version: 1.362.0-5d2767de00
|
|
485
485
|
|
|
486
486
|
/**
|
|
487
487
|
* Returns true if the value acts like a Promise, i.e. has a "then" function,
|
|
@@ -5121,7 +5121,7 @@ function equals$1c(existing, incoming) {
|
|
|
5121
5121
|
return true;
|
|
5122
5122
|
}
|
|
5123
5123
|
|
|
5124
|
-
const VERSION$2W = "
|
|
5124
|
+
const VERSION$2W = "2738fe8faf98ecd076d7c4df86fd5bf0";
|
|
5125
5125
|
function validate$20(obj, path = 'FieldValueRepresentation') {
|
|
5126
5126
|
const v_error = (() => {
|
|
5127
5127
|
if (typeof obj !== 'object' || ArrayIsArray(obj) || obj === null) {
|
|
@@ -5193,20 +5193,37 @@ function validate$20(obj, path = 'FieldValueRepresentation') {
|
|
|
5193
5193
|
}
|
|
5194
5194
|
let obj_value_union4 = null;
|
|
5195
5195
|
const obj_value_union4_error = (() => {
|
|
5196
|
-
if (obj_value
|
|
5197
|
-
return new TypeError('Expected "
|
|
5196
|
+
if (!ArrayIsArray(obj_value)) {
|
|
5197
|
+
return new TypeError('Expected "array" but received "' + typeof obj_value + '" (at "' + path_value + '")');
|
|
5198
|
+
}
|
|
5199
|
+
for (let i = 0; i < obj_value.length; i++) {
|
|
5200
|
+
const obj_value_item = obj_value[i];
|
|
5201
|
+
const path_value_item = path_value + '[' + i + ']';
|
|
5202
|
+
if (typeof obj_value_item !== 'string') {
|
|
5203
|
+
return new TypeError('Expected "string" but received "' + typeof obj_value_item + '" (at "' + path_value_item + '")');
|
|
5204
|
+
}
|
|
5198
5205
|
}
|
|
5199
5206
|
})();
|
|
5200
5207
|
if (obj_value_union4_error != null) {
|
|
5201
5208
|
obj_value_union4 = obj_value_union4_error.message;
|
|
5202
5209
|
}
|
|
5203
|
-
|
|
5210
|
+
let obj_value_union5 = null;
|
|
5211
|
+
const obj_value_union5_error = (() => {
|
|
5212
|
+
if (obj_value !== null) {
|
|
5213
|
+
return new TypeError('Expected "null" but received "' + typeof obj_value + '" (at "' + path_value + '")');
|
|
5214
|
+
}
|
|
5215
|
+
})();
|
|
5216
|
+
if (obj_value_union5_error != null) {
|
|
5217
|
+
obj_value_union5 = obj_value_union5_error.message;
|
|
5218
|
+
}
|
|
5219
|
+
if (obj_value_union0 && obj_value_union1 && obj_value_union2 && obj_value_union3 && obj_value_union4 && obj_value_union5) {
|
|
5204
5220
|
let message = 'Object doesn\'t match union (at "' + path_value + '")';
|
|
5205
5221
|
message += '\n' + obj_value_union0.split('\n').map((line) => '\t' + line).join('\n');
|
|
5206
5222
|
message += '\n' + obj_value_union1.split('\n').map((line) => '\t' + line).join('\n');
|
|
5207
5223
|
message += '\n' + obj_value_union2.split('\n').map((line) => '\t' + line).join('\n');
|
|
5208
5224
|
message += '\n' + obj_value_union3.split('\n').map((line) => '\t' + line).join('\n');
|
|
5209
5225
|
message += '\n' + obj_value_union4.split('\n').map((line) => '\t' + line).join('\n');
|
|
5226
|
+
message += '\n' + obj_value_union5.split('\n').map((line) => '\t' + line).join('\n');
|
|
5210
5227
|
return new TypeError(message);
|
|
5211
5228
|
}
|
|
5212
5229
|
})();
|
|
@@ -5224,10 +5241,10 @@ const select$3B = function FieldValueRepresentationSelect() {
|
|
|
5224
5241
|
kind: 'Scalar'
|
|
5225
5242
|
},
|
|
5226
5243
|
{
|
|
5244
|
+
kind: 'Object',
|
|
5227
5245
|
name: 'value',
|
|
5228
|
-
kind: 'Link',
|
|
5229
5246
|
nullable: true,
|
|
5230
|
-
|
|
5247
|
+
// Complex union deep
|
|
5231
5248
|
}
|
|
5232
5249
|
]
|
|
5233
5250
|
};
|
|
@@ -5240,12 +5257,32 @@ function equals$1b(existing, incoming) {
|
|
|
5240
5257
|
}
|
|
5241
5258
|
const existing_value = existing.value;
|
|
5242
5259
|
const incoming_value = incoming.value;
|
|
5243
|
-
if (!(
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
existing_value
|
|
5260
|
+
if (!((() => {
|
|
5261
|
+
if (existing_value === null || incoming_value === null) {
|
|
5262
|
+
return existing_value === incoming_value;
|
|
5263
|
+
}
|
|
5264
|
+
if (Array.isArray(existing_value) && Array.isArray(incoming_value)) {
|
|
5265
|
+
const equals_value_items = equalsArray(existing_value, incoming_value, (existing_value_item, incoming_value_item) => {
|
|
5266
|
+
if (!(existing_value_item === incoming_value_item)) {
|
|
5267
|
+
return false;
|
|
5268
|
+
}
|
|
5269
|
+
});
|
|
5270
|
+
if (equals_value_items === false) {
|
|
5271
|
+
return false;
|
|
5272
|
+
}
|
|
5273
|
+
}
|
|
5274
|
+
else {
|
|
5275
|
+
if (!(existing_value === incoming_value
|
|
5276
|
+
|| (existing_value != null &&
|
|
5277
|
+
incoming_value != null &&
|
|
5278
|
+
existing_value.__ref != null &&
|
|
5279
|
+
incoming_value.__ref != null &&
|
|
5280
|
+
existing_value.__ref === incoming_value.__ref))) {
|
|
5281
|
+
return false;
|
|
5282
|
+
}
|
|
5283
|
+
}
|
|
5284
|
+
return true;
|
|
5285
|
+
})())) {
|
|
5249
5286
|
return false;
|
|
5250
5287
|
}
|
|
5251
5288
|
return true;
|
|
@@ -7770,6 +7807,7 @@ function addScalarField(current, leafNodeFieldKey) {
|
|
|
7770
7807
|
}
|
|
7771
7808
|
}
|
|
7772
7809
|
function extractTrackedFieldsToTrie(recordId, node, root, config, visitedRecordIds = {}, depth = 0) {
|
|
7810
|
+
var _a, _b;
|
|
7773
7811
|
// Filter Error and null nodes
|
|
7774
7812
|
if (!isGraphNode$1(node)) {
|
|
7775
7813
|
return;
|
|
@@ -7808,7 +7846,7 @@ function extractTrackedFieldsToTrie(recordId, node, root, config, visitedRecordI
|
|
|
7808
7846
|
continue;
|
|
7809
7847
|
}
|
|
7810
7848
|
const { maxDepth, onlyFetchLeafNodeIdAndName } = config;
|
|
7811
|
-
if (field.isScalar('value') === false) {
|
|
7849
|
+
if (field.isScalar('value') === false && !Array.isArray((_a = field.data) === null || _a === void 0 ? void 0 : _a.value)) {
|
|
7812
7850
|
if (depth + 1 > maxDepth) {
|
|
7813
7851
|
if (onlyFetchLeafNodeIdAndName === true) {
|
|
7814
7852
|
addScalarFieldId(current);
|
|
@@ -7845,7 +7883,7 @@ function extractTrackedFieldsToTrie(recordId, node, root, config, visitedRecordI
|
|
|
7845
7883
|
addScalarFieldName(current);
|
|
7846
7884
|
continue;
|
|
7847
7885
|
}
|
|
7848
|
-
if (field.scalar('value') === null) {
|
|
7886
|
+
if (field.scalar('value') === null && !Array.isArray((_b = field.data) === null || _b === void 0 ? void 0 : _b.value)) {
|
|
7849
7887
|
continue;
|
|
7850
7888
|
}
|
|
7851
7889
|
}
|
|
@@ -7971,6 +8009,7 @@ function markMissingOptionalFields(record, optionalFields) {
|
|
|
7971
8009
|
}
|
|
7972
8010
|
}
|
|
7973
8011
|
function _markMissingPath(record, path) {
|
|
8012
|
+
var _a;
|
|
7974
8013
|
// Filter out Error and null nodes
|
|
7975
8014
|
if (!isGraphNode$1(record)) {
|
|
7976
8015
|
return;
|
|
@@ -7992,7 +8031,7 @@ function _markMissingPath(record, path) {
|
|
|
7992
8031
|
return;
|
|
7993
8032
|
}
|
|
7994
8033
|
// if value is not a scalar, follow the link and mark it as missing
|
|
7995
|
-
if (fieldValue.isScalar('value') === false) {
|
|
8034
|
+
if (fieldValue.isScalar('value') === false && !Array.isArray((_a = fieldValue.data) === null || _a === void 0 ? void 0 : _a.value)) {
|
|
7996
8035
|
_markMissingPath(fieldValue
|
|
7997
8036
|
.link('value')
|
|
7998
8037
|
.follow(), path);
|
|
@@ -8070,6 +8109,7 @@ function isSuperRecordFieldTrie(a, b) {
|
|
|
8070
8109
|
// This function sets fields that we are refreshing to pending
|
|
8071
8110
|
// These values will go into the store
|
|
8072
8111
|
function mergePendingFields(newRecord, oldRecord, existingNode) {
|
|
8112
|
+
var _a;
|
|
8073
8113
|
const mergedFields = { ...newRecord.fields };
|
|
8074
8114
|
const merged = { ...newRecord, fields: mergedFields };
|
|
8075
8115
|
const existingFields = keys$1(oldRecord.fields);
|
|
@@ -8093,7 +8133,7 @@ function mergePendingFields(newRecord, oldRecord, existingNode) {
|
|
|
8093
8133
|
.link(spanningFieldName);
|
|
8094
8134
|
const field = fieldValueRep.follow();
|
|
8095
8135
|
if (isGraphNode$1(field)) {
|
|
8096
|
-
if (field.isScalar('value') === false) {
|
|
8136
|
+
if (field.isScalar('value') === false && !Array.isArray((_a = field.data) === null || _a === void 0 ? void 0 : _a.value)) {
|
|
8097
8137
|
const record = field
|
|
8098
8138
|
.link('value')
|
|
8099
8139
|
.follow();
|
|
@@ -8335,7 +8375,7 @@ function fixDisplayValue(existing, incoming, path) {
|
|
|
8335
8375
|
function normalize$S(input, existing, path, luvio, store, timestamp, fieldsTrie, optionalFieldsTrie, recordConflictMap) {
|
|
8336
8376
|
const input_value = input.value;
|
|
8337
8377
|
const input_value_id = path.fullPath + '__value';
|
|
8338
|
-
if (input_value !== null && typeof input_value === 'object') {
|
|
8378
|
+
if (input_value !== null && typeof input_value === 'object' && !Array.isArray(input_value)) {
|
|
8339
8379
|
const ingest = createRecordIngest(fieldsTrie, optionalFieldsTrie, recordConflictMap);
|
|
8340
8380
|
input.value = ingest(input_value, {
|
|
8341
8381
|
fullPath: input_value_id,
|
|
@@ -9477,7 +9517,7 @@ function isGraphNode(node) {
|
|
|
9477
9517
|
return node !== null && node.type === 'Node';
|
|
9478
9518
|
}
|
|
9479
9519
|
function isSpanningRecord(fieldValue) {
|
|
9480
|
-
return fieldValue !== null && typeof fieldValue === 'object';
|
|
9520
|
+
return fieldValue !== null && typeof fieldValue === 'object' && !Array.isArray(fieldValue);
|
|
9481
9521
|
}
|
|
9482
9522
|
function isStoreKeyRecordId(key) {
|
|
9483
9523
|
return key.indexOf(RECORD_ID_PREFIX) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1;
|
|
@@ -9511,7 +9551,7 @@ function getShallowRecordDenormalized(luvio, storeRecordId) {
|
|
|
9511
9551
|
}
|
|
9512
9552
|
const fieldObject = fieldsNode.object(fieldName);
|
|
9513
9553
|
const { displayValue, value } = fieldObject.retrieve();
|
|
9514
|
-
if (fieldObject.isScalar('value')) {
|
|
9554
|
+
if (fieldObject.isScalar('value') || Array.isArray(fieldObject.data?.value)) {
|
|
9515
9555
|
fieldCopy = {
|
|
9516
9556
|
displayValue: displayValue,
|
|
9517
9557
|
value: value,
|
|
@@ -9569,7 +9609,7 @@ function getShallowRecord(luvio, storeRecordId) {
|
|
|
9569
9609
|
continue;
|
|
9570
9610
|
}
|
|
9571
9611
|
const { displayValue, value } = fieldNode.retrieve();
|
|
9572
|
-
if (fieldNode.isScalar('value')) {
|
|
9612
|
+
if (fieldNode.isScalar('value') || Array.isArray(fieldNode.data?.value)) {
|
|
9573
9613
|
fieldCopy = {
|
|
9574
9614
|
displayValue: displayValue,
|
|
9575
9615
|
value: value,
|
package/dist/adsBridge.js
CHANGED
|
@@ -53,7 +53,7 @@ function isGraphNode(node) {
|
|
|
53
53
|
return node !== null && node.type === 'Node';
|
|
54
54
|
}
|
|
55
55
|
function isSpanningRecord(fieldValue) {
|
|
56
|
-
return fieldValue !== null && typeof fieldValue === 'object';
|
|
56
|
+
return fieldValue !== null && typeof fieldValue === 'object' && !Array.isArray(fieldValue);
|
|
57
57
|
}
|
|
58
58
|
function isStoreKeyRecordId(key) {
|
|
59
59
|
return key.indexOf(RECORD_ID_PREFIX) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION) === -1;
|
|
@@ -87,7 +87,7 @@ function getShallowRecordDenormalized(luvio, storeRecordId) {
|
|
|
87
87
|
}
|
|
88
88
|
const fieldObject = fieldsNode.object(fieldName);
|
|
89
89
|
const { displayValue, value } = fieldObject.retrieve();
|
|
90
|
-
if (fieldObject.isScalar('value')) {
|
|
90
|
+
if (fieldObject.isScalar('value') || Array.isArray(fieldObject.data?.value)) {
|
|
91
91
|
fieldCopy = {
|
|
92
92
|
displayValue: displayValue,
|
|
93
93
|
value: value,
|
|
@@ -145,7 +145,7 @@ function getShallowRecord(luvio, storeRecordId) {
|
|
|
145
145
|
continue;
|
|
146
146
|
}
|
|
147
147
|
const { displayValue, value } = fieldNode.retrieve();
|
|
148
|
-
if (fieldNode.isScalar('value')) {
|
|
148
|
+
if (fieldNode.isScalar('value') || Array.isArray(fieldNode.data?.value)) {
|
|
149
149
|
fieldCopy = {
|
|
150
150
|
displayValue: displayValue,
|
|
151
151
|
value: value,
|
|
@@ -435,4 +435,4 @@ function withAdsBridge(callback) {
|
|
|
435
435
|
}
|
|
436
436
|
|
|
437
437
|
export { instrument, withAdsBridge };
|
|
438
|
-
// version: 1.
|
|
438
|
+
// version: 1.362.0-5d2767de00
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-ads-bridge",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.362.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,9 +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.
|
|
34
|
-
"@salesforce/lds-runtime-mobile": "^1.
|
|
35
|
-
"@salesforce/lds-uiapi-record-utils-mobile": "^1.
|
|
33
|
+
"@salesforce/lds-adapters-uiapi": "^1.362.0",
|
|
34
|
+
"@salesforce/lds-runtime-mobile": "^1.362.0",
|
|
35
|
+
"@salesforce/lds-uiapi-record-utils-mobile": "^1.362.0"
|
|
36
36
|
},
|
|
37
37
|
"volta": {
|
|
38
38
|
"extends": "../../package.json"
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"path": "./dist/adsBridge.js",
|
|
43
43
|
"maxSize": {
|
|
44
44
|
"none": "17 kB",
|
|
45
|
-
"min": "5.
|
|
45
|
+
"min": "5.51 kB",
|
|
46
46
|
"compressed": "4 kB"
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -725,6 +725,44 @@ describe('AdsBridge', () => {
|
|
|
725
725
|
expect(timerMetricAddDurationSpy).toHaveBeenCalledTimes(1);
|
|
726
726
|
});
|
|
727
727
|
|
|
728
|
+
it('emits when a record is ingested with array values', () => {
|
|
729
|
+
const { bridge, luvio } = createBridge();
|
|
730
|
+
|
|
731
|
+
const fn = jest.fn();
|
|
732
|
+
bridge.receiveFromLdsCallback = fn;
|
|
733
|
+
|
|
734
|
+
addRecord(
|
|
735
|
+
luvio,
|
|
736
|
+
createRecord({
|
|
737
|
+
id: '123456',
|
|
738
|
+
apiName: 'Test__c',
|
|
739
|
+
fields: {
|
|
740
|
+
Id: { displayValue: null, value: ['123456'] },
|
|
741
|
+
},
|
|
742
|
+
})
|
|
743
|
+
);
|
|
744
|
+
|
|
745
|
+
expect(fn).toHaveBeenCalledTimes(1);
|
|
746
|
+
expect(fn).toHaveBeenCalledWith(
|
|
747
|
+
{
|
|
748
|
+
'123456': {
|
|
749
|
+
Test__c: {
|
|
750
|
+
isPrimary: true,
|
|
751
|
+
record: expect.objectContaining({
|
|
752
|
+
id: '123456',
|
|
753
|
+
apiName: 'Test__c',
|
|
754
|
+
fields: {
|
|
755
|
+
Id: { displayValue: null, value: ['123456'] },
|
|
756
|
+
},
|
|
757
|
+
}),
|
|
758
|
+
},
|
|
759
|
+
},
|
|
760
|
+
},
|
|
761
|
+
expect.any(Object)
|
|
762
|
+
);
|
|
763
|
+
expect(timerMetricAddDurationSpy).toHaveBeenCalledTimes(1);
|
|
764
|
+
});
|
|
765
|
+
|
|
728
766
|
it('does not emit when a record is evicted from luvio', () => {
|
|
729
767
|
const { bridge, luvio } = createBridge();
|
|
730
768
|
|
package/src/ads-bridge.ts
CHANGED
|
@@ -98,9 +98,9 @@ function isGraphNode<T, U>(node: ProxyGraphNode<T, U>): node is GraphNode<T, U>
|
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
function isSpanningRecord(
|
|
101
|
-
fieldValue: null | string | number | boolean | RecordRepresentation
|
|
101
|
+
fieldValue: null | string | string[] | number | boolean | RecordRepresentation
|
|
102
102
|
): fieldValue is RecordRepresentation {
|
|
103
|
-
return fieldValue !== null && typeof fieldValue === 'object';
|
|
103
|
+
return fieldValue !== null && typeof fieldValue === 'object' && !Array.isArray(fieldValue);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
function isStoreKeyRecordId(key: string) {
|
|
@@ -149,10 +149,10 @@ function getShallowRecordDenormalized(
|
|
|
149
149
|
|
|
150
150
|
const fieldObject = fieldsNode.object(fieldName);
|
|
151
151
|
const { displayValue, value } = fieldObject.retrieve();
|
|
152
|
-
if (fieldObject.isScalar('value')) {
|
|
152
|
+
if (fieldObject.isScalar('value') || Array.isArray(fieldObject.data?.value)) {
|
|
153
153
|
fieldCopy = {
|
|
154
154
|
displayValue: displayValue,
|
|
155
|
-
value: value as string | number | boolean | null,
|
|
155
|
+
value: value as string | number | boolean | string[] | null,
|
|
156
156
|
};
|
|
157
157
|
} else {
|
|
158
158
|
const spanningRecordLink = fieldObject.link<
|
|
@@ -225,10 +225,10 @@ function getShallowRecord(luvio: Luvio, storeRecordId: string): RecordRepresenta
|
|
|
225
225
|
}
|
|
226
226
|
|
|
227
227
|
const { displayValue, value } = fieldNode.retrieve();
|
|
228
|
-
if (fieldNode.isScalar('value')) {
|
|
228
|
+
if (fieldNode.isScalar('value') || Array.isArray(fieldNode.data?.value)) {
|
|
229
229
|
fieldCopy = {
|
|
230
230
|
displayValue: displayValue,
|
|
231
|
-
value: value as string | number | boolean | null,
|
|
231
|
+
value: value as string | number | boolean | string[] | null,
|
|
232
232
|
};
|
|
233
233
|
} else {
|
|
234
234
|
const spanningRecordLink = fieldNode.link<
|