@salesforce/lds-runtime-mobile 1.369.0 → 1.370.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/sfdc/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 'force/luvioEngine';
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 'force/ldsAdaptersUiapi';
22
22
  import { getInstrumentation, idleDetector } from 'o11y/client';
23
- import { Kind as Kind$1, visit as visit$1, isObjectType, defaultFieldResolver, buildSchema, parse as parse$7, extendSchema, isScalarType, execute, print } from 'force/ldsGraphqlParser';
23
+ import { Kind as Kind$1, visit as visit$1, isObjectType, defaultFieldResolver, buildSchema, parse as parse$8, extendSchema, isScalarType, execute, print } from 'force/ldsGraphqlParser';
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';
@@ -49,7 +49,7 @@ import { setServices } from 'force/luvioServiceProvisioner1';
49
49
  */
50
50
 
51
51
 
52
- const { parse: parse$6, stringify: stringify$6 } = JSON;
52
+ const { parse: parse$7, stringify: stringify$7 } = JSON;
53
53
  const { join: join$1, push: push$2, unshift } = Array.prototype;
54
54
  const { isArray: isArray$5 } = Array;
55
55
  const { entries: entries$4, keys: keys$6 } = Object;
@@ -352,10 +352,10 @@ function getTransactionKey(req) {
352
352
  const { resourceRequest } = req;
353
353
  const { baseUri, basePath, queryParams, headers } = resourceRequest;
354
354
  const path = `${baseUri}${basePath}`;
355
- const queryParamsString = queryParams ? stringify$6(queryParams) : EMPTY_STRING;
356
- const headersString = stringify$6(headers);
355
+ const queryParamsString = queryParams ? stringify$7(queryParams) : EMPTY_STRING;
356
+ const headersString = stringify$7(headers);
357
357
  const bodyString = resourceRequest.body && isResourceRequestDedupable(req)
358
- ? stringify$6(resourceRequest.body)
358
+ ? stringify$7(resourceRequest.body)
359
359
  : EMPTY_STRING;
360
360
  return `${path}${TRANSACTION_KEY_SEP}${headersString}${TRANSACTION_KEY_SEP}${queryParamsString}${bodyString}`;
361
361
  }
@@ -426,7 +426,7 @@ const dedupeRequest = (req) => {
426
426
  // extra clone (particularly when there's only 1 handler).
427
427
  for (let i = 1, len = handlers.length; i < len; i++) {
428
428
  const handler = handlers[i];
429
- handler.resolve(parse$6(stringify$6(response)));
429
+ handler.resolve(parse$7(stringify$7(response)));
430
430
  }
431
431
  handlers[0].resolve(response);
432
432
  }, (error) => {
@@ -1841,7 +1841,7 @@ var QueueOperationType;
1841
1841
  })(QueueOperationType || (QueueOperationType = {}));
1842
1842
 
1843
1843
  const { keys: keys$4, create: create$4, assign: assign$3, values: values$2 } = Object;
1844
- const { stringify: stringify$5, parse: parse$5 } = JSON;
1844
+ const { stringify: stringify$6, parse: parse$6 } = JSON;
1845
1845
  const { isArray: isArray$4 } = Array;
1846
1846
 
