@salesforce/lds-runtime-mobile 1.365.0 → 1.366.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -19,11 +19,11 @@ import { withRegistration, register } from '@salesforce/lds-default-luvio';
19
19
  import { setupInstrumentation, instrumentAdapter as instrumentAdapter$1, instrumentLuvio, setLdsAdaptersUiapiInstrumentation, setLdsNetworkAdapterInstrumentation } from '@salesforce/lds-instrumentation';
20
20
  import { HttpStatusCode, setBypassDeepFreeze, StoreKeySet, serializeStructuredKey, StringKeyInMemoryStore, Reader, deepFreeze, emitAdapterEvent, ingestShape, coerceConfig as coerceConfig$1, typeCheckConfig as typeCheckConfig$h, createResourceParams as createResourceParams$h, StoreKeyMap, buildNetworkSnapshotCachePolicy as buildNetworkSnapshotCachePolicy$f, resolveLink, createCustomAdapterEventEmitter, isFileReference, Environment, Luvio, InMemoryStore } from '@luvio/engine';
21
21
  import { isSupportedEntity, configuration, getObjectInfoAdapterFactory, RECORD_ID_PREFIX, RECORD_FIELDS_KEY_JUNCTION, isStoreKeyRecordViewEntity, extractRecordIdFromStoreKey, buildRecordRepKeyFromId, keyBuilderRecord, RecordRepresentationTTL, keyBuilderQuickActionExecutionRepresentation, ingestQuickActionExecutionRepresentation, getRecordId18 as getRecordId18$1, getRecordsAdapterFactory as getRecordsAdapterFactory$1, RecordRepresentationRepresentationType, ObjectInfoRepresentationType, getObjectInfosAdapterFactory, getObjectInfoDirectoryAdapterFactory, UiApiNamespace, RecordRepresentationType, RecordRepresentationVersion } from '@salesforce/lds-adapters-uiapi';
22
+ import { getInstrumentation, idleDetector } from 'o11y/client';
22
23
  import { Kind as Kind$1, visit as visit$1, isObjectType, defaultFieldResolver, buildSchema, parse as parse$5, extendSchema, isScalarType, execute, print } from '@luvio/graphql-parser';
23
24
  import FIRST_DAY_OF_WEEK from '@salesforce/i18n/firstDayOfWeek';
24
25
  import graphqQueryFieldLimit from '@salesforce/gate/lmr.graphqQueryFieldLimit';
25
26
  import caseSensitiveUserId from '@salesforce/user/Id';
26
- import { idleDetector, getInstrumentation } from 'o11y/client';
27
27
  import { instrument as instrument$1 } from '@salesforce/lds-bindings';
28
28
  import ldsAdapterO11yLoggingGate from '@salesforce/gate/lmr.ldsAdapterO11yLogging';
29
29
  import LOCALE from '@salesforce/i18n/locale';
@@ -53,7 +53,7 @@ const { entries: entries$3, keys: keys$5 } = Object;
53
53
 
54
54
  const UI_API_BASE_URI = '/services/data/v65.0/ui-api';
55
55
 
