@salesforce/lds-runtime-webruntime 1.401.0 → 1.402.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.
@@ -16,6 +16,7 @@ import { getInstrumentation } from 'o11y/client';
16
16
  import 'force/luvioTypeNormalization1';
17
17
  import { setServices } from 'force/luvioServiceProvisioner1';
18
18
  export { default, resolve, setServices } from 'force/luvioServiceProvisioner1';
19
+ import { withDefaultLuvio } from 'force/ldsEngine';
19
20
  import { getSfapJwt } from 'force/clwrSfapExchange';
20
21
  import language from '@salesforce/i18n/lang';
21
22
  import isDesignMode from '@app/isDesignMode';
@@ -31,14 +32,15 @@ import apiBasePath from '@app/apiBasePath';
31
32
  const { create, freeze, keys, entries } = Object;
32
33
  const { isArray: isArray$1 } = Array;
33
34
  const { stringify: stringify$1, parse: parse$1 } = JSON;
34
- const LogLevelMap$1 = {
35
+ const WeakSetConstructor = WeakSet;
36
+ const LogLevelMap = {
35
37
  TRACE: 4,
36
38
  DEBUG: 3,
37
39
  INFO: 2,
38
40
  WARN: 1,
39
41
  ERROR: 0
40
42
  };
41
- let ConsoleLogger$1 = class ConsoleLogger {
43
+ class ConsoleLogger {
42
44
  constructor(level = "WARN", printer = console.log, formatter = (level2, message) => `${level2}: ${message}`) {
43
45
  this.level = level;
44
46
  this.printer = printer;
@@ -61,12 +63,15 @@ let ConsoleLogger$1 = class ConsoleLogger {
61
63
  this.log("ERROR", message);
62
64
  }
63
65
  log(level, message) {
64
- if (LogLevelMap$1[level] > LogLevelMap$1[this.level]) {
66
+ if (LogLevelMap[level] > LogLevelMap[this.level]) {
65
67
  return;
66
68
  }
67
69
  this.printer(this.formatter(level, message));
68
70
  }
69
- };
71
+ }
72
+ function loggerService$1(level, printer, formatter) {
73
+ return new ConsoleLogger(level, printer, formatter);
74
+ }
70
75
  let Ok$2 = class Ok {
71
76
  constructor(value) {
72
77
  this.value = value;
@@ -110,43 +115,79 @@ function buildSubscribableResult$1(result, subscribe, refresh) {
110
115
  return err$1({ failure: result.error, subscribe, refresh });
111
116
  }
112
117
  }
113
- function resolvedPromiseLike$3(result) {
114
- if (isPromiseLike$3(result)) {
118
+ function resolvedPromiseLike$2(result) {
119
+ if (isPromiseLike$2(result)) {
115
120
  return result.then((nextResult) => nextResult);
116
121
  }
117
122
  return {
118
123
  then: (onFulfilled, _onRejected) => {
119
124
  try {
120
- return resolvedPromiseLike$3(onFulfilled(result));
125
+ return resolvedPromiseLike$2(onFulfilled(result));
121
126
  } catch (e) {
122
127
  if (onFulfilled === void 0) {
123
- return resolvedPromiseLike$3(result);
128
+ return resolvedPromiseLike$2(result);
124
129
  }
125
- return rejectedPromiseLike$3(e);
130
+ return rejectedPromiseLike$2(e);
126
131
  }
127
132
  }
128
133
  };
129
134
  }
130
- function rejectedPromiseLike$3(reason) {
131
- if (isPromiseLike$3(reason)) {
135
+ function rejectedPromiseLike$2(reason) {
136
+ if (isPromiseLike$2(reason)) {
132
137
  return reason.then((nextResult) => nextResult);
133
138
  }
134
139
  return {
135
140
  then: (_onFulfilled, onRejected) => {
136
141
  if (typeof onRejected === "function") {
137
142
  try {
138
- return resolvedPromiseLike$3(onRejected(reason));
143
+ return resolvedPromiseLike$2(onRejected(reason));
139
144
  } catch (e) {
140
- return rejectedPromiseLike$3(e);
145
+ return rejectedPromiseLike$2(e);
141
146
  }
142
147
  }
143
- return rejectedPromiseLike$3(reason);
148
+ return rejectedPromiseLike$2(reason);
144
149
  }
145
150
  };
146
151
  }
147
- function isPromiseLike$3(x) {
152
+ function isPromiseLike$2(x) {
148
153
  return typeof (x == null ? void 0 : x.then) === "function";
149
154
  }
155
+ function deepEquals$1(x, y) {
156
+ if (x === void 0) {
157
+ return y === void 0;
158
+ } else if (x === null) {
159
+ return y === null;
160
+ } else if (y === null) {
161
+ return x === null;
162
+ } else if (isArray$1(x)) {
163
+ if (!isArray$1(y) || x.length !== y.length) {
164
+ return false;
165
+ }
166
+ for (let i = 0; i < x.length; ++i) {
167
+ if (!deepEquals$1(x[i], y[i])) {
168
+ return false;
169
+ }
170
+ }
171
+ return true;
172
+ } else if (typeof x === "object") {
173
+ if (typeof y !== "object") {
174
+ return false;
175
+ }
176
+ const xkeys = Object.keys(x);
177
+ const ykeys = Object.keys(y);
178
+ if (xkeys.length !== ykeys.length) {
179
+ return false;
180
+ }
181
+ for (let i = 0; i < xkeys.length; ++i) {
182
+ const key = xkeys[i];
183
+ if (!deepEquals$1(x[key], y[key])) {
184
+ return false;
185
+ }
186
+ }
187
+ return true;
188
+ }
189
+ return x === y;
190
+ }
150
191
  function stableJSONStringify(node) {
151
192
  if (node && node.toJSON && typeof node.toJSON === "function") {
152
193
  node = node.toJSON();
@@ -237,6 +278,24 @@ class FetchResponse extends Error {
237
278
  this.statusText = getStatusText(status);
238
279
  }
239
280
  }
281
+ const deeplyFrozen = new WeakSetConstructor();
282
+ function deepFreeze(value) {
283
+ if (typeof value !== "object" || value === null || deeplyFrozen.has(value)) {
284
+ return;
285
+ }
286
+ deeplyFrozen.add(value);
287
+ if (isArray$1(value)) {
288
+ for (let i = 0, len = value.length; i < len; i += 1) {
289
+ deepFreeze(value[i]);
290
+ }
291
+ } else {
292
+ const keys$1 = keys(value);
293
+ for (let i = 0, len = keys$1.length; i < len; i += 1) {
294
+ deepFreeze(value[keys$1[i]]);
295
+ }
296
+ }
297
+ freeze(value);
298
+ }
240
299
  class InternalError extends Error {
241
300
  constructor(data) {
242
301
  super();
@@ -251,6 +310,15 @@ class UserVisibleError extends Error {
251
310
  this.type = "user-visible";
252
311
  }
253
312
  }
313
+ function isUserVisibleError$1(error) {
314
+ return error instanceof Error && "type" in error && error.type === "user-visible";
315
+ }
316
+ function logError$1(error) {
317
+ if (isUserVisibleError$1(error)) {
318
+ return;
319
+ }
320
+ console.error("OneStore Command threw an error that we did not expect", error);
321
+ }
254
322
 
255
323
  /*!
256
324
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -307,7 +375,7 @@ let NetworkCommand$1 = class NetworkCommand extends BaseCommand {
307
375
  async afterRequestHooks(_options) {
308
376
  }
309
377
  };
310
- function buildServiceDescriptor$j() {
378
+ function buildServiceDescriptor$q() {
311
379
  return {
312
380
  type: "networkCommandBaseClass",
313
381
  version: "1.0",
@@ -406,10 +474,10 @@ class AuraNetworkCommand extends NetworkCommand$1 {
406
474
  } else if (this.shouldUseFetch()) {
407
475
  return this.convertFetchResponseToData(this.services.fetch(...this.fetchParams));
408
476
  }
409
- return resolvedPromiseLike$3(err$1(toError("Aura/Fetch network services not found")));
477
+ return resolvedPromiseLike$2(err$1(toError("Aura/Fetch network services not found")));
410
478
  }
411
479
  }
412
- function buildServiceDescriptor$i() {
480
+ function buildServiceDescriptor$p() {
413
481
  return {
414
482
  type: "auraNetworkCommandBaseClass",
415
483
  version: "1.0",
@@ -459,41 +527,41 @@ function buildSubscribableResult(result, subscribe, refresh) {
459
527
  return err({ failure: result.error, subscribe, refresh });
460
528
  }
461
529
  }
462
- function resolvedPromiseLike$2(result) {
463
- if (isPromiseLike$2(result)) {
530
+ function resolvedPromiseLike$1(result) {
531
+ if (isPromiseLike$1(result)) {
464
532
  return result.then((nextResult) => nextResult);
465
533
  }
466
534
  return {
467
535
  then: (onFulfilled, _onRejected) => {
468
536
  try {
469
- return resolvedPromiseLike$2(onFulfilled(result));
537
+ return resolvedPromiseLike$1(onFulfilled(result));
470
538
  } catch (e) {
471
539
  if (onFulfilled === void 0) {
472
- return resolvedPromiseLike$2(result);
540
+ return resolvedPromiseLike$1(result);
473
541
  }
474
- return rejectedPromiseLike$2(e);
542
+ return rejectedPromiseLike$1(e);
475
543
  }
476
544
  }
477
545
  };
478
546
  }
479
- function rejectedPromiseLike$2(reason) {
480
- if (isPromiseLike$2(reason)) {
547
+ function rejectedPromiseLike$1(reason) {
548
+ if (isPromiseLike$1(reason)) {
481
549
  return reason.then((nextResult) => nextResult);
482
550
  }
483
551
  return {
484
552
  then: (_onFulfilled, onRejected) => {
485
553
  if (typeof onRejected === "function") {
486
554
  try {
487
- return resolvedPromiseLike$2(onRejected(reason));
555
+ return resolvedPromiseLike$1(onRejected(reason));
488
556
  } catch (e) {
489
- return rejectedPromiseLike$2(e);
557
+ return rejectedPromiseLike$1(e);
490
558
  }
491
559
  }
492
- return rejectedPromiseLike$2(reason);
560
+ return rejectedPromiseLike$1(reason);
493
561
  }
494
562
  };
495
563
  }
496
- function isPromiseLike$2(x) {
564
+ function isPromiseLike$1(x) {
497
565
  return typeof (x == null ? void 0 : x.then) === "function";
498
566
  }
499
567
  function deepEquals(x, y) {
@@ -728,7 +796,7 @@ class CacheControlCommand extends BaseCommand {
728
796
  });
729
797
  }
730
798
  }
731
- return resolvedPromiseLike$2(void 0);
799
+ return resolvedPromiseLike$1(void 0);
732
800
  }
733
801
  get operationType() {
734
802
  return "query";
@@ -1004,7 +1072,7 @@ let AuraCacheControlCommand$1 = class AuraCacheControlCommand extends CacheContr
1004
1072
  } else if (this.shouldUseFetch()) {
1005
1073
  return this.convertFetchResponseToData(this.services.fetch(...this.fetchParams));
1006
1074
  }
1007
- return resolvedPromiseLike$3(err$1(toError("Aura/Fetch network services not found")));
1075
+ return resolvedPromiseLike$2(err$1(toError("Aura/Fetch network services not found")));
1008
1076
  }
1009
1077
  coerceAuraErrors(auraErrors) {
1010
1078
  return toError(auraErrors[0]);
@@ -1078,9 +1146,9 @@ class AuraResourceCacheControlCommand extends AuraCacheControlCommand$1 {
1078
1146
  var _a;
1079
1147
  const data = (_a = cache.get(this.buildKey())) == null ? void 0 : _a.value;
1080
1148
  if (data === void 0) {
1081
- return resolvedPromiseLike$3(err$1(new Error("Failed to find data in cache")));
1149
+ return resolvedPromiseLike$2(err$1(new Error("Failed to find data in cache")));
1082
1150
  }
1083
- return resolvedPromiseLike$3(ok$2(data));
1151
+ return resolvedPromiseLike$2(ok$2(data));
1084
1152
  }
1085
1153
  writeToCache(cache, networkResult) {
1086
1154
  if (networkResult.isOk()) {
@@ -1091,13 +1159,13 @@ class AuraResourceCacheControlCommand extends AuraCacheControlCommand$1 {
1091
1159
  }
1092
1160
  });
1093
1161
  }
1094
- return resolvedPromiseLike$3(void 0);
1162
+ return resolvedPromiseLike$2(void 0);
1095
1163
  }
1096
1164
  buildKey() {
1097
1165
  return `{"endpoint":${this.endpoint},"params":${stableJSONStringify(this.auraParams)}}`;
1098
1166
  }
1099
1167
  }
1100
- function buildServiceDescriptor$h() {
1168
+ function buildServiceDescriptor$o() {
1101
1169
  return {
1102
1170
  type: "auraResourceCacheControlCommand",
1103
1171
  version: "1.0",
@@ -1147,7 +1215,7 @@ class AuraCacheControlCommand extends CacheControlCommand {
1147
1215
  } else if (this.shouldUseFetch()) {
1148
1216
  return this.convertFetchResponseToData(this.services.fetch(...this.fetchParams));
1149
1217
  }
1150
- return resolvedPromiseLike$3(err$1(toError("Aura/Fetch network services not found")));
1218
+ return resolvedPromiseLike$2(err$1(toError("Aura/Fetch network services not found")));
1151
1219
  }
1152
1220
  coerceAuraErrors(auraErrors) {
1153
1221
  return toError(auraErrors[0]);
@@ -1220,11 +1288,11 @@ class AuraNormalizedCacheControlCommand extends AuraCacheControlCommand {
1220
1288
  readFromCache(cache) {
1221
1289
  const data = this.buildResultType().query(cache, this.buildQuery());
1222
1290
  if (data.isErr()) {
1223
- return resolvedPromiseLike$3(
1291
+ return resolvedPromiseLike$2(
1224
1292
  err$1(new Error(`Failed to build data from type: ${stringify$1(data.error)}`))
1225
1293
  );
1226
1294
  }
1227
- return resolvedPromiseLike$3(ok$2(data.value));
1295
+ return resolvedPromiseLike$2(ok$2(data.value));
1228
1296
  }
1229
1297
  writeToCache(cache, networkResult) {
1230
1298
  if (networkResult.isOk()) {
@@ -1233,10 +1301,10 @@ class AuraNormalizedCacheControlCommand extends AuraCacheControlCommand {
1233
1301
  this.buildWriteInput(networkResult.value)
1234
1302
  );
1235
1303
  }
1236
- return resolvedPromiseLike$3(void 0);
1304
+ return resolvedPromiseLike$2(void 0);
1237
1305
  }
1238
1306
  }
1239
- function buildServiceDescriptor$g() {
1307
+ function buildServiceDescriptor$n() {
1240
1308
  return {
1241
1309
  type: "auraNormalizedCacheControlCommand",
1242
1310
  version: "1.0",
@@ -1309,11 +1377,11 @@ class HttpNormalizedCacheControlCommand extends HttpCacheControlCommand {
1309
1377
  readFromCache(cache) {
1310
1378
  const data = this.buildResultType().query(cache, this.buildQuery());
1311
1379
  if (data.isErr()) {
1312
- return resolvedPromiseLike$3(
1380
+ return resolvedPromiseLike$2(
1313
1381
  err$1(new Error(`Failed to build data from type: ${stringify$1(data.error)}`))
1314
1382
  );
1315
1383
  }
1316
- return resolvedPromiseLike$3(ok$2(data.value));
1384
+ return resolvedPromiseLike$2(ok$2(data.value));
1317
1385
  }
1318
1386
  writeToCache(cache, networkResult) {
1319
1387
  if (networkResult.isOk()) {
@@ -1322,10 +1390,10 @@ class HttpNormalizedCacheControlCommand extends HttpCacheControlCommand {
1322
1390
  this.buildWriteInput(networkResult.value)
1323
1391
  );
1324
1392
  }
1325
- return resolvedPromiseLike$3(void 0);
1393
+ return resolvedPromiseLike$2(void 0);
1326
1394
  }
1327
1395
  }
1328
- function buildServiceDescriptor$f() {
1396
+ function buildServiceDescriptor$m() {
1329
1397
  return {
1330
1398
  type: "httpNormalizedCacheControlCommand",
1331
1399
  version: "1.0",
@@ -1503,7 +1571,7 @@ _FetchNetworkCommand.availableDecorators = {
1503
1571
  abortable: createAbortableDecorator
1504
1572
  };
1505
1573
  let FetchNetworkCommand = _FetchNetworkCommand;
1506
- function buildServiceDescriptor$e() {
1574
+ function buildServiceDescriptor$l() {
1507
1575
  return {
1508
1576
  type: "fetchNetworkCommandBaseClass",
1509
1577
  version: "1.0",
@@ -1539,7 +1607,7 @@ class StreamingCommand extends BaseCommand {
1539
1607
  );
1540
1608
  }
1541
1609
  }
1542
- function buildServiceDescriptor$d() {
1610
+ function buildServiceDescriptor$k() {
1543
1611
  return {
1544
1612
  type: "streamingCommandBaseClass",
1545
1613
  version: "1.0",
@@ -1622,7 +1690,7 @@ class SSEParsingStream extends TransformStream {
1622
1690
  });
1623
1691
  }
1624
1692
  }
1625
- function buildServiceDescriptor$c() {
1693
+ function buildServiceDescriptor$j() {
1626
1694
  return {
1627
1695
  type: "SSECommandBaseClass",
1628
1696
  version: "1.0",
@@ -1673,7 +1741,7 @@ function buildInstrumentCommand(services) {
1673
1741
  };
1674
1742
  };
1675
1743
  }
1676
- function buildServiceDescriptor$b(instrumentation) {
1744
+ function buildServiceDescriptor$i(instrumentation) {
1677
1745
  return {
1678
1746
  type: "instrumentCommand",
1679
1747
  version: "1.0",
@@ -1943,7 +2011,7 @@ class O11yInstrumentation {
1943
2011
  this.metrics = new O11yOTelMetricsAPI(this.services);
1944
2012
  }
1945
2013
  }
1946
- function buildServiceDescriptor$a(logger) {
2014
+ function buildServiceDescriptor$h(logger) {
1947
2015
  return {
1948
2016
  type: "instrumentation",
1949
2017
  version: "1.0",
@@ -2196,7 +2264,7 @@ class DefaultCache {
2196
2264
  return new FixedTimeWritableCache(this, generatedTime);
2197
2265
  }
2198
2266
  }
2199
- function buildServiceDescriptor$9() {
2267
+ function buildServiceDescriptor$g() {
2200
2268
  return {
2201
2269
  type: "cache",
2202
2270
  version: "1.0",
@@ -2419,7 +2487,7 @@ class CacheController {
2419
2487
  yield* this.services.cacheInclusionPolicy.findAndModify(query, cacheUpdate);
2420
2488
  }
2421
2489
  }
2422
- function buildServiceDescriptor$8(cache, cacheInclusionPolicy, instrumentation) {
2490
+ function buildServiceDescriptor$f(cache, cacheInclusionPolicy, instrumentation) {
2423
2491
  return {
2424
2492
  type: "cacheController",
2425
2493
  version: "1.0",
@@ -2432,48 +2500,6 @@ function buildServiceDescriptor$8(cache, cacheInclusionPolicy, instrumentation)
2432
2500
  * All rights reserved.
2433
2501
  * For full license text, see the LICENSE.txt file
2434
2502
  */
2435
- /*!
2436
- * Copyright (c) 2022, Salesforce, Inc.,
2437
- * All rights reserved.
2438
- * For full license text, see the LICENSE.txt file
2439
- */
2440
- function resolvedPromiseLike$1(result) {
2441
- if (isPromiseLike$1(result)) {
2442
- return result.then((nextResult) => nextResult);
2443
- }
2444
- return {
2445
- then: (onFulfilled, _onRejected) => {
2446
- try {
2447
- return resolvedPromiseLike$1(onFulfilled(result));
2448
- } catch (e) {
2449
- if (onFulfilled === void 0) {
2450
- return resolvedPromiseLike$1(result);
2451
- }
2452
- return rejectedPromiseLike$1(e);
2453
- }
2454
- }
2455
- };
2456
- }
2457
- function rejectedPromiseLike$1(reason) {
2458
- if (isPromiseLike$1(reason)) {
2459
- return reason.then((nextResult) => nextResult);
2460
- }
2461
- return {
2462
- then: (_onFulfilled, onRejected) => {
2463
- if (typeof onRejected === "function") {
2464
- try {
2465
- return resolvedPromiseLike$1(onRejected(reason));
2466
- } catch (e) {
2467
- return rejectedPromiseLike$1(e);
2468
- }
2469
- }
2470
- return rejectedPromiseLike$1(reason);
2471
- }
2472
- };
2473
- }
2474
- function isPromiseLike$1(x) {
2475
- return typeof (x == null ? void 0 : x.then) === "function";
2476
- }
2477
2503
  const EventTypeWildcard = Symbol("EventTypeWildcard");
2478
2504
  class DefaultPubSubService {
2479
2505
  constructor() {
@@ -2501,14 +2527,14 @@ class DefaultPubSubService {
2501
2527
  return;
2502
2528
  }
2503
2529
  const returnVal = subscription.callback.call(subscription, event);
2504
- if (isPromiseLike$1(returnVal)) {
2530
+ if (isPromiseLike$2(returnVal)) {
2505
2531
  promises.push(returnVal);
2506
2532
  }
2507
2533
  });
2508
2534
  if (promises.length > 0) {
2509
2535
  return Promise.all(promises).then(() => void 0);
2510
2536
  }
2511
- return resolvedPromiseLike$1(void 0);
2537
+ return resolvedPromiseLike$2(void 0);
2512
2538
  }
2513
2539
  getSubscriptions(event) {
2514
2540
  const eventTypeSubscriptions = this.subscriptions.get(event.type);
@@ -2529,7 +2555,7 @@ class DefaultPubSubService {
2529
2555
  return matchingSubscriptions;
2530
2556
  }
2531
2557
  }
2532
- function buildServiceDescriptor$7() {
2558
+ function buildServiceDescriptor$e() {
2533
2559
  return {
2534
2560
  type: "pubSub",
2535
2561
  version: "1.0",
@@ -2740,7 +2766,7 @@ class FeatureFlagsService {
2740
2766
  return this.flags.get(flagName) || defaultValue;
2741
2767
  }
2742
2768
  }
2743
- function buildServiceDescriptor$6() {
2769
+ function buildServiceDescriptor$d() {
2744
2770
  return {
2745
2771
  version: "1.0",
2746
2772
  service: new FeatureFlagsService(),
@@ -3587,6 +3613,62 @@ function hasMultilineItems(maybeArray) {
3587
3613
  var _maybeArray$some;
3588
3614
  return (_maybeArray$some = maybeArray === null || maybeArray === void 0 ? void 0 : maybeArray.some((str) => str.includes("\n"))) !== null && _maybeArray$some !== void 0 ? _maybeArray$some : false;
3589
3615
  }
3616
+ const referenceMap = /* @__PURE__ */ new WeakMap();
3617
+ const astResolver = function(astReference) {
3618
+ return referenceMap.get(astReference);
3619
+ };
3620
+ function findExecutableOperation$1(document, operationName) {
3621
+ const operations = document.definitions.filter(
3622
+ (def) => def.kind === Kind.OPERATION_DEFINITION
3623
+ );
3624
+ if (operations.length === 0) {
3625
+ return void 0;
3626
+ }
3627
+ if (operations.length === 1 && !operationName) {
3628
+ return operations[0];
3629
+ }
3630
+ if (operationName) {
3631
+ return operations.find((op) => {
3632
+ var _a;
3633
+ return ((_a = op.name) == null ? void 0 : _a.value) === operationName;
3634
+ });
3635
+ }
3636
+ return void 0;
3637
+ }
3638
+ function validateGraphQLOperations(config, options) {
3639
+ const executableOperation = findExecutableOperation$1(config.query, config.operationName);
3640
+ if (executableOperation) {
3641
+ const operationType = executableOperation.operation;
3642
+ if (!options.acceptedOperations.includes(operationType)) {
3643
+ const operationTypeCapitalized = operationType.charAt(0).toUpperCase() + operationType.slice(1);
3644
+ throw new Error(
3645
+ `${operationTypeCapitalized} operations are not supported in this context`
3646
+ );
3647
+ }
3648
+ }
3649
+ }
3650
+ function resolveAst(ast) {
3651
+ if (ast === null || ast === void 0) {
3652
+ return;
3653
+ }
3654
+ const result = astResolver(ast);
3655
+ if (result === void 0) {
3656
+ throw new Error("Could not resolve AST. Did you parse the query with gql?");
3657
+ }
3658
+ return result;
3659
+ }
3660
+ function wrapConfigAndVerify(config, options) {
3661
+ if (config == null ? void 0 : config.query) {
3662
+ config = { ...config, query: resolveAst(config.query) };
3663
+ if (config.query === void 0) {
3664
+ throw new Error("Internal error in GraphQL adapter occurred: Unable to resolve query");
3665
+ }
3666
+ validateGraphQLOperations(config, {
3667
+ acceptedOperations: (options == null ? void 0 : options.acceptedOperations) ?? ["query"]
3668
+ });
3669
+ }
3670
+ return config;
3671
+ }
3590
3672
 
3591
3673
  /*!
3592
3674
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -3803,7 +3885,7 @@ class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheContro
3803
3885
  return buildSubscribableResult$1(result, this.buildSubscribe(), () => this.refresh());
3804
3886
  });
3805
3887
  }
3806
- return resolvedPromiseLike$3(
3888
+ return resolvedPromiseLike$2(
3807
3889
  buildSubscribableResult$1(
3808
3890
  err$1(toError("Aura/Fetch network services not found")),
3809
3891
  this.buildSubscribe(),
@@ -3845,7 +3927,7 @@ class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheContro
3845
3927
  });
3846
3928
  }
3847
3929
  }
3848
- function buildServiceDescriptor$5() {
3930
+ function buildServiceDescriptor$c() {
3849
3931
  return {
3850
3932
  type: "auraGraphQLNormalizedCacheControlCommand",
3851
3933
  version: "1.0",
@@ -3963,7 +4045,7 @@ class HttpGraphQLNormalizedCacheControlCommand extends HttpNormalizedCacheContro
3963
4045
  });
3964
4046
  }
3965
4047
  }
3966
- function buildServiceDescriptor$4() {
4048
+ function buildServiceDescriptor$b() {
3967
4049
  return {
3968
4050
  type: "httpGraphQLNormalizedCacheControlCommand",
3969
4051
  version: "1.0",
@@ -4026,7 +4108,7 @@ class NDJSONParsingStream extends TransformStream {
4026
4108
  });
4027
4109
  }
4028
4110
  }
4029
- function buildServiceDescriptor$3() {
4111
+ function buildServiceDescriptor$a() {
4030
4112
  return {
4031
4113
  type: "NDJSONCommandBaseClass",
4032
4114
  version: "1.0",
@@ -4067,7 +4149,7 @@ function buildServiceDescriptor$3() {
4067
4149
  * };
4068
4150
  * ```
4069
4151
  */
4070
- function buildServiceDescriptor$2(luvio) {
4152
+ function buildServiceDescriptor$9(luvio) {
4071
4153
  return {
4072
4154
  type: 'luvio',
4073
4155
  version: '1.0',
@@ -4076,7 +4158,7 @@ function buildServiceDescriptor$2(luvio) {
4076
4158
  },
4077
4159
  };
4078
4160
  }
4079
- // version: 1.401.0-c620f9ffed
4161
+ // version: 1.402.0-566b6c5389
4080
4162
 
4081
4163
  /**
4082
4164
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -4092,7 +4174,7 @@ function buildServiceDescriptor$2(luvio) {
4092
4174
  * *******************************************************************************************
4093
4175
  */
4094
4176
  /* proxy-compat-disable */
4095
- function buildServiceDescriptor$1(notifyRecordUpdateAvailable, getNormalizedLuvioRecord) {
4177
+ function buildServiceDescriptor$8(notifyRecordUpdateAvailable, getNormalizedLuvioRecord) {
4096
4178
  return {
4097
4179
  type: 'luvioUiapiRecords',
4098
4180
  version: '1.0',
@@ -4102,105 +4184,1201 @@ function buildServiceDescriptor$1(notifyRecordUpdateAvailable, getNormalizedLuvi
4102
4184
  },
4103
4185
  };
4104
4186
  }
4105
- // version: 1.401.0-c620f9ffed
4187
+ // version: 1.402.0-566b6c5389
4106
4188
 
4107
4189
  /*!
4108
4190
  * Copyright (c) 2022, Salesforce, Inc.,
4109
4191
  * All rights reserved.
4110
4192
  * For full license text, see the LICENSE.txt file
4111
4193
  */
4112
- function e(e2) {
4113
- this.message = e2;
4114
- }
4115
- e.prototype = new Error(), e.prototype.name = "InvalidCharacterError";
4116
- var r = "undefined" != typeof window && window.atob && window.atob.bind(window) || function(r2) {
4117
- var t2 = String(r2).replace(/=+$/, "");
4118
- if (t2.length % 4 == 1) throw new e("'atob' failed: The string to be decoded is not correctly encoded.");
4119
- 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);
4120
- return c;
4121
- };
4122
- function t(e2) {
4123
- var t2 = e2.replace(/-/g, "+").replace(/_/g, "/");
4124
- switch (t2.length % 4) {
4125
- case 0:
4126
- break;
4127
- case 2:
4128
- t2 += "==";
4129
- break;
4130
- case 3:
4131
- t2 += "=";
4132
- break;
4133
- default:
4134
- throw "Illegal base64url string!";
4135
- }
4136
- try {
4137
- return (function(e3) {
4138
- return decodeURIComponent(r(e3).replace(/(.)/g, (function(e4, r2) {
4139
- var t3 = r2.charCodeAt(0).toString(16).toUpperCase();
4140
- return t3.length < 2 && (t3 = "0" + t3), "%" + t3;
4141
- })));
4142
- })(t2);
4143
- } catch (e3) {
4144
- return r(t2);
4194
+ class JsonSchemaViolationError extends Error {
4195
+ constructor(message, validationErrors) {
4196
+ super(message);
4197
+ this.validationErrors = [];
4198
+ this.validationErrors = validationErrors || [];
4145
4199
  }
4146
4200
  }
4147
- function n(e2) {
4148
- this.message = e2;
4201
+ class MinItemsViolationError extends JsonSchemaViolationError {
4149
4202
  }
4150
- function o(e2, r2) {
4151
- if ("string" != typeof e2) throw new n("Invalid token specified");
4152
- var o2 = true === (r2 = r2 || {}).header ? 0 : 1;
4153
- try {
4154
- return JSON.parse(t(e2.split(".")[o2]));
4155
- } catch (e3) {
4156
- throw new n("Invalid token specified: " + e3.message);
4157
- }
4203
+ class MaxItemsViolationError extends JsonSchemaViolationError {
4158
4204
  }
4159
- n.prototype = new Error(), n.prototype.name = "InvalidTokenError";
4160
- /*!
4161
- * Copyright (c) 2022, Salesforce, Inc.,
4162
- * All rights reserved.
4163
- * For full license text, see the LICENSE.txt file
4164
- */
4165
- const LogLevelMap = {
4166
- TRACE: 4,
4167
- DEBUG: 3,
4168
- INFO: 2,
4169
- WARN: 1,
4170
- ERROR: 0
4171
- };
4172
- class ConsoleLogger {
4173
- constructor(level = "WARN", printer = console.log, formatter = (level2, message) => `${level2}: ${message}`) {
4174
- this.level = level;
4175
- this.printer = printer;
4176
- this.formatter = formatter;
4177
- this.messages = [];
4178
- }
4179
- trace(message) {
4180
- this.log("TRACE", message);
4205
+ class IncorrectTypeError extends JsonSchemaViolationError {
4206
+ }
4207
+ class AdditionalPropertiesError extends JsonSchemaViolationError {
4208
+ }
4209
+ class MissingRequiredPropertyError extends JsonSchemaViolationError {
4210
+ }
4211
+ class InvalidRefError extends JsonSchemaViolationError {
4212
+ }
4213
+ class JsonSchemaErrorCollector {
4214
+ constructor() {
4215
+ this.errors = [];
4181
4216
  }
4182
- debug(message) {
4183
- this.log("DEBUG", message);
4217
+ add(error) {
4218
+ this.errors.push(error);
4184
4219
  }
4185
- info(message) {
4186
- this.log("INFO", message);
4220
+ append(response) {
4221
+ if (response.isErr()) {
4222
+ this.errors.push(...response.error);
4223
+ }
4187
4224
  }
4188
- warn(message) {
4189
- this.log("WARN", message);
4225
+ hasErrors() {
4226
+ return this.errors.length > 0;
4190
4227
  }
4191
- error(message) {
4192
- this.log("ERROR", message);
4228
+ prepend(error) {
4229
+ this.errors.unshift(error);
4193
4230
  }
4194
- log(level, message) {
4195
- if (LogLevelMap[level] > LogLevelMap[this.level]) {
4196
- return;
4197
- }
4198
- this.printer(this.formatter(level, message));
4231
+ toValidationResponse() {
4232
+ return !this.hasErrors() ? ok$2(true) : err$1(this.errors);
4199
4233
  }
4200
4234
  }
4201
- function loggerService$1(level, printer, formatter) {
4202
- return new ConsoleLogger(level, printer, formatter);
4235
+ function createThrowableError(errors) {
4236
+ if (errors[0] instanceof MinItemsViolationError) {
4237
+ return new MinItemsViolationError(errors[0].message, errors);
4238
+ }
4239
+ if (errors[0] instanceof MaxItemsViolationError) {
4240
+ return new MaxItemsViolationError(errors[0].message, errors);
4241
+ }
4242
+ if (errors[0] instanceof IncorrectTypeError) {
4243
+ return new IncorrectTypeError(errors[0].message, errors);
4244
+ }
4245
+ if (errors[0] instanceof AdditionalPropertiesError) {
4246
+ return new AdditionalPropertiesError(errors[0].message, errors);
4247
+ }
4248
+ if (errors[0] instanceof MissingRequiredPropertyError) {
4249
+ return new MissingRequiredPropertyError(errors[0].message, errors);
4250
+ }
4251
+ if (errors[0] instanceof InvalidRefError) {
4252
+ return new InvalidRefError(errors[0].message, errors);
4253
+ }
4254
+ return new JsonSchemaViolationError(errors[0].message, errors);
4255
+ }
4256
+ function assertIsValid(data, schema) {
4257
+ const validationResponse = validateJsonSchema(data, schema);
4258
+ if (validationResponse.isErr()) {
4259
+ throw createThrowableError(validationResponse.error);
4260
+ }
4261
+ }
4262
+ function incorrectTypeError(expected, actual, path) {
4263
+ return new IncorrectTypeError(
4264
+ `Expected type ${expected} at path '${path}', found type ${actual}.`
4265
+ );
4266
+ }
4267
+ function validSchemaResponse() {
4268
+ return ok$2(true);
4269
+ }
4270
+ function invalidSchemaResponseWithError(error) {
4271
+ return err$1([error]);
4272
+ }
4273
+ function validateJsonSchema(data, schema, path = "$", document = schema) {
4274
+ if (schema === true) return validSchemaResponse();
4275
+ if (schema === false)
4276
+ return invalidSchemaResponseWithError(
4277
+ new JsonSchemaViolationError(`Data at ${path} has schema 'false'`)
4278
+ );
4279
+ const dataType = data === null ? "null" : Array.isArray(data) ? "array" : typeof data;
4280
+ const errorCollector = new JsonSchemaErrorCollector();
4281
+ if ("anyOf" in schema) {
4282
+ errorCollector.append(validateAnyOf(data, schema, path, document));
4283
+ } else if ("oneOf" in schema) {
4284
+ errorCollector.append(validateOneOf(data, schema, path, document));
4285
+ } else if ("allOf" in schema) {
4286
+ errorCollector.append(validateAllOf(data, schema, path, document));
4287
+ } else if ("not" in schema) {
4288
+ errorCollector.append(validateNot(data, schema, path, document));
4289
+ } else if ("$ref" in schema) {
4290
+ errorCollector.append(validateRef(data, schema, path, document));
4291
+ } else if ("type" in schema) {
4292
+ if (schema.type === "object") {
4293
+ if (dataType !== "object") {
4294
+ errorCollector.add(incorrectTypeError("object", dataType, path));
4295
+ } else {
4296
+ errorCollector.append(
4297
+ validateObject(data, schema, path, document)
4298
+ );
4299
+ }
4300
+ } else if (schema.type === "array") {
4301
+ if (dataType !== "array") {
4302
+ errorCollector.add(incorrectTypeError("array", dataType, path));
4303
+ } else {
4304
+ errorCollector.append(
4305
+ validateArray(data, schema, path, document)
4306
+ );
4307
+ }
4308
+ } else {
4309
+ errorCollector.append(
4310
+ validateScalar(data, schema, path)
4311
+ );
4312
+ }
4313
+ }
4314
+ if (schema.enum) {
4315
+ errorCollector.append(validateEnum(data, schema.enum, path));
4316
+ }
4317
+ if (schema.const) {
4318
+ errorCollector.append(validateConst(data, schema.const, path));
4319
+ }
4320
+ return errorCollector.toValidationResponse();
4321
+ }
4322
+ function validateAnyOf(data, schema, path, document) {
4323
+ let isValid = false;
4324
+ const errorCollector = new JsonSchemaErrorCollector();
4325
+ for (let i = 0, { length } = schema.anyOf; i < length; i++) {
4326
+ const element = schema.anyOf[i];
4327
+ const validationResponse = validateJsonSchema(
4328
+ data,
4329
+ element,
4330
+ `${path}.anyOf[${i}]`,
4331
+ document
4332
+ );
4333
+ if (validationResponse.isOk()) {
4334
+ isValid = true;
4335
+ break;
4336
+ } else {
4337
+ errorCollector.append(validationResponse);
4338
+ }
4339
+ }
4340
+ if (!isValid) {
4341
+ errorCollector.prepend(
4342
+ new JsonSchemaViolationError(`Data at ${path} did not match any subschema in anyOf.`)
4343
+ );
4344
+ return errorCollector.toValidationResponse();
4345
+ }
4346
+ return validSchemaResponse();
4347
+ }
4348
+ function validateOneOf(data, schema, path, document) {
4349
+ let validSubShemaPaths = [];
4350
+ const errorCollector = new JsonSchemaErrorCollector();
4351
+ for (let i = 0, { length } = schema.oneOf; i < length; i++) {
4352
+ const element = schema.oneOf[i];
4353
+ const oneOfPath = `${path}.oneOf[${i}]`;
4354
+ const validationResponse = validateJsonSchema(data, element, oneOfPath, document);
4355
+ if (validationResponse.isOk()) {
4356
+ validSubShemaPaths.push(oneOfPath);
4357
+ } else {
4358
+ errorCollector.append(validationResponse);
4359
+ }
4360
+ }
4361
+ if (validSubShemaPaths.length === 0) {
4362
+ errorCollector.prepend(
4363
+ new JsonSchemaViolationError(`Data at ${path} did not match any subschema in oneOf.`)
4364
+ );
4365
+ return errorCollector.toValidationResponse();
4366
+ } else if (validSubShemaPaths.length > 1) {
4367
+ errorCollector.prepend(
4368
+ new JsonSchemaViolationError(
4369
+ `Data at ${path} matched multiple subschemas: [${validSubShemaPaths.join(", ")}].`
4370
+ )
4371
+ );
4372
+ return errorCollector.toValidationResponse();
4373
+ }
4374
+ return validSchemaResponse();
4375
+ }
4376
+ function validateAllOf(data, schema, path, document) {
4377
+ let isValid = true;
4378
+ const errorCollector = new JsonSchemaErrorCollector();
4379
+ for (let i = 0, { length } = schema.allOf; i < length; i++) {
4380
+ const element = schema.allOf[i];
4381
+ const validationResponse = validateJsonSchema(
4382
+ data,
4383
+ element,
4384
+ `${path}.allOf[${i}]`,
4385
+ document
4386
+ );
4387
+ if (!validationResponse.isOk()) {
4388
+ errorCollector.append(validationResponse);
4389
+ isValid = false;
4390
+ }
4391
+ }
4392
+ if (!isValid) {
4393
+ errorCollector.prepend(
4394
+ new JsonSchemaViolationError(`Data at ${path} did not match some subschemas in allOf.`)
4395
+ );
4396
+ }
4397
+ return errorCollector.toValidationResponse();
4398
+ }
4399
+ function validateNot(data, schema, path, document) {
4400
+ const validationResponse = validateJsonSchema(data, schema.not, path, document);
4401
+ if (validationResponse.isOk()) {
4402
+ return invalidSchemaResponseWithError(
4403
+ new JsonSchemaViolationError(
4404
+ `Data at ${path} validated against the schema of a not clause.`
4405
+ )
4406
+ );
4407
+ }
4408
+ return validSchemaResponse();
4409
+ }
4410
+ function validateObject(data, schema, path, document) {
4411
+ const schemaKeys = Object.keys(schema.properties);
4412
+ const requiredKeys = new Set(schema.required);
4413
+ const schemaKeySet = new Set(schemaKeys);
4414
+ const errorCollector = new JsonSchemaErrorCollector();
4415
+ Object.keys(data).forEach((key) => {
4416
+ if (!schemaKeySet.has(key)) {
4417
+ errorCollector.append(
4418
+ validateJsonSchema(
4419
+ data[key],
4420
+ schema.additionalProperties,
4421
+ `${path}.additionalProperties[${key}]`,
4422
+ document
4423
+ )
4424
+ );
4425
+ }
4426
+ });
4427
+ for (let i = 0, length = schemaKeys.length; i < length; i++) {
4428
+ const key = schemaKeys[i];
4429
+ const keyInData = key in data && data[key] !== void 0;
4430
+ if (requiredKeys.has(key) && !keyInData) {
4431
+ errorCollector.add(
4432
+ new MissingRequiredPropertyError(
4433
+ `Object at path '${path}' is missing required property '${key}'.`
4434
+ )
4435
+ );
4436
+ }
4437
+ if (keyInData) {
4438
+ errorCollector.append(
4439
+ validateJsonSchema(
4440
+ data[key],
4441
+ schema.properties[key],
4442
+ `${path}.${key}`,
4443
+ document
4444
+ )
4445
+ );
4446
+ }
4447
+ }
4448
+ return errorCollector.toValidationResponse();
4449
+ }
4450
+ function validateArray(data, schema, path, document) {
4451
+ if (schema.minItems !== void 0 && data.length < schema.minItems) {
4452
+ return invalidSchemaResponseWithError(
4453
+ new MinItemsViolationError(
4454
+ `Array at path '${path}' fails minItems constraint. Has ${data.length} items, needs at least ${schema.minItems}.`
4455
+ )
4456
+ );
4457
+ }
4458
+ if (schema.maxItems !== void 0 && data.length > schema.maxItems) {
4459
+ return invalidSchemaResponseWithError(
4460
+ new MaxItemsViolationError(
4461
+ `Array at path '${path}' fails maxItems constraint. Has ${data.length} items, needs at most ${schema.maxItems}.`
4462
+ )
4463
+ );
4464
+ }
4465
+ const errorCollector = new JsonSchemaErrorCollector();
4466
+ data.forEach(
4467
+ (element, index) => errorCollector.append(
4468
+ validateJsonSchema(element, schema.items, `${path}[${index}]`, document)
4469
+ )
4470
+ );
4471
+ return errorCollector.toValidationResponse();
4472
+ }
4473
+ function validateScalar(data, schema, path) {
4474
+ const schemaDataType = schema.type;
4475
+ const dataType = typeof data;
4476
+ if (schemaDataType === "integer") {
4477
+ if (dataType !== "number" || !Number.isInteger(data)) {
4478
+ return invalidSchemaResponseWithError(incorrectTypeError("integer", dataType, path));
4479
+ }
4480
+ } else if (schemaDataType === "number") {
4481
+ if (dataType !== "number") {
4482
+ return invalidSchemaResponseWithError(incorrectTypeError("number", dataType, path));
4483
+ }
4484
+ } else if (schemaDataType === "string") {
4485
+ if (dataType !== "string") {
4486
+ return invalidSchemaResponseWithError(incorrectTypeError("string", dataType, path));
4487
+ }
4488
+ } else if (schemaDataType === "boolean") {
4489
+ if (dataType !== "boolean") {
4490
+ return invalidSchemaResponseWithError(incorrectTypeError("boolean", dataType, path));
4491
+ }
4492
+ } else if (schemaDataType === "null") {
4493
+ if (data !== null) {
4494
+ return invalidSchemaResponseWithError(incorrectTypeError("null", dataType, path));
4495
+ }
4496
+ } else {
4497
+ return invalidSchemaResponseWithError(
4498
+ new IncorrectTypeError(`Unknown schema data type: ${schemaDataType}.`)
4499
+ );
4500
+ }
4501
+ return validSchemaResponse();
4502
+ }
4503
+ function validateRef(data, schema, path, document) {
4504
+ if (!schema.$ref.startsWith("#")) {
4505
+ return invalidSchemaResponseWithError(
4506
+ new InvalidRefError(
4507
+ `$ref values that do not refer to the current document are unsupported (must start with '#')`
4508
+ )
4509
+ );
4510
+ }
4511
+ try {
4512
+ const schemaToValidate = findSchemaAtPath(document, schema.$ref);
4513
+ return validateJsonSchema(data, schemaToValidate, path, document);
4514
+ } catch (e) {
4515
+ return invalidSchemaResponseWithError(e);
4516
+ }
4517
+ }
4518
+ function validateEnum(data, enumValue, path) {
4519
+ if (!enumValue.some((value) => deepEquals$1(value, data))) {
4520
+ return invalidSchemaResponseWithError(
4521
+ new JsonSchemaViolationError(
4522
+ `Data at ${path} did not match any values in enum. Expected value in: [${enumValue.map((value) => stringify$1(value)).join()}]`
4523
+ )
4524
+ );
4525
+ }
4526
+ return validSchemaResponse();
4527
+ }
4528
+ function validateConst(data, constValue, path) {
4529
+ if (!deepEquals$1(constValue, data)) {
4530
+ return invalidSchemaResponseWithError(
4531
+ new JsonSchemaViolationError(
4532
+ `Data at ${path} did not match const. Expected: ${stringify$1(constValue)}`
4533
+ )
4534
+ );
4535
+ }
4536
+ return validSchemaResponse();
4537
+ }
4538
+ function findSchemaAtPath(document, ref) {
4539
+ if (ref === "#") return document;
4540
+ const keys = ref.replace(/^#\//, "").split("/");
4541
+ let current = document;
4542
+ let path = "#";
4543
+ for (const key of keys) {
4544
+ path = `${path}/${key}`;
4545
+ if (current[key] === void 0) {
4546
+ throw new InvalidRefError(
4547
+ `Invalid $ref value '${ref}'. Cannot find target schema at '${path}'`
4548
+ );
4549
+ }
4550
+ current = current[key];
4551
+ }
4552
+ return current;
4553
+ }
4554
+
4555
+ /*!
4556
+ * Copyright (c) 2022, Salesforce, Inc.,
4557
+ * All rights reserved.
4558
+ * For full license text, see the LICENSE.txt file
4559
+ */
4560
+ function isUserVisibleError(error) {
4561
+ return error instanceof Error && "type" in error && error.type === "user-visible";
4562
+ }
4563
+ function throwUserlandError(error) {
4564
+ logError(error);
4565
+ throw buildUserlandError(error);
4566
+ }
4567
+ function emitError(callback, error) {
4568
+ logError(error);
4569
+ callback({ data: void 0, error: buildUserlandError(error) });
4570
+ }
4571
+ function buildUserlandError(error) {
4572
+ if (isUserVisibleError(error)) {
4573
+ return error.data;
4574
+ }
4575
+ return new Error("Internal error in Lightning Data Service adapter occurred.");
4576
+ }
4577
+ function logError(error) {
4578
+ if (isUserVisibleError(error)) {
4579
+ return;
4580
+ }
4581
+ console.error("OneStore Command threw an error that we did not expect", error);
4582
+ }
4583
+
4584
+ /*!
4585
+ * Copyright (c) 2022, Salesforce, Inc.,
4586
+ * All rights reserved.
4587
+ * For full license text, see the LICENSE.txt file
4588
+ */
4589
+ function buildBaseImperativeInvoker(getCommand, transformResult) {
4590
+ return async (...params) => {
4591
+ const command = getCommand({ params, assertIsValid });
4592
+ try {
4593
+ return command.execute().then((result) => transformResult(result));
4594
+ } catch (error) {
4595
+ throwUserlandError(error);
4596
+ }
4597
+ };
4598
+ }
4599
+ const supportedCachePolicyTypes = ["no-cache", "only-if-cached"];
4600
+ function requestContextIsSupportedCachePolicy(requestContext) {
4601
+ return typeof requestContext === "object" && requestContext !== null && "cachePolicy" in requestContext && typeof requestContext.cachePolicy === "object" && requestContext.cachePolicy !== null && "type" in requestContext.cachePolicy && typeof requestContext.cachePolicy.type === "string" && supportedCachePolicyTypes.includes(
4602
+ requestContext.cachePolicy.type
4603
+ );
4604
+ }
4605
+ function getOverridesForLegacyRequestContext(requestContext) {
4606
+ if (requestContextIsSupportedCachePolicy(requestContext)) {
4607
+ return { cacheControlConfig: { type: requestContext.cachePolicy.type } };
4608
+ }
4609
+ return {};
4610
+ }
4611
+ function handleEmit(res, callback) {
4612
+ const consumerEmittedData = {
4613
+ data: void 0,
4614
+ errors: void 0
4615
+ };
4616
+ if (res.isOk()) {
4617
+ consumerEmittedData.data = res.value.data;
4618
+ } else {
4619
+ const { data, errors } = toGraphQLResponseFromFailure$1(res.error);
4620
+ consumerEmittedData.data = data;
4621
+ consumerEmittedData.errors = errors;
4622
+ }
4623
+ callback(consumerEmittedData);
4624
+ }
4625
+ function toGraphQLResponseFromFailure$1(failure) {
4626
+ if (isUserVisibleError$1(failure)) {
4627
+ return {
4628
+ data: failure.data.data,
4629
+ errors: failure.data.errors
4630
+ };
4631
+ }
4632
+ logError$1(failure);
4633
+ return {
4634
+ data: void 0,
4635
+ errors: [{ message: "Internal error in GraphQL adapter occurred", locations: [] }]
4636
+ };
4637
+ }
4638
+ class DefaultImperativeBindingsService {
4639
+ bind(getCommand) {
4640
+ return buildBaseImperativeInvoker(getCommand, (result) => {
4641
+ if (result.isOk()) {
4642
+ deepFreeze(result.value);
4643
+ return isSubscribableResult(result) ? result.value.data : result.value;
4644
+ }
4645
+ throw toError(isSubscribableResult(result) ? result.error.failure : result.error);
4646
+ });
4647
+ }
4648
+ }
4649
+ function buildServiceDescriptor$6() {
4650
+ return {
4651
+ type: "defaultImperativeBindings",
4652
+ version: "1.0",
4653
+ service: new DefaultImperativeBindingsService()
4654
+ };
4655
+ }
4656
+ class QueryImperativeBindingsService {
4657
+ bind(getCommand) {
4658
+ return buildBaseImperativeInvoker(getCommand, (result) => {
4659
+ if (result.isOk()) {
4660
+ deepFreeze(result.value);
4661
+ return isSubscribableResult(result) ? { data: result.value.data } : { data: result.value };
4662
+ }
4663
+ throw toError(isSubscribableResult(result) ? result.error.failure : result.error);
4664
+ });
4665
+ }
4666
+ }
4667
+ function buildServiceDescriptor$5() {
4668
+ return {
4669
+ type: "queryImperativeBindings",
4670
+ version: "1.0",
4671
+ service: new QueryImperativeBindingsService()
4672
+ };
4673
+ }
4674
+ class SubscribableImperativeBindingsService {
4675
+ bind(getCommand, exposeRefresh = false) {
4676
+ return buildBaseImperativeInvoker(
4677
+ getCommand,
4678
+ (result) => this.transformResult(result, exposeRefresh)
4679
+ );
4680
+ }
4681
+ transformResult(result, exposeRefresh = false) {
4682
+ if (!isSubscribableResult(result)) {
4683
+ console.error(
4684
+ "Non-subscribable result encountered - please use correct operation type"
4685
+ );
4686
+ throw new Error("Internal error in Lightning Data Service adapter occurred");
4687
+ }
4688
+ if (result.isOk()) {
4689
+ deepFreeze(result.value.data);
4690
+ const api = {
4691
+ data: result.value.data,
4692
+ subscribe: (cb) => {
4693
+ result.value.subscribe((result2) => {
4694
+ if (result2.isErr()) {
4695
+ return cb({ data: void 0, error: toError(result2.error) });
4696
+ }
4697
+ return cb({ data: result2.value, error: void 0 });
4698
+ });
4699
+ }
4700
+ };
4701
+ if (exposeRefresh) {
4702
+ return {
4703
+ ...api,
4704
+ refresh: () => {
4705
+ return result.value.refresh().then((res) => {
4706
+ if (res.isOk()) {
4707
+ return void 0;
4708
+ }
4709
+ throw res.error;
4710
+ });
4711
+ }
4712
+ };
4713
+ } else {
4714
+ return api;
4715
+ }
4716
+ } else {
4717
+ throw toError(result.error.failure);
4718
+ }
4719
+ }
4720
+ }
4721
+ function buildServiceDescriptor$4() {
4722
+ return {
4723
+ type: "subscribableImperativeBindings",
4724
+ version: "1.0",
4725
+ service: new SubscribableImperativeBindingsService()
4726
+ };
4727
+ }
4728
+ class LegacyImperativeBindingsService {
4729
+ bind(getCommand) {
4730
+ const invoke = async (config, requestContext, callback) => {
4731
+ const command = getCommand({ config, assertIsValid });
4732
+ try {
4733
+ const overrides = getOverridesForLegacyRequestContext(requestContext);
4734
+ const result = await command.execute(overrides);
4735
+ if (result.isOk()) {
4736
+ deepFreeze(result.value);
4737
+ callback({ data: result.value.data, error: void 0 });
4738
+ } else {
4739
+ callback({ data: void 0, error: toError(result.error.failure) });
4740
+ }
4741
+ } catch (error) {
4742
+ emitError(callback, error);
4743
+ }
4744
+ };
4745
+ const subscribe = (config, requestContext, callback) => {
4746
+ const command = getCommand({ config, assertIsValid });
4747
+ let unsubscribe = () => {
4748
+ };
4749
+ try {
4750
+ const overrides = getOverridesForLegacyRequestContext(requestContext);
4751
+ command.execute(overrides).then(
4752
+ (result) => {
4753
+ if (!result.isOk()) {
4754
+ callback({ data: void 0, error: toError(result.error.failure) });
4755
+ return;
4756
+ }
4757
+ unsubscribe = result.value.subscribe((res) => {
4758
+ if (res.isOk()) {
4759
+ callback({ data: res.value, error: void 0 });
4760
+ } else {
4761
+ callback({ data: void 0, error: toError(res.error) });
4762
+ }
4763
+ });
4764
+ callback({ data: result.value.data, error: void 0 });
4765
+ },
4766
+ (e) => {
4767
+ emitError(callback, e);
4768
+ }
4769
+ );
4770
+ } catch (e) {
4771
+ emitError(callback, e);
4772
+ }
4773
+ return () => {
4774
+ unsubscribe();
4775
+ };
4776
+ };
4777
+ return { invoke, subscribe };
4778
+ }
4779
+ }
4780
+ function buildServiceDescriptor$3() {
4781
+ return {
4782
+ type: "legacyImperativeBindings",
4783
+ version: "1.0",
4784
+ service: new LegacyImperativeBindingsService()
4785
+ };
4786
+ }
4787
+ class GraphQLImperativeBindingsService {
4788
+ bind(getCommand, exposeRefresh = false) {
4789
+ return async (...params) => {
4790
+ try {
4791
+ if (params.length) {
4792
+ params[0] = wrapConfigAndVerify(params[0]);
4793
+ }
4794
+ return await buildBaseImperativeInvoker(getCommand, (result) => this.transformResult(result, exposeRefresh))(...params);
4795
+ } catch (error) {
4796
+ logError$1(error);
4797
+ return {
4798
+ data: void 0,
4799
+ errors: [
4800
+ { message: "Internal error in GraphQL adapter occurred", locations: [] }
4801
+ ]
4802
+ };
4803
+ }
4804
+ };
4805
+ }
4806
+ transformResult(result, exposeRefresh = false) {
4807
+ const consumerEmittedData = {
4808
+ data: void 0,
4809
+ errors: void 0
4810
+ };
4811
+ if (result.isOk()) {
4812
+ deepFreeze(result.value);
4813
+ consumerEmittedData.data = result.value.data.data;
4814
+ consumerEmittedData.subscribe = (cb) => {
4815
+ result.value.subscribe((res) => {
4816
+ const consumerEmittedData2 = {
4817
+ data: void 0,
4818
+ errors: void 0
4819
+ };
4820
+ if (res.isOk()) {
4821
+ consumerEmittedData2.data = res.value.data;
4822
+ } else {
4823
+ if (isUserVisibleError$1(res.error)) {
4824
+ consumerEmittedData2.data = res.error.data.data;
4825
+ consumerEmittedData2.errors = res.error.data.errors;
4826
+ } else {
4827
+ logError$1(res.error);
4828
+ consumerEmittedData2.errors = [
4829
+ {
4830
+ message: "Internal error in GraphQL adapter occurred",
4831
+ locations: []
4832
+ }
4833
+ ];
4834
+ }
4835
+ }
4836
+ cb(consumerEmittedData2);
4837
+ });
4838
+ };
4839
+ if (exposeRefresh) {
4840
+ consumerEmittedData.refresh = () => {
4841
+ return new Promise((resolve, reject) => {
4842
+ try {
4843
+ result.value.refresh().then((res) => {
4844
+ if (res.isOk()) {
4845
+ resolve();
4846
+ } else {
4847
+ reject(
4848
+ new Error(
4849
+ "Internal error in GraphQL adapter occurred: Failed to refresh GraphQL data"
4850
+ )
4851
+ );
4852
+ }
4853
+ });
4854
+ } catch (error) {
4855
+ logError$1(error);
4856
+ reject(
4857
+ new Error(
4858
+ "Internal error in GraphQL adapter occurred: Failed to refresh GraphQL data"
4859
+ )
4860
+ );
4861
+ }
4862
+ });
4863
+ };
4864
+ }
4865
+ } else {
4866
+ const resp = toGraphQLResponseFromFailure$1(result.error.failure);
4867
+ consumerEmittedData.data = resp.data;
4868
+ consumerEmittedData.errors = resp.errors;
4869
+ }
4870
+ return consumerEmittedData;
4871
+ }
4872
+ }
4873
+ function buildServiceDescriptor$2$1() {
4874
+ return {
4875
+ type: "graphQLImperativeBindings",
4876
+ version: "1.0",
4877
+ service: new GraphQLImperativeBindingsService()
4878
+ };
4879
+ }
4880
+ class GraphQLLegacyImperativeBindingsService {
4881
+ bind(getCommand) {
4882
+ const invoke = async (config, requestContext, callback) => {
4883
+ config = wrapConfigAndVerify(config);
4884
+ const command = getCommand({ config, assertIsValid });
4885
+ try {
4886
+ const overrides = getOverridesForLegacyRequestContext(requestContext);
4887
+ const result = await command.execute(overrides);
4888
+ const consumerEmittedData = {
4889
+ data: void 0,
4890
+ errors: void 0
4891
+ };
4892
+ if (result.isOk()) {
4893
+ deepFreeze(result.value);
4894
+ consumerEmittedData.data = result.value.data.data;
4895
+ } else {
4896
+ const { data, errors } = toGraphQLResponseFromFailure$1(result.error.failure);
4897
+ consumerEmittedData.data = data;
4898
+ consumerEmittedData.errors = errors;
4899
+ }
4900
+ callback(consumerEmittedData);
4901
+ } catch (error) {
4902
+ logError$1(error);
4903
+ callback({
4904
+ data: void 0,
4905
+ errors: [
4906
+ { message: "Internal error in GraphQL adapter occurred", locations: [] }
4907
+ ]
4908
+ });
4909
+ }
4910
+ };
4911
+ const subscribe = (config, requestContext, callback) => {
4912
+ config = wrapConfigAndVerify(config);
4913
+ const command = getCommand({ config, assertIsValid });
4914
+ let unsubscribe = () => {
4915
+ };
4916
+ const overrides = getOverridesForLegacyRequestContext(requestContext);
4917
+ command.execute(overrides).then((result) => {
4918
+ const consumerEmittedData = {
4919
+ data: void 0,
4920
+ errors: void 0
4921
+ };
4922
+ if (result.isOk()) {
4923
+ deepFreeze(result.value);
4924
+ consumerEmittedData.data = result.value.data.data;
4925
+ unsubscribe = result.value.subscribe(
4926
+ (res) => {
4927
+ handleEmit(res, callback);
4928
+ }
4929
+ );
4930
+ } else {
4931
+ const { data, errors } = toGraphQLResponseFromFailure$1(result.error.failure);
4932
+ consumerEmittedData.data = data;
4933
+ consumerEmittedData.errors = errors;
4934
+ unsubscribe = result.error.subscribe(
4935
+ (res) => {
4936
+ handleEmit(res, callback);
4937
+ }
4938
+ );
4939
+ }
4940
+ callback(consumerEmittedData);
4941
+ });
4942
+ return () => {
4943
+ unsubscribe();
4944
+ };
4945
+ };
4946
+ return { invoke, subscribe };
4947
+ }
4948
+ }
4949
+ function buildServiceDescriptor$1$1() {
4950
+ return {
4951
+ type: "graphQLLegacyImperativeBindings",
4952
+ version: "1.0",
4953
+ service: new GraphQLLegacyImperativeBindingsService()
4954
+ };
4955
+ }
4956
+ class GraphQLMutationBindingsService {
4957
+ bind(getCommand) {
4958
+ return async (...params) => {
4959
+ try {
4960
+ if (params.length) {
4961
+ params[0] = wrapConfigAndVerify(params[0], {
4962
+ acceptedOperations: ["mutation"]
4963
+ });
4964
+ }
4965
+ const command = getCommand({ params, assertIsValid });
4966
+ const result = await command.execute({ cacheControlConfig: { type: "no-cache" } });
4967
+ if (result.isOk()) {
4968
+ deepFreeze(result.value);
4969
+ return result.value.data;
4970
+ } else {
4971
+ return toGraphQLResponseFromFailure$1(result.error.failure);
4972
+ }
4973
+ } catch (error) {
4974
+ logError$1(error);
4975
+ return {
4976
+ data: void 0,
4977
+ errors: [
4978
+ { message: "Internal error in GraphQL adapter occurred", locations: [] }
4979
+ ]
4980
+ };
4981
+ }
4982
+ };
4983
+ }
4984
+ }
4985
+ function buildServiceDescriptor$7() {
4986
+ return {
4987
+ type: "graphQLMutationBindings",
4988
+ version: "1.0",
4989
+ service: new GraphQLMutationBindingsService()
4990
+ };
4991
+ }
4992
+
4993
+ /*!
4994
+ * Copyright (c) 2022, Salesforce, Inc.,
4995
+ * All rights reserved.
4996
+ * For full license text, see the LICENSE.txt file
4997
+ */
4998
+ class Sanitizer {
4999
+ constructor(obj) {
5000
+ this.obj = obj;
5001
+ this.copy = {};
5002
+ this.currentPath = {
5003
+ key: "",
5004
+ value: obj,
5005
+ parent: null,
5006
+ data: this.copy
5007
+ };
5008
+ }
5009
+ sanitize() {
5010
+ const sanitizer = this;
5011
+ JSON.stringify(this.obj, function(key, value) {
5012
+ if (key === "") {
5013
+ return value;
5014
+ }
5015
+ const parent = this;
5016
+ if (parent !== sanitizer.currentPath.value) {
5017
+ sanitizer.exit(parent);
5018
+ }
5019
+ if (typeof value === "object" && value !== null) {
5020
+ sanitizer.enter(key, value);
5021
+ return value;
5022
+ }
5023
+ sanitizer.currentPath.data[key] = value;
5024
+ return value;
5025
+ });
5026
+ return this.copy;
5027
+ }
5028
+ enter(key, value) {
5029
+ const { currentPath: parentPath } = this;
5030
+ const data = parentPath.data[key] = Array.isArray(value) ? [] : {};
5031
+ this.currentPath = {
5032
+ key,
5033
+ value,
5034
+ parent: parentPath,
5035
+ data
5036
+ };
5037
+ }
5038
+ exit(parent) {
5039
+ while (this.currentPath.value !== parent) {
5040
+ this.currentPath = this.currentPath.parent || this.currentPath;
5041
+ }
5042
+ }
5043
+ }
5044
+ function sanitize(obj) {
5045
+ return new Sanitizer(obj).sanitize();
5046
+ }
5047
+ function isIncompleteConfigError(err) {
5048
+ return err instanceof MissingRequiredPropertyError || err instanceof JsonSchemaViolationError && err.validationErrors.find(
5049
+ (validationError) => validationError instanceof MissingRequiredPropertyError
5050
+ ) !== void 0;
4203
5051
  }
5052
+ class CommandWireAdapterConstructor {
5053
+ constructor(callback, sourceContext, options) {
5054
+ this.callback = callback;
5055
+ this.connected = false;
5056
+ this.exposeRefresh = false;
5057
+ if (!(options == null ? void 0 : options.skipEmptyEmit)) {
5058
+ this.emit();
5059
+ }
5060
+ }
5061
+ connect() {
5062
+ this.connected = true;
5063
+ this.invokeAdapter();
5064
+ }
5065
+ disconnect() {
5066
+ this.unsubscribe();
5067
+ this.connected = false;
5068
+ }
5069
+ update(config, _context) {
5070
+ this.unsubscribe();
5071
+ this.config = sanitize(config);
5072
+ this.invokeAdapter();
5073
+ }
5074
+ emit(result) {
5075
+ try {
5076
+ if (result === void 0) {
5077
+ this.callback({ data: void 0, error: void 0 });
5078
+ } else {
5079
+ const consumerEmittedRefresh = () => {
5080
+ if (!this.refresh) {
5081
+ return Promise.resolve();
5082
+ }
5083
+ return new Promise((resolve, reject) => {
5084
+ if (!this.refresh) {
5085
+ resolve();
5086
+ return;
5087
+ }
5088
+ this.refresh().then((res) => {
5089
+ if (res.isOk()) {
5090
+ resolve();
5091
+ } else {
5092
+ reject(
5093
+ new Error(
5094
+ "Internal error in Lightning Data Service adapter occurred: Failed to refresh data"
5095
+ )
5096
+ );
5097
+ }
5098
+ });
5099
+ });
5100
+ };
5101
+ let consumerEmittedData = {
5102
+ data: void 0,
5103
+ error: void 0
5104
+ };
5105
+ if (this.exposeRefresh && this.refresh) {
5106
+ consumerEmittedData.refresh = consumerEmittedRefresh;
5107
+ }
5108
+ if (result.isErr()) {
5109
+ if (isSubscribableResult(result)) {
5110
+ consumerEmittedData.error = result.error.failure;
5111
+ } else {
5112
+ consumerEmittedData.error = result.error;
5113
+ }
5114
+ } else {
5115
+ if (isSubscribableResult(result)) {
5116
+ deepFreeze(result.value.data);
5117
+ consumerEmittedData.data = result.value.data;
5118
+ } else {
5119
+ deepFreeze(result.value);
5120
+ consumerEmittedData.data = result.value;
5121
+ }
5122
+ }
5123
+ this.callback(consumerEmittedData);
5124
+ }
5125
+ } catch (e) {
5126
+ this.handleExecutionThrow(e);
5127
+ }
5128
+ }
5129
+ invokeAdapter() {
5130
+ if (!this.connected || this.config === void 0) {
5131
+ return;
5132
+ }
5133
+ if (this.configSchema) {
5134
+ try {
5135
+ assertIsValid(this.config, this.configSchema);
5136
+ } catch (err) {
5137
+ if (isIncompleteConfigError(err)) {
5138
+ return;
5139
+ }
5140
+ throw err;
5141
+ }
5142
+ }
5143
+ const initialConfig = this.config;
5144
+ const command = this.getCommand();
5145
+ try {
5146
+ command.execute().then((result) => {
5147
+ if (!this.connected || this.config !== initialConfig) {
5148
+ return;
5149
+ }
5150
+ this.refresh = void 0;
5151
+ if (result.isOk()) {
5152
+ if (isSubscribableResult(result)) {
5153
+ const value = result.value;
5154
+ this.unsubscriber = value.subscribe((updatedResult) => {
5155
+ if (!this.connected || this.config !== initialConfig) {
5156
+ this.unsubscribe();
5157
+ return;
5158
+ }
5159
+ this.emit(updatedResult);
5160
+ });
5161
+ this.refresh = value.refresh;
5162
+ this.emit(ok$2(value.data));
5163
+ } else {
5164
+ this.emit(result);
5165
+ }
5166
+ } else {
5167
+ if (isSubscribableResult(result)) {
5168
+ const value = result.error;
5169
+ this.unsubscriber = value.subscribe((updatedResult) => {
5170
+ if (!this.connected || this.config !== initialConfig) {
5171
+ this.unsubscribe();
5172
+ return;
5173
+ }
5174
+ this.emit(updatedResult);
5175
+ });
5176
+ this.refresh = value.refresh;
5177
+ this.emit(result);
5178
+ } else {
5179
+ this.unsubscriber = () => {
5180
+ };
5181
+ this.emit(result);
5182
+ }
5183
+ }
5184
+ });
5185
+ } catch (e) {
5186
+ this.handleExecutionThrow(e);
5187
+ }
5188
+ }
5189
+ handleExecutionThrow(error) {
5190
+ emitError(this.callback, error);
5191
+ }
5192
+ unsubscribe() {
5193
+ if (this.unsubscriber) {
5194
+ this.unsubscriber();
5195
+ delete this.unsubscriber;
5196
+ }
5197
+ }
5198
+ }
5199
+ function toGraphQLResponseFromFailure(failure) {
5200
+ if (isUserVisibleError$1(failure)) {
5201
+ return {
5202
+ data: failure.data.data,
5203
+ errors: failure.data.errors
5204
+ };
5205
+ }
5206
+ logError$1(failure);
5207
+ return {
5208
+ data: void 0,
5209
+ errors: [{ message: "Internal error in GraphQL adapter occurred", locations: [] }]
5210
+ };
5211
+ }
5212
+ class LWCWireBindingsService {
5213
+ bind(getCommand, configSchema, exposeRefresh = false) {
5214
+ return class extends CommandWireAdapterConstructor {
5215
+ constructor() {
5216
+ super(...arguments);
5217
+ this.configSchema = configSchema;
5218
+ this.exposeRefresh = exposeRefresh;
5219
+ }
5220
+ getCommand() {
5221
+ return getCommand(this.config);
5222
+ }
5223
+ };
5224
+ }
5225
+ }
5226
+ function buildServiceDescriptor$1() {
5227
+ return {
5228
+ type: "lwcWireBindings",
5229
+ version: "1.0",
5230
+ service: new LWCWireBindingsService()
5231
+ };
5232
+ }
5233
+ class GraphQLCommandWireAdapterConstructor extends CommandWireAdapterConstructor {
5234
+ emit(result) {
5235
+ try {
5236
+ if (result === void 0) {
5237
+ this.callback({ data: void 0, errors: void 0 });
5238
+ } else {
5239
+ const consumerEmittedRefresh = () => {
5240
+ if (!this.refresh) {
5241
+ return Promise.resolve();
5242
+ }
5243
+ return new Promise((resolve, reject) => {
5244
+ if (!this.refresh) {
5245
+ resolve();
5246
+ return;
5247
+ }
5248
+ this.refresh().then((res) => {
5249
+ if (res.isOk()) {
5250
+ resolve();
5251
+ } else {
5252
+ reject(
5253
+ new Error(
5254
+ "Internal error in GraphQL adapter occurred: Failed to refresh GraphQL data"
5255
+ )
5256
+ );
5257
+ }
5258
+ });
5259
+ });
5260
+ };
5261
+ let consumerEmittedData = {
5262
+ data: void 0,
5263
+ errors: void 0
5264
+ };
5265
+ if (this.exposeRefresh && this.refresh) {
5266
+ consumerEmittedData.refresh = consumerEmittedRefresh;
5267
+ }
5268
+ if (result.isErr()) {
5269
+ const failure = isSubscribableResult(result) ? result.error.failure : result.error;
5270
+ const resp = toGraphQLResponseFromFailure(failure);
5271
+ consumerEmittedData.data = resp.data;
5272
+ consumerEmittedData.errors = resp.errors;
5273
+ } else {
5274
+ consumerEmittedData.data = result.value.data;
5275
+ }
5276
+ deepFreeze(consumerEmittedData);
5277
+ this.callback(consumerEmittedData);
5278
+ }
5279
+ } catch (e) {
5280
+ logError$1(e);
5281
+ this.handleExecutionThrow(e);
5282
+ }
5283
+ }
5284
+ handleExecutionThrow(e) {
5285
+ logError$1(e);
5286
+ this.callback({
5287
+ data: void 0,
5288
+ errors: [{ message: "Internal error in GraphQL adapter occurred", locations: [] }]
5289
+ });
5290
+ }
5291
+ update(config, _context) {
5292
+ this.unsubscribe();
5293
+ const resolvedQuery = resolveAst(config.query);
5294
+ if (resolvedQuery) {
5295
+ validateGraphQLOperations(
5296
+ { query: resolvedQuery, operationName: config == null ? void 0 : config.operationName },
5297
+ { acceptedOperations: ["query"] }
5298
+ );
5299
+ }
5300
+ this.config = {
5301
+ ...sanitize(config),
5302
+ query: resolvedQuery
5303
+ };
5304
+ this.invokeAdapter();
5305
+ }
5306
+ }
5307
+ class LWCGraphQLWireBindingsService {
5308
+ bind(getCommand, configSchema, exposeRefresh = false) {
5309
+ return class extends GraphQLCommandWireAdapterConstructor {
5310
+ constructor() {
5311
+ super(...arguments);
5312
+ this.configSchema = configSchema;
5313
+ this.exposeRefresh = exposeRefresh;
5314
+ }
5315
+ getCommand() {
5316
+ return getCommand(this.config);
5317
+ }
5318
+ };
5319
+ }
5320
+ }
5321
+ function buildServiceDescriptor$2() {
5322
+ return {
5323
+ type: "lwcGraphQLWireBindings",
5324
+ version: "1.0",
5325
+ service: new LWCGraphQLWireBindingsService()
5326
+ };
5327
+ }
5328
+
5329
+ /*!
5330
+ * Copyright (c) 2022, Salesforce, Inc.,
5331
+ * All rights reserved.
5332
+ * For full license text, see the LICENSE.txt file
5333
+ */
5334
+ function e(e2) {
5335
+ this.message = e2;
5336
+ }
5337
+ e.prototype = new Error(), e.prototype.name = "InvalidCharacterError";
5338
+ var r = "undefined" != typeof window && window.atob && window.atob.bind(window) || function(r2) {
5339
+ var t2 = String(r2).replace(/=+$/, "");
5340
+ if (t2.length % 4 == 1) throw new e("'atob' failed: The string to be decoded is not correctly encoded.");
5341
+ 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);
5342
+ return c;
5343
+ };
5344
+ function t(e2) {
5345
+ var t2 = e2.replace(/-/g, "+").replace(/_/g, "/");
5346
+ switch (t2.length % 4) {
5347
+ case 0:
5348
+ break;
5349
+ case 2:
5350
+ t2 += "==";
5351
+ break;
5352
+ case 3:
5353
+ t2 += "=";
5354
+ break;
5355
+ default:
5356
+ throw "Illegal base64url string!";
5357
+ }
5358
+ try {
5359
+ return (function(e3) {
5360
+ return decodeURIComponent(r(e3).replace(/(.)/g, (function(e4, r2) {
5361
+ var t3 = r2.charCodeAt(0).toString(16).toUpperCase();
5362
+ return t3.length < 2 && (t3 = "0" + t3), "%" + t3;
5363
+ })));
5364
+ })(t2);
5365
+ } catch (e3) {
5366
+ return r(t2);
5367
+ }
5368
+ }
5369
+ function n(e2) {
5370
+ this.message = e2;
5371
+ }
5372
+ function o(e2, r2) {
5373
+ if ("string" != typeof e2) throw new n("Invalid token specified");
5374
+ var o2 = true === (r2 = r2 || {}).header ? 0 : 1;
5375
+ try {
5376
+ return JSON.parse(t(e2.split(".")[o2]));
5377
+ } catch (e3) {
5378
+ throw new n("Invalid token specified: " + e3.message);
5379
+ }
5380
+ }
5381
+ n.prototype = new Error(), n.prototype.name = "InvalidTokenError";
4204
5382
  class JwtToken {
4205
5383
  /**
4206
5384
  * Create a new JwtToken.
@@ -4443,26 +5621,39 @@ class JwtManager {
4443
5621
  * All rights reserved.
4444
5622
  * For full license text, see the LICENSE.txt file
4445
5623
  */
4446
- function buildServiceDescriptor(interceptors = { request: [], response: [] }, retryService) {
5624
+ function buildServiceDescriptor(interceptors = { request: [], response: [], finally: [] }, retryService) {
4447
5625
  return {
4448
5626
  type: "fetch",
4449
5627
  version: "1.0",
4450
5628
  service: function(...args) {
4451
- const { request: requestInterceptors = [], response: responseInterceptors = [] } = interceptors;
5629
+ var _a;
5630
+ const context = (_a = interceptors.createContext) == null ? void 0 : _a.call(interceptors);
5631
+ const {
5632
+ request: requestInterceptors = [],
5633
+ response: responseInterceptors = [],
5634
+ finally: finallyInterceptors = []
5635
+ } = interceptors;
4452
5636
  const pending = requestInterceptors.reduce(
4453
- (previousPromise, interceptor) => previousPromise.then(interceptor),
4454
- resolvedPromiseLike$3(args)
5637
+ (previousPromise, interceptor) => previousPromise.then((args2) => interceptor(args2, context)),
5638
+ resolvedPromiseLike$2(args)
4455
5639
  );
4456
- return pending.then((args2) => {
5640
+ return Promise.resolve(pending).then((args2) => {
4457
5641
  if (retryService) {
4458
5642
  return retryService.applyRetry(() => fetch(...args2));
4459
5643
  }
4460
5644
  return fetch(...args2);
4461
5645
  }).then((response) => {
4462
5646
  return responseInterceptors.reduce(
4463
- (previousPromise, interceptor) => previousPromise.then(interceptor),
4464
- resolvedPromiseLike$3(response)
5647
+ (previousPromise, interceptor) => previousPromise.then((response2) => interceptor(response2, context)),
5648
+ resolvedPromiseLike$2(response)
4465
5649
  );
5650
+ }).finally(() => {
5651
+ if (finallyInterceptors.length > 0) {
5652
+ return finallyInterceptors.reduce(
5653
+ (previousPromise, interceptor) => previousPromise.then(() => interceptor(context)),
5654
+ Promise.resolve()
5655
+ );
5656
+ }
4466
5657
  });
4467
5658
  }
4468
5659
  };
@@ -4507,7 +5698,7 @@ function setHeaderAuthorization({ token }, fetchParams) {
4507
5698
  }
4508
5699
  function buildJwtRequestHeaderInterceptor(jwtManager, jwtRequestModifier = (_e, fetchArgs) => fetchArgs) {
4509
5700
  return (args) => {
4510
- return resolvedPromiseLike$3(jwtManager.getJwt()).then((token) => {
5701
+ return resolvedPromiseLike$2(jwtManager.getJwt()).then((token) => {
4511
5702
  const fetchArgsWithRequestHeaderAuthorization = setHeaderAuthorization(token, args);
4512
5703
  return token.extraInfo ? jwtRequestModifier(token.extraInfo, fetchArgsWithRequestHeaderAuthorization) : fetchArgsWithRequestHeaderAuthorization;
4513
5704
  });
@@ -4557,7 +5748,7 @@ const METHODS_WITH_CSRF = ['POST', 'PATCH', 'PUT', 'DELETE'];
4557
5748
  async function webruntimeRequestInterceptor(args) {
4558
5749
  const [url, requestInit] = args;
4559
5750
  if (!(typeof url === 'string' || url instanceof URL)) {
4560
- return resolvedPromiseLike$3(args);
5751
+ return resolvedPromiseLike$2(args);
4561
5752
  }
4562
5753
  const urlObj = buildApiBaseUrl(url, apiBasePath);
4563
5754
  urlObj.searchParams.append('language', language);
@@ -4568,7 +5759,7 @@ async function webruntimeRequestInterceptor(args) {
4568
5759
  if (requestInit?.method && METHODS_WITH_CSRF.includes(requestInit.method)) {
4569
5760
  await addCSRFToken(requestInit);
4570
5761
  }
4571
- return resolvedPromiseLike$3(args);
5762
+ return resolvedPromiseLike$2(args);
4572
5763
  }
4573
5764
  function buildApiBaseUrl(url, apiBasePath) {
4574
5765
  // The URL constructor's second argument provides a base if the first argument is a relative URL.
@@ -4643,9 +5834,9 @@ function buildCopilotFetchServiceDescriptor(logger) {
4643
5834
  requestInit.method !== 'POST' ||
4644
5835
  !requestInit.body ||
4645
5836
  typeof requestInit.body !== 'string') {
4646
- return resolvedPromiseLike$3(args);
5837
+ return resolvedPromiseLike$2(args);
4647
5838
  }
4648
- return resolvedPromiseLike$3(sfapJwtManager.getJwt()).then((token) => {
5839
+ return resolvedPromiseLike$2(sfapJwtManager.getJwt()).then((token) => {
4649
5840
  // replace the body's instanceConfig.endpoint with the JWT's iss value
4650
5841
  const body = JSON.parse(requestInit.body);
4651
5842
  if (!body || !token.decodedInfo || !token.decodedInfo.iss) {
@@ -4702,38 +5893,84 @@ function buildJwtRequestInterceptor(logger) {
4702
5893
  return jwtRequestHeaderInterceptor;
4703
5894
  }
4704
5895
 
4705
- const loggerService = new ConsoleLogger$1('ERROR');
4706
- const cacheServiceDescriptor = buildServiceDescriptor$9();
4707
- const instrumentationServiceDescriptor = buildServiceDescriptor$a(loggerService);
5896
+ const loggerService = new ConsoleLogger('ERROR');
5897
+ const cacheServiceDescriptor = buildServiceDescriptor$g();
5898
+ const instrumentationServiceDescriptor = buildServiceDescriptor$h(loggerService);
4708
5899
  const inMemoryCacheInclusionPolicyServiceDescriptor = buildInMemoryCacheInclusionPolicyService(cacheServiceDescriptor.service);
4709
- const featureFlagsServiceDescriptor = buildServiceDescriptor$6();
5900
+ const featureFlagsServiceDescriptor = buildServiceDescriptor$d();
4710
5901
  const featureFlagsService = featureFlagsServiceDescriptor.service;
4711
- // This disables the OneStore GraphQL in this runtime,
4712
- // we will enable this in the future, but while we do rollout, we disable it here
5902
+ // This disables the OneStore GraphQL mapping from lightning/uiGraphQLApi to lightning/graphql in this runtime,
5903
+ // The gate is likely NOT to rollout ever, but we keep it here for completeness
4713
5904
  featureFlagsService.set('useOneStoreGraphQL', false);
4714
- const services = [
4715
- instrumentationServiceDescriptor,
4716
- buildDefaultFetchServiceDescriptor(),
4717
- buildJwtAuthorizedSfapFetchServiceDescriptor(loggerService),
4718
- buildCopilotFetchServiceDescriptor(loggerService),
4719
- buildServiceDescriptor$b(instrumentationServiceDescriptor.service),
4720
- buildServiceDescriptor$8(cacheServiceDescriptor.service, inMemoryCacheInclusionPolicyServiceDescriptor.service, instrumentationServiceDescriptor.service),
4721
- buildServiceDescriptor$i(),
4722
- buildServiceDescriptor$3(),
4723
- buildServiceDescriptor$e(),
4724
- buildServiceDescriptor$j(),
4725
- buildServiceDescriptor$d(),
4726
- buildServiceDescriptor$c(),
4727
- buildServiceDescriptor$h(),
4728
- buildServiceDescriptor$g(),
4729
- buildServiceDescriptor$f(),
4730
- buildServiceDescriptor$7(),
4731
- buildServiceDescriptor$5(),
4732
- buildServiceDescriptor$4(),
4733
- featureFlagsServiceDescriptor,
4734
- // Luvio service won't be used since we set the useOneStoreGraphQL flag to false
4735
- buildServiceDescriptor$2({}),
4736
- buildServiceDescriptor$1({}, {}),
4737
- ];
4738
- setServices(services);
4739
- // version: 1.401.0-b1adb82748
5905
+ // Hardcoding to avoid dependency on lds-adapters-uiapi
5906
+ const notifyUpdateAvailableFactory = (luvio) => {
5907
+ return function notifyRecordUpdateAvailable(configs) {
5908
+ if (process.env.NODE_ENV !== 'production') {
5909
+ const requiredKeyParams = ['recordId'];
5910
+ configs.forEach((config) => {
5911
+ if (false === requiredKeyParams.every((req) => req in config)) {
5912
+ throw new Error(`one of the configs did not contain all required parameters`);
5913
+ }
5914
+ });
5915
+ }
5916
+ const keys = configs.map((c) => `UiApi::RecordRepresentation:${c.recordId}`); // Hardcoding to avoid dependency on lds-adapters-uiapi
5917
+ return luvio.notifyStoreUpdateAvailable(keys);
5918
+ };
5919
+ };
5920
+ function bindLuvioUiapiRecordsServiceDescriptor(luvio) {
5921
+ return buildServiceDescriptor$8((configs) => {
5922
+ return notifyUpdateAvailableFactory(luvio)(configs);
5923
+ }, (recordId, reader) => {
5924
+ const recordKey = `UiApi::RecordRepresentation:${recordId}`; // Hardcoding to avoid dependency on lds-adapters-uiapi
5925
+ reader.markSeenId(recordKey);
5926
+ const linkedData = reader.read({
5927
+ recordId: recordKey,
5928
+ node: {
5929
+ kind: 'Fragment',
5930
+ private: [],
5931
+ opaque: true,
5932
+ version: '98c5b18512e48ca8d28727549507e4ba', // Hardcoding to avoid dependency on lds-adapters-uiapi
5933
+ },
5934
+ variables: {},
5935
+ });
5936
+ // we don't want anything to be marked missing, since this results in an unfulfilled snapshot
5937
+ reader.unMarkMissing();
5938
+ return linkedData.data;
5939
+ });
5940
+ }
5941
+ withDefaultLuvio((luvio) => {
5942
+ const services = [
5943
+ instrumentationServiceDescriptor,
5944
+ buildDefaultFetchServiceDescriptor(),
5945
+ buildJwtAuthorizedSfapFetchServiceDescriptor(loggerService),
5946
+ buildCopilotFetchServiceDescriptor(loggerService),
5947
+ buildServiceDescriptor$i(instrumentationServiceDescriptor.service),
5948
+ buildServiceDescriptor$f(cacheServiceDescriptor.service, inMemoryCacheInclusionPolicyServiceDescriptor.service, instrumentationServiceDescriptor.service),
5949
+ buildServiceDescriptor$p(),
5950
+ buildServiceDescriptor$a(),
5951
+ buildServiceDescriptor$l(),
5952
+ buildServiceDescriptor$q(),
5953
+ buildServiceDescriptor$k(),
5954
+ buildServiceDescriptor$j(),
5955
+ buildServiceDescriptor$o(),
5956
+ buildServiceDescriptor$n(),
5957
+ buildServiceDescriptor$m(),
5958
+ buildServiceDescriptor$e(),
5959
+ buildServiceDescriptor$c(),
5960
+ buildServiceDescriptor$b(),
5961
+ featureFlagsServiceDescriptor,
5962
+ buildServiceDescriptor$9(luvio),
5963
+ bindLuvioUiapiRecordsServiceDescriptor(luvio),
5964
+ buildServiceDescriptor$6(),
5965
+ buildServiceDescriptor$5(),
5966
+ buildServiceDescriptor$4(),
5967
+ buildServiceDescriptor$3(),
5968
+ buildServiceDescriptor$2$1(),
5969
+ buildServiceDescriptor$1$1(),
5970
+ buildServiceDescriptor$7(),
5971
+ buildServiceDescriptor$1(),
5972
+ buildServiceDescriptor$2(),
5973
+ ];
5974
+ setServices(services);
5975
+ });
5976
+ // version: 1.402.0-bf9ae185ef