@salesforce/lds-worker-api 1.309.0-dev10 → 1.309.0-dev12

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 'native/ldsAdaptersUiapiMobile';
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
@@ -440,9 +441,14 @@ function invokeAdapterWithMetadata(adapterId, config, metadata, onResponse, nati
440
441
  draftIds.length > 0) {
441
442
  const draftId = draftIds[draftIds.length - 1];
442
443
  const managerState = await draftManager.getQueue();
443
- const existingMetadata = (managerState.items.find((i) => i.id === draftId) || {}).metadata || {};
444
+ const draftItem = managerState.items.find((x) => x.id === draftId);
445
+ if (draftItem === undefined) {
446
+ // draftItem no longer exists, might have already been uploaded
447
+ ldsMobileInstrumentation$1.log('tried to set metadata on draft item that no longer exists');
448
+ return onResponse(responseValue);
449
+ }
444
450
  draftManager
445
- .setMetadata(draftId, { ...existingMetadata, ...metadata })
451
+ .setMetadata(draftId, { ...draftItem.metadata, ...metadata })
446
452
  .then(() => {
447
453
  onResponse(responseValue);
448
454
  })
@@ -1071,4 +1077,4 @@ if (process.env.NODE_ENV !== 'production') {
1071
1077
  }
1072
1078
 
1073
1079
  export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
1074
- // version: 1.309.0-dev10-fb453615fe
1080
+ // version: 1.309.0-dev12-09ae94a55e
@@ -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;
@@ -4265,7 +4265,7 @@ function withDefaultLuvio(callback) {
4265
4265
  }
4266
4266
  callbacks.push(callback);
4267
4267
  }
4268
- // version: 1.309.0-dev10-fb453615fe
4268
+ // version: 1.309.0-dev12-09ae94a55e
4269
4269
 
4270
4270
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4271
4271
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15764,7 +15764,7 @@ function gql(literals, ...subs) {
15764
15764
  }
15765
15765
  return superResult;
15766
15766
  }
15767
- // version: 1.309.0-dev10-fb453615fe
15767
+ // version: 1.309.0-dev12-09ae94a55e
15768
15768
 
15769
15769
  function unwrap(data) {
15770
15770
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16705,7 +16705,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
16705
16705
  const { apiFamily, name } = metadata;
16706
16706
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16707
16707
  }
16708
- // version: 1.309.0-dev10-fb453615fe
16708
+ // version: 1.309.0-dev12-09ae94a55e
16709
16709
 
16710
16710
  /**
16711
16711
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -44812,7 +44812,7 @@ withDefaultLuvio((luvio) => {
44812
44812
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
44813
44813
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
44814
44814
  });
44815
- // version: 1.309.0-dev10-96422fc06f
44815
+ // version: 1.309.0-dev12-9b91cf52fb
44816
44816
 
44817
44817
  var ldsIdempotencyWriteDisabled = {
44818
44818
  isOpen: function (e) {
@@ -50460,7 +50460,7 @@ class DurableDraftQueue {
50460
50460
  switch (result) {
50461
50461
  case ProcessActionResult.BLOCKED_ON_ERROR:
50462
50462
  this.state = DraftQueueState.Error;
50463
- return Promise.reject();
50463
+ return Promise.reject('Unable to start queue - first action is in error state');
50464
50464
  default:
50465
50465
  return Promise.resolve();
50466
50466
  }
@@ -51752,16 +51752,17 @@ class DraftManager {
51752
51752
  return Promise.reject('cannot edit incompatible action type or uploading actions');
51753
51753
  }
51754
51754
  action.data.body.fields = { ...action.data.body.fields, ...fields };
51755
+ action.status = DraftActionStatus.Pending;
51755
51756
  await this.draftQueue.updateDraftAction(action);
51756
51757
  return this.buildDraftQueueItem(action);
51757
51758
  }
51758
51759
  isValidFieldMap(fields) {
51759
51760
  const keys$1 = keys$6(fields);
51760
- const validTypes = ['string', 'number', 'null', 'boolean'];
51761
+ const validTypes = ['string', 'number', 'boolean'];
51761
51762
  for (let i = 0; i < keys$1.length; i++) {
51762
51763
  const key = keys$1[i];
51763
51764
  const value = fields[key];
51764
- if (!validTypes.includes(typeof value)) {
51765
+ if (!validTypes.includes(typeof value) && value !== null) {
51765
51766
  return false;
51766
51767
  }
51767
51768
  }
@@ -51789,6 +51790,7 @@ class DraftManager {
51789
51790
  }
51790
51791
  const data = action.data;
51791
51792
  data.body.fields = { ...data.body.fields, ...fields };
51793
+ action.status = DraftActionStatus.Pending;
51792
51794
  await this.draftQueue.updateDraftAction(action);
51793
51795
  return this.buildDraftQueueItem(action);
51794
51796
  }
@@ -57144,14 +57146,14 @@ async function connectionResolver(obj, args, context, info) {
57144
57146
  limit = args.first;
57145
57147
  }
57146
57148
  let offset = 0;
57147
- if (args.after) {
57148
- let originalCursor = context.mappedCursors.get(queryCacheKey);
57149
- if (!originalCursor) {
57150
- // eslint-disable-next-line @salesforce/lds/no-error-in-production
57151
- throw new Error('Internal Error: unable to determine `after` cursor value');
57152
- }
57149
+ let originalCursor = context.mappedCursors.get(queryCacheKey);
57150
+ if (originalCursor) {
57153
57151
  offset = decodeV1Cursor(originalCursor).i;
57154
57152
  }
57153
+ else if (args.after) {
57154
+ // eslint-disable-next-line @salesforce/lds/no-error-in-production
57155
+ throw new Error('Internal Error: unable to determine `after` cursor value');
57156
+ }
57155
57157
  // if the query wants to know `hasNextPage` then we need to request 1 additional record
57156
57158
  let selections = info.fieldNodes
57157
57159
  .map((n) => (n.selectionSet ? n.selectionSet.selections : []))
@@ -59743,8 +59745,9 @@ function createErrorSnapshot(result, snapshot) {
59743
59745
  },
59744
59746
  };
59745
59747
  }
59746
- function createLocalEvalSnapshot(data, seenRecords, recordId, rebuildWithLocalEval) {
59748
+ function createLocalEvalSnapshot(data, seenRecords, recordId, rebuildWithLocalEval, refresh) {
59747
59749
  return {
59750
+ refresh,
59748
59751
  recordId,
59749
59752
  variables: {},
59750
59753
  seenRecords,
@@ -59962,11 +59965,11 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
59962
59965
  isDraftId,
59963
59966
  getCanonicalId,
59964
59967
  };
59968
+ const eventEmitter = createCustomAdapterEventEmitter(GRAPHQL_EVAL_NAMESPACE, requestContext.eventObservers || []);
59965
59969
  try {
59966
59970
  // NB: This occurs BEFORE synthetic field injection on purpose to
59967
59971
  // ensure we don't charge the caller for spanning records we inject
59968
59972
  // on their behalf.
59969
- const eventEmitter = createCustomAdapterEventEmitter(GRAPHQL_EVAL_NAMESPACE, requestContext.eventObservers || []);
59970
59973
  const queryInstrumentation = instrumentLimits(copy, config.variables || {});
59971
59974
  eventEmitter({
59972
59975
  type: 'graphql-query-instrumentation',
@@ -60098,7 +60101,7 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
60098
60101
  // the error is network error or 504), otherwise we spread over
60099
60102
  // the non-eval'ed snapshot (which will be either Fulfilled or Stale)
60100
60103
  const resultSnapshot = nonEvaluatedSnapshot.state === 'Error'
60101
- ? createLocalEvalSnapshot(gqlResult, seenRecords, recordId, rebuildWithLocalEval)
60104
+ ? createLocalEvalSnapshot(gqlResult, seenRecords, recordId, rebuildWithLocalEval, nonEvaluatedSnapshot.refresh)
60102
60105
  : {
60103
60106
  ...nonEvaluatedSnapshot,
60104
60107
  data: gqlResult,
@@ -60121,6 +60124,9 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
60121
60124
  },
60122
60125
  };
60123
60126
  }
60127
+ if (refresh === undefined) {
60128
+ eventEmitter({ type: 'graphql-luvio-refresh-undefined' });
60129
+ }
60124
60130
  if (possibleStaleRecordMap.size > 0) {
60125
60131
  initiateStaleRecordRefresh(luvio, possibleStaleRecordMap);
60126
60132
  resultSnapshot.state = 'Stale';
@@ -61327,32 +61333,122 @@ function normalizeError$2(err) {
61327
61333
  }
61328
61334
  return new Error(stringify$1$1(err));
61329
61335
  }
61336
+ // metrics
61337
+ /** GraphQL */
61338
+ const GRAPHQL_EVAL_ERROR = 'gql-eval-error';
61339
+ const GRAPHQL_EVAL_DB_READ_DURATION = 'gql-eval-db-read-duration';
61330
61340
  const GRAPHQL_EVAL_ROOT_QUERY_COUNT = 'gql-eval-root-query-count';
