@salesforce/lds-worker-api 1.380.0-dev5 → 1.380.0-dev6

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.
@@ -1371,4 +1371,4 @@ if (process.env.NODE_ENV !== 'production') {
1371
1371
  }
1372
1372
 
1373
1373
  export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, importLuvioAdapterModule, importOneStoreAdapterModule, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
1374
- // version: 1.380.0-dev5-94859d35c9
1374
+ // version: 1.380.0-dev6-1891f38076
@@ -1981,7 +1981,7 @@ function adapterToNetworkPriority(priority) {
1981
1981
  return 'normal';
1982
1982
  }
1983
1983
  }
1984
- var HttpStatusCode$1;
1984
+ var HttpStatusCode$2;
1985
1985
  (function (HttpStatusCode) {
1986
1986
  HttpStatusCode[HttpStatusCode["Ok"] = 200] = "Ok";
1987
1987
  HttpStatusCode[HttpStatusCode["Created"] = 201] = "Created";
@@ -1993,7 +1993,7 @@ var HttpStatusCode$1;
1993
1993
  HttpStatusCode[HttpStatusCode["NotFound"] = 404] = "NotFound";
1994
1994
  HttpStatusCode[HttpStatusCode["ServerError"] = 500] = "ServerError";
1995
1995
  HttpStatusCode[HttpStatusCode["GatewayTimeout"] = 504] = "GatewayTimeout";
1996
- })(HttpStatusCode$1 || (HttpStatusCode$1 = {}));
1996
+ })(HttpStatusCode$2 || (HttpStatusCode$2 = {}));
1997
1997
  /**
1998
1998
  * A type guard function for determining if an unknown object is a {@link FileReference}
1999
1999
  */
@@ -2111,7 +2111,7 @@ const onlyIfCachedImplementation = function (args) {
2111
2111
  body: undefined,
2112
2112
  headers: {},
2113
2113
  ok: false,
2114
- status: HttpStatusCode$1.GatewayTimeout,
2114
+ status: HttpStatusCode$2.GatewayTimeout,
2115
2115
  statusText: 'Data requested with only-if-cached policy and not found in the cache.',
2116
2116
  errorType: 'fetchResponse',
2117
2117
  }, refresh);
@@ -3374,7 +3374,7 @@ class Environment {
3374
3374
  isErrorCacheable(errorSnapshot) {
3375
3375
  const { error } = errorSnapshot;
3376
3376
  if (error.errorType === 'fetchResponse') {
3377
- return error.status === HttpStatusCode$1.NotFound;
3377
+ return error.status === HttpStatusCode$2.NotFound;
3378
3378
  }
3379
3379
  return false;
3380
3380
  }
@@ -4274,7 +4274,7 @@ function withDefaultLuvio(callback) {
4274
4274
  }
4275
4275
  callbacks.push(callback);
4276
4276
  }
4277
- // version: 1.380.0-dev5-94859d35c9
4277
+ // version: 1.380.0-dev6-1891f38076
4278
4278
 
4279
4279
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4280
4280
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -5318,7 +5318,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
5318
5318
  const { apiFamily, name } = metadata;
5319
5319
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
5320
5320
  }
5321
- // version: 1.380.0-dev5-94859d35c9
5321
+ // version: 1.380.0-dev6-1891f38076
5322
5322
 
