@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
|
@@ -730,6 +730,7 @@ function createPrimingSession(config) {
|
|
|
730
730
|
}
|
|
731
731
|
return {
|
|
732
732
|
enqueue: session.enqueue.bind(session),
|
|
733
|
+
cancel: session.cancel.bind(session),
|
|
733
734
|
};
|
|
734
735
|
}
|
|
735
736
|
|
|
@@ -743,4 +744,4 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
743
744
|
}
|
|
744
745
|
|
|
745
746
|
export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
|
|
746
|
-
// version: 1.
|
|
747
|
+
// 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 {};
|
|
@@ -3649,7 +3649,7 @@ class Luvio {
|
|
|
3649
3649
|
return this.environment.buildStructuredKey(namespace, representationName, idValues);
|
|
3650
3650
|
}
|
|
3651
3651
|
}
|
|
3652
|
-
// engine version: 0.
|
|
3652
|
+
// engine version: 0.136.5-77eb3bb4
|
|
3653
3653
|
|
|
3654
3654
|
/**
|
|
3655
3655
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -3776,7 +3776,7 @@ function withDefaultLuvio(callback) {
|
|
|
3776
3776
|
}
|
|
3777
3777
|
callbacks.push(callback);
|
|
3778
3778
|
}
|
|
3779
|
-
// version: 1.
|
|
3779
|
+
// version: 1.111.1-dfc59aa0e
|
|
3780
3780
|
|
|
3781
3781
|
// TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
|
|
3782
3782
|
function instrumentAdapter$1(createFunction, _metadata) {
|
|
@@ -15200,7 +15200,7 @@ function parseAndVisit(source) {
|
|
|
15200
15200
|
updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
|
|
15201
15201
|
return luvioDocumentNode;
|
|
15202
15202
|
}
|
|
15203
|
-
// version: 1.
|
|
15203
|
+
// version: 1.111.1-dfc59aa0e
|
|
15204
15204
|
|
|
15205
15205
|
function unwrap(data) {
|
|
15206
15206
|
// The lwc-luvio bindings import a function from lwc called "unwrap".
|
|
@@ -16081,7 +16081,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
|
|
|
16081
16081
|
const { apiFamily, name } = metadata;
|
|
16082
16082
|
return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
|
|
16083
16083
|
}
|
|
16084
|
-
// version: 1.
|
|
16084
|
+
// version: 1.111.1-dfc59aa0e
|
|
16085
16085
|
|
|
16086
16086
|
/**
|
|
16087
16087
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -16164,7 +16164,7 @@ var FragmentReadResultState;
|
|
|
16164
16164
|
({
|
|
16165
16165
|
state: FragmentReadResultState.Missing,
|
|
16166
16166
|
});
|
|
16167
|
-
// engine version: 0.
|
|
16167
|
+
// engine version: 0.136.5-77eb3bb4
|
|
16168
16168
|
|
|
16169
16169
|
const { keys: ObjectKeys$3, freeze: ObjectFreeze$3, create: ObjectCreate$3 } = Object;
|
|
16170
16170
|
|
|
@@ -20818,7 +20818,7 @@ function tokenFromOffset$1(paginationMetadata, offset) {
|
|
|
20818
20818
|
}
|
|
20819
20819
|
}
|
|
20820
20820
|
}
|
|
20821
|
-
function tokenForAtMost(paginationMetadata, maxOffset) {
|
|
20821
|
+
function tokenForAtMost$1(paginationMetadata, maxOffset) {
|
|
20822
20822
|
const tokens = Object.keys(paginationMetadata);
|
|
20823
20823
|
let tokenResult = undefined;
|
|
20824
20824
|
let offsetResult = -1;
|
|
@@ -22624,7 +22624,7 @@ function minimizePaginationParams$1(luvio, resourceParams, cacheSnapshot) {
|
|
|
22624
22624
|
return [undefined, -1];
|
|
22625
22625
|
}
|
|
22626
22626
|
const maxOffset = configTokenOffset + num;
|
|
22627
|
-
const [token, offset] = tokenForAtMost(paginationMetadata, maxOffset);
|
|
22627
|
+
const [token, offset] = tokenForAtMost$1(paginationMetadata, maxOffset);
|
|
22628
22628
|
if (token !== undefined) {
|
|
22629
22629
|
return [token, configPageSize - (offset - configTokenOffset)];
|
|
22630
22630
|
}
|
|
@@ -23045,7 +23045,7 @@ function prepareRequest_getMruListRecords(luvio, config, listInfo, snapshot) {
|
|
|
23045
23045
|
pageToken: config.pageToken,
|
|
23046
23046
|
pagination: {
|
|
23047
23047
|
offsetFromToken: offsetFromToken$1,
|
|
23048
|
-
tokenForAtMost,
|
|
23048
|
+
tokenForAtMost: tokenForAtMost$1,
|
|
23049
23049
|
paginationMetadata,
|
|
23050
23050
|
},
|
|
23051
23051
|
});
|
|
@@ -23400,7 +23400,7 @@ function prepareRequest_getListRecords(luvio, context, config, listInfo, snapsho
|
|
|
23400
23400
|
pageToken: config.pageToken,
|
|
23401
23401
|
pagination: {
|
|
23402
23402
|
offsetFromToken: offsetFromToken$1,
|
|
23403
|
-
tokenForAtMost,
|
|
23403
|
+
tokenForAtMost: tokenForAtMost$1,
|
|
23404
23404
|
paginationMetadata,
|
|
23405
23405
|
},
|
|
23406
23406
|
});
|
|
@@ -40367,7 +40367,7 @@ function minimizePaginationParams(luvio, resourceParams, cacheSnapshot) {
|
|
|
40367
40367
|
return [undefined, -1];
|
|
40368
40368
|
}
|
|
40369
40369
|
const maxOffset = configTokenOffset + num;
|
|
40370
|
-
const [token, offset] = tokenForAtMost(paginationMetadata, maxOffset);
|
|
40370
|
+
const [token, offset] = tokenForAtMost$1(paginationMetadata, maxOffset);
|
|
40371
40371
|
if (token !== undefined) {
|
|
40372
40372
|
return [token, configPageSize - (offset - configTokenOffset)];
|
|
40373
40373
|
}
|
|
@@ -44024,7 +44024,7 @@ withDefaultLuvio((luvio) => {
|
|
|
44024
44024
|
dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
|
|
44025
44025
|
});
|
|
44026
44026
|
});
|
|
44027
|
-
// version: 1.
|
|
44027
|
+
// version: 1.111.1-dfc59aa0e
|
|
44028
44028
|
|
|
44029
44029
|
var caseSensitiveUserId = '005B0000000GR4OIAW';
|
|
44030
44030
|
|
|
@@ -45107,10 +45107,10 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
45107
45107
|
};
|
|
45108
45108
|
const storeBroadcast = function (_rebuildSnapshot, _snapshotDataAvailable) {
|
|
45109
45109
|
validateNotDisposed();
|
|
45110
|
-
//
|
|
45111
|
-
//
|
|
45112
|
-
//
|
|
45113
|
-
return
|
|
45110
|
+
// publishing to L2 is essentially "broadcasting" because the onChanged
|
|
45111
|
+
// handler will fire which will revive records to the main L1 store and
|
|
45112
|
+
// call the base storeBroadcast
|
|
45113
|
+
return publishChangesToDurableStore();
|
|
45114
45114
|
};
|
|
45115
45115
|
const publishChangesToDurableStore = function () {
|
|
45116
45116
|
validateNotDisposed();
|
|
@@ -45331,7 +45331,6 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
45331
45331
|
// we don't need to prime metadata
|
|
45332
45332
|
() => { });
|
|
45333
45333
|
snapshotFromMemoryIngest = await ingestAndBroadcastFunc();
|
|
45334
|
-
await publishChangesToDurableStore();
|
|
45335
45334
|
})();
|
|
45336
45335
|
for (const key of keysToReviveAsArray) {
|
|
45337
45336
|
// we are overwriting the previous promise at this key, but that
|
|
@@ -45359,7 +45358,6 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
45359
45358
|
// so all we have to do is ingest then write to L2
|
|
45360
45359
|
ingestStagingStore = buildIngestStagingStore(environment);
|
|
45361
45360
|
snapshotFromMemoryIngest = await ingestAndBroadcastFunc();
|
|
45362
|
-
await publishChangesToDurableStore();
|
|
45363
45361
|
}
|
|
45364
45362
|
if (snapshotFromMemoryIngest === undefined) {
|
|
45365
45363
|
return undefined;
|
|
@@ -45372,12 +45370,10 @@ function makeDurable(environment, { durableStore, instrumentation }) {
|
|
|
45372
45370
|
const result = await reviveSnapshot(environment, durableStore, snapshotFromMemoryIngest, durableStoreErrorHandler, () => environment.storeLookup(select, environment.createSnapshot, refresh));
|
|
45373
45371
|
return result.snapshot;
|
|
45374
45372
|
};
|
|
45375
|
-
const handleErrorResponse = function (ingestAndBroadcastFunc) {
|
|
45373
|
+
const handleErrorResponse = async function (ingestAndBroadcastFunc) {
|
|
45376
45374
|
validateNotDisposed();
|
|
45377
|
-
|
|
45378
|
-
return
|
|
45379
|
-
return snapshotFromMemoryIngest;
|
|
45380
|
-
});
|
|
45375
|
+
ingestStagingStore = buildIngestStagingStore(environment);
|
|
45376
|
+
return ingestAndBroadcastFunc();
|
|
45381
45377
|
};
|
|
45382
45378
|
const getNotifyChangeStoreEntries = function (keys) {
|
|
45383
45379
|
validateNotDisposed();
|
|
@@ -48402,6 +48398,58 @@ function makeStoreEval(preconditioner, objectInfoService, userId, contextProvide
|
|
|
48402
48398
|
* For full license text, see the LICENSE.txt file
|
|
48403
48399
|
*/
|
|
48404
48400
|
|
|
48401
|
+
/* Ideally we would use AbortController but it does not exist in V8, if it is ever polyfilled we can swap for it */
|
|
48402
|
+
class LdsAbortController {
|
|
48403
|
+
constructor() {
|
|
48404
|
+
this.signal = new AbortSignal();
|
|
48405
|
+
}
|
|
48406
|
+
abort() {
|
|
48407
|
+
this.signal.abort();
|
|
48408
|
+
}
|
|
48409
|
+
}
|
|
48410
|
+
class AbortSignal {
|
|
48411
|
+
constructor() {
|
|
48412
|
+
this._aborted = false;
|
|
48413
|
+
this.listeners = new Map();
|
|
48414
|
+
}
|
|
48415
|
+
get aborted() {
|
|
48416
|
+
return this._aborted;
|
|
48417
|
+
}
|
|
48418
|
+
addEventListener(type, listener) {
|
|
48419
|
+
let listeners = this.listeners.get(type);
|
|
48420
|
+
if (!listeners) {
|
|
48421
|
+
listeners = new Set();
|
|
48422
|
+
this.listeners.set(type, listeners);
|
|
48423
|
+
}
|
|
48424
|
+
listeners.add(listener);
|
|
48425
|
+
}
|
|
48426
|
+
removeEventListener(type, listener) {
|
|
48427
|
+
const listeners = this.listeners.get(type);
|
|
48428
|
+
if (listeners) {
|
|
48429
|
+
listeners.delete(listener);
|
|
48430
|
+
if (listeners.size === 0) {
|
|
48431
|
+
this.listeners.delete(type);
|
|
48432
|
+
}
|
|
48433
|
+
}
|
|
48434
|
+
}
|
|
48435
|
+
dispatchEvent(event) {
|
|
48436
|
+
const listeners = this.listeners.get(event.type);
|
|
48437
|
+
if (listeners) {
|
|
48438
|
+
for (const listener of listeners) {
|
|
48439
|
+
listener(this, event);
|
|
48440
|
+
}
|
|
48441
|
+
}
|
|
48442
|
+
return !event.defaultPrevented;
|
|
48443
|
+
}
|
|
48444
|
+
abort() {
|
|
48445
|
+
if (!this.aborted) {
|
|
48446
|
+
this._aborted = true;
|
|
48447
|
+
const abortEvent = new Event('abort');
|
|
48448
|
+
this.dispatchEvent(abortEvent);
|
|
48449
|
+
}
|
|
48450
|
+
}
|
|
48451
|
+
}
|
|
48452
|
+
|
|
48405
48453
|
class AsyncWorkerPool {
|
|
48406
48454
|
constructor(concurrency) {
|
|
48407
48455
|
this.queue = [];
|
|
@@ -48412,51 +48460,57 @@ class AsyncWorkerPool {
|
|
|
48412
48460
|
return new Promise((resolve, reject) => {
|
|
48413
48461
|
this.queue.push({
|
|
48414
48462
|
...work,
|
|
48415
|
-
workFn: () => work.workFn().then(resolve).catch(reject),
|
|
48463
|
+
workFn: (abortController) => work.workFn(abortController).then(resolve).catch(reject),
|
|
48416
48464
|
});
|
|
48417
48465
|
this.doWork();
|
|
48418
48466
|
});
|
|
48419
48467
|
}
|
|
48420
|
-
|
|
48421
|
-
|
|
48422
|
-
|
|
48423
|
-
|
|
48424
|
-
|
|
48425
|
-
|
|
48426
|
-
|
|
48427
|
-
const { cancelFn } = work;
|
|
48468
|
+
/**
|
|
48469
|
+
* cancel all work in the queue and active work
|
|
48470
|
+
* @returns true if all work was cancelled, false if any work could not be cancelled
|
|
48471
|
+
*/
|
|
48472
|
+
cancel() {
|
|
48473
|
+
let success = true;
|
|
48474
|
+
for (const { cancelFn } of this.queue) {
|
|
48428
48475
|
if (cancelFn) {
|
|
48429
|
-
|
|
48476
|
+
try {
|
|
48477
|
+
cancelFn();
|
|
48478
|
+
}
|
|
48479
|
+
catch (_a) {
|
|
48480
|
+
success = false;
|
|
48481
|
+
}
|
|
48430
48482
|
}
|
|
48431
|
-
}
|
|
48432
|
-
|
|
48483
|
+
}
|
|
48484
|
+
this.queue = [];
|
|
48485
|
+
for (const { abortController, cancelFn } of this.activeWork) {
|
|
48486
|
+
abortController.abort();
|
|
48487
|
+
if (cancelFn) {
|
|
48488
|
+
try {
|
|
48489
|
+
cancelFn();
|
|
48490
|
+
}
|
|
48491
|
+
catch (_b) {
|
|
48492
|
+
success = false;
|
|
48493
|
+
}
|
|
48494
|
+
}
|
|
48495
|
+
}
|
|
48496
|
+
this.activeWork = [];
|
|
48497
|
+
return success;
|
|
48433
48498
|
}
|
|
48434
48499
|
doWork() {
|
|
48435
48500
|
while (this.queue.length > 0 && this.activeWork.length < this.concurrency) {
|
|
48436
48501
|
const work = this.queue.shift();
|
|
48437
48502
|
if (work) {
|
|
48438
|
-
|
|
48503
|
+
const abortController = new LdsAbortController();
|
|
48504
|
+
const newWork = { ...work, abortController };
|
|
48505
|
+
this.activeWork.push(newWork);
|
|
48439
48506
|
const { workFn } = work;
|
|
48440
|
-
workFn()
|
|
48441
|
-
.
|
|
48442
|
-
.finally(() => {
|
|
48443
|
-
this.activeWork = this.activeWork.filter((w) => w !== work);
|
|
48507
|
+
workFn(abortController).finally(() => {
|
|
48508
|
+
this.activeWork = this.activeWork.filter((w) => w !== newWork);
|
|
48444
48509
|
this.doWork();
|
|
48445
48510
|
});
|
|
48446
48511
|
}
|
|
48447
48512
|
}
|
|
48448
48513
|
}
|
|
48449
|
-
}
|
|
48450
|
-
function promiseAllSettled(promises) {
|
|
48451
|
-
return Promise.all(promises.map((promise) => promise
|
|
48452
|
-
.then((value) => ({
|
|
48453
|
-
status: 'fulfilled',
|
|
48454
|
-
value,
|
|
48455
|
-
}))
|
|
48456
|
-
.catch((reason) => ({
|
|
48457
|
-
status: 'rejected',
|
|
48458
|
-
reason,
|
|
48459
|
-
}))));
|
|
48460
48514
|
}
|
|
48461
48515
|
|
|
48462
48516
|
/**
|
|
@@ -58857,9 +58911,10 @@ const DEFAULT_BATCH_SIZE = 500;
|
|
|
58857
58911
|
const DEFAULT_CONCURRENCY = 6;
|
|
58858
58912
|
class PrimingSession extends EventEmitter {
|
|
58859
58913
|
constructor(config) {
|
|
58914
|
+
var _a, _b;
|
|
58860
58915
|
super();
|
|
58861
|
-
this.batchSize = config.batchSize
|
|
58862
|
-
this.concurrency = config.concurrency
|
|
58916
|
+
this.batchSize = (_a = config.batchSize) !== null && _a !== void 0 ? _a : DEFAULT_BATCH_SIZE;
|
|
58917
|
+
this.concurrency = (_b = config.concurrency) !== null && _b !== void 0 ? _b : DEFAULT_CONCURRENCY;
|
|
58863
58918
|
this.recordLoader = config.recordLoader;
|
|
58864
58919
|
this.recordIngestor = config.recordIngestor;
|
|
58865
58920
|
this.objectInfoLoader = config.objectInfoLoader;
|
|
@@ -58887,12 +58942,20 @@ class PrimingSession extends EventEmitter {
|
|
|
58887
58942
|
this.enqueueBatches(availableBatches);
|
|
58888
58943
|
}
|
|
58889
58944
|
}
|
|
58945
|
+
cancel() {
|
|
58946
|
+
this.networkWorkerPool.cancel();
|
|
58947
|
+
}
|
|
58890
58948
|
// parallelizes batches of priming work
|
|
58891
58949
|
enqueueBatches(batches) {
|
|
58892
58950
|
for (const batch of batches) {
|
|
58893
58951
|
this.networkWorkerPool.push({
|
|
58894
|
-
workFn: () => {
|
|
58895
|
-
return this.recordLoader
|
|
58952
|
+
workFn: (abortController) => {
|
|
58953
|
+
return this.recordLoader
|
|
58954
|
+
.fetchRecordData(batch, abortController)
|
|
58955
|
+
.then(async (result) => {
|
|
58956
|
+
if (abortController.signal.aborted) {
|
|
58957
|
+
return;
|
|
58958
|
+
}
|
|
58896
58959
|
if (result.ok === false) {
|
|
58897
58960
|
const { error } = result;
|
|
58898
58961
|
const primingError = error === 'network-error' ? 'service-unavailable' : 'unknown';
|
|
@@ -58916,6 +58979,9 @@ class PrimingSession extends EventEmitter {
|
|
|
58916
58979
|
this.recordIngestor
|
|
58917
58980
|
.insertRecords(records)
|
|
58918
58981
|
.then(({ written, conflicted }) => {
|
|
58982
|
+
if (abortController.signal.aborted) {
|
|
58983
|
+
return;
|
|
58984
|
+
}
|
|
58919
58985
|
// now that the records are persisted, emit the primed event
|
|
58920
58986
|
if (written.length > 0) {
|
|
58921
58987
|
this.emit('primed', Array.from(written));
|
|
@@ -58932,6 +58998,13 @@ class PrimingSession extends EventEmitter {
|
|
|
58932
58998
|
});
|
|
58933
58999
|
});
|
|
58934
59000
|
},
|
|
59001
|
+
cancelFn: () => {
|
|
59002
|
+
this.emit('error', {
|
|
59003
|
+
ids: batch.ids,
|
|
59004
|
+
code: 'canceled',
|
|
59005
|
+
message: `batch canceled`,
|
|
59006
|
+
});
|
|
59007
|
+
},
|
|
58935
59008
|
});
|
|
58936
59009
|
}
|
|
58937
59010
|
}
|
|
@@ -58957,8 +59030,6 @@ class PrimingSession extends EventEmitter {
|
|
|
58957
59030
|
}
|
|
58958
59031
|
|
|
58959
59032
|
const requiredPrefix = `required_`;
|
|
58960
|
-
// note this is automatically incremented by scripts/release/bump-api-version.js at each release
|
|
58961
|
-
const apiVersion = `v58.0`;
|
|
58962
59033
|
const requiredFieldMap = {
|
|
58963
59034
|
ApiName: 'ApiName',
|
|
58964
59035
|
Id: 'Id',
|
|
@@ -58972,10 +59043,10 @@ class RecordLoaderGraphQL {
|
|
|
58972
59043
|
constructor(networkAdapter) {
|
|
58973
59044
|
this.networkAdapter = networkAdapter;
|
|
58974
59045
|
}
|
|
58975
|
-
async fetchRecordData(batch) {
|
|
59046
|
+
async fetchRecordData(batch, abortController) {
|
|
58976
59047
|
let rep;
|
|
58977
59048
|
try {
|
|
58978
|
-
rep = await this.callGraphQL(batch);
|
|
59049
|
+
rep = await this.callGraphQL(batch, abortController);
|
|
58979
59050
|
}
|
|
58980
59051
|
catch (e) {
|
|
58981
59052
|
return {
|
|
@@ -59017,25 +59088,9 @@ class RecordLoaderGraphQL {
|
|
|
59017
59088
|
missingIds: Array.from(seenRecords),
|
|
59018
59089
|
};
|
|
59019
59090
|
}
|
|
59020
|
-
|
|
59091
|
+
callGraphQL(batch, abortController) {
|
|
59021
59092
|
const query = this.generateGraphQLQuery(batch.type, batch.fields);
|
|
59022
|
-
|
|
59023
|
-
baseUri: `/services/data/${apiVersion}`,
|
|
59024
|
-
basePath: '/graphql',
|
|
59025
|
-
method: 'POST',
|
|
59026
|
-
priority: 'background',
|
|
59027
|
-
body: {
|
|
59028
|
-
query,
|
|
59029
|
-
variables: {
|
|
59030
|
-
ids: batch.ids,
|
|
59031
|
-
first: batch.ids.length,
|
|
59032
|
-
},
|
|
59033
|
-
},
|
|
59034
|
-
queryParams: {},
|
|
59035
|
-
urlParams: {},
|
|
59036
|
-
headers: {},
|
|
59037
|
-
}, {});
|
|
59038
|
-
return response.body;
|
|
59093
|
+
return this.networkAdapter.postGraphQL(query, { ids: batch.ids, first: batch.ids.length }, abortController);
|
|
59039
59094
|
}
|
|
59040
59095
|
generateGraphQLQuery(type, fields) {
|
|
59041
59096
|
const fieldList = Object.keys(requiredFieldMap)
|
|
@@ -59170,8 +59225,57 @@ function instrumentPrimingSession(session) {
|
|
|
59170
59225
|
return session;
|
|
59171
59226
|
}
|
|
59172
59227
|
|
|
59228
|
+
// so eslint doesn't complain about nimbus
|
|
59229
|
+
/* global __nimbus */
|
|
59230
|
+
// note this is automatically incremented by scripts/release/bump-api-version.js at each release
|
|
59231
|
+
const apiVersion = `v58.0`;
|
|
59232
|
+
class NimbusPrimingNetworkAdapter {
|
|
59233
|
+
postGraphQL(query, variables, abortController) {
|
|
59234
|
+
return new Promise((resolve, reject) => {
|
|
59235
|
+
let listener;
|
|
59236
|
+
const unregisterListener = () => {
|
|
59237
|
+
if (listener) {
|
|
59238
|
+
abortController.signal.removeEventListener('abort', listener);
|
|
59239
|
+
}
|
|
59240
|
+
};
|
|
59241
|
+
__nimbus.plugins.LdsNetworkAdapter
|
|
59242
|
+
.sendRequest({
|
|
59243
|
+
method: 'POST',
|
|
59244
|
+
path: `/services/data/${apiVersion}/graphql`,
|
|
59245
|
+
body: JSON.stringify({
|
|
59246
|
+
query,
|
|
59247
|
+
variables,
|
|
59248
|
+
}),
|
|
59249
|
+
headers: {},
|
|
59250
|
+
queryParams: {},
|
|
59251
|
+
priority: 'background',
|
|
59252
|
+
observabilityContext: {},
|
|
59253
|
+
}, (response) => {
|
|
59254
|
+
unregisterListener();
|
|
59255
|
+
const { body } = response;
|
|
59256
|
+
if (body) {
|
|
59257
|
+
resolve(JSON.parse(body));
|
|
59258
|
+
}
|
|
59259
|
+
else {
|
|
59260
|
+
reject(new Error('No body returned from graphql endpoint'));
|
|
59261
|
+
}
|
|
59262
|
+
}, (error) => {
|
|
59263
|
+
unregisterListener();
|
|
59264
|
+
reject(error);
|
|
59265
|
+
})
|
|
59266
|
+
.then((cancellationToken) => {
|
|
59267
|
+
listener = () => {
|
|
59268
|
+
__nimbus.plugins.LdsNetworkAdapter.cancelRequest(cancellationToken);
|
|
59269
|
+
};
|
|
59270
|
+
abortController.signal.addEventListener('abort', listener);
|
|
59271
|
+
});
|
|
59272
|
+
});
|
|
59273
|
+
}
|
|
59274
|
+
}
|
|
59275
|
+
|
|
59173
59276
|
function primingSessionFactory(config) {
|
|
59174
|
-
const {
|
|
59277
|
+
const { store, objectInfoService, getLuvio } = config;
|
|
59278
|
+
const networkAdapter = new NimbusPrimingNetworkAdapter();
|
|
59175
59279
|
const recordLoader = new RecordLoaderGraphQL(networkAdapter);
|
|
59176
59280
|
const recordIngestor = new RecordIngestor(store, getLuvio);
|
|
59177
59281
|
const session = new PrimingSession({
|
|
@@ -59296,7 +59400,6 @@ function getRuntime() {
|
|
|
59296
59400
|
createPrimingSession: (config) => {
|
|
59297
59401
|
return primingSessionFactory({
|
|
59298
59402
|
store: lazyBaseDurableStore,
|
|
59299
|
-
networkAdapter: lazyNetworkAdapter,
|
|
59300
59403
|
objectInfoService: lazyObjectInfoService,
|
|
59301
59404
|
getLuvio: () => lazyLuvio,
|
|
59302
59405
|
concurrency: config.concurrency,
|
|
@@ -59317,7 +59420,7 @@ register({
|
|
|
59317
59420
|
id: '@salesforce/lds-network-adapter',
|
|
59318
59421
|
instrument: instrument$1,
|
|
59319
59422
|
});
|
|
59320
|
-
// version: 1.
|
|
59423
|
+
// version: 1.111.1-dfc59aa0e
|
|
59321
59424
|
|
|
59322
59425
|
const { create: create$2, keys: keys$2 } = Object;
|
|
59323
59426
|
const { stringify: stringify$1, parse: parse$1 } = JSON;
|
|
@@ -59590,6 +59693,26 @@ function tokenFromOffset(paginationMetadata, offset) {
|
|
|
59590
59693
|
}
|
|
59591
59694
|
}
|
|
59592
59695
|
}
|
|
59696
|
+
function tokenForAtMost(paginationMetadata, maxOffset) {
|
|
59697
|
+
const tokens = Object.keys(paginationMetadata);
|
|
59698
|
+
let tokenResult = undefined;
|
|
59699
|
+
let offsetResult = -1;
|
|
59700
|
+
for (let i = 0, len = tokens.length; i < len; i++) {
|
|
59701
|
+
const token = tokens[i];
|
|
59702
|
+
const offset = paginationMetadata[token];
|
|
59703
|
+
if (token === '__END__' || offset === undefined) {
|
|
59704
|
+
continue;
|
|
59705
|
+
}
|
|
59706
|
+
if (offset === maxOffset) {
|
|
59707
|
+
return [token, offset];
|
|
59708
|
+
}
|
|
59709
|
+
if (offset < maxOffset && offset > offsetResult) {
|
|
59710
|
+
tokenResult = token;
|
|
59711
|
+
offsetResult = offset;
|
|
59712
|
+
}
|
|
59713
|
+
}
|
|
59714
|
+
return [tokenResult, offsetResult];
|
|
59715
|
+
}
|
|
59593
59716
|
function trimEdges(edges, startOffset, endOffset) {
|
|
59594
59717
|
const trimmedEdges = [];
|
|
59595
59718
|
if (edges !== undefined) {
|
|
@@ -59601,6 +59724,35 @@ function trimEdges(edges, startOffset, endOffset) {
|
|
|
59601
59724
|
}
|
|
59602
59725
|
}
|
|
59603
59726
|
return trimmedEdges;
|
|
59727
|
+
}
|
|
59728
|
+
function optimizePagination(metadata, firstArgName, afterArgName, variables) {
|
|
59729
|
+
if (typeof metadata === 'object' && metadata !== null && offsetFromToken(metadata, variables[afterArgName]) >= 0) {
|
|
59730
|
+
// optimize only if after cursor is unspecified in the request or it's already loaded in metadata
|
|
59731
|
+
const length = Object.keys(metadata).length;
|
|
59732
|
+
const lastTokenAndOffset = tokenForAtMost(metadata, length);
|
|
59733
|
+
if (lastTokenAndOffset !== undefined) {
|
|
59734
|
+
const [token, offset] = lastTokenAndOffset;
|
|
59735
|
+
variables[firstArgName + '_original'] = variables[firstArgName];
|
|
59736
|
+
variables[afterArgName + '_original'] = variables[afterArgName];
|
|
59737
|
+
variables[firstArgName] -= variables[afterArgName] === null ? (offset + 1) : (offset - 1);
|
|
59738
|
+
variables[afterArgName] = token;
|
|
59739
|
+
}
|
|
59740
|
+
}
|
|
59741
|
+
}
|
|
59742
|
+
function revertPaginationOptimization(variables) {
|
|
59743
|
+
if (variables) {
|
|
59744
|
+
const toBeRemoved = [];
|
|
59745
|
+
for (const key in variables) {
|
|
59746
|
+
if (key.endsWith('_original')) {
|
|
59747
|
+
const origKey = key.substring(0, key.length - '_original'.length);
|
|
59748
|
+
if (Object.prototype.hasOwnProperty.call(variables, origKey)) {
|
|
59749
|
+
variables[origKey] = variables[key];
|
|
59750
|
+
toBeRemoved.push(key);
|
|
59751
|
+
}
|
|
59752
|
+
}
|
|
59753
|
+
}
|
|
59754
|
+
toBeRemoved.forEach((k) => delete variables[k]);
|
|
59755
|
+
}
|
|
59604
59756
|
}
|
|
59605
59757
|
|
|
59606
59758
|
function applyToSelection$6(selection, directive, variables) {
|
|
@@ -66211,7 +66363,7 @@ function ingest$i(astNode, state) {
|
|
|
66211
66363
|
});
|
|
66212
66364
|
}
|
|
66213
66365
|
function selectType$h(typename, sel, fieldData, reader, key, sink, variables, fragments) {
|
|
66214
|
-
var _a, _b, _c;
|
|
66366
|
+
var _a, _b, _c, _d, _e;
|
|
66215
66367
|
if (fieldData === null) {
|
|
66216
66368
|
reader.assignScalar(key, sink, fieldData);
|
|
66217
66369
|
return sink;
|
|
@@ -66869,6 +67021,10 @@ function selectType$h(typename, sel, fieldData, reader, key, sink, variables, fr
|
|
|
66869
67021
|
if (trimmedEdges === undefined || !listHasEnoughItems) {
|
|
66870
67022
|
reader.markMissingLink(fieldData.__ref);
|
|
66871
67023
|
reader.markMissing();
|
|
67024
|
+
// optimize pagination when "first" and "after" args are part of the variable
|
|
67025
|
+
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') {
|
|
67026
|
+
optimizePagination(metadata, firstArg.value.name.value, afterArg.value.name.value, variables);
|
|
67027
|
+
}
|
|
66872
67028
|
return;
|
|
66873
67029
|
}
|
|
66874
67030
|
}
|
|
@@ -66882,7 +67038,7 @@ function selectType$h(typename, sel, fieldData, reader, key, sink, variables, fr
|
|
|
66882
67038
|
const result = select$o(sel, variables, fragments)(paginatedData, reader);
|
|
66883
67039
|
const pageInfo = createPageInfo(result === null || result === void 0 ? void 0 : result.edges, startOffset, endOffset, maxOffset, metadata);
|
|
66884
67040
|
if (pageInfo !== undefined) {
|
|
66885
|
-
const selectedPageInfo = selectPageInfo$1((
|
|
67041
|
+
const selectedPageInfo = selectPageInfo$1((_e = sel.selectionSet) === null || _e === void 0 ? void 0 : _e.selections, fragments, pageInfo);
|
|
66886
67042
|
if (selectedPageInfo !== undefined) {
|
|
66887
67043
|
reader.assignNonScalar(result, 'pageInfo', selectedPageInfo);
|
|
66888
67044
|
}
|
|
@@ -68513,7 +68669,7 @@ function getFieldData$e(source, sel, variables) {
|
|
|
68513
68669
|
}
|
|
68514
68670
|
}
|
|
68515
68671
|
function selectType$e(typename, sel, fieldData, reader, key, sink, variables, fragments) {
|
|
68516
|
-
var _a, _b, _c;
|
|
68672
|
+
var _a, _b, _c, _d, _e;
|
|
68517
68673
|
if (fieldData === null) {
|
|
68518
68674
|
reader.assignScalar(key, sink, fieldData);
|
|
68519
68675
|
return sink;
|
|
@@ -68591,6 +68747,10 @@ function selectType$e(typename, sel, fieldData, reader, key, sink, variables, fr
|
|
|
68591
68747
|
if (trimmedEdges === undefined || !listHasEnoughItems) {
|
|
68592
68748
|
reader.markMissingLink(fieldData.__ref);
|
|
68593
68749
|
reader.markMissing();
|
|
68750
|
+
// optimize pagination when "first" and "after" args are part of the variable
|
|
68751
|
+
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') {
|
|
68752
|
+
optimizePagination(metadata, firstArg.value.name.value, afterArg.value.name.value, variables);
|
|
68753
|
+
}
|
|
68594
68754
|
return;
|
|
68595
68755
|
}
|
|
68596
68756
|
}
|
|
@@ -68604,7 +68764,7 @@ function selectType$e(typename, sel, fieldData, reader, key, sink, variables, fr
|
|
|
68604
68764
|
const result = select$o(sel, variables, fragments)(paginatedData, reader);
|
|
68605
68765
|
const pageInfo = createPageInfo(result === null || result === void 0 ? void 0 : result.edges, startOffset, endOffset, maxOffset, metadata);
|
|
68606
68766
|
if (pageInfo !== undefined) {
|
|
68607
|
-
const selectedPageInfo = selectPageInfo((
|
|
68767
|
+
const selectedPageInfo = selectPageInfo((_e = sel.selectionSet) === null || _e === void 0 ? void 0 : _e.selections, fragments, pageInfo);
|
|
68608
68768
|
if (selectedPageInfo !== undefined) {
|
|
68609
68769
|
reader.assignNonScalar(result, 'pageInfo', selectedPageInfo);
|
|
68610
68770
|
}
|
|
@@ -75017,7 +75177,8 @@ function serializeValueNode$1(valueNode, variables) {
|
|
|
75017
75177
|
return aVal < bVal ? -1 : (aVal > bVal) ? 1 : 0;
|
|
75018
75178
|
}).map((val, i) => serializeValueNode$1(val, variables) + `[${i}]`).join(',');
|
|
75019
75179
|
case ("Variable"):
|
|
75020
|
-
|
|
75180
|
+
const variableValue = variables[valueNode.name.value];
|
|
75181
|
+
return typeof variableValue === "string" ? variableValue : JSON.stringify(variableValue);
|
|
75021
75182
|
case ("NullValue"):
|
|
75022
75183
|
return "null";
|
|
75023
75184
|
case ("ObjectValue"):
|
|
@@ -75788,6 +75949,9 @@ function ingestSuccess$1(luvio, config, resourceParams, response, snapshotRefres
|
|
|
75788
75949
|
const key = keyBuilder$3();
|
|
75789
75950
|
const { query, variables } = resourceParams.body;
|
|
75790
75951
|
luvio.storeIngest(key, ingest(query, variables), body);
|
|
75952
|
+
// 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
|
|
75953
|
+
// see optimizePagination for initial update to optimize the query
|
|
75954
|
+
revertPaginationOptimization(variables);
|
|
75791
75955
|
const snapshot = luvio.storeLookup({
|
|
75792
75956
|
recordId: key,
|
|
75793
75957
|
node: select$7(luvio, config),
|
|
@@ -76970,7 +77134,7 @@ register({
|
|
|
76970
77134
|
configuration: { ...configurationForGraphQLAdapters },
|
|
76971
77135
|
instrument,
|
|
76972
77136
|
});
|
|
76973
|
-
// version: 1.
|
|
77137
|
+
// version: 1.111.1-dfc59aa0e
|
|
76974
77138
|
|
|
76975
77139
|
// On core the unstable adapters are re-exported with different names,
|
|
76976
77140
|
|
|
@@ -79099,7 +79263,7 @@ withDefaultLuvio((luvio) => {
|
|
|
79099
79263
|
unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
|
|
79100
79264
|
graphQLImperative = ldsAdapter;
|
|
79101
79265
|
});
|
|
79102
|
-
// version: 1.
|
|
79266
|
+
// version: 1.111.1-dfc59aa0e
|
|
79103
79267
|
|
|
79104
79268
|
var gqlApi = /*#__PURE__*/Object.freeze({
|
|
79105
79269
|
__proto__: null,
|
|
@@ -79765,6 +79929,7 @@ function createPrimingSession(config) {
|
|
|
79765
79929
|
}
|
|
79766
79930
|
return {
|
|
79767
79931
|
enqueue: session.enqueue.bind(session),
|
|
79932
|
+
cancel: session.cancel.bind(session),
|
|
79768
79933
|
};
|
|
79769
79934
|
}
|
|
79770
79935
|
|
|
@@ -79773,4 +79938,4 @@ const { luvio } = getRuntime();
|
|
|
79773
79938
|
setDefaultLuvio({ luvio });
|
|
79774
79939
|
|
|
79775
79940
|
export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
|
|
79776
|
-
// version: 1.
|
|
79941
|
+
// version: 1.111.1-dfc59aa0e
|