61331
61341
  const GRAPHQL_EVAL_TOTAL_QUERY_COUNT = 'gql-eval-total-query-count';
61332
61342
  const GRAPHQL_EVAL_MAX_CHILD_RELATIONSHIPS_COUNT = 'gql-eval-max-child-count';
61333
61343
  const GRAPHQL_EVAL_QUERY_RECORD_COUNT = 'gql-eval-query-record-count';
61344
+ const GRAPHQL_SNAPSHOT_REFRESH_UNDEFINED = 'gql-snapshot-refresh-undefined';
61345
+ /** Draft Queue */
61346
+ const DRAFT_QUEUE_STATE_STARTED = 'draft-queue-state-started';
61347
+ const DRAFT_QUEUE_STATE_ERROR = 'draft-queue-state-error';
61348
+ const DRAFT_QUEUE_STATE_WAITING = 'draft-queue-state-waiting';
61349
+ const DRAFT_QUEUE_STATE_STOPPED = 'draft-queue-state-stopped';
61350
+ const DRAFT_QUEUE_ACTION_ADDED = 'draft-queue-action-added';
61351
+ const DRAFT_QUEUE_ACTION_UPLOADING = 'draft-queue-action-uploading';
61352
+ const DRAFT_QUEUE_ACTION_COMPLETED = 'draft-queue-action-completed';
61353
+ const DRAFT_QUEUE_ACTION_DELETED = 'draft-queue-action-deleted';
61354
+ const DRAFT_QUEUE_ACTION_UPDATED = 'draft-queue-action-updated';
61355
+ const DRAFT_QUEUE_ACTION_FAILED = 'draft-queue-action-failed';
61334
61356
  const DRAFT_QUEUE_TOTAL_MERGE_ACTIONS_CALLS = 'draft-queue-total-mergeActions-calls';
61335
- const ldsMobileInstrumentation$1 = getInstrumentation();
61357
+ /** Content Document */
61358
+ const CREATE_CONTENT_DOCUMENT_AND_VERSION_TOTAL_SYNTHESIZE_CALLS = 'content-document-version-total-synthesize-calls';
61359
+ const CREATE_CONTENT_DOCUMENT_AND_VERSION_DRAFT_SYNTHESIZE_ERROR = 'create-content-document-version-draft-synthesize-error';
61360
+ /** Priming */
61361
+ const PRIMING_TOTAL_SESSION_COUNT = 'priming-total-session-count';
61362
+ const PRIMING_TOTAL_ERROR_COUNT = 'priming-total-error-count';
61363
+ const PRIMING_TOTAL_PRIMED_COUNT = 'priming-total-primed-count';
61364
+ const PRIMING_TOTAL_CONFLICT_COUNT = 'priming-total-conflict-count';
61365
+ // logs
61366
+ const GRAPHQL_QUERY_PARSE_ERROR = 'gql-query-parse-error';
61367
+ const GRAPHQL_SQL_EVAL_PRECONDITION_ERROR = 'gql-sql-pre-eval-error';
61368
+ const GRAPHQL_CREATE_SNAPSHOT_ERROR = 'gql-create-snapshot-error';
61369
+ const DRAFT_AWARE_CREATE_CONTENT_DOCUMENT_AND_VERSION_ERROR = 'draft-aware-create-content-document-and-version-error';
61370
+ const ldsMobileInstrumentation$2 = getInstrumentation();
61336
61371
  function reportGraphqlQueryParseError(err) {
61337
- normalizeError$2(err);
61372
+ const error = normalizeError$2(err);
61373
+ const errorCode = GRAPHQL_QUERY_PARSE_ERROR;
61374
+ // Metric
61375
+ reportGraphqlAdapterError(errorCode);
61376
+ // Log
61377
+ ldsMobileInstrumentation$2.error(error, errorCode);
61338
61378
  }
61339
61379
  function reportGraphqlSqlEvalPreconditionError(err) {
61340
- normalizeError$2(err);
61380
+ const error = normalizeError$2(err);
61381
+ const errorCode = GRAPHQL_SQL_EVAL_PRECONDITION_ERROR;
61382
+ // Metric
61383
+ reportGraphqlAdapterError(errorCode);
61384
+ // Log
61385
+ ldsMobileInstrumentation$2.error(error, errorCode);
61341
61386
  }
61342
61387
  function reportGraphqlCreateSnapshotError(err) {
61343
- normalizeError$2(err);
61388
+ const error = normalizeError$2(err);
61389
+ const errorCode = GRAPHQL_CREATE_SNAPSHOT_ERROR;
61390
+ // Metric
61391
+ reportGraphqlAdapterError(errorCode);
61392
+ // Log
61393
+ ldsMobileInstrumentation$2.error(error, errorCode);
61344
61394
  }
