@salesforce/lds-runtime-mobile 1.366.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
@@ -20,7 +20,7 @@ import { setupInstrumentation, instrumentAdapter as instrumentAdapter$1, instrum
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
22
  import { getInstrumentation, idleDetector } from 'o11y/client';
23
- import { Kind as Kind$1, visit as visit$1, isObjectType, defaultFieldResolver, buildSchema, parse as parse$5, extendSchema, isScalarType, execute, print } from '@luvio/graphql-parser';
23
+ import { Kind as Kind$1, visit as visit$1, isObjectType, defaultFieldResolver, buildSchema, parse as parse$7, extendSchema, isScalarType, execute, print } from '@luvio/graphql-parser';
24
24
  import FIRST_DAY_OF_WEEK from '@salesforce/i18n/firstDayOfWeek';
25
25
  import graphqQueryFieldLimit from '@salesforce/gate/lmr.graphqQueryFieldLimit';
26
26
  import caseSensitiveUserId from '@salesforce/user/Id';
@@ -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,10 +48,10 @@ 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
 
@@ -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];
@@ -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) => {
@@ -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);
@@ -42780,7 +42782,7 @@ function normalizeError(err) {
42780
42782
  else if (typeof err === 'string') {
42781
42783
  return new Error(err);
42782
42784
  }
42783
- return new Error(stringify$2(err));
42785
+ return new Error(stringify$4(err));
42784
42786
  }
42785
42787
 
42786
42788
  const O11Y_NAMESPACE_LDS_MOBILE = 'lds-mobile';
@@ -43298,7 +43300,7 @@ function createContentDocumentAndVersionDraftAdapterFactory(luvio, binaryStore,
43298
43300
  ...trimmedDownData.contentVersion,
43299
43301
  fields: cvFields,
43300
43302
  };
43301
- freeze(trimmedDownData);
43303
+ freeze$1(trimmedDownData);
43302
43304
  eventEmitter({ type: 'create-content-document-and-version-draft-finished' });
