@salesforce/lds-worker-api 1.370.0 → 1.372.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 +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 +1718 -1136
- 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 +1718 -1135
- 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
|
@@ -1212,6 +1212,155 @@ class LuvioAdapterModule {
|
|
|
1212
1212
|
}
|
|
1213
1213
|
}
|
|
1214
1214
|
|
|
1215
|
+
const ONESTORE_ADAPTER_FAMILY = /^force\/ldsAdapters/;
|
|
1216
|
+
function buildOneStoreError(error) {
|
|
1217
|
+
let errorMessage;
|
|
1218
|
+
if (typeof error === 'string') {
|
|
1219
|
+
errorMessage = error;
|
|
1220
|
+
}
|
|
1221
|
+
else if (error && error.message) {
|
|
1222
|
+
errorMessage = error.message;
|
|
1223
|
+
}
|
|
1224
|
+
else if (error !== null && error !== undefined) {
|
|
1225
|
+
errorMessage = error.toString();
|
|
1226
|
+
}
|
|
1227
|
+
else {
|
|
1228
|
+
errorMessage = error;
|
|
1229
|
+
}
|
|
1230
|
+
return {
|
|
1231
|
+
data: undefined,
|
|
1232
|
+
error: errorMessage,
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
function buildInvalidAdapterError(adapterOrCommandName) {
|
|
1236
|
+
return {
|
|
1237
|
+
data: undefined,
|
|
1238
|
+
error: `Invalid adapter or command: ${adapterOrCommandName}`,
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
function buildNativeResponse(response) {
|
|
1242
|
+
if (response && response.error) {
|
|
1243
|
+
return buildOneStoreError(response.error);
|
|
1244
|
+
}
|
|
1245
|
+
return response;
|
|
1246
|
+
}
|
|
1247
|
+
async function importOneStoreAdapterModule(specifier) {
|
|
1248
|
+
if (!ONESTORE_ADAPTER_FAMILY.test(specifier)) {
|
|
1249
|
+
throw `${specifier} is not an allowed onestore adapter module`;
|
|
1250
|
+
}
|
|
1251
|
+
let module;
|
|
1252
|
+
try {
|
|
1253
|
+
module = await import(specifier);
|
|
1254
|
+
}
|
|
1255
|
+
catch {
|
|
1256
|
+
throw `module not found for specifier ${specifier}`;
|
|
1257
|
+
}
|
|
1258
|
+
return new OneStoreAdapterModule(module);
|
|
1259
|
+
}
|
|
1260
|
+
class OneStoreAdapterModule {
|
|
1261
|
+
constructor(module) {
|
|
1262
|
+
this.module = module;
|
|
1263
|
+
}
|
|
1264
|
+
async invoke(adapterOrCommandName, config) {
|
|
1265
|
+
const adapterOrCommand = this.module[adapterOrCommandName];
|
|
1266
|
+
if (adapterOrCommand === undefined) {
|
|
1267
|
+
return buildInvalidAdapterError(`Command ${adapterOrCommandName} not recognized`);
|
|
1268
|
+
}
|
|
1269
|
+
return new Promise((resolve) => {
|
|
1270
|
+
try {
|
|
1271
|
+
if (this.isCommandWireAdapter(adapterOrCommand)) {
|
|
1272
|
+
// WIRE COMMAND
|
|
1273
|
+
const adapter = new adapterOrCommand((result) => {
|
|
1274
|
+
resolve(buildNativeResponse(result));
|
|
1275
|
+
adapter.disconnect();
|
|
1276
|
+
}, undefined, { skipEmptyEmit: true });
|
|
1277
|
+
adapter.connect();
|
|
1278
|
+
adapter.update(config);
|
|
1279
|
+
}
|
|
1280
|
+
else if (this.hasInvoke(adapterOrCommand)) {
|
|
1281
|
+
// IMPERATIVE LEGACY INVOKER
|
|
1282
|
+
adapterOrCommand.invoke(config, null, (result) => {
|
|
1283
|
+
resolve(buildNativeResponse(result));
|
|
1284
|
+
});
|
|
1285
|
+
}
|
|
1286
|
+
else {
|
|
1287
|
+
// IMPERATIVE INVOKER
|
|
1288
|
+
adapterOrCommand(config)
|
|
1289
|
+
.then((response) => {
|
|
1290
|
+
resolve(buildNativeResponse(response));
|
|
1291
|
+
})
|
|
1292
|
+
.catch((error) => {
|
|
1293
|
+
resolve(buildOneStoreError(error));
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
catch (error) {
|
|
1298
|
+
resolve(buildInvalidAdapterError(adapterOrCommandName));
|
|
1299
|
+
}
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
subscribe(adapterOrCommandName, config, callback) {
|
|
1303
|
+
const adapterOrCommand = this.module[adapterOrCommandName];
|
|
1304
|
+
if (adapterOrCommand === undefined) {
|
|
1305
|
+
callback(buildInvalidAdapterError(adapterOrCommandName));
|
|
1306
|
+
return Promise.resolve(undefined);
|
|
1307
|
+
}
|
|
1308
|
+
return new Promise((resolve) => {
|
|
1309
|
+
try {
|
|
1310
|
+
if (this.isCommandWireAdapter(adapterOrCommand)) {
|
|
1311
|
+
// WIRE COMMAND
|
|
1312
|
+
const adapter = new adapterOrCommand((result) => {
|
|
1313
|
+
callback(buildNativeResponse(result));
|
|
1314
|
+
}, undefined, { skipEmptyEmit: true });
|
|
1315
|
+
adapter.connect();
|
|
1316
|
+
adapter.update(config);
|
|
1317
|
+
resolve(() => adapter.disconnect());
|
|
1318
|
+
}
|
|
1319
|
+
else if (this.hasSubscribe(adapterOrCommand)) {
|
|
1320
|
+
// IMPERATIVE LEGACY INVOKER
|
|
1321
|
+
const unsubscribe = adapterOrCommand.subscribe(config, null, (result) => {
|
|
1322
|
+
callback(buildNativeResponse(result));
|
|
1323
|
+
});
|
|
1324
|
+
resolve(unsubscribe);
|
|
1325
|
+
}
|
|
1326
|
+
else {
|
|
1327
|
+
// IMPERATIVE INVOKER
|
|
1328
|
+
adapterOrCommand(config)
|
|
1329
|
+
.then((response) => {
|
|
1330
|
+
if (response.subscribe === undefined) {
|
|
1331
|
+
callback(buildNativeResponse(response));
|
|
1332
|
+
resolve(undefined);
|
|
1333
|
+
}
|
|
1334
|
+
else {
|
|
1335
|
+
const unsubscribe = response.subscribe((subscriptionResult) => {
|
|
1336
|
+
callback(buildNativeResponse(subscriptionResult));
|
|
1337
|
+
});
|
|
1338
|
+
resolve(unsubscribe);
|
|
1339
|
+
}
|
|
1340
|
+
})
|
|
1341
|
+
.catch((error) => {
|
|
1342
|
+
callback(buildOneStoreError(error));
|
|
1343
|
+
resolve(undefined);
|
|
1344
|
+
});
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
catch (error) {
|
|
1348
|
+
callback(buildInvalidAdapterError(adapterOrCommandName));
|
|
1349
|
+
resolve(undefined);
|
|
1350
|
+
}
|
|
1351
|
+
});
|
|
1352
|
+
}
|
|
1353
|
+
isCommandWireAdapter(adapterOrCommand) {
|
|
1354
|
+
return Object.getPrototypeOf(adapterOrCommand).name === 'CommandWireAdapterConstructor';
|
|
1355
|
+
}
|
|
1356
|
+
hasInvoke(adapterOrCommand) {
|
|
1357
|
+
return typeof adapterOrCommand.invoke === 'function';
|
|
1358
|
+
}
|
|
1359
|
+
hasSubscribe(adapterOrCommand) {
|
|
1360
|
+
return typeof adapterOrCommand.subscribe === 'function';
|
|
1361
|
+
}
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1215
1364
|
if (process.env.NODE_ENV !== 'production') {
|
|
1216
1365
|
// eslint-disable-next-line no-undef
|
|
1217
1366
|
withDefaultLuvio((luvio) => {
|
|
@@ -1221,5 +1370,5 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
1221
1370
|
});
|
|
1222
1371
|
}
|
|
1223
1372
|
|
|
1224
|
-
export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, importLuvioAdapterModule, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
|
|
1225
|
-
// version: 1.
|
|
1373
|
+
export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, importLuvioAdapterModule, importOneStoreAdapterModule, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
|
|
1374
|
+
// version: 1.372.0-5866fad2db
|
|
@@ -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, };
|