@salesforce/lds-runtime-webruntime 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.
@@ -196,6 +196,47 @@ function toError(x) {
196
196
  }
197
197
  return new Error(typeof x === "string" ? x : JSON.stringify(x));
198
198
  }
199
+ var HttpStatusCode = /* @__PURE__ */ ((HttpStatusCode2) => {
200
+ HttpStatusCode2[HttpStatusCode2["Ok"] = 200] = "Ok";
201
+ HttpStatusCode2[HttpStatusCode2["Created"] = 201] = "Created";
202
+ HttpStatusCode2[HttpStatusCode2["NoContent"] = 204] = "NoContent";
203
+ HttpStatusCode2[HttpStatusCode2["NotModified"] = 304] = "NotModified";
204
+ HttpStatusCode2[HttpStatusCode2["BadRequest"] = 400] = "BadRequest";
205
+ HttpStatusCode2[HttpStatusCode2["Unauthorized"] = 401] = "Unauthorized";
206
+ HttpStatusCode2[HttpStatusCode2["Forbidden"] = 403] = "Forbidden";
207
+ HttpStatusCode2[HttpStatusCode2["NotFound"] = 404] = "NotFound";
208
+ HttpStatusCode2[HttpStatusCode2["ServerError"] = 500] = "ServerError";
209
+ HttpStatusCode2[HttpStatusCode2["GatewayTimeout"] = 504] = "GatewayTimeout";
210
+ return HttpStatusCode2;
211
+ })(HttpStatusCode || {});
212
+ function getStatusText(status) {
213
+ switch (status) {
214
+ case 200:
215
+ return "OK";
216
+ case 201:
217
+ return "Created";
218
+ case 304:
219
+ return "Not Modified";
220
+ case 400:
221
+ return "Bad Request";
222
+ case 404:
223
+ return "Not Found";
224
+ case 500:
225
+ return "Server Error";
226
+ default:
227
+ return `Unexpected HTTP Status Code: ${status}`;
228
+ }
229
+ }
230
+ class FetchResponse extends Error {
231
+ constructor(status, body, headers) {
232
+ super();
233
+ this.status = status;
234
+ this.body = body;
235
+ this.headers = headers || {};
236
+ this.ok = status >= 200 && this.status <= 299;
237
+ this.statusText = getStatusText(status);
238
+ }
239
+ }
199
240
  class InternalError extends Error {
200
241
  constructor(data) {
201
242
  super();
@@ -879,9 +920,6 @@ class AuraResourceCacheControlCommand extends AuraCacheControlCommand$1 {
879
920
  super(services);
880
921
  this.services = services;
881
922
  }
882
- execute() {
883
- return super.execute();
884
- }
885
923
  readFromCache(cache) {
886
924
  var _a;
887
925
  const data = (_a = cache.get(this.buildKey())) == null ? void 0 : _a.value;
@@ -2057,6 +2095,59 @@ class MaxAgeCacheControlStrategy extends CacheControlStrategy {
2057
2095
  ];
2058
2096
  }
2059
2097
  }
2098
+ class OnlyIfCachedCacheControlStrategy extends CacheControlStrategy {
2099
+ execute(options) {
2100
+ const startTime = this.services.instrumentation ? this.services.instrumentation.currentTimeMs() : 0;
2101
+ return this.services.cacheInclusionPolicy.read({
2102
+ l1: this.filteredCache,
2103
+ readFromL1: (l1) => this.requestRunner.readFromCache(l1)
2104
+ }).then((result) => {
2105
+ if (result.isOk()) {
2106
+ this.collectCacheHitInstrumentation(
2107
+ startTime,
2108
+ options == null ? void 0 : options.instrumentationAttributes
2109
+ );
2110
+ return ok$2(void 0);
2111
+ }
2112
+ this.collectCacheMissInstrumentation(startTime, options == null ? void 0 : options.instrumentationAttributes);
2113
+ const error = new UserVisibleError(
2114
+ new FetchResponse(HttpStatusCode.GatewayTimeout, {
2115
+ error: "Cache miss for only-if-cached request"
2116
+ })
2117
+ );
2118
+ return err$1(error);
2119
+ });
2120
+ }
2121
+ get expiredChecks() {
2122
+ return [
2123
+ (cacheControlMetadata) => cacheControlMetadata.type === "no-store"
2124
+ ];
2125
+ }
2126
+ collectCacheHitInstrumentation(startTime, instrumentationAttributes) {
2127
+ if (this.services.instrumentation) {
2128
+ const meter = this.services.instrumentation.metrics.getMeter("onestore");
2129
+ meter.createCounter(`command.only-if-cached.cache-hit.count`).add(1, instrumentationAttributes);
2130
+ meter.createHistogram(
2131
+ `command.only-if-cached.cache-hit.duration`
2132
+ ).record(
2133
+ this.services.instrumentation.currentTimeMs() - startTime,
2134
+ instrumentationAttributes
2135
+ );
2136
+ }
2137
+ }
2138
+ collectCacheMissInstrumentation(startTime, instrumentationAttributes) {
2139
+ if (this.services.instrumentation) {
2140
+ const meter = this.services.instrumentation.metrics.getMeter("onestore");
2141
+ meter.createCounter(`command.only-if-cached.cache-miss.count`).add(1, instrumentationAttributes);
2142
+ meter.createHistogram(
2143
+ `command.only-if-cached.cache-miss.duration`
2144
+ ).record(
2145
+ this.services.instrumentation.currentTimeMs() - startTime,
2146
+ instrumentationAttributes
2147
+ );
2148
+ }
2149
+ }
2150
+ }
2060
2151
  class CacheController {
2061
2152
  constructor(services) {
2062
2153
  this.services = services;
@@ -2070,6 +2161,8 @@ class CacheController {
2070
2161
  return new MaxAgeCacheControlStrategy(this.services, config, requestRunner);
2071
2162
  } else if (config.type === "no-cache") {
2072
2163
  return new NoCacheCacheControlStrategy(this.services, config, requestRunner);
2164
+ } else if (config.type === "only-if-cached") {
2165
+ return new OnlyIfCachedCacheControlStrategy(this.services, config, requestRunner);
2073
2166
  }
2074
2167
  throw new Error(`Unknown cache control strategy ${config.type}`);
2075
2168
  }
@@ -3717,7 +3810,7 @@ function buildServiceDescriptor$2(luvio) {
3717
3810
  },
3718
3811
  };
3719
3812
  }
3720
- // version: 1.380.0-dev5-27c3b66ede
3813
+ // version: 1.380.0-dev6-9d4fd6e5dc
3721
3814
 
3722
3815
  /**
3723
3816
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -3743,7 +3836,7 @@ function buildServiceDescriptor$1(notifyRecordUpdateAvailable, getNormalizedLuvi
3743
3836
  },
3744
3837
  };
3745
3838
  }
3746
- // version: 1.380.0-dev5-27c3b66ede
3839
+ // version: 1.380.0-dev6-9d4fd6e5dc
3747
3840
 
3748
3841
  /*!
3749
3842
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -4363,4 +4456,4 @@ const services = [
4363
4456
  buildServiceDescriptor$1({}, {}),
4364
4457
  ];
4365
4458
  setServices(services);
4366
- // version: 1.380.0-dev5-94859d35c9
4459
+ // version: 1.380.0-dev6-1891f38076
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-webruntime",
3
- "version": "1.380.0-dev5",
3
+ "version": "1.380.0-dev6",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS engine for Webruntime runtime",
6
6
  "main": "dist/ldsWebruntimeOneStoreInit.js",
@@ -35,35 +35,35 @@
35
35
  "ready": "yarn build && jest --collectCoverage && yarn test:size && yarn release:corejar"
36
36
  },
37
37
  "devDependencies": {
38
- "@luvio/service-provisioner": "5.59.0",
39
- "@luvio/tools-core": "5.59.0",
38
+ "@luvio/service-provisioner": "5.60.0-dev1",
39
+ "@luvio/tools-core": "5.60.0-dev1",
40
40
  "jwt-encode": "1.0.1"
41
41
  },
42
42
  "dependencies": {
43
- "@luvio/command-aura-network": "5.59.0",
44
- "@luvio/command-aura-normalized-cache-control": "5.59.0",
45
- "@luvio/command-aura-resource-cache-control": "5.59.0",
46
- "@luvio/command-fetch-network": "5.59.0",
47
- "@luvio/command-http-normalized-cache-control": "5.59.0",
48
- "@luvio/command-ndjson": "5.59.0",
49
- "@luvio/command-network": "5.59.0",
50
- "@luvio/command-sse": "5.59.0",
51
- "@luvio/command-streaming": "5.59.0",
52
- "@luvio/jwt-manager": "5.59.0",
43
+ "@luvio/command-aura-network": "5.60.0-dev1",
44
+ "@luvio/command-aura-normalized-cache-control": "5.60.0-dev1",
45
+ "@luvio/command-aura-resource-cache-control": "5.60.0-dev1",
46
+ "@luvio/command-fetch-network": "5.60.0-dev1",
47
+ "@luvio/command-http-normalized-cache-control": "5.60.0-dev1",
48
+ "@luvio/command-ndjson": "5.60.0-dev1",
49
+ "@luvio/command-network": "5.60.0-dev1",
50
+ "@luvio/command-sse": "5.60.0-dev1",
51
+ "@luvio/command-streaming": "5.60.0-dev1",
52
+ "@luvio/jwt-manager": "5.60.0-dev1",
53
53
  "@luvio/network-adapter-composable": "0.158.7",
54
54
  "@luvio/network-adapter-fetch": "0.158.7",
55
- "@luvio/service-aura-network": "5.59.0",
56
- "@luvio/service-cache": "5.59.0",
57
- "@luvio/service-cache-control": "5.59.0",
58
- "@luvio/service-cache-inclusion-policy": "5.59.0",
59
- "@luvio/service-fetch-network": "5.59.0",
60
- "@luvio/service-instrument-command": "5.59.0",
61
- "@luvio/service-pubsub": "5.59.0",
62
- "@luvio/service-store": "5.59.0",
63
- "@luvio/utils": "5.59.0",
64
- "@salesforce/lds-adapters-uiapi-lex": "^1.380.0-dev5",
65
- "@salesforce/lds-luvio-service": "^1.380.0-dev5",
66
- "@salesforce/lds-luvio-uiapi-records-service": "^1.380.0-dev5"
55
+ "@luvio/service-aura-network": "5.60.0-dev1",
56
+ "@luvio/service-cache": "5.60.0-dev1",
57
+ "@luvio/service-cache-control": "5.60.0-dev1",
58
+ "@luvio/service-cache-inclusion-policy": "5.60.0-dev1",
59
+ "@luvio/service-fetch-network": "5.60.0-dev1",
60
+ "@luvio/service-instrument-command": "5.60.0-dev1",
61
+ "@luvio/service-pubsub": "5.60.0-dev1",
62
+ "@luvio/service-store": "5.60.0-dev1",
63
+ "@luvio/utils": "5.60.0-dev1",
64
+ "@salesforce/lds-adapters-uiapi-lex": "^1.380.0-dev6",
65
+ "@salesforce/lds-luvio-service": "^1.380.0-dev6",
66
+ "@salesforce/lds-luvio-uiapi-records-service": "^1.380.0-dev6"
67
67
  },
68
68
  "luvioBundlesize": [
69
69
  {