@salesforce/lds-worker-api 1.322.0 → 1.324.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.
@@ -33,12 +33,12 @@ import * as lightningRelatedListApi from 'lightning/uiRelatedListApi';
33
33
  import * as unstableLightningRelatedListApi from 'lightning/unstable_uiRelatedListApi';
34
34
  import * as lightningGraphQLApi from 'lightning/uiGraphQLApi';
35
35
  import * as gqlApi from 'force/ldsAdaptersGraphql';
36
- import { getRuntime, reportGraphqlQueryParseError, O11Y_NAMESPACE_LDS_MOBILE } from 'native/ldsRuntimeMobile';
36
+ import { getRuntime, O11Y_NAMESPACE_LDS_MOBILE, reportGraphqlQueryParseError } from 'native/ldsRuntimeMobile';
37
37
  export { registerReportObserver } from 'native/ldsRuntimeMobile';
38
38
  import { HttpStatusCode } from 'force/luvioEngine';
39
+ import { getInstrumentation } from 'o11y/client';
39
40
  import { API_NAMESPACE, RECORD_REPRESENTATION_NAME, keyBuilderRecord } from 'force/ldsAdaptersUiapi';
40
41
  import { withDefaultLuvio } from 'native/ldsEngineMobile';
41
- import { getInstrumentation } from 'o11y/client';
42
42
  import { evictCacheRecordsByIdsSchema, evictExpiredEntriesSchema } from 'o11y_schema/sf_lds';
43
43
 
44
44
  const { create, keys } = Object;
@@ -159,6 +159,7 @@ function normalizeError(error) {
159
159
  return new Error(stringify(error));
160
160
  }
161
161
 
162
+ const ldsMobileInstrumentation$1 = getInstrumentation(O11Y_NAMESPACE_LDS_MOBILE);
162
163
  /**
163
164
  * Coerces a cache policy passed in from native to a luvio cache policy
164
165
  * @param nativeCachePolicy The cache policy passed in from native
@@ -452,9 +453,14 @@ function invokeAdapterWithMetadata(adapterId, config, metadata, onResponse, nati
452
453
  draftIds.length > 0) {
453
454
  const draftId = draftIds[draftIds.length - 1];
454
455
  const managerState = await draftManager.getQueue();
455
- const existingMetadata = (managerState.items.find((i) => i.id === draftId) || {}).metadata || {};
456
+ const draftItem = managerState.items.find((x) => x.id === draftId);
457
+ if (draftItem === undefined) {
458
+ // draftItem no longer exists, might have already been uploaded
459
+ ldsMobileInstrumentation$1.log('tried to set metadata on draft item that no longer exists');
460
+ return onResponse(responseValue);
461
+ }
456
462
  draftManager
457
- .setMetadata(draftId, { ...existingMetadata, ...metadata })
463
+ .setMetadata(draftId, { ...draftItem.metadata, ...metadata })
458
464
  .then(() => {
459
465
  onResponse(responseValue);
460
466
  })
@@ -1092,4 +1098,4 @@ if (process.env.NODE_ENV !== 'production') {
1092
1098
  }
1093
1099
 
1094
1100
  export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
1095
- // version: 1.322.0-6aa042602a
1101
+ // version: 1.324.0-62e02d2ff9
@@ -2,6 +2,7 @@ import type { AdapterRequestContext, CachePolicy, LuvioAdapterEventObserver } fr
2
2
  import type { DraftQueueItemMetadata } from '@salesforce/lds-drafts';
3
3
  import type { NativeErrorResponse } from './responses';
4
4
  import type { ObservabilityContext } from '@salesforce/lds-runtime-mobile';
5
+ export declare const ldsMobileInstrumentation: import("o11y/dist/modules/o11y/client/interfaces").Instrumentation;
5
6
  export type NativeCallbackValue = NativeCallbackData | NativeCallbackError | NativeCallbackErrors;
6
7
  export type NativeCallbackData = {
7
8
  data: any | undefined;