5323
5323
  /**
5324
5324
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -5362,7 +5362,7 @@ var StoreResolveResultState;
5362
5362
  StoreResolveResultState[StoreResolveResultState["NotPresent"] = 3] = "NotPresent";
5363
5363
  StoreResolveResultState[StoreResolveResultState["Stale"] = 4] = "Stale";
5364
5364
  })(StoreResolveResultState || (StoreResolveResultState = {}));
5365
- var HttpStatusCode;
5365
+ var HttpStatusCode$1;
5366
5366
  (function (HttpStatusCode) {
5367
5367
  HttpStatusCode[HttpStatusCode["Ok"] = 200] = "Ok";
5368
5368
  HttpStatusCode[HttpStatusCode["Created"] = 201] = "Created";
@@ -5374,7 +5374,7 @@ var HttpStatusCode;
5374
5374
  HttpStatusCode[HttpStatusCode["NotFound"] = 404] = "NotFound";
5375
5375
  HttpStatusCode[HttpStatusCode["ServerError"] = 500] = "ServerError";
5376
5376
  HttpStatusCode[HttpStatusCode["GatewayTimeout"] = 504] = "GatewayTimeout";
5377
- })(HttpStatusCode || (HttpStatusCode = {}));
5377
+ })(HttpStatusCode$1 || (HttpStatusCode$1 = {}));
5378
5378
  var GraphNodeType;
5379
5379
  (function (GraphNodeType) {
5380
5380
  GraphNodeType["Link"] = "Link";
@@ -32839,7 +32839,7 @@ const createResourceParams$4$1 = /*#__PURE__*/ createResourceParams$14(createRec
32839
32839
 
32840
32840
  function onResponseSuccess(luvio, response, recordIngest, conflictMap) {
32841
32841
  const { body, status } = response;
32842
- if (status === HttpStatusCode$1.NoContent) {
32842
+ if (status === HttpStatusCode$2.NoContent) {
32843
32843
  const syntheticSnapshot = {
32844
32844
  state: 'Fulfilled',
32845
32845
  data: {},
@@ -33116,7 +33116,7 @@ function buildNetworkSnapshot$2$1(luvio, config, clientOptions) {
33116
33116
  const recordIngest = createRecordIngest$1(fieldTrie, optionalFieldTrie, conflictMap);
33117
33117
  return luvio.dispatchResourceRequest(request).then((response) => {
33118
33118
  return luvio.handleSuccessResponse(() => {
33119
- if (response.status === HttpStatusCode$1.NoContent) {
33119
+ if (response.status === HttpStatusCode$2.NoContent) {
33120
33120
  const syntheticSnapshot = {
33121
33121
  state: 'Fulfilled',
33122
33122
  data: {},
@@ -34154,7 +34154,7 @@ withDefaultLuvio((luvio) => {
34154
34154
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
34155
34155
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
34156
34156
  });
34157
- // version: 1.380.0-dev5-27c3b66ede
34157
+ // version: 1.380.0-dev6-9d4fd6e5dc
34158
34158
 
34159
34159
  function requestIdleDetectedCallback(_callback) { }
34160
34160
  function declareNotifierTaskSingle(_name) {
@@ -46161,7 +46161,7 @@ const MAX_STRING_LENGTH_PER_CHUNK = 10000;
46161
46161
  const MAX_AGGREGATE_UI_CHUNK_LIMIT = 50;
46162
46162
  function createOkResponse$1(body) {
46163
46163
  return {
46164
- status: HttpStatusCode$1.Ok,
46164
+ status: HttpStatusCode$2.Ok,
46165
46165
  body,
46166
46166
  statusText: 'ok',
46167
46167
  headers: {},
@@ -46170,15 +46170,15 @@ function createOkResponse$1(body) {
46170
46170
  }
46171
46171
  function getErrorResponseText(status) {
46172
46172
  switch (status) {
46173
- case HttpStatusCode$1.Ok:
46173
+ case HttpStatusCode$2.Ok:
46174
46174
  return 'OK';
46175
- case HttpStatusCode$1.NotModified:
46175
+ case HttpStatusCode$2.NotModified:
46176
46176
  return 'Not Modified';
46177
- case HttpStatusCode$1.NotFound:
46177
+ case HttpStatusCode$2.NotFound:
46178
46178
  return 'Not Found';
46179
- case HttpStatusCode$1.BadRequest:
46179
+ case HttpStatusCode$2.BadRequest:
46180
46180
  return 'Bad Request';
46181
- case HttpStatusCode$1.ServerError:
46181
+ case HttpStatusCode$2.ServerError:
46182
46182
  return 'Server Error';
46183
46183
  default:
46184
46184
  return `Unexpected HTTP Status Code: ${status}`;
@@ -46230,14 +46230,14 @@ function dispatchSplitRecordAggregateUiAction(recordId, networkAdapter, resource
46230
46230
  body.compositeResponse === undefined ||
46231
46231
  body.compositeResponse.length === 0) {
46232
46232
  // We shouldn't even get into this state - a 200 with no body?
46233
- throw createErrorResponse(HttpStatusCode$1.ServerError, {
46233
+ throw createErrorResponse(HttpStatusCode$2.ServerError, {
46234
46234
  error: 'No response body in executeAggregateUi found',
46235
46235
  });
46236
46236
  }
46237
46237
  const merged = body.compositeResponse.reduce((seed, response) => {
46238
- if (response.httpStatusCode !== HttpStatusCode$1.Ok) {
46238
+ if (response.httpStatusCode !== HttpStatusCode$2.Ok) {
46239
46239
  instrumentation$3.getRecordAggregateReject(() => recordId);
46240
- throw createErrorResponse(HttpStatusCode$1.ServerError, {
46240
+ throw createErrorResponse(HttpStatusCode$2.ServerError, {
46241
46241
  error: response.message,
46242
46242
  });
46243
46243
  }
@@ -46319,8 +46319,8 @@ const UIAPI_RECORDS_BATCH_PATH = `${UI_API_BASE_URI}/records/batch/`;
46319
46319
  const QUERY_TOO_COMPLICATED_ERROR_CODE = 'QUERY_TOO_COMPLICATED';
46320
46320
  function fetchResponseIsQueryTooComplicated(error) {
46321
46321
  const { body } = error;
46322
- if (error.status === HttpStatusCode$1.BadRequest && body !== undefined) {
46323
- return (body.statusCode === HttpStatusCode$1.BadRequest &&
46322
+ if (error.status === HttpStatusCode$2.BadRequest && body !== undefined) {
46323
+ return (body.statusCode === HttpStatusCode$2.BadRequest &&
46324
46324
  body.errorCode === QUERY_TOO_COMPLICATED_ERROR_CODE);
46325
46325
  }
46326
46326
  return false;
@@ -47933,15 +47933,15 @@ class DraftFetchResponse {
47933
47933
  get statusText() {
47934
47934
  const { status } = this;
47935
47935
  switch (status) {
47936
- case HttpStatusCode$1.Ok:
47936
+ case HttpStatusCode$2.Ok:
47937
47937
  return 'OK';
47938
- case HttpStatusCode$1.Created:
47938
+ case HttpStatusCode$2.Created:
47939
47939
  return 'Created';
47940
- case HttpStatusCode$1.NoContent:
47940
+ case HttpStatusCode$2.NoContent:
47941
47941
  return 'No Content';
47942
- case HttpStatusCode$1.BadRequest:
47942
+ case HttpStatusCode$2.BadRequest:
47943
47943
  return 'Bad Request';
47944
- case HttpStatusCode$1.ServerError:
47944
+ case HttpStatusCode$2.ServerError:
47945
47945
  return 'Server Error';
47946
47946
  default:
47947
47947
  return `Unexpected HTTP Status Code: ${status}`;
@@ -47962,11 +47962,11 @@ class DraftErrorFetchResponse {
47962
47962
  get statusText() {
47963
47963
  const { status } = this;
47964
47964
  switch (status) {
47965
- case HttpStatusCode$1.BadRequest:
47965
+ case HttpStatusCode$2.BadRequest:
47966
47966
  return 'Bad Request';
47967
- case HttpStatusCode$1.ServerError:
47967
+ case HttpStatusCode$2.ServerError:
47968
47968
  return 'Server Error';
47969
- case HttpStatusCode$1.NotFound:
47969
+ case HttpStatusCode$2.NotFound:
47970
47970
  return 'Not Found';
47971
47971
  default:
47972
47972
  return `Unexpected HTTP Status Code: ${status}`;
@@ -47974,13 +47974,13 @@ class DraftErrorFetchResponse {
47974
47974
  }
47975
47975
  }
47976
47976
  function createOkResponse(body) {
47977
- return new DraftFetchResponse(HttpStatusCode$1.Ok, body);
47977
+ return new DraftFetchResponse(HttpStatusCode$2.Ok, body);
47978
47978
  }
47979
47979
  function createBadRequestResponse(body) {
47980
- return new DraftErrorFetchResponse(HttpStatusCode$1.BadRequest, body);
47980
+ return new DraftErrorFetchResponse(HttpStatusCode$2.BadRequest, body);
47981
47981
  }
47982
47982
  function createNotFoundResponse(body) {
47983
- return new DraftErrorFetchResponse(HttpStatusCode$1.NotFound, body);
47983
+ return new DraftErrorFetchResponse(HttpStatusCode$2.NotFound, body);
47984
47984
  }
47985
47985
  function transformErrorToDraftSynthesisError(error) {
47986
47986
  if (isDraftSynthesisError(error)) {
@@ -47997,7 +47997,7 @@ function createDraftSynthesisErrorResponse(message = 'failed to synthesize draft
47997
47997
  if (errorType !== undefined) {
47998
47998
  error.errorType = errorType;
47999
47999
  }
48000
- return new DraftErrorFetchResponse(HttpStatusCode$1.BadRequest, error);
48000
+ return new DraftErrorFetchResponse(HttpStatusCode$2.BadRequest, error);
48001
48001
  }
48002
48002
 
48003
48003
  /**
@@ -79941,7 +79941,7 @@ class AbstractResourceRequestActionHandler {
79941
79941
  retryDelayInMs = getRetryAfterInMs(response.headers);
79942
79942
  shouldRetry = true;
79943
79943
  break;
79944
- case HttpStatusCode$1.ServerError: {
79944
+ case HttpStatusCode$2.ServerError: {
79945
79945
  shouldRetry = true;
79946
79946
  if (this.handleIdempotencyServerError(response.body, updatedAction, false, ERROR_CODE_IDEMPOTENCY_BACKEND_OPERATION_ERROR)) {
79947
79947
  this.isIdempotencySupported = false;
@@ -79964,7 +79964,7 @@ class AbstractResourceRequestActionHandler {
79964
79964
  }
79965
79965
  break;
79966
79966
  }
79967
- case HttpStatusCode$1.BadRequest: {
79967
+ case HttpStatusCode$2.BadRequest: {
79968
79968
  if (this.handleIdempotencyServerError(response.body, updatedAction, false, ERROR_CODE_IDEMPOTENCY_FEATURE_NOT_ENABLED, ERROR_CODE_IDEMPOTENCY_NOT_SUPPORTED)) {
79969
79969
  retryDelayInMs = 0;
79970
79970
  actionDataChanged = true;
@@ -79982,13 +79982,13 @@ class AbstractResourceRequestActionHandler {
79982
79982
  }
79983
79983
  }
79984
79984
  }
79985
- if (response.status === HttpStatusCode$1.BadRequest &&
79985
+ if (response.status === HttpStatusCode$2.BadRequest &&
79986
79986
  this.hasIdempotencySupport() &&
79987
79987
  updatedAction.data.headers[HTTP_HEADER_IDEMPOTENCY_KEY] !== undefined) {
79988
79988
  updatedAction.data.headers[HTTP_HEADER_IDEMPOTENCY_KEY] = uuidv4();
79989
79989
  actionDataChanged = true;
79990
79990
  }
79991
- if (response.status === HttpStatusCode$1.BadRequest &&
79991
+ if (response.status === HttpStatusCode$2.BadRequest &&
79992
79992
  this.isBackdatingError(response.body, action)) {
79993
79993
  updatedAction.timestamp = Date.now();
79994
79994
  updatedAction.data.body.fields = {
@@ -88581,7 +88581,7 @@ function environmentAwareGraphQLBatchAdapterFactory(objectInfoService, luvio, is
88581
88581
  // remove injected fields from response.
88582
88582
  const data = snapshot.data;
88583
88583
  const userResults = data.results.map((compositeResult, index) => {
88584
- if (compositeResult.statusCode === HttpStatusCode$1.Ok) {
88584
+ if (compositeResult.statusCode === HttpStatusCode$2.Ok) {
88585
88585
  return {
88586
88586
  result: removeSyntheticFields(compositeResult.result, config.batchQuery[index].query),
88587
88587
  statusCode: compositeResult.statusCode,
@@ -88798,15 +88798,15 @@ function ldsParamsToString(params) {
88798
88798
  }
88799
88799
  function statusTextFromStatusCode(status) {
88800
88800
  switch (status) {
88801
- case HttpStatusCode$1.Ok:
88801
+ case HttpStatusCode$2.Ok:
88802
88802
  return 'OK';
88803
- case HttpStatusCode$1.NotModified:
88803
+ case HttpStatusCode$2.NotModified:
88804
88804
  return 'Not Modified';
88805
- case HttpStatusCode$1.NotFound:
88805
+ case HttpStatusCode$2.NotFound:
88806
88806
  return 'Not Found';
88807
- case HttpStatusCode$1.BadRequest:
88807
+ case HttpStatusCode$2.BadRequest:
88808
88808
  return 'Bad Request';
88809
- case HttpStatusCode$1.ServerError:
88809
+ case HttpStatusCode$2.ServerError:
88810
88810
  return 'Server Error';
88811
88811
  default:
88812
88812
  return `Unexpected HTTP Status Code: ${status}`;
@@ -89173,7 +89173,7 @@ function mergeAggregateUiResponse(response, mergeFunc) {
89173
89173
  return {
89174
89174
  ...response,
89175
89175
  ok: false,
89176
- status: HttpStatusCode$1.ServerError,
89176
+ status: HttpStatusCode$2.ServerError,
89177
89177
  statusText: PARSE_ERROR,
89178
89178
  body: [
89179
89179
  {
@@ -89231,9 +89231,9 @@ function mergeBatchRecordsFields(first, second, collectionMergeFunc) {
89231
89231
  for (let i = 0, len = targetResults.length; i < len; i += 1) {
89232
89232
  const targetResult = targetResults[i];
89233
89233
  const sourceResult = sourceResults[i];
89234
- if (targetResult.statusCode !== HttpStatusCode$1.Ok)
89234
+ if (targetResult.statusCode !== HttpStatusCode$2.Ok)
89235
89235
  continue;
89236
- if (sourceResult.statusCode !== HttpStatusCode$1.Ok) {
89236
+ if (sourceResult.statusCode !== HttpStatusCode$2.Ok) {
89237
89237
  targetResults[i] = sourceResult;
89238
89238
  continue;
89239
89239
  }
@@ -93944,6 +93944,47 @@ function toError(x) {
93944
93944
  }
93945
93945
  return new Error(typeof x === "string" ? x : JSON.stringify(x));
93946
93946
  }
93947
+ var HttpStatusCode = /* @__PURE__ */ ((HttpStatusCode2) => {
93948
+ HttpStatusCode2[HttpStatusCode2["Ok"] = 200] = "Ok";
93949
+ HttpStatusCode2[HttpStatusCode2["Created"] = 201] = "Created";
93950
+ HttpStatusCode2[HttpStatusCode2["NoContent"] = 204] = "NoContent";
93951
+ HttpStatusCode2[HttpStatusCode2["NotModified"] = 304] = "NotModified";
93952
+ HttpStatusCode2[HttpStatusCode2["BadRequest"] = 400] = "BadRequest";
93953
+ HttpStatusCode2[HttpStatusCode2["Unauthorized"] = 401] = "Unauthorized";
93954
+ HttpStatusCode2[HttpStatusCode2["Forbidden"] = 403] = "Forbidden";
93955
+ HttpStatusCode2[HttpStatusCode2["NotFound"] = 404] = "NotFound";
93956
+ HttpStatusCode2[HttpStatusCode2["ServerError"] = 500] = "ServerError";
93957
+ HttpStatusCode2[HttpStatusCode2["GatewayTimeout"] = 504] = "GatewayTimeout";
93958
+ return HttpStatusCode2;
93959
+ })(HttpStatusCode || {});
93960
+ function getStatusText(status) {
93961
+ switch (status) {
93962
+ case 200:
93963
+ return "OK";
93964
+ case 201:
93965
+ return "Created";
93966
+ case 304:
93967
+ return "Not Modified";
93968
+ case 400:
93969
+ return "Bad Request";
93970
+ case 404:
93971
+ return "Not Found";
93972
+ case 500:
93973
+ return "Server Error";
93974
+ default:
93975
+ return `Unexpected HTTP Status Code: ${status}`;
93976
+ }
93977
+ }
93978
+ class FetchResponse extends Error {
93979
+ constructor(status, body, headers) {
93980
+ super();
93981
+ this.status = status;
93982
+ this.body = body;
93983
+ this.headers = headers || {};
93984
+ this.ok = status >= 200 && this.status <= 299;
93985
+ this.statusText = getStatusText(status);
93986
+ }
93987
+ }
93947
93988
  let InternalError$1 = class InternalError extends Error {
93948
93989
  constructor(data) {
93949
93990
  super();
@@ -94766,9 +94807,6 @@ class AuraResourceCacheControlCommand extends AuraCacheControlCommand {
94766
94807
  super(services);
94767
94808
  this.services = services;
94768
94809
  }
94769
- execute() {
94770
- return super.execute();
94771
- }
94772
94810
  readFromCache(cache) {
94773
94811
  var _a;
94774
94812
  const data = (_a = cache.get(this.buildKey())) == null ? void 0 : _a.value;
@@ -95370,6 +95408,59 @@ class MaxAgeCacheControlStrategy extends CacheControlStrategy {
95370
95408
  ];
95371
95409
  }
95372
95410
  }
95411
+ class OnlyIfCachedCacheControlStrategy extends CacheControlStrategy {
95412
+ execute(options) {
95413
+ const startTime = this.services.instrumentation ? this.services.instrumentation.currentTimeMs() : 0;
95414
+ return this.services.cacheInclusionPolicy.read({
95415
+ l1: this.filteredCache,
95416
+ readFromL1: (l1) => this.requestRunner.readFromCache(l1)
95417
+ }).then((result) => {
95418
+ if (result.isOk()) {
95419
+ this.collectCacheHitInstrumentation(
95420
+ startTime,
95421
+ options == null ? void 0 : options.instrumentationAttributes
95422
+ );
95423
+ return ok$1$1(void 0);
95424
+ }
95425
+ this.collectCacheMissInstrumentation(startTime, options == null ? void 0 : options.instrumentationAttributes);
95426
+ const error = new UserVisibleError(
95427
+ new FetchResponse(HttpStatusCode.GatewayTimeout, {
95428
+ error: "Cache miss for only-if-cached request"
95429
+ })
95430
+ );
95431
+ return err$1$1(error);
95432
+ });
95433
+ }
95434
+ get expiredChecks() {
95435
+ return [
95436
+ (cacheControlMetadata) => cacheControlMetadata.type === "no-store"
95437
+ ];
95438
+ }
95439
+ collectCacheHitInstrumentation(startTime, instrumentationAttributes) {
95440
+ if (this.services.instrumentation) {
95441
+ const meter = this.services.instrumentation.metrics.getMeter("onestore");
95442
+ meter.createCounter(`command.only-if-cached.cache-hit.count`).add(1, instrumentationAttributes);
95443
+ meter.createHistogram(
95444
+ `command.only-if-cached.cache-hit.duration`
95445
+ ).record(
95446
+ this.services.instrumentation.currentTimeMs() - startTime,
95447
+ instrumentationAttributes
95448
+ );
95449
+ }
95450
+ }
95451
+ collectCacheMissInstrumentation(startTime, instrumentationAttributes) {
95452
+ if (this.services.instrumentation) {
95453
+ const meter = this.services.instrumentation.metrics.getMeter("onestore");
95454
+ meter.createCounter(`command.only-if-cached.cache-miss.count`).add(1, instrumentationAttributes);
95455
+ meter.createHistogram(
95456
+ `command.only-if-cached.cache-miss.duration`
95457
+ ).record(
95458
+ this.services.instrumentation.currentTimeMs() - startTime,
95459
+ instrumentationAttributes
95460
+ );
95461
+ }
95462
+ }
95463
+ }
95373
95464
  class CacheController {
95374
95465
  constructor(services) {
95375
95466
  this.services = services;
@@ -95383,6 +95474,8 @@ class CacheController {
95383
95474
  return new MaxAgeCacheControlStrategy(this.services, config, requestRunner);
95384
95475
  } else if (config.type === "no-cache") {
95385
95476
  return new NoCacheCacheControlStrategy(this.services, config, requestRunner);
95477
+ } else if (config.type === "only-if-cached") {
95478
+ return new OnlyIfCachedCacheControlStrategy(this.services, config, requestRunner);
95386
95479
  }
95387
95480
  throw new Error(`Unknown cache control strategy ${config.type}`);
95388
95481
  }
@@ -95901,7 +95994,7 @@ function buildServiceDescriptor$5(luvio) {
95901
95994
  },
95902
95995
  };
95903
95996
  }
95904
- // version: 1.380.0-dev5-27c3b66ede
95997
+ // version: 1.380.0-dev6-9d4fd6e5dc
95905
95998
 
95906
95999
  /**
95907
96000
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -95927,7 +96020,7 @@ function buildServiceDescriptor$4(notifyRecordUpdateAvailable, getNormalizedLuvi
95927
96020
  },
95928
96021
  };
95929
96022
  }
95930
- // version: 1.380.0-dev5-27c3b66ede
96023
+ // version: 1.380.0-dev6-9d4fd6e5dc
95931
96024
 
95932
96025
  /*!
95933
96026
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -98075,7 +98168,7 @@ register$1({
98075
98168
  id: '@salesforce/lds-network-adapter',
98076
98169
  instrument: instrument$2,
98077
98170
  });
98078
- // version: 1.380.0-dev5-94859d35c9
98171
+ // version: 1.380.0-dev6-1891f38076
98079
98172
 
98080
98173
  const { create: create$3, keys: keys$3 } = Object;
98081
98174
  const { stringify: stringify$1, parse } = JSON;
@@ -100432,12 +100525,15 @@ function logError(error) {
100432
100525
  }
100433
100526
  console.error("OneStore Command threw an error that we did not expect", error);
100434
100527
  }
100528
+ const supportedCachePolicyTypes = ["no-cache", "only-if-cached"];
100435
100529
  function requestContextIsSupportedCachePolicy(requestContext) {
100436
- return typeof requestContext === "object" && requestContext !== null && "cachePolicy" in requestContext && typeof requestContext.cachePolicy === "object" && requestContext.cachePolicy !== null && "type" in requestContext.cachePolicy && requestContext.cachePolicy.type === "no-cache";
100530
+ return typeof requestContext === "object" && requestContext !== null && "cachePolicy" in requestContext && typeof requestContext.cachePolicy === "object" && requestContext.cachePolicy !== null && "type" in requestContext.cachePolicy && typeof requestContext.cachePolicy.type === "string" && supportedCachePolicyTypes.includes(
100531
+ requestContext.cachePolicy.type
100532
+ );
100437
100533
  }
100438
100534
  function getOverridesForLegacyRequestContext(requestContext) {
100439
100535
  if (requestContextIsSupportedCachePolicy(requestContext)) {
100440
- return { cacheControlConfig: { type: "no-cache" } };
100536
+ return { cacheControlConfig: { type: requestContext.cachePolicy.type } };
100441
100537
  }
100442
100538
  return {};
100443
100539
  }
@@ -100831,7 +100927,7 @@ function handleEmit(res, callback) {
100831
100927
  }
100832
100928
  callback(consumerEmittedData);
100833
100929
  }
100834
- // version: 1.380.0-dev5-27c3b66ede
100930
+ // version: 1.380.0-dev6-9d4fd6e5dc
100835
100931
 
100836
100932
  class Analytics__AnalyticsBrowseRepository extends UnidentifiableGraphQLTypeRepository {
100837
100933
  constructor(services, typeRegistry) {
@@ -104624,7 +104720,7 @@ function registerCallback(cb) {
104624
104720
  cb(graphql$1, graphql_imperative$1, useOneStoreGraphQL);
104625
104721
  }
104626
104722
  }
104627
- // version: 1.380.0-dev5-27c3b66ede
104723
+ // version: 1.380.0-dev6-9d4fd6e5dc
104628
104724
 
104629
104725
  function createFragmentMap(documentNode) {
104630
104726
  const fragments = {};
@@ -131253,7 +131349,7 @@ function refreshGraphQL(data) {
131253
131349
  }
131254
131350
  return refresh$3(data, 'refreshUiApi');
131255
131351
  }
131256
- // version: 1.380.0-dev5-27c3b66ede
131352
+ // version: 1.380.0-dev6-9d4fd6e5dc
131257
131353
 
131258
131354
  // On core the unstable adapters are re-exported with different names,
131259
131355
  // we want to match them here.
@@ -131405,7 +131501,7 @@ withDefaultLuvio((luvio) => {
131405
131501
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
131406
131502
  graphQLImperative = ldsAdapter;
131407
131503
  });
131408
- // version: 1.380.0-dev5-27c3b66ede
131504
+ // version: 1.380.0-dev6-9d4fd6e5dc
131409
131505
 
131410
131506
  var gqlApi = /*#__PURE__*/Object.freeze({
131411
131507
  __proto__: null,
@@ -131492,15 +131588,15 @@ class NativeFetchResponse {
131492
131588
  get statusText() {
131493
131589
  const { status } = this;
131494
131590
  switch (status) {
131495
- case HttpStatusCode$1.Ok:
131591
+ case HttpStatusCode$2.Ok:
131496
131592
  return 'OK';
131497
- case HttpStatusCode$1.Created:
131593
+ case HttpStatusCode$2.Created:
131498
131594
  return 'Created';
131499
- case HttpStatusCode$1.NoContent:
131595
+ case HttpStatusCode$2.NoContent:
131500
131596
  return 'No Content';
131501
- case HttpStatusCode$1.BadRequest:
131597
+ case HttpStatusCode$2.BadRequest:
131502
131598
  return 'Bad Request';
131503
- case HttpStatusCode$1.ServerError:
131599
+ case HttpStatusCode$2.ServerError:
131504
131600
  return 'Server Error';
131505
131601
  default:
131506
131602
  return `Unexpected HTTP Status Code: ${status}`;
@@ -131517,7 +131613,7 @@ class NativeFetchErrorResponse extends NativeFetchResponse {
131517
131613
  }
131518
131614
  }
131519
131615
  function createNativeFetchErrorResponse(message) {
131520
- return new NativeFetchErrorResponse(HttpStatusCode$1.BadRequest, {
131616
+ return new NativeFetchErrorResponse(HttpStatusCode$2.BadRequest, {
131521
131617
  errorCode: NATIVE_ERROR_CODE,
131522
131618
  message: message,
131523
131619
  });
@@ -132204,7 +132300,7 @@ const callbacks$1 = [];
132204
132300
  function register(r) {
132205
132301
  callbacks$1.forEach((callback) => callback(r));
132206
132302
  }
132207
- // version: 1.380.0-dev5-94859d35c9
132303
+ // version: 1.380.0-dev6-1891f38076
132208
132304
 
132209
132305
  /**
132210
132306
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -133520,4 +133616,4 @@ const { luvio } = getRuntime();
133520
133616
  setDefaultLuvio({ luvio });
133521
133617
 
133522
133618
  export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, importLuvioAdapterModule, importOneStoreAdapterModule, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
133523
- // version: 1.380.0-dev5-94859d35c9
133619
+ // version: 1.380.0-dev6-1891f38076
@@ -1987,7 +1987,7 @@
1987
1987
  return 'normal';
1988
1988
  }
1989
1989
  }
1990
- var HttpStatusCode$1;
1990
+ var HttpStatusCode$2;
1991
1991
  (function (HttpStatusCode) {
1992
1992
  HttpStatusCode[HttpStatusCode["Ok"] = 200] = "Ok";
1993
1993
  HttpStatusCode[HttpStatusCode["Created"] = 201] = "Created";
@@ -1999,7 +1999,7 @@
1999
1999
  HttpStatusCode[HttpStatusCode["NotFound"] = 404] = "NotFound";
2000
2000
  HttpStatusCode[HttpStatusCode["ServerError"] = 500] = "ServerError";
2001
2001
  HttpStatusCode[HttpStatusCode["GatewayTimeout"] = 504] = "GatewayTimeout";
2002
- })(HttpStatusCode$1 || (HttpStatusCode$1 = {}));
2002
+ })(HttpStatusCode$2 || (HttpStatusCode$2 = {}));
2003
2003
  /**
2004
2004
  * A type guard function for determining if an unknown object is a {@link FileReference}
2005
2005
  */
@@ -2117,7 +2117,7 @@
2117
2117
  body: undefined,
2118
2118
  headers: {},
2119
2119
  ok: false,
2120
- status: HttpStatusCode$1.GatewayTimeout,
2120
+ status: HttpStatusCode$2.GatewayTimeout,
2121
2121
  statusText: 'Data requested with only-if-cached policy and not found in the cache.',
2122
2122
  errorType: 'fetchResponse',
2123
2123
  }, refresh);
@@ -3380,7 +3380,7 @@
3380
3380
  isErrorCacheable(errorSnapshot) {
3381
3381
  const { error } = errorSnapshot;
3382
3382
  if (error.errorType === 'fetchResponse') {
3383
- return error.status === HttpStatusCode$1.NotFound;
3383
+ return error.status === HttpStatusCode$2.NotFound;
3384
3384
  }
3385
3385
  return false;
3386
3386
  }
@@ -4280,7 +4280,7 @@
4280
4280
  }
4281
4281
  callbacks.push(callback);
4282
4282
  }
4283
- // version: 1.380.0-dev5-94859d35c9
4283
+ // version: 1.380.0-dev6-1891f38076
4284
4284
 
4285
4285
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4286
4286
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -5324,7 +5324,7 @@
5324
5324
  const { apiFamily, name } = metadata;
5325
5325
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
5326
5326
  }
5327
- // version: 1.380.0-dev5-94859d35c9
5327
+ // version: 1.380.0-dev6-1891f38076
5328
5328
 
5329
5329
  /**
5330
5330
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -5368,7 +5368,7 @@
5368
5368
  StoreResolveResultState[StoreResolveResultState["NotPresent"] = 3] = "NotPresent";
5369
5369
  StoreResolveResultState[StoreResolveResultState["Stale"] = 4] = "Stale";
5370
5370
  })(StoreResolveResultState || (StoreResolveResultState = {}));
5371
- var HttpStatusCode;
5371
+ var HttpStatusCode$1;
5372
5372
  (function (HttpStatusCode) {
5373
5373
  HttpStatusCode[HttpStatusCode["Ok"] = 200] = "Ok";
5374
5374
  HttpStatusCode[HttpStatusCode["Created"] = 201] = "Created";
@@ -5380,7 +5380,7 @@
5380
5380
  HttpStatusCode[HttpStatusCode["NotFound"] = 404] = "NotFound";
5381
5381
  HttpStatusCode[HttpStatusCode["ServerError"] = 500] = "ServerError";
5382
5382
  HttpStatusCode[HttpStatusCode["GatewayTimeout"] = 504] = "GatewayTimeout";
5383
- })(HttpStatusCode || (HttpStatusCode = {}));
5383
+ })(HttpStatusCode$1 || (HttpStatusCode$1 = {}));
5384
5384
  var GraphNodeType;
5385
5385
  (function (GraphNodeType) {
5386
5386
  GraphNodeType["Link"] = "Link";
@@ -32845,7 +32845,7 @@
32845
32845
 
32846
32846
  function onResponseSuccess(luvio, response, recordIngest, conflictMap) {
32847
32847
  const { body, status } = response;
32848
- if (status === HttpStatusCode$1.NoContent) {
32848
+ if (status === HttpStatusCode$2.NoContent) {
32849
32849
  const syntheticSnapshot = {
32850
32850
  state: 'Fulfilled',
32851
32851
  data: {},
@@ -33122,7 +33122,7 @@
33122
33122
  const recordIngest = createRecordIngest$1(fieldTrie, optionalFieldTrie, conflictMap);
33123
33123
  return luvio.dispatchResourceRequest(request).then((response) => {
33124
33124
  return luvio.handleSuccessResponse(() => {
33125
- if (response.status === HttpStatusCode$1.NoContent) {
33125
+ if (response.status === HttpStatusCode$2.NoContent) {
33126
33126
  const syntheticSnapshot = {
33127
33127
  state: 'Fulfilled',
33128
33128
  data: {},
@@ -34160,7 +34160,7 @@
34160
34160
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
34161
34161
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
34162
34162
  });
34163
- // version: 1.380.0-dev5-27c3b66ede
34163
+ // version: 1.380.0-dev6-9d4fd6e5dc
34164
34164
 
34165
34165
  function requestIdleDetectedCallback(_callback) { }
34166
34166
  function declareNotifierTaskSingle(_name) {
@@ -46167,7 +46167,7 @@
46167
46167
  const MAX_AGGREGATE_UI_CHUNK_LIMIT = 50;
46168
46168
  function createOkResponse$1(body) {
46169
46169
  return {
46170
- status: HttpStatusCode$1.Ok,
46170
+ status: HttpStatusCode$2.Ok,
46171
46171
  body,
46172
46172
  statusText: 'ok',
46173
46173
  headers: {},
@@ -46176,15 +46176,15 @@
46176
46176
  }
46177
46177
  function getErrorResponseText(status) {
46178
46178
  switch (status) {
46179
- case HttpStatusCode$1.Ok:
46179
+ case HttpStatusCode$2.Ok:
46180
46180
  return 'OK';
46181
- case HttpStatusCode$1.NotModified:
46181
+ case HttpStatusCode$2.NotModified:
46182
46182
  return 'Not Modified';
46183
- case HttpStatusCode$1.NotFound:
46183
+ case HttpStatusCode$2.NotFound:
46184
46184
  return 'Not Found';
46185
- case HttpStatusCode$1.BadRequest:
46185
+ case HttpStatusCode$2.BadRequest:
46186
46186
  return 'Bad Request';
46187
- case HttpStatusCode$1.ServerError:
46187
+ case HttpStatusCode$2.ServerError:
46188
46188
  return 'Server Error';
46189
46189
  default:
46190
46190
  return `Unexpected HTTP Status Code: ${status}`;
@@ -46236,14 +46236,14 @@
46236
46236
  body.compositeResponse === undefined ||
46237
46237
  body.compositeResponse.length === 0) {
46238
46238
  // We shouldn't even get into this state - a 200 with no body?
46239
- throw createErrorResponse(HttpStatusCode$1.ServerError, {
46239
+ throw createErrorResponse(HttpStatusCode$2.ServerError, {
46240
46240
  error: 'No response body in executeAggregateUi found',
46241
46241
  });
46242
46242
  }
46243
46243
  const merged = body.compositeResponse.reduce((seed, response) => {
46244
- if (response.httpStatusCode !== HttpStatusCode$1.Ok) {
46244
+ if (response.httpStatusCode !== HttpStatusCode$2.Ok) {
46245
46245
  instrumentation$3.getRecordAggregateReject(() => recordId);
46246
- throw createErrorResponse(HttpStatusCode$1.ServerError, {
46246
+ throw createErrorResponse(HttpStatusCode$2.ServerError, {
46247
46247
  error: response.message,
46248
46248
  });
46249
46249
  }
@@ -46325,8 +46325,8 @@
46325
46325
  const QUERY_TOO_COMPLICATED_ERROR_CODE = 'QUERY_TOO_COMPLICATED';
46326
46326
  function fetchResponseIsQueryTooComplicated(error) {
46327
46327
  const { body } = error;
46328
- if (error.status === HttpStatusCode$1.BadRequest && body !== undefined) {
46329
- return (body.statusCode === HttpStatusCode$1.BadRequest &&
46328
+ if (error.status === HttpStatusCode$2.BadRequest && body !== undefined) {
46329
+ return (body.statusCode === HttpStatusCode$2.BadRequest &&
46330
46330
  body.errorCode === QUERY_TOO_COMPLICATED_ERROR_CODE);
46331
46331
  }
46332
46332
  return false;
@@ -47939,15 +47939,15 @@
47939
47939
  get statusText() {
47940
47940
  const { status } = this;
47941
47941
  switch (status) {
47942
- case HttpStatusCode$1.Ok:
47942
+ case HttpStatusCode$2.Ok:
47943
47943
  return 'OK';
47944
- case HttpStatusCode$1.Created:
47944
+ case HttpStatusCode$2.Created:
47945
47945
  return 'Created';
47946
- case HttpStatusCode$1.NoContent:
47946
+ case HttpStatusCode$2.NoContent:
47947
47947
  return 'No Content';
47948
- case HttpStatusCode$1.BadRequest:
47948
+ case HttpStatusCode$2.BadRequest:
47949
47949
  return 'Bad Request';
47950
- case HttpStatusCode$1.ServerError:
47950
+ case HttpStatusCode$2.ServerError:
47951
47951
  return 'Server Error';
47952
47952
  default:
47953
47953
  return `Unexpected HTTP Status Code: ${status}`;
@@ -47968,11 +47968,11 @@
47968
47968
  get statusText() {
47969
47969
  const { status } = this;
47970
47970
  switch (status) {
47971
- case HttpStatusCode$1.BadRequest:
47971
+ case HttpStatusCode$2.BadRequest:
47972
47972
  return 'Bad Request';
47973
- case HttpStatusCode$1.ServerError:
47973
+ case HttpStatusCode$2.ServerError:
47974
47974
  return 'Server Error';
47975
- case HttpStatusCode$1.NotFound:
47975
+ case HttpStatusCode$2.NotFound:
47976
47976
  return 'Not Found';
47977
47977
  default:
47978
47978
  return `Unexpected HTTP Status Code: ${status}`;
@@ -47980,13 +47980,13 @@
47980
47980
  }
47981
47981
  }
47982
47982
  function createOkResponse(body) {
47983
- return new DraftFetchResponse(HttpStatusCode$1.Ok, body);
47983
+ return new DraftFetchResponse(HttpStatusCode$2.Ok, body);
47984
47984
  }
47985
47985
  function createBadRequestResponse(body) {
47986
- return new DraftErrorFetchResponse(HttpStatusCode$1.BadRequest, body);
47986
+ return new DraftErrorFetchResponse(HttpStatusCode$2.BadRequest, body);
47987
47987
  }
47988
47988
  function createNotFoundResponse(body) {
47989
- return new DraftErrorFetchResponse(HttpStatusCode$1.NotFound, body);
47989
+ return new DraftErrorFetchResponse(HttpStatusCode$2.NotFound, body);
47990
47990
  }
47991
47991
  function transformErrorToDraftSynthesisError(error) {
47992
47992
  if (isDraftSynthesisError(error)) {
@@ -48003,7 +48003,7 @@
48003
48003
  if (errorType !== undefined) {
48004
48004
  error.errorType = errorType;
48005
48005
  }
48006
- return new DraftErrorFetchResponse(HttpStatusCode$1.BadRequest, error);
48006
+ return new DraftErrorFetchResponse(HttpStatusCode$2.BadRequest, error);
48007
48007
  }
48008
48008
 
48009
48009
  /**
@@ -79947,7 +79947,7 @@
79947
79947
  retryDelayInMs = getRetryAfterInMs(response.headers);
79948
79948
  shouldRetry = true;
79949
79949
  break;
79950
- case HttpStatusCode$1.ServerError: {
79950
+ case HttpStatusCode$2.ServerError: {
79951
79951
  shouldRetry = true;
79952
79952
  if (this.handleIdempotencyServerError(response.body, updatedAction, false, ERROR_CODE_IDEMPOTENCY_BACKEND_OPERATION_ERROR)) {
79953
79953
  this.isIdempotencySupported = false;
@@ -79970,7 +79970,7 @@
79970
79970
  }
79971
79971
  break;
79972
79972
  }
79973
- case HttpStatusCode$1.BadRequest: {
79973
+ case HttpStatusCode$2.BadRequest: {
79974
79974
  if (this.handleIdempotencyServerError(response.body, updatedAction, false, ERROR_CODE_IDEMPOTENCY_FEATURE_NOT_ENABLED, ERROR_CODE_IDEMPOTENCY_NOT_SUPPORTED)) {
79975
79975
  retryDelayInMs = 0;
79976
79976
  actionDataChanged = true;
@@ -79988,13 +79988,13 @@
79988
79988
  }
79989
79989
  }
79990
79990
  }
79991
- if (response.status === HttpStatusCode$1.BadRequest &&
79991
+ if (response.status === HttpStatusCode$2.BadRequest &&
79992
79992
  this.hasIdempotencySupport() &&
79993
79993
  updatedAction.data.headers[HTTP_HEADER_IDEMPOTENCY_KEY] !== undefined) {
79994
79994
  updatedAction.data.headers[HTTP_HEADER_IDEMPOTENCY_KEY] = uuidv4();
79995
79995
  actionDataChanged = true;
79996
79996
  }
79997
- if (response.status === HttpStatusCode$1.BadRequest &&
79997
+ if (response.status === HttpStatusCode$2.BadRequest &&
79998
79998
  this.isBackdatingError(response.body, action)) {
79999
79999
  updatedAction.timestamp = Date.now();
80000
80000
  updatedAction.data.body.fields = {
@@ -88587,7 +88587,7 @@
88587
88587
  // remove injected fields from response.
88588
88588
  const data = snapshot.data;
88589
88589
  const userResults = data.results.map((compositeResult, index) => {
88590
- if (compositeResult.statusCode === HttpStatusCode$1.Ok) {
88590
+ if (compositeResult.statusCode === HttpStatusCode$2.Ok) {
88591
88591
  return {
88592
88592
  result: removeSyntheticFields(compositeResult.result, config.batchQuery[index].query),
88593
88593
  statusCode: compositeResult.statusCode,
@@ -88804,15 +88804,15 @@
88804
88804
  }
88805
88805
  function statusTextFromStatusCode(status) {
88806
88806
  switch (status) {
88807
- case HttpStatusCode$1.Ok:
88807
+ case HttpStatusCode$2.Ok:
88808
88808
  return 'OK';
88809
- case HttpStatusCode$1.NotModified:
88809
+ case HttpStatusCode$2.NotModified:
88810
88810
  return 'Not Modified';
88811
- case HttpStatusCode$1.NotFound:
88811
+ case HttpStatusCode$2.NotFound:
88812
88812
  return 'Not Found';
88813
- case HttpStatusCode$1.BadRequest:
88813
+ case HttpStatusCode$2.BadRequest:
88814
88814
  return 'Bad Request';
88815
- case HttpStatusCode$1.ServerError:
88815
+ case HttpStatusCode$2.ServerError:
88816
88816
  return 'Server Error';
88817
88817
  default:
88818
88818
  return `Unexpected HTTP Status Code: ${status}`;
@@ -89179,7 +89179,7 @@
89179
89179
  return {
89180
89180
  ...response,
89181
89181
  ok: false,
89182
- status: HttpStatusCode$1.ServerError,
89182
+ status: HttpStatusCode$2.ServerError,
89183
89183
  statusText: PARSE_ERROR,
89184
89184
  body: [
89185
89185
  {
@@ -89237,9 +89237,9 @@
89237
89237
  for (let i = 0, len = targetResults.length; i < len; i += 1) {
89238
89238
  const targetResult = targetResults[i];
89239
89239
  const sourceResult = sourceResults[i];
89240
- if (targetResult.statusCode !== HttpStatusCode$1.Ok)
89240
+ if (targetResult.statusCode !== HttpStatusCode$2.Ok)
89241
89241
  continue;
89242
- if (sourceResult.statusCode !== HttpStatusCode$1.Ok) {
89242
+ if (sourceResult.statusCode !== HttpStatusCode$2.Ok) {
89243
89243
  targetResults[i] = sourceResult;
89244
89244
  continue;
89245
89245
  }
@@ -93950,6 +93950,47 @@
93950
93950
  }
93951
93951
  return new Error(typeof x === "string" ? x : JSON.stringify(x));
93952
93952
  }
93953
+ var HttpStatusCode = /* @__PURE__ */ ((HttpStatusCode2) => {
93954
+ HttpStatusCode2[HttpStatusCode2["Ok"] = 200] = "Ok";
93955
+ HttpStatusCode2[HttpStatusCode2["Created"] = 201] = "Created";
93956
+ HttpStatusCode2[HttpStatusCode2["NoContent"] = 204] = "NoContent";
93957
+ HttpStatusCode2[HttpStatusCode2["NotModified"] = 304] = "NotModified";
93958
+ HttpStatusCode2[HttpStatusCode2["BadRequest"] = 400] = "BadRequest";
93959
+ HttpStatusCode2[HttpStatusCode2["Unauthorized"] = 401] = "Unauthorized";
93960
+ HttpStatusCode2[HttpStatusCode2["Forbidden"] = 403] = "Forbidden";
93961
+ HttpStatusCode2[HttpStatusCode2["NotFound"] = 404] = "NotFound";
93962
+ HttpStatusCode2[HttpStatusCode2["ServerError"] = 500] = "ServerError";
93963
+ HttpStatusCode2[HttpStatusCode2["GatewayTimeout"] = 504] = "GatewayTimeout";
93964
+ return HttpStatusCode2;
93965
+ })(HttpStatusCode || {});
93966
+ function getStatusText(status) {
93967
+ switch (status) {
93968
+ case 200:
93969
+ return "OK";
93970
+ case 201:
93971
+ return "Created";
93972
+ case 304:
93973
+ return "Not Modified";
93974
+ case 400:
93975
+ return "Bad Request";
93976
+ case 404:
93977
+ return "Not Found";
93978
+ case 500:
93979
+ return "Server Error";
93980
+ default:
93981
+ return `Unexpected HTTP Status Code: ${status}`;
93982
+ }
93983
+ }
93984
+ class FetchResponse extends Error {
93985
+ constructor(status, body, headers) {
93986
+ super();
93987
+ this.status = status;
93988
+ this.body = body;
93989
+ this.headers = headers || {};
93990
+ this.ok = status >= 200 && this.status <= 299;
93991
+ this.statusText = getStatusText(status);
93992
+ }
93993
+ }
93953
93994
  let InternalError$1 = class InternalError extends Error {
93954
93995
  constructor(data) {
93955
93996
  super();
@@ -94772,9 +94813,6 @@
94772
94813
  super(services);
94773
94814
  this.services = services;
94774
94815
  }
94775
- execute() {
94776
- return super.execute();
94777
- }
94778
94816
  readFromCache(cache) {
94779
94817
  var _a;
94780
94818
  const data = (_a = cache.get(this.buildKey())) == null ? void 0 : _a.value;
@@ -95376,6 +95414,59 @@
95376
95414
  ];
95377
95415
  }
95378
95416
  }
95417
+ class OnlyIfCachedCacheControlStrategy extends CacheControlStrategy {
95418
+ execute(options) {
95419
+ const startTime = this.services.instrumentation ? this.services.instrumentation.currentTimeMs() : 0;
95420
+ return this.services.cacheInclusionPolicy.read({
95421
+ l1: this.filteredCache,
95422
+ readFromL1: (l1) => this.requestRunner.readFromCache(l1)
95423
+ }).then((result) => {
95424
+ if (result.isOk()) {
95425
+ this.collectCacheHitInstrumentation(
95426
+ startTime,
95427
+ options == null ? void 0 : options.instrumentationAttributes
95428
+ );
95429
+ return ok$1$1(void 0);
95430
+ }
95431
+ this.collectCacheMissInstrumentation(startTime, options == null ? void 0 : options.instrumentationAttributes);
95432
+ const error = new UserVisibleError(
95433
+ new FetchResponse(HttpStatusCode.GatewayTimeout, {
95434
+ error: "Cache miss for only-if-cached request"
95435
+ })
95436
+ );
95437
+ return err$1$1(error);
95438
+ });
95439
+ }
95440
+ get expiredChecks() {
95441
+ return [
95442
+ (cacheControlMetadata) => cacheControlMetadata.type === "no-store"
95443
+ ];
95444
+ }
95445
+ collectCacheHitInstrumentation(startTime, instrumentationAttributes) {
95446
+ if (this.services.instrumentation) {
95447
+ const meter = this.services.instrumentation.metrics.getMeter("onestore");
95448
+ meter.createCounter(`command.only-if-cached.cache-hit.count`).add(1, instrumentationAttributes);
95449
+ meter.createHistogram(
95450
+ `command.only-if-cached.cache-hit.duration`
95451
+ ).record(
95452
+ this.services.instrumentation.currentTimeMs() - startTime,
95453
+ instrumentationAttributes
95454
+ );
95455
+ }
95456
+ }
95457
+ collectCacheMissInstrumentation(startTime, instrumentationAttributes) {
95458
+ if (this.services.instrumentation) {
95459
+ const meter = this.services.instrumentation.metrics.getMeter("onestore");
95460
+ meter.createCounter(`command.only-if-cached.cache-miss.count`).add(1, instrumentationAttributes);
95461
+ meter.createHistogram(
95462
+ `command.only-if-cached.cache-miss.duration`
95463
+ ).record(
95464
+ this.services.instrumentation.currentTimeMs() - startTime,
95465
+ instrumentationAttributes
95466
+ );
95467
+ }
95468
+ }
95469
+ }
95379
95470
  class CacheController {
95380
95471
  constructor(services) {
95381
95472
  this.services = services;
@@ -95389,6 +95480,8 @@
95389
95480
  return new MaxAgeCacheControlStrategy(this.services, config, requestRunner);
95390
95481
  } else if (config.type === "no-cache") {
95391
95482
  return new NoCacheCacheControlStrategy(this.services, config, requestRunner);
95483
+ } else if (config.type === "only-if-cached") {
95484
+ return new OnlyIfCachedCacheControlStrategy(this.services, config, requestRunner);
95392
95485
  }
95393
95486
  throw new Error(`Unknown cache control strategy ${config.type}`);
95394
95487
  }
@@ -95907,7 +96000,7 @@
95907
96000
  },
95908
96001
  };
95909
96002
  }
95910
- // version: 1.380.0-dev5-27c3b66ede
96003
+ // version: 1.380.0-dev6-9d4fd6e5dc
95911
96004
 
95912
96005
  /**
95913
96006
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -95933,7 +96026,7 @@
95933
96026
  },
95934
96027
  };
95935
96028
  }
95936
- // version: 1.380.0-dev5-27c3b66ede
96029
+ // version: 1.380.0-dev6-9d4fd6e5dc
95937
96030
 
95938
96031
  /*!
95939
96032
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -98081,7 +98174,7 @@
98081
98174
  id: '@salesforce/lds-network-adapter',
98082
98175
  instrument: instrument$2,
98083
98176
  });
98084
- // version: 1.380.0-dev5-94859d35c9
98177
+ // version: 1.380.0-dev6-1891f38076
98085
98178
 
98086
98179
  const { create: create$3, keys: keys$3 } = Object;
98087
98180
  const { stringify: stringify$1, parse } = JSON;
@@ -100438,12 +100531,15 @@
100438
100531
  }
100439
100532
  console.error("OneStore Command threw an error that we did not expect", error);
100440
100533
  }
100534
+ const supportedCachePolicyTypes = ["no-cache", "only-if-cached"];
100441
100535
  function requestContextIsSupportedCachePolicy(requestContext) {
100442
- return typeof requestContext === "object" && requestContext !== null && "cachePolicy" in requestContext && typeof requestContext.cachePolicy === "object" && requestContext.cachePolicy !== null && "type" in requestContext.cachePolicy && requestContext.cachePolicy.type === "no-cache";
100536
+ return typeof requestContext === "object" && requestContext !== null && "cachePolicy" in requestContext && typeof requestContext.cachePolicy === "object" && requestContext.cachePolicy !== null && "type" in requestContext.cachePolicy && typeof requestContext.cachePolicy.type === "string" && supportedCachePolicyTypes.includes(
100537
+ requestContext.cachePolicy.type
100538
+ );
100443
100539
  }
100444
100540
  function getOverridesForLegacyRequestContext(requestContext) {
100445
100541
  if (requestContextIsSupportedCachePolicy(requestContext)) {
100446
- return { cacheControlConfig: { type: "no-cache" } };
100542
+ return { cacheControlConfig: { type: requestContext.cachePolicy.type } };
100447
100543
  }
100448
100544
  return {};
100449
100545
  }
@@ -100837,7 +100933,7 @@
100837
100933
  }
100838
100934
  callback(consumerEmittedData);
100839
100935
  }
100840
- // version: 1.380.0-dev5-27c3b66ede
100936
+ // version: 1.380.0-dev6-9d4fd6e5dc
100841
100937
 
100842
100938
  class Analytics__AnalyticsBrowseRepository extends UnidentifiableGraphQLTypeRepository {
100843
100939
  constructor(services, typeRegistry) {
@@ -104630,7 +104726,7 @@
104630
104726
  cb(graphql$1, graphql_imperative$1, useOneStoreGraphQL);
104631
104727
  }
104632
104728
  }
104633
- // version: 1.380.0-dev5-27c3b66ede
104729
+ // version: 1.380.0-dev6-9d4fd6e5dc
104634
104730
 
104635
104731
  function createFragmentMap(documentNode) {
104636
104732
  const fragments = {};
@@ -131259,7 +131355,7 @@
131259
131355
  }
131260
131356
  return refresh$3(data, 'refreshUiApi');
131261
131357
  }
131262
- // version: 1.380.0-dev5-27c3b66ede
131358
+ // version: 1.380.0-dev6-9d4fd6e5dc
131263
131359
 
131264
131360
  // On core the unstable adapters are re-exported with different names,
131265
131361
  // we want to match them here.
@@ -131411,7 +131507,7 @@
131411
131507
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
131412
131508
  graphQLImperative = ldsAdapter;
131413
131509
  });
131414
- // version: 1.380.0-dev5-27c3b66ede
131510
+ // version: 1.380.0-dev6-9d4fd6e5dc
131415
131511
 
131416
131512
  var gqlApi = /*#__PURE__*/Object.freeze({
131417
131513
  __proto__: null,
@@ -131498,15 +131594,15 @@
131498
131594
  get statusText() {
131499
131595
  const { status } = this;
131500
131596
  switch (status) {
131501
- case HttpStatusCode$1.Ok:
131597
+ case HttpStatusCode$2.Ok:
131502
131598
  return 'OK';
131503
- case HttpStatusCode$1.Created:
131599
+ case HttpStatusCode$2.Created:
131504
131600
  return 'Created';
131505
- case HttpStatusCode$1.NoContent:
131601
+ case HttpStatusCode$2.NoContent:
131506
131602
  return 'No Content';
131507
- case HttpStatusCode$1.BadRequest:
131603
+ case HttpStatusCode$2.BadRequest:
131508
131604
  return 'Bad Request';
131509
- case HttpStatusCode$1.ServerError:
131605
+ case HttpStatusCode$2.ServerError:
131510
131606
  return 'Server Error';
131511
131607
  default:
131512
131608
  return `Unexpected HTTP Status Code: ${status}`;
@@ -131523,7 +131619,7 @@
131523
131619
  }
131524
131620
  }
131525
131621
  function createNativeFetchErrorResponse(message) {
131526
- return new NativeFetchErrorResponse(HttpStatusCode$1.BadRequest, {
131622
+ return new NativeFetchErrorResponse(HttpStatusCode$2.BadRequest, {
131527
131623
  errorCode: NATIVE_ERROR_CODE,
131528
131624
  message: message,
131529
131625
  });
@@ -132210,7 +132306,7 @@
132210
132306
  function register(r) {
132211
132307
  callbacks$1.forEach((callback) => callback(r));
132212
132308
  }
132213
- // version: 1.380.0-dev5-94859d35c9
132309
+ // version: 1.380.0-dev6-1891f38076
132214
132310
 
132215
132311
  /**
132216
132312
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -133547,4 +133643,4 @@
133547
133643
  exports.subscribeToAdapter = subscribeToAdapter;
133548
133644
 
133549
133645
  }));
133550
- // version: 1.380.0-dev5-94859d35c9
133646
+ // version: 1.380.0-dev6-1891f38076
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-worker-api",
3
- "version": "1.380.0-dev5",
3
+ "version": "1.380.0-dev6",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "",
6
6
  "main": "dist/standalone/es/lds-worker-api.js",
@@ -35,14 +35,14 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@oat-sa/rollup-plugin-wildcard-external": "^1.0.0",
38
- "@salesforce/lds-adapters-graphql": "^1.380.0-dev5",
39
- "@salesforce/lds-adapters-uiapi": "^1.380.0-dev5",
40
- "@salesforce/lds-default-luvio": "^1.380.0-dev5",
41
- "@salesforce/lds-drafts": "^1.380.0-dev5",
42
- "@salesforce/lds-graphql-parser": "^1.380.0-dev5",
43
- "@salesforce/lds-luvio-engine": "^1.380.0-dev5",
44
- "@salesforce/lds-runtime-mobile": "^1.380.0-dev5",
45
- "@salesforce/nimbus-plugin-lds": "^1.380.0-dev5",
38
+ "@salesforce/lds-adapters-graphql": "^1.380.0-dev6",
39
+ "@salesforce/lds-adapters-uiapi": "^1.380.0-dev6",
40
+ "@salesforce/lds-default-luvio": "^1.380.0-dev6",
41
+ "@salesforce/lds-drafts": "^1.380.0-dev6",
42
+ "@salesforce/lds-graphql-parser": "^1.380.0-dev6",
43
+ "@salesforce/lds-luvio-engine": "^1.380.0-dev6",
44
+ "@salesforce/lds-runtime-mobile": "^1.380.0-dev6",
45
+ "@salesforce/nimbus-plugin-lds": "^1.380.0-dev6",
46
46
  "ajv": "^8.11.0",
47
47
  "glob": "^7.1.5",
48
48
  "nimbus-types": "^2.0.0-alpha1",