@salesforce/lds-worker-api 1.354.0-dev11 → 1.354.0-dev13

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.
@@ -4280,7 +4280,7 @@
4280
4280
  }
4281
4281
  callbacks.push(callback);
4282
4282
  }
4283
- // version: 1.354.0-dev11-5ded66ad52
4283
+ // version: 1.354.0-dev13-f27ca1a3a7
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) {
@@ -4918,7 +4918,7 @@
4918
4918
  }
4919
4919
 
4920
4920
  // For use by callers within this module to instrument interesting things.
4921
- let instrumentation$5 = {
4921
+ let instrumentation$6 = {
4922
4922
  refreshCalled: (_fromSource) => { },
4923
4923
  instrumentAdapter: (adapter, _metadata) => {
4924
4924
  return adapter;
@@ -4933,20 +4933,20 @@
4933
4933
  * @param newInstrumentation instrumentation hooks to be overridden
4934
4934
  */
4935
4935
  function instrument$4(newInstrumentation) {
4936
- instrumentation$5 = Object.assign(instrumentation$5, newInstrumentation);
4936
+ instrumentation$6 = Object.assign(instrumentation$6, newInstrumentation);
4937
4937
  }
4938
4938
 
4939
4939
  let refresh$3;
4940
4940
  function bindWireRefresh(luvio) {
4941
4941
  const wireRefresh = bindWireRefresh$1(luvio);
4942
4942
  refresh$3 = (data, apiFamily) => {
4943
- instrumentation$5.refreshCalled(apiFamily);
4943
+ instrumentation$6.refreshCalled(apiFamily);
4944
4944
  return wireRefresh(data);
4945
4945
  };
4946
4946
  }
4947
4947
 
4948
4948
  function createInstrumentedAdapter(adapter, metadata) {
4949
- return instrumentation$5.instrumentAdapter(adapter, metadata);
4949
+ return instrumentation$6.instrumentAdapter(adapter, metadata);
4950
4950
  }
4951
4951
 
4952
4952
  function createLDSAdapter(luvio, name, factory) {
@@ -5292,7 +5292,7 @@
5292
5292
  const { apiFamily, name } = metadata;
5293
5293
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
5294
5294
  }
5295
- // version: 1.354.0-dev11-5ded66ad52
5295
+ // version: 1.354.0-dev13-f27ca1a3a7
5296
5296
 
5297
5297
  /**
5298
5298
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -5904,7 +5904,7 @@
5904
5904
  }
5905
5905
 
5906
5906
  // For use by callers within this module to instrument interesting things.
5907
- let instrumentation$4 = {
5907
+ let instrumentation$5 = {
5908
5908
  /**
5909
5909
  * Called when a set of record conflicts has been fully resolved. The
5910
5910
  * parameter indicates the number of server requests that were needed
@@ -5953,7 +5953,7 @@
5953
5953
  * @param newInstrumentation instrumentation hooks to be overridden
5954
5954
  */
5955
5955
  function instrument$3(newInstrumentation) {
5956
- instrumentation$4 = Object.assign(instrumentation$4, newInstrumentation);
5956
+ instrumentation$5 = Object.assign(instrumentation$5, newInstrumentation);
5957
5957
  }
5958
5958
 
5959
5959
  const engineForPrefetcherMap = new Map();
@@ -9811,7 +9811,7 @@
9811
9811
  incoming.recordTypeId === undefined ||
9812
9812
  existing.recordTypeId === null ||
9813
9813
  existing.recordTypeId === undefined) {
9814
- instrumentation$4.recordTypeIdIsNull(incoming.apiName);
9814
+ instrumentation$5.recordTypeIdIsNull(incoming.apiName);
9815
9815
  }
9816
9816
  const recordDepKey = dependencyKeyBuilder$1({ recordId: existing.id });
9817
9817
  const node = luvio.getNode(recordDepKey);
@@ -9836,12 +9836,12 @@
9836
9836
  // }
9837
9837
  // Adding instrumentation to see how frequently this occurs
9838
9838
  if (existing.apiName !== incoming.apiName) {
9839
- instrumentation$4.recordApiNameChanged(incoming.apiName, existing.apiName);
9839
+ instrumentation$5.recordApiNameChanged(incoming.apiName, existing.apiName);
9840
9840
  }
9841
9841
  const incomingWeakEtagZero = incoming.weakEtag === 0;
9842
9842
  const existingWeakEtagZero = existing.weakEtag === 0;
9843
9843
  if (incomingWeakEtagZero || existingWeakEtagZero) {
9844
- instrumentation$4.weakEtagZero(incomingWeakEtagZero, existingWeakEtagZero, incoming.apiName);
9844
+ instrumentation$5.weakEtagZero(incomingWeakEtagZero, existingWeakEtagZero, incoming.apiName);
9845
9845
  }
9846
9846
  // TODO [W-6900085]: UIAPI returns weakEtag=0 when the record is >2 levels nested. For now
9847
9847
  // we treat the record as mergeable.
@@ -9901,7 +9901,7 @@
9901
9901
  incomingValue !== null) {
9902
9902
  incoming.displayValue = existing.displayValue;
9903
9903
  const isSpanningRecord = typeof incomingValue === 'object';
9904
- instrumentation$4.nullDisplayValueConflict({
9904
+ instrumentation$5.nullDisplayValueConflict({
9905
9905
  entityName: path.parent.data.apiName,
9906
9906
  fieldName: path.propertyName,
9907
9907
  fieldType: isSpanningRecord ? 'spanning-record' : 'scalar',
@@ -10691,7 +10691,7 @@
10691
10691
  function resolveConflict$1(luvio, map) {
10692
10692
  const ids = keys$7(map.conflicts);
10693
10693
  if (ids.length === 0) {
10694
- instrumentation$4.recordConflictsResolved(map.serverRequestCount);
10694
+ instrumentation$5.recordConflictsResolved(map.serverRequestCount);
10695
10695
  return;
10696
10696
  }
10697
10697
  if (ids.length === 1) {
@@ -15524,7 +15524,7 @@
15524
15524
  serverRequestCount: 1,
15525
15525
  }), body);
15526
15526
  const result = luvio.storeBroadcast();
15527
- instrumentation$4.getRecordNotifyChangeNetworkResult(existingWeakEtag !== body.weakEtag);
15527
+ instrumentation$5.getRecordNotifyChangeNetworkResult(existingWeakEtag !== body.weakEtag);
15528
15528
  return result;
15529
15529
  }, () => {
15530
15530
  const cache = new StoreKeyMap();
@@ -15536,7 +15536,7 @@
15536
15536
  const errorSnapshot = luvio.errorSnapshot(error);
15537
15537
  luvio.storeIngestError(key, errorSnapshot, RECORD_REPRESENTATION_ERROR_STORE_METADATA_PARAMS$1);
15538
15538
  const result = luvio.storeBroadcast();
15539
- instrumentation$4.getRecordNotifyChangeNetworkResult(null, true);
15539
+ instrumentation$5.getRecordNotifyChangeNetworkResult(null, true);
15540
15540
  return result.then(() => errorSnapshot);
15541
15541
  });
15542
15542
  });
@@ -34049,12 +34049,12 @@
34049
34049
  baseUpdateRelatedListInfo = createLDSAdapter(luvio, 'baseUpdateRelatedListInfo', updateRelatedListInfoAdapterFactory);
34050
34050
  createLDSAdapter(luvio, 'baseUpdateRelatedListPreferences', updateRelatedListPreferencesAdapterFactory);
34051
34051
  throttle(60, 60000, createLDSAdapter(luvio, 'getRecordNotifyChange', notifyChangeFactory), {
34052
- allowFunction: instrumentation$4.getRecordNotifyChangeAllowed,
34053
- dropFunction: instrumentation$4.getRecordNotifyChangeDropped,
34052
+ allowFunction: instrumentation$5.getRecordNotifyChangeAllowed,
34053
+ dropFunction: instrumentation$5.getRecordNotifyChangeDropped,
34054
34054
  });
34055
34055
  throttle(60, 60000, createLDSAdapter(luvio, 'notifyRecordUpdateAvailable', notifyUpdateAvailableFactory$5), {
34056
- allowFunction: instrumentation$4.notifyRecordUpdateAvailableAllowed,
34057
- dropFunction: instrumentation$4.notifyRecordUpdateAvailableDropped,
34056
+ allowFunction: instrumentation$5.notifyRecordUpdateAvailableAllowed,
34057
+ dropFunction: instrumentation$5.notifyRecordUpdateAvailableDropped,
34058
34058
  });
34059
34059
  throttle(60, 60000, createLDSAdapter(luvio, 'notifyListViewSummaryUpdateAvailable', notifyUpdateAvailableFactory$2));
34060
34060
  throttle(60, 60000, createLDSAdapter(luvio, 'notifyListInfoSummaryUpdateAvailable', notifyUpdateAvailableFactory$3));
@@ -34068,7 +34068,50 @@
34068
34068
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
34069
34069
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
34070
34070
  });
