@salesforce/lds-worker-api 1.287.0-dev14 → 1.287.0-dev16
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.
|
@@ -1074,4 +1074,4 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
1074
1074
|
}
|
|
1075
1075
|
|
|
1076
1076
|
export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
|
|
1077
|
-
// version: 1.287.0-
|
|
1077
|
+
// version: 1.287.0-dev16-db839640ab
|
|
@@ -835,14 +835,7 @@ class StringKeyInMemoryStore {
|
|
|
835
835
|
// of the function, in case the reference changes (because of an unsubscribe)
|
|
836
836
|
const { snapshotSubscriptions } = this;
|
|
837
837
|
// read metadata for each key, and mark as expired
|
|
838
|
-
|
|
839
|
-
for (let i = 0, len = keys.length; i < len; i++) {
|
|
840
|
-
const key = keys[i];
|
|
841
|
-
const metadata = this.readMetadata(key);
|
|
842
|
-
if (metadata !== undefined) {
|
|
843
|
-
this.publishMetadata(key, { ...metadata, expirationTimestamp });
|
|
844
|
-
}
|
|
845
|
-
}
|
|
838
|
+
this.expirePossibleStaleRecords(keys);
|
|
846
839
|
// Process snapshot subscriptions
|
|
847
840
|
const pendingPromises = [];
|
|
848
841
|
for (let i = 0, len = snapshotSubscriptions.length; i < len; i++) {
|
|
@@ -937,6 +930,16 @@ class StringKeyInMemoryStore {
|
|
|
937
930
|
this.metadata[canonicalKey] = storeMetadata;
|
|
938
931
|
}
|
|
939
932
|
}
|
|
933
|
+
expirePossibleStaleRecords(keys) {
|
|
934
|
+
const expirationTimestamp = Date.now();
|
|
935
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
936
|
+
const key = keys[i];
|
|
937
|
+
const metadata = this.readMetadata(key);
|
|
938
|
+
if (metadata !== undefined) {
|
|
939
|
+
this.publishMetadata(key, { ...metadata, expirationTimestamp });
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
}
|
|
940
943
|
setTTLOverride(namespace, representationName, ttl) {
|
|
941
944
|
this.ttlOverrides[getTTLOverrideKey(namespace, representationName)] = ttl;
|
|
942
945
|
}
|
|
@@ -1531,14 +1534,7 @@ class InMemoryStore {
|
|
|
1531
1534
|
// of the function, in case the reference changes (because of an unsubscribe)
|
|
1532
1535
|
const { snapshotSubscriptions } = this;
|
|
1533
1536
|
// read metadata for each key, and mark as expired
|
|
1534
|
-
|
|
1535
|
-
for (let i = 0, len = keys.length; i < len; i++) {
|
|
1536
|
-
const key = keys[i];
|
|
1537
|
-
const metadata = this.readMetadata(key);
|
|
1538
|
-
if (metadata !== undefined) {
|
|
1539
|
-
this.publishMetadata(key, { ...metadata, expirationTimestamp });
|
|
1540
|
-
}
|
|
1541
|
-
}
|
|
1537
|
+
this.expirePossibleStaleRecords(keys);
|
|
1542
1538
|
// Process snapshot subscriptions
|
|
1543
1539
|
const pendingPromises = [];
|
|
1544
1540
|
for (let i = 0, len = snapshotSubscriptions.length; i < len; i++) {
|
|
@@ -1661,6 +1657,19 @@ class InMemoryStore {
|
|
|
1661
1657
|
this.metadataMap.set(canonicalKey, storeMetadata);
|
|
1662
1658
|
}
|
|
1663
1659
|
}
|
|
1660
|
+
expirePossibleStaleRecords(keys) {
|
|
1661
|
+
if (keys.length > 0 && typeof keys[0] === 'string') {
|
|
1662
|
+
return this.fallbackStringKeyInMemoryStore.expirePossibleStaleRecords(keys);
|
|
1663
|
+
}
|
|
1664
|
+
const expirationTimestamp = Date.now();
|
|
1665
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
1666
|
+
const key = keys[i];
|
|
1667
|
+
const metadata = this.readMetadata(key);
|
|
1668
|
+
if (metadata !== undefined) {
|
|
1669
|
+
this.publishMetadata(key, { ...metadata, expirationTimestamp });
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
}
|
|
1664
1673
|
setTTLOverride(namespace, representationName, ttl) {
|
|
1665
1674
|
// Set the TTLs in both the stores
|
|
1666
1675
|
this.fallbackStringKeyInMemoryStore.setTTLOverride(namespace, representationName, ttl);
|
|
@@ -3622,6 +3631,30 @@ class Environment {
|
|
|
3622
3631
|
buildStructuredKey(namespace, representationName, idValues) {
|
|
3623
3632
|
return this.store.buildStructuredKey(namespace, representationName, idValues);
|
|
3624
3633
|
}
|
|
3634
|
+
/**
|
|
3635
|
+
* Take a list of keys and marks them as stale to be refreshed.
|
|
3636
|
+
* Then will be refreshed with the provided refresh function.
|
|
3637
|
+
* If no refresh and makeConfig functions are provided it will refresh
|
|
3638
|
+
* time that record is trying to be fetched
|
|
3639
|
+
*
|
|
3640
|
+
* Example: one record from graphql needs to be refreshed and not
|
|
3641
|
+
* the entire graphql query
|
|
3642
|
+
*
|
|
3643
|
+
* @param keys
|
|
3644
|
+
* @param makeConfig
|
|
3645
|
+
* @param refresh
|
|
3646
|
+
* @returns
|
|
3647
|
+
*/
|
|
3648
|
+
expirePossibleStaleRecords(keys, config, refresh) {
|
|
3649
|
+
this.store.expirePossibleStaleRecords(keys);
|
|
3650
|
+
if (refresh !== undefined && config !== undefined) {
|
|
3651
|
+
return this.refreshPossibleStaleRecords(config, refresh);
|
|
3652
|
+
}
|
|
3653
|
+
return Promise.resolve();
|
|
3654
|
+
}
|
|
3655
|
+
refreshPossibleStaleRecords(config, refresh) {
|
|
3656
|
+
return Promise.resolve(refresh(config, { cachePolicy: { type: 'no-cache' } })).then(() => { });
|
|
3657
|
+
}
|
|
3625
3658
|
}
|
|
3626
3659
|
|
|
3627
3660
|
class Luvio {
|
|
@@ -3688,6 +3721,9 @@ class Luvio {
|
|
|
3688
3721
|
storeCleanup() {
|
|
3689
3722
|
this.environment.storeCleanup();
|
|
3690
3723
|
}
|
|
3724
|
+
storeExpirePossibleStaleRecords(keys, config, refresh) {
|
|
3725
|
+
return this.environment.expirePossibleStaleRecords(keys, config, refresh);
|
|
3726
|
+
}
|
|
3691
3727
|
createSnapshot(selector, refresh) {
|
|
3692
3728
|
return this.environment.createSnapshot(selector, refresh);
|
|
3693
3729
|
}
|
|
@@ -4076,7 +4112,7 @@ function createResourceParamsImpl(config, configMetadata) {
|
|
|
4076
4112
|
}
|
|
4077
4113
|
return resourceParams;
|
|
4078
4114
|
}
|
|
4079
|
-
// engine version: 0.154.17-
|
|
4115
|
+
// engine version: 0.154.17-dev3-133dce6d
|
|
4080
4116
|
|
|
4081
4117
|
/**
|
|
4082
4118
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -4204,7 +4240,7 @@ function withDefaultLuvio(callback) {
|
|
|
4204
4240
|
}
|
|
4205
4241
|
callbacks.push(callback);
|
|
4206
4242
|
}
|
|
4207
|
-
// version: 1.287.0-
|
|
4243
|
+
// version: 1.287.0-dev16-db839640ab
|
|
4208
4244
|
|
|
4209
4245
|
// TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
|
|
4210
4246
|
function instrumentAdapter$1(createFunction, _metadata) {
|
|
@@ -15712,7 +15748,7 @@ function gql(literals, ...subs) {
|
|
|
15712
15748
|
}
|
|
15713
15749
|
return superResult;
|
|
15714
15750
|
}
|
|
15715
|
-
// version: 1.287.0-
|
|
15751
|
+
// version: 1.287.0-dev16-db839640ab
|
|
15716
15752
|
|
|
15717
15753
|
function unwrap(data) {
|
|
15718
15754
|
// The lwc-luvio bindings import a function from lwc called "unwrap".
|
|
@@ -16641,7 +16677,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
|
|
|
16641
16677
|
const { apiFamily, name } = metadata;
|
|
16642
16678
|
return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
|
|
16643
16679
|
}
|
|
16644
|
-
// version: 1.287.0-
|
|
16680
|
+
// version: 1.287.0-dev16-db839640ab
|
|
16645
16681
|
|
|
16646
16682
|
/**
|
|
16647
16683
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -16740,7 +16776,7 @@ var TypeCheckShapes;
|
|
|
16740
16776
|
TypeCheckShapes[TypeCheckShapes["Integer"] = 3] = "Integer";
|
|
16741
16777
|
TypeCheckShapes[TypeCheckShapes["Unsupported"] = 4] = "Unsupported";
|
|
16742
16778
|
})(TypeCheckShapes || (TypeCheckShapes = {}));
|
|
16743
|
-
// engine version: 0.154.17-
|
|
16779
|
+
// engine version: 0.154.17-dev3-133dce6d
|
|
16744
16780
|
|
|
16745
16781
|
const { keys: ObjectKeys$3, create: ObjectCreate$3 } = Object;
|
|
16746
16782
|
|
|
@@ -44256,7 +44292,7 @@ withDefaultLuvio((luvio) => {
|
|
|
44256
44292
|
throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
|
|
44257
44293
|
throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
|
|
44258
44294
|
});
|
|
44259
|
-
// version: 1.287.0-
|
|
44295
|
+
// version: 1.287.0-dev16-4d742a2467
|
|
44260
44296
|
|
|
44261
44297
|
var ldsIdempotencyWriteDisabled = {
|
|
44262
44298
|
isOpen: function (e) {
|
|
@@ -45949,6 +45985,32 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
|
|
|
45949
45985
|
}, revivingStore).finally(() => {
|
|
45950
45986
|
});
|
|
45951
45987
|
};
|
|
45988
|
+
const expirePossibleStaleRecords = async function (keys$1, config, refresh) {
|
|
45989
|
+
validateNotDisposed();
|
|
45990
|
+
const metadataKeys = keys$1.map(serializeStructuredKey);
|
|
45991
|
+
const now = Date.now();
|
|
45992
|
+
const entries = await durableStore.getMetadata(metadataKeys, DefaultDurableSegment);
|
|
45993
|
+
if (entries === undefined || keys$7(entries).length === 0) {
|
|
45994
|
+
return environment.expirePossibleStaleRecords(keys$1);
|
|
45995
|
+
}
|
|
45996
|
+
let metaDataChanged = false;
|
|
45997
|
+
const metadataEntries = metadataKeys.reduce((accu, key) => {
|
|
45998
|
+
const metadataEntry = entries[key];
|
|
45999
|
+
if (metadataEntry.metadata !== undefined) {
|
|
46000
|
+
const metadata = { ...metadataEntry.metadata, expirationTimestamp: now };
|
|
46001
|
+
accu[key] = { metadata };
|
|
46002
|
+
metaDataChanged = true;
|
|
46003
|
+
}
|
|
46004
|
+
return accu;
|
|
46005
|
+
}, {});
|
|
46006
|
+
if (metaDataChanged) {
|
|
46007
|
+
await durableStore.setMetadata(metadataEntries, DefaultDurableSegment);
|
|
46008
|
+
}
|
|
46009
|
+
if (config !== undefined && refresh !== undefined) {
|
|
46010
|
+
return environment.refreshPossibleStaleRecords(config, refresh);
|
|
46011
|
+
}
|
|
46012
|
+
return Promise.resolve();
|
|
46013
|
+
};
|
|
45952
46014
|
// set the default cache policy of the base environment
|
|
45953
46015
|
environment.setDefaultCachePolicy({
|
|
45954
46016
|
type: 'stale-while-revalidate',
|
|
@@ -45981,6 +46043,7 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
|
|
|
45981
46043
|
handleErrorResponse: { value: handleErrorResponse },
|
|
45982
46044
|
getNotifyChangeStoreEntries: { value: getNotifyChangeStoreEntries },
|
|
45983
46045
|
notifyStoreUpdateAvailable: { value: notifyStoreUpdateAvailable },
|
|
46046
|
+
expirePossibleStaleRecords: { value: expirePossibleStaleRecords },
|
|
45984
46047
|
});
|
|
45985
46048
|
}
|
|
45986
46049
|
|
|
@@ -51599,6 +51662,7 @@ function createContext(store, objectInfos, eventEmitter, settings, snapshot, dra
|
|
|
51599
51662
|
Record,
|
|
51600
51663
|
snapshot,
|
|
51601
51664
|
seenRecordIds: new Set(),
|
|
51665
|
+
possibleStaleRecordMap: new Map(),
|
|
51602
51666
|
draftFunctions,
|
|
51603
51667
|
};
|
|
51604
51668
|
}
|
|
@@ -52210,7 +52274,6 @@ function isTodayStartOfWeek() {
|
|
|
52210
52274
|
|
|
52211
52275
|
const JSON_EXTRACT_PATH_INGESTION_TIMESTAMP = '$.ingestionTimestamp';
|
|
52212
52276
|
const JSON_EXTRACT_PATH_INGESTION_APINAME = '$.apiName';
|
|
52213
|
-
const JSON_EXTRACT_PATH_DRAFTS = '$.drafts';
|
|
52214
52277
|
|
|
52215
52278
|
const MultiPickListValueSeparator = ';';
|
|
52216
52279
|
function filterToPredicates(where, recordType, alias, objectInfoMap, joins, draftFunctions) {
|
|
@@ -52740,18 +52803,11 @@ function buildQuery(config) {
|
|
|
52740
52803
|
const joins = buildJoins(config);
|
|
52741
52804
|
const predicates = buildPredicates(config);
|
|
52742
52805
|
const orderBy = buildOrderBy(config);
|
|
52743
|
-
const staleRecordsSql = excludeStaleRecordsGate.isOpen({ fallback: false })
|
|
52744
|
-
? `AND (
|
|
52745
|
-
json_extract("${config.alias}".metadata, '${JSON_EXTRACT_PATH_INGESTION_TIMESTAMP}') >= ?
|
|
52746
|
-
OR json_extract("${config.alias}".data, '${JSON_EXTRACT_PATH_DRAFTS}') IS NOT NULL
|
|
52747
|
-
)`
|
|
52748
|
-
: '';
|
|
52749
52806
|
const sql = `
|
|
52750
|
-
SELECT "${config.alias}".data
|
|
52807
|
+
SELECT "${config.alias}".data, "${config.alias}".metadata
|
|
52751
52808
|
FROM lds_data "${config.alias}" ${joins.sql}
|
|
52752
52809
|
WHERE "${config.alias}".key like 'UiApi::RecordRepresentation:%'
|
|
52753
52810
|
AND json_extract("${config.alias}".data, '${JSON_EXTRACT_PATH_INGESTION_APINAME}') = '${config.alias}'
|
|
52754
|
-
${staleRecordsSql}
|
|
52755
52811
|
${predicates.sql}
|
|
52756
52812
|
${orderBy.sql}
|
|
52757
52813
|
LIMIT ?
|
|
@@ -52762,7 +52818,6 @@ function buildQuery(config) {
|
|
|
52762
52818
|
const bindings = [
|
|
52763
52819
|
// bindings from predicates on joins
|
|
52764
52820
|
...joins.bindings,
|
|
52765
|
-
...(excludeStaleRecordsGate.isOpen({ fallback: false }) ? [config.ingestionTimestamp] : []),
|
|
52766
52821
|
// where clause and parent scope bindings
|
|
52767
52822
|
...predicates.bindings,
|
|
52768
52823
|
// limit binding
|
|
@@ -52788,33 +52843,19 @@ function buildJoins(config) {
|
|
|
52788
52843
|
if (allJoins.length === 0)
|
|
52789
52844
|
return { sql, bindings };
|
|
52790
52845
|
sql = allJoins.reduce((joinAccumulator, join) => {
|
|
52791
|
-
let timestampAdded = false;
|
|
52792
52846
|
const joinConditions = join.conditions.reduce((conditionAccumulator, condition) => {
|
|
52793
52847
|
let joined_sql;
|
|
52794
|
-
const joinMetadataTimestamp = excludeStaleRecordsGate.isOpen({ fallback: false })
|
|
52795
|
-
? ` AND (json_extract("${join.alias}".metadata, '${JSON_EXTRACT_PATH_INGESTION_TIMESTAMP}') >= ? OR json_extract("${join.alias}".data, '${JSON_EXTRACT_PATH_DRAFTS}') IS NOT NULL)`
|
|
52796
|
-
: '';
|
|
52797
52848
|
// predicate on a value, use the newly joined table
|
|
52798
52849
|
if ('type' in condition) {
|
|
52799
52850
|
const { sql, binding } = predicateToSQL(condition, join.alias);
|
|
52800
|
-
joined_sql = ` AND ${sql}
|
|
52851
|
+
joined_sql = ` AND ${sql}`;
|
|
52801
52852
|
bindings.push(...binding);
|
|
52802
|
-
if (excludeStaleRecordsGate.isOpen({ fallback: false }) &&
|
|
52803
|
-
timestampAdded === false) {
|
|
52804
|
-
bindings.push(config.ingestionTimestamp);
|
|
52805
|
-
timestampAdded = true;
|
|
52806
|
-
}
|
|
52807
52853
|
}
|
|
52808
52854
|
else {
|
|
52809
52855
|
// predicate on a path
|
|
52810
52856
|
const left = ` AND json_extract("${join.to}".data, '${condition.leftPath}')`;
|
|
52811
52857
|
const right = `json_extract("${join.alias}".data, '${condition.rightPath}')`;
|
|
52812
|
-
joined_sql = `${left} = ${right}
|
|
52813
|
-
if (excludeStaleRecordsGate.isOpen({ fallback: false }) &&
|
|
52814
|
-
timestampAdded === false) {
|
|
52815
|
-
bindings.push(config.ingestionTimestamp);
|
|
52816
|
-
timestampAdded = true;
|
|
52817
|
-
}
|
|
52858
|
+
joined_sql = `${left} = ${right}`;
|
|
52818
52859
|
}
|
|
52819
52860
|
conditionAccumulator += joined_sql;
|
|
52820
52861
|
return conditionAccumulator;
|
|
@@ -53759,8 +53800,7 @@ function addResolversToSchema(schema, polyFields) {
|
|
|
53759
53800
|
for (const field of fields) {
|
|
53760
53801
|
if (field.name === 'node') {
|
|
53761
53802
|
field.resolve = function nodeResolver(obj, _args, { seenRecordIds }) {
|
|
53762
|
-
const {
|
|
53763
|
-
const recordRepresentation = parse$4(record);
|
|
53803
|
+
const { recordRepresentation, ingestionTimestamp } = obj;
|
|
53764
53804
|
seenRecordIds.add(recordRepresentation.id);
|
|
53765
53805
|
return { recordRepresentation, ingestionTimestamp };
|
|
53766
53806
|
};
|
|
@@ -53974,16 +54014,30 @@ async function connectionEdgeResolver(obj, _args, context) {
|
|
|
53974
54014
|
predicates,
|
|
53975
54015
|
orderBy: orderByToPredicate(parentArgs.orderBy, alias, alias, context.objectInfos),
|
|
53976
54016
|
limit: parentArgs.first,
|
|
53977
|
-
ingestionTimestamp,
|
|
53978
54017
|
};
|
|
53979
54018
|
const { sql, bindings } = buildQuery(queryConfig);
|
|
53980
54019
|
const results = await query(sql, bindings);
|
|
53981
54020
|
//map each sql result with the ingestion timestamp to pass it down a level
|
|
53982
|
-
return results.rows
|
|
53983
|
-
|
|
53984
|
-
|
|
54021
|
+
return results.rows.map((row) => {
|
|
54022
|
+
const recordMetadataResult = {
|
|
54023
|
+
recordRepresentation: parse$4(row[0]),
|
|
54024
|
+
metadata: parse$4(row[1]),
|
|
54025
|
+
};
|
|
54026
|
+
const { recordRepresentation, metadata } = recordMetadataResult;
|
|
54027
|
+
context.seenRecordIds.add(recordRepresentation.id);
|
|
54028
|
+
if (metadata.ingestionTimestamp < ingestionTimestamp &&
|
|
54029
|
+
recordRepresentation.drafts === undefined) {
|
|
54030
|
+
if (context.possibleStaleRecordMap.has(recordRepresentation.apiName) === false) {
|
|
54031
|
+
context.possibleStaleRecordMap.set(recordRepresentation.apiName, []);
|
|
54032
|
+
}
|
|
54033
|
+
const ids = context.possibleStaleRecordMap.get(recordRepresentation.apiName);
|
|
54034
|
+
if (ids !== undefined) {
|
|
54035
|
+
ids.push(recordRepresentation.id);
|
|
54036
|
+
context.possibleStaleRecordMap.set(recordRepresentation.apiName, ids);
|
|
54037
|
+
}
|
|
54038
|
+
}
|
|
53985
54039
|
return {
|
|
53986
|
-
|
|
54040
|
+
recordRepresentation,
|
|
53987
54041
|
ingestionTimestamp,
|
|
53988
54042
|
};
|
|
53989
54043
|
});
|
|
@@ -54548,7 +54602,11 @@ async function evaluate(config, observers, settings, objectInfos, store, snapsho
|
|
|
54548
54602
|
seenRecordIds.push(queryString);
|
|
54549
54603
|
});
|
|
54550
54604
|
}
|
|
54551
|
-
return {
|
|
54605
|
+
return {
|
|
54606
|
+
result,
|
|
54607
|
+
seenRecordIds,
|
|
54608
|
+
possibleStaleRecordMap: contextValue.possibleStaleRecordMap,
|
|
54609
|
+
};
|
|
54552
54610
|
}
|
|
54553
54611
|
finally {
|
|
54554
54612
|
eventEmitter({ type: 'graphql-eval-end' });
|
|
@@ -58291,8 +58349,13 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
|
|
|
58291
58349
|
: [];
|
|
58292
58350
|
let gqlResult;
|
|
58293
58351
|
let seenRecordIds;
|
|
58352
|
+
let possibleStaleRecordMap;
|
|
58294
58353
|
try {
|
|
58295
|
-
({
|
|
58354
|
+
({
|
|
58355
|
+
result: gqlResult,
|
|
58356
|
+
seenRecordIds,
|
|
58357
|
+
possibleStaleRecordMap,
|
|
58358
|
+
} = await evaluate({
|
|
58296
58359
|
...config,
|
|
58297
58360
|
//need to create another copy of the ast for future writes
|
|
58298
58361
|
query: parse$3(stringify$3(injectedAST)),
|
|
@@ -58322,13 +58385,18 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
|
|
|
58322
58385
|
const seenRecords = createSeenRecords(seenRecordIds, nonEvaluatedSnapshot);
|
|
58323
58386
|
const recordId = generateUniqueRecordId();
|
|
58324
58387
|
const rebuildWithLocalEval = async (originalSnapshot) => {
|
|
58325
|
-
let { result: rebuildResult, seenRecordIds } = await evaluate({
|
|
58388
|
+
let { result: rebuildResult, seenRecordIds, possibleStaleRecordMap, } = await evaluate({
|
|
58326
58389
|
...config,
|
|
58327
58390
|
query: injectedAST,
|
|
58328
58391
|
}, observers, { userId }, objectInfoNeeded, store, originalSnapshot, graphqlSchemaCache, draftFunctions);
|
|
58329
58392
|
if (!rebuildResult.errors) {
|
|
58330
58393
|
rebuildResult = removeSyntheticFields(rebuildResult, config.query);
|
|
58331
58394
|
}
|
|
58395
|
+
let snapshotState = 'Fulfilled';
|
|
58396
|
+
if (possibleStaleRecordMap.size > 0) {
|
|
58397
|
+
initiateStaleRecordRefresh(luvio, possibleStaleRecordMap);
|
|
58398
|
+
snapshotState = 'Stale';
|
|
58399
|
+
}
|
|
58332
58400
|
if (objectsDeepEqual(rebuildResult, originalSnapshot.data)) {
|
|
58333
58401
|
return originalSnapshot;
|
|
58334
58402
|
}
|
|
@@ -58337,6 +58405,7 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
|
|
|
58337
58405
|
...originalSnapshot,
|
|
58338
58406
|
data: rebuildResult,
|
|
58339
58407
|
recordId,
|
|
58408
|
+
state: snapshotState,
|
|
58340
58409
|
seenRecords: createSeenRecords(seenRecordIds, nonEvaluatedSnapshot),
|
|
58341
58410
|
rebuildWithLocalEval,
|
|
58342
58411
|
};
|
|
@@ -58374,6 +58443,10 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
|
|
|
58374
58443
|
},
|
|
58375
58444
|
};
|
|
58376
58445
|
}
|
|
58446
|
+
if (possibleStaleRecordMap.size > 0) {
|
|
58447
|
+
initiateStaleRecordRefresh(luvio, possibleStaleRecordMap);
|
|
58448
|
+
resultSnapshot.state = 'Stale';
|
|
58449
|
+
}
|
|
58377
58450
|
return resultSnapshot;
|
|
58378
58451
|
};
|
|
58379
58452
|
}
|
|
@@ -58434,6 +58507,24 @@ function environmentAwareGraphQLBatchAdapterFactory(objectInfoService, luvio, is
|
|
|
58434
58507
|
};
|
|
58435
58508
|
};
|
|
58436
58509
|
}
|
|
58510
|
+
function initiateStaleRecordRefresh(luvio, keyMap) {
|
|
58511
|
+
const staleRecordKeys = from$1(keyMap.values())
|
|
58512
|
+
.flat()
|
|
58513
|
+
.map((id) => `UiApi::RecordRepresentation:${id}`);
|
|
58514
|
+
luvio.storeExpirePossibleStaleRecords(staleRecordKeys, makeGetRecordsConfig(keyMap), getRecordsAdapterFactory(luvio));
|
|
58515
|
+
}
|
|
58516
|
+
function makeGetRecordsConfig(keyMap) {
|
|
58517
|
+
const records = [];
|
|
58518
|
+
keyMap.forEach((recordIds, apiName) => {
|
|
58519
|
+
records.push({
|
|
58520
|
+
recordIds,
|
|
58521
|
+
fields: [`${apiName}.Id`],
|
|
58522
|
+
});
|
|
58523
|
+
});
|
|
58524
|
+
return {
|
|
58525
|
+
records,
|
|
58526
|
+
};
|
|
58527
|
+
}
|
|
58437
58528
|
|
|
58438
58529
|
const CONTENT_DOCUMENT_DRAFT_ID_KEY = 'CONTENT_DOCUMENT_DRAFT_ID';
|
|
58439
58530
|
const CONTENT_VERSION_DRAFT_ID_KEY = 'CONTENT_VERSION_DRAFT_ID';
|
|
@@ -62595,7 +62686,7 @@ register$1({
|
|
|
62595
62686
|
id: '@salesforce/lds-network-adapter',
|
|
62596
62687
|
instrument: instrument$2,
|
|
62597
62688
|
});
|
|
62598
|
-
// version: 1.287.0-
|
|
62689
|
+
// version: 1.287.0-dev16-db839640ab
|
|
62599
62690
|
|
|
62600
62691
|
const { create: create$3, keys: keys$3 } = Object;
|
|
62601
62692
|
const { stringify: stringify$1, parse: parse$1 } = JSON;
|
|
@@ -82659,7 +82750,7 @@ register$1({
|
|
|
82659
82750
|
configuration: { ...configurationForGraphQLAdapters$1 },
|
|
82660
82751
|
instrument: instrument$1,
|
|
82661
82752
|
});
|
|
82662
|
-
// version: 1.287.0-
|
|
82753
|
+
// version: 1.287.0-dev16-4d742a2467
|
|
82663
82754
|
|
|
82664
82755
|
// On core the unstable adapters are re-exported with different names,
|
|
82665
82756
|
// we want to match them here.
|
|
@@ -84915,7 +85006,7 @@ withDefaultLuvio((luvio) => {
|
|
|
84915
85006
|
unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
|
|
84916
85007
|
graphQLImperative = ldsAdapter;
|
|
84917
85008
|
});
|
|
84918
|
-
// version: 1.287.0-
|
|
85009
|
+
// version: 1.287.0-dev16-4d742a2467
|
|
84919
85010
|
|
|
84920
85011
|
var gqlApi = /*#__PURE__*/Object.freeze({
|
|
84921
85012
|
__proto__: null,
|
|
@@ -85653,7 +85744,7 @@ const callbacks$1 = [];
|
|
|
85653
85744
|
function register(r) {
|
|
85654
85745
|
callbacks$1.forEach((callback) => callback(r));
|
|
85655
85746
|
}
|
|
85656
|
-
// version: 1.287.0-
|
|
85747
|
+
// version: 1.287.0-dev16-db839640ab
|
|
85657
85748
|
|
|
85658
85749
|
/**
|
|
85659
85750
|
* Returns true if the value acts like a Promise, i.e. has a "then" function,
|
|
@@ -90615,4 +90706,4 @@ const { luvio } = getRuntime();
|
|
|
90615
90706
|
setDefaultLuvio({ luvio });
|
|
90616
90707
|
|
|
90617
90708
|
export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
|
|
90618
|
-
// version: 1.287.0-
|
|
90709
|
+
// version: 1.287.0-dev16-db839640ab
|
|
@@ -841,14 +841,7 @@
|
|
|
841
841
|
// of the function, in case the reference changes (because of an unsubscribe)
|
|
842
842
|
const { snapshotSubscriptions } = this;
|
|
843
843
|
// read metadata for each key, and mark as expired
|
|
844
|
-
|
|
845
|
-
for (let i = 0, len = keys.length; i < len; i++) {
|
|
846
|
-
const key = keys[i];
|
|
847
|
-
const metadata = this.readMetadata(key);
|
|
848
|
-
if (metadata !== undefined) {
|
|
849
|
-
this.publishMetadata(key, { ...metadata, expirationTimestamp });
|
|
850
|
-
}
|
|
851
|
-
}
|
|
844
|
+
this.expirePossibleStaleRecords(keys);
|
|
852
845
|
// Process snapshot subscriptions
|
|
853
846
|
const pendingPromises = [];
|
|
854
847
|
for (let i = 0, len = snapshotSubscriptions.length; i < len; i++) {
|
|
@@ -943,6 +936,16 @@
|
|
|
943
936
|
this.metadata[canonicalKey] = storeMetadata;
|
|
944
937
|
}
|
|
945
938
|
}
|
|
939
|
+
expirePossibleStaleRecords(keys) {
|
|
940
|
+
const expirationTimestamp = Date.now();
|
|
941
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
942
|
+
const key = keys[i];
|
|
943
|
+
const metadata = this.readMetadata(key);
|
|
944
|
+
if (metadata !== undefined) {
|
|
945
|
+
this.publishMetadata(key, { ...metadata, expirationTimestamp });
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
}
|
|
946
949
|
setTTLOverride(namespace, representationName, ttl) {
|
|
947
950
|
this.ttlOverrides[getTTLOverrideKey(namespace, representationName)] = ttl;
|
|
948
951
|
}
|
|
@@ -1537,14 +1540,7 @@
|
|
|
1537
1540
|
// of the function, in case the reference changes (because of an unsubscribe)
|
|
1538
1541
|
const { snapshotSubscriptions } = this;
|
|
1539
1542
|
// read metadata for each key, and mark as expired
|
|
1540
|
-
|
|
1541
|
-
for (let i = 0, len = keys.length; i < len; i++) {
|
|
1542
|
-
const key = keys[i];
|
|
1543
|
-
const metadata = this.readMetadata(key);
|
|
1544
|
-
if (metadata !== undefined) {
|
|
1545
|
-
this.publishMetadata(key, { ...metadata, expirationTimestamp });
|
|
1546
|
-
}
|
|
1547
|
-
}
|
|
1543
|
+
this.expirePossibleStaleRecords(keys);
|
|
1548
1544
|
// Process snapshot subscriptions
|
|
1549
1545
|
const pendingPromises = [];
|
|
1550
1546
|
for (let i = 0, len = snapshotSubscriptions.length; i < len; i++) {
|
|
@@ -1667,6 +1663,19 @@
|
|
|
1667
1663
|
this.metadataMap.set(canonicalKey, storeMetadata);
|
|
1668
1664
|
}
|
|
1669
1665
|
}
|
|
1666
|
+
expirePossibleStaleRecords(keys) {
|
|
1667
|
+
if (keys.length > 0 && typeof keys[0] === 'string') {
|
|
1668
|
+
return this.fallbackStringKeyInMemoryStore.expirePossibleStaleRecords(keys);
|
|
1669
|
+
}
|
|
1670
|
+
const expirationTimestamp = Date.now();
|
|
1671
|
+
for (let i = 0, len = keys.length; i < len; i++) {
|
|
1672
|
+
const key = keys[i];
|
|
1673
|
+
const metadata = this.readMetadata(key);
|
|
1674
|
+
if (metadata !== undefined) {
|
|
1675
|
+
this.publishMetadata(key, { ...metadata, expirationTimestamp });
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1670
1679
|
setTTLOverride(namespace, representationName, ttl) {
|
|
1671
1680
|
// Set the TTLs in both the stores
|
|
1672
1681
|
this.fallbackStringKeyInMemoryStore.setTTLOverride(namespace, representationName, ttl);
|
|
@@ -3628,6 +3637,30 @@
|
|
|
3628
3637
|
buildStructuredKey(namespace, representationName, idValues) {
|
|
3629
3638
|
return this.store.buildStructuredKey(namespace, representationName, idValues);
|
|
3630
3639
|
}
|
|
3640
|
+
/**
|
|
3641
|
+
* Take a list of keys and marks them as stale to be refreshed.
|
|
3642
|
+
* Then will be refreshed with the provided refresh function.
|
|
3643
|
+
* If no refresh and makeConfig functions are provided it will refresh
|
|
3644
|
+
* time that record is trying to be fetched
|
|
3645
|
+
*
|
|
3646
|
+
* Example: one record from graphql needs to be refreshed and not
|
|
3647
|
+
* the entire graphql query
|
|
3648
|
+
*
|
|
3649
|
+
* @param keys
|
|
3650
|
+
* @param makeConfig
|
|
3651
|
+
* @param refresh
|
|
3652
|
+
* @returns
|
|
3653
|
+
*/
|
|
3654
|
+
expirePossibleStaleRecords(keys, config, refresh) {
|
|
3655
|
+
this.store.expirePossibleStaleRecords(keys);
|
|
3656
|
+
if (refresh !== undefined && config !== undefined) {
|
|
3657
|
+
return this.refreshPossibleStaleRecords(config, refresh);
|
|
3658
|
+
}
|
|
3659
|
+
return Promise.resolve();
|
|
3660
|
+
}
|
|
3661
|
+
refreshPossibleStaleRecords(config, refresh) {
|
|
3662
|
+
return Promise.resolve(refresh(config, { cachePolicy: { type: 'no-cache' } })).then(() => { });
|
|
3663
|
+
}
|
|
3631
3664
|
}
|
|
3632
3665
|
|
|
3633
3666
|
class Luvio {
|
|
@@ -3694,6 +3727,9 @@
|
|
|
3694
3727
|
storeCleanup() {
|
|
3695
3728
|
this.environment.storeCleanup();
|
|
3696
3729
|
}
|
|
3730
|
+
storeExpirePossibleStaleRecords(keys, config, refresh) {
|
|
3731
|
+
return this.environment.expirePossibleStaleRecords(keys, config, refresh);
|
|
3732
|
+
}
|
|
3697
3733
|
createSnapshot(selector, refresh) {
|
|
3698
3734
|
return this.environment.createSnapshot(selector, refresh);
|
|
3699
3735
|
}
|
|
@@ -4082,7 +4118,7 @@
|
|
|
4082
4118
|
}
|
|
4083
4119
|
return resourceParams;
|
|
4084
4120
|
}
|
|
4085
|
-
// engine version: 0.154.17-
|
|
4121
|
+
// engine version: 0.154.17-dev3-133dce6d
|
|
4086
4122
|
|
|
4087
4123
|
/**
|
|
4088
4124
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -4210,7 +4246,7 @@
|
|
|
4210
4246
|
}
|
|
4211
4247
|
callbacks.push(callback);
|
|
4212
4248
|
}
|
|
4213
|
-
// version: 1.287.0-
|
|
4249
|
+
// version: 1.287.0-dev16-db839640ab
|
|
4214
4250
|
|
|
4215
4251
|
// TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
|
|
4216
4252
|
function instrumentAdapter$1(createFunction, _metadata) {
|
|
@@ -15718,7 +15754,7 @@
|
|
|
15718
15754
|
}
|
|
15719
15755
|
return superResult;
|
|
15720
15756
|
}
|
|
15721
|
-
// version: 1.287.0-
|
|
15757
|
+
// version: 1.287.0-dev16-db839640ab
|
|
15722
15758
|
|
|
15723
15759
|
function unwrap(data) {
|
|
15724
15760
|
// The lwc-luvio bindings import a function from lwc called "unwrap".
|
|
@@ -16647,7 +16683,7 @@
|
|
|
16647
16683
|
const { apiFamily, name } = metadata;
|
|
16648
16684
|
return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
|
|
16649
16685
|
}
|
|
16650
|
-
// version: 1.287.0-
|
|
16686
|
+
// version: 1.287.0-dev16-db839640ab
|
|
16651
16687
|
|
|
16652
16688
|
/**
|
|
16653
16689
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -16746,7 +16782,7 @@
|
|
|
16746
16782
|
TypeCheckShapes[TypeCheckShapes["Integer"] = 3] = "Integer";
|
|
16747
16783
|
TypeCheckShapes[TypeCheckShapes["Unsupported"] = 4] = "Unsupported";
|
|
16748
16784
|
})(TypeCheckShapes || (TypeCheckShapes = {}));
|
|
16749
|
-
// engine version: 0.154.17-
|
|
16785
|
+
// engine version: 0.154.17-dev3-133dce6d
|
|
16750
16786
|
|
|
16751
16787
|
const { keys: ObjectKeys$3, create: ObjectCreate$3 } = Object;
|
|
16752
16788
|
|
|
@@ -44262,7 +44298,7 @@
|
|
|
44262
44298
|
throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
|
|
44263
44299
|
throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
|
|
44264
44300
|
});
|
|
44265
|
-
// version: 1.287.0-
|
|
44301
|
+
// version: 1.287.0-dev16-4d742a2467
|
|
44266
44302
|
|
|
44267
44303
|
var ldsIdempotencyWriteDisabled = {
|
|
44268
44304
|
isOpen: function (e) {
|
|
@@ -45955,6 +45991,32 @@
|
|
|
45955
45991
|
}, revivingStore).finally(() => {
|
|
45956
45992
|
});
|
|
45957
45993
|
};
|
|
45994
|
+
const expirePossibleStaleRecords = async function (keys$1, config, refresh) {
|
|
45995
|
+
validateNotDisposed();
|
|
45996
|
+
const metadataKeys = keys$1.map(serializeStructuredKey);
|
|
45997
|
+
const now = Date.now();
|
|
45998
|
+
const entries = await durableStore.getMetadata(metadataKeys, DefaultDurableSegment);
|
|
45999
|
+
if (entries === undefined || keys$7(entries).length === 0) {
|
|
46000
|
+
return environment.expirePossibleStaleRecords(keys$1);
|
|
46001
|
+
}
|
|
46002
|
+
let metaDataChanged = false;
|
|
46003
|
+
const metadataEntries = metadataKeys.reduce((accu, key) => {
|
|
46004
|
+
const metadataEntry = entries[key];
|
|
46005
|
+
if (metadataEntry.metadata !== undefined) {
|
|
46006
|
+
const metadata = { ...metadataEntry.metadata, expirationTimestamp: now };
|
|
46007
|
+
accu[key] = { metadata };
|
|
46008
|
+
metaDataChanged = true;
|
|
46009
|
+
}
|
|
46010
|
+
return accu;
|
|
46011
|
+
}, {});
|
|
46012
|
+
if (metaDataChanged) {
|
|
46013
|
+
await durableStore.setMetadata(metadataEntries, DefaultDurableSegment);
|
|
46014
|
+
}
|
|
46015
|
+
if (config !== undefined && refresh !== undefined) {
|
|
46016
|
+
return environment.refreshPossibleStaleRecords(config, refresh);
|
|
46017
|
+
}
|
|
46018
|
+
return Promise.resolve();
|
|
46019
|
+
};
|
|
45958
46020
|
// set the default cache policy of the base environment
|
|
45959
46021
|
environment.setDefaultCachePolicy({
|
|
45960
46022
|
type: 'stale-while-revalidate',
|
|
@@ -45987,6 +46049,7 @@
|
|
|
45987
46049
|
handleErrorResponse: { value: handleErrorResponse },
|
|
45988
46050
|
getNotifyChangeStoreEntries: { value: getNotifyChangeStoreEntries },
|
|
45989
46051
|
notifyStoreUpdateAvailable: { value: notifyStoreUpdateAvailable },
|
|
46052
|
+
expirePossibleStaleRecords: { value: expirePossibleStaleRecords },
|
|
45990
46053
|
});
|
|
45991
46054
|
}
|
|
45992
46055
|
|
|
@@ -51605,6 +51668,7 @@
|
|
|
51605
51668
|
Record,
|
|
51606
51669
|
snapshot,
|
|
51607
51670
|
seenRecordIds: new Set(),
|
|
51671
|
+
possibleStaleRecordMap: new Map(),
|
|
51608
51672
|
draftFunctions,
|
|
51609
51673
|
};
|
|
51610
51674
|
}
|
|
@@ -52216,7 +52280,6 @@
|
|
|
52216
52280
|
|
|
52217
52281
|
const JSON_EXTRACT_PATH_INGESTION_TIMESTAMP = '$.ingestionTimestamp';
|
|
52218
52282
|
const JSON_EXTRACT_PATH_INGESTION_APINAME = '$.apiName';
|
|
52219
|
-
const JSON_EXTRACT_PATH_DRAFTS = '$.drafts';
|
|
52220
52283
|
|
|
52221
52284
|
const MultiPickListValueSeparator = ';';
|
|
52222
52285
|
function filterToPredicates(where, recordType, alias, objectInfoMap, joins, draftFunctions) {
|
|
@@ -52746,18 +52809,11 @@
|
|
|
52746
52809
|
const joins = buildJoins(config);
|
|
52747
52810
|
const predicates = buildPredicates(config);
|
|
52748
52811
|
const orderBy = buildOrderBy(config);
|
|
52749
|
-
const staleRecordsSql = excludeStaleRecordsGate.isOpen({ fallback: false })
|
|
52750
|
-
? `AND (
|
|
52751
|
-
json_extract("${config.alias}".metadata, '${JSON_EXTRACT_PATH_INGESTION_TIMESTAMP}') >= ?
|
|
52752
|
-
OR json_extract("${config.alias}".data, '${JSON_EXTRACT_PATH_DRAFTS}') IS NOT NULL
|
|
52753
|
-
)`
|
|
52754
|
-
: '';
|
|
52755
52812
|
const sql = `
|
|
52756
|
-
SELECT "${config.alias}".data
|
|
52813
|
+
SELECT "${config.alias}".data, "${config.alias}".metadata
|
|
52757
52814
|
FROM lds_data "${config.alias}" ${joins.sql}
|
|
52758
52815
|
WHERE "${config.alias}".key like 'UiApi::RecordRepresentation:%'
|
|
52759
52816
|
AND json_extract("${config.alias}".data, '${JSON_EXTRACT_PATH_INGESTION_APINAME}') = '${config.alias}'
|
|
52760
|
-
${staleRecordsSql}
|
|
52761
52817
|
${predicates.sql}
|
|
52762
52818
|
${orderBy.sql}
|
|
52763
52819
|
LIMIT ?
|
|
@@ -52768,7 +52824,6 @@
|
|
|
52768
52824
|
const bindings = [
|
|
52769
52825
|
// bindings from predicates on joins
|
|
52770
52826
|
...joins.bindings,
|
|
52771
|
-
...(excludeStaleRecordsGate.isOpen({ fallback: false }) ? [config.ingestionTimestamp] : []),
|
|
52772
52827
|
// where clause and parent scope bindings
|
|
52773
52828
|
...predicates.bindings,
|
|
52774
52829
|
// limit binding
|
|
@@ -52794,33 +52849,19 @@
|
|
|
52794
52849
|
if (allJoins.length === 0)
|
|
52795
52850
|
return { sql, bindings };
|
|
52796
52851
|
sql = allJoins.reduce((joinAccumulator, join) => {
|
|
52797
|
-
let timestampAdded = false;
|
|
52798
52852
|
const joinConditions = join.conditions.reduce((conditionAccumulator, condition) => {
|
|
52799
52853
|
let joined_sql;
|
|
52800
|
-
const joinMetadataTimestamp = excludeStaleRecordsGate.isOpen({ fallback: false })
|
|
52801
|
-
? ` AND (json_extract("${join.alias}".metadata, '${JSON_EXTRACT_PATH_INGESTION_TIMESTAMP}') >= ? OR json_extract("${join.alias}".data, '${JSON_EXTRACT_PATH_DRAFTS}') IS NOT NULL)`
|
|
52802
|
-
: '';
|
|
52803
52854
|
// predicate on a value, use the newly joined table
|
|
52804
52855
|
if ('type' in condition) {
|
|
52805
52856
|
const { sql, binding } = predicateToSQL(condition, join.alias);
|
|
52806
|
-
joined_sql = ` AND ${sql}
|
|
52857
|
+
joined_sql = ` AND ${sql}`;
|
|
52807
52858
|
bindings.push(...binding);
|
|
52808
|
-
if (excludeStaleRecordsGate.isOpen({ fallback: false }) &&
|
|
52809
|
-
timestampAdded === false) {
|
|
52810
|
-
bindings.push(config.ingestionTimestamp);
|
|
52811
|
-
timestampAdded = true;
|
|
52812
|
-
}
|
|
52813
52859
|
}
|
|
52814
52860
|
else {
|
|
52815
52861
|
// predicate on a path
|
|
52816
52862
|
const left = ` AND json_extract("${join.to}".data, '${condition.leftPath}')`;
|
|
52817
52863
|
const right = `json_extract("${join.alias}".data, '${condition.rightPath}')`;
|
|
52818
|
-
joined_sql = `${left} = ${right}
|
|
52819
|
-
if (excludeStaleRecordsGate.isOpen({ fallback: false }) &&
|
|
52820
|
-
timestampAdded === false) {
|
|
52821
|
-
bindings.push(config.ingestionTimestamp);
|
|
52822
|
-
timestampAdded = true;
|
|
52823
|
-
}
|
|
52864
|
+
joined_sql = `${left} = ${right}`;
|
|
52824
52865
|
}
|
|
52825
52866
|
conditionAccumulator += joined_sql;
|
|
52826
52867
|
return conditionAccumulator;
|
|
@@ -53765,8 +53806,7 @@
|
|
|
53765
53806
|
for (const field of fields) {
|
|
53766
53807
|
if (field.name === 'node') {
|
|
53767
53808
|
field.resolve = function nodeResolver(obj, _args, { seenRecordIds }) {
|
|
53768
|
-
const {
|
|
53769
|
-
const recordRepresentation = parse$4(record);
|
|
53809
|
+
const { recordRepresentation, ingestionTimestamp } = obj;
|
|
53770
53810
|
seenRecordIds.add(recordRepresentation.id);
|
|
53771
53811
|
return { recordRepresentation, ingestionTimestamp };
|
|
53772
53812
|
};
|
|
@@ -53980,16 +54020,30 @@
|
|
|
53980
54020
|
predicates,
|
|
53981
54021
|
orderBy: orderByToPredicate(parentArgs.orderBy, alias, alias, context.objectInfos),
|
|
53982
54022
|
limit: parentArgs.first,
|
|
53983
|
-
ingestionTimestamp,
|
|
53984
54023
|
};
|
|
53985
54024
|
const { sql, bindings } = buildQuery(queryConfig);
|
|
53986
54025
|
const results = await query(sql, bindings);
|
|
53987
54026
|
//map each sql result with the ingestion timestamp to pass it down a level
|
|
53988
|
-
return results.rows
|
|
53989
|
-
|
|
53990
|
-
|
|
54027
|
+
return results.rows.map((row) => {
|
|
54028
|
+
const recordMetadataResult = {
|
|
54029
|
+
recordRepresentation: parse$4(row[0]),
|
|
54030
|
+
metadata: parse$4(row[1]),
|
|
54031
|
+
};
|
|
54032
|
+
const { recordRepresentation, metadata } = recordMetadataResult;
|
|
54033
|
+
context.seenRecordIds.add(recordRepresentation.id);
|
|
54034
|
+
if (metadata.ingestionTimestamp < ingestionTimestamp &&
|
|
54035
|
+
recordRepresentation.drafts === undefined) {
|
|
54036
|
+
if (context.possibleStaleRecordMap.has(recordRepresentation.apiName) === false) {
|
|
54037
|
+
context.possibleStaleRecordMap.set(recordRepresentation.apiName, []);
|
|
54038
|
+
}
|
|
54039
|
+
const ids = context.possibleStaleRecordMap.get(recordRepresentation.apiName);
|
|
54040
|
+
if (ids !== undefined) {
|
|
54041
|
+
ids.push(recordRepresentation.id);
|
|
54042
|
+
context.possibleStaleRecordMap.set(recordRepresentation.apiName, ids);
|
|
54043
|
+
}
|
|
54044
|
+
}
|
|
53991
54045
|
return {
|
|
53992
|
-
|
|
54046
|
+
recordRepresentation,
|
|
53993
54047
|
ingestionTimestamp,
|
|
53994
54048
|
};
|
|
53995
54049
|
});
|
|
@@ -54554,7 +54608,11 @@
|
|
|
54554
54608
|
seenRecordIds.push(queryString);
|
|
54555
54609
|
});
|
|
54556
54610
|
}
|
|
54557
|
-
return {
|
|
54611
|
+
return {
|
|
54612
|
+
result,
|
|
54613
|
+
seenRecordIds,
|
|
54614
|
+
possibleStaleRecordMap: contextValue.possibleStaleRecordMap,
|
|
54615
|
+
};
|
|
54558
54616
|
}
|
|
54559
54617
|
finally {
|
|
54560
54618
|
eventEmitter({ type: 'graphql-eval-end' });
|
|
@@ -58297,8 +58355,13 @@
|
|
|
58297
58355
|
: [];
|
|
58298
58356
|
let gqlResult;
|
|
58299
58357
|
let seenRecordIds;
|
|
58358
|
+
let possibleStaleRecordMap;
|
|
58300
58359
|
try {
|
|
58301
|
-
({
|
|
58360
|
+
({
|
|
58361
|
+
result: gqlResult,
|
|
58362
|
+
seenRecordIds,
|
|
58363
|
+
possibleStaleRecordMap,
|
|
58364
|
+
} = await evaluate({
|
|
58302
58365
|
...config,
|
|
58303
58366
|
//need to create another copy of the ast for future writes
|
|
58304
58367
|
query: parse$3(stringify$3(injectedAST)),
|
|
@@ -58328,13 +58391,18 @@
|
|
|
58328
58391
|
const seenRecords = createSeenRecords(seenRecordIds, nonEvaluatedSnapshot);
|
|
58329
58392
|
const recordId = generateUniqueRecordId();
|
|
58330
58393
|
const rebuildWithLocalEval = async (originalSnapshot) => {
|
|
58331
|
-
let { result: rebuildResult, seenRecordIds } = await evaluate({
|
|
58394
|
+
let { result: rebuildResult, seenRecordIds, possibleStaleRecordMap, } = await evaluate({
|
|
58332
58395
|
...config,
|
|
58333
58396
|
query: injectedAST,
|
|
58334
58397
|
}, observers, { userId }, objectInfoNeeded, store, originalSnapshot, graphqlSchemaCache, draftFunctions);
|
|
58335
58398
|
if (!rebuildResult.errors) {
|
|
58336
58399
|
rebuildResult = removeSyntheticFields(rebuildResult, config.query);
|
|
58337
58400
|
}
|
|
58401
|
+
let snapshotState = 'Fulfilled';
|
|
58402
|
+
if (possibleStaleRecordMap.size > 0) {
|
|
58403
|
+
initiateStaleRecordRefresh(luvio, possibleStaleRecordMap);
|
|
58404
|
+
snapshotState = 'Stale';
|
|
58405
|
+
}
|
|
58338
58406
|
if (objectsDeepEqual(rebuildResult, originalSnapshot.data)) {
|
|
58339
58407
|
return originalSnapshot;
|
|
58340
58408
|
}
|
|
@@ -58343,6 +58411,7 @@
|
|
|
58343
58411
|
...originalSnapshot,
|
|
58344
58412
|
data: rebuildResult,
|
|
58345
58413
|
recordId,
|
|
58414
|
+
state: snapshotState,
|
|
58346
58415
|
seenRecords: createSeenRecords(seenRecordIds, nonEvaluatedSnapshot),
|
|
58347
58416
|
rebuildWithLocalEval,
|
|
58348
58417
|
};
|
|
@@ -58380,6 +58449,10 @@
|
|
|
58380
58449
|
},
|
|
58381
58450
|
};
|
|
58382
58451
|
}
|
|
58452
|
+
if (possibleStaleRecordMap.size > 0) {
|
|
58453
|
+
initiateStaleRecordRefresh(luvio, possibleStaleRecordMap);
|
|
58454
|
+
resultSnapshot.state = 'Stale';
|
|
58455
|
+
}
|
|
58383
58456
|
return resultSnapshot;
|
|
58384
58457
|
};
|
|
58385
58458
|
}
|
|
@@ -58440,6 +58513,24 @@
|
|
|
58440
58513
|
};
|
|
58441
58514
|
};
|
|
58442
58515
|
}
|
|
58516
|
+
function initiateStaleRecordRefresh(luvio, keyMap) {
|
|
58517
|
+
const staleRecordKeys = from$1(keyMap.values())
|
|
58518
|
+
.flat()
|
|
58519
|
+
.map((id) => `UiApi::RecordRepresentation:${id}`);
|
|
58520
|
+
luvio.storeExpirePossibleStaleRecords(staleRecordKeys, makeGetRecordsConfig(keyMap), getRecordsAdapterFactory(luvio));
|
|
58521
|
+
}
|
|
58522
|
+
function makeGetRecordsConfig(keyMap) {
|
|
58523
|
+
const records = [];
|
|
58524
|
+
keyMap.forEach((recordIds, apiName) => {
|
|
58525
|
+
records.push({
|
|
58526
|
+
recordIds,
|
|
58527
|
+
fields: [`${apiName}.Id`],
|
|
58528
|
+
});
|
|
58529
|
+
});
|
|
58530
|
+
return {
|
|
58531
|
+
records,
|
|
58532
|
+
};
|
|
58533
|
+
}
|
|
58443
58534
|
|
|
58444
58535
|
const CONTENT_DOCUMENT_DRAFT_ID_KEY = 'CONTENT_DOCUMENT_DRAFT_ID';
|
|
58445
58536
|
const CONTENT_VERSION_DRAFT_ID_KEY = 'CONTENT_VERSION_DRAFT_ID';
|
|
@@ -62601,7 +62692,7 @@
|
|
|
62601
62692
|
id: '@salesforce/lds-network-adapter',
|
|
62602
62693
|
instrument: instrument$2,
|
|
62603
62694
|
});
|
|
62604
|
-
// version: 1.287.0-
|
|
62695
|
+
// version: 1.287.0-dev16-db839640ab
|
|
62605
62696
|
|
|
62606
62697
|
const { create: create$3, keys: keys$3 } = Object;
|
|
62607
62698
|
const { stringify: stringify$1, parse: parse$1 } = JSON;
|
|
@@ -82665,7 +82756,7 @@
|
|
|
82665
82756
|
configuration: { ...configurationForGraphQLAdapters$1 },
|
|
82666
82757
|
instrument: instrument$1,
|
|
82667
82758
|
});
|
|
82668
|
-
// version: 1.287.0-
|
|
82759
|
+
// version: 1.287.0-dev16-4d742a2467
|
|
82669
82760
|
|
|
82670
82761
|
// On core the unstable adapters are re-exported with different names,
|
|
82671
82762
|
// we want to match them here.
|
|
@@ -84921,7 +85012,7 @@
|
|
|
84921
85012
|
unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
|
|
84922
85013
|
graphQLImperative = ldsAdapter;
|
|
84923
85014
|
});
|
|
84924
|
-
// version: 1.287.0-
|
|
85015
|
+
// version: 1.287.0-dev16-4d742a2467
|
|
84925
85016
|
|
|
84926
85017
|
var gqlApi = /*#__PURE__*/Object.freeze({
|
|
84927
85018
|
__proto__: null,
|
|
@@ -85659,7 +85750,7 @@
|
|
|
85659
85750
|
function register(r) {
|
|
85660
85751
|
callbacks$1.forEach((callback) => callback(r));
|
|
85661
85752
|
}
|
|
85662
|
-
// version: 1.287.0-
|
|
85753
|
+
// version: 1.287.0-dev16-db839640ab
|
|
85663
85754
|
|
|
85664
85755
|
/**
|
|
85665
85756
|
* Returns true if the value acts like a Promise, i.e. has a "then" function,
|
|
@@ -90640,4 +90731,4 @@
|
|
|
90640
90731
|
exports.subscribeToAdapter = subscribeToAdapter;
|
|
90641
90732
|
|
|
90642
90733
|
}));
|
|
90643
|
-
// version: 1.287.0-
|
|
90734
|
+
// version: 1.287.0-dev16-db839640ab
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-worker-api",
|
|
3
|
-
"version": "1.287.0-
|
|
3
|
+
"version": "1.287.0-dev16",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "dist/standalone/es/lds-worker-api.js",
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@oat-sa/rollup-plugin-wildcard-external": "^1.0.0",
|
|
38
|
-
"@salesforce/lds-adapters-graphql": "^1.287.0-
|
|
39
|
-
"@salesforce/lds-adapters-uiapi": "^1.287.0-
|
|
40
|
-
"@salesforce/lds-default-luvio": "^1.287.0-
|
|
41
|
-
"@salesforce/lds-drafts": "^1.287.0-
|
|
42
|
-
"@salesforce/lds-graphql-parser": "^1.287.0-
|
|
43
|
-
"@salesforce/lds-luvio-engine": "^1.287.0-
|
|
44
|
-
"@salesforce/lds-priming": "^1.287.0-
|
|
45
|
-
"@salesforce/lds-runtime-mobile": "^1.287.0-
|
|
46
|
-
"@salesforce/nimbus-plugin-lds": "^1.287.0-
|
|
38
|
+
"@salesforce/lds-adapters-graphql": "^1.287.0-dev16",
|
|
39
|
+
"@salesforce/lds-adapters-uiapi": "^1.287.0-dev16",
|
|
40
|
+
"@salesforce/lds-default-luvio": "^1.287.0-dev16",
|
|
41
|
+
"@salesforce/lds-drafts": "^1.287.0-dev16",
|
|
42
|
+
"@salesforce/lds-graphql-parser": "^1.287.0-dev16",
|
|
43
|
+
"@salesforce/lds-luvio-engine": "^1.287.0-dev16",
|
|
44
|
+
"@salesforce/lds-priming": "^1.287.0-dev16",
|
|
45
|
+
"@salesforce/lds-runtime-mobile": "^1.287.0-dev16",
|
|
46
|
+
"@salesforce/nimbus-plugin-lds": "^1.287.0-dev16",
|
|
47
47
|
"ajv": "^8.11.0",
|
|
48
48
|
"glob": "^7.1.5",
|
|
49
49
|
"nimbus-types": "^2.0.0-alpha1",
|