61345
61395
  function reportGraphQlEvalDbReadDuration(duration) {
61396
+ ldsMobileInstrumentation$2.trackValue(GRAPHQL_EVAL_DB_READ_DURATION, duration);
61397
+ }
61398
+ function reportGraphqlAdapterError(errorCode) {
61399
+ // Increment overall count with errorCode as tag
61400
+ ldsMobileInstrumentation$2.incrementCounter(GRAPHQL_EVAL_ERROR, 1, true, { errorCode });
61346
61401
  }
61347
61402
  function reportGraphqlQueryInstrumentation(data) {
61348
61403
  const queryBuckets = [1, 2, 3, 4, 5, 10, 20, 50, 100];
61349
61404
  const recordBuckets = [
61350
61405
  1, 5, 10, 20, 50, 100, 1000, 2000, 5000, 10000, 50000, 100000, 1000000,
61351
61406
  ];
61352
- ldsMobileInstrumentation$1.bucketValue(GRAPHQL_EVAL_ROOT_QUERY_COUNT, data.rootQueryCount, queryBuckets);
61353
- ldsMobileInstrumentation$1.bucketValue(GRAPHQL_EVAL_TOTAL_QUERY_COUNT, data.totalQueryCount, queryBuckets);
61354
- ldsMobileInstrumentation$1.bucketValue(GRAPHQL_EVAL_MAX_CHILD_RELATIONSHIPS_COUNT, data.maxChildRelationships, queryBuckets);
61355
- ldsMobileInstrumentation$1.bucketValue(GRAPHQL_EVAL_QUERY_RECORD_COUNT, data.requestedRecordCount, recordBuckets);
61407
+ ldsMobileInstrumentation$2.bucketValue(GRAPHQL_EVAL_ROOT_QUERY_COUNT, data.rootQueryCount, queryBuckets);
61408
+ ldsMobileInstrumentation$2.bucketValue(GRAPHQL_EVAL_TOTAL_QUERY_COUNT, data.totalQueryCount, queryBuckets);
61409
+ ldsMobileInstrumentation$2.bucketValue(GRAPHQL_EVAL_MAX_CHILD_RELATIONSHIPS_COUNT, data.maxChildRelationships, queryBuckets);
61410
+ ldsMobileInstrumentation$2.bucketValue(GRAPHQL_EVAL_QUERY_RECORD_COUNT, data.requestedRecordCount, recordBuckets);
61411
+ }
61412
+ function incrementGraphQLRefreshUndfined() {
61413
+ ldsMobileInstrumentation$2.incrementCounter(GRAPHQL_SNAPSHOT_REFRESH_UNDEFINED);
61414
+ }
61415
+ function reportDraftActionEvent(state) {
61416
+ switch (state) {
61417
+ case 'added':
61418
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_ADDED);
61419
+ break;
61420
+ case 'uploading':
61421
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_UPLOADING);
61422
+ break;
61423
+ case 'completed':
61424
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_COMPLETED);
61425
+ break;
61426
+ case 'deleted':
61427
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_DELETED);
61428
+ break;
61429
+ case 'failed':
61430
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_FAILED, 1, true);
61431
+ break;
61432
+ case 'updated':
61433
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_UPDATED);
61434
+ break;
61435
+ }
61436
+ }
61437
+ function reportDraftQueueState(state) {
61438
+ switch (state) {
61439
+ case 'started':
61440
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_STATE_STARTED);
61441
+ break;
61442
+ case 'error':
61443
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_STATE_ERROR, 1, true);
61444
+ break;
61445
+ case 'waiting':
61446
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_STATE_WAITING);
61447
+ break;
61448
+ case 'stopped':
61449
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_STATE_STOPPED);
61450
+ break;
61451
+ }
61356
61452
  }