34071
- // version: 1.354.0-dev11-634f7f7752
34071
+ // version: 1.354.0-dev13-272d3dd416
34072
+
34073
+ function requestIdleDetectedCallback(_callback) { }
34074
+ function declareNotifierTaskSingle(_name) {
34075
+ return {
34076
+ isBusy: false,
34077
+ done: function () { },
34078
+ };
34079
+ }
34080
+ function declareNotifierTaskMulti(_name, _existingBusyCount) {
34081
+ return {
34082
+ isBusy: false,
34083
+ add: function () { },
34084
+ done: function () { },
34085
+ };
34086
+ }
34087
+ function declarePollableTaskMulti(_name, _isBusyChecker) { }
34088
+ const idleDetector = {
34089
+ requestIdleDetectedCallback,
34090
+ declareNotifierTaskSingle,
34091
+ declareNotifierTaskMulti,
34092
+ declarePollableTaskMulti,
34093
+ };
34094
+ function stop(_userSchemaOrText, _userData) { }
34095
+ function error(_error, _userSchemaOrText, _userData) { }
34096
+ const activity = {
34097
+ stop,
34098
+ error,
34099
+ };
34100
+ function startActivity(_name) {
34101
+ return activity;
34102
+ }
34103
+ function log(_schema, _data) { }
34104
+ const mockInstrumentation = {
34105
+ log,
34106
+ startActivity,
34107
+ error: () => { },
34108
+ trackValue: (_operation, _value, _hasError, _tags) => { },
34109
+ incrementCounter: (_operation, _increment, _hasError, _tags) => { },
34110
+ bucketValue: (_operation, _value, _buckets) => { },
34111
+ };
34112
+ const getInstrumentation = () => {
34113
+ return mockInstrumentation;
34114
+ };
34072
34115
 