56
- let instrumentation$2 = {
56
+ let instrumentation$3 = {
57
57
  aggregateUiChunkCount: (_cb) => { },
58
58
  aggregateUiConnectError: () => { },
59
59
  duplicateRequest: (_cb) => { },
@@ -65,7 +65,7 @@ let instrumentation$2 = {
65
65
  networkRateLimitExceeded: () => { },
66
66
  };
67
67
  function instrument(newInstrumentation) {
68
- instrumentation$2 = Object.assign(instrumentation$2, newInstrumentation);
68
+ instrumentation$3 = Object.assign(instrumentation$3, newInstrumentation);
69
69
  }
70
70
 
71
71
  const LDS_RECORDS_AGGREGATE_UI = 'LDS_Records_AggregateUi';
@@ -135,7 +135,7 @@ function mergeRecordFields$2(first, second) {
135
135
  * would otherwise cause a query length exception.
136
136
  */
137
137
  function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resourceRequest, resourceRequestContext) {
138
- instrumentation$2.getRecordAggregateInvoke();
138
+ instrumentation$3.getRecordAggregateInvoke();
139
139
  return networkAdapter(resourceRequest, resourceRequestContext).then((resp) => {
140
140
  const { body } = resp;
141
141
  // This response body could be an executeAggregateUi, which we don't natively support.
@@ -151,7 +151,7 @@ function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resource
151
151
  }
152
152
  const merged = body.compositeResponse.reduce((seed, response) => {
153
153
  if (response.httpStatusCode !== HttpStatusCode.Ok) {
154
- instrumentation$2.getRecordAggregateReject(() => recordId);
154
+ instrumentation$3.getRecordAggregateReject(() => recordId);
155
155
  throw createErrorResponse(HttpStatusCode.ServerError, {
156
156
  error: response.message,
157
157
  });
@@ -161,7 +161,7 @@ function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resource
161
161
  }
162
162
  return mergeRecordFields$2(seed, response.body);
163
163
  }, null);
164
- instrumentation$2.getRecordAggregateResolve(() => {
164
+ instrumentation$3.getRecordAggregateResolve(() => {
165
165
  return {
166
166
  recordId,
167
167
  apiName: merged.apiName,
@@ -169,7 +169,7 @@ function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resource
169
169
  });
170
170
  return createOkResponse$1(merged);
171
171
  }, (err) => {
172
- instrumentation$2.getRecordAggregateReject(() => recordId);
172
+ instrumentation$3.getRecordAggregateReject(() => recordId);
173
173
  // rethrow error
174
174
  throw err;
175
175
  });
@@ -247,7 +247,7 @@ function buildAndDispatchGetRecordAggregateUi(recordId, req, params) {
247
247
  const { networkAdapter, resourceRequest, resourceRequestContext } = req;
248
248
  const compositeRequest = buildGetRecordByFieldsCompositeRequest(resourceRequest, params);
249
249
  // W-12245125: Emit chunk size metrics
250
- instrumentation$2.aggregateUiChunkCount(() => compositeRequest.length);
250
+ instrumentation$3.aggregateUiChunkCount(() => compositeRequest.length);
251
251
  const aggregateUiParams = {
252
252
  compositeRequest,
253
253
  };
@@ -491,7 +491,7 @@ function platformNetworkAdapter(baseNetworkAdapter) {
491
491
  return (resourceRequest, resourceRequestContext) => {
492
492
  if (!tokenBucket.take(1)) {
493
493
  // We are hitting rate limiting, add some metrics
494
- instrumentation$2.networkRateLimitExceeded();
494
+ instrumentation$3.networkRateLimitExceeded();
495
495
  }
496
496
  const salesforceRequest = {
497
497
  networkAdapter: baseNetworkAdapter,
@@ -42754,6 +42754,211 @@ class AbstractQuickActionHandler extends AbstractResourceRequestActionHandler {
42754
42754
  }
42755
42755
  }
42756
42756
 
42757
+ function attachObserversToAdapterRequestContext(observers, adapterRequestContext) {
42758
+ if (adapterRequestContext === undefined) {
42759
+ return { eventObservers: observers };
42760
+ }
42761
+ if (adapterRequestContext.eventObservers === undefined) {
42762
+ return { ...adapterRequestContext, eventObservers: observers };
42763
+ }
42764
+ return {
42765
+ ...adapterRequestContext,
42766
+ eventObservers: adapterRequestContext.eventObservers.concat(observers),
42767
+ };
42768
+ }
42769
+ /**
42770
+ * Use this method to sanitize the unknown error object when
42771
+ * we are unsure of the type of the error thrown
42772
+ *
42773
+ * @param err Unknown object to sanitize
42774
+ * @returns an instance of error
42775
+ */
42776
+ function normalizeError(err) {
42777
+ if (err instanceof Error) {
42778
+ return err;
42779
+ }
42780
+ else if (typeof err === 'string') {
42781
+ return new Error(err);
42782
+ }
42783
+ return new Error(stringify$2(err));
42784
+ }
42785
+
42786
+ const O11Y_NAMESPACE_LDS_MOBILE = 'lds-mobile';
42787
+ // metrics
42788
+ /** GraphQL */
42789
+ const GRAPHQL_EVAL_ERROR = 'gql-eval-error';
42790
+ const GRAPHQL_EVAL_DB_READ_DURATION = 'gql-eval-db-read-duration';
42791
+ const GRAPHQL_EVAL_ROOT_QUERY_COUNT = 'gql-eval-root-query-count';
42792
+ const GRAPHQL_EVAL_TOTAL_QUERY_COUNT = 'gql-eval-total-query-count';
42793
+ const GRAPHQL_EVAL_MAX_CHILD_RELATIONSHIPS_COUNT = 'gql-eval-max-child-count';
42794
+ const GRAPHQL_EVAL_QUERY_RECORD_COUNT = 'gql-eval-query-record-count';
42795
+ const GRAPHQL_SNAPSHOT_REFRESH_UNDEFINED = 'gql-snapshot-refresh-undefined';
42796
+ /** Draft Queue */
42797
+ const DRAFT_QUEUE_STATE_STARTED = 'draft-queue-state-started';
42798
+ const DRAFT_QUEUE_STATE_ERROR = 'draft-queue-state-error';
42799
+ const DRAFT_QUEUE_STATE_WAITING = 'draft-queue-state-waiting';
42800
+ const DRAFT_QUEUE_STATE_STOPPED = 'draft-queue-state-stopped';
42801
+ const DRAFT_QUEUE_ACTION_ADDED = 'draft-queue-action-added';
42802
+ const DRAFT_QUEUE_ACTION_UPLOADING = 'draft-queue-action-uploading';
42803
+ const DRAFT_QUEUE_ACTION_COMPLETED = 'draft-queue-action-completed';
42804
+ const DRAFT_QUEUE_ACTION_DELETED = 'draft-queue-action-deleted';
42805
+ const DRAFT_QUEUE_ACTION_UPDATED = 'draft-queue-action-updated';
42806
+ const DRAFT_QUEUE_ACTION_FAILED = 'draft-queue-action-failed';
42807
+ const DRAFT_QUEUE_TOTAL_MERGE_ACTIONS_CALLS = 'draft-queue-total-mergeActions-calls';
42808
+ /** Content Document */
42809
+ const CREATE_CONTENT_DOCUMENT_AND_VERSION_TOTAL_SYNTHESIZE_CALLS = 'content-document-version-total-synthesize-calls';
42810
+ const CREATE_CONTENT_DOCUMENT_AND_VERSION_DRAFT_SYNTHESIZE_ERROR = 'create-content-document-version-draft-synthesize-error';
42811
+ /** Priming */
42812
+ const PRIMING_TOTAL_SESSION_COUNT = 'priming-total-session-count';
42813
+ const PRIMING_TOTAL_ERROR_COUNT = 'priming-total-error-count';
42814
+ const PRIMING_TOTAL_PRIMED_COUNT = 'priming-total-primed-count';
42815
+ const PRIMING_TOTAL_CONFLICT_COUNT = 'priming-total-conflict-count';
42816
+ // logs
42817
+ const GRAPHQL_QUERY_PARSE_ERROR = 'gql-query-parse-error';
42818
+ const GRAPHQL_SQL_EVAL_PRECONDITION_ERROR = 'gql-sql-pre-eval-error';
42819
+ const GRAPHQL_CREATE_SNAPSHOT_ERROR = 'gql-create-snapshot-error';
42820
+ const DRAFT_AWARE_CREATE_CONTENT_DOCUMENT_AND_VERSION_ERROR = 'draft-aware-create-content-document-and-version-error';
42821
+ const ldsMobileInstrumentation = getInstrumentation(O11Y_NAMESPACE_LDS_MOBILE);
42822
+ const nimbusLogger = typeof __nimbus !== 'undefined' &&
42823
+ __nimbus.plugins !== undefined &&
42824
+ __nimbus.plugins.JSLoggerPlugin !== undefined
42825
+ ? __nimbus.plugins.JSLoggerPlugin
42826
+ : undefined;
42827
+ function reportGraphqlQueryParseError(err) {
42828
+ const error = normalizeError(err);
42829
+ const errorCode = GRAPHQL_QUERY_PARSE_ERROR;
42830
+ // Metric
42831
+ reportGraphqlAdapterError(errorCode);
42832
+ // Log
42833
+ ldsMobileInstrumentation.error(error, errorCode);
42834
+ }
42835
+ function reportGraphqlSqlEvalPreconditionError(err) {
42836
+ const error = normalizeError(err);
42837
+ const errorCode = GRAPHQL_SQL_EVAL_PRECONDITION_ERROR;
42838
+ // Metric
42839
+ reportGraphqlAdapterError(errorCode);
42840
+ // Log
42841
+ ldsMobileInstrumentation.error(error, errorCode);
42842
+ }
42843
+ function reportGraphqlCreateSnapshotError(err) {
42844
+ const error = normalizeError(err);
42845
+ const errorCode = GRAPHQL_CREATE_SNAPSHOT_ERROR;
42846
+ // Metric
42847
+ reportGraphqlAdapterError(errorCode);
42848
+ // Log
42849
+ ldsMobileInstrumentation.error(error, errorCode);
42850
+ }
42851
+ function reportGraphQlEvalDbReadDuration(duration) {
42852
+ ldsMobileInstrumentation.trackValue(GRAPHQL_EVAL_DB_READ_DURATION, duration);
42853
+ }
42854
+ function reportGraphqlAdapterError(errorCode) {
42855
+ // Increment overall count with errorCode as tag
42856
+ ldsMobileInstrumentation.incrementCounter(GRAPHQL_EVAL_ERROR, 1, true, { errorCode });
42857
+ }
42858
+ function reportGraphqlQueryInstrumentation(data) {
42859
+ const queryBuckets = [1, 2, 3, 4, 5, 10, 20, 50, 100];
42860
+ const recordBuckets = [
42861
+ 1, 5, 10, 20, 50, 100, 1000, 2000, 5000, 10000, 50000, 100000, 1000000,
42862
+ ];
42863
+ ldsMobileInstrumentation.bucketValue(GRAPHQL_EVAL_ROOT_QUERY_COUNT, data.rootQueryCount, queryBuckets);
42864
+ ldsMobileInstrumentation.bucketValue(GRAPHQL_EVAL_TOTAL_QUERY_COUNT, data.totalQueryCount, queryBuckets);
42865
+ ldsMobileInstrumentation.bucketValue(GRAPHQL_EVAL_MAX_CHILD_RELATIONSHIPS_COUNT, data.maxChildRelationships, queryBuckets);
42866
+ ldsMobileInstrumentation.bucketValue(GRAPHQL_EVAL_QUERY_RECORD_COUNT, data.requestedRecordCount, recordBuckets);
42867
+ }
42868
+ function incrementGraphQLRefreshUndfined() {
42869
+ ldsMobileInstrumentation.incrementCounter(GRAPHQL_SNAPSHOT_REFRESH_UNDEFINED);
42870
+ }
42871
+ function reportDraftActionEvent(state, draftCount, message) {
42872
+ if (nimbusLogger) {
42873
+ nimbusLogger.logInfo(`Draft action event: ${state}, depth: ${draftCount}${message ? `, message: ${message}` : ''}`);
42874
+ }
42875
+ switch (state) {
42876
+ case 'added':
42877
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_ADDED);
42878
+ break;
42879
+ case 'uploading':
42880
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_UPLOADING);
42881
+ break;
42882
+ case 'completed':
42883
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_COMPLETED);
42884
+ break;
42885
+ case 'deleted':
42886
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_DELETED);
42887
+ break;
42888
+ case 'failed':
42889
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_FAILED, 1, true);
42890
+ break;
42891
+ case 'updated':
42892
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_UPDATED);
42893
+ break;
42894
+ }
42895
+ }
42896
+ function reportDraftQueueState(state, draftCount) {
42897
+ if (nimbusLogger) {
42898
+ nimbusLogger.logInfo(`Draft state changed: ${state}, depth: ${draftCount}`);
42899
+ }
42900
+ switch (state) {
42901
+ case 'started':
42902
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_STATE_STARTED);
42903
+ break;
42904
+ case 'error':
42905
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_STATE_ERROR, 1, true);
42906
+ break;
42907
+ case 'waiting':
42908
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_STATE_WAITING);
42909
+ break;
42910
+ case 'stopped':
42911
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_STATE_STOPPED);
42912
+ break;
42913
+ }
42914
+ }
42915
+ function reportDraftAwareContentDocumentVersionSynthesizeError(err) {
42916
+ let error;
42917
+ if (err.body !== undefined) {
42918
+ error = err.body;
42919
+ }
42920
+ else {
42921
+ error = normalizeError(err);
42922
+ }
42923
+ const errorCode = DRAFT_AWARE_CREATE_CONTENT_DOCUMENT_AND_VERSION_ERROR;
42924
+ const errorType = error.errorType;
42925
+ const tags = {
42926
+ errorCode,
42927
+ };
42928
+ if (errorType !== undefined) {
42929
+ tags.errorType = errorType;
42930
+ }
42931
+ // Metric
42932
+ ldsMobileInstrumentation.incrementCounter(CREATE_CONTENT_DOCUMENT_AND_VERSION_DRAFT_SYNTHESIZE_ERROR, 1, true, tags);
42933
+ // Log
42934
+ ldsMobileInstrumentation.error(error, errorCode);
42935
+ }
42936
+ function reportDraftAwareContentVersionSynthesizeCalls(mimeType) {
42937
+ ldsMobileInstrumentation.incrementCounter(CREATE_CONTENT_DOCUMENT_AND_VERSION_TOTAL_SYNTHESIZE_CALLS, 1, undefined, { mimeType });
42938
+ }
42939
+ /** Priming */
42940
+ function reportPrimingSessionCreated() {
42941
+ ldsMobileInstrumentation.incrementCounter(PRIMING_TOTAL_SESSION_COUNT, 1, undefined, {});
42942
+ }
42943
+ function reportPrimingError(errorType, recordCount) {
42944
+ ldsMobileInstrumentation.incrementCounter(PRIMING_TOTAL_ERROR_COUNT, recordCount, undefined, {
42945
+ errorType,
42946
+ });
42947
+ }
42948
+ function reportPrimingSuccess(recordCount) {
42949
+ ldsMobileInstrumentation.incrementCounter(PRIMING_TOTAL_PRIMED_COUNT, recordCount, undefined);
42950
+ }
42951
+ function reportPrimingConflict(resolutionType, recordCount) {
42952
+ ldsMobileInstrumentation.incrementCounter(PRIMING_TOTAL_CONFLICT_COUNT, recordCount, undefined, {
42953
+ resolutionType,
42954
+ });
42955
+ }
42956
+ /** Network */
42957
+ function reportChunkCandidateUrlLength(urlLength) {
42958
+ const buckets = [8000, 10000, 12000, 14000, 16000];
42959
+ ldsMobileInstrumentation.bucketValue('chunk-candidate-url-length-histogram', urlLength, buckets);
42960
+ }
42961
+
42757
42962
  const QUICK_ACTION_HANDLER = 'QUICK_ACTION_HANDLER';