61357
61453
  function reportDraftAwareContentDocumentVersionSynthesizeError(err) {
61358
61454
  let error;
@@ -61362,16 +61458,43 @@ function reportDraftAwareContentDocumentVersionSynthesizeError(err) {
61362
61458
  else {
61363
61459
  error = normalizeError$2(err);
61364
61460
  }
61365
- error.errorType;
61461
+ const errorCode = DRAFT_AWARE_CREATE_CONTENT_DOCUMENT_AND_VERSION_ERROR;
61462
+ const errorType = error.errorType;
61463
+ const tags = {
61464
+ errorCode,
61465
+ };
61466
+ if (errorType !== undefined) {
61467
+ tags.errorType = errorType;
61468
+ }
61469
+ // Metric
61470
+ ldsMobileInstrumentation$2.incrementCounter(CREATE_CONTENT_DOCUMENT_AND_VERSION_DRAFT_SYNTHESIZE_ERROR, 1, true, tags);
61471
+ // Log
61472
+ ldsMobileInstrumentation$2.error(error, errorCode);
61366
61473
  }
61367
61474
  function reportDraftAwareContentVersionSynthesizeCalls(mimeType) {
61475
+ ldsMobileInstrumentation$2.incrementCounter(CREATE_CONTENT_DOCUMENT_AND_VERSION_TOTAL_SYNTHESIZE_CALLS, 1, undefined, { mimeType });
61476
+ }
61477
+ /** Priming */
61478
+ function reportPrimingSessionCreated() {
61479
+ ldsMobileInstrumentation$2.incrementCounter(PRIMING_TOTAL_SESSION_COUNT, 1, undefined, {});
61368
61480
  }
61369
61481
  function reportPrimingError(errorType, recordCount) {
61482
+ ldsMobileInstrumentation$2.incrementCounter(PRIMING_TOTAL_ERROR_COUNT, recordCount, undefined, {
61483
+ errorType,
61484
+ });
61485
+ }
61486
+ function reportPrimingSuccess(recordCount) {
61487
+ ldsMobileInstrumentation$2.incrementCounter(PRIMING_TOTAL_PRIMED_COUNT, recordCount, undefined);
61370
61488
  }
61371
61489
  function reportPrimingConflict(resolutionType, recordCount) {
61490
+ ldsMobileInstrumentation$2.incrementCounter(PRIMING_TOTAL_CONFLICT_COUNT, recordCount, undefined, {
61491
+ resolutionType,
61492
+ });
61372
61493
  }
61373
61494
  /** Network */
61374
61495
  function reportChunkCandidateUrlLength(urlLength) {
61496
+ const buckets = [8000, 10000, 12000, 14000, 16000];
61497
+ ldsMobileInstrumentation$2.bucketValue('chunk-candidate-url-length-histogram', urlLength, buckets);
61375
61498
  }
61376
61499
 
61377
61500
  /**
@@ -61385,13 +61508,19 @@ const withInstrumentation = (operation, config) => {
61385
61508
  return operation();
61386
61509
  }
61387
61510
  const { tags, metricName, logError } = config;
61511
+ let hasError = false;
61388
61512
  return operation()
61389
61513
  .catch((err) => {
61514
+ hasError = true;
61390
61515
  const error = normalizeError$2(err);
61391
61516
  tags['errorMessage'] = error.message;
61517
+ if (logError) {
61518
+ ldsMobileInstrumentation$2.error(error);
61519
+ }
61392
61520
  throw err;
61393
61521
  })
61394
61522
  .finally(() => {
61523
+ ldsMobileInstrumentation$2.incrementCounter(metricName, 1, hasError, tags);
61395
61524
  });
61396
61525
  };
61397
61526
 
@@ -61404,26 +61533,36 @@ function instrumentDraftQueue(queue) {
61404
61533
  case DraftQueueEventType.QueueStateChanged:
61405
61534
  switch (draftQueueEvent.state) {
61406
61535
  case DraftQueueState.Error:
61536
+ reportDraftQueueState('error');
61407
61537
  break;
61408
61538
  case DraftQueueState.Started:
61539
+ reportDraftQueueState('started');
61409
61540
  break;
61410
61541
  case DraftQueueState.Stopped:
61542
+ reportDraftQueueState('stopped');
61411
61543
  break;
61412
61544
  case DraftQueueState.Waiting:
61545
+ reportDraftQueueState('waiting');
61413
61546
  break;
61414
61547
  }
61415
61548
  break;
61416
61549
  case DraftQueueEventType.ActionAdded:
61550
+ reportDraftActionEvent('added');
61417
61551
  break;
61418
61552
  case DraftQueueEventType.ActionUploading:
61553
+ reportDraftActionEvent('uploading');
61419
61554
  break;
61420
61555
  case DraftQueueEventType.ActionCompleted:
61556
+ reportDraftActionEvent('completed');
61421
61557
  break;
61422
61558
  case DraftQueueEventType.ActionDeleted:
61559
+ reportDraftActionEvent('deleted');
61423
61560
  break;
61424
61561
  case DraftQueueEventType.ActionFailed:
61562
+ reportDraftActionEvent('failed');
61425
61563
  break;
61426
61564
  case DraftQueueEventType.ActionUpdated:
61565
+ reportDraftActionEvent('updated');
61427
61566
  break;
61428
61567
  }
61429
61568
  return Promise.resolve();
@@ -61689,6 +61828,9 @@ function instrumentGraphQLEval(adapter) {
61689
61828
  case 'graphql-query-instrumentation':
61690
61829
  reportGraphqlQueryInstrumentation(data.data);
61691
61830
  break;
61831
+ case 'graphql-luvio-refresh-undefined':
61832
+ incrementGraphQLRefreshUndfined();
61833
+ break;
61692
61834
  }
61693
61835
  }
61694
61836
  },
@@ -63248,10 +63390,12 @@ class RecordIngestor {
63248
63390
  }
63249
63391
 
63250
63392
  function instrumentPrimingSession(session) {
63393
+ reportPrimingSessionCreated();
63251
63394
  session.on('error', ({ code, ids }) => {
63252
63395
  reportPrimingError(code, ids.length);
63253
63396
  });
63254
63397
  session.on('primed', ({ length }) => {
63398
+ reportPrimingSuccess(length);
63255
63399
  });
63256
63400
  session.on('conflict', ({ ids, resolution }) => {
63257
63401
  reportPrimingConflict(resolution, ids.length);
@@ -63944,7 +64088,7 @@ register$1({
63944
64088
  id: '@salesforce/lds-network-adapter',
63945
64089
  instrument: instrument$2,
63946
64090
  });
63947
- // version: 1.309.0-dev10-fb453615fe
64091
+ // version: 1.309.0-dev12-09ae94a55e
63948
64092
 
63949
64093
  const { create: create$3, keys: keys$3 } = Object;
63950
64094
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -83980,7 +84124,7 @@ register$1({
83980
84124
  configuration: { ...configurationForGraphQLAdapters$1 },
83981
84125
  instrument: instrument$1,
83982
84126
  });
83983
- // version: 1.309.0-dev10-96422fc06f
84127
+ // version: 1.309.0-dev12-9b91cf52fb
83984
84128
 
83985
84129
  // On core the unstable adapters are re-exported with different names,
83986
84130
  // we want to match them here.
@@ -86236,7 +86380,7 @@ withDefaultLuvio((luvio) => {
86236
86380
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
86237
86381
  graphQLImperative = ldsAdapter;
86238
86382
  });
86239
- // version: 1.309.0-dev10-96422fc06f
86383
+ // version: 1.309.0-dev12-9b91cf52fb
86240
86384
 
86241
86385
  var gqlApi = /*#__PURE__*/Object.freeze({
86242
86386
  __proto__: null,
@@ -86359,6 +86503,7 @@ function normalizeError(error) {
86359
86503
  return new Error(stringify$1(error));
86360
86504
  }
86361
86505
 
86506
+ const ldsMobileInstrumentation$1 = getInstrumentation();
86362
86507
  /**
86363
86508
  * Coerces a cache policy passed in from native to a luvio cache policy
86364
86509
  * @param nativeCachePolicy The cache policy passed in from native
@@ -86640,9 +86785,14 @@ function invokeAdapterWithMetadata(adapterId, config, metadata, onResponse, nati
86640
86785
  draftIds.length > 0) {
86641
86786
  const draftId = draftIds[draftIds.length - 1];
86642
86787
  const managerState = await draftManager.getQueue();
86643
- const existingMetadata = (managerState.items.find((i) => i.id === draftId) || {}).metadata || {};
86788
+ const draftItem = managerState.items.find((x) => x.id === draftId);
86789
+ if (draftItem === undefined) {
86790
+ // draftItem no longer exists, might have already been uploaded
86791
+ ldsMobileInstrumentation$1.log('tried to set metadata on draft item that no longer exists');
86792
+ return onResponse(responseValue);
86793
+ }
86644
86794
  draftManager
86645
- .setMetadata(draftId, { ...existingMetadata, ...metadata })
86795
+ .setMetadata(draftId, { ...draftItem.metadata, ...metadata })
86646
86796
  .then(() => {
86647
86797
  onResponse(responseValue);
86648
86798
  })
@@ -86971,7 +87121,7 @@ const callbacks$1 = [];
86971
87121
  function register(r) {
86972
87122
  callbacks$1.forEach((callback) => callback(r));
86973
87123
  }
86974
- // version: 1.309.0-dev10-fb453615fe
87124
+ // version: 1.309.0-dev12-09ae94a55e
86975
87125
 
86976
87126
  /**
86977
87127
  * Returns true if the value acts like a Promise, i.e. has a "then" function,
@@ -91933,4 +92083,4 @@ const { luvio } = getRuntime();
91933
92083
  setDefaultLuvio({ luvio });
91934
92084
 
91935
92085
  export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
91936
- // version: 1.309.0-dev10-fb453615fe
92086
+ // version: 1.309.0-dev12-09ae94a55e
@@ -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;
@@ -4271,7 +4271,7 @@
4271
4271
  }
4272
4272
  callbacks.push(callback);
4273
4273
  }
4274
- // version: 1.309.0-dev10-fb453615fe
4274
+ // version: 1.309.0-dev12-09ae94a55e
4275
4275
 
4276
4276
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4277
4277
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15770,7 +15770,7 @@
15770
15770
  }
15771
15771
  return superResult;
15772
15772
  }
15773
- // version: 1.309.0-dev10-fb453615fe
15773
+ // version: 1.309.0-dev12-09ae94a55e
15774
15774
 
15775
15775
  function unwrap(data) {
15776
15776
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16711,7 +16711,7 @@
16711
16711
  const { apiFamily, name } = metadata;
16712
16712
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16713
16713
  }
16714
- // version: 1.309.0-dev10-fb453615fe
16714
+ // version: 1.309.0-dev12-09ae94a55e
16715
16715
 
16716
16716
  /**
16717
16717
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -44818,7 +44818,7 @@
44818
44818
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
44819
44819
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
44820
44820
  });
44821
- // version: 1.309.0-dev10-96422fc06f
44821
+ // version: 1.309.0-dev12-9b91cf52fb
44822
44822
 
44823
44823
  var ldsIdempotencyWriteDisabled = {
44824
44824
  isOpen: function (e) {
@@ -50466,7 +50466,7 @@
50466
50466
  switch (result) {
50467
50467
  case ProcessActionResult.BLOCKED_ON_ERROR:
50468
50468
  this.state = DraftQueueState.Error;
50469
- return Promise.reject();
50469
+ return Promise.reject('Unable to start queue - first action is in error state');
50470
50470
  default:
50471
50471
  return Promise.resolve();
50472
50472
  }
@@ -51758,16 +51758,17 @@
51758
51758
  return Promise.reject('cannot edit incompatible action type or uploading actions');
51759
51759
  }
51760
51760
  action.data.body.fields = { ...action.data.body.fields, ...fields };
51761
+ action.status = DraftActionStatus.Pending;
51761
51762
  await this.draftQueue.updateDraftAction(action);
51762
51763
  return this.buildDraftQueueItem(action);
51763
51764
  }
51764
51765
  isValidFieldMap(fields) {
51765
51766
  const keys$1 = keys$6(fields);
51766
- const validTypes = ['string', 'number', 'null', 'boolean'];
51767
+ const validTypes = ['string', 'number', 'boolean'];
51767
51768
  for (let i = 0; i < keys$1.length; i++) {
51768
51769
  const key = keys$1[i];
51769
51770
  const value = fields[key];
51770
- if (!validTypes.includes(typeof value)) {
51771
+ if (!validTypes.includes(typeof value) && value !== null) {
51771
51772
  return false;
51772
51773
  }
51773
51774
  }
@@ -51795,6 +51796,7 @@
51795
51796
  }
51796
51797
  const data = action.data;
51797
51798
  data.body.fields = { ...data.body.fields, ...fields };
51799
+ action.status = DraftActionStatus.Pending;
51798
51800
  await this.draftQueue.updateDraftAction(action);
51799
51801
  return this.buildDraftQueueItem(action);
51800
51802
  }
@@ -57150,14 +57152,14 @@
57150
57152
  limit = args.first;
57151
57153
  }
57152
57154
  let offset = 0;
57153
- if (args.after) {
57154
- let originalCursor = context.mappedCursors.get(queryCacheKey);
57155
- if (!originalCursor) {
57156
- // eslint-disable-next-line @salesforce/lds/no-error-in-production
57157
- throw new Error('Internal Error: unable to determine `after` cursor value');
57158
- }
57155
+ let originalCursor = context.mappedCursors.get(queryCacheKey);
57156
+ if (originalCursor) {
57159
57157
  offset = decodeV1Cursor(originalCursor).i;
57160
57158
  }
57159
+ else if (args.after) {
57160
+ // eslint-disable-next-line @salesforce/lds/no-error-in-production
57161
+ throw new Error('Internal Error: unable to determine `after` cursor value');
57162
+ }
57161
57163
  // if the query wants to know `hasNextPage` then we need to request 1 additional record
57162
57164
  let selections = info.fieldNodes
57163
57165
  .map((n) => (n.selectionSet ? n.selectionSet.selections : []))
@@ -59749,8 +59751,9 @@
59749
59751
  },
59750
59752
  };
59751
59753
  }
59752
- function createLocalEvalSnapshot(data, seenRecords, recordId, rebuildWithLocalEval) {
59754
+ function createLocalEvalSnapshot(data, seenRecords, recordId, rebuildWithLocalEval, refresh) {
59753
59755
  return {
59756
+ refresh,
59754
59757
  recordId,
59755
59758
  variables: {},
59756
59759
  seenRecords,
@@ -59968,11 +59971,11 @@
59968
59971
  isDraftId,
59969
59972
  getCanonicalId,
59970
59973
  };
59974
+ const eventEmitter = createCustomAdapterEventEmitter(GRAPHQL_EVAL_NAMESPACE, requestContext.eventObservers || []);
59971
59975
  try {
59972
59976
  // NB: This occurs BEFORE synthetic field injection on purpose to
59973
59977
  // ensure we don't charge the caller for spanning records we inject
59974
59978
  // on their behalf.
59975
- const eventEmitter = createCustomAdapterEventEmitter(GRAPHQL_EVAL_NAMESPACE, requestContext.eventObservers || []);
59976
59979
  const queryInstrumentation = instrumentLimits(copy, config.variables || {});
59977
59980
  eventEmitter({
59978
59981
  type: 'graphql-query-instrumentation',
@@ -60104,7 +60107,7 @@
60104
60107
  // the error is network error or 504), otherwise we spread over
60105
60108
  // the non-eval'ed snapshot (which will be either Fulfilled or Stale)
60106
60109
  const resultSnapshot = nonEvaluatedSnapshot.state === 'Error'
60107
- ? createLocalEvalSnapshot(gqlResult, seenRecords, recordId, rebuildWithLocalEval)
60110
+ ? createLocalEvalSnapshot(gqlResult, seenRecords, recordId, rebuildWithLocalEval, nonEvaluatedSnapshot.refresh)
60108
60111
  : {
60109
60112
  ...nonEvaluatedSnapshot,
60110
60113
  data: gqlResult,
@@ -60127,6 +60130,9 @@
60127
60130
  },
60128
60131
  };
60129
60132
  }
60133
+ if (refresh === undefined) {
60134
+ eventEmitter({ type: 'graphql-luvio-refresh-undefined' });
60135
+ }
60130
60136
  if (possibleStaleRecordMap.size > 0) {
60131
60137
  initiateStaleRecordRefresh(luvio, possibleStaleRecordMap);
60132
60138
  resultSnapshot.state = 'Stale';
@@ -61333,32 +61339,122 @@
61333
61339
  }
61334
61340
  return new Error(stringify$1$1(err));
61335
61341
  }
61342
+ // metrics
61343
+ /** GraphQL */
61344
+ const GRAPHQL_EVAL_ERROR = 'gql-eval-error';
61345
+ const GRAPHQL_EVAL_DB_READ_DURATION = 'gql-eval-db-read-duration';
61336
61346
  const GRAPHQL_EVAL_ROOT_QUERY_COUNT = 'gql-eval-root-query-count';
61337
61347
  const GRAPHQL_EVAL_TOTAL_QUERY_COUNT = 'gql-eval-total-query-count';
61338
61348
  const GRAPHQL_EVAL_MAX_CHILD_RELATIONSHIPS_COUNT = 'gql-eval-max-child-count';
61339
61349
  const GRAPHQL_EVAL_QUERY_RECORD_COUNT = 'gql-eval-query-record-count';
61350
+ const GRAPHQL_SNAPSHOT_REFRESH_UNDEFINED = 'gql-snapshot-refresh-undefined';
61351
+ /** Draft Queue */
61352
+ const DRAFT_QUEUE_STATE_STARTED = 'draft-queue-state-started';
61353
+ const DRAFT_QUEUE_STATE_ERROR = 'draft-queue-state-error';
61354
+ const DRAFT_QUEUE_STATE_WAITING = 'draft-queue-state-waiting';
61355
+ const DRAFT_QUEUE_STATE_STOPPED = 'draft-queue-state-stopped';
61356
+ const DRAFT_QUEUE_ACTION_ADDED = 'draft-queue-action-added';
61357
+ const DRAFT_QUEUE_ACTION_UPLOADING = 'draft-queue-action-uploading';
61358
+ const DRAFT_QUEUE_ACTION_COMPLETED = 'draft-queue-action-completed';
61359
+ const DRAFT_QUEUE_ACTION_DELETED = 'draft-queue-action-deleted';
61360
+ const DRAFT_QUEUE_ACTION_UPDATED = 'draft-queue-action-updated';
61361
+ const DRAFT_QUEUE_ACTION_FAILED = 'draft-queue-action-failed';
61340
61362
  const DRAFT_QUEUE_TOTAL_MERGE_ACTIONS_CALLS = 'draft-queue-total-mergeActions-calls';
61341
- const ldsMobileInstrumentation$1 = getInstrumentation();
61363
+ /** Content Document */
61364
+ const CREATE_CONTENT_DOCUMENT_AND_VERSION_TOTAL_SYNTHESIZE_CALLS = 'content-document-version-total-synthesize-calls';
61365
+ const CREATE_CONTENT_DOCUMENT_AND_VERSION_DRAFT_SYNTHESIZE_ERROR = 'create-content-document-version-draft-synthesize-error';
61366
+ /** Priming */
61367
+ const PRIMING_TOTAL_SESSION_COUNT = 'priming-total-session-count';
61368
+ const PRIMING_TOTAL_ERROR_COUNT = 'priming-total-error-count';
61369
+ const PRIMING_TOTAL_PRIMED_COUNT = 'priming-total-primed-count';
61370
+ const PRIMING_TOTAL_CONFLICT_COUNT = 'priming-total-conflict-count';
61371
+ // logs
61372
+ const GRAPHQL_QUERY_PARSE_ERROR = 'gql-query-parse-error';
61373
+ const GRAPHQL_SQL_EVAL_PRECONDITION_ERROR = 'gql-sql-pre-eval-error';
61374
+ const GRAPHQL_CREATE_SNAPSHOT_ERROR = 'gql-create-snapshot-error';
61375
+ const DRAFT_AWARE_CREATE_CONTENT_DOCUMENT_AND_VERSION_ERROR = 'draft-aware-create-content-document-and-version-error';
61376
+ const ldsMobileInstrumentation$2 = getInstrumentation();
61342
61377
  function reportGraphqlQueryParseError(err) {
61343
- normalizeError$2(err);
61378
+ const error = normalizeError$2(err);
61379
+ const errorCode = GRAPHQL_QUERY_PARSE_ERROR;
61380
+ // Metric
61381
+ reportGraphqlAdapterError(errorCode);
61382
+ // Log
61383
+ ldsMobileInstrumentation$2.error(error, errorCode);
61344
61384
  }
61345
61385
  function reportGraphqlSqlEvalPreconditionError(err) {
61346
- normalizeError$2(err);
61386
+ const error = normalizeError$2(err);
61387
+ const errorCode = GRAPHQL_SQL_EVAL_PRECONDITION_ERROR;
61388
+ // Metric
61389
+ reportGraphqlAdapterError(errorCode);
61390
+ // Log
61391
+ ldsMobileInstrumentation$2.error(error, errorCode);
61347
61392
  }
61348
61393
  function reportGraphqlCreateSnapshotError(err) {
61349
- normalizeError$2(err);
61394
+ const error = normalizeError$2(err);
61395
+ const errorCode = GRAPHQL_CREATE_SNAPSHOT_ERROR;
61396
+ // Metric
61397
+ reportGraphqlAdapterError(errorCode);
61398
+ // Log
61399
+ ldsMobileInstrumentation$2.error(error, errorCode);
61350
61400
  }
61351
61401
  function reportGraphQlEvalDbReadDuration(duration) {
61402
+ ldsMobileInstrumentation$2.trackValue(GRAPHQL_EVAL_DB_READ_DURATION, duration);
61403
+ }
61404
+ function reportGraphqlAdapterError(errorCode) {
61405
+ // Increment overall count with errorCode as tag
61406
+ ldsMobileInstrumentation$2.incrementCounter(GRAPHQL_EVAL_ERROR, 1, true, { errorCode });
61352
61407
  }
61353
61408
  function reportGraphqlQueryInstrumentation(data) {
61354
61409
  const queryBuckets = [1, 2, 3, 4, 5, 10, 20, 50, 100];
61355
61410
  const recordBuckets = [
61356
61411
  1, 5, 10, 20, 50, 100, 1000, 2000, 5000, 10000, 50000, 100000, 1000000,
61357
61412
  ];
61358
- ldsMobileInstrumentation$1.bucketValue(GRAPHQL_EVAL_ROOT_QUERY_COUNT, data.rootQueryCount, queryBuckets);
61359
- ldsMobileInstrumentation$1.bucketValue(GRAPHQL_EVAL_TOTAL_QUERY_COUNT, data.totalQueryCount, queryBuckets);
61360
- ldsMobileInstrumentation$1.bucketValue(GRAPHQL_EVAL_MAX_CHILD_RELATIONSHIPS_COUNT, data.maxChildRelationships, queryBuckets);
61361
- ldsMobileInstrumentation$1.bucketValue(GRAPHQL_EVAL_QUERY_RECORD_COUNT, data.requestedRecordCount, recordBuckets);
61413
+ ldsMobileInstrumentation$2.bucketValue(GRAPHQL_EVAL_ROOT_QUERY_COUNT, data.rootQueryCount, queryBuckets);
61414
+ ldsMobileInstrumentation$2.bucketValue(GRAPHQL_EVAL_TOTAL_QUERY_COUNT, data.totalQueryCount, queryBuckets);
61415
+ ldsMobileInstrumentation$2.bucketValue(GRAPHQL_EVAL_MAX_CHILD_RELATIONSHIPS_COUNT, data.maxChildRelationships, queryBuckets);
61416
+ ldsMobileInstrumentation$2.bucketValue(GRAPHQL_EVAL_QUERY_RECORD_COUNT, data.requestedRecordCount, recordBuckets);
61417
+ }
61418
+ function incrementGraphQLRefreshUndfined() {
61419
+ ldsMobileInstrumentation$2.incrementCounter(GRAPHQL_SNAPSHOT_REFRESH_UNDEFINED);
61420
+ }
61421
+ function reportDraftActionEvent(state) {
61422
+ switch (state) {
61423
+ case 'added':
61424
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_ADDED);
61425
+ break;
61426
+ case 'uploading':
61427
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_UPLOADING);
61428
+ break;
61429
+ case 'completed':
61430
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_COMPLETED);
61431
+ break;
61432
+ case 'deleted':
61433
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_DELETED);
61434
+ break;
61435
+ case 'failed':
61436
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_FAILED, 1, true);
61437
+ break;
61438
+ case 'updated':
61439
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_UPDATED);
61440
+ break;
61441
+ }
61442
+ }
61443
+ function reportDraftQueueState(state) {
61444
+ switch (state) {
61445
+ case 'started':
61446
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_STATE_STARTED);
61447
+ break;
61448
+ case 'error':
61449
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_STATE_ERROR, 1, true);
61450
+ break;
61451
+ case 'waiting':
61452
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_STATE_WAITING);
61453
+ break;
61454
+ case 'stopped':
61455
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_STATE_STOPPED);
61456
+ break;
61457
+ }
61362
61458
  }
