@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
|
@@ -4280,7 +4280,7 @@
|
|
|
4280
4280
|
}
|
|
4281
4281
|
callbacks.push(callback);
|
|
4282
4282
|
}
|
|
4283
|
-
// version: 1.
|
|
4283
|
+
// version: 1.372.1-5ff6849fe2
|
|
4284
4284
|
|
|
4285
4285
|
// TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
|
|
4286
4286
|
function instrumentAdapter$1(createFunction, _metadata) {
|
|
@@ -5124,6 +5124,24 @@
|
|
|
5124
5124
|
}
|
|
5125
5125
|
return payload;
|
|
5126
5126
|
}
|
|
5127
|
+
/**
|
|
5128
|
+
* The graphql batch snapshot should be treated the same as a regular imperative adapter snapshot.
|
|
5129
|
+
* @param snapshot - The snapshot to convert to a tuple
|
|
5130
|
+
* @returns The tuple representation of the snapshot
|
|
5131
|
+
*/
|
|
5132
|
+
function batchSnapshotToTuple(snapshot) {
|
|
5133
|
+
if (isErrorSnapshot$2(snapshot)) {
|
|
5134
|
+
return {
|
|
5135
|
+
data: undefined,
|
|
5136
|
+
error: snapshot.error,
|
|
5137
|
+
};
|
|
5138
|
+
}
|
|
5139
|
+
// We might still get pending snapshot here from invoke calls here
|
|
5140
|
+
return {
|
|
5141
|
+
data: snapshot.data,
|
|
5142
|
+
error: undefined,
|
|
5143
|
+
};
|
|
5144
|
+
}
|
|
5127
5145
|
function createInvalidConfigError() {
|
|
5128
5146
|
return {
|
|
5129
5147
|
data: undefined,
|
|
@@ -5151,7 +5169,9 @@
|
|
|
5151
5169
|
const { name } = metadata;
|
|
5152
5170
|
const imperativeAdapterInvoke = (config, requestContext, callback) => {
|
|
5153
5171
|
let coercedConfig = null;
|
|
5172
|
+
let isBatch = false;
|
|
5154
5173
|
if ('batchQuery' in config) {
|
|
5174
|
+
isBatch = true;
|
|
5155
5175
|
coercedConfig = {
|
|
5156
5176
|
batchQuery: config.batchQuery.map((individualConfig) => ({
|
|
5157
5177
|
...individualConfig,
|
|
@@ -5181,7 +5201,9 @@
|
|
|
5181
5201
|
return;
|
|
5182
5202
|
}
|
|
5183
5203
|
if (!isPromise$3(snapshotOrPromise)) {
|
|
5184
|
-
callback(
|
|
5204
|
+
callback(isBatch
|
|
5205
|
+
? batchSnapshotToTuple(snapshotOrPromise)
|
|
5206
|
+
: snapshotToTuple(snapshotOrPromise));
|
|
5185
5207
|
return;
|
|
5186
5208
|
}
|
|
5187
5209
|
snapshotOrPromise
|
|
@@ -5190,7 +5212,7 @@
|
|
|
5190
5212
|
callback(createInvalidConfigError());
|
|
5191
5213
|
return;
|
|
5192
5214
|
}
|
|
5193
|
-
callback(snapshotToTuple(snapshot));
|
|
5215
|
+
callback(isBatch ? batchSnapshotToTuple(snapshot) : snapshotToTuple(snapshot));
|
|
5194
5216
|
})
|
|
5195
5217
|
.finally(() => {
|
|
5196
5218
|
luvio.storeCleanup();
|
|
@@ -5205,7 +5227,9 @@
|
|
|
5205
5227
|
let subscriberCallback = callback;
|
|
5206
5228
|
let unsub;
|
|
5207
5229
|
let coercedConfig = null;
|
|
5230
|
+
let isBatch = false;
|
|
5208
5231
|
if ('batchQuery' in config) {
|
|
5232
|
+
isBatch = true;
|
|
5209
5233
|
coercedConfig = {
|
|
5210
5234
|
batchQuery: config.batchQuery.map((individualConfig) => ({
|
|
5211
5235
|
...individualConfig,
|
|
@@ -5238,7 +5262,9 @@
|
|
|
5238
5262
|
const luvioStoreSubscribe = (snapshot) => {
|
|
5239
5263
|
unsub = luvio.storeSubscribe(snapshot, (snapshotFromRebuild) => {
|
|
5240
5264
|
if (subscriberCallback !== null && !isPendingSnapshot(snapshotFromRebuild)) {
|
|
5241
|
-
subscriberCallback(
|
|
5265
|
+
subscriberCallback(isBatch
|
|
5266
|
+
? batchSnapshotToTuple(snapshotFromRebuild)
|
|
5267
|
+
: snapshotToTuple(snapshotFromRebuild));
|
|
5242
5268
|
}
|
|
5243
5269
|
});
|
|
5244
5270
|
};
|
|
@@ -5246,7 +5272,9 @@
|
|
|
5246
5272
|
// We don't want to return pending snapshots to user-land
|
|
5247
5273
|
// Instead we just subscribe to it
|
|
5248
5274
|
if (!isPendingSnapshot(snapshotOrPromise)) {
|
|
5249
|
-
subscriberCallback(
|
|
5275
|
+
subscriberCallback(isBatch
|
|
5276
|
+
? batchSnapshotToTuple(snapshotOrPromise)
|
|
5277
|
+
: snapshotToTuple(snapshotOrPromise));
|
|
5250
5278
|
}
|
|
5251
5279
|
luvioStoreSubscribe(snapshotOrPromise);
|
|
5252
5280
|
}
|
|
@@ -5261,7 +5289,7 @@
|
|
|
5261
5289
|
// We don't want to return pending snapshots to user-land
|
|
5262
5290
|
// Instead we just subscribe to it
|
|
5263
5291
|
if (!isPendingSnapshot(snapshot)) {
|
|
5264
|
-
subscriberCallback(snapshotToTuple(snapshot));
|
|
5292
|
+
subscriberCallback(isBatch ? batchSnapshotToTuple(snapshot) : snapshotToTuple(snapshot));
|
|
5265
5293
|
}
|
|
5266
5294
|
luvioStoreSubscribe(snapshot);
|
|
5267
5295
|
}
|
|
@@ -5296,7 +5324,7 @@
|
|
|
5296
5324
|
const { apiFamily, name } = metadata;
|
|
5297
5325
|
return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
|
|
5298
5326
|
}
|
|
5299
|
-
// version: 1.
|
|
5327
|
+
// version: 1.372.1-5ff6849fe2
|
|
5300
5328
|
|
|
5301
5329
|
/**
|
|
5302
5330
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -34172,7 +34200,7 @@
|
|
|
34172
34200
|
throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
|
|
34173
34201
|
throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
|
|
34174
34202
|
});
|
|
34175
|
-
// version: 1.
|
|
34203
|
+
// version: 1.372.1-8824ae9dd4
|
|
34176
34204
|
|
|
34177
34205
|
function requestIdleDetectedCallback(_callback) { }
|
|
34178
34206
|
function declareNotifierTaskSingle(_name) {
|
|
@@ -94203,14 +94231,20 @@
|
|
|
94203
94231
|
async coerceFetchError(errorResponse) {
|
|
94204
94232
|
return toError(errorResponse.statusText);
|
|
94205
94233
|
}
|
|
94234
|
+
processAuraReturnValue(auraReturnValue) {
|
|
94235
|
+
return ok$1(auraReturnValue);
|
|
94236
|
+
}
|
|
94237
|
+
processFetchReturnValue(json) {
|
|
94238
|
+
return ok$1(json);
|
|
94239
|
+
}
|
|
94206
94240
|
convertAuraResponseToData(responsePromise, coerceError) {
|
|
94207
94241
|
return responsePromise.then((response) => {
|
|
94208
|
-
|
|
94242
|
+
return this.processAuraReturnValue(response.getReturnValue());
|
|
94243
|
+
}).finally(() => {
|
|
94209
94244
|
try {
|
|
94210
94245
|
this.afterRequestHooks({ statusCode: 200 });
|
|
94211
94246
|
} catch (e) {
|
|
94212
94247
|
}
|
|
94213
|
-
return ok$1(auraReturnValue);
|
|
94214
94248
|
}).catch((error) => {
|
|
94215
94249
|
if (!error || !error.getError) {
|
|
94216
94250
|
return err$1(toError("Failed to get error from response"));
|
|
@@ -94229,7 +94263,9 @@
|
|
|
94229
94263
|
(response2) => {
|
|
94230
94264
|
if (response2.ok) {
|
|
94231
94265
|
return response2.json().then(
|
|
94232
|
-
(json) =>
|
|
94266
|
+
(json) => {
|
|
94267
|
+
return this.processFetchReturnValue(json);
|
|
94268
|
+
},
|
|
94233
94269
|
(reason) => err$1(toError(reason))
|
|
94234
94270
|
).finally(() => {
|
|
94235
94271
|
try {
|
|
@@ -94334,14 +94370,20 @@
|
|
|
94334
94370
|
async coerceFetchError(errorResponse) {
|
|
94335
94371
|
return toError(errorResponse.statusText);
|
|
94336
94372
|
}
|
|
94373
|
+
processAuraReturnValue(auraReturnValue) {
|
|
94374
|
+
return ok$1(auraReturnValue);
|
|
94375
|
+
}
|
|
94376
|
+
processFetchReturnValue(json) {
|
|
94377
|
+
return ok$1(json);
|
|
94378
|
+
}
|
|
94337
94379
|
convertAuraResponseToData(responsePromise, coerceError) {
|
|
94338
94380
|
return responsePromise.then((response) => {
|
|
94339
|
-
|
|
94381
|
+
return this.processAuraReturnValue(response.getReturnValue());
|
|
94382
|
+
}).finally(() => {
|
|
94340
94383
|
try {
|
|
94341
94384
|
this.afterRequestHooks({ statusCode: 200 });
|
|
94342
94385
|
} catch (e) {
|
|
94343
94386
|
}
|
|
94344
|
-
return ok$1(auraReturnValue);
|
|
94345
94387
|
}).catch((error) => {
|
|
94346
94388
|
if (!error || !error.getError) {
|
|
94347
94389
|
return err$1(toError("Failed to get error from response"));
|
|
@@ -94360,7 +94402,9 @@
|
|
|
94360
94402
|
(response2) => {
|
|
94361
94403
|
if (response2.ok) {
|
|
94362
94404
|
return response2.json().then(
|
|
94363
|
-
(json) =>
|
|
94405
|
+
(json) => {
|
|
94406
|
+
return this.processFetchReturnValue(json);
|
|
94407
|
+
},
|
|
94364
94408
|
(reason) => err$1(toError(reason))
|
|
94365
94409
|
).finally(() => {
|
|
94366
94410
|
try {
|
|
@@ -94553,12 +94597,17 @@
|
|
|
94553
94597
|
async coerceError(errorResponse) {
|
|
94554
94598
|
return toError(errorResponse.statusText);
|
|
94555
94599
|
}
|
|
94600
|
+
processFetchReturnValue(json) {
|
|
94601
|
+
return ok$1(json);
|
|
94602
|
+
}
|
|
94556
94603
|
convertFetchResponseToData(response) {
|
|
94557
94604
|
return response.then(
|
|
94558
94605
|
(response2) => {
|
|
94559
94606
|
if (response2.ok) {
|
|
94560
94607
|
return response2.json().then(
|
|
94561
|
-
(json) =>
|
|
94608
|
+
(json) => {
|
|
94609
|
+
return this.processFetchReturnValue(json);
|
|
94610
|
+
},
|
|
94562
94611
|
(reason) => err$1(toError(reason))
|
|
94563
94612
|
).finally(() => {
|
|
94564
94613
|
try {
|
|
@@ -95490,12 +95539,31 @@
|
|
|
95490
95539
|
const service = (...args) => {
|
|
95491
95540
|
const resourceRequest = convertFetchParamsToResourceRequest(args);
|
|
95492
95541
|
const context = {};
|
|
95493
|
-
return NimbusNetworkAdapter(resourceRequest, context)
|
|
95494
|
-
|
|
95542
|
+
return NimbusNetworkAdapter(resourceRequest, context)
|
|
95543
|
+
.then((response) => {
|
|
95544
|
+
// This is a hack to make the response compatible with the Response interface
|
|
95545
|
+
const r = {
|
|
95546
|
+
body: response.body,
|
|
95495
95547
|
headers: response.headers,
|
|
95496
95548
|
status: response.status,
|
|
95497
95549
|
statusText: response.statusText,
|
|
95498
|
-
|
|
95550
|
+
json: () => {
|
|
95551
|
+
return Promise.resolve(response.body);
|
|
95552
|
+
},
|
|
95553
|
+
ok: response.status >= 200 && response.status < 300,
|
|
95554
|
+
};
|
|
95555
|
+
return r;
|
|
95556
|
+
})
|
|
95557
|
+
.catch((error) => {
|
|
95558
|
+
// Create a Response-like error object
|
|
95559
|
+
return {
|
|
95560
|
+
body: null,
|
|
95561
|
+
headers: {},
|
|
95562
|
+
status: 500,
|
|
95563
|
+
statusText: error.message || 'Internal Server Error',
|
|
95564
|
+
json: () => Promise.resolve(null),
|
|
95565
|
+
ok: false,
|
|
95566
|
+
};
|
|
95499
95567
|
});
|
|
95500
95568
|
};
|
|
95501
95569
|
return {
|
|
@@ -95514,38 +95582,113 @@
|
|
|
95514
95582
|
* @returns A ResourceRequest object compatible with NimbusNetworkAdapter
|
|
95515
95583
|
*/
|
|
95516
95584
|
function convertFetchParamsToResourceRequest([input, init]) {
|
|
95517
|
-
const
|
|
95518
|
-
|
|
95519
|
-
: input instanceof URL
|
|
95520
|
-
? input
|
|
95521
|
-
: new URL(input.url);
|
|
95585
|
+
const urlString = typeof input === 'string' ? input : input.href || input.url || input;
|
|
95586
|
+
const { baseUri, basePath, queryParams } = parseUrlParts(urlString);
|
|
95522
95587
|
const headers = {};
|
|
95523
95588
|
if (init?.headers) {
|
|
95524
|
-
if (init
|
|
95589
|
+
if (typeof Headers !== 'undefined' && init?.headers instanceof Headers) {
|
|
95525
95590
|
init.headers.forEach((value, key) => {
|
|
95526
95591
|
headers[key] = value;
|
|
95527
95592
|
});
|
|
95528
95593
|
}
|
|
95529
|
-
else if (Array.isArray(init
|
|
95594
|
+
else if (Array.isArray(init?.headers)) {
|
|
95530
95595
|
init.headers.forEach(([key, value]) => {
|
|
95531
95596
|
headers[key] = value;
|
|
95532
95597
|
});
|
|
95533
95598
|
}
|
|
95534
95599
|
else {
|
|
95535
|
-
Object.entries(init
|
|
95600
|
+
Object.entries(init?.headers || {}).forEach(([key, value]) => {
|
|
95536
95601
|
headers[key] = value;
|
|
95537
95602
|
});
|
|
95538
95603
|
}
|
|
95539
95604
|
}
|
|
95540
|
-
|
|
95541
|
-
baseUri
|
|
95542
|
-
basePath
|
|
95605
|
+
const resourceRequest = {
|
|
95606
|
+
baseUri,
|
|
95607
|
+
basePath,
|
|
95543
95608
|
method: (init?.method || 'GET').toLowerCase(),
|
|
95544
|
-
body: init?.body || null,
|
|
95545
95609
|
headers,
|
|
95546
|
-
|
|
95610
|
+
body: (() => {
|
|
95611
|
+
if (!init?.body) {
|
|
95612
|
+
return null;
|
|
95613
|
+
}
|
|
95614
|
+
try {
|
|
95615
|
+
return typeof init.body === 'string' ? JSON.parse(init.body) : init.body;
|
|
95616
|
+
}
|
|
95617
|
+
catch {
|
|
95618
|
+
return init.body;
|
|
95619
|
+
}
|
|
95620
|
+
})(),
|
|
95621
|
+
queryParams,
|
|
95547
95622
|
urlParams: {},
|
|
95548
95623
|
};
|
|
95624
|
+
return resourceRequest;
|
|
95625
|
+
}
|
|
95626
|
+
function parseUrlParts(urlString) {
|
|
95627
|
+
// Split by protocol first
|
|
95628
|
+
const [protocol, rest] = urlString.split('://');
|
|
95629
|
+
// If no protocol, treat whole string as path
|
|
95630
|
+
if (!rest) {
|
|
95631
|
+
return {
|
|
95632
|
+
baseUri: '',
|
|
95633
|
+
basePath: urlString.startsWith('/')
|
|
95634
|
+
? urlString.split('?')[0]
|
|
95635
|
+
: `/${urlString.split('?')[0]}`,
|
|
95636
|
+
queryParams: extractQueryParams(urlString),
|
|
95637
|
+
};
|
|
95638
|
+
}
|
|
95639
|
+
// Split remaining parts
|
|
95640
|
+
const parts = rest.split('/');
|
|
95641
|
+
let hostPart = parts[0] || '';
|
|
95642
|
+
const pathParts = parts.slice(1);
|
|
95643
|
+
// Handle query string in host part (e.g., "example.com?key=value")
|
|
95644
|
+
let hostQueryString = '';
|
|
95645
|
+
if (hostPart.includes('?')) {
|
|
95646
|
+
const [host, query] = hostPart.split('?');
|
|
95647
|
+
hostPart = host;
|
|
95648
|
+
hostQueryString = query;
|
|
95649
|
+
}
|
|
95650
|
+
// Handle query string in path parts
|
|
95651
|
+
const lastPart = pathParts[pathParts.length - 1] || '';
|
|
95652
|
+
const [pathEnd, pathQueryString] = lastPart.split('?');
|
|
95653
|
+
// Combine query strings (host takes precedence if both exist)
|
|
95654
|
+
const queryString = hostQueryString || pathQueryString;
|
|
95655
|
+
// Reconstruct
|
|
95656
|
+
const baseUri = hostPart ? `${protocol}://${hostPart}` : urlString;
|
|
95657
|
+
const basePath = pathParts.length > 0 ? `/${pathParts.slice(0, -1).concat(pathEnd).join('/')}` : '/';
|
|
95658
|
+
const queryParams = {};
|
|
95659
|
+
if (queryString) {
|
|
95660
|
+
queryString.split('&').forEach((param) => {
|
|
95661
|
+
const [key, value = ''] = param.split('=');
|
|
95662
|
+
if (key) {
|
|
95663
|
+
try {
|
|
95664
|
+
queryParams[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
95665
|
+
}
|
|
95666
|
+
catch {
|
|
95667
|
+
queryParams[key] = value;
|
|
95668
|
+
}
|
|
95669
|
+
}
|
|
95670
|
+
});
|
|
95671
|
+
}
|
|
95672
|
+
return { baseUri, basePath, queryParams };
|
|
95673
|
+
}
|
|
95674
|
+
function extractQueryParams(urlString) {
|
|
95675
|
+
const queryParams = {};
|
|
95676
|
+
const queryStart = urlString.indexOf('?');
|
|
95677
|
+
if (queryStart > -1) {
|
|
95678
|
+
const queryString = urlString.substring(queryStart + 1);
|
|
95679
|
+
queryString.split('&').forEach((param) => {
|
|
95680
|
+
const [key, value = ''] = param.split('=');
|
|
95681
|
+
if (key) {
|
|
95682
|
+
try {
|
|
95683
|
+
queryParams[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
95684
|
+
}
|
|
95685
|
+
catch {
|
|
95686
|
+
queryParams[key] = value;
|
|
95687
|
+
}
|
|
95688
|
+
}
|
|
95689
|
+
});
|
|
95690
|
+
}
|
|
95691
|
+
return queryParams;
|
|
95549
95692
|
}
|
|
95550
95693
|
|
|
95551
95694
|
/*!
|
|
@@ -96075,6 +96218,10 @@
|
|
|
96075
96218
|
if (!useOneStore.isOpen({ fallback: true })) {
|
|
96076
96219
|
return;
|
|
96077
96220
|
}
|
|
96221
|
+
// Initialize performance.now() fallback if not available
|
|
96222
|
+
if (typeof globalThis.performance === 'undefined') {
|
|
96223
|
+
globalThis.performance = { now: () => Date.now() };
|
|
96224
|
+
}
|
|
96078
96225
|
const loggerService = new ConsoleLogger('ERROR');
|
|
96079
96226
|
const cacheServiceDescriptor = buildServiceDescriptor$6();
|
|
96080
96227
|
const instrumentationServiceDescriptor = buildServiceDescriptor$3(loggerService);
|
|
@@ -96302,7 +96449,7 @@
|
|
|
96302
96449
|
id: '@salesforce/lds-network-adapter',
|
|
96303
96450
|
instrument: instrument$2,
|
|
96304
96451
|
});
|
|
96305
|
-
// version: 1.
|
|
96452
|
+
// version: 1.372.1-5ff6849fe2
|
|
96306
96453
|
|
|
96307
96454
|
const { create: create$2, keys: keys$2 } = Object;
|
|
96308
96455
|
const { stringify, parse } = JSON;
|
|
@@ -122793,7 +122940,7 @@
|
|
|
122793
122940
|
}
|
|
122794
122941
|
return refresh$3(data, 'refreshUiApi');
|
|
122795
122942
|
}
|
|
122796
|
-
// version: 1.
|
|
122943
|
+
// version: 1.372.1-8824ae9dd4
|
|
122797
122944
|
|
|
122798
122945
|
// On core the unstable adapters are re-exported with different names,
|
|
122799
122946
|
// we want to match them here.
|
|
@@ -122945,7 +123092,7 @@
|
|
|
122945
123092
|
unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
|
|
122946
123093
|
graphQLImperative = ldsAdapter;
|
|
122947
123094
|
});
|
|
122948
|
-
// version: 1.
|
|
123095
|
+
// version: 1.372.1-8824ae9dd4
|
|
122949
123096
|
|
|
122950
123097
|
var gqlApi = /*#__PURE__*/Object.freeze({
|
|
122951
123098
|
__proto__: null,
|
|
@@ -123744,7 +123891,7 @@
|
|
|
123744
123891
|
function register(r) {
|
|
123745
123892
|
callbacks$1.forEach((callback) => callback(r));
|
|
123746
123893
|
}
|
|
123747
|
-
// version: 1.
|
|
123894
|
+
// version: 1.372.1-5ff6849fe2
|
|
123748
123895
|
|
|
123749
123896
|
/**
|
|
123750
123897
|
* Copyright (c) 2022, Salesforce, Inc.,
|
|
@@ -124924,6 +125071,155 @@
|
|
|
124924
125071
|
}
|
|
124925
125072
|
}
|
|
124926
125073
|
|
|
125074
|
+
const ONESTORE_ADAPTER_FAMILY = /^force\/ldsAdapters/;
|
|
125075
|
+
function buildOneStoreError(error) {
|
|
125076
|
+
let errorMessage;
|
|
125077
|
+
if (typeof error === 'string') {
|
|
125078
|
+
errorMessage = error;
|
|
125079
|
+
}
|
|
125080
|
+
else if (error && error.message) {
|
|
125081
|
+
errorMessage = error.message;
|
|
125082
|
+
}
|
|
125083
|
+
else if (error !== null && error !== undefined) {
|
|
125084
|
+
errorMessage = error.toString();
|
|
125085
|
+
}
|
|
125086
|
+
else {
|
|
125087
|
+
errorMessage = error;
|
|
125088
|
+
}
|
|
125089
|
+
return {
|
|
125090
|
+
data: undefined,
|
|
125091
|
+
error: errorMessage,
|
|
125092
|
+
};
|
|
125093
|
+
}
|
|
125094
|
+
function buildInvalidAdapterError(adapterOrCommandName) {
|
|
125095
|
+
return {
|
|
125096
|
+
data: undefined,
|
|
125097
|
+
error: `Invalid adapter or command: ${adapterOrCommandName}`,
|
|
125098
|
+
};
|
|
125099
|
+
}
|
|
125100
|
+
function buildNativeResponse(response) {
|
|
125101
|
+
if (response && response.error) {
|
|
125102
|
+
return buildOneStoreError(response.error);
|
|
125103
|
+
}
|
|
125104
|
+
return response;
|
|
125105
|
+
}
|
|
125106
|
+
async function importOneStoreAdapterModule(specifier) {
|
|
125107
|
+
if (!ONESTORE_ADAPTER_FAMILY.test(specifier)) {
|
|
125108
|
+
throw `${specifier} is not an allowed onestore adapter module`;
|
|
125109
|
+
}
|
|
125110
|
+
let module;
|
|
125111
|
+
try {
|
|
125112
|
+
module = await import(specifier);
|
|
125113
|
+
}
|
|
125114
|
+
catch {
|
|
125115
|
+
throw `module not found for specifier ${specifier}`;
|
|
125116
|
+
}
|
|
125117
|
+
return new OneStoreAdapterModule(module);
|
|
125118
|
+
}
|
|
125119
|
+
class OneStoreAdapterModule {
|
|
125120
|
+
constructor(module) {
|
|
125121
|
+
this.module = module;
|
|
125122
|
+
}
|
|
125123
|
+
async invoke(adapterOrCommandName, config) {
|
|
125124
|
+
const adapterOrCommand = this.module[adapterOrCommandName];
|
|
125125
|
+
if (adapterOrCommand === undefined) {
|
|
125126
|
+
return buildInvalidAdapterError(`Command ${adapterOrCommandName} not recognized`);
|
|
125127
|
+
}
|
|
125128
|
+
return new Promise((resolve) => {
|
|
125129
|
+
try {
|
|
125130
|
+
if (this.isCommandWireAdapter(adapterOrCommand)) {
|
|
125131
|
+
// WIRE COMMAND
|
|
125132
|
+
const adapter = new adapterOrCommand((result) => {
|
|
125133
|
+
resolve(buildNativeResponse(result));
|
|
125134
|
+
adapter.disconnect();
|
|
125135
|
+
}, undefined, { skipEmptyEmit: true });
|
|
125136
|
+
adapter.connect();
|
|
125137
|
+
adapter.update(config);
|
|
125138
|
+
}
|
|
125139
|
+
else if (this.hasInvoke(adapterOrCommand)) {
|
|
125140
|
+
// IMPERATIVE LEGACY INVOKER
|
|
125141
|
+
adapterOrCommand.invoke(config, null, (result) => {
|
|
125142
|
+
resolve(buildNativeResponse(result));
|
|
125143
|
+
});
|
|
125144
|
+
}
|
|
125145
|
+
else {
|
|
125146
|
+
// IMPERATIVE INVOKER
|
|
125147
|
+
adapterOrCommand(config)
|
|
125148
|
+
.then((response) => {
|
|
125149
|
+
resolve(buildNativeResponse(response));
|
|
125150
|
+
})
|
|
125151
|
+
.catch((error) => {
|
|
125152
|
+
resolve(buildOneStoreError(error));
|
|
125153
|
+
});
|
|
125154
|
+
}
|
|
125155
|
+
}
|
|
125156
|
+
catch (error) {
|
|
125157
|
+
resolve(buildInvalidAdapterError(adapterOrCommandName));
|
|
125158
|
+
}
|
|
125159
|
+
});
|
|
125160
|
+
}
|
|
125161
|
+
subscribe(adapterOrCommandName, config, callback) {
|
|
125162
|
+
const adapterOrCommand = this.module[adapterOrCommandName];
|
|
125163
|
+
if (adapterOrCommand === undefined) {
|
|
125164
|
+
callback(buildInvalidAdapterError(adapterOrCommandName));
|
|
125165
|
+
return Promise.resolve(undefined);
|
|
125166
|
+
}
|
|
125167
|
+
return new Promise((resolve) => {
|
|
125168
|
+
try {
|
|
125169
|
+
if (this.isCommandWireAdapter(adapterOrCommand)) {
|
|
125170
|
+
// WIRE COMMAND
|
|
125171
|
+
const adapter = new adapterOrCommand((result) => {
|
|
125172
|
+
callback(buildNativeResponse(result));
|
|
125173
|
+
}, undefined, { skipEmptyEmit: true });
|
|
125174
|
+
adapter.connect();
|
|
125175
|
+
adapter.update(config);
|
|
125176
|
+
resolve(() => adapter.disconnect());
|
|
125177
|
+
}
|
|
125178
|
+
else if (this.hasSubscribe(adapterOrCommand)) {
|
|
125179
|
+
// IMPERATIVE LEGACY INVOKER
|
|
125180
|
+
const unsubscribe = adapterOrCommand.subscribe(config, null, (result) => {
|
|
125181
|
+
callback(buildNativeResponse(result));
|
|
125182
|
+
});
|
|
125183
|
+
resolve(unsubscribe);
|
|
125184
|
+
}
|
|
125185
|
+
else {
|
|
125186
|
+
// IMPERATIVE INVOKER
|
|
125187
|
+
adapterOrCommand(config)
|
|
125188
|
+
.then((response) => {
|
|
125189
|
+
if (response.subscribe === undefined) {
|
|
125190
|
+
callback(buildNativeResponse(response));
|
|
125191
|
+
resolve(undefined);
|
|
125192
|
+
}
|
|
125193
|
+
else {
|
|
125194
|
+
const unsubscribe = response.subscribe((subscriptionResult) => {
|
|
125195
|
+
callback(buildNativeResponse(subscriptionResult));
|
|
125196
|
+
});
|
|
125197
|
+
resolve(unsubscribe);
|
|
125198
|
+
}
|
|
125199
|
+
})
|
|
125200
|
+
.catch((error) => {
|
|
125201
|
+
callback(buildOneStoreError(error));
|
|
125202
|
+
resolve(undefined);
|
|
125203
|
+
});
|
|
125204
|
+
}
|
|
125205
|
+
}
|
|
125206
|
+
catch (error) {
|
|
125207
|
+
callback(buildInvalidAdapterError(adapterOrCommandName));
|
|
125208
|
+
resolve(undefined);
|
|
125209
|
+
}
|
|
125210
|
+
});
|
|
125211
|
+
}
|
|
125212
|
+
isCommandWireAdapter(adapterOrCommand) {
|
|
125213
|
+
return Object.getPrototypeOf(adapterOrCommand).name === 'CommandWireAdapterConstructor';
|
|
125214
|
+
}
|
|
125215
|
+
hasInvoke(adapterOrCommand) {
|
|
125216
|
+
return typeof adapterOrCommand.invoke === 'function';
|
|
125217
|
+
}
|
|
125218
|
+
hasSubscribe(adapterOrCommand) {
|
|
125219
|
+
return typeof adapterOrCommand.subscribe === 'function';
|
|
125220
|
+
}
|
|
125221
|
+
}
|
|
125222
|
+
|
|
124927
125223
|
// LWR has a "setupLDS" bootstrap service/loader hook, we simulate this in
|
|
124928
125224
|
// standalone bundle by mimicking what "setupLDS" does here and then exporting
|
|
124929
125225
|
// everything from main.ts
|
|
@@ -124939,6 +125235,7 @@
|
|
|
124939
125235
|
exports.executeMutatingAdapter = executeMutatingAdapter;
|
|
124940
125236
|
exports.getImperativeAdapterNames = getImperativeAdapterNames;
|
|
124941
125237
|
exports.importLuvioAdapterModule = importLuvioAdapterModule;
|
|
125238
|
+
exports.importOneStoreAdapterModule = importOneStoreAdapterModule;
|
|
124942
125239
|
exports.invokeAdapter = invokeAdapter;
|
|
124943
125240
|
exports.invokeAdapterWithDraftToMerge = invokeAdapterWithDraftToMerge;
|
|
124944
125241
|
exports.invokeAdapterWithDraftToReplace = invokeAdapterWithDraftToReplace;
|
|
@@ -124951,4 +125248,4 @@
|
|
|
124951
125248
|
exports.subscribeToAdapter = subscribeToAdapter;
|
|
124952
125249
|
|
|
124953
125250
|
}));
|
|
124954
|
-
// version: 1.
|
|
125251
|
+
// 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, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/lds-worker-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.372.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "dist/standalone/es/lds-worker-api.js",
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@oat-sa/rollup-plugin-wildcard-external": "^1.0.0",
|
|
38
|
-
"@salesforce/lds-adapters-graphql": "^1.
|
|
39
|
-
"@salesforce/lds-adapters-uiapi": "^1.
|
|
40
|
-
"@salesforce/lds-default-luvio": "^1.
|
|
41
|
-
"@salesforce/lds-drafts": "^1.
|
|
42
|
-
"@salesforce/lds-graphql-parser": "^1.
|
|
43
|
-
"@salesforce/lds-luvio-engine": "^1.
|
|
44
|
-
"@salesforce/lds-runtime-mobile": "^1.
|
|
45
|
-
"@salesforce/nimbus-plugin-lds": "^1.
|
|
38
|
+
"@salesforce/lds-adapters-graphql": "^1.372.1",
|
|
39
|
+
"@salesforce/lds-adapters-uiapi": "^1.372.1",
|
|
40
|
+
"@salesforce/lds-default-luvio": "^1.372.1",
|
|
41
|
+
"@salesforce/lds-drafts": "^1.372.1",
|
|
42
|
+
"@salesforce/lds-graphql-parser": "^1.372.1",
|
|
43
|
+
"@salesforce/lds-luvio-engine": "^1.372.1",
|
|
44
|
+
"@salesforce/lds-runtime-mobile": "^1.372.1",
|
|
45
|
+
"@salesforce/nimbus-plugin-lds": "^1.372.1",
|
|
46
46
|
"ajv": "^8.11.0",
|
|
47
47
|
"glob": "^7.1.5",
|
|
48
48
|
"nimbus-types": "^2.0.0-alpha1",
|
|
@@ -54,8 +54,8 @@
|
|
|
54
54
|
{
|
|
55
55
|
"path": "./dist/sfdc/es/ldsWorkerApi.js",
|
|
56
56
|
"maxSize": {
|
|
57
|
-
"none": "
|
|
58
|
-
"min": "
|
|
57
|
+
"none": "55 kB",
|
|
58
|
+
"min": "23 kB",
|
|
59
59
|
"compressed": "9 kB"
|
|
60
60
|
}
|
|
61
61
|
}
|