@salesforce/lds-runtime-aura 1.386.0 → 1.388.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.
@@ -12,7 +12,7 @@
12
12
  * *******************************************************************************************
13
13
  */
14
14
  /* proxy-compat-disable */
15
- import { HttpStatusCode as HttpStatusCode$1, InMemoryStore, Environment, Luvio, InMemoryStoreQueryEvaluator } from 'force/luvioEngine';
15
+ import { HttpStatusCode as HttpStatusCode$2, InMemoryStore, Environment, Luvio, InMemoryStoreQueryEvaluator } from 'force/luvioEngine';
16
16
  import ldsTrackedFieldsBehaviorGate from '@salesforce/gate/lds.useNewTrackedFieldBehavior';
17
17
  import usePredictiveLoading from '@salesforce/gate/lds.usePredictiveLoading';
18
18
  import useApexPredictions from '@salesforce/gate/lds.pdl.useApexPredictions';
@@ -215,6 +215,60 @@ function toError(x) {
215
215
  }
216
216
  return new Error(typeof x === "string" ? x : JSON.stringify(x));
217
217
  }
218
+ var HttpStatusCode$1 = /* @__PURE__ */ ((HttpStatusCode2) => {
219
+ HttpStatusCode2[HttpStatusCode2["Ok"] = 200] = "Ok";
220
+ HttpStatusCode2[HttpStatusCode2["Created"] = 201] = "Created";
221
+ HttpStatusCode2[HttpStatusCode2["NoContent"] = 204] = "NoContent";
222
+ HttpStatusCode2[HttpStatusCode2["NotModified"] = 304] = "NotModified";
223
+ HttpStatusCode2[HttpStatusCode2["BadRequest"] = 400] = "BadRequest";
224
+ HttpStatusCode2[HttpStatusCode2["Unauthorized"] = 401] = "Unauthorized";
225
+ HttpStatusCode2[HttpStatusCode2["Forbidden"] = 403] = "Forbidden";
226
+ HttpStatusCode2[HttpStatusCode2["NotFound"] = 404] = "NotFound";
227
+ HttpStatusCode2[HttpStatusCode2["ServerError"] = 500] = "ServerError";
228
+ HttpStatusCode2[HttpStatusCode2["GatewayTimeout"] = 504] = "GatewayTimeout";
229
+ return HttpStatusCode2;
230
+ })(HttpStatusCode$1 || {});
231
+ async function coerceResponseToFetchResponse(response) {
232
+ const { status } = response;
233
+ const responseHeaders = {};
234
+ response.headers.forEach((value, key) => {
235
+ responseHeaders[key] = value;
236
+ });
237
+ let responseBody = null;
238
+ if (status !== 204) {
239
+ const contentType = responseHeaders["content-type"];
240
+ responseBody = contentType && contentType.startsWith("application/json") ? await response.json() : await response.text();
241
+ }
242
+ return new FetchResponse(status, responseBody, responseHeaders);
243
+ }
244
+ function getStatusText(status) {
245
+ switch (status) {
246
+ case 200:
247
+ return "OK";
248
+ case 201:
249
+ return "Created";
250
+ case 304:
251
+ return "Not Modified";
252
+ case 400:
253
+ return "Bad Request";
254
+ case 404:
255
+ return "Not Found";
256
+ case 500:
257
+ return "Server Error";
258
+ default:
259
+ return `Unexpected HTTP Status Code: ${status}`;
260
+ }
261
+ }
262
+ class FetchResponse extends Error {
263
+ constructor(status, body, headers) {
264
+ super();
265
+ this.status = status;
266
+ this.body = body;
267
+ this.headers = headers || {};
268
+ this.ok = status >= 200 && this.status <= 299;
269
+ this.statusText = getStatusText(status);
270
+ }
271
+ }
218
272
  class InternalError extends Error {
219
273
  constructor(data) {
220
274
  super();
@@ -734,7 +788,7 @@ class CacheControlCommand extends BaseCommand {
734
788
  */
735
789
  buildSubscribe() {
736
790
  return (consumerCallback) => {
737
- if (this.subscriptions.length === 0 && this.operationType === "query") {
791
+ if (this.subscriptions.length === 0 && (this.operationType === "query" || this.operationType === "graphql")) {
738
792
  this.subscribeToKeysUsed();
739
793
  }
740
794
  this.subscriptions.push(consumerCallback);
@@ -898,9 +952,6 @@ class AuraResourceCacheControlCommand extends AuraCacheControlCommand$1 {
898
952
  super(services);
899
953
  this.services = services;
900
954
  }
901
- execute() {
902
- return super.execute();
903
- }
904
955
  readFromCache(cache) {
905
956
  var _a;
906
957
  const data = (_a = cache.get(this.buildKey())) == null ? void 0 : _a.value;
@@ -2076,6 +2127,59 @@ class MaxAgeCacheControlStrategy extends CacheControlStrategy {
2076
2127
  ];
2077
2128
  }
2078
2129
  }
2130
+ class OnlyIfCachedCacheControlStrategy extends CacheControlStrategy {
2131
+ execute(options) {
2132
+ const startTime = this.services.instrumentation ? this.services.instrumentation.currentTimeMs() : 0;
2133
+ return this.services.cacheInclusionPolicy.read({
2134
+ l1: this.filteredCache,
2135
+ readFromL1: (l1) => this.requestRunner.readFromCache(l1)
2136
+ }).then((result) => {
2137
+ if (result.isOk()) {
2138
+ this.collectCacheHitInstrumentation(
2139
+ startTime,
2140
+ options == null ? void 0 : options.instrumentationAttributes
2141
+ );
2142
+ return ok$2(void 0);
2143
+ }
2144
+ this.collectCacheMissInstrumentation(startTime, options == null ? void 0 : options.instrumentationAttributes);
2145
+ const error = new UserVisibleError(
2146
+ new FetchResponse(HttpStatusCode$1.GatewayTimeout, {
2147
+ error: "Cache miss for only-if-cached request"
2148
+ })
2149
+ );
2150
+ return err$1(error);
2151
+ });
2152
+ }
2153
+ get expiredChecks() {
2154
+ return [
2155
+ (cacheControlMetadata) => cacheControlMetadata.type === "no-store"
2156
+ ];
2157
+ }
2158
+ collectCacheHitInstrumentation(startTime, instrumentationAttributes) {
2159
+ if (this.services.instrumentation) {
2160
+ const meter = this.services.instrumentation.metrics.getMeter("onestore");
2161
+ meter.createCounter(`command.only-if-cached.cache-hit.count`).add(1, instrumentationAttributes);
2162
+ meter.createHistogram(
2163
+ `command.only-if-cached.cache-hit.duration`
2164
+ ).record(
2165
+ this.services.instrumentation.currentTimeMs() - startTime,
2166
+ instrumentationAttributes
2167
+ );
2168
+ }
2169
+ }
2170
+ collectCacheMissInstrumentation(startTime, instrumentationAttributes) {
2171
+ if (this.services.instrumentation) {
2172
+ const meter = this.services.instrumentation.metrics.getMeter("onestore");
2173
+ meter.createCounter(`command.only-if-cached.cache-miss.count`).add(1, instrumentationAttributes);
2174
+ meter.createHistogram(
2175
+ `command.only-if-cached.cache-miss.duration`
2176
+ ).record(
2177
+ this.services.instrumentation.currentTimeMs() - startTime,
2178
+ instrumentationAttributes
2179
+ );
2180
+ }
2181
+ }
2182
+ }
2079
2183
  class CacheController {
2080
2184
  constructor(services) {
2081
2185
  this.services = services;
@@ -2089,6 +2193,8 @@ class CacheController {
2089
2193
  return new MaxAgeCacheControlStrategy(this.services, config, requestRunner);
2090
2194
  } else if (config.type === "no-cache") {
2091
2195
  return new NoCacheCacheControlStrategy(this.services, config, requestRunner);
2196
+ } else if (config.type === "only-if-cached") {
2197
+ return new OnlyIfCachedCacheControlStrategy(this.services, config, requestRunner);
2092
2198
  }
2093
2199
  throw new Error(`Unknown cache control strategy ${config.type}`);
2094
2200
  }
@@ -2330,7 +2436,7 @@ function buildServiceDescriptor$5(luvio) {
2330
2436
  },
2331
2437
  };
2332
2438
  }
2333
- // version: 1.386.0-521094e838
2439
+ // version: 1.388.0-fabb0e5a71
2334
2440
 
2335
2441
  /*!
2336
2442
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -2640,7 +2746,7 @@ function buildServiceDescriptor$1(notifyRecordUpdateAvailable, getNormalizedLuvi
2640
2746
  },
2641
2747
  };
2642
2748
  }
2643
- // version: 1.386.0-521094e838
2749
+ // version: 1.388.0-fabb0e5a71
2644
2750
 
2645
2751
  /*!
2646
2752
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -3280,7 +3386,7 @@ const platformSfapJwtResolver = {
3280
3386
  }
3281
3387
  // AuraFetchResponse errors
3282
3388
  const { status } = error;
3283
- if (status !== HttpStatusCode$1.ServerError) {
3389
+ if (status !== HttpStatusCode$2.ServerError) {
3284
3390
  // ConnectInJavaError
3285
3391
  reject(error.body.message);
3286
3392
  return;
@@ -6142,7 +6248,7 @@ function getEnvironmentSetting(name) {
6142
6248
  }
6143
6249
  return undefined;
6144
6250
  }
6145
- // version: 1.386.0-521094e838
6251
+ // version: 1.388.0-fabb0e5a71
6146
6252
 
6147
6253
  const forceRecordTransactionsDisabled = getEnvironmentSetting(EnvironmentSettings.ForceRecordTransactionsDisabled);
6148
6254
  //TODO: Some duplication here that can be most likely moved to a util class
@@ -6740,44 +6846,41 @@ function buildInMemoryCacheInclusionPolicyService(cache) {
6740
6846
  };
6741
6847
  }
6742
6848
 
6849
+ function buildLexRuntimeAuthExpirationRedirectResponseInterceptor(logger) {
6850
+ return async (response) => {
6851
+ if (response.status === 401) {
6852
+ try {
6853
+ const coercedResponse = (await coerceResponseToFetchResponse(response.clone()));
6854
+ if (coercedResponse.body.errorCode === 'INVALID_SESSION_ID') {
6855
+ logger.warn(`Received ${response.status} status code from LEX runtime service`);
6856
+ // Fire the event asynchronously, similar to the legacy setTimeout pattern
6857
+ window.setTimeout(() => {
6858
+ window?.$A?.get('e.aura:invalidSession').fire();
6859
+ }, 0);
6860
+ }
6861
+ }
6862
+ catch (error) {
6863
+ logger.warn(`Error parsing response from LEX runtime service: ${error}`);
6864
+ }
6865
+ }
6866
+ return response;
6867
+ };
6868
+ }
6869
+
6743
6870
  function buildLexRuntimeFetchServiceDescriptor(logger) {
6744
6871
  const fetchService = buildServiceDescriptor({
6745
6872
  request: [],
6746
- response: [buildLexRuntimeResponseInterceptor(logger)],
6873
+ response: [
6874
+ // TODO: Revisit after ADR for 5xx error propagation in W-19363628
6875
+ // buildLexRuntime5xxStatusResponseInterceptor(logger),
6876
+ buildLexRuntimeAuthExpirationRedirectResponseInterceptor(logger),
6877
+ ],
6747
6878
  });
6748
6879
  return {
6749
6880
  ...fetchService,
6750
6881
  tags: { runtimeInterceptors: 'lex_runtime_interceptors' },
6751
6882
  };
6752
6883
  }
6753
- function buildLexRuntimeResponseInterceptor(logger) {
6754
- return async (response) => {
6755
- if (response.status >= 500 && response.status < 600) {
6756
- logger.warn(`Received ${response.status} status code from LEX runtime service`);
6757
- // Create an error object similar to Aura's current shape for system errors
6758
- const error = {
6759
- message: `Runtime Error: ${response.status} ${response.statusText}`,
6760
- severity: 'ALERT',
6761
- name: 'LEXRuntimeError',
6762
- stack: null,
6763
- handled: false,
6764
- reported: false,
6765
- };
6766
- const evtArgs = {
6767
- message: error.message,
6768
- error: null,
6769
- auraError: error,
6770
- };
6771
- // Fire the event asynchronously, similar to the legacy setTimeout pattern
6772
- window.setTimeout(() => {
6773
- if (window && window.$A && window.$A.eventService) {
6774
- window.$A.eventService.getNewEvent('markup://aura:systemError').fire(evtArgs);
6775
- }
6776
- }, 0);
6777
- }
6778
- return response;
6779
- };
6780
- }
6781
6884
 
6782
6885
  // This code *should* be in lds-network-adapter, but when combined with the Aura
6783
6886
  // component test workaround in lds-default-luvio it creates a circular dependecy
@@ -7109,4 +7212,4 @@ function ldsEngineCreator() {
7109
7212
  }
7110
7213
 
7111
7214
  export { LexRequestStrategy, PdlRequestPriority, buildPredictorForContext, ldsEngineCreator as default, initializeLDS, initializeOneStore, notifyUpdateAvailableFactory, registerRequestStrategy, saveRequestAsPrediction, unregisterRequestStrategy, whenPredictionsReady };
7112
- // version: 1.386.0-667e615528
7215
+ // version: 1.388.0-d914c9e6b5
@@ -1,17 +1,3 @@
1
1
  import { type LoggerService } from '@luvio/utils';
2
- import { type FetchServiceDescriptor, type ResponseInterceptor } from '@luvio/service-fetch-network/v1';
3
- export type LexRuntimeError = {
4
- message: string;
5
- severity: string;
6
- name: string;
7
- stack: string | null;
8
- handled: boolean;
9
- reported: boolean;
10
- };
11
- export type LexErrorEventArgs = {
12
- message: string;
13
- error: string | null;
14
- auraError: LexRuntimeError;
15
- };
2
+ import { type FetchServiceDescriptor } from '@luvio/service-fetch-network/v1';
16
3
  export declare function buildLexRuntimeFetchServiceDescriptor(logger: LoggerService): FetchServiceDescriptor;
17
- export declare function buildLexRuntimeResponseInterceptor(logger: LoggerService): ResponseInterceptor;
@@ -0,0 +1,16 @@
1
+ import { LoggerService } from '@luvio/utils';
2
+ import { ResponseInterceptor } from '@luvio/service-fetch-network/v1';
3
+ export type LexRuntimeError = {
4
+ message: string;
5
+ severity: string;
6
+ name: string;
7
+ stack: string | null;
8
+ handled: boolean;
9
+ reported: boolean;
10
+ };
11
+ export type LexErrorEventArgs = {
12
+ message: string;
13
+ error: string | null;
14
+ auraError: LexRuntimeError;
15
+ };
16
+ export declare function buildLexRuntime5xxStatusResponseInterceptor(logger: LoggerService): ResponseInterceptor;
@@ -0,0 +1,3 @@
1
+ import { LoggerService } from '@luvio/utils';
2
+ import { ResponseInterceptor } from '@luvio/service-fetch-network/v1';
3
+ export declare function buildLexRuntimeAuthExpirationRedirectResponseInterceptor(logger: LoggerService): ResponseInterceptor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-aura",
3
- "version": "1.386.0",
3
+ "version": "1.388.0",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS engine for Aura runtime",
6
6
  "main": "dist/ldsEngineCreator.js",
@@ -34,47 +34,47 @@
34
34
  "release:corejar": "yarn build && ../core-build/scripts/core.js --name=lds-runtime-aura"
35
35
  },
36
36
  "devDependencies": {
37
- "@luvio/service-provisioner": "5.59.0",
38
- "@luvio/tools-core": "5.59.0",
39
- "@salesforce/lds-adapters-apex": "^1.386.0",
40
- "@salesforce/lds-adapters-uiapi": "^1.386.0",
41
- "@salesforce/lds-ads-bridge": "^1.386.0",
42
- "@salesforce/lds-aura-storage": "^1.386.0",
43
- "@salesforce/lds-bindings": "^1.386.0",
44
- "@salesforce/lds-instrumentation": "^1.386.0",
45
- "@salesforce/lds-network-aura": "^1.386.0",
46
- "@salesforce/lds-network-fetch": "^1.386.0",
37
+ "@luvio/service-provisioner": "5.61.0",
38
+ "@luvio/tools-core": "5.61.0",
39
+ "@salesforce/lds-adapters-apex": "^1.388.0",
40
+ "@salesforce/lds-adapters-uiapi": "^1.388.0",
41
+ "@salesforce/lds-ads-bridge": "^1.388.0",
42
+ "@salesforce/lds-aura-storage": "^1.388.0",
43
+ "@salesforce/lds-bindings": "^1.388.0",
44
+ "@salesforce/lds-instrumentation": "^1.388.0",
45
+ "@salesforce/lds-network-aura": "^1.388.0",
46
+ "@salesforce/lds-network-fetch": "^1.388.0",
47
47
  "jwt-encode": "1.0.1"
48
48
  },
49
49
  "dependencies": {
50
- "@luvio/command-aura-graphql-normalized-cache-control": "5.59.0",
51
- "@luvio/command-aura-network": "5.59.0",
52
- "@luvio/command-aura-normalized-cache-control": "5.59.0",
53
- "@luvio/command-aura-resource-cache-control": "5.59.0",
54
- "@luvio/command-fetch-network": "5.59.0",
55
- "@luvio/command-http-graphql-normalized-cache-control": "5.59.0",
56
- "@luvio/command-http-normalized-cache-control": "5.59.0",
57
- "@luvio/command-ndjson": "5.59.0",
58
- "@luvio/command-network": "5.59.0",
59
- "@luvio/command-sse": "5.59.0",
60
- "@luvio/command-streaming": "5.59.0",
50
+ "@luvio/command-aura-graphql-normalized-cache-control": "5.61.0",
51
+ "@luvio/command-aura-network": "5.61.0",
52
+ "@luvio/command-aura-normalized-cache-control": "5.61.0",
53
+ "@luvio/command-aura-resource-cache-control": "5.61.0",
54
+ "@luvio/command-fetch-network": "5.61.0",
55
+ "@luvio/command-http-graphql-normalized-cache-control": "5.61.0",
56
+ "@luvio/command-http-normalized-cache-control": "5.61.0",
57
+ "@luvio/command-ndjson": "5.61.0",
58
+ "@luvio/command-network": "5.61.0",
59
+ "@luvio/command-sse": "5.61.0",
60
+ "@luvio/command-streaming": "5.61.0",
61
61
  "@luvio/network-adapter-composable": "0.158.7",
62
62
  "@luvio/network-adapter-fetch": "0.158.7",
63
- "@luvio/service-aura-network": "5.59.0",
64
- "@luvio/service-cache": "5.59.0",
65
- "@luvio/service-cache-control": "5.59.0",
66
- "@luvio/service-cache-inclusion-policy": "5.59.0",
67
- "@luvio/service-feature-flags": "5.59.0",
68
- "@luvio/service-fetch-network": "5.59.0",
69
- "@luvio/service-instrument-command": "5.59.0",
70
- "@luvio/service-pubsub": "5.59.0",
71
- "@luvio/service-store": "5.59.0",
72
- "@luvio/utils": "5.59.0",
63
+ "@luvio/service-aura-network": "5.61.0",
64
+ "@luvio/service-cache": "5.61.0",
65
+ "@luvio/service-cache-control": "5.61.0",
66
+ "@luvio/service-cache-inclusion-policy": "5.61.0",
67
+ "@luvio/service-feature-flags": "5.61.0",
68
+ "@luvio/service-fetch-network": "5.61.0",
69
+ "@luvio/service-instrument-command": "5.61.0",
70
+ "@luvio/service-pubsub": "5.61.0",
71
+ "@luvio/service-store": "5.61.0",
72
+ "@luvio/utils": "5.61.0",
73
73
  "@lwc/state": "^0.23.0",
74
- "@salesforce/lds-adapters-onestore-graphql": "^1.386.0",
75
- "@salesforce/lds-adapters-uiapi-lex": "^1.386.0",
76
- "@salesforce/lds-luvio-service": "^1.386.0",
77
- "@salesforce/lds-luvio-uiapi-records-service": "^1.386.0"
74
+ "@salesforce/lds-adapters-onestore-graphql": "^1.388.0",
75
+ "@salesforce/lds-adapters-uiapi-lex": "^1.388.0",
76
+ "@salesforce/lds-luvio-service": "^1.388.0",
77
+ "@salesforce/lds-luvio-uiapi-records-service": "^1.388.0"
78
78
  },
79
79
  "luvioBundlesize": [
80
80
  {