1847
1847
  class DraftSynthesisError extends Error {
@@ -2543,7 +2543,7 @@ class DurableDraftQueue {
2543
2543
  }
2544
2544
 
2545
2545
  function clone$1(obj) {
2546
- return parse$5(stringify$5(obj));
2546
+ return parse$6(stringify$6(obj));
2547
2547
  }
2548
2548
 
2549
2549
  const DRAFT_ACTION_KEY_JUNCTION = '__DraftAction__';
@@ -3010,7 +3010,7 @@ class DraftManager {
3010
3010
  // We should always return an array, if the body is just a dictionary,
3011
3011
  // stick it in an array
3012
3012
  const body = isArray$4(action.error.body) ? action.error.body : [action.error.body];
3013
- const bodyString = stringify$5(body);
3013
+ const bodyString = stringify$6(body);
3014
3014
  item.error = {
3015
3015
  status: action.error.status || 0,
3016
3016
  ok: action.error.ok || false,
@@ -3257,7 +3257,7 @@ const { hasOwnProperty } = Object.prototype;
3257
3257
  const { split, endsWith } = String.prototype;
3258
3258
  const { from: from$1, isArray: isArray$3 } = Array;
3259
3259
  const { concat, filter, includes, push: push$1, reduce, shift, slice: slice$1 } = Array.prototype;
3260
- const { parse: parse$4, stringify: stringify$4 } = JSON;
3260
+ const { parse: parse$5, stringify: stringify$5 } = JSON;
3261
3261
 
3262
3262
  function isString(value) {
3263
3263
  return typeof value === 'string';
@@ -14854,7 +14854,7 @@ function prepareRequest$3(luvio, config) {
14854
14854
  // we have to run ingest code and look at the resulting snapshot's seenRecords.
14855
14855
  function getCacheKeys(keySet, luvio, config, key, originalResponseBody) {
14856
14856
  const { recordIds, layoutTypes, modes } = config;
14857
- const responseBody = parse$4(stringify$4(originalResponseBody));
14857
+ const responseBody = parse$5(stringify$5(originalResponseBody));
14858
14858
  eachLayout(responseBody, (apiName, recordTypeId, layout) => {
14859
14859
  if (layout.id === null) {
14860
14860
  return;
@@ -42023,7 +42023,7 @@ class AbstractResourceRequestActionHandler {
42023
42023
  let updatedActionTargetId = undefined;
42024
42024
  const { tag: queueActionTag, data: queueActionRequest, id: queueActionId, } = queueAction;
42025
42025
  let { basePath, body } = queueActionRequest;
42026
- let stringifiedBody = stringify$4(body);
42026
+ let stringifiedBody = stringify$5(body);
42027
42027
  // for each redirected ID/key we loop over the operation to see if it needs
42028
42028
  // to be updated
42029
42029
  for (const { draftId, draftKey, canonicalId, canonicalKey } of redirects) {
@@ -42048,7 +42048,7 @@ class AbstractResourceRequestActionHandler {
42048
42048
  data: {
42049
42049
  ...queueActionRequest,
42050
42050
  basePath: basePath,
42051
- body: parse$4(stringifiedBody),
42051
+ body: parse$5(stringifiedBody),
42052
42052
  },
42053
42053
  };
42054
42054
  // item needs to be replaced with a new item at the new record key
@@ -42067,7 +42067,7 @@ class AbstractResourceRequestActionHandler {
42067
42067
  data: {
42068
42068
  ...queueActionRequest,
42069
42069
  basePath: basePath,
42070
- body: parse$4(stringifiedBody),
42070
+ body: parse$5(stringifiedBody),
42071
42071
  },
42072
42072
  };
42073
42073
  // item needs to be updated
@@ -42783,7 +42783,7 @@ function normalizeError(err) {
42783
42783
  else if (typeof err === 'string') {
42784
42784
  return new Error(err);
42785
42785
  }
42786
- return new Error(stringify$4(err));
42786
+ return new Error(stringify$5(err));
42787
42787
  }
42788
42788
 
42789
42789
  const O11Y_NAMESPACE_LDS_MOBILE = 'lds-mobile';
@@ -43902,7 +43902,7 @@ function recordLoaderFactory(query) {
43902
43902
  rows.forEach((row) => {
43903
43903
  if (!row[0])
43904
43904
  return null;
43905
- const record = parse$4(row[0]);
43905
+ const record = parse$5(row[0]);
43906
43906
  if (record.id === id) {
43907
43907
  foundRow = record;
43908
43908
  }
@@ -44261,7 +44261,7 @@ function dateTimePredicate(input, operator, field, alias) {
44261
44261
  return dateTimeRange(range, operator, field, alias);
44262
44262
  }
44263
44263
  // eslint-disable-next-line @salesforce/lds/no-error-in-production
44264
- throw new Error(`Where filter ${stringify$4(input)} is not supported`);
44264
+ throw new Error(`Where filter ${stringify$5(input)} is not supported`);
44265
44265
  }
44266
44266
  function dateTimeRange(input, op, field, alias) {
44267
44267
  const dateFunction = field.dataType === 'DateTime' ? 'datetime' : 'date';
@@ -46905,14 +46905,14 @@ function isLocalCursor(maybeCursor) {
46905
46905
  typeof maybeCursor.i === 'number');
46906
46906
  }
46907
46907
  function encodeV1Cursor(cursor) {
46908
- return base64encode(stringify$4(cursor));
46908
+ return base64encode(stringify$5(cursor));
46909
46909
  }
46910
46910
  const CURSOR_PARSE_ERROR = 'Unable to parse cursor';
46911
46911
  function decodeV1Cursor(base64cursor) {
46912
46912
  let maybeCursor;
46913
46913
  try {
46914
46914
  const cursorString = base64decode(base64cursor);
46915
- maybeCursor = parse$4(cursorString);
46915
+ maybeCursor = parse$5(cursorString);
46916
46916
  }
46917
46917
  catch (error) {
46918
46918
  let message = CURSOR_PARSE_ERROR;
@@ -47116,7 +47116,7 @@ async function readPaginationMetadataForKeys(keys, query) {
47116
47116
  const results = await query(sql, keys.map((k) => k + '__pagination'));
47117
47117
  for (let row of results.rows) {
47118
47118
  let key = row[0].replace(/__pagination$/, '');
47119
- let metadata = parse$4(row[1]);
47119
+ let metadata = parse$5(row[1]);
47120
47120
  metadataMap.set(key, metadata);
47121
47121
  }
47122
47122
  return metadataMap;
@@ -47222,8 +47222,8 @@ async function connectionResolver(obj, args, context, info) {
47222
47222
  //map each sql result with the ingestion timestamp to pass it down a level
47223
47223
  let records = results.rows.map((row, index) => {
47224
47224
  const recordMetadataResult = {
47225
- recordRepresentation: parse$4(row[0]),
47226
- metadata: parse$4(row[1]),
47225
+ recordRepresentation: parse$5(row[0]),
47226
+ metadata: parse$5(row[1]),
47227
47227
  };
47228
47228
  const { recordRepresentation, metadata } = recordMetadataResult;
47229
47229
  context.seenRecordIds.add(recordRepresentation.id);
@@ -47674,7 +47674,7 @@ function extendSchemaWithObjectInfos(cache, objectInfoMap) {
47674
47674
  return cache;
47675
47675
  }
47676
47676
  // parse extensions into DocumentNode to extend the schema
47677
- const extensions = parse$7(typeDefs);
47677
+ const extensions = parse$8(typeDefs);
47678
47678
  const polymorphicFieldTypeNames = [
47679
47679
  ...polyFieldTypeNameArr,
47680
47680
  ...cache.getPolymorphicFieldTypeNames(),
@@ -50217,7 +50217,7 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
50217
50217
  const getCanonicalId = getCanonicalIdFunction(luvio);
50218
50218
  return async function draftAwareGraphQLAdapter(config, requestContext = {}) {
50219
50219
  //create a copy to not accidentally modify the AST in the astResolver map of luvio
50220
- const copy = parse$4(stringify$4(config.query));
50220
+ const copy = parse$5(stringify$5(config.query));
50221
50221
  // the injected ast has extra fields needed for eval in it
50222
50222
  let injectedAST;
50223
50223
  // the cursor mapped ast is passed upstream so it won't reject on our local cursors
@@ -50310,7 +50310,7 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
50310
50310
  } = await evaluate({
50311
50311
  ...config,
50312
50312
  //need to create another copy of the ast for future writes
50313
- query: parse$4(stringify$4(injectedAST)),
50313
+ query: parse$5(stringify$5(injectedAST)),
50314
50314
  }, observers, { userId }, objectInfoNeeded, store, nonEvaluatedSnapshot, graphqlSchemaCache, draftFunctions, mappedCursors));
50315
50315
  }
50316
50316
  catch (throwable) {
@@ -50436,7 +50436,7 @@ function makeGetRecordsConfig(keyMap) {
50436
50436
 
50437
50437
  function environmentAwareGraphQLBatchAdapterFactory(objectInfoService, luvio, isDraftId, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy) {
50438
50438
  return async function environmentAwareGraphQLBatchAdapter(config, requestContext = {}) {
50439
- const batchQueryCopy = config.batchQuery.map((query) => parse$4(stringify$4(query)));
50439
+ const batchQueryCopy = config.batchQuery.map((query) => parse$5(stringify$5(query)));
50440
50440
  let injectedBatchQuery = [];
50441
50441
  const getCanonicalId = getCanonicalIdFunction(luvio);
50442
50442
  const draftFunctions = {
@@ -50661,7 +50661,7 @@ const recordIdGenerator = (id) => {
50661
50661
 
50662
50662
 
50663
50663
  const { keys: keys$2, create: create$2, assign: assign$1, entries: entries$2 } = Object;
50664
- const { stringify: stringify$3, parse: parse$3 } = JSON;
50664
+ const { stringify: stringify$4, parse: parse$4 } = JSON;
50665
50665
  const { push, join, slice } = Array.prototype;
50666
50666
  const { isArray: isArray$2, from } = Array;
50667
50667
 
@@ -50685,7 +50685,7 @@ function ldsParamsToString(params) {
50685
50685
  returnParams[key] = `${value}`;
50686
50686
  }
50687
50687
  if (isObject(value) === true && keys$2(value).length > 0) {
50688
- returnParams[key] = stringify$3(value);
50688
+ returnParams[key] = stringify$4(value);
50689
50689
  }
50690
50690
  }
50691
50691
  return returnParams;
@@ -50747,13 +50747,13 @@ function stringifyIfPresent(value) {
50747
50747
  if (typeof value === 'string') {
50748
50748
  return value;
50749
50749
  }
50750
- return stringify$3(value);
50750
+ return stringify$4(value);
50751
50751
  }
50752
50752
  function parseIfPresent(value) {
50753
50753
  if (value === undefined || value === null || value === '') {
50754
50754
  return null;
50755
50755
  }
50756
- return parse$3(value);
50756
+ return parse$4(value);
50757
50757
  }
50758
50758
  function buildNimbusNetworkPluginRequest(resourceRequest, resourceRequestContext) {
50759
50759
  const { basePath, baseUri, method, headers, queryParams, body } = resourceRequest;
@@ -51253,8 +51253,8 @@ function getMaxLengthPerChunkAllowed(request) {
51253
51253
  // Too much work to get exact length of the final url, so use stringified json to get the rough length.
51254
51254
  const roughUrlLengthWithoutFieldsAndOptionFields = request.basePath.length +
51255
51255
  request.baseUri.length +
51256
- (request.urlParams ? stringify$3(request.urlParams).length : 0) +
51257
- stringify$3({ ...request.queryParams, fields: {}, optionalFields: {} }).length;
51256
+ (request.urlParams ? stringify$4(request.urlParams).length : 0) +
51257
+ stringify$4({ ...request.queryParams, fields: {}, optionalFields: {} }).length;
51258
51258
  return MAX_URL_LENGTH - roughUrlLengthWithoutFieldsAndOptionFields;
51259
51259
  }
51260
51260
  // we don't have access to the host so we cannot calculate the exact length of the url
@@ -51360,10 +51360,10 @@ class NimbusDraftQueue {
51360
51360
  if (callProxyMethod === undefined) {
51361
51361
  return Promise.reject(new Error('callProxyMethod not defined on the nimbus plugin'));
51362
51362
  }
51363
- const serializedAction = stringify$4([handlerId, data]);
51363
+ const serializedAction = stringify$5([handlerId, data]);
51364
51364
  return new Promise((resolve, reject) => {
51365
51365
  callProxyMethod('enqueue', serializedAction, (serializedActionResponse) => {
51366
- const response = parse$4(serializedActionResponse);
51366
+ const response = parse$5(serializedActionResponse);
51367
51367
  resolve(response);
51368
51368
  }, (errorMessage) => {
51369
51369
  reject(new Error(errorMessage));
@@ -51384,8 +51384,8 @@ class NimbusDraftQueue {
51384
51384
  return Promise.reject(new Error('callProxyMethod not defined on the nimbus plugin'));
51385
51385
  }
51386
51386
  return new Promise((resolve, reject) => {
51387
- callProxyMethod('getQueueActions', stringify$4([]), (serializedQueue) => {
51388
- resolve(parse$4(serializedQueue));
51387
+ callProxyMethod('getQueueActions', stringify$5([]), (serializedQueue) => {
51388
+ resolve(parse$5(serializedQueue));
51389
51389
  }, (errorMessage) => {
51390
51390
  reject(new Error(errorMessage));
51391
51391
  });
@@ -51396,17 +51396,17 @@ class NimbusDraftQueue {
51396
51396
  if (callProxyMethod === undefined) {
51397
51397
  return Promise.reject('callProxyMethod not defined on the nimbus plugin');
51398
51398
  }
51399
- const stringifiedArgs = stringify$4([action]);
51399
+ const stringifiedArgs = stringify$5([action]);
51400
51400
  return new Promise((resolve, reject) => {
51401
51401
  callProxyMethod('getDataForAction', stringifiedArgs, (data) => {
51402
51402
  if (data === undefined) {
51403
51403
  resolve(undefined);
51404
51404
  }
51405
51405
  else {
51406
- resolve(parse$4(data));
51406
+ resolve(parse$5(data));
51407
51407
  }
51408
51408
  }, (serializedError) => {
51409
- reject(parse$4(serializedError));
51409
+ reject(parse$5(serializedError));
51410
51410
  });
51411
51411
  });
51412
51412
  }
@@ -51898,7 +51898,7 @@ function registerReportObserver(reportObserver) {
51898
51898
  }
51899
51899
 
51900
51900
  const { keys: keys$1, create: create$1, assign, entries: entries$1, values } = Object;
51901
- const { stringify: stringify$2, parse: parse$2 } = JSON;
51901
+ const { stringify: stringify$3, parse: parse$3 } = JSON;
51902
51902
 
51903
51903
  function selectColumnsFromTableWhereKeyIn(columnNames, table, keyColumnName, whereIn) {
51904
51904
  const paramList = whereIn.map(() => '?').join(',');
@@ -51911,13 +51911,13 @@ function selectColumnsFromTableWhereKeyInNamespaced(columnNames, table, keyColum
51911
51911
 
51912
51912
  // These const values must be in sync with the latest
51913
51913
  // @salesforce/nimbus-plugin-lds/sql schema file
51914
- const TABLE_NAME$1 = 'lds_data';
51914
+ const TABLE_NAME$1$1 = 'lds_data';
51915
51915
  const COLUMN_NAME_KEY$2 = 'key';
51916
51916
  const COLUMN_NAME_DATA$2 = 'data';
51917
51917
  const COLUMN_NAME_METADATA$1 = 'metadata';
51918
51918
  class LdsDataTable {
51919
51919
  constructor(plugin) {
51920
- this.tableName = TABLE_NAME$1;
51920
+ this.tableName = TABLE_NAME$1$1;
51921
51921
  this.columnNames = [COLUMN_NAME_KEY$2, COLUMN_NAME_DATA$2, COLUMN_NAME_METADATA$1];
51922
51922
  this.conflictColumnNames = [COLUMN_NAME_KEY$2];
51923
51923
  this.getAllQuery = `SELECT ${this.columnNames.join(',')} FROM ${this.tableName}`;
@@ -51939,7 +51939,7 @@ class LdsDataTable {
51939
51939
  const [key, stringifiedMetadata] = row;
51940
51940
  if (stringifiedMetadata !== undefined) {
51941
51941
  entries[key] = {
51942
- metadata: parse$2(stringifiedMetadata),
51942
+ metadata: parse$3(stringifiedMetadata),
51943
51943
  };
51944
51944
  }
51945
51945
  return entries;
@@ -51967,7 +51967,7 @@ class LdsDataTable {
51967
51967
  rows: keys$1(entries).reduce((rows, key) => {
51968
51968
  const entry = entries[key];
51969
51969
  const { data, metadata } = entry;
51970
- const row = [key, stringify$2(data), metadata ? stringify$2(metadata) : null];
51970
+ const row = [key, stringify$3(data), metadata ? stringify$3(metadata) : null];
51971
51971
  rows.push(row);
51972
51972
  return rows;
51973
51973
  }, []),
@@ -51985,7 +51985,7 @@ class LdsDataTable {
51985
51985
  columns: [COLUMN_NAME_METADATA$1],
51986
51986
  values: keys$1(entries).reduce((values, key) => {
51987
51987
  const { metadata } = entries[key];
51988
- const row = [metadata ? stringify$2(metadata) : null];
51988
+ const row = [metadata ? stringify$3(metadata) : null];
51989
51989
  values[key] = row;
51990
51990
  return values;
51991
51991
  }, {}),
@@ -51995,10 +51995,10 @@ class LdsDataTable {
51995
51995
  return sqliteResult.rows.reduce((entries, row) => {
51996
51996
  const [key, stringifiedData, stringifiedMetadata] = row;
51997
51997
  const durableStoreEntry = {
51998
- data: parse$2(stringifiedData),
51998
+ data: parse$3(stringifiedData),
51999
51999
  };
52000
52000
  if (stringifiedMetadata !== null) {
52001
- durableStoreEntry.metadata = parse$2(stringifiedMetadata);
52001
+ durableStoreEntry.metadata = parse$3(stringifiedMetadata);
52002
52002
  }
52003
52003
  entries[key] = durableStoreEntry;
52004
52004
  return entries;
@@ -52048,7 +52048,7 @@ class LdsInternalDataTable {
52048
52048
  const [key, stringifiedMetadata] = row;
52049
52049
  if (stringifiedMetadata !== undefined) {
52050
52050
  entries[key] = {
52051
- metadata: parse$2(stringifiedMetadata),
52051
+ metadata: parse$3(stringifiedMetadata),
52052
52052
  };
52053
52053
  }
52054
52054
  return entries;
@@ -52076,9 +52076,9 @@ class LdsInternalDataTable {
52076
52076
  rows: keys$1(entries).reduce((rows, key) => {
52077
52077
  const entry = entries[key];
52078
52078
  const { data, metadata } = entry;
52079
- const row = [key, stringify$2(data)];
52079
+ const row = [key, stringify$3(data)];
52080
52080
  if (metadata) {
52081
- row.push(stringify$2(metadata));
52081
+ row.push(stringify$3(metadata));
52082
52082
  }
52083
52083
  else {
52084
52084
  row.push(null);
@@ -52101,7 +52101,7 @@ class LdsInternalDataTable {
52101
52101
  columns: [COLUMN_NAME_METADATA],
52102
52102
  values: keys$1(entries).reduce((values, key) => {
52103
52103
  const { metadata } = entries[key];
52104
- const row = [metadata ? stringify$2(metadata) : null];
52104
+ const row = [metadata ? stringify$3(metadata) : null];
52105
52105
  values[key] = row;
52106
52106
  return values;
52107
52107
  }, {}),
@@ -52113,7 +52113,7 @@ class LdsInternalDataTable {
52113
52113
  if (metadata !== undefined) {
52114
52114
  accu.push({
52115
52115
  sql: `UPDATE ${this.tableName} SET ${COLUMN_NAME_METADATA} = ? WHERE (${COLUMN_NAME_KEY$1} IS ? AND ${COLUMN_NAME_NAMESPACE} IS ?)`,
52116
- params: [stringify$2(metadata), key, segment],
52116
+ params: [stringify$3(metadata), key, segment],
52117
52117
  change: {
52118
52118
  ids: [key],
52119
52119
  segment,
@@ -52129,10 +52129,10 @@ class LdsInternalDataTable {
52129
52129
  return sqliteResult.rows.reduce((entries, row) => {
52130
52130
  const [key, stringifiedData, stringifiedMetadata] = row;
52131
52131
  const durableStoreEntry = {
52132
- data: parse$2(stringifiedData),
52132
+ data: parse$3(stringifiedData),
52133
52133
  };
52134
52134
  if (stringifiedMetadata !== null) {
52135
- durableStoreEntry.metadata = parse$2(stringifiedMetadata);
52135
+ durableStoreEntry.metadata = parse$3(stringifiedMetadata);
52136
52136
  }
52137
52137
  entries[key] = durableStoreEntry;
52138
52138
  return entries;
@@ -52360,7 +52360,7 @@ class AbstractKeyValueDataTable {
52360
52360
  columns: this.columnNames,
52361
52361
  rows: keys$1(entries).reduce((rows, key) => {
52362
52362
  const entry = entries[key];
52363
- rows.push([key, stringify$2(entry.data)]);
52363
+ rows.push([key, stringify$3(entry.data)]);
52364
52364
  return rows;
52365
52365
  }, []),
52366
52366
  };
@@ -52373,7 +52373,7 @@ class AbstractKeyValueDataTable {
52373
52373
  return sqliteResult.rows.reduce((entries, row) => {
52374
52374
  const [key, stringifiedData] = row;
52375
52375
  const durableStoreEntry = {
52376
- data: parse$2(stringifiedData),
52376
+ data: parse$3(stringifiedData),
52377
52377
  };
52378
52378
  entries[key] = durableStoreEntry;
52379
52379
  return entries;
@@ -52383,10 +52383,10 @@ class AbstractKeyValueDataTable {
52383
52383
 
52384
52384
  // These const values must be in sync with the latest
52385
52385
  // @salesforce/nimbus-plugin-lds/sql schema file
52386
- const TABLE_NAME = 'lds_env_drafts';
52386
+ const TABLE_NAME$1 = 'lds_env_drafts';
52387
52387
  class LdsDraftsDataTable extends AbstractKeyValueDataTable {
52388
52388
  constructor(plugin) {
52389
- super(plugin, TABLE_NAME);
52389
+ super(plugin, TABLE_NAME$1);
52390
52390
  }
52391
52391
  }
52392
52392
 
@@ -54248,7 +54248,7 @@ function setupObserver() {
54248
54248
  registerReportObserver((report) => {
54249
54249
  __nimbus.plugins.LdsObserverPlugin.logAdapterExecution({
54250
54250
  name: report.adapterName,
54251
- serializedConfig: stringify$4(report.config),
54251
+ serializedConfig: stringify$5(report.config),
54252
54252
  status: report.result,
54253
54253
  duration: report.executionTime,
54254
54254
  });
@@ -54369,7 +54369,7 @@ function transformConfiguration$1(config) {
54369
54369
  // Make a copy of the config before running transform to avoid mutating the original config
54370
54370
  const adapterConfigCopy = {
54371
54371
  ...config,
54372
- query: parse$7(print(config.query))
54372
+ query: parse$8(print(config.query))
54373
54373
  };
54374
54374
  return {
54375
54375
  ...adapterConfigCopy,
@@ -54747,7 +54747,7 @@ function transformConfiguration(config) {
54747
54747
  const batchQueryTransformed = config.batchQuery.map((singleConfig) => {
54748
54748
  return {
54749
54749
  ...singleConfig,
54750
- 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?
54750
+ query: applyMinimumFieldsToQuery(parse$8(print(singleConfig.query))), // Stringifies and parses again to avoid mutating original. Should we just JSON.stringify to avoid the dependency on the parser?
54751
54751
  };
54752
54752
  });
54753
54753
  return {
@@ -55212,7 +55212,7 @@ class SideEffectService {
55212
55212
  }
55213
55213
 
55214
55214
  function clone(obj) {
55215
- return parse$4(stringify$4(obj));
55215
+ return parse$5(stringify$5(obj));
55216
55216
  }
55217
55217
 
55218
55218
  /* global __nimbus */
@@ -55710,7 +55710,7 @@ function createSfsSideEffectHooks(durableRecordStore) {
55710
55710
  */
55711
55711
  const { create, freeze, keys, entries } = Object;
55712
55712
  const { isArray: isArray$1 } = Array;
55713
- const { stringify: stringify$1, parse: parse$1 } = JSON;
55713
+ const { stringify: stringify$2, parse: parse$2 } = JSON;
55714
55714
  const LogLevelMap = {
55715
55715
  TRACE: 4,
55716
55716
  DEBUG: 3,
@@ -55747,7 +55747,7 @@ class ConsoleLogger {
55747
55747
  this.printer(this.formatter(level, message));
55748
55748
  }
55749
55749
  }
55750
- let Ok$2 = class Ok {
55750
+ let Ok$1 = class Ok {
55751
55751
  constructor(value) {
55752
55752
  this.value = value;
55753
55753
  }
@@ -55769,7 +55769,7 @@ let Err$1 = class Err {
55769
55769
  return !this.isOk();
55770
55770
  }
55771
55771
  };
55772
- const ok$2 = (value) => new Ok$2(value);
55772
+ const ok$1 = (value) => new Ok$1(value);
55773
55773
  const err$1 = (err2) => new Err$1(err2);
55774
55774
  function isSubscribableResult(x) {
55775
55775
  if (typeof x !== "object" || x === null) {
@@ -55832,7 +55832,7 @@ function stableJSONStringify(node) {
55832
55832
  return isFinite(node) ? "" + node : "null";
55833
55833
  }
55834
55834
  if (typeof node !== "object") {
55835
- return stringify$1(node);
55835
+ return stringify$2(node);
55836
55836
  }
55837
55837
  let i;
55838
55838
  let out;
@@ -55860,7 +55860,7 @@ function stableJSONStringify(node) {
55860
55860
  if (out) {
55861
55861
  out += ",";
55862
55862
  }
55863
- out += stringify$1(key) + ":" + value;
55863
+ out += stringify$2(key) + ":" + value;
55864
55864
  }
55865
55865
  return "{" + out + "}";
55866
55866
  }
@@ -55904,7 +55904,7 @@ let NetworkCommand$1 = class NetworkCommand extends BaseCommand {
55904
55904
  return err$1(networkResult.error);
55905
55905
  } else {
55906
55906
  const data = networkResult.value;
55907
- return ok$2({
55907
+ return ok$1({
55908
55908
  data,
55909
55909
  subscribe: (cb) => {
55910
55910
  this.subscriptions.push(cb);
@@ -55923,10 +55923,10 @@ let NetworkCommand$1 = class NetworkCommand extends BaseCommand {
55923
55923
  if (isSubscribableResult(newResult)) {
55924
55924
  const value = newResult.value;
55925
55925
  this.subscriptions.forEach((cb) => {
55926
- cb(ok$2(value.data));
55926
+ cb(ok$1(value.data));
55927
55927
  });
55928
55928
  }
55929
- return ok$2(void 0);
55929
+ return ok$1(void 0);
55930
55930
  }
55931
55931
  return err$1(newResult.error);
55932
55932
  });
@@ -55934,7 +55934,7 @@ let NetworkCommand$1 = class NetworkCommand extends BaseCommand {
55934
55934
  async afterRequestHooks(_options) {
55935
55935
  }
55936
55936
  };
55937
- function buildServiceDescriptor$b() {
55937
+ function buildServiceDescriptor$c() {
55938
55938
  return {
55939
55939
  type: "networkCommandBaseClass",
55940
55940
  version: "1.0",
@@ -55977,7 +55977,7 @@ class AuraNetworkCommand extends NetworkCommand$1 {
55977
55977
  this.afterRequestHooks({ statusCode: 200 });
55978
55978
  } catch (e) {
55979
55979
  }
55980
- return ok$2(auraReturnValue);
55980
+ return ok$1(auraReturnValue);
55981
55981
  }).catch((error) => {
55982
55982
  if (!error || !error.getError) {
55983
55983
  return err$1(toError("Failed to get error from response"));
@@ -55996,7 +55996,7 @@ class AuraNetworkCommand extends NetworkCommand$1 {
55996
55996
  (response2) => {
55997
55997
  if (response2.ok) {
55998
55998
  return response2.json().then(
55999
- (json) => ok$2(json),
55999
+ (json) => ok$1(json),
56000
56000
  (reason) => err$1(toError(reason))
56001
56001
  ).finally(() => {
56002
56002
  try {
@@ -56036,7 +56036,7 @@ class AuraNetworkCommand extends NetworkCommand$1 {
56036
56036
  return resolvedPromiseLike$3(err$1(toError("Aura/Fetch network services not found")));
56037
56037
  }
56038
56038
  }
56039
- function buildServiceDescriptor$a() {
56039
+ function buildServiceDescriptor$b() {
56040
56040
  return {
56041
56041
  type: "auraNetworkCommandBaseClass",
56042
56042
  version: "1.0",
@@ -56055,7 +56055,7 @@ function buildServiceDescriptor$a() {
56055
56055
  * For full license text, see the LICENSE.txt file
56056
56056
  */
56057
56057
  const { isArray } = Array;
56058
- let Ok$1 = class Ok {
56058
+ class Ok {
56059
56059
  constructor(value) {
56060
56060
  this.value = value;
56061
56061
  }
@@ -56065,7 +56065,7 @@ let Ok$1 = class Ok {
56065
56065
  isErr() {
56066
56066
  return !this.isOk();
56067
56067
  }
56068
- };
56068
+ }
56069
56069
  class Err {
56070
56070
  constructor(error) {
56071
56071
  this.error = error;
@@ -56077,7 +56077,7 @@ class Err {
56077
56077
  return !this.isOk();
56078
56078
  }
56079
56079
  }
56080
- const ok$1 = (value) => new Ok$1(value);
56080
+ const ok = (value) => new Ok(value);
56081
56081
  const err = (err2) => new Err(err2);
56082
56082
  function resolvedPromiseLike$2(result) {
56083
56083
  if (isPromiseLike$2(result)) {
@@ -56168,6 +56168,38 @@ function setOverlaps(setA, setB) {
56168
56168
  }
56169
56169
  return false;
56170
56170
  }
56171
+ class CacheControlRequestRunner {
56172
+ constructor(readFromCache, requestFromNetwork, writeToCache) {
56173
+ this.readFromCacheInternal = readFromCache;
56174
+ this.requestFromNetworkInternal = requestFromNetwork;
56175
+ this.writeToCacheInternal = writeToCache;
56176
+ }
56177
+ readFromCache(cache) {
56178
+ const resultPromise = this.readFromCacheInternal(cache);
56179
+ return resultPromise.then((result) => {
56180
+ if (result.isErr()) {
56181
+ return err(result.error);
56182
+ }
56183
+ this.returnData = result;
56184
+ return ok(void 0);
56185
+ });
56186
+ }
56187
+ requestFromNetwork() {
56188
+ const that = this;
56189
+ return async function* () {
56190
+ const result = await that.requestFromNetworkInternal();
56191
+ if (result.isErr()) {
56192
+ that.networkError = result;
56193
+ } else {
56194
+ that.networkData = result;
56195
+ }
56196
+ yield result;
56197
+ }();
56198
+ }
56199
+ writeToCache(cache, networkResult) {
56200
+ return this.writeToCacheInternal(cache, networkResult);
56201
+ }
56202
+ }
56171
56203
  class CacheControlCommand extends BaseCommand {
56172
56204
  constructor(services) {
56173
56205
  super();
@@ -56187,57 +56219,48 @@ class CacheControlCommand extends BaseCommand {
56187
56219
  this.cacheControlStrategyConfig,
56188
56220
  overrides
56189
56221
  );
56190
- let returnData;
56191
- let returnError;
56192
- const requestRunner = {
56193
- readFromCache: (cache) => {
56194
- const resultPromise2 = this.buildResultWithSubscribe(cache);
56195
- return resultPromise2.then((result) => {
56196
- if (result.isErr()) {
56197
- return err(result.error);
56198
- }
56199
- returnData = result;
56200
- return ok$1(void 0);
56201
- });
56202
- },
56203
- requestFromNetwork: () => {
56204
- const that = this;
56205
- return async function* () {
56206
- const result = await that.requestFromNetwork();
56207
- if (result.isErr()) {
56208
- returnError = result;
56209
- }
56210
- yield result;
56211
- }();
56212
- },
56213
- writeToCache: (cache, networkResult) => {
56214
- return this.writeToCacheAndRecordKeys(cache, networkResult);
56215
- }
56216
- };
56222
+ const requestRunner = this.buildRequestRunner();
56217
56223
  const resultPromise = this.services.cacheController.execute(mergedCacheControlConfig, requestRunner, {
56218
56224
  instrumentationAttributes: this.instrumentationAttributes
56219
56225
  });
56220
56226
  return resultPromise.then((result) => {
56221
- return this.publishUpdatedKeys().then(() => {
56222
- if (returnError) {
56223
- return returnError;
56224
- }
56225
- if (result.isErr()) {
56226
- return err(result.error);
56227
- }
56228
- if (this.subscriptions.length > 0) {
56229
- this.subscribeToKeysUsed();
56230
- }
56231
- if (returnData === void 0) {
56232
- return err(new Error("Cache miss after fetching from network"));
56227
+ return this.handleCacheControllerResult(result, requestRunner);
56228
+ });
56229
+ }
56230
+ handleCacheControllerResult(result, requestRunner) {
56231
+ const { networkError, networkData, returnData } = requestRunner;
56232
+ return this.publishUpdatedKeys().then(() => {
56233
+ if (networkError) {
56234
+ return networkError;
56235
+ }
56236
+ if (result.isErr()) {
56237
+ if (networkData) {
56238
+ return this.constructSubscribableResult(networkData.value);
56233
56239
  }
56234
- if (returnData.isOk() && this.lastEmittedData === void 0) {
56235
- this.lastEmittedData = returnData.value.data;
56240
+ return err(result.error);
56241
+ }
56242
+ if (this.subscriptions.length > 0) {
56243
+ this.subscribeToKeysUsed();
56244
+ }
56245
+ if (returnData === void 0) {
56246
+ if (networkData) {
56247
+ return this.constructSubscribableResult(networkData.value);
56236
56248
  }
56237
- return returnData;
56238
- });
56249
+ return err(new Error("Cache miss after fetching from network"));
56250
+ }
56251
+ if (returnData.isOk() && this.lastEmittedData === void 0) {
56252
+ this.lastEmittedData = returnData.value.data;
56253
+ }
56254
+ return returnData;
56239
56255
  });
56240
56256
  }
56257
+ buildRequestRunner() {
56258
+ return new CacheControlRequestRunner(
56259
+ (cache) => this.buildResultWithSubscribe(cache),
56260
+ () => this.requestFromNetwork(),
56261
+ (cache, networkResult) => this.writeToCacheAndRecordKeys(cache, networkResult)
56262
+ );
56263
+ }
56241
56264
  publishUpdatedKeys() {
56242
56265
  if (this.services.pubSub) {
56243
56266
  if (this.keysUpdated !== void 0 && this.keysUpdated.size > 0) {
@@ -56288,7 +56311,7 @@ class CacheControlCommand extends BaseCommand {
56288
56311
  if (result.isErr()) {
56289
56312
  return err(result.error);
56290
56313
  }
56291
- return ok$1(void 0);
56314
+ return ok(void 0);
56292
56315
  });
56293
56316
  }
56294
56317
  writeToCacheAndRecordKeys(cache, networkResult) {
@@ -56296,7 +56319,7 @@ class CacheControlCommand extends BaseCommand {
56296
56319
  return this.writeToCache(recordableCache, networkResult).then((result) => {
56297
56320
  this.instantiationTime = Date.now() / 1e3;
56298
56321
  this.keysUpdated = recordableCache.keysUpdated;
56299
- return ok$1(result);
56322
+ return ok(result);
56300
56323
  });
56301
56324
  }
56302
56325
  buildResultWithSubscribe(cache) {
@@ -56308,14 +56331,18 @@ class CacheControlCommand extends BaseCommand {
56308
56331
  } else {
56309
56332
  const data = readResult.value;
56310
56333
  this.keysUsed = recordableCache.keysRead;
56311
- return ok$1({
56312
- data,
56313
- subscribe: this.buildSubscribe(),
56314
- refresh: () => this.refresh()
56315
- });
56334
+ return this.constructSubscribableResult(data);
56316
56335
  }
56317
56336
  });
56318
56337
  }
56338
+ constructSubscribableResult(data) {
56339
+ return ok({
56340
+ data,
56341
+ // this cast is in case we need to return Network data as a fallback for caching errors
56342
+ subscribe: this.buildSubscribe(),
56343
+ refresh: () => this.refresh()
56344
+ });
56345
+ }
56319
56346
  /**
56320
56347
  * Builds a function that subscribes to cache changes via the pubsub service. Whenever
56321
56348
  * relevant cache updates occur, it re-reads the data and compares it against
@@ -56347,7 +56374,7 @@ class CacheControlCommand extends BaseCommand {
56347
56374
  }
56348
56375
  if (!this.equals(this.lastEmittedData, result.value.data)) {
56349
56376
  this.lastEmittedData = result.value.data;
56350
- this.invokeConsumerCallbacks(ok$1(result.value.data));
56377
+ this.invokeConsumerCallbacks(ok(result.value.data));
56351
56378
  }
56352
56379
  return result;
56353
56380
  });
@@ -56435,7 +56462,7 @@ let AuraCacheControlCommand$1 = class AuraCacheControlCommand extends CacheContr
56435
56462
  this.afterRequestHooks({ statusCode: 200 });
56436
56463
  } catch (e) {
56437
56464
  }
56438
- return ok$2(auraReturnValue);
56465
+ return ok$1(auraReturnValue);
56439
56466
  }).catch((error) => {
56440
56467
  if (!error || !error.getError) {
56441
56468
  return err$1(toError("Failed to get error from response"));
@@ -56454,7 +56481,7 @@ let AuraCacheControlCommand$1 = class AuraCacheControlCommand extends CacheContr
56454
56481
  (response2) => {
56455
56482
  if (response2.ok) {
56456
56483
  return response2.json().then(
56457
- (json) => ok$2(json),
56484
+ (json) => ok$1(json),
56458
56485
  (reason) => err$1(toError(reason))
56459
56486
  ).finally(() => {
56460
56487
  try {
@@ -56486,10 +56513,10 @@ class AuraNormalizedCacheControlCommand extends AuraCacheControlCommand$1 {
56486
56513
  const data = this.buildResultType().query(cache, this.buildQuery());
56487
56514
  if (data.isErr()) {
56488
56515
  return resolvedPromiseLike$3(
56489
- err$1(new Error(`Failed to build data from type: ${stringify$1(data.error)}`))
56516
+ err$1(new Error(`Failed to build data from type: ${stringify$2(data.error)}`))
56490
56517
  );
56491
56518
  }
56492
- return resolvedPromiseLike$3(ok$2(data.value));
56519
+ return resolvedPromiseLike$3(ok$1(data.value));
56493
56520
  }
56494
56521
  writeToCache(cache, networkResult) {
56495
56522
  if (networkResult.isOk()) {
@@ -56501,7 +56528,7 @@ class AuraNormalizedCacheControlCommand extends AuraCacheControlCommand$1 {
56501
56528
  return resolvedPromiseLike$3(void 0);
56502
56529
  }
56503
56530
  }
56504
- function buildServiceDescriptor$9() {
56531
+ function buildServiceDescriptor$a() {
56505
56532
  return {
56506
56533
  type: "auraNormalizedCacheControlCommand",
56507
56534
  version: "1.0",
@@ -56566,7 +56593,7 @@ class AuraCacheControlCommand extends CacheControlCommand {
56566
56593
  this.afterRequestHooks({ statusCode: 200 });
56567
56594
  } catch (e) {
56568
56595
  }
56569
- return ok$2(auraReturnValue);
56596
+ return ok$1(auraReturnValue);
56570
56597
  }).catch((error) => {
56571
56598
  if (!error || !error.getError) {
56572
56599
  return err$1(toError("Failed to get error from response"));
@@ -56585,7 +56612,7 @@ class AuraCacheControlCommand extends CacheControlCommand {
56585
56612
  (response2) => {
56586
56613
  if (response2.ok) {
56587
56614
  return response2.json().then(
56588
- (json) => ok$2(json),
56615
+ (json) => ok$1(json),
56589
56616
  (reason) => err$1(toError(reason))
56590
56617
  ).finally(() => {
56591
56618
  try {
@@ -56622,7 +56649,7 @@ class AuraResourceCacheControlCommand extends AuraCacheControlCommand {
56622
56649
  if (data === void 0) {
56623
56650
  return resolvedPromiseLike$3(err$1(new Error("Failed to find data in cache")));
56624
56651
  }
56625
- return resolvedPromiseLike$3(ok$2(data));
56652
+ return resolvedPromiseLike$3(ok$1(data));
56626
56653
  }
56627
56654
  writeToCache(cache, networkResult) {
56628
56655
  if (networkResult.isOk()) {
@@ -56639,7 +56666,7 @@ class AuraResourceCacheControlCommand extends AuraCacheControlCommand {
56639
56666
  return `{"endpoint":${this.endpoint},"params":${stableJSONStringify(this.auraParams)}}`;
56640
56667
  }
56641
56668
  }
56642
- function buildServiceDescriptor$8() {
56669
+ function buildServiceDescriptor$9() {
56643
56670
  return {
56644
56671
  type: "auraResourceCacheControlCommand",
56645
56672
  version: "1.0",
@@ -56677,7 +56704,7 @@ class NetworkCommand extends BaseCommand {
56677
56704
  return err$1(networkResult.error);
56678
56705
  } else {
56679
56706
  const data = networkResult.value;
56680
- return ok$2({
56707
+ return ok$1({
56681
56708
  data,
56682
56709
  subscribe: (cb) => {
56683
56710
  this.subscriptions.push(cb);
@@ -56696,10 +56723,10 @@ class NetworkCommand extends BaseCommand {
56696
56723
  if (isSubscribableResult(newResult)) {
56697
56724
  const value = newResult.value;
56698
56725
  this.subscriptions.forEach((cb) => {
56699
- cb(ok$2(value.data));
56726
+ cb(ok$1(value.data));
56700
56727
  });
56701
56728
  }
56702
- return ok$2(void 0);
56729
+ return ok$1(void 0);
56703
56730
  }
56704
56731
  return err$1(newResult.error);
56705
56732
  });
@@ -56723,7 +56750,7 @@ class FetchNetworkCommand extends NetworkCommand {
56723
56750
  (response2) => {
56724
56751
  if (response2.ok) {
56725
56752
  return response2.json().then(
56726
- (json) => ok$2(json),
56753
+ (json) => ok$1(json),
56727
56754
  (reason) => err$1(toError(reason))
56728
56755
  ).finally(() => {
56729
56756
  try {
@@ -56746,7 +56773,7 @@ class FetchNetworkCommand extends NetworkCommand {
56746
56773
  );
56747
56774
  }
56748
56775
  }
56749
- function buildServiceDescriptor$7() {
56776
+ function buildServiceDescriptor$8() {
56750
56777
  return {
56751
56778
  type: "fetchNetworkCommandBaseClass",
56752
56779
  version: "1.0",
@@ -56783,7 +56810,7 @@ class HttpCacheControlCommand extends CacheControlCommand {
56783
56810
  (response2) => {
56784
56811
  if (response2.ok) {
56785
56812
  return response2.json().then(
56786
- (json) => ok$2(json),
56813
+ (json) => ok$1(json),
56787
56814
  (reason) => err$1(toError(reason))
56788
56815
  ).finally(() => {
56789
56816
  try {
@@ -56815,10 +56842,10 @@ class HttpNormalizedCacheControlCommand extends HttpCacheControlCommand {
56815
56842
  const data = this.buildResultType().query(cache, this.buildQuery());
56816
56843
  if (data.isErr()) {
56817
56844
  return resolvedPromiseLike$3(
56818
- err$1(new Error(`Failed to build data from type: ${stringify$1(data.error)}`))
56845
+ err$1(new Error(`Failed to build data from type: ${stringify$2(data.error)}`))
56819
56846
  );
56820
56847
  }
56821
- return resolvedPromiseLike$3(ok$2(data.value));
56848
+ return resolvedPromiseLike$3(ok$1(data.value));
56822
56849
  }
56823
56850
  writeToCache(cache, networkResult) {
56824
56851
  if (networkResult.isOk()) {
@@ -56830,7 +56857,7 @@ class HttpNormalizedCacheControlCommand extends HttpCacheControlCommand {
56830
56857
  return resolvedPromiseLike$3(void 0);
56831
56858
  }
56832
56859
  }
56833
- function buildServiceDescriptor$6() {
56860
+ function buildServiceDescriptor$7() {
56834
56861
  return {
56835
56862
  type: "httpNormalizedCacheControlCommand",
56836
56863
  version: "1.0",
@@ -56848,12 +56875,12 @@ function buildServiceDescriptor$6() {
56848
56875
  * All rights reserved.
56849
56876
  * For full license text, see the LICENSE.txt file
56850
56877
  */
56851
- const { stringify, parse } = JSON;
56852
- function deepCopy(x) {
56853
- const stringified = stringify(x);
56854
- return stringified ? parse(stringified) : void 0;
56878
+ const { stringify: stringify$1, parse: parse$1 } = JSON;
56879
+ function deepCopy$1(x) {
56880
+ const stringified = stringify$1(x);
56881
+ return stringified ? parse$1(stringified) : void 0;
56855
56882
  }
56856
- class DefaultRecordableCache {
56883
+ let DefaultRecordableCache$1 = class DefaultRecordableCache {
56857
56884
  constructor(baseCache) {
56858
56885
  this.baseCache = baseCache;
56859
56886
  this.keysRead = /* @__PURE__ */ new Set();
@@ -56872,7 +56899,7 @@ class DefaultRecordableCache {
56872
56899
  this.missingKeysRead.add(key);
56873
56900
  }
56874
56901
  if (options == null ? void 0 : options.copy) {
56875
- return deepCopy(value);
56902
+ return deepCopy$1(value);
56876
56903
  }
56877
56904
  return value;
56878
56905
  }
@@ -56898,13 +56925,13 @@ class DefaultRecordableCache {
56898
56925
  return new DefaultRecordableCache(this);
56899
56926
  }
56900
56927
  filter(predicate) {
56901
- return new DefaultFilteredCache(this, predicate);
56928
+ return new DefaultFilteredCache$1(this, predicate);
56902
56929
  }
56903
56930
  buildFixedTimeWritableCache(generatedTime) {
56904
- return new FixedTimeWritableCache(this, generatedTime);
56931
+ return new FixedTimeWritableCache$1(this, generatedTime);
56905
56932
  }
56906
- }
56907
- class DefaultFilteredCache {
56933
+ };
56934
+ let DefaultFilteredCache$1 = class DefaultFilteredCache {
56908
56935
  constructor(baseCache, predicate) {
56909
56936
  this.baseCache = baseCache;
56910
56937
  this.predicate = predicate;
@@ -56916,7 +56943,7 @@ class DefaultFilteredCache {
56916
56943
  const result = this.baseCache.get(key);
56917
56944
  if (result && this.predicate(key, result)) {
56918
56945
  if (options == null ? void 0 : options.copy) {
56919
- return deepCopy(result);
56946
+ return deepCopy$1(result);
56920
56947
  }
56921
56948
  return result;
56922
56949
  }
@@ -56938,7 +56965,7 @@ class DefaultFilteredCache {
56938
56965
  return this.getFilteredEntries();
56939
56966
  }
56940
56967
  record() {
56941
- return new DefaultRecordableCache(this);
56968
+ return new DefaultRecordableCache$1(this);
56942
56969
  }
56943
56970
  filter(predicate) {
56944
56971
  return new DefaultFilteredCache(this, predicate);
@@ -56958,10 +56985,10 @@ class DefaultFilteredCache {
56958
56985
  return filteredKeySet;
56959
56986
  }
56960
56987
  buildFixedTimeWritableCache(generatedTime) {
56961
- return new FixedTimeWritableCache(this, generatedTime);
56988
+ return new FixedTimeWritableCache$1(this, generatedTime);
56962
56989
  }
56963
- }
56964
- class FixedTimeWritableCache {
56990
+ };
56991
+ let FixedTimeWritableCache$1 = class FixedTimeWritableCache {
56965
56992
  constructor(baseCache, generatedTime) {
56966
56993
  this.baseCache = baseCache;
56967
56994
  this.generatedTime = generatedTime;
@@ -56997,22 +57024,22 @@ class FixedTimeWritableCache {
56997
57024
  return this.baseCache.entries();
56998
57025
  }
56999
57026
  record() {
57000
- return new DefaultRecordableCache(this);
57027
+ return new DefaultRecordableCache$1(this);
57001
57028
  }
57002
57029
  filter(predicate) {
57003
- return new DefaultFilteredCache(this, predicate);
57030
+ return new DefaultFilteredCache$1(this, predicate);
57004
57031
  }
57005
57032
  buildFixedTimeWritableCache(generatedTime) {
57006
57033
  return new FixedTimeWritableCache(this, generatedTime);
57007
57034
  }
57008
- }
57009
- class DefaultCache {
57035
+ };
57036
+ let DefaultCache$1 = class DefaultCache {
57010
57037
  constructor() {
57011
57038
  this.data = {};
57012
57039
  }
57013
57040
  get(key, options) {
57014
57041
  if (options == null ? void 0 : options.copy) {
57015
- return deepCopy(this.data[key]);
57042
+ return deepCopy$1(this.data[key]);
57016
57043
  }
57017
57044
  return this.data[key];
57018
57045
  }
@@ -57074,20 +57101,20 @@ class DefaultCache {
57074
57101
  return Object.entries(this.data);
57075
57102
  }
57076
57103
  record() {
57077
- return new DefaultRecordableCache(this);
57104
+ return new DefaultRecordableCache$1(this);
57078
57105
  }
57079
57106
  filter(predicate) {
57080
- return new DefaultFilteredCache(this, predicate);
57107
+ return new DefaultFilteredCache$1(this, predicate);
57081
57108
  }
57082
57109
  buildFixedTimeWritableCache(generatedTime) {
57083
- return new FixedTimeWritableCache(this, generatedTime);
57110
+ return new FixedTimeWritableCache$1(this, generatedTime);
57084
57111
  }
57085
- }
57086
- function buildServiceDescriptor$5() {
57112
+ };
57113
+ function buildServiceDescriptor$6() {
57087
57114
  return {
57088
57115
  type: "cache",
57089
57116
  version: "1.0",
57090
- service: new DefaultCache()
57117
+ service: new DefaultCache$1()
57091
57118
  };
57092
57119
  }
57093
57120
 
@@ -57120,7 +57147,7 @@ class NoCacheCacheControlStrategy extends CacheControlStrategy {
57120
57147
  const tempCache = this.filteredCache;
57121
57148
  return new Promise(async (resolve, reject) => {
57122
57149
  try {
57123
- let readResult = ok$2(void 0);
57150
+ let readResult = ok$1(void 0);
57124
57151
  for await (const rfnResult of this.requestRunner.requestFromNetwork()) {
57125
57152
  if (rfnResult) {
57126
57153
  const result = await this.services.cacheInclusionPolicy.write({
@@ -57158,13 +57185,13 @@ class MaxAgeCacheControlStrategy extends CacheControlStrategy {
57158
57185
  startTime,
57159
57186
  options == null ? void 0 : options.instrumentationAttributes
57160
57187
  );
57161
- return ok$2(void 0);
57188
+ return ok$1(void 0);
57162
57189
  }
57163
57190
  this.collectCacheMissInstrumentation(startTime, options == null ? void 0 : options.instrumentationAttributes);
57164
57191
  const tempCache = this.filteredCache;
57165
57192
  return new Promise(async (resolve, reject) => {
57166
57193
  try {
57167
- let readResult = ok$2(void 0);
57194
+ let readResult = ok$1(void 0);
57168
57195
  for await (const rfnResult of this.requestRunner.requestFromNetwork()) {
57169
57196
  if (rfnResult) {
57170
57197
  const result = await this.services.cacheInclusionPolicy.write({
@@ -57180,7 +57207,7 @@ class MaxAgeCacheControlStrategy extends CacheControlStrategy {
57180
57207
  readFromL1: (l1) => this.requestRunner.readFromCache(l1)
57181
57208
  });
57182
57209
  if (readResult.isOk()) {
57183
- resolve(ok$2(void 0));
57210
+ resolve(ok$1(void 0));
57184
57211
  }
57185
57212
  }
57186
57213
  return resolve(readResult);
@@ -57251,7 +57278,7 @@ class CacheController {
57251
57278
  yield* this.services.cacheInclusionPolicy.findAndModify(query, cacheUpdate);
57252
57279
  }
57253
57280
  }
57254
- function buildServiceDescriptor$4(cache, cacheInclusionPolicy) {
57281
+ function buildServiceDescriptor$5(cache, cacheInclusionPolicy) {
57255
57282
  return {
57256
57283
  type: "cacheController",
57257
57284
  version: "1.0",
@@ -57259,193 +57286,6 @@ function buildServiceDescriptor$4(cache, cacheInclusionPolicy) {
57259
57286
  };
57260
57287
  }
57261
57288
 
57262
- /*!
57263
- * Copyright (c) 2022, Salesforce, Inc.,
57264
- * All rights reserved.
57265
- * For full license text, see the LICENSE.txt file
57266
- */
57267
- class CacheInclusionPolicyService {
57268
- }
57269
- /*!
57270
- * Copyright (c) 2022, Salesforce, Inc.,
57271
- * All rights reserved.
57272
- * For full license text, see the LICENSE.txt file
57273
- */
57274
- class Ok {
57275
- constructor(value) {
57276
- this.value = value;
57277
- }
57278
- isOk() {
57279
- return true;
57280
- }
57281
- isErr() {
57282
- return !this.isOk();
57283
- }
57284
- }
57285
- const ok = (value) => new Ok(value);
57286
- function resolvedPromiseLike$1(result) {
57287
- if (isPromiseLike$1(result)) {
57288
- return result.then((nextResult) => nextResult);
57289
- }
57290
- return {
57291
- then: (onFulfilled, _onRejected) => {
57292
- try {
57293
- return resolvedPromiseLike$1(onFulfilled(result));
57294
- } catch (e) {
57295
- if (onFulfilled === void 0) {
57296
- return resolvedPromiseLike$1(result);
57297
- }
57298
- return rejectedPromiseLike$1(e);
57299
- }
57300
- }
57301
- };
57302
- }
57303
- function rejectedPromiseLike$1(reason) {
57304
- if (isPromiseLike$1(reason)) {
57305
- return reason.then((nextResult) => nextResult);
57306
- }
57307
- return {
57308
- then: (_onFulfilled, onRejected) => {
57309
- if (typeof onRejected === "function") {
57310
- try {
57311
- return resolvedPromiseLike$1(onRejected(reason));
57312
- } catch (e) {
57313
- return rejectedPromiseLike$1(e);
57314
- }
57315
- }
57316
- return rejectedPromiseLike$1(reason);
57317
- }
57318
- };
57319
- }
57320
- function isPromiseLike$1(x) {
57321
- return typeof (x == null ? void 0 : x.then) === "function";
57322
- }
57323
- const isAndQuery = (query) => "$and" in query;
57324
- const isOrQuery = (query) => "$or" in query;
57325
- const isNotQuery = (query) => "$not" in query;
57326
- const matchesMetadata = (metadataQuery, cacheControl) => {
57327
- if ("cacheControlType" in metadataQuery && cacheControl.type !== metadataQuery.cacheControlType.$eq) {
57328
- return false;
57329
- }
57330
- if ("maxAge" in metadataQuery && cacheControl.type === "max-age") {
57331
- const maxAge = cacheControl.maxAge ?? 0;
57332
- if (metadataQuery.maxAge.$gte !== void 0 && maxAge < metadataQuery.maxAge.$gte || metadataQuery.maxAge.$lte !== void 0 && maxAge > metadataQuery.maxAge.$lte) {
57333
- return false;
57334
- }
57335
- }
57336
- return true;
57337
- };
57338
- function queryToPredicate(query) {
57339
- return (key, entry) => {
57340
- if (!query) return false;
57341
- if (isAndQuery(query))
57342
- return query.$and.every((subQuery) => queryToPredicate(subQuery)(key, entry));
57343
- if (isOrQuery(query))
57344
- return query.$or.some((subQuery) => queryToPredicate(subQuery)(key, entry));
57345
- if (isNotQuery(query)) return !queryToPredicate(query.$not)(key, entry);
57346
- if ("key" in query) return matchesKey(query.key, key);
57347
- if ("metadata" in query)
57348
- return matchesMetadata(query.metadata, entry.metadata.cacheControl);
57349
- if ("value" in query) return false;
57350
- throw new Error("Unknown Query Operation");
57351
- };
57352
- }
57353
- function matchesKey(keyQuery, key) {
57354
- if ("$regex" in keyQuery) {
57355
- return keyQuery.$regex.test(key);
57356
- }
57357
- return false;
57358
- }
57359
- function buildUpdate(update, existing) {
57360
- switch (update.type) {
57361
- case "invalidate":
57362
- const updatedCacheControl = buildInvalidatedCacheControl(
57363
- existing.metadata.cacheControl
57364
- );
57365
- return updatedCacheControl !== void 0 ? { type: "metadata", metadata: updatedCacheControl } : { type: "no-op" };
57366
- default:
57367
- throw new Error(`Invalid update operation: ${update.type}`);
57368
- }
57369
- }
57370
- function buildInvalidatedCacheControl(existingCacheControl) {
57371
- switch (existingCacheControl.type) {
57372
- case "max-age":
57373
- case "stale-while-revalidate":
57374
- if (existingCacheControl.maxAge !== 0) {
57375
- return {
57376
- ...existingCacheControl,
57377
- maxAge: 0
57378
- };
57379
- }
57380
- }
57381
- return void 0;
57382
- }
57383
- class InMemoryCacheInclusionPolicy extends CacheInclusionPolicyService {
57384
- constructor(services) {
57385
- super();
57386
- this.services = services;
57387
- }
57388
- /**
57389
- * Reads data out of a single level in memory store.
57390
- */
57391
- read(options) {
57392
- const { l1, readFromL1 } = options;
57393
- return readFromL1(l1);
57394
- }
57395
- /**
57396
- * Writes data to a single level in memory store.
57397
- */
57398
- write(options) {
57399
- const { l1, writeToL1 } = options;
57400
- return writeToL1(l1);
57401
- }
57402
- /**
57403
- * Finds cache entries that match the given query.
57404
- * Returns an async generator that yields `[key, entry]`.
57405
- */
57406
- async *find(query) {
57407
- const cache = this.services.cache;
57408
- const predicate = queryToPredicate(query);
57409
- const filteredEntries = cache.filter(predicate).entries();
57410
- for (const entry of filteredEntries) {
57411
- yield entry;
57412
- }
57413
- }
57414
- /**
57415
- * Finds and modifies cache entries that match the given query.
57416
- * Extends `find(query)` and returns an async generator of modified keys.
57417
- */
57418
- async *findAndModify(query, cacheUpdate) {
57419
- const cache = this.services.cache;
57420
- for await (const [key, value] of this.find(query)) {
57421
- const update = buildUpdate(cacheUpdate, value);
57422
- switch (update.type) {
57423
- case "entry":
57424
- this.write({
57425
- l1: cache,
57426
- writeToL1: (l1) => resolvedPromiseLike$1(ok(l1.set(key, update.entry)))
57427
- });
57428
- yield key;
57429
- break;
57430
- case "metadata":
57431
- this.write({
57432
- l1: cache,
57433
- writeToL1: (l1) => resolvedPromiseLike$1(ok(l1.setMetadata(key, update.metadata)))
57434
- });
57435
- yield key;
57436
- break;
57437
- }
57438
- }
57439
- }
57440
- }
57441
- function buildInMemoryCacheInclusionPolicyService(cache) {
57442
- return {
57443
- service: new InMemoryCacheInclusionPolicy({ cache }),
57444
- type: "cacheInclusionPolicy",
57445
- version: "1.0"
57446
- };
57447
- }
57448
-
57449
57289
  /*!
57450
57290
  * Copyright (c) 2022, Salesforce, Inc.,
57451
57291
  * All rights reserved.
@@ -57484,7 +57324,7 @@ function buildInstrumentCommand(services) {
57484
57324
  };
57485
57325
  };
57486
57326
  }
57487
- function buildServiceDescriptor$3(instrumentation) {
57327
+ function buildServiceDescriptor$4(instrumentation) {
57488
57328
  return {
57489
57329
  type: "instrumentCommand",
57490
57330
  version: "1.0",
@@ -57754,7 +57594,7 @@ class O11yInstrumentation {
57754
57594
  this.metrics = new O11yOTelMetricsAPI(this.services);
57755
57595
  }
57756
57596
  }
57757
- function buildServiceDescriptor$2(logger) {
57597
+ function buildServiceDescriptor$3(logger) {
57758
57598
  return {
57759
57599
  type: "instrumentation",
57760
57600
  version: "1.0",
@@ -57772,41 +57612,41 @@ function buildServiceDescriptor$2(logger) {
57772
57612
  * All rights reserved.
57773
57613
  * For full license text, see the LICENSE.txt file
57774
57614
  */
57775
- function resolvedPromiseLike(result) {
57776
- if (isPromiseLike(result)) {
57615
+ function resolvedPromiseLike$1(result) {
57616
+ if (isPromiseLike$1(result)) {
57777
57617
  return result.then((nextResult) => nextResult);
57778
57618
  }
57779
57619
  return {
57780
57620
  then: (onFulfilled, _onRejected) => {
57781
57621
  try {
57782
- return resolvedPromiseLike(onFulfilled(result));
57622
+ return resolvedPromiseLike$1(onFulfilled(result));
57783
57623
  } catch (e) {
57784
57624
  if (onFulfilled === void 0) {
57785
- return resolvedPromiseLike(result);
57625
+ return resolvedPromiseLike$1(result);
57786
57626
  }
57787
- return rejectedPromiseLike(e);
57627
+ return rejectedPromiseLike$1(e);
57788
57628
  }
57789
57629
  }
57790
57630
  };
57791
57631
  }
57792
- function rejectedPromiseLike(reason) {
57793
- if (isPromiseLike(reason)) {
57632
+ function rejectedPromiseLike$1(reason) {
57633
+ if (isPromiseLike$1(reason)) {
57794
57634
  return reason.then((nextResult) => nextResult);
57795
57635
  }
57796
57636
  return {
57797
57637
  then: (_onFulfilled, onRejected) => {
57798
57638
  if (typeof onRejected === "function") {
57799
57639
  try {
57800
- return resolvedPromiseLike(onRejected(reason));
57640
+ return resolvedPromiseLike$1(onRejected(reason));
57801
57641
  } catch (e) {
57802
- return rejectedPromiseLike(e);
57642
+ return rejectedPromiseLike$1(e);
57803
57643
  }
57804
57644
  }
57805
- return rejectedPromiseLike(reason);
57645
+ return rejectedPromiseLike$1(reason);
57806
57646
  }
57807
57647
  };
57808
57648
  }
57809
- function isPromiseLike(x) {
57649
+ function isPromiseLike$1(x) {
57810
57650
  return typeof (x == null ? void 0 : x.then) === "function";
57811
57651
  }
57812
57652
  const EventTypeWildcard = Symbol("EventTypeWildcard");
@@ -57836,14 +57676,14 @@ class DefaultPubSubService {
57836
57676
  return;
57837
57677
  }
57838
57678
  const returnVal = subscription.callback.call(subscription, event);
57839
- if (isPromiseLike(returnVal)) {
57679
+ if (isPromiseLike$1(returnVal)) {
57840
57680
  promises.push(returnVal);
57841
57681
  }
57842
57682
  });
57843
57683
  if (promises.length > 0) {
57844
57684
  return Promise.all(promises).then(() => void 0);
57845
57685
  }
57846
- return resolvedPromiseLike(void 0);
57686
+ return resolvedPromiseLike$1(void 0);
57847
57687
  }
57848
57688
  getSubscriptions(event) {
57849
57689
  const eventTypeSubscriptions = this.subscriptions.get(event.type);
@@ -57864,7 +57704,7 @@ class DefaultPubSubService {
57864
57704
  return matchingSubscriptions;
57865
57705
  }
57866
57706
  }
57867
- function buildServiceDescriptor$1() {
57707
+ function buildServiceDescriptor$2() {
57868
57708
  return {
57869
57709
  type: "pubSub",
57870
57710
  version: "1.0",
@@ -57877,7 +57717,7 @@ function buildServiceDescriptor$1() {
57877
57717
  * All rights reserved.
57878
57718
  * For full license text, see the LICENSE.txt file
57879
57719
  */
57880
- function buildServiceDescriptor(interceptors = { request: [], response: [] }) {
57720
+ function buildServiceDescriptor$1(interceptors = { request: [], response: [] }) {
57881
57721
  return {
57882
57722
  type: "fetch",
57883
57723
  version: "1.0",
@@ -57911,7 +57751,7 @@ function buildNimbusFetchServiceDescriptor() {
57911
57751
  });
57912
57752
  };
57913
57753
  return {
57914
- ...buildServiceDescriptor(),
57754
+ ...buildServiceDescriptor$1(),
57915
57755
  service: service,
57916
57756
  };
57917
57757
  }
@@ -57960,31 +57800,550 @@ function convertFetchParamsToResourceRequest([input, init]) {
57960
57800
  };
57961
57801
  }
57962
57802
 
57803
+ /*!
57804
+ * Copyright (c) 2022, Salesforce, Inc.,
57805
+ * All rights reserved.
57806
+ * For full license text, see the LICENSE.txt file
57807
+ */
57808
+ class CacheInclusionPolicyService {
57809
+ }
57810
+ function setDifference(setA, setB) {
57811
+ const differenceSet = /* @__PURE__ */ new Set();
57812
+ for (const element of setA) {
57813
+ if (!setB.has(element)) {
57814
+ differenceSet.add(element);
57815
+ }
57816
+ }
57817
+ return differenceSet;
57818
+ }
57819
+ function resolvedPromiseLike(result) {
57820
+ if (isPromiseLike(result)) {
57821
+ return result.then((nextResult) => nextResult);
57822
+ }
57823
+ return {
57824
+ then: (onFulfilled, _onRejected) => {
57825
+ try {
57826
+ return resolvedPromiseLike(onFulfilled(result));
57827
+ } catch (e) {
57828
+ if (onFulfilled === void 0) {
57829
+ return resolvedPromiseLike(result);
57830
+ }
57831
+ return rejectedPromiseLike(e);
57832
+ }
57833
+ }
57834
+ };
57835
+ }
57836
+ function rejectedPromiseLike(reason) {
57837
+ if (isPromiseLike(reason)) {
57838
+ return reason.then((nextResult) => nextResult);
57839
+ }
57840
+ return {
57841
+ then: (_onFulfilled, onRejected) => {
57842
+ if (typeof onRejected === "function") {
57843
+ try {
57844
+ return resolvedPromiseLike(onRejected(reason));
57845
+ } catch (e) {
57846
+ return rejectedPromiseLike(e);
57847
+ }
57848
+ }
57849
+ return rejectedPromiseLike(reason);
57850
+ }
57851
+ };
57852
+ }
57853
+ function isPromiseLike(x) {
57854
+ return typeof (x == null ? void 0 : x.then) === "function";
57855
+ }
57856
+ /*!
57857
+ * Copyright (c) 2022, Salesforce, Inc.,
57858
+ * All rights reserved.
57859
+ * For full license text, see the LICENSE.txt file
57860
+ */
57861
+ /*!
57862
+ * Copyright (c) 2022, Salesforce, Inc.,
57863
+ * All rights reserved.
57864
+ * For full license text, see the LICENSE.txt file
57865
+ */
57866
+ const { stringify, parse } = JSON;
57867
+ function deepCopy(x) {
57868
+ const stringified = stringify(x);
57869
+ return stringified ? parse(stringified) : void 0;
57870
+ }
57871
+ class DefaultRecordableCache {
57872
+ constructor(baseCache) {
57873
+ this.baseCache = baseCache;
57874
+ this.keysRead = /* @__PURE__ */ new Set();
57875
+ this.missingKeysRead = /* @__PURE__ */ new Set();
57876
+ this.keysUpdated = /* @__PURE__ */ new Set();
57877
+ this.metadataKeysUpdated = /* @__PURE__ */ new Set();
57878
+ }
57879
+ delete(key) {
57880
+ this.keysUpdated.add(key);
57881
+ this.baseCache.delete(key);
57882
+ }
57883
+ get(key, options) {
57884
+ this.keysRead.add(key);
57885
+ const value = this.baseCache.get(key);
57886
+ if (value === void 0) {
57887
+ this.missingKeysRead.add(key);
57888
+ }
57889
+ if (options == null ? void 0 : options.copy) {
57890
+ return deepCopy(value);
57891
+ }
57892
+ return value;
57893
+ }
57894
+ set(key, value) {
57895
+ this.keysUpdated.add(key);
57896
+ this.metadataKeysUpdated.add(key);
57897
+ this.baseCache.set(key, value);
57898
+ }
57899
+ setMetadata(key, cacheControlMetadata) {
57900
+ this.metadataKeysUpdated.add(key);
57901
+ this.baseCache.setMetadata(key, cacheControlMetadata);
57902
+ }
57903
+ length() {
57904
+ return this.baseCache.length();
57905
+ }
57906
+ keys() {
57907
+ return this.baseCache.keys();
57908
+ }
57909
+ entries() {
57910
+ return this.baseCache.entries();
57911
+ }
57912
+ record() {
57913
+ return new DefaultRecordableCache(this);
57914
+ }
57915
+ filter(predicate) {
57916
+ return new DefaultFilteredCache(this, predicate);
57917
+ }
57918
+ buildFixedTimeWritableCache(generatedTime) {
57919
+ return new FixedTimeWritableCache(this, generatedTime);
57920
+ }
57921
+ }
57922
+ class DefaultFilteredCache {
57923
+ constructor(baseCache, predicate) {
57924
+ this.baseCache = baseCache;
57925
+ this.predicate = predicate;
57926
+ }
57927
+ delete(key) {
57928
+ this.baseCache.delete(key);
57929
+ }
57930
+ get(key, options) {
57931
+ const result = this.baseCache.get(key);
57932
+ if (result && this.predicate(key, result)) {
57933
+ if (options == null ? void 0 : options.copy) {
57934
+ return deepCopy(result);
57935
+ }
57936
+ return result;
57937
+ }
57938
+ return void 0;
57939
+ }
57940
+ set(key, value) {
57941
+ this.baseCache.set(key, value);
57942
+ }
57943
+ setMetadata(key, cacheControlMetadata) {
57944
+ this.baseCache.setMetadata(key, cacheControlMetadata);
57945
+ }
57946
+ length() {
57947
+ return this.getFilteredKeys().size;
57948
+ }
57949
+ keys() {
57950
+ return this.getFilteredKeys();
57951
+ }
57952
+ entries() {
57953
+ return this.getFilteredEntries();
57954
+ }
57955
+ record() {
57956
+ return new DefaultRecordableCache(this);
57957
+ }
57958
+ filter(predicate) {
57959
+ return new DefaultFilteredCache(this, predicate);
57960
+ }
57961
+ getFilteredEntries() {
57962
+ return this.baseCache.entries().filter(([key, _value]) => {
57963
+ return this.get(key);
57964
+ });
57965
+ }
57966
+ getFilteredKeys() {
57967
+ const filteredKeySet = /* @__PURE__ */ new Set();
57968
+ this.baseCache.keys().forEach((key) => {
57969
+ if (this.get(key)) {
57970
+ filteredKeySet.add(key);
57971
+ }
57972
+ });
57973
+ return filteredKeySet;
57974
+ }
57975
+ buildFixedTimeWritableCache(generatedTime) {
57976
+ return new FixedTimeWritableCache(this, generatedTime);
57977
+ }
57978
+ }
57979
+ class FixedTimeWritableCache {
57980
+ constructor(baseCache, generatedTime) {
57981
+ this.baseCache = baseCache;
57982
+ this.generatedTime = generatedTime;
57983
+ }
57984
+ delete(key) {
57985
+ this.baseCache.delete(key);
57986
+ }
57987
+ get(key, options) {
57988
+ return this.baseCache.get(key, options);
57989
+ }
57990
+ set(key, value) {
57991
+ this.baseCache.set(key, {
57992
+ ...value,
57993
+ metadata: {
57994
+ ...value.metadata,
57995
+ cacheControl: { ...value.metadata.cacheControl, generatedTime: this.generatedTime }
57996
+ }
57997
+ });
57998
+ }
57999
+ setMetadata(key, cacheControlMetadata) {
58000
+ this.baseCache.setMetadata(key, {
58001
+ ...cacheControlMetadata,
58002
+ generatedTime: this.generatedTime
58003
+ });
58004
+ }
58005
+ length() {
58006
+ return this.baseCache.length();
58007
+ }
58008
+ keys() {
58009
+ return this.baseCache.keys();
58010
+ }
58011
+ entries() {
58012
+ return this.baseCache.entries();
58013
+ }
58014
+ record() {
58015
+ return new DefaultRecordableCache(this);
58016
+ }
58017
+ filter(predicate) {
58018
+ return new DefaultFilteredCache(this, predicate);
58019
+ }
58020
+ buildFixedTimeWritableCache(generatedTime) {
58021
+ return new FixedTimeWritableCache(this, generatedTime);
58022
+ }
58023
+ }
58024
+ class DefaultCache {
58025
+ constructor() {
58026
+ this.data = {};
58027
+ }
58028
+ get(key, options) {
58029
+ if (options == null ? void 0 : options.copy) {
58030
+ return deepCopy(this.data[key]);
58031
+ }
58032
+ return this.data[key];
58033
+ }
58034
+ /**
58035
+ * Adds the specified key/value to the cache.
58036
+ *
58037
+ * @param key key at which to store value
58038
+ * @param entry value to be stored
58039
+ */
58040
+ set(key, entry) {
58041
+ if (entry.metadata.cacheControl.type === "no-store") {
58042
+ return;
58043
+ }
58044
+ this.data[key] = {
58045
+ ...entry,
58046
+ metadata: {
58047
+ ...entry.metadata,
58048
+ type: entry.metadata.type || {
58049
+ namespace: "OneStore:Internal",
58050
+ name: "UnknownType"
58051
+ },
58052
+ cacheControl: {
58053
+ generatedTime: Date.now() / 1e3,
58054
+ ...entry.metadata.cacheControl
58055
+ }
58056
+ }
58057
+ };
58058
+ }
58059
+ /**
58060
+ * Removes the cache entry associated with the specified key.
58061
+ *
58062
+ * @param key key to be removed from the store
58063
+ */
58064
+ delete(key) {
58065
+ delete this.data[key];
58066
+ }
58067
+ /**
58068
+ * Sets the metadata for the specified key if the key is in cache.
58069
+ * If the key doesn't exist, it does nothing.
58070
+ *
58071
+ * @param key key at which to store metadata
58072
+ * @param cacheControlMetadata metadata to be stored
58073
+ */
58074
+ setMetadata(key, cacheControlMetadata) {
58075
+ if (key in this.data) {
58076
+ this.data[key].metadata.cacheControl = {
58077
+ generatedTime: Date.now() / 1e3,
58078
+ ...cacheControlMetadata
58079
+ };
58080
+ }
58081
+ }
58082
+ length() {
58083
+ return this.keys().size;
58084
+ }
58085
+ keys() {
58086
+ return new Set(Object.keys(this.data));
58087
+ }
58088
+ entries() {
58089
+ return Object.entries(this.data);
58090
+ }
58091
+ record() {
58092
+ return new DefaultRecordableCache(this);
58093
+ }
58094
+ filter(predicate) {
58095
+ return new DefaultFilteredCache(this, predicate);
58096
+ }
58097
+ buildFixedTimeWritableCache(generatedTime) {
58098
+ return new FixedTimeWritableCache(this, generatedTime);
58099
+ }
58100
+ }
58101
+ function buildServiceDescriptor() {
58102
+ return {
58103
+ type: "cache",
58104
+ version: "1.0",
58105
+ service: new DefaultCache()
58106
+ };
58107
+ }
58108
+ class DurableCacheInclusionPolicy extends CacheInclusionPolicyService {
58109
+ /**
58110
+ * Reads data out of a 2 level inclusive store.
58111
+ */
58112
+ read(options) {
58113
+ const { l1, readFromL1, alreadyRevivedKeys } = options;
58114
+ const recordableCache = l1.record();
58115
+ return readFromL1(recordableCache).then((readResult) => {
58116
+ if (readResult.isOk()) {
58117
+ return readResult;
58118
+ }
58119
+ const keysToRevive = recordableCache.keysRead;
58120
+ if (alreadyRevivedKeys && setDifference(keysToRevive, alreadyRevivedKeys).size === 0) {
58121
+ return readResult;
58122
+ }
58123
+ return this.revive(keysToRevive, l1).then((revivedKeys) => {
58124
+ if (setDifference(keysToRevive, revivedKeys).size > 0) {
58125
+ return readResult;
58126
+ }
58127
+ return this.read({ l1, readFromL1, alreadyRevivedKeys: revivedKeys });
58128
+ });
58129
+ });
58130
+ }
58131
+ /**
58132
+ * Writes data to a 2 level inclusive store.
58133
+ */
58134
+ write(options) {
58135
+ const { l1, writeToL1 } = options;
58136
+ const tempL1 = buildServiceDescriptor().service.record();
58137
+ return writeToL1(tempL1).then(() => {
58138
+ const keysToReviveRecordableCache = l1.record();
58139
+ tempL1.keysUpdated.forEach((key) => keysToReviveRecordableCache.get(key));
58140
+ tempL1.missingKeysRead.forEach((key) => keysToReviveRecordableCache.get(key));
58141
+ const missingKeys = keysToReviveRecordableCache.missingKeysRead;
58142
+ const revivePromiseLike = missingKeys.size > 0 ? this.revive(missingKeys, l1).then(() => void 0) : resolvedPromiseLike(void 0);
58143
+ return revivePromiseLike.then(() => {
58144
+ const recordableCache = l1.record();
58145
+ return writeToL1(recordableCache).then((result) => {
58146
+ this.syncToL2Cache(recordableCache.keysUpdated, l1);
58147
+ return result;
58148
+ });
58149
+ });
58150
+ });
58151
+ }
58152
+ }
58153
+
58154
+ class NimbusDurableCacheInclusionPolicy extends DurableCacheInclusionPolicy {
58155
+ constructor(services, store) {
58156
+ super();
58157
+ this.services = services;
58158
+ this.store = store;
58159
+ this.registerListener();
58160
+ }
58161
+ revive(keys, l1) {
58162
+ if (keys.size === 0)
58163
+ return Promise.resolve(new Set());
58164
+ return this.store.getEntries(keys).then((entries) => {
58165
+ const keysRevived = new Set();
58166
+ if (!entries)
58167
+ return keysRevived;
58168
+ entries.forEach(({ key, entry }) => {
58169
+ l1.set(key, entry);
58170
+ keysRevived.add(key);
58171
+ });
58172
+ return keysRevived;
58173
+ });
58174
+ }
58175
+ syncToL2Cache(changedKeys, l1) {
58176
+ if (changedKeys.size === 0)
58177
+ return Promise.resolve();
58178
+ const entries = [];
58179
+ for (const key of changedKeys) {
58180
+ const entry = l1.get(key);
58181
+ if (entry) {
58182
+ entries.push({ key, entry });
58183
+ }
58184
+ }
58185
+ return entries.length > 0 ? this.store.setEntries(entries) : Promise.resolve();
58186
+ }
58187
+ find(_query) {
58188
+ throw new Error('find not supported on the NimbusDurableCacheInclusionPolicy');
58189
+ }
58190
+ findAndModify(_query, _cacheUpdate) {
58191
+ throw new Error('findAndModify not supported on the NimbusDurableCacheInclusionPolicy');
58192
+ }
58193
+ registerListener() {
58194
+ this.store.registerOnChangedListener(async (changes) => {
58195
+ changes.forEach((change) => {
58196
+ const upsertKeys = new Set();
58197
+ const evictKeys = new Set();
58198
+ for (const key of change.keys) {
58199
+ if (change.type === 'upsert') {
58200
+ upsertKeys.add(key);
58201
+ }
58202
+ else {
58203
+ evictKeys.add(key);
58204
+ }
58205
+ }
58206
+ if (upsertKeys.size > 0) {
58207
+ this.store.getEntries(upsertKeys).then((entries) => {
58208
+ if (entries === undefined)
58209
+ return;
58210
+ entries.forEach(({ key, entry }) => {
58211
+ this.services.cache.set(key, entry);
58212
+ return resolvedPromiseLike$3(ok$1(undefined));
58213
+ });
58214
+ });
58215
+ }
58216
+ // TODO: onestore doesnt support cache eviction yet
58217
+ // if (evictKeys.size > 0) {
58218
+ // evictKeys.forEach((key) => {
58219
+ // this.services.cache.evict(key);
58220
+ // });
58221
+ // }
58222
+ });
58223
+ });
58224
+ }
58225
+ }
58226
+ function buildNimbusDurableCacheInclusionPolicyService(cache, store) {
58227
+ return {
58228
+ service: new NimbusDurableCacheInclusionPolicy({ cache }, store),
58229
+ type: 'cacheInclusionPolicy',
58230
+ version: '1.0',
58231
+ };
58232
+ }
58233
+
58234
+ const TABLE_NAME = 'lds_one_store_data';
58235
+ class NimbusSqliteOneStoreCache {
58236
+ constructor(sqlStore) {
58237
+ this.sqlStore = sqlStore;
58238
+ }
58239
+ async getEntry(key) {
58240
+ const result = await this.query(`SELECT key, data, metadata FROM ${TABLE_NAME} WHERE key = ?`, [key]);
58241
+ if (result.rows.length === 0)
58242
+ return undefined;
58243
+ const [_key, data, metadata] = result.rows[0];
58244
+ return {
58245
+ key,
58246
+ entry: {
58247
+ value: JSON.parse(data),
58248
+ metadata: metadata ? JSON.parse(metadata) : undefined,
58249
+ },
58250
+ };
58251
+ }
58252
+ async getEntries(keys) {
58253
+ if (keys.size === 0)
58254
+ return undefined;
58255
+ const placeholders = Array(keys.size).fill('?').join(', ');
58256
+ const result = await this.query(`SELECT key, data, metadata FROM ${TABLE_NAME} WHERE key IN (${placeholders})`, [...keys]);
58257
+ if (result.rows.length === 0)
58258
+ return undefined;
58259
+ return result.rows.map((row) => {
58260
+ const [key, data, metadata] = row;
58261
+ return {
58262
+ key: key,
58263
+ entry: {
58264
+ value: JSON.parse(data),
58265
+ metadata: metadata ? JSON.parse(metadata) : undefined,
58266
+ },
58267
+ };
58268
+ });
58269
+ }
58270
+ async setEntry(key, entry) {
58271
+ return this.setEntries([{ key, entry }]);
58272
+ }
58273
+ async setEntries(entries) {
58274
+ if (entries.length === 0)
58275
+ return;
58276
+ const rows = entries.map(({ key, entry: { value, metadata } }) => [
58277
+ key,
58278
+ JSON.stringify(value),
58279
+ JSON.stringify(metadata),
58280
+ ]);
58281
+ const operation = {
58282
+ type: 'upsert',
58283
+ table: TABLE_NAME,
58284
+ keyColumn: 'key',
58285
+ conflictColumns: ['key'],
58286
+ columns: ['key', 'data', 'metadata'],
58287
+ rows,
58288
+ context: {},
58289
+ };
58290
+ return this.batchQuery([operation]);
58291
+ }
58292
+ registerOnChangedListener(listener) {
58293
+ let unsubscribeId = undefined;
58294
+ this.sqlStore
58295
+ .registerOnChangedListener((changes) => {
58296
+ const onestoreChanges = changes.filter((change) => change.table === TABLE_NAME);
58297
+ return listener(onestoreChanges);
58298
+ })
58299
+ .then((id) => {
58300
+ unsubscribeId = id;
58301
+ });
58302
+ return () => {
58303
+ if (unsubscribeId === undefined)
58304
+ return Promise.resolve();
58305
+ return this.sqlStore.unsubscribeOnChangedListener(unsubscribeId);
58306
+ };
58307
+ }
58308
+ batchQuery(operations) {
58309
+ return new Promise((resolve, reject) => {
58310
+ this.sqlStore.batchOperations(operations, (error) => {
58311
+ error ? reject(error) : resolve();
58312
+ });
58313
+ });
58314
+ }
58315
+ query(sql, params) {
58316
+ return new Promise((resolve, reject) => {
58317
+ this.sqlStore.query(sql, params, resolve, reject);
58318
+ });
58319
+ }
58320
+ }
58321
+
57963
58322
  // TODO[@W-18753648]: These services depend on WebApis that aren't available in the worker.
57964
58323
  // import { buildServiceDescriptor as buildNdJsonServiceDescriptor } from '@luvio/command-ndjson/v1';
57965
58324
  // import { buildServiceDescriptor as buildStreamingCommandServiceDescriptor } from '@luvio/command-streaming/v1';
57966
58325
  // import { buildServiceDescriptor as buildSseCommandServiceDescriptor } from '@luvio/command-sse/v1';
57967
- function initializeOneStore() {
58326
+ function initializeOneStore(sqliteStore) {
57968
58327
  if (!useOneStore.isOpen({ fallback: true })) {
57969
58328
  return;
57970
58329
  }
57971
58330
  const loggerService = new ConsoleLogger('ERROR');
57972
- const cacheServiceDescriptor = buildServiceDescriptor$5();
57973
- const instrumentationServiceDescriptor = buildServiceDescriptor$2(loggerService);
57974
- const inMemoryCacheInclusionPolicyServiceDescriptor = buildInMemoryCacheInclusionPolicyService(cacheServiceDescriptor.service);
58331
+ const cacheServiceDescriptor = buildServiceDescriptor$6();
58332
+ const instrumentationServiceDescriptor = buildServiceDescriptor$3(loggerService);
58333
+ const nimbusSqliteOneStoreCacheServiceDescriptor = buildNimbusDurableCacheInclusionPolicyService(cacheServiceDescriptor.service, new NimbusSqliteOneStoreCache(sqliteStore));
57975
58334
  const services = [
57976
58335
  instrumentationServiceDescriptor,
57977
58336
  buildNimbusFetchServiceDescriptor(),
57978
- buildServiceDescriptor$3(instrumentationServiceDescriptor.service),
58337
+ buildServiceDescriptor$4(instrumentationServiceDescriptor.service),
57979
58338
  // NOTE: These do not directly depend on Aura, and are necessary for HTTP fallback support.
58339
+ buildServiceDescriptor$b(),
57980
58340
  buildServiceDescriptor$a(),
57981
58341
  buildServiceDescriptor$9(),
58342
+ buildServiceDescriptor$5(cacheServiceDescriptor.service, nimbusSqliteOneStoreCacheServiceDescriptor.service),
57982
58343
  buildServiceDescriptor$8(),
57983
- buildServiceDescriptor$4(cacheServiceDescriptor.service, inMemoryCacheInclusionPolicyServiceDescriptor.service),
58344
+ buildServiceDescriptor$c(),
57984
58345
  buildServiceDescriptor$7(),
57985
- buildServiceDescriptor$b(),
57986
- buildServiceDescriptor$6(),
57987
- buildServiceDescriptor$1(),
58346
+ buildServiceDescriptor$2(),
57988
58347
  // TODO[@W-18753648]: See note above.
57989
58348
  // buildStreamingCommandServiceDescriptor(),
57990
58349
  // buildNdJsonServiceDescriptor(),
@@ -58164,7 +58523,7 @@ function getRuntime({ primeUser = false } = {}) {
58164
58523
  withRegistration('@salesforce/lds-adapters-uiapi/graphql', configureUIAPIGraphQL);
58165
58524
  }
58166
58525
  // onestore initialization
58167
- initializeOneStore();
58526
+ initializeOneStore(lazyDurableStore['plugin']);
58168
58527
  return {
58169
58528
  luvio: lazyLuvio,
58170
58529
  internalLuvio: lazyInternalLuvio,
@@ -58198,4 +58557,4 @@ register({
58198
58557
  });
58199
58558
 
58200
58559
  export { O11Y_NAMESPACE_LDS_MOBILE, getRuntime, ingest$1o as ingestDenormalizedRecordRepresentation, registerReportObserver, reportGraphqlQueryParseError };
58201
- // version: 1.369.0-b61b56bd49
58560
+ // version: 1.370.0-3ec6ffba72