42758
42963
  class QuickActionExecutionRepresentationHandler extends AbstractQuickActionHandler {
42759
42964
  constructor(getLuvio, draftRecordService, draftQueue, networkAdapter, isDraftId, sideEffectService, objectInfoService, getRecord) {
@@ -42764,6 +42969,7 @@ class QuickActionExecutionRepresentationHandler extends AbstractQuickActionHandl
42764
42969
  this.objectInfoService = objectInfoService;
42765
42970
  this.getRecord = getRecord;
42766
42971
  this.handlerId = QUICK_ACTION_HANDLER;
42972
+ this.instrumentation = getInstrumentation(O11Y_NAMESPACE_LDS_MOBILE);
42767
42973
  draftRecordService.registerRecordHandler(this);
42768
42974
  }
42769
42975
  async draftActionToSideEffects(queueEntry) {
@@ -42795,10 +43001,26 @@ class QuickActionExecutionRepresentationHandler extends AbstractQuickActionHandl
42795
43001
  luvio.storeIngest(key, ingestQuickActionExecutionRepresentation, response);
42796
43002
  }
42797
43003
  async handleActionCompleted(action, queueOperations) {
43004
+ /* performQuickAction will not return the new record itself, so before the action
43005
+ * is marked as completed, we need to fetch the actual record. This must be done before
43006
+ * the super method is called because the super method will revert the side effects that
43007
+ * were created for this action, and critically that means evicting the synthetic record
43008
+ * that was created to represent the draft of what would become the canonical record.
43009
+ * Since getRecord is a network call, it is better to have a small timeframe (on the order
43010
+ * of microseconds) where both the synthetic record and the canonical record are in the
43011
+ * store instead of the record missing from the store for the entire duration of the
43012
+ * network call.
43013
+ */
43014
+ try {
43015
+ await this.fetchRecordIntoStoreFromCompletedAction(action);
43016
+ }
43017
+ catch (error) {
43018
+ this.instrumentation.error(error, 'Error fetching the record created from performQuickAction adapter.');
43019
+ }
42798
43020
  await super.handleActionCompleted(action, queueOperations);
42799
- this.getLuvio();
43021
+ }
43022
+ async fetchRecordIntoStoreFromCompletedAction(action) {
42800
43023
  const canonicalId = action.response.body.id;
42801
- this.buildTagForTargetId(canonicalId);
42802
43024
  const prefix = canonicalId.substring(0, 3);
42803
43025
  if (prefix.length !== 3) {
42804
43026
  // if we can't get a prefix, don't do the rest
@@ -50509,6 +50731,9 @@ function stringifyIfPresent(value) {
50509
50731
  if (value === undefined || value === null) {
50510
50732
  return null;
50511
50733
  }
50734
+ if (typeof value === 'string') {
50735
+ return value;
50736
+ }
50512
50737
  return stringify$1(value);
50513
50738
  }
50514
50739
  function parseIfPresent(value) {
@@ -51215,211 +51440,6 @@ class NimbusDraftQueue {
51215
51440
  }
51216
51441
  }
51217
51442
 
51218
- function attachObserversToAdapterRequestContext(observers, adapterRequestContext) {
51219
- if (adapterRequestContext === undefined) {
51220
- return { eventObservers: observers };
51221
- }
51222
- if (adapterRequestContext.eventObservers === undefined) {
51223
- return { ...adapterRequestContext, eventObservers: observers };
51224
- }
51225
- return {
51226
- ...adapterRequestContext,
51227
- eventObservers: adapterRequestContext.eventObservers.concat(observers),
51228
- };
51229
- }
51230
- /**
51231
- * Use this method to sanitize the unknown error object when
51232
- * we are unsure of the type of the error thrown
51233
- *
51234
- * @param err Unknown object to sanitize
51235
- * @returns an instance of error
51236
- */
51237
- function normalizeError(err) {
51238
- if (err instanceof Error) {
51239
- return err;
51240
- }
51241
- else if (typeof err === 'string') {
51242
- return new Error(err);
51243
- }
51244
- return new Error(stringify$2(err));
51245
- }
51246
-
51247
- const O11Y_NAMESPACE_LDS_MOBILE = 'lds-mobile';
51248
- // metrics
51249
- /** GraphQL */
51250
- const GRAPHQL_EVAL_ERROR = 'gql-eval-error';
51251
- const GRAPHQL_EVAL_DB_READ_DURATION = 'gql-eval-db-read-duration';
51252
- const GRAPHQL_EVAL_ROOT_QUERY_COUNT = 'gql-eval-root-query-count';
51253
- const GRAPHQL_EVAL_TOTAL_QUERY_COUNT = 'gql-eval-total-query-count';
51254
- const GRAPHQL_EVAL_MAX_CHILD_RELATIONSHIPS_COUNT = 'gql-eval-max-child-count';
51255
- const GRAPHQL_EVAL_QUERY_RECORD_COUNT = 'gql-eval-query-record-count';
51256
- const GRAPHQL_SNAPSHOT_REFRESH_UNDEFINED = 'gql-snapshot-refresh-undefined';
51257
- /** Draft Queue */
51258
- const DRAFT_QUEUE_STATE_STARTED = 'draft-queue-state-started';
51259
- const DRAFT_QUEUE_STATE_ERROR = 'draft-queue-state-error';
51260
- const DRAFT_QUEUE_STATE_WAITING = 'draft-queue-state-waiting';
51261
- const DRAFT_QUEUE_STATE_STOPPED = 'draft-queue-state-stopped';
51262
- const DRAFT_QUEUE_ACTION_ADDED = 'draft-queue-action-added';
51263
- const DRAFT_QUEUE_ACTION_UPLOADING = 'draft-queue-action-uploading';
51264
- const DRAFT_QUEUE_ACTION_COMPLETED = 'draft-queue-action-completed';
51265
- const DRAFT_QUEUE_ACTION_DELETED = 'draft-queue-action-deleted';
51266
- const DRAFT_QUEUE_ACTION_UPDATED = 'draft-queue-action-updated';
51267
- const DRAFT_QUEUE_ACTION_FAILED = 'draft-queue-action-failed';
51268
- const DRAFT_QUEUE_TOTAL_MERGE_ACTIONS_CALLS = 'draft-queue-total-mergeActions-calls';
51269
- /** Content Document */
51270
- const CREATE_CONTENT_DOCUMENT_AND_VERSION_TOTAL_SYNTHESIZE_CALLS = 'content-document-version-total-synthesize-calls';
51271
- const CREATE_CONTENT_DOCUMENT_AND_VERSION_DRAFT_SYNTHESIZE_ERROR = 'create-content-document-version-draft-synthesize-error';
51272
- /** Priming */
51273
- const PRIMING_TOTAL_SESSION_COUNT = 'priming-total-session-count';
51274
- const PRIMING_TOTAL_ERROR_COUNT = 'priming-total-error-count';
51275
- const PRIMING_TOTAL_PRIMED_COUNT = 'priming-total-primed-count';
51276
- const PRIMING_TOTAL_CONFLICT_COUNT = 'priming-total-conflict-count';
51277
- // logs
51278
- const GRAPHQL_QUERY_PARSE_ERROR = 'gql-query-parse-error';
51279
- const GRAPHQL_SQL_EVAL_PRECONDITION_ERROR = 'gql-sql-pre-eval-error';
51280
- const GRAPHQL_CREATE_SNAPSHOT_ERROR = 'gql-create-snapshot-error';
51281
- const DRAFT_AWARE_CREATE_CONTENT_DOCUMENT_AND_VERSION_ERROR = 'draft-aware-create-content-document-and-version-error';
51282
- const ldsMobileInstrumentation = getInstrumentation(O11Y_NAMESPACE_LDS_MOBILE);
51283
- const nimbusLogger = typeof __nimbus !== 'undefined' &&
51284
- __nimbus.plugins !== undefined &&
51285
- __nimbus.plugins.JSLoggerPlugin !== undefined
51286
- ? __nimbus.plugins.JSLoggerPlugin
51287
- : undefined;
51288
- function reportGraphqlQueryParseError(err) {
51289
- const error = normalizeError(err);
51290
- const errorCode = GRAPHQL_QUERY_PARSE_ERROR;
51291
- // Metric
51292
- reportGraphqlAdapterError(errorCode);
51293
- // Log
51294
- ldsMobileInstrumentation.error(error, errorCode);
51295
- }
51296
- function reportGraphqlSqlEvalPreconditionError(err) {
51297
- const error = normalizeError(err);
51298
- const errorCode = GRAPHQL_SQL_EVAL_PRECONDITION_ERROR;
51299
- // Metric
51300
- reportGraphqlAdapterError(errorCode);
51301
- // Log
51302
- ldsMobileInstrumentation.error(error, errorCode);
51303
- }
51304
- function reportGraphqlCreateSnapshotError(err) {
51305
- const error = normalizeError(err);
51306
- const errorCode = GRAPHQL_CREATE_SNAPSHOT_ERROR;
51307
- // Metric
51308
- reportGraphqlAdapterError(errorCode);
51309
- // Log
51310
- ldsMobileInstrumentation.error(error, errorCode);
51311
- }
51312
- function reportGraphQlEvalDbReadDuration(duration) {
51313
- ldsMobileInstrumentation.trackValue(GRAPHQL_EVAL_DB_READ_DURATION, duration);
51314
- }
51315
- function reportGraphqlAdapterError(errorCode) {
51316
- // Increment overall count with errorCode as tag
51317
- ldsMobileInstrumentation.incrementCounter(GRAPHQL_EVAL_ERROR, 1, true, { errorCode });
51318
- }
51319
- function reportGraphqlQueryInstrumentation(data) {
51320
- const queryBuckets = [1, 2, 3, 4, 5, 10, 20, 50, 100];
51321
- const recordBuckets = [
51322
- 1, 5, 10, 20, 50, 100, 1000, 2000, 5000, 10000, 50000, 100000, 1000000,
51323
- ];
51324
- ldsMobileInstrumentation.bucketValue(GRAPHQL_EVAL_ROOT_QUERY_COUNT, data.rootQueryCount, queryBuckets);
51325
- ldsMobileInstrumentation.bucketValue(GRAPHQL_EVAL_TOTAL_QUERY_COUNT, data.totalQueryCount, queryBuckets);
51326
- ldsMobileInstrumentation.bucketValue(GRAPHQL_EVAL_MAX_CHILD_RELATIONSHIPS_COUNT, data.maxChildRelationships, queryBuckets);
51327
- ldsMobileInstrumentation.bucketValue(GRAPHQL_EVAL_QUERY_RECORD_COUNT, data.requestedRecordCount, recordBuckets);
51328
- }
51329
- function incrementGraphQLRefreshUndfined() {
51330
- ldsMobileInstrumentation.incrementCounter(GRAPHQL_SNAPSHOT_REFRESH_UNDEFINED);
51331
- }
51332
- function reportDraftActionEvent(state, draftCount, message) {
51333
- if (nimbusLogger) {
51334
- nimbusLogger.logInfo(`Draft action event: ${state}, depth: ${draftCount}${message ? `, message: ${message}` : ''}`);
51335
- }
51336
- switch (state) {
51337
- case 'added':
51338
- ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_ADDED);
51339
- break;
51340
- case 'uploading':
51341
- ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_UPLOADING);
51342
- break;
51343
- case 'completed':
51344
- ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_COMPLETED);
51345
- break;
51346
- case 'deleted':
51347
- ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_DELETED);
51348
- break;
51349
- case 'failed':
51350
- ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_FAILED, 1, true);
51351
- break;
51352
- case 'updated':
51353
- ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_UPDATED);
51354
- break;
51355
- }
51356
- }
51357
- function reportDraftQueueState(state, draftCount) {
51358
- if (nimbusLogger) {
51359
- nimbusLogger.logInfo(`Draft state changed: ${state}, depth: ${draftCount}`);
51360
- }
51361
- switch (state) {
51362
- case 'started':
51363
- ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_STATE_STARTED);
51364
- break;
51365
- case 'error':
51366
- ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_STATE_ERROR, 1, true);
51367
- break;
51368
- case 'waiting':
51369
- ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_STATE_WAITING);
51370
- break;
51371
- case 'stopped':
51372
- ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_STATE_STOPPED);
51373
- break;
51374
- }
51375
- }
51376
- function reportDraftAwareContentDocumentVersionSynthesizeError(err) {
51377
- let error;
51378
- if (err.body !== undefined) {
51379
- error = err.body;
51380
- }
51381
- else {
51382
- error = normalizeError(err);
51383
- }
51384
- const errorCode = DRAFT_AWARE_CREATE_CONTENT_DOCUMENT_AND_VERSION_ERROR;
51385
- const errorType = error.errorType;
51386
- const tags = {
51387
- errorCode,
51388
- };
51389
- if (errorType !== undefined) {
51390
- tags.errorType = errorType;
51391
- }
51392
- // Metric
51393
- ldsMobileInstrumentation.incrementCounter(CREATE_CONTENT_DOCUMENT_AND_VERSION_DRAFT_SYNTHESIZE_ERROR, 1, true, tags);
51394
- // Log
51395
- ldsMobileInstrumentation.error(error, errorCode);
51396
- }
51397
- function reportDraftAwareContentVersionSynthesizeCalls(mimeType) {
51398
- ldsMobileInstrumentation.incrementCounter(CREATE_CONTENT_DOCUMENT_AND_VERSION_TOTAL_SYNTHESIZE_CALLS, 1, undefined, { mimeType });
51399
- }
51400
- /** Priming */
51401
- function reportPrimingSessionCreated() {
51402
- ldsMobileInstrumentation.incrementCounter(PRIMING_TOTAL_SESSION_COUNT, 1, undefined, {});
51403
- }
51404
- function reportPrimingError(errorType, recordCount) {
51405
- ldsMobileInstrumentation.incrementCounter(PRIMING_TOTAL_ERROR_COUNT, recordCount, undefined, {
51406
- errorType,
51407
- });
51408
- }
51409
- function reportPrimingSuccess(recordCount) {
51410
- ldsMobileInstrumentation.incrementCounter(PRIMING_TOTAL_PRIMED_COUNT, recordCount, undefined);
51411
- }
51412
- function reportPrimingConflict(resolutionType, recordCount) {
51413
- ldsMobileInstrumentation.incrementCounter(PRIMING_TOTAL_CONFLICT_COUNT, recordCount, undefined, {
51414
- resolutionType,
51415
- });
51416
- }
51417
- /** Network */
51418
- function reportChunkCandidateUrlLength(urlLength) {
51419
- const buckets = [8000, 10000, 12000, 14000, 16000];
51420
- ldsMobileInstrumentation.bucketValue('chunk-candidate-url-length-histogram', urlLength, buckets);
51421
- }
51422
-
51423
51443
  /**
51424
51444
  * HOF (high-order-function) that instruments any async operation. If the operation
51425
51445
  * has an error then the hasError param will be set on the call to o11y.incrementCounter
@@ -52108,6 +52128,9 @@ class LdsInternalDataTable {
52108
52128
  }
52109
52129
 
52110
52130
  const tasker = idleDetector.declareNotifierTaskMulti('NimbusSqliteStore');
52131
+ const instrumentation$2 = getInstrumentation('lds-mobile');
52132
+ const GRAPHQL_QUERY_ROOT_KEY = 'UiApi::uiapi::Query[uiapi]__uiapi__query';
52133
+ const GRAPHQL_QUERY_ROOT_METRIC_NAME = 'gql-query-root-object-size';
52111
52134
  class NimbusSqliteStore {
52112
52135
  constructor(plugin, additionalTableMap = {}) {
52113
52136
  this.plugin = plugin;
@@ -52159,6 +52182,9 @@ class NimbusSqliteStore {
52159
52182
  }
52160
52183
  const table = this.getTable(segment);
52161
52184
  const upsertOperation = table.entriesToUpsertOperations(entries, segment);
52185
+ if (entries[GRAPHQL_QUERY_ROOT_KEY]) {
52186
+ this.trackGraphQLQueryRootSize(upsertOperation);
52187
+ }
52162
52188
  return this.batchOperationAsPromise([upsertOperation]);
52163
52189
  }
52164
52190
  setMetadata(entries, segment) {
@@ -52174,7 +52200,11 @@ class NimbusSqliteStore {
52174
52200
  if (cur.type === 'setEntries') {
52175
52201
  if (keys(cur.entries).length > 0) {
52176
52202
  const table = this.getTable(cur.segment);
52177
- acc.push(table.entriesToUpsertOperations(cur.entries, cur.segment));
52203
+ const upsertOperation = table.entriesToUpsertOperations(cur.entries, cur.segment);
52204
+ if (cur.entries[GRAPHQL_QUERY_ROOT_KEY]) {
52205
+ this.trackGraphQLQueryRootSize(upsertOperation);
52206
+ }
52207
+ acc.push(upsertOperation);
52178
52208
  }
52179
52209
  }
52180
52210
  else if (cur.type === 'setMetadata') {
@@ -52259,6 +52289,19 @@ class NimbusSqliteStore {
52259
52289
  });
52260
52290
  }).finally(() => tasker.done());
52261
52291
  }
52292
+ trackGraphQLQueryRootSize(upsertOperation) {
52293
+ try {
52294
+ if (upsertOperation.type !== 'upsert') {
52295
+ return;
52296
+ }
52297
+ const row = upsertOperation.rows.find((r) => r[0] === GRAPHQL_QUERY_ROOT_KEY);
52298
+ if (!(row && row[1] && typeof row[1] === 'string')) {
52299
+ return;
52300
+ }
52301
+ instrumentation$2.trackValue(GRAPHQL_QUERY_ROOT_METRIC_NAME, row[1].length);
52302
+ }
52303
+ catch { }
52304
+ }
52262
52305
  }
52263
52306
 
52264
52307
  // These const values must be in sync with the latest
@@ -55833,4 +55876,4 @@ register({
55833
55876
  });
55834
55877
 
55835
55878
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, ingest$1o as ingestDenormalizedRecordRepresentation, registerReportObserver, reportGraphqlQueryParseError };
55836
- // version: 1.365.0-eec7b6223e
55879
+ // version: 1.366.0-30380c7ed7
@@ -20,6 +20,7 @@ export declare class QuickActionExecutionRepresentationHandler extends AbstractQ
20
20
  private readonly objectInfoService;
21
21
  private readonly getRecord;
22
22
  handlerId: string;
23
+ private readonly instrumentation;
23
24
  constructor(getLuvio: () => Luvio, draftRecordService: UiApiDraftRecordService, draftQueue: DraftQueue, networkAdapter: NetworkAdapter, isDraftId: (targetId: string) => boolean, sideEffectService: SideEffectService, objectInfoService: ObjectInfoService, getRecord: Adapter<GetRecordConfig, RecordRepresentation>);
24
25
  draftActionToSideEffects(queueEntry: DraftAction<PerformQuickActionResourceRequest, QuickActionExecutionRepresentation>): Promise<SideEffect[]>;
25
26
  getIdFromRequest(request: ResourceRequest): Promise<string>;
@@ -28,6 +29,7 @@ export declare class QuickActionExecutionRepresentationHandler extends AbstractQ
28
29
  buildCacheKeysFromResponse(_response: QuickActionExecutionRepresentation): DurableStoreKeyMetadataMap;
29
30
  synchronousIngest(response: QuickActionExecutionRepresentation): void;
30
31
  handleActionCompleted(action: CompletedDraftAction<ResourceRequest, QuickActionExecutionRepresentation>, queueOperations: QueueOperation[]): Promise<void>;
32
+ private fetchRecordIntoStoreFromCompletedAction;
31
33
  private allFields;
32
34
  mergeRequestBody<T>(): T;
33
35
  }
@@ -1,7 +1,7 @@
1
1
  import type { QueryInstrumentation } from '../graphql/instrumentLimits';
2
2
  export declare const O11Y_NAMESPACE_LDS_MOBILE = "lds-mobile";
3
3
  export declare const DRAFT_QUEUE_TOTAL_MERGE_ACTIONS_CALLS = "draft-queue-total-mergeActions-calls";
4
- export declare const ldsMobileInstrumentation: import("o11y/dist/modules/o11y/client/interfaces").Instrumentation;
4
+ export declare const ldsMobileInstrumentation: any;
5
5
  export declare function reportGraphqlQueryParseError(err: unknown): void;
6
6
  export declare function reportGraphqlSqlEvalPreconditionError(err: unknown): void;
7
7
  export declare function reportGraphqlCreateSnapshotError(err: unknown): void;
@@ -0,0 +1,3 @@
1
+ import { IFetchService } from '@luvio/service-fetch-network/v1';
2
+ import { type ServiceDescriptor } from '@luvio/utils';
3
+ export declare function buildNimbusFetchServiceDescriptor(): ServiceDescriptor<IFetchService, 'fetch', '1.0'>;
@@ -6,7 +6,7 @@ import type { PrimingStore } from './PrimingStore';
6
6
  import type { LdsRecordRefresher } from './LdsRecordRefresher';
7
7
  import type { ObservabilityContext } from '@salesforce/nimbus-plugin-lds';
8
8
  import { EventEmitter } from './Emitter';
9
- export declare const instrumentation: import("o11y/dist/modules/o11y/client/interfaces").Instrumentation;
9
+ export declare const instrumentation: any;
10
10
  export interface PrimingSessionConfig {
11
11
  store: PrimingStore;
12
12
  recordLoader: RecordLoader;
@@ -1,7 +1,7 @@
1
1
  import { SideEffect } from '../drafts/sideEffects';
2
2
  import type { CreateSideEffectHook, DeleteSideEffectHook, UpdateSideEffectHook } from '../drafts/records/actionHandlers/SideEffectHook';
3
3
  import { DurableRecordStore } from '../durableStore/DurableRecordStore';
4
- export declare const instrumentation: import("o11y/dist/modules/o11y/client/interfaces").Instrumentation;
4
+ export declare const instrumentation: any;
5
5
  export declare class ProductConsumedCreatedHook implements CreateSideEffectHook {
6
6
  on: 'post';
7
7
  apiName: string;