@salesforce/lds-worker-api 1.371.0 → 1.372.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 +151 -2
- package/dist/sfdc/es/types/customOneStoreAdapter.d.ts +21 -0
- package/dist/sfdc/es/types/main.d.ts +2 -1
- package/dist/standalone/es/lds-worker-api.js +333 -37
- package/dist/standalone/es/types/customOneStoreAdapter.d.ts +21 -0
- package/dist/standalone/es/types/main.d.ts +2 -1
- package/dist/standalone/umd/lds-worker-api.js +333 -36
- package/dist/standalone/umd/types/customOneStoreAdapter.d.ts +21 -0
- package/dist/standalone/umd/types/main.d.ts +2 -1
- package/package.json +11 -11
|
@@ -4274,7 +4274,7 @@ function withDefaultLuvio(callback) {
|
|
|
4274
4274
|
}
|
|
4275
4275
|
callbacks.push(callback);
|
|
4276
4276
|
}
|
|
4277
|
-
// version: 1.
|
|
4277
|
+
// version: 1.372.1-5ff6849fe2
|
|
4278
4278
|
|
|
4279
4279
|
// TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
|
|
4280
4280
|
function instrumentAdapter$1(createFunction, _metadata) {
|
|
@@ -5118,6 +5118,24 @@ function snapshotToTuple(snapshot) {
|
|
|
5118
5118
|
}
|
|
5119
5119
|
return payload;
|
|
5120
5120
|
}
|
|
5121
|
+
/**
|
|
5122
|
+
* The graphql batch snapshot should be treated the same as a regular imperative adapter snapshot.
|
|
5123
|
+
* @param snapshot - The snapshot to convert to a tuple
|
|
5124
|
+
* @returns The tuple representation of the snapshot
|
|
5125
|
+
*/
|
|
5126
|
+
function batchSnapshotToTuple(snapshot) {
|
|
5127
|
+
if (isErrorSnapshot$2(snapshot)) {
|
|
5128
|
+
return {
|
|
5129
|
+
data: undefined,
|
|
5130
|
+
error: snapshot.error,
|
|
5131
|
+
};
|
|
5132
|
+
}
|
|
5133
|
+
// We might still get pending snapshot here from invoke calls here
|
|
5134
|
+
return {
|
|
5135
|
+
data: snapshot.data,
|
|
5136
|
+
error: undefined,
|
|
5137
|
+
};
|
|
5138
|
+
}
|
|
5121
5139
|
function createInvalidConfigError() {
|
|
5122
5140
|
return {
|
|
5123
5141
|
data: undefined,
|
|
@@ -5145,7 +5163,9 @@ function createGraphQLImperativeAdapter(luvio, adapter, metadata, astResolver) {
|
|
|
5145
5163
|
const { name } = metadata;
|
|
5146
5164
|
const imperativeAdapterInvoke = (config, requestContext, callback) => {
|
|
5147
5165
|
let coercedConfig = null;
|
|
5166
|
+
let isBatch = false;
|
|
5148
5167
|
if ('batchQuery' in config) {
|
|
5168
|
+
isBatch = true;
|
|
5149
5169
|
coercedConfig = {
|
|
5150
5170
|
batchQuery: config.batchQuery.map((individualConfig) => ({
|
|
5151
5171
|
...individualConfig,
|
|
@@ -5175,7 +5195,9 @@ function createGraphQLImperativeAdapter(luvio, adapter, metadata, astResolver) {
|
|
|
5175
5195
|
return;
|
|
5176
5196
|
}
|
|
5177
5197
|
if (!isPromise$3(snapshotOrPromise)) {
|
|
5178
|
-
callback(
|
|
5198
|
+
callback(isBatch
|
|
5199
|
+
? batchSnapshotToTuple(snapshotOrPromise)
|
|
5200
|
+
: snapshotToTuple(snapshotOrPromise));
|
|
5179
5201
|
return;
|
|
5180
5202
|
}
|
|
5181
5203
|
snapshotOrPromise
|
|
@@ -5184,7 +5206,7 @@ function createGraphQLImperativeAdapter(luvio, adapter, metadata, astResolver) {
|
|
|
5184
5206
|
callback(createInvalidConfigError());
|
|
5185
5207
|
return;
|
|
5186
5208
|
}
|
|
5187
|
-
callback(snapshotToTuple(snapshot));
|
|
5209
|
+
callback(isBatch ? batchSnapshotToTuple(snapshot) : snapshotToTuple(snapshot));
|
|
5188
5210
|
})
|
|
5189
5211
|
.finally(() => {
|
|
5190
5212
|
luvio.storeCleanup();
|
|
@@ -5199,7 +5221,9 @@ function createGraphQLImperativeAdapter(luvio, adapter, metadata, astResolver) {
|
|
|
5199
5221
|
let subscriberCallback = callback;
|
|
5200
5222
|
let unsub;
|
|
5201
5223
|
let coercedConfig = null;
|
|
5224
|
+
let isBatch = false;
|
|
5202
5225
|
if ('batchQuery' in config) {
|
|
5226
|
+
isBatch = true;
|
|
5203
5227
|
coercedConfig = {
|
|
5204
5228
|
batchQuery: config.batchQuery.map((individualConfig) => ({
|
|
5205
5229
|
...individualConfig,
|
|
@@ -5232,7 +5256,9 @@ function createGraphQLImperativeAdapter(luvio, adapter, metadata, astResolver) {
|
|
|
5232
5256
|
const luvioStoreSubscribe = (snapshot) => {
|
|
5233
5257
|
unsub = luvio.storeSubscribe(snapshot, (snapshotFromRebuild) => {
|
|
5234
5258
|
if (subscriberCallback !== null && !isPendingSnapshot(snapshotFromRebuild)) {
|
|
5235
|
-
subscriberCallback(
|
|
5259
|
+
subscriberCallback(isBatch
|
|
5260
|
+
? batchSnapshotToTuple(snapshotFromRebuild)
|
|
5261
|
+
: snapshotToTuple(snapshotFromRebuild));
|
|
5236
5262
|
}
|
|
5237
5263
|
});
|
|
5238
5264
|
};
|
|
@@ -5240,7 +5266,9 @@ function createGraphQLImperativeAdapter(luvio, adapter, metadata, astResolver) {
|
|
|
5240
5266
|
// We don't want to return pending snapshots to user-land
|
|
5241
5267
|
// Instead we just subscribe to it
|
|
5242
5268
|
if (!isPendingSnapshot(snapshotOrPromise)) {
|
|
5243
|
-
subscriberCallback(
|
|
5269
|
+
subscriberCallback(isBatch
|
|
5270
|
+
? batchSnapshotToTuple(snapshotOrPromise)
|
|
5271
|
+
: snapshotToTuple(snapshotOrPromise));
|
|
5244
5272
|
}
|
|
5245
5273
|
luvioStoreSubscribe(snapshotOrPromise);
|
|
5246
5274
|
}
|
|
@@ -5255,7 +5283,7 @@ function createGraphQLImperativeAdapter(luvio, adapter, metadata, astResolver) {
|
|
|
5255
5283
|
// We don't want to return pending snapshots to user-land
|
|
5256
5284
|
// Instead we just subscribe to it
|
|
5257
5285
|
if (!isPendingSnapshot(snapshot)) {
|
|
5258
|
-
subscriberCallback(snapshotToTuple(snapshot));
|
|
5286
|
+
subscriberCallback(isBatch ? batchSnapshotToTuple(snapshot) : snapshotToTuple(snapshot));
|
|
5259
5287
|
}
|
|
5260
5288
|
luvioStoreSubscribe(snapshot);
|
|
5261
5289
|
}
|
|
@@ -5290,7 +5318,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
|
|
|
5290
5318
|
const { apiFamily, name } = metadata;
|
|
5291
5319
|
return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
|
|
5292
5320
|
}
|
|
5293
|
-
// version: 1.
|
|
5321
|
+
// version: 1.372.1-5ff6849fe2
|
|
5294
5322
|
|
|
5295
5323
|
/**
|
|
5296
5324
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -34166,7 +34194,7 @@ withDefaultLuvio((luvio) => {
|
|
|
34166
34194
|
throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
|
|
34167
34195
|
throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
|
|
34168
34196
|
});
|
|
34169
|
-
// version: 1.
|
|
34197
|
+
// version: 1.372.1-8824ae9dd4
|
|
34170
34198
|
|
|
34171
34199
|
function requestIdleDetectedCallback(_callback) { }
|
|
34172
34200
|
function declareNotifierTaskSingle(_name) {
|
|
@@ -94197,14 +94225,20 @@ let AuraCacheControlCommand$1 = class AuraCacheControlCommand extends CacheContr
|
|
|
94197
94225
|
async coerceFetchError(errorResponse) {
|
|
94198
94226
|
return toError(errorResponse.statusText);
|
|
94199
94227
|
}
|
|
94228
|
+
processAuraReturnValue(auraReturnValue) {
|
|
94229
|
+
return ok$1(auraReturnValue);
|
|
94230
|
+
}
|
|
94231
|
+
processFetchReturnValue(json) {
|
|
94232
|
+
return ok$1(json);
|
|
94233
|
+
}
|
|
94200
94234
|
convertAuraResponseToData(responsePromise, coerceError) {
|
|
94201
94235
|
return responsePromise.then((response) => {
|
|
94202
|
-
|
|
94236
|
+
return this.processAuraReturnValue(response.getReturnValue());
|
|
94237
|
+
}).finally(() => {
|
|
94203
94238
|
try {
|
|
94204
94239
|
this.afterRequestHooks({ statusCode: 200 });
|
|
94205
94240
|
} catch (e) {
|
|
94206
94241
|
}
|
|
94207
|
-
return ok$1(auraReturnValue);
|
|
94208
94242
|
}).catch((error) => {
|
|
94209
94243
|
if (!error || !error.getError) {
|
|
94210
94244
|
return err$1(toError("Failed to get error from response"));
|
|
@@ -94223,7 +94257,9 @@ let AuraCacheControlCommand$1 = class AuraCacheControlCommand extends CacheContr
|
|
|
94223
94257
|
(response2) => {
|
|
94224
94258
|
if (response2.ok) {
|
|
94225
94259
|
return response2.json().then(
|
|
94226
|
-
(json) =>
|
|
94260
|
+
(json) => {
|
|
94261
|
+
return this.processFetchReturnValue(json);
|
|
94262
|
+
},
|
|
94227
94263
|
(reason) => err$1(toError(reason))
|
|
94228
94264
|
).finally(() => {
|
|
94229
94265
|
try {
|
|
@@ -94328,14 +94364,20 @@ class AuraCacheControlCommand extends CacheControlCommand {
|
|
|
94328
94364
|
async coerceFetchError(errorResponse) {
|
|
94329
94365
|
return toError(errorResponse.statusText);
|
|
94330
94366
|
}
|
|
94367
|
+
processAuraReturnValue(auraReturnValue) {
|
|
94368
|
+
return ok$1(auraReturnValue);
|
|
94369
|
+
}
|
|
94370
|
+
processFetchReturnValue(json) {
|
|
94371
|
+
return ok$1(json);
|
|
94372
|
+
}
|
|
94331
94373
|
convertAuraResponseToData(responsePromise, coerceError) {
|
|
94332
94374
|
return responsePromise.then((response) => {
|
|
94333
|
-
|
|
94375
|
+
return this.processAuraReturnValue(response.getReturnValue());
|
|
94376
|
+
}).finally(() => {
|
|
94334
94377
|
try {
|
|
94335
94378
|
this.afterRequestHooks({ statusCode: 200 });
|
|
94336
94379
|
} catch (e) {
|
|
94337
94380
|
}
|
|
94338
|
-
return ok$1(auraReturnValue);
|
|
94339
94381
|
}).catch((error) => {
|
|
94340
94382
|
if (!error || !error.getError) {
|
|
94341
94383
|
return err$1(toError("Failed to get error from response"));
|
|
@@ -94354,7 +94396,9 @@ class AuraCacheControlCommand extends CacheControlCommand {
|
|
|
94354
94396
|
(response2) => {
|
|
94355
94397
|
if (response2.ok) {
|
|
94356
94398
|
return response2.json().then(
|
|
94357
|
-
(json) =>
|
|
94399
|
+
(json) => {
|
|
94400
|
+
return this.processFetchReturnValue(json);
|
|
94401
|
+
},
|
|
94358
94402
|
(reason) => err$1(toError(reason))
|
|
94359
94403
|
).finally(() => {
|
|
94360
94404
|
try {
|
|
@@ -94547,12 +94591,17 @@ class HttpCacheControlCommand extends CacheControlCommand {
|
|
|
94547
94591
|
async coerceError(errorResponse) {
|
|
94548
94592
|
return toError(errorResponse.statusText);
|
|
94549
94593
|
}
|
|
94594
|
+
processFetchReturnValue(json) {
|
|
94595
|
+
return ok$1(json);
|
|
94596
|
+
}
|
|
94550
94597
|
convertFetchResponseToData(response) {
|
|
94551
94598
|
return response.then(
|
|
94552
94599
|
(response2) => {
|
|
94553
94600
|
if (response2.ok) {
|
|
94554
94601
|
return response2.json().then(
|
|
94555
|
-
(json) =>
|
|
94602
|
+
(json) => {
|
|
94603
|
+
return this.processFetchReturnValue(json);
|
|
94604
|
+
},
|
|
94556
94605
|
(reason) => err$1(toError(reason))
|
|
94557
94606
|
).finally(() => {
|
|
94558
94607
|
try {
|
|
@@ -95484,12 +95533,31 @@ function buildNimbusFetchServiceDescriptor() {
|
|
|
95484
95533
|
const service = (...args) => {
|
|
95485
95534
|
const resourceRequest = convertFetchParamsToResourceRequest(args);
|
|
95486
95535
|
const context = {};
|
|
95487
|
-
return NimbusNetworkAdapter(resourceRequest, context)
|
|
95488
|
-
|
|
95536
|
+
return NimbusNetworkAdapter(resourceRequest, context)
|
|
95537
|
+
.then((response) => {
|
|
95538
|
+
// This is a hack to make the response compatible with the Response interface
|
|
95539
|
+
const r = {
|
|
95540
|
+
body: response.body,
|
|
95489
95541
|
headers: response.headers,
|
|
95490
95542
|
status: response.status,
|
|
95491
95543
|
statusText: response.statusText,
|
|
95492
|
-
|
|
95544
|
+
json: () => {
|
|
95545
|
+
return Promise.resolve(response.body);
|
|
95546
|
+
},
|
|
95547
|
+
ok: response.status >= 200 && response.status < 300,
|
|
95548
|
+
};
|
|
95549
|
+
return r;
|
|
95550
|
+
})
|
|
95551
|
+
.catch((error) => {
|
|
95552
|
+
// Create a Response-like error object
|
|
95553
|
+
return {
|
|
95554
|
+
body: null,
|
|
95555
|
+
headers: {},
|
|
95556
|
+
status: 500,
|
|
95557
|
+
statusText: error.message || 'Internal Server Error',
|
|
95558
|
+
json: () => Promise.resolve(null),
|
|
95559
|
+
ok: false,
|
|
95560
|
+
};
|
|
95493
95561
|
});
|
|
95494
95562
|
};
|
|
95495
95563
|
return {
|
|
@@ -95508,38 +95576,113 @@ function buildNimbusFetchServiceDescriptor() {
|
|
|
95508
95576
|
* @returns A ResourceRequest object compatible with NimbusNetworkAdapter
|
|
95509
95577
|
*/
|
|
95510
95578
|
function convertFetchParamsToResourceRequest([input, init]) {
|
|
95511
|
-
const
|
|
95512
|
-
|
|
95513
|
-
: input instanceof URL
|
|
95514
|
-
? input
|
|
95515
|
-
: new URL(input.url);
|
|
95579
|
+
const urlString = typeof input === 'string' ? input : input.href || input.url || input;
|
|
95580
|
+
const { baseUri, basePath, queryParams } = parseUrlParts(urlString);
|
|
95516
95581
|
const headers = {};
|
|
95517
95582
|
if (init?.headers) {
|
|
95518
|
-
if (init
|
|
95583
|
+
if (typeof Headers !== 'undefined' && init?.headers instanceof Headers) {
|
|
95519
95584
|
init.headers.forEach((value, key) => {
|
|
95520
95585
|
headers[key] = value;
|
|
95521
95586
|
});
|
|
95522
95587
|
}
|
|
95523
|
-
else if (Array.isArray(init
|
|
95588
|
+
else if (Array.isArray(init?.headers)) {
|
|
95524
95589
|
init.headers.forEach(([key, value]) => {
|
|
95525
95590
|
headers[key] = value;
|
|
95526
95591
|
});
|
|
95527
95592
|
}
|
|
95528
95593
|
else {
|
|
95529
|
-
Object.entries(init
|
|
95594
|
+
Object.entries(init?.headers || {}).forEach(([key, value]) => {
|
|
95530
95595
|
headers[key] = value;
|
|
95531
95596
|
});
|
|
95532
95597
|
}
|
|
95533
95598
|
}
|
|
95534
|
-
|
|
95535
|
-
baseUri
|
|
95536
|
-
basePath
|
|
95599
|
+
const resourceRequest = {
|
|
95600
|
+
baseUri,
|
|
95601
|
+
basePath,
|
|
95537
95602
|
method: (init?.method || 'GET').toLowerCase(),
|
|
95538
|
-
body: init?.body || null,
|
|
95539
95603
|
headers,
|
|
95540
|
-
|
|
95604
|
+
body: (() => {
|
|
95605
|
+
if (!init?.body) {
|
|
95606
|
+
return null;
|
|
95607
|
+
}
|
|
95608
|
+
try {
|
|
95609
|
+
return typeof init.body === 'string' ? JSON.parse(init.body) : init.body;
|
|
95610
|
+
}
|
|
95611
|
+
catch {
|
|
95612
|
+
return init.body;
|
|
95613
|
+
}
|
|
95614
|
+
})(),
|
|
95615
|
+
queryParams,
|
|
95541
95616
|
urlParams: {},
|
|
95542
95617
|
};
|
|
95618
|
+
return resourceRequest;
|
|
95619
|
+
}
|
|
95620
|
+
function parseUrlParts(urlString) {
|
|
95621
|
+
// Split by protocol first
|
|
95622
|
+
const [protocol, rest] = urlString.split('://');
|
|
95623
|
+
// If no protocol, treat whole string as path
|
|
95624
|
+
if (!rest) {
|
|
95625
|
+
return {
|
|
95626
|
+
baseUri: '',
|
|
95627
|
+
basePath: urlString.startsWith('/')
|
|
95628
|
+
? urlString.split('?')[0]
|
|
95629
|
+
: `/${urlString.split('?')[0]}`,
|
|
95630
|
+
queryParams: extractQueryParams(urlString),
|
|
95631
|
+
};
|
|
95632
|
+
}
|
|
95633
|
+
// Split remaining parts
|
|
95634
|
+
const parts = rest.split('/');
|
|
95635
|
+
let hostPart = parts[0] || '';
|
|
95636
|
+
const pathParts = parts.slice(1);
|
|
95637
|
+
// Handle query string in host part (e.g., "example.com?key=value")
|
|
95638
|
+
let hostQueryString = '';
|
|
95639
|
+
if (hostPart.includes('?')) {
|
|
95640
|
+
const [host, query] = hostPart.split('?');
|
|
95641
|
+
hostPart = host;
|
|
95642
|
+
hostQueryString = query;
|
|
95643
|
+
}
|
|
95644
|
+
// Handle query string in path parts
|
|
95645
|
+
const lastPart = pathParts[pathParts.length - 1] || '';
|
|
95646
|
+
const [pathEnd, pathQueryString] = lastPart.split('?');
|
|
95647
|
+
// Combine query strings (host takes precedence if both exist)
|
|
95648
|
+
const queryString = hostQueryString || pathQueryString;
|
|
95649
|
+
// Reconstruct
|
|
95650
|
+
const baseUri = hostPart ? `${protocol}://${hostPart}` : urlString;
|
|
95651
|
+
const basePath = pathParts.length > 0 ? `/${pathParts.slice(0, -1).concat(pathEnd).join('/')}` : '/';
|
|
95652
|
+
const queryParams = {};
|
|
95653
|
+
if (queryString) {
|
|
95654
|
+
queryString.split('&').forEach((param) => {
|
|
95655
|
+
const [key, value = ''] = param.split('=');
|
|
95656
|
+
if (key) {
|
|
95657
|
+
try {
|
|
95658
|
+
queryParams[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
95659
|
+
}
|
|
95660
|
+
catch {
|
|
95661
|
+
queryParams[key] = value;
|
|
95662
|
+
}
|
|
95663
|
+
}
|
|
95664
|
+
});
|
|
95665
|
+
}
|
|
95666
|
+
return { baseUri, basePath, queryParams };
|
|
95667
|
+
}
|
|
95668
|
+
function extractQueryParams(urlString) {
|
|
95669
|
+
const queryParams = {};
|
|
95670
|
+
const queryStart = urlString.indexOf('?');
|
|
95671
|
+
if (queryStart > -1) {
|
|
95672
|
+
const queryString = urlString.substring(queryStart + 1);
|
|
95673
|
+
queryString.split('&').forEach((param) => {
|
|
95674
|
+
const [key, value = ''] = param.split('=');
|
|
95675
|
+
if (key) {
|
|
95676
|
+
try {
|
|
95677
|
+
queryParams[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
95678
|
+
}
|
|
95679
|
+
catch {
|
|
95680
|
+
queryParams[key] = value;
|
|
95681
|
+
}
|
|
95682
|
+
}
|
|
95683
|
+
});
|
|
95684
|
+
}
|
|
95685
|
+
return queryParams;
|
|
95543
95686
|
}
|
|
95544
95687
|
|
|
95545
95688
|
/*!
|
|
@@ -96069,6 +96212,10 @@ function initializeOneStore(sqliteStore) {
|
|
|
96069
96212
|
if (!useOneStore.isOpen({ fallback: true })) {
|
|
96070
96213
|
return;
|
|
96071
96214
|
}
|
|
96215
|
+
// Initialize performance.now() fallback if not available
|
|
96216
|
+
if (typeof globalThis.performance === 'undefined') {
|
|
96217
|
+
globalThis.performance = { now: () => Date.now() };
|
|
96218
|
+
}
|
|
96072
96219
|
const loggerService = new ConsoleLogger('ERROR');
|
|
96073
96220
|
const cacheServiceDescriptor = buildServiceDescriptor$6();
|
|
96074
96221
|
const instrumentationServiceDescriptor = buildServiceDescriptor$3(loggerService);
|
|
@@ -96296,7 +96443,7 @@ register$1({
|
|
|
96296
96443
|
id: '@salesforce/lds-network-adapter',
|
|
96297
96444
|
instrument: instrument$2,
|
|
96298
96445
|
});
|
|
96299
|
-
// version: 1.
|
|
96446
|
+
// version: 1.372.1-5ff6849fe2
|
|
96300
96447
|
|
|
96301
96448
|
const { create: create$2, keys: keys$2 } = Object;
|
|
96302
96449
|
const { stringify, parse } = JSON;
|
|
@@ -122787,7 +122934,7 @@ function refreshGraphQL(data) {
|
|
|
122787
122934
|
}
|
|
122788
122935
|
return refresh$3(data, 'refreshUiApi');
|
|
122789
122936
|
}
|
|
122790
|
-
// version: 1.
|
|
122937
|
+
// version: 1.372.1-8824ae9dd4
|
|
122791
122938
|
|
|
122792
122939
|
// On core the unstable adapters are re-exported with different names,
|
|
122793
122940
|
// we want to match them here.
|
|
@@ -122939,7 +123086,7 @@ withDefaultLuvio((luvio) => {
|
|
|
122939
123086
|
unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
|
|
122940
123087
|
graphQLImperative = ldsAdapter;
|
|
122941
123088
|
});
|
|
122942
|
-
// version: 1.
|
|
123089
|
+
// version: 1.372.1-8824ae9dd4
|
|
122943
123090
|
|
|
122944
123091
|
var gqlApi = /*#__PURE__*/Object.freeze({
|
|
122945
123092
|
__proto__: null,
|
|
@@ -123738,7 +123885,7 @@ const callbacks$1 = [];
|
|
|
123738
123885
|
function register(r) {
|
|
123739
123886
|
callbacks$1.forEach((callback) => callback(r));
|
|
123740
123887
|
}
|
|
123741
|
-
// version: 1.
|
|
123888
|
+
// version: 1.372.1-5ff6849fe2
|
|
123742
123889
|
|
|
123743
123890
|
/**
|
|
123744
123891
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -124918,11 +125065,160 @@ class LuvioAdapterModule {
|
|
|
124918
125065
|
}
|
|
124919
125066
|
}
|
|
124920
125067
|
|
|
125068
|
+
const ONESTORE_ADAPTER_FAMILY = /^force\/ldsAdapters/;
|
|
125069
|
+
function buildOneStoreError(error) {
|
|
125070
|
+
let errorMessage;
|
|
125071
|
+
if (typeof error === 'string') {
|
|
125072
|
+
errorMessage = error;
|
|
125073
|
+
}
|
|
125074
|
+
else if (error && error.message) {
|
|
125075
|
+
errorMessage = error.message;
|
|
125076
|
+
}
|
|
125077
|
+
else if (error !== null && error !== undefined) {
|
|
125078
|
+
errorMessage = error.toString();
|
|
125079
|
+
}
|
|
125080
|
+
else {
|
|
125081
|
+
errorMessage = error;
|
|
125082
|
+
}
|
|
125083
|
+
return {
|
|
125084
|
+
data: undefined,
|
|
125085
|
+
error: errorMessage,
|
|
125086
|
+
};
|
|
125087
|
+
}
|
|
125088
|
+
function buildInvalidAdapterError(adapterOrCommandName) {
|
|
125089
|
+
return {
|
|
125090
|
+
data: undefined,
|
|
125091
|
+
error: `Invalid adapter or command: ${adapterOrCommandName}`,
|
|
125092
|
+
};
|
|
125093
|
+
}
|
|
125094
|
+
function buildNativeResponse(response) {
|
|
125095
|
+
if (response && response.error) {
|
|
125096
|
+
return buildOneStoreError(response.error);
|
|
125097
|
+
}
|
|
125098
|
+
return response;
|
|
125099
|
+
}
|
|
125100
|
+
async function importOneStoreAdapterModule(specifier) {
|
|
125101
|
+
if (!ONESTORE_ADAPTER_FAMILY.test(specifier)) {
|
|
125102
|
+
throw `${specifier} is not an allowed onestore adapter module`;
|
|
125103
|
+
}
|
|
125104
|
+
let module;
|
|
125105
|
+
try {
|
|
125106
|
+
module = await import(specifier);
|
|
125107
|
+
}
|
|
125108
|
+
catch {
|
|
125109
|
+
throw `module not found for specifier ${specifier}`;
|
|
125110
|
+
}
|
|
125111
|
+
return new OneStoreAdapterModule(module);
|
|
125112
|
+
}
|
|
125113
|
+
class OneStoreAdapterModule {
|
|
125114
|
+
constructor(module) {
|
|
125115
|
+
this.module = module;
|
|
125116
|
+
}
|
|
125117
|
+
async invoke(adapterOrCommandName, config) {
|
|
125118
|
+
const adapterOrCommand = this.module[adapterOrCommandName];
|
|
125119
|
+
if (adapterOrCommand === undefined) {
|
|
125120
|
+
return buildInvalidAdapterError(`Command ${adapterOrCommandName} not recognized`);
|
|
125121
|
+
}
|
|
125122
|
+
return new Promise((resolve) => {
|
|
125123
|
+
try {
|
|
125124
|
+
if (this.isCommandWireAdapter(adapterOrCommand)) {
|
|
125125
|
+
// WIRE COMMAND
|
|
125126
|
+
const adapter = new adapterOrCommand((result) => {
|
|
125127
|
+
resolve(buildNativeResponse(result));
|
|
125128
|
+
adapter.disconnect();
|
|
125129
|
+
}, undefined, { skipEmptyEmit: true });
|
|
125130
|
+
adapter.connect();
|
|
125131
|
+
adapter.update(config);
|
|
125132
|
+
}
|
|
125133
|
+
else if (this.hasInvoke(adapterOrCommand)) {
|
|
125134
|
+
// IMPERATIVE LEGACY INVOKER
|
|
125135
|
+
adapterOrCommand.invoke(config, null, (result) => {
|
|
125136
|
+
resolve(buildNativeResponse(result));
|
|
125137
|
+
});
|
|
125138
|
+
}
|
|
125139
|
+
else {
|
|
125140
|
+
// IMPERATIVE INVOKER
|
|
125141
|
+
adapterOrCommand(config)
|
|
125142
|
+
.then((response) => {
|
|
125143
|
+
resolve(buildNativeResponse(response));
|
|
125144
|
+
})
|
|
125145
|
+
.catch((error) => {
|
|
125146
|
+
resolve(buildOneStoreError(error));
|
|
125147
|
+
});
|
|
125148
|
+
}
|
|
125149
|
+
}
|
|
125150
|
+
catch (error) {
|
|
125151
|
+
resolve(buildInvalidAdapterError(adapterOrCommandName));
|
|
125152
|
+
}
|
|
125153
|
+
});
|
|
125154
|
+
}
|
|
125155
|
+
subscribe(adapterOrCommandName, config, callback) {
|
|
125156
|
+
const adapterOrCommand = this.module[adapterOrCommandName];
|
|
125157
|
+
if (adapterOrCommand === undefined) {
|
|
125158
|
+
callback(buildInvalidAdapterError(adapterOrCommandName));
|
|
125159
|
+
return Promise.resolve(undefined);
|
|
125160
|
+
}
|
|
125161
|
+
return new Promise((resolve) => {
|
|
125162
|
+
try {
|
|
125163
|
+
if (this.isCommandWireAdapter(adapterOrCommand)) {
|
|
125164
|
+
// WIRE COMMAND
|
|
125165
|
+
const adapter = new adapterOrCommand((result) => {
|
|
125166
|
+
callback(buildNativeResponse(result));
|
|
125167
|
+
}, undefined, { skipEmptyEmit: true });
|
|
125168
|
+
adapter.connect();
|
|
125169
|
+
adapter.update(config);
|
|
125170
|
+
resolve(() => adapter.disconnect());
|
|
125171
|
+
}
|
|
125172
|
+
else if (this.hasSubscribe(adapterOrCommand)) {
|
|
125173
|
+
// IMPERATIVE LEGACY INVOKER
|
|
125174
|
+
const unsubscribe = adapterOrCommand.subscribe(config, null, (result) => {
|
|
125175
|
+
callback(buildNativeResponse(result));
|
|
125176
|
+
});
|
|
125177
|
+
resolve(unsubscribe);
|
|
125178
|
+
}
|
|
125179
|
+
else {
|
|
125180
|
+
// IMPERATIVE INVOKER
|
|
125181
|
+
adapterOrCommand(config)
|
|
125182
|
+
.then((response) => {
|
|
125183
|
+
if (response.subscribe === undefined) {
|
|
125184
|
+
callback(buildNativeResponse(response));
|
|
125185
|
+
resolve(undefined);
|
|
125186
|
+
}
|
|
125187
|
+
else {
|
|
125188
|
+
const unsubscribe = response.subscribe((subscriptionResult) => {
|
|
125189
|
+
callback(buildNativeResponse(subscriptionResult));
|
|
125190
|
+
});
|
|
125191
|
+
resolve(unsubscribe);
|
|
125192
|
+
}
|
|
125193
|
+
})
|
|
125194
|
+
.catch((error) => {
|
|
125195
|
+
callback(buildOneStoreError(error));
|
|
125196
|
+
resolve(undefined);
|
|
125197
|
+
});
|
|
125198
|
+
}
|
|
125199
|
+
}
|
|
125200
|
+
catch (error) {
|
|
125201
|
+
callback(buildInvalidAdapterError(adapterOrCommandName));
|
|
125202
|
+
resolve(undefined);
|
|
125203
|
+
}
|
|
125204
|
+
});
|
|
125205
|
+
}
|
|
125206
|
+
isCommandWireAdapter(adapterOrCommand) {
|
|
125207
|
+
return Object.getPrototypeOf(adapterOrCommand).name === 'CommandWireAdapterConstructor';
|
|
125208
|
+
}
|
|
125209
|
+
hasInvoke(adapterOrCommand) {
|
|
125210
|
+
return typeof adapterOrCommand.invoke === 'function';
|
|
125211
|
+
}
|
|
125212
|
+
hasSubscribe(adapterOrCommand) {
|
|
125213
|
+
return typeof adapterOrCommand.subscribe === 'function';
|
|
125214
|
+
}
|
|
125215
|
+
}
|
|
125216
|
+
|
|
124921
125217
|
// LWR has a "setupLDS" bootstrap service/loader hook, we simulate this in
|
|
124922
125218
|
// standalone bundle by mimicking what "setupLDS" does here and then exporting
|
|
124923
125219
|
// everything from main.ts
|
|
124924
125220
|
const { luvio } = getRuntime();
|
|
124925
125221
|
setDefaultLuvio({ luvio });
|
|
124926
125222
|
|
|
124927
|
-
export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, importLuvioAdapterModule, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
|
|
124928
|
-
// version: 1.
|
|
125223
|
+
export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, importLuvioAdapterModule, importOneStoreAdapterModule, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
|
|
125224
|
+
// version: 1.372.1-5ff6849fe2
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Unsubscribe } from '@luvio/engine';
|
|
2
|
+
export type OneStoreNativeCallbackValue = OneStoreNativeCallbackData | OneStoreNativeCallbackError;
|
|
3
|
+
export type OneStoreNativeCallbackData = {
|
|
4
|
+
data: any | undefined;
|
|
5
|
+
error?: undefined;
|
|
6
|
+
};
|
|
7
|
+
export type OneStoreNativeCallbackError = {
|
|
8
|
+
data?: undefined;
|
|
9
|
+
error: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function importOneStoreAdapterModule(specifier: string): Promise<OneStoreAdapterModule>;
|
|
12
|
+
declare class OneStoreAdapterModule {
|
|
13
|
+
module: any;
|
|
14
|
+
constructor(module: any);
|
|
15
|
+
invoke<Config>(adapterOrCommandName: string, config: Config): Promise<OneStoreNativeCallbackValue>;
|
|
16
|
+
subscribe<Config>(adapterOrCommandName: string, config: Config, callback: (value: OneStoreNativeCallbackValue) => void): Promise<Unsubscribe | undefined>;
|
|
17
|
+
private isCommandWireAdapter;
|
|
18
|
+
private hasInvoke;
|
|
19
|
+
private hasSubscribe;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -7,4 +7,5 @@ import { registerReportObserver } from '@salesforce/lds-runtime-mobile';
|
|
|
7
7
|
import { createPrimingSession } from './primingApi';
|
|
8
8
|
import { evictCacheRecordsByIds, evictExpiredCacheEntries, stopEviction } from './cachePurging';
|
|
9
9
|
import { importLuvioAdapterModule } from './customLuvioAdapter';
|
|
10
|
-
|
|
10
|
+
import { importOneStoreAdapterModule } from './customOneStoreAdapter';
|
|
11
|
+
export { subscribeToAdapter, invokeAdapter, invokeAdapterWithMetadata, invokeAdapterWithDraftToReplace, invokeAdapterWithDraftToMerge, executeAdapter, executeMutatingAdapter, nimbusDraftQueue, draftQueue, draftManager, setUiApiRecordTTL, setMetadataTTL, registerReportObserver, getImperativeAdapterNames, createPrimingSession, evictCacheRecordsByIds, evictExpiredCacheEntries, stopEviction, importLuvioAdapterModule, importOneStoreAdapterModule, };
|