@salesforce/lds-runtime-mobile 1.365.0 → 1.367.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 { Kind as Kind$1, visit as visit$1, isObjectType, defaultFieldResolver, buildSchema, parse as parse$5, extendSchema, isScalarType, execute, print } from '@luvio/graphql-parser';
22
+ import { getInstrumentation, idleDetector } from 'o11y/client';
23
+ import { Kind as Kind$1, visit as visit$1, isObjectType, defaultFieldResolver, buildSchema, parse as parse$7, 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';
@@ -38,6 +38,8 @@ import ldsPrimingGraphqlBatch from '@salesforce/gate/lds.primingGraphqlBatch';
38
38
  import lmrPrimingUseSoql from '@salesforce/gate/lmr.primingUseSoql';
39
39
  import graphqlL2AdapterGate from '@salesforce/gate/lmr.graphqlL2Adapter';
40
40
  import productConsumedSideEffects from '@salesforce/gate/com.salesforce.fieldservice.vanStockLDSBypass256';
41
+ import useOneStore from '@salesforce/gate/lmr.useOneStore';
42
+ import { setServices } from '@luvio/service-provisioner/v1';
41
43
 
42
44
  /**
43
45
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -46,14 +48,14 @@ import productConsumedSideEffects from '@salesforce/gate/com.salesforce.fieldser
46
48
  */
47
49
 
48
50
 
49
- const { parse: parse$4, stringify: stringify$4 } = JSON;
51
+ const { parse: parse$6, stringify: stringify$6 } = JSON;
50
52
  const { join: join$1, push: push$2, unshift } = Array.prototype;
51
- const { isArray: isArray$3 } = Array;
52
- const { entries: entries$3, keys: keys$5 } = Object;
53
+ const { isArray: isArray$5 } = Array;
54
+ const { entries: entries$4, keys: keys$6 } = Object;
53
55
 
54
56
  const UI_API_BASE_URI = '/services/data/v65.0/ui-api';
55
57
 
56
- let instrumentation$2 = {
58
+ let instrumentation$3 = {
57
59
  aggregateUiChunkCount: (_cb) => { },
58
60
  aggregateUiConnectError: () => { },
59
61
  duplicateRequest: (_cb) => { },
@@ -65,7 +67,7 @@ let instrumentation$2 = {
65
67
  networkRateLimitExceeded: () => { },
66
68
  };
67
69
  function instrument(newInstrumentation) {
68
- instrumentation$2 = Object.assign(instrumentation$2, newInstrumentation);
70
+ instrumentation$3 = Object.assign(instrumentation$3, newInstrumentation);
69
71
  }
70
72
 
71
73
  const LDS_RECORDS_AGGREGATE_UI = 'LDS_Records_AggregateUi';
@@ -114,7 +116,7 @@ function isSpanningRecord$2(fieldValue) {
114
116
  function mergeRecordFields$2(first, second) {
115
117
  const { fields: targetFields } = first;
116
118
  const { fields: sourceFields } = second;
117
- const fieldNames = keys$5(sourceFields);
119
+ const fieldNames = keys$6(sourceFields);
118
120
  for (let i = 0, len = fieldNames.length; i < len; i += 1) {
119
121
  const fieldName = fieldNames[i];
120
122
  const sourceField = sourceFields[fieldName];
@@ -135,7 +137,7 @@ function mergeRecordFields$2(first, second) {
135
137
  * would otherwise cause a query length exception.
136
138
  */
137
139
  function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resourceRequest, resourceRequestContext) {
138
- instrumentation$2.getRecordAggregateInvoke();
140
+ instrumentation$3.getRecordAggregateInvoke();
139
141
  return networkAdapter(resourceRequest, resourceRequestContext).then((resp) => {
140
142
  const { body } = resp;
141
143
  // This response body could be an executeAggregateUi, which we don't natively support.
@@ -151,7 +153,7 @@ function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resource
151
153
  }
152
154
  const merged = body.compositeResponse.reduce((seed, response) => {
153
155
  if (response.httpStatusCode !== HttpStatusCode.Ok) {
154
- instrumentation$2.getRecordAggregateReject(() => recordId);
156
+ instrumentation$3.getRecordAggregateReject(() => recordId);
155
157
  throw createErrorResponse(HttpStatusCode.ServerError, {
156
158
  error: response.message,
157
159
  });
@@ -161,7 +163,7 @@ function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resource
161
163
  }
162
164
  return mergeRecordFields$2(seed, response.body);
163
165
  }, null);
164
- instrumentation$2.getRecordAggregateResolve(() => {
166
+ instrumentation$3.getRecordAggregateResolve(() => {
165
167
  return {
166
168
  recordId,
167
169
  apiName: merged.apiName,
@@ -169,7 +171,7 @@ function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resource
169
171
  });
170
172
  return createOkResponse$1(merged);
171
173
  }, (err) => {
172
- instrumentation$2.getRecordAggregateReject(() => recordId);
174
+ instrumentation$3.getRecordAggregateReject(() => recordId);
173
175
  // rethrow error
174
176
  throw err;
175
177
  });
@@ -247,7 +249,7 @@ function buildAndDispatchGetRecordAggregateUi(recordId, req, params) {
247
249
  const { networkAdapter, resourceRequest, resourceRequestContext } = req;
248
250
  const compositeRequest = buildGetRecordByFieldsCompositeRequest(resourceRequest, params);
249
251
  // W-12245125: Emit chunk size metrics
250
- instrumentation$2.aggregateUiChunkCount(() => compositeRequest.length);
252
+ instrumentation$3.aggregateUiChunkCount(() => compositeRequest.length);
251
253
  const aggregateUiParams = {
252
254
  compositeRequest,
253
255
  };
@@ -273,7 +275,7 @@ const getRecordDispatcher = (req) => {
273
275
  }
274
276
  }
275
277
  const recordId = urlParams.recordId;
276
- const fieldsArray = fields !== undefined && isArray$3(fields) ? fields : [];
278
+ const fieldsArray = fields !== undefined && isArray$5(fields) ? fields : [];
277
279
  const optionalFieldsArray = optionalFields !== undefined && Array.isArray(optionalFields)
278
280
  ? optionalFields
279
281
  : [];
@@ -349,10 +351,10 @@ function getTransactionKey(req) {
349
351
  const { resourceRequest } = req;
350
352
  const { baseUri, basePath, queryParams, headers } = resourceRequest;
351
353
  const path = `${baseUri}${basePath}`;
352
- const queryParamsString = queryParams ? stringify$4(queryParams) : EMPTY_STRING;
353
- const headersString = stringify$4(headers);
354
+ const queryParamsString = queryParams ? stringify$6(queryParams) : EMPTY_STRING;
355
+ const headersString = stringify$6(headers);
354
356
  const bodyString = resourceRequest.body && isResourceRequestDedupable(req)
355
- ? stringify$4(resourceRequest.body)
357
+ ? stringify$6(resourceRequest.body)
356
358
  : EMPTY_STRING;
357
359
  return `${path}${TRANSACTION_KEY_SEP}${headersString}${TRANSACTION_KEY_SEP}${queryParamsString}${bodyString}`;
358
360
  }
@@ -361,7 +363,7 @@ function getFulfillingRequest(inflightRequests, resourceRequest) {
361
363
  if (fulfill === undefined) {
362
364
  return null;
363
365
  }
364
- const handlersMap = entries$3(inflightRequests);
366
+ const handlersMap = entries$4(inflightRequests);
365
367
  for (let i = 0, len = handlersMap.length; i < len; i += 1) {
366
368
  const [transactionKey, handlers] = handlersMap[i];
367
369
  // check fulfillment against only the first handler ([0]) because it's equal or
@@ -423,7 +425,7 @@ const dedupeRequest = (req) => {
423
425
  // extra clone (particularly when there's only 1 handler).
424
426
  for (let i = 1, len = handlers.length; i < len; i++) {
425
427
  const handler = handlers[i];
426
- handler.resolve(parse$4(stringify$4(response)));
428
+ handler.resolve(parse$6(stringify$6(response)));
427
429
  }
428
430
  handlers[0].resolve(response);
429
431
  }, (error) => {
@@ -491,7 +493,7 @@ function platformNetworkAdapter(baseNetworkAdapter) {
491
493
  return (resourceRequest, resourceRequestContext) => {
492
494
  if (!tokenBucket.take(1)) {
493
495
  // We are hitting rate limiting, add some metrics
494
- instrumentation$2.networkRateLimitExceeded();
496
+ instrumentation$3.networkRateLimitExceeded();
495
497
  }
496
498
  const salesforceRequest = {
497
499
  networkAdapter: baseNetworkAdapter,
@@ -531,7 +533,7 @@ const RedirectDurableSegment$1 = 'REDIRECT_KEYS';
531
533
  const MessagingDurableSegment = 'MESSAGING';
532
534
  const MessageNotifyStoreUpdateAvailable = 'notifyStoreUpdateAvailable';
533
535
 
534
- const { keys: keys$4, create: create$4, assign: assign$4, freeze: freeze$1 } = Object;
536
+ const { keys: keys$5, create: create$5, assign: assign$4, freeze: freeze$2 } = Object;
535
537
 
536
538
  //Durable store error instrumentation key
537
539
  const DURABLE_STORE_ERROR = 'durable-store-error';
@@ -581,7 +583,7 @@ function publishDurableStoreEntries(durableRecords, put, publishMetadata) {
581
583
  if (durableRecords === undefined) {
582
584
  return { revivedKeys, hadUnexpectedShape };
583
585
  }
584
- const durableKeys = keys$4(durableRecords);
586
+ const durableKeys = keys$5(durableRecords);
585
587
  if (durableKeys.length === 0) {
586
588
  // no records to revive
587
589
  return { revivedKeys, hadUnexpectedShape };
@@ -766,7 +768,7 @@ class DurableTTLStore {
766
768
  overrides,
767
769
  };
768
770
  }
769
- const keys$1 = keys$4(entries);
771
+ const keys$1 = keys$5(entries);
770
772
  for (let i = 0, len = keys$1.length; i < len; i++) {
771
773
  const key = keys$1[i];
772
774
  const entry = entries[key];
@@ -788,14 +790,14 @@ class DurableTTLStore {
788
790
  }
789
791
 
790
792
  function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStoreErrorHandler, redirects, shouldFlush, additionalDurableStoreOperations = [], enableDurableMetadataRefresh = false) {
791
- const durableRecords = create$4(null);
792
- const refreshedDurableRecords = create$4(null);
793
- const evictedRecords = create$4(null);
793
+ const durableRecords = create$5(null);
794
+ const refreshedDurableRecords = create$5(null);
795
+ const evictedRecords = create$5(null);
794
796
  const { visitedIds, refreshedIds } = store.fallbackStringKeyInMemoryStore;
795
797
  // TODO: W-8909393 Once metadata is stored in its own segment we need to
796
798
  // call setEntries for the visitedIds on default segment and call setEntries
797
799
  // on the metadata segment for the refreshedIds
798
- const keys$1 = keys$4({ ...visitedIds, ...refreshedIds });
800
+ const keys$1 = keys$5({ ...visitedIds, ...refreshedIds });
799
801
  for (let i = 0, len = keys$1.length; i < len; i += 1) {
800
802
  const key = keys$1[i];
801
803
  const canonicalKey = store.getCanonicalRecordId(key);
@@ -827,7 +829,7 @@ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStor
827
829
  }
828
830
  }
829
831
  const durableStoreOperations = additionalDurableStoreOperations;
830
- const recordKeys = keys$4(durableRecords);
832
+ const recordKeys = keys$5(durableRecords);
831
833
  if (recordKeys.length > 0) {
832
834
  // publishes with data
833
835
  durableStoreOperations.push({
@@ -836,7 +838,7 @@ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStor
836
838
  segment: DefaultDurableSegment,
837
839
  });
838
840
  }
839
- const refreshKeys = keys$4(refreshedDurableRecords);
841
+ const refreshKeys = keys$5(refreshedDurableRecords);
840
842
  if (refreshKeys.length > 0) {
841
843
  // publishes with only metadata updates
842
844
  durableStoreOperations.push({
@@ -858,7 +860,7 @@ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStor
858
860
  });
859
861
  });
860
862
  // evicts
861
- const evictedKeys = keys$4(evictedRecords);
863
+ const evictedKeys = keys$5(evictedRecords);
862
864
  if (evictedKeys.length > 0) {
863
865
  durableStoreOperations.push({
864
866
  type: 'evictEntries',
@@ -962,7 +964,7 @@ function buildRevivingStagingStore(upstreamStore) {
962
964
  // A reviving store is only "active" during a call to `environment.storeLookup`, and will
963
965
  // be used by the reader attempting to build an L1 snapshot. Immediately after the L1 rebuild
964
966
  // the reviving store becomes inactive other than receiving change notifications.
965
- return create$4(upstreamStore, {
967
+ return create$5(upstreamStore, {
966
968
  readEntry: { value: readEntry },
967
969
  markStale: { value: markStale },
968
970
  clearStale: { value: clearStale },
@@ -974,7 +976,7 @@ const AdapterContextSegment = 'ADAPTER-CONTEXT';
974
976
  const ADAPTER_CONTEXT_ID_SUFFIX = '__NAMED_CONTEXT';
975
977
  async function reviveOrCreateContext(adapterId, durableStore, durableStoreErrorHandler, contextStores, pendingContextStoreKeys, onContextLoaded) {
976
978
  // initialize empty context store
977
- contextStores[adapterId] = create$4(null);
979
+ contextStores[adapterId] = create$5(null);
978
980
  const context = {
979
981
  set(key, value) {
980
982
  contextStores[adapterId][key] = value;
@@ -1039,7 +1041,7 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1039
1041
  const revivingStores = new Set();
1040
1042
  // redirects that need to be flushed to the durable store
1041
1043
  const pendingStoreRedirects = new Map();
1042
- const contextStores = create$4(null);
1044
+ const contextStores = create$5(null);
1043
1045
  let initializationPromise = new Promise((resolve) => {
1044
1046
  const finish = () => {
1045
1047
  resolve();
@@ -1116,7 +1118,7 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1116
1118
  try {
1117
1119
  const entries = await durableStore.getEntries(adapterContextKeysFromDifferentInstance, AdapterContextSegment);
1118
1120
  if (entries !== undefined) {
1119
- const entryKeys = keys$4(entries);
1121
+ const entryKeys = keys$5(entries);
1120
1122
  for (let i = 0, len = entryKeys.length; i < len; i++) {
1121
1123
  const entryKey = entryKeys[i];
1122
1124
  const entry = entries[entryKey];
@@ -1151,7 +1153,7 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1151
1153
  if (filteredKeys.length > 0) {
1152
1154
  const entries = await durableStore.getMetadata(filteredKeys, DefaultDurableSegment);
1153
1155
  if (entries !== undefined) {
1154
- const entryKeys = keys$4(entries);
1156
+ const entryKeys = keys$5(entries);
1155
1157
  for (let i = 0, len = entryKeys.length; i < len; i++) {
1156
1158
  const entryKey = entryKeys[i];
1157
1159
  const { metadata } = entries[entryKey];
@@ -1523,7 +1525,7 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1523
1525
  validateNotDisposed();
1524
1526
  const entryKeys = keys$1.map(serializeStructuredKey);
1525
1527
  const entries = await durableStore.getEntries(entryKeys, DefaultDurableSegment);
1526
- if (entries === undefined || keys$4(entries).length === 0) {
1528
+ if (entries === undefined || keys$5(entries).length === 0) {
1527
1529
  return environment.notifyStoreUpdateAvailable(keys$1);
1528
1530
  }
1529
1531
  const now = Date.now();
@@ -1575,7 +1577,7 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1575
1577
  const metadataKeys = keys$1.map(serializeStructuredKey);
1576
1578
  const now = Date.now();
1577
1579
  const entries = await durableStore.getMetadata(metadataKeys, DefaultDurableSegment);
1578
- if (entries === undefined || keys$4(entries).length === 0) {
1580
+ if (entries === undefined || keys$5(entries).length === 0) {
1579
1581
  return environment.expirePossibleStaleRecords(keys$1);
1580
1582
  }
1581
1583
  let metaDataChanged = false;
@@ -1601,7 +1603,7 @@ function makeDurable(environment, { durableStore, instrumentation, useRevivingSt
1601
1603
  type: 'stale-while-revalidate',
1602
1604
  staleDurationSeconds: Number.MAX_SAFE_INTEGER,
1603
1605
  });
1604
- return create$4(environment, {
1606
+ return create$5(environment, {
1605
1607
  publishStoreMetadata: { value: publishStoreMetadata },
1606
1608
  storeIngest: { value: storeIngest },
1607
1609
  storeIngestError: { value: storeIngestError },
@@ -1837,9 +1839,9 @@ var QueueOperationType;
1837
1839
  QueueOperationType["Update"] = "update";
1838
1840
  })(QueueOperationType || (QueueOperationType = {}));
1839
1841
 
1840
- const { keys: keys$3, create: create$3, assign: assign$3, values: values$2 } = Object;
1841
- const { stringify: stringify$3, parse: parse$3 } = JSON;
1842
- const { isArray: isArray$2 } = Array;
1842
+ const { keys: keys$4, create: create$4, assign: assign$3, values: values$2 } = Object;
1843
+ const { stringify: stringify$5, parse: parse$5 } = JSON;
1844
+ const { isArray: isArray$4 } = Array;
1843
1845
 
1844
1846
  class DraftSynthesisError extends Error {
1845
1847
  constructor(message, errorType) {
@@ -2414,7 +2416,7 @@ class DurableDraftQueue {
2414
2416
  return pendingAction;
2415
2417
  }
2416
2418
  async setMetadata(actionId, metadata) {
2417
- const keys$1 = keys$3(metadata);
2419
+ const keys$1 = keys$4(metadata);
2418
2420
  const compatibleKeys = keys$1.filter((key) => {
2419
2421
  const value = metadata[key];
2420
2422
  return typeof key === 'string' && typeof value === 'string';
@@ -2540,7 +2542,7 @@ class DurableDraftQueue {
2540
2542
  }
2541
2543
 
2542
2544
  function clone$1(obj) {
2543
- return parse$3(stringify$3(obj));
2545
+ return parse$5(stringify$5(obj));
2544
2546
  }
2545
2547
 
2546
2548
  const DRAFT_ACTION_KEY_JUNCTION = '__DraftAction__';
@@ -2581,7 +2583,7 @@ class DurableDraftStore {
2581
2583
  const waitForOngoingSync = this.syncPromise || Promise.resolve();
2582
2584
  return waitForOngoingSync.then(() => {
2583
2585
  const { draftStore } = this;
2584
- const keys$1 = keys$3(draftStore);
2586
+ const keys$1 = keys$4(draftStore);
2585
2587
  const actionArray = [];
2586
2588
  for (let i = 0, len = keys$1.length; i < len; i++) {
2587
2589
  const key = keys$1[i];
@@ -2606,7 +2608,7 @@ class DurableDraftStore {
2606
2608
  deleteByTag(tag) {
2607
2609
  const deleteAction = () => {
2608
2610
  const { draftStore } = this;
2609
- const keys$1 = keys$3(draftStore);
2611
+ const keys$1 = keys$4(draftStore);
2610
2612
  const durableKeys = [];
2611
2613
  for (let i = 0, len = keys$1.length; i < len; i++) {
2612
2614
  const key = keys$1[i];
@@ -2658,7 +2660,7 @@ class DurableDraftStore {
2658
2660
  return this.enqueueAction(action);
2659
2661
  }
2660
2662
  getCount() {
2661
- return keys$3(this.draftStore).length;
2663
+ return keys$4(this.draftStore).length;
2662
2664
  }
2663
2665
  /**
2664
2666
  * Runs a write operation against the draft store, if the initial
@@ -2699,7 +2701,7 @@ class DurableDraftStore {
2699
2701
  return this.runQueuedOperations();
2700
2702
  }
2701
2703
  const { draftStore } = this;
2702
- const keys$1 = keys$3(durableEntries);
2704
+ const keys$1 = keys$4(durableEntries);
2703
2705
  for (let i = 0, len = keys$1.length; i < len; i++) {
2704
2706
  const entry = durableEntries[keys$1[i]];
2705
2707
  const action = entry.data;
@@ -2955,7 +2957,7 @@ class DraftManager {
2955
2957
  return this.buildDraftQueueItem(action);
2956
2958
  }
2957
2959
  isValidFieldMap(fields) {
2958
- const keys$1 = keys$3(fields);
2960
+ const keys$1 = keys$4(fields);
2959
2961
  const validTypes = ['string', 'number', 'boolean'];
2960
2962
  for (let i = 0; i < keys$1.length; i++) {
2961
2963
  const key = keys$1[i];
@@ -3006,8 +3008,8 @@ class DraftManager {
3006
3008
  if (isDraftError(action)) {
3007
3009
  // We should always return an array, if the body is just a dictionary,
3008
3010
  // stick it in an array
3009
- const body = isArray$2(action.error.body) ? action.error.body : [action.error.body];
3010
- const bodyString = stringify$3(body);
3011
+ const body = isArray$4(action.error.body) ? action.error.body : [action.error.body];
3012
+ const bodyString = stringify$5(body);
3011
3013
  item.error = {
3012
3014
  status: action.error.status || 0,
3013
3015
  ok: action.error.ok || false,
@@ -3160,7 +3162,7 @@ const snapshotRefreshOptions = {
3160
3162
  * @param data Data to be JSON-stringified.
3161
3163
  * @returns JSON.stringified value with consistent ordering of keys.
3162
3164
  */
3163
- function stableJSONStringify(node) {
3165
+ function stableJSONStringify$1(node) {
3164
3166
  // This is for Date values.
3165
3167
  if (node && node.toJSON && typeof node.toJSON === 'function') {
3166
3168
  // eslint-disable-next-line no-param-reassign
@@ -3183,7 +3185,7 @@ function stableJSONStringify(node) {
3183
3185
  if (i) {
3184
3186
  out += ',';
3185
3187
  }
3186
- out += stableJSONStringify(node[i]) || 'null';
3188
+ out += stableJSONStringify$1(node[i]) || 'null';
3187
3189
  }
3188
3190
  return out + ']';
3189
3191
  }
@@ -3194,7 +3196,7 @@ function stableJSONStringify(node) {
3194
3196
  out = '';
3195
3197
  for (i = 0; i < keys.length; i++) {
3196
3198
  const key = keys[i];
3197
- const value = stableJSONStringify(node[key]);
3199
+ const value = stableJSONStringify$1(node[key]);
3198
3200
  if (!value) {
3199
3201
  continue;
3200
3202
  }
@@ -3249,12 +3251,12 @@ function buildAdapterValidationConfig(displayName, paramsMeta) {
3249
3251
  }
3250
3252
  const keyPrefix = 'UiApi';
3251
3253
 
3252
- const { assign: assign$2, create: create$2, entries: entries$2, freeze, isFrozen, keys: keys$2, values: values$1 } = Object;
3254
+ const { assign: assign$2, create: create$3, entries: entries$3, freeze: freeze$1, isFrozen, keys: keys$3, values: values$1 } = Object;
3253
3255
  const { hasOwnProperty } = Object.prototype;
3254
3256
  const { split, endsWith } = String.prototype;
3255
- const { from: from$1, isArray: isArray$1 } = Array;
3257
+ const { from: from$1, isArray: isArray$3 } = Array;
3256
3258
  const { concat, filter, includes, push: push$1, reduce, shift, slice: slice$1 } = Array.prototype;
3257
- const { parse: parse$2, stringify: stringify$2 } = JSON;
3259
+ const { parse: parse$4, stringify: stringify$4 } = JSON;
3258
3260
 
3259
3261
  function isString(value) {
3260
3262
  return typeof value === 'string';
@@ -3278,7 +3280,7 @@ function dedupe(value) {
3278
3280
  for (let i = 0, len = value.length; i < len; i += 1) {
3279
3281
  result[value[i]] = true;
3280
3282
  }
3281
- return keys$2(result);
3283
+ return keys$3(result);
3282
3284
  }
3283
3285
  /**
3284
3286
  * @param source The array of string to filter
@@ -3411,7 +3413,7 @@ function getFieldApiName(value, onlyQualifiedFieldNames = false) {
3411
3413
  * @returns The field API name.
3412
3414
  */
3413
3415
  function getFieldApiNamesArray(value, options = { onlyQualifiedFieldNames: false }) {
3414
- const valueArray = isArray$1(value) ? value : [value];
3416
+ const valueArray = isArray$3(value) ? value : [value];
3415
3417
  const array = [];
3416
3418
  for (let i = 0, len = valueArray.length; i < len; i += 1) {
3417
3419
  const item = valueArray[i];
@@ -5236,7 +5238,7 @@ function getRecordId18(value) {
5236
5238
  }
5237
5239
 
5238
5240
  function toSortedStringArray(value) {
5239
- const valueArray = isArray$1(value) ? value : [value];
5241
+ const valueArray = isArray$3(value) ? value : [value];
5240
5242
  if (valueArray.length !== 0 && isArrayOfNonEmptyStrings(valueArray)) {
5241
5243
  return dedupe(valueArray).sort();
5242
5244
  }
@@ -5361,14 +5363,14 @@ const getTypeCacheKeys$1u = (rootKeySet, luvio, input, _fullPathFactory) => {
5361
5363
  mergeable: true,
5362
5364
  });
5363
5365
  const input_childRelationships = input.childRelationships;
5364
- const input_childRelationships_keys = keys$2(input_childRelationships);
5366
+ const input_childRelationships_keys = keys$3(input_childRelationships);
5365
5367
  const input_childRelationships_length = input_childRelationships_keys.length;
5366
5368
  for (let i = 0; i < input_childRelationships_length; i++) {
5367
5369
  const key = input_childRelationships_keys[i];
5368
5370
  getTypeCacheKeys$1t(rootKeySet, luvio, input_childRelationships[key], () => rootKey + '__childRelationships' + '__' + key);
5369
5371
  }
5370
5372
  const input_fields = input.fields;
5371
- const field_values = keys$2(input_fields);
5373
+ const field_values = keys$3(input_fields);
5372
5374
  const input_fields_length = field_values.length;
5373
5375
  for (let i = 0; i < input_fields_length; i++) {
5374
5376
  const field_value = input_fields[field_values[i]];
@@ -5943,7 +5945,7 @@ function convertRecordFieldsArrayToTrie(fields, optionalFields = []) {
5943
5945
  function createPathSelection(propertyName, fieldDefinition) {
5944
5946
  const fieldsSelection = [];
5945
5947
  const { children } = fieldDefinition;
5946
- const childrenKeys = keys$2(children);
5948
+ const childrenKeys = keys$3(children);
5947
5949
  for (let i = 0, len = childrenKeys.length; i < len; i += 1) {
5948
5950
  const childKey = childrenKeys[i];
5949
5951
  const childFieldDefinition = children[childKey];
@@ -5994,7 +5996,7 @@ function createPathSelection(propertyName, fieldDefinition) {
5994
5996
  */
5995
5997
  function createPathSelectionFromValue(fields) {
5996
5998
  const fieldsSelections = [];
5997
- const fieldNames = keys$2(fields);
5999
+ const fieldNames = keys$3(fields);
5998
6000
  for (let i = 0, len = fieldNames.length; i < len; i++) {
5999
6001
  const fieldName = fieldNames[i];
6000
6002
  const { value: fieldValue } = fields[fieldName];
@@ -6039,7 +6041,7 @@ function createPathSelectionFromValue(fields) {
6039
6041
  }
6040
6042
  function extractRecordFieldsRecursively(record) {
6041
6043
  const fields = [];
6042
- const fieldNames = keys$2(record.fields);
6044
+ const fieldNames = keys$3(record.fields);
6043
6045
  for (let i = 0, len = fieldNames.length; i < len; i++) {
6044
6046
  const fieldName = fieldNames[i];
6045
6047
  const { value: fieldValue } = record.fields[fieldName];
@@ -6619,7 +6621,7 @@ function mergePendingFields(newRecord, oldRecord) {
6619
6621
  // RecordRepresentationNormalized['fields'] to include `pending:true` property
6620
6622
  const mergedFields = { ...newRecord.fields };
6621
6623
  const merged = { ...newRecord, fields: mergedFields };
6622
- const existingFields = keys$2(oldRecord.fields);
6624
+ const existingFields = keys$3(oldRecord.fields);
6623
6625
  for (let i = 0, len = existingFields.length; i < len; i += 1) {
6624
6626
  const spanningFieldName = existingFields[i];
6625
6627
  if (newRecord.fields[spanningFieldName] === undefined) {
@@ -6736,7 +6738,7 @@ function merge$1(existing, incoming, luvio, _path, recordConflictMap) {
6736
6738
  if (isGraphNode(node)) {
6737
6739
  const dependencies = node.retrieve();
6738
6740
  if (dependencies !== null) {
6739
- const depKeys = keys$2(dependencies);
6741
+ const depKeys = keys$3(dependencies);
6740
6742
  for (let i = 0, len = depKeys.length; i < len; i++) {
6741
6743
  luvio.storeEvict(depKeys[i]);
6742
6744
  }
@@ -6894,7 +6896,7 @@ fieldNode) {
6894
6896
  }
6895
6897
  for (let i = 0; i < fieldSubtries.length; i++) {
6896
6898
  const subtrie = fieldSubtries[i];
6897
- const fieldNames = keys$2(subtrie.children);
6899
+ const fieldNames = keys$3(subtrie.children);
6898
6900
  for (let i = 0; i < fieldNames.length; i++) {
6899
6901
  const fieldName = fieldNames[i];
6900
6902
  const childTrie = subtrie.children[fieldName];
@@ -7016,13 +7018,13 @@ function isExternalLookupFieldKey(spanningNode) {
7016
7018
  return endsWith.call(spanningNode.scalar('apiName'), CUSTOM_EXTERNAL_OBJECT_FIELD_SUFFIX);
7017
7019
  }
7018
7020
  function convertTrieToFields(root) {
7019
- if (keys$2(root.children).length === 0) {
7021
+ if (keys$3(root.children).length === 0) {
7020
7022
  return [];
7021
7023
  }
7022
7024
  return convertTrieToFieldsRecursively(root);
7023
7025
  }
7024
7026
  function convertTrieToFieldsRecursively(root) {
7025
- const childKeys = keys$2(root.children);
7027
+ const childKeys = keys$3(root.children);
7026
7028
  if (childKeys.length === 0) {
7027
7029
  if (root.name === '') {
7028
7030
  return [];
@@ -7031,7 +7033,7 @@ function convertTrieToFieldsRecursively(root) {
7031
7033
  }
7032
7034
  return reduce.call(childKeys, (acc, cur) => concat.call(acc, convertTrieToFieldsRecursively(root.children[cur]).map((i) => `${root.name}.${i}`)), []);
7033
7035
  }
7034
- const BLANK_RECORD_FIELDS_TRIE = freeze({
7036
+ const BLANK_RECORD_FIELDS_TRIE = freeze$1({
7035
7037
  name: '',
7036
7038
  children: {},
7037
7039
  });
@@ -7059,7 +7061,7 @@ const getObjectNameFromField = (field) => {
7059
7061
  function mergeFieldsTries(rootA, rootB) {
7060
7062
  const rootAchildren = rootA.children;
7061
7063
  const rootBchildren = rootB.children;
7062
- const childBKeys = keys$2(rootBchildren);
7064
+ const childBKeys = keys$3(rootBchildren);
7063
7065
  for (let i = 0, len = childBKeys.length; i < len; i++) {
7064
7066
  const childBKey = childBKeys[i];
7065
7067
  if (rootAchildren[childBKey] === undefined) {
@@ -7214,8 +7216,8 @@ function isSuperRecordFieldTrie(a, b) {
7214
7216
  }
7215
7217
  const childrenA = a.children;
7216
7218
  const childrenB = b.children;
7217
- const childKeysA = keys$2(childrenA);
7218
- const childKeysB = keys$2(childrenB);
7219
+ const childKeysA = keys$3(childrenA);
7220
+ const childKeysB = keys$3(childrenB);
7219
7221
  const childKeysBLength = childKeysB.length;
7220
7222
  if (childKeysBLength > childKeysA.length) {
7221
7223
  return false;
@@ -7269,9 +7271,9 @@ function fulfill(existing, incoming) {
7269
7271
  return false;
7270
7272
  }
7271
7273
  }
7272
- const headersKeys = keys$2(headers);
7274
+ const headersKeys = keys$3(headers);
7273
7275
  const headersKeyLength = headersKeys.length;
7274
- if (headersKeyLength !== keys$2(existingHeaders).length) {
7276
+ if (headersKeyLength !== keys$3(existingHeaders).length) {
7275
7277
  return false;
7276
7278
  }
7277
7279
  for (let i = 0, len = headersKeyLength; i < len; i++) {
@@ -7288,8 +7290,8 @@ function fulfill(existing, incoming) {
7288
7290
  return isSuperset(existingFieldsUnion, incomingFieldsUnion);
7289
7291
  }
7290
7292
  function unionFields(fields, optionalFields) {
7291
- const fieldsArray = isArray$1(fields) ? fields : [];
7292
- const optionalFieldsArray = isArray$1(optionalFields) ? optionalFields : [];
7293
+ const fieldsArray = isArray$3(fields) ? fields : [];
7294
+ const optionalFieldsArray = isArray$3(optionalFields) ? optionalFields : [];
7293
7295
  return [...fieldsArray, ...optionalFieldsArray];
7294
7296
  }
7295
7297
  function getRecordIdsFromUrlParams(urlParams) {
@@ -7508,7 +7510,7 @@ function getRecordByFields(luvio, config, requestContext) {
7508
7510
  return luvio.applyCachePolicy(requestContext || {}, { config, luvio }, buildCachedSnapshotCachePolicy$d, buildNetworkSnapshotCachePolicy$e);
7509
7511
  }
7510
7512
  function isSingleBatchRecordResponse(response) {
7511
- return (isArray$1(response.results) &&
7513
+ return (isArray$3(response.results) &&
7512
7514
  response.results.length === 1);
7513
7515
  }
7514
7516
 
@@ -7924,7 +7926,7 @@ function buildNetworkSnapshot$g(luvio, config, serverRequestCount = 0, options)
7924
7926
 
7925
7927
  // iterate through the map to build configs for network calls
7926
7928
  function resolveConflict(luvio, map) {
7927
- const ids = keys$2(map.conflicts);
7929
+ const ids = keys$3(map.conflicts);
7928
7930
  if (ids.length === 0) {
7929
7931
  return;
7930
7932
  }
@@ -9617,18 +9619,18 @@ function listFields(luvio, { fields = [], optionalFields = [], sortBy, }, listIn
9617
9619
  return {
9618
9620
  getRecordSelectionFieldSets() {
9619
9621
  const optionalPlusDefaultFields = { ...optionalFields_ };
9620
- const fields = keys$2(defaultFields_);
9622
+ const fields = keys$3(defaultFields_);
9621
9623
  for (let i = 0; i < fields.length; ++i) {
9622
9624
  const field = fields[i];
9623
9625
  if (!fields_[field] && !defaultServerFieldStatus.missingFields[field]) {
9624
9626
  optionalPlusDefaultFields[field] = true;
9625
9627
  }
9626
9628
  }
9627
- return [keys$2(fields_).sort(), keys$2(optionalPlusDefaultFields).sort()];
9629
+ return [keys$3(fields_).sort(), keys$3(optionalPlusDefaultFields).sort()];
9628
9630
  },
9629
9631
  processRecords(records) {
9630
9632
  const { missingFields } = defaultServerFieldStatus;
9631
- const fields = keys$2(missingFields);
9633
+ const fields = keys$3(missingFields);
9632
9634
  for (let i = 0; i < fields.length; ++i) {
9633
9635
  const field = fields[i], splitField = field.split('.').slice(1);
9634
9636
  for (let i = 0; i < records.length; ++i) {
@@ -13985,7 +13987,7 @@ function getTypeCacheKeys$1m(rootKeySet, luvio, input, _fullPathFactory) {
13985
13987
  * @returns The object API name.
13986
13988
  */
13987
13989
  function getRecordId18Array(value) {
13988
- const valueArray = isArray$1(value) ? value : [value];
13990
+ const valueArray = isArray$3(value) ? value : [value];
13989
13991
  const array = [];
13990
13992
  for (let i = 0, len = valueArray.length; i < len; i += 1) {
13991
13993
  const item = valueArray[i];
@@ -14701,7 +14703,7 @@ function getMissingRecordLookupFields(record, objectInfo) {
14701
14703
  const lookupFields = {};
14702
14704
  const { apiName, fields: recordFields } = record;
14703
14705
  const { fields: objectInfoFields } = objectInfo;
14704
- const objectInfoFieldNames = keys$2(objectInfoFields);
14706
+ const objectInfoFieldNames = keys$3(objectInfoFields);
14705
14707
  for (let i = 0, len = objectInfoFieldNames.length; i < len; i += 1) {
14706
14708
  const fieldName = objectInfoFieldNames[i];
14707
14709
  const field = objectInfoFields[fieldName];
@@ -14720,12 +14722,12 @@ function getMissingRecordLookupFields(record, objectInfo) {
14720
14722
  const nameField = `${apiName}.${relationshipName}.${getNameField(objectInfo, fieldName)}`;
14721
14723
  lookupFields[nameField] = true;
14722
14724
  }
14723
- return keys$2(lookupFields);
14725
+ return keys$3(lookupFields);
14724
14726
  }
14725
14727
  function getRecordUiMissingRecordLookupFields(recordUi) {
14726
14728
  const { records, objectInfos } = recordUi;
14727
14729
  const recordLookupFields = {};
14728
- const recordIds = keys$2(records);
14730
+ const recordIds = keys$3(records);
14729
14731
  for (let i = 0, len = recordIds.length; i < len; i += 1) {
14730
14732
  const recordId = recordIds[i];
14731
14733
  const recordData = records[recordId];
@@ -14763,19 +14765,19 @@ function buildCachedSelectorKey(key) {
14763
14765
  }
14764
14766
  function eachLayout(recordUi, cb) {
14765
14767
  const { layouts } = recordUi;
14766
- const layoutApiNames = keys$2(layouts);
14768
+ const layoutApiNames = keys$3(layouts);
14767
14769
  for (let a = 0, len = layoutApiNames.length; a < len; a += 1) {
14768
14770
  const apiName = layoutApiNames[a];
14769
14771
  const apiNameData = layouts[apiName];
14770
- const recordTypeIds = keys$2(apiNameData);
14772
+ const recordTypeIds = keys$3(apiNameData);
14771
14773
  for (let b = 0, recordTypeIdsLen = recordTypeIds.length; b < recordTypeIdsLen; b += 1) {
14772
14774
  const recordTypeId = recordTypeIds[b];
14773
14775
  const recordTypeData = apiNameData[recordTypeId];
14774
- const layoutTypes = keys$2(recordTypeData);
14776
+ const layoutTypes = keys$3(recordTypeData);
14775
14777
  for (let c = 0, layoutTypesLen = layoutTypes.length; c < layoutTypesLen; c += 1) {
14776
14778
  const layoutType = layoutTypes[c];
14777
14779
  const layoutTypeData = recordTypeData[layoutType];
14778
- const modes = keys$2(layoutTypeData);
14780
+ const modes = keys$3(layoutTypeData);
14779
14781
  for (let d = 0, modesLen = modes.length; d < modesLen; d += 1) {
14780
14782
  const mode = modes[d];
14781
14783
  const layout = layoutTypeData[mode];
@@ -14851,7 +14853,7 @@ function prepareRequest$3(luvio, config) {
14851
14853
  // we have to run ingest code and look at the resulting snapshot's seenRecords.
14852
14854
  function getCacheKeys(keySet, luvio, config, key, originalResponseBody) {
14853
14855
  const { recordIds, layoutTypes, modes } = config;
14854
- const responseBody = parse$2(stringify$2(originalResponseBody));
14856
+ const responseBody = parse$4(stringify$4(originalResponseBody));
14855
14857
  eachLayout(responseBody, (apiName, recordTypeId, layout) => {
14856
14858
  if (layout.id === null) {
14857
14859
  return;
@@ -14981,7 +14983,7 @@ function buildNetworkSnapshot$e(luvio, config, dispatchContext) {
14981
14983
  function publishDependencies(luvio, recordIds, depKeys) {
14982
14984
  for (let i = 0, len = recordIds.length; i < len; i += 1) {
14983
14985
  const recordDepKey = dependencyKeyBuilder({ recordId: recordIds[i] });
14984
- const dependencies = create$2(null);
14986
+ const dependencies = create$3(null);
14985
14987
  for (let j = 0, len = depKeys.length; j < len; j++) {
14986
14988
  dependencies[depKeys[j]] = true;
14987
14989
  }
@@ -15106,7 +15108,7 @@ function refresh(luvio, config) {
15106
15108
  }
15107
15109
  if (isUnfulfilledSnapshot$1(snapshot)) {
15108
15110
  if (process.env.NODE_ENV !== 'production') {
15109
- throw new Error(`RecordUi adapter resolved with a snapshot with missing data, missingPaths: ${keys$2(snapshot.missingPaths)}`);
15111
+ throw new Error(`RecordUi adapter resolved with a snapshot with missing data, missingPaths: ${keys$3(snapshot.missingPaths)}`);
15110
15112
  }
15111
15113
  }
15112
15114
  const { data } = snapshot;
@@ -15153,7 +15155,7 @@ function processRecordUiRepresentation(luvio, refresh, recordId, modes, snapshot
15153
15155
  }
15154
15156
  if (isUnfulfilledSnapshot$1(snapshot)) {
15155
15157
  if (process.env.NODE_ENV !== 'production') {
15156
- throw new Error(`RecordUi adapter resolved with a snapshot with missing data, missingPaths: ${keys$2(snapshot.missingPaths)}`);
15158
+ throw new Error(`RecordUi adapter resolved with a snapshot with missing data, missingPaths: ${keys$3(snapshot.missingPaths)}`);
15157
15159
  }
15158
15160
  }
15159
15161
  const { data } = snapshot;
@@ -15182,11 +15184,11 @@ const recordLayoutFragmentSelector = [
15182
15184
  function getFieldsFromLayoutMap(layoutMap, objectInfo) {
15183
15185
  let fields = [];
15184
15186
  let optionalFields = [];
15185
- const layoutTypes = keys$2(layoutMap);
15187
+ const layoutTypes = keys$3(layoutMap);
15186
15188
  for (let i = 0, layoutTypesLen = layoutTypes.length; i < layoutTypesLen; i += 1) {
15187
15189
  const layoutType = layoutTypes[i];
15188
15190
  const modesMap = layoutMap[layoutType];
15189
- const modes = keys$2(modesMap);
15191
+ const modes = keys$3(modesMap);
15190
15192
  for (let m = 0, modesLen = modes.length; m < modesLen; m += 1) {
15191
15193
  const mode = modes[m];
15192
15194
  const { fields: modeFields, optionalFields: modeOptionalFields } = getQualifiedFieldApiNamesFromLayout(modesMap[mode], objectInfo);
@@ -15222,7 +15224,7 @@ function getRecordForLayoutableEntities(luvio, refresh, recordId, layoutMap, obj
15222
15224
  return getRecord(luvio, refresh, recordId, [], implicitFields);
15223
15225
  }
15224
15226
  function getRecordForNonLayoutableEntities(luvio, adapterContext, refresh, recordId, objectInfo, configOptionalFields, configFields) {
15225
- const fields = keys$2(configFields ? configFields : {}).map((key) => `${objectInfo.apiName}.${key}`);
15227
+ const fields = keys$3(configFields ? configFields : {}).map((key) => `${objectInfo.apiName}.${key}`);
15226
15228
  // W-12697744
15227
15229
  // Set the implicit fields received from the server in adapter context
15228
15230
  // This ensures that the implicit fields are available when data is read locally or from durable store
@@ -40437,7 +40439,7 @@ function ingestTypeWithStrategy(astNode, state, isCursorConnectionType, { key, i
40437
40439
  }
40438
40440
  if (existingData !== undefined && existingData !== null && ObjectPrototypeHasOwnProperty$1.call(existingData, "__type") === false) {
40439
40441
  const mergedData = mergeData(existingData, newData);
40440
- if (!equalsObject(existingData, mergedData, (propA, propB) => stableJSONStringify(propA) === stableJSONStringify(propB))) { // naive impl
40442
+ if (!equalsObject(existingData, mergedData, (propA, propB) => stableJSONStringify$1(propA) === stableJSONStringify$1(propB))) { // naive impl
40441
40443
  luvio.storePublish(key, mergedData);
40442
40444
  }
40443
40445
  }
@@ -41487,7 +41489,7 @@ function getRecordKeyForId(luvio, recordId) {
41487
41489
  */
41488
41490
  function filterOutReferenceNonScalarFields(record) {
41489
41491
  const filteredFields = {};
41490
- const fieldNames = keys$2(record.fields);
41492
+ const fieldNames = keys$3(record.fields);
41491
41493
  for (const fieldName of fieldNames) {
41492
41494
  const field = record.fields[fieldName];
41493
41495
  if (isFieldLink(field) === false && isPendingOrMissing(field) === false) {
@@ -41593,7 +41595,7 @@ function getRecordDraftEnvironment(luvio, env, { isDraftId, durableRecordStore }
41593
41595
  const resolvedRequest = resolveResourceRequestIds(luvio, resourceRequest, canonicalKey);
41594
41596
  return env.dispatchResourceRequest(resolvedRequest, context, eventObservers);
41595
41597
  };
41596
- return create$2(env, {
41598
+ return create$3(env, {
41597
41599
  dispatchResourceRequest: { value: dispatchResourceRequest },
41598
41600
  });
41599
41601
  }
@@ -41613,7 +41615,7 @@ function isRequestForGetRecords(request) {
41613
41615
  */
41614
41616
  function extractRecordIdsFromResourceRequest(request) {
41615
41617
  const ids = request.urlParams['recordIds'];
41616
- if (isArray$1(ids) === false) {
41618
+ if (isArray$3(ids) === false) {
41617
41619
  return undefined;
41618
41620
  }
41619
41621
  return ids;
@@ -41771,7 +41773,7 @@ function getRecordsDraftEnvironment(luvio, env, { isDraftId }) {
41771
41773
  return applyDraftsToBatchResponse(resourceRequest, response, removedDraftIds);
41772
41774
  }));
41773
41775
  };
41774
- return create$2(env, {
41776
+ return create$3(env, {
41775
41777
  dispatchResourceRequest: { value: dispatchResourceRequest },
41776
41778
  });
41777
41779
  }
@@ -41781,7 +41783,7 @@ function makeEnvironmentUiApiRecordDraftAware(luvio, options, env) {
41781
41783
  const adapterSpecificEnvironments = synthesizers.reduce((environment, synthesizer) => {
41782
41784
  return synthesizer(luvio, environment, options);
41783
41785
  }, env);
41784
- return create$2(adapterSpecificEnvironments, {});
41786
+ return create$3(adapterSpecificEnvironments, {});
41785
41787
  }
41786
41788
 
41787
41789
  const HTTP_HEADER_RETRY_AFTER = 'Retry-After';
@@ -42020,7 +42022,7 @@ class AbstractResourceRequestActionHandler {
42020
42022
  let updatedActionTargetId = undefined;
42021
42023
  const { tag: queueActionTag, data: queueActionRequest, id: queueActionId, } = queueAction;
42022
42024
  let { basePath, body } = queueActionRequest;
42023
- let stringifiedBody = stringify$2(body);
42025
+ let stringifiedBody = stringify$4(body);
42024
42026
  // for each redirected ID/key we loop over the operation to see if it needs
42025
42027
  // to be updated
42026
42028
  for (const { draftId, draftKey, canonicalId, canonicalKey } of redirects) {
@@ -42045,7 +42047,7 @@ class AbstractResourceRequestActionHandler {
42045
42047
  data: {
42046
42048
  ...queueActionRequest,
42047
42049
  basePath: basePath,
42048
- body: parse$2(stringifiedBody),
42050
+ body: parse$4(stringifiedBody),
42049
42051
  },
42050
42052
  };
42051
42053
  // item needs to be replaced with a new item at the new record key
@@ -42064,7 +42066,7 @@ class AbstractResourceRequestActionHandler {
42064
42066
  data: {
42065
42067
  ...queueActionRequest,
42066
42068
  basePath: basePath,
42067
- body: parse$2(stringifiedBody),
42069
+ body: parse$4(stringifiedBody),
42068
42070
  },
42069
42071
  };
42070
42072
  // item needs to be updated
@@ -42182,14 +42184,14 @@ class AbstractResourceRequestActionHandler {
42182
42184
  }
42183
42185
  // checks if the body is an array of UiApiError. Sometimes the body has `enhancedErrorType` field as an error indicator(one example is the field validation failure). In such case Action being processed updates to an Error Action.
42184
42186
  isUiApiErrors(body) {
42185
- return body !== undefined && isArray$1(body) && body.length > 0 && body[0].errorCode;
42187
+ return body !== undefined && isArray$3(body) && body.length > 0 && body[0].errorCode;
42186
42188
  }
42187
42189
  isBackdatingError(body, action) {
42188
42190
  if (body.enhancedErrorType &&
42189
42191
  body.enhancedErrorType === 'RecordError' &&
42190
42192
  body.output &&
42191
42193
  body.output.errors &&
42192
- isArray$1(body.output.errors) &&
42194
+ isArray$3(body.output.errors) &&
42193
42195
  body.output.errors.length > 0 &&
42194
42196
  action.data.body &&
42195
42197
  action.data.body.fields &&
@@ -42337,7 +42339,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
42337
42339
  pendingAction.data.method !== 'delete' && //'delete' action does not have fields
42338
42340
  objectInfo) {
42339
42341
  const appendedFields = this.getBackdatingFields(objectInfo, resolvedRequest.method, pendingAction);
42340
- if (keys$2(appendedFields).length > 0) {
42342
+ if (keys$3(appendedFields).length > 0) {
42341
42343
  pendingAction.data.body = {
42342
42344
  ...pendingAction.data.body,
42343
42345
  fields: {
@@ -42351,7 +42353,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
42351
42353
  }
42352
42354
  getBackdatingFields(objectInfo, requestMethod, pendingAction) {
42353
42355
  const fields = {};
42354
- const actionFieldNames = keys$2(pendingAction.data.body.fields);
42356
+ const actionFieldNames = keys$3(pendingAction.data.body.fields);
42355
42357
  if (requestMethod === 'post') {
42356
42358
  // `CreateRecord` with `CreatedDate` field
42357
42359
  if (isBackdatingFieldEditable(objectInfo, DEFAULT_FIELD_CREATED_DATE$1, 'createable', actionFieldNames)) {
@@ -42502,7 +42504,7 @@ class UiApiActionHandler extends AbstractResourceRequestActionHandler {
42502
42504
  let resolvedUrlParams = request.urlParams;
42503
42505
  if (request.method === 'post' || request.method === 'patch') {
42504
42506
  const bodyFields = resolvedBody.fields;
42505
- const fieldNames = keys$2(bodyFields);
42507
+ const fieldNames = keys$3(bodyFields);
42506
42508
  for (let i = 0, len = fieldNames.length; i < len; i++) {
42507
42509
  const fieldName = fieldNames[i];
42508
42510
  const fieldValue = bodyFields[fieldName];
@@ -42658,7 +42660,7 @@ class UiApiDraftRecordService {
42658
42660
  };
42659
42661
  }
42660
42662
  const referenceFields = [];
42661
- const fieldNames = keys$2(fields);
42663
+ const fieldNames = keys$3(fields);
42662
42664
  const unexpectedFields = [];
42663
42665
  for (const field of fieldNames) {
42664
42666
  const fieldInfo = objectInfo.fields[field];
@@ -42738,7 +42740,7 @@ class AbstractQuickActionHandler extends AbstractResourceRequestActionHandler {
42738
42740
  }
42739
42741
  }
42740
42742
  }
42741
- for (const field of keys$2(body.fields)) {
42743
+ for (const field of keys$3(body.fields)) {
42742
42744
  const fieldValue = body.fields[field];
42743
42745
  if (typeof fieldValue === 'string' && this.isDraftId(fieldValue)) {
42744
42746
  const draftKey = getRecordKeyForId(this.getLuvio(), fieldValue);
@@ -42754,6 +42756,211 @@ class AbstractQuickActionHandler extends AbstractResourceRequestActionHandler {
42754
42756
  }
42755
42757
  }
42756
42758
 
42759
+ function attachObserversToAdapterRequestContext(observers, adapterRequestContext) {
42760
+ if (adapterRequestContext === undefined) {
42761
+ return { eventObservers: observers };
42762
+ }
42763
+ if (adapterRequestContext.eventObservers === undefined) {
42764
+ return { ...adapterRequestContext, eventObservers: observers };
42765
+ }
42766
+ return {
42767
+ ...adapterRequestContext,
42768
+ eventObservers: adapterRequestContext.eventObservers.concat(observers),
42769
+ };
42770
+ }
42771
+ /**
42772
+ * Use this method to sanitize the unknown error object when
42773
+ * we are unsure of the type of the error thrown
42774
+ *
42775
+ * @param err Unknown object to sanitize
42776
+ * @returns an instance of error
42777
+ */
42778
+ function normalizeError(err) {
42779
+ if (err instanceof Error) {
42780
+ return err;
42781
+ }
42782
+ else if (typeof err === 'string') {
42783
+ return new Error(err);
42784
+ }
42785
+ return new Error(stringify$4(err));
42786
+ }
42787
+
42788
+ const O11Y_NAMESPACE_LDS_MOBILE = 'lds-mobile';
42789
+ // metrics
42790
+ /** GraphQL */
42791
+ const GRAPHQL_EVAL_ERROR = 'gql-eval-error';
42792
+ const GRAPHQL_EVAL_DB_READ_DURATION = 'gql-eval-db-read-duration';
42793
+ const GRAPHQL_EVAL_ROOT_QUERY_COUNT = 'gql-eval-root-query-count';
42794
+ const GRAPHQL_EVAL_TOTAL_QUERY_COUNT = 'gql-eval-total-query-count';
42795
+ const GRAPHQL_EVAL_MAX_CHILD_RELATIONSHIPS_COUNT = 'gql-eval-max-child-count';
42796
+ const GRAPHQL_EVAL_QUERY_RECORD_COUNT = 'gql-eval-query-record-count';
42797
+ const GRAPHQL_SNAPSHOT_REFRESH_UNDEFINED = 'gql-snapshot-refresh-undefined';
42798
+ /** Draft Queue */
42799
+ const DRAFT_QUEUE_STATE_STARTED = 'draft-queue-state-started';
42800
+ const DRAFT_QUEUE_STATE_ERROR = 'draft-queue-state-error';
42801
+ const DRAFT_QUEUE_STATE_WAITING = 'draft-queue-state-waiting';
42802
+ const DRAFT_QUEUE_STATE_STOPPED = 'draft-queue-state-stopped';
42803
+ const DRAFT_QUEUE_ACTION_ADDED = 'draft-queue-action-added';
42804
+ const DRAFT_QUEUE_ACTION_UPLOADING = 'draft-queue-action-uploading';
42805
+ const DRAFT_QUEUE_ACTION_COMPLETED = 'draft-queue-action-completed';
42806
+ const DRAFT_QUEUE_ACTION_DELETED = 'draft-queue-action-deleted';
42807
+ const DRAFT_QUEUE_ACTION_UPDATED = 'draft-queue-action-updated';
42808
+ const DRAFT_QUEUE_ACTION_FAILED = 'draft-queue-action-failed';
42809
+ const DRAFT_QUEUE_TOTAL_MERGE_ACTIONS_CALLS = 'draft-queue-total-mergeActions-calls';
42810
+ /** Content Document */
42811
+ const CREATE_CONTENT_DOCUMENT_AND_VERSION_TOTAL_SYNTHESIZE_CALLS = 'content-document-version-total-synthesize-calls';
42812
+ const CREATE_CONTENT_DOCUMENT_AND_VERSION_DRAFT_SYNTHESIZE_ERROR = 'create-content-document-version-draft-synthesize-error';
42813
+ /** Priming */
42814
+ const PRIMING_TOTAL_SESSION_COUNT = 'priming-total-session-count';
42815
+ const PRIMING_TOTAL_ERROR_COUNT = 'priming-total-error-count';
42816
+ const PRIMING_TOTAL_PRIMED_COUNT = 'priming-total-primed-count';
42817
+ const PRIMING_TOTAL_CONFLICT_COUNT = 'priming-total-conflict-count';
42818
+ // logs
42819
+ const GRAPHQL_QUERY_PARSE_ERROR = 'gql-query-parse-error';
42820
+ const GRAPHQL_SQL_EVAL_PRECONDITION_ERROR = 'gql-sql-pre-eval-error';
42821
+ const GRAPHQL_CREATE_SNAPSHOT_ERROR = 'gql-create-snapshot-error';
42822
+ const DRAFT_AWARE_CREATE_CONTENT_DOCUMENT_AND_VERSION_ERROR = 'draft-aware-create-content-document-and-version-error';
42823
+ const ldsMobileInstrumentation = getInstrumentation(O11Y_NAMESPACE_LDS_MOBILE);
42824
+ const nimbusLogger = typeof __nimbus !== 'undefined' &&
42825
+ __nimbus.plugins !== undefined &&
42826
+ __nimbus.plugins.JSLoggerPlugin !== undefined
42827
+ ? __nimbus.plugins.JSLoggerPlugin
42828
+ : undefined;
42829
+ function reportGraphqlQueryParseError(err) {
42830
+ const error = normalizeError(err);
42831
+ const errorCode = GRAPHQL_QUERY_PARSE_ERROR;
42832
+ // Metric
42833
+ reportGraphqlAdapterError(errorCode);
42834
+ // Log
42835
+ ldsMobileInstrumentation.error(error, errorCode);
42836
+ }
42837
+ function reportGraphqlSqlEvalPreconditionError(err) {
42838
+ const error = normalizeError(err);
42839
+ const errorCode = GRAPHQL_SQL_EVAL_PRECONDITION_ERROR;
42840
+ // Metric
42841
+ reportGraphqlAdapterError(errorCode);
42842
+ // Log
42843
+ ldsMobileInstrumentation.error(error, errorCode);
42844
+ }
42845
+ function reportGraphqlCreateSnapshotError(err) {
42846
+ const error = normalizeError(err);
42847
+ const errorCode = GRAPHQL_CREATE_SNAPSHOT_ERROR;
42848
+ // Metric
42849
+ reportGraphqlAdapterError(errorCode);
42850
+ // Log
42851
+ ldsMobileInstrumentation.error(error, errorCode);
42852
+ }
42853
+ function reportGraphQlEvalDbReadDuration(duration) {
42854
+ ldsMobileInstrumentation.trackValue(GRAPHQL_EVAL_DB_READ_DURATION, duration);
42855
+ }
42856
+ function reportGraphqlAdapterError(errorCode) {
42857
+ // Increment overall count with errorCode as tag
42858
+ ldsMobileInstrumentation.incrementCounter(GRAPHQL_EVAL_ERROR, 1, true, { errorCode });
42859
+ }
42860
+ function reportGraphqlQueryInstrumentation(data) {
42861
+ const queryBuckets = [1, 2, 3, 4, 5, 10, 20, 50, 100];
42862
+ const recordBuckets = [
42863
+ 1, 5, 10, 20, 50, 100, 1000, 2000, 5000, 10000, 50000, 100000, 1000000,
42864
+ ];
42865
+ ldsMobileInstrumentation.bucketValue(GRAPHQL_EVAL_ROOT_QUERY_COUNT, data.rootQueryCount, queryBuckets);
42866
+ ldsMobileInstrumentation.bucketValue(GRAPHQL_EVAL_TOTAL_QUERY_COUNT, data.totalQueryCount, queryBuckets);
42867
+ ldsMobileInstrumentation.bucketValue(GRAPHQL_EVAL_MAX_CHILD_RELATIONSHIPS_COUNT, data.maxChildRelationships, queryBuckets);
42868
+ ldsMobileInstrumentation.bucketValue(GRAPHQL_EVAL_QUERY_RECORD_COUNT, data.requestedRecordCount, recordBuckets);
42869
+ }
42870
+ function incrementGraphQLRefreshUndfined() {
42871
+ ldsMobileInstrumentation.incrementCounter(GRAPHQL_SNAPSHOT_REFRESH_UNDEFINED);
42872
+ }
42873
+ function reportDraftActionEvent(state, draftCount, message) {
42874
+ if (nimbusLogger) {
42875
+ nimbusLogger.logInfo(`Draft action event: ${state}, depth: ${draftCount}${message ? `, message: ${message}` : ''}`);
42876
+ }
42877
+ switch (state) {
42878
+ case 'added':
42879
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_ADDED);
42880
+ break;
42881
+ case 'uploading':
42882
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_UPLOADING);
42883
+ break;
42884
+ case 'completed':
42885
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_COMPLETED);
42886
+ break;
42887
+ case 'deleted':
42888
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_DELETED);
42889
+ break;
42890
+ case 'failed':
42891
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_FAILED, 1, true);
42892
+ break;
42893
+ case 'updated':
42894
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_ACTION_UPDATED);
42895
+ break;
42896
+ }
42897
+ }
42898
+ function reportDraftQueueState(state, draftCount) {
42899
+ if (nimbusLogger) {
42900
+ nimbusLogger.logInfo(`Draft state changed: ${state}, depth: ${draftCount}`);
42901
+ }
42902
+ switch (state) {
42903
+ case 'started':
42904
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_STATE_STARTED);
42905
+ break;
42906
+ case 'error':
42907
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_STATE_ERROR, 1, true);
42908
+ break;
42909
+ case 'waiting':
42910
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_STATE_WAITING);
42911
+ break;
42912
+ case 'stopped':
42913
+ ldsMobileInstrumentation.incrementCounter(DRAFT_QUEUE_STATE_STOPPED);
42914
+ break;
42915
+ }
42916
+ }
42917
+ function reportDraftAwareContentDocumentVersionSynthesizeError(err) {
42918
+ let error;
42919
+ if (err.body !== undefined) {
42920
+ error = err.body;
42921
+ }
42922
+ else {
42923
+ error = normalizeError(err);
42924
+ }
42925
+ const errorCode = DRAFT_AWARE_CREATE_CONTENT_DOCUMENT_AND_VERSION_ERROR;
42926
+ const errorType = error.errorType;
42927
+ const tags = {
42928
+ errorCode,
42929
+ };
42930
+ if (errorType !== undefined) {
42931
+ tags.errorType = errorType;
42932
+ }
42933
+ // Metric
42934
+ ldsMobileInstrumentation.incrementCounter(CREATE_CONTENT_DOCUMENT_AND_VERSION_DRAFT_SYNTHESIZE_ERROR, 1, true, tags);
42935
+ // Log
42936
+ ldsMobileInstrumentation.error(error, errorCode);
42937
+ }
42938
+ function reportDraftAwareContentVersionSynthesizeCalls(mimeType) {
42939
+ ldsMobileInstrumentation.incrementCounter(CREATE_CONTENT_DOCUMENT_AND_VERSION_TOTAL_SYNTHESIZE_CALLS, 1, undefined, { mimeType });
42940
+ }
42941
+ /** Priming */
42942
+ function reportPrimingSessionCreated() {
42943
+ ldsMobileInstrumentation.incrementCounter(PRIMING_TOTAL_SESSION_COUNT, 1, undefined, {});
42944
+ }
42945
+ function reportPrimingError(errorType, recordCount) {
42946
+ ldsMobileInstrumentation.incrementCounter(PRIMING_TOTAL_ERROR_COUNT, recordCount, undefined, {
42947
+ errorType,
42948
+ });
42949
+ }
42950
+ function reportPrimingSuccess(recordCount) {
42951
+ ldsMobileInstrumentation.incrementCounter(PRIMING_TOTAL_PRIMED_COUNT, recordCount, undefined);
42952
+ }
42953
+ function reportPrimingConflict(resolutionType, recordCount) {
42954
+ ldsMobileInstrumentation.incrementCounter(PRIMING_TOTAL_CONFLICT_COUNT, recordCount, undefined, {
42955
+ resolutionType,
42956
+ });
42957
+ }
42958
+ /** Network */
42959
+ function reportChunkCandidateUrlLength(urlLength) {
42960
+ const buckets = [8000, 10000, 12000, 14000, 16000];
42961
+ ldsMobileInstrumentation.bucketValue('chunk-candidate-url-length-histogram', urlLength, buckets);
42962
+ }
42963
+
42757
42964
  const QUICK_ACTION_HANDLER = 'QUICK_ACTION_HANDLER';
42758
42965
  class QuickActionExecutionRepresentationHandler extends AbstractQuickActionHandler {
42759
42966
  constructor(getLuvio, draftRecordService, draftQueue, networkAdapter, isDraftId, sideEffectService, objectInfoService, getRecord) {
@@ -42764,6 +42971,7 @@ class QuickActionExecutionRepresentationHandler extends AbstractQuickActionHandl
42764
42971
  this.objectInfoService = objectInfoService;
42765
42972
  this.getRecord = getRecord;
42766
42973
  this.handlerId = QUICK_ACTION_HANDLER;
42974
+ this.instrumentation = getInstrumentation(O11Y_NAMESPACE_LDS_MOBILE);
42767
42975
  draftRecordService.registerRecordHandler(this);
42768
42976
  }
42769
42977
  async draftActionToSideEffects(queueEntry) {
@@ -42795,10 +43003,26 @@ class QuickActionExecutionRepresentationHandler extends AbstractQuickActionHandl
42795
43003
  luvio.storeIngest(key, ingestQuickActionExecutionRepresentation, response);
42796
43004
  }
42797
43005
  async handleActionCompleted(action, queueOperations) {
43006
+ /* performQuickAction will not return the new record itself, so before the action
43007
+ * is marked as completed, we need to fetch the actual record. This must be done before
43008
+ * the super method is called because the super method will revert the side effects that
43009
+ * were created for this action, and critically that means evicting the synthetic record
43010
+ * that was created to represent the draft of what would become the canonical record.
43011
+ * Since getRecord is a network call, it is better to have a small timeframe (on the order
43012
+ * of microseconds) where both the synthetic record and the canonical record are in the
43013
+ * store instead of the record missing from the store for the entire duration of the
43014
+ * network call.
43015
+ */
43016
+ try {
43017
+ await this.fetchRecordIntoStoreFromCompletedAction(action);
43018
+ }
43019
+ catch (error) {
43020
+ this.instrumentation.error(error, 'Error fetching the record created from performQuickAction adapter.');
43021
+ }
42798
43022
  await super.handleActionCompleted(action, queueOperations);
42799
- this.getLuvio();
43023
+ }
43024
+ async fetchRecordIntoStoreFromCompletedAction(action) {
42800
43025
  const canonicalId = action.response.body.id;
42801
- this.buildTagForTargetId(canonicalId);
42802
43026
  const prefix = canonicalId.substring(0, 3);
42803
43027
  if (prefix.length !== 3) {
42804
43028
  // if we can't get a prefix, don't do the rest
@@ -43076,7 +43300,7 @@ function createContentDocumentAndVersionDraftAdapterFactory(luvio, binaryStore,
43076
43300
  ...trimmedDownData.contentVersion,
43077
43301
  fields: cvFields,
43078
43302
  };
43079
- freeze(trimmedDownData);
43303
+ freeze$1(trimmedDownData);
43080
43304
  eventEmitter({ type: 'create-content-document-and-version-draft-finished' });
43081
43305
  return {
43082
43306
  state: 'Fulfilled',
@@ -43667,7 +43891,7 @@ function recordLoaderFactory(query) {
43667
43891
  rows.forEach((row) => {
43668
43892
  if (!row[0])
43669
43893
  return null;
43670
- const record = parse$2(row[0]);
43894
+ const record = parse$4(row[0]);
43671
43895
  if (record.id === id) {
43672
43896
  foundRow = record;
43673
43897
  }
@@ -43729,7 +43953,7 @@ function removeUndefined(array) {
43729
43953
  }
43730
43954
  // We won't need this when we enable ES2019+ support
43731
43955
  function flat(arr, d = 1) {
43732
- if (!isArray$1(arr)) {
43956
+ if (!isArray$3(arr)) {
43733
43957
  return arr;
43734
43958
  }
43735
43959
  return d > 0 ? arr.reduce((acc, val) => acc.concat(flat(val, d - 1)), []) : arr.slice();
@@ -44026,11 +44250,11 @@ function dateTimePredicate(input, operator, field, alias) {
44026
44250
  return dateTimeRange(range, operator, field, alias);
44027
44251
  }
44028
44252
  // eslint-disable-next-line @salesforce/lds/no-error-in-production
44029
- throw new Error(`Where filter ${stringify$2(input)} is not supported`);
44253
+ throw new Error(`Where filter ${stringify$4(input)} is not supported`);
44030
44254
  }
44031
44255
  function dateTimeRange(input, op, field, alias) {
44032
44256
  const dateFunction = field.dataType === 'DateTime' ? 'datetime' : 'date';
44033
- const key = keys$2(input)[0];
44257
+ const key = keys$3(input)[0];
44034
44258
  let operator = op;
44035
44259
  if (operator === '=')
44036
44260
  operator = 'BETWEEN';
@@ -44330,7 +44554,7 @@ function filterToPredicates(where, recordType, alias, objectInfoMap, joins, draf
44330
44554
  if (!where)
44331
44555
  return [];
44332
44556
  let predicates = [];
44333
- const fields = keys$2(where);
44557
+ const fields = keys$3(where);
44334
44558
  for (const field of fields) {
44335
44559
  if (field === 'and' || field === 'or') {
44336
44560
  predicates.push(processCompoundPredicate(field, where[field], recordType, alias, objectInfoMap, joins));
@@ -44451,7 +44675,7 @@ function filterToPredicates(where, recordType, alias, objectInfoMap, joins, draf
44451
44675
  }
44452
44676
  else {
44453
44677
  // @W-12618378 polymorphic query sometimes does not work as expected on server. The GQL on certain entities could fail.
44454
- const entityNames = keys$2(where[field]);
44678
+ const entityNames = keys$3(where[field]);
44455
44679
  const polyPredicatesGroups = entityNames
44456
44680
  .filter((entityName) => fieldInfo.referenceToInfos.some((referenceInfo) => referenceInfo.apiName === entityName))
44457
44681
  .map((entityName) => {
@@ -44486,7 +44710,7 @@ function filterToPredicates(where, recordType, alias, objectInfoMap, joins, draf
44486
44710
  }
44487
44711
  else {
44488
44712
  //`field` match the filedInfo's apiName
44489
- for (const [op, value] of entries$2(where[field])) {
44713
+ for (const [op, value] of entries$3(where[field])) {
44490
44714
  const operator = operatorToSql(op);
44491
44715
  /**
44492
44716
  Two types ID processing might be needed. Draft ID swapping is optional, which depends on DraftFunctions existence.
@@ -44531,7 +44755,7 @@ function isIDValueField(fieldInfo) {
44531
44755
  * @returns sanitized previdicate value
44532
44756
  */
44533
44757
  function sanitizePredicateIDValue(value, draftFunction) {
44534
- if (isArray$1(value)) {
44758
+ if (isArray$3(value)) {
44535
44759
  return value.map((singleValue) => sanitizePredicateIDValue(singleValue, draftFunction));
44536
44760
  }
44537
44761
  else if (typeof value === 'string' && value === '') {
@@ -44549,7 +44773,7 @@ function sanitizePredicateIDValue(value, draftFunction) {
44549
44773
  }
44550
44774
  }
44551
44775
  function createMultiPicklistPredicate(value, operator, fieldInfo, alias) {
44552
- if (value === undefined || (isArray$1(value) && value.length === 0)) {
44776
+ if (value === undefined || (isArray$3(value) && value.length === 0)) {
44553
44777
  // eslint-disable-next-line
44554
44778
  throw new Error(`No value specified for MultiPickList filter`);
44555
44779
  }
@@ -44570,7 +44794,7 @@ function createMultiPicklistPredicate(value, operator, fieldInfo, alias) {
44570
44794
  // if we have more than 1 value in the array from an includes/excludes we must split the values into
44571
44795
  // a compound OR predicate for includes, AND predicate for excludes. each predicate could a composite
44572
44796
  // if the value in the array is ; separated. sample: ['a:b','c']
44573
- const valueArray = isArray$1(value) ? value : [value];
44797
+ const valueArray = isArray$3(value) ? value : [value];
44574
44798
  return {
44575
44799
  type: PredicateType.compound,
44576
44800
  operator: operator === 'LIKE' ? 'or' : 'and',
@@ -44601,7 +44825,7 @@ function createSinglePredicate(val, operator, field, alias) {
44601
44825
  value = multiPicklistToSql(operator, val);
44602
44826
  }
44603
44827
  else if (typeof value !== 'object' &&
44604
- !isArray$1(value) &&
44828
+ !isArray$3(value) &&
44605
44829
  typeof value !== 'number' &&
44606
44830
  (typeof value !== 'string' || typeof value !== 'boolean')) {
44607
44831
  value = value.toString();
@@ -44676,7 +44900,7 @@ function flattenSqlAndBindings(sqlAndBindings, operator) {
44676
44900
  }
44677
44901
  function inOrNotInValuesIncludeNull(predicate) {
44678
44902
  const isInOrNin = predicate.operator === 'IN' || predicate.operator === 'NOT IN';
44679
- const nullValueExists = isArray$1(predicate.value)
44903
+ const nullValueExists = isArray$3(predicate.value)
44680
44904
  ? predicate.value.some((v) => v === null)
44681
44905
  : predicate.value === null;
44682
44906
  return isInOrNin && nullValueExists;
@@ -44844,7 +45068,7 @@ function handleExtractedPredicateValue(boundValue, checkForNull) {
44844
45068
  let questionSql = '?';
44845
45069
  let binding = [];
44846
45070
  let includesNull = false;
44847
- if (isArray$1(boundValue)) {
45071
+ if (isArray$3(boundValue)) {
44848
45072
  const removeNull = boundValue.filter((v) => v !== null);
44849
45073
  includesNull = removeNull.length !== boundValue.length;
44850
45074
  // construct (?, ?)
@@ -45678,7 +45902,7 @@ function depth(json, currentLevel = 0) {
45678
45902
  if (typeof json !== 'object') {
45679
45903
  return currentLevel;
45680
45904
  }
45681
- const keys = keys$2(json);
45905
+ const keys = keys$3(json);
45682
45906
  if (keys.length === 0)
45683
45907
  return 0;
45684
45908
  const depths = keys.map((key) => {
@@ -45731,7 +45955,7 @@ function orderByToPredicate(orderBy, recordType, alias, objectInfoMap, joins) {
45731
45955
  return predicates;
45732
45956
  const isSpanning = depth(orderBy) > 2;
45733
45957
  if (isSpanning) {
45734
- const keys = keys$2(orderBy);
45958
+ const keys = keys$3(orderBy);
45735
45959
  for (let i = 0, len = keys.length; i < len; i++) {
45736
45960
  const key = keys[i];
45737
45961
  const parentFields = objectInfoMap[recordType].fields;
@@ -45761,7 +45985,7 @@ function orderByToPredicate(orderBy, recordType, alias, objectInfoMap, joins) {
45761
45985
  }
45762
45986
  }
45763
45987
  else {
45764
- const keys = keys$2(orderBy);
45988
+ const keys = keys$3(orderBy);
45765
45989
  for (let i = 0, len = keys.length; i < len; i++) {
45766
45990
  const key = keys[i];
45767
45991
  if (!objectInfoMap[recordType])
@@ -46670,14 +46894,14 @@ function isLocalCursor(maybeCursor) {
46670
46894
  typeof maybeCursor.i === 'number');
46671
46895
  }
46672
46896
  function encodeV1Cursor(cursor) {
46673
- return base64encode(stringify$2(cursor));
46897
+ return base64encode(stringify$4(cursor));
46674
46898
  }
46675
46899
  const CURSOR_PARSE_ERROR = 'Unable to parse cursor';
46676
46900
  function decodeV1Cursor(base64cursor) {
46677
46901
  let maybeCursor;
46678
46902
  try {
46679
46903
  const cursorString = base64decode(base64cursor);
46680
- maybeCursor = parse$2(cursorString);
46904
+ maybeCursor = parse$4(cursorString);
46681
46905
  }
46682
46906
  catch (error) {
46683
46907
  let message = CURSOR_PARSE_ERROR;
@@ -46881,7 +47105,7 @@ async function readPaginationMetadataForKeys(keys, query) {
46881
47105
  const results = await query(sql, keys.map((k) => k + '__pagination'));
46882
47106
  for (let row of results.rows) {
46883
47107
  let key = row[0].replace(/__pagination$/, '');
46884
- let metadata = parse$2(row[1]);
47108
+ let metadata = parse$4(row[1]);
46885
47109
  metadataMap.set(key, metadata);
46886
47110
  }
46887
47111
  return metadataMap;
@@ -46987,8 +47211,8 @@ async function connectionResolver(obj, args, context, info) {
46987
47211
  //map each sql result with the ingestion timestamp to pass it down a level
46988
47212
  let records = results.rows.map((row, index) => {
46989
47213
  const recordMetadataResult = {
46990
- recordRepresentation: parse$2(row[0]),
46991
- metadata: parse$2(row[1]),
47214
+ recordRepresentation: parse$4(row[0]),
47215
+ metadata: parse$4(row[1]),
46992
47216
  };
46993
47217
  const { recordRepresentation, metadata } = recordMetadataResult;
46994
47218
  context.seenRecordIds.add(recordRepresentation.id);
@@ -47439,7 +47663,7 @@ function extendSchemaWithObjectInfos(cache, objectInfoMap) {
47439
47663
  return cache;
47440
47664
  }
47441
47665
  // parse extensions into DocumentNode to extend the schema
47442
- const extensions = parse$5(typeDefs);
47666
+ const extensions = parse$7(typeDefs);
47443
47667
  const polymorphicFieldTypeNames = [
47444
47668
  ...polyFieldTypeNameArr,
47445
47669
  ...cache.getPolymorphicFieldTypeNames(),
@@ -47477,7 +47701,7 @@ function generateRecordQueries(schema, objectInfoMap) {
47477
47701
  // use a set to not allow duplicate scalars causing error(s)
47478
47702
  let addedTypedScalars = new Set();
47479
47703
  let allPolymorphicFieldTypeNames = new Set();
47480
- for (const name of keys$2(objectInfoMap)) {
47704
+ for (const name of keys$3(objectInfoMap)) {
47481
47705
  const objectInfo = objectInfoMap[name];
47482
47706
  const { apiName } = objectInfo;
47483
47707
  const type = schema.getType(apiName);
@@ -47604,7 +47828,7 @@ function extendExistingRecordType(schema, type, objectInfo, objectInfoMap) {
47604
47828
  // use a set to not allow duplicate scalars causing error(s)
47605
47829
  let typedScalars = new Set();
47606
47830
  let parentRelationshipFields = new Set();
47607
- const existingFields = keys$2(type.getFields());
47831
+ const existingFields = keys$3(type.getFields());
47608
47832
  const missingFields = values$1(objectInfo.fields).filter((field) => {
47609
47833
  return (existingFields.includes(field.apiName) === false ||
47610
47834
  (field.relationshipName !== null && field.referenceToInfos.length > 0));
@@ -48465,7 +48689,7 @@ async function resolveObjectInfos(objectInfotree, pathToObjectApiNamesMap, start
48465
48689
  // eslint-disable-next-line
48466
48690
  throw new Error(`Unable to resolve ObjectInfo(s) for ${Array.from(startNodes)}`);
48467
48691
  }
48468
- if (keys$2(objectInfos).length < startNodes.size) {
48692
+ if (keys$3(objectInfos).length < startNodes.size) {
48469
48693
  // eslint-disable-next-line
48470
48694
  throw new Error(`Unable to resolve ObjectInfo(s) for ${Array.from(startNodes)}`);
48471
48695
  }
@@ -49493,7 +49717,7 @@ function removeSyntheticFields(result, query) {
49493
49717
  output.data.uiapi = { ...output.data.uiapi };
49494
49718
  output.data.uiapi.query = { ...output.data.uiapi.query };
49495
49719
  const outputApiParent = output.data.uiapi.query;
49496
- const keys = keys$2(nodeJson);
49720
+ const keys = keys$3(nodeJson);
49497
49721
  keys.forEach((recordName) => {
49498
49722
  const outputApi = {};
49499
49723
  // Each connectionSelection's maps its name or alias to one of returned records. The record name could be `apiName' or alias
@@ -49513,7 +49737,7 @@ function removeSyntheticFields(result, query) {
49513
49737
  * @param jsonOutput JsonObject which will be populated with properties. It would only contains properties defined in 'FieldNode'
49514
49738
  */
49515
49739
  function createUserJsonOutput(selection, jsonInput, jsonOutput) {
49516
- const keys = keys$2(jsonInput);
49740
+ const keys = keys$3(jsonInput);
49517
49741
  if (selection.selectionSet) {
49518
49742
  createjsonOutput(selection.selectionSet.selections, jsonInput, jsonOutput);
49519
49743
  }
@@ -49522,11 +49746,11 @@ function createUserJsonOutput(selection, jsonInput, jsonOutput) {
49522
49746
  }
49523
49747
  }
49524
49748
  function createjsonOutput(selections, jsonInput, jsonOutput) {
49525
- const keys = keys$2(jsonInput);
49749
+ const keys = keys$3(jsonInput);
49526
49750
  selections.filter(isFieldNode).forEach((subSelection) => {
49527
49751
  const fieldName = subSelection.alias ? subSelection.alias.value : subSelection.name.value;
49528
49752
  if (keys.includes(fieldName)) {
49529
- if (isArray$1(jsonInput[fieldName])) {
49753
+ if (isArray$3(jsonInput[fieldName])) {
49530
49754
  jsonOutput[fieldName] = [];
49531
49755
  jsonInput[fieldName].forEach((childJson) => {
49532
49756
  const childOutput = {};
@@ -49930,7 +50154,7 @@ function findRecordQueryContainsFieldType(recordQueryNode, fieldNames) {
49930
50154
  */
49931
50155
  function findFieldTypeInObjectInfo(objectInfos, fieldType) {
49932
50156
  let fieldsWithDataType = [];
49933
- keys$2(objectInfos).filter((recordType) => {
50157
+ keys$3(objectInfos).filter((recordType) => {
49934
50158
  for (const field in objectInfos[recordType].fields) {
49935
50159
  if (objectInfos[recordType].fields[field].dataType === fieldType) {
49936
50160
  fieldsWithDataType.push(field);
@@ -49956,12 +50180,12 @@ const replaceDraftIdsInVariables = (variables, draftFunctions, unmappedDraftIDs)
49956
50180
  }
49957
50181
  return canonicalId;
49958
50182
  }
49959
- else if (isArray$1(object)) {
50183
+ else if (isArray$3(object)) {
49960
50184
  return object.map(replace);
49961
50185
  }
49962
50186
  else if (typeof object === 'object' && object !== null) {
49963
50187
  let source = object;
49964
- return keys$2(source).reduce((acc, key) => {
50188
+ return keys$3(source).reduce((acc, key) => {
49965
50189
  acc[key] = replace(source[key]);
49966
50190
  return acc;
49967
50191
  }, {});
@@ -49970,7 +50194,7 @@ const replaceDraftIdsInVariables = (variables, draftFunctions, unmappedDraftIDs)
49970
50194
  return object;
49971
50195
  }
49972
50196
  };
49973
- let newVariables = keys$2(variables).reduce((acc, key) => {
50197
+ let newVariables = keys$3(variables).reduce((acc, key) => {
49974
50198
  acc[key] = replace(variables[key]);
49975
50199
  return acc;
49976
50200
  }, {});
@@ -49982,7 +50206,7 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
49982
50206
  const getCanonicalId = getCanonicalIdFunction(luvio);
49983
50207
  return async function draftAwareGraphQLAdapter(config, requestContext = {}) {
49984
50208
  //create a copy to not accidentally modify the AST in the astResolver map of luvio
49985
- const copy = parse$2(stringify$2(config.query));
50209
+ const copy = parse$4(stringify$4(config.query));
49986
50210
  // the injected ast has extra fields needed for eval in it
49987
50211
  let injectedAST;
49988
50212
  // the cursor mapped ast is passed upstream so it won't reject on our local cursors
@@ -50075,7 +50299,7 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
50075
50299
  } = await evaluate({
50076
50300
  ...config,
50077
50301
  //need to create another copy of the ast for future writes
50078
- query: parse$2(stringify$2(injectedAST)),
50302
+ query: parse$4(stringify$4(injectedAST)),
50079
50303
  }, observers, { userId }, objectInfoNeeded, store, nonEvaluatedSnapshot, graphqlSchemaCache, draftFunctions, mappedCursors));
50080
50304
  }
50081
50305
  catch (throwable) {
@@ -50201,7 +50425,7 @@ function makeGetRecordsConfig(keyMap) {
50201
50425
 
50202
50426
  function environmentAwareGraphQLBatchAdapterFactory(objectInfoService, luvio, isDraftId, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy) {
50203
50427
  return async function environmentAwareGraphQLBatchAdapter(config, requestContext = {}) {
50204
- const batchQueryCopy = config.batchQuery.map((query) => parse$2(stringify$2(query)));
50428
+ const batchQueryCopy = config.batchQuery.map((query) => parse$4(stringify$4(query)));
50205
50429
  let injectedBatchQuery = [];
50206
50430
  const getCanonicalId = getCanonicalIdFunction(luvio);
50207
50431
  const draftFunctions = {
@@ -50425,22 +50649,22 @@ const recordIdGenerator = (id) => {
50425
50649
  */
50426
50650
 
50427
50651
 
50428
- const { keys: keys$1, create: create$1, assign: assign$1, entries: entries$1 } = Object;
50429
- const { stringify: stringify$1, parse: parse$1 } = JSON;
50652
+ const { keys: keys$2, create: create$2, assign: assign$1, entries: entries$2 } = Object;
50653
+ const { stringify: stringify$3, parse: parse$3 } = JSON;
50430
50654
  const { push, join, slice } = Array.prototype;
50431
- const { isArray, from } = Array;
50655
+ const { isArray: isArray$2, from } = Array;
50432
50656
 
50433
50657
  function ldsParamsToString(params) {
50434
- const returnParams = create$1(null);
50435
- const keys$1$1 = keys$1(params);
50436
- for (let i = 0, len = keys$1$1.length; i < len; i++) {
50437
- const key = keys$1$1[i];
50658
+ const returnParams = create$2(null);
50659
+ const keys$1 = keys$2(params);
50660
+ for (let i = 0, len = keys$1.length; i < len; i++) {
50661
+ const key = keys$1[i];
50438
50662
  const value = params[key];
50439
50663
  if (value === undefined) {
50440
50664
  // filter out params that have no value
50441
50665
  continue;
50442
50666
  }
50443
- if (isArray(value)) {
50667
+ if (isArray$2(value)) {
50444
50668
  // filter out empty arrays
50445
50669
  if (value.length > 0) {
50446
50670
  returnParams[key] = value.join(',');
@@ -50449,8 +50673,8 @@ function ldsParamsToString(params) {
50449
50673
  else {
50450
50674
  returnParams[key] = `${value}`;
50451
50675
  }
50452
- if (isObject(value) === true && keys$1(value).length > 0) {
50453
- returnParams[key] = stringify$1(value);
50676
+ if (isObject(value) === true && keys$2(value).length > 0) {
50677
+ returnParams[key] = stringify$3(value);
50454
50678
  }
50455
50679
  }
50456
50680
  return returnParams;
@@ -50503,19 +50727,22 @@ function isStatusOk(status) {
50503
50727
  }
50504
50728
  // adapted from adapter-utils untrustedIsObject
50505
50729
  function isObject(value) {
50506
- return typeof value === 'object' && value !== null && isArray(value) === false;
50730
+ return typeof value === 'object' && value !== null && isArray$2(value) === false;
50507
50731
  }
50508
50732
  function stringifyIfPresent(value) {
50509
50733
  if (value === undefined || value === null) {
50510
50734
  return null;
50511
50735
  }
50512
- return stringify$1(value);
50736
+ if (typeof value === 'string') {
50737
+ return value;
50738
+ }
50739
+ return stringify$3(value);
50513
50740
  }
50514
50741
  function parseIfPresent(value) {
50515
50742
  if (value === undefined || value === null || value === '') {
50516
50743
  return null;
50517
50744
  }
50518
- return parse$1(value);
50745
+ return parse$3(value);
50519
50746
  }
50520
50747
  function buildNimbusNetworkPluginRequest(resourceRequest, resourceRequestContext) {
50521
50748
  const { basePath, baseUri, method, headers, queryParams, body } = resourceRequest;
@@ -50849,9 +51076,9 @@ function buildAggregateUiUrl(params, resourceRequest) {
50849
51076
  optionalFields,
50850
51077
  };
50851
51078
  const queryString = [];
50852
- for (const [key, value] of entries$1(mergedParams)) {
51079
+ for (const [key, value] of entries$2(mergedParams)) {
50853
51080
  if (value !== undefined) {
50854
- queryString.push(`${key}=${isArray(value) ? value.join(',') : value}`);
51081
+ queryString.push(`${key}=${isArray$2(value) ? value.join(',') : value}`);
50855
51082
  }
50856
51083
  }
50857
51084
  return `${resourceRequest.baseUri}${resourceRequest.basePath}?${join.call(queryString, '&')}`;
@@ -50865,7 +51092,7 @@ function isSpanningRecord(fieldValue) {
50865
51092
  function mergeRecordFields(first, second) {
50866
51093
  const { fields: targetFields } = first;
50867
51094
  const { fields: sourceFields } = second;
50868
- const fieldNames = keys$1(sourceFields);
51095
+ const fieldNames = keys$2(sourceFields);
50869
51096
  for (let i = 0, len = fieldNames.length; i < len; i += 1) {
50870
51097
  const fieldName = fieldNames[i];
50871
51098
  const sourceField = sourceFields[fieldName];
@@ -51002,7 +51229,7 @@ function isGetRequestForEndpoint(endpoint, request) {
51002
51229
  * @returns the array or an empty array
51003
51230
  */
51004
51231
  function arrayOrEmpty(array) {
51005
- return array !== undefined && isArray(array) ? array : [];
51232
+ return array !== undefined && isArray$2(array) ? array : [];
51006
51233
  }
51007
51234
  /**
51008
51235
  * Calculate the max length per chunk.
@@ -51015,8 +51242,8 @@ function getMaxLengthPerChunkAllowed(request) {
51015
51242
  // Too much work to get exact length of the final url, so use stringified json to get the rough length.
51016
51243
  const roughUrlLengthWithoutFieldsAndOptionFields = request.basePath.length +
51017
51244
  request.baseUri.length +
51018
- (request.urlParams ? stringify$1(request.urlParams).length : 0) +
51019
- stringify$1({ ...request.queryParams, fields: {}, optionalFields: {} }).length;
51245
+ (request.urlParams ? stringify$3(request.urlParams).length : 0) +
51246
+ stringify$3({ ...request.queryParams, fields: {}, optionalFields: {} }).length;
51020
51247
  return MAX_URL_LENGTH - roughUrlLengthWithoutFieldsAndOptionFields;
51021
51248
  }
51022
51249
  // we don't have access to the host so we cannot calculate the exact length of the url
@@ -51025,7 +51252,7 @@ function calculateEstimatedTotalUrlLength(request) {
51025
51252
  const { baseUri, basePath, queryParams } = request;
51026
51253
  let url = `${baseUri}${basePath}`;
51027
51254
  if (queryParams) {
51028
- const queryParamString = entries$1(queryParams)
51255
+ const queryParamString = entries$2(queryParams)
51029
51256
  .map(([key, value]) => `${key}=${value}`)
51030
51257
  .join('&');
51031
51258
  if (queryParamString) {
@@ -51046,13 +51273,13 @@ const referenceId$1 = 'LDS_Records_AggregateUi';
51046
51273
  */
51047
51274
  function mergeGetRecordResult(first, second) {
51048
51275
  // return the error if first is error.
51049
- if (isArray(first) && !isArray(second))
51276
+ if (isArray$2(first) && !isArray$2(second))
51050
51277
  return first;
51051
51278
  // return the error if second is error.
51052
- if (!isArray(first) && isArray(second))
51279
+ if (!isArray$2(first) && isArray$2(second))
51053
51280
  return second;
51054
51281
  // concat the error array if both are error
51055
- if (isArray(first) && isArray(second)) {
51282
+ if (isArray$2(first) && isArray$2(second)) {
51056
51283
  return [...first, ...second];
51057
51284
  }
51058
51285
  mergeRecordFields(first, second);
@@ -51122,10 +51349,10 @@ class NimbusDraftQueue {
51122
51349
  if (callProxyMethod === undefined) {
51123
51350
  return Promise.reject(new Error('callProxyMethod not defined on the nimbus plugin'));
51124
51351
  }
51125
- const serializedAction = stringify$2([handlerId, data]);
51352
+ const serializedAction = stringify$4([handlerId, data]);
51126
51353
  return new Promise((resolve, reject) => {
51127
51354
  callProxyMethod('enqueue', serializedAction, (serializedActionResponse) => {
51128
- const response = parse$2(serializedActionResponse);
51355
+ const response = parse$4(serializedActionResponse);
51129
51356
  resolve(response);
51130
51357
  }, (errorMessage) => {
51131
51358
  reject(new Error(errorMessage));
@@ -51146,8 +51373,8 @@ class NimbusDraftQueue {
51146
51373
  return Promise.reject(new Error('callProxyMethod not defined on the nimbus plugin'));
51147
51374
  }
51148
51375
  return new Promise((resolve, reject) => {
51149
- callProxyMethod('getQueueActions', stringify$2([]), (serializedQueue) => {
51150
- resolve(parse$2(serializedQueue));
51376
+ callProxyMethod('getQueueActions', stringify$4([]), (serializedQueue) => {
51377
+ resolve(parse$4(serializedQueue));
51151
51378
  }, (errorMessage) => {
51152
51379
  reject(new Error(errorMessage));
51153
51380
  });
@@ -51158,17 +51385,17 @@ class NimbusDraftQueue {
51158
51385
  if (callProxyMethod === undefined) {
51159
51386
  return Promise.reject('callProxyMethod not defined on the nimbus plugin');
51160
51387
  }
51161
- const stringifiedArgs = stringify$2([action]);
51388
+ const stringifiedArgs = stringify$4([action]);
51162
51389
  return new Promise((resolve, reject) => {
51163
51390
  callProxyMethod('getDataForAction', stringifiedArgs, (data) => {
51164
51391
  if (data === undefined) {
51165
51392
  resolve(undefined);
51166
51393
  }
51167
51394
  else {
51168
- resolve(parse$2(data));
51395
+ resolve(parse$4(data));
51169
51396
  }
51170
51397
  }, (serializedError) => {
51171
- reject(parse$2(serializedError));
51398
+ reject(parse$4(serializedError));
51172
51399
  });
51173
51400
  });
51174
51401
  }
@@ -51215,211 +51442,6 @@ class NimbusDraftQueue {
51215
51442
  }
51216
51443
  }
51217
51444
 
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
51445
  /**
51424
51446
  * HOF (high-order-function) that instruments any async operation. If the operation
51425
51447
  * has an error then the hasError param will be set on the call to o11y.incrementCounter
@@ -51458,7 +51480,7 @@ function instrumentDraftQueue(queue) {
51458
51480
  logError: false,
51459
51481
  });
51460
51482
  };
51461
- const overriddenQueue = create$2(queue, { mergeActions: { value: mergeActions } });
51483
+ const overriddenQueue = create$3(queue, { mergeActions: { value: mergeActions } });
51462
51484
  overriddenQueue.registerOnChangedListener((draftQueueEvent) => {
51463
51485
  switch (draftQueueEvent.type) {
51464
51486
  case DraftQueueEventType.QueueStateChanged: {
@@ -51596,7 +51618,7 @@ function enableObjectInfoCaching(env, ensureObjectInfoCached) {
51596
51618
  function dataIsObjectInfo(key, data) {
51597
51619
  return incomingObjectInfos.has(key);
51598
51620
  }
51599
- return create$2(env, {
51621
+ return create$3(env, {
51600
51622
  handleSuccessResponse: { value: handleSuccessResponse },
51601
51623
  storePublish: { value: storePublish },
51602
51624
  });
@@ -51697,8 +51719,8 @@ class ObjectInfoService {
51697
51719
  }
51698
51720
  };
51699
51721
  // Local in-memory cache for apiName to key prefixes
51700
- this.apiNameToKeyPrefixMemoryCache = create$2(null);
51701
- this.keyPrefixToApiNameMemoryCache = create$2(null);
51722
+ this.apiNameToKeyPrefixMemoryCache = create$3(null);
51723
+ this.keyPrefixToApiNameMemoryCache = create$3(null);
51702
51724
  }
51703
51725
  /**
51704
51726
  * Size of return map not necessarily correlated with number of inputs. The
@@ -51864,8 +51886,8 @@ function registerReportObserver(reportObserver) {
51864
51886
  };
51865
51887
  }
51866
51888
 
51867
- const { keys, create, assign, entries, values } = Object;
51868
- const { stringify, parse } = JSON;
51889
+ const { keys: keys$1, create: create$1, assign, entries: entries$1, values } = Object;
51890
+ const { stringify: stringify$2, parse: parse$2 } = JSON;
51869
51891
 
51870
51892
  function selectColumnsFromTableWhereKeyIn(columnNames, table, keyColumnName, whereIn) {
51871
51893
  const paramList = whereIn.map(() => '?').join(',');
@@ -51906,7 +51928,7 @@ class LdsDataTable {
51906
51928
  const [key, stringifiedMetadata] = row;
51907
51929
  if (stringifiedMetadata !== undefined) {
51908
51930
  entries[key] = {
51909
- metadata: parse(stringifiedMetadata),
51931
+ metadata: parse$2(stringifiedMetadata),
51910
51932
  };
51911
51933
  }
51912
51934
  return entries;
@@ -51931,10 +51953,10 @@ class LdsDataTable {
51931
51953
  },
51932
51954
  conflictColumns: this.conflictColumnNames,
51933
51955
  columns: this.columnNames,
51934
- rows: keys(entries).reduce((rows, key) => {
51956
+ rows: keys$1(entries).reduce((rows, key) => {
51935
51957
  const entry = entries[key];
51936
51958
  const { data, metadata } = entry;
51937
- const row = [key, stringify(data), metadata ? stringify(metadata) : null];
51959
+ const row = [key, stringify$2(data), metadata ? stringify$2(metadata) : null];
51938
51960
  rows.push(row);
51939
51961
  return rows;
51940
51962
  }, []),
@@ -51950,9 +51972,9 @@ class LdsDataTable {
51950
51972
  type: 'setMetadata',
51951
51973
  },
51952
51974
  columns: [COLUMN_NAME_METADATA$1],
51953
- values: keys(entries).reduce((values, key) => {
51975
+ values: keys$1(entries).reduce((values, key) => {
51954
51976
  const { metadata } = entries[key];
51955
- const row = [metadata ? stringify(metadata) : null];
51977
+ const row = [metadata ? stringify$2(metadata) : null];
51956
51978
  values[key] = row;
51957
51979
  return values;
51958
51980
  }, {}),
@@ -51962,10 +51984,10 @@ class LdsDataTable {
51962
51984
  return sqliteResult.rows.reduce((entries, row) => {
51963
51985
  const [key, stringifiedData, stringifiedMetadata] = row;
51964
51986
  const durableStoreEntry = {
51965
- data: parse(stringifiedData),
51987
+ data: parse$2(stringifiedData),
51966
51988
  };
51967
51989
  if (stringifiedMetadata !== null) {
51968
- durableStoreEntry.metadata = parse(stringifiedMetadata);
51990
+ durableStoreEntry.metadata = parse$2(stringifiedMetadata);
51969
51991
  }
51970
51992
  entries[key] = durableStoreEntry;
51971
51993
  return entries;
@@ -52015,7 +52037,7 @@ class LdsInternalDataTable {
52015
52037
  const [key, stringifiedMetadata] = row;
52016
52038
  if (stringifiedMetadata !== undefined) {
52017
52039
  entries[key] = {
52018
- metadata: parse(stringifiedMetadata),
52040
+ metadata: parse$2(stringifiedMetadata),
52019
52041
  };
52020
52042
  }
52021
52043
  return entries;
@@ -52040,12 +52062,12 @@ class LdsInternalDataTable {
52040
52062
  },
52041
52063
  conflictColumns: this.conflictColumnNames,
52042
52064
  columns: this.columnNames,
52043
- rows: keys(entries).reduce((rows, key) => {
52065
+ rows: keys$1(entries).reduce((rows, key) => {
52044
52066
  const entry = entries[key];
52045
52067
  const { data, metadata } = entry;
52046
- const row = [key, stringify(data)];
52068
+ const row = [key, stringify$2(data)];
52047
52069
  if (metadata) {
52048
- row.push(stringify(metadata));
52070
+ row.push(stringify$2(metadata));
52049
52071
  }
52050
52072
  else {
52051
52073
  row.push(null);
@@ -52066,21 +52088,21 @@ class LdsInternalDataTable {
52066
52088
  type: 'setMetadata',
52067
52089
  },
52068
52090
  columns: [COLUMN_NAME_METADATA],
52069
- values: keys(entries).reduce((values, key) => {
52091
+ values: keys$1(entries).reduce((values, key) => {
52070
52092
  const { metadata } = entries[key];
52071
- const row = [metadata ? stringify(metadata) : null];
52093
+ const row = [metadata ? stringify$2(metadata) : null];
52072
52094
  values[key] = row;
52073
52095
  return values;
52074
52096
  }, {}),
52075
52097
  };
52076
52098
  }
52077
52099
  metadataToUpdateSQLQueries(entries, segment) {
52078
- return keys(entries).reduce((accu, key) => {
52100
+ return keys$1(entries).reduce((accu, key) => {
52079
52101
  const { metadata } = entries[key];
52080
52102
  if (metadata !== undefined) {
52081
52103
  accu.push({
52082
52104
  sql: `UPDATE ${this.tableName} SET ${COLUMN_NAME_METADATA} = ? WHERE (${COLUMN_NAME_KEY$1} IS ? AND ${COLUMN_NAME_NAMESPACE} IS ?)`,
52083
- params: [stringify(metadata), key, segment],
52105
+ params: [stringify$2(metadata), key, segment],
52084
52106
  change: {
52085
52107
  ids: [key],
52086
52108
  segment,
@@ -52096,10 +52118,10 @@ class LdsInternalDataTable {
52096
52118
  return sqliteResult.rows.reduce((entries, row) => {
52097
52119
  const [key, stringifiedData, stringifiedMetadata] = row;
52098
52120
  const durableStoreEntry = {
52099
- data: parse(stringifiedData),
52121
+ data: parse$2(stringifiedData),
52100
52122
  };
52101
52123
  if (stringifiedMetadata !== null) {
52102
- durableStoreEntry.metadata = parse(stringifiedMetadata);
52124
+ durableStoreEntry.metadata = parse$2(stringifiedMetadata);
52103
52125
  }
52104
52126
  entries[key] = durableStoreEntry;
52105
52127
  return entries;
@@ -52108,6 +52130,9 @@ class LdsInternalDataTable {
52108
52130
  }
52109
52131
 
52110
52132
  const tasker = idleDetector.declareNotifierTaskMulti('NimbusSqliteStore');
52133
+ const instrumentation$2 = getInstrumentation('lds-mobile');
52134
+ const GRAPHQL_QUERY_ROOT_KEY = 'UiApi::uiapi::Query[uiapi]__uiapi__query';
52135
+ const GRAPHQL_QUERY_ROOT_METRIC_NAME = 'gql-query-root-object-size';
52111
52136
  class NimbusSqliteStore {
52112
52137
  constructor(plugin, additionalTableMap = {}) {
52113
52138
  this.plugin = plugin;
@@ -52154,15 +52179,18 @@ class NimbusSqliteStore {
52154
52179
  .finally(() => tasker.done());
52155
52180
  }
52156
52181
  setEntries(entries, segment) {
52157
- if (keys(entries).length === 0) {
52182
+ if (keys$1(entries).length === 0) {
52158
52183
  return Promise.resolve();
52159
52184
  }
52160
52185
  const table = this.getTable(segment);
52161
52186
  const upsertOperation = table.entriesToUpsertOperations(entries, segment);
52187
+ if (entries[GRAPHQL_QUERY_ROOT_KEY]) {
52188
+ this.trackGraphQLQueryRootSize(upsertOperation);
52189
+ }
52162
52190
  return this.batchOperationAsPromise([upsertOperation]);
52163
52191
  }
52164
52192
  setMetadata(entries, segment) {
52165
- if (keys(entries).length === 0) {
52193
+ if (keys$1(entries).length === 0) {
52166
52194
  return Promise.resolve();
52167
52195
  }
52168
52196
  const table = this.getTable(segment);
@@ -52172,13 +52200,17 @@ class NimbusSqliteStore {
52172
52200
  batchOperations(operations) {
52173
52201
  const sqliteOperations = operations.reduce((acc, cur) => {
52174
52202
  if (cur.type === 'setEntries') {
52175
- if (keys(cur.entries).length > 0) {
52203
+ if (keys$1(cur.entries).length > 0) {
52176
52204
  const table = this.getTable(cur.segment);
52177
- acc.push(table.entriesToUpsertOperations(cur.entries, cur.segment));
52205
+ const upsertOperation = table.entriesToUpsertOperations(cur.entries, cur.segment);
52206
+ if (cur.entries[GRAPHQL_QUERY_ROOT_KEY]) {
52207
+ this.trackGraphQLQueryRootSize(upsertOperation);
52208
+ }
52209
+ acc.push(upsertOperation);
52178
52210
  }
52179
52211
  }
52180
52212
  else if (cur.type === 'setMetadata') {
52181
- if (keys(cur.entries).length > 0) {
52213
+ if (keys$1(cur.entries).length > 0) {
52182
52214
  const table = this.getTable(cur.segment);
52183
52215
  acc.push(table.metadataToUpdateOperations(cur.entries, cur.segment));
52184
52216
  }
@@ -52259,6 +52291,19 @@ class NimbusSqliteStore {
52259
52291
  });
52260
52292
  }).finally(() => tasker.done());
52261
52293
  }
52294
+ trackGraphQLQueryRootSize(upsertOperation) {
52295
+ try {
52296
+ if (upsertOperation.type !== 'upsert') {
52297
+ return;
52298
+ }
52299
+ const row = upsertOperation.rows.find((r) => r[0] === GRAPHQL_QUERY_ROOT_KEY);
52300
+ if (!(row && row[1] && typeof row[1] === 'string')) {
52301
+ return;
52302
+ }
52303
+ instrumentation$2.trackValue(GRAPHQL_QUERY_ROOT_METRIC_NAME, row[1].length);
52304
+ }
52305
+ catch { }
52306
+ }
52262
52307
  }
52263
52308
 
52264
52309
  // These const values must be in sync with the latest
@@ -52302,9 +52347,9 @@ class AbstractKeyValueDataTable {
52302
52347
  },
52303
52348
  conflictColumns: this.conflictColumnNames,
52304
52349
  columns: this.columnNames,
52305
- rows: keys(entries).reduce((rows, key) => {
52350
+ rows: keys$1(entries).reduce((rows, key) => {
52306
52351
  const entry = entries[key];
52307
- rows.push([key, stringify(entry.data)]);
52352
+ rows.push([key, stringify$2(entry.data)]);
52308
52353
  return rows;
52309
52354
  }, []),
52310
52355
  };
@@ -52317,7 +52362,7 @@ class AbstractKeyValueDataTable {
52317
52362
  return sqliteResult.rows.reduce((entries, row) => {
52318
52363
  const [key, stringifiedData] = row;
52319
52364
  const durableStoreEntry = {
52320
- data: parse(stringifiedData),
52365
+ data: parse$2(stringifiedData),
52321
52366
  };
52322
52367
  entries[key] = durableStoreEntry;
52323
52368
  return entries;
@@ -52470,7 +52515,7 @@ function makeEnvironmentGraphqlAware(environment) {
52470
52515
  }
52471
52516
  return environment.applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, localBuildCachedSnapshot, buildNetworkSnapshot);
52472
52517
  };
52473
- return create$2(environment, {
52518
+ return create$3(environment, {
52474
52519
  rebuildSnapshot: { value: rebuildSnapshot },
52475
52520
  applyCachePolicy: { value: applyCachePolicy },
52476
52521
  setDefaultCachePolicy: { value: environment.setDefaultCachePolicy.bind(environment) },
@@ -52950,14 +52995,10 @@ class PrimingSession extends EventEmitter {
52950
52995
  const userData = {
52951
52996
  ...stats,
52952
52997
  };
52953
- if (errors.length) {
52954
- for (const error in errors) {
52955
- activity.error(error, schema, userData);
52956
- }
52957
- }
52958
- else {
52959
- activity.stop(schema, userData);
52998
+ for (const error in errors) {
52999
+ activity.error(error);
52960
53000
  }
53001
+ activity.stop(schema, userData);
52961
53002
  }
52962
53003
  enqueueBatches(batches, paginationCount = 0, instrumentationContext) {
52963
53004
  for (const batch of batches) {
@@ -53125,7 +53166,7 @@ class PrimingSession extends EventEmitter {
53125
53166
  }
53126
53167
  return;
53127
53168
  }
53128
- if (keys$2(result.additionalWork.records).length > 0) {
53169
+ if (keys$3(result.additionalWork.records).length > 0) {
53129
53170
  this.emit('conflict', {
53130
53171
  ids: Object.values(result.additionalWork.records).flatMap((record) => record.ids),
53131
53172
  resolution: 'priming-refresh',
@@ -53134,7 +53175,7 @@ class PrimingSession extends EventEmitter {
53134
53175
  let limitedResult = this.applyRetryLimits(result.additionalWork);
53135
53176
  this.enqueue(limitedResult.additionalWork);
53136
53177
  if (limitedResult.recordsNeedingRefetch.size > 0) {
53137
- for (const key in keys$2(limitedResult.recordsNeedingRefetch)) {
53178
+ for (const key in keys$3(limitedResult.recordsNeedingRefetch)) {
53138
53179
  const value = limitedResult.recordsNeedingRefetch.get(key);
53139
53180
  if (result.recordsNeedingRefetch.has(key)) {
53140
53181
  let existing = result.recordsNeedingRefetch.get(key);
@@ -53220,7 +53261,7 @@ class PrimingSession extends EventEmitter {
53220
53261
  };
53221
53262
  // refetchable work gets delegated to getRecords
53222
53263
  let refetchableWork = new Map();
53223
- for (const key of keys$2(primingWork.records)) {
53264
+ for (const key of keys$3(primingWork.records)) {
53224
53265
  let work = primingWork.records[key];
53225
53266
  let limitedIds = [];
53226
53267
  for (const id of work.ids) {
@@ -54119,7 +54160,7 @@ async function aggressiveTrim(data, deallocateFn, options = {}) {
54119
54160
  const batchSize = options.batchSize !== undefined ? options.batchSize : DEFAULT_MAX_BATCH_SIZE;
54120
54161
  let deallocatedCount = 0;
54121
54162
  const { pendingTrimKeys, retainedIds, storeRecords } = data;
54122
- const storeKeyLength = keys$2(storeRecords).length;
54163
+ const storeKeyLength = keys$3(storeRecords).length;
54123
54164
  if (storeKeyLength <= maxStoreRecords) {
54124
54165
  return { deallocatedCount, trimKeysSkipped: pendingTrimKeys };
54125
54166
  }
@@ -54187,7 +54228,7 @@ function setupObserver() {
54187
54228
  registerReportObserver((report) => {
54188
54229
  __nimbus.plugins.LdsObserverPlugin.logAdapterExecution({
54189
54230
  name: report.adapterName,
54190
- serializedConfig: stringify$2(report.config),
54231
+ serializedConfig: stringify$4(report.config),
54191
54232
  status: report.result,
54192
54233
  duration: report.executionTime,
54193
54234
  });
@@ -54308,7 +54349,7 @@ function transformConfiguration$1(config) {
54308
54349
  // Make a copy of the config before running transform to avoid mutating the original config
54309
54350
  const adapterConfigCopy = {
54310
54351
  ...config,
54311
- query: parse$5(print(config.query))
54352
+ query: parse$7(print(config.query))
54312
54353
  };
54313
54354
  return {
54314
54355
  ...adapterConfigCopy,
@@ -54686,7 +54727,7 @@ function transformConfiguration(config) {
54686
54727
  const batchQueryTransformed = config.batchQuery.map((singleConfig) => {
54687
54728
  return {
54688
54729
  ...singleConfig,
54689
- query: applyMinimumFieldsToQuery(parse$5(print(singleConfig.query))), // Stringifies and parses again to avoid mutating original. Should we just JSON.stringify to avoid the dependency on the parser?
54730
+ query: applyMinimumFieldsToQuery(parse$7(print(singleConfig.query))), // Stringifies and parses again to avoid mutating original. Should we just JSON.stringify to avoid the dependency on the parser?
54690
54731
  };
54691
54732
  });
54692
54733
  return {
@@ -54783,7 +54824,7 @@ class SideEffectStore {
54783
54824
  if (idsToFetch.size > 0) {
54784
54825
  const effects = await durableStore.getEntries(Array.from(idsToFetch), SIDE_EFFECT_SEGMENT);
54785
54826
  if (effects !== undefined) {
54786
- keys$2(effects).forEach((effectId) => {
54827
+ keys$3(effects).forEach((effectId) => {
54787
54828
  const effect = effects[effectId].data;
54788
54829
  const key = effect.uniqueId;
54789
54830
  this.allEffects.set(key, effect);
@@ -54837,7 +54878,7 @@ class SideEffectStore {
54837
54878
  if (effects === undefined) {
54838
54879
  return;
54839
54880
  }
54840
- keys$2(effects).forEach((effectId) => {
54881
+ keys$3(effects).forEach((effectId) => {
54841
54882
  const effect = effects[effectId].data;
54842
54883
  const key = effect.uniqueId;
54843
54884
  this.allEffects.set(key, effect);
@@ -54970,7 +55011,7 @@ class SideEffectService {
54970
55011
  async synthesizeFieldsFromParts(fields, apiName) {
54971
55012
  const objectInfo = await this.ensureObjectInfo(apiName);
54972
55013
  const recordFields = {};
54973
- for (const fieldName of keys$2(fields)) {
55014
+ for (const fieldName of keys$3(fields)) {
54974
55015
  const draftField = fields[fieldName] ?? null;
54975
55016
  recordFields[fieldName] = { value: draftField, displayValue: null };
54976
55017
  const fieldInfo = objectInfo.fields[fieldName];
@@ -55051,7 +55092,7 @@ class SideEffectService {
55051
55092
  changedNameFields[fieldName] = fieldValue;
55052
55093
  }
55053
55094
  }
55054
- if (keys$2(changedNameFields).length > 0) {
55095
+ if (keys$3(changedNameFields).length > 0) {
55055
55096
  const newNameValue = filteredNameFields
55056
55097
  .map((key) => {
55057
55098
  if (changedNameFields[key] !== undefined) {
@@ -55151,7 +55192,7 @@ class SideEffectService {
55151
55192
  }
55152
55193
 
55153
55194
  function clone(obj) {
55154
- return parse$2(stringify$2(obj));
55195
+ return parse$4(stringify$4(obj));
55155
55196
  }
55156
55197
 
55157
55198
  /* global __nimbus */
@@ -55178,7 +55219,7 @@ class UpdateRecordEffectHandler {
55178
55219
  }
55179
55220
  const patchedFields = effect.recordPatch.fields;
55180
55221
  if (patchedFields) {
55181
- const fieldNames = keys$2(patchedFields);
55222
+ const fieldNames = keys$3(patchedFields);
55182
55223
  for (let i = 0, len = fieldNames.length; i < len; i++) {
55183
55224
  const fieldName = fieldNames[i];
55184
55225
  // don't apply server values to draft created records
@@ -55337,7 +55378,7 @@ function removeEffects(record) {
55337
55378
  return undefined;
55338
55379
  }
55339
55380
  const updatedFields = {};
55340
- const fieldNames = keys$2(fields);
55381
+ const fieldNames = keys$3(fields);
55341
55382
  for (let i = 0, len = fieldNames.length; i < len; i++) {
55342
55383
  const fieldName = fieldNames[i];
55343
55384
  const field = fields[fieldName];
@@ -55449,7 +55490,7 @@ class DurableRecordStore {
55449
55490
  if (entries === undefined) {
55450
55491
  return directory;
55451
55492
  }
55452
- keys$2(entries).forEach((key) => {
55493
+ keys$3(entries).forEach((key) => {
55453
55494
  const { data: record, metadata } = entries[key];
55454
55495
  if (isStoreRecordError(record)) {
55455
55496
  return;
@@ -55642,6 +55683,2296 @@ function createSfsSideEffectHooks(durableRecordStore) {
55642
55683
  return [];
55643
55684
  }
55644
55685
 
55686
+ /*!
55687
+ * Copyright (c) 2022, Salesforce, Inc.,
55688
+ * All rights reserved.
55689
+ * For full license text, see the LICENSE.txt file
55690
+ */
55691
+ const { create, freeze, keys, entries } = Object;
55692
+ const { isArray: isArray$1 } = Array;
55693
+ const { stringify: stringify$1, parse: parse$1 } = JSON;
55694
+ const LogLevelMap = {
55695
+ TRACE: 4,
55696
+ DEBUG: 3,
55697
+ INFO: 2,
55698
+ WARN: 1,
55699
+ ERROR: 0
55700
+ };
55701
+ class ConsoleLogger {
55702
+ constructor(level = "WARN", printer = console.log, formatter = (level2, message) => `${level2}: ${message}`) {
55703
+ this.level = level;
55704
+ this.printer = printer;
55705
+ this.formatter = formatter;
55706
+ this.messages = [];
55707
+ }
55708
+ trace(message) {
55709
+ this.log("TRACE", message);
55710
+ }
55711
+ debug(message) {
55712
+ this.log("DEBUG", message);
55713
+ }
55714
+ info(message) {
55715
+ this.log("INFO", message);
55716
+ }
55717
+ warn(message) {
55718
+ this.log("WARN", message);
55719
+ }
55720
+ error(message) {
55721
+ this.log("ERROR", message);
55722
+ }
55723
+ log(level, message) {
55724
+ if (LogLevelMap[level] > LogLevelMap[this.level]) {
55725
+ return;
55726
+ }
55727
+ this.printer(this.formatter(level, message));
55728
+ }
55729
+ }
55730
+ let Ok$2 = class Ok {
55731
+ constructor(value) {
55732
+ this.value = value;
55733
+ }
55734
+ isOk() {
55735
+ return true;
55736
+ }
55737
+ isErr() {
55738
+ return !this.isOk();
55739
+ }
55740
+ };
55741
+ let Err$1 = class Err {
55742
+ constructor(error) {
55743
+ this.error = error;
55744
+ }
55745
+ isOk() {
55746
+ return false;
55747
+ }
55748
+ isErr() {
55749
+ return !this.isOk();
55750
+ }
55751
+ };
55752
+ const ok$2 = (value) => new Ok$2(value);
55753
+ const err$1 = (err2) => new Err$1(err2);
55754
+ function isSubscribableResult(x) {
55755
+ if (typeof x !== "object" || x === null) {
55756
+ return false;
55757
+ }
55758
+ if ("isOk" in x && typeof x.isOk === "function") {
55759
+ if (x.isOk()) {
55760
+ return "value" in x && typeof x.value === "object" && x.value !== null && "subscribe" in x.value && typeof x.value.subscribe === "function" && "refresh" in x.value && typeof x.value.refresh === "function";
55761
+ } else {
55762
+ return "error" in x;
55763
+ }
55764
+ }
55765
+ return false;
55766
+ }
55767
+ function resolvedPromiseLike$3(result) {
55768
+ if (isPromiseLike$3(result)) {
55769
+ return result.then((nextResult) => nextResult);
55770
+ }
55771
+ return {
55772
+ then: (onFulfilled, _onRejected) => {
55773
+ try {
55774
+ return resolvedPromiseLike$3(onFulfilled(result));
55775
+ } catch (e) {
55776
+ if (onFulfilled === void 0) {
55777
+ return resolvedPromiseLike$3(result);
55778
+ }
55779
+ return rejectedPromiseLike$3(e);
55780
+ }
55781
+ }
55782
+ };
55783
+ }
55784
+ function rejectedPromiseLike$3(reason) {
55785
+ if (isPromiseLike$3(reason)) {
55786
+ return reason.then((nextResult) => nextResult);
55787
+ }
55788
+ return {
55789
+ then: (_onFulfilled, onRejected) => {
55790
+ if (typeof onRejected === "function") {
55791
+ try {
55792
+ return resolvedPromiseLike$3(onRejected(reason));
55793
+ } catch (e) {
55794
+ return rejectedPromiseLike$3(e);
55795
+ }
55796
+ }
55797
+ return rejectedPromiseLike$3(reason);
55798
+ }
55799
+ };
55800
+ }
55801
+ function isPromiseLike$3(x) {
55802
+ return typeof (x == null ? void 0 : x.then) === "function";
55803
+ }
55804
+ function stableJSONStringify(node) {
55805
+ if (node && node.toJSON && typeof node.toJSON === "function") {
55806
+ node = node.toJSON();
55807
+ }
55808
+ if (node === void 0) {
55809
+ return;
55810
+ }
55811
+ if (typeof node === "number") {
55812
+ return isFinite(node) ? "" + node : "null";
55813
+ }
55814
+ if (typeof node !== "object") {
55815
+ return stringify$1(node);
55816
+ }
55817
+ let i;
55818
+ let out;
55819
+ if (isArray$1(node)) {
55820
+ out = "[";
55821
+ for (i = 0; i < node.length; i++) {
55822
+ if (i) {
55823
+ out += ",";
55824
+ }
55825
+ out += stableJSONStringify(node[i]) || "null";
55826
+ }
55827
+ return out + "]";
55828
+ }
55829
+ if (node === null) {
55830
+ return "null";
55831
+ }
55832
+ const objKeys = keys(node).sort();
55833
+ out = "";
55834
+ for (i = 0; i < objKeys.length; i++) {
55835
+ const key = objKeys[i];
55836
+ const value = stableJSONStringify(node[key]);
55837
+ if (!value) {
55838
+ continue;
55839
+ }
55840
+ if (out) {
55841
+ out += ",";
55842
+ }
55843
+ out += stringify$1(key) + ":" + value;
55844
+ }
55845
+ return "{" + out + "}";
55846
+ }
55847
+ function toError(x) {
55848
+ if (x instanceof Error) {
55849
+ return x;
55850
+ }
55851
+ return new Error(typeof x === "string" ? x : JSON.stringify(x));
55852
+ }
55853
+
55854
+ /*!
55855
+ * Copyright (c) 2022, Salesforce, Inc.,
55856
+ * All rights reserved.
55857
+ * For full license text, see the LICENSE.txt file
55858
+ */
55859
+ class BaseCommand {
55860
+ }
55861
+
55862
+ /*!
55863
+ * Copyright (c) 2022, Salesforce, Inc.,
55864
+ * All rights reserved.
55865
+ * For full license text, see the LICENSE.txt file
55866
+ */
55867
+ let NetworkCommand$1 = class NetworkCommand extends BaseCommand {
55868
+ constructor(services) {
55869
+ super();
55870
+ this.services = services;
55871
+ this.subscriptions = [];
55872
+ this.exposeSubscribeAndRefresh = false;
55873
+ }
55874
+ execute() {
55875
+ const result = this.fetch();
55876
+ if (this.exposeSubscribeAndRefresh) {
55877
+ return this.fetchSubscribableResult(result);
55878
+ }
55879
+ return result;
55880
+ }
55881
+ fetchSubscribableResult(res) {
55882
+ return res.then((networkResult) => {
55883
+ if (networkResult.isErr()) {
55884
+ return err$1(networkResult.error);
55885
+ } else {
55886
+ const data = networkResult.value;
55887
+ return ok$2({
55888
+ data,
55889
+ subscribe: (cb) => {
55890
+ this.subscriptions.push(cb);
55891
+ return () => {
55892
+ this.subscriptions = this.subscriptions.filter((cb2) => cb2 !== cb);
55893
+ };
55894
+ },
55895
+ refresh: () => this.refresh()
55896
+ });
55897
+ }
55898
+ });
55899
+ }
55900
+ refresh() {
55901
+ return this.execute().then((newResult) => {
55902
+ if (newResult.isOk()) {
55903
+ if (isSubscribableResult(newResult)) {
55904
+ const value = newResult.value;
55905
+ this.subscriptions.forEach((cb) => {
55906
+ cb(ok$2(value.data));
55907
+ });
55908
+ }
55909
+ return ok$2(void 0);
55910
+ }
55911
+ return err$1(newResult.error);
55912
+ });
55913
+ }
55914
+ async afterRequestHooks(_options) {
55915
+ }
55916
+ };
55917
+ function buildServiceDescriptor$b() {
55918
+ return {
55919
+ type: "networkCommandBaseClass",
55920
+ version: "1.0",
55921
+ service: NetworkCommand$1
55922
+ };
55923
+ }
55924
+
55925
+ /*!
55926
+ * Copyright (c) 2022, Salesforce, Inc.,
55927
+ * All rights reserved.
55928
+ * For full license text, see the LICENSE.txt file
55929
+ */
55930
+ class AuraNetworkCommand extends NetworkCommand$1 {
55931
+ constructor(services) {
55932
+ super(services);
55933
+ this.services = services;
55934
+ this.actionConfig = {
55935
+ background: false,
55936
+ hotspot: true,
55937
+ longRunning: false,
55938
+ storable: false
55939
+ };
55940
+ this.networkPreference = "aura";
55941
+ }
55942
+ get fetchParams() {
55943
+ throw new Error(
55944
+ "Fetch parameters must be specified when using HTTP transport on an Aura adapter"
55945
+ );
55946
+ }
55947
+ coerceAuraErrors(auraErrors) {
55948
+ return toError(auraErrors[0]);
55949
+ }
55950
+ async coerceFetchErrors(errorResponse) {
55951
+ return toError(errorResponse.statusText);
55952
+ }
55953
+ convertAuraResponseToData(responsePromise, coerceError) {
55954
+ return responsePromise.then((response) => {
55955
+ const auraReturnValue = response.getReturnValue();
55956
+ try {
55957
+ this.afterRequestHooks({ statusCode: 200 });
55958
+ } catch (e) {
55959
+ }
55960
+ return ok$2(auraReturnValue);
55961
+ }).catch((error) => {
55962
+ if (!error || !error.getError) {
55963
+ return err$1(toError("Failed to get error from response"));
55964
+ } else {
55965
+ const actionErrors = error.getError();
55966
+ if (actionErrors.length > 0) {
55967
+ return err$1(coerceError(actionErrors));
55968
+ } else {
55969
+ return err$1(toError("Error fetching component"));
55970
+ }
55971
+ }
55972
+ });
55973
+ }
55974
+ convertFetchResponseToData(response) {
55975
+ return response.then(
55976
+ (response2) => {
55977
+ if (response2.ok) {
55978
+ return response2.json().then(
55979
+ (json) => ok$2(json),
55980
+ (reason) => err$1(toError(reason))
55981
+ ).finally(() => {
55982
+ try {
55983
+ this.afterRequestHooks({ statusCode: response2.status });
55984
+ } catch (e) {
55985
+ }
55986
+ });
55987
+ } else {
55988
+ return this.coerceFetchErrors(response2).then((coercedError) => {
55989
+ return err$1(coercedError);
55990
+ }).finally(() => {
55991
+ try {
55992
+ this.afterRequestHooks({ statusCode: response2.status });
55993
+ } catch (e) {
55994
+ }
55995
+ });
55996
+ }
55997
+ },
55998
+ (reason) => err$1(toError(reason))
55999
+ );
56000
+ }
56001
+ shouldUseAuraNetwork() {
56002
+ return this.services.auraNetwork !== void 0 && (this.networkPreference === "aura" || !this.services.fetch);
56003
+ }
56004
+ shouldUseFetch() {
56005
+ return this.services.fetch !== void 0 && (this.networkPreference === "http" || !this.services.auraNetwork);
56006
+ }
56007
+ fetch() {
56008
+ if (this.shouldUseAuraNetwork()) {
56009
+ return this.convertAuraResponseToData(
56010
+ this.services.auraNetwork(this.endpoint, this.auraParams, this.actionConfig),
56011
+ this.coerceAuraErrors
56012
+ );
56013
+ } else if (this.shouldUseFetch()) {
56014
+ return this.convertFetchResponseToData(this.services.fetch(...this.fetchParams));
56015
+ }
56016
+ return resolvedPromiseLike$3(err$1(toError("Aura/Fetch network services not found")));
56017
+ }
56018
+ }
56019
+ function buildServiceDescriptor$a() {
56020
+ return {
56021
+ type: "auraNetworkCommandBaseClass",
56022
+ version: "1.0",
56023
+ service: AuraNetworkCommand
56024
+ };
56025
+ }
56026
+
56027
+ /*!
56028
+ * Copyright (c) 2022, Salesforce, Inc.,
56029
+ * All rights reserved.
56030
+ * For full license text, see the LICENSE.txt file
56031
+ */
56032
+ /*!
56033
+ * Copyright (c) 2022, Salesforce, Inc.,
56034
+ * All rights reserved.
56035
+ * For full license text, see the LICENSE.txt file
56036
+ */
56037
+ const { isArray } = Array;
56038
+ let Ok$1 = class Ok {
56039
+ constructor(value) {
56040
+ this.value = value;
56041
+ }
56042
+ isOk() {
56043
+ return true;
56044
+ }
56045
+ isErr() {
56046
+ return !this.isOk();
56047
+ }
56048
+ };
56049
+ class Err {
56050
+ constructor(error) {
56051
+ this.error = error;
56052
+ }
56053
+ isOk() {
56054
+ return false;
56055
+ }
56056
+ isErr() {
56057
+ return !this.isOk();
56058
+ }
56059
+ }
56060
+ const ok$1 = (value) => new Ok$1(value);
56061
+ const err = (err2) => new Err(err2);
56062
+ function resolvedPromiseLike$2(result) {
56063
+ if (isPromiseLike$2(result)) {
56064
+ return result.then((nextResult) => nextResult);
56065
+ }
56066
+ return {
56067
+ then: (onFulfilled, _onRejected) => {
56068
+ try {
56069
+ return resolvedPromiseLike$2(onFulfilled(result));
56070
+ } catch (e) {
56071
+ if (onFulfilled === void 0) {
56072
+ return resolvedPromiseLike$2(result);
56073
+ }
56074
+ return rejectedPromiseLike$2(e);
56075
+ }
56076
+ }
56077
+ };
56078
+ }
56079
+ function rejectedPromiseLike$2(reason) {
56080
+ if (isPromiseLike$2(reason)) {
56081
+ return reason.then((nextResult) => nextResult);
56082
+ }
56083
+ return {
56084
+ then: (_onFulfilled, onRejected) => {
56085
+ if (typeof onRejected === "function") {
56086
+ try {
56087
+ return resolvedPromiseLike$2(onRejected(reason));
56088
+ } catch (e) {
56089
+ return rejectedPromiseLike$2(e);
56090
+ }
56091
+ }
56092
+ return rejectedPromiseLike$2(reason);
56093
+ }
56094
+ };
56095
+ }
56096
+ function isPromiseLike$2(x) {
56097
+ return typeof (x == null ? void 0 : x.then) === "function";
56098
+ }
56099
+ function deepEquals(x, y) {
56100
+ if (x === void 0) {
56101
+ return y === void 0;
56102
+ } else if (x === null) {
56103
+ return y === null;
56104
+ } else if (y === null) {
56105
+ return x === null;
56106
+ } else if (isArray(x)) {
56107
+ if (!isArray(y) || x.length !== y.length) {
56108
+ return false;
56109
+ }
56110
+ for (let i = 0; i < x.length; ++i) {
56111
+ if (!deepEquals(x[i], y[i])) {
56112
+ return false;
56113
+ }
56114
+ }
56115
+ return true;
56116
+ } else if (typeof x === "object") {
56117
+ if (typeof y !== "object") {
56118
+ return false;
56119
+ }
56120
+ const xkeys = Object.keys(x);
56121
+ const ykeys = Object.keys(y);
56122
+ if (xkeys.length !== ykeys.length) {
56123
+ return false;
56124
+ }
56125
+ for (let i = 0; i < xkeys.length; ++i) {
56126
+ const key = xkeys[i];
56127
+ if (!deepEquals(x[key], y[key])) {
56128
+ return false;
56129
+ }
56130
+ }
56131
+ return true;
56132
+ }
56133
+ return x === y;
56134
+ }
56135
+ function setOverlaps(setA, setB) {
56136
+ if (setA.size > setB.size) {
56137
+ for (const key of setB.keys()) {
56138
+ if (setA.has(key)) {
56139
+ return true;
56140
+ }
56141
+ }
56142
+ } else {
56143
+ for (const key of setA) {
56144
+ if (setB.has(key)) {
56145
+ return true;
56146
+ }
56147
+ }
56148
+ }
56149
+ return false;
56150
+ }
56151
+ class CacheControlCommand extends BaseCommand {
56152
+ constructor(services) {
56153
+ super();
56154
+ this.services = services;
56155
+ this.keysUsed = /* @__PURE__ */ new Set();
56156
+ this.keysUpdated = void 0;
56157
+ this.operationType = "query";
56158
+ this.lastEmittedData = void 0;
56159
+ this.unsubscribeFromKeysImpl = () => void 0;
56160
+ this.subscriptions = [];
56161
+ this.instantiationTime = Date.now() / 1e3;
56162
+ }
56163
+ execute(overrides) {
56164
+ this.keysUpdated = void 0;
56165
+ this.unsubscribeFromKeys();
56166
+ const mergedCacheControlConfig = mergeCacheControlConfigs(
56167
+ this.cacheControlStrategyConfig,
56168
+ overrides
56169
+ );
56170
+ let returnData;
56171
+ let returnError;
56172
+ const requestRunner = {
56173
+ readFromCache: (cache) => {
56174
+ const resultPromise2 = this.buildResultWithSubscribe(cache);
56175
+ return resultPromise2.then((result) => {
56176
+ if (result.isErr()) {
56177
+ return err(result.error);
56178
+ }
56179
+ returnData = result;
56180
+ return ok$1(void 0);
56181
+ });
56182
+ },
56183
+ requestFromNetwork: () => {
56184
+ const that = this;
56185
+ return async function* () {
56186
+ const result = await that.requestFromNetwork();
56187
+ if (result.isErr()) {
56188
+ returnError = result;
56189
+ }
56190
+ yield result;
56191
+ }();
56192
+ },
56193
+ writeToCache: (cache, networkResult) => {
56194
+ return this.writeToCacheAndRecordKeys(cache, networkResult);
56195
+ }
56196
+ };
56197
+ const resultPromise = this.services.cacheController.execute(mergedCacheControlConfig, requestRunner, {
56198
+ instrumentationAttributes: this.instrumentationAttributes
56199
+ });
56200
+ return resultPromise.then((result) => {
56201
+ return this.publishUpdatedKeys().then(() => {
56202
+ if (returnError) {
56203
+ return returnError;
56204
+ }
56205
+ if (result.isErr()) {
56206
+ return err(result.error);
56207
+ }
56208
+ if (this.subscriptions.length > 0) {
56209
+ this.subscribeToKeysUsed();
56210
+ }
56211
+ if (returnData === void 0) {
56212
+ return err(new Error("Cache miss after fetching from network"));
56213
+ }
56214
+ if (returnData.isOk() && this.lastEmittedData === void 0) {
56215
+ this.lastEmittedData = returnData.value.data;
56216
+ }
56217
+ return returnData;
56218
+ });
56219
+ });
56220
+ }
56221
+ publishUpdatedKeys() {
56222
+ if (this.services.pubSub) {
56223
+ if (this.keysUpdated !== void 0 && this.keysUpdated.size > 0) {
56224
+ return this.services.pubSub.publish({
56225
+ type: "cacheUpdate",
56226
+ data: this.keysUpdated
56227
+ });
56228
+ }
56229
+ }
56230
+ return resolvedPromiseLike$2(void 0);
56231
+ }
56232
+ subscribeToKeysUsed() {
56233
+ this.unsubscribeFromKeys();
56234
+ const { pubSub } = this.services;
56235
+ if (!pubSub) {
56236
+ this.unsubscribeFromKeysImpl = () => void 0;
56237
+ return;
56238
+ }
56239
+ const rebuildUnsubscribe = pubSub.subscribe({
56240
+ type: "cacheUpdate",
56241
+ predicate: (event) => setOverlaps(event.data, this.keysUsed),
56242
+ callback: () => this.rerun({ now: this.instantiationTime }).then(() => void 0),
56243
+ keys: this.keysUsed
56244
+ });
56245
+ const refreshUnsubscribe = pubSub.subscribe({
56246
+ type: "cacheInvalidation",
56247
+ predicate: (event) => setOverlaps(event.data, this.keysUsed),
56248
+ callback: () => this.rerun().then(() => void 0),
56249
+ keys: this.keysUsed
56250
+ });
56251
+ this.unsubscribeFromKeysImpl = () => {
56252
+ rebuildUnsubscribe();
56253
+ refreshUnsubscribe();
56254
+ };
56255
+ return;
56256
+ }
56257
+ unsubscribeFromKeys() {
56258
+ this.unsubscribeFromKeysImpl();
56259
+ }
56260
+ // TODO: This should likely be abstract in v2. For v1, provide default comparison logic.
56261
+ equals(result1, result2) {
56262
+ return deepEquals(result1, result2);
56263
+ }
56264
+ async afterRequestHooks(_options) {
56265
+ }
56266
+ refresh() {
56267
+ return this.rerun({ cacheControlConfig: { type: "no-cache" } }).then((result) => {
56268
+ if (result.isErr()) {
56269
+ return err(result.error);
56270
+ }
56271
+ return ok$1(void 0);
56272
+ });
56273
+ }
56274
+ writeToCacheAndRecordKeys(cache, networkResult) {
56275
+ const recordableCache = cache.record();
56276
+ return this.writeToCache(recordableCache, networkResult).then((result) => {
56277
+ this.instantiationTime = Date.now() / 1e3;
56278
+ this.keysUpdated = recordableCache.keysUpdated;
56279
+ return ok$1(result);
56280
+ });
56281
+ }
56282
+ buildResultWithSubscribe(cache) {
56283
+ const recordableCache = cache.record();
56284
+ const result = this.readFromCache(recordableCache);
56285
+ return result.then((readResult) => {
56286
+ if (readResult.isErr()) {
56287
+ return err(readResult.error);
56288
+ } else {
56289
+ const data = readResult.value;
56290
+ this.keysUsed = recordableCache.keysRead;
56291
+ return ok$1({
56292
+ data,
56293
+ subscribe: this.buildSubscribe(),
56294
+ refresh: () => this.refresh()
56295
+ });
56296
+ }
56297
+ });
56298
+ }
56299
+ /**
56300
+ * Builds a function that subscribes to cache changes via the pubsub service. Whenever
56301
+ * relevant cache updates occur, it re-reads the data and compares it against
56302
+ * the last known value. If a change is detected, the provided
56303
+ * callback is invoked.
56304
+ *
56305
+ * @param keysRead - keys of interest that were read during readFromCache
56306
+ * @returns an unsubscribe function to stop watching for updates
56307
+ */
56308
+ buildSubscribe() {
56309
+ return (consumerCallback) => {
56310
+ if (this.subscriptions.length === 0 && this.operationType === "query") {
56311
+ this.subscribeToKeysUsed();
56312
+ }
56313
+ this.subscriptions.push(consumerCallback);
56314
+ return () => {
56315
+ this.subscriptions = this.subscriptions.filter((cb) => cb !== consumerCallback);
56316
+ if (this.subscriptions.length === 0) {
56317
+ this.unsubscribeFromKeys();
56318
+ }
56319
+ };
56320
+ };
56321
+ }
56322
+ rerun(overrides) {
56323
+ return this.execute(overrides).then((result) => {
56324
+ if (result.isErr()) {
56325
+ this.invokeConsumerCallbacks(result);
56326
+ return result;
56327
+ }
56328
+ if (!this.equals(this.lastEmittedData, result.value.data)) {
56329
+ this.lastEmittedData = result.value.data;
56330
+ this.invokeConsumerCallbacks(ok$1(result.value.data));
56331
+ }
56332
+ return result;
56333
+ });
56334
+ }
56335
+ invokeConsumerCallbacks(data) {
56336
+ this.subscriptions.forEach((cb) => {
56337
+ try {
56338
+ cb(data);
56339
+ } catch (error) {
56340
+ }
56341
+ });
56342
+ }
56343
+ }
56344
+ function mergeCacheControlConfigs(baseConfig, overrides) {
56345
+ if (!overrides) {
56346
+ return baseConfig;
56347
+ }
56348
+ const now = overrides.now ?? baseConfig.now;
56349
+ if (!overrides.cacheControlConfig) {
56350
+ return {
56351
+ ...baseConfig,
56352
+ now
56353
+ };
56354
+ }
56355
+ return {
56356
+ ...overrides.cacheControlConfig,
56357
+ now
56358
+ };
56359
+ }
56360
+
56361
+ /*!
56362
+ * Copyright (c) 2022, Salesforce, Inc.,
56363
+ * All rights reserved.
56364
+ * For full license text, see the LICENSE.txt file
56365
+ */
56366
+ /*!
56367
+ * Copyright (c) 2022, Salesforce, Inc.,
56368
+ * All rights reserved.
56369
+ * For full license text, see the LICENSE.txt file
56370
+ */
56371
+ let AuraCacheControlCommand$1 = class AuraCacheControlCommand extends CacheControlCommand {
56372
+ constructor(services) {
56373
+ super(services);
56374
+ this.services = services;
56375
+ this.actionConfig = {
56376
+ background: false,
56377
+ hotspot: true,
56378
+ longRunning: false,
56379
+ storable: false
56380
+ };
56381
+ this.networkPreference = "aura";
56382
+ }
56383
+ get fetchParams() {
56384
+ throw new Error(
56385
+ "Fetch parameters must be specified when using HTTP transport on an Aura adapter"
56386
+ );
56387
+ }
56388
+ shouldUseAuraNetwork() {
56389
+ return this.services.auraNetwork !== void 0 && (this.networkPreference === "aura" || !this.services.fetch);
56390
+ }
56391
+ shouldUseFetch() {
56392
+ return this.services.fetch !== void 0 && (this.networkPreference === "http" || !this.services.auraNetwork);
56393
+ }
56394
+ requestFromNetwork() {
56395
+ if (this.shouldUseAuraNetwork()) {
56396
+ return this.convertAuraResponseToData(
56397
+ this.services.auraNetwork(this.endpoint, this.auraParams, this.actionConfig),
56398
+ (errs) => this.coerceError(errs)
56399
+ );
56400
+ } else if (this.shouldUseFetch()) {
56401
+ return this.convertFetchResponseToData(this.services.fetch(...this.fetchParams));
56402
+ }
56403
+ return resolvedPromiseLike$3(err$1(toError("Aura/Fetch network services not found")));
56404
+ }
56405
+ coerceError(auraErrors) {
56406
+ return toError(auraErrors[0]);
56407
+ }
56408
+ async coerceFetchError(errorResponse) {
56409
+ return toError(errorResponse.statusText);
56410
+ }
56411
+ convertAuraResponseToData(responsePromise, coerceError) {
56412
+ return responsePromise.then((response) => {
56413
+ const auraReturnValue = response.getReturnValue();
56414
+ try {
56415
+ this.afterRequestHooks({ statusCode: 200 });
56416
+ } catch (e) {
56417
+ }
56418
+ return ok$2(auraReturnValue);
56419
+ }).catch((error) => {
56420
+ if (!error || !error.getError) {
56421
+ return err$1(toError("Failed to get error from response"));
56422
+ } else {
56423
+ const actionErrors = error.getError();
56424
+ if (actionErrors.length > 0) {
56425
+ return err$1(coerceError(actionErrors));
56426
+ } else {
56427
+ return err$1(toError("Error fetching component"));
56428
+ }
56429
+ }
56430
+ });
56431
+ }
56432
+ convertFetchResponseToData(response) {
56433
+ return response.then(
56434
+ (response2) => {
56435
+ if (response2.ok) {
56436
+ return response2.json().then(
56437
+ (json) => ok$2(json),
56438
+ (reason) => err$1(toError(reason))
56439
+ ).finally(() => {
56440
+ try {
56441
+ this.afterRequestHooks({ statusCode: response2.status });
56442
+ } catch (e) {
56443
+ }
56444
+ });
56445
+ } else {
56446
+ return this.coerceFetchError(response2).then((coercedError) => {
56447
+ return err$1(coercedError);
56448
+ }).finally(() => {
56449
+ try {
56450
+ this.afterRequestHooks({ statusCode: response2.status });
56451
+ } catch (e) {
56452
+ }
56453
+ });
56454
+ }
56455
+ },
56456
+ (reason) => err$1(toError(reason))
56457
+ );
56458
+ }
56459
+ };
56460
+ class AuraNormalizedCacheControlCommand extends AuraCacheControlCommand$1 {
56461
+ constructor(services) {
56462
+ super(services);
56463
+ this.services = services;
56464
+ }
56465
+ readFromCache(cache) {
56466
+ const data = this.buildResultType().query(cache, this.buildQuery());
56467
+ if (data.isErr()) {
56468
+ return resolvedPromiseLike$3(
56469
+ err$1(new Error(`Failed to build data from type: ${stringify$1(data.error)}`))
56470
+ );
56471
+ }
56472
+ return resolvedPromiseLike$3(ok$2(data.value));
56473
+ }
56474
+ writeToCache(cache, networkResult) {
56475
+ if (networkResult.isOk()) {
56476
+ this.buildResultType().write(
56477
+ cache.buildFixedTimeWritableCache(Date.now() / 1e3),
56478
+ this.buildWriteInput(networkResult.value)
56479
+ );
56480
+ }
56481
+ return resolvedPromiseLike$3(void 0);
56482
+ }
56483
+ }
56484
+ function buildServiceDescriptor$9() {
56485
+ return {
56486
+ type: "auraNormalizedCacheControlCommand",
56487
+ version: "1.0",
56488
+ service: AuraNormalizedCacheControlCommand
56489
+ };
56490
+ }
56491
+
56492
+ /*!
56493
+ * Copyright (c) 2022, Salesforce, Inc.,
56494
+ * All rights reserved.
56495
+ * For full license text, see the LICENSE.txt file
56496
+ */
56497
+ /*!
56498
+ * Copyright (c) 2022, Salesforce, Inc.,
56499
+ * All rights reserved.
56500
+ * For full license text, see the LICENSE.txt file
56501
+ */
56502
+ class AuraCacheControlCommand extends CacheControlCommand {
56503
+ constructor(services) {
56504
+ super(services);
56505
+ this.services = services;
56506
+ this.actionConfig = {
56507
+ background: false,
56508
+ hotspot: true,
56509
+ longRunning: false,
56510
+ storable: false
56511
+ };
56512
+ this.networkPreference = "aura";
56513
+ }
56514
+ get fetchParams() {
56515
+ throw new Error(
56516
+ "Fetch parameters must be specified when using HTTP transport on an Aura adapter"
56517
+ );
56518
+ }
56519
+ shouldUseAuraNetwork() {
56520
+ return this.services.auraNetwork !== void 0 && (this.networkPreference === "aura" || !this.services.fetch);
56521
+ }
56522
+ shouldUseFetch() {
56523
+ return this.services.fetch !== void 0 && (this.networkPreference === "http" || !this.services.auraNetwork);
56524
+ }
56525
+ requestFromNetwork() {
56526
+ if (this.shouldUseAuraNetwork()) {
56527
+ return this.convertAuraResponseToData(
56528
+ this.services.auraNetwork(this.endpoint, this.auraParams, this.actionConfig),
56529
+ (errs) => this.coerceError(errs)
56530
+ );
56531
+ } else if (this.shouldUseFetch()) {
56532
+ return this.convertFetchResponseToData(this.services.fetch(...this.fetchParams));
56533
+ }
56534
+ return resolvedPromiseLike$3(err$1(toError("Aura/Fetch network services not found")));
56535
+ }
56536
+ coerceError(auraErrors) {
56537
+ return toError(auraErrors[0]);
56538
+ }
56539
+ async coerceFetchError(errorResponse) {
56540
+ return toError(errorResponse.statusText);
56541
+ }
56542
+ convertAuraResponseToData(responsePromise, coerceError) {
56543
+ return responsePromise.then((response) => {
56544
+ const auraReturnValue = response.getReturnValue();
56545
+ try {
56546
+ this.afterRequestHooks({ statusCode: 200 });
56547
+ } catch (e) {
56548
+ }
56549
+ return ok$2(auraReturnValue);
56550
+ }).catch((error) => {
56551
+ if (!error || !error.getError) {
56552
+ return err$1(toError("Failed to get error from response"));
56553
+ } else {
56554
+ const actionErrors = error.getError();
56555
+ if (actionErrors.length > 0) {
56556
+ return err$1(coerceError(actionErrors));
56557
+ } else {
56558
+ return err$1(toError("Error fetching component"));
56559
+ }
56560
+ }
56561
+ });
56562
+ }
56563
+ convertFetchResponseToData(response) {
56564
+ return response.then(
56565
+ (response2) => {
56566
+ if (response2.ok) {
56567
+ return response2.json().then(
56568
+ (json) => ok$2(json),
56569
+ (reason) => err$1(toError(reason))
56570
+ ).finally(() => {
56571
+ try {
56572
+ this.afterRequestHooks({ statusCode: response2.status });
56573
+ } catch (e) {
56574
+ }
56575
+ });
56576
+ } else {
56577
+ return this.coerceFetchError(response2).then((coercedError) => {
56578
+ return err$1(coercedError);
56579
+ }).finally(() => {
56580
+ try {
56581
+ this.afterRequestHooks({ statusCode: response2.status });
56582
+ } catch (e) {
56583
+ }
56584
+ });
56585
+ }
56586
+ },
56587
+ (reason) => err$1(toError(reason))
56588
+ );
56589
+ }
56590
+ }
56591
+ class AuraResourceCacheControlCommand extends AuraCacheControlCommand {
56592
+ constructor(services) {
56593
+ super(services);
56594
+ this.services = services;
56595
+ }
56596
+ execute() {
56597
+ return super.execute();
56598
+ }
56599
+ readFromCache(cache) {
56600
+ var _a;
56601
+ const data = (_a = cache.get(this.buildKey())) == null ? void 0 : _a.value;
56602
+ if (data === void 0) {
56603
+ return resolvedPromiseLike$3(err$1(new Error("Failed to find data in cache")));
56604
+ }
56605
+ return resolvedPromiseLike$3(ok$2(data));
56606
+ }
56607
+ writeToCache(cache, networkResult) {
56608
+ if (networkResult.isOk()) {
56609
+ cache.set(this.buildKey(), {
56610
+ value: networkResult.value,
56611
+ metadata: {
56612
+ cacheControl: this.buildCacheControlMetadata(networkResult.value)
56613
+ }
56614
+ });
56615
+ }
56616
+ return resolvedPromiseLike$3(void 0);
56617
+ }
56618
+ buildKey() {
56619
+ return `{"endpoint":${this.endpoint},"params":${stableJSONStringify(this.auraParams)}}`;
56620
+ }
56621
+ }
56622
+ function buildServiceDescriptor$8() {
56623
+ return {
56624
+ type: "auraResourceCacheControlCommand",
56625
+ version: "1.0",
56626
+ service: AuraResourceCacheControlCommand
56627
+ };
56628
+ }
56629
+
56630
+ /*!
56631
+ * Copyright (c) 2022, Salesforce, Inc.,
56632
+ * All rights reserved.
56633
+ * For full license text, see the LICENSE.txt file
56634
+ */
56635
+ /*!
56636
+ * Copyright (c) 2022, Salesforce, Inc.,
56637
+ * All rights reserved.
56638
+ * For full license text, see the LICENSE.txt file
56639
+ */
56640
+ class NetworkCommand extends BaseCommand {
56641
+ constructor(services) {
56642
+ super();
56643
+ this.services = services;
56644
+ this.subscriptions = [];
56645
+ this.exposeSubscribeAndRefresh = false;
56646
+ }
56647
+ execute() {
56648
+ const result = this.fetch();
56649
+ if (this.exposeSubscribeAndRefresh) {
56650
+ return this.fetchSubscribableResult(result);
56651
+ }
56652
+ return result;
56653
+ }
56654
+ fetchSubscribableResult(res) {
56655
+ return res.then((networkResult) => {
56656
+ if (networkResult.isErr()) {
56657
+ return err$1(networkResult.error);
56658
+ } else {
56659
+ const data = networkResult.value;
56660
+ return ok$2({
56661
+ data,
56662
+ subscribe: (cb) => {
56663
+ this.subscriptions.push(cb);
56664
+ return () => {
56665
+ this.subscriptions = this.subscriptions.filter((cb2) => cb2 !== cb);
56666
+ };
56667
+ },
56668
+ refresh: () => this.refresh()
56669
+ });
56670
+ }
56671
+ });
56672
+ }
56673
+ refresh() {
56674
+ return this.execute().then((newResult) => {
56675
+ if (newResult.isOk()) {
56676
+ if (isSubscribableResult(newResult)) {
56677
+ const value = newResult.value;
56678
+ this.subscriptions.forEach((cb) => {
56679
+ cb(ok$2(value.data));
56680
+ });
56681
+ }
56682
+ return ok$2(void 0);
56683
+ }
56684
+ return err$1(newResult.error);
56685
+ });
56686
+ }
56687
+ async afterRequestHooks(_options) {
56688
+ }
56689
+ }
56690
+ class FetchNetworkCommand extends NetworkCommand {
56691
+ constructor(services) {
56692
+ super(services);
56693
+ this.services = services;
56694
+ }
56695
+ fetch() {
56696
+ return this.convertFetchResponseToData(this.services.fetch(...this.fetchParams));
56697
+ }
56698
+ async coerceError(errorResponse) {
56699
+ return toError(errorResponse.statusText);
56700
+ }
56701
+ convertFetchResponseToData(response) {
56702
+ return response.then(
56703
+ (response2) => {
56704
+ if (response2.ok) {
56705
+ return response2.json().then(
56706
+ (json) => ok$2(json),
56707
+ (reason) => err$1(toError(reason))
56708
+ ).finally(() => {
56709
+ try {
56710
+ this.afterRequestHooks({ statusCode: response2.status });
56711
+ } catch (e) {
56712
+ }
56713
+ });
56714
+ } else {
56715
+ return this.coerceError(response2).then((coercedError) => {
56716
+ return err$1(coercedError);
56717
+ }).finally(() => {
56718
+ try {
56719
+ this.afterRequestHooks({ statusCode: response2.status });
56720
+ } catch (e) {
56721
+ }
56722
+ });
56723
+ }
56724
+ },
56725
+ (reason) => err$1(toError(reason))
56726
+ );
56727
+ }
56728
+ }
56729
+ function buildServiceDescriptor$7() {
56730
+ return {
56731
+ type: "fetchNetworkCommandBaseClass",
56732
+ version: "1.0",
56733
+ service: FetchNetworkCommand
56734
+ };
56735
+ }
56736
+
56737
+ /*!
56738
+ * Copyright (c) 2022, Salesforce, Inc.,
56739
+ * All rights reserved.
56740
+ * For full license text, see the LICENSE.txt file
56741
+ */
56742
+ /*!
56743
+ * Copyright (c) 2022, Salesforce, Inc.,
56744
+ * All rights reserved.
56745
+ * For full license text, see the LICENSE.txt file
56746
+ */
56747
+ class HttpCacheControlCommand extends CacheControlCommand {
56748
+ constructor(services) {
56749
+ super(services);
56750
+ this.services = services;
56751
+ }
56752
+ requestFromNetwork() {
56753
+ return this.fetch();
56754
+ }
56755
+ fetch() {
56756
+ return this.convertFetchResponseToData(this.services.fetch(...this.fetchParams));
56757
+ }
56758
+ async coerceError(errorResponse) {
56759
+ return toError(errorResponse.statusText);
56760
+ }
56761
+ convertFetchResponseToData(response) {
56762
+ return response.then(
56763
+ (response2) => {
56764
+ if (response2.ok) {
56765
+ return response2.json().then(
56766
+ (json) => ok$2(json),
56767
+ (reason) => err$1(toError(reason))
56768
+ ).finally(() => {
56769
+ try {
56770
+ this.afterRequestHooks({ statusCode: response2.status });
56771
+ } catch (e) {
56772
+ }
56773
+ });
56774
+ } else {
56775
+ return this.coerceError(response2).then((coercedError) => {
56776
+ return err$1(coercedError);
56777
+ }).finally(() => {
56778
+ try {
56779
+ this.afterRequestHooks({ statusCode: response2.status });
56780
+ } catch (e) {
56781
+ }
56782
+ });
56783
+ }
56784
+ },
56785
+ (reason) => err$1(toError(reason))
56786
+ );
56787
+ }
56788
+ }
56789
+ class HttpNormalizedCacheControlCommand extends HttpCacheControlCommand {
56790
+ constructor(services) {
56791
+ super(services);
56792
+ this.services = services;
56793
+ }
56794
+ readFromCache(cache) {
56795
+ const data = this.buildResultType().query(cache, this.buildQuery());
56796
+ if (data.isErr()) {
56797
+ return resolvedPromiseLike$3(
56798
+ err$1(new Error(`Failed to build data from type: ${stringify$1(data.error)}`))
56799
+ );
56800
+ }
56801
+ return resolvedPromiseLike$3(ok$2(data.value));
56802
+ }
56803
+ writeToCache(cache, networkResult) {
56804
+ if (networkResult.isOk()) {
56805
+ this.buildResultType().write(
56806
+ cache.buildFixedTimeWritableCache(Date.now() / 1e3),
56807
+ this.buildWriteInput(networkResult.value)
56808
+ );
56809
+ }
56810
+ return resolvedPromiseLike$3(void 0);
56811
+ }
56812
+ }
56813
+ function buildServiceDescriptor$6() {
56814
+ return {
56815
+ type: "httpNormalizedCacheControlCommand",
56816
+ version: "1.0",
56817
+ service: HttpNormalizedCacheControlCommand
56818
+ };
56819
+ }
56820
+
56821
+ /*!
56822
+ * Copyright (c) 2022, Salesforce, Inc.,
56823
+ * All rights reserved.
56824
+ * For full license text, see the LICENSE.txt file
56825
+ */
56826
+ /*!
56827
+ * Copyright (c) 2022, Salesforce, Inc.,
56828
+ * All rights reserved.
56829
+ * For full license text, see the LICENSE.txt file
56830
+ */
56831
+ const { stringify, parse } = JSON;
56832
+ function deepCopy(x) {
56833
+ const stringified = stringify(x);
56834
+ return stringified ? parse(stringified) : void 0;
56835
+ }
56836
+ class DefaultRecordableCache {
56837
+ constructor(baseCache) {
56838
+ this.baseCache = baseCache;
56839
+ this.keysRead = /* @__PURE__ */ new Set();
56840
+ this.missingKeysRead = /* @__PURE__ */ new Set();
56841
+ this.keysUpdated = /* @__PURE__ */ new Set();
56842
+ this.metadataKeysUpdated = /* @__PURE__ */ new Set();
56843
+ }
56844
+ delete(key) {
56845
+ this.keysUpdated.add(key);
56846
+ this.baseCache.delete(key);
56847
+ }
56848
+ get(key, options) {
56849
+ this.keysRead.add(key);
56850
+ const value = this.baseCache.get(key);
56851
+ if (value === void 0) {
56852
+ this.missingKeysRead.add(key);
56853
+ }
56854
+ if (options == null ? void 0 : options.copy) {
56855
+ return deepCopy(value);
56856
+ }
56857
+ return value;
56858
+ }
56859
+ set(key, value) {
56860
+ this.keysUpdated.add(key);
56861
+ this.metadataKeysUpdated.add(key);
56862
+ this.baseCache.set(key, value);
56863
+ }
56864
+ setMetadata(key, cacheControlMetadata) {
56865
+ this.metadataKeysUpdated.add(key);
56866
+ this.baseCache.setMetadata(key, cacheControlMetadata);
56867
+ }
56868
+ length() {
56869
+ return this.baseCache.length();
56870
+ }
56871
+ keys() {
56872
+ return this.baseCache.keys();
56873
+ }
56874
+ entries() {
56875
+ return this.baseCache.entries();
56876
+ }
56877
+ record() {
56878
+ return new DefaultRecordableCache(this);
56879
+ }
56880
+ filter(predicate) {
56881
+ return new DefaultFilteredCache(this, predicate);
56882
+ }
56883
+ buildFixedTimeWritableCache(generatedTime) {
56884
+ return new FixedTimeWritableCache(this, generatedTime);
56885
+ }
56886
+ }
56887
+ class DefaultFilteredCache {
56888
+ constructor(baseCache, predicate) {
56889
+ this.baseCache = baseCache;
56890
+ this.predicate = predicate;
56891
+ }
56892
+ delete(key) {
56893
+ this.baseCache.delete(key);
56894
+ }
56895
+ get(key, options) {
56896
+ const result = this.baseCache.get(key);
56897
+ if (result && this.predicate(key, result)) {
56898
+ if (options == null ? void 0 : options.copy) {
56899
+ return deepCopy(result);
56900
+ }
56901
+ return result;
56902
+ }
56903
+ return void 0;
56904
+ }
56905
+ set(key, value) {
56906
+ this.baseCache.set(key, value);
56907
+ }
56908
+ setMetadata(key, cacheControlMetadata) {
56909
+ this.baseCache.setMetadata(key, cacheControlMetadata);
56910
+ }
56911
+ length() {
56912
+ return this.getFilteredKeys().size;
56913
+ }
56914
+ keys() {
56915
+ return this.getFilteredKeys();
56916
+ }
56917
+ entries() {
56918
+ return this.getFilteredEntries();
56919
+ }
56920
+ record() {
56921
+ return new DefaultRecordableCache(this);
56922
+ }
56923
+ filter(predicate) {
56924
+ return new DefaultFilteredCache(this, predicate);
56925
+ }
56926
+ getFilteredEntries() {
56927
+ return this.baseCache.entries().filter(([key, _value]) => {
56928
+ return this.get(key);
56929
+ });
56930
+ }
56931
+ getFilteredKeys() {
56932
+ const filteredKeySet = /* @__PURE__ */ new Set();
56933
+ this.baseCache.keys().forEach((key) => {
56934
+ if (this.get(key)) {
56935
+ filteredKeySet.add(key);
56936
+ }
56937
+ });
56938
+ return filteredKeySet;
56939
+ }
56940
+ buildFixedTimeWritableCache(generatedTime) {
56941
+ return new FixedTimeWritableCache(this, generatedTime);
56942
+ }
56943
+ }
56944
+ class FixedTimeWritableCache {
56945
+ constructor(baseCache, generatedTime) {
56946
+ this.baseCache = baseCache;
56947
+ this.generatedTime = generatedTime;
56948
+ }
56949
+ delete(key) {
56950
+ this.baseCache.delete(key);
56951
+ }
56952
+ get(key, options) {
56953
+ return this.baseCache.get(key, options);
56954
+ }
56955
+ set(key, value) {
56956
+ this.baseCache.set(key, {
56957
+ ...value,
56958
+ metadata: {
56959
+ ...value.metadata,
56960
+ cacheControl: { ...value.metadata.cacheControl, generatedTime: this.generatedTime }
56961
+ }
56962
+ });
56963
+ }
56964
+ setMetadata(key, cacheControlMetadata) {
56965
+ this.baseCache.setMetadata(key, {
56966
+ ...cacheControlMetadata,
56967
+ generatedTime: this.generatedTime
56968
+ });
56969
+ }
56970
+ length() {
56971
+ return this.baseCache.length();
56972
+ }
56973
+ keys() {
56974
+ return this.baseCache.keys();
56975
+ }
56976
+ entries() {
56977
+ return this.baseCache.entries();
56978
+ }
56979
+ record() {
56980
+ return new DefaultRecordableCache(this);
56981
+ }
56982
+ filter(predicate) {
56983
+ return new DefaultFilteredCache(this, predicate);
56984
+ }
56985
+ buildFixedTimeWritableCache(generatedTime) {
56986
+ return new FixedTimeWritableCache(this, generatedTime);
56987
+ }
56988
+ }
56989
+ class DefaultCache {
56990
+ constructor() {
56991
+ this.data = {};
56992
+ }
56993
+ get(key, options) {
56994
+ if (options == null ? void 0 : options.copy) {
56995
+ return deepCopy(this.data[key]);
56996
+ }
56997
+ return this.data[key];
56998
+ }
56999
+ /**
57000
+ * Adds the specified key/value to the cache.
57001
+ *
57002
+ * @param key key at which to store value
57003
+ * @param entry value to be stored
57004
+ */
57005
+ set(key, entry) {
57006
+ if (entry.metadata.cacheControl.type === "no-store") {
57007
+ return;
57008
+ }
57009
+ this.data[key] = {
57010
+ ...entry,
57011
+ metadata: {
57012
+ ...entry.metadata,
57013
+ type: entry.metadata.type || {
57014
+ namespace: "OneStore:Internal",
57015
+ name: "UnknownType"
57016
+ },
57017
+ cacheControl: {
57018
+ generatedTime: Date.now() / 1e3,
57019
+ ...entry.metadata.cacheControl
57020
+ }
57021
+ }
57022
+ };
57023
+ }
57024
+ /**
57025
+ * Removes the cache entry associated with the specified key.
57026
+ *
57027
+ * @param key key to be removed from the store
57028
+ */
57029
+ delete(key) {
57030
+ delete this.data[key];
57031
+ }
57032
+ /**
57033
+ * Sets the metadata for the specified key if the key is in cache.
57034
+ * If the key doesn't exist, it does nothing.
57035
+ *
57036
+ * @param key key at which to store metadata
57037
+ * @param cacheControlMetadata metadata to be stored
57038
+ */
57039
+ setMetadata(key, cacheControlMetadata) {
57040
+ if (key in this.data) {
57041
+ this.data[key].metadata.cacheControl = {
57042
+ generatedTime: Date.now() / 1e3,
57043
+ ...cacheControlMetadata
57044
+ };
57045
+ }
57046
+ }
57047
+ length() {
57048
+ return this.keys().size;
57049
+ }
57050
+ keys() {
57051
+ return new Set(Object.keys(this.data));
57052
+ }
57053
+ entries() {
57054
+ return Object.entries(this.data);
57055
+ }
57056
+ record() {
57057
+ return new DefaultRecordableCache(this);
57058
+ }
57059
+ filter(predicate) {
57060
+ return new DefaultFilteredCache(this, predicate);
57061
+ }
57062
+ buildFixedTimeWritableCache(generatedTime) {
57063
+ return new FixedTimeWritableCache(this, generatedTime);
57064
+ }
57065
+ }
57066
+ function buildServiceDescriptor$5() {
57067
+ return {
57068
+ type: "cache",
57069
+ version: "1.0",
57070
+ service: new DefaultCache()
57071
+ };
57072
+ }
57073
+
57074
+ /*!
57075
+ * Copyright (c) 2022, Salesforce, Inc.,
57076
+ * All rights reserved.
57077
+ * For full license text, see the LICENSE.txt file
57078
+ */
57079
+ class CacheControlStrategy {
57080
+ constructor(services, config, requestRunner) {
57081
+ this.services = services;
57082
+ this.config = config;
57083
+ this.requestRunner = requestRunner;
57084
+ this.filteredCache = this.services.cache.filter((_, entry) => {
57085
+ const { cacheControl } = entry.metadata;
57086
+ return !this.expiredChecks.some((check) => check(cacheControl));
57087
+ });
57088
+ }
57089
+ get expiredChecks() {
57090
+ return [
57091
+ (cacheControlMetadata) => cacheControlMetadata.type === "max-age" && this.config.now > cacheControlMetadata.generatedTime + cacheControlMetadata.maxAge,
57092
+ (cacheControlMetadata) => cacheControlMetadata.type === "max-age" && cacheControlMetadata.maxAge <= 0,
57093
+ (cacheControlMetadata) => cacheControlMetadata.type === "no-store",
57094
+ (cacheControlMetadata) => cacheControlMetadata.type === "no-cache" && cacheControlMetadata.generatedTime < this.config.now
57095
+ ];
57096
+ }
57097
+ }
57098
+ class NoCacheCacheControlStrategy extends CacheControlStrategy {
57099
+ execute() {
57100
+ const tempCache = this.filteredCache;
57101
+ return new Promise(async (resolve, reject) => {
57102
+ try {
57103
+ let readResult = ok$2(void 0);
57104
+ for await (const rfnResult of this.requestRunner.requestFromNetwork()) {
57105
+ if (rfnResult) {
57106
+ const result = await this.services.cacheInclusionPolicy.write({
57107
+ l1: tempCache,
57108
+ writeToL1: (l1) => this.requestRunner.writeToCache(l1, rfnResult)
57109
+ });
57110
+ if (result.isErr()) {
57111
+ return resolve(result);
57112
+ }
57113
+ }
57114
+ readResult = await this.services.cacheInclusionPolicy.read({
57115
+ l1: tempCache,
57116
+ readFromL1: (l1) => this.requestRunner.readFromCache(l1)
57117
+ });
57118
+ if (readResult.isOk()) {
57119
+ resolve(readResult);
57120
+ }
57121
+ }
57122
+ return resolve(readResult);
57123
+ } catch (error) {
57124
+ return reject(error);
57125
+ }
57126
+ });
57127
+ }
57128
+ }
57129
+ class MaxAgeCacheControlStrategy extends CacheControlStrategy {
57130
+ execute(options) {
57131
+ const startTime = this.services.instrumentation ? this.services.instrumentation.currentTimeMs() : 0;
57132
+ return this.services.cacheInclusionPolicy.read({
57133
+ l1: this.filteredCache,
57134
+ readFromL1: (l1) => this.requestRunner.readFromCache(l1)
57135
+ }).then((value) => {
57136
+ if (value.isOk()) {
57137
+ this.collectCacheHitInstrumentation(
57138
+ startTime,
57139
+ options == null ? void 0 : options.instrumentationAttributes
57140
+ );
57141
+ return ok$2(void 0);
57142
+ }
57143
+ this.collectCacheMissInstrumentation(startTime, options == null ? void 0 : options.instrumentationAttributes);
57144
+ const tempCache = this.filteredCache;
57145
+ return new Promise(async (resolve, reject) => {
57146
+ try {
57147
+ let readResult = ok$2(void 0);
57148
+ for await (const rfnResult of this.requestRunner.requestFromNetwork()) {
57149
+ if (rfnResult) {
57150
+ const result = await this.services.cacheInclusionPolicy.write({
57151
+ l1: tempCache,
57152
+ writeToL1: (l1) => this.requestRunner.writeToCache(l1, rfnResult)
57153
+ });
57154
+ if (result.isErr()) {
57155
+ return resolve(err$1(result.error));
57156
+ }
57157
+ }
57158
+ readResult = await this.services.cacheInclusionPolicy.read({
57159
+ l1: tempCache,
57160
+ readFromL1: (l1) => this.requestRunner.readFromCache(l1)
57161
+ });
57162
+ if (readResult.isOk()) {
57163
+ resolve(ok$2(void 0));
57164
+ }
57165
+ }
57166
+ return resolve(readResult);
57167
+ } catch (e) {
57168
+ return reject(e);
57169
+ }
57170
+ });
57171
+ });
57172
+ }
57173
+ collectCacheHitInstrumentation(startTime, instrumentationAttributes) {
57174
+ if (this.services.instrumentation) {
57175
+ const meter = this.services.instrumentation.metrics.getMeter("onestore");
57176
+ meter.createCounter(`command.max-age.cache-hit.count`).add(1, instrumentationAttributes);
57177
+ meter.createHistogram(`command.max-age.cache-hit.duration`).record(
57178
+ this.services.instrumentation.currentTimeMs() - startTime,
57179
+ instrumentationAttributes
57180
+ );
57181
+ }
57182
+ }
57183
+ collectCacheMissInstrumentation(startTime, instrumentationAttributes) {
57184
+ if (this.services.instrumentation) {
57185
+ const meter = this.services.instrumentation.metrics.getMeter("onestore");
57186
+ meter.createCounter(`command.max-age.cache-miss.count`).add(1, instrumentationAttributes);
57187
+ meter.createHistogram(`command.max-age.cache-miss.duration`).record(
57188
+ this.services.instrumentation.currentTimeMs() - startTime,
57189
+ instrumentationAttributes
57190
+ );
57191
+ }
57192
+ }
57193
+ get expiredChecks() {
57194
+ const config = this.config;
57195
+ return [
57196
+ ...super.expiredChecks,
57197
+ (cacheControlMetadata) => {
57198
+ return cacheControlMetadata.generatedTime + config.requestMaxAge < config.now;
57199
+ }
57200
+ ];
57201
+ }
57202
+ }
57203
+ class CacheController {
57204
+ constructor(services) {
57205
+ this.services = services;
57206
+ }
57207
+ execute(config, requestRunner, options) {
57208
+ const strategy = this.getCacheControlStrategy(config, requestRunner);
57209
+ return strategy.execute(options);
57210
+ }
57211
+ getCacheControlStrategy(config, requestRunner) {
57212
+ if (config.type === "max-age") {
57213
+ return new MaxAgeCacheControlStrategy(this.services, config, requestRunner);
57214
+ } else if (config.type === "no-cache") {
57215
+ return new NoCacheCacheControlStrategy(this.services, config, requestRunner);
57216
+ }
57217
+ throw new Error(`Unknown cache control strategy ${config.type}`);
57218
+ }
57219
+ /**
57220
+ * Finds cache entries that match the given query.
57221
+ * Returns an async generator that yields `[key, entry]`.
57222
+ */
57223
+ async *find(query) {
57224
+ yield* this.services.cacheInclusionPolicy.find(query);
57225
+ }
57226
+ /**
57227
+ * Finds and modifies cache entries that match the given query.
57228
+ * Extends `find(query)` and returns an async generator of modified keys.
57229
+ */
57230
+ async *findAndModify(query, cacheUpdate) {
57231
+ yield* this.services.cacheInclusionPolicy.findAndModify(query, cacheUpdate);
57232
+ }
57233
+ }
57234
+ function buildServiceDescriptor$4(cache, cacheInclusionPolicy) {
57235
+ return {
57236
+ type: "cacheController",
57237
+ version: "1.0",
57238
+ service: new CacheController({ cache, cacheInclusionPolicy })
57239
+ };
57240
+ }
57241
+
57242
+ /*!
57243
+ * Copyright (c) 2022, Salesforce, Inc.,
57244
+ * All rights reserved.
57245
+ * For full license text, see the LICENSE.txt file
57246
+ */
57247
+ class CacheInclusionPolicyService {
57248
+ }
57249
+ /*!
57250
+ * Copyright (c) 2022, Salesforce, Inc.,
57251
+ * All rights reserved.
57252
+ * For full license text, see the LICENSE.txt file
57253
+ */
57254
+ class Ok {
57255
+ constructor(value) {
57256
+ this.value = value;
57257
+ }
57258
+ isOk() {
57259
+ return true;
57260
+ }
57261
+ isErr() {
57262
+ return !this.isOk();
57263
+ }
57264
+ }
57265
+ const ok = (value) => new Ok(value);
57266
+ function resolvedPromiseLike$1(result) {
57267
+ if (isPromiseLike$1(result)) {
57268
+ return result.then((nextResult) => nextResult);
57269
+ }
57270
+ return {
57271
+ then: (onFulfilled, _onRejected) => {
57272
+ try {
57273
+ return resolvedPromiseLike$1(onFulfilled(result));
57274
+ } catch (e) {
57275
+ if (onFulfilled === void 0) {
57276
+ return resolvedPromiseLike$1(result);
57277
+ }
57278
+ return rejectedPromiseLike$1(e);
57279
+ }
57280
+ }
57281
+ };
57282
+ }
57283
+ function rejectedPromiseLike$1(reason) {
57284
+ if (isPromiseLike$1(reason)) {
57285
+ return reason.then((nextResult) => nextResult);
57286
+ }
57287
+ return {
57288
+ then: (_onFulfilled, onRejected) => {
57289
+ if (typeof onRejected === "function") {
57290
+ try {
57291
+ return resolvedPromiseLike$1(onRejected(reason));
57292
+ } catch (e) {
57293
+ return rejectedPromiseLike$1(e);
57294
+ }
57295
+ }
57296
+ return rejectedPromiseLike$1(reason);
57297
+ }
57298
+ };
57299
+ }
57300
+ function isPromiseLike$1(x) {
57301
+ return typeof (x == null ? void 0 : x.then) === "function";
57302
+ }
57303
+ const isAndQuery = (query) => "$and" in query;
57304
+ const isOrQuery = (query) => "$or" in query;
57305
+ const isNotQuery = (query) => "$not" in query;
57306
+ const matchesMetadata = (metadataQuery, cacheControl) => {
57307
+ if ("cacheControlType" in metadataQuery && cacheControl.type !== metadataQuery.cacheControlType.$eq) {
57308
+ return false;
57309
+ }
57310
+ if ("maxAge" in metadataQuery && cacheControl.type === "max-age") {
57311
+ const maxAge = cacheControl.maxAge ?? 0;
57312
+ if (metadataQuery.maxAge.$gte !== void 0 && maxAge < metadataQuery.maxAge.$gte || metadataQuery.maxAge.$lte !== void 0 && maxAge > metadataQuery.maxAge.$lte) {
57313
+ return false;
57314
+ }
57315
+ }
57316
+ return true;
57317
+ };
57318
+ function queryToPredicate(query) {
57319
+ return (key, entry) => {
57320
+ if (!query) return false;
57321
+ if (isAndQuery(query))
57322
+ return query.$and.every((subQuery) => queryToPredicate(subQuery)(key, entry));
57323
+ if (isOrQuery(query))
57324
+ return query.$or.some((subQuery) => queryToPredicate(subQuery)(key, entry));
57325
+ if (isNotQuery(query)) return !queryToPredicate(query.$not)(key, entry);
57326
+ if ("key" in query) return matchesKey(query.key, key);
57327
+ if ("metadata" in query)
57328
+ return matchesMetadata(query.metadata, entry.metadata.cacheControl);
57329
+ if ("value" in query) return false;
57330
+ throw new Error("Unknown Query Operation");
57331
+ };
57332
+ }
57333
+ function matchesKey(keyQuery, key) {
57334
+ if ("$regex" in keyQuery) {
57335
+ return keyQuery.$regex.test(key);
57336
+ }
57337
+ return false;
57338
+ }
57339
+ function buildUpdate(update, existing) {
57340
+ switch (update.type) {
57341
+ case "invalidate":
57342
+ const updatedCacheControl = buildInvalidatedCacheControl(
57343
+ existing.metadata.cacheControl
57344
+ );
57345
+ return updatedCacheControl !== void 0 ? { type: "metadata", metadata: updatedCacheControl } : { type: "no-op" };
57346
+ default:
57347
+ throw new Error(`Invalid update operation: ${update.type}`);
57348
+ }
57349
+ }
57350
+ function buildInvalidatedCacheControl(existingCacheControl) {
57351
+ switch (existingCacheControl.type) {
57352
+ case "max-age":
57353
+ case "stale-while-revalidate":
57354
+ if (existingCacheControl.maxAge !== 0) {
57355
+ return {
57356
+ ...existingCacheControl,
57357
+ maxAge: 0
57358
+ };
57359
+ }
57360
+ }
57361
+ return void 0;
57362
+ }
57363
+ class InMemoryCacheInclusionPolicy extends CacheInclusionPolicyService {
57364
+ constructor(services) {
57365
+ super();
57366
+ this.services = services;
57367
+ }
57368
+ /**
57369
+ * Reads data out of a single level in memory store.
57370
+ */
57371
+ read(options) {
57372
+ const { l1, readFromL1 } = options;
57373
+ return readFromL1(l1);
57374
+ }
57375
+ /**
57376
+ * Writes data to a single level in memory store.
57377
+ */
57378
+ write(options) {
57379
+ const { l1, writeToL1 } = options;
57380
+ return writeToL1(l1);
57381
+ }
57382
+ /**
57383
+ * Finds cache entries that match the given query.
57384
+ * Returns an async generator that yields `[key, entry]`.
57385
+ */
57386
+ async *find(query) {
57387
+ const cache = this.services.cache;
57388
+ const predicate = queryToPredicate(query);
57389
+ const filteredEntries = cache.filter(predicate).entries();
57390
+ for (const entry of filteredEntries) {
57391
+ yield entry;
57392
+ }
57393
+ }
57394
+ /**
57395
+ * Finds and modifies cache entries that match the given query.
57396
+ * Extends `find(query)` and returns an async generator of modified keys.
57397
+ */
57398
+ async *findAndModify(query, cacheUpdate) {
57399
+ const cache = this.services.cache;
57400
+ for await (const [key, value] of this.find(query)) {
57401
+ const update = buildUpdate(cacheUpdate, value);
57402
+ switch (update.type) {
57403
+ case "entry":
57404
+ this.write({
57405
+ l1: cache,
57406
+ writeToL1: (l1) => resolvedPromiseLike$1(ok(l1.set(key, update.entry)))
57407
+ });
57408
+ yield key;
57409
+ break;
57410
+ case "metadata":
57411
+ this.write({
57412
+ l1: cache,
57413
+ writeToL1: (l1) => resolvedPromiseLike$1(ok(l1.setMetadata(key, update.metadata)))
57414
+ });
57415
+ yield key;
57416
+ break;
57417
+ }
57418
+ }
57419
+ }
57420
+ }
57421
+ function buildInMemoryCacheInclusionPolicyService(cache) {
57422
+ return {
57423
+ service: new InMemoryCacheInclusionPolicy({ cache }),
57424
+ type: "cacheInclusionPolicy",
57425
+ version: "1.0"
57426
+ };
57427
+ }
57428
+
57429
+ /*!
57430
+ * Copyright (c) 2022, Salesforce, Inc.,
57431
+ * All rights reserved.
57432
+ * For full license text, see the LICENSE.txt file
57433
+ */
57434
+ function buildInstrumentCommand(services) {
57435
+ const meter = services.instrumentation.metrics.getMeter("onestore");
57436
+ return function instrumentCommand(commandClass, commandName) {
57437
+ const invocationCounter = meter.createCounter(`${commandName}.command.invocation.count`);
57438
+ const errorCounter = meter.createCounter(`${commandName}.command.error.count`);
57439
+ const durationHistogram = meter.createHistogram(`${commandName}.command.duration`);
57440
+ return class extends commandClass {
57441
+ execute(...args) {
57442
+ invocationCounter.add(1);
57443
+ let result;
57444
+ const start = services.instrumentation.currentTimeMs();
57445
+ function recordDuration() {
57446
+ const end = services.instrumentation.currentTimeMs();
57447
+ durationHistogram.record(end - start);
57448
+ }
57449
+ try {
57450
+ result = super.execute(...args);
57451
+ } catch (e) {
57452
+ errorCounter.add(1);
57453
+ throw e;
57454
+ }
57455
+ if (typeof result === "object" && result !== null && "then" in result) {
57456
+ result.then(recordDuration, () => {
57457
+ errorCounter.add(1);
57458
+ });
57459
+ } else {
57460
+ recordDuration();
57461
+ }
57462
+ return result;
57463
+ }
57464
+ };
57465
+ };
57466
+ }
57467
+ function buildServiceDescriptor$3(instrumentation) {
57468
+ return {
57469
+ type: "instrumentCommand",
57470
+ version: "1.0",
57471
+ service: buildInstrumentCommand({ instrumentation })
57472
+ };
57473
+ }
57474
+
57475
+ /*!
57476
+ * Copyright (c) 2022, Salesforce, Inc.,
57477
+ * All rights reserved.
57478
+ * For full license text, see the LICENSE.txt file
57479
+ */
57480
+ /*!
57481
+ * Copyright (c) 2022, Salesforce, Inc.,
57482
+ * All rights reserved.
57483
+ * For full license text, see the LICENSE.txt file
57484
+ */
57485
+ class O11yOTelTraceAPI {
57486
+ constructor(services) {
57487
+ this.services = services;
57488
+ }
57489
+ getTracer(name, _version, _options) {
57490
+ const o11yInstrumentation = getInstrumentation(name);
57491
+ return new O11yTracer(o11yInstrumentation, this.services.logger);
57492
+ }
57493
+ }
57494
+ class O11yTracer {
57495
+ constructor(o11yInstrumentation, logger) {
57496
+ this.o11yInstrumentation = o11yInstrumentation;
57497
+ this.logger = logger;
57498
+ }
57499
+ startSpan(name, _options, context) {
57500
+ const traceId = context == null ? void 0 : context.getValue(Symbol.for("traceId"));
57501
+ const spanId = context == null ? void 0 : context.getValue(Symbol.for("spanId"));
57502
+ const traceFlags = context == null ? void 0 : context.getValue(Symbol.for("traceFlags"));
57503
+ let spanContext = void 0;
57504
+ if (traceId !== void 0 && spanId !== void 0 && traceFlags !== void 0) {
57505
+ spanContext = {
57506
+ traceId,
57507
+ spanId,
57508
+ traceFlags
57509
+ };
57510
+ }
57511
+ const activityOptions = spanContext === void 0 ? void 0 : {
57512
+ instrumentationContext: {
57513
+ rootId: spanContext.traceId,
57514
+ isRootActivitySampled: spanContext.traceFlags === 1,
57515
+ parentId: spanId
57516
+ }
57517
+ };
57518
+ const activity = this.o11yInstrumentation.startActivity(name, activityOptions);
57519
+ return new O11ySpan(activity, this.logger);
57520
+ }
57521
+ startActiveSpan(name, options, context, fn) {
57522
+ let opts;
57523
+ let ctx;
57524
+ let fun;
57525
+ if (typeof options === "function") {
57526
+ fun = options;
57527
+ } else {
57528
+ opts = options;
57529
+ if (typeof context === "function") {
57530
+ fun = context;
57531
+ } else {
57532
+ ctx = context;
57533
+ fun = fn;
57534
+ }
57535
+ }
57536
+ const span = this.startSpan(name, opts, ctx);
57537
+ return fun(span);
57538
+ }
57539
+ }
57540
+ class O11ySpan {
57541
+ constructor(activity, logger) {
57542
+ this.activity = activity;
57543
+ this.logger = logger;
57544
+ this._isRecording = true;
57545
+ this.attributes = {};
57546
+ }
57547
+ spanContext() {
57548
+ return {
57549
+ traceId: this.activity.getRootId(),
57550
+ spanId: this.activity.getId(),
57551
+ traceFlags: this.activity.getIsSampled() ? 1 : 0
57552
+ };
57553
+ }
57554
+ setAttribute(key, value) {
57555
+ this.attributes[key] = value;
57556
+ return this;
57557
+ }
57558
+ setAttributes(attributes) {
57559
+ this.attributes = { ...this.attributes, ...attributes };
57560
+ return this;
57561
+ }
57562
+ addEvent(_name, _attributesOrStartTime, _startTime) {
57563
+ this.logger.warn("O11ySpan does not support addEvents.");
57564
+ return this;
57565
+ }
57566
+ setStatus(_status) {
57567
+ this.logger.warn("O11ySpan does not support setStatus.");
57568
+ return this;
57569
+ }
57570
+ updateName(_name) {
57571
+ this.logger.warn("O11ySpan does not support updateName.");
57572
+ return this;
57573
+ }
57574
+ end(endTime) {
57575
+ let endTimeInternal = endTime;
57576
+ try {
57577
+ if (typeof endTimeInternal !== "number") {
57578
+ this.logger.warn("O11ySpan does not support non number endTime override.");
57579
+ endTimeInternal = void 0;
57580
+ }
57581
+ this.activity.stop(
57582
+ void 0,
57583
+ void 0,
57584
+ endTimeInternal ? { perfStopOverride: endTimeInternal } : void 0
57585
+ );
57586
+ } finally {
57587
+ this._isRecording = false;
57588
+ }
57589
+ return;
57590
+ }
57591
+ isRecording() {
57592
+ return this._isRecording;
57593
+ }
57594
+ recordException(exception, _time) {
57595
+ this.activity.error(exception);
57596
+ }
57597
+ }
57598
+ class O11yOTelMetricsAPI {
57599
+ constructor(services) {
57600
+ this.services = services;
57601
+ }
57602
+ getMeter(name, _version, __options) {
57603
+ const o11yInstrumentation = getInstrumentation(name);
57604
+ return new O11yMeter(o11yInstrumentation, this.services.logger);
57605
+ }
57606
+ }
57607
+ class O11yMeter {
57608
+ constructor(o11yInstrumentation, logger) {
57609
+ this.o11yInstrumentation = o11yInstrumentation;
57610
+ this.logger = logger;
57611
+ }
57612
+ createHistogram(name, _options) {
57613
+ return new O11yHistogram(name, this.o11yInstrumentation, this.logger);
57614
+ }
57615
+ createCounter(name, options) {
57616
+ if (options) {
57617
+ this.logger.warn("counter options not supported in O11y instrumentation");
57618
+ }
57619
+ return new O11yCounter(name, this.o11yInstrumentation, this.logger);
57620
+ }
57621
+ createUpDownCounter(_name, _options) {
57622
+ return new O11yUpDownCounter(this.logger);
57623
+ }
57624
+ createObservableGauge(_name, _options) {
57625
+ return new O11yObservableGuage(this.logger);
57626
+ }
57627
+ createObservableCounter(_name, _options) {
57628
+ return new O11yObservableCounter(this.logger);
57629
+ }
57630
+ createObservableUpDownCounter(_name, _options) {
57631
+ return new O11yObservableUpDownCounter(this.logger);
57632
+ }
57633
+ addBatchObservableCallback(_callback, _observables) {
57634
+ this.logger.warn("addBatchObservableCallback not supported yet");
57635
+ }
57636
+ removeBatchObservableCallback(_callback, _observables) {
57637
+ this.logger.warn("removeBatchObservableCallback not supported yet");
57638
+ }
57639
+ }
57640
+ class O11yCounter {
57641
+ constructor(name, o11yInstrumentation, logger) {
57642
+ this.name = name;
57643
+ this.o11yInstrumentation = o11yInstrumentation;
57644
+ this.logger = logger;
57645
+ }
57646
+ add(value, attributes, _context) {
57647
+ if (value < 0) {
57648
+ this.logger.warn(`Counter values must be non-negative. Got ${value}.`);
57649
+ return;
57650
+ }
57651
+ this.o11yInstrumentation.incrementCounter(
57652
+ this.name,
57653
+ value,
57654
+ void 0,
57655
+ sanitizeAttributes(attributes)
57656
+ );
57657
+ }
57658
+ }
57659
+ class O11yHistogram {
57660
+ constructor(name, o11yInstrumentation, logger) {
57661
+ this.name = name;
57662
+ this.o11yInstrumentation = o11yInstrumentation;
57663
+ this.logger = logger;
57664
+ }
57665
+ record(value, attributes, _context) {
57666
+ if (value < 0) {
57667
+ this.logger.warn(`Histogram values must be non-negative. Got ${value}.`);
57668
+ return;
57669
+ }
57670
+ this.o11yInstrumentation.trackValue(
57671
+ this.name,
57672
+ value,
57673
+ void 0,
57674
+ sanitizeAttributes(attributes)
57675
+ );
57676
+ }
57677
+ }
57678
+ class O11yUpDownCounter {
57679
+ constructor(logger) {
57680
+ this.logger = logger;
57681
+ }
57682
+ add(_value, _attributes, _context) {
57683
+ this.logger.warn("O11yUpDownCounter not supported yet.");
57684
+ }
57685
+ }
57686
+ class O11yObservableCounter {
57687
+ constructor(logger) {
57688
+ this.logger = logger;
57689
+ }
57690
+ addCallback(_callback) {
57691
+ this.logger.warn("O11yObservableCounter not supported yet. Defaulting to noop.");
57692
+ }
57693
+ removeCallback(_callback) {
57694
+ this.logger.warn("O11yObservableCounter not supported yet. Defaulting to noop.");
57695
+ }
57696
+ }
57697
+ class O11yObservableGuage {
57698
+ constructor(logger) {
57699
+ this.logger = logger;
57700
+ }
57701
+ addCallback(_callback) {
57702
+ this.logger.warn("O11yObservableGuage not supported yet. Defaulting to noop.");
57703
+ }
57704
+ removeCallback(_callback) {
57705
+ this.logger.warn("O11yObservableGuage not supported yet. Defaulting to noop.");
57706
+ }
57707
+ }
57708
+ class O11yObservableUpDownCounter {
57709
+ constructor(logger) {
57710
+ this.logger = logger;
57711
+ }
57712
+ addCallback(_callback) {
57713
+ this.logger.warn("O11yObservableUpDownCounter not supported yet. Defaulting to noop.");
57714
+ }
57715
+ removeCallback(_callback) {
57716
+ this.logger.warn("O11yObservableUpDownCounter not supported yet. Defaulting to noop.");
57717
+ }
57718
+ }
57719
+ function sanitizeAttributes(attributes) {
57720
+ if (!attributes) return;
57721
+ const metricTags = {};
57722
+ Object.entries(attributes).forEach(([key, value]) => {
57723
+ if (value !== void 0 && !Array.isArray(value)) {
57724
+ metricTags[key] = value;
57725
+ }
57726
+ });
57727
+ return metricTags;
57728
+ }
57729
+ class O11yInstrumentation {
57730
+ constructor(services) {
57731
+ this.services = services;
57732
+ this.currentTimeMs = () => performance.now();
57733
+ this.trace = new O11yOTelTraceAPI(this.services);
57734
+ this.metrics = new O11yOTelMetricsAPI(this.services);
57735
+ }
57736
+ }
57737
+ function buildServiceDescriptor$2(logger) {
57738
+ return {
57739
+ type: "instrumentation",
57740
+ version: "1.0",
57741
+ service: new O11yInstrumentation({ logger })
57742
+ };
57743
+ }
57744
+
57745
+ /*!
57746
+ * Copyright (c) 2022, Salesforce, Inc.,
57747
+ * All rights reserved.
57748
+ * For full license text, see the LICENSE.txt file
57749
+ */
57750
+ /*!
57751
+ * Copyright (c) 2022, Salesforce, Inc.,
57752
+ * All rights reserved.
57753
+ * For full license text, see the LICENSE.txt file
57754
+ */
57755
+ function resolvedPromiseLike(result) {
57756
+ if (isPromiseLike(result)) {
57757
+ return result.then((nextResult) => nextResult);
57758
+ }
57759
+ return {
57760
+ then: (onFulfilled, _onRejected) => {
57761
+ try {
57762
+ return resolvedPromiseLike(onFulfilled(result));
57763
+ } catch (e) {
57764
+ if (onFulfilled === void 0) {
57765
+ return resolvedPromiseLike(result);
57766
+ }
57767
+ return rejectedPromiseLike(e);
57768
+ }
57769
+ }
57770
+ };
57771
+ }
57772
+ function rejectedPromiseLike(reason) {
57773
+ if (isPromiseLike(reason)) {
57774
+ return reason.then((nextResult) => nextResult);
57775
+ }
57776
+ return {
57777
+ then: (_onFulfilled, onRejected) => {
57778
+ if (typeof onRejected === "function") {
57779
+ try {
57780
+ return resolvedPromiseLike(onRejected(reason));
57781
+ } catch (e) {
57782
+ return rejectedPromiseLike(e);
57783
+ }
57784
+ }
57785
+ return rejectedPromiseLike(reason);
57786
+ }
57787
+ };
57788
+ }
57789
+ function isPromiseLike(x) {
57790
+ return typeof (x == null ? void 0 : x.then) === "function";
57791
+ }
57792
+ const EventTypeWildcard = Symbol("EventTypeWildcard");
57793
+ class DefaultPubSubService {
57794
+ constructor() {
57795
+ this.subscriptions = /* @__PURE__ */ new Map();
57796
+ }
57797
+ subscribe(subscription) {
57798
+ let eventTypeSubscriptions = this.subscriptions.get(subscription.type);
57799
+ if (eventTypeSubscriptions === void 0) {
57800
+ eventTypeSubscriptions = [];
57801
+ this.subscriptions.set(subscription.type, eventTypeSubscriptions);
57802
+ }
57803
+ eventTypeSubscriptions.push(subscription);
57804
+ return () => {
57805
+ this.subscriptions.set(
57806
+ subscription.type,
57807
+ this.subscriptions.get(subscription.type).filter((value) => value !== subscription)
57808
+ );
57809
+ };
57810
+ }
57811
+ publish(event) {
57812
+ const promises = [];
57813
+ const subscriptions = this.getSubscriptions(event);
57814
+ subscriptions.forEach((subscription) => {
57815
+ if (!this.getSubscriptions(event).includes(subscription)) {
57816
+ return;
57817
+ }
57818
+ const returnVal = subscription.callback.call(subscription, event);
57819
+ if (isPromiseLike(returnVal)) {
57820
+ promises.push(returnVal);
57821
+ }
57822
+ });
57823
+ if (promises.length > 0) {
57824
+ return Promise.all(promises).then(() => void 0);
57825
+ }
57826
+ return resolvedPromiseLike(void 0);
57827
+ }
57828
+ getSubscriptions(event) {
57829
+ const eventTypeSubscriptions = this.subscriptions.get(event.type);
57830
+ const wildcardSubscriptions = this.subscriptions.get(EventTypeWildcard);
57831
+ if (eventTypeSubscriptions === void 0 && wildcardSubscriptions === void 0) {
57832
+ return [];
57833
+ }
57834
+ let matchingSubscriptions = [];
57835
+ if (eventTypeSubscriptions !== void 0) {
57836
+ matchingSubscriptions = eventTypeSubscriptions.filter((subscription) => {
57837
+ if (subscription.predicate) {
57838
+ return subscription.predicate(event);
57839
+ }
57840
+ return true;
57841
+ });
57842
+ }
57843
+ matchingSubscriptions = [...matchingSubscriptions, ...wildcardSubscriptions || []];
57844
+ return matchingSubscriptions;
57845
+ }
57846
+ }
57847
+ function buildServiceDescriptor$1() {
57848
+ return {
57849
+ type: "pubSub",
57850
+ version: "1.0",
57851
+ service: new DefaultPubSubService()
57852
+ };
57853
+ }
57854
+
57855
+ /*!
57856
+ * Copyright (c) 2022, Salesforce, Inc.,
57857
+ * All rights reserved.
57858
+ * For full license text, see the LICENSE.txt file
57859
+ */
57860
+ function buildServiceDescriptor(interceptors = { request: [], response: [] }) {
57861
+ return {
57862
+ type: "fetch",
57863
+ version: "1.0",
57864
+ service: function(...args) {
57865
+ const { request: requestInterceptors = [], response: responseInterceptors = [] } = interceptors;
57866
+ const pending = requestInterceptors.reduce(
57867
+ (previousPromise, interceptor) => previousPromise.then(interceptor),
57868
+ resolvedPromiseLike$3(args)
57869
+ );
57870
+ return pending.then((args2) => fetch(...args2)).then((response) => {
57871
+ return responseInterceptors.reduce(
57872
+ (previousPromise, interceptor) => previousPromise.then(interceptor),
57873
+ resolvedPromiseLike$3(response)
57874
+ );
57875
+ });
57876
+ }
57877
+ };
57878
+ }
57879
+
57880
+ function buildNimbusFetchServiceDescriptor() {
57881
+ // the fetch() function that will be used to make network requests using the NimbusNetworkAdapter
57882
+ const service = (...args) => {
57883
+ const resourceRequest = convertFetchParamsToResourceRequest(args);
57884
+ const context = {};
57885
+ return NimbusNetworkAdapter(resourceRequest, context).then((response) => {
57886
+ return new Response(response.body, {
57887
+ headers: response.headers,
57888
+ status: response.status,
57889
+ statusText: response.statusText,
57890
+ });
57891
+ });
57892
+ };
57893
+ return {
57894
+ ...buildServiceDescriptor(),
57895
+ service: service,
57896
+ };
57897
+ }
57898
+ /**
57899
+ * Converts fetch API parameters to a ResourceRequest format for Nimbus.
57900
+ *
57901
+ * @param params - Destructured fetch parameters tuple [input, init]
57902
+ * - FetchParameters is defined as Parameters<typeof fetch>
57903
+ * - This matches the standard fetch(input, init) signature
57904
+ * - input: URL or request info (first parameter of fetch)
57905
+ * - init: Optional request configuration (second parameter of fetch)
57906
+ * @returns A ResourceRequest object compatible with NimbusNetworkAdapter
57907
+ */
57908
+ function convertFetchParamsToResourceRequest([input, init]) {
57909
+ const url = typeof input === 'string'
57910
+ ? new URL(input)
57911
+ : input instanceof URL
57912
+ ? input
57913
+ : new URL(input.url);
57914
+ const headers = {};
57915
+ if (init?.headers) {
57916
+ if (init.headers instanceof Headers) {
57917
+ init.headers.forEach((value, key) => {
57918
+ headers[key] = value;
57919
+ });
57920
+ }
57921
+ else if (Array.isArray(init.headers)) {
57922
+ init.headers.forEach(([key, value]) => {
57923
+ headers[key] = value;
57924
+ });
57925
+ }
57926
+ else {
57927
+ Object.entries(init.headers).forEach(([key, value]) => {
57928
+ headers[key] = value;
57929
+ });
57930
+ }
57931
+ }
57932
+ return {
57933
+ baseUri: url.origin,
57934
+ basePath: url.pathname,
57935
+ method: (init?.method || 'GET').toLowerCase(),
57936
+ body: init?.body || null,
57937
+ headers,
57938
+ queryParams: Object.fromEntries(url.searchParams),
57939
+ urlParams: {},
57940
+ };
57941
+ }
57942
+
57943
+ // TODO[@W-18753648]: These services depend on WebApis that aren't available in the worker.
57944
+ // import { buildServiceDescriptor as buildNdJsonServiceDescriptor } from '@luvio/command-ndjson/v1';
57945
+ // import { buildServiceDescriptor as buildStreamingCommandServiceDescriptor } from '@luvio/command-streaming/v1';
57946
+ // import { buildServiceDescriptor as buildSseCommandServiceDescriptor } from '@luvio/command-sse/v1';
57947
+ function initializeOneStore() {
57948
+ if (!useOneStore.isOpen({ fallback: true })) {
57949
+ return;
57950
+ }
57951
+ const loggerService = new ConsoleLogger('ERROR');
57952
+ const cacheServiceDescriptor = buildServiceDescriptor$5();
57953
+ const instrumentationServiceDescriptor = buildServiceDescriptor$2(loggerService);
57954
+ const inMemoryCacheInclusionPolicyServiceDescriptor = buildInMemoryCacheInclusionPolicyService(cacheServiceDescriptor.service);
57955
+ const services = [
57956
+ instrumentationServiceDescriptor,
57957
+ buildNimbusFetchServiceDescriptor(),
57958
+ buildServiceDescriptor$3(instrumentationServiceDescriptor.service),
57959
+ // NOTE: These do not directly depend on Aura, and are necessary for HTTP fallback support.
57960
+ buildServiceDescriptor$a(),
57961
+ buildServiceDescriptor$9(),
57962
+ buildServiceDescriptor$8(),
57963
+ buildServiceDescriptor$4(cacheServiceDescriptor.service, inMemoryCacheInclusionPolicyServiceDescriptor.service),
57964
+ buildServiceDescriptor$7(),
57965
+ buildServiceDescriptor$b(),
57966
+ buildServiceDescriptor$6(),
57967
+ buildServiceDescriptor$1(),
57968
+ // TODO[@W-18753648]: See note above.
57969
+ // buildStreamingCommandServiceDescriptor(),
57970
+ // buildNdJsonServiceDescriptor(),
57971
+ // buildSseCommandServiceDescriptor(),
57972
+ ];
57973
+ setServices(services);
57974
+ }
57975
+
55645
57976
  // so eslint doesn't complain about nimbus
55646
57977
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
55647
57978
  /* global __nimbus */
@@ -55664,7 +57995,7 @@ const shouldFlush = (key, value) => {
55664
57995
  if (value && typeof value === 'object') {
55665
57996
  const fields = value.fields;
55666
57997
  if (fields && typeof fields === 'object') {
55667
- const keys = keys$2(fields);
57998
+ const keys = keys$3(fields);
55668
57999
  for (const key of keys) {
55669
58000
  const field = fields[key];
55670
58001
  if (fields && field.__state && field.__state.pending === true) {
@@ -55681,7 +58012,7 @@ const shouldFlush = (key, value) => {
55681
58012
  /**
55682
58013
  * This returns the LDS on Mobile Runtime singleton object.
55683
58014
  */
55684
- function getRuntime() {
58015
+ function getRuntime({ primeUser = false } = {}) {
55685
58016
  if (lazyLuvio === undefined ||
55686
58017
  lazyEnvironment === undefined ||
55687
58018
  lazyDraftManager === undefined ||
@@ -55705,6 +58036,18 @@ function getRuntime() {
55705
58036
  // specific adapters
55706
58037
  const internalAdapterStore = new InMemoryStore();
55707
58038
  const { adapters: { getObjectInfo, getObjectInfos, getRecord, getObjectInfoDirectory }, luvio: internalLuvio, } = buildInternalAdapters(internalAdapterStore, lazyNetworkAdapter, lazyDurableStore, (apiName, objectInfo) => lazyObjectInfoService.ensureObjectInfoCached(apiName, objectInfo), shouldFlush);
58039
+ // Make a best-effort attempt to get the user record, which is used by drafts side effects
58040
+ if (primeUser) {
58041
+ getRecord({
58042
+ recordId: userId,
58043
+ optionalFields: ['User.Id', 'User.Name', 'User.FirstName', 'User.LastName'],
58044
+ }, {
58045
+ cachePolicy: {
58046
+ type: 'stale-while-revalidate',
58047
+ staleDurationSeconds: Number.MAX_SAFE_INTEGER,
58048
+ },
58049
+ });
58050
+ }
55708
58051
  lazyInternalLuvio = internalLuvio;
55709
58052
  lazyObjectInfoService = new ObjectInfoService(getObjectInfo, getObjectInfos, getObjectInfoDirectory, lazyDurableStore);
55710
58053
  const baseEnv = new Environment(store, lazyNetworkAdapter);
@@ -55800,6 +58143,8 @@ function getRuntime() {
55800
58143
  });
55801
58144
  withRegistration('@salesforce/lds-adapters-uiapi/graphql', configureUIAPIGraphQL);
55802
58145
  }
58146
+ // onestore initialization
58147
+ initializeOneStore();
55803
58148
  return {
55804
58149
  luvio: lazyLuvio,
55805
58150
  internalLuvio: lazyInternalLuvio,
@@ -55833,4 +58178,4 @@ register({
55833
58178
  });
55834
58179
 
55835
58180
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, ingest$1o as ingestDenormalizedRecordRepresentation, registerReportObserver, reportGraphqlQueryParseError };
55836
- // version: 1.365.0-eec7b6223e
58181
+ // version: 1.367.0-def0c51200