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