@salesforce/lds-worker-api 1.110.1 → 1.111.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/sfdc/es/ldsWorkerApi.js +2 -1
- package/dist/sfdc/es/primingApi.d.ts +2 -1
- package/dist/standalone/es/lds-worker-api.js +258 -94
- package/dist/standalone/es/primingApi.d.ts +2 -1
- package/dist/standalone/umd/lds-worker-api.js +258 -94
- package/dist/standalone/umd/primingApi.d.ts +2 -1
- package/package.json +13 -13
|
@@ -3655,7 +3655,7 @@
|
|
|
3655
3655
|
return this.environment.buildStructuredKey(namespace, representationName, idValues);
|
|
3656
3656
|
}
|
|
3657
3657
|
}
|
|
3658
|
-
// engine version: 0.
|
|
3658
|
+
// engine version: 0.136.5-77eb3bb4
|
|
3659
3659
|
|
|
3660
3660
|
/**
|
|
3661
3661
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -3782,7 +3782,7 @@
|
|
|
3782
3782
|
}
|
|
3783
3783
|
callbacks.push(callback);
|
|
3784
3784
|
}
|
|
3785
|
-
// version: 1.
|
|
3785
|
+
// version: 1.111.0-f30e5e921
|
|
3786
3786
|
|
|
3787
3787
|
// TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
|
|
3788
3788
|
function instrumentAdapter$1(createFunction, _metadata) {
|
|
@@ -15206,7 +15206,7 @@
|
|
|
15206
15206
|
updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
|
|
15207
15207
|
return luvioDocumentNode;
|
|
15208
15208
|
}
|
|
15209
|
-
// version: 1.
|
|
15209
|
+
// version: 1.111.0-f30e5e921
|
|
15210
15210
|
|
|
15211
15211
|
function unwrap(data) {
|
|
15212
15212
|
// The lwc-luvio bindings import a function from lwc called "unwrap".
|
|
@@ -16087,7 +16087,7 @@
|
|
|
16087
16087
|
const { apiFamily, name } = metadata;
|
|
16088
16088
|
return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
|
|
16089
16089
|
}
|
|
16090
|
-
// version: 1.
|
|
16090
|
+
// version: 1.111.0-f30e5e921
|
|
16091
16091
|
|
|
16092
16092
|
/**
|
|
16093
16093
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -16170,7 +16170,7 @@
|
|
|
16170
16170
|
({
|
|
16171
16171
|
state: FragmentReadResultState.Missing,
|
|
16172
16172
|
});
|
|
16173
|
-
// engine version: 0.
|
|
16173
|
+
// engine version: 0.136.5-77eb3bb4
|
|
16174
16174
|
|
|
16175
16175
|
const { keys: ObjectKeys$3, freeze: ObjectFreeze$3, create: ObjectCreate$3 } = Object;
|
|
16176
16176
|
|
|
@@ -20824,7 +20824,7 @@
|
|
|
20824
20824
|
}
|
|
20825
20825
|
}
|
|
20826
20826
|
}
|
|
20827
|
-
function tokenForAtMost(paginationMetadata, maxOffset) {
|
|
20827
|
+
function tokenForAtMost$1(paginationMetadata, maxOffset) {
|
|
20828
20828
|
const tokens = Object.keys(paginationMetadata);
|
|
20829
20829
|
let tokenResult = undefined;
|
|
20830
20830
|
let offsetResult = -1;
|
|
@@ -22630,7 +22630,7 @@
|
|
|
22630
22630
|
return [undefined, -1];
|
|
22631
22631
|
}
|
|
22632
22632
|
const maxOffset = configTokenOffset + num;
|
|
22633
|
-
const [token, offset] = tokenForAtMost(paginationMetadata, maxOffset);
|
|
22633
|
+
const [token, offset] = tokenForAtMost$1(paginationMetadata, maxOffset);
|
|
22634
22634
|
if (token !== undefined) {
|
|
22635
22635
|
return [token, configPageSize - (offset - configTokenOffset)];
|
|
22636
22636
|
}
|
|
@@ -23051,7 +23051,7 @@
|
|
|
23051
23051
|
pageToken: config.pageToken,
|
|
23052
23052
|
pagination: {
|
|
23053
23053
|
offsetFromToken: offsetFromToken$1,
|
|
23054
|
-
tokenForAtMost,
|
|
23054
|
+
tokenForAtMost: tokenForAtMost$1,
|
|
23055
23055
|
paginationMetadata,
|
|
23056
23056
|
},
|
|
23057
23057
|
});
|
|
@@ -23406,7 +23406,7 @@
|
|
|
23406
23406
|
pageToken: config.pageToken,
|
|
23407
23407
|
pagination: {
|
|
23408
23408
|
offsetFromToken: offsetFromToken$1,
|
|
23409
|
-
tokenForAtMost,
|
|
23409
|
+
tokenForAtMost: tokenForAtMost$1,
|
|
23410
23410
|
paginationMetadata,
|
|
23411
23411
|
},
|
|
23412
23412
|
});
|
|
@@ -40373,7 +40373,7 @@
|
|
|
40373
40373
|
return [undefined, -1];
|
|
40374
40374
|
}
|
|
40375
40375
|
const maxOffset = configTokenOffset + num;
|
|
40376
|
-
const [token, offset] = tokenForAtMost(paginationMetadata, maxOffset);
|
|
40376
|
+
const [token, offset] = tokenForAtMost$1(paginationMetadata, maxOffset);
|
|
40377
40377
|
if (token !== undefined) {
|
|
40378
40378
|
return [token, configPageSize - (offset - configTokenOffset)];
|
|
40379
40379
|
}
|
|
@@ -41970,11 +41970,11 @@
|
|
|
41970
41970
|
trackedFields: optionalFieldsTrie,
|
|
41971
41971
|
serverRequestCount: 1,
|
|
41972
41972
|
}), body);
|
|
41973
|
+
const snapshot = buildCachedSnapshot$1(luvio, context, {
|
|
41974
|
+
...config,
|
|
41975
|
+
recordTypeId: responseRecordTypeId,
|
|
41976
|
+
});
|
|
41973
41977
|
return luvio.storeBroadcast().then(() => {
|
|
41974
|
-
const snapshot = buildCachedSnapshot$1(luvio, context, {
|
|
41975
|
-
...config,
|
|
41976
|
-
recordTypeId: responseRecordTypeId,
|
|
41977
|
-
});
|
|
41978
41978
|
return snapshot;
|
|
41979
41979
|
});
|
|
41980
41980
|
}, () => {
|
|
@@ -44030,7 +44030,7 @@
|
|
|
44030
44030
|
dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
|
|
44031
44031
|
});
|
|
44032
44032
|
});
|
|
44033
|
-
// version: 1.
|
|
44033
|
+
// version: 1.111.0-f30e5e921
|
|
44034
44034
|
|
|
44035
44035
|
var caseSensitiveUserId = '005B0000000GR4OIAW';
|
|
44036
44036
|
|
|
@@ -45113,10 +45113,10 @@
|
|
|
45113
45113
|
};
|
|
45114
45114
|
const storeBroadcast = function (_rebuildSnapshot, _snapshotDataAvailable) {
|
|
45115
45115
|
validateNotDisposed();
|
|
45116
|
-
//
|
|
45117
|
-
//
|
|
45118
|
-
//
|
|
45119
|
-
return
|
|
45116
|
+
// publishing to L2 is essentially "broadcasting" because the onChanged
|
|
45117
|
+
// handler will fire which will revive records to the main L1 store and
|
|
45118
|
+
// call the base storeBroadcast
|
|
45119
|
+
return publishChangesToDurableStore();
|
|
45120
45120
|
};
|
|
45121
45121
|
const publishChangesToDurableStore = function () {
|
|
45122
45122
|
validateNotDisposed();
|
|
@@ -45337,7 +45337,6 @@
|
|
|
45337
45337
|
// we don't need to prime metadata
|
|
45338
45338
|
() => { });
|
|
45339
45339
|
snapshotFromMemoryIngest = await ingestAndBroadcastFunc();
|
|
45340
|
-
await publishChangesToDurableStore();
|
|
45341
45340
|
})();
|
|
45342
45341
|
for (const key of keysToReviveAsArray) {
|
|
45343
45342
|
// we are overwriting the previous promise at this key, but that
|
|
@@ -45365,7 +45364,6 @@
|
|
|
45365
45364
|
// so all we have to do is ingest then write to L2
|
|
45366
45365
|
ingestStagingStore = buildIngestStagingStore(environment);
|
|
45367
45366
|
snapshotFromMemoryIngest = await ingestAndBroadcastFunc();
|
|
45368
|
-
await publishChangesToDurableStore();
|
|
45369
45367
|
}
|
|
45370
45368
|
if (snapshotFromMemoryIngest === undefined) {
|
|
45371
45369
|
return undefined;
|
|
@@ -45378,12 +45376,10 @@
|
|
|
45378
45376
|
const result = await reviveSnapshot(environment, durableStore, snapshotFromMemoryIngest, durableStoreErrorHandler, () => environment.storeLookup(select, environment.createSnapshot, refresh));
|
|
45379
45377
|
return result.snapshot;
|
|
45380
45378
|
};
|
|
45381
|
-
const handleErrorResponse = function (ingestAndBroadcastFunc) {
|
|
45379
|
+
const handleErrorResponse = async function (ingestAndBroadcastFunc) {
|
|
45382
45380
|
validateNotDisposed();
|
|
45383
|
-
|
|
45384
|
-
return
|
|
45385
|
-
return snapshotFromMemoryIngest;
|
|
45386
|
-
});
|
|
45381
|
+
ingestStagingStore = buildIngestStagingStore(environment);
|
|
45382
|
+
return ingestAndBroadcastFunc();
|
|
45387
45383
|
};
|
|
45388
45384
|
const getNotifyChangeStoreEntries = function (keys) {
|
|
45389
45385
|
validateNotDisposed();
|
|
@@ -48408,6 +48404,58 @@
|
|
|
48408
48404
|
* For full license text, see the LICENSE.txt file
|
|
48409
48405
|
*/
|
|
48410
48406
|
|
|
48407
|
+
/* Ideally we would use AbortController but it does not exist in V8, if it is ever polyfilled we can swap for it */
|
|
48408
|
+
class LdsAbortController {
|
|
48409
|
+
constructor() {
|
|
48410
|
+
this.signal = new AbortSignal();
|
|
48411
|
+
}
|
|
48412
|
+
abort() {
|
|
48413
|
+
this.signal.abort();
|
|
48414
|
+
}
|
|
48415
|
+
}
|
|
48416
|
+
class AbortSignal {
|
|
48417
|
+
constructor() {
|
|
48418
|
+
this._aborted = false;
|
|
48419
|
+
this.listeners = new Map();
|
|
48420
|
+
}
|
|
48421
|
+
get aborted() {
|
|
48422
|
+
return this._aborted;
|
|
48423
|
+
}
|
|
48424
|
+
addEventListener(type, listener) {
|
|
48425
|
+
let listeners = this.listeners.get(type);
|
|
48426
|
+
if (!listeners) {
|
|
48427
|
+
listeners = new Set();
|
|
48428
|
+
this.listeners.set(type, listeners);
|
|
48429
|
+
}
|
|
48430
|
+
listeners.add(listener);
|
|
48431
|
+
}
|
|
48432
|
+
removeEventListener(type, listener) {
|
|
48433
|
+
const listeners = this.listeners.get(type);
|
|
48434
|
+
if (listeners) {
|
|
48435
|
+
listeners.delete(listener);
|
|
48436
|
+
if (listeners.size === 0) {
|
|
48437
|
+
this.listeners.delete(type);
|
|
48438
|
+
}
|
|
48439
|
+
}
|
|
48440
|
+
}
|
|
48441
|
+
dispatchEvent(event) {
|
|
48442
|
+
const listeners = this.listeners.get(event.type);
|
|
48443
|
+
if (listeners) {
|
|
48444
|
+
for (const listener of listeners) {
|
|
48445
|
+
listener(this, event);
|
|
48446
|
+
}
|
|
48447
|
+
}
|
|
48448
|
+
return !event.defaultPrevented;
|
|
48449
|
+
}
|
|
48450
|
+
abort() {
|
|
48451
|
+
if (!this.aborted) {
|
|
48452
|
+
this._aborted = true;
|
|
48453
|
+
const abortEvent = new Event('abort');
|
|
48454
|
+
this.dispatchEvent(abortEvent);
|
|
48455
|
+
}
|
|
48456
|
+
}
|
|
48457
|
+
}
|
|
48458
|
+
|
|
48411
48459
|
class AsyncWorkerPool {
|
|
48412
48460
|
constructor(concurrency) {
|
|
48413
48461
|
this.queue = [];
|
|
@@ -48418,51 +48466,57 @@
|
|
|
48418
48466
|
return new Promise((resolve, reject) => {
|
|
48419
48467
|
this.queue.push({
|
|
48420
48468
|
...work,
|
|
48421
|
-
workFn: () => work.workFn().then(resolve).catch(reject),
|
|
48469
|
+
workFn: (abortController) => work.workFn(abortController).then(resolve).catch(reject),
|
|
48422
48470
|
});
|
|
48423
48471
|
this.doWork();
|
|
48424
48472
|
});
|
|
48425
48473
|
}
|
|
48426
|
-
|
|
48427
|
-
|
|
48428
|
-
|
|
48429
|
-
|
|
48430
|
-
|
|
48431
|
-
|
|
48432
|
-
|
|
48433
|
-
const { cancelFn } = work;
|
|
48474
|
+
/**
|
|
48475
|
+
* cancel all work in the queue and active work
|
|
48476
|
+
* @returns true if all work was cancelled, false if any work could not be cancelled
|
|
48477
|
+
*/
|
|
48478
|
+
cancel() {
|
|
48479
|
+
let success = true;
|
|
48480
|
+
for (const { cancelFn } of this.queue) {
|
|
48434
48481
|
if (cancelFn) {
|
|
48435
|
-
|
|
48482
|
+
try {
|
|
48483
|
+
cancelFn();
|
|
48484
|
+
}
|
|
48485
|
+
catch (_a) {
|
|
48486
|
+
success = false;
|
|
48487
|
+
}
|
|
48436
48488
|
}
|
|
48437
|
-
}
|
|
48438
|
-
|
|
48489
|
+
}
|
|
48490
|
+
this.queue = [];
|
|
48491
|
+
for (const { abortController, cancelFn } of this.activeWork) {
|
|
48492
|
+
abortController.abort();
|
|
48493
|
+
if (cancelFn) {
|
|
48494
|
+
try {
|
|
48495
|
+
cancelFn();
|
|
48496
|
+
}
|
|
48497
|
+
catch (_b) {
|
|
48498
|
+
success = false;
|
|
48499
|
+
}
|
|
48500
|
+
}
|
|
48501
|
+
}
|
|
48502
|
+
this.activeWork = [];
|
|
48503
|
+
return success;
|
|
48439
48504
|
}
|
|
48440
48505
|
doWork() {
|
|
48441
48506
|
while (this.queue.length > 0 && this.activeWork.length < this.concurrency) {
|
|
48442
48507
|
const work = this.queue.shift();
|
|
48443
48508
|
if (work) {
|
|
48444
|
-
|
|
48509
|
+
const abortController = new LdsAbortController();
|
|
48510
|
+
const newWork = { ...work, abortController };
|
|
48511
|
+
this.activeWork.push(newWork);
|
|
48445
48512
|
const { workFn } = work;
|
|
48446
|
-
workFn()
|
|
48447
|
-
.
|
|
48448
|
-
.finally(() => {
|
|
48449
|
-
this.activeWork = this.activeWork.filter((w) => w !== work);
|
|
48513
|
+
workFn(abortController).finally(() => {
|
|
48514
|
+
this.activeWork = this.activeWork.filter((w) => w !== newWork);
|
|
48450
48515
|
this.doWork();
|
|
48451
48516
|
});
|
|
48452
48517
|
}
|
|
48453
48518
|
}
|
|
48454
48519
|
}
|
|
48455
|
-
}
|
|
48456
|
-
function promiseAllSettled(promises) {
|
|
48457
|
-
return Promise.all(promises.map((promise) => promise
|
|
48458
|
-
.then((value) => ({
|
|
48459
|
-
status: 'fulfilled',
|
|
48460
|
-
value,
|
|
48461
|
-
}))
|
|
48462
|
-
.catch((reason) => ({
|
|
48463
|
-
status: 'rejected',
|
|
48464
|
-
reason,
|
|
48465
|
-
}))));
|
|
48466
48520
|
}
|
|
48467
48521
|
|
|
48468
48522
|
/**
|
|
@@ -49764,9 +49818,8 @@
|
|
|
49764
49818
|
const { response, synchronousIngest } = entry;
|
|
49765
49819
|
synchronousIngest(response, action);
|
|
49766
49820
|
}
|
|
49767
|
-
//
|
|
49768
|
-
|
|
49769
|
-
return Promise.resolve();
|
|
49821
|
+
// must call base broadcast
|
|
49822
|
+
return luvio.storeBroadcast();
|
|
49770
49823
|
},
|
|
49771
49824
|
// getTypeCacheKeysRecord uses the response, not the full path factory
|
|
49772
49825
|
// so 2nd parameter will be unused
|
|
@@ -58864,9 +58917,10 @@
|
|
|
58864
58917
|
const DEFAULT_CONCURRENCY = 6;
|
|
58865
58918
|
class PrimingSession extends EventEmitter {
|
|
58866
58919
|
constructor(config) {
|
|
58920
|
+
var _a, _b;
|
|
58867
58921
|
super();
|
|
58868
|
-
this.batchSize = config.batchSize
|
|
58869
|
-
this.concurrency = config.concurrency
|
|
58922
|
+
this.batchSize = (_a = config.batchSize) !== null && _a !== void 0 ? _a : DEFAULT_BATCH_SIZE;
|
|
58923
|
+
this.concurrency = (_b = config.concurrency) !== null && _b !== void 0 ? _b : DEFAULT_CONCURRENCY;
|
|
58870
58924
|
this.recordLoader = config.recordLoader;
|
|
58871
58925
|
this.recordIngestor = config.recordIngestor;
|
|
58872
58926
|
this.objectInfoLoader = config.objectInfoLoader;
|
|
@@ -58894,12 +58948,20 @@
|
|
|
58894
58948
|
this.enqueueBatches(availableBatches);
|
|
58895
58949
|
}
|
|
58896
58950
|
}
|
|
58951
|
+
cancel() {
|
|
58952
|
+
this.networkWorkerPool.cancel();
|
|
58953
|
+
}
|
|
58897
58954
|
// parallelizes batches of priming work
|
|
58898
58955
|
enqueueBatches(batches) {
|
|
58899
58956
|
for (const batch of batches) {
|
|
58900
58957
|
this.networkWorkerPool.push({
|
|
58901
|
-
workFn: () => {
|
|
58902
|
-
return this.recordLoader
|
|
58958
|
+
workFn: (abortController) => {
|
|
58959
|
+
return this.recordLoader
|
|
58960
|
+
.fetchRecordData(batch, abortController)
|
|
58961
|
+
.then(async (result) => {
|
|
58962
|
+
if (abortController.signal.aborted) {
|
|
58963
|
+
return;
|
|
58964
|
+
}
|
|
58903
58965
|
if (result.ok === false) {
|
|
58904
58966
|
const { error } = result;
|
|
58905
58967
|
const primingError = error === 'network-error' ? 'service-unavailable' : 'unknown';
|
|
@@ -58923,6 +58985,9 @@
|
|
|
58923
58985
|
this.recordIngestor
|
|
58924
58986
|
.insertRecords(records)
|
|
58925
58987
|
.then(({ written, conflicted }) => {
|
|
58988
|
+
if (abortController.signal.aborted) {
|
|
58989
|
+
return;
|
|
58990
|
+
}
|
|
58926
58991
|
// now that the records are persisted, emit the primed event
|
|
58927
58992
|
if (written.length > 0) {
|
|
58928
58993
|
this.emit('primed', Array.from(written));
|
|
@@ -58939,6 +59004,13 @@
|
|
|
58939
59004
|
});
|
|
58940
59005
|
});
|
|
58941
59006
|
},
|
|
59007
|
+
cancelFn: () => {
|
|
59008
|
+
this.emit('error', {
|
|
59009
|
+
ids: batch.ids,
|
|
59010
|
+
code: 'canceled',
|
|
59011
|
+
message: `batch canceled`,
|
|
59012
|
+
});
|
|
59013
|
+
},
|
|
58942
59014
|
});
|
|
58943
59015
|
}
|
|
58944
59016
|
}
|
|
@@ -58964,8 +59036,6 @@
|
|
|
58964
59036
|
}
|
|
58965
59037
|
|
|
58966
59038
|
const requiredPrefix = `required_`;
|
|
58967
|
-
// note this is automatically incremented by scripts/release/bump-api-version.js at each release
|
|
58968
|
-
const apiVersion = `v58.0`;
|
|
58969
59039
|
const requiredFieldMap = {
|
|
58970
59040
|
ApiName: 'ApiName',
|
|
58971
59041
|
Id: 'Id',
|
|
@@ -58979,10 +59049,10 @@
|
|
|
58979
59049
|
constructor(networkAdapter) {
|
|
58980
59050
|
this.networkAdapter = networkAdapter;
|
|
58981
59051
|
}
|
|
58982
|
-
async fetchRecordData(batch) {
|
|
59052
|
+
async fetchRecordData(batch, abortController) {
|
|
58983
59053
|
let rep;
|
|
58984
59054
|
try {
|
|
58985
|
-
rep = await this.callGraphQL(batch);
|
|
59055
|
+
rep = await this.callGraphQL(batch, abortController);
|
|
58986
59056
|
}
|
|
58987
59057
|
catch (e) {
|
|
58988
59058
|
return {
|
|
@@ -59024,25 +59094,9 @@
|
|
|
59024
59094
|
missingIds: Array.from(seenRecords),
|
|
59025
59095
|
};
|
|
59026
59096
|
}
|
|
59027
|
-
|
|
59097
|
+
callGraphQL(batch, abortController) {
|
|
59028
59098
|
const query = this.generateGraphQLQuery(batch.type, batch.fields);
|
|
59029
|
-
|
|
59030
|
-
baseUri: `/services/data/${apiVersion}`,
|
|
59031
|
-
basePath: '/graphql',
|
|
59032
|
-
method: 'POST',
|
|
59033
|
-
priority: 'background',
|
|
59034
|
-
body: {
|
|
59035
|
-
query,
|
|
59036
|
-
variables: {
|
|
59037
|
-
ids: batch.ids,
|
|
59038
|
-
first: batch.ids.length,
|
|
59039
|
-
},
|
|
59040
|
-
},
|
|
59041
|
-
queryParams: {},
|
|
59042
|
-
urlParams: {},
|
|
59043
|
-
headers: {},
|
|
59044
|
-
}, {});
|
|
59045
|
-
return response.body;
|
|
59099
|
+
return this.networkAdapter.postGraphQL(query, { ids: batch.ids, first: batch.ids.length }, abortController);
|
|
59046
59100
|
}
|
|
59047
59101
|
generateGraphQLQuery(type, fields) {
|
|
59048
59102
|
const fieldList = Object.keys(requiredFieldMap)
|
|
@@ -59177,8 +59231,57 @@
|
|
|
59177
59231
|
return session;
|
|
59178
59232
|
}
|
|
59179
59233
|
|
|
59234
|
+
// so eslint doesn't complain about nimbus
|
|
59235
|
+
/* global __nimbus */
|
|
59236
|
+
// note this is automatically incremented by scripts/release/bump-api-version.js at each release
|
|
59237
|
+
const apiVersion = `v58.0`;
|
|
59238
|
+
class NimbusPrimingNetworkAdapter {
|
|
59239
|
+
postGraphQL(query, variables, abortController) {
|
|
59240
|
+
return new Promise((resolve, reject) => {
|
|
59241
|
+
let listener;
|
|
59242
|
+
const unregisterListener = () => {
|
|
59243
|
+
if (listener) {
|
|
59244
|
+
abortController.signal.removeEventListener('abort', listener);
|
|
59245
|
+
}
|
|
59246
|
+
};
|
|
59247
|
+
__nimbus.plugins.LdsNetworkAdapter
|
|
59248
|
+
.sendRequest({
|
|
59249
|
+
method: 'POST',
|
|
59250
|
+
path: `/services/data/${apiVersion}/graphql`,
|
|
59251
|
+
body: JSON.stringify({
|
|
59252
|
+
query,
|
|
59253
|
+
variables,
|
|
59254
|
+
}),
|
|
59255
|
+
headers: {},
|
|
59256
|
+
queryParams: {},
|
|
59257
|
+
priority: 'background',
|
|
59258
|
+
observabilityContext: {},
|
|
59259
|
+
}, (response) => {
|
|
59260
|
+
unregisterListener();
|
|
59261
|
+
const { body } = response;
|
|
59262
|
+
if (body) {
|
|
59263
|
+
resolve(JSON.parse(body));
|
|
59264
|
+
}
|
|
59265
|
+
else {
|
|
59266
|
+
reject(new Error('No body returned from graphql endpoint'));
|
|
59267
|
+
}
|
|
59268
|
+
}, (error) => {
|
|
59269
|
+
unregisterListener();
|
|
59270
|
+
reject(error);
|
|
59271
|
+
})
|
|
59272
|
+
.then((cancellationToken) => {
|
|
59273
|
+
listener = () => {
|
|
59274
|
+
__nimbus.plugins.LdsNetworkAdapter.cancelRequest(cancellationToken);
|
|
59275
|
+
};
|
|
59276
|
+
abortController.signal.addEventListener('abort', listener);
|
|
59277
|
+
});
|
|
59278
|
+
});
|
|
59279
|
+
}
|
|
59280
|
+
}
|
|
59281
|
+
|
|
59180
59282
|
function primingSessionFactory(config) {
|
|
59181
|
-
const {
|
|
59283
|
+
const { store, objectInfoService, getLuvio } = config;
|
|
59284
|
+
const networkAdapter = new NimbusPrimingNetworkAdapter();
|
|
59182
59285
|
const recordLoader = new RecordLoaderGraphQL(networkAdapter);
|
|
59183
59286
|
const recordIngestor = new RecordIngestor(store, getLuvio);
|
|
59184
59287
|
const session = new PrimingSession({
|
|
@@ -59303,7 +59406,6 @@
|
|
|
59303
59406
|
createPrimingSession: (config) => {
|
|
59304
59407
|
return primingSessionFactory({
|
|
59305
59408
|
store: lazyBaseDurableStore,
|
|
59306
|
-
networkAdapter: lazyNetworkAdapter,
|
|
59307
59409
|
objectInfoService: lazyObjectInfoService,
|
|
59308
59410
|
getLuvio: () => lazyLuvio,
|
|
59309
59411
|
concurrency: config.concurrency,
|
|
@@ -59324,7 +59426,7 @@
|
|
|
59324
59426
|
id: '@salesforce/lds-network-adapter',
|
|
59325
59427
|
instrument: instrument$1,
|
|
59326
59428
|
});
|
|
59327
|
-
// version: 1.
|
|
59429
|
+
// version: 1.111.0-f30e5e921
|
|
59328
59430
|
|
|
59329
59431
|
const { create: create$2, keys: keys$2 } = Object;
|
|
59330
59432
|
const { stringify: stringify$1, parse: parse$1 } = JSON;
|
|
@@ -59597,6 +59699,26 @@
|
|
|
59597
59699
|
}
|
|
59598
59700
|
}
|
|
59599
59701
|
}
|
|
59702
|
+
function tokenForAtMost(paginationMetadata, maxOffset) {
|
|
59703
|
+
const tokens = Object.keys(paginationMetadata);
|
|
59704
|
+
let tokenResult = undefined;
|
|
59705
|
+
let offsetResult = -1;
|
|
59706
|
+
for (let i = 0, len = tokens.length; i < len; i++) {
|
|
59707
|
+
const token = tokens[i];
|
|
59708
|
+
const offset = paginationMetadata[token];
|
|
59709
|
+
if (token === '__END__' || offset === undefined) {
|
|
59710
|
+
continue;
|
|
59711
|
+
}
|
|
59712
|
+
if (offset === maxOffset) {
|
|
59713
|
+
return [token, offset];
|
|
59714
|
+
}
|
|
59715
|
+
if (offset < maxOffset && offset > offsetResult) {
|
|
59716
|
+
tokenResult = token;
|
|
59717
|
+
offsetResult = offset;
|
|
59718
|
+
}
|
|
59719
|
+
}
|
|
59720
|
+
return [tokenResult, offsetResult];
|
|
59721
|
+
}
|
|
59600
59722
|
function trimEdges(edges, startOffset, endOffset) {
|
|
59601
59723
|
const trimmedEdges = [];
|
|
59602
59724
|
if (edges !== undefined) {
|
|
@@ -59608,6 +59730,35 @@
|
|
|
59608
59730
|
}
|
|
59609
59731
|
}
|
|
59610
59732
|
return trimmedEdges;
|
|
59733
|
+
}
|
|
59734
|
+
function optimizePagination(metadata, firstArgName, afterArgName, variables) {
|
|
59735
|
+
if (typeof metadata === 'object' && metadata !== null && offsetFromToken(metadata, variables[afterArgName]) >= 0) {
|
|
59736
|
+
// optimize only if after cursor is unspecified in the request or it's already loaded in metadata
|
|
59737
|
+
const length = Object.keys(metadata).length;
|
|
59738
|
+
const lastTokenAndOffset = tokenForAtMost(metadata, length);
|
|
59739
|
+
if (lastTokenAndOffset !== undefined) {
|
|
59740
|
+
const [token, offset] = lastTokenAndOffset;
|
|
59741
|
+
variables[firstArgName + '_original'] = variables[firstArgName];
|
|
59742
|
+
variables[afterArgName + '_original'] = variables[afterArgName];
|
|
59743
|
+
variables[firstArgName] -= variables[afterArgName] === null ? (offset + 1) : (offset - 1);
|
|
59744
|
+
variables[afterArgName] = token;
|
|
59745
|
+
}
|
|
59746
|
+
}
|
|
59747
|
+
}
|
|
59748
|
+
function revertPaginationOptimization(variables) {
|
|
59749
|
+
if (variables) {
|
|
59750
|
+
const toBeRemoved = [];
|
|
59751
|
+
for (const key in variables) {
|
|
59752
|
+
if (key.endsWith('_original')) {
|
|
59753
|
+
const origKey = key.substring(0, key.length - '_original'.length);
|
|
59754
|
+
if (Object.prototype.hasOwnProperty.call(variables, origKey)) {
|
|
59755
|
+
variables[origKey] = variables[key];
|
|
59756
|
+
toBeRemoved.push(key);
|
|
59757
|
+
}
|
|
59758
|
+
}
|
|
59759
|
+
}
|
|
59760
|
+
toBeRemoved.forEach((k) => delete variables[k]);
|
|
59761
|
+
}
|
|
59611
59762
|
}
|
|
59612
59763
|
|
|
59613
59764
|
function applyToSelection$6(selection, directive, variables) {
|
|
@@ -66218,7 +66369,7 @@
|
|
|
66218
66369
|
});
|
|
66219
66370
|
}
|
|
66220
66371
|
function selectType$h(typename, sel, fieldData, reader, key, sink, variables, fragments) {
|
|
66221
|
-
var _a, _b, _c;
|
|
66372
|
+
var _a, _b, _c, _d, _e;
|
|
66222
66373
|
if (fieldData === null) {
|
|
66223
66374
|
reader.assignScalar(key, sink, fieldData);
|
|
66224
66375
|
return sink;
|
|
@@ -66876,6 +67027,10 @@
|
|
|
66876
67027
|
if (trimmedEdges === undefined || !listHasEnoughItems) {
|
|
66877
67028
|
reader.markMissingLink(fieldData.__ref);
|
|
66878
67029
|
reader.markMissing();
|
|
67030
|
+
// optimize pagination when "first" and "after" args are part of the variable
|
|
67031
|
+
if (((_c = firstArg === null || firstArg === void 0 ? void 0 : firstArg.value) === null || _c === void 0 ? void 0 : _c.kind) === 'Variable' && ((_d = afterArg === null || afterArg === void 0 ? void 0 : afterArg.value) === null || _d === void 0 ? void 0 : _d.kind) === 'Variable') {
|
|
67032
|
+
optimizePagination(metadata, firstArg.value.name.value, afterArg.value.name.value, variables);
|
|
67033
|
+
}
|
|
66879
67034
|
return;
|
|
66880
67035
|
}
|
|
66881
67036
|
}
|
|
@@ -66889,7 +67044,7 @@
|
|
|
66889
67044
|
const result = select$o(sel, variables, fragments)(paginatedData, reader);
|
|
66890
67045
|
const pageInfo = createPageInfo(result === null || result === void 0 ? void 0 : result.edges, startOffset, endOffset, maxOffset, metadata);
|
|
66891
67046
|
if (pageInfo !== undefined) {
|
|
66892
|
-
const selectedPageInfo = selectPageInfo$1((
|
|
67047
|
+
const selectedPageInfo = selectPageInfo$1((_e = sel.selectionSet) === null || _e === void 0 ? void 0 : _e.selections, fragments, pageInfo);
|
|
66893
67048
|
if (selectedPageInfo !== undefined) {
|
|
66894
67049
|
reader.assignNonScalar(result, 'pageInfo', selectedPageInfo);
|
|
66895
67050
|
}
|
|
@@ -68520,7 +68675,7 @@
|
|
|
68520
68675
|
}
|
|
68521
68676
|
}
|
|
68522
68677
|
function selectType$e(typename, sel, fieldData, reader, key, sink, variables, fragments) {
|
|
68523
|
-
var _a, _b, _c;
|
|
68678
|
+
var _a, _b, _c, _d, _e;
|
|
68524
68679
|
if (fieldData === null) {
|
|
68525
68680
|
reader.assignScalar(key, sink, fieldData);
|
|
68526
68681
|
return sink;
|
|
@@ -68598,6 +68753,10 @@
|
|
|
68598
68753
|
if (trimmedEdges === undefined || !listHasEnoughItems) {
|
|
68599
68754
|
reader.markMissingLink(fieldData.__ref);
|
|
68600
68755
|
reader.markMissing();
|
|
68756
|
+
// optimize pagination when "first" and "after" args are part of the variable
|
|
68757
|
+
if (((_c = firstArg === null || firstArg === void 0 ? void 0 : firstArg.value) === null || _c === void 0 ? void 0 : _c.kind) === 'Variable' && ((_d = afterArg === null || afterArg === void 0 ? void 0 : afterArg.value) === null || _d === void 0 ? void 0 : _d.kind) === 'Variable') {
|
|
68758
|
+
optimizePagination(metadata, firstArg.value.name.value, afterArg.value.name.value, variables);
|
|
68759
|
+
}
|
|
68601
68760
|
return;
|
|
68602
68761
|
}
|
|
68603
68762
|
}
|
|
@@ -68611,7 +68770,7 @@
|
|
|
68611
68770
|
const result = select$o(sel, variables, fragments)(paginatedData, reader);
|
|
68612
68771
|
const pageInfo = createPageInfo(result === null || result === void 0 ? void 0 : result.edges, startOffset, endOffset, maxOffset, metadata);
|
|
68613
68772
|
if (pageInfo !== undefined) {
|
|
68614
|
-
const selectedPageInfo = selectPageInfo((
|
|
68773
|
+
const selectedPageInfo = selectPageInfo((_e = sel.selectionSet) === null || _e === void 0 ? void 0 : _e.selections, fragments, pageInfo);
|
|
68615
68774
|
if (selectedPageInfo !== undefined) {
|
|
68616
68775
|
reader.assignNonScalar(result, 'pageInfo', selectedPageInfo);
|
|
68617
68776
|
}
|
|
@@ -75024,7 +75183,8 @@
|
|
|
75024
75183
|
return aVal < bVal ? -1 : (aVal > bVal) ? 1 : 0;
|
|
75025
75184
|
}).map((val, i) => serializeValueNode$1(val, variables) + `[${i}]`).join(',');
|
|
75026
75185
|
case ("Variable"):
|
|
75027
|
-
|
|
75186
|
+
const variableValue = variables[valueNode.name.value];
|
|
75187
|
+
return typeof variableValue === "string" ? variableValue : JSON.stringify(variableValue);
|
|
75028
75188
|
case ("NullValue"):
|
|
75029
75189
|
return "null";
|
|
75030
75190
|
case ("ObjectValue"):
|
|
@@ -75795,6 +75955,9 @@
|
|
|
75795
75955
|
const key = keyBuilder$3();
|
|
75796
75956
|
const { query, variables } = resourceParams.body;
|
|
75797
75957
|
luvio.storeIngest(key, ingest(query, variables), body);
|
|
75958
|
+
// revert the optimized pagination variables back to its original so that subsequent store lookup will include all records, not just the ones loaded by an optimized query
|
|
75959
|
+
// see optimizePagination for initial update to optimize the query
|
|
75960
|
+
revertPaginationOptimization(variables);
|
|
75798
75961
|
const snapshot = luvio.storeLookup({
|
|
75799
75962
|
recordId: key,
|
|
75800
75963
|
node: select$7(luvio, config),
|
|
@@ -76977,7 +77140,7 @@
|
|
|
76977
77140
|
configuration: { ...configurationForGraphQLAdapters },
|
|
76978
77141
|
instrument,
|
|
76979
77142
|
});
|
|
76980
|
-
// version: 1.
|
|
77143
|
+
// version: 1.111.0-f30e5e921
|
|
76981
77144
|
|
|
76982
77145
|
// On core the unstable adapters are re-exported with different names,
|
|
76983
77146
|
|
|
@@ -79106,7 +79269,7 @@
|
|
|
79106
79269
|
unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
|
|
79107
79270
|
graphQLImperative = ldsAdapter;
|
|
79108
79271
|
});
|
|
79109
|
-
// version: 1.
|
|
79272
|
+
// version: 1.111.0-f30e5e921
|
|
79110
79273
|
|
|
79111
79274
|
var gqlApi = /*#__PURE__*/Object.freeze({
|
|
79112
79275
|
__proto__: null,
|
|
@@ -79772,6 +79935,7 @@
|
|
|
79772
79935
|
}
|
|
79773
79936
|
return {
|
|
79774
79937
|
enqueue: session.enqueue.bind(session),
|
|
79938
|
+
cancel: session.cancel.bind(session),
|
|
79775
79939
|
};
|
|
79776
79940
|
}
|
|
79777
79941
|
|
|
@@ -79797,4 +79961,4 @@
|
|
|
79797
79961
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
79798
79962
|
|
|
79799
79963
|
}));
|
|
79800
|
-
// version: 1.
|
|
79964
|
+
// version: 1.111.0-f30e5e921
|
|
@@ -3,7 +3,7 @@ interface PrimingError {
|
|
|
3
3
|
code: ErrorCode;
|
|
4
4
|
message: string;
|
|
5
5
|
}
|
|
6
|
-
type ErrorCode = 'precondition-error' | 'not-found' | 'service-unavailable' | 'unknown';
|
|
6
|
+
type ErrorCode = 'precondition-error' | 'not-found' | 'service-unavailable' | 'canceled' | 'unknown';
|
|
7
7
|
interface PrimingEventHandler {
|
|
8
8
|
onError?: (error: PrimingError) => void;
|
|
9
9
|
onPrimed?: (ids: string[]) => void;
|
|
@@ -15,5 +15,6 @@ export interface PrimingSessionConfig {
|
|
|
15
15
|
}
|
|
16
16
|
export declare function createPrimingSession(config: PrimingSessionConfig): {
|
|
17
17
|
enqueue: (work: PrimingWork) => Promise<void>;
|
|
18
|
+
cancel: () => void;
|
|
18
19
|
};
|
|
19
20
|
export {};
|