61363
61459
  function reportDraftAwareContentDocumentVersionSynthesizeError(err) {
61364
61460
  let error;
@@ -61368,16 +61464,43 @@
61368
61464
  else {
61369
61465
  error = normalizeError$2(err);
61370
61466
  }
61371
- error.errorType;
61467
+ const errorCode = DRAFT_AWARE_CREATE_CONTENT_DOCUMENT_AND_VERSION_ERROR;
61468
+ const errorType = error.errorType;
61469
+ const tags = {
61470
+ errorCode,
61471
+ };
61472
+ if (errorType !== undefined) {
61473
+ tags.errorType = errorType;
61474
+ }
61475
+ // Metric
61476
+ ldsMobileInstrumentation$2.incrementCounter(CREATE_CONTENT_DOCUMENT_AND_VERSION_DRAFT_SYNTHESIZE_ERROR, 1, true, tags);
61477
+ // Log
61478
+ ldsMobileInstrumentation$2.error(error, errorCode);
61372
61479
  }
61373
61480
  function reportDraftAwareContentVersionSynthesizeCalls(mimeType) {
61481
+ ldsMobileInstrumentation$2.incrementCounter(CREATE_CONTENT_DOCUMENT_AND_VERSION_TOTAL_SYNTHESIZE_CALLS, 1, undefined, { mimeType });
61482
+ }
61483
+ /** Priming */
61484
+ function reportPrimingSessionCreated() {
61485
+ ldsMobileInstrumentation$2.incrementCounter(PRIMING_TOTAL_SESSION_COUNT, 1, undefined, {});
61374
61486
  }
