@salesforce/lds-worker-api 1.110.2 → 1.111.1
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 +252 -87
- package/dist/standalone/es/primingApi.d.ts +2 -1
- package/dist/standalone/umd/lds-worker-api.js +252 -87
- package/dist/standalone/umd/primingApi.d.ts +2 -1
- package/package.json +13 -13
|
@@ -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 {};
|
|
@@ -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.1-dfc59aa0e
|
|
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.1-dfc59aa0e
|
|
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.1-dfc59aa0e
|
|
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
|
}
|
|
@@ -44030,7 +44030,7 @@
|
|
|
44030
44030
|
dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
|
|
44031
44031
|
});
|
|
44032
44032
|
});
|
|
44033
|
-
// version: 1.
|
|
44033
|
+
// version: 1.111.1-dfc59aa0e
|
|
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
|
/**
|
|
@@ -58863,9 +58917,10 @@
|
|
|
58863
58917
|
const DEFAULT_CONCURRENCY = 6;
|
|
58864
58918
|
class PrimingSession extends EventEmitter {
|
|
58865
58919
|
constructor(config) {
|
|
58920
|
+
var _a, _b;
|
|
58866
58921
|
super();
|
|
58867
|
-
this.batchSize = config.batchSize
|
|
58868
|
-
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;
|
|
58869
58924
|
this.recordLoader = config.recordLoader;
|
|
58870
58925
|
this.recordIngestor = config.recordIngestor;
|
|
58871
58926
|
this.objectInfoLoader = config.objectInfoLoader;
|
|
@@ -58893,12 +58948,20 @@
|
|
|
58893
58948
|
this.enqueueBatches(availableBatches);
|
|
58894
58949
|
}
|
|
58895
58950
|
}
|
|
58951
|
+
cancel() {
|
|
58952
|
+
this.networkWorkerPool.cancel();
|
|
58953
|
+
}
|
|
58896
58954
|
// parallelizes batches of priming work
|
|
58897
58955
|
enqueueBatches(batches) {
|
|
58898
58956
|
for (const batch of batches) {
|
|
58899
58957
|
this.networkWorkerPool.push({
|
|
58900
|
-
workFn: () => {
|
|
58901
|
-
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
|
+
}
|
|
58902
58965
|
if (result.ok === false) {
|
|
58903
58966
|
const { error } = result;
|
|
58904
58967
|
const primingError = error === 'network-error' ? 'service-unavailable' : 'unknown';
|
|
@@ -58922,6 +58985,9 @@
|
|
|
58922
58985
|
this.recordIngestor
|
|
58923
58986
|
.insertRecords(records)
|
|
58924
58987
|
.then(({ written, conflicted }) => {
|
|
58988
|
+
if (abortController.signal.aborted) {
|
|
58989
|
+
return;
|
|
58990
|
+
}
|
|
58925
58991
|
// now that the records are persisted, emit the primed event
|
|
58926
58992
|
if (written.length > 0) {
|
|
58927
58993
|
this.emit('primed', Array.from(written));
|
|
@@ -58938,6 +59004,13 @@
|
|
|
58938
59004
|
});
|
|
58939
59005
|
});
|
|
58940
59006
|
},
|
|
59007
|
+
cancelFn: () => {
|
|
59008
|
+
this.emit('error', {
|
|
59009
|
+
ids: batch.ids,
|
|
59010
|
+
code: 'canceled',
|
|
59011
|
+
message: `batch canceled`,
|
|
59012
|
+
});
|
|
59013
|
+
},
|
|
58941
59014
|
});
|
|
58942
59015
|
}
|
|
58943
59016
|
}
|
|
@@ -58963,8 +59036,6 @@
|
|
|
58963
59036
|
}
|
|
58964
59037
|
|
|
58965
59038
|
const requiredPrefix = `required_`;
|
|
58966
|
-
// note this is automatically incremented by scripts/release/bump-api-version.js at each release
|
|
58967
|
-
const apiVersion = `v58.0`;
|
|
58968
59039
|
const requiredFieldMap = {
|
|
58969
59040
|
ApiName: 'ApiName',
|
|
58970
59041
|
Id: 'Id',
|
|
@@ -58978,10 +59049,10 @@
|
|
|
58978
59049
|
constructor(networkAdapter) {
|
|
58979
59050
|
this.networkAdapter = networkAdapter;
|
|
58980
59051
|
}
|
|
58981
|
-
async fetchRecordData(batch) {
|
|
59052
|
+
async fetchRecordData(batch, abortController) {
|
|
58982
59053
|
let rep;
|
|
58983
59054
|
try {
|
|
58984
|
-
rep = await this.callGraphQL(batch);
|
|
59055
|
+
rep = await this.callGraphQL(batch, abortController);
|
|
58985
59056
|
}
|
|
58986
59057
|
catch (e) {
|
|
58987
59058
|
return {
|
|
@@ -59023,25 +59094,9 @@
|
|
|
59023
59094
|
missingIds: Array.from(seenRecords),
|
|
59024
59095
|
};
|
|
59025
59096
|
}
|
|
59026
|
-
|
|
59097
|
+
callGraphQL(batch, abortController) {
|
|
59027
59098
|
const query = this.generateGraphQLQuery(batch.type, batch.fields);
|
|
59028
|
-
|
|
59029
|
-
baseUri: `/services/data/${apiVersion}`,
|
|
59030
|
-
basePath: '/graphql',
|
|
59031
|
-
method: 'POST',
|
|
59032
|
-
priority: 'background',
|
|
59033
|
-
body: {
|
|
59034
|
-
query,
|
|
59035
|
-
variables: {
|
|
59036
|
-
ids: batch.ids,
|
|
59037
|
-
first: batch.ids.length,
|
|
59038
|
-
},
|
|
59039
|
-
},
|
|
59040
|
-
queryParams: {},
|
|
59041
|
-
urlParams: {},
|
|
59042
|
-
headers: {},
|
|
59043
|
-
}, {});
|
|
59044
|
-
return response.body;
|
|
59099
|
+
return this.networkAdapter.postGraphQL(query, { ids: batch.ids, first: batch.ids.length }, abortController);
|
|
59045
59100
|
}
|
|
59046
59101
|
generateGraphQLQuery(type, fields) {
|
|
59047
59102
|
const fieldList = Object.keys(requiredFieldMap)
|
|
@@ -59176,8 +59231,57 @@
|
|
|
59176
59231
|
return session;
|
|
59177
59232
|
}
|
|
59178
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
|
+
|
|
59179
59282
|
function primingSessionFactory(config) {
|
|
59180
|
-
const {
|
|
59283
|
+
const { store, objectInfoService, getLuvio } = config;
|
|
59284
|
+
const networkAdapter = new NimbusPrimingNetworkAdapter();
|
|
59181
59285
|
const recordLoader = new RecordLoaderGraphQL(networkAdapter);
|
|
59182
59286
|
const recordIngestor = new RecordIngestor(store, getLuvio);
|
|
59183
59287
|
const session = new PrimingSession({
|
|
@@ -59302,7 +59406,6 @@
|
|
|
59302
59406
|
createPrimingSession: (config) => {
|
|
59303
59407
|
return primingSessionFactory({
|
|
59304
59408
|
store: lazyBaseDurableStore,
|
|
59305
|
-
networkAdapter: lazyNetworkAdapter,
|
|
59306
59409
|
objectInfoService: lazyObjectInfoService,
|
|
59307
59410
|
getLuvio: () => lazyLuvio,
|
|
59308
59411
|
concurrency: config.concurrency,
|
|
@@ -59323,7 +59426,7 @@
|
|
|
59323
59426
|
id: '@salesforce/lds-network-adapter',
|
|
59324
59427
|
instrument: instrument$1,
|
|
59325
59428
|
});
|
|
59326
|
-
// version: 1.
|
|
59429
|
+
// version: 1.111.1-dfc59aa0e
|
|
59327
59430
|
|
|
59328
59431
|
const { create: create$2, keys: keys$2 } = Object;
|
|
59329
59432
|
const { stringify: stringify$1, parse: parse$1 } = JSON;
|
|
@@ -59596,6 +59699,26 @@
|
|
|
59596
59699
|
}
|
|
59597
59700
|
}
|
|
59598
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
|
+
}
|
|
59599
59722
|
function trimEdges(edges, startOffset, endOffset) {
|
|
59600
59723
|
const trimmedEdges = [];
|
|
59601
59724
|
if (edges !== undefined) {
|
|
@@ -59607,6 +59730,35 @@
|
|
|
59607
59730
|
}
|
|
59608
59731
|
}
|
|
59609
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
|
+
}
|
|
59610
59762
|
}
|
|
59611
59763
|
|
|
59612
59764
|
function applyToSelection$6(selection, directive, variables) {
|
|
@@ -66217,7 +66369,7 @@
|
|
|
66217
66369
|
});
|
|
66218
66370
|
}
|
|
66219
66371
|
function selectType$h(typename, sel, fieldData, reader, key, sink, variables, fragments) {
|
|
66220
|
-
var _a, _b, _c;
|
|
66372
|
+
var _a, _b, _c, _d, _e;
|
|
66221
66373
|
if (fieldData === null) {
|
|
66222
66374
|
reader.assignScalar(key, sink, fieldData);
|
|
66223
66375
|
return sink;
|
|
@@ -66875,6 +67027,10 @@
|
|
|
66875
67027
|
if (trimmedEdges === undefined || !listHasEnoughItems) {
|
|
66876
67028
|
reader.markMissingLink(fieldData.__ref);
|
|
66877
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
|
+
}
|
|
66878
67034
|
return;
|
|
66879
67035
|
}
|
|
66880
67036
|
}
|
|
@@ -66888,7 +67044,7 @@
|
|
|
66888
67044
|
const result = select$o(sel, variables, fragments)(paginatedData, reader);
|
|
66889
67045
|
const pageInfo = createPageInfo(result === null || result === void 0 ? void 0 : result.edges, startOffset, endOffset, maxOffset, metadata);
|
|
66890
67046
|
if (pageInfo !== undefined) {
|
|
66891
|
-
const selectedPageInfo = selectPageInfo$1((
|
|
67047
|
+
const selectedPageInfo = selectPageInfo$1((_e = sel.selectionSet) === null || _e === void 0 ? void 0 : _e.selections, fragments, pageInfo);
|
|
66892
67048
|
if (selectedPageInfo !== undefined) {
|
|
66893
67049
|
reader.assignNonScalar(result, 'pageInfo', selectedPageInfo);
|
|
66894
67050
|
}
|
|
@@ -68519,7 +68675,7 @@
|
|
|
68519
68675
|
}
|
|
68520
68676
|
}
|
|
68521
68677
|
function selectType$e(typename, sel, fieldData, reader, key, sink, variables, fragments) {
|
|
68522
|
-
var _a, _b, _c;
|
|
68678
|
+
var _a, _b, _c, _d, _e;
|
|
68523
68679
|
if (fieldData === null) {
|
|
68524
68680
|
reader.assignScalar(key, sink, fieldData);
|
|
68525
68681
|
return sink;
|
|
@@ -68597,6 +68753,10 @@
|
|
|
68597
68753
|
if (trimmedEdges === undefined || !listHasEnoughItems) {
|
|
68598
68754
|
reader.markMissingLink(fieldData.__ref);
|
|
68599
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
|
+
}
|
|
68600
68760
|
return;
|
|
68601
68761
|
}
|
|
68602
68762
|
}
|
|
@@ -68610,7 +68770,7 @@
|
|
|
68610
68770
|
const result = select$o(sel, variables, fragments)(paginatedData, reader);
|
|
68611
68771
|
const pageInfo = createPageInfo(result === null || result === void 0 ? void 0 : result.edges, startOffset, endOffset, maxOffset, metadata);
|
|
68612
68772
|
if (pageInfo !== undefined) {
|
|
68613
|
-
const selectedPageInfo = selectPageInfo((
|
|
68773
|
+
const selectedPageInfo = selectPageInfo((_e = sel.selectionSet) === null || _e === void 0 ? void 0 : _e.selections, fragments, pageInfo);
|
|
68614
68774
|
if (selectedPageInfo !== undefined) {
|
|
68615
68775
|
reader.assignNonScalar(result, 'pageInfo', selectedPageInfo);
|
|
68616
68776
|
}
|
|
@@ -75023,7 +75183,8 @@
|
|
|
75023
75183
|
return aVal < bVal ? -1 : (aVal > bVal) ? 1 : 0;
|
|
75024
75184
|
}).map((val, i) => serializeValueNode$1(val, variables) + `[${i}]`).join(',');
|
|
75025
75185
|
case ("Variable"):
|
|
75026
|
-
|
|
75186
|
+
const variableValue = variables[valueNode.name.value];
|
|
75187
|
+
return typeof variableValue === "string" ? variableValue : JSON.stringify(variableValue);
|
|
75027
75188
|
case ("NullValue"):
|
|
75028
75189
|
return "null";
|
|
75029
75190
|
case ("ObjectValue"):
|
|
@@ -75794,6 +75955,9 @@
|
|
|
75794
75955
|
const key = keyBuilder$3();
|
|
75795
75956
|
const { query, variables } = resourceParams.body;
|
|
75796
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);
|
|
75797
75961
|
const snapshot = luvio.storeLookup({
|
|
75798
75962
|
recordId: key,
|
|
75799
75963
|
node: select$7(luvio, config),
|
|
@@ -76976,7 +77140,7 @@
|
|
|
76976
77140
|
configuration: { ...configurationForGraphQLAdapters },
|
|
76977
77141
|
instrument,
|
|
76978
77142
|
});
|
|
76979
|
-
// version: 1.
|
|
77143
|
+
// version: 1.111.1-dfc59aa0e
|
|
76980
77144
|
|
|
76981
77145
|
// On core the unstable adapters are re-exported with different names,
|
|
76982
77146
|
|
|
@@ -79105,7 +79269,7 @@
|
|
|
79105
79269
|
unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
|
|
79106
79270
|
graphQLImperative = ldsAdapter;
|
|
79107
79271
|
});
|
|
79108
|
-
// version: 1.
|
|
79272
|
+
// version: 1.111.1-dfc59aa0e
|
|
79109
79273
|
|
|
79110
79274
|
var gqlApi = /*#__PURE__*/Object.freeze({
|
|
79111
79275
|
__proto__: null,
|
|
@@ -79771,6 +79935,7 @@
|
|
|
79771
79935
|
}
|
|
79772
79936
|
return {
|
|
79773
79937
|
enqueue: session.enqueue.bind(session),
|
|
79938
|
+
cancel: session.cancel.bind(session),
|
|
79774
79939
|
};
|
|
79775
79940
|
}
|
|
79776
79941
|
|
|
@@ -79796,4 +79961,4 @@
|
|
|
79796
79961
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
79797
79962
|
|
|
79798
79963
|
}));
|
|
79799
|
-
// version: 1.
|
|
79964
|
+
// version: 1.111.1-dfc59aa0e
|
|
@@ -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 {};
|