43303
43305
  return {
43304
43306
  state: 'Fulfilled',
@@ -43889,7 +43891,7 @@ function recordLoaderFactory(query) {
43889
43891
  rows.forEach((row) => {
43890
43892
  if (!row[0])
43891
43893
  return null;
43892
- const record = parse$2(row[0]);
43894
+ const record = parse$4(row[0]);
43893
43895
  if (record.id === id) {
43894
43896
  foundRow = record;
43895
43897
  }
@@ -43951,7 +43953,7 @@ function removeUndefined(array) {
43951
43953
  }
43952
43954
  // We won't need this when we enable ES2019+ support
43953
43955
  function flat(arr, d = 1) {
43954
- if (!isArray$1(arr)) {
43956
+ if (!isArray$3(arr)) {
43955
43957
  return arr;
43956
43958
  }
43957
43959
  return d > 0 ? arr.reduce((acc, val) => acc.concat(flat(val, d - 1)), []) : arr.slice();
@@ -44248,11 +44250,11 @@ function dateTimePredicate(input, operator, field, alias) {
44248
44250
  return dateTimeRange(range, operator, field, alias);
44249
44251
  }
44250
44252
  // eslint-disable-next-line @salesforce/lds/no-error-in-production
44251
- throw new Error(`Where filter ${stringify$2(input)} is not supported`);
44253
+ throw new Error(`Where filter ${stringify$4(input)} is not supported`);
44252
44254
  }
44253
44255
  function dateTimeRange(input, op, field, alias) {
44254
44256
  const dateFunction = field.dataType === 'DateTime' ? 'datetime' : 'date';
44255
- const key = keys$2(input)[0];
44257
+ const key = keys$3(input)[0];
44256
44258
  let operator = op;
44257
44259
  if (operator === '=')
44258
44260
  operator = 'BETWEEN';
@@ -44552,7 +44554,7 @@ function filterToPredicates(where, recordType, alias, objectInfoMap, joins, draf
44552
44554
  if (!where)
44553
44555
  return [];
44554
44556
  let predicates = [];
44555
- const fields = keys$2(where);
44557
+ const fields = keys$3(where);
44556
44558
  for (const field of fields) {
44557
44559
  if (field === 'and' || field === 'or') {
44558
44560
  predicates.push(processCompoundPredicate(field, where[field], recordType, alias, objectInfoMap, joins));
@@ -44673,7 +44675,7 @@ function filterToPredicates(where, recordType, alias, objectInfoMap, joins, draf
44673
44675
  }
44674
44676
  else {
44675
44677
  // @W-12618378 polymorphic query sometimes does not work as expected on server. The GQL on certain entities could fail.
44676
- const entityNames = keys$2(where[field]);
44678
+ const entityNames = keys$3(where[field]);
44677
44679
  const polyPredicatesGroups = entityNames
44678
44680
  .filter((entityName) => fieldInfo.referenceToInfos.some((referenceInfo) => referenceInfo.apiName === entityName))
44679
44681
  .map((entityName) => {
@@ -44708,7 +44710,7 @@ function filterToPredicates(where, recordType, alias, objectInfoMap, joins, draf
44708
44710
  }
44709
44711
  else {
44710
44712
  //`field` match the filedInfo's apiName
44711
- for (const [op, value] of entries$2(where[field])) {
44713
+ for (const [op, value] of entries$3(where[field])) {
44712
44714
  const operator = operatorToSql(op);
44713
44715
  /**
44714
44716
  Two types ID processing might be needed. Draft ID swapping is optional, which depends on DraftFunctions existence.
@@ -44753,7 +44755,7 @@ function isIDValueField(fieldInfo) {
44753
44755
  * @returns sanitized previdicate value
44754
44756
  */
44755
44757
  function sanitizePredicateIDValue(value, draftFunction) {
44756
- if (isArray$1(value)) {
44758
+ if (isArray$3(value)) {
44757
44759
  return value.map((singleValue) => sanitizePredicateIDValue(singleValue, draftFunction));
44758
44760
  }
44759
44761
  else if (typeof value === 'string' && value === '') {
@@ -44771,7 +44773,7 @@ function sanitizePredicateIDValue(value, draftFunction) {
44771
44773
  }
44772
44774
  }
44773
44775
  function createMultiPicklistPredicate(value, operator, fieldInfo, alias) {
44774
- if (value === undefined || (isArray$1(value) && value.length === 0)) {
44776
+ if (value === undefined || (isArray$3(value) && value.length === 0)) {
44775
44777
  // eslint-disable-next-line
44776
44778
  throw new Error(`No value specified for MultiPickList filter`);
44777
44779
  }
@@ -44792,7 +44794,7 @@ function createMultiPicklistPredicate(value, operator, fieldInfo, alias) {
44792
44794
  // if we have more than 1 value in the array from an includes/excludes we must split the values into
44793
44795
  // a compound OR predicate for includes, AND predicate for excludes. each predicate could a composite
44794
44796
  // if the value in the array is ; separated. sample: ['a:b','c']
44795
- const valueArray = isArray$1(value) ? value : [value];
44797
+ const valueArray = isArray$3(value) ? value : [value];
44796
44798
  return {
44797
44799
  type: PredicateType.compound,
44798
44800
  operator: operator === 'LIKE' ? 'or' : 'and',
@@ -44823,7 +44825,7 @@ function createSinglePredicate(val, operator, field, alias) {
44823
44825
  value = multiPicklistToSql(operator, val);
44824
44826
  }
44825
44827
  else if (typeof value !== 'object' &&
44826
- !isArray$1(value) &&
44828
+ !isArray$3(value) &&
44827
44829
  typeof value !== 'number' &&
44828
44830
  (typeof value !== 'string' || typeof value !== 'boolean')) {
44829
44831
  value = value.toString();
@@ -44898,7 +44900,7 @@ function flattenSqlAndBindings(sqlAndBindings, operator) {
44898
44900
  }
44899
44901
  function inOrNotInValuesIncludeNull(predicate) {
44900
44902
  const isInOrNin = predicate.operator === 'IN' || predicate.operator === 'NOT IN';
44901
- const nullValueExists = isArray$1(predicate.value)
44903
+ const nullValueExists = isArray$3(predicate.value)
44902
44904
  ? predicate.value.some((v) => v === null)
44903
44905
  : predicate.value === null;
44904
44906
  return isInOrNin && nullValueExists;
@@ -45066,7 +45068,7 @@ function handleExtractedPredicateValue(boundValue, checkForNull) {
45066
45068
  let questionSql = '?';
45067
45069
  let binding = [];
45068
45070
  let includesNull = false;
45069
- if (isArray$1(boundValue)) {
45071
+ if (isArray$3(boundValue)) {
45070
45072
  const removeNull = boundValue.filter((v) => v !== null);
45071
45073
  includesNull = removeNull.length !== boundValue.length;
45072
45074
  // construct (?, ?)
@@ -45900,7 +45902,7 @@ function depth(json, currentLevel = 0) {
45900
45902
  if (typeof json !== 'object') {
45901
45903
  return currentLevel;
45902
45904
  }
45903
- const keys = keys$2(json);
45905
+ const keys = keys$3(json);
45904
45906
  if (keys.length === 0)
45905
45907
  return 0;
45906
45908
  const depths = keys.map((key) => {
@@ -45953,7 +45955,7 @@ function orderByToPredicate(orderBy, recordType, alias, objectInfoMap, joins) {
45953
45955
  return predicates;
45954
45956
  const isSpanning = depth(orderBy) > 2;
45955
45957
  if (isSpanning) {
45956
- const keys = keys$2(orderBy);
45958
+ const keys = keys$3(orderBy);
45957
45959
  for (let i = 0, len = keys.length; i < len; i++) {
45958
45960
  const key = keys[i];
45959
45961
  const parentFields = objectInfoMap[recordType].fields;
@@ -45983,7 +45985,7 @@ function orderByToPredicate(orderBy, recordType, alias, objectInfoMap, joins) {
45983
45985
  }
45984
45986
  }
45985
45987
  else {
45986
- const keys = keys$2(orderBy);
45988
+ const keys = keys$3(orderBy);
45987
45989
  for (let i = 0, len = keys.length; i < len; i++) {
45988
45990
  const key = keys[i];
45989
45991
  if (!objectInfoMap[recordType])
@@ -46892,14 +46894,14 @@ function isLocalCursor(maybeCursor) {
46892
46894
  typeof maybeCursor.i === 'number');
46893
46895
  }
46894
46896
  function encodeV1Cursor(cursor) {
46895
- return base64encode(stringify$2(cursor));
46897
+ return base64encode(stringify$4(cursor));
46896
46898
  }
46897
46899
  const CURSOR_PARSE_ERROR = 'Unable to parse cursor';
46898
46900
  function decodeV1Cursor(base64cursor) {
46899
46901
  let maybeCursor;
46900
46902
  try {
46901
46903
  const cursorString = base64decode(base64cursor);
46902
- maybeCursor = parse$2(cursorString);
46904
+ maybeCursor = parse$4(cursorString);
46903
46905
  }
46904
46906
  catch (error) {
46905
46907
  let message = CURSOR_PARSE_ERROR;
@@ -47103,7 +47105,7 @@ async function readPaginationMetadataForKeys(keys, query) {
47103
47105
  const results = await query(sql, keys.map((k) => k + '__pagination'));
47104
47106
  for (let row of results.rows) {
47105
47107
  let key = row[0].replace(/__pagination$/, '');
47106
- let metadata = parse$2(row[1]);
47108
+ let metadata = parse$4(row[1]);
47107
47109
  metadataMap.set(key, metadata);
47108
47110
  }
47109
47111
  return metadataMap;
@@ -47209,8 +47211,8 @@ async function connectionResolver(obj, args, context, info) {
47209
47211
  //map each sql result with the ingestion timestamp to pass it down a level
47210
47212
  let records = results.rows.map((row, index) => {
47211
47213
  const recordMetadataResult = {
47212
- recordRepresentation: parse$2(row[0]),
47213
- metadata: parse$2(row[1]),
47214
+ recordRepresentation: parse$4(row[0]),
47215
+ metadata: parse$4(row[1]),
47214
47216
  };
47215
47217
  const { recordRepresentation, metadata } = recordMetadataResult;
47216
47218
  context.seenRecordIds.add(recordRepresentation.id);
@@ -47661,7 +47663,7 @@ function extendSchemaWithObjectInfos(cache, objectInfoMap) {
47661
47663
  return cache;
47662
47664
  }
47663
47665
  // parse extensions into DocumentNode to extend the schema
47664
- const extensions = parse$5(typeDefs);
47666
+ const extensions = parse$7(typeDefs);
47665
47667
  const polymorphicFieldTypeNames = [
47666
47668
  ...polyFieldTypeNameArr,
47667
47669
  ...cache.getPolymorphicFieldTypeNames(),
@@ -47699,7 +47701,7 @@ function generateRecordQueries(schema, objectInfoMap) {
47699
47701
  // use a set to not allow duplicate scalars causing error(s)
47700
47702
  let addedTypedScalars = new Set();
47701
47703
  let allPolymorphicFieldTypeNames = new Set();
47702
- for (const name of keys$2(objectInfoMap)) {
47704
+ for (const name of keys$3(objectInfoMap)) {
47703
47705
  const objectInfo = objectInfoMap[name];
47704
47706
  const { apiName } = objectInfo;
47705
47707
  const type = schema.getType(apiName);
@@ -47826,7 +47828,7 @@ function extendExistingRecordType(schema, type, objectInfo, objectInfoMap) {
47826
47828
  // use a set to not allow duplicate scalars causing error(s)
47827
47829
  let typedScalars = new Set();
47828
47830
  let parentRelationshipFields = new Set();
47829
- const existingFields = keys$2(type.getFields());
47831
+ const existingFields = keys$3(type.getFields());
47830
47832
  const missingFields = values$1(objectInfo.fields).filter((field) => {
47831
47833
  return (existingFields.includes(field.apiName) === false ||
47832
47834
  (field.relationshipName !== null && field.referenceToInfos.length > 0));
@@ -48687,7 +48689,7 @@ async function resolveObjectInfos(objectInfotree, pathToObjectApiNamesMap, start
48687
48689
  // eslint-disable-next-line
48688
48690
  throw new Error(`Unable to resolve ObjectInfo(s) for ${Array.from(startNodes)}`);
48689
48691
  }
48690
- if (keys$2(objectInfos).length < startNodes.size) {
48692
+ if (keys$3(objectInfos).length < startNodes.size) {
48691
48693
  // eslint-disable-next-line
48692
48694
  throw new Error(`Unable to resolve ObjectInfo(s) for ${Array.from(startNodes)}`);
48693
48695
  }
@@ -49715,7 +49717,7 @@ function removeSyntheticFields(result, query) {
49715
49717
  output.data.uiapi = { ...output.data.uiapi };
49716
49718
  output.data.uiapi.query = { ...output.data.uiapi.query };
49717
49719
  const outputApiParent = output.data.uiapi.query;
49718
- const keys = keys$2(nodeJson);
49720
+ const keys = keys$3(nodeJson);
49719
49721
  keys.forEach((recordName) => {
49720
49722
  const outputApi = {};
49721
49723
  // Each connectionSelection's maps its name or alias to one of returned records. The record name could be `apiName' or alias
@@ -49735,7 +49737,7 @@ function removeSyntheticFields(result, query) {
49735
49737
  * @param jsonOutput JsonObject which will be populated with properties. It would only contains properties defined in 'FieldNode'
49736
49738
  */
49737
49739
  function createUserJsonOutput(selection, jsonInput, jsonOutput) {
49738
- const keys = keys$2(jsonInput);
49740
+ const keys = keys$3(jsonInput);
49739
49741
  if (selection.selectionSet) {
49740
49742
  createjsonOutput(selection.selectionSet.selections, jsonInput, jsonOutput);
49741
49743
  }
@@ -49744,11 +49746,11 @@ function createUserJsonOutput(selection, jsonInput, jsonOutput) {
49744
49746
  }
49745
49747
  }
49746
49748
  function createjsonOutput(selections, jsonInput, jsonOutput) {
49747
- const keys = keys$2(jsonInput);
49749
+ const keys = keys$3(jsonInput);
49748
49750
  selections.filter(isFieldNode).forEach((subSelection) => {
49749
49751
  const fieldName = subSelection.alias ? subSelection.alias.value : subSelection.name.value;
49750
49752
  if (keys.includes(fieldName)) {
49751
- if (isArray$1(jsonInput[fieldName])) {
49753
+ if (isArray$3(jsonInput[fieldName])) {
49752
49754
  jsonOutput[fieldName] = [];
49753
49755
  jsonInput[fieldName].forEach((childJson) => {
49754
49756
  const childOutput = {};
@@ -50152,7 +50154,7 @@ function findRecordQueryContainsFieldType(recordQueryNode, fieldNames) {
50152
50154
  */
50153
50155
  function findFieldTypeInObjectInfo(objectInfos, fieldType) {
50154
50156
  let fieldsWithDataType = [];
50155
- keys$2(objectInfos).filter((recordType) => {
50157
+ keys$3(objectInfos).filter((recordType) => {
50156
50158
  for (const field in objectInfos[recordType].fields) {
50157
50159
  if (objectInfos[recordType].fields[field].dataType === fieldType) {
50158
50160
  fieldsWithDataType.push(field);
@@ -50178,12 +50180,12 @@ const replaceDraftIdsInVariables = (variables, draftFunctions, unmappedDraftIDs)
50178
50180
  }
50179
50181
  return canonicalId;
50180
50182
  }
50181
- else if (isArray$1(object)) {
50183
+ else if (isArray$3(object)) {
50182
50184
  return object.map(replace);
50183
50185
  }
50184
50186
  else if (typeof object === 'object' && object !== null) {
50185
50187
  let source = object;
50186
- return keys$2(source).reduce((acc, key) => {
50188
+ return keys$3(source).reduce((acc, key) => {
50187
50189
  acc[key] = replace(source[key]);
50188
50190
  return acc;
50189
50191
  }, {});
@@ -50192,7 +50194,7 @@ const replaceDraftIdsInVariables = (variables, draftFunctions, unmappedDraftIDs)
50192
50194
  return object;
50193
50195
  }
50194
50196
  };
50195
- let newVariables = keys$2(variables).reduce((acc, key) => {
50197
+ let newVariables = keys$3(variables).reduce((acc, key) => {
50196
50198
  acc[key] = replace(variables[key]);
50197
50199
  return acc;
50198
50200
  }, {});
@@ -50204,7 +50206,7 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
50204
50206
  const getCanonicalId = getCanonicalIdFunction(luvio);
50205
50207
  return async function draftAwareGraphQLAdapter(config, requestContext = {}) {
50206
50208
  //create a copy to not accidentally modify the AST in the astResolver map of luvio
50207
- const copy = parse$2(stringify$2(config.query));
50209
+ const copy = parse$4(stringify$4(config.query));
50208
50210
  // the injected ast has extra fields needed for eval in it
50209
50211
  let injectedAST;
50210
50212
  // the cursor mapped ast is passed upstream so it won't reject on our local cursors
@@ -50297,7 +50299,7 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
50297
50299
  } = await evaluate({
50298
50300
  ...config,
50299
50301
  //need to create another copy of the ast for future writes
50300
- query: parse$2(stringify$2(injectedAST)),
50302
+ query: parse$4(stringify$4(injectedAST)),
50301
50303
  }, observers, { userId }, objectInfoNeeded, store, nonEvaluatedSnapshot, graphqlSchemaCache, draftFunctions, mappedCursors));
50302
50304
  }
50303
50305
  catch (throwable) {
@@ -50423,7 +50425,7 @@ function makeGetRecordsConfig(keyMap) {
50423
50425
 
50424
50426
  function environmentAwareGraphQLBatchAdapterFactory(objectInfoService, luvio, isDraftId, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy) {
50425
50427
  return async function environmentAwareGraphQLBatchAdapter(config, requestContext = {}) {
50426
- const batchQueryCopy = config.batchQuery.map((query) => parse$2(stringify$2(query)));
50428
+ const batchQueryCopy = config.batchQuery.map((query) => parse$4(stringify$4(query)));
50427
50429
  let injectedBatchQuery = [];
50428
50430
  const getCanonicalId = getCanonicalIdFunction(luvio);
50429
50431
  const draftFunctions = {
@@ -50647,22 +50649,22 @@ const recordIdGenerator = (id) => {
50647
50649
  */
50648
50650
 
50649
50651
 
50650
- const { keys: keys$1, create: create$1, assign: assign$1, entries: entries$1 } = Object;
50651
- 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;
50652
50654
  const { push, join, slice } = Array.prototype;
50653
- const { isArray, from } = Array;
50655
+ const { isArray: isArray$2, from } = Array;
50654
50656
 
50655
50657
  function ldsParamsToString(params) {
50656
- const returnParams = create$1(null);
50657
- const keys$1$1 = keys$1(params);
50658
- for (let i = 0, len = keys$1$1.length; i < len; i++) {
50659
- 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];
50660
50662
  const value = params[key];
50661
50663
  if (value === undefined) {
50662
50664
  // filter out params that have no value
50663
50665
  continue;
50664
50666
  }
50665
- if (isArray(value)) {
50667
+ if (isArray$2(value)) {
50666
50668
  // filter out empty arrays
50667
50669
  if (value.length > 0) {
50668
50670
  returnParams[key] = value.join(',');
@@ -50671,8 +50673,8 @@ function ldsParamsToString(params) {
50671
50673
  else {
50672
50674
  returnParams[key] = `${value}`;
50673
50675
  }
50674
- if (isObject(value) === true && keys$1(value).length > 0) {
50675
- returnParams[key] = stringify$1(value);
50676
+ if (isObject(value) === true && keys$2(value).length > 0) {
50677
+ returnParams[key] = stringify$3(value);
50676
50678
  }
50677
50679
  }
50678
50680
  return returnParams;
@@ -50725,7 +50727,7 @@ function isStatusOk(status) {
50725
50727
  }
50726
50728
  // adapted from adapter-utils untrustedIsObject
50727
50729
  function isObject(value) {
50728
- return typeof value === 'object' && value !== null && isArray(value) === false;
50730
+ return typeof value === 'object' && value !== null && isArray$2(value) === false;
50729
50731
  }
50730
50732
  function stringifyIfPresent(value) {
50731
50733
  if (value === undefined || value === null) {
@@ -50734,13 +50736,13 @@ function stringifyIfPresent(value) {
50734
50736
  if (typeof value === 'string') {
50735
50737
  return value;
50736
50738
  }
50737
- return stringify$1(value);
50739
+ return stringify$3(value);
50738
50740
  }
50739
50741
  function parseIfPresent(value) {
50740
50742
  if (value === undefined || value === null || value === '') {
50741
50743
  return null;
50742
50744
  }
50743
- return parse$1(value);
50745
+ return parse$3(value);
50744
50746
  }
50745
50747
  function buildNimbusNetworkPluginRequest(resourceRequest, resourceRequestContext) {
50746
50748
  const { basePath, baseUri, method, headers, queryParams, body } = resourceRequest;
@@ -51074,9 +51076,9 @@ function buildAggregateUiUrl(params, resourceRequest) {
51074
51076
  optionalFields,
51075
51077
  };
51076
51078
  const queryString = [];
51077
- for (const [key, value] of entries$1(mergedParams)) {
51079
+ for (const [key, value] of entries$2(mergedParams)) {
51078
51080
  if (value !== undefined) {
51079
- queryString.push(`${key}=${isArray(value) ? value.join(',') : value}`);
51081
+ queryString.push(`${key}=${isArray$2(value) ? value.join(',') : value}`);
51080
51082
  }
51081
51083
  }
51082
51084
  return `${resourceRequest.baseUri}${resourceRequest.basePath}?${join.call(queryString, '&')}`;
@@ -51090,7 +51092,7 @@ function isSpanningRecord(fieldValue) {
51090
51092
  function mergeRecordFields(first, second) {
51091
51093
  const { fields: targetFields } = first;
51092
51094
  const { fields: sourceFields } = second;
51093
- const fieldNames = keys$1(sourceFields);
51095
+ const fieldNames = keys$2(sourceFields);
51094
51096
  for (let i = 0, len = fieldNames.length; i < len; i += 1) {
51095
51097
  const fieldName = fieldNames[i];
51096
51098
  const sourceField = sourceFields[fieldName];
@@ -51227,7 +51229,7 @@ function isGetRequestForEndpoint(endpoint, request) {
51227
51229
  * @returns the array or an empty array
51228
51230
  */
51229
51231
  function arrayOrEmpty(array) {
51230
- return array !== undefined && isArray(array) ? array : [];
51232
+ return array !== undefined && isArray$2(array) ? array : [];
51231
51233
  }
51232
51234
  /**
51233
51235
  * Calculate the max length per chunk.
@@ -51240,8 +51242,8 @@ function getMaxLengthPerChunkAllowed(request) {
51240
51242
  // Too much work to get exact length of the final url, so use stringified json to get the rough length.
51241
51243
  const roughUrlLengthWithoutFieldsAndOptionFields = request.basePath.length +
51242
51244
  request.baseUri.length +
51243
- (request.urlParams ? stringify$1(request.urlParams).length : 0) +
51244
- stringify$1({ ...request.queryParams, fields: {}, optionalFields: {} }).length;
51245
+ (request.urlParams ? stringify$3(request.urlParams).length : 0) +
51246
+ stringify$3({ ...request.queryParams, fields: {}, optionalFields: {} }).length;
51245
51247
  return MAX_URL_LENGTH - roughUrlLengthWithoutFieldsAndOptionFields;
51246
51248
  }
51247
51249
  // we don't have access to the host so we cannot calculate the exact length of the url
@@ -51250,7 +51252,7 @@ function calculateEstimatedTotalUrlLength(request) {
51250
51252
  const { baseUri, basePath, queryParams } = request;
51251
51253
  let url = `${baseUri}${basePath}`;
51252
51254
  if (queryParams) {
51253
- const queryParamString = entries$1(queryParams)
51255
+ const queryParamString = entries$2(queryParams)
51254
51256
  .map(([key, value]) => `${key}=${value}`)
51255
51257
  .join('&');
51256
51258
  if (queryParamString) {
@@ -51271,13 +51273,13 @@ const referenceId$1 = 'LDS_Records_AggregateUi';
51271
51273
  */
51272
51274
  function mergeGetRecordResult(first, second) {
51273
51275
  // return the error if first is error.
51274
- if (isArray(first) && !isArray(second))
51276
+ if (isArray$2(first) && !isArray$2(second))
51275
51277
  return first;
51276
51278
  // return the error if second is error.
51277
- if (!isArray(first) && isArray(second))
51279
+ if (!isArray$2(first) && isArray$2(second))
51278
51280
  return second;
51279
51281
  // concat the error array if both are error
51280
- if (isArray(first) && isArray(second)) {
51282
+ if (isArray$2(first) && isArray$2(second)) {
51281
51283
  return [...first, ...second];
51282
51284
  }
51283
51285
  mergeRecordFields(first, second);
@@ -51347,10 +51349,10 @@ class NimbusDraftQueue {
51347
51349
  if (callProxyMethod === undefined) {
51348
51350
  return Promise.reject(new Error('callProxyMethod not defined on the nimbus plugin'));
51349
51351
  }
51350
- const serializedAction = stringify$2([handlerId, data]);
51352
+ const serializedAction = stringify$4([handlerId, data]);
51351
51353
  return new Promise((resolve, reject) => {
51352
51354
  callProxyMethod('enqueue', serializedAction, (serializedActionResponse) => {
51353
- const response = parse$2(serializedActionResponse);
51355
+ const response = parse$4(serializedActionResponse);
51354
51356
  resolve(response);
51355
51357
  }, (errorMessage) => {
51356
51358
  reject(new Error(errorMessage));
@@ -51371,8 +51373,8 @@ class NimbusDraftQueue {
51371
51373
  return Promise.reject(new Error('callProxyMethod not defined on the nimbus plugin'));
51372
51374
  }
51373
51375
  return new Promise((resolve, reject) => {
51374
- callProxyMethod('getQueueActions', stringify$2([]), (serializedQueue) => {
51375
- resolve(parse$2(serializedQueue));
51376
+ callProxyMethod('getQueueActions', stringify$4([]), (serializedQueue) => {
51377
+ resolve(parse$4(serializedQueue));
51376
51378
  }, (errorMessage) => {
51377
51379
  reject(new Error(errorMessage));
51378
51380
  });
@@ -51383,17 +51385,17 @@ class NimbusDraftQueue {
51383
51385
  if (callProxyMethod === undefined) {
51384
51386
  return Promise.reject('callProxyMethod not defined on the nimbus plugin');
51385
51387
  }
51386
- const stringifiedArgs = stringify$2([action]);
51388
+ const stringifiedArgs = stringify$4([action]);
51387
51389
  return new Promise((resolve, reject) => {
51388
51390
  callProxyMethod('getDataForAction', stringifiedArgs, (data) => {
51389
51391
  if (data === undefined) {
51390
51392
  resolve(undefined);
51391
51393
  }
51392
51394
  else {
51393
- resolve(parse$2(data));
51395
+ resolve(parse$4(data));
51394
51396
  }
51395
51397
  }, (serializedError) => {
51396
- reject(parse$2(serializedError));
51398
+ reject(parse$4(serializedError));
51397
51399
  });
51398
51400
  });
51399
51401
  }
@@ -51478,7 +51480,7 @@ function instrumentDraftQueue(queue) {
51478
51480
  logError: false,
51479
51481
  });
51480
51482
  };
51481
- const overriddenQueue = create$2(queue, { mergeActions: { value: mergeActions } });
51483
+ const overriddenQueue = create$3(queue, { mergeActions: { value: mergeActions } });
51482
51484
  overriddenQueue.registerOnChangedListener((draftQueueEvent) => {
51483
51485
  switch (draftQueueEvent.type) {
51484
51486
  case DraftQueueEventType.QueueStateChanged: {
@@ -51616,7 +51618,7 @@ function enableObjectInfoCaching(env, ensureObjectInfoCached) {
51616
51618
  function dataIsObjectInfo(key, data) {
51617
51619
  return incomingObjectInfos.has(key);
51618
51620
  }
51619
- return create$2(env, {
51621
+ return create$3(env, {
51620
51622
  handleSuccessResponse: { value: handleSuccessResponse },
51621
51623
  storePublish: { value: storePublish },
51622
51624
  });
@@ -51717,8 +51719,8 @@ class ObjectInfoService {
51717
51719
  }
51718
51720
  };
51719
51721
  // Local in-memory cache for apiName to key prefixes
51720
- this.apiNameToKeyPrefixMemoryCache = create$2(null);
51721
- this.keyPrefixToApiNameMemoryCache = create$2(null);
51722
+ this.apiNameToKeyPrefixMemoryCache = create$3(null);
51723
+ this.keyPrefixToApiNameMemoryCache = create$3(null);
51722
51724
  }
51723
51725
  /**
51724
51726
  * Size of return map not necessarily correlated with number of inputs. The
@@ -51884,8 +51886,8 @@ function registerReportObserver(reportObserver) {
51884
51886
  };
51885
51887
  }
51886
51888
 
51887
- const { keys, create, assign, entries, values } = Object;
51888
- 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;
51889
51891
 
51890
51892
  function selectColumnsFromTableWhereKeyIn(columnNames, table, keyColumnName, whereIn) {
51891
51893
  const paramList = whereIn.map(() => '?').join(',');
@@ -51926,7 +51928,7 @@ class LdsDataTable {
51926
51928
  const [key, stringifiedMetadata] = row;
51927
51929
  if (stringifiedMetadata !== undefined) {
51928
51930
  entries[key] = {
51929
- metadata: parse(stringifiedMetadata),
51931
+ metadata: parse$2(stringifiedMetadata),
51930
51932
  };
51931
51933
  }
51932
51934
  return entries;
@@ -51951,10 +51953,10 @@ class LdsDataTable {
51951
51953
  },
51952
51954
  conflictColumns: this.conflictColumnNames,
51953
51955
  columns: this.columnNames,
51954
- rows: keys(entries).reduce((rows, key) => {
51956
+ rows: keys$1(entries).reduce((rows, key) => {
51955
51957
  const entry = entries[key];
51956
51958
  const { data, metadata } = entry;
51957
- const row = [key, stringify(data), metadata ? stringify(metadata) : null];
51959
+ const row = [key, stringify$2(data), metadata ? stringify$2(metadata) : null];
51958
51960
  rows.push(row);
51959
51961
  return rows;
51960
51962
  }, []),
@@ -51970,9 +51972,9 @@ class LdsDataTable {
51970
51972
  type: 'setMetadata',
51971
51973
  },
51972
51974
  columns: [COLUMN_NAME_METADATA$1],
51973
- values: keys(entries).reduce((values, key) => {
51975
+ values: keys$1(entries).reduce((values, key) => {
51974
51976
  const { metadata } = entries[key];
51975
- const row = [metadata ? stringify(metadata) : null];
51977
+ const row = [metadata ? stringify$2(metadata) : null];
51976
51978
  values[key] = row;
51977
51979
  return values;
51978
51980
  }, {}),
@@ -51982,10 +51984,10 @@ class LdsDataTable {
51982
51984
  return sqliteResult.rows.reduce((entries, row) => {
51983
51985
  const [key, stringifiedData, stringifiedMetadata] = row;
51984
51986
  const durableStoreEntry = {
51985
- data: parse(stringifiedData),
51987
+ data: parse$2(stringifiedData),
51986
51988
  };
51987
51989
  if (stringifiedMetadata !== null) {
51988
- durableStoreEntry.metadata = parse(stringifiedMetadata);
51990
+ durableStoreEntry.metadata = parse$2(stringifiedMetadata);
51989
51991
  }
51990
51992
  entries[key] = durableStoreEntry;
51991
51993
  return entries;
@@ -52035,7 +52037,7 @@ class LdsInternalDataTable {
52035
52037
  const [key, stringifiedMetadata] = row;
52036
52038
  if (stringifiedMetadata !== undefined) {
52037
52039
  entries[key] = {
52038
- metadata: parse(stringifiedMetadata),
52040
+ metadata: parse$2(stringifiedMetadata),
52039
52041
  };
52040
52042
  }
52041
52043
  return entries;
@@ -52060,12 +52062,12 @@ class LdsInternalDataTable {
52060
52062
  },
52061
52063
  conflictColumns: this.conflictColumnNames,
52062
52064
  columns: this.columnNames,
52063
- rows: keys(entries).reduce((rows, key) => {
52065
+ rows: keys$1(entries).reduce((rows, key) => {
52064
52066
  const entry = entries[key];
52065
52067
  const { data, metadata } = entry;
52066
- const row = [key, stringify(data)];
52068
+ const row = [key, stringify$2(data)];
52067
52069
  if (metadata) {
52068
- row.push(stringify(metadata));
52070
+ row.push(stringify$2(metadata));
52069
52071
  }
52070
52072
  else {
52071
52073
  row.push(null);
@@ -52086,21 +52088,21 @@ class LdsInternalDataTable {
52086
52088
  type: 'setMetadata',
52087
52089
  },
52088
52090
  columns: [COLUMN_NAME_METADATA],
52089
- values: keys(entries).reduce((values, key) => {
52091
+ values: keys$1(entries).reduce((values, key) => {
52090
52092
  const { metadata } = entries[key];
52091
- const row = [metadata ? stringify(metadata) : null];
52093
+ const row = [metadata ? stringify$2(metadata) : null];
52092
52094
  values[key] = row;
52093
52095
  return values;
52094
52096
  }, {}),
52095
52097
  };
52096
52098
  }
52097
52099
  metadataToUpdateSQLQueries(entries, segment) {
52098
- return keys(entries).reduce((accu, key) => {
52100
+ return keys$1(entries).reduce((accu, key) => {
52099
52101
  const { metadata } = entries[key];
52100
52102
  if (metadata !== undefined) {
52101
52103
  accu.push({
52102
52104
  sql: `UPDATE ${this.tableName} SET ${COLUMN_NAME_METADATA} = ? WHERE (${COLUMN_NAME_KEY$1} IS ? AND ${COLUMN_NAME_NAMESPACE} IS ?)`,
52103
- params: [stringify(metadata), key, segment],
52105
+ params: [stringify$2(metadata), key, segment],
52104
52106
  change: {
52105
52107
  ids: [key],
52106
52108
  segment,
@@ -52116,10 +52118,10 @@ class LdsInternalDataTable {
52116
52118
  return sqliteResult.rows.reduce((entries, row) => {
52117
52119
  const [key, stringifiedData, stringifiedMetadata] = row;
52118
52120
  const durableStoreEntry = {
52119
- data: parse(stringifiedData),
52121
+ data: parse$2(stringifiedData),
52120
52122
  };
52121
52123
  if (stringifiedMetadata !== null) {
52122
- durableStoreEntry.metadata = parse(stringifiedMetadata);
52124
+ durableStoreEntry.metadata = parse$2(stringifiedMetadata);
52123
52125
  }
52124
52126
  entries[key] = durableStoreEntry;
52125
52127
  return entries;
@@ -52177,7 +52179,7 @@ class NimbusSqliteStore {
52177
52179
  .finally(() => tasker.done());
52178
52180
  }
52179
52181
  setEntries(entries, segment) {
52180
- if (keys(entries).length === 0) {
52182
+ if (keys$1(entries).length === 0) {
52181
52183
  return Promise.resolve();
52182
52184
  }
52183
52185
  const table = this.getTable(segment);
@@ -52188,7 +52190,7 @@ class NimbusSqliteStore {
52188
52190
  return this.batchOperationAsPromise([upsertOperation]);
52189
52191
  }
52190
52192
  setMetadata(entries, segment) {
52191
- if (keys(entries).length === 0) {
52193
+ if (keys$1(entries).length === 0) {
52192
52194
  return Promise.resolve();
52193
52195
  }
52194
52196
  const table = this.getTable(segment);
@@ -52198,7 +52200,7 @@ class NimbusSqliteStore {
52198
52200
  batchOperations(operations) {
52199
52201
  const sqliteOperations = operations.reduce((acc, cur) => {
52200
52202
  if (cur.type === 'setEntries') {
52201
- if (keys(cur.entries).length > 0) {
52203
+ if (keys$1(cur.entries).length > 0) {
52202
52204
  const table = this.getTable(cur.segment);
52203
52205
  const upsertOperation = table.entriesToUpsertOperations(cur.entries, cur.segment);
52204
52206
  if (cur.entries[GRAPHQL_QUERY_ROOT_KEY]) {
@@ -52208,7 +52210,7 @@ class NimbusSqliteStore {
52208
52210
  }
52209
52211
  }
52210
52212
  else if (cur.type === 'setMetadata') {
52211
- if (keys(cur.entries).length > 0) {
52213
+ if (keys$1(cur.entries).length > 0) {
52212
52214
  const table = this.getTable(cur.segment);
52213
52215
  acc.push(table.metadataToUpdateOperations(cur.entries, cur.segment));
52214
52216
  }
@@ -52345,9 +52347,9 @@ class AbstractKeyValueDataTable {
52345
52347
  },
52346
52348
  conflictColumns: this.conflictColumnNames,
52347
52349
  columns: this.columnNames,
52348
- rows: keys(entries).reduce((rows, key) => {
52350
+ rows: keys$1(entries).reduce((rows, key) => {
52349
52351
  const entry = entries[key];
52350
- rows.push([key, stringify(entry.data)]);
52352
+ rows.push([key, stringify$2(entry.data)]);
52351
52353
  return rows;
52352
52354
  }, []),
52353
52355
  };
@@ -52360,7 +52362,7 @@ class AbstractKeyValueDataTable {
52360
52362
  return sqliteResult.rows.reduce((entries, row) => {
52361
52363
  const [key, stringifiedData] = row;
52362
52364
  const durableStoreEntry = {
52363
- data: parse(stringifiedData),
52365
+ data: parse$2(stringifiedData),
52364
52366
  };
52365
52367
  entries[key] = durableStoreEntry;
52366
52368
  return entries;
@@ -52513,7 +52515,7 @@ function makeEnvironmentGraphqlAware(environment) {
52513
52515
  }
52514
52516
  return environment.applyCachePolicy(luvio, adapterRequestContext, buildSnapshotContext, localBuildCachedSnapshot, buildNetworkSnapshot);
52515
52517
  };
52516
- return create$2(environment, {
52518
+ return create$3(environment, {
52517
52519
  rebuildSnapshot: { value: rebuildSnapshot },
52518
52520
  applyCachePolicy: { value: applyCachePolicy },
52519
52521
  setDefaultCachePolicy: { value: environment.setDefaultCachePolicy.bind(environment) },
@@ -52993,14 +52995,10 @@ class PrimingSession extends EventEmitter {
52993
52995
  const userData = {
52994
52996
  ...stats,
52995
52997
  };
52996
- if (errors.length) {
52997
- for (const error in errors) {
52998
- activity.error(error, schema, userData);
52999
- }
53000
- }
53001
- else {
53002
- activity.stop(schema, userData);
52998
+ for (const error in errors) {
52999
+ activity.error(error);
53003
53000
  }
53001
+ activity.stop(schema, userData);
53004
53002
  }
53005
53003
  enqueueBatches(batches, paginationCount = 0, instrumentationContext) {
53006
53004
  for (const batch of batches) {
@@ -53168,7 +53166,7 @@ class PrimingSession extends EventEmitter {
53168
53166
  }
53169
53167
  return;
53170
53168
  }
53171
- if (keys$2(result.additionalWork.records).length > 0) {
53169
+ if (keys$3(result.additionalWork.records).length > 0) {
53172
53170
  this.emit('conflict', {
53173
53171
  ids: Object.values(result.additionalWork.records).flatMap((record) => record.ids),
53174
53172
  resolution: 'priming-refresh',
@@ -53177,7 +53175,7 @@ class PrimingSession extends EventEmitter {
53177
53175
  let limitedResult = this.applyRetryLimits(result.additionalWork);
53178
53176
  this.enqueue(limitedResult.additionalWork);
53179
53177
  if (limitedResult.recordsNeedingRefetch.size > 0) {
53180
- for (const key in keys$2(limitedResult.recordsNeedingRefetch)) {
53178
+ for (const key in keys$3(limitedResult.recordsNeedingRefetch)) {
53181
53179
  const value = limitedResult.recordsNeedingRefetch.get(key);
53182
53180
  if (result.recordsNeedingRefetch.has(key)) {
53183
53181
  let existing = result.recordsNeedingRefetch.get(key);
@@ -53263,7 +53261,7 @@ class PrimingSession extends EventEmitter {
53263
53261
  };
53264
53262
  // refetchable work gets delegated to getRecords
53265
53263
  let refetchableWork = new Map();
53266
- for (const key of keys$2(primingWork.records)) {
53264
+ for (const key of keys$3(primingWork.records)) {
53267
53265
  let work = primingWork.records[key];
53268
53266
  let limitedIds = [];
53269
53267
  for (const id of work.ids) {
@@ -54162,7 +54160,7 @@ async function aggressiveTrim(data, deallocateFn, options = {}) {
54162
54160
  const batchSize = options.batchSize !== undefined ? options.batchSize : DEFAULT_MAX_BATCH_SIZE;
54163
54161
  let deallocatedCount = 0;
54164
54162
  const { pendingTrimKeys, retainedIds, storeRecords } = data;
54165
- const storeKeyLength = keys$2(storeRecords).length;
54163
+ const storeKeyLength = keys$3(storeRecords).length;
54166
54164
  if (storeKeyLength <= maxStoreRecords) {
54167
54165
  return { deallocatedCount, trimKeysSkipped: pendingTrimKeys };
54168
54166
  }
@@ -54230,7 +54228,7 @@ function setupObserver() {
54230
54228
  registerReportObserver((report) => {
54231
54229
  __nimbus.plugins.LdsObserverPlugin.logAdapterExecution({
54232
54230
  name: report.adapterName,
54233
- serializedConfig: stringify$2(report.config),
54231
+ serializedConfig: stringify$4(report.config),
54234
54232
  status: report.result,
54235
54233
  duration: report.executionTime,
54236
54234
  });
@@ -54351,7 +54349,7 @@ function transformConfiguration$1(config) {
54351
54349
  // Make a copy of the config before running transform to avoid mutating the original config
54352
54350
  const adapterConfigCopy = {
54353
54351
  ...config,
54354
- query: parse$5(print(config.query))
54352
+ query: parse$7(print(config.query))
54355
54353
  };
54356
54354
  return {
54357
54355
  ...adapterConfigCopy,
@@ -54729,7 +54727,7 @@ function transformConfiguration(config) {
54729
54727
  const batchQueryTransformed = config.batchQuery.map((singleConfig) => {
54730
54728
  return {
54731
54729
  ...singleConfig,
54732
- 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?
54733
54731
  };
54734
54732
  });
54735
54733
  return {
@@ -54826,7 +54824,7 @@ class SideEffectStore {
54826
54824
  if (idsToFetch.size > 0) {
54827
54825
  const effects = await durableStore.getEntries(Array.from(idsToFetch), SIDE_EFFECT_SEGMENT);
54828
54826
  if (effects !== undefined) {
54829
- keys$2(effects).forEach((effectId) => {
54827
+ keys$3(effects).forEach((effectId) => {
54830
54828
  const effect = effects[effectId].data;
54831
54829
  const key = effect.uniqueId;
54832
54830
  this.allEffects.set(key, effect);
@@ -54880,7 +54878,7 @@ class SideEffectStore {
54880
54878
  if (effects === undefined) {
54881
54879
  return;
54882
54880
  }
54883
- keys$2(effects).forEach((effectId) => {
54881
+ keys$3(effects).forEach((effectId) => {
54884
54882
  const effect = effects[effectId].data;
54885
54883
  const key = effect.uniqueId;
54886
54884
  this.allEffects.set(key, effect);
@@ -55013,7 +55011,7 @@ class SideEffectService {
55013
55011
  async synthesizeFieldsFromParts(fields, apiName) {
55014
55012
  const objectInfo = await this.ensureObjectInfo(apiName);
55015
55013
  const recordFields = {};
55016
- for (const fieldName of keys$2(fields)) {
55014
+ for (const fieldName of keys$3(fields)) {
55017
55015
  const draftField = fields[fieldName] ?? null;
55018
55016
  recordFields[fieldName] = { value: draftField, displayValue: null };
55019
55017
  const fieldInfo = objectInfo.fields[fieldName];
@@ -55094,7 +55092,7 @@ class SideEffectService {
55094
55092
  changedNameFields[fieldName] = fieldValue;
55095
55093
  }
55096
55094
  }
55097
- if (keys$2(changedNameFields).length > 0) {
55095
+ if (keys$3(changedNameFields).length > 0) {
55098
55096
  const newNameValue = filteredNameFields
55099
55097
  .map((key) => {
55100
55098
  if (changedNameFields[key] !== undefined) {
@@ -55194,7 +55192,7 @@ class SideEffectService {
55194
55192
  }
55195
55193
 
55196
55194
  function clone(obj) {
55197
- return parse$2(stringify$2(obj));
55195
+ return parse$4(stringify$4(obj));
55198
55196
  }
55199
55197
 
55200
55198
  /* global __nimbus */
@@ -55221,7 +55219,7 @@ class UpdateRecordEffectHandler {
55221
55219
  }
55222
55220
  const patchedFields = effect.recordPatch.fields;
55223
55221
  if (patchedFields) {
55224
- const fieldNames = keys$2(patchedFields);
55222
+ const fieldNames = keys$3(patchedFields);
55225
55223
  for (let i = 0, len = fieldNames.length; i < len; i++) {
55226
55224
  const fieldName = fieldNames[i];
55227
55225
  // don't apply server values to draft created records
@@ -55380,7 +55378,7 @@ function removeEffects(record) {
55380
55378
  return undefined;
55381
55379
  }
55382
55380
  const updatedFields = {};
55383
- const fieldNames = keys$2(fields);
55381
+ const fieldNames = keys$3(fields);
55384
55382
  for (let i = 0, len = fieldNames.length; i < len; i++) {
55385
55383
  const fieldName = fieldNames[i];
55386
55384
  const field = fields[fieldName];
@@ -55492,7 +55490,7 @@ class DurableRecordStore {
55492
55490
  if (entries === undefined) {
55493
55491
  return directory;
55494
55492
  }
55495
- keys$2(entries).forEach((key) => {
55493
+ keys$3(entries).forEach((key) => {
55496
55494
  const { data: record, metadata } = entries[key];
55497
55495
  if (isStoreRecordError(record)) {
55498
55496
  return;
@@ -55685,6 +55683,2296 @@ function createSfsSideEffectHooks(durableRecordStore) {
55685
55683
  return [];
55686
55684
  }
55687
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
+
55688
57976
  // so eslint doesn't complain about nimbus
55689
57977
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
55690
57978
  /* global __nimbus */
@@ -55707,7 +57995,7 @@ const shouldFlush = (key, value) => {
55707
57995
  if (value && typeof value === 'object') {
55708
57996
  const fields = value.fields;
55709
57997
  if (fields && typeof fields === 'object') {
55710
- const keys = keys$2(fields);
57998
+ const keys = keys$3(fields);
55711
57999
  for (const key of keys) {
55712
58000
  const field = fields[key];
55713
58001
  if (fields && field.__state && field.__state.pending === true) {
@@ -55724,7 +58012,7 @@ const shouldFlush = (key, value) => {
55724
58012
  /**
55725
58013
  * This returns the LDS on Mobile Runtime singleton object.
55726
58014
  */
55727
- function getRuntime() {
58015
+ function getRuntime({ primeUser = false } = {}) {
55728
58016
  if (lazyLuvio === undefined ||
55729
58017
  lazyEnvironment === undefined ||
55730
58018
  lazyDraftManager === undefined ||
@@ -55748,6 +58036,18 @@ function getRuntime() {
55748
58036
  // specific adapters
55749
58037
  const internalAdapterStore = new InMemoryStore();
55750
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
+ }
55751
58051
  lazyInternalLuvio = internalLuvio;
55752
58052
  lazyObjectInfoService = new ObjectInfoService(getObjectInfo, getObjectInfos, getObjectInfoDirectory, lazyDurableStore);
55753
58053
  const baseEnv = new Environment(store, lazyNetworkAdapter);
@@ -55843,6 +58143,8 @@ function getRuntime() {
55843
58143
  });
55844
58144
  withRegistration('@salesforce/lds-adapters-uiapi/graphql', configureUIAPIGraphQL);
55845
58145
  }
58146
+ // onestore initialization
58147
+ initializeOneStore();
55846
58148
  return {
55847
58149
  luvio: lazyLuvio,
55848
58150
  internalLuvio: lazyInternalLuvio,
@@ -55876,4 +58178,4 @@ register({
55876
58178
  });
55877
58179
 
55878
58180
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, ingest$1o as ingestDenormalizedRecordRepresentation, registerReportObserver, reportGraphqlQueryParseError };
55879
- // version: 1.366.0-30380c7ed7
58181
+ // version: 1.367.0-def0c51200