61375
61487
  function reportPrimingError(errorType, recordCount) {
61488
+ ldsMobileInstrumentation$2.incrementCounter(PRIMING_TOTAL_ERROR_COUNT, recordCount, undefined, {
61489
+ errorType,
61490
+ });
61491
+ }
61492
+ function reportPrimingSuccess(recordCount) {
61493
+ ldsMobileInstrumentation$2.incrementCounter(PRIMING_TOTAL_PRIMED_COUNT, recordCount, undefined);
61376
61494
  }
61377
61495
  function reportPrimingConflict(resolutionType, recordCount) {
61496
+ ldsMobileInstrumentation$2.incrementCounter(PRIMING_TOTAL_CONFLICT_COUNT, recordCount, undefined, {
61497
+ resolutionType,
61498
+ });
61378
61499
  }
61379
61500
  /** Network */
61380
61501
  function reportChunkCandidateUrlLength(urlLength) {
61502
+ const buckets = [8000, 10000, 12000, 14000, 16000];
61503
+ ldsMobileInstrumentation$2.bucketValue('chunk-candidate-url-length-histogram', urlLength, buckets);
61381
61504
  }
61382
61505
 
61383
61506
  /**
@@ -61391,13 +61514,19 @@
61391
61514
  return operation();
61392
61515
  }
61393
61516
  const { tags, metricName, logError } = config;
61517
+ let hasError = false;
61394
61518
  return operation()
61395
61519
  .catch((err) => {
61520
+ hasError = true;
61396
61521
  const error = normalizeError$2(err);
61397
61522
  tags['errorMessage'] = error.message;
61523
+ if (logError) {
61524
+ ldsMobileInstrumentation$2.error(error);
61525
+ }
61398
61526
  throw err;
61399
61527
  })
61400
61528
  .finally(() => {
61529
+ ldsMobileInstrumentation$2.incrementCounter(metricName, 1, hasError, tags);
61401
61530
  });
61402
61531
  };
61403
61532
 
@@ -61410,26 +61539,36 @@
61410
61539
  case DraftQueueEventType.QueueStateChanged:
61411
61540
  switch (draftQueueEvent.state) {
61412
61541
  case DraftQueueState.Error:
61542
+ reportDraftQueueState('error');
61413
61543
  break;
61414
61544
  case DraftQueueState.Started:
61545
+ reportDraftQueueState('started');
61415
61546
  break;
61416
61547
  case DraftQueueState.Stopped:
61548
+ reportDraftQueueState('stopped');
61417
61549
  break;
61418
61550
  case DraftQueueState.Waiting:
61551
+ reportDraftQueueState('waiting');
61419
61552
  break;
61420
61553
  }
61421
61554
  break;
61422
61555
  case DraftQueueEventType.ActionAdded:
61556
+ reportDraftActionEvent('added');
61423
61557
  break;
61424
61558
  case DraftQueueEventType.ActionUploading:
61559
+ reportDraftActionEvent('uploading');
61425
61560
  break;
61426
61561
  case DraftQueueEventType.ActionCompleted:
61562
+ reportDraftActionEvent('completed');
61427
61563
  break;
61428
61564
  case DraftQueueEventType.ActionDeleted:
61565
+ reportDraftActionEvent('deleted');
61429
61566
  break;
61430
61567
  case DraftQueueEventType.ActionFailed:
61568
+ reportDraftActionEvent('failed');
61431
61569
  break;
61432
61570
  case DraftQueueEventType.ActionUpdated:
61571
+ reportDraftActionEvent('updated');
61433
61572
  break;
61434
61573
  }
61435
61574
  return Promise.resolve();
@@ -61695,6 +61834,9 @@
61695
61834
  case 'graphql-query-instrumentation':
61696
61835
  reportGraphqlQueryInstrumentation(data.data);
61697
61836
  break;
61837
+ case 'graphql-luvio-refresh-undefined':
61838
+ incrementGraphQLRefreshUndfined();
61839
+ break;
61698
61840
  }
61699
61841
  }
61700
61842
  },
@@ -63254,10 +63396,12 @@
63254
63396
  }
63255
63397
 
63256
63398
  function instrumentPrimingSession(session) {
63399
+ reportPrimingSessionCreated();
63257
63400
  session.on('error', ({ code, ids }) => {
63258
63401
  reportPrimingError(code, ids.length);
63259
63402
  });
63260
63403
  session.on('primed', ({ length }) => {
63404
+ reportPrimingSuccess(length);
63261
63405
  });
63262
63406
  session.on('conflict', ({ ids, resolution }) => {
63263
63407
  reportPrimingConflict(resolution, ids.length);
@@ -63950,7 +64094,7 @@
63950
64094
  id: '@salesforce/lds-network-adapter',
63951
64095
  instrument: instrument$2,
63952
64096
  });
63953
- // version: 1.309.0-dev10-fb453615fe
64097
+ // version: 1.309.0-dev12-09ae94a55e
63954
64098
 
63955
64099
  const { create: create$3, keys: keys$3 } = Object;
63956
64100
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -83986,7 +84130,7 @@
83986
84130
  configuration: { ...configurationForGraphQLAdapters$1 },
83987
84131
  instrument: instrument$1,
83988
84132
  });
83989
- // version: 1.309.0-dev10-96422fc06f
84133
+ // version: 1.309.0-dev12-9b91cf52fb
83990
84134
 
83991
84135
  // On core the unstable adapters are re-exported with different names,
83992
84136
  // we want to match them here.
@@ -86242,7 +86386,7 @@
86242
86386
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
86243
86387
  graphQLImperative = ldsAdapter;
86244
86388
  });
86245
- // version: 1.309.0-dev10-96422fc06f
86389
+ // version: 1.309.0-dev12-9b91cf52fb
86246
86390
 
86247
86391
  var gqlApi = /*#__PURE__*/Object.freeze({
86248
86392
  __proto__: null,
@@ -86365,6 +86509,7 @@
86365
86509
  return new Error(stringify$1(error));
86366
86510
  }
86367
86511
 
86512
+ const ldsMobileInstrumentation$1 = getInstrumentation();
86368
86513
  /**
86369
86514
  * Coerces a cache policy passed in from native to a luvio cache policy
86370
86515
  * @param nativeCachePolicy The cache policy passed in from native
@@ -86646,9 +86791,14 @@
86646
86791
  draftIds.length > 0) {
86647
86792
  const draftId = draftIds[draftIds.length - 1];
86648
86793
  const managerState = await draftManager.getQueue();
86649
- const existingMetadata = (managerState.items.find((i) => i.id === draftId) || {}).metadata || {};
86794
+ const draftItem = managerState.items.find((x) => x.id === draftId);
86795
+ if (draftItem === undefined) {
86796
+ // draftItem no longer exists, might have already been uploaded
86797
+ ldsMobileInstrumentation$1.log('tried to set metadata on draft item that no longer exists');
86798
+ return onResponse(responseValue);
86799
+ }
86650
86800
  draftManager
86651
- .setMetadata(draftId, { ...existingMetadata, ...metadata })
86801
+ .setMetadata(draftId, { ...draftItem.metadata, ...metadata })
86652
86802
  .then(() => {
86653
86803
  onResponse(responseValue);
86654
86804
  })
@@ -86977,7 +87127,7 @@
86977
87127
  function register(r) {
86978
87128
  callbacks$1.forEach((callback) => callback(r));
86979
87129
  }
86980
- // version: 1.309.0-dev10-fb453615fe
87130
+ // version: 1.309.0-dev12-09ae94a55e
86981
87131
 
86982
87132
  /**
86983
87133
  * Returns true if the value acts like a Promise, i.e. has a "then" function,
@@ -91958,4 +92108,4 @@
91958
92108
  exports.subscribeToAdapter = subscribeToAdapter;
91959
92109
 
91960
92110
  }));
91961
- // version: 1.309.0-dev10-fb453615fe
92111
+ // version: 1.309.0-dev12-09ae94a55e
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-worker-api",
3
- "version": "1.309.0-dev10",
3
+ "version": "1.309.0-dev12",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "",
6
6
  "main": "dist/standalone/es/lds-worker-api.js",
@@ -35,15 +35,15 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@oat-sa/rollup-plugin-wildcard-external": "^1.0.0",
38
- "@salesforce/lds-adapters-graphql": "^1.309.0-dev10",
39
- "@salesforce/lds-adapters-uiapi": "^1.309.0-dev10",
40
- "@salesforce/lds-default-luvio": "^1.309.0-dev10",
41
- "@salesforce/lds-drafts": "^1.309.0-dev10",
42
- "@salesforce/lds-graphql-parser": "^1.309.0-dev10",
43
- "@salesforce/lds-luvio-engine": "^1.309.0-dev10",
44
- "@salesforce/lds-priming": "^1.309.0-dev10",
45
- "@salesforce/lds-runtime-mobile": "^1.309.0-dev10",
46
- "@salesforce/nimbus-plugin-lds": "^1.309.0-dev10",
38
+ "@salesforce/lds-adapters-graphql": "^1.309.0-dev12",
39
+ "@salesforce/lds-adapters-uiapi": "^1.309.0-dev12",
40
+ "@salesforce/lds-default-luvio": "^1.309.0-dev12",
41
+ "@salesforce/lds-drafts": "^1.309.0-dev12",
42
+ "@salesforce/lds-graphql-parser": "^1.309.0-dev12",
43
+ "@salesforce/lds-luvio-engine": "^1.309.0-dev12",
44
+ "@salesforce/lds-priming": "^1.309.0-dev12",
45
+ "@salesforce/lds-runtime-mobile": "^1.309.0-dev12",
46
+ "@salesforce/nimbus-plugin-lds": "^1.309.0-dev12",
47
47
  "ajv": "^8.11.0",
48
48
  "glob": "^7.1.5",
49
49
  "nimbus-types": "^2.0.0-alpha1",
@@ -56,7 +56,7 @@
56
56
  "path": "./dist/sfdc/es/ldsWorkerApi.js",
57
57
  "maxSize": {
58
58
  "none": "45 kB",
59
- "min": "17.8 kB",
59
+ "min": "19.0 kB",
60
60
  "compressed": "8 kB"
61
61
  }
62
62
  }