@salesforce/lds-runtime-aura 1.380.0-dev4 → 1.380.0-dev5

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.
Files changed (2) hide show
  1. package/dist/ldsEngineCreator.js +121 -110
  2. package/package.json +36 -36
@@ -109,18 +109,24 @@ let Err$1 = class Err {
109
109
  };
110
110
  const ok$2 = (value) => new Ok$2(value);
111
111
  const err$1 = (err2) => new Err$1(err2);
112
+ function isResult(value) {
113
+ return value != null && typeof value === "object" && "isOk" in value && "isErr" in value && typeof value.isOk === "function" && typeof value.isErr === "function" && (value.isOk() === true && value.isErr() === false && "value" in value || value.isOk() === false && value.isErr() === true && "error" in value);
114
+ }
115
+ function isSubscribable(obj) {
116
+ return typeof obj === "object" && obj !== null && "subscribe" in obj && typeof obj.subscribe === "function" && "refresh" in obj && typeof obj.refresh === "function";
117
+ }
112
118
  function isSubscribableResult(x) {
113
- if (typeof x !== "object" || x === null) {
119
+ if (!isResult(x)) {
114
120
  return false;
115
121
  }
116
- if ("isOk" in x && typeof x.isOk === "function") {
117
- if (x.isOk()) {
118
- return "value" in x && typeof x.value === "object" && x.value !== null && "subscribe" in x.value && typeof x.value.subscribe === "function" && "refresh" in x.value && typeof x.value.refresh === "function";
119
- } else {
120
- return "error" in x;
121
- }
122
+ return isSubscribable(x.isOk() ? x.value : x.error);
123
+ }
124
+ function buildSubscribableResult$1(result, subscribe, refresh) {
125
+ if (result.isOk()) {
126
+ return ok$2({ data: result.value, subscribe, refresh });
127
+ } else {
128
+ return err$1({ failure: result.error, subscribe, refresh });
122
129
  }
123
- return false;
124
130
  }
125
131
  function resolvedPromiseLike$3(result) {
126
132
  if (isPromiseLike$3(result)) {
@@ -252,35 +258,27 @@ let NetworkCommand$1 = class NetworkCommand extends BaseCommand {
252
258
  }
253
259
  fetchSubscribableResult(res) {
254
260
  return res.then((networkResult) => {
255
- if (networkResult.isErr()) {
256
- return err$1(networkResult.error);
257
- } else {
258
- const data = networkResult.value;
259
- return ok$2({
260
- data,
261
- subscribe: (cb) => {
262
- this.subscriptions.push(cb);
263
- return () => {
264
- this.subscriptions = this.subscriptions.filter((cb2) => cb2 !== cb);
265
- };
266
- },
267
- refresh: () => this.refresh()
268
- });
269
- }
261
+ return buildSubscribableResult$1(
262
+ networkResult,
263
+ (cb) => {
264
+ this.subscriptions.push(cb);
265
+ return () => {
266
+ this.subscriptions = this.subscriptions.filter((cb2) => cb2 !== cb);
267
+ };
268
+ },
269
+ () => this.refresh()
270
+ );
270
271
  });
271
272
  }
272
273
  refresh() {
273
274
  return this.execute().then((newResult) => {
274
- if (newResult.isOk()) {
275
- if (isSubscribableResult(newResult)) {
276
- const value = newResult.value;
277
- this.subscriptions.forEach((cb) => {
278
- cb(ok$2(value.data));
279
- });
280
- }
281
- return ok$2(void 0);
275
+ if (isSubscribableResult(newResult)) {
276
+ const value = newResult.isOk() ? ok$2(newResult.value.data) : err$1(newResult.error.failure);
277
+ this.subscriptions.forEach((cb) => {
278
+ cb(value);
279
+ });
282
280
  }
283
- return err$1(newResult.error);
281
+ return ok$2(void 0);
284
282
  });
285
283
  }
286
284
  async afterRequestHooks(_options) {
@@ -431,6 +429,13 @@ class Err {
431
429
  }
432
430
  const ok$1 = (value) => new Ok$1(value);
433
431
  const err = (err2) => new Err(err2);
432
+ function buildSubscribableResult(result, subscribe, refresh) {
433
+ if (result.isOk()) {
434
+ return ok$1({ data: result.value, subscribe, refresh });
435
+ } else {
436
+ return err({ failure: result.error, subscribe, refresh });
437
+ }
438
+ }
434
439
  function resolvedPromiseLike$2(result) {
435
440
  if (isPromiseLike$2(result)) {
436
441
  return result.then((nextResult) => nextResult);
@@ -530,7 +535,7 @@ class CacheControlRequestRunner {
530
535
  const resultPromise = this.readFromCacheInternal(cache);
531
536
  return resultPromise.then((result) => {
532
537
  if (result.isErr()) {
533
- return err(result.error);
538
+ return err(result.error.failure);
534
539
  }
535
540
  this.returnData = result;
536
541
  return ok$1(void 0);
@@ -538,7 +543,7 @@ class CacheControlRequestRunner {
538
543
  }
539
544
  requestFromNetwork() {
540
545
  const that = this;
541
- return async function* () {
546
+ return (async function* () {
542
547
  const result = await that.requestFromNetworkInternal();
543
548
  if (result.isErr()) {
544
549
  that.networkError = result;
@@ -546,7 +551,7 @@ class CacheControlRequestRunner {
546
551
  that.networkData = result;
547
552
  }
548
553
  yield result;
549
- }();
554
+ })();
550
555
  }
551
556
  writeToCache(cache, networkResult) {
552
557
  return this.writeToCacheInternal(cache, networkResult);
@@ -559,7 +564,7 @@ class CacheControlCommand extends BaseCommand {
559
564
  this.keysUsed = /* @__PURE__ */ new Set();
560
565
  this.keysUpdated = void 0;
561
566
  this.operationType = "query";
562
- this.lastEmittedData = void 0;
567
+ this.lastResult = void 0;
563
568
  this.unsubscribeFromKeysImpl = () => void 0;
564
569
  this.subscriptions = [];
565
570
  this.instantiationTime = Date.now() / 1e3;
@@ -576,32 +581,54 @@ class CacheControlCommand extends BaseCommand {
576
581
  instrumentationAttributes: this.instrumentationAttributes
577
582
  });
578
583
  return resultPromise.then((result) => {
579
- return this.handleCacheControllerResult(result, requestRunner);
584
+ return this.handleCacheControllerResult(result, requestRunner).then((result2) => {
585
+ if (this.lastResult === void 0) {
586
+ if (result2.isErr()) {
587
+ this.lastResult = { type: "error", error: result2.error.failure };
588
+ } else {
589
+ this.lastResult = { type: "data", data: result2.value.data };
590
+ }
591
+ }
592
+ return result2;
593
+ });
580
594
  });
581
595
  }
582
596
  handleCacheControllerResult(result, requestRunner) {
583
597
  const { networkError, networkData, returnData } = requestRunner;
584
598
  return this.publishUpdatedKeys().then(() => {
585
599
  if (networkError) {
586
- return networkError;
600
+ return buildSubscribableResult(
601
+ networkError,
602
+ this.buildSubscribe(),
603
+ () => this.refresh()
604
+ );
587
605
  }
588
606
  if (result.isErr()) {
589
607
  if (networkData) {
590
- return this.constructSubscribableResult(networkData.value);
608
+ return buildSubscribableResult(
609
+ networkData,
610
+ this.buildSubscribe(),
611
+ () => this.refresh()
612
+ );
591
613
  }
592
- return err(result.error);
614
+ return buildSubscribableResult(result, this.buildSubscribe(), () => this.refresh());
593
615
  }
594
616
  if (this.subscriptions.length > 0) {
595
617
  this.subscribeToKeysUsed();
596
618
  }
597
619
  if (returnData === void 0) {
598
620
  if (networkData) {
599
- return this.constructSubscribableResult(networkData.value);
621
+ return buildSubscribableResult(
622
+ networkData,
623
+ this.buildSubscribe(),
624
+ () => this.refresh()
625
+ );
600
626
  }
601
- return err(new Error("Cache miss after fetching from network"));
602
- }
603
- if (returnData.isOk() && this.lastEmittedData === void 0) {
604
- this.lastEmittedData = returnData.value.data;
627
+ return buildSubscribableResult(
628
+ err(new Error("Cache miss after fetching from network")),
629
+ this.buildSubscribe(),
630
+ () => this.refresh()
631
+ );
605
632
  }
606
633
  return returnData;
607
634
  });
@@ -661,7 +688,7 @@ class CacheControlCommand extends BaseCommand {
661
688
  refresh() {
662
689
  return this.rerun({ cacheControlConfig: { type: "no-cache" } }).then((result) => {
663
690
  if (result.isErr()) {
664
- return err(result.error);
691
+ return err(result.error.failure);
665
692
  }
666
693
  return ok$1(void 0);
667
694
  });
@@ -679,22 +706,22 @@ class CacheControlCommand extends BaseCommand {
679
706
  const result = this.readFromCache(recordableCache);
680
707
  return result.then((readResult) => {
681
708
  if (readResult.isErr()) {
682
- return err(readResult.error);
709
+ return buildSubscribableResult(
710
+ readResult,
711
+ this.buildSubscribe(),
712
+ () => this.refresh()
713
+ );
683
714
  } else {
684
715
  const data = readResult.value;
685
716
  this.keysUsed = recordableCache.keysRead;
686
- return this.constructSubscribableResult(data);
717
+ return buildSubscribableResult(
718
+ ok$1(data),
719
+ this.buildSubscribe(),
720
+ () => this.refresh()
721
+ );
687
722
  }
688
723
  });
689
724
  }
690
- constructSubscribableResult(data) {
691
- return ok$1({
692
- data,
693
- // this cast is in case we need to return Network data as a fallback for caching errors
694
- subscribe: this.buildSubscribe(),
695
- refresh: () => this.refresh()
696
- });
697
- }
698
725
  /**
699
726
  * Builds a function that subscribes to cache changes via the pubsub service. Whenever
700
727
  * relevant cache updates occur, it re-reads the data and compares it against
@@ -721,11 +748,12 @@ class CacheControlCommand extends BaseCommand {
721
748
  rerun(overrides) {
722
749
  return this.execute(overrides).then((result) => {
723
750
  if (result.isErr()) {
724
- this.invokeConsumerCallbacks(result);
751
+ this.lastResult = { type: "error", error: result.error.failure };
752
+ this.invokeConsumerCallbacks(err(result.error.failure));
725
753
  return result;
726
754
  }
727
- if (!this.equals(this.lastEmittedData, result.value.data)) {
728
- this.lastEmittedData = result.value.data;
755
+ if (this.lastResult === void 0 || this.lastResult.type === "error" || !this.equals(this.lastResult.data, result.value.data)) {
756
+ this.lastResult = { type: "data", data: result.value.data };
729
757
  this.invokeConsumerCallbacks(ok$1(result.value.data));
730
758
  }
731
759
  return result;
@@ -1157,35 +1185,27 @@ class NetworkCommand extends BaseCommand {
1157
1185
  }
1158
1186
  fetchSubscribableResult(res) {
1159
1187
  return res.then((networkResult) => {
1160
- if (networkResult.isErr()) {
1161
- return err$1(networkResult.error);
1162
- } else {
1163
- const data = networkResult.value;
1164
- return ok$2({
1165
- data,
1166
- subscribe: (cb) => {
1167
- this.subscriptions.push(cb);
1168
- return () => {
1169
- this.subscriptions = this.subscriptions.filter((cb2) => cb2 !== cb);
1170
- };
1171
- },
1172
- refresh: () => this.refresh()
1173
- });
1174
- }
1188
+ return buildSubscribableResult$1(
1189
+ networkResult,
1190
+ (cb) => {
1191
+ this.subscriptions.push(cb);
1192
+ return () => {
1193
+ this.subscriptions = this.subscriptions.filter((cb2) => cb2 !== cb);
1194
+ };
1195
+ },
1196
+ () => this.refresh()
1197
+ );
1175
1198
  });
1176
1199
  }
1177
1200
  refresh() {
1178
1201
  return this.execute().then((newResult) => {
1179
- if (newResult.isOk()) {
1180
- if (isSubscribableResult(newResult)) {
1181
- const value = newResult.value;
1182
- this.subscriptions.forEach((cb) => {
1183
- cb(ok$2(value.data));
1184
- });
1185
- }
1186
- return ok$2(void 0);
1202
+ if (isSubscribableResult(newResult)) {
1203
+ const value = newResult.isOk() ? ok$2(newResult.value.data) : err$1(newResult.error.failure);
1204
+ this.subscriptions.forEach((cb) => {
1205
+ cb(value);
1206
+ });
1187
1207
  }
1188
- return err$1(newResult.error);
1208
+ return ok$2(void 0);
1189
1209
  });
1190
1210
  }
1191
1211
  async afterRequestHooks(_options) {
@@ -2309,7 +2329,7 @@ function buildServiceDescriptor$5(luvio) {
2309
2329
  },
2310
2330
  };
2311
2331
  }
2312
- // version: 1.380.0-dev4-6d09d6af3b
2332
+ // version: 1.380.0-dev5-27c3b66ede
2313
2333
 
2314
2334
  /*!
2315
2335
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -2411,22 +2431,22 @@ class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheContro
2411
2431
  ),
2412
2432
  (errs) => this.coerceError(errs)
2413
2433
  ).then((result) => {
2414
- if (result.isOk()) {
2415
- return this.constructSubscribableResult(result.value);
2416
- }
2417
- return result;
2434
+ return buildSubscribableResult$1(result, this.buildSubscribe(), () => this.refresh());
2418
2435
  });
2419
2436
  } else if (this.shouldUseFetch()) {
2420
2437
  return this.convertFetchResponseToData(
2421
2438
  this.services.fetch(...this.originalFetchParams)
2422
2439
  ).then((result) => {
2423
- if (result.isOk()) {
2424
- return this.constructSubscribableResult(result.value);
2425
- }
2426
- return result;
2440
+ return buildSubscribableResult$1(result, this.buildSubscribe(), () => this.refresh());
2427
2441
  });
2428
2442
  }
2429
- return resolvedPromiseLike$3(err$1(toError("Aura/Fetch network services not found")));
2443
+ return resolvedPromiseLike$3(
2444
+ buildSubscribableResult$1(
2445
+ err$1(toError("Aura/Fetch network services not found")),
2446
+ this.buildSubscribe(),
2447
+ () => this.refresh()
2448
+ )
2449
+ );
2430
2450
  }
2431
2451
  buildRequestQuery() {
2432
2452
  const augmentedQueryResult = this.documentRootType.buildAugmentedQuery(this.config);
@@ -2455,9 +2475,6 @@ class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheContro
2455
2475
  if (this.subscriptions.length > 0) {
2456
2476
  this.subscribeToKeysUsed();
2457
2477
  }
2458
- if (this.lastEmittedData === void 0) {
2459
- this.lastEmittedData = returnData.value.data;
2460
- }
2461
2478
  return returnData;
2462
2479
  });
2463
2480
  }
@@ -2549,10 +2566,7 @@ class HttpGraphQLNormalizedCacheControlCommand extends HttpNormalizedCacheContro
2549
2566
  return this.convertFetchResponseToData(
2550
2567
  this.services.fetch(...this.originalFetchParams)
2551
2568
  ).then((result) => {
2552
- if (result.isOk()) {
2553
- return this.constructSubscribableResult(result.value);
2554
- }
2555
- return result;
2569
+ return buildSubscribableResult$1(result, this.buildSubscribe(), () => this.refresh());
2556
2570
  });
2557
2571
  }
2558
2572
  // Any changes to this method should most likely be duplicated in the aura command as well
@@ -2565,9 +2579,6 @@ class HttpGraphQLNormalizedCacheControlCommand extends HttpNormalizedCacheContro
2565
2579
  if (this.subscriptions.length > 0) {
2566
2580
  this.subscribeToKeysUsed();
2567
2581
  }
2568
- if (this.lastEmittedData === void 0) {
2569
- this.lastEmittedData = returnData.value.data;
2570
- }
2571
2582
  return returnData;
2572
2583
  });
2573
2584
  }
@@ -2628,7 +2639,7 @@ function buildServiceDescriptor$1(notifyRecordUpdateAvailable, getNormalizedLuvi
2628
2639
  },
2629
2640
  };
2630
2641
  }
2631
- // version: 1.380.0-dev4-6d09d6af3b
2642
+ // version: 1.380.0-dev5-27c3b66ede
2632
2643
 
2633
2644
  /*!
2634
2645
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -2660,12 +2671,12 @@ function t(e2) {
2660
2671
  throw "Illegal base64url string!";
2661
2672
  }
2662
2673
  try {
2663
- return function(e3) {
2664
- return decodeURIComponent(r(e3).replace(/(.)/g, function(e4, r2) {
2674
+ return (function(e3) {
2675
+ return decodeURIComponent(r(e3).replace(/(.)/g, (function(e4, r2) {
2665
2676
  var t3 = r2.charCodeAt(0).toString(16).toUpperCase();
2666
2677
  return t3.length < 2 && (t3 = "0" + t3), "%" + t3;
2667
- }));
2668
- }(t2);
2678
+ })));
2679
+ })(t2);
2669
2680
  } catch (e3) {
2670
2681
  return r(t2);
2671
2682
  }
@@ -6119,7 +6130,7 @@ function getEnvironmentSetting(name) {
6119
6130
  }
6120
6131
  return undefined;
6121
6132
  }
6122
- // version: 1.380.0-dev4-6d09d6af3b
6133
+ // version: 1.380.0-dev5-27c3b66ede
6123
6134
 
6124
6135
  const forceRecordTransactionsDisabled = getEnvironmentSetting(EnvironmentSettings.ForceRecordTransactionsDisabled);
6125
6136
  //TODO: Some duplication here that can be most likely moved to a util class
@@ -7086,4 +7097,4 @@ function ldsEngineCreator() {
7086
7097
  }
7087
7098
 
7088
7099
  export { LexRequestStrategy, PdlRequestPriority, buildPredictorForContext, ldsEngineCreator as default, initializeLDS, initializeOneStore, notifyUpdateAvailableFactory, registerRequestStrategy, saveRequestAsPrediction, unregisterRequestStrategy, whenPredictionsReady };
7089
- // version: 1.380.0-dev4-be0d98927e
7100
+ // version: 1.380.0-dev5-94859d35c9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-aura",
3
- "version": "1.380.0-dev4",
3
+ "version": "1.380.0-dev5",
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.58.2",
38
- "@luvio/tools-core": "5.58.2",
39
- "@salesforce/lds-adapters-apex": "^1.380.0-dev4",
40
- "@salesforce/lds-adapters-uiapi": "^1.380.0-dev4",
37
+ "@luvio/service-provisioner": "5.59.0",
38
+ "@luvio/tools-core": "5.59.0",
39
+ "@salesforce/lds-adapters-apex": "^1.380.0-dev5",
40
+ "@salesforce/lds-adapters-uiapi": "^1.380.0-dev5",
41
41
  "@salesforce/lds-adapters-uiapi-lex": "^1.371.0",
42
- "@salesforce/lds-ads-bridge": "^1.380.0-dev4",
43
- "@salesforce/lds-aura-storage": "^1.380.0-dev4",
44
- "@salesforce/lds-bindings": "^1.380.0-dev4",
45
- "@salesforce/lds-instrumentation": "^1.380.0-dev4",
46
- "@salesforce/lds-network-aura": "^1.380.0-dev4",
47
- "@salesforce/lds-network-fetch": "^1.380.0-dev4",
42
+ "@salesforce/lds-ads-bridge": "^1.380.0-dev5",
43
+ "@salesforce/lds-aura-storage": "^1.380.0-dev5",
44
+ "@salesforce/lds-bindings": "^1.380.0-dev5",
45
+ "@salesforce/lds-instrumentation": "^1.380.0-dev5",
46
+ "@salesforce/lds-network-aura": "^1.380.0-dev5",
47
+ "@salesforce/lds-network-fetch": "^1.380.0-dev5",
48
48
  "jwt-encode": "1.0.1"
49
49
  },
50
50
  "dependencies": {
51
- "@luvio/command-aura-graphql-normalized-cache-control": "5.58.2",
52
- "@luvio/command-aura-network": "5.58.2",
53
- "@luvio/command-aura-normalized-cache-control": "5.58.2",
54
- "@luvio/command-aura-resource-cache-control": "5.58.2",
55
- "@luvio/command-fetch-network": "5.58.2",
56
- "@luvio/command-http-graphql-normalized-cache-control": "5.58.2",
57
- "@luvio/command-http-normalized-cache-control": "5.58.2",
58
- "@luvio/command-ndjson": "5.58.2",
59
- "@luvio/command-network": "5.58.2",
60
- "@luvio/command-sse": "5.58.2",
61
- "@luvio/command-streaming": "5.58.2",
51
+ "@luvio/command-aura-graphql-normalized-cache-control": "5.59.0",
52
+ "@luvio/command-aura-network": "5.59.0",
53
+ "@luvio/command-aura-normalized-cache-control": "5.59.0",
54
+ "@luvio/command-aura-resource-cache-control": "5.59.0",
55
+ "@luvio/command-fetch-network": "5.59.0",
56
+ "@luvio/command-http-graphql-normalized-cache-control": "5.59.0",
57
+ "@luvio/command-http-normalized-cache-control": "5.59.0",
58
+ "@luvio/command-ndjson": "5.59.0",
59
+ "@luvio/command-network": "5.59.0",
60
+ "@luvio/command-sse": "5.59.0",
61
+ "@luvio/command-streaming": "5.59.0",
62
62
  "@luvio/network-adapter-composable": "0.158.7",
63
63
  "@luvio/network-adapter-fetch": "0.158.7",
64
- "@luvio/service-aura-network": "5.58.2",
65
- "@luvio/service-cache": "5.58.2",
66
- "@luvio/service-cache-control": "5.58.2",
67
- "@luvio/service-cache-inclusion-policy": "5.58.2",
68
- "@luvio/service-feature-flags": "5.58.2",
69
- "@luvio/service-fetch-network": "5.58.2",
70
- "@luvio/service-instrument-command": "5.58.2",
71
- "@luvio/service-pubsub": "5.58.2",
72
- "@luvio/service-store": "5.58.2",
73
- "@luvio/utils": "5.58.2",
74
- "@salesforce/lds-adapters-onestore-graphql": "^1.380.0-dev4",
75
- "@salesforce/lds-adapters-uiapi-lex": "^1.380.0-dev4",
76
- "@salesforce/lds-luvio-service": "^1.380.0-dev4",
77
- "@salesforce/lds-luvio-uiapi-records-service": "^1.380.0-dev4"
64
+ "@luvio/service-aura-network": "5.59.0",
65
+ "@luvio/service-cache": "5.59.0",
66
+ "@luvio/service-cache-control": "5.59.0",
67
+ "@luvio/service-cache-inclusion-policy": "5.59.0",
68
+ "@luvio/service-feature-flags": "5.59.0",
69
+ "@luvio/service-fetch-network": "5.59.0",
70
+ "@luvio/service-instrument-command": "5.59.0",
71
+ "@luvio/service-pubsub": "5.59.0",
72
+ "@luvio/service-store": "5.59.0",
73
+ "@luvio/utils": "5.59.0",
74
+ "@salesforce/lds-adapters-onestore-graphql": "^1.380.0-dev5",
75
+ "@salesforce/lds-adapters-uiapi-lex": "^1.380.0-dev5",
76
+ "@salesforce/lds-luvio-service": "^1.380.0-dev5",
77
+ "@salesforce/lds-luvio-uiapi-records-service": "^1.380.0-dev5"
78
78
  },
79
79
  "luvioBundlesize": [
80
80
  {