@salesforce/lds-worker-api 1.311.1 → 1.313.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.
@@ -237,8 +237,8 @@ function imperativeAdapterKeyBuilder(adapterId) {
237
237
  * callback with data or error. Returns an unsubscribe function that should
238
238
  * be called to stop receiving updated snapshots.
239
239
  *
240
- * This function throws an error if the given adapterId cannot be found or is not
241
- * a GET wire adapter. It will also throw if it fails to parse the config string.
240
+ * This function returns an error if the given adapterId cannot be found or is not
241
+ * a GET wire adapter. It will also return an error if it fails to parse the config string.
242
242
  */
243
243
  function subscribeToAdapter(adapterId, config, onSnapshot, nativeAdapterRequestContext) {
244
244
  const imperativeAdapterIdentifier = imperativeAdapterKeyBuilder(adapterId);
@@ -250,9 +250,17 @@ function subscribeToAdapter(adapterId, config, onSnapshot, nativeAdapterRequestC
250
250
  // This check is here for legacy purpose
251
251
  // So the consumers still get the same errors
252
252
  if (getDMLAdapterFromName(adapterId) === undefined) {
253
- throw Error(`adapter ${adapterId} not recognized`);
253
+ onResponseDelegate({
254
+ data: undefined,
255
+ error: createNativeFetchErrorResponse(`adapter ${adapterId} not recognized`),
256
+ });
257
+ return () => { };
254
258
  }
255
- throw Error(`${adapterId} is not a GET wire adapter.`);
259
+ onResponseDelegate({
260
+ data: undefined,
261
+ error: createNativeFetchErrorResponse(`${adapterId} is not a GET wire adapter.`),
262
+ });
263
+ return () => { };
256
264
  }
257
265
  const configObject = parse(config);
258
266
  // Check if it's graphQl adapter
@@ -344,11 +352,11 @@ function invokeAdapterWithDraftToReplace(adapterId, config, draftIdToReplace, on
344
352
  invokeAdapterWithDraftToMerge(adapterId, config, draftIdToReplace, onResponse, nativeAdapterRequestContext);
345
353
  }
346
354
  /**
347
- * Executes the specified adapter with the given @param dapterId and @param config. Then
348
- * it merge the draft with the given id with the draft generated by
355
+ * Executes the specified adapter with the given @param adapterId and @param config. Then
356
+ * it merges the draft with the given id with the draft generated by
349
357
  * the mutating adapter. Will call onResult callback once with data or error.
350
358
  *
351
- * This function throws an error if the given adapterId cannot be found, or if the
359
+ * This function returns an error if the given adapterId cannot be found, or if the
352
360
  * adapterId is not a mutating adapter if a draft isn't created, or
353
361
  * if it fails to parse the given config string.
354
362
  *
@@ -411,7 +419,7 @@ function invokeAdapterWithDraftToMerge(adapterId, config, targetDraftId, onRespo
411
419
  * it sets the given metadata on the draft created by the mutating adapter. Will call
412
420
  * onResult callback once with data or error.
413
421
  *
414
- * This function throws an error if the given adapterId cannot be found, or if the
422
+ * This function returns an error if the given adapterId cannot be found, or if the
415
423
  * adapterId is not a mutating adapter, or if a draft isn't created, or if it
416
424
  * fails to parse the given config string.
417
425
  */
@@ -427,7 +435,11 @@ function invokeAdapterWithMetadata(adapterId, config, metadata, onResponse, nati
427
435
  });
428
436
  return;
429
437
  }
430
- throw Error(`adapter ${adapterId} not recognized`);
438
+ onResponse({
439
+ data: undefined,
440
+ error: createNativeFetchErrorResponse(`adapter ${adapterId} not recognized`),
441
+ });
442
+ return;
431
443
  }
