@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
|
@@ -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.0-f30e5e921
|
|
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.0-f30e5e921
|
|
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.0-f30e5e921
|
|
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
|
}
|
|
@@ -41964,11 +41964,11 @@ const buildNetworkSnapshot$6 = (luvio, context, config, options) => {
|
|
|
41964
41964
|
trackedFields: optionalFieldsTrie,
|
|
41965
41965
|
serverRequestCount: 1,
|
|
41966
41966
|
}), body);
|
|
41967
|
+
const snapshot = buildCachedSnapshot$1(luvio, context, {
|
|
41968
|
+
...config,
|
|
41969
|
+
recordTypeId: responseRecordTypeId,
|
|
41970
|
+
});
|
|
41967
41971
|
return luvio.storeBroadcast().then(() => {
|
|
41968
|
-
const snapshot = buildCachedSnapshot$1(luvio, context, {
|
|
41969
|
-
...config,
|
|
41970
|
-
recordTypeId: responseRecordTypeId,
|
|
41971
|
-
});
|
|
41972
41972
|
return snapshot;
|
|
41973
41973
|
});
|
|
41974
41974
|
}, () => {
|
|
@@ -44024,7 +44024,7 @@ withDefaultLuvio((luvio) => {
|
|
|
44024
44024
|
dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
|
|
44025
44025
|
});
|
|
44026
44026
|
});
|
|
44027
|
-
// version: 1.
|
|
44027
|
+
// version: 1.111.0-f30e5e921
|
|
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
|
/**
|
|
@@ -49758,9 +49812,8 @@ class AbstractResourceRequestActionHandler {
|
|
|
49758
49812
|
const { response, synchronousIngest } = entry;
|
|
49759
49813
|
synchronousIngest(response, action);
|
|
49760
49814
|
}
|
|
49761
|
-
//
|
|
49762
|
-
|
|
49763
|
-
return Promise.resolve();
|
|
49815
|
+
// must call base broadcast
|
|
49816
|
+
return luvio.storeBroadcast();
|
|
49764
49817
|
},
|
|
49765
49818
|
// getTypeCacheKeysRecord uses the response, not the full path factory
|
|
49766
49819
|
// so 2nd parameter will be unused
|
|
@@ -58858,9 +58911,10 @@ const DEFAULT_BATCH_SIZE = 500;
|
|
|
58858
58911
|
const DEFAULT_CONCURRENCY = 6;
|
|
58859
58912
|
class PrimingSession extends EventEmitter {
|
|
58860
58913
|
constructor(config) {
|
|
58914
|
+
var _a, _b;
|
|
58861
58915
|
super();
|
|
58862
|
-
this.batchSize = config.batchSize
|
|
58863
|
-
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;
|
|
58864
58918
|
this.recordLoader = config.recordLoader;
|
|
58865
58919
|
this.recordIngestor = config.recordIngestor;
|
|
58866
58920
|
this.objectInfoLoader = config.objectInfoLoader;
|
|
@@ -58888,12 +58942,20 @@ class PrimingSession extends EventEmitter {
|
|
|
58888
58942
|
this.enqueueBatches(availableBatches);
|
|
58889
58943
|
}
|
|
58890
58944
|
}
|
|
58945
|
+
cancel() {
|
|
58946
|
+
this.networkWorkerPool.cancel();
|
|
58947
|
+
}
|
|
58891
58948
|
// parallelizes batches of priming work
|
|
58892
58949
|
enqueueBatches(batches) {
|
|
58893
58950
|
for (const batch of batches) {
|
|
58894
58951
|
this.networkWorkerPool.push({
|
|
58895
|
-
workFn: () => {
|
|
58896
|
-
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
|
+
}
|
|
58897
58959
|
if (result.ok === false) {
|
|
58898
58960
|
const { error } = result;
|
|
58899
58961
|
const primingError = error === 'network-error' ? 'service-unavailable' : 'unknown';
|
|
@@ -58917,6 +58979,9 @@ class PrimingSession extends EventEmitter {
|
|
|
58917
58979
|
this.recordIngestor
|
|
58918
58980
|
.insertRecords(records)
|
|
58919
58981
|
.then(({ written, conflicted }) => {
|
|
58982
|
+
if (abortController.signal.aborted) {
|
|
58983
|
+
return;
|
|
58984
|
+
}
|
|
58920
58985
|
// now that the records are persisted, emit the primed event
|
|
58921
58986
|
if (written.length > 0) {
|
|
58922
58987
|
this.emit('primed', Array.from(written));
|
|
@@ -58933,6 +58998,13 @@ class PrimingSession extends EventEmitter {
|
|
|
58933
58998
|
});
|
|
58934
58999
|
});
|
|
58935
59000
|
},
|
|
59001
|
+
cancelFn: () => {
|
|
59002
|
+
this.emit('error', {
|
|
59003
|
+
ids: batch.ids,
|
|
59004
|
+
code: 'canceled',
|
|
59005
|
+
message: `batch canceled`,
|
|
59006
|
+
});
|
|
59007
|
+
},
|
|
58936
59008
|
});
|
|
58937
59009
|
}
|
|
58938
59010
|
}
|
|
@@ -58958,8 +59030,6 @@ class PrimingSession extends EventEmitter {
|
|
|
58958
59030
|
}
|
|
58959
59031
|
|
|
58960
59032
|
const requiredPrefix = `required_`;
|
|
58961
|
-
// note this is automatically incremented by scripts/release/bump-api-version.js at each release
|
|
58962
|
-
const apiVersion = `v58.0`;
|
|
58963
59033
|
const requiredFieldMap = {
|
|
58964
59034
|
ApiName: 'ApiName',
|
|
58965
59035
|
Id: 'Id',
|
|
@@ -58973,10 +59043,10 @@ class RecordLoaderGraphQL {
|
|
|
58973
59043
|
constructor(networkAdapter) {
|
|
58974
59044
|
this.networkAdapter = networkAdapter;
|
|
58975
59045
|
}
|
|
58976
|
-
async fetchRecordData(batch) {
|
|
59046
|
+
async fetchRecordData(batch, abortController) {
|
|
58977
59047
|
let rep;
|
|
58978
59048
|
try {
|
|
58979
|
-
rep = await this.callGraphQL(batch);
|
|
59049
|
+
rep = await this.callGraphQL(batch, abortController);
|
|
58980
59050
|
}
|
|
58981
59051
|
catch (e) {
|
|
58982
59052
|
return {
|
|
@@ -59018,25 +59088,9 @@ class RecordLoaderGraphQL {
|
|
|
59018
59088
|
missingIds: Array.from(seenRecords),
|
|
59019
59089
|
};
|
|
59020
59090
|
}
|
|
59021
|
-
|
|
59091
|
+
callGraphQL(batch, abortController) {
|
|
59022
59092
|
const query = this.generateGraphQLQuery(batch.type, batch.fields);
|
|
59023
|
-
|
|
59024
|
-
baseUri: `/services/data/${apiVersion}`,
|
|
59025
|
-
basePath: '/graphql',
|
|
59026
|
-
method: 'POST',
|
|
59027
|
-
priority: 'background',
|
|
59028
|
-
body: {
|
|
59029
|
-
query,
|
|
59030
|
-
variables: {
|
|
59031
|
-
ids: batch.ids,
|
|
59032
|
-
first: batch.ids.length,
|
|
59033
|
-
},
|
|
59034
|
-
},
|
|
59035
|
-
queryParams: {},
|
|
59036
|
-
urlParams: {},
|
|
59037
|
-
headers: {},
|
|
59038
|
-
}, {});
|
|
59039
|
-
return response.body;
|
|
59093
|
+
return this.networkAdapter.postGraphQL(query, { ids: batch.ids, first: batch.ids.length }, abortController);
|
|
59040
59094
|
}
|
|
59041
59095
|
generateGraphQLQuery(type, fields) {
|
|
59042
59096
|
const fieldList = Object.keys(requiredFieldMap)
|
|
@@ -59171,8 +59225,57 @@ function instrumentPrimingSession(session) {
|
|
|
59171
59225
|
return session;
|
|
59172
59226
|
}
|
|
59173
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
|
+
|
|
59174
59276
|
function primingSessionFactory(config) {
|
|
59175
|
-
const {
|
|
59277
|
+
const { store, objectInfoService, getLuvio } = config;
|
|
59278
|
+
const networkAdapter = new NimbusPrimingNetworkAdapter();
|
|
59176
59279
|
const recordLoader = new RecordLoaderGraphQL(networkAdapter);
|
|
59177
59280
|
const recordIngestor = new RecordIngestor(store, getLuvio);
|
|
59178
59281
|
const session = new PrimingSession({
|
|
@@ -59297,7 +59400,6 @@ function getRuntime() {
|
|
|
59297
59400
|
createPrimingSession: (config) => {
|
|
59298
59401
|
return primingSessionFactory({
|
|
59299
59402
|
store: lazyBaseDurableStore,
|
|
59300
|
-
networkAdapter: lazyNetworkAdapter,
|
|
59301
59403
|
objectInfoService: lazyObjectInfoService,
|
|
59302
59404
|
getLuvio: () => lazyLuvio,
|
|
59303
59405
|
concurrency: config.concurrency,
|
|
@@ -59318,7 +59420,7 @@ register({
|
|
|
59318
59420
|
id: '@salesforce/lds-network-adapter',
|
|
59319
59421
|
instrument: instrument$1,
|
|
59320
59422
|
});
|
|
59321
|
-
// version: 1.
|
|
59423
|
+
// version: 1.111.0-f30e5e921
|
|
59322
59424
|
|
|
59323
59425
|
const { create: create$2, keys: keys$2 } = Object;
|
|
59324
59426
|
const { stringify: stringify$1, parse: parse$1 } = JSON;
|
|
@@ -59591,6 +59693,26 @@ function tokenFromOffset(paginationMetadata, offset) {
|
|
|
59591
59693
|
}
|
|
59592
59694
|
}
|
|
59593
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
|
+
}
|
|
59594
59716
|
function trimEdges(edges, startOffset, endOffset) {
|
|
59595
59717
|
const trimmedEdges = [];
|
|
59596
59718
|
if (edges !== undefined) {
|
|
@@ -59602,6 +59724,35 @@ function trimEdges(edges, startOffset, endOffset) {
|
|
|
59602
59724
|
}
|
|
59603
59725
|
}
|
|
59604
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
|
+
}
|
|
59605
59756
|
}
|
|
59606
59757
|
|
|
59607
59758
|
function applyToSelection$6(selection, directive, variables) {
|
|
@@ -66212,7 +66363,7 @@ function ingest$i(astNode, state) {
|
|
|
66212
66363
|
});
|
|
66213
66364
|
}
|
|
66214
66365
|
function selectType$h(typename, sel, fieldData, reader, key, sink, variables, fragments) {
|
|
66215
|
-
var _a, _b, _c;
|
|
66366
|
+
var _a, _b, _c, _d, _e;
|
|
66216
66367
|
if (fieldData === null) {
|
|
66217
66368
|
reader.assignScalar(key, sink, fieldData);
|
|
66218
66369
|
return sink;
|
|
@@ -66870,6 +67021,10 @@ function selectType$h(typename, sel, fieldData, reader, key, sink, variables, fr
|
|
|
66870
67021
|
if (trimmedEdges === undefined || !listHasEnoughItems) {
|
|
66871
67022
|
reader.markMissingLink(fieldData.__ref);
|
|
66872
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
|
+
}
|
|
66873
67028
|
return;
|
|
66874
67029
|
}
|
|
66875
67030
|
}
|
|
@@ -66883,7 +67038,7 @@ function selectType$h(typename, sel, fieldData, reader, key, sink, variables, fr
|
|
|
66883
67038
|
const result = select$o(sel, variables, fragments)(paginatedData, reader);
|
|
66884
67039
|
const pageInfo = createPageInfo(result === null || result === void 0 ? void 0 : result.edges, startOffset, endOffset, maxOffset, metadata);
|
|
66885
67040
|
if (pageInfo !== undefined) {
|
|
66886
|
-
const selectedPageInfo = selectPageInfo$1((
|
|
67041
|
+
const selectedPageInfo = selectPageInfo$1((_e = sel.selectionSet) === null || _e === void 0 ? void 0 : _e.selections, fragments, pageInfo);
|
|
66887
67042
|
if (selectedPageInfo !== undefined) {
|
|
66888
67043
|
reader.assignNonScalar(result, 'pageInfo', selectedPageInfo);
|
|
66889
67044
|
}
|
|
@@ -68514,7 +68669,7 @@ function getFieldData$e(source, sel, variables) {
|
|
|
68514
68669
|
}
|
|
68515
68670
|
}
|
|
68516
68671
|
function selectType$e(typename, sel, fieldData, reader, key, sink, variables, fragments) {
|
|
68517
|
-
var _a, _b, _c;
|
|
68672
|
+
var _a, _b, _c, _d, _e;
|
|
68518
68673
|
if (fieldData === null) {
|
|
68519
68674
|
reader.assignScalar(key, sink, fieldData);
|
|
68520
68675
|
return sink;
|
|
@@ -68592,6 +68747,10 @@ function selectType$e(typename, sel, fieldData, reader, key, sink, variables, fr
|
|
|
68592
68747
|
if (trimmedEdges === undefined || !listHasEnoughItems) {
|
|
68593
68748
|
reader.markMissingLink(fieldData.__ref);
|
|
68594
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
|
+
}
|
|
68595
68754
|
return;
|
|
68596
68755
|
}
|
|
68597
68756
|
}
|
|
@@ -68605,7 +68764,7 @@ function selectType$e(typename, sel, fieldData, reader, key, sink, variables, fr
|
|
|
68605
68764
|
const result = select$o(sel, variables, fragments)(paginatedData, reader);
|
|
68606
68765
|
const pageInfo = createPageInfo(result === null || result === void 0 ? void 0 : result.edges, startOffset, endOffset, maxOffset, metadata);
|
|
68607
68766
|
if (pageInfo !== undefined) {
|
|
68608
|
-
const selectedPageInfo = selectPageInfo((
|
|
68767
|
+
const selectedPageInfo = selectPageInfo((_e = sel.selectionSet) === null || _e === void 0 ? void 0 : _e.selections, fragments, pageInfo);
|
|
68609
68768
|
if (selectedPageInfo !== undefined) {
|
|
68610
68769
|
reader.assignNonScalar(result, 'pageInfo', selectedPageInfo);
|
|
68611
68770
|
}
|
|
@@ -75018,7 +75177,8 @@ function serializeValueNode$1(valueNode, variables) {
|
|
|
75018
75177
|
return aVal < bVal ? -1 : (aVal > bVal) ? 1 : 0;
|
|
75019
75178
|
}).map((val, i) => serializeValueNode$1(val, variables) + `[${i}]`).join(',');
|
|
75020
75179
|
case ("Variable"):
|
|
75021
|
-
|
|
75180
|
+
const variableValue = variables[valueNode.name.value];
|
|
75181
|
+
return typeof variableValue === "string" ? variableValue : JSON.stringify(variableValue);
|
|
75022
75182
|
case ("NullValue"):
|
|
75023
75183
|
return "null";
|
|
75024
75184
|
case ("ObjectValue"):
|
|
@@ -75789,6 +75949,9 @@ function ingestSuccess$1(luvio, config, resourceParams, response, snapshotRefres
|
|
|
75789
75949
|
const key = keyBuilder$3();
|
|
75790
75950
|
const { query, variables } = resourceParams.body;
|
|
75791
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);
|
|
75792
75955
|
const snapshot = luvio.storeLookup({
|
|
75793
75956
|
recordId: key,
|
|
75794
75957
|
node: select$7(luvio, config),
|
|
@@ -76971,7 +77134,7 @@ register({
|
|
|
76971
77134
|
configuration: { ...configurationForGraphQLAdapters },
|
|
76972
77135
|
instrument,
|
|
76973
77136
|
});
|
|
76974
|
-
// version: 1.
|
|
77137
|
+
// version: 1.111.0-f30e5e921
|
|
76975
77138
|
|
|
76976
77139
|
// On core the unstable adapters are re-exported with different names,
|
|
76977
77140
|
|
|
@@ -79100,7 +79263,7 @@ withDefaultLuvio((luvio) => {
|
|
|
79100
79263
|
unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
|
|
79101
79264
|
graphQLImperative = ldsAdapter;
|
|
79102
79265
|
});
|
|
79103
|
-
// version: 1.
|
|
79266
|
+
// version: 1.111.0-f30e5e921
|
|
79104
79267
|
|
|
79105
79268
|
var gqlApi = /*#__PURE__*/Object.freeze({
|
|
79106
79269
|
__proto__: null,
|
|
@@ -79766,6 +79929,7 @@ function createPrimingSession(config) {
|
|
|
79766
79929
|
}
|
|
79767
79930
|
return {
|
|
79768
79931
|
enqueue: session.enqueue.bind(session),
|
|
79932
|
+
cancel: session.cancel.bind(session),
|
|
79769
79933
|
};
|
|
79770
79934
|
}
|
|
79771
79935
|
|
|
@@ -79774,4 +79938,4 @@ const { luvio } = getRuntime();
|
|
|
79774
79938
|
setDefaultLuvio({ luvio });
|
|
79775
79939
|
|
|
79776
79940
|
export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
|
|
79777
|
-
// version: 1.
|
|
79941
|
+
// 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 {};
|