@salesforce/lds-worker-api 1.233.0 → 1.235.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.
|
@@ -20,7 +20,7 @@ var SnapshotState$3;
|
|
|
20
20
|
SnapshotState["Stale"] = "Stale";
|
|
21
21
|
})(SnapshotState$3 || (SnapshotState$3 = {}));
|
|
22
22
|
|
|
23
|
-
const { create: create$b, entries: entries$5, freeze: freeze$5, keys: keys$c, values: values$
|
|
23
|
+
const { create: create$b, entries: entries$5, freeze: freeze$5, keys: keys$c, values: values$5 } = Object;
|
|
24
24
|
const { hasOwnProperty: hasOwnProperty$3 } = Object.prototype;
|
|
25
25
|
const { isArray: isArray$9 } = Array;
|
|
26
26
|
const { push: push$5, indexOf, slice: slice$2 } = Array.prototype;
|
|
@@ -840,14 +840,16 @@ class StringKeyInMemoryStore {
|
|
|
840
840
|
delete this.records[canonicalKey];
|
|
841
841
|
}
|
|
842
842
|
publishMetadata(key, storeMetadata) {
|
|
843
|
+
this.putMetadata(key, storeMetadata, true);
|
|
844
|
+
const canonicalKey = this.getCanonicalRecordId(key);
|
|
845
|
+
this.markRefreshed(canonicalKey);
|
|
846
|
+
}
|
|
847
|
+
putMetadata(key, storeMetadata, adjustTTLOverride) {
|
|
843
848
|
const { namespace, representationName, ingestionTimestamp } = storeMetadata;
|
|
844
849
|
const ttlOverrideKey = getTTLOverrideKey(namespace, representationName);
|
|
845
850
|
const ttlOverride = getTTLOverride$1(ttlOverrideKey, this.ttlOverrides, this.defaultTTLOverride);
|
|
846
851
|
const canonicalKey = this.getCanonicalRecordId(key);
|
|
847
|
-
|
|
848
|
-
if (ttlOverride !== undefined) {
|
|
849
|
-
// It should check if the namespace + representationName exists in the ttlOverride map.
|
|
850
|
-
// If a ttlOverride does exist, calculate a new ExpirationTimestamp with the override.
|
|
852
|
+
if (ttlOverride !== undefined && adjustTTLOverride === true) {
|
|
851
853
|
const newExpiration = ingestionTimestamp + ttlOverride;
|
|
852
854
|
// Create a new StoreMetadata object and publish the new object to storeMetadata.
|
|
853
855
|
const metaDataOverride = {
|
|
@@ -1489,12 +1491,20 @@ class InMemoryStore {
|
|
|
1489
1491
|
this.fallbackStringKeyInMemoryStore.publishMetadata(key, storeMetadata);
|
|
1490
1492
|
return;
|
|
1491
1493
|
}
|
|
1494
|
+
this.putMetadata(key, storeMetadata, true);
|
|
1495
|
+
const canonicalKey = this.getCanonicalRecordId(key);
|
|
1496
|
+
this.markRefreshed(canonicalKey);
|
|
1497
|
+
}
|
|
1498
|
+
putMetadata(key, storeMetadata, adjustTTLOverride) {
|
|
1499
|
+
if (typeof key === 'string') {
|
|
1500
|
+
this.fallbackStringKeyInMemoryStore.putMetadata(key, storeMetadata, adjustTTLOverride);
|
|
1501
|
+
return;
|
|
1502
|
+
}
|
|
1492
1503
|
const { namespace, representationName, ingestionTimestamp } = storeMetadata;
|
|
1493
1504
|
const ttlOverrideKey = this.buildStructuredKey(namespace, representationName, {});
|
|
1494
1505
|
const ttlOverride = getTTLOverride(ttlOverrideKey, this.ttlOverridesMap, this.defaultTTLOverride);
|
|
1495
1506
|
const canonicalKey = this.getCanonicalRecordId(key);
|
|
1496
|
-
|
|
1497
|
-
if (ttlOverride !== undefined) {
|
|
1507
|
+
if (ttlOverride !== undefined && adjustTTLOverride) {
|
|
1498
1508
|
// It should check if the namespace + representationName exists in the ttlOverride map.
|
|
1499
1509
|
// If a ttlOverride does exist, calculate a new ExpirationTimestamp with the override.
|
|
1500
1510
|
const newExpiration = ingestionTimestamp + ttlOverride;
|
|
@@ -3278,6 +3288,9 @@ class Environment {
|
|
|
3278
3288
|
publishStoreMetadata(key, storeMetadata) {
|
|
3279
3289
|
this.store.publishMetadata(key, storeMetadata);
|
|
3280
3290
|
}
|
|
3291
|
+
putStoreMetadata(key, storeMetadata, adjustTTLOverride) {
|
|
3292
|
+
this.store.putMetadata(key, storeMetadata, adjustTTLOverride);
|
|
3293
|
+
}
|
|
3281
3294
|
storeSetTTLOverride(namespace, representationName, ttl) {
|
|
3282
3295
|
this.store.setTTLOverride(namespace, representationName, ttl);
|
|
3283
3296
|
this.recomputeTTLOverrideExpirations(namespace, representationName);
|
|
@@ -3841,7 +3854,7 @@ function createResourceParamsImpl(config, configMetadata) {
|
|
|
3841
3854
|
}
|
|
3842
3855
|
return resourceParams;
|
|
3843
3856
|
}
|
|
3844
|
-
// engine version: 0.
|
|
3857
|
+
// engine version: 0.147.1-bc3a8b47
|
|
3845
3858
|
|
|
3846
3859
|
/**
|
|
3847
3860
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -3968,7 +3981,7 @@ function withDefaultLuvio(callback) {
|
|
|
3968
3981
|
}
|
|
3969
3982
|
callbacks.push(callback);
|
|
3970
3983
|
}
|
|
3971
|
-
// version: 1.
|
|
3984
|
+
// version: 1.235.0-3790decf0
|
|
3972
3985
|
|
|
3973
3986
|
// TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
|
|
3974
3987
|
function instrumentAdapter$1(createFunction, _metadata) {
|
|
@@ -15429,7 +15442,7 @@ function gql(literals, ...subs) {
|
|
|
15429
15442
|
}
|
|
15430
15443
|
return superResult;
|
|
15431
15444
|
}
|
|
15432
|
-
// version: 1.
|
|
15445
|
+
// version: 1.235.0-3790decf0
|
|
15433
15446
|
|
|
15434
15447
|
function unwrap(data) {
|
|
15435
15448
|
// The lwc-luvio bindings import a function from lwc called "unwrap".
|
|
@@ -15530,14 +15543,15 @@ function refreshData(data, dataToTuple, luvio) {
|
|
|
15530
15543
|
return undefined;
|
|
15531
15544
|
});
|
|
15532
15545
|
}
|
|
15533
|
-
const { isArray: isArray$8 } = Array;
|
|
15534
|
-
const { stringify: stringify$9 } = JSON;
|
|
15535
15546
|
|
|
15536
15547
|
function isPromise$1(value) {
|
|
15537
15548
|
// check for Thenable due to test frameworks using custom Promise impls
|
|
15538
15549
|
return value.then !== undefined;
|
|
15539
15550
|
}
|
|
15540
15551
|
|
|
15552
|
+
const { isArray: isArray$8 } = Array;
|
|
15553
|
+
const { stringify: stringify$9 } = JSON;
|
|
15554
|
+
|
|
15541
15555
|
/**
|
|
15542
15556
|
* (Re)throws an error after adding a prefix to the message.
|
|
15543
15557
|
*
|
|
@@ -16352,7 +16366,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
|
|
|
16352
16366
|
const { apiFamily, name } = metadata;
|
|
16353
16367
|
return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
|
|
16354
16368
|
}
|
|
16355
|
-
// version: 1.
|
|
16369
|
+
// version: 1.235.0-3790decf0
|
|
16356
16370
|
|
|
16357
16371
|
/**
|
|
16358
16372
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -16451,7 +16465,7 @@ var TypeCheckShapes;
|
|
|
16451
16465
|
TypeCheckShapes[TypeCheckShapes["Integer"] = 3] = "Integer";
|
|
16452
16466
|
TypeCheckShapes[TypeCheckShapes["Unsupported"] = 4] = "Unsupported";
|
|
16453
16467
|
})(TypeCheckShapes || (TypeCheckShapes = {}));
|
|
16454
|
-
// engine version: 0.
|
|
16468
|
+
// engine version: 0.147.1-bc3a8b47
|
|
16455
16469
|
|
|
16456
16470
|
const { keys: ObjectKeys$3, create: ObjectCreate$3 } = Object;
|
|
16457
16471
|
|
|
@@ -41305,7 +41319,7 @@ withDefaultLuvio((luvio) => {
|
|
|
41305
41319
|
throttle(60, 60000, createLDSAdapter(luvio, 'notifyListInfoUpdateAvailable', notifyUpdateAvailableFactory$1));
|
|
41306
41320
|
throttle(60, 60000, createLDSAdapter(luvio, 'notifyQuickActionDefaultsUpdateAvailable', notifyUpdateAvailableFactory));
|
|
41307
41321
|
});
|
|
41308
|
-
// version: 1.
|
|
41322
|
+
// version: 1.235.0-c252f93dc
|
|
41309
41323
|
|
|
41310
41324
|
var caseSensitiveUserId = '005B0000000GR4OIAW';
|
|
41311
41325
|
|
|
@@ -41425,6 +41439,15 @@ var ldsPrimingGraphqlBatch = {
|
|
|
41425
41439
|
},
|
|
41426
41440
|
};
|
|
41427
41441
|
|
|
41442
|
+
var ldsMetadataRefreshEnabled = {
|
|
41443
|
+
isOpen: function (e) {
|
|
41444
|
+
return e.fallback;
|
|
41445
|
+
},
|
|
41446
|
+
hasError: function () {
|
|
41447
|
+
return !0;
|
|
41448
|
+
},
|
|
41449
|
+
};
|
|
41450
|
+
|
|
41428
41451
|
/**
|
|
41429
41452
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
41430
41453
|
* All rights reserved.
|
|
@@ -41999,7 +42022,7 @@ function publishDurableStoreEntries(durableRecords, put, publishMetadata) {
|
|
|
41999
42022
|
* will refresh the snapshot from network, and then run the results from network
|
|
42000
42023
|
* through L2 ingestion, returning the subsequent revived snapshot.
|
|
42001
42024
|
*/
|
|
42002
|
-
function reviveSnapshot(baseEnvironment, durableStore, unavailableSnapshot, durableStoreErrorHandler, buildL1Snapshot, reviveMetrics = { l2Trips: [] }) {
|
|
42025
|
+
function reviveSnapshot(baseEnvironment, durableStore, unavailableSnapshot, durableStoreErrorHandler, buildL1Snapshot, revivingStore, reviveMetrics = { l2Trips: [] }) {
|
|
42003
42026
|
const { recordId, select, missingLinks, seenRecords, state } = unavailableSnapshot;
|
|
42004
42027
|
// L2 can only revive Unfulfilled snapshots that have a selector since they have the
|
|
42005
42028
|
// info needed to revive (like missingLinks) and rebuild. Otherwise return L1 snapshot.
|
|
@@ -42009,10 +42032,21 @@ function reviveSnapshot(baseEnvironment, durableStore, unavailableSnapshot, dura
|
|
|
42009
42032
|
metrics: reviveMetrics,
|
|
42010
42033
|
});
|
|
42011
42034
|
}
|
|
42012
|
-
|
|
42013
|
-
|
|
42014
|
-
|
|
42015
|
-
|
|
42035
|
+
const keysToReviveSet = new StoreKeySet();
|
|
42036
|
+
if (revivingStore) {
|
|
42037
|
+
// Any stale keys since the last l2 read should be cleared and fetched again
|
|
42038
|
+
for (const staleKey of revivingStore.staleEntries) {
|
|
42039
|
+
keysToReviveSet.add(staleKey);
|
|
42040
|
+
}
|
|
42041
|
+
revivingStore.clearStale();
|
|
42042
|
+
}
|
|
42043
|
+
else {
|
|
42044
|
+
// when not using a reviving store:
|
|
42045
|
+
// in case L1 store changes/deallocs a record while we are doing the async read
|
|
42046
|
+
// we attempt to read all keys from L2 - so combine recordId with any seenRecords
|
|
42047
|
+
keysToReviveSet.add(recordId);
|
|
42048
|
+
keysToReviveSet.merge(seenRecords);
|
|
42049
|
+
}
|
|
42016
42050
|
keysToReviveSet.merge(missingLinks);
|
|
42017
42051
|
const keysToRevive = keysToReviveSet.keysAsArray();
|
|
42018
42052
|
const canonicalKeys = keysToRevive.map((x) => serializeStructuredKey(baseEnvironment.storeGetCanonicalKey(x)));
|
|
@@ -42062,7 +42096,7 @@ function reviveSnapshot(baseEnvironment, durableStore, unavailableSnapshot, dura
|
|
|
42062
42096
|
for (let i = 0, len = newKeys.length; i < len; i++) {
|
|
42063
42097
|
const newSnapshotSeenKey = newKeys[i];
|
|
42064
42098
|
if (!alreadyRequestedOrRevivedSet.has(newSnapshotSeenKey)) {
|
|
42065
|
-
return reviveSnapshot(baseEnvironment, durableStore, snapshot, durableStoreErrorHandler, buildL1Snapshot, reviveMetrics);
|
|
42099
|
+
return reviveSnapshot(baseEnvironment, durableStore, snapshot, durableStoreErrorHandler, buildL1Snapshot, revivingStore, reviveMetrics);
|
|
42066
42100
|
}
|
|
42067
42101
|
}
|
|
42068
42102
|
}
|
|
@@ -42151,8 +42185,9 @@ class DurableTTLStore {
|
|
|
42151
42185
|
}
|
|
42152
42186
|
}
|
|
42153
42187
|
|
|
42154
|
-
function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStoreErrorHandler, redirects, additionalDurableStoreOperations = []) {
|
|
42188
|
+
function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStoreErrorHandler, redirects, additionalDurableStoreOperations = [], enableDurableMetadataRefresh = false) {
|
|
42155
42189
|
const durableRecords = create$6(null);
|
|
42190
|
+
const refreshedDurableRecords = create$6(null);
|
|
42156
42191
|
const evictedRecords = create$6(null);
|
|
42157
42192
|
const { records, metadata: storeMetadata, visitedIds, refreshedIds, } = store.fallbackStringKeyInMemoryStore;
|
|
42158
42193
|
// TODO: W-8909393 Once metadata is stored in its own segment we need to
|
|
@@ -42162,32 +42197,36 @@ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStor
|
|
|
42162
42197
|
for (let i = 0, len = keys$1.length; i < len; i += 1) {
|
|
42163
42198
|
const key = keys$1[i];
|
|
42164
42199
|
const record = records[key];
|
|
42200
|
+
const wasVisited = visitedIds[key] !== undefined;
|
|
42165
42201
|
// this record has been evicted, evict from DS
|
|
42166
|
-
if (record === undefined) {
|
|
42202
|
+
if (wasVisited && record === undefined) {
|
|
42167
42203
|
evictedRecords[key] = true;
|
|
42168
42204
|
continue;
|
|
42169
42205
|
}
|
|
42170
42206
|
const metadata = storeMetadata[key];
|
|
42171
|
-
|
|
42172
|
-
|
|
42173
|
-
|
|
42174
|
-
|
|
42175
|
-
durableRecords[key].metadata = {
|
|
42176
|
-
...metadata,
|
|
42177
|
-
metadataVersion: DURABLE_METADATA_VERSION,
|
|
42178
|
-
};
|
|
42179
|
-
}
|
|
42207
|
+
const entries = wasVisited === true || enableDurableMetadataRefresh === false
|
|
42208
|
+
? durableRecords
|
|
42209
|
+
: refreshedDurableRecords;
|
|
42210
|
+
setRecordTo(entries, key, record, metadata);
|
|
42180
42211
|
}
|
|
42181
42212
|
const durableStoreOperations = additionalDurableStoreOperations;
|
|
42182
|
-
// publishes
|
|
42183
42213
|
const recordKeys = keys$7(durableRecords);
|
|
42184
42214
|
if (recordKeys.length > 0) {
|
|
42215
|
+
// publishes with data
|
|
42185
42216
|
durableStoreOperations.push({
|
|
42186
42217
|
type: 'setEntries',
|
|
42187
42218
|
entries: durableRecords,
|
|
42188
42219
|
segment: DefaultDurableSegment,
|
|
42189
42220
|
});
|
|
42190
42221
|
}
|
|
42222
|
+
if (keys$7(refreshedDurableRecords).length > 0) {
|
|
42223
|
+
// publishes with only metadata updates
|
|
42224
|
+
durableStoreOperations.push({
|
|
42225
|
+
type: 'setMetadata',
|
|
42226
|
+
entries: refreshedDurableRecords,
|
|
42227
|
+
segment: DefaultDurableSegment,
|
|
42228
|
+
});
|
|
42229
|
+
}
|
|
42191
42230
|
// redirects
|
|
42192
42231
|
redirects.forEach((value, key) => {
|
|
42193
42232
|
durableStoreOperations.push({
|
|
@@ -42214,6 +42253,17 @@ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStor
|
|
|
42214
42253
|
}
|
|
42215
42254
|
return Promise.resolve();
|
|
42216
42255
|
}
|
|
42256
|
+
function setRecordTo(entries, key, record, metadata) {
|
|
42257
|
+
entries[key] = {
|
|
42258
|
+
data: record,
|
|
42259
|
+
};
|
|
42260
|
+
if (metadata !== undefined) {
|
|
42261
|
+
entries[key].metadata = {
|
|
42262
|
+
...metadata,
|
|
42263
|
+
metadataVersion: DURABLE_METADATA_VERSION,
|
|
42264
|
+
};
|
|
42265
|
+
}
|
|
42266
|
+
}
|
|
42217
42267
|
|
|
42218
42268
|
const DurableEnvironmentEventDiscriminator = 'durable';
|
|
42219
42269
|
function emitDurableEnvironmentAdapterEvent(eventData, observers) {
|
|
@@ -42258,6 +42308,50 @@ async function reviveRedirects(durableStore, env) {
|
|
|
42258
42308
|
}
|
|
42259
42309
|
}
|
|
42260
42310
|
|
|
42311
|
+
function buildRevivingStagingStore(upstreamStore) {
|
|
42312
|
+
const localStore = new StringKeyInMemoryStore();
|
|
42313
|
+
const staleEntries = new Set();
|
|
42314
|
+
function readEntry(key) {
|
|
42315
|
+
if (typeof key !== 'string') {
|
|
42316
|
+
return upstreamStore.readEntry(key);
|
|
42317
|
+
}
|
|
42318
|
+
let storeEntry = localStore.readEntry(key);
|
|
42319
|
+
if (!storeEntry) {
|
|
42320
|
+
// read from upstream store...
|
|
42321
|
+
storeEntry = upstreamStore.readEntry(key);
|
|
42322
|
+
// put it in our store to avoid it getting evicted prior to the next durable store read
|
|
42323
|
+
localStore.put(key, storeEntry);
|
|
42324
|
+
}
|
|
42325
|
+
return storeEntry;
|
|
42326
|
+
}
|
|
42327
|
+
// Entries are marked stale by the durable store change listener. They are not
|
|
42328
|
+
// immediately evicted so as to not result in a cache miss during a rebuild.
|
|
42329
|
+
// The revive process will clear stale entries and read them from the durable store
|
|
42330
|
+
// on the next revive loop.
|
|
42331
|
+
function markStale(key) {
|
|
42332
|
+
staleEntries.add(key);
|
|
42333
|
+
}
|
|
42334
|
+
// The revive loop clears stale entries right before reading from the durable store.
|
|
42335
|
+
// Any stale entries will be revived to ensure they are present in L1 and match the
|
|
42336
|
+
// latest data.
|
|
42337
|
+
function clearStale() {
|
|
42338
|
+
for (const key of staleEntries) {
|
|
42339
|
+
localStore.dealloc(key);
|
|
42340
|
+
}
|
|
42341
|
+
staleEntries.clear();
|
|
42342
|
+
}
|
|
42343
|
+
// All functions other than `readEntry` pass through to the upstream store.
|
|
42344
|
+
// A reviving store is only "active" during a call to `environment.storeLookup`, and will
|
|
42345
|
+
// be used by the reader attempting to build an L1 snapshot. Immediately after the L1 rebuild
|
|
42346
|
+
// the reviving store becomes inactive other than receiving change notifications.
|
|
42347
|
+
return create$6(upstreamStore, {
|
|
42348
|
+
readEntry: { value: readEntry },
|
|
42349
|
+
markStale: { value: markStale },
|
|
42350
|
+
clearStale: { value: clearStale },
|
|
42351
|
+
staleEntries: { value: staleEntries },
|
|
42352
|
+
});
|
|
42353
|
+
}
|
|
42354
|
+
|
|
42261
42355
|
const AdapterContextSegment = 'ADAPTER-CONTEXT';
|
|
42262
42356
|
const ADAPTER_CONTEXT_ID_SUFFIX = '__NAMED_CONTEXT';
|
|
42263
42357
|
async function reviveOrCreateContext(adapterId, durableStore, durableStoreErrorHandler, contextStores, pendingContextStoreKeys, onContextLoaded) {
|
|
@@ -42313,14 +42407,16 @@ function isUnfulfilledSnapshot$1(cachedSnapshotResult) {
|
|
|
42313
42407
|
* @param durableStore A DurableStore implementation
|
|
42314
42408
|
* @param instrumentation An instrumentation function implementation
|
|
42315
42409
|
*/
|
|
42316
|
-
function makeDurable(environment, { durableStore, instrumentation }) {
|
|
42317
|
-
let
|
|
42410
|
+
function makeDurable(environment, { durableStore, instrumentation, useRevivingStore, enableDurableMetadataRefresh = false, }) {
|
|
42411
|
+
let stagingStore = null;
|
|
42318
42412
|
const durableTTLStore = new DurableTTLStore(durableStore);
|
|
42319
42413
|
const mergeKeysPromiseMap = new Map();
|
|
42320
42414
|
// When a context store is mutated we write it to L2, which causes DS on change
|
|
42321
42415
|
// event. If this instance of makeDurable caused that L2 write we can ignore that
|
|
42322
42416
|
// on change event. This Set helps us do that.
|
|
42323
42417
|
const pendingContextStoreKeys = new Set();
|
|
42418
|
+
// Reviving stores are tracked so that they can be notified of durable store change notifications.
|
|
42419
|
+
const revivingStores = new Set();
|
|
42324
42420
|
// redirects that need to be flushed to the durable store
|
|
42325
42421
|
const pendingStoreRedirects = new Map();
|
|
42326
42422
|
const contextStores = create$6(null);
|
|
@@ -42346,6 +42442,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
42346
42442
|
const defaultSegmentKeys = [];
|
|
42347
42443
|
const adapterContextSegmentKeys = [];
|
|
42348
42444
|
const redirectSegmentKeys = [];
|
|
42445
|
+
const metadataRefreshSegmentKeys = [];
|
|
42349
42446
|
const messagingSegmentKeys = [];
|
|
42350
42447
|
let shouldBroadcast = false;
|
|
42351
42448
|
for (let i = 0, len = changes.length; i < len; i++) {
|
|
@@ -42353,7 +42450,12 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
42353
42450
|
// we only care about changes to the data which is stored in the default
|
|
42354
42451
|
// segment or the adapter context
|
|
42355
42452
|
if (change.segment === DefaultDurableSegment) {
|
|
42356
|
-
|
|
42453
|
+
if (change.type === 'setMetadata') {
|
|
42454
|
+
metadataRefreshSegmentKeys.push(...change.ids);
|
|
42455
|
+
}
|
|
42456
|
+
else {
|
|
42457
|
+
defaultSegmentKeys.push(...change.ids);
|
|
42458
|
+
}
|
|
42357
42459
|
}
|
|
42358
42460
|
else if (change.segment === AdapterContextSegment) {
|
|
42359
42461
|
adapterContextSegmentKeys.push(...change.ids);
|
|
@@ -42417,9 +42519,26 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
42417
42519
|
// and go through an entire broadcast/revive cycle for unchanged data
|
|
42418
42520
|
// call base environment storeEvict so this evict is not tracked for durable deletion
|
|
42419
42521
|
environment.storeEvict(key);
|
|
42522
|
+
for (const revivingStore of revivingStores) {
|
|
42523
|
+
revivingStore.markStale(key);
|
|
42524
|
+
}
|
|
42420
42525
|
}
|
|
42421
42526
|
shouldBroadcast = true;
|
|
42422
42527
|
}
|
|
42528
|
+
// process metadata only refreshes
|
|
42529
|
+
if (metadataRefreshSegmentKeys.length > 0) {
|
|
42530
|
+
const entries = await durableStore.getMetadata(metadataRefreshSegmentKeys, DefaultDurableSegment);
|
|
42531
|
+
if (entries !== undefined) {
|
|
42532
|
+
const entryKeys = keys$7(entries);
|
|
42533
|
+
for (let i = 0, len = entryKeys.length; i < len; i++) {
|
|
42534
|
+
const entryKey = entryKeys[i];
|
|
42535
|
+
const { metadata } = entries[entryKey];
|
|
42536
|
+
if (metadata !== undefined) {
|
|
42537
|
+
environment.putStoreMetadata(entryKey, metadata, false);
|
|
42538
|
+
}
|
|
42539
|
+
}
|
|
42540
|
+
}
|
|
42541
|
+
}
|
|
42423
42542
|
if (shouldBroadcast) {
|
|
42424
42543
|
await environment.storeBroadcast(rebuildSnapshot, environment.snapshotAvailable);
|
|
42425
42544
|
}
|
|
@@ -42445,10 +42564,10 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
42445
42564
|
};
|
|
42446
42565
|
const storePublish = function (key, data) {
|
|
42447
42566
|
validateNotDisposed();
|
|
42448
|
-
if (
|
|
42449
|
-
|
|
42567
|
+
if (stagingStore === null) {
|
|
42568
|
+
stagingStore = buildIngestStagingStore(environment);
|
|
42450
42569
|
}
|
|
42451
|
-
|
|
42570
|
+
stagingStore.publish(key, data);
|
|
42452
42571
|
// remove record from main luvio L1 cache while we are on the synchronous path
|
|
42453
42572
|
// because we do not want some other code attempting to use the
|
|
42454
42573
|
// in-memory values before the durable store onChanged handler
|
|
@@ -42457,26 +42576,26 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
42457
42576
|
};
|
|
42458
42577
|
const publishStoreMetadata = function (recordId, storeMetadata) {
|
|
42459
42578
|
validateNotDisposed();
|
|
42460
|
-
if (
|
|
42461
|
-
|
|
42579
|
+
if (stagingStore === null) {
|
|
42580
|
+
stagingStore = buildIngestStagingStore(environment);
|
|
42462
42581
|
}
|
|
42463
|
-
|
|
42582
|
+
stagingStore.publishMetadata(recordId, storeMetadata);
|
|
42464
42583
|
};
|
|
42465
42584
|
const storeIngest = function (key, ingest, response, luvio) {
|
|
42466
42585
|
validateNotDisposed();
|
|
42467
42586
|
// we don't ingest to the luvio L1 store from network directly, we ingest to
|
|
42468
42587
|
// L2 and let DurableStore on change event revive keys into luvio L1 store
|
|
42469
|
-
if (
|
|
42470
|
-
|
|
42588
|
+
if (stagingStore === null) {
|
|
42589
|
+
stagingStore = buildIngestStagingStore(environment);
|
|
42471
42590
|
}
|
|
42472
|
-
environment.storeIngest(key, ingest, response, luvio,
|
|
42591
|
+
environment.storeIngest(key, ingest, response, luvio, stagingStore);
|
|
42473
42592
|
};
|
|
42474
42593
|
const storeIngestError = function (key, errorSnapshot, storeMetadataParams, _storeOverride) {
|
|
42475
42594
|
validateNotDisposed();
|
|
42476
|
-
if (
|
|
42477
|
-
|
|
42595
|
+
if (stagingStore === null) {
|
|
42596
|
+
stagingStore = buildIngestStagingStore(environment);
|
|
42478
42597
|
}
|
|
42479
|
-
environment.storeIngestError(key, errorSnapshot, storeMetadataParams,
|
|
42598
|
+
environment.storeIngestError(key, errorSnapshot, storeMetadataParams, stagingStore);
|
|
42480
42599
|
};
|
|
42481
42600
|
const storeBroadcast = function (_rebuildSnapshot, _snapshotDataAvailable) {
|
|
42482
42601
|
validateNotDisposed();
|
|
@@ -42487,19 +42606,19 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
42487
42606
|
};
|
|
42488
42607
|
const publishChangesToDurableStore = function (additionalDurableStoreOperations) {
|
|
42489
42608
|
validateNotDisposed();
|
|
42490
|
-
if (
|
|
42609
|
+
if (stagingStore === null) {
|
|
42491
42610
|
return Promise.resolve();
|
|
42492
42611
|
}
|
|
42493
|
-
const promise = flushInMemoryStoreValuesToDurableStore(
|
|
42612
|
+
const promise = flushInMemoryStoreValuesToDurableStore(stagingStore, durableStore, durableStoreErrorHandler, new Map(pendingStoreRedirects), additionalDurableStoreOperations, enableDurableMetadataRefresh);
|
|
42494
42613
|
pendingStoreRedirects.clear();
|
|
42495
|
-
|
|
42614
|
+
stagingStore = null;
|
|
42496
42615
|
return promise;
|
|
42497
42616
|
};
|
|
42498
42617
|
const storeLookup = function (sel, createSnapshot, refresh, ttlStrategy) {
|
|
42499
42618
|
validateNotDisposed();
|
|
42500
|
-
// if this lookup is right after an ingest there will be a staging store
|
|
42501
|
-
if (
|
|
42502
|
-
const reader = new Reader(
|
|
42619
|
+
// if this lookup is right after an ingest or during a revive there will be a staging store
|
|
42620
|
+
if (stagingStore !== null) {
|
|
42621
|
+
const reader = new Reader(stagingStore, sel.variables, refresh, undefined, ttlStrategy);
|
|
42503
42622
|
return reader.read(sel);
|
|
42504
42623
|
}
|
|
42505
42624
|
// otherwise this is from buildCachedSnapshot and we should use the luvio
|
|
@@ -42508,24 +42627,24 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
42508
42627
|
};
|
|
42509
42628
|
const storeEvict = function (key) {
|
|
42510
42629
|
validateNotDisposed();
|
|
42511
|
-
if (
|
|
42512
|
-
|
|
42630
|
+
if (stagingStore === null) {
|
|
42631
|
+
stagingStore = buildIngestStagingStore(environment);
|
|
42513
42632
|
}
|
|
42514
|
-
|
|
42633
|
+
stagingStore.evict(key);
|
|
42515
42634
|
};
|
|
42516
42635
|
const getNode = function (key) {
|
|
42517
42636
|
validateNotDisposed();
|
|
42518
|
-
if (
|
|
42519
|
-
|
|
42637
|
+
if (stagingStore === null) {
|
|
42638
|
+
stagingStore = buildIngestStagingStore(environment);
|
|
42520
42639
|
}
|
|
42521
|
-
return environment.getNode(key,
|
|
42640
|
+
return environment.getNode(key, stagingStore);
|
|
42522
42641
|
};
|
|
42523
42642
|
const wrapNormalizedGraphNode = function (normalized) {
|
|
42524
42643
|
validateNotDisposed();
|
|
42525
|
-
if (
|
|
42526
|
-
|
|
42644
|
+
if (stagingStore === null) {
|
|
42645
|
+
stagingStore = buildIngestStagingStore(environment);
|
|
42527
42646
|
}
|
|
42528
|
-
return environment.wrapNormalizedGraphNode(normalized,
|
|
42647
|
+
return environment.wrapNormalizedGraphNode(normalized, stagingStore);
|
|
42529
42648
|
};
|
|
42530
42649
|
const rebuildSnapshot = function (snapshot, onRebuild) {
|
|
42531
42650
|
validateNotDisposed();
|
|
@@ -42537,7 +42656,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
42537
42656
|
return;
|
|
42538
42657
|
}
|
|
42539
42658
|
// Do an L2 revive and emit to subscriber using the callback.
|
|
42540
|
-
|
|
42659
|
+
reviveSnapshotWrapper(rebuilt, () => {
|
|
42541
42660
|
// reviveSnapshot will revive into L1, and since "records" is a reference
|
|
42542
42661
|
// (and not a copy) to the L1 records we can use it for rebuild
|
|
42543
42662
|
let rebuiltSnap;
|
|
@@ -42578,10 +42697,10 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
42578
42697
|
// the next publishChangesToDurableStore. NOTE: we don't need to call
|
|
42579
42698
|
// redirect on the base environment store because staging store and base
|
|
42580
42699
|
// L1 store share the same redirect and reverseRedirectKeys
|
|
42581
|
-
if (
|
|
42582
|
-
|
|
42700
|
+
if (stagingStore === null) {
|
|
42701
|
+
stagingStore = buildIngestStagingStore(environment);
|
|
42583
42702
|
}
|
|
42584
|
-
|
|
42703
|
+
stagingStore.redirect(existingKey, canonicalKey);
|
|
42585
42704
|
};
|
|
42586
42705
|
const storeSetTTLOverride = function (namespace, representationName, ttl) {
|
|
42587
42706
|
validateNotDisposed();
|
|
@@ -42622,7 +42741,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
42622
42741
|
if (isUnfulfilledSnapshot$1(snapshot)) {
|
|
42623
42742
|
const start = Date.now();
|
|
42624
42743
|
emitDurableEnvironmentAdapterEvent({ type: 'l2-revive-start' }, adapterRequestContext.eventObservers);
|
|
42625
|
-
const revivedSnapshot =
|
|
42744
|
+
const revivedSnapshot = reviveSnapshotWrapper(snapshot, () => injectedStoreLookup(snapshot.select, snapshot.refresh)).then((result) => {
|
|
42626
42745
|
emitDurableEnvironmentAdapterEvent({
|
|
42627
42746
|
type: 'l2-revive-end',
|
|
42628
42747
|
snapshot: result.snapshot,
|
|
@@ -42647,15 +42766,15 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
42647
42766
|
};
|
|
42648
42767
|
const getIngestStagingStoreRecords = function () {
|
|
42649
42768
|
validateNotDisposed();
|
|
42650
|
-
if (
|
|
42651
|
-
return
|
|
42769
|
+
if (stagingStore !== null) {
|
|
42770
|
+
return stagingStore.fallbackStringKeyInMemoryStore.records;
|
|
42652
42771
|
}
|
|
42653
42772
|
return {};
|
|
42654
42773
|
};
|
|
42655
42774
|
const getIngestStagingStoreMetadata = function () {
|
|
42656
42775
|
validateNotDisposed();
|
|
42657
|
-
if (
|
|
42658
|
-
return
|
|
42776
|
+
if (stagingStore !== null) {
|
|
42777
|
+
return stagingStore.fallbackStringKeyInMemoryStore.metadata;
|
|
42659
42778
|
}
|
|
42660
42779
|
return {};
|
|
42661
42780
|
};
|
|
@@ -42694,22 +42813,20 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
42694
42813
|
}
|
|
42695
42814
|
await Promise.all(pendingPromises);
|
|
42696
42815
|
const entries = await durableStore.getEntries(keysToReviveAsArray, DefaultDurableSegment);
|
|
42697
|
-
|
|
42816
|
+
stagingStore = buildIngestStagingStore(environment);
|
|
42698
42817
|
publishDurableStoreEntries(entries, (key, record) => {
|
|
42699
42818
|
if (typeof key === 'string') {
|
|
42700
|
-
|
|
42701
|
-
record;
|
|
42819
|
+
stagingStore.fallbackStringKeyInMemoryStore.records[key] = record;
|
|
42702
42820
|
}
|
|
42703
42821
|
else {
|
|
42704
|
-
|
|
42822
|
+
stagingStore.recordsMap.set(key, record);
|
|
42705
42823
|
}
|
|
42706
42824
|
}, (key, metadata) => {
|
|
42707
42825
|
if (typeof key === 'string') {
|
|
42708
|
-
|
|
42709
|
-
metadata;
|
|
42826
|
+
stagingStore.fallbackStringKeyInMemoryStore.metadata[key] = metadata;
|
|
42710
42827
|
}
|
|
42711
42828
|
else {
|
|
42712
|
-
|
|
42829
|
+
stagingStore.metadataMap.set(key, metadata);
|
|
42713
42830
|
}
|
|
42714
42831
|
});
|
|
42715
42832
|
snapshotFromMemoryIngest = await ingestAndBroadcastFunc();
|
|
@@ -42738,7 +42855,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
42738
42855
|
// we aren't doing any merging so we don't have to synchronize, the
|
|
42739
42856
|
// underlying DurableStore implementation takes care of R/W sync
|
|
42740
42857
|
// so all we have to do is ingest then write to L2
|
|
42741
|
-
|
|
42858
|
+
stagingStore = buildIngestStagingStore(environment);
|
|
42742
42859
|
snapshotFromMemoryIngest = await ingestAndBroadcastFunc();
|
|
42743
42860
|
}
|
|
42744
42861
|
if (snapshotFromMemoryIngest === undefined) {
|
|
@@ -42749,12 +42866,12 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
42749
42866
|
}
|
|
42750
42867
|
// if snapshot from staging store lookup is unfulfilled then do an L2 lookup
|
|
42751
42868
|
const { select, refresh } = snapshotFromMemoryIngest;
|
|
42752
|
-
const result = await
|
|
42869
|
+
const result = await reviveSnapshotWrapper(snapshotFromMemoryIngest, () => environment.storeLookup(select, environment.createSnapshot, refresh));
|
|
42753
42870
|
return result.snapshot;
|
|
42754
42871
|
};
|
|
42755
42872
|
const handleErrorResponse = async function (ingestAndBroadcastFunc) {
|
|
42756
42873
|
validateNotDisposed();
|
|
42757
|
-
|
|
42874
|
+
stagingStore = buildIngestStagingStore(environment);
|
|
42758
42875
|
return ingestAndBroadcastFunc();
|
|
42759
42876
|
};
|
|
42760
42877
|
const getNotifyChangeStoreEntries = function (keys) {
|
|
@@ -42805,6 +42922,27 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
42805
42922
|
await durableStore.setEntries({ notifyStoreUpdateAvailable: { data: entryKeys } }, MessagingDurableSegment);
|
|
42806
42923
|
return Promise.resolve(undefined);
|
|
42807
42924
|
};
|
|
42925
|
+
const reviveSnapshotWrapper = function (unavailableSnapshot, buildL1Snapshot) {
|
|
42926
|
+
let revivingStore = undefined;
|
|
42927
|
+
if (useRevivingStore) {
|
|
42928
|
+
// NOTE: `store` is private, there doesn't seem to be a better,
|
|
42929
|
+
// cleaner way of accessing it from a derived environment.
|
|
42930
|
+
let baseStore = environment.store;
|
|
42931
|
+
// If we're rebuilding during an ingest, the existing staging store should be the base store.
|
|
42932
|
+
if (stagingStore) {
|
|
42933
|
+
baseStore = stagingStore;
|
|
42934
|
+
}
|
|
42935
|
+
let revivingStore = buildRevivingStagingStore(baseStore);
|
|
42936
|
+
revivingStores.add(revivingStore);
|
|
42937
|
+
}
|
|
42938
|
+
return reviveSnapshot(environment, durableStore, unavailableSnapshot, durableStoreErrorHandler, () => {
|
|
42939
|
+
const tempStore = stagingStore;
|
|
42940
|
+
const result = buildL1Snapshot();
|
|
42941
|
+
stagingStore = tempStore;
|
|
42942
|
+
return result;
|
|
42943
|
+
}, revivingStore).finally(() => {
|
|
42944
|
+
});
|
|
42945
|
+
};
|
|
42808
42946
|
// set the default cache policy of the base environment
|
|
42809
42947
|
environment.setDefaultCachePolicy({
|
|
42810
42948
|
type: 'stale-while-revalidate',
|
|
@@ -42839,6 +42977,72 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
42839
42977
|
});
|
|
42840
42978
|
}
|
|
42841
42979
|
|
|
42980
|
+
/**
|
|
42981
|
+
* Copyright (c) 2022, Salesforce, Inc.,
|
|
42982
|
+
* All rights reserved.
|
|
42983
|
+
* For full license text, see the LICENSE.txt file
|
|
42984
|
+
*/
|
|
42985
|
+
|
|
42986
|
+
const API_NAMESPACE$1 = 'UiApi';
|
|
42987
|
+
const RECORD_REPRESENTATION_NAME$2 = 'RecordRepresentation';
|
|
42988
|
+
const RECORD_VIEW_ENTITY_REPRESENTATION_NAME$1 = 'RecordViewEntityRepresentation';
|
|
42989
|
+
const RECORD_ID_PREFIX$1 = `${API_NAMESPACE$1}::${RECORD_REPRESENTATION_NAME$2}:`;
|
|
42990
|
+
const RECORD_VIEW_ENTITY_ID_PREFIX$1 = `${API_NAMESPACE$1}::${RECORD_VIEW_ENTITY_REPRESENTATION_NAME$1}:Name:`;
|
|
42991
|
+
const RECORD_FIELDS_KEY_JUNCTION$1 = '__fields__';
|
|
42992
|
+
function isStoreKeyRecordId(key) {
|
|
42993
|
+
return key.indexOf(RECORD_ID_PREFIX$1) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) === -1;
|
|
42994
|
+
}
|
|
42995
|
+
function isStoreKeyRecordViewEntity$1(key) {
|
|
42996
|
+
return (key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX$1) > -1 &&
|
|
42997
|
+
key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) === -1);
|
|
42998
|
+
}
|
|
42999
|
+
function isStoreKeyRecordField(key) {
|
|
43000
|
+
return key.indexOf(RECORD_ID_PREFIX$1) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) > -1;
|
|
43001
|
+
}
|
|
43002
|
+
function extractRecordIdFromStoreKey$1(key) {
|
|
43003
|
+
if (key === undefined ||
|
|
43004
|
+
(key.indexOf(RECORD_ID_PREFIX$1) === -1 && key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX$1) === -1)) {
|
|
43005
|
+
return undefined;
|
|
43006
|
+
}
|
|
43007
|
+
const parts = key.split(':');
|
|
43008
|
+
return parts[parts.length - 1].split('_')[0];
|
|
43009
|
+
}
|
|
43010
|
+
function buildRecordFieldStoreKey(recordKey, fieldName) {
|
|
43011
|
+
return `${recordKey}${RECORD_FIELDS_KEY_JUNCTION$1}${fieldName}`;
|
|
43012
|
+
}
|
|
43013
|
+
function objectsDeepEqual(lhs, rhs) {
|
|
43014
|
+
if (lhs === rhs)
|
|
43015
|
+
return true;
|
|
43016
|
+
if (typeof lhs !== 'object' || typeof rhs !== 'object' || lhs === null || rhs === null)
|
|
43017
|
+
return false;
|
|
43018
|
+
const lhsKeys = Object.keys(lhs);
|
|
43019
|
+
const rhsKeys = Object.keys(rhs);
|
|
43020
|
+
if (lhsKeys.length !== rhsKeys.length)
|
|
43021
|
+
return false;
|
|
43022
|
+
for (let key of lhsKeys) {
|
|
43023
|
+
if (!rhsKeys.includes(key))
|
|
43024
|
+
return false;
|
|
43025
|
+
if (typeof lhs[key] === 'function' || typeof rhs[key] === 'function') {
|
|
43026
|
+
if (lhs[key].toString() !== rhs[key].toString())
|
|
43027
|
+
return false;
|
|
43028
|
+
}
|
|
43029
|
+
else {
|
|
43030
|
+
if (!objectsDeepEqual(lhs[key], rhs[key]))
|
|
43031
|
+
return false;
|
|
43032
|
+
}
|
|
43033
|
+
}
|
|
43034
|
+
return true;
|
|
43035
|
+
}
|
|
43036
|
+
|
|
43037
|
+
function isStoreRecordError(storeRecord) {
|
|
43038
|
+
return storeRecord.__type === 'error';
|
|
43039
|
+
}
|
|
43040
|
+
function isEntryDurableRecordRepresentation(entry, key) {
|
|
43041
|
+
// Either a DurableRecordRepresentation or StoreRecordError can live at a record key
|
|
43042
|
+
return ((isStoreKeyRecordId(key) || isStoreKeyRecordViewEntity$1(key)) &&
|
|
43043
|
+
entry.data.__type === undefined);
|
|
43044
|
+
}
|
|
43045
|
+
|
|
42842
43046
|
/**
|
|
42843
43047
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
42844
43048
|
* All rights reserved.
|
|
@@ -43223,7 +43427,7 @@ function isFailure(result) {
|
|
|
43223
43427
|
function errors(result) {
|
|
43224
43428
|
return result.error;
|
|
43225
43429
|
}
|
|
43226
|
-
function values$
|
|
43430
|
+
function values$4(result) {
|
|
43227
43431
|
return result.value;
|
|
43228
43432
|
}
|
|
43229
43433
|
function flattenResults(results) {
|
|
@@ -43231,7 +43435,7 @@ function flattenResults(results) {
|
|
|
43231
43435
|
if (fails.length > 0) {
|
|
43232
43436
|
return failure(fails);
|
|
43233
43437
|
}
|
|
43234
|
-
return success(results.filter(isSuccess).map(values$
|
|
43438
|
+
return success(results.filter(isSuccess).map(values$4));
|
|
43235
43439
|
}
|
|
43236
43440
|
|
|
43237
43441
|
function getFieldInfo(apiName, fieldName, infoMap) {
|
|
@@ -44117,7 +44321,7 @@ function fieldsToFilters(fieldValues, joinAlias, apiName, input, compoundOperato
|
|
|
44117
44321
|
if (failures.length > 0) {
|
|
44118
44322
|
return failure(failures);
|
|
44119
44323
|
}
|
|
44120
|
-
const containers = results.filter(isSuccess).map(values$
|
|
44324
|
+
const containers = results.filter(isSuccess).map(values$4);
|
|
44121
44325
|
const predicates = [];
|
|
44122
44326
|
containers.forEach((c) => {
|
|
44123
44327
|
if (c.predicate !== undefined) {
|
|
@@ -44409,7 +44613,7 @@ function dateFunctions(operatorNode, extract, dataType) {
|
|
|
44409
44613
|
if (fails.length > 0) {
|
|
44410
44614
|
return failure(fails);
|
|
44411
44615
|
}
|
|
44412
|
-
const vals = results.filter(isSuccess).reduce(flatMap$1(values$
|
|
44616
|
+
const vals = results.filter(isSuccess).reduce(flatMap$1(values$4), []);
|
|
44413
44617
|
return success(vals);
|
|
44414
44618
|
}
|
|
44415
44619
|
function isFilterFunction(name) {
|
|
@@ -44419,7 +44623,7 @@ function fieldOperators(operatorNode, dataType) {
|
|
|
44419
44623
|
const results = Object.entries(operatorNode.fields)
|
|
44420
44624
|
.filter(([key, _]) => isFilterFunction(key) === false)
|
|
44421
44625
|
.map(([key, value]) => operatorWithValue(key, value, dataType));
|
|
44422
|
-
const _values = results.filter(isSuccess).map(values$
|
|
44626
|
+
const _values = results.filter(isSuccess).map(values$4);
|
|
44423
44627
|
const fails = results.filter(isFailure).reduce(flatMap$1(errors), []);
|
|
44424
44628
|
if (fails.length > 0) {
|
|
44425
44629
|
return failure(fails);
|
|
@@ -45340,7 +45544,7 @@ function selectionToQueryField(node, names, parentApiName, parentAlias, input, j
|
|
|
45340
45544
|
}
|
|
45341
45545
|
function recordFields(luvioSelections, names, parentApiName, parentAlias, input, joins) {
|
|
45342
45546
|
const results = luvioSelections.map((selection) => selectionToQueryField(selection, names, parentApiName, parentAlias, input, joins));
|
|
45343
|
-
const fields = results.filter(isSuccess).reduce(flatMap$1(values$
|
|
45547
|
+
const fields = results.filter(isSuccess).reduce(flatMap$1(values$4), []);
|
|
45344
45548
|
const fails = results.filter(isFailure).reduce(flatMap$1(errors), []);
|
|
45345
45549
|
if (fails.length > 0) {
|
|
45346
45550
|
return failure(fails);
|
|
@@ -45586,7 +45790,7 @@ function rootRecordQuery(selection, input) {
|
|
|
45586
45790
|
}
|
|
45587
45791
|
function rootQuery(recordNodes, input) {
|
|
45588
45792
|
const results = recordNodes.map((record) => rootRecordQuery(record, input));
|
|
45589
|
-
const connections = results.filter(isSuccess).map(values$
|
|
45793
|
+
const connections = results.filter(isSuccess).map(values$4);
|
|
45590
45794
|
const fails = results.filter(isFailure).reduce(flatMap$1(errors), []);
|
|
45591
45795
|
if (fails.length > 0) {
|
|
45592
45796
|
return failure(fails);
|
|
@@ -46037,7 +46241,11 @@ function makeStoreEval(preconditioner, objectInfoService, userId, contextProvide
|
|
|
46037
46241
|
try {
|
|
46038
46242
|
const { data, seenRecords } = await queryEvaluator(rootQuery, context, eventEmitter);
|
|
46039
46243
|
const rebuildWithStoreEval = ((originalSnapshot) => {
|
|
46040
|
-
return storeEval(config, originalSnapshot, observers, connectionKeyBuilder)
|
|
46244
|
+
return storeEval(config, originalSnapshot, observers, connectionKeyBuilder).then((rebuiltSnapshot) => {
|
|
46245
|
+
return objectsDeepEqual(originalSnapshot.data, rebuiltSnapshot.data)
|
|
46246
|
+
? originalSnapshot
|
|
46247
|
+
: rebuiltSnapshot;
|
|
46248
|
+
});
|
|
46041
46249
|
});
|
|
46042
46250
|
const recordId = generateUniqueRecordId$1();
|
|
46043
46251
|
// if the non-eval'ed snapshot was an error then we return a synthetic
|
|
@@ -46340,7 +46548,7 @@ function createDraftSynthesisErrorResponse(message = 'failed to synthesize draft
|
|
|
46340
46548
|
return new DraftErrorFetchResponse(HttpStatusCode$1.BadRequest, error);
|
|
46341
46549
|
}
|
|
46342
46550
|
|
|
46343
|
-
const { keys: keys$5, create: create$5, assign: assign$5, values: values$
|
|
46551
|
+
const { keys: keys$5, create: create$5, assign: assign$5, values: values$3 } = Object;
|
|
46344
46552
|
const { stringify: stringify$5, parse: parse$5 } = JSON;
|
|
46345
46553
|
const { isArray: isArray$3 } = Array;
|
|
46346
46554
|
|
|
@@ -46775,7 +46983,7 @@ class DurableDraftQueue {
|
|
|
46775
46983
|
const queueOperations = handler.getQueueOperationsForCompletingDrafts(queue, action);
|
|
46776
46984
|
// write the queue operations to the store prior to ingesting the result
|
|
46777
46985
|
await this.draftStore.completeAction(queueOperations);
|
|
46778
|
-
await handler.handleActionCompleted(action, queueOperations, values$
|
|
46986
|
+
await handler.handleActionCompleted(action, queueOperations, values$3(this.handlers));
|
|
46779
46987
|
this.retryIntervalMilliseconds = 0;
|
|
46780
46988
|
this.uploadingActionId = undefined;
|
|
46781
46989
|
await this.notifyChangedListeners({
|
|
@@ -47983,49 +48191,6 @@ function makeEnvironmentDraftAware(luvio, env, durableStore, handlers, draftQueu
|
|
|
47983
48191
|
});
|
|
47984
48192
|
}
|
|
47985
48193
|
|
|
47986
|
-
/**
|
|
47987
|
-
* Copyright (c) 2022, Salesforce, Inc.,
|
|
47988
|
-
* All rights reserved.
|
|
47989
|
-
* For full license text, see the LICENSE.txt file
|
|
47990
|
-
*/
|
|
47991
|
-
|
|
47992
|
-
const API_NAMESPACE$1 = 'UiApi';
|
|
47993
|
-
const RECORD_REPRESENTATION_NAME$2 = 'RecordRepresentation';
|
|
47994
|
-
const RECORD_VIEW_ENTITY_REPRESENTATION_NAME$1 = 'RecordViewEntityRepresentation';
|
|
47995
|
-
const RECORD_ID_PREFIX$1 = `${API_NAMESPACE$1}::${RECORD_REPRESENTATION_NAME$2}:`;
|
|
47996
|
-
const RECORD_VIEW_ENTITY_ID_PREFIX$1 = `${API_NAMESPACE$1}::${RECORD_VIEW_ENTITY_REPRESENTATION_NAME$1}:Name:`;
|
|
47997
|
-
const RECORD_FIELDS_KEY_JUNCTION$1 = '__fields__';
|
|
47998
|
-
function isStoreKeyRecordId(key) {
|
|
47999
|
-
return key.indexOf(RECORD_ID_PREFIX$1) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) === -1;
|
|
48000
|
-
}
|
|
48001
|
-
function isStoreKeyRecordViewEntity$1(key) {
|
|
48002
|
-
return (key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX$1) > -1 &&
|
|
48003
|
-
key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) === -1);
|
|
48004
|
-
}
|
|
48005
|
-
function isStoreKeyRecordField(key) {
|
|
48006
|
-
return key.indexOf(RECORD_ID_PREFIX$1) > -1 && key.indexOf(RECORD_FIELDS_KEY_JUNCTION$1) > -1;
|
|
48007
|
-
}
|
|
48008
|
-
function extractRecordIdFromStoreKey$1(key) {
|
|
48009
|
-
if (key === undefined ||
|
|
48010
|
-
(key.indexOf(RECORD_ID_PREFIX$1) === -1 && key.indexOf(RECORD_VIEW_ENTITY_ID_PREFIX$1) === -1)) {
|
|
48011
|
-
return undefined;
|
|
48012
|
-
}
|
|
48013
|
-
const parts = key.split(':');
|
|
48014
|
-
return parts[parts.length - 1].split('_')[0];
|
|
48015
|
-
}
|
|
48016
|
-
function buildRecordFieldStoreKey(recordKey, fieldName) {
|
|
48017
|
-
return `${recordKey}${RECORD_FIELDS_KEY_JUNCTION$1}${fieldName}`;
|
|
48018
|
-
}
|
|
48019
|
-
|
|
48020
|
-
function isStoreRecordError(storeRecord) {
|
|
48021
|
-
return storeRecord.__type === 'error';
|
|
48022
|
-
}
|
|
48023
|
-
function isEntryDurableRecordRepresentation(entry, key) {
|
|
48024
|
-
// Either a DurableRecordRepresentation or StoreRecordError can live at a record key
|
|
48025
|
-
return ((isStoreKeyRecordId(key) || isStoreKeyRecordViewEntity$1(key)) &&
|
|
48026
|
-
entry.data.__type === undefined);
|
|
48027
|
-
}
|
|
48028
|
-
|
|
48029
48194
|
function serializeFieldArguments$1(argumentNodes, variables) {
|
|
48030
48195
|
const mutableArgumentNodes = Object.assign([], argumentNodes);
|
|
48031
48196
|
return `args__(${mutableArgumentNodes
|
|
@@ -48257,7 +48422,7 @@ function isArrayLike(x) {
|
|
|
48257
48422
|
(x.length === 0 || (x.length > 0 && Object.prototype.hasOwnProperty.call(x, x.length - 1))));
|
|
48258
48423
|
}
|
|
48259
48424
|
|
|
48260
|
-
const { create: create$4, keys: keys$4, values: values$
|
|
48425
|
+
const { create: create$4, keys: keys$4, values: values$2, entries: entries$3, assign: assign$4 } = Object;
|
|
48261
48426
|
const { stringify: stringify$4, parse: parse$4 } = JSON;
|
|
48262
48427
|
const { isArray: isArray$2$1 } = Array;
|
|
48263
48428
|
|
|
@@ -48590,7 +48755,7 @@ function dateTimePredicate(input, operator, field, alias) {
|
|
|
48590
48755
|
return predicate;
|
|
48591
48756
|
}
|
|
48592
48757
|
else if (literal !== undefined) {
|
|
48593
|
-
const isAvailableLiteral = values$
|
|
48758
|
+
const isAvailableLiteral = values$2(DateLiteral).includes(literal);
|
|
48594
48759
|
// eslint-disable-next-line @salesforce/lds/no-error-in-production
|
|
48595
48760
|
if (!isAvailableLiteral)
|
|
48596
48761
|
throw new Error(`${literal} is not a valid DateLiteral`);
|
|
@@ -49264,7 +49429,7 @@ function dedupeJoins(joins) {
|
|
|
49264
49429
|
for (const join of joins) {
|
|
49265
49430
|
deduped[join.alias + join.to] = join;
|
|
49266
49431
|
}
|
|
49267
|
-
return values$
|
|
49432
|
+
return values$2(deduped);
|
|
49268
49433
|
}
|
|
49269
49434
|
function buildJoins(config) {
|
|
49270
49435
|
let sql = '';
|
|
@@ -49912,7 +50077,7 @@ function flatten(previous, current) {
|
|
|
49912
50077
|
return previous.concat(current);
|
|
49913
50078
|
}
|
|
49914
50079
|
function findFieldInfo(objectInfo, fieldName) {
|
|
49915
|
-
return values$
|
|
50080
|
+
return values$2(objectInfo.fields).find((field) => field.apiName === fieldName ||
|
|
49916
50081
|
(field.dataType === 'Reference' && field.relationshipName === fieldName));
|
|
49917
50082
|
}
|
|
49918
50083
|
|
|
@@ -49932,10 +50097,10 @@ function orderByToPredicate(orderBy, recordType, alias, objectInfoMap, joins) {
|
|
|
49932
50097
|
for (let i = 0, len = keys$1.length; i < len; i++) {
|
|
49933
50098
|
const key = keys$1[i];
|
|
49934
50099
|
const parentFields = objectInfoMap[recordType].fields;
|
|
49935
|
-
const fieldInfo = values$
|
|
50100
|
+
const fieldInfo = values$2(parentFields).find(findSpanningField(key));
|
|
49936
50101
|
if (fieldInfo && fieldInfo.referenceToInfos.length > 0) {
|
|
49937
50102
|
const { apiName } = fieldInfo.referenceToInfos[0];
|
|
49938
|
-
const parentFieldInfo = values$
|
|
50103
|
+
const parentFieldInfo = values$2(objectInfoMap[recordType].fields).find(findSpanningField(fieldInfo.apiName));
|
|
49939
50104
|
if (parentFieldInfo !== undefined) {
|
|
49940
50105
|
const path = {
|
|
49941
50106
|
leftPath: `$.fields.${parentFieldInfo.apiName}.value`,
|
|
@@ -50077,7 +50242,7 @@ function addResolversToSchema(schema, polyFields) {
|
|
|
50077
50242
|
let baseRecord = undefined;
|
|
50078
50243
|
// Concrete types for Polymorphic field
|
|
50079
50244
|
const polyTypes = [];
|
|
50080
|
-
for (const type of values$
|
|
50245
|
+
for (const type of values$2(schema.getTypeMap())) {
|
|
50081
50246
|
if (type.name === 'Record') {
|
|
50082
50247
|
recordInterface = type;
|
|
50083
50248
|
}
|
|
@@ -50090,7 +50255,7 @@ function addResolversToSchema(schema, polyFields) {
|
|
|
50090
50255
|
if (polyFields.find((fieldTypeName) => fieldTypeName === type.name) !== undefined) {
|
|
50091
50256
|
polyTypes.push(type);
|
|
50092
50257
|
}
|
|
50093
|
-
const fields = values$
|
|
50258
|
+
const fields = values$2(type.getFields());
|
|
50094
50259
|
// initialize the fields of current type with default behavior
|
|
50095
50260
|
for (const field of fields) {
|
|
50096
50261
|
field.resolve = defaultFieldResolver;
|
|
@@ -50492,26 +50657,20 @@ function generateRecordQueries(objectInfos) {
|
|
|
50492
50657
|
let recordConnections = ``;
|
|
50493
50658
|
const polymorphicFieldTypeNames = new Set();
|
|
50494
50659
|
let typedScalars = new Set();
|
|
50495
|
-
|
|
50660
|
+
let parentRelationshipFields = new Set();
|
|
50661
|
+
for (const objectInfo of values$2(objectInfos)) {
|
|
50496
50662
|
const { apiName, childRelationships } = objectInfo;
|
|
50497
50663
|
let fields = ``;
|
|
50498
50664
|
typedScalars.add(`${apiName}_Filter`);
|
|
50499
50665
|
typedScalars.add(`${apiName}_OrderBy`);
|
|
50500
|
-
for (const
|
|
50501
|
-
const { childObjectApiName } = childRelationship;
|
|
50502
|
-
// Only add the relationship if there is relevant objectinfos for it,
|
|
50503
|
-
// otherwise we'd be defining types we cannot satisfy and aren't referenced in
|
|
50504
|
-
// the query.
|
|
50505
|
-
if (objectInfos[childObjectApiName] !== undefined) {
|
|
50506
|
-
fields += `${childRelationship.relationshipName}(first: Int, where: ${childObjectApiName}_Filter, orderBy: ${childObjectApiName}_OrderBy, scope: SupportedScopes): ${childObjectApiName}Connection \n`;
|
|
50507
|
-
typedScalars.add(`${childObjectApiName}_Filter`);
|
|
50508
|
-
typedScalars.add(`${childObjectApiName}_OrderBy`);
|
|
50509
|
-
}
|
|
50510
|
-
}
|
|
50511
|
-
for (const field of values$1(objectInfo.fields)) {
|
|
50666
|
+
for (const field of values$2(objectInfo.fields)) {
|
|
50512
50667
|
if (!fieldsStaticallyAdded.includes(field.apiName)) {
|
|
50513
50668
|
fields += `${field.apiName}: ${dataTypeToType(field.dataType, field.apiName)}\n`;
|
|
50514
50669
|
}
|
|
50670
|
+
//handles parent relationship
|
|
50671
|
+
if (field.relationshipName === null) {
|
|
50672
|
+
continue;
|
|
50673
|
+
}
|
|
50515
50674
|
// For spanning parent relationships with no union types
|
|
50516
50675
|
if (field.referenceToInfos.length === 1) {
|
|
50517
50676
|
const [relation] = field.referenceToInfos;
|
|
@@ -50519,11 +50678,13 @@ function generateRecordQueries(objectInfos) {
|
|
|
50519
50678
|
// otherwise we'd be defining types we cannot satisfy and aren't referenced in
|
|
50520
50679
|
// the query.
|
|
50521
50680
|
if (objectInfos[relation.apiName] !== undefined) {
|
|
50681
|
+
parentRelationshipFields.add(field.relationshipName);
|
|
50522
50682
|
fields += `${field.relationshipName}: ${relation.apiName}\n`;
|
|
50523
50683
|
}
|
|
50524
50684
|
// For polymorphic field, its type is 'Record' inteface. The concrete entity type name is saved for field resolving of next phase
|
|
50525
50685
|
}
|
|
50526
50686
|
else if (field.referenceToInfos.length > 1) {
|
|
50687
|
+
parentRelationshipFields.add(field.relationshipName);
|
|
50527
50688
|
fields += `${field.relationshipName}: Record\n`;
|
|
50528
50689
|
for (const relation of field.referenceToInfos) {
|
|
50529
50690
|
if (objectInfos[relation.apiName] !== undefined) {
|
|
@@ -50532,6 +50693,20 @@ function generateRecordQueries(objectInfos) {
|
|
|
50532
50693
|
}
|
|
50533
50694
|
}
|
|
50534
50695
|
}
|
|
50696
|
+
// handles child relationship
|
|
50697
|
+
for (const childRelationship of childRelationships) {
|
|
50698
|
+
const { childObjectApiName } = childRelationship;
|
|
50699
|
+
// Only add the relationship if there is relevant objectinfos for it,
|
|
50700
|
+
// otherwise we'd be defining types we cannot satisfy and aren't referenced in
|
|
50701
|
+
// the query.
|
|
50702
|
+
// If one field has both parent relationship and child relationship with the same name, the child relationship is ignored. This is how the server GQL has implemented as date of 08/07/2023
|
|
50703
|
+
if (objectInfos[childObjectApiName] !== undefined &&
|
|
50704
|
+
!parentRelationshipFields.has(childRelationship.relationshipName)) {
|
|
50705
|
+
fields += `${childRelationship.relationshipName}(first: Int, where: ${childObjectApiName}_Filter, orderBy: ${childObjectApiName}_OrderBy, scope: SupportedScopes): ${childObjectApiName}Connection \n`;
|
|
50706
|
+
typedScalars.add(`${childObjectApiName}_Filter`);
|
|
50707
|
+
typedScalars.add(`${childObjectApiName}_OrderBy`);
|
|
50708
|
+
}
|
|
50709
|
+
}
|
|
50535
50710
|
recordQueries += `${apiName}(first: Int, where: ${apiName}_Filter, orderBy: ${apiName}_OrderBy, scope: SupportedScopes): ${apiName}Connection\n`;
|
|
50536
50711
|
const isServiceAppointment = apiName === 'ServiceAppointment';
|
|
50537
50712
|
recordConnections += /* GraphQL */ `
|
|
@@ -51011,7 +51186,7 @@ function isMineScopeAvailable(apiNamePath, objectInfoApiMap, objectInfos) {
|
|
|
51011
51186
|
const objectInfo = objectInfos[apiName[0]];
|
|
51012
51187
|
if (!objectInfo)
|
|
51013
51188
|
return false;
|
|
51014
|
-
return values$
|
|
51189
|
+
return values$2(objectInfo.fields).some((fieldInfo) => {
|
|
51015
51190
|
return (fieldInfo.apiName === 'OwnerId' &&
|
|
51016
51191
|
fieldInfo.referenceToInfos.some((referenceToInfo) => {
|
|
51017
51192
|
return referenceToInfo.apiName === 'User';
|
|
@@ -52262,7 +52437,7 @@ function referenceIdFieldForRelationship(relationshipName) {
|
|
|
52262
52437
|
* For full license text, see the LICENSE.txt file
|
|
52263
52438
|
*/
|
|
52264
52439
|
|
|
52265
|
-
const { keys: keys$3, values, create: create$3, assign: assign$3, freeze: freeze$2 } = Object;
|
|
52440
|
+
const { keys: keys$3, values: values$1, create: create$3, assign: assign$3, freeze: freeze$2 } = Object;
|
|
52266
52441
|
const { stringify: stringify$3, parse: parse$3 } = JSON;
|
|
52267
52442
|
const { shift } = Array.prototype;
|
|
52268
52443
|
const { isArray: isArray$1$1 } = Array;
|
|
@@ -53112,7 +53287,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
|
|
|
53112
53287
|
return;
|
|
53113
53288
|
}
|
|
53114
53289
|
const objectInfo = objectInfoMap[apiName];
|
|
53115
|
-
const optionalFields = values(objectInfo.fields).map((field) => `${apiName}.${field.apiName}`);
|
|
53290
|
+
const optionalFields = values$1(objectInfo.fields).map((field) => `${apiName}.${field.apiName}`);
|
|
53116
53291
|
await getAdapterData(this.getRecordAdapter, {
|
|
53117
53292
|
recordId: referenceFieldInfo.id,
|
|
53118
53293
|
optionalFields,
|
|
@@ -53131,7 +53306,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
|
|
|
53131
53306
|
const referenceToInfos = fieldInfo.referenceToInfos;
|
|
53132
53307
|
const apiNames = referenceToInfos.map((referenceToInfo) => referenceToInfo.apiName);
|
|
53133
53308
|
const objectInfoMap = await this.objectInfoService.getObjectInfos(apiNames);
|
|
53134
|
-
for (const objectInfo of values(objectInfoMap)) {
|
|
53309
|
+
for (const objectInfo of values$1(objectInfoMap)) {
|
|
53135
53310
|
const { apiName, keyPrefix } = objectInfo;
|
|
53136
53311
|
if (keyPrefix !== null && id.startsWith(keyPrefix)) {
|
|
53137
53312
|
return apiName;
|
|
@@ -53641,14 +53816,30 @@ function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecord
|
|
|
53641
53816
|
const operationsWithDenormedRecords = [];
|
|
53642
53817
|
for (let i = 0, len = operations.length; i < len; i++) {
|
|
53643
53818
|
const operation = operations[i];
|
|
53644
|
-
if (
|
|
53645
|
-
|
|
53646
|
-
|
|
53819
|
+
if (durableStore.plugin !== undefined &&
|
|
53820
|
+
durableStore.plugin.supportsBatchUpdates !== undefined &&
|
|
53821
|
+
durableStore.plugin.supportsBatchUpdates() === true) {
|
|
53822
|
+
if (operation.segment !== DefaultDurableSegment ||
|
|
53823
|
+
operation.type !== 'setEntries') {
|
|
53824
|
+
operationsWithDenormedRecords.push(operation);
|
|
53825
|
+
continue;
|
|
53826
|
+
}
|
|
53827
|
+
operationsWithDenormedRecords.push({
|
|
53828
|
+
...operation,
|
|
53829
|
+
entries: denormalizeEntries(operation.entries),
|
|
53830
|
+
});
|
|
53831
|
+
}
|
|
53832
|
+
else {
|
|
53833
|
+
if (operation.segment !== DefaultDurableSegment ||
|
|
53834
|
+
operation.type === 'evictEntries') {
|
|
53835
|
+
operationsWithDenormedRecords.push(operation);
|
|
53836
|
+
continue;
|
|
53837
|
+
}
|
|
53838
|
+
operationsWithDenormedRecords.push({
|
|
53839
|
+
...operation,
|
|
53840
|
+
entries: denormalizeEntries(operation.entries),
|
|
53841
|
+
});
|
|
53647
53842
|
}
|
|
53648
|
-
operationsWithDenormedRecords.push({
|
|
53649
|
-
...operation,
|
|
53650
|
-
entries: denormalizeEntries(operation.entries),
|
|
53651
|
-
});
|
|
53652
53843
|
}
|
|
53653
53844
|
return durableStore.batchOperations(operationsWithDenormedRecords);
|
|
53654
53845
|
};
|
|
@@ -54196,6 +54387,9 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
|
|
|
54196
54387
|
if (!rebuildResult.errors) {
|
|
54197
54388
|
rebuildResult = removeSyntheticFields(rebuildResult, config.query);
|
|
54198
54389
|
}
|
|
54390
|
+
if (objectsDeepEqual(rebuildResult, originalSnapshot.data)) {
|
|
54391
|
+
return originalSnapshot;
|
|
54392
|
+
}
|
|
54199
54393
|
// 'originalSnapshot' is the local eval snapshot subscribed. It is always in 'Fulfilled' state. This behavior would change once W-1273462(rebuild non-evaluated snapshot when the graphql local eval rebuild is triggered) is resolved.
|
|
54200
54394
|
return {
|
|
54201
54395
|
...originalSnapshot,
|
|
@@ -56227,7 +56421,7 @@ function registerReportObserver(reportObserver) {
|
|
|
56227
56421
|
};
|
|
56228
56422
|
}
|
|
56229
56423
|
|
|
56230
|
-
const { keys: keys$9, create: create$7, assign: assign$7, entries } = Object;
|
|
56424
|
+
const { keys: keys$9, create: create$7, assign: assign$7, entries, values } = Object;
|
|
56231
56425
|
const { stringify: stringify$7, parse: parse$7 } = JSON;
|
|
56232
56426
|
|
|
56233
56427
|
function selectColumnsFromTableWhereKeyIn(columnNames, table, keyColumnName, whereIn) {
|
|
@@ -56261,6 +56455,22 @@ class LdsDataTable {
|
|
|
56261
56455
|
}, reject);
|
|
56262
56456
|
});
|
|
56263
56457
|
}
|
|
56458
|
+
getMetadataByKeys(keys) {
|
|
56459
|
+
const query = selectColumnsFromTableWhereKeyIn([COLUMN_NAME_KEY$2, COLUMN_NAME_METADATA$1], this.tableName, COLUMN_NAME_KEY$2, keys);
|
|
56460
|
+
return new Promise((resolve, reject) => {
|
|
56461
|
+
this.plugin.query(query, keys, (results) => {
|
|
56462
|
+
resolve(results.rows.reduce((entries, row) => {
|
|
56463
|
+
const [key, stringifiedMetadata] = row;
|
|
56464
|
+
if (stringifiedMetadata !== undefined) {
|
|
56465
|
+
entries[key] = {
|
|
56466
|
+
metadata: parse$7(stringifiedMetadata),
|
|
56467
|
+
};
|
|
56468
|
+
}
|
|
56469
|
+
return entries;
|
|
56470
|
+
}, {}));
|
|
56471
|
+
}, reject);
|
|
56472
|
+
});
|
|
56473
|
+
}
|
|
56264
56474
|
getAll() {
|
|
56265
56475
|
return new Promise((resolve, reject) => {
|
|
56266
56476
|
this.plugin.query(this.getAllQuery, [], (x) => {
|
|
@@ -56287,6 +56497,24 @@ class LdsDataTable {
|
|
|
56287
56497
|
}, []),
|
|
56288
56498
|
};
|
|
56289
56499
|
}
|
|
56500
|
+
metadataToUpdateOperations(entries, segment) {
|
|
56501
|
+
return {
|
|
56502
|
+
type: 'update',
|
|
56503
|
+
table: this.tableName,
|
|
56504
|
+
keyColumn: COLUMN_NAME_KEY$2,
|
|
56505
|
+
context: {
|
|
56506
|
+
segment,
|
|
56507
|
+
type: 'setMetadata',
|
|
56508
|
+
},
|
|
56509
|
+
columns: [COLUMN_NAME_METADATA$1],
|
|
56510
|
+
values: keys$9(entries).reduce((values, key) => {
|
|
56511
|
+
const { metadata } = entries[key];
|
|
56512
|
+
const row = [metadata ? stringify$7(metadata) : null];
|
|
56513
|
+
values[key] = row;
|
|
56514
|
+
return values;
|
|
56515
|
+
}, {}),
|
|
56516
|
+
};
|
|
56517
|
+
}
|
|
56290
56518
|
mapToDurableEntries(sqliteResult) {
|
|
56291
56519
|
return sqliteResult.rows.reduce((entries, row) => {
|
|
56292
56520
|
const [key, stringifiedData, stringifiedMetadata] = row;
|
|
@@ -56333,6 +56561,25 @@ class LdsInternalDataTable {
|
|
|
56333
56561
|
}, reject);
|
|
56334
56562
|
});
|
|
56335
56563
|
}
|
|
56564
|
+
getMetadataByKeys(keys, namespace) {
|
|
56565
|
+
if (namespace === undefined) {
|
|
56566
|
+
throw Error('LdsInternalDataTable requires namespace');
|
|
56567
|
+
}
|
|
56568
|
+
const query = selectColumnsFromTableWhereKeyInNamespaced([COLUMN_NAME_KEY$1, COLUMN_NAME_METADATA], this.tableName, COLUMN_NAME_KEY$1, keys, COLUMN_NAME_NAMESPACE);
|
|
56569
|
+
return new Promise((resolve, reject) => {
|
|
56570
|
+
this.plugin.query(query, [namespace].concat(keys), (results) => {
|
|
56571
|
+
resolve(results.rows.reduce((entries, row) => {
|
|
56572
|
+
const [key, stringifiedMetadata] = row;
|
|
56573
|
+
if (stringifiedMetadata !== undefined) {
|
|
56574
|
+
entries[key] = {
|
|
56575
|
+
metadata: parse$7(stringifiedMetadata),
|
|
56576
|
+
};
|
|
56577
|
+
}
|
|
56578
|
+
return entries;
|
|
56579
|
+
}, {}));
|
|
56580
|
+
}, reject);
|
|
56581
|
+
});
|
|
56582
|
+
}
|
|
56336
56583
|
getAll(namespace) {
|
|
56337
56584
|
return new Promise((resolve, reject) => {
|
|
56338
56585
|
this.plugin.query(this.getAllQuery, [namespace], (x) => {
|
|
@@ -56366,6 +56613,42 @@ class LdsInternalDataTable {
|
|
|
56366
56613
|
}, []),
|
|
56367
56614
|
};
|
|
56368
56615
|
}
|
|
56616
|
+
metadataToUpdateOperations(entries, segment) {
|
|
56617
|
+
return {
|
|
56618
|
+
type: 'update',
|
|
56619
|
+
table: this.tableName,
|
|
56620
|
+
keyColumn: COLUMN_NAME_KEY$1,
|
|
56621
|
+
context: {
|
|
56622
|
+
segment,
|
|
56623
|
+
type: 'setMetadata',
|
|
56624
|
+
},
|
|
56625
|
+
columns: [COLUMN_NAME_METADATA],
|
|
56626
|
+
values: keys$9(entries).reduce((values, key) => {
|
|
56627
|
+
const { metadata } = entries[key];
|
|
56628
|
+
const row = [metadata ? stringify$7(metadata) : null];
|
|
56629
|
+
values[key] = row;
|
|
56630
|
+
return values;
|
|
56631
|
+
}, {}),
|
|
56632
|
+
};
|
|
56633
|
+
}
|
|
56634
|
+
metadataToUpdateSQLQueries(entries, segment) {
|
|
56635
|
+
return keys$9(entries).reduce((accu, key) => {
|
|
56636
|
+
const { metadata } = entries[key];
|
|
56637
|
+
if (metadata !== undefined) {
|
|
56638
|
+
accu.push({
|
|
56639
|
+
sql: `UPDATE ${this.tableName} SET ${COLUMN_NAME_METADATA} = ? WHERE (${COLUMN_NAME_KEY$1} IS ? AND ${COLUMN_NAME_NAMESPACE} IS ?)`,
|
|
56640
|
+
params: [stringify$7(metadata), key, segment],
|
|
56641
|
+
change: {
|
|
56642
|
+
ids: [key],
|
|
56643
|
+
segment,
|
|
56644
|
+
type: 'setMetadata',
|
|
56645
|
+
isExternalChange: false,
|
|
56646
|
+
},
|
|
56647
|
+
});
|
|
56648
|
+
}
|
|
56649
|
+
return accu;
|
|
56650
|
+
}, []);
|
|
56651
|
+
}
|
|
56369
56652
|
mapToDurableEntries(sqliteResult) {
|
|
56370
56653
|
return sqliteResult.rows.reduce((entries, row) => {
|
|
56371
56654
|
const [key, stringifiedData, stringifiedMetadata] = row;
|
|
@@ -56402,9 +56685,16 @@ class NimbusSqliteStore {
|
|
|
56402
56685
|
});
|
|
56403
56686
|
});
|
|
56404
56687
|
}
|
|
56688
|
+
batchQuery(queries) {
|
|
56689
|
+
const promises = queries.map((q) => this.query(q.sql, q.params));
|
|
56690
|
+
return Promise.all(promises);
|
|
56691
|
+
}
|
|
56405
56692
|
async getEntries(entryIds, segment) {
|
|
56406
56693
|
return this.getTable(segment).getByKeys(entryIds, segment);
|
|
56407
56694
|
}
|
|
56695
|
+
async getMetadata(entryIds, segment) {
|
|
56696
|
+
return this.getTable(segment).getMetadataByKeys(entryIds, segment);
|
|
56697
|
+
}
|
|
56408
56698
|
getAllEntries(segment) {
|
|
56409
56699
|
return this.getTable(segment).getAll(segment);
|
|
56410
56700
|
}
|
|
@@ -56413,12 +56703,30 @@ class NimbusSqliteStore {
|
|
|
56413
56703
|
const upsertOperation = table.entriesToUpsertOperations(entries, segment);
|
|
56414
56704
|
return this.batchOperationAsPromise([upsertOperation]);
|
|
56415
56705
|
}
|
|
56706
|
+
setMetadata(entries, segment) {
|
|
56707
|
+
const table = this.getTable(segment);
|
|
56708
|
+
const operation = this.plugin.supportsBatchUpdates === undefined ||
|
|
56709
|
+
this.plugin.supportsBatchUpdates() === false
|
|
56710
|
+
? table.entriesToUpsertOperations(entries, segment)
|
|
56711
|
+
: table.metadataToUpdateOperations(entries, segment);
|
|
56712
|
+
return this.batchOperationAsPromise([operation]);
|
|
56713
|
+
}
|
|
56416
56714
|
batchOperations(operations) {
|
|
56417
56715
|
const sqliteOperations = operations.reduce((acc, cur) => {
|
|
56418
56716
|
if (cur.type === 'setEntries') {
|
|
56419
56717
|
const table = this.getTable(cur.segment);
|
|
56420
56718
|
acc.push(table.entriesToUpsertOperations(cur.entries, cur.segment));
|
|
56421
56719
|
}
|
|
56720
|
+
else if (cur.type === 'setMetadata') {
|
|
56721
|
+
const table = this.getTable(cur.segment);
|
|
56722
|
+
if (this.plugin.supportsBatchUpdates === undefined ||
|
|
56723
|
+
this.plugin.supportsBatchUpdates() === false) {
|
|
56724
|
+
acc.push(table.entriesToUpsertOperations(cur.entries, cur.segment));
|
|
56725
|
+
}
|
|
56726
|
+
else {
|
|
56727
|
+
acc.push(table.metadataToUpdateOperations(cur.entries, cur.segment));
|
|
56728
|
+
}
|
|
56729
|
+
}
|
|
56422
56730
|
else {
|
|
56423
56731
|
acc.push(this.idsToDeleteOperation(cur.ids, cur.segment));
|
|
56424
56732
|
}
|
|
@@ -56435,8 +56743,15 @@ class NimbusSqliteStore {
|
|
|
56435
56743
|
this.plugin
|
|
56436
56744
|
.registerOnChangedListener(async (changes) => {
|
|
56437
56745
|
const durableChanges = changes.map((c) => {
|
|
56746
|
+
let type = c.type === 'upsert' ? 'setEntries' : 'evictEntries';
|
|
56747
|
+
// if our context contains a type then set that as our main level type
|
|
56748
|
+
// allows us in the future of updates to specify the segment change happening
|
|
56749
|
+
// example being update call on metadata only or updating data
|
|
56750
|
+
if (c.type === 'update' && c.context.type !== undefined) {
|
|
56751
|
+
type = c.context.type;
|
|
56752
|
+
}
|
|
56438
56753
|
return {
|
|
56439
|
-
type
|
|
56754
|
+
type,
|
|
56440
56755
|
ids: c.keys,
|
|
56441
56756
|
isExternalChange: false,
|
|
56442
56757
|
segment: c.context.segment,
|
|
@@ -56503,6 +56818,10 @@ class AbstractKeyValueDataTable {
|
|
|
56503
56818
|
}, reject);
|
|
56504
56819
|
});
|
|
56505
56820
|
}
|
|
56821
|
+
getMetadataByKeys(_keys) {
|
|
56822
|
+
// eslint-disable-next-line @salesforce/lds/no-error-in-production
|
|
56823
|
+
throw new Error(`There is no metadata in the ${this.tableName} table.`);
|
|
56824
|
+
}
|
|
56506
56825
|
getAll() {
|
|
56507
56826
|
const getAllQuery = `SELECT ${this.columnNames.join(',')} FROM ${this.tableName}`;
|
|
56508
56827
|
return new Promise((resolve, reject) => {
|
|
@@ -56528,6 +56847,10 @@ class AbstractKeyValueDataTable {
|
|
|
56528
56847
|
}, []),
|
|
56529
56848
|
};
|
|
56530
56849
|
}
|
|
56850
|
+
metadataToUpdateOperations(_entries, _segment) {
|
|
56851
|
+
// eslint-disable-next-line @salesforce/lds/no-error-in-production
|
|
56852
|
+
throw new Error(`There is no metadata in the ${this.tableName} table.`);
|
|
56853
|
+
}
|
|
56531
56854
|
mapToDurableEntries(sqliteResult) {
|
|
56532
56855
|
return sqliteResult.rows.reduce((entries, row) => {
|
|
56533
56856
|
const [key, stringifiedData] = row;
|
|
@@ -57865,6 +58188,7 @@ function getRuntime() {
|
|
|
57865
58188
|
const gqlEnv = makeEnvironmentGraphqlAware(baseEnv);
|
|
57866
58189
|
const durableEnv = makeDurable(gqlEnv, {
|
|
57867
58190
|
durableStore: recordDenormingStore,
|
|
58191
|
+
enableDurableMetadataRefresh: ldsMetadataRefreshEnabled.isOpen({ fallback: false }),
|
|
57868
58192
|
});
|
|
57869
58193
|
getIngestRecords = durableEnv.getIngestStagingStoreRecords;
|
|
57870
58194
|
getIngestMetadata = durableEnv.getIngestStagingStoreMetadata;
|
|
@@ -57963,7 +58287,7 @@ register({
|
|
|
57963
58287
|
id: '@salesforce/lds-network-adapter',
|
|
57964
58288
|
instrument: instrument$1,
|
|
57965
58289
|
});
|
|
57966
|
-
// version: 1.
|
|
58290
|
+
// version: 1.235.0-3790decf0
|
|
57967
58291
|
|
|
57968
58292
|
const { create: create$2, keys: keys$2 } = Object;
|
|
57969
58293
|
const { stringify: stringify$1, parse: parse$1 } = JSON;
|
|
@@ -76434,7 +76758,7 @@ register({
|
|
|
76434
76758
|
configuration: { ...configurationForGraphQLAdapters },
|
|
76435
76759
|
instrument,
|
|
76436
76760
|
});
|
|
76437
|
-
// version: 1.
|
|
76761
|
+
// version: 1.235.0-c252f93dc
|
|
76438
76762
|
|
|
76439
76763
|
// On core the unstable adapters are re-exported with different names,
|
|
76440
76764
|
|
|
@@ -78681,7 +79005,7 @@ withDefaultLuvio((luvio) => {
|
|
|
78681
79005
|
unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
|
|
78682
79006
|
graphQLImperative = ldsAdapter;
|
|
78683
79007
|
});
|
|
78684
|
-
// version: 1.
|
|
79008
|
+
// version: 1.235.0-c252f93dc
|
|
78685
79009
|
|
|
78686
79010
|
var gqlApi = /*#__PURE__*/Object.freeze({
|
|
78687
79011
|
__proto__: null,
|
|
@@ -79395,4 +79719,4 @@ const { luvio } = getRuntime();
|
|
|
79395
79719
|
setDefaultLuvio({ luvio });
|
|
79396
79720
|
|
|
79397
79721
|
export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
|
|
79398
|
-
// version: 1.
|
|
79722
|
+
// version: 1.235.0-3790decf0
|