@salesforce/lds-worker-api 1.377.0 → 1.377.1

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.
@@ -4274,7 +4274,7 @@ function withDefaultLuvio(callback) {
4274
4274
  }
4275
4275
  callbacks.push(callback);
4276
4276
  }
4277
- // version: 1.377.0-3c95caf11c
4277
+ // version: 1.377.1-dadb6358f3
4278
4278
 
4279
4279
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4280
4280
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -5318,7 +5318,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
5318
5318
  const { apiFamily, name } = metadata;
5319
5319
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
5320
5320
  }
5321
- // version: 1.377.0-3c95caf11c
5321
+ // version: 1.377.1-dadb6358f3
5322
5322
 
5323
5323
  /**
5324
5324
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -34154,7 +34154,7 @@ withDefaultLuvio((luvio) => {
34154
34154
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
34155
34155
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
34156
34156
  });
34157
- // version: 1.377.0-b0d5c49e07
34157
+ // version: 1.377.1-db77d3f339
34158
34158
 
34159
34159
  function requestIdleDetectedCallback(_callback) { }
34160
34160
  function declareNotifierTaskSingle(_name) {
@@ -45659,6 +45659,15 @@ var graphqQueryFieldLimit = {
45659
45659
  },
45660
45660
  };
45661
45661
 
45662
+ var graphqlPartialEmitParity = {
45663
+ isOpen: function (e) {
45664
+ return e.fallback;
45665
+ },
45666
+ hasError: function () {
45667
+ return !0;
45668
+ },
45669
+ };
45670
+
45662
45671
  var caseSensitiveUserId = '005B0000000GR4OIAW';
45663
45672
 
45664
45673
  var ldsAdapterO11yLoggingGate = {
@@ -45806,47 +45815,47 @@ let Err$4 = class Err {
45806
45815
  };
45807
45816
  const ok$4 = (value) => new Ok$4(value);
45808
45817
  const err$4 = (err2) => new Err$4(err2);
45809
- function resolvedPromiseLike$4(result) {
45810
- if (isPromiseLike$4(result)) {
45818
+ function resolvedPromiseLike$5(result) {
45819
+ if (isPromiseLike$5(result)) {
45811
45820
  return result.then((nextResult) => nextResult);
45812
45821
  }
45813
45822
  return {
45814
45823
  then: (onFulfilled, _onRejected) => {
45815
45824
  try {
45816
- return resolvedPromiseLike$4(onFulfilled(result));
45825
+ return resolvedPromiseLike$5(onFulfilled(result));
45817
45826
  } catch (e) {
45818
45827
  if (onFulfilled === void 0) {
45819
- return resolvedPromiseLike$4(result);
45828
+ return resolvedPromiseLike$5(result);
45820
45829
  }
45821
- return rejectedPromiseLike$4(e);
45830
+ return rejectedPromiseLike$5(e);
45822
45831
  }
45823
45832
  }
45824
45833
  };
45825
45834
  }
45826
- function rejectedPromiseLike$4(reason) {
45827
- if (isPromiseLike$4(reason)) {
45835
+ function rejectedPromiseLike$5(reason) {
45836
+ if (isPromiseLike$5(reason)) {
45828
45837
  return reason.then((nextResult) => nextResult);
45829
45838
  }
45830
45839
  return {
45831
45840
  then: (_onFulfilled, onRejected) => {
45832
45841
  if (typeof onRejected === "function") {
45833
45842
  try {
45834
- return resolvedPromiseLike$4(onRejected(reason));
45843
+ return resolvedPromiseLike$5(onRejected(reason));
45835
45844
  } catch (e) {
45836
- return rejectedPromiseLike$4(e);
45845
+ return rejectedPromiseLike$5(e);
45837
45846
  }
45838
45847
  }
45839
- return rejectedPromiseLike$4(reason);
45848
+ return rejectedPromiseLike$5(reason);
45840
45849
  }
45841
45850
  };
45842
45851
  }
45843
- function isPromiseLike$4(x) {
45852
+ function isPromiseLike$5(x) {
45844
45853
  return typeof (x == null ? void 0 : x.then) === "function";
45845
45854
  }
45846
45855
  function racesync(values) {
45847
45856
  for (const value of values) {
45848
45857
  let settled = void 0;
45849
- if (isPromiseLike$4(value)) {
45858
+ if (isPromiseLike$5(value)) {
45850
45859
  value.then(
45851
45860
  (_) => {
45852
45861
  settled = value;
@@ -45856,7 +45865,7 @@ function racesync(values) {
45856
45865
  }
45857
45866
  );
45858
45867
  } else {
45859
- settled = resolvedPromiseLike$4(value);
45868
+ settled = resolvedPromiseLike$5(value);
45860
45869
  }
45861
45870
  if (settled !== void 0) {
45862
45871
  return settled;
@@ -46005,7 +46014,7 @@ function getServices(request, timeout = 3e4) {
46005
46014
  );
46006
46015
  }
46007
46016
  function setServices(services) {
46008
- waitForServices = resolvedPromiseLike$4(services);
46017
+ waitForServices = resolvedPromiseLike$5(services);
46009
46018
  servicesAvailable(services);
46010
46019
  }
46011
46020
 
@@ -61593,7 +61602,7 @@ const { hasOwnProperty: ObjectPrototypeHasOwnProperty$2 } = Object.prototype;
61593
61602
  // Deep merge that works on GraphQL data. It:
61594
61603
  // - recursively merges any Object properties that are present in both
61595
61604
  // - recursively merges arrays by deepMerging each Object item in the array (by index).
61596
- function deepMerge$2(target, ...sources) {
61605
+ function deepMerge$3(target, ...sources) {
61597
61606
  for (const source of sources) {
61598
61607
  for (const key in source) {
61599
61608
  if (ObjectPrototypeHasOwnProperty$2.call(source, key)) {
@@ -61614,7 +61623,7 @@ function deepMerge$2(target, ...sources) {
61614
61623
  !Array.isArray(targetItem) &&
61615
61624
  sourceItem instanceof Object &&
61616
61625
  !Array.isArray(sourceItem)) {
61617
- return deepMerge$2({}, targetItem, sourceItem);
61626
+ return deepMerge$3({}, targetItem, sourceItem);
61618
61627
  }
61619
61628
  else {
61620
61629
  return sourceItem;
@@ -61625,7 +61634,7 @@ function deepMerge$2(target, ...sources) {
61625
61634
  !Array.isArray(targetValue) &&
61626
61635
  sourceValue instanceof Object &&
61627
61636
  !Array.isArray(sourceValue)) {
61628
- deepMerge$2(targetValue, sourceValue);
61637
+ deepMerge$3(targetValue, sourceValue);
61629
61638
  }
61630
61639
  else {
61631
61640
  target[key] = sourceValue;
@@ -79243,7 +79252,7 @@ function selectCalculateSink$1(sink, field, buildSelectionForNodeFn, source, rea
79243
79252
  field.selectionSet?.selections.forEach((sel) => {
79244
79253
  const builtSelection = buildSelectionForNodeFn(source, reader, field, sel, variables, fragments, parentRecordId);
79245
79254
  if (builtSelection !== undefined) {
79246
- deepMerge$2(sink, builtSelection);
79255
+ deepMerge$3(sink, builtSelection);
79247
79256
  }
79248
79257
  });
79249
79258
  return sink;
@@ -81989,6 +81998,7 @@ function createContext(store, objectInfos, eventEmitter, settings, snapshot, map
81989
81998
  possibleStaleRecordMap: new Map(),
81990
81999
  draftFunctions,
81991
82000
  mappedCursors,
82001
+ missingFieldsMap: new Map(),
81992
82002
  };
81993
82003
  }
81994
82004
 
@@ -85590,8 +85600,17 @@ function addResolversToSchema(schema, polyFields) {
85590
85600
  field.resolve = connectionResolver;
85591
85601
  }
85592
85602
  else {
85593
- field.resolve = function recordFieldResolver({ recordRepresentation: record, }) {
85594
- return record.fields[field.name] || null;
85603
+ field.resolve = function recordFieldResolver({ recordRepresentation: record }, _args, { missingFieldsMap }) {
85604
+ const { id, fields } = record;
85605
+ const recordField = fields[field.name];
85606
+ // If the field is not present, add it to the missing fields map
85607
+ if (!recordField) {
85608
+ let missingFieldsSet = missingFieldsMap.get(id) ?? new Set();
85609
+ missingFieldsSet.add(field.name);
85610
+ missingFieldsMap.set(id, missingFieldsSet);
85611
+ return null;
85612
+ }
85613
+ return recordField;
85595
85614
  };
85596
85615
  }
85597
85616
  }
@@ -86182,6 +86201,7 @@ async function evaluate(config, observers, settings, objectInfos, store, snapsho
86182
86201
  result,
86183
86202
  seenRecordIds,
86184
86203
  possibleStaleRecordMap: contextValue.possibleStaleRecordMap,
86204
+ missingFieldsMap: contextValue.missingFieldsMap,
86185
86205
  };
86186
86206
  }
86187
86207
  finally {
@@ -87009,9 +87029,9 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
87009
87029
  }
87010
87030
  // spanning field needs to have the directive with 'parentRelationship'
87011
87031
  const directives = isSpanning && !isInlineFragment ? [parentRelationshipDirective] : [];
87012
- let idField = isSpanning && !isPolymorphicField ? [createFieldNode('Id')] : [];
87032
+ let idField = isSpanning && !isPolymorphicField ? [createFieldNode$1('Id')] : [];
87013
87033
  // This variable change to InlineFragment if 'isInlineFragment' is true
87014
- let sel = createFieldNode(fieldName);
87034
+ let sel = createFieldNode$1(fieldName);
87015
87035
  // Check if fields is valid
87016
87036
  if (apiNames.length === 1 && !isInlineFragment) {
87017
87037
  const objectInfo = objectInfos[apiNames[0]];
@@ -87057,7 +87077,7 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
87057
87077
  idField = [];
87058
87078
  }
87059
87079
  if (isInlineFragment && !isTypeNameExisting) {
87060
- idField.push(createFieldNode('__typename'));
87080
+ idField.push(createFieldNode$1('__typename'));
87061
87081
  }
87062
87082
  //Inject Conditions: 1. Same field does not exist 2. Same fields has different children. 3. Filter spanning field does not have Id. 4. InLineFragment does not have the '__typename' field
87063
87083
  if (!existingFields ||
@@ -87124,7 +87144,7 @@ function injectFilter(filterNode, idState, parentPath, isParentPolymorphic, obje
87124
87144
  .filter(isFieldNode)
87125
87145
  .filter((subNode) => subNode.name.value === relationField);
87126
87146
  if (!existingRelationFields || existingRelationFields.length === 0) {
87127
- injectedSelections.push(createFieldNode(relationField, FieldValueNodeSelectionSet));
87147
+ injectedSelections.push(createFieldNode$1(relationField, FieldValueNodeSelectionSet));
87128
87148
  }
87129
87149
  }
87130
87150
  }
@@ -87215,7 +87235,7 @@ function produceValueFieldLeaves(queryNode) {
87215
87235
  .filter(isFieldNode)
87216
87236
  .filter((subNode) => subNode.name.value === 'value');
87217
87237
  return !existingValueFields || existingValueFields.length === 0
87218
- ? [createFieldNode('value')]
87238
+ ? [createFieldNode$1('value')]
87219
87239
  : [];
87220
87240
  }
87221
87241
  function updateIDInfo(fieldNode, idState, draftFunctions) {
@@ -87296,20 +87316,20 @@ function injectParentRelationships(selections, parentNode, parentPath, ancestors
87296
87316
  .filter(isFieldNode)
87297
87317
  .filter((subNode) => subNode.name.value === relationshipId);
87298
87318
  if (existingRelationFields.length === 0) {
87299
- parentInjectedNodes.push(createFieldNode(relationshipId, FieldValueNodeSelectionSet));
87319
+ parentInjectedNodes.push(createFieldNode$1(relationshipId, FieldValueNodeSelectionSet));
87300
87320
  }
87301
87321
  }
87302
87322
  // For polymorphic fields, the Id field is excluded.
87303
87323
  const excludeId = isPolymorphicFieldPath(curPath, pathToObjectApiNamesMap, objectInfos);
87304
87324
  const idSelection = [];
87305
87325
  if (!excludeId && hasIdNode === false) {
87306
- idSelection.push(createFieldNode('Id'));
87326
+ idSelection.push(createFieldNode$1('Id'));
87307
87327
  }
87308
87328
  // Inject '__typename' for InlineFragment. '__typename' field acts as a reference to concrete type of a polymorphic field or a standard field in the returned GQL response, which equals to
87309
87329
  // `typedCondition` of the InlineFragment in the query AST. It is used to match JSON response with AST node. For more detail, please reference 'removeSyntheticFields'.
87310
87330
  if (isInlineFragmentNode(selection) &&
87311
87331
  !selection.selectionSet.selections.find((selection) => isFieldNode(selection) && selection.name.value === '__typename')) {
87312
- idSelection.push(createFieldNode('__typename'));
87332
+ idSelection.push(createFieldNode$1('__typename'));
87313
87333
  }
87314
87334
  // 'ServiceAppointment' --> 'Contact' --> 'Id', Inject 'Contact' with Id. 'Id' field is at the sub level.
87315
87335
  if (idSelection.length > 0 || subInjectedSelections.length > 0) {
@@ -87353,7 +87373,7 @@ function injectFieldsForDisplayValue(topNode, apiName, objectInfos) {
87353
87373
  objectInfo.nameFields !== undefined &&
87354
87374
  objectInfo.nameFields.length > 0) {
87355
87375
  displayValueNameFields = objectInfo.nameFields.map((fieldName) => {
87356
- return createFieldNode(fieldName, FieldValueNodeSelectionSet);
87376
+ return createFieldNode$1(fieldName, FieldValueNodeSelectionSet);
87357
87377
  });
87358
87378
  }
87359
87379
  }
@@ -87384,7 +87404,7 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
87384
87404
  if (parentNode.name.value === 'node') {
87385
87405
  const idNode = findIdFieldNode(parentNode);
87386
87406
  if (idNode === false) {
87387
- rootQueryIdField.push(createFieldNode('Id'));
87407
+ rootQueryIdField.push(createFieldNode$1('Id'));
87388
87408
  }
87389
87409
  }
87390
87410
  // example { node { Id } }. The operation happens at the 'edges' -> 'node' level of the 'childRelationship' field
@@ -87412,7 +87432,7 @@ function injectFields(selections, parentNode, parentPath, ancestors, objectInfos
87412
87432
  .filter(isFieldNode)
87413
87433
  .some((sibling) => sibling.name.value === injectedParentFieldName)) {
87414
87434
  // example: TimeSheetId { value }
87415
- relatedIdForChildRelationship.push(createFieldNode(injectedParentFieldName, FieldValueNodeSelectionSet));
87435
+ relatedIdForChildRelationship.push(createFieldNode$1(injectedParentFieldName, FieldValueNodeSelectionSet));
87416
87436
  }
87417
87437
  displayValueNameFields.push(...injectFieldsForDisplayValue(parentNode, targetRelationship.childObjectApiName, objectInfos));
87418
87438
  }
@@ -87864,7 +87884,7 @@ function referenceIdFieldForRelationship(relationshipName) {
87864
87884
  * @param selectionSet
87865
87885
  * @returns
87866
87886
  */
87867
- function createFieldNode(nameValue, selectionSet) {
87887
+ function createFieldNode$1(nameValue, selectionSet) {
87868
87888
  return {
87869
87889
  kind: Kind$3.FIELD,
87870
87890
  name: {
@@ -88348,11 +88368,13 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
88348
88368
  let gqlResult;
88349
88369
  let seenRecordIds;
88350
88370
  let possibleStaleRecordMap;
88371
+ let missingFieldsMap;
88351
88372
  try {
88352
88373
  ({
88353
88374
  result: gqlResult,
88354
88375
  seenRecordIds,
88355
88376
  possibleStaleRecordMap,
88377
+ missingFieldsMap,
88356
88378
  } = await evaluate({
88357
88379
  ...config,
88358
88380
  //need to create another copy of the ast for future writes
@@ -88382,13 +88404,23 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
88382
88404
  const seenRecords = createSeenRecords(seenRecordIds, nonEvaluatedSnapshot);
88383
88405
  const recordId = generateUniqueRecordId();
88384
88406
  const rebuildWithLocalEval = async (originalSnapshot) => {
88385
- let { result: rebuildResult, seenRecordIds, possibleStaleRecordMap, } = await evaluate({
88407
+ let { result: rebuildResult, seenRecordIds, possibleStaleRecordMap, missingFieldsMap: rebuildMissingFieldsMap, } = await evaluate({
88386
88408
  ...config,
88387
88409
  query: injectedAST,
88388
88410
  }, observers, { userId }, objectInfoNeeded, store, originalSnapshot, graphqlSchemaCache, draftFunctions, mappedCursors);
88389
88411
  if (!rebuildResult.errors) {
88390
88412
  rebuildResult = removeSyntheticFields(rebuildResult, config.query);
88391
88413
  }
88414
+ // If the query includes any missing fields, we return an ErrorSnapshot
88415
+ // with a message that contains the missing fields for each record.
88416
+ if (graphqlPartialEmitParity.isOpen({ fallback: false }) &&
88417
+ rebuildMissingFieldsMap.size > 0) {
88418
+ const missingFieldsErrorSnapshot = createMissingFieldsErrorSnapshot(originalSnapshot, rebuildMissingFieldsMap);
88419
+ return {
88420
+ ...missingFieldsErrorSnapshot,
88421
+ rebuildWithLocalEval,
88422
+ };
88423
+ }
88392
88424
  let snapshotState = 'Fulfilled';
88393
88425
  if (possibleStaleRecordMap.size > 0) {
88394
88426
  initiateStaleRecordRefresh(luvio, possibleStaleRecordMap);
@@ -88423,6 +88455,10 @@ function draftAwareGraphQLAdapterFactory(userId, objectInfoService, store, luvio
88423
88455
  },
88424
88456
  };
88425
88457
  }
88458
+ // If the query includes any missing fields, we return an ErrorSnapshot
88459
+ if (graphqlPartialEmitParity.isOpen({ fallback: false }) && missingFieldsMap.size > 0) {
88460
+ return createMissingFieldsErrorSnapshot(nonEvaluatedSnapshot, missingFieldsMap);
88461
+ }
88426
88462
  // if the non-eval'ed snapshot was an error then we return a synthetic
88427
88463
  // Fulfilled snapshot (this only happens in this code path if
88428
88464
  // the error is network error or 504), otherwise we spread over
@@ -88479,6 +88515,30 @@ function makeGetRecordsConfig(keyMap) {
88479
88515
  records,
88480
88516
  };
88481
88517
  }
88518
+ /**
88519
+ * Creates an ErrorSnapshot with a message that contains the missing fields for each record.
88520
+ * @param originalSnapshot The original snapshot that is being rebuilt.
88521
+ * @param missingFieldsMap A map of record ids to the fields that are missing.
88522
+ * @returns An ErrorSnapshot with a message that contains the missing fields for each record.
88523
+ */
88524
+ function createMissingFieldsErrorSnapshot(originalSnapshot, missingFieldsMap) {
88525
+ const message = Array.from(missingFieldsMap)
88526
+ .map(([id, fields]) => `Missing fields for record ${id}: ${Array.from(fields).join(', ')}`)
88527
+ .join('; ');
88528
+ return {
88529
+ ...originalSnapshot,
88530
+ data: undefined,
88531
+ state: 'Error',
88532
+ error: {
88533
+ errorType: 'adapterError',
88534
+ error: [
88535
+ {
88536
+ message,
88537
+ },
88538
+ ],
88539
+ },
88540
+ };
88541
+ }
88482
88542
 
88483
88543
  function environmentAwareGraphQLBatchAdapterFactory(objectInfoService, luvio, isDraftId, buildCachedSnapshotCachePolicy, buildNetworkSnapshotCachePolicy) {
88484
88544
  return async function environmentAwareGraphQLBatchAdapter(config, requestContext = {}) {
@@ -93878,13 +93938,13 @@ function toError(x) {
93878
93938
  }
93879
93939
  return new Error(typeof x === "string" ? x : JSON.stringify(x));
93880
93940
  }
93881
- class InternalError extends Error {
93941
+ let InternalError$1 = class InternalError extends Error {
93882
93942
  constructor(data) {
93883
93943
  super();
93884
93944
  this.data = data;
93885
93945
  this.type = "internal";
93886
93946
  }
93887
- }
93947
+ };
93888
93948
  class UserVisibleError extends Error {
93889
93949
  constructor(data) {
93890
93950
  super();
@@ -93956,7 +94016,7 @@ let NetworkCommand$1 = class NetworkCommand extends BaseCommand {
93956
94016
  async afterRequestHooks(_options) {
93957
94017
  }
93958
94018
  };
93959
- function buildServiceDescriptor$g() {
94019
+ function buildServiceDescriptor$h() {
93960
94020
  return {
93961
94021
  type: "networkCommandBaseClass",
93962
94022
  version: "1.0",
@@ -94058,7 +94118,7 @@ class AuraNetworkCommand extends NetworkCommand$1 {
94058
94118
  return resolvedPromiseLike$3(err$1$1(toError("Aura/Fetch network services not found")));
94059
94119
  }
94060
94120
  }
94061
- function buildServiceDescriptor$f() {
94121
+ function buildServiceDescriptor$g() {
94062
94122
  return {
94063
94123
  type: "auraNetworkCommandBaseClass",
94064
94124
  version: "1.0",
@@ -94558,7 +94618,7 @@ class AuraNormalizedCacheControlCommand extends AuraCacheControlCommand$1 {
94558
94618
  return resolvedPromiseLike$3(void 0);
94559
94619
  }
94560
94620
  }
94561
- function buildServiceDescriptor$e() {
94621
+ function buildServiceDescriptor$f() {
94562
94622
  return {
94563
94623
  type: "auraNormalizedCacheControlCommand",
94564
94624
  version: "1.0",
@@ -94704,7 +94764,7 @@ class AuraResourceCacheControlCommand extends AuraCacheControlCommand {
94704
94764
  return `{"endpoint":${this.endpoint},"params":${stableJSONStringify$2(this.auraParams)}}`;
94705
94765
  }
94706
94766
  }
94707
- function buildServiceDescriptor$d() {
94767
+ function buildServiceDescriptor$e() {
94708
94768
  return {
94709
94769
  type: "auraResourceCacheControlCommand",
94710
94770
  version: "1.0",
@@ -94811,7 +94871,7 @@ class FetchNetworkCommand extends NetworkCommand {
94811
94871
  );
94812
94872
  }
94813
94873
  }
94814
- function buildServiceDescriptor$c() {
94874
+ function buildServiceDescriptor$d() {
94815
94875
  return {
94816
94876
  type: "fetchNetworkCommandBaseClass",
94817
94877
  version: "1.0",
@@ -94900,7 +94960,7 @@ class HttpNormalizedCacheControlCommand extends HttpCacheControlCommand {
94900
94960
  return resolvedPromiseLike$3(void 0);
94901
94961
  }
94902
94962
  }
94903
- function buildServiceDescriptor$b() {
94963
+ function buildServiceDescriptor$c() {
94904
94964
  return {
94905
94965
  type: "httpNormalizedCacheControlCommand",
94906
94966
  version: "1.0",
@@ -95153,7 +95213,7 @@ let DefaultCache$1 = class DefaultCache {
95153
95213
  return new FixedTimeWritableCache$1(this, generatedTime);
95154
95214
  }
95155
95215
  };
95156
- function buildServiceDescriptor$a() {
95216
+ function buildServiceDescriptor$b() {
95157
95217
  return {
95158
95218
  type: "cache",
95159
95219
  version: "1.0",
@@ -95321,7 +95381,7 @@ class CacheController {
95321
95381
  yield* this.services.cacheInclusionPolicy.findAndModify(query, cacheUpdate);
95322
95382
  }
95323
95383
  }
95324
- function buildServiceDescriptor$9(cache, cacheInclusionPolicy) {
95384
+ function buildServiceDescriptor$a(cache, cacheInclusionPolicy) {
95325
95385
  return {
95326
95386
  type: "cacheController",
95327
95387
  version: "1.0",
@@ -95367,7 +95427,7 @@ function buildInstrumentCommand(services) {
95367
95427
  };
95368
95428
  };
95369
95429
  }
95370
- function buildServiceDescriptor$8(instrumentation) {
95430
+ function buildServiceDescriptor$9(instrumentation) {
95371
95431
  return {
95372
95432
  type: "instrumentCommand",
95373
95433
  version: "1.0",
@@ -95637,7 +95697,7 @@ class O11yInstrumentation {
95637
95697
  this.metrics = new O11yOTelMetricsAPI(this.services);
95638
95698
  }
95639
95699
  }
95640
- function buildServiceDescriptor$7(logger) {
95700
+ function buildServiceDescriptor$8(logger) {
95641
95701
  return {
95642
95702
  type: "instrumentation",
95643
95703
  version: "1.0",
@@ -95747,7 +95807,7 @@ class DefaultPubSubService {
95747
95807
  return matchingSubscriptions;
95748
95808
  }
95749
95809
  }
95750
- function buildServiceDescriptor$6() {
95810
+ function buildServiceDescriptor$7() {
95751
95811
  return {
95752
95812
  type: "pubSub",
95753
95813
  version: "1.0",
@@ -95771,7 +95831,7 @@ class FeatureFlagsService {
95771
95831
  return this.flags.get(flagName) || defaultValue;
95772
95832
  }
95773
95833
  }
95774
- function buildServiceDescriptor$5() {
95834
+ function buildServiceDescriptor$6() {
95775
95835
  return {
95776
95836
  version: "1.0",
95777
95837
  service: new FeatureFlagsService(),
@@ -95812,7 +95872,7 @@ function buildServiceDescriptor$5() {
95812
95872
  * };
95813
95873
  * ```
95814
95874
  */
95815
- function buildServiceDescriptor$4(luvio) {
95875
+ function buildServiceDescriptor$5(luvio) {
95816
95876
  return {
95817
95877
  type: 'luvio',
95818
95878
  version: '1.0',
@@ -95821,7 +95881,33 @@ function buildServiceDescriptor$4(luvio) {
95821
95881
  },
95822
95882
  };
95823
95883
  }
95824
- // version: 1.377.0-b0d5c49e07
95884
+ // version: 1.377.1-db77d3f339
95885
+
95886
+ /**
95887
+ * Copyright (c) 2022, Salesforce, Inc.,
95888
+ * All rights reserved.
95889
+ * For full license text, see the LICENSE.txt file
95890
+ */
95891
+
95892
+ /*
95893
+ * ATTENTION!
95894
+ * THIS IS A GENERATED FILE FROM https://github.com/salesforce-experience-platform-emu/lds-lightning-platform
95895
+ * If you would like to contribute to LDS, please follow the steps outlined in the git repo.
95896
+ * Any changes made to this file in p4 will be automatically overwritten.
95897
+ * *******************************************************************************************
95898
+ */
95899
+ /* proxy-compat-disable */
95900
+ function buildServiceDescriptor$4(notifyRecordUpdateAvailable, getNormalizedLuvioRecord) {
95901
+ return {
95902
+ type: 'luvioUiapiRecords',
95903
+ version: '1.0',
95904
+ service: {
95905
+ notifyRecordUpdateAvailable,
95906
+ getNormalizedLuvioRecord,
95907
+ },
95908
+ };
95909
+ }
95910
+ // version: 1.377.1-db77d3f339
95825
95911
 
95826
95912
  /*!
95827
95913
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -96688,7 +96774,7 @@ function findExecutableOperation$1(input) {
96688
96774
  }
96689
96775
  return err$1$1(new Error("Multiple operations found in query, and no operation name provided"));
96690
96776
  }
96691
- function buildGraphQLInputExtension(input) {
96777
+ function buildGraphQLInputExtension$1(input) {
96692
96778
  const operationResult = findExecutableOperation$1(input);
96693
96779
  if (operationResult.isErr()) {
96694
96780
  return err$1$1(operationResult.error);
@@ -96731,7 +96817,7 @@ class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheContro
96731
96817
  return this.documentRootType;
96732
96818
  }
96733
96819
  buildQuery() {
96734
- const extensionResult = buildGraphQLInputExtension(this.config);
96820
+ const extensionResult = buildGraphQLInputExtension$1(this.config);
96735
96821
  if (extensionResult.isErr()) {
96736
96822
  throw extensionResult.error;
96737
96823
  }
@@ -96840,12 +96926,12 @@ class AuraGraphQLNormalizedCacheControlCommand extends AuraNormalizedCacheContro
96840
96926
  return augmentedQueryResult.value;
96841
96927
  }
96842
96928
  buildWriteInput(data) {
96843
- const extensionResult = buildGraphQLInputExtension({
96929
+ const extensionResult = buildGraphQLInputExtension$1({
96844
96930
  ...this.config,
96845
96931
  query: this.buildRequestQuery()
96846
96932
  });
96847
96933
  if (extensionResult.isErr()) {
96848
- throw new InternalError(extensionResult.error);
96934
+ throw new InternalError$1(extensionResult.error);
96849
96935
  }
96850
96936
  return { data: data.data, ...extensionResult.value };
96851
96937
  }
@@ -96890,7 +96976,7 @@ class HttpGraphQLNormalizedCacheControlCommand extends HttpNormalizedCacheContro
96890
96976
  return this.documentRootType;
96891
96977
  }
96892
96978
  buildQuery() {
96893
- const extensionResult = buildGraphQLInputExtension(this.config);
96979
+ const extensionResult = buildGraphQLInputExtension$1(this.config);
96894
96980
  if (extensionResult.isErr()) {
96895
96981
  throw extensionResult.error;
96896
96982
  }
@@ -96934,12 +97020,12 @@ class HttpGraphQLNormalizedCacheControlCommand extends HttpNormalizedCacheContro
96934
97020
  return augmentedQueryResult.value;
96935
97021
  }
96936
97022
  buildWriteInput(data) {
96937
- const extensionResult = buildGraphQLInputExtension({
97023
+ const extensionResult = buildGraphQLInputExtension$1({
96938
97024
  ...this.config,
96939
97025
  query: this.buildRequestQuery()
96940
97026
  });
96941
97027
  if (extensionResult.isErr()) {
96942
- throw new InternalError(extensionResult.error);
97028
+ throw new InternalError$1(extensionResult.error);
96943
97029
  }
96944
97030
  return { data: data.data, ...extensionResult.value };
96945
97031
  }
@@ -97182,41 +97268,41 @@ function setDifference(setA, setB) {
97182
97268
  }
97183
97269
  return differenceSet;
97184
97270
  }
97185
- function resolvedPromiseLike(result) {
97186
- if (isPromiseLike(result)) {
97271
+ function resolvedPromiseLike$4(result) {
97272
+ if (isPromiseLike$4(result)) {
97187
97273
  return result.then((nextResult) => nextResult);
97188
97274
  }
97189
97275
  return {
97190
97276
  then: (onFulfilled, _onRejected) => {
97191
97277
  try {
97192
- return resolvedPromiseLike(onFulfilled(result));
97278
+ return resolvedPromiseLike$4(onFulfilled(result));
97193
97279
  } catch (e) {
97194
97280
  if (onFulfilled === void 0) {
97195
- return resolvedPromiseLike(result);
97281
+ return resolvedPromiseLike$4(result);
97196
97282
  }
97197
- return rejectedPromiseLike(e);
97283
+ return rejectedPromiseLike$4(e);
97198
97284
  }
97199
97285
  }
97200
97286
  };
97201
97287
  }
97202
- function rejectedPromiseLike(reason) {
97203
- if (isPromiseLike(reason)) {
97288
+ function rejectedPromiseLike$4(reason) {
97289
+ if (isPromiseLike$4(reason)) {
97204
97290
  return reason.then((nextResult) => nextResult);
97205
97291
  }
97206
97292
  return {
97207
97293
  then: (_onFulfilled, onRejected) => {
97208
97294
  if (typeof onRejected === "function") {
97209
97295
  try {
97210
- return resolvedPromiseLike(onRejected(reason));
97296
+ return resolvedPromiseLike$4(onRejected(reason));
97211
97297
  } catch (e) {
97212
- return rejectedPromiseLike(e);
97298
+ return rejectedPromiseLike$4(e);
97213
97299
  }
97214
97300
  }
97215
- return rejectedPromiseLike(reason);
97301
+ return rejectedPromiseLike$4(reason);
97216
97302
  }
97217
97303
  };
97218
97304
  }
97219
- function isPromiseLike(x) {
97305
+ function isPromiseLike$4(x) {
97220
97306
  return typeof (x == null ? void 0 : x.then) === "function";
97221
97307
  }
97222
97308
  /*!
@@ -97505,7 +97591,7 @@ class DurableCacheInclusionPolicy extends CacheInclusionPolicyService {
97505
97591
  tempL1.keysUpdated.forEach((key) => keysToReviveRecordableCache.get(key));
97506
97592
  tempL1.missingKeysRead.forEach((key) => keysToReviveRecordableCache.get(key));
97507
97593
  const missingKeys = keysToReviveRecordableCache.missingKeysRead;
97508
- const revivePromiseLike = missingKeys.size > 0 ? this.revive(missingKeys, l1).then(() => void 0) : resolvedPromiseLike(void 0);
97594
+ const revivePromiseLike = missingKeys.size > 0 ? this.revive(missingKeys, l1).then(() => void 0) : resolvedPromiseLike$4(void 0);
97509
97595
  return revivePromiseLike.then(() => {
97510
97596
  const recordableCache = l1.record();
97511
97597
  return writeToL1(recordableCache).then((result) => {
@@ -97698,10 +97784,10 @@ function initializeOneStore(sqliteStore) {
97698
97784
  globalThis.performance = { now: () => Date.now() };
97699
97785
  }
97700
97786
  const loggerService = new ConsoleLogger('ERROR');
97701
- const cacheServiceDescriptor = buildServiceDescriptor$a();
97702
- const instrumentationServiceDescriptor = buildServiceDescriptor$7(loggerService);
97787
+ const cacheServiceDescriptor = buildServiceDescriptor$b();
97788
+ const instrumentationServiceDescriptor = buildServiceDescriptor$8(loggerService);
97703
97789
  const nimbusSqliteOneStoreCacheServiceDescriptor = buildNimbusDurableCacheInclusionPolicyService(cacheServiceDescriptor.service, new NimbusSqliteOneStoreCache(sqliteStore));
97704
- const featureFlagsServiceDescriptor = buildServiceDescriptor$5();
97790
+ const featureFlagsServiceDescriptor = buildServiceDescriptor$6();
97705
97791
  const featureFlagsService = featureFlagsServiceDescriptor.service;
97706
97792
  // This disables the OneStore GraphQL in this runtime
97707
97793
  // We made the decision to continue using the Luvio based version in Mobile
@@ -97711,21 +97797,22 @@ function initializeOneStore(sqliteStore) {
97711
97797
  const services = [
97712
97798
  instrumentationServiceDescriptor,
97713
97799
  buildNimbusFetchServiceDescriptor(),
97714
- buildServiceDescriptor$8(instrumentationServiceDescriptor.service),
97800
+ buildServiceDescriptor$9(instrumentationServiceDescriptor.service),
97715
97801
  // NOTE: These do not directly depend on Aura, and are necessary for HTTP fallback support.
97802
+ buildServiceDescriptor$g(),
97716
97803
  buildServiceDescriptor$f(),
97717
97804
  buildServiceDescriptor$e(),
97805
+ buildServiceDescriptor$a(cacheServiceDescriptor.service, nimbusSqliteOneStoreCacheServiceDescriptor.service),
97718
97806
  buildServiceDescriptor$d(),
97719
- buildServiceDescriptor$9(cacheServiceDescriptor.service, nimbusSqliteOneStoreCacheServiceDescriptor.service),
97807
+ buildServiceDescriptor$h(),
97720
97808
  buildServiceDescriptor$c(),
97721
- buildServiceDescriptor$g(),
97722
- buildServiceDescriptor$b(),
97723
- buildServiceDescriptor$6(),
97809
+ buildServiceDescriptor$7(),
97724
97810
  buildServiceDescriptor$3(),
97725
97811
  buildServiceDescriptor$2(),
97726
97812
  featureFlagsServiceDescriptor,
97727
97813
  // Luvio service won't be used since we set the useOneStoreGraphQL flag to false
97728
- buildServiceDescriptor$4({}),
97814
+ buildServiceDescriptor$5({}),
97815
+ buildServiceDescriptor$4({}, {}),
97729
97816
  // TODO[@W-18753648]: See note above.
97730
97817
  // buildStreamingCommandServiceDescriptor(),
97731
97818
  // buildNdJsonServiceDescriptor(),
@@ -97936,7 +98023,7 @@ register$1({
97936
98023
  id: '@salesforce/lds-network-adapter',
97937
98024
  instrument: instrument$2,
97938
98025
  });
97939
- // version: 1.377.0-3c95caf11c
98026
+ // version: 1.377.1-dadb6358f3
97940
98027
 
97941
98028
  const { create: create$3, keys: keys$3 } = Object;
97942
98029
  const { stringify: stringify$1, parse } = JSON;
@@ -98826,7 +98913,7 @@ function validateExpectedType(value, expectedType) {
98826
98913
  new Error(`Expected ${expectedTypeString}, but got ${actualType}: ${JSON.stringify(value)}`)
98827
98914
  );
98828
98915
  }
98829
- function deepMerge$1(target, ...sources) {
98916
+ function deepMerge$2(target, ...sources) {
98830
98917
  for (const source of sources) {
98831
98918
  for (const key in source) {
98832
98919
  if (hasOwnProperty$2.call(source, key)) {
@@ -98842,13 +98929,13 @@ function deepMerge$1(target, ...sources) {
98842
98929
  } else if (sourceItem === void 0) {
98843
98930
  return targetItem;
98844
98931
  } else if (targetItem instanceof Object && !Array.isArray(targetItem) && sourceItem instanceof Object && !Array.isArray(sourceItem)) {
98845
- return deepMerge$1({}, targetItem, sourceItem);
98932
+ return deepMerge$2({}, targetItem, sourceItem);
98846
98933
  } else {
98847
98934
  return sourceItem;
98848
98935
  }
98849
98936
  });
98850
98937
  } else if (targetValue instanceof Object && !Array.isArray(targetValue) && sourceValue instanceof Object && !Array.isArray(sourceValue)) {
98851
- deepMerge$1(
98938
+ deepMerge$2(
98852
98939
  targetValue,
98853
98940
  sourceValue
98854
98941
  );
@@ -98882,6 +98969,32 @@ function findExecutableOperation(input) {
98882
98969
  }
98883
98970
  return err$4(new Error("Multiple operations found in query, and no operation name provided"));
98884
98971
  }
98972
+ function buildGraphQLInputExtension(input) {
98973
+ const operationResult = findExecutableOperation(input);
98974
+ if (operationResult.isErr()) {
98975
+ return err$4(operationResult.error);
98976
+ }
98977
+ const operation = operationResult.value;
98978
+ const selections = operation.selectionSet.selections;
98979
+ const variableDefinitions = operation.variableDefinitions;
98980
+ const variables = (variableDefinitions == null ? void 0 : variableDefinitions.reduce((prev, def) => {
98981
+ var _a;
98982
+ prev[def.variable.name.value] = {
98983
+ definition: def,
98984
+ value: (_a = input.variables) == null ? void 0 : _a[def.variable.name.value]
98985
+ };
98986
+ return prev;
98987
+ }, {})) || {};
98988
+ const fragments = input.query.definitions.filter((def) => def.kind === "FragmentDefinition").reduce((prev, fragment) => {
98989
+ prev[fragment.name.value] = fragment;
98990
+ return prev;
98991
+ }, {});
98992
+ return ok$4({
98993
+ selections,
98994
+ request: { definitions: { variables, fragments } },
98995
+ parentFieldSelection: void 0
98996
+ });
98997
+ }
98885
98998
  function buildUniqueAugmentedFieldSelection(newSelection, selections, fragments) {
98886
98999
  var _a;
98887
99000
  const baseAlias = ((_a = newSelection.alias) == null ? void 0 : _a.value) || newSelection.name.value;
@@ -99108,7 +99221,7 @@ class BaseGraphQLTypeRepository {
99108
99221
  const errors = [];
99109
99222
  for (const selection of input.selections) {
99110
99223
  if (selection.kind === Kind.FIELD) {
99111
- deepMerge$1(
99224
+ deepMerge$2(
99112
99225
  normalized,
99113
99226
  this.normalizeFieldSelection(cache, input, selection, errors)
99114
99227
  );
@@ -99129,7 +99242,7 @@ class BaseGraphQLTypeRepository {
99129
99242
  ]
99130
99243
  };
99131
99244
  }
99132
- deepMerge$1(normalized, this.normalizeFragment(cache, input, fragment, errors));
99245
+ deepMerge$2(normalized, this.normalizeFragment(cache, input, fragment, errors));
99133
99246
  }
99134
99247
  }
99135
99248
  return buildReadWriteResult(normalized, errors);
@@ -99223,7 +99336,7 @@ class BaseGraphQLTypeRepository {
99223
99336
  const denormalized = {};
99224
99337
  for (const selection of input.selections) {
99225
99338
  if (selection.kind === Kind.FIELD) {
99226
- deepMerge$1(
99339
+ deepMerge$2(
99227
99340
  denormalized,
99228
99341
  this.denormalizeFieldSelection(cache, input, selection, errors)
99229
99342
  );
@@ -99244,7 +99357,7 @@ class BaseGraphQLTypeRepository {
99244
99357
  ]
99245
99358
  };
99246
99359
  }
99247
- deepMerge$1(denormalized, this.denormalizeFragment(cache, input, fragment, errors));
99360
+ deepMerge$2(denormalized, this.denormalizeFragment(cache, input, fragment, errors));
99248
99361
  }
99249
99362
  }
99250
99363
  return buildReadWriteResult(denormalized, errors);
@@ -99460,7 +99573,7 @@ class IdentifiableGraphQLTypeRepository extends IdentifiableTypeRepository {
99460
99573
  return normalizeDataResult;
99461
99574
  }
99462
99575
  return ok$4(
99463
- deepMerge$1(
99576
+ deepMerge$2(
99464
99577
  {},
99465
99578
  (existingNormalizedData == null ? void 0 : existingNormalizedData.value) || {},
99466
99579
  normalizeDataResult.value
@@ -100365,7 +100478,7 @@ function buildAsyncGraphQLImperativeLegacyInvoker(getCommand) {
100365
100478
  };
100366
100479
  return { invoke, subscribe };
100367
100480
  }
100368
- // version: 1.377.0-b0d5c49e07
100481
+ // version: 1.377.1-db77d3f339
100369
100482
 
100370
100483
  class Analytics__AnalyticsBrowseRepository extends UnidentifiableGraphQLTypeRepository {
100371
100484
  constructor(services, typeRegistry) {
@@ -103049,6 +103162,50 @@ class Err {
103049
103162
  }
103050
103163
  const ok = (value) => new Ok(value);
103051
103164
  const err = (err2) => new Err(err2);
103165
+ function resolvedPromiseLike(result) {
103166
+ if (isPromiseLike(result)) {
103167
+ return result.then((nextResult) => nextResult);
103168
+ }
103169
+ return {
103170
+ then: (onFulfilled, _onRejected) => {
103171
+ try {
103172
+ return resolvedPromiseLike(onFulfilled(result));
103173
+ } catch (e) {
103174
+ if (onFulfilled === void 0) {
103175
+ return resolvedPromiseLike(result);
103176
+ }
103177
+ return rejectedPromiseLike(e);
103178
+ }
103179
+ }
103180
+ };
103181
+ }
103182
+ function rejectedPromiseLike(reason) {
103183
+ if (isPromiseLike(reason)) {
103184
+ return reason.then((nextResult) => nextResult);
103185
+ }
103186
+ return {
103187
+ then: (_onFulfilled, onRejected) => {
103188
+ if (typeof onRejected === "function") {
103189
+ try {
103190
+ return resolvedPromiseLike(onRejected(reason));
103191
+ } catch (e) {
103192
+ return rejectedPromiseLike(e);
103193
+ }
103194
+ }
103195
+ return rejectedPromiseLike(reason);
103196
+ }
103197
+ };
103198
+ }
103199
+ function isPromiseLike(x) {
103200
+ return typeof (x == null ? void 0 : x.then) === "function";
103201
+ }
103202
+ class InternalError extends Error {
103203
+ constructor(data) {
103204
+ super();
103205
+ this.data = data;
103206
+ this.type = "internal";
103207
+ }
103208
+ }
103052
103209
 
103053
103210
  function buildGenericTypeFieldDef(selection, fields, staticFieldNames, typename) {
103054
103211
  // If the field is not a category field, return the base field def for the field
@@ -103166,12 +103323,25 @@ class RecordRepresentationRepository extends RecordRepresentationRepository$1 {
103166
103323
  }
103167
103324
  write(cache, input) {
103168
103325
  const result = super.write(cache, input);
103169
- input.data.Id;
103326
+ const recordId = input.data.Id;
103327
+ const luvioRecord = input.getNormalizedLuvioRecord(recordId, input.reader);
103328
+ if (luvioRecord?.weakEtag &&
103329
+ input.data?.WeakEtag &&
103330
+ luvioRecord.weakEtag !== input.data.WeakEtag) {
103331
+ input.luvioRecordIdsToInvalidate.push(recordId);
103332
+ }
103170
103333
  return result;
103171
103334
  }
103172
103335
  read(cache, input) {
103173
103336
  const result = super.read(cache, input);
103174
- // TODO: read luvio record to track subscription
103337
+ const idData = super.read(cache, {
103338
+ ...input,
103339
+ selections: [{ kind: 'Field', name: { kind: 'Name', value: 'Id' } }],
103340
+ });
103341
+ if (idData.isOk()) {
103342
+ // Read the record to track subscription
103343
+ input.getNormalizedLuvioRecord(idData.value.Id, input.reader);
103344
+ }
103175
103345
  return result;
103176
103346
  }
103177
103347
  }
@@ -103453,6 +103623,155 @@ class CustomGraphQLTypeRegistry extends GraphQLTypeRegistry {
103453
103623
  }
103454
103624
 
103455
103625
  const CONFIG_SCHEMA = GraphQLQueryJsonSchema;
103626
+
103627
+ // Fields with arguments need to be aliased to avoid a potential conflict.
103628
+ const ALIASED_FIELDS = {
103629
+ ldsRecordTypeId: {
103630
+ kind: Kind$1.FIELD,
103631
+ name: {
103632
+ kind: Kind$1.NAME,
103633
+ value: 'RecordTypeId',
103634
+ },
103635
+ arguments: [
103636
+ {
103637
+ kind: Kind$1.ARGUMENT,
103638
+ name: {
103639
+ kind: Kind$1.NAME,
103640
+ value: 'fallback',
103641
+ },
103642
+ value: {
103643
+ kind: Kind$1.BOOLEAN,
103644
+ value: true,
103645
+ },
103646
+ },
103647
+ ],
103648
+ alias: {
103649
+ kind: Kind$1.NAME,
103650
+ value: 'ldsRecordTypeId',
103651
+ },
103652
+ },
103653
+ };
103654
+ // TODO: export graphql's deepMerge from @luvio/graphql-normalization? Promote to @luvio/utils?
103655
+ function deepMerge$1(target, source) {
103656
+ if (source === null || source === undefined)
103657
+ return target;
103658
+ if (target === null || target === undefined)
103659
+ return source;
103660
+ if (typeof source !== 'object' || typeof target !== 'object') {
103661
+ return source;
103662
+ }
103663
+ if (Array.isArray(source)) {
103664
+ return source;
103665
+ }
103666
+ const result = { ...target };
103667
+ for (const key of Object.keys(source)) {
103668
+ if (key === 'extensions') {
103669
+ // Skip extensions key from final result
103670
+ continue;
103671
+ }
103672
+ if (source[key] !== null &&
103673
+ typeof source[key] === 'object' &&
103674
+ !Array.isArray(source[key])) {
103675
+ result[key] = deepMerge$1(result[key], source[key]);
103676
+ }
103677
+ else {
103678
+ result[key] = source[key];
103679
+ }
103680
+ }
103681
+ return result;
103682
+ }
103683
+ function createFieldNode(name, data) {
103684
+ if (name === '__genericTypename') {
103685
+ return undefined;
103686
+ }
103687
+ const baseField = ALIASED_FIELDS[name] ?? {
103688
+ kind: Kind$1.FIELD,
103689
+ name: {
103690
+ kind: Kind$1.NAME,
103691
+ value: name,
103692
+ },
103693
+ };
103694
+ if (typeof data === 'object' && data !== null && data !== undefined) {
103695
+ if (Array.isArray(data)) {
103696
+ // For arrays, we need to merge the structure from all non-null elements
103697
+ // to capture the full schema, not just the first element
103698
+ let mergedStructure = {};
103699
+ for (const item of data) {
103700
+ if (item !== null && typeof item === 'object' && !Array.isArray(item)) {
103701
+ mergedStructure = deepMerge$1(mergedStructure, item);
103702
+ }
103703
+ }
103704
+ if (Object.keys(mergedStructure).length > 0) {
103705
+ baseField.selectionSet = {
103706
+ kind: Kind$1.SELECTION_SET,
103707
+ selections: Object.entries(mergedStructure)
103708
+ .map(([key, value]) => createFieldNode(key, value))
103709
+ .filter((node) => node !== undefined),
103710
+ };
103711
+ }
103712
+ }
103713
+ else {
103714
+ baseField.selectionSet = {
103715
+ kind: Kind$1.SELECTION_SET,
103716
+ selections: Object.entries(data)
103717
+ .map(([key, value]) => createFieldNode(key, value))
103718
+ .filter((node) => node !== undefined),
103719
+ };
103720
+ }
103721
+ }
103722
+ return baseField;
103723
+ }
103724
+ function createASTFromExtensions(extensions) {
103725
+ const fieldNodes = Object.entries(extensions)
103726
+ .map(([field, value]) => createFieldNode(field, value))
103727
+ .filter((node) => node !== undefined);
103728
+ return {
103729
+ kind: Kind$1.SELECTION_SET,
103730
+ selections: fieldNodes,
103731
+ };
103732
+ }
103733
+ function mergeASTs(query, extensionsAST) {
103734
+ return {
103735
+ ...query,
103736
+ definitions: query.definitions.map((def) => {
103737
+ if (def.kind === Kind$1.OPERATION_DEFINITION) {
103738
+ return {
103739
+ ...def,
103740
+ selectionSet: {
103741
+ kind: Kind$1.SELECTION_SET,
103742
+ selections: [...def.selectionSet.selections, ...extensionsAST.selections],
103743
+ },
103744
+ };
103745
+ }
103746
+ return def;
103747
+ }),
103748
+ };
103749
+ }
103750
+ /**
103751
+ * Augments a query with the extensions from a response. The general algorithm is:
103752
+ * 1. Create an AST from just the extensions.
103753
+ * 2. Deep merge the extensions AST into the query AST.
103754
+ * 3. Deep merge the extensions into the response data.
103755
+ * 4. Return the augmented query and response.
103756
+ * @param query - The query to augment.
103757
+ * @param response - The response to augment the query with.
103758
+ * @returns The augmented query and response.
103759
+ */
103760
+ function augmentQueryByResponse(query, response) {
103761
+ const extensions = response.extensions?.lds || {};
103762
+ const extensionsAST = createASTFromExtensions(extensions);
103763
+ const augmentedQuery = mergeASTs(query, extensionsAST);
103764
+ // Deep merge extensions into data, removing extensions key from result
103765
+ const mergedData = deepMerge$1(response.data, extensions);
103766
+ return {
103767
+ query: augmentedQuery,
103768
+ response: {
103769
+ data: mergedData,
103770
+ ...(response.errors && { errors: response.errors }),
103771
+ },
103772
+ };
103773
+ }
103774
+
103456
103775
  function buildCommandClass(baseClass) {
103457
103776
  return class extends baseClass {
103458
103777
  constructor(config, documentRootType, services) {
@@ -103460,21 +103779,169 @@ function buildCommandClass(baseClass) {
103460
103779
  this.config = config;
103461
103780
  this.documentRootType = documentRootType;
103462
103781
  this.services = services;
103463
- this.endpoint = "RecordUiController.executeGraphQL";
103464
- this.operationType = "graphql";
103782
+ this.endpoint = 'RecordUiController.executeGraphQL';
103783
+ }
103784
+ get url() {
103785
+ return '/graphql';
103465
103786
  }
103466
103787
  get cacheControlStrategyConfig() {
103467
103788
  return {
103468
- type: "max-age",
103789
+ type: 'max-age',
103469
103790
  requestMaxAge: 60,
103470
103791
  now: Date.now() / 1000,
103471
103792
  };
103472
103793
  }
103473
- get url() {
103474
- return "/graphql";
103475
- }
103476
103794
  get auraBodyWrapperName() {
103477
- return "queryInput";
103795
+ return 'queryInput';
103796
+ }
103797
+ get auraParams() {
103798
+ const params = super.auraParams;
103799
+ const body = params[this.auraBodyWrapperName];
103800
+ return {
103801
+ ...params,
103802
+ [this.auraBodyWrapperName]: {
103803
+ ...body,
103804
+ extensions: {
103805
+ ldsRequiredFields: true,
103806
+ },
103807
+ },
103808
+ };
103809
+ }
103810
+ get fetchParams() {
103811
+ const [url, params] = super.fetchParams;
103812
+ const body = JSON.parse(params.body);
103813
+ const modifiedBody = {
103814
+ ...body,
103815
+ extensions: {
103816
+ ldsRequiredFields: true,
103817
+ },
103818
+ };
103819
+ return [
103820
+ url,
103821
+ {
103822
+ ...params,
103823
+ body: JSON.stringify(modifiedBody),
103824
+ },
103825
+ ];
103826
+ }
103827
+ buildWriteInput(data) {
103828
+ this.latestLuvioRecordIdsToInvalidate = [];
103829
+ const baseQuery = this.buildRequestQuery();
103830
+ const { query: augmentedQuery, response: augmentedData } = augmentQueryByResponse(baseQuery, data);
103831
+ const extensionResult = buildGraphQLInputExtension({
103832
+ ...this.config,
103833
+ query: augmentedQuery,
103834
+ });
103835
+ if (extensionResult.isErr()) {
103836
+ throw new InternalError(extensionResult.error);
103837
+ }
103838
+ return {
103839
+ data: augmentedData.data,
103840
+ ...extensionResult.value,
103841
+ luvioRecordIdsToInvalidate: this.latestLuvioRecordIdsToInvalidate,
103842
+ };
103843
+ }
103844
+ readFromCache(cache) {
103845
+ let readFromCacheResult = undefined;
103846
+ try {
103847
+ const luvioService = this.services.luvio;
103848
+ const luvioInstance = luvioService.luvio;
103849
+ // Create a Luvio reader and get the latest snapshot
103850
+ this.latestLuvioSnapshot = luvioInstance.storeLookup({
103851
+ recordId: 'onestore-graphql',
103852
+ node: {
103853
+ kind: 'Fragment',
103854
+ reader: true,
103855
+ synthetic: true,
103856
+ read: (reader) => {
103857
+ readFromCacheResult = this.buildResultType().query(cache, {
103858
+ ...this.buildQuery(),
103859
+ reader,
103860
+ getNormalizedLuvioRecord: this.services.luvioUiapiRecords.getNormalizedLuvioRecord,
103861
+ });
103862
+ return readFromCacheResult;
103863
+ },
103864
+ },
103865
+ variables: {},
103866
+ });
103867
+ }
103868
+ catch (error) {
103869
+ return resolvedPromiseLike(err(error));
103870
+ }
103871
+ const readResult = readFromCacheResult;
103872
+ if (readResult === undefined) {
103873
+ return resolvedPromiseLike(err(new Error('No result from query')));
103874
+ }
103875
+ // Convert ReadResult to Result<any, Error>
103876
+ if (readResult.isErr()) {
103877
+ return resolvedPromiseLike(err(new Error('Failed to find data in cache')));
103878
+ }
103879
+ return resolvedPromiseLike(ok(readResult.value));
103880
+ }
103881
+ writeToCache(cache, networkResult) {
103882
+ try {
103883
+ const luvioService = this.services.luvio;
103884
+ const luvioInstance = luvioService.luvio;
103885
+ // Create a Luvio reader to allow the record representation type to lookup records in luvio
103886
+ // and mark them as needing invalidation when necessary
103887
+ luvioInstance.storeLookup({
103888
+ recordId: 'onestore-graphql',
103889
+ node: {
103890
+ kind: 'Fragment',
103891
+ reader: true,
103892
+ synthetic: true,
103893
+ read: (reader) => {
103894
+ if (networkResult.isOk()) {
103895
+ const x = this.buildResultType().write(cache.buildFixedTimeWritableCache(Date.now() / 1000), {
103896
+ ...this.buildWriteInput(networkResult.value),
103897
+ reader,
103898
+ getNormalizedLuvioRecord: this.services.luvioUiapiRecords
103899
+ .getNormalizedLuvioRecord,
103900
+ });
103901
+ }
103902
+ },
103903
+ },
103904
+ variables: {},
103905
+ });
103906
+ }
103907
+ catch (error) {
103908
+ // swallow error
103909
+ console.error(error);
103910
+ }
103911
+ return resolvedPromiseLike(undefined);
103912
+ }
103913
+ execute() {
103914
+ // Clear snapshot and unsubscribe from any existing subscriptions at the beginning of execute calls
103915
+ this.latestLuvioSnapshot = undefined;
103916
+ this.latestLuvioRecordIdsToInvalidate = undefined;
103917
+ if (this.unsubscribeFromLuvioSnapshot) {
103918
+ this.unsubscribeFromLuvioSnapshot();
103919
+ this.unsubscribeFromLuvioSnapshot = undefined;
103920
+ }
103921
+ const result = super.execute();
103922
+ result.then((_) => {
103923
+ if (this.latestLuvioRecordIdsToInvalidate &&
103924
+ this.latestLuvioRecordIdsToInvalidate.length > 0) {
103925
+ return this.services.luvioUiapiRecords.notifyRecordUpdateAvailable(this.latestLuvioRecordIdsToInvalidate.map((recordId) => ({ recordId })));
103926
+ }
103927
+ });
103928
+ return result;
103929
+ }
103930
+ subscribeToKeysUsed() {
103931
+ super.subscribeToKeysUsed();
103932
+ // Subscribe to luvio cache changes using the stored snapshot
103933
+ if (this.latestLuvioSnapshot) {
103934
+ try {
103935
+ const luvioService = this.services.luvio;
103936
+ const luvioInstance = luvioService.luvio;
103937
+ // Subscribe to changes using the stored snapshot
103938
+ this.unsubscribeFromLuvioSnapshot = luvioInstance.storeSubscribe(this.latestLuvioSnapshot, (_) => {
103939
+ // If any records used change at the top level, refresh all the data
103940
+ this.refresh();
103941
+ });
103942
+ }
103943
+ catch (error) { }
103944
+ }
103478
103945
  }
103479
103946
  };
103480
103947
  }
@@ -103518,6 +103985,10 @@ const serviceRequirements = {
103518
103985
  version: '1.0',
103519
103986
  optional: true,
103520
103987
  },
103988
+ luvioUiapiRecords: {
103989
+ type: 'luvioUiapiRecords',
103990
+ version: '1.0',
103991
+ },
103521
103992
  };
103522
103993
  let provisionedCallback;
103523
103994
  getServices(serviceRequirements).then((services) => {
@@ -103553,7 +104024,7 @@ function registerCallback(cb) {
103553
104024
  cb(graphql$1, graphql_imperative$1, useOneStoreGraphQL);
103554
104025
  }
103555
104026
  }
103556
- // version: 1.377.0-b0d5c49e07
104027
+ // version: 1.377.1-db77d3f339
103557
104028
 
103558
104029
  function createFragmentMap(documentNode) {
103559
104030
  const fragments = {};
@@ -130048,7 +130519,7 @@ function refreshGraphQL(data) {
130048
130519
  }
130049
130520
  return refresh$3(data, 'refreshUiApi');
130050
130521
  }
130051
- // version: 1.377.0-b0d5c49e07
130522
+ // version: 1.377.1-db77d3f339
130052
130523
 
130053
130524
  // On core the unstable adapters are re-exported with different names,
130054
130525
  // we want to match them here.
@@ -130200,7 +130671,7 @@ withDefaultLuvio((luvio) => {
130200
130671
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
130201
130672
  graphQLImperative = ldsAdapter;
130202
130673
  });
130203
- // version: 1.377.0-b0d5c49e07
130674
+ // version: 1.377.1-db77d3f339
130204
130675
 
130205
130676
  var gqlApi = /*#__PURE__*/Object.freeze({
130206
130677
  __proto__: null,
@@ -130999,7 +131470,7 @@ const callbacks$1 = [];
130999
131470
  function register(r) {
131000
131471
  callbacks$1.forEach((callback) => callback(r));
131001
131472
  }
131002
- // version: 1.377.0-3c95caf11c
131473
+ // version: 1.377.1-dadb6358f3
131003
131474
 
131004
131475
  /**
131005
131476
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -132315,4 +132786,4 @@ const { luvio } = getRuntime();
132315
132786
  setDefaultLuvio({ luvio });
132316
132787
 
132317
132788
  export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, importLuvioAdapterModule, importOneStoreAdapterModule, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
132318
- // version: 1.377.0-3c95caf11c
132789
+ // version: 1.377.1-dadb6358f3