432
444
  if (adapterId === 'deleteRecord') {
433
445
  invokeAdapterWithMetadataDeleteRecord(adapter, config, metadata, onResponse, nativeAdapterRequestContext);
@@ -590,7 +602,7 @@ function draftIdsForResponseValue(response) {
590
602
  * Executes the specified adapter with the given adapterId and config. Will call
591
603
  * onResponse callback once with data or error.
592
604
  *
593
- * This function throws an error if the given adapterId cannot be found or if it
605
+ * This function returns an error if the given adapterId cannot be found or if it
594
606
  * fails to parse the given config string.
595
607
  */
596
608
  function invokeAdapter(adapterId, config, onResponse, nativeAdapterRequestContext) {
@@ -654,7 +666,11 @@ function invokeAdapter(adapterId, config, onResponse, nativeAdapterRequestContex
654
666
  }
655
667
  const adapter = getDMLAdapterFromName(adapterId);
656
668
  if (adapter === undefined) {
657
- throw Error(`adapter ${adapterId} not recognized`);
669
+ onResponseDelegate({
670
+ data: undefined,
671
+ error: createNativeFetchErrorResponse(`adapter ${adapterId} not recognized`),
672
+ });
673
+ return;
658
674
  }
659
675
  invokeDmlAdapter(adapter, configObject, onResponseDelegate, nativeAdapterRequestContext);
660
676
  }
@@ -1071,4 +1087,4 @@ if (process.env.NODE_ENV !== 'production') {
1071
1087
  }
1072
1088
 
1073
1089
  export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
1074
- // version: 1.311.1-73c3329af5
1090
+ // version: 1.313.0-bf88d762e3
@@ -42,8 +42,8 @@ export declare function buildAdapterRequestContext(nativeRequestContext: NativeA
42
42
  * callback with data or error. Returns an unsubscribe function that should
43
43
  * be called to stop receiving updated snapshots.
44
44
  *
45
- * This function throws an error if the given adapterId cannot be found or is not
46
- * a GET wire adapter. It will also throw if it fails to parse the config string.
45
+ * This function returns an error if the given adapterId cannot be found or is not
46
+ * a GET wire adapter. It will also return an error if it fails to parse the config string.
47
47
  */
48
48
  export declare function subscribeToAdapter(adapterId: string, config: string, onSnapshot: NativeOnSnapshot, nativeAdapterRequestContext?: NativeAdapterRequestContext): Unsubscribe;
49
49
  /**
@@ -54,11 +54,11 @@ export declare function subscribeToAdapter(adapterId: string, config: string, on
54
54
  */
55
55
  export declare function invokeAdapterWithDraftToReplace(adapterId: string, config: string, draftIdToReplace: string, onResponse: NativeOnResponse, nativeAdapterRequestContext?: NativeAdapterRequestContext): void;
56
56
  /**
57
- * Executes the specified adapter with the given @param dapterId and @param config. Then
58
- * it merge the draft with the given id with the draft generated by
57
+ * Executes the specified adapter with the given @param adapterId and @param config. Then
58
+ * it merges the draft with the given id with the draft generated by
59
59
  * the mutating adapter. Will call onResult callback once with data or error.
60
60
  *
61
- * This function throws an error if the given adapterId cannot be found, or if the
61
+ * This function returns an error if the given adapterId cannot be found, or if the
62
62
  * adapterId is not a mutating adapter if a draft isn't created, or
63
63
  * if it fails to parse the given config string.
64
64
  *
@@ -71,7 +71,7 @@ export declare function invokeAdapterWithDraftToMerge(adapterId: string, config:
71
71
  * it sets the given metadata on the draft created by the mutating adapter. Will call
72
72
  * onResult callback once with data or error.
73
73
  *
74
- * This function throws an error if the given adapterId cannot be found, or if the
74
+ * This function returns an error if the given adapterId cannot be found, or if the
75
75
  * adapterId is not a mutating adapter, or if a draft isn't created, or if it
76
76
  * fails to parse the given config string.
77
77
  */
@@ -80,7 +80,7 @@ export declare function invokeAdapterWithMetadata(adapterId: string, config: str
80
80
  * Executes the specified adapter with the given adapterId and config. Will call
81
81
  * onResponse callback once with data or error.
82
82
  *
83
- * This function throws an error if the given adapterId cannot be found or if it
83
+ * This function returns an error if the given adapterId cannot be found or if it
84
84
  * fails to parse the given config string.
85
85
  */
86
86
  export declare function invokeAdapter(adapterId: string, config: string, onResponse: NativeOnResponse, nativeAdapterRequestContext?: NativeAdapterRequestContext): void;
@@ -4,7 +4,7 @@ interface PrimingError {
4
4
  code: ErrorCode;
5
5
  message: string;
6
6
  }
7
- type ErrorCode = 'precondition-error' | 'not-found' | 'service-unavailable' | 'canceled' | 'unknown';
7
+ type ErrorCode = 'precondition-error' | 'not-found' | 'service-protection-error' | 'service-unavailable' | 'canceled' | 'unknown';
8
8
  export interface PrimingEventHandler {
9
9
  onError?: (error: PrimingError) => void;
10
10
  onPrimed?: (ids: string[]) => void;