34073
34116
  /**
34074
34117
  * Returns true if the value acts like a Promise, i.e. has a "then" function,
@@ -45532,49 +45575,6 @@
45532
45575
 
45533
45576
  var caseSensitiveUserId = '005B0000000GR4OIAW';
45534
45577
 
45535
- function requestIdleDetectedCallback(_callback) { }
45536
- function declareNotifierTaskSingle(_name) {
45537
- return {
45538
- isBusy: false,
45539
- done: function () { },
45540
- };
45541
- }
45542
- function declareNotifierTaskMulti(_name, _existingBusyCount) {
45543
- return {
45544
- isBusy: false,
45545
- add: function () { },
45546
- done: function () { },
45547
- };
45548
- }
45549
- function declarePollableTaskMulti(_name, _isBusyChecker) { }
45550
- const idleDetector = {
45551
- requestIdleDetectedCallback,
45552
- declareNotifierTaskSingle,
45553
- declareNotifierTaskMulti,
45554
- declarePollableTaskMulti,
45555
- };
45556
- function stop(_userSchemaOrText, _userData) { }
45557
- function error(_error, _userSchemaOrText, _userData) { }
45558
- const activity = {
45559
- stop,
45560
- error,
45561
- };
45562
- function startActivity(_name) {
45563
- return activity;
45564
- }
45565
- function log(_schema, _data) { }
45566
- const mockInstrumentation = {
45567
- log,
45568
- startActivity,
45569
- error: () => { },
45570
- trackValue: (_operation, _value, _hasError, _tags) => { },
45571
- incrementCounter: (_operation, _increment, _hasError, _tags) => { },
45572
- bucketValue: (_operation, _value, _buckets) => { },
45573
- };
45574
- const getInstrumentation = () => {
45575
- return mockInstrumentation;
45576
- };
45577
-
45578
45578
  var ldsAdapterO11yLoggingGate = {
45579
45579
  isOpen: function (e) {
45580
45580
  return e.fallback;
@@ -45690,7 +45690,7 @@
45690
45690
 
45691
45691
  const UI_API_BASE_URI = '/services/data/v64.0/ui-api';
45692
45692
 
45693
- let instrumentation$2 = {
45693
+ let instrumentation$3 = {
45694
45694
  aggregateUiChunkCount: (_cb) => { },
45695
45695
  aggregateUiConnectError: () => { },
45696
45696
  duplicateRequest: (_cb) => { },
@@ -45702,7 +45702,7 @@
45702
45702
  networkRateLimitExceeded: () => { },
45703
45703
  };
45704
45704
  function instrument$2(newInstrumentation) {
45705
- instrumentation$2 = Object.assign(instrumentation$2, newInstrumentation);
45705
+ instrumentation$3 = Object.assign(instrumentation$3, newInstrumentation);
45706
45706
  }
45707
45707
 
45708
45708
  const LDS_RECORDS_AGGREGATE_UI = 'LDS_Records_AggregateUi';
@@ -45772,7 +45772,7 @@
45772
45772
  * would otherwise cause a query length exception.
45773
45773
  */
45774
45774
  function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resourceRequest, resourceRequestContext) {
45775
- instrumentation$2.getRecordAggregateInvoke();
45775
+ instrumentation$3.getRecordAggregateInvoke();
45776
45776
  return networkAdapter(resourceRequest, resourceRequestContext).then((resp) => {
45777
45777
  const { body } = resp;
45778
45778
  // This response body could be an executeAggregateUi, which we don't natively support.
@@ -45788,7 +45788,7 @@
45788
45788
  }
45789
45789
  const merged = body.compositeResponse.reduce((seed, response) => {
45790
45790
  if (response.httpStatusCode !== HttpStatusCode$1.Ok) {
45791
- instrumentation$2.getRecordAggregateReject(() => recordId);
45791
+ instrumentation$3.getRecordAggregateReject(() => recordId);
45792
45792
  throw createErrorResponse(HttpStatusCode$1.ServerError, {
45793
45793
  error: response.message,
45794
45794
  });
@@ -45798,7 +45798,7 @@
45798
45798
  }
45799
45799
  return mergeRecordFields$2(seed, response.body);
45800
45800
  }, null);
45801
- instrumentation$2.getRecordAggregateResolve(() => {
45801
+ instrumentation$3.getRecordAggregateResolve(() => {
45802
45802
  return {
45803
45803
  recordId,
45804
45804
  apiName: merged.apiName,
@@ -45806,7 +45806,7 @@
45806
45806
  });
45807
45807
  return createOkResponse$1(merged);
45808
45808
  }, (err) => {
45809
- instrumentation$2.getRecordAggregateReject(() => recordId);
45809
+ instrumentation$3.getRecordAggregateReject(() => recordId);
45810
45810
  // rethrow error
45811
45811
  throw err;
45812
45812
  });
@@ -45884,7 +45884,7 @@
45884
45884
  const { networkAdapter, resourceRequest, resourceRequestContext } = req;
45885
45885
  const compositeRequest = buildGetRecordByFieldsCompositeRequest(resourceRequest, params);
45886
45886
  // W-12245125: Emit chunk size metrics
45887
- instrumentation$2.aggregateUiChunkCount(() => compositeRequest.length);
45887
+ instrumentation$3.aggregateUiChunkCount(() => compositeRequest.length);
45888
45888
  const aggregateUiParams = {
45889
45889
  compositeRequest,
45890
45890
  };
@@ -46118,7 +46118,7 @@
46118
46118
  return (resourceRequest, resourceRequestContext) => {
46119
46119
  if (!tokenBucket.take(1)) {
46120
46120
  // We are hitting rate limiting, add some metrics
46121
- instrumentation$2.networkRateLimitExceeded();
46121
+ instrumentation$3.networkRateLimitExceeded();
46122
46122
  }
46123
46123
  const salesforceRequest = {
46124
46124
  networkAdapter: baseNetworkAdapter,
@@ -80332,6 +80332,209 @@
80332
80332
  }
80333
80333
  }
80334
80334
 
80335
+ function attachObserversToAdapterRequestContext(observers, adapterRequestContext) {
80336
+ if (adapterRequestContext === undefined) {
80337
+ return { eventObservers: observers };
80338
+ }
80339
+ if (adapterRequestContext.eventObservers === undefined) {
80340
+ return { ...adapterRequestContext, eventObservers: observers };
80341
+ }
80342
+ return {
80343
+ ...adapterRequestContext,
80344
+ eventObservers: adapterRequestContext.eventObservers.concat(observers),
80345
+ };
80346
+ }
80347
+ /**
80348
+ * Use this method to sanitize the unknown error object when
80349
+ * we are unsure of the type of the error thrown
80350
+ *
80351
+ * @param err Unknown object to sanitize
80352
+ * @returns an instance of error
80353
+ */
80354
+ function normalizeError$1(err) {
80355
+ if (err instanceof Error) {
80356
+ return err;
80357
+ }
80358
+ else if (typeof err === 'string') {
80359
+ return new Error(err);
80360
+ }
80361
+ return new Error(stringify$2(err));
80362
+ }
80363
+ // metrics
80364
+ /** GraphQL */
80365
+ const GRAPHQL_EVAL_ERROR = 'gql-eval-error';
80366
+ const GRAPHQL_EVAL_DB_READ_DURATION = 'gql-eval-db-read-duration';
80367
+ const GRAPHQL_EVAL_ROOT_QUERY_COUNT = 'gql-eval-root-query-count';
80368
+ const GRAPHQL_EVAL_TOTAL_QUERY_COUNT = 'gql-eval-total-query-count';
80369
+ const GRAPHQL_EVAL_MAX_CHILD_RELATIONSHIPS_COUNT = 'gql-eval-max-child-count';
80370
+ const GRAPHQL_EVAL_QUERY_RECORD_COUNT = 'gql-eval-query-record-count';
80371
+ const GRAPHQL_SNAPSHOT_REFRESH_UNDEFINED = 'gql-snapshot-refresh-undefined';
80372
+ /** Draft Queue */
80373
+ const DRAFT_QUEUE_STATE_STARTED = 'draft-queue-state-started';
80374
+ const DRAFT_QUEUE_STATE_ERROR = 'draft-queue-state-error';
80375
+ const DRAFT_QUEUE_STATE_WAITING = 'draft-queue-state-waiting';
80376
+ const DRAFT_QUEUE_STATE_STOPPED = 'draft-queue-state-stopped';
80377
+ const DRAFT_QUEUE_ACTION_ADDED = 'draft-queue-action-added';
80378
+ const DRAFT_QUEUE_ACTION_UPLOADING = 'draft-queue-action-uploading';
80379
+ const DRAFT_QUEUE_ACTION_COMPLETED = 'draft-queue-action-completed';
80380
+ const DRAFT_QUEUE_ACTION_DELETED = 'draft-queue-action-deleted';
80381
+ const DRAFT_QUEUE_ACTION_UPDATED = 'draft-queue-action-updated';
80382
+ const DRAFT_QUEUE_ACTION_FAILED = 'draft-queue-action-failed';
80383
+ const DRAFT_QUEUE_TOTAL_MERGE_ACTIONS_CALLS = 'draft-queue-total-mergeActions-calls';
80384
+ /** Content Document */
80385
+ const CREATE_CONTENT_DOCUMENT_AND_VERSION_TOTAL_SYNTHESIZE_CALLS = 'content-document-version-total-synthesize-calls';
80386
+ const CREATE_CONTENT_DOCUMENT_AND_VERSION_DRAFT_SYNTHESIZE_ERROR = 'create-content-document-version-draft-synthesize-error';
80387
+ /** Priming */
80388
+ const PRIMING_TOTAL_SESSION_COUNT = 'priming-total-session-count';
80389
+ const PRIMING_TOTAL_ERROR_COUNT = 'priming-total-error-count';
80390
+ const PRIMING_TOTAL_PRIMED_COUNT = 'priming-total-primed-count';
80391
+ const PRIMING_TOTAL_CONFLICT_COUNT = 'priming-total-conflict-count';
80392
+ // logs
80393
+ const GRAPHQL_QUERY_PARSE_ERROR = 'gql-query-parse-error';
80394
+ const GRAPHQL_SQL_EVAL_PRECONDITION_ERROR = 'gql-sql-pre-eval-error';
80395
+ const GRAPHQL_CREATE_SNAPSHOT_ERROR = 'gql-create-snapshot-error';
80396
+ const DRAFT_AWARE_CREATE_CONTENT_DOCUMENT_AND_VERSION_ERROR = 'draft-aware-create-content-document-and-version-error';
80397
+ const ldsMobileInstrumentation$2 = getInstrumentation();
80398
+ const nimbusLogger = typeof __nimbus !== 'undefined' &&
80399
+ __nimbus.plugins !== undefined &&
80400
+ __nimbus.plugins.JSLoggerPlugin !== undefined
80401
+ ? __nimbus.plugins.JSLoggerPlugin
80402
+ : undefined;
80403
+ function reportGraphqlQueryParseError(err) {
80404
+ const error = normalizeError$1(err);
80405
+ const errorCode = GRAPHQL_QUERY_PARSE_ERROR;
80406
+ // Metric
80407
+ reportGraphqlAdapterError(errorCode);
80408
+ // Log
80409
+ ldsMobileInstrumentation$2.error(error, errorCode);
80410
+ }
80411
+ function reportGraphqlSqlEvalPreconditionError(err) {
80412
+ const error = normalizeError$1(err);
80413
+ const errorCode = GRAPHQL_SQL_EVAL_PRECONDITION_ERROR;
80414
+ // Metric
80415
+ reportGraphqlAdapterError(errorCode);
80416
+ // Log
80417
+ ldsMobileInstrumentation$2.error(error, errorCode);
80418
+ }
80419
+ function reportGraphqlCreateSnapshotError(err) {
80420
+ const error = normalizeError$1(err);
80421
+ const errorCode = GRAPHQL_CREATE_SNAPSHOT_ERROR;
80422
+ // Metric
80423
+ reportGraphqlAdapterError(errorCode);
80424
+ // Log
80425
+ ldsMobileInstrumentation$2.error(error, errorCode);
80426
+ }
80427
+ function reportGraphQlEvalDbReadDuration(duration) {
80428
+ ldsMobileInstrumentation$2.trackValue(GRAPHQL_EVAL_DB_READ_DURATION, duration);
80429
+ }
80430
+ function reportGraphqlAdapterError(errorCode) {
80431
+ // Increment overall count with errorCode as tag
80432
+ ldsMobileInstrumentation$2.incrementCounter(GRAPHQL_EVAL_ERROR, 1, true, { errorCode });
80433
+ }
80434
+ function reportGraphqlQueryInstrumentation(data) {
80435
+ const queryBuckets = [1, 2, 3, 4, 5, 10, 20, 50, 100];
80436
+ const recordBuckets = [
80437
+ 1, 5, 10, 20, 50, 100, 1000, 2000, 5000, 10000, 50000, 100000, 1000000,
80438
+ ];
80439
+ ldsMobileInstrumentation$2.bucketValue(GRAPHQL_EVAL_ROOT_QUERY_COUNT, data.rootQueryCount, queryBuckets);
80440
+ ldsMobileInstrumentation$2.bucketValue(GRAPHQL_EVAL_TOTAL_QUERY_COUNT, data.totalQueryCount, queryBuckets);
80441
+ ldsMobileInstrumentation$2.bucketValue(GRAPHQL_EVAL_MAX_CHILD_RELATIONSHIPS_COUNT, data.maxChildRelationships, queryBuckets);
80442
+ ldsMobileInstrumentation$2.bucketValue(GRAPHQL_EVAL_QUERY_RECORD_COUNT, data.requestedRecordCount, recordBuckets);
80443
+ }
80444
+ function incrementGraphQLRefreshUndfined() {
80445
+ ldsMobileInstrumentation$2.incrementCounter(GRAPHQL_SNAPSHOT_REFRESH_UNDEFINED);
80446
+ }
80447
+ function reportDraftActionEvent(state, draftCount, message) {
80448
+ if (nimbusLogger) {
80449
+ nimbusLogger.logInfo(`Draft action event: ${state}, depth: ${draftCount}${message ? `, message: ${message}` : ''}`);
80450
+ }
80451
+ switch (state) {
80452
+ case 'added':
80453
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_ADDED);
80454
+ break;
80455
+ case 'uploading':
80456
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_UPLOADING);
80457
+ break;
80458
+ case 'completed':
80459
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_COMPLETED);
80460
+ break;
80461
+ case 'deleted':
80462
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_DELETED);
80463
+ break;
80464
+ case 'failed':
80465
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_FAILED, 1, true);
80466
+ break;
80467
+ case 'updated':
80468
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_ACTION_UPDATED);
80469
+ break;
80470
+ }
80471
+ }
80472
+ function reportDraftQueueState(state, draftCount) {
80473
+ if (nimbusLogger) {
80474
+ nimbusLogger.logInfo(`Draft state changed: ${state}, depth: ${draftCount}`);
80475
+ }
80476
+ switch (state) {
80477
+ case 'started':
80478
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_STATE_STARTED);
80479
+ break;
80480
+ case 'error':
80481
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_STATE_ERROR, 1, true);
80482
+ break;
80483
+ case 'waiting':
80484
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_STATE_WAITING);
80485
+ break;
80486
+ case 'stopped':
80487
+ ldsMobileInstrumentation$2.incrementCounter(DRAFT_QUEUE_STATE_STOPPED);
80488
+ break;
80489
+ }
80490
+ }
80491
+ function reportDraftAwareContentDocumentVersionSynthesizeError(err) {
80492
+ let error;
80493
+ if (err.body !== undefined) {
80494
+ error = err.body;
80495
+ }
80496
+ else {
80497
+ error = normalizeError$1(err);
80498
+ }
80499
+ const errorCode = DRAFT_AWARE_CREATE_CONTENT_DOCUMENT_AND_VERSION_ERROR;
80500
+ const errorType = error.errorType;
80501
+ const tags = {
80502
+ errorCode,
80503
+ };
80504
+ if (errorType !== undefined) {
80505
+ tags.errorType = errorType;
80506
+ }
80507
+ // Metric
80508
+ ldsMobileInstrumentation$2.incrementCounter(CREATE_CONTENT_DOCUMENT_AND_VERSION_DRAFT_SYNTHESIZE_ERROR, 1, true, tags);
80509
+ // Log
80510
+ ldsMobileInstrumentation$2.error(error, errorCode);
80511
+ }
80512
+ function reportDraftAwareContentVersionSynthesizeCalls(mimeType) {
80513
+ ldsMobileInstrumentation$2.incrementCounter(CREATE_CONTENT_DOCUMENT_AND_VERSION_TOTAL_SYNTHESIZE_CALLS, 1, undefined, { mimeType });
80514
+ }
80515
+ /** Priming */
80516
+ function reportPrimingSessionCreated() {
80517
+ ldsMobileInstrumentation$2.incrementCounter(PRIMING_TOTAL_SESSION_COUNT, 1, undefined, {});
80518
+ }
80519
+ function reportPrimingError(errorType, recordCount) {
80520
+ ldsMobileInstrumentation$2.incrementCounter(PRIMING_TOTAL_ERROR_COUNT, recordCount, undefined, {
80521
+ errorType,
80522
+ });
80523
+ }
80524
+ function reportPrimingSuccess(recordCount) {
80525
+ ldsMobileInstrumentation$2.incrementCounter(PRIMING_TOTAL_PRIMED_COUNT, recordCount, undefined);
80526
+ }
80527
+ function reportPrimingConflict(resolutionType, recordCount) {
80528
+ ldsMobileInstrumentation$2.incrementCounter(PRIMING_TOTAL_CONFLICT_COUNT, recordCount, undefined, {
80529
+ resolutionType,
80530
+ });
80531
+ }
80532
+ /** Network */
80533
+ function reportChunkCandidateUrlLength(urlLength) {
80534
+ const buckets = [8000, 10000, 12000, 14000, 16000];
80535
+ ldsMobileInstrumentation$2.bucketValue('chunk-candidate-url-length-histogram', urlLength, buckets);
80536
+ }
80537
+
80335
80538
  const QUICK_ACTION_HANDLER = 'QUICK_ACTION_HANDLER';
80336
80539
  class QuickActionExecutionRepresentationHandler extends AbstractResourceRequestActionHandler {
80337
80540
  constructor(getLuvio, draftRecordService, draftQueue, networkAdapter, isDraftId, sideEffectService, objectInfoService, getRecord) {
@@ -80342,6 +80545,7 @@
80342
80545
  this.objectInfoService = objectInfoService;
80343
80546
  this.getRecord = getRecord;
80344
80547
  this.handlerId = QUICK_ACTION_HANDLER;
80548
+ this.instrumentation = getInstrumentation();
80345
80549
  draftRecordService.registerRecordHandler(this);
80346
80550
  }
80347
80551
  async draftActionToSideEffects(queueEntry) {
@@ -80373,10 +80577,26 @@
80373
80577
  luvio.storeIngest(key, ingest$B$2, response);
80374
80578
  }
80375
80579
  async handleActionCompleted(action, queueOperations) {
80580
+ /* performQuickAction will not return the new record itself, so before the action
80581
+ * is marked as completed, we need to fetch the actual record. This must be done before
80582
+ * the super method is called because the super method will revert the side effects that
80583
+ * were created for this action, and critically that means evicting the synthetic record
80584
+ * that was created to represent the draft of what would become the canonical record.
80585
+ * Since getRecord is a network call, it is better to have a small timeframe (on the order
80586
+ * of microseconds) where both the synthetic record and the canonical record are in the
80587
+ * store instead of the record missing from the store for the entire duration of the
80588
+ * network call.
80589
+ */
80590
+ try {
80591
+ await this.fetchRecordIntoStoreFromCompletedAction(action);
80592
+ }
80593
+ catch (error) {
80594
+ this.instrumentation.error(error, 'Error fetching the record created from performQuickAction adapter.');
80595
+ }
80376
80596
  await super.handleActionCompleted(action, queueOperations);
80377
- this.getLuvio();
80597
+ }
80598
+ async fetchRecordIntoStoreFromCompletedAction(action) {
80378
80599
  const canonicalId = action.response.body.id;
80379
- this.buildTagForTargetId(canonicalId);
80380
80600
  const prefix = canonicalId.substring(0, 3);
80381
80601
  if (prefix.length !== 3) {
80382
80602
  // if we can't get a prefix, don't do the rest
@@ -88776,96 +88996,6 @@
88776
88996
  }
88777
88997
  }
88778
88998
 
88779
- function attachObserversToAdapterRequestContext(observers, adapterRequestContext) {
88780
- if (adapterRequestContext === undefined) {
88781
- return { eventObservers: observers };
88782
- }
88783
- if (adapterRequestContext.eventObservers === undefined) {
88784
- return { ...adapterRequestContext, eventObservers: observers };
88785
- }
88786
- return {
88787
- ...adapterRequestContext,
88788
- eventObservers: adapterRequestContext.eventObservers.concat(observers),
88789
- };
88790
- }
88791
- /**
88792
- * Use this method to sanitize the unknown error object when
88793
- * we are unsure of the type of the error thrown
88794
- *
88795
- * @param err Unknown object to sanitize
88796
- * @returns an instance of error
88797
- */
88798
- function normalizeError$1(err) {
88799
- if (err instanceof Error) {
88800
- return err;
88801
- }
88802
- else if (typeof err === 'string') {
88803
- return new Error(err);
88804
- }
88805
- return new Error(stringify$2(err));
88806
- }
88807
- const GRAPHQL_EVAL_ROOT_QUERY_COUNT = 'gql-eval-root-query-count';
88808
- const GRAPHQL_EVAL_TOTAL_QUERY_COUNT = 'gql-eval-total-query-count';
88809
- const GRAPHQL_EVAL_MAX_CHILD_RELATIONSHIPS_COUNT = 'gql-eval-max-child-count';
88810
- const GRAPHQL_EVAL_QUERY_RECORD_COUNT = 'gql-eval-query-record-count';
88811
- const DRAFT_QUEUE_TOTAL_MERGE_ACTIONS_CALLS = 'draft-queue-total-mergeActions-calls';
88812
- const ldsMobileInstrumentation$2 = getInstrumentation();
88813
- const nimbusLogger = typeof __nimbus !== 'undefined' &&
88814
- __nimbus.plugins !== undefined &&
88815
- __nimbus.plugins.JSLoggerPlugin !== undefined
88816
- ? __nimbus.plugins.JSLoggerPlugin
88817
- : undefined;
88818
- function reportGraphqlQueryParseError(err) {
88819
- normalizeError$1(err);
88820
- }
88821
- function reportGraphqlSqlEvalPreconditionError(err) {
88822
- normalizeError$1(err);
88823
- }
88824
- function reportGraphqlCreateSnapshotError(err) {
88825
- normalizeError$1(err);
88826
- }
88827
- function reportGraphQlEvalDbReadDuration(duration) {
88828
- }
88829
- function reportGraphqlQueryInstrumentation(data) {
88830
- const queryBuckets = [1, 2, 3, 4, 5, 10, 20, 50, 100];
88831
- const recordBuckets = [
88832
- 1, 5, 10, 20, 50, 100, 1000, 2000, 5000, 10000, 50000, 100000, 1000000,
88833
- ];
88834
- ldsMobileInstrumentation$2.bucketValue(GRAPHQL_EVAL_ROOT_QUERY_COUNT, data.rootQueryCount, queryBuckets);
88835
- ldsMobileInstrumentation$2.bucketValue(GRAPHQL_EVAL_TOTAL_QUERY_COUNT, data.totalQueryCount, queryBuckets);
88836
- ldsMobileInstrumentation$2.bucketValue(GRAPHQL_EVAL_MAX_CHILD_RELATIONSHIPS_COUNT, data.maxChildRelationships, queryBuckets);
88837
- ldsMobileInstrumentation$2.bucketValue(GRAPHQL_EVAL_QUERY_RECORD_COUNT, data.requestedRecordCount, recordBuckets);
88838
- }
88839
- function reportDraftActionEvent(state, draftCount, message) {
88840
- if (nimbusLogger) {
88841
- nimbusLogger.logInfo(`Draft action event: ${state}, depth: ${draftCount}${message ? `, message: ${message}` : ''}`);
88842
- }
88843
- }
88844
- function reportDraftQueueState(state, draftCount) {
88845
- if (nimbusLogger) {
88846
- nimbusLogger.logInfo(`Draft state changed: ${state}, depth: ${draftCount}`);
88847
- }
88848
- }
88849
- function reportDraftAwareContentDocumentVersionSynthesizeError(err) {
88850
- let error;
88851
- if (err.body !== undefined) {
88852
- error = err.body;
88853
- }
88854
- else {
88855
- error = normalizeError$1(err);
88856
- }
88857
- error.errorType;
88858
- }
88859
- function reportDraftAwareContentVersionSynthesizeCalls(mimeType) {
88860
- }
88861
- function reportPrimingError(errorType, recordCount) {
88862
- }
88863
- function reportPrimingConflict(resolutionType, recordCount) {
88864
- }
88865
- /** Network */
88866
- function reportChunkCandidateUrlLength(urlLength) {
88867
- }
88868
-
88869
88999
  /**
88870
89000
  * HOF (high-order-function) that instruments any async operation. If the operation
88871
89001
  * has an error then the hasError param will be set on the call to o11y.incrementCounter
@@ -88877,13 +89007,19 @@
88877
89007
  return operation();
88878
89008
  }
88879
89009
  const { tags, metricName, logError } = config;
89010
+ let hasError = false;
88880
89011
  return operation()
88881
89012
  .catch((err) => {
89013
+ hasError = true;
88882
89014
  const error = normalizeError$1(err);
88883
89015
  tags['errorMessage'] = error.message;
89016
+ if (logError) {
89017
+ ldsMobileInstrumentation$2.error(error);
89018
+ }
88884
89019
  throw err;
88885
89020
  })
88886
89021
  .finally(() => {
89022
+ ldsMobileInstrumentation$2.incrementCounter(metricName, 1, hasError, tags);
88887
89023
  });
88888
89024
  };
88889
89025
 
@@ -89223,6 +89359,9 @@
89223
89359
  case 'graphql-query-instrumentation':
89224
89360
  reportGraphqlQueryInstrumentation(data.data);
89225
89361
  break;
89362
+ case 'graphql-luvio-refresh-undefined':
89363
+ incrementGraphQLRefreshUndfined();
89364
+ break;
89226
89365
  }
89227
89366
  }
89228
89367
  },
@@ -89535,6 +89674,9 @@
89535
89674
  }
89536
89675
 
89537
89676
  const tasker = idleDetector.declareNotifierTaskMulti('NimbusSqliteStore');
89677
+ const instrumentation$2 = getInstrumentation();
89678
+ const GRAPHQL_QUERY_ROOT_KEY = 'UiApi::uiapi::Query[uiapi]__uiapi__query';
89679
+ const GRAPHQL_QUERY_ROOT_METRIC_NAME = 'gql-query-root-object-size';
89538
89680
  class NimbusSqliteStore {
89539
89681
  constructor(plugin, additionalTableMap = {}) {
89540
89682
  this.plugin = plugin;
@@ -89581,6 +89723,9 @@
89581
89723
  }
89582
89724
  const table = this.getTable(segment);
89583
89725
  const upsertOperation = table.entriesToUpsertOperations(entries, segment);
89726
+ if (entries[GRAPHQL_QUERY_ROOT_KEY]) {
89727
+ this.trackGraphQLQueryRootSize(upsertOperation);
89728
+ }
89584
89729
  return this.batchOperationAsPromise([upsertOperation]);
89585
89730
  }
89586
89731
  setMetadata(entries, segment) {
@@ -89596,7 +89741,11 @@
89596
89741
  if (cur.type === 'setEntries') {
89597
89742
  if (keys$6(cur.entries).length > 0) {
89598
89743
  const table = this.getTable(cur.segment);
89599
- acc.push(table.entriesToUpsertOperations(cur.entries, cur.segment));
89744
+ const upsertOperation = table.entriesToUpsertOperations(cur.entries, cur.segment);
89745
+ if (cur.entries[GRAPHQL_QUERY_ROOT_KEY]) {
89746
+ this.trackGraphQLQueryRootSize(upsertOperation);
89747
+ }
89748
+ acc.push(upsertOperation);
89600
89749
  }
89601
89750
  }
89602
89751
  else if (cur.type === 'setMetadata') {
@@ -89680,6 +89829,19 @@
89680
89829
  });
89681
89830
  }).finally(() => tasker.done());
89682
89831
  }
89832
+ trackGraphQLQueryRootSize(upsertOperation) {
89833
+ try {
89834
+ if (upsertOperation.type !== 'upsert') {
89835
+ return;
89836
+ }
89837
+ const row = upsertOperation.rows.find((r) => r[0] === GRAPHQL_QUERY_ROOT_KEY);
89838
+ if (!(row && row[1] && typeof row[1] === 'string')) {
89839
+ return;
89840
+ }
89841
+ instrumentation$2.trackValue(GRAPHQL_QUERY_ROOT_METRIC_NAME, row[1].length);
89842
+ }
89843
+ catch { }
89844
+ }
89683
89845
  }
89684
89846
 
89685
89847
  // These const values must be in sync with the latest
@@ -90317,6 +90479,7 @@
90317
90479
  const SESSION_INGEST_WRITTEN = 'priming-session-ingest-written-count';
90318
90480
  const SESSION_INGEST_CONFLICTED = 'priming-session-ingest-conflicted-count';
90319
90481
  const SESSION_INGEST_ERRORS = 'priming-session-ingest-error-count';
90482
+ const SESSION_INGEST_DURATION = 'priming-session-ingest-duration';
90320
90483
  class PrimingSession extends EventEmitter {
90321
90484
  constructor(config) {
90322
90485
  super();
@@ -90489,6 +90652,7 @@
90489
90652
  instrumentation$1$1.trackValue(SESSION_INGEST_WRITTEN, written.length);
90490
90653
  instrumentation$1$1.trackValue(SESSION_INGEST_CONFLICTED, conflicted.length);
90491
90654
  instrumentation$1$1.trackValue(SESSION_INGEST_ERRORS, errors.length);
90655
+ instrumentation$1$1.trackValue(SESSION_INGEST_DURATION, Date.now() - beforeWrite);
90492
90656
  stats.conflictedCount = conflicted.length;
90493
90657
  this.emit('batch-written', {
90494
90658
  written,
@@ -91227,10 +91391,12 @@
91227
91391
  }
91228
91392
 
91229
91393
  function instrumentPrimingSession(session) {
91394
+ reportPrimingSessionCreated();
91230
91395
  session.on('error', ({ code, ids }) => {
91231
91396
  reportPrimingError(code, ids.length);
91232
91397
  });
91233
91398
  session.on('primed', ({ length }) => {
91399
+ reportPrimingSuccess(length);
91234
91400
  });
91235
91401
  session.on('conflict', ({ ids, resolution }) => {
91236
91402
  reportPrimingConflict(resolution, ids.length);
@@ -92839,7 +93005,7 @@
92839
93005
  return storeRecord.__type === 'error';
92840
93006
  }
92841
93007
 
92842
- const instrumentation$3 = getInstrumentation();
93008
+ const instrumentation$4 = getInstrumentation();
92843
93009
  const ProductConsumed = {
92844
93010
  API_NAME: 'ProductConsumed',
92845
93011
  Fields: {
@@ -92897,6 +93063,7 @@
92897
93063
  const originalRecord = await this.durableRecordStore.getRecord(buildRecordRepKeyFromId$1(draftRecordId));
92898
93064
  if (originalRecord === undefined) {
92899
93065
  incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Error);
93066
+ instrumentation$4.error(`SFS - ProductConsumedUpdatedHook - Original record ${draftRecordId} not found`);
92900
93067
  return [];
92901
93068
  }
92902
93069
  const originalProductItemId = getProductItemIdFromRecordFields(originalRecord.fields);
@@ -92907,6 +93074,7 @@
92907
93074
  }
92908
93075
  if (originalQuantityConsumed === undefined) {
92909
93076
  incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Error);
93077
+ instrumentation$4.error(`SFS - ProductConsumedUpdatedHook - Original record ${draftRecordId} QuantityConsumed not found`);
92910
93078
  return [];
92911
93079
  }
92912
93080
  incrementCounter(ProductConsumedUpdatedHook.COUNTER_NAME, CounterResult.Created);
@@ -92933,6 +93101,7 @@
92933
93101
  const originalRecord = await this.durableRecordStore.getRecord(buildRecordRepKeyFromId$1(draftRecordId));
92934
93102
  if (originalRecord === undefined) {
92935
93103
  incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Error);
93104
+ instrumentation$4.error(`SFS - ProductConsumedDeletedHook - Original record ${draftRecordId} not found`);
92936
93105
  return [];
92937
93106
  }
92938
93107
  const productItemId = getProductItemIdFromRecordFields(originalRecord.fields);
@@ -92943,6 +93112,7 @@
92943
93112
  }
92944
93113
  if (quantityConsumed === undefined) {
92945
93114
  incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Error);
93115
+ instrumentation$4.error(`SFS - ProductConsumedDeletedHook - Original record ${draftRecordId} QuantityConsumed not found`);
92946
93116
  return [];
92947
93117
  }
92948
93118
  incrementCounter(ProductConsumedDeletedHook.COUNTER_NAME, CounterResult.Created);
@@ -92997,7 +93167,7 @@
92997
93167
  CounterResult["Error"] = "Error";
92998
93168
  })(CounterResult || (CounterResult = {}));
92999
93169
  function incrementCounter(name, result) {
93000
- instrumentation$3.incrementCounter('SFSSideEffect', 1, result == CounterResult.Error, {
93170
+ instrumentation$4.incrementCounter('SFSSideEffect', 1, result == CounterResult.Error, {
93001
93171
  Name: name,
93002
93172
  Result: result,
93003
93173
  });
@@ -93202,7 +93372,7 @@
93202
93372
  id: '@salesforce/lds-network-adapter',
93203
93373
  instrument: instrument$2,
93204
93374
  });
93205
- // version: 1.354.0-dev11-5ded66ad52
93375
+ // version: 1.354.0-dev13-f27ca1a3a7
93206
93376
 
93207
93377
  const { create: create$2, keys: keys$2 } = Object;
93208
93378
  const { stringify, parse } = JSON;
@@ -117553,7 +117723,7 @@
117553
117723
  configuration: { ...configurationForGraphQLAdapters$1 },
117554
117724
  instrument: instrument$1,
117555
117725
  });
117556
- // version: 1.354.0-dev11-634f7f7752
117726
+ // version: 1.354.0-dev13-272d3dd416
117557
117727
 
117558
117728
  // On core the unstable adapters are re-exported with different names,
117559
117729
  // we want to match them here.
@@ -117705,7 +117875,7 @@
117705
117875
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
117706
117876
  graphQLImperative = ldsAdapter;
117707
117877
  });
117708
- // version: 1.354.0-dev11-634f7f7752
117878
+ // version: 1.354.0-dev13-272d3dd416
117709
117879
 
117710
117880
  var gqlApi = /*#__PURE__*/Object.freeze({
117711
117881
  __proto__: null,
@@ -118497,7 +118667,7 @@
118497
118667
  function register(r) {
118498
118668
  callbacks$1.forEach((callback) => callback(r));
118499
118669
  }
118500
- // version: 1.354.0-dev11-5ded66ad52
118670
+ // version: 1.354.0-dev13-f27ca1a3a7
118501
118671
 
118502
118672
  /**
118503
118673
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -119596,4 +119766,4 @@
119596
119766
  exports.subscribeToAdapter = subscribeToAdapter;
119597
119767
 
119598
119768
  }));
119599
- // version: 1.354.0-dev11-5ded66ad52
119769
+ // version: 1.354.0-dev13-f27ca1a3a7