@salesforce/lds-runtime-one-runtime 1.469.0 → 1.471.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.
@@ -22,8 +22,8 @@ import { getInstrumentation } from 'o11y/client';
22
22
  import { findExecutableOperation, buildGraphQLInputExtension, addTypenameToDocument } from 'force/luvioGraphqlNormalization';
23
23
  import { print, resolveAndValidateGraphQLConfig, toGraphQLErrorResponse } from 'force/luvioOnestoreGraphqlParser';
24
24
  import getServices, { setServices } from 'force/luvioServiceProvisioner1';
25
- import { assertIsValid, JsonSchemaViolationError, MissingRequiredPropertyError } from 'force/luvioJsonschemaValidate5';
26
25
  import { dispatchGlobalEvent as dispatchGlobalEvent$1, executeGlobalControllerRawResponse } from 'aura';
26
+ import { assertIsValid, JsonSchemaViolationError, MissingRequiredPropertyError } from 'force/luvioJsonschemaValidate5';
27
27
  import { REFRESH_ADAPTER_EVENT, ADAPTER_UNFULFILLED_ERROR, instrument as instrument$3 } from 'force/ldsBindings';
28
28
  import { counter, registerCacheStats, perfStart, perfEnd, registerPeriodicLogger, interaction, markStart, mark, markEnd, timer } from 'instrumentation/service';
29
29
  import { LRUCache, instrumentAdapter, instrumentLuvio, logMessage as logMessage$1, setupInstrumentation as setupInstrumentation$1, logObjectInfoChanged as logObjectInfoChanged$1, updatePercentileHistogramMetric, incrementCounterMetric, incrementGetRecordNotifyChangeAllowCount, incrementGetRecordNotifyChangeDropCount, incrementNotifyRecordUpdateAvailableAllowCount, incrementNotifyRecordUpdateAvailableDropCount, setLdsAdaptersUiapiInstrumentation, logError as logError$2, setLdsNetworkAdapterInstrumentation, stateManagerInstrumentation, OperationTypeValue, executeAsyncActivity, METRIC_KEYS, onIdleDetected } from 'force/ldsInstrumentation';
@@ -33,18 +33,18 @@ import { instrument as instrument$4 } from 'force/adsBridge';
33
33
  import { instrument as instrument$5 } from '@lwc/state';
34
34
  import { withRegistration, register, setDefaultLuvio } from 'force/ldsEngine';
35
35
  import { ThirdPartyTracker } from 'instrumentation:thirdPartyTracker';
36
+ import { createStorage, clearStorages } from 'force/ldsDurableStorage';
36
37
  import lightningConnectEnabled from '@salesforce/gate/ui.services.LightningConnect.enabled';
37
38
  import bypassAppRestrictionEnabled from '@salesforce/gate/ui.services.LightningConnect.BypassAppRestriction.enabled';
38
39
  import csrfValidationEnabled from '@salesforce/gate/ui.services.LightningConnect.CsrfValidation.enabled';
39
40
  import sessionApiEnabled from '@salesforce/gate/ui.uisdk.session.api.enabled';
40
41
  import { pageScopedCache } from 'instrumentation/utility';
41
- import { createStorage, clearStorages } from 'force/ldsDurableStorage';
42
42
  import auraBasedRequestsEnabled from '@salesforce/gate/ui.services.auraBasedRequests.enabled';
43
43
  import { registerSubRequestNetworkAdapter } from 'force/ldsNetwork';
44
44
 
45
45
  const { create: create$1, freeze, keys: keys$2, entries: entries$1 } = Object;
46
- const { isArray: isArray$4 } = Array;
47
- const { stringify: stringify$3, parse: parse$2 } = JSON;
46
+ const { isArray: isArray$3 } = Array;
47
+ const { stringify: stringify$1, parse } = JSON;
48
48
  const WeakSetConstructor = WeakSet;
49
49
  const LogLevelMap = {
50
50
  TRACE: 4,
@@ -85,7 +85,7 @@ class ConsoleLogger {
85
85
  function loggerService(level, printer, formatter) {
86
86
  return new ConsoleLogger(level, printer, formatter);
87
87
  }
88
- let Ok$2 = class Ok {
88
+ class Ok {
89
89
  constructor(value) {
90
90
  this.value = value;
91
91
  }
@@ -95,8 +95,8 @@ let Ok$2 = class Ok {
95
95
  isErr() {
96
96
  return !this.isOk();
97
97
  }
98
- };
99
- let Err$1 = class Err {
98
+ }
99
+ class Err {
100
100
  constructor(error) {
101
101
  this.error = error;
102
102
  }
@@ -106,12 +106,26 @@ let Err$1 = class Err {
106
106
  isErr() {
107
107
  return !this.isOk();
108
108
  }
109
- };
110
- const ok$2 = (value) => new Ok$2(value);
111
- const err$1 = (err2) => new Err$1(err2);
109
+ }
110
+ const ok = (value) => new Ok(value);
111
+ const err = (err2) => new Err(err2);
112
112
  function isResult(value) {
113
113
  return value !== null && value !== void 0 && 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
114
  }
115
+ function setDifference(setA, setB) {
116
+ const differenceSet = /* @__PURE__ */ new Set();
117
+ for (const element of setA) {
118
+ if (!setB.has(element)) {
119
+ differenceSet.add(element);
120
+ }
121
+ }
122
+ return differenceSet;
123
+ }
124
+ function addAllToSet(targetSet, sourceSet) {
125
+ for (const element of sourceSet) {
126
+ targetSet.add(element);
127
+ }
128
+ }
115
129
  function isSubscribable(obj) {
116
130
  return typeof obj === "object" && obj !== null && "subscribe" in obj && typeof obj.subscribe === "function" && "refresh" in obj && typeof obj.refresh === "function";
117
131
  }
@@ -121,15 +135,15 @@ function isSubscribableResult(x) {
121
135
  }
122
136
  return isSubscribable(x.isOk() ? x.value : x.error);
123
137
  }
124
- function buildSubscribableResult$1(result, subscribe, refresh) {
138
+ function buildSubscribableResult(result, subscribe, refresh) {
125
139
  if (result.isOk()) {
126
- return ok$2({ data: result.value, subscribe, refresh });
140
+ return ok({ data: result.value, subscribe, refresh });
127
141
  } else {
128
- return err$1({ failure: result.error, subscribe, refresh });
142
+ return err({ failure: result.error, subscribe, refresh });
129
143
  }
130
144
  }
131
- function resolvedPromiseLike$2(result) {
132
- if (isPromiseLike$2(result)) {
145
+ function resolvedPromiseLike(result) {
146
+ if (isPromiseLike(result)) {
133
147
  return result.then(
134
148
  (nextResult) => nextResult
135
149
  );
@@ -137,18 +151,18 @@ function resolvedPromiseLike$2(result) {
137
151
  return {
138
152
  then: (onFulfilled, _onRejected) => {
139
153
  try {
140
- return resolvedPromiseLike$2(onFulfilled(result));
154
+ return resolvedPromiseLike(onFulfilled(result));
141
155
  } catch (e) {
142
156
  if (onFulfilled === void 0) {
143
- return resolvedPromiseLike$2(result);
157
+ return resolvedPromiseLike(result);
144
158
  }
145
- return rejectedPromiseLike$2(e);
159
+ return rejectedPromiseLike(e);
146
160
  }
147
161
  }
148
162
  };
149
163
  }
150
- function rejectedPromiseLike$2(reason) {
151
- if (isPromiseLike$2(reason)) {
164
+ function rejectedPromiseLike(reason) {
165
+ if (isPromiseLike(reason)) {
152
166
  return reason.then(
153
167
  (nextResult) => nextResult
154
168
  );
@@ -157,31 +171,31 @@ function rejectedPromiseLike$2(reason) {
157
171
  then: (_onFulfilled, onRejected) => {
158
172
  if (typeof onRejected === "function") {
159
173
  try {
160
- return resolvedPromiseLike$2(onRejected(reason));
174
+ return resolvedPromiseLike(onRejected(reason));
161
175
  } catch (e) {
162
- return rejectedPromiseLike$2(e);
176
+ return rejectedPromiseLike(e);
163
177
  }
164
178
  }
165
- return rejectedPromiseLike$2(reason);
179
+ return rejectedPromiseLike(reason);
166
180
  }
167
181
  };
168
182
  }
169
- function isPromiseLike$2(x) {
183
+ function isPromiseLike(x) {
170
184
  return typeof x?.then === "function";
171
185
  }
172
- function deepEquals$2(x, y) {
186
+ function deepEquals$1(x, y) {
173
187
  if (x === void 0) {
174
188
  return y === void 0;
175
189
  } else if (x === null) {
176
190
  return y === null;
177
191
  } else if (y === null) {
178
192
  return x === null;
179
- } else if (isArray$4(x)) {
180
- if (!isArray$4(y) || x.length !== y.length) {
193
+ } else if (isArray$3(x)) {
194
+ if (!isArray$3(y) || x.length !== y.length) {
181
195
  return false;
182
196
  }
183
197
  for (let i = 0; i < x.length; ++i) {
184
- if (!deepEquals$2(x[i], y[i])) {
198
+ if (!deepEquals$1(x[i], y[i])) {
185
199
  return false;
186
200
  }
187
201
  }
@@ -197,7 +211,7 @@ function deepEquals$2(x, y) {
197
211
  }
198
212
  for (let i = 0; i < xkeys.length; ++i) {
199
213
  const key = xkeys[i];
200
- if (!deepEquals$2(
214
+ if (!deepEquals$1(
201
215
  x[key],
202
216
  y[key]
203
217
  )) {
@@ -220,11 +234,11 @@ function stableJSONStringify$2(node) {
220
234
  return isFinite(node) ? "" + node : "null";
221
235
  }
222
236
  if (typeof node !== "object") {
223
- return stringify$3(node);
237
+ return stringify$1(node);
224
238
  }
225
239
  let i;
226
240
  let out;
227
- if (isArray$4(node)) {
241
+ if (isArray$3(node)) {
228
242
  out = "[";
229
243
  for (i = 0; i < node.length; i++) {
230
244
  if (i) {
@@ -249,7 +263,7 @@ function stableJSONStringify$2(node) {
249
263
  if (out) {
250
264
  out += ",";
251
265
  }
252
- out += stringify$3(key) + ":" + value;
266
+ out += stringify$1(key) + ":" + value;
253
267
  }
254
268
  return "{" + out + "}";
255
269
  }
@@ -259,6 +273,10 @@ function toError(x) {
259
273
  }
260
274
  return new Error(typeof x === "string" ? x : JSON.stringify(x));
261
275
  }
276
+ function deepCopy(x) {
277
+ const stringified = stringify$1(x);
278
+ return stringified ? parse(stringified) : void 0;
279
+ }
262
280
  var HttpStatusCode$1 = /* @__PURE__ */ ((HttpStatusCode2) => {
263
281
  HttpStatusCode2[HttpStatusCode2["Ok"] = 200] = "Ok";
264
282
  HttpStatusCode2[HttpStatusCode2["Created"] = 201] = "Created";
@@ -332,7 +350,7 @@ function deepFreeze(value) {
332
350
  return;
333
351
  }
334
352
  deeplyFrozen.add(value);
335
- if (isArray$4(value)) {
353
+ if (isArray$3(value)) {
336
354
  for (let i = 0, len = value.length; i < len; i += 1) {
337
355
  deepFreeze(value[i]);
338
356
  }
@@ -372,7 +390,7 @@ function logError$1(error) {
372
390
  class BaseCommand {
373
391
  }
374
392
 
375
- let NetworkCommand$1 = class NetworkCommand extends BaseCommand {
393
+ class NetworkCommand extends BaseCommand {
376
394
  constructor(services) {
377
395
  super();
378
396
  this.services = services;
@@ -388,7 +406,7 @@ let NetworkCommand$1 = class NetworkCommand extends BaseCommand {
388
406
  }
389
407
  fetchSubscribableResult(res) {
390
408
  return res.then((networkResult) => {
391
- return buildSubscribableResult$1(
409
+ return buildSubscribableResult(
392
410
  networkResult,
393
411
  (cb) => {
394
412
  this.subscriptions.push(cb);
@@ -403,7 +421,7 @@ let NetworkCommand$1 = class NetworkCommand extends BaseCommand {
403
421
  refresh() {
404
422
  return this.execute().then((newResult) => {
405
423
  if (isSubscribableResult(newResult)) {
406
- const value = newResult.isOk() ? ok$2(newResult.value.data) : err$1(newResult.error.failure);
424
+ const value = newResult.isOk() ? ok(newResult.value.data) : err(newResult.error.failure);
407
425
  this.subscriptions.forEach((cb) => {
408
426
  try {
409
427
  cb(value);
@@ -411,21 +429,21 @@ let NetworkCommand$1 = class NetworkCommand extends BaseCommand {
411
429
  }
412
430
  });
413
431
  }
414
- return ok$2(void 0);
432
+ return ok(void 0);
415
433
  });
416
434
  }
417
435
  async afterRequestHooks(_options) {
418
436
  }
419
- };
420
- function buildServiceDescriptor$q() {
437
+ }
438
+ function buildServiceDescriptor$r() {
421
439
  return {
422
440
  type: "networkCommandBaseClass",
423
441
  version: "1.0",
424
- service: NetworkCommand$1
442
+ service: NetworkCommand
425
443
  };
426
444
  }
427
445
 
428
- function applyOperationRequestOptions$3(init, operationType, requestOptions) {
446
+ function applyOperationRequestOptions(init, operationType, requestOptions) {
429
447
  if (operationType === void 0 && requestOptions === void 0) {
430
448
  return init;
431
449
  }
@@ -438,7 +456,164 @@ function applyOperationRequestOptions$3(init, operationType, requestOptions) {
438
456
  }
439
457
  };
440
458
  }
441
- class AuraNetworkCommand extends NetworkCommand$1 {
459
+ function buildServiceDescriptor$q(interceptors = {
460
+ request: [],
461
+ retry: void 0,
462
+ response: [],
463
+ finally: []
464
+ }, retryService) {
465
+ return {
466
+ type: "fetch",
467
+ version: "1.0",
468
+ service: function(input, init) {
469
+ let contextSeed;
470
+ let cleanInit = init;
471
+ if (init !== void 0 && "__contextSeed" in init) {
472
+ const { __contextSeed, ...initWithoutSeed } = init;
473
+ contextSeed = __contextSeed;
474
+ cleanInit = Object.keys(initWithoutSeed).length === 0 ? void 0 : initWithoutSeed;
475
+ }
476
+ const fetchArgs = cleanInit === void 0 ? [input] : [input, cleanInit];
477
+ const baseContext = interceptors.createContext?.();
478
+ const onestore = cleanInit?.onestore;
479
+ const context = contextSeed === void 0 && onestore === void 0 ? baseContext : {
480
+ ...baseContext,
481
+ ...contextSeed,
482
+ ...onestore !== void 0 && { onestore }
483
+ };
484
+ const {
485
+ request: requestInterceptors = [],
486
+ retry: retryInterceptor = void 0,
487
+ response: responseInterceptors = [],
488
+ finally: finallyInterceptors = []
489
+ } = interceptors;
490
+ const pending = requestInterceptors.reduce(
491
+ (previousPromise, interceptor) => previousPromise.then((args) => interceptor(args, context)),
492
+ resolvedPromiseLike(fetchArgs)
493
+ );
494
+ return Promise.resolve(pending).then((args) => {
495
+ if (retryInterceptor) {
496
+ return retryInterceptor(args, retryService, context);
497
+ } else {
498
+ if (retryService) {
499
+ return retryService.applyRetry(() => fetch(...args));
500
+ }
501
+ return fetch(...args);
502
+ }
503
+ }).then((response) => {
504
+ return responseInterceptors.reduce(
505
+ (previousPromise, interceptor) => previousPromise.then((response2) => interceptor(response2, context)),
506
+ resolvedPromiseLike(response)
507
+ );
508
+ }).finally(() => {
509
+ if (finallyInterceptors.length > 0) {
510
+ return finallyInterceptors.reduce(
511
+ (previousPromise, interceptor) => previousPromise.then(() => interceptor(context)),
512
+ Promise.resolve()
513
+ );
514
+ }
515
+ });
516
+ }
517
+ };
518
+ }
519
+ let textEncoder;
520
+ function getTextEncoder() {
521
+ if (!textEncoder) {
522
+ if (typeof TextEncoder === "undefined") {
523
+ throw new Error(
524
+ "TextEncoder is not available in this environment. Request body compression requires TextEncoder support."
525
+ );
526
+ }
527
+ textEncoder = new TextEncoder();
528
+ }
529
+ return textEncoder;
530
+ }
531
+ function buildCompressionInterceptor(defaultConfig) {
532
+ return async (args) => {
533
+ const [resource, options = {}] = args;
534
+ const config = options.onestore?.compression ?? defaultConfig;
535
+ if (config === void 0) {
536
+ return resolvedPromiseLike(args);
537
+ }
538
+ const threshold = config.threshold ?? 1024;
539
+ if (!options.body || typeof options.body !== "string") {
540
+ return resolvedPromiseLike(args);
541
+ }
542
+ if (typeof CompressionStream === "undefined") {
543
+ return resolvedPromiseLike(args);
544
+ }
545
+ const headers = new Headers(options.headers);
546
+ if (headers.has("Content-Encoding")) {
547
+ return resolvedPromiseLike(args);
548
+ }
549
+ const encodedBody = getTextEncoder().encode(options.body);
550
+ if (encodedBody.byteLength < threshold) {
551
+ return resolvedPromiseLike(args);
552
+ }
553
+ try {
554
+ const stream = new Blob([encodedBody]).stream().pipeThrough(new CompressionStream(config.algorithm));
555
+ const compressedBody = await new Response(stream).blob();
556
+ headers.set("Content-Encoding", config.algorithm);
557
+ headers.delete("Content-Length");
558
+ const compressedOptions = {
559
+ ...options,
560
+ body: compressedBody,
561
+ headers
562
+ };
563
+ return resolvedPromiseLike([resource, compressedOptions]);
564
+ } catch {
565
+ return resolvedPromiseLike(args);
566
+ }
567
+ };
568
+ }
569
+ function setHeader(headerName, headerValue, [resource, options = {}], {
570
+ throwOnExisting = false,
571
+ errorMessage = `Unexpected ${headerName} header encountered`
572
+ } = {}) {
573
+ let hasHeaderBeenSet = false;
574
+ if (resource instanceof Request && !options?.headers) {
575
+ if (throwOnExisting && resource.headers.has(headerName)) {
576
+ throw new Error(errorMessage);
577
+ }
578
+ resource.headers.set(headerName, headerValue);
579
+ hasHeaderBeenSet = true;
580
+ }
581
+ if (options?.headers instanceof Headers) {
582
+ if (throwOnExisting && options.headers.has(headerName)) {
583
+ throw new Error(errorMessage);
584
+ }
585
+ options.headers.set(headerName, headerValue);
586
+ } else {
587
+ if (throwOnExisting && options?.headers && Reflect.has(options.headers, headerName)) {
588
+ throw new Error(errorMessage);
589
+ }
590
+ if (!hasHeaderBeenSet) {
591
+ options.headers = {
592
+ ...options?.headers,
593
+ [headerName]: headerValue
594
+ };
595
+ }
596
+ }
597
+ return [resource, options];
598
+ }
599
+ const UNEXPECTED_AUTHORIZATION_HEADER_MESSAGE = "Unexpected Authorization header encountered. To specify a custom Authorization header, use a Fetch service that is not configured with JwtRequestHeaderInterceptor";
600
+ function setHeaderAuthorization({ token }, fetchParams) {
601
+ const authorizationValue = `Bearer ${token}`;
602
+ return setHeader("Authorization", authorizationValue, fetchParams, {
603
+ throwOnExisting: true,
604
+ errorMessage: UNEXPECTED_AUTHORIZATION_HEADER_MESSAGE
605
+ });
606
+ }
607
+ function buildJwtRequestHeaderInterceptor(jwtManager, jwtRequestModifier = (_e, fetchArgs) => fetchArgs) {
608
+ return (args) => {
609
+ return resolvedPromiseLike(jwtManager.getJwt()).then((token) => {
610
+ const fetchArgsWithRequestHeaderAuthorization = setHeaderAuthorization(token, args);
611
+ return token.extraInfo ? jwtRequestModifier(token.extraInfo, fetchArgsWithRequestHeaderAuthorization) : fetchArgsWithRequestHeaderAuthorization;
612
+ });
613
+ };
614
+ }
615
+
616
+ class AuraNetworkCommand extends NetworkCommand {
442
617
  constructor(services) {
443
618
  super(services);
444
619
  this.services = services;
@@ -492,19 +667,19 @@ class AuraNetworkCommand extends NetworkCommand$1 {
492
667
  this.afterRequestHooks({ statusCode: 200 });
493
668
  } catch {
494
669
  }
495
- return ok$2(auraReturnValue);
670
+ return ok(auraReturnValue);
496
671
  }).catch((error) => {
497
672
  if (!error) {
498
- return err$1(toError("Failed to get error from response"));
673
+ return err(toError("Failed to get error from response"));
499
674
  }
500
675
  if (!error.getError) {
501
- return err$1(toError(error));
676
+ return err(toError(error));
502
677
  }
503
678
  const actionErrors = error.getError();
504
679
  if (actionErrors.length > 0) {
505
- return err$1(coerceError(actionErrors));
680
+ return err(coerceError(actionErrors));
506
681
  }
507
- return err$1(toError("Error fetching component"));
682
+ return err(toError("Error fetching component"));
508
683
  });
509
684
  }
510
685
  isSemanticNullResponse(response) {
@@ -522,10 +697,10 @@ class AuraNetworkCommand extends NetworkCommand$1 {
522
697
  if (response2.ok) {
523
698
  let resultPromise;
524
699
  if (this.isSemanticNullResponse(response2)) {
525
- resultPromise = Promise.resolve(ok$2(null));
700
+ resultPromise = Promise.resolve(ok(null));
526
701
  } else if (this.isUndeclaredNoBodyResponse(response2)) {
527
702
  resultPromise = Promise.resolve(
528
- err$1(
703
+ err(
529
704
  toError(
530
705
  `Unexpected ${response2.status} response: no-content status was not declared in the API specification. Declare this response in your OAS without a content property.`
531
706
  )
@@ -533,8 +708,8 @@ class AuraNetworkCommand extends NetworkCommand$1 {
533
708
  );
534
709
  } else {
535
710
  resultPromise = response2.json().then(
536
- (json) => ok$2(json),
537
- (reason) => err$1(toError(reason))
711
+ (json) => ok(json),
712
+ (reason) => err(toError(reason))
538
713
  );
539
714
  }
540
715
  return resultPromise.finally(() => {
@@ -545,7 +720,7 @@ class AuraNetworkCommand extends NetworkCommand$1 {
545
720
  });
546
721
  } else {
547
722
  return this.coerceError(response2).then((coercedError) => {
548
- return err$1(coercedError);
723
+ return err(coercedError);
549
724
  }).finally(() => {
550
725
  try {
551
726
  this.afterRequestHooks({ statusCode: response2.status });
@@ -554,7 +729,7 @@ class AuraNetworkCommand extends NetworkCommand$1 {
554
729
  });
555
730
  }
556
731
  },
557
- (reason) => err$1(toError(reason))
732
+ (reason) => err(toError(reason))
558
733
  );
559
734
  }
560
735
  shouldUseAuraNetwork() {
@@ -578,7 +753,7 @@ class AuraNetworkCommand extends NetworkCommand$1 {
578
753
  );
579
754
  } else if (this.shouldUseFetch()) {
580
755
  const [input, init] = this.fetchParams;
581
- const initWithOptions = applyOperationRequestOptions$3(
756
+ const initWithOptions = applyOperationRequestOptions(
582
757
  init,
583
758
  this.operationType,
584
759
  this.requestOptions
@@ -587,10 +762,10 @@ class AuraNetworkCommand extends NetworkCommand$1 {
587
762
  const fetchCall = initWithOptions === void 0 ? this.services.fetch(input) : this.services.fetch(input, initWithOptions);
588
763
  return this.convertFetchResponseToData(fetchCall);
589
764
  } catch (reason) {
590
- return resolvedPromiseLike$2(err$1(toError(reason)));
765
+ return resolvedPromiseLike(err(toError(reason)));
591
766
  }
592
767
  }
593
- return resolvedPromiseLike$2(err$1(toError("Aura/Fetch network services not found")));
768
+ return resolvedPromiseLike(err(toError("Aura/Fetch network services not found")));
594
769
  }
595
770
  }
596
771
  function buildServiceDescriptor$p() {
@@ -601,164 +776,52 @@ function buildServiceDescriptor$p() {
601
776
  };
602
777
  }
603
778
 
604
- const { isArray: isArray$3 } = Array;
605
- let Ok$1 = class Ok {
606
- constructor(value) {
607
- this.value = value;
779
+ function setOverlaps(setA, setB) {
780
+ if (setA.size > setB.size) {
781
+ for (const key of setB.keys()) {
782
+ if (setA.has(key)) {
783
+ return true;
784
+ }
785
+ }
786
+ } else {
787
+ for (const key of setA) {
788
+ if (setB.has(key)) {
789
+ return true;
790
+ }
791
+ }
608
792
  }
609
- isOk() {
610
- return true;
793
+ return false;
794
+ }
795
+ class CacheControlRequestRunner {
796
+ constructor(readFromCache, requestFromNetwork, writeToCache) {
797
+ this.readFromCacheInternal = readFromCache;
798
+ this.requestFromNetworkInternal = requestFromNetwork;
799
+ this.writeToCacheInternal = writeToCache;
611
800
  }
612
- isErr() {
613
- return !this.isOk();
801
+ readFromCache(cache) {
802
+ const resultPromise = this.readFromCacheInternal(cache);
803
+ return resultPromise.then((result) => {
804
+ if (result.isErr()) {
805
+ return err(result.error.failure);
806
+ }
807
+ this.returnData = result;
808
+ return ok(void 0);
809
+ });
614
810
  }
615
- };
616
- class Err {
617
- constructor(error) {
618
- this.error = error;
811
+ requestFromNetwork() {
812
+ const that = this;
813
+ return (async function* () {
814
+ const result = await that.requestFromNetworkInternal();
815
+ if (result.isErr()) {
816
+ that.networkError = result;
817
+ } else {
818
+ that.networkData = result;
819
+ }
820
+ yield result;
821
+ })();
619
822
  }
620
- isOk() {
621
- return false;
622
- }
623
- isErr() {
624
- return !this.isOk();
625
- }
626
- }
627
- const ok$1 = (value) => new Ok$1(value);
628
- const err = (err2) => new Err(err2);
629
- function buildSubscribableResult(result, subscribe, refresh) {
630
- if (result.isOk()) {
631
- return ok$1({ data: result.value, subscribe, refresh });
632
- } else {
633
- return err({ failure: result.error, subscribe, refresh });
634
- }
635
- }
636
- function resolvedPromiseLike$1(result) {
637
- if (isPromiseLike$1(result)) {
638
- return result.then(
639
- (nextResult) => nextResult
640
- );
641
- }
642
- return {
643
- then: (onFulfilled, _onRejected) => {
644
- try {
645
- return resolvedPromiseLike$1(onFulfilled(result));
646
- } catch (e) {
647
- if (onFulfilled === void 0) {
648
- return resolvedPromiseLike$1(result);
649
- }
650
- return rejectedPromiseLike$1(e);
651
- }
652
- }
653
- };
654
- }
655
- function rejectedPromiseLike$1(reason) {
656
- if (isPromiseLike$1(reason)) {
657
- return reason.then(
658
- (nextResult) => nextResult
659
- );
660
- }
661
- return {
662
- then: (_onFulfilled, onRejected) => {
663
- if (typeof onRejected === "function") {
664
- try {
665
- return resolvedPromiseLike$1(onRejected(reason));
666
- } catch (e) {
667
- return rejectedPromiseLike$1(e);
668
- }
669
- }
670
- return rejectedPromiseLike$1(reason);
671
- }
672
- };
673
- }
674
- function isPromiseLike$1(x) {
675
- return typeof x?.then === "function";
676
- }
677
- function deepEquals$1(x, y) {
678
- if (x === void 0) {
679
- return y === void 0;
680
- } else if (x === null) {
681
- return y === null;
682
- } else if (y === null) {
683
- return x === null;
684
- } else if (isArray$3(x)) {
685
- if (!isArray$3(y) || x.length !== y.length) {
686
- return false;
687
- }
688
- for (let i = 0; i < x.length; ++i) {
689
- if (!deepEquals$1(x[i], y[i])) {
690
- return false;
691
- }
692
- }
693
- return true;
694
- } else if (typeof x === "object") {
695
- if (typeof y !== "object") {
696
- return false;
697
- }
698
- const xkeys = Object.keys(x);
699
- const ykeys = Object.keys(y);
700
- if (xkeys.length !== ykeys.length) {
701
- return false;
702
- }
703
- for (let i = 0; i < xkeys.length; ++i) {
704
- const key = xkeys[i];
705
- if (!deepEquals$1(
706
- x[key],
707
- y[key]
708
- )) {
709
- return false;
710
- }
711
- }
712
- return true;
713
- }
714
- return x === y;
715
- }
716
- function setOverlaps(setA, setB) {
717
- if (setA.size > setB.size) {
718
- for (const key of setB.keys()) {
719
- if (setA.has(key)) {
720
- return true;
721
- }
722
- }
723
- } else {
724
- for (const key of setA) {
725
- if (setB.has(key)) {
726
- return true;
727
- }
728
- }
729
- }
730
- return false;
731
- }
732
- class CacheControlRequestRunner {
733
- constructor(readFromCache, requestFromNetwork, writeToCache) {
734
- this.readFromCacheInternal = readFromCache;
735
- this.requestFromNetworkInternal = requestFromNetwork;
736
- this.writeToCacheInternal = writeToCache;
737
- }
738
- readFromCache(cache) {
739
- const resultPromise = this.readFromCacheInternal(cache);
740
- return resultPromise.then((result) => {
741
- if (result.isErr()) {
742
- return err(result.error.failure);
743
- }
744
- this.returnData = result;
745
- return ok$1(void 0);
746
- });
747
- }
748
- requestFromNetwork() {
749
- const that = this;
750
- return (async function* () {
751
- const result = await that.requestFromNetworkInternal();
752
- if (result.isErr()) {
753
- that.networkError = result;
754
- } else {
755
- that.networkData = result;
756
- }
757
- yield result;
758
- })();
759
- }
760
- writeToCache(cache, networkResult) {
761
- return this.writeToCacheInternal(cache, networkResult);
823
+ writeToCache(cache, networkResult) {
824
+ return this.writeToCacheInternal(cache, networkResult);
762
825
  }
763
826
  }
764
827
  class CacheControlCommand extends BaseCommand {
@@ -909,7 +972,7 @@ class CacheControlCommand extends BaseCommand {
909
972
  });
910
973
  }
911
974
  }
912
- return resolvedPromiseLike$1(void 0);
975
+ return resolvedPromiseLike(void 0);
913
976
  }
914
977
  get operationType() {
915
978
  return "query";
@@ -1011,7 +1074,7 @@ class CacheControlCommand extends BaseCommand {
1011
1074
  if (result.isErr()) {
1012
1075
  return err(result.error.failure);
1013
1076
  }
1014
- return ok$1(void 0);
1077
+ return ok(void 0);
1015
1078
  });
1016
1079
  }
1017
1080
  /**
@@ -1030,7 +1093,7 @@ class CacheControlCommand extends BaseCommand {
1030
1093
  return this.writeToCache(recordableCache, networkResult).then((result) => {
1031
1094
  this.instantiationTime = Date.now() / 1e3;
1032
1095
  this.keysUpdated = recordableCache.keysUpdated;
1033
- return ok$1(result);
1096
+ return ok(result);
1034
1097
  });
1035
1098
  }
1036
1099
  /**
@@ -1057,7 +1120,7 @@ class CacheControlCommand extends BaseCommand {
1057
1120
  const data = readResult.value;
1058
1121
  this.keysUsed = recordableCache.keysRead;
1059
1122
  return buildSubscribableResult(
1060
- ok$1(data),
1123
+ ok(data),
1061
1124
  this.buildSubscribe(),
1062
1125
  () => this.refresh()
1063
1126
  );
@@ -1110,7 +1173,7 @@ class CacheControlCommand extends BaseCommand {
1110
1173
  }
1111
1174
  if (this.lastResult === void 0 || this.lastResult.type === "error" || !this.equals(this.lastResult.data, result.value.data)) {
1112
1175
  this.lastResult = { type: "data", data: result.value.data };
1113
- this.invokeConsumerCallbacks(ok$1(result.value.data));
1176
+ this.invokeConsumerCallbacks(ok(result.value.data));
1114
1177
  }
1115
1178
  return result;
1116
1179
  });
@@ -1150,19 +1213,6 @@ function mergeCacheControlConfigs(baseConfig, overrides) {
1150
1213
  };
1151
1214
  }
1152
1215
 
1153
- function applyOperationRequestOptions$2(init, operationType, requestOptions) {
1154
- if (operationType === void 0 && requestOptions === void 0) {
1155
- return init;
1156
- }
1157
- return {
1158
- ...init,
1159
- onestore: {
1160
- ...requestOptions,
1161
- ...init?.onestore,
1162
- ...operationType !== void 0 && { retrySafe: operationType === "query" }
1163
- }
1164
- };
1165
- }
1166
1216
  class AuraCacheControlCommand extends CacheControlCommand {
1167
1217
  constructor(services) {
1168
1218
  super(services);
@@ -1192,7 +1242,7 @@ class AuraCacheControlCommand extends CacheControlCommand {
1192
1242
  input,
1193
1243
  init
1194
1244
  ]) {
1195
- return [input, applyOperationRequestOptions$2(init, this.operationType, this.requestOptions)];
1245
+ return [input, applyOperationRequestOptions(init, this.operationType, this.requestOptions)];
1196
1246
  }
1197
1247
  shouldUseAuraNetwork() {
1198
1248
  return this.services.auraNetwork !== void 0 && (this.networkPreference === "aura" || !this.services.fetch);
@@ -1216,10 +1266,10 @@ class AuraCacheControlCommand extends CacheControlCommand {
1216
1266
  try {
1217
1267
  return this.convertFetchResponseToData(this.services.fetch(...params));
1218
1268
  } catch (reason) {
1219
- return resolvedPromiseLike$2(err$1(toError(reason)));
1269
+ return resolvedPromiseLike(err(toError(reason)));
1220
1270
  }
1221
1271
  }
1222
- return resolvedPromiseLike$2(err$1(toError("Aura/Fetch network services not found")));
1272
+ return resolvedPromiseLike(err(toError("Aura/Fetch network services not found")));
1223
1273
  }
1224
1274
  coerceAuraErrors(auraErrors) {
1225
1275
  return toError(auraErrors[0]);
@@ -1228,10 +1278,10 @@ class AuraCacheControlCommand extends CacheControlCommand {
1228
1278
  return toError(errorResponse.statusText);
1229
1279
  }
1230
1280
  processAuraReturnValue(auraReturnValue) {
1231
- return ok$2(auraReturnValue);
1281
+ return ok(auraReturnValue);
1232
1282
  }
1233
1283
  processFetchReturnValue(json) {
1234
- return ok$2(json);
1284
+ return ok(json);
1235
1285
  }
1236
1286
  convertAuraResponseToData(responsePromise, coerceError) {
1237
1287
  return responsePromise.then((response) => {
@@ -1243,16 +1293,16 @@ class AuraCacheControlCommand extends CacheControlCommand {
1243
1293
  }
1244
1294
  }).catch((error) => {
1245
1295
  if (!error) {
1246
- return err$1(toError("Failed to get error from response"));
1296
+ return err(toError("Failed to get error from response"));
1247
1297
  }
1248
1298
  if (!error.getError) {
1249
- return err$1(toError(error));
1299
+ return err(toError(error));
1250
1300
  }
1251
1301
  const actionErrors = error.getError();
1252
1302
  if (actionErrors.length > 0) {
1253
- return err$1(coerceError(actionErrors));
1303
+ return err(coerceError(actionErrors));
1254
1304
  }
1255
- return err$1(toError("Error fetching component"));
1305
+ return err(toError("Error fetching component"));
1256
1306
  });
1257
1307
  }
1258
1308
  convertFetchResponseToData(response) {
@@ -1263,7 +1313,7 @@ class AuraCacheControlCommand extends CacheControlCommand {
1263
1313
  (json) => {
1264
1314
  return this.processFetchReturnValue(json);
1265
1315
  },
1266
- (reason) => err$1(toError(reason))
1316
+ (reason) => err(toError(reason))
1267
1317
  ).finally(() => {
1268
1318
  try {
1269
1319
  this.afterRequestHooks({ statusCode: response2.status });
@@ -1272,7 +1322,7 @@ class AuraCacheControlCommand extends CacheControlCommand {
1272
1322
  });
1273
1323
  } else {
1274
1324
  return this.coerceError(response2).then((coercedError) => {
1275
- return err$1(coercedError);
1325
+ return err(coercedError);
1276
1326
  }).finally(() => {
1277
1327
  try {
1278
1328
  this.afterRequestHooks({ statusCode: response2.status });
@@ -1281,10 +1331,11 @@ class AuraCacheControlCommand extends CacheControlCommand {
1281
1331
  });
1282
1332
  }
1283
1333
  },
1284
- (reason) => err$1(toError(reason))
1334
+ (reason) => err(toError(reason))
1285
1335
  );
1286
1336
  }
1287
1337
  }
1338
+
1288
1339
  class AuraNormalizedCacheControlCommand extends AuraCacheControlCommand {
1289
1340
  constructor(services) {
1290
1341
  super(services);
@@ -1293,11 +1344,11 @@ class AuraNormalizedCacheControlCommand extends AuraCacheControlCommand {
1293
1344
  readFromCache(cache) {
1294
1345
  const data = this.buildResultType().query(cache, this.buildQuery());
1295
1346
  if (data.isErr()) {
1296
- return resolvedPromiseLike$2(
1297
- err$1(new Error(`Failed to build data from type: ${stringify$3(data.error)}`))
1347
+ return resolvedPromiseLike(
1348
+ err(new Error(`Failed to build data from type: ${stringify$1(data.error)}`))
1298
1349
  );
1299
1350
  }
1300
- return resolvedPromiseLike$2(ok$2(data.value));
1351
+ return resolvedPromiseLike(ok(data.value));
1301
1352
  }
1302
1353
  writeToCache(cache, networkResult) {
1303
1354
  if (networkResult.isOk()) {
@@ -1306,7 +1357,7 @@ class AuraNormalizedCacheControlCommand extends AuraCacheControlCommand {
1306
1357
  this.buildWriteInput(networkResult.value)
1307
1358
  );
1308
1359
  }
1309
- return resolvedPromiseLike$2(void 0);
1360
+ return resolvedPromiseLike(void 0);
1310
1361
  }
1311
1362
  }
1312
1363
  function buildServiceDescriptor$o() {
@@ -1317,19 +1368,6 @@ function buildServiceDescriptor$o() {
1317
1368
  };
1318
1369
  }
1319
1370
 
1320
- function applyOperationRequestOptions$1(init, operationType, requestOptions) {
1321
- if (operationType === void 0 && requestOptions === void 0) {
1322
- return init;
1323
- }
1324
- return {
1325
- ...init,
1326
- onestore: {
1327
- ...requestOptions,
1328
- ...init?.onestore,
1329
- ...operationType !== void 0 && { retrySafe: operationType === "query" }
1330
- }
1331
- };
1332
- }
1333
1371
  class HttpCacheControlCommand extends CacheControlCommand {
1334
1372
  constructor(services) {
1335
1373
  super(services);
@@ -1351,7 +1389,7 @@ class HttpCacheControlCommand extends CacheControlCommand {
1351
1389
  input,
1352
1390
  init
1353
1391
  ]) {
1354
- return [input, applyOperationRequestOptions$1(init, this.operationType, this.requestOptions)];
1392
+ return [input, applyOperationRequestOptions(init, this.operationType, this.requestOptions)];
1355
1393
  }
1356
1394
  fetch() {
1357
1395
  try {
@@ -1359,7 +1397,7 @@ class HttpCacheControlCommand extends CacheControlCommand {
1359
1397
  this.services.fetch(...this.withRequestOptions(this.fetchParams))
1360
1398
  );
1361
1399
  } catch (reason) {
1362
- return resolvedPromiseLike$2(err$1(toError(reason)));
1400
+ return resolvedPromiseLike(err(toError(reason)));
1363
1401
  }
1364
1402
  }
1365
1403
  isSemanticNullResponse(response) {
@@ -1375,7 +1413,7 @@ class HttpCacheControlCommand extends CacheControlCommand {
1375
1413
  return toError(errorResponse.statusText);
1376
1414
  }
1377
1415
  processFetchReturnValue(json) {
1378
- return ok$2(json);
1416
+ return ok(json);
1379
1417
  }
1380
1418
  convertFetchResponseToData(response) {
1381
1419
  return response.then(
@@ -1383,10 +1421,10 @@ class HttpCacheControlCommand extends CacheControlCommand {
1383
1421
  if (response2.ok) {
1384
1422
  let resultPromise;
1385
1423
  if (this.isSemanticNullResponse(response2)) {
1386
- resultPromise = Promise.resolve(ok$2(null));
1424
+ resultPromise = Promise.resolve(ok(null));
1387
1425
  } else if (this.isUndeclaredNoBodyResponse(response2)) {
1388
1426
  resultPromise = Promise.resolve(
1389
- err$1(
1427
+ err(
1390
1428
  toError(
1391
1429
  `Unexpected ${response2.status} response: no-content status was not declared in the API specification. Declare this response in your OAS without a content property.`
1392
1430
  )
@@ -1397,7 +1435,7 @@ class HttpCacheControlCommand extends CacheControlCommand {
1397
1435
  (json) => {
1398
1436
  return this.processFetchReturnValue(json);
1399
1437
  },
1400
- (reason) => err$1(toError(reason))
1438
+ (reason) => err(toError(reason))
1401
1439
  );
1402
1440
  }
1403
1441
  return resultPromise.finally(() => {
@@ -1408,7 +1446,7 @@ class HttpCacheControlCommand extends CacheControlCommand {
1408
1446
  });
1409
1447
  } else {
1410
1448
  return this.coerceError(response2).then((coercedError) => {
1411
- return err$1(coercedError);
1449
+ return err(coercedError);
1412
1450
  }).finally(() => {
1413
1451
  try {
1414
1452
  this.afterRequestHooks({ statusCode: response2.status });
@@ -1417,10 +1455,11 @@ class HttpCacheControlCommand extends CacheControlCommand {
1417
1455
  });
1418
1456
  }
1419
1457
  },
1420
- (reason) => err$1(toError(reason))
1458
+ (reason) => err(toError(reason))
1421
1459
  );
1422
1460
  }
1423
1461
  }
1462
+
1424
1463
  class HttpNormalizedCacheControlCommand extends HttpCacheControlCommand {
1425
1464
  constructor(services) {
1426
1465
  super(services);
@@ -1429,11 +1468,11 @@ class HttpNormalizedCacheControlCommand extends HttpCacheControlCommand {
1429
1468
  readFromCache(cache) {
1430
1469
  const data = this.buildResultType().query(cache, this.buildQuery());
1431
1470
  if (data.isErr()) {
1432
- return resolvedPromiseLike$2(
1433
- err$1(new Error(`Failed to build data from type: ${stringify$3(data.error)}`))
1471
+ return resolvedPromiseLike(
1472
+ err(new Error(`Failed to build data from type: ${stringify$1(data.error)}`))
1434
1473
  );
1435
1474
  }
1436
- return resolvedPromiseLike$2(ok$2(data.value));
1475
+ return resolvedPromiseLike(ok(data.value));
1437
1476
  }
1438
1477
  writeToCache(cache, networkResult) {
1439
1478
  if (networkResult.isOk()) {
@@ -1442,7 +1481,7 @@ class HttpNormalizedCacheControlCommand extends HttpCacheControlCommand {
1442
1481
  this.buildWriteInput(networkResult.value)
1443
1482
  );
1444
1483
  }
1445
- return resolvedPromiseLike$2(void 0);
1484
+ return resolvedPromiseLike(void 0);
1446
1485
  }
1447
1486
  }
1448
1487
  function buildServiceDescriptor$n() {
@@ -1453,64 +1492,6 @@ function buildServiceDescriptor$n() {
1453
1492
  };
1454
1493
  }
1455
1494
 
1456
- class NetworkCommand extends BaseCommand {
1457
- constructor(services) {
1458
- super();
1459
- this.services = services;
1460
- this.subscriptions = [];
1461
- this.exposeSubscribeAndRefresh = false;
1462
- }
1463
- execute() {
1464
- const result = this.fetch();
1465
- if (this.exposeSubscribeAndRefresh) {
1466
- return this.fetchSubscribableResult(result);
1467
- }
1468
- return result;
1469
- }
1470
- fetchSubscribableResult(res) {
1471
- return res.then((networkResult) => {
1472
- return buildSubscribableResult$1(
1473
- networkResult,
1474
- (cb) => {
1475
- this.subscriptions.push(cb);
1476
- return () => {
1477
- this.subscriptions = this.subscriptions.filter((cb2) => cb2 !== cb);
1478
- };
1479
- },
1480
- () => this.refresh()
1481
- );
1482
- });
1483
- }
1484
- refresh() {
1485
- return this.execute().then((newResult) => {
1486
- if (isSubscribableResult(newResult)) {
1487
- const value = newResult.isOk() ? ok$2(newResult.value.data) : err$1(newResult.error.failure);
1488
- this.subscriptions.forEach((cb) => {
1489
- try {
1490
- cb(value);
1491
- } catch {
1492
- }
1493
- });
1494
- }
1495
- return ok$2(void 0);
1496
- });
1497
- }
1498
- async afterRequestHooks(_options) {
1499
- }
1500
- }
1501
- function applyOperationRequestOptions(init, operationType, requestOptions) {
1502
- if (operationType === void 0 && requestOptions === void 0) {
1503
- return init;
1504
- }
1505
- return {
1506
- ...init,
1507
- onestore: {
1508
- ...requestOptions,
1509
- ...init?.onestore,
1510
- ...operationType !== void 0 && { retrySafe: operationType === "query" }
1511
- }
1512
- };
1513
- }
1514
1495
  function fetchFromNetwork(getRequest, hooks, contextSeed) {
1515
1496
  try {
1516
1497
  const {
@@ -1525,7 +1506,7 @@ function fetchFromNetwork(getRequest, hooks, contextSeed) {
1525
1506
  const fetchCall = initWithSeed === void 0 ? services.fetch(input) : services.fetch(input, initWithSeed);
1526
1507
  return convertFetchResponseToData(fetchCall, hooks);
1527
1508
  } catch (reason) {
1528
- return resolvedPromiseLike$2(err$1(toError(reason)));
1509
+ return resolvedPromiseLike(err(toError(reason)));
1529
1510
  }
1530
1511
  }
1531
1512
  function convertFetchResponseToData(response, hooks) {
@@ -1534,10 +1515,10 @@ function convertFetchResponseToData(response, hooks) {
1534
1515
  if (response2.ok) {
1535
1516
  let resultPromise;
1536
1517
  if (hooks.isSemanticNullResponse(response2)) {
1537
- resultPromise = Promise.resolve(ok$2(null));
1518
+ resultPromise = Promise.resolve(ok(null));
1538
1519
  } else if (hooks.isProtocolNoBodyStatus(response2.status) && !hooks.isSemanticNullResponse(response2)) {
1539
1520
  resultPromise = Promise.resolve(
1540
- err$1(
1521
+ err(
1541
1522
  toError(
1542
1523
  `Unexpected ${response2.status} response: no-content status was not declared in the API specification. Declare this response in your OAS without a content property.`
1543
1524
  )
@@ -1545,8 +1526,8 @@ function convertFetchResponseToData(response, hooks) {
1545
1526
  );
1546
1527
  } else {
1547
1528
  resultPromise = response2.json().then(
1548
- (json) => ok$2(json),
1549
- (reason) => err$1(toError(reason))
1529
+ (json) => ok(json),
1530
+ (reason) => err(toError(reason))
1550
1531
  );
1551
1532
  }
1552
1533
  return resultPromise.finally(() => {
@@ -1557,7 +1538,7 @@ function convertFetchResponseToData(response, hooks) {
1557
1538
  });
1558
1539
  } else {
1559
1540
  return hooks.coerceError(response2).then((coercedError) => {
1560
- return err$1(coercedError);
1541
+ return err(coercedError);
1561
1542
  }).finally(() => {
1562
1543
  try {
1563
1544
  hooks.afterRequestHooks({ statusCode: response2.status });
@@ -1566,12 +1547,12 @@ function convertFetchResponseToData(response, hooks) {
1566
1547
  });
1567
1548
  }
1568
1549
  },
1569
- (reason) => err$1(toError(reason))
1550
+ (reason) => err(toError(reason))
1570
1551
  );
1571
1552
  }
1572
1553
  function completeRefresh(result, getSubscriptions, options = {}) {
1573
1554
  const { previousResult } = options;
1574
- if (!options.suppressEqualSuccesses || result.isErr() || !previousResult || previousResult.isErr() || !deepEquals$2(previousResult.value, result.value)) {
1555
+ if (!options.suppressEqualSuccesses || result.isErr() || !previousResult || previousResult.isErr() || !deepEquals$1(previousResult.value, result.value)) {
1575
1556
  const subscriptions = getSubscriptions();
1576
1557
  const callbacks = options.skipRemovedSubscriptions ? [...subscriptions] : subscriptions;
1577
1558
  callbacks.forEach((callback) => {
@@ -1582,7 +1563,7 @@ function completeRefresh(result, getSubscriptions, options = {}) {
1582
1563
  }
1583
1564
  });
1584
1565
  }
1585
- return options.reportFailure && result.isErr() ? result : ok$2(void 0);
1566
+ return options.reportFailure && result.isErr() ? result : ok(void 0);
1586
1567
  }
1587
1568
  function isAbortableCommand(command) {
1588
1569
  return !!command && typeof command === "object" && "isAbortableCommand" in command && command.isAbortableCommand === true;
@@ -1692,8 +1673,8 @@ const _FetchNetworkCommand = class _FetchNetworkCommand extends NetworkCommand {
1692
1673
  }
1693
1674
  refresh() {
1694
1675
  return this.execute().then((newResult) => {
1695
- if (!isSubscribableResult(newResult)) return ok$2(void 0);
1696
- const result = newResult.isOk() ? ok$2(newResult.value.data) : err$1(newResult.error.failure);
1676
+ if (!isSubscribableResult(newResult)) return ok(void 0);
1677
+ const result = newResult.isOk() ? ok(newResult.value.data) : err(newResult.error.failure);
1697
1678
  return completeRefresh(result, () => this.subscriptions);
1698
1679
  });
1699
1680
  }
@@ -1728,21 +1709,21 @@ class StreamingCommand extends BaseCommand {
1728
1709
  try {
1729
1710
  return this.convertFetchStreamResponseToData(this.services.fetch(...this.fetchParams));
1730
1711
  } catch (reason) {
1731
- return resolvedPromiseLike$2(err$1(toError(reason)));
1712
+ return resolvedPromiseLike(err(toError(reason)));
1732
1713
  }
1733
1714
  }
1734
1715
  convertFetchStreamResponseToData(response) {
1735
1716
  return response.then(
1736
1717
  (response2) => {
1737
1718
  if (response2.ok && response2.body) {
1738
- return ok$2(this.decodeByteStream(response2.body));
1719
+ return ok(this.decodeByteStream(response2.body));
1739
1720
  } else {
1740
- return err$1(
1721
+ return err(
1741
1722
  toError(response2.ok ? "Response body not present" : response2.statusText)
1742
1723
  );
1743
1724
  }
1744
1725
  },
1745
- (reason) => err$1(toError(reason))
1726
+ (reason) => err(toError(reason))
1746
1727
  );
1747
1728
  }
1748
1729
  }
@@ -2157,12 +2138,7 @@ function buildServiceDescriptor$i(logger) {
2157
2138
  };
2158
2139
  }
2159
2140
 
2160
- const { stringify: stringify$2, parse: parse$1 } = JSON;
2161
- function deepCopy$1(x) {
2162
- const stringified = stringify$2(x);
2163
- return stringified ? parse$1(stringified) : void 0;
2164
- }
2165
- let DefaultRecordableCache$1 = class DefaultRecordableCache {
2141
+ class DefaultRecordableCache {
2166
2142
  constructor(baseCache) {
2167
2143
  this.baseCache = baseCache;
2168
2144
  this.keysRead = /* @__PURE__ */ new Set();
@@ -2181,7 +2157,7 @@ let DefaultRecordableCache$1 = class DefaultRecordableCache {
2181
2157
  this.missingKeysRead.add(key);
2182
2158
  }
2183
2159
  if (options?.copy) {
2184
- return deepCopy$1(value);
2160
+ return deepCopy(value);
2185
2161
  }
2186
2162
  return value;
2187
2163
  }
@@ -2207,13 +2183,13 @@ let DefaultRecordableCache$1 = class DefaultRecordableCache {
2207
2183
  return new DefaultRecordableCache(this);
2208
2184
  }
2209
2185
  filter(predicate) {
2210
- return new DefaultFilteredCache$1(this, predicate);
2186
+ return new DefaultFilteredCache(this, predicate);
2211
2187
  }
2212
2188
  buildFixedTimeWritableCache(generatedTime) {
2213
- return new FixedTimeWritableCache$1(this, generatedTime);
2189
+ return new FixedTimeWritableCache(this, generatedTime);
2214
2190
  }
2215
- };
2216
- let DefaultFilteredCache$1 = class DefaultFilteredCache {
2191
+ }
2192
+ class DefaultFilteredCache {
2217
2193
  constructor(baseCache, predicate) {
2218
2194
  this.baseCache = baseCache;
2219
2195
  this.predicate = predicate;
@@ -2225,7 +2201,7 @@ let DefaultFilteredCache$1 = class DefaultFilteredCache {
2225
2201
  const result = this.baseCache.get(key);
2226
2202
  if (result && this.predicate(key, result)) {
2227
2203
  if (options?.copy) {
2228
- return deepCopy$1(result);
2204
+ return deepCopy(result);
2229
2205
  }
2230
2206
  return result;
2231
2207
  }
@@ -2247,7 +2223,7 @@ let DefaultFilteredCache$1 = class DefaultFilteredCache {
2247
2223
  return this.getFilteredEntries();
2248
2224
  }
2249
2225
  record() {
2250
- return new DefaultRecordableCache$1(this);
2226
+ return new DefaultRecordableCache(this);
2251
2227
  }
2252
2228
  filter(predicate) {
2253
2229
  return new DefaultFilteredCache(this, predicate);
@@ -2267,10 +2243,10 @@ let DefaultFilteredCache$1 = class DefaultFilteredCache {
2267
2243
  return filteredKeySet;
2268
2244
  }
2269
2245
  buildFixedTimeWritableCache(generatedTime) {
2270
- return new FixedTimeWritableCache$1(this, generatedTime);
2246
+ return new FixedTimeWritableCache(this, generatedTime);
2271
2247
  }
2272
- };
2273
- let FixedTimeWritableCache$1 = class FixedTimeWritableCache {
2248
+ }
2249
+ class FixedTimeWritableCache {
2274
2250
  constructor(baseCache, generatedTime) {
2275
2251
  this.baseCache = baseCache;
2276
2252
  this.generatedTime = generatedTime;
@@ -2306,22 +2282,22 @@ let FixedTimeWritableCache$1 = class FixedTimeWritableCache {
2306
2282
  return this.baseCache.entries();
2307
2283
  }
2308
2284
  record() {
2309
- return new DefaultRecordableCache$1(this);
2285
+ return new DefaultRecordableCache(this);
2310
2286
  }
2311
2287
  filter(predicate) {
2312
- return new DefaultFilteredCache$1(this, predicate);
2288
+ return new DefaultFilteredCache(this, predicate);
2313
2289
  }
2314
2290
  buildFixedTimeWritableCache(generatedTime) {
2315
2291
  return new FixedTimeWritableCache(this, generatedTime);
2316
2292
  }
2317
- };
2318
- let DefaultCache$1 = class DefaultCache {
2293
+ }
2294
+ class DefaultCache {
2319
2295
  constructor() {
2320
2296
  this.data = {};
2321
2297
  }
2322
2298
  get(key, options) {
2323
2299
  if (options?.copy) {
2324
- return deepCopy$1(this.data[key]);
2300
+ return deepCopy(this.data[key]);
2325
2301
  }
2326
2302
  return this.data[key];
2327
2303
  }
@@ -2383,20 +2359,20 @@ let DefaultCache$1 = class DefaultCache {
2383
2359
  return Object.entries(this.data);
2384
2360
  }
2385
2361
  record() {
2386
- return new DefaultRecordableCache$1(this);
2362
+ return new DefaultRecordableCache(this);
2387
2363
  }
2388
2364
  filter(predicate) {
2389
- return new DefaultFilteredCache$1(this, predicate);
2365
+ return new DefaultFilteredCache(this, predicate);
2390
2366
  }
2391
2367
  buildFixedTimeWritableCache(generatedTime) {
2392
- return new FixedTimeWritableCache$1(this, generatedTime);
2368
+ return new FixedTimeWritableCache(this, generatedTime);
2393
2369
  }
2394
- };
2370
+ }
2395
2371
  function buildServiceDescriptor$h() {
2396
2372
  return {
2397
2373
  type: "cache",
2398
2374
  version: "1.0",
2399
- service: new DefaultCache$1()
2375
+ service: new DefaultCache()
2400
2376
  };
2401
2377
  }
2402
2378
 
@@ -2424,7 +2400,7 @@ class NoCacheCacheControlStrategy extends CacheControlStrategy {
2424
2400
  const tempCache = this.filteredCache;
2425
2401
  return new Promise(async (resolve, reject) => {
2426
2402
  try {
2427
- let readResult = ok$2(void 0);
2403
+ let readResult = ok(void 0);
2428
2404
  for await (const rfnResult of this.requestRunner.requestFromNetwork()) {
2429
2405
  if (rfnResult) {
2430
2406
  const result = await this.services.cacheInclusionPolicy.write({
@@ -2462,13 +2438,13 @@ class MaxAgeCacheControlStrategy extends CacheControlStrategy {
2462
2438
  startTime,
2463
2439
  options?.instrumentationAttributes
2464
2440
  );
2465
- return ok$2(void 0);
2441
+ return ok(void 0);
2466
2442
  }
2467
2443
  this.collectCacheMissInstrumentation(startTime, options?.instrumentationAttributes);
2468
2444
  const tempCache = this.filteredCache;
2469
2445
  return new Promise(async (resolve, reject) => {
2470
2446
  try {
2471
- let readResult = ok$2(void 0);
2447
+ let readResult = ok(void 0);
2472
2448
  for await (const rfnResult of this.requestRunner.requestFromNetwork()) {
2473
2449
  if (rfnResult) {
2474
2450
  const result = await this.services.cacheInclusionPolicy.write({
@@ -2476,7 +2452,7 @@ class MaxAgeCacheControlStrategy extends CacheControlStrategy {
2476
2452
  writeToL1: (l1) => this.requestRunner.writeToCache(l1, rfnResult)
2477
2453
  });
2478
2454
  if (result.isErr()) {
2479
- return resolve(err$1(result.error));
2455
+ return resolve(err(result.error));
2480
2456
  }
2481
2457
  }
2482
2458
  readResult = await this.services.cacheInclusionPolicy.read({
@@ -2484,7 +2460,7 @@ class MaxAgeCacheControlStrategy extends CacheControlStrategy {
2484
2460
  readFromL1: (l1) => this.requestRunner.readFromCache(l1)
2485
2461
  });
2486
2462
  if (readResult.isOk()) {
2487
- resolve(ok$2(void 0));
2463
+ resolve(ok(void 0));
2488
2464
  }
2489
2465
  }
2490
2466
  return resolve(readResult);
@@ -2536,7 +2512,7 @@ class OnlyIfCachedCacheControlStrategy extends CacheControlStrategy {
2536
2512
  startTime,
2537
2513
  options?.instrumentationAttributes
2538
2514
  );
2539
- return ok$2(void 0);
2515
+ return ok(void 0);
2540
2516
  }
2541
2517
  this.collectCacheMissInstrumentation(startTime, options?.instrumentationAttributes);
2542
2518
  const error = new UserVisibleError(
@@ -2544,7 +2520,7 @@ class OnlyIfCachedCacheControlStrategy extends CacheControlStrategy {
2544
2520
  error: "Cache miss for only-if-cached request"
2545
2521
  })
2546
2522
  );
2547
- return err$1(error);
2523
+ return err(error);
2548
2524
  });
2549
2525
  }
2550
2526
  get expiredChecks() {
@@ -2649,14 +2625,14 @@ class DefaultPubSubService {
2649
2625
  return;
2650
2626
  }
2651
2627
  const returnVal = subscription.callback.call(subscription, event);
2652
- if (isPromiseLike$2(returnVal)) {
2628
+ if (isPromiseLike(returnVal)) {
2653
2629
  promises.push(returnVal);
2654
2630
  }
2655
2631
  });
2656
2632
  if (promises.length > 0) {
2657
2633
  return Promise.all(promises).then(() => void 0);
2658
2634
  }
2659
- return resolvedPromiseLike$2(void 0);
2635
+ return resolvedPromiseLike(void 0);
2660
2636
  }
2661
2637
  getSubscriptions(event) {
2662
2638
  const eventTypeSubscriptions = this.subscriptions.get(event.type);
@@ -2785,7 +2761,7 @@ function buildServiceDescriptor$d(luvio) {
2785
2761
  },
2786
2762
  };
2787
2763
  }
2788
- // version: 1.469.0-efd4e5a180
2764
+ // version: 1.471.0-2898c91740
2789
2765
 
2790
2766
  class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheControlCommand {
2791
2767
  constructor(config, documentRootType, services) {
@@ -2824,15 +2800,15 @@ class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheContro
2824
2800
  }
2825
2801
  processAuraReturnValue(auraReturnValue) {
2826
2802
  if (this.responseHasErrors(auraReturnValue)) {
2827
- return err$1(new UserVisibleError(auraReturnValue));
2803
+ return err(new UserVisibleError(auraReturnValue));
2828
2804
  }
2829
- return ok$2(auraReturnValue);
2805
+ return ok(auraReturnValue);
2830
2806
  }
2831
2807
  processFetchReturnValue(json) {
2832
2808
  if (this.responseHasErrors(json)) {
2833
- return err$1(new UserVisibleError(json));
2809
+ return err(new UserVisibleError(json));
2834
2810
  }
2835
- return ok$2(json);
2811
+ return ok(json);
2836
2812
  }
2837
2813
  /**
2838
2814
  * Optional body wrapper name for aura requests.
@@ -2893,14 +2869,14 @@ class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheContro
2893
2869
  ),
2894
2870
  (errs) => this.coerceAuraErrors(errs)
2895
2871
  ).then((result) => {
2896
- return buildSubscribableResult$1(result, this.buildSubscribe(), () => this.refresh());
2872
+ return buildSubscribableResult(result, this.buildSubscribe(), () => this.refresh());
2897
2873
  });
2898
2874
  } else if (this.shouldUseFetch()) {
2899
2875
  const params = this.withRequestOptions(this.originalFetchParams);
2900
2876
  try {
2901
2877
  return this.convertFetchResponseToData(this.services.fetch(...params)).then(
2902
2878
  (result) => {
2903
- return buildSubscribableResult$1(
2879
+ return buildSubscribableResult(
2904
2880
  result,
2905
2881
  this.buildSubscribe(),
2906
2882
  () => this.refresh()
@@ -2908,18 +2884,18 @@ class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheContro
2908
2884
  }
2909
2885
  );
2910
2886
  } catch (reason) {
2911
- return resolvedPromiseLike$2(
2912
- buildSubscribableResult$1(
2913
- err$1(toError(reason)),
2887
+ return resolvedPromiseLike(
2888
+ buildSubscribableResult(
2889
+ err(toError(reason)),
2914
2890
  this.buildSubscribe(),
2915
2891
  () => this.refresh()
2916
2892
  )
2917
2893
  );
2918
2894
  }
2919
2895
  }
2920
- return resolvedPromiseLike$2(
2921
- buildSubscribableResult$1(
2922
- err$1(toError("Aura/Fetch network services not found")),
2896
+ return resolvedPromiseLike(
2897
+ buildSubscribableResult(
2898
+ err(toError("Aura/Fetch network services not found")),
2923
2899
  this.buildSubscribe(),
2924
2900
  () => this.refresh()
2925
2901
  )
@@ -3045,15 +3021,15 @@ class HttpGraphQLNormalizedCacheControlCommand extends HttpNormalizedCacheContro
3045
3021
  }
3046
3022
  processFetchReturnValue(json) {
3047
3023
  if (json.errors && json.errors.length > 0) {
3048
- return err$1(new UserVisibleError(json));
3024
+ return err(new UserVisibleError(json));
3049
3025
  }
3050
- return ok$2(json);
3026
+ return ok(json);
3051
3027
  }
3052
3028
  runOriginalRequest() {
3053
3029
  return this.convertFetchResponseToData(
3054
3030
  this.services.fetch(...this.withRequestOptions(this.originalFetchParams))
3055
3031
  ).then((result) => {
3056
- return buildSubscribableResult$1(result, this.buildSubscribe(), () => this.refresh());
3032
+ return buildSubscribableResult(result, this.buildSubscribe(), () => this.refresh());
3057
3033
  });
3058
3034
  }
3059
3035
  // Any changes to this method should most likely be duplicated in the aura command as well
@@ -3124,7 +3100,7 @@ function buildServiceDescriptor$9(notifyRecordUpdateAvailable, getNormalizedLuvi
3124
3100
  },
3125
3101
  };
3126
3102
  }
3127
- // version: 1.469.0-efd4e5a180
3103
+ // version: 1.471.0-2898c91740
3128
3104
 
3129
3105
  class RetryService {
3130
3106
  constructor(defaultRetryPolicy) {
@@ -3320,12 +3296,48 @@ function buildRenewableResourceManagerDescriptor(type, service) {
3320
3296
  };
3321
3297
  }
3322
3298
 
3323
- function isUserVisibleError(error) {
3324
- return error instanceof Error && "type" in error && error.type === "user-visible";
3299
+ /**
3300
+ * Helpers for reaching the Aura framework from the LDS Aura runtime.
3301
+ *
3302
+ * `window.$A` is only present when the runtime is hosted inside Aura (LEX or
3303
+ * an Aura site); in tests and non-Aura runtimes it is absent. `getAura()`
3304
+ * centralizes the guarded lookup so the `$A` access lives in one place instead
3305
+ * of being duplicated across modules.
3306
+ */
3307
+ /**
3308
+ * Returns the Aura framework global (`window.$A`) when running inside Aura
3309
+ * (LEX or an Aura site), or `undefined` in tests and non-Aura runtimes.
3310
+ * Centralizes the guarded `$A` lookup so callers reach for it once and read
3311
+ * intent instead of repeating `typeof window` / `$A` guards.
3312
+ */
3313
+ function getAura() {
3314
+ if (typeof window === 'undefined') {
3315
+ return undefined;
3316
+ }
3317
+ return window.$A;
3325
3318
  }
3326
- function throwUserlandError(error) {
3327
- logError(error);
3328
- throw buildUserlandError(error);
3319
+ /**
3320
+ * Fires an Aura application-level event (e.g. `aura:invalidSession`). Thin
3321
+ * pass-through to the `aura` framework module so callers depend on this util
3322
+ * rather than importing `aura` directly.
3323
+ */
3324
+ function dispatchGlobalEvent(...args) {
3325
+ dispatchGlobalEvent$1(...args);
3326
+ }
3327
+ /**
3328
+ * Returns `$A.clientService` when running inside an Aura environment, or
3329
+ * `undefined` otherwise. Defensive: never throws.
3330
+ */
3331
+ function getAuraClientService() {
3332
+ return getAura()?.clientService;
3333
+ }
3334
+
3335
+ function isUserVisibleError(error) {
3336
+ return error instanceof Error && "type" in error && error.type === "user-visible";
3337
+ }
3338
+ function throwUserlandError(error) {
3339
+ logError(error);
3340
+ throw buildUserlandError(error);
3329
3341
  }
3330
3342
  function emitError(callback, error) {
3331
3343
  logError(error);
@@ -3547,7 +3559,7 @@ class LegacyImperativeBindingsService {
3547
3559
  return { invoke, subscribe };
3548
3560
  }
3549
3561
  }
3550
- function buildServiceDescriptor$3$1() {
3562
+ function buildServiceDescriptor$3() {
3551
3563
  return {
3552
3564
  type: "legacyImperativeBindings",
3553
3565
  version: "1.0",
@@ -3747,7 +3759,7 @@ class GraphQLLegacyImperativeBindingsService {
3747
3759
  return { invoke, subscribe };
3748
3760
  }
3749
3761
  }
3750
- function buildServiceDescriptor$1$2() {
3762
+ function buildServiceDescriptor$1$1() {
3751
3763
  return {
3752
3764
  type: "graphQLLegacyImperativeBindings",
3753
3765
  version: "1.0",
@@ -3966,7 +3978,7 @@ class CommandWireAdapterConstructor {
3966
3978
  this.emit(updatedResult);
3967
3979
  });
3968
3980
  this.refresh = value.refresh;
3969
- this.emit(ok$2(value.data));
3981
+ this.emit(ok(value.data));
3970
3982
  } else {
3971
3983
  this.emit(result);
3972
3984
  }
@@ -4040,7 +4052,7 @@ class LWCWireBindingsService {
4040
4052
  };
4041
4053
  }
4042
4054
  }
4043
- function buildServiceDescriptor$1$1() {
4055
+ function buildServiceDescriptor$1() {
4044
4056
  return {
4045
4057
  type: "lwcWireBindings",
4046
4058
  version: "1.0",
@@ -4146,7 +4158,7 @@ class LWCGraphQLWireBindingsService {
4146
4158
  };
4147
4159
  }
4148
4160
  }
4149
- function buildServiceDescriptor$3() {
4161
+ function buildServiceDescriptor$2() {
4150
4162
  return {
4151
4163
  type: "lwcGraphQLWireBindings",
4152
4164
  version: "1.0",
@@ -4164,7 +4176,7 @@ function createLockerCompatibleWireConstructor(DelegateCtor) {
4164
4176
  return Constructor;
4165
4177
  }
4166
4178
  function buildLWCWireBindingsServiceDescriptor() {
4167
- const base = buildServiceDescriptor$1$1();
4179
+ const base = buildServiceDescriptor$1();
4168
4180
  const originalBind = base.service.bind.bind(base.service);
4169
4181
  const bind = (...args) => {
4170
4182
  const ctor = originalBind(...args);
@@ -4179,7 +4191,7 @@ function buildLWCWireBindingsServiceDescriptor() {
4179
4191
  };
4180
4192
  }
4181
4193
  function buildLWCGraphQLWireBindingsServiceDescriptor() {
4182
- const base = buildServiceDescriptor$3();
4194
+ const base = buildServiceDescriptor$2();
4183
4195
  const originalBind = base.service.bind.bind(base.service);
4184
4196
  const bind = (...args) => {
4185
4197
  const ctor = originalBind(...args);
@@ -4194,54 +4206,8 @@ function buildLWCGraphQLWireBindingsServiceDescriptor() {
4194
4206
  };
4195
4207
  }
4196
4208
 
4197
- function e(e2) {
4198
- this.message = e2;
4199
- }
4200
- e.prototype = new Error(), e.prototype.name = "InvalidCharacterError";
4201
- var r = "undefined" != typeof window && window.atob && window.atob.bind(window) || function(r2) {
4202
- var t2 = String(r2).replace(/=+$/, "");
4203
- if (t2.length % 4 == 1) throw new e("'atob' failed: The string to be decoded is not correctly encoded.");
4204
- for (var n2, o2, a = 0, i = 0, c = ""; o2 = t2.charAt(i++); ~o2 && (n2 = a % 4 ? 64 * n2 + o2 : o2, a++ % 4) ? c += String.fromCharCode(255 & n2 >> (-2 * a & 6)) : 0) o2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o2);
4205
- return c;
4206
- };
4207
- function t(e2) {
4208
- var t2 = e2.replace(/-/g, "+").replace(/_/g, "/");
4209
- switch (t2.length % 4) {
4210
- case 0:
4211
- break;
4212
- case 2:
4213
- t2 += "==";
4214
- break;
4215
- case 3:
4216
- t2 += "=";
4217
- break;
4218
- default:
4219
- throw "Illegal base64url string!";
4220
- }
4221
- try {
4222
- return (function(e3) {
4223
- return decodeURIComponent(r(e3).replace(/(.)/g, (function(e4, r2) {
4224
- var t3 = r2.charCodeAt(0).toString(16).toUpperCase();
4225
- return t3.length < 2 && (t3 = "0" + t3), "%" + t3;
4226
- })));
4227
- })(t2);
4228
- } catch (e3) {
4229
- return r(t2);
4230
- }
4231
- }
4232
- function n(e2) {
4233
- this.message = e2;
4234
- }
4235
- function o(e2, r2) {
4236
- if ("string" != typeof e2) throw new n("Invalid token specified");
4237
- var o2 = true === (r2 = r2 || {}).header ? 0 : 1;
4238
- try {
4239
- return JSON.parse(t(e2.split(".")[o2]));
4240
- } catch (e3) {
4241
- throw new n("Invalid token specified: " + e3.message);
4242
- }
4243
- }
4244
- n.prototype = new Error(), n.prototype.name = "InvalidTokenError";
4209
+ function e(e){this.message=e;}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(r){var t=String(r).replace(/=+$/,"");if(t.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,a=0,i=0,c="";o=t.charAt(i++);~o&&(n=a%4?64*n+o:o,a++%4)?c+=String.fromCharCode(255&n>>(-2*a&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return c};function t(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw "Illegal base64url string!"}try{return function(e){return decodeURIComponent(r(e).replace(/(.)/g,(function(e,r){var t=r.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0"+t),"%"+t})))}(t)}catch(e){return r(t)}}function n(e){this.message=e;}function o(e,r){if("string"!=typeof e)throw new n("Invalid token specified");var o=!0===(r=r||{}).header?0:1;try{return JSON.parse(t(e.split(".")[o]))}catch(e){throw new n("Invalid token specified: "+e.message)}}n.prototype=new Error,n.prototype.name="InvalidTokenError";
4210
+
4245
4211
  class JwtToken {
4246
4212
  /**
4247
4213
  * Create a new JwtToken.
@@ -4485,8 +4451,8 @@ class JwtRepository {
4485
4451
  this.observers.forEach((cb) => {
4486
4452
  try {
4487
4453
  cb.call(void 0, token);
4488
- } catch (e2) {
4489
- this.logger.error(e2.message);
4454
+ } catch (e) {
4455
+ this.logger.error(e.message);
4490
4456
  }
4491
4457
  });
4492
4458
  }
@@ -4567,163 +4533,6 @@ class JwtManager {
4567
4533
  }
4568
4534
  }
4569
4535
 
4570
- function buildServiceDescriptor$2(interceptors = {
4571
- request: [],
4572
- retry: void 0,
4573
- response: [],
4574
- finally: []
4575
- }, retryService) {
4576
- return {
4577
- type: "fetch",
4578
- version: "1.0",
4579
- service: function(input, init) {
4580
- let contextSeed;
4581
- let cleanInit = init;
4582
- if (init !== void 0 && "__contextSeed" in init) {
4583
- const { __contextSeed, ...initWithoutSeed } = init;
4584
- contextSeed = __contextSeed;
4585
- cleanInit = Object.keys(initWithoutSeed).length === 0 ? void 0 : initWithoutSeed;
4586
- }
4587
- const fetchArgs = cleanInit === void 0 ? [input] : [input, cleanInit];
4588
- const baseContext = interceptors.createContext?.();
4589
- const onestore = cleanInit?.onestore;
4590
- const context = contextSeed === void 0 && onestore === void 0 ? baseContext : {
4591
- ...baseContext,
4592
- ...contextSeed,
4593
- ...onestore !== void 0 && { onestore }
4594
- };
4595
- const {
4596
- request: requestInterceptors = [],
4597
- retry: retryInterceptor = void 0,
4598
- response: responseInterceptors = [],
4599
- finally: finallyInterceptors = []
4600
- } = interceptors;
4601
- const pending = requestInterceptors.reduce(
4602
- (previousPromise, interceptor) => previousPromise.then((args) => interceptor(args, context)),
4603
- resolvedPromiseLike$2(fetchArgs)
4604
- );
4605
- return Promise.resolve(pending).then((args) => {
4606
- if (retryInterceptor) {
4607
- return retryInterceptor(args, retryService, context);
4608
- } else {
4609
- if (retryService) {
4610
- return retryService.applyRetry(() => fetch(...args));
4611
- }
4612
- return fetch(...args);
4613
- }
4614
- }).then((response) => {
4615
- return responseInterceptors.reduce(
4616
- (previousPromise, interceptor) => previousPromise.then((response2) => interceptor(response2, context)),
4617
- resolvedPromiseLike$2(response)
4618
- );
4619
- }).finally(() => {
4620
- if (finallyInterceptors.length > 0) {
4621
- return finallyInterceptors.reduce(
4622
- (previousPromise, interceptor) => previousPromise.then(() => interceptor(context)),
4623
- Promise.resolve()
4624
- );
4625
- }
4626
- });
4627
- }
4628
- };
4629
- }
4630
- let textEncoder;
4631
- function getTextEncoder() {
4632
- if (!textEncoder) {
4633
- if (typeof TextEncoder === "undefined") {
4634
- throw new Error(
4635
- "TextEncoder is not available in this environment. Request body compression requires TextEncoder support."
4636
- );
4637
- }
4638
- textEncoder = new TextEncoder();
4639
- }
4640
- return textEncoder;
4641
- }
4642
- function buildCompressionInterceptor(defaultConfig) {
4643
- return async (args) => {
4644
- const [resource, options = {}] = args;
4645
- const config = options.onestore?.compression ?? defaultConfig;
4646
- if (config === void 0) {
4647
- return resolvedPromiseLike$2(args);
4648
- }
4649
- const threshold = config.threshold ?? 1024;
4650
- if (!options.body || typeof options.body !== "string") {
4651
- return resolvedPromiseLike$2(args);
4652
- }
4653
- if (typeof CompressionStream === "undefined") {
4654
- return resolvedPromiseLike$2(args);
4655
- }
4656
- const headers = new Headers(options.headers);
4657
- if (headers.has("Content-Encoding")) {
4658
- return resolvedPromiseLike$2(args);
4659
- }
4660
- const encodedBody = getTextEncoder().encode(options.body);
4661
- if (encodedBody.byteLength < threshold) {
4662
- return resolvedPromiseLike$2(args);
4663
- }
4664
- try {
4665
- const stream = new Blob([encodedBody]).stream().pipeThrough(new CompressionStream(config.algorithm));
4666
- const compressedBody = await new Response(stream).blob();
4667
- headers.set("Content-Encoding", config.algorithm);
4668
- headers.delete("Content-Length");
4669
- const compressedOptions = {
4670
- ...options,
4671
- body: compressedBody,
4672
- headers
4673
- };
4674
- return resolvedPromiseLike$2([resource, compressedOptions]);
4675
- } catch {
4676
- return resolvedPromiseLike$2(args);
4677
- }
4678
- };
4679
- }
4680
- function setHeader(headerName, headerValue, [resource, options = {}], {
4681
- throwOnExisting = false,
4682
- errorMessage = `Unexpected ${headerName} header encountered`
4683
- } = {}) {
4684
- let hasHeaderBeenSet = false;
4685
- if (resource instanceof Request && !options?.headers) {
4686
- if (throwOnExisting && resource.headers.has(headerName)) {
4687
- throw new Error(errorMessage);
4688
- }
4689
- resource.headers.set(headerName, headerValue);
4690
- hasHeaderBeenSet = true;
4691
- }
4692
- if (options?.headers instanceof Headers) {
4693
- if (throwOnExisting && options.headers.has(headerName)) {
4694
- throw new Error(errorMessage);
4695
- }
4696
- options.headers.set(headerName, headerValue);
4697
- } else {
4698
- if (throwOnExisting && options?.headers && Reflect.has(options.headers, headerName)) {
4699
- throw new Error(errorMessage);
4700
- }
4701
- if (!hasHeaderBeenSet) {
4702
- options.headers = {
4703
- ...options?.headers,
4704
- [headerName]: headerValue
4705
- };
4706
- }
4707
- }
4708
- return [resource, options];
4709
- }
4710
- const UNEXPECTED_AUTHORIZATION_HEADER_MESSAGE = "Unexpected Authorization header encountered. To specify a custom Authorization header, use a Fetch service that is not configured with JwtRequestHeaderInterceptor";
4711
- function setHeaderAuthorization({ token }, fetchParams) {
4712
- const authorizationValue = `Bearer ${token}`;
4713
- return setHeader("Authorization", authorizationValue, fetchParams, {
4714
- throwOnExisting: true,
4715
- errorMessage: UNEXPECTED_AUTHORIZATION_HEADER_MESSAGE
4716
- });
4717
- }
4718
- function buildJwtRequestHeaderInterceptor(jwtManager, jwtRequestModifier = (_e, fetchArgs) => fetchArgs) {
4719
- return (args) => {
4720
- return resolvedPromiseLike$2(jwtManager.getJwt()).then((token) => {
4721
- const fetchArgsWithRequestHeaderAuthorization = setHeaderAuthorization(token, args);
4722
- return token.extraInfo ? jwtRequestModifier(token.extraInfo, fetchArgsWithRequestHeaderAuthorization) : fetchArgsWithRequestHeaderAuthorization;
4723
- });
4724
- };
4725
- }
4726
-
4727
4536
  var SnapshotState;
4728
4537
  (function (SnapshotState) {
4729
4538
  SnapshotState["Fulfilled"] = "Fulfilled";
@@ -4921,330 +4730,21 @@ function generateQueryString(params) {
4921
4730
  }
4922
4731
  searchParams.append(key, String(value));
4923
4732
  }
4924
- const queryString = searchParams.toString();
4925
- if (queryString.length > 0) {
4926
- return `?${queryString}`;
4927
- }
4928
- return '';
4929
- }
4930
- function generateHeaders(headers) {
4931
- const fetchHeaders = new Headers();
4932
- for (const key of keys$1(headers)) {
4933
- fetchHeaders.set(key, headers[key]);
4934
- }
4935
- return fetchHeaders;
4936
- }
4937
-
4938
- class CacheInclusionPolicyService {
4939
- }
4940
- class Ok {
4941
- constructor(value) {
4942
- this.value = value;
4943
- }
4944
- isOk() {
4945
- return true;
4946
- }
4947
- isErr() {
4948
- return !this.isOk();
4949
- }
4950
- }
4951
- const ok = (value) => new Ok(value);
4952
- function setDifference(setA, setB) {
4953
- const differenceSet = /* @__PURE__ */ new Set();
4954
- for (const element of setA) {
4955
- if (!setB.has(element)) {
4956
- differenceSet.add(element);
4957
- }
4958
- }
4959
- return differenceSet;
4960
- }
4961
- function addAllToSet(targetSet, sourceSet) {
4962
- for (const element of sourceSet) {
4963
- targetSet.add(element);
4964
- }
4965
- }
4966
- function resolvedPromiseLike(result) {
4967
- if (isPromiseLike(result)) {
4968
- return result.then(
4969
- (nextResult) => nextResult
4970
- );
4971
- }
4972
- return {
4973
- then: (onFulfilled, _onRejected) => {
4974
- try {
4975
- return resolvedPromiseLike(onFulfilled(result));
4976
- } catch (e) {
4977
- if (onFulfilled === void 0) {
4978
- return resolvedPromiseLike(result);
4979
- }
4980
- return rejectedPromiseLike(e);
4981
- }
4982
- }
4983
- };
4984
- }
4985
- function rejectedPromiseLike(reason) {
4986
- if (isPromiseLike(reason)) {
4987
- return reason.then(
4988
- (nextResult) => nextResult
4989
- );
4990
- }
4991
- return {
4992
- then: (_onFulfilled, onRejected) => {
4993
- if (typeof onRejected === "function") {
4994
- try {
4995
- return resolvedPromiseLike(onRejected(reason));
4996
- } catch (e) {
4997
- return rejectedPromiseLike(e);
4998
- }
4999
- }
5000
- return rejectedPromiseLike(reason);
5001
- }
5002
- };
5003
- }
5004
- function isPromiseLike(x) {
5005
- return typeof x?.then === "function";
5006
- }
5007
- const { stringify: stringify$1, parse } = JSON;
5008
- function deepCopy(x) {
5009
- const stringified = stringify$1(x);
5010
- return stringified ? parse(stringified) : void 0;
5011
- }
5012
- class DefaultRecordableCache {
5013
- constructor(baseCache) {
5014
- this.baseCache = baseCache;
5015
- this.keysRead = /* @__PURE__ */ new Set();
5016
- this.missingKeysRead = /* @__PURE__ */ new Set();
5017
- this.keysUpdated = /* @__PURE__ */ new Set();
5018
- this.metadataKeysUpdated = /* @__PURE__ */ new Set();
5019
- }
5020
- delete(key) {
5021
- this.keysUpdated.add(key);
5022
- this.baseCache.delete(key);
5023
- }
5024
- get(key, options) {
5025
- this.keysRead.add(key);
5026
- const value = this.baseCache.get(key);
5027
- if (value === void 0) {
5028
- this.missingKeysRead.add(key);
5029
- }
5030
- if (options?.copy) {
5031
- return deepCopy(value);
5032
- }
5033
- return value;
5034
- }
5035
- set(key, value) {
5036
- this.keysUpdated.add(key);
5037
- this.metadataKeysUpdated.add(key);
5038
- this.baseCache.set(key, value);
5039
- }
5040
- setMetadata(key, cacheControlMetadata) {
5041
- this.metadataKeysUpdated.add(key);
5042
- this.baseCache.setMetadata(key, cacheControlMetadata);
5043
- }
5044
- length() {
5045
- return this.baseCache.length();
5046
- }
5047
- keys() {
5048
- return this.baseCache.keys();
5049
- }
5050
- entries() {
5051
- return this.baseCache.entries();
5052
- }
5053
- record() {
5054
- return new DefaultRecordableCache(this);
5055
- }
5056
- filter(predicate) {
5057
- return new DefaultFilteredCache(this, predicate);
5058
- }
5059
- buildFixedTimeWritableCache(generatedTime) {
5060
- return new FixedTimeWritableCache(this, generatedTime);
5061
- }
5062
- }
5063
- class DefaultFilteredCache {
5064
- constructor(baseCache, predicate) {
5065
- this.baseCache = baseCache;
5066
- this.predicate = predicate;
5067
- }
5068
- delete(key) {
5069
- this.baseCache.delete(key);
5070
- }
5071
- get(key, options) {
5072
- const result = this.baseCache.get(key);
5073
- if (result && this.predicate(key, result)) {
5074
- if (options?.copy) {
5075
- return deepCopy(result);
5076
- }
5077
- return result;
5078
- }
5079
- return void 0;
5080
- }
5081
- set(key, value) {
5082
- this.baseCache.set(key, value);
5083
- }
5084
- setMetadata(key, cacheControlMetadata) {
5085
- this.baseCache.setMetadata(key, cacheControlMetadata);
5086
- }
5087
- length() {
5088
- return this.getFilteredKeys().size;
5089
- }
5090
- keys() {
5091
- return this.getFilteredKeys();
5092
- }
5093
- entries() {
5094
- return this.getFilteredEntries();
5095
- }
5096
- record() {
5097
- return new DefaultRecordableCache(this);
5098
- }
5099
- filter(predicate) {
5100
- return new DefaultFilteredCache(this, predicate);
5101
- }
5102
- getFilteredEntries() {
5103
- return this.baseCache.entries().filter(([key, _value]) => {
5104
- return this.get(key);
5105
- });
5106
- }
5107
- getFilteredKeys() {
5108
- const filteredKeySet = /* @__PURE__ */ new Set();
5109
- this.baseCache.keys().forEach((key) => {
5110
- if (this.get(key)) {
5111
- filteredKeySet.add(key);
5112
- }
5113
- });
5114
- return filteredKeySet;
5115
- }
5116
- buildFixedTimeWritableCache(generatedTime) {
5117
- return new FixedTimeWritableCache(this, generatedTime);
5118
- }
5119
- }
5120
- class FixedTimeWritableCache {
5121
- constructor(baseCache, generatedTime) {
5122
- this.baseCache = baseCache;
5123
- this.generatedTime = generatedTime;
5124
- }
5125
- delete(key) {
5126
- this.baseCache.delete(key);
5127
- }
5128
- get(key, options) {
5129
- return this.baseCache.get(key, options);
5130
- }
5131
- set(key, value) {
5132
- this.baseCache.set(key, {
5133
- ...value,
5134
- metadata: {
5135
- ...value.metadata,
5136
- cacheControl: { ...value.metadata.cacheControl, generatedTime: this.generatedTime }
5137
- }
5138
- });
5139
- }
5140
- setMetadata(key, cacheControlMetadata) {
5141
- this.baseCache.setMetadata(key, {
5142
- ...cacheControlMetadata,
5143
- generatedTime: this.generatedTime
5144
- });
5145
- }
5146
- length() {
5147
- return this.baseCache.length();
5148
- }
5149
- keys() {
5150
- return this.baseCache.keys();
5151
- }
5152
- entries() {
5153
- return this.baseCache.entries();
5154
- }
5155
- record() {
5156
- return new DefaultRecordableCache(this);
5157
- }
5158
- filter(predicate) {
5159
- return new DefaultFilteredCache(this, predicate);
5160
- }
5161
- buildFixedTimeWritableCache(generatedTime) {
5162
- return new FixedTimeWritableCache(this, generatedTime);
5163
- }
5164
- }
5165
- class DefaultCache {
5166
- constructor() {
5167
- this.data = {};
5168
- }
5169
- get(key, options) {
5170
- if (options?.copy) {
5171
- return deepCopy(this.data[key]);
5172
- }
5173
- return this.data[key];
5174
- }
5175
- /**
5176
- * Adds the specified key/value to the cache.
5177
- *
5178
- * @param key key at which to store value
5179
- * @param entry value to be stored
5180
- */
5181
- set(key, entry) {
5182
- if (entry.metadata.cacheControl.type === "no-store") {
5183
- return;
5184
- }
5185
- this.data[key] = {
5186
- ...entry,
5187
- metadata: {
5188
- ...entry.metadata,
5189
- type: entry.metadata.type || {
5190
- namespace: "OneStore:Internal",
5191
- name: "UnknownType"
5192
- },
5193
- cacheControl: {
5194
- generatedTime: Date.now() / 1e3,
5195
- ...entry.metadata.cacheControl
5196
- }
5197
- }
5198
- };
5199
- }
5200
- /**
5201
- * Removes the cache entry associated with the specified key.
5202
- *
5203
- * @param key key to be removed from the store
5204
- */
5205
- delete(key) {
5206
- delete this.data[key];
5207
- }
5208
- /**
5209
- * Sets the metadata for the specified key if the key is in cache.
5210
- * If the key doesn't exist, it does nothing.
5211
- *
5212
- * @param key key at which to store metadata
5213
- * @param cacheControlMetadata metadata to be stored
5214
- */
5215
- setMetadata(key, cacheControlMetadata) {
5216
- if (key in this.data) {
5217
- this.data[key].metadata.cacheControl = {
5218
- generatedTime: Date.now() / 1e3,
5219
- ...cacheControlMetadata
5220
- };
5221
- }
5222
- }
5223
- length() {
5224
- return this.keys().size;
5225
- }
5226
- keys() {
5227
- return new Set(Object.keys(this.data));
5228
- }
5229
- entries() {
5230
- return Object.entries(this.data);
5231
- }
5232
- record() {
5233
- return new DefaultRecordableCache(this);
5234
- }
5235
- filter(predicate) {
5236
- return new DefaultFilteredCache(this, predicate);
5237
- }
5238
- buildFixedTimeWritableCache(generatedTime) {
5239
- return new FixedTimeWritableCache(this, generatedTime);
5240
- }
4733
+ const queryString = searchParams.toString();
4734
+ if (queryString.length > 0) {
4735
+ return `?${queryString}`;
4736
+ }
4737
+ return '';
5241
4738
  }
5242
- function buildServiceDescriptor$1() {
5243
- return {
5244
- type: "cache",
5245
- version: "1.0",
5246
- service: new DefaultCache()
5247
- };
4739
+ function generateHeaders(headers) {
4740
+ const fetchHeaders = new Headers();
4741
+ for (const key of keys$1(headers)) {
4742
+ fetchHeaders.set(key, headers[key]);
4743
+ }
4744
+ return fetchHeaders;
4745
+ }
4746
+
4747
+ class CacheInclusionPolicyService {
5248
4748
  }
5249
4749
  class DurableCacheInclusionPolicy extends CacheInclusionPolicyService {
5250
4750
  /**
@@ -5277,7 +4777,7 @@ class DurableCacheInclusionPolicy extends CacheInclusionPolicyService {
5277
4777
  */
5278
4778
  write(options) {
5279
4779
  const { l1, writeToL1 } = options;
5280
- const tempL1 = buildServiceDescriptor$1().service.record();
4780
+ const tempL1 = buildServiceDescriptor$h().service.record();
5281
4781
  return writeToL1(tempL1).then(() => {
5282
4782
  const keysToReviveRecordableCache = l1.record();
5283
4783
  tempL1.keysUpdated.forEach((key) => keysToReviveRecordableCache.get(key));
@@ -6610,7 +6110,7 @@ function buildActionMarksSendInterceptor() {
6610
6110
  if (context && context.instrumentationId) {
6611
6111
  createActionStartMark(context);
6612
6112
  }
6613
- return resolvedPromiseLike$2(fetchArgs);
6113
+ return resolvedPromiseLike(fetchArgs);
6614
6114
  };
6615
6115
  }
6616
6116
  function buildLuvioActionMarksSendInterceptor() {
@@ -6618,9 +6118,119 @@ function buildLuvioActionMarksSendInterceptor() {
6618
6118
  if (context && context.instrumentationId) {
6619
6119
  createActionStartMark(context);
6620
6120
  }
6621
- return resolvedPromiseLike$2(resourceRequest);
6121
+ return resolvedPromiseLike(resourceRequest);
6122
+ };
6123
+ }
6124
+
6125
+ const CSRF_TOKEN_KEY = 'salesforce_csrf_token';
6126
+ const CSRF_STORAGE_NAME = 'ldsCSRFToken';
6127
+ const BASE_URI = '/services/data/v69.0';
6128
+ const UI_API_BASE_URI = `${BASE_URI}/ui-api`;
6129
+ const CSRF_TOKEN_ENDPOINT = `${UI_API_BASE_URI}/session/csrf`;
6130
+ const CSRF_STORAGE_CONFIG = {
6131
+ name: CSRF_STORAGE_NAME,
6132
+ persistent: true,
6133
+ secure: true,
6134
+ maxSize: 1024,
6135
+ expiration: 24 * 60 * 60,
6136
+ clearOnInit: false,
6137
+ debugLogging: false,
6138
+ };
6139
+ function readPreloadedToken(getPreloadedToken) {
6140
+ try {
6141
+ const token = getPreloadedToken?.();
6142
+ return typeof token === 'string' && token ? token : undefined;
6143
+ }
6144
+ catch {
6145
+ return undefined;
6146
+ }
6147
+ }
6148
+ /**
6149
+ * Fetches a fresh CSRF token from the server. Resolves `undefined` (not a
6150
+ * rejection) on any non-ok response, missing token, or network/parse error so
6151
+ * the manager treats it as "no value" and leaves any cached token intact. The
6152
+ * CSRF retry policy — not this fetch — owns retry semantics.
6153
+ */
6154
+ async function fetchFreshToken() {
6155
+ try {
6156
+ const response = await fetch(CSRF_TOKEN_ENDPOINT, {
6157
+ method: 'GET',
6158
+ credentials: 'same-origin',
6159
+ });
6160
+ if (!response.ok) {
6161
+ return undefined;
6162
+ }
6163
+ const data = await response.json();
6164
+ const token = data.csrfToken;
6165
+ return typeof token === 'string' && token ? token : undefined;
6166
+ }
6167
+ catch {
6168
+ return undefined;
6169
+ }
6170
+ }
6171
+ /**
6172
+ * Durable store fronted by memory so `get()` is sync once loaded (W-24883855).
6173
+ * No TTL: a stale token is replaced via the CSRF retry policy's `refresh()`.
6174
+ */
6175
+ function buildCsrfResourceStorage(getPreloadedToken) {
6176
+ const storage = createStorage(CSRF_STORAGE_CONFIG);
6177
+ let currentToken;
6178
+ let loaded = false;
6179
+ // Seed once (stored, else preloaded) so a later clear() isn't resurrected by
6180
+ // the preload. A set()/clear() during the read wins.
6181
+ const seeded = (async () => {
6182
+ const preloadedToken = readPreloadedToken(getPreloadedToken);
6183
+ let existing;
6184
+ try {
6185
+ const cached = await storage?.get(CSRF_TOKEN_KEY);
6186
+ existing = typeof cached === 'string' && cached ? cached : undefined;
6187
+ }
6188
+ catch {
6189
+ // Treated as a miss; the manager fetches.
6190
+ }
6191
+ if (loaded) {
6192
+ return;
6193
+ }
6194
+ currentToken = existing ?? preloadedToken;
6195
+ loaded = true;
6196
+ if (storage && !existing && preloadedToken) {
6197
+ try {
6198
+ await storage.set(CSRF_TOKEN_KEY, preloadedToken);
6199
+ }
6200
+ catch {
6201
+ // Still usable from memory.
6202
+ }
6203
+ }
6204
+ })();
6205
+ // Durable writes wait for the seed so they land after its preload write.
6206
+ // Failures are ignored; memory stays authoritative.
6207
+ const afterSeed = (write) => seeded.then(write).then(() => { }, () => { });
6208
+ return {
6209
+ get: () => (loaded ? resolvedPromiseLike(currentToken) : seeded.then(() => currentToken)),
6210
+ set: (value) => {
6211
+ currentToken = value;
6212
+ loaded = true;
6213
+ return afterSeed(() => storage?.set(CSRF_TOKEN_KEY, value));
6214
+ },
6215
+ clear: () => {
6216
+ currentToken = undefined;
6217
+ loaded = true;
6218
+ return afterSeed(() => storage?.remove(CSRF_TOKEN_KEY));
6219
+ },
6622
6220
  };
6623
6221
  }
6222
+ /**
6223
+ * Builds the CSRF token manager: a {@link BasicRenewableResourceManager} that
6224
+ * lazily caches the token in durable storage, coalesces concurrent fetches onto
6225
+ * a single in-flight request, and dedups refresh storms. Registered as a
6226
+ * provisioner service (`csrfTokenManager`) by `initializeOneStore`.
6227
+ */
6228
+ function buildCsrfTokenManager(options = {}) {
6229
+ return new BasicRenewableResourceManager({
6230
+ fetch: fetchFreshToken,
6231
+ storage: buildCsrfResourceStorage(options.getPreloadedToken),
6232
+ });
6233
+ }
6624
6234
 
6625
6235
  /**
6626
6236
  * Service name the CSRF token manager is registered under by
@@ -6634,6 +6244,11 @@ const CSRF_TOKEN_MANAGER_REQUEST = {
6634
6244
  },
6635
6245
  };
6636
6246
  let cached;
6247
+ let resolvedManager;
6248
+ /** The manager if {@link getCsrfTokenManager} has resolved it, else `undefined`. */
6249
+ function peekCsrfTokenManager() {
6250
+ return resolvedManager;
6251
+ }
6637
6252
  /**
6638
6253
  * Resolves the CSRF token manager from the service provisioner.
6639
6254
  *
@@ -6649,7 +6264,10 @@ let cached;
6649
6264
  function getCsrfTokenManager() {
6650
6265
  if (!cached) {
6651
6266
  cached = Promise.resolve(getServices(CSRF_TOKEN_MANAGER_REQUEST))
6652
- .then((services) => services[CSRF_TOKEN_MANAGER_SERVICE])
6267
+ .then((services) => {
6268
+ resolvedManager = services[CSRF_TOKEN_MANAGER_SERVICE];
6269
+ return resolvedManager;
6270
+ })
6653
6271
  .catch((error) => {
6654
6272
  cached = undefined;
6655
6273
  throw error;
@@ -6663,14 +6281,18 @@ const CSRF_TOKEN_HEADER = 'X-CSRF-Token';
6663
6281
  * Resolves the CSRF token manager and returns the current token. Returns
6664
6282
  * `undefined` if the manager cannot be resolved (service not yet provisioned)
6665
6283
  * or has no token, so a request is never blocked by token resolution.
6284
+ * Synchronous once the manager has resolved and the token is loaded (W-24883855).
6666
6285
  */
6667
- async function getCsrfToken() {
6286
+ function getCsrfToken() {
6668
6287
  try {
6669
- const manager = await getCsrfTokenManager();
6670
- return await manager.get();
6288
+ const manager = peekCsrfTokenManager();
6289
+ const token = manager
6290
+ ? manager.get()
6291
+ : getCsrfTokenManager().then((resolved) => resolved.get());
6292
+ return token.then((value) => value, () => undefined);
6671
6293
  }
6672
6294
  catch {
6673
- return undefined;
6295
+ return resolvedPromiseLike(undefined);
6674
6296
  }
6675
6297
  }
6676
6298
  /**
@@ -6701,7 +6323,7 @@ function buildCsrfTokenInterceptor() {
6701
6323
  return async (fetchArgs) => {
6702
6324
  // Check if all required gates are enabled before running
6703
6325
  if (!areCsrfGatesEnabled()) {
6704
- return resolvedPromiseLike$2(fetchArgs);
6326
+ return resolvedPromiseLike(fetchArgs);
6705
6327
  }
6706
6328
  // Only add CSRF token for mutating operations
6707
6329
  if (isMutatingMethod(getFetchMethod(fetchArgs))) {
@@ -6711,7 +6333,7 @@ function buildCsrfTokenInterceptor() {
6711
6333
  fetchArgs = setHeader(CSRF_TOKEN_HEADER, token, fetchArgs);
6712
6334
  }
6713
6335
  }
6714
- return resolvedPromiseLike$2(fetchArgs);
6336
+ return resolvedPromiseLike(fetchArgs);
6715
6337
  };
6716
6338
  }
6717
6339
  /**
@@ -6722,26 +6344,30 @@ function buildCsrfTokenInterceptor() {
6722
6344
  * @returns A request interceptor function for Luvio ResourceRequest objects
6723
6345
  */
6724
6346
  function buildLuvioCsrfTokenInterceptor() {
6725
- return async (resourceRequest) => {
6347
+ // Sync on purpose (W-24883855).
6348
+ return (resourceRequest) => {
6726
6349
  // Check if all required gates are enabled before running
6727
6350
  if (!areCsrfGatesEnabled()) {
6728
- return resolvedPromiseLike$2(resourceRequest);
6351
+ return resolvedPromiseLike(resourceRequest);
6729
6352
  }
6730
6353
  // Ensure headers object exists
6731
6354
  if (!resourceRequest.headers) {
6732
6355
  resourceRequest.headers = {};
6733
6356
  }
6734
- // Only add CSRF token for mutating operations
6735
- if (isMutatingMethod(resourceRequest.method)) {
6736
- // Don't overwrite existing CSRF token header if it already exists
6737
- if (!resourceRequest.headers[CSRF_TOKEN_HEADER]) {
6738
- const token = await getCsrfToken();
6739
- if (token) {
6740
- resourceRequest.headers[CSRF_TOKEN_HEADER] = token;
6741
- }
6742
- }
6357
+ if (!peekCsrfTokenManager()) {
6358
+ // Warm it (GETs too) so mutations attach the token synchronously.
6359
+ getCsrfTokenManager().catch(() => { });
6743
6360
  }
6744
- return resolvedPromiseLike$2(resourceRequest);
6361
+ if (!isMutatingMethod(resourceRequest.method) ||
6362
+ resourceRequest.headers[CSRF_TOKEN_HEADER]) {
6363
+ return resolvedPromiseLike(resourceRequest);
6364
+ }
6365
+ return getCsrfToken().then((token) => {
6366
+ if (token) {
6367
+ resourceRequest.headers[CSRF_TOKEN_HEADER] = token;
6368
+ }
6369
+ return resourceRequest;
6370
+ });
6745
6371
  };
6746
6372
  }
6747
6373
 
@@ -6755,7 +6381,7 @@ const ENTITY_ENCODING_DISABLED_VALUE = 'false';
6755
6381
  */
6756
6382
  function buildEntityEncodingInterceptor() {
6757
6383
  return (fetchArgs) => {
6758
- return resolvedPromiseLike$2(setHeader(ENTITY_ENCODING_HEADER, ENTITY_ENCODING_DISABLED_VALUE, fetchArgs));
6384
+ return resolvedPromiseLike(setHeader(ENTITY_ENCODING_HEADER, ENTITY_ENCODING_DISABLED_VALUE, fetchArgs));
6759
6385
  };
6760
6386
  }
6761
6387
  /**
@@ -6771,7 +6397,7 @@ function buildLuvioEntityEncodingInterceptor() {
6771
6397
  if (!resourceRequest.headers[ENTITY_ENCODING_HEADER]) {
6772
6398
  resourceRequest.headers[ENTITY_ENCODING_HEADER] = ENTITY_ENCODING_DISABLED_VALUE;
6773
6399
  }
6774
- return resolvedPromiseLike$2(resourceRequest);
6400
+ return resolvedPromiseLike(resourceRequest);
6775
6401
  };
6776
6402
  }
6777
6403
 
@@ -6786,7 +6412,7 @@ const FIRST_PARTY_VALUE = 'platform-ui';
6786
6412
  function buildFirstPartyHeaderInterceptor() {
6787
6413
  return async (fetchArgs) => {
6788
6414
  const returnedFetchArgs = setHeader(FIRST_PARTY_HEADER, FIRST_PARTY_VALUE, fetchArgs);
6789
- return resolvedPromiseLike$2(returnedFetchArgs);
6415
+ return resolvedPromiseLike(returnedFetchArgs);
6790
6416
  };
6791
6417
  }
6792
6418
  /**
@@ -6797,14 +6423,15 @@ function buildFirstPartyHeaderInterceptor() {
6797
6423
  * @returns A request interceptor for Luvio ResourceRequest objects
6798
6424
  */
6799
6425
  function buildLuvioFirstPartyHeaderInterceptor() {
6800
- return async (resourceRequest) => {
6426
+ // Sync on purpose (W-24883855).
6427
+ return (resourceRequest) => {
6801
6428
  if (!resourceRequest.headers) {
6802
6429
  resourceRequest.headers = {};
6803
6430
  }
6804
6431
  if (!resourceRequest.headers[FIRST_PARTY_HEADER]) {
6805
6432
  resourceRequest.headers[FIRST_PARTY_HEADER] = FIRST_PARTY_VALUE;
6806
6433
  }
6807
- return resolvedPromiseLike$2(resourceRequest);
6434
+ return resolvedPromiseLike(resourceRequest);
6808
6435
  };
6809
6436
  }
6810
6437
 
@@ -6842,7 +6469,8 @@ function mintIdempotencyKey() {
6842
6469
  * registry flag can never cause an unsafe replay.
6843
6470
  */
6844
6471
  function buildLuvioIdempotencyKeyInterceptor() {
6845
- return async (resourceRequest) => {
6472
+ // Sync on purpose (W-24883855).
6473
+ return (resourceRequest) => {
6846
6474
  if (!resourceRequest.headers) {
6847
6475
  resourceRequest.headers = {};
6848
6476
  }
@@ -6851,7 +6479,7 @@ function buildLuvioIdempotencyKeyInterceptor() {
6851
6479
  !resourceRequest.headers[IDEMPOTENCY_KEY_HEADER]) {
6852
6480
  resourceRequest.headers[IDEMPOTENCY_KEY_HEADER] = mintIdempotencyKey();
6853
6481
  }
6854
- return resolvedPromiseLike$2(resourceRequest);
6482
+ return resolvedPromiseLike(resourceRequest);
6855
6483
  };
6856
6484
  }
6857
6485
 
@@ -6934,9 +6562,9 @@ function buildJwtParameterizationInterceptor(jwtManager, jwtRequestModifier = (_
6934
6562
  // interceptor handles it. This MUST be the first statement so non-opted-in
6935
6563
  // SFAP commands observe no work at all.
6936
6564
  if (mintParams === undefined) {
6937
- return resolvedPromiseLike$2(fetchArgs);
6565
+ return resolvedPromiseLike(fetchArgs);
6938
6566
  }
6939
- return resolvedPromiseLike$2(jwtManager.getJwt(mintParams)).then((token) => {
6567
+ return resolvedPromiseLike(jwtManager.getJwt(mintParams)).then((token) => {
6940
6568
  const fetchArgsWithAuthorization = setHeaderAuthorization(token, fetchArgs);
6941
6569
  return token.extraInfo
6942
6570
  ? jwtRequestModifier(token.extraInfo, fetchArgsWithAuthorization)
@@ -6962,7 +6590,7 @@ function buildLuvioPageScopedCacheRequestInterceptor() {
6962
6590
  }
6963
6591
  // Pass the headers to pageScopedCache which will mutate them
6964
6592
  pageScopedCache.addHeader(resourceRequest.headers);
6965
- return resolvedPromiseLike$2(resourceRequest);
6593
+ return resolvedPromiseLike(resourceRequest);
6966
6594
  };
6967
6595
  }
6968
6596
 
@@ -6976,7 +6604,7 @@ function buildPageScopedCacheRequestInterceptor() {
6976
6604
  Object.entries(pageScopedCacheHeaders).forEach(([key, value]) => {
6977
6605
  returnedFetchArgs = setHeader(key, value, returnedFetchArgs);
6978
6606
  });
6979
- return resolvedPromiseLike$2(returnedFetchArgs);
6607
+ return resolvedPromiseLike(returnedFetchArgs);
6980
6608
  };
6981
6609
  }
6982
6610
 
@@ -6991,7 +6619,7 @@ function buildTransportMarksSendInterceptor() {
6991
6619
  context.startTime = performance.now();
6992
6620
  createTransportStartMark(requestId);
6993
6621
  }
6994
- return resolvedPromiseLike$2(fetchArgs);
6622
+ return resolvedPromiseLike(fetchArgs);
6995
6623
  };
6996
6624
  }
6997
6625
  function buildLuvioTransportMarksSendInterceptor() {
@@ -7002,7 +6630,7 @@ function buildLuvioTransportMarksSendInterceptor() {
7002
6630
  context.startTime = performance.now();
7003
6631
  createTransportStartMark(requestId);
7004
6632
  }
7005
- return resolvedPromiseLike$2(resourceRequest);
6633
+ return resolvedPromiseLike(resourceRequest);
7006
6634
  };
7007
6635
  }
7008
6636
  function setLuvioRequestIdHeader(resourceRequest, requestId) {
@@ -7949,7 +7577,7 @@ class PrioritizedConfigService {
7949
7577
  }
7950
7578
  });
7951
7579
  this.validated = errors.length === 0;
7952
- return errors.length === 0 ? ok$2(void 0) : err$1(errors);
7580
+ return errors.length === 0 ? ok(void 0) : err(errors);
7953
7581
  }
7954
7582
  // constructs a proxy for the given non-leaf object path in the config tree
7955
7583
  buildReadonlyObjectProxy(path) {
@@ -7968,7 +7596,7 @@ class PrioritizedConfigService {
7968
7596
  get: (_, property) => {
7969
7597
  const propertyPath = [...path, property];
7970
7598
  const value = this.valueFor(propertyPath);
7971
- return typeof value === "object" && value !== null && !isArray$4(value) ? this.buildReadonlyObjectProxy(propertyPath) : value;
7599
+ return typeof value === "object" && value !== null && !isArray$3(value) ? this.buildReadonlyObjectProxy(propertyPath) : value;
7972
7600
  },
7973
7601
  getOwnPropertyDescriptor: (target, property) => {
7974
7602
  const propertyPath = [...path, property];
@@ -7976,7 +7604,7 @@ class PrioritizedConfigService {
7976
7604
  return {
7977
7605
  value: (
7978
7606
  // TODO - need to wrap arrays in a Proxy as well
7979
- typeof value === "object" && value !== null && !isArray$4(value) ? this.buildReadonlyObjectProxy(propertyPath) : value
7607
+ typeof value === "object" && value !== null && !isArray$3(value) ? this.buildReadonlyObjectProxy(propertyPath) : value
7980
7608
  ),
7981
7609
  writable: false,
7982
7610
  configurable: true,
@@ -8077,43 +7705,7 @@ function getEnvironmentSetting(name) {
8077
7705
  }
8078
7706
  return undefined;
8079
7707
  }
8080
- // version: 1.469.0-20bccd4816
8081
-
8082
- /**
8083
- * Helpers for reaching the Aura framework from the LDS Aura runtime.
8084
- *
8085
- * `window.$A` is only present when the runtime is hosted inside Aura (LEX or
8086
- * an Aura site); in tests and non-Aura runtimes it is absent. `getAura()`
8087
- * centralizes the guarded lookup so the `$A` access lives in one place instead
8088
- * of being duplicated across modules.
8089
- */
8090
- /**
8091
- * Returns the Aura framework global (`window.$A`) when running inside Aura
8092
- * (LEX or an Aura site), or `undefined` in tests and non-Aura runtimes.
8093
- * Centralizes the guarded `$A` lookup so callers reach for it once and read
8094
- * intent instead of repeating `typeof window` / `$A` guards.
8095
- */
8096
- function getAura() {
8097
- if (typeof window === 'undefined') {
8098
- return undefined;
8099
- }
8100
- return window.$A;
8101
- }
8102
- /**
8103
- * Fires an Aura application-level event (e.g. `aura:invalidSession`). Thin
8104
- * pass-through to the `aura` framework module so callers depend on this util
8105
- * rather than importing `aura` directly.
8106
- */
8107
- function dispatchGlobalEvent(...args) {
8108
- dispatchGlobalEvent$1(...args);
8109
- }
8110
- /**
8111
- * Returns `$A.clientService` when running inside an Aura environment, or
8112
- * `undefined` otherwise. Defensive: never throws.
8113
- */
8114
- function getAuraClientService() {
8115
- return getAura()?.clientService;
8116
- }
7708
+ // version: 1.471.0-a0bc34effb
8117
7709
 
8118
7710
  const auraClientService = getAuraClientService();
8119
7711
  const defaultConfig = {
@@ -8567,7 +8159,7 @@ function buildLuvioThirdPartyTrackerRegisterInterceptor() {
8567
8159
  return false;
8568
8160
  });
8569
8161
  }
8570
- return resolvedPromiseLike$2(resourceRequest);
8162
+ return resolvedPromiseLike(resourceRequest);
8571
8163
  };
8572
8164
  }
8573
8165
 
@@ -8718,7 +8310,7 @@ function buildThirdPartyTrackerRegisterInterceptor() {
8718
8310
  return false;
8719
8311
  });
8720
8312
  }
8721
- return resolvedPromiseLike$2(fetchArgs);
8313
+ return resolvedPromiseLike(fetchArgs);
8722
8314
  };
8723
8315
  }
8724
8316
 
@@ -8821,7 +8413,7 @@ function prefetchSfapJwt() {
8821
8413
  return Promise.resolve(undefined);
8822
8414
  }
8823
8415
  function buildJwtAuthorizedSfapFetchServiceDescriptor(logger) {
8824
- const jwtAuthorizedFetchService = buildServiceDescriptor$2({
8416
+ const jwtAuthorizedFetchService = buildServiceDescriptor$q({
8825
8417
  createContext: createInstrumentationIdContext(),
8826
8418
  request: [
8827
8419
  buildThirdPartyTrackerRegisterInterceptor(),
@@ -8861,7 +8453,7 @@ function buildJwtAuthorizedSfapFetchServiceDescriptor(logger) {
8861
8453
  * the Data360 command — the SFAP fleet never flows past this interceptor.
8862
8454
  */
8863
8455
  function buildJwtAuthorizedData360FetchServiceDescriptor(logger) {
8864
- const data360FetchService = buildServiceDescriptor$2({
8456
+ const data360FetchService = buildServiceDescriptor$q({
8865
8457
  createContext: createInstrumentationIdContext(),
8866
8458
  request: [
8867
8459
  buildThirdPartyTrackerRegisterInterceptor(),
@@ -8891,7 +8483,7 @@ function buildCopilotFetchServiceDescriptor(logger) {
8891
8483
  // we switch to JWT authentication this will need to change to incorporate the
8892
8484
  // Interceptor here with the logic in buildJwtAuthorizedSfapFetchServiceDescriptor()
8893
8485
  // above.
8894
- ...buildServiceDescriptor$2({
8486
+ ...buildServiceDescriptor$q({
8895
8487
  createContext: createInstrumentationIdContext(),
8896
8488
  request: [
8897
8489
  buildThirdPartyTrackerRegisterInterceptor(),
@@ -8907,9 +8499,9 @@ function buildCopilotFetchServiceDescriptor(logger) {
8907
8499
  requestInit.method !== 'POST' ||
8908
8500
  !requestInit.body ||
8909
8501
  typeof requestInit.body !== 'string') {
8910
- return resolvedPromiseLike$2(args);
8502
+ return resolvedPromiseLike(args);
8911
8503
  }
8912
- return resolvedPromiseLike$2(sfapJwtManager.getJwt()).then((token) => {
8504
+ return resolvedPromiseLike(sfapJwtManager.getJwt()).then((token) => {
8913
8505
  // replace the body's instanceConfig.endpoint with the JWT's iss value
8914
8506
  const body = JSON.parse(requestInit.body);
8915
8507
  if (!body || !token.decodedInfo || !token.decodedInfo.iss) {
@@ -8944,7 +8536,7 @@ function buildCopilotFetchServiceDescriptor(logger) {
8944
8536
  };
8945
8537
  }
8946
8538
  function buildUnauthorizedFetchServiceDescriptor() {
8947
- const fetchService = buildServiceDescriptor$2({
8539
+ const fetchService = buildServiceDescriptor$q({
8948
8540
  createContext: createInstrumentationIdContext(),
8949
8541
  // Per-request gzip (opt-in via `init.onestore.compression`).
8950
8542
  request: [buildThirdPartyTrackerRegisterInterceptor(), buildCompressionInterceptor()],
@@ -9020,9 +8612,9 @@ function buildData360HostRewriteInterceptor(logger) {
9020
8612
  context?.[JWT_MINT_PARAMS_SEED_KEY];
9021
8613
  // No mint params → not a parameterized Data360 request. Nothing to do.
9022
8614
  if (mintParams === undefined) {
9023
- return resolvedPromiseLike$2(fetchArgs);
8615
+ return resolvedPromiseLike(fetchArgs);
9024
8616
  }
9025
- return resolvedPromiseLike$2(sfapJwtManager.getJwt(mintParams)).then((token) => {
8617
+ return resolvedPromiseLike(sfapJwtManager.getJwt(mintParams)).then((token) => {
9026
8618
  const [resource, request] = fetchArgs;
9027
8619
  if (typeof resource !== 'string' && !(resource instanceof URL)) {
9028
8620
  // istanbul ignore else: not exercised under NODE_ENV=production
@@ -9069,7 +8661,7 @@ function buildData360HostRewriteInterceptor(logger) {
9069
8661
  */
9070
8662
  function buildGuardedLegacyJwtRequestInterceptor(logger) {
9071
8663
  const legacyInterceptor = buildJwtRequestInterceptor(logger);
9072
- return (args) => hasAuthorizationHeader(args) ? resolvedPromiseLike$2(args) : legacyInterceptor(args);
8664
+ return (args) => hasAuthorizationHeader(args) ? resolvedPromiseLike(args) : legacyInterceptor(args);
9073
8665
  }
9074
8666
 
9075
8667
  const PDL_EXECUTE_ASYNC_OPTIONS = {
@@ -11201,12 +10793,12 @@ function getLexRuntimeDefaultInterceptorConfig(logger) {
11201
10793
  };
11202
10794
  }
11203
10795
  function buildLexRuntimeDefaultFetchServiceDescriptor(logger, retryService) {
11204
- const fetchService = buildServiceDescriptor$2(getLexRuntimeDefaultInterceptorConfig(logger), retryService);
10796
+ const fetchService = buildServiceDescriptor$q(getLexRuntimeDefaultInterceptorConfig(logger), retryService);
11205
10797
  return { ...fetchService };
11206
10798
  }
11207
10799
  function buildLexRuntimeAllow5xxFetchServiceDescriptor(logger, retryService) {
11208
10800
  const config = getLexRuntimeDefaultInterceptorConfig(logger);
11209
- const fetchService = buildServiceDescriptor$2({
10801
+ const fetchService = buildServiceDescriptor$q({
11210
10802
  ...config,
11211
10803
  // Omit 5xx interceptor - allow 5xx responses to pass through
11212
10804
  response: [
@@ -11222,7 +10814,7 @@ function buildLexRuntimeAllow5xxFetchServiceDescriptor(logger, retryService) {
11222
10814
  }
11223
10815
  function buildLexRuntimeCompressedFetchServiceDescriptor(logger, retryService) {
11224
10816
  const config = getLexRuntimeDefaultInterceptorConfig(logger);
11225
- const fetchService = buildServiceDescriptor$2({
10817
+ const fetchService = buildServiceDescriptor$q({
11226
10818
  ...config,
11227
10819
  // Append compression interceptor last, after any body-modifying interceptors
11228
10820
  request: [...config.request, buildCompressionInterceptor({ algorithm: 'gzip' })],
@@ -11233,149 +10825,6 @@ function buildLexRuntimeCompressedFetchServiceDescriptor(logger, retryService) {
11233
10825
  };
11234
10826
  }
11235
10827
 
11236
- const CSRF_TOKEN_KEY = 'salesforce_csrf_token';
11237
- const CSRF_STORAGE_NAME = 'ldsCSRFToken';
11238
- const BASE_URI = '/services/data/v69.0';
11239
- const UI_API_BASE_URI = `${BASE_URI}/ui-api`;
11240
- const CSRF_TOKEN_ENDPOINT = `${UI_API_BASE_URI}/session/csrf`;
11241
- const CSRF_STORAGE_CONFIG = {
11242
- name: CSRF_STORAGE_NAME,
11243
- persistent: true,
11244
- secure: true,
11245
- maxSize: 1024,
11246
- expiration: 24 * 60 * 60,
11247
- clearOnInit: false,
11248
- debugLogging: false,
11249
- };
11250
- /**
11251
- * Reads the CSRF token Aura preloads onto the bootstrap payload. When the
11252
- * Connect Framework CSRF token is minted at template-render time it is exposed
11253
- * via `$A.clientService.getConnectCsrfToken()`. Reading it here lets the first
11254
- * state-changing request skip the cold `/ui-api/session/csrf` round trip.
11255
- *
11256
- * Defensive against a missing getter or server killswitch: returns `undefined`,
11257
- * never throws.
11258
- */
11259
- function readPreloadedToken() {
11260
- const clientService = getAuraClientService();
11261
- if (typeof clientService?.getConnectCsrfToken !== 'function') {
11262
- return undefined;
11263
- }
11264
- try {
11265
- const token = clientService.getConnectCsrfToken();
11266
- return typeof token === 'string' && token ? token : undefined;
11267
- }
11268
- catch {
11269
- return undefined;
11270
- }
11271
- }
11272
- /**
11273
- * Fetches a fresh CSRF token from the server. Resolves `undefined` (not a
11274
- * rejection) on any non-ok response, missing token, or network/parse error so
11275
- * the manager treats it as "no value" and leaves any cached token intact. The
11276
- * CSRF retry policy — not this fetch — owns retry semantics.
11277
- */
11278
- async function fetchFreshToken() {
11279
- try {
11280
- const response = await fetch(CSRF_TOKEN_ENDPOINT, {
11281
- method: 'GET',
11282
- credentials: 'same-origin',
11283
- });
11284
- if (!response.ok) {
11285
- return undefined;
11286
- }
11287
- const data = await response.json();
11288
- const token = data.csrfToken;
11289
- return typeof token === 'string' && token ? token : undefined;
11290
- }
11291
- catch {
11292
- return undefined;
11293
- }
11294
- }
11295
- /**
11296
- * Adapts the durable AuraStorage backing store to the {@link ResourceStorage}
11297
- * contract the renewable-resource manager expects.
11298
- *
11299
- * The Aura-preloaded token is written into the store **once at creation** (only
11300
- * when the store is otherwise empty), so the first `get()` finds it and the
11301
- * first mutation skips the network. Seeding the store — rather than having
11302
- * `get()` fall back to the preload on every empty read — means a later
11303
- * `clear()` (logout / org switch) is not silently resurrected by the preload.
11304
- *
11305
- * Every operation awaits the one-time seed so reads and writes observe a
11306
- * consistent store. Storage read/write failures are non-fatal.
11307
- */
11308
- function buildCsrfResourceStorage() {
11309
- const storage = createStorage(CSRF_STORAGE_CONFIG);
11310
- // Pre-seed the preloaded token into the store, once, if the store is empty.
11311
- const seeded = (async () => {
11312
- const preloadedToken = readPreloadedToken();
11313
- if (!storage || !preloadedToken) {
11314
- return;
11315
- }
11316
- try {
11317
- const existing = await storage.get(CSRF_TOKEN_KEY);
11318
- if (typeof existing !== 'string' || !existing) {
11319
- await storage.set(CSRF_TOKEN_KEY, preloadedToken);
11320
- }
11321
- }
11322
- catch {
11323
- // Non-fatal: fall back to fetching a fresh token on first use.
11324
- }
11325
- })();
11326
- return {
11327
- get: async () => {
11328
- await seeded;
11329
- if (storage) {
11330
- try {
11331
- const cached = await storage.get(CSRF_TOKEN_KEY);
11332
- if (typeof cached === 'string' && cached) {
11333
- return cached;
11334
- }
11335
- }
11336
- catch {
11337
- // Non-fatal: treat as a cache miss so the manager fetches.
11338
- }
11339
- }
11340
- return undefined;
11341
- },
11342
- set: async (value) => {
11343
- await seeded;
11344
- if (storage) {
11345
- try {
11346
- await storage.set(CSRF_TOKEN_KEY, value);
11347
- }
11348
- catch {
11349
- // Non-fatal: token is still usable even if caching fails.
11350
- }
11351
- }
11352
- },
11353
- clear: async () => {
11354
- await seeded;
11355
- if (storage) {
11356
- try {
11357
- await storage.remove(CSRF_TOKEN_KEY);
11358
- }
11359
- catch {
11360
- // Non-fatal: continue even if the clear fails.
11361
- }
11362
- }
11363
- },
11364
- };
11365
- }
11366
- /**
11367
- * Builds the CSRF token manager: a {@link BasicRenewableResourceManager} that
11368
- * lazily caches the token in durable storage, coalesces concurrent fetches onto
11369
- * a single in-flight request, and dedups refresh storms. Registered as a
11370
- * provisioner service (`csrfTokenManager`) by `initializeOneStore`.
11371
- */
11372
- function buildCsrfTokenManager() {
11373
- return new BasicRenewableResourceManager({
11374
- fetch: fetchFreshToken,
11375
- storage: buildCsrfResourceStorage(),
11376
- });
11377
- }
11378
-
11379
10828
  // Registration published on the force/ldsEngine bus so shared (cross-runtime) laf
11380
10829
  // loaders can read buildPredictorForContext without importing a bootstrap bundle.
11381
10830
  const PDL_ENGINE_REGISTRATION_ID = '@salesforce/lds-pdl-engine';
@@ -11638,7 +11087,9 @@ function initializeOneStore(luvio) {
11638
11087
  // loudly in development instead.
11639
11088
  const retryServiceDescriptor = buildServiceDescriptor$8(new UnconfiguredRetryPolicy());
11640
11089
  const retryService = retryServiceDescriptor.service;
11641
- const csrfTokenManagerServiceDescriptor = buildRenewableResourceManagerDescriptor(CSRF_TOKEN_MANAGER_SERVICE, buildCsrfTokenManager());
11090
+ const csrfTokenManagerServiceDescriptor = buildRenewableResourceManagerDescriptor(CSRF_TOKEN_MANAGER_SERVICE, buildCsrfTokenManager({
11091
+ getPreloadedToken: () => getAuraClientService()?.getConnectCsrfToken?.(),
11092
+ }));
11642
11093
  const prefetchSfapJwtServiceDescriptor = {
11643
11094
  type: 'prefetchSfapJwt',
11644
11095
  version: '1.0',
@@ -11663,7 +11114,7 @@ function initializeOneStore(luvio) {
11663
11114
  buildServiceDescriptor$p(),
11664
11115
  buildServiceDescriptor$e(),
11665
11116
  buildServiceDescriptor$m(),
11666
- buildServiceDescriptor$q(),
11117
+ buildServiceDescriptor$r(),
11667
11118
  buildServiceDescriptor$l(),
11668
11119
  buildServiceDescriptor$k(),
11669
11120
  buildServiceDescriptor$o(),
@@ -11680,9 +11131,9 @@ function initializeOneStore(luvio) {
11680
11131
  buildServiceDescriptor$5(),
11681
11132
  buildServiceDescriptor$4(),
11682
11133
  buildServiceDescriptor$7(),
11683
- buildServiceDescriptor$3$1(),
11134
+ buildServiceDescriptor$3(),
11684
11135
  buildServiceDescriptor$2$1(),
11685
- buildServiceDescriptor$1$2(),
11136
+ buildServiceDescriptor$1$1(),
11686
11137
  buildServiceDescriptor$6(),
11687
11138
  buildLWCWireBindingsServiceDescriptor(),
11688
11139
  buildLWCGraphQLWireBindingsServiceDescriptor(),
@@ -11708,4 +11159,4 @@ function ldsEngineCreator() {
11708
11159
  }
11709
11160
 
11710
11161
  export { LexRequestStrategy, PDL_ENGINE_REGISTRATION_ID, PdlPrefetcherEventType, PdlRequestPriority, buildPredictorForContext, configService, ldsEngineCreator as default, initializeLDS, initializeOneStore, notifyUpdateAvailableFactory, registerRequestStrategy, saveRequestAsPrediction, subscribeToPrefetcherEvents, unregisterRequestStrategy, whenPredictionsReady };
11711
- // version: 1.469.0-efd4e5a180
11162
+ // version: 1.471.0-2898c91740