@salesforce/lds-runtime-mobile 1.136.6 → 1.136.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/main.js +168 -58
  2. package/package.json +3 -3
  3. package/sfdc/main.js +168 -58
package/dist/main.js CHANGED
@@ -37,7 +37,7 @@ import formattingOptions from 'lightning/i18nCldrOptions';
37
37
  const { parse: parse$5, stringify: stringify$5 } = JSON;
38
38
  const { join: join$2, push: push$2, unshift } = Array.prototype;
39
39
  const { isArray: isArray$5 } = Array;
40
- const { entries: entries$3, keys: keys$6 } = Object;
40
+ const { entries: entries$3, keys: keys$7 } = Object;
41
41
 
42
42
  const UI_API_BASE_URI = '/services/data/v59.0/ui-api';
43
43
 
@@ -102,7 +102,7 @@ function isSpanningRecord$1(fieldValue) {
102
102
  function mergeRecordFields$1(first, second) {
103
103
  const { fields: targetFields } = first;
104
104
  const { fields: sourceFields } = second;
105
- const fieldNames = keys$6(sourceFields);
105
+ const fieldNames = keys$7(sourceFields);
106
106
  for (let i = 0, len = fieldNames.length; i < len; i += 1) {
107
107
  const fieldName = fieldNames[i];
108
108
  const sourceField = sourceFields[fieldName];
@@ -516,7 +516,7 @@ function isDeprecatedDurableStoreEntry(durableRecord) {
516
516
  }
517
517
  const DefaultDurableSegment = 'DEFAULT';
518
518
 
519
- const { keys: keys$5, create: create$5, assign: assign$4, freeze: freeze$1 } = Object;
519
+ const { keys: keys$6, create: create$5, assign: assign$4, freeze: freeze$1 } = Object;
520
520
 
521
521
  //Durable store error instrumentation key
522
522
  const DURABLE_STORE_ERROR = 'durable-store-error';
@@ -563,7 +563,7 @@ function publishDurableStoreEntries(durableRecords, put, publishMetadata) {
563
563
  if (durableRecords === undefined) {
564
564
  return { revivedKeys, hadUnexpectedShape };
565
565
  }
566
- const durableKeys = keys$5(durableRecords);
566
+ const durableKeys = keys$6(durableRecords);
567
567
  if (durableKeys.length === 0) {
568
568
  // no records to revive
569
569
  return { revivedKeys, hadUnexpectedShape };
@@ -737,7 +737,7 @@ class DurableTTLStore {
737
737
  overrides,
738
738
  };
739
739
  }
740
- const keys$1 = keys$5(entries);
740
+ const keys$1 = keys$6(entries);
741
741
  for (let i = 0, len = keys$1.length; i < len; i++) {
742
742
  const key = keys$1[i];
743
743
  const entry = entries[key];
@@ -765,7 +765,7 @@ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStor
765
765
  // TODO: W-8909393 Once metadata is stored in its own segment we need to
766
766
  // call setEntries for the visitedIds on default segment and call setEntries
767
767
  // on the metadata segment for the refreshedIds
768
- const keys$1 = keys$5({ ...visitedIds, ...refreshedIds });
768
+ const keys$1 = keys$6({ ...visitedIds, ...refreshedIds });
769
769
  for (let i = 0, len = keys$1.length; i < len; i += 1) {
770
770
  const key = keys$1[i];
771
771
  const record = records[key];
@@ -787,7 +787,7 @@ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStor
787
787
  }
788
788
  const durableStoreOperations = [];
789
789
  // publishes
790
- const recordKeys = keys$5(durableRecords);
790
+ const recordKeys = keys$6(durableRecords);
791
791
  if (recordKeys.length > 0) {
792
792
  durableStoreOperations.push({
793
793
  type: 'setEntries',
@@ -796,7 +796,7 @@ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStor
796
796
  });
797
797
  }
798
798
  // evicts
799
- const evictedKeys = keys$5(evictedRecords);
799
+ const evictedKeys = keys$6(evictedRecords);
800
800
  if (evictedKeys.length > 0) {
801
801
  durableStoreOperations.push({
802
802
  type: 'evictEntries',
@@ -950,7 +950,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
950
950
  try {
951
951
  const entries = await durableStore.getEntries(adapterContextKeysFromDifferentInstance, AdapterContextSegment);
952
952
  if (entries !== undefined) {
953
- const entryKeys = keys$5(entries);
953
+ const entryKeys = keys$6(entries);
954
954
  for (let i = 0, len = entryKeys.length; i < len; i++) {
955
955
  const entryKey = entryKeys[i];
956
956
  const entry = entries[entryKey];
@@ -1767,6 +1767,12 @@ function getRelationshipInfo(apiName, fieldName, infoMap) {
1767
1767
  function stringLiteral(value, safe = false, isCaseSensitive = false) {
1768
1768
  return { type: ValueType.StringLiteral, value, safe, isCaseSensitive };
1769
1769
  }
1770
+ function isStringLiteral(expression) {
1771
+ return expression.type === ValueType.StringLiteral;
1772
+ }
1773
+ function isStringArray(expression) {
1774
+ return expression.type === ValueType.StringArray;
1775
+ }
1770
1776
  function comparison(left, operator, right) {
1771
1777
  return { type: PredicateType$1.comparison, left, right, operator };
1772
1778
  }
@@ -2537,6 +2543,9 @@ function compoundOperatorToSql(operator) {
2537
2543
  }
2538
2544
  }
2539
2545
 
2546
+ const { isArray: isArray$4 } = Array;
2547
+ const { keys: keys$5 } = Object;
2548
+
2540
2549
  function isListValueNode(node) {
2541
2550
  return node.kind === 'ListValue';
2542
2551
  }
@@ -2589,13 +2598,13 @@ function isScalarDataType(type) {
2589
2598
  const NotOperator = 'not';
2590
2599
  const { eq, ne, gt, gte, lt, lte, nin, like, includes, excludes } = ComparisonOperator;
2591
2600
  const inOp = ComparisonOperator.in;
2592
- function fieldsToFilters(fieldValues, joinAlias, apiName, input, compoundOperator = CompoundOperator.and, joins) {
2601
+ function fieldsToFilters(fieldValues, joinAlias, apiName, input, compoundOperator = CompoundOperator.and, joins, draftFunctions) {
2593
2602
  const results = fieldValues
2594
2603
  .map((value) => {
2595
2604
  if (!isObjectValueNode$1(value)) {
2596
2605
  return [failure([message('Parent filter node should be an object.')])];
2597
2606
  }
2598
- return Object.entries(value.fields).map(([key, value]) => filter(key, value, joinAlias, apiName, input, joins));
2607
+ return Object.entries(value.fields).map(([key, value]) => filter(key, value, joinAlias, apiName, input, joins, draftFunctions));
2599
2608
  })
2600
2609
  .reduce(flatten$1, []);
2601
2610
  const failures = results.filter(isFailure).reduce(flatMap(errors), []);
@@ -2617,22 +2626,22 @@ function fieldsToFilters(fieldValues, joinAlias, apiName, input, compoundOperato
2617
2626
  return success({ predicate: resolvedPredicate });
2618
2627
  }
2619
2628
  //{where: {Field: ... | and: ... | or: ... | not: ...}}
2620
- function recordFilter(where, joinAlias, apiName, input, joins) {
2629
+ function recordFilter(where, joinAlias, apiName, input, joins, draftFunctions) {
2621
2630
  if (where === undefined) {
2622
2631
  return success(undefined);
2623
2632
  }
2624
2633
  // when 'recordFilter' starts, there is no 'NotPredicated'
2625
- return fieldsToFilters([where.value], joinAlias, apiName, input, CompoundOperator.and, joins).map((result) => result.predicate === undefined || isEmptyPredicate(result.predicate) ? undefined : result);
2634
+ return fieldsToFilters([where.value], joinAlias, apiName, input, CompoundOperator.and, joins, draftFunctions).map((result) => result.predicate === undefined || isEmptyPredicate(result.predicate) ? undefined : result);
2626
2635
  }
2627
- function filter(name, value, tableAlias, apiName, input, joins) {
2636
+ function filter(name, value, tableAlias, apiName, input, joins, draftFunctions) {
2628
2637
  if (isCompoundOperator(name)) {
2629
2638
  if (!isListValueNode(value)) {
2630
2639
  return failure([message(`Value for ${name} node must be a list.`)]);
2631
2640
  }
2632
- return compoundPredicate(name, value, tableAlias, apiName, input, joins);
2641
+ return compoundPredicate(name, value, tableAlias, apiName, input, joins, draftFunctions);
2633
2642
  }
2634
2643
  if (name === NotOperator) {
2635
- const children = fieldsToFilters([value], tableAlias, apiName, input, CompoundOperator.and, joins);
2644
+ const children = fieldsToFilters([value], tableAlias, apiName, input, CompoundOperator.and, joins, draftFunctions);
2636
2645
  // take the children of a not predicate
2637
2646
  // and wrap them all inside it
2638
2647
  return children.flatMap((container) => {
@@ -2650,10 +2659,10 @@ function filter(name, value, tableAlias, apiName, input, joins) {
2650
2659
  if (!isObjectValueNode$1(value)) {
2651
2660
  return failure([message('Filter node must be an object or list.')]);
2652
2661
  }
2653
- return fieldFilter(name, value, tableAlias, apiName, input, joins);
2662
+ return fieldFilter(name, value, tableAlias, apiName, input, joins, draftFunctions);
2654
2663
  }
2655
- function compoundPredicate(operator, list, joinAlias, apiName, input, joins) {
2656
- return fieldsToFilters(list.values, joinAlias, apiName, input, operator, joins);
2664
+ function compoundPredicate(operator, list, joinAlias, apiName, input, joins, draftFunctions) {
2665
+ return fieldsToFilters(list.values, joinAlias, apiName, input, operator, joins, draftFunctions);
2657
2666
  }
2658
2667
  /**
2659
2668
  * spans a FieldNode with its ObjectValueNode is passed. All the predicates is added into the 'join' array.
@@ -2664,7 +2673,7 @@ function compoundPredicate(operator, list, joinAlias, apiName, input, joins) {
2664
2673
  * @param joins
2665
2674
  * @returns undefined predicate
2666
2675
  */
2667
- function spanningFilter(fieldInfo, fieldNode, alias, input, joins) {
2676
+ function spanningFilter(fieldInfo, fieldNode, alias, input, joins, draftFunctions) {
2668
2677
  const { apiName: fieldName, referenceToInfos, relationshipName } = fieldInfo;
2669
2678
  const referenceInfo = referenceToInfos[0];
2670
2679
  const jsonAlias = `${alias}.${relationshipName}`;
@@ -2683,7 +2692,7 @@ function spanningFilter(fieldInfo, fieldNode, alias, input, joins) {
2683
2692
  joins.push(join);
2684
2693
  // moves constraint predicate to where
2685
2694
  const constraintPredicates = [];
2686
- const filterResult = fieldsToFilters([fieldNode], jsonAlias, apiName, input, CompoundOperator.and, joins);
2695
+ const filterResult = fieldsToFilters([fieldNode], jsonAlias, apiName, input, CompoundOperator.and, joins, draftFunctions);
2687
2696
  if (filterResult.isSuccess === false) {
2688
2697
  return filterResult;
2689
2698
  }
@@ -2695,7 +2704,11 @@ function spanningFilter(fieldInfo, fieldNode, alias, input, joins) {
2695
2704
  });
2696
2705
  return success({ predicate: combinePredicates(constraintPredicates, CompoundOperator.and) });
2697
2706
  }
2698
- function fieldFilter(fieldName, fieldNode, alias, apiName, input, joins) {
2707
+ function isIDValueField$1(fieldInfo) {
2708
+ return (fieldInfo.apiName === 'Id' ||
2709
+ (fieldInfo.referenceToInfos !== undefined && fieldInfo.referenceToInfos.length > 0));
2710
+ }
2711
+ function fieldFilter(fieldName, fieldNode, alias, apiName, input, joins, draftFunctions) {
2699
2712
  const fieldInfoResult = getFieldInfo(apiName, fieldName, input);
2700
2713
  if (fieldInfoResult.isSuccess === false) {
2701
2714
  return failure([fieldInfoResult.error]);
@@ -2705,8 +2718,9 @@ function fieldFilter(fieldName, fieldNode, alias, apiName, input, joins) {
2705
2718
  return failure([message(`Field ${fieldName} for type ${apiName} not found.`)]);
2706
2719
  }
2707
2720
  if (fieldInfo.dataType === 'Reference' && fieldInfo.relationshipName === fieldName) {
2708
- return spanningFilter(fieldInfo, fieldNode, alias, input, joins);
2721
+ return spanningFilter(fieldInfo, fieldNode, alias, input, joins, draftFunctions);
2709
2722
  }
2723
+ const idProcessingNeeded = isIDValueField$1(fieldInfo);
2710
2724
  const extract = {
2711
2725
  type: ValueType.Extract,
2712
2726
  jsonAlias: alias,
@@ -2797,7 +2811,29 @@ function fieldFilter(fieldName, fieldNode, alias, apiName, input, joins) {
2797
2811
  children,
2798
2812
  };
2799
2813
  }
2800
- return comparison(extract, op.operator, op.value);
2814
+ const rightOperand = op.value;
2815
+ if (idProcessingNeeded) {
2816
+ if (isStringLiteral(rightOperand)) {
2817
+ if (rightOperand.value !== null) {
2818
+ if (draftFunctions.isDraftId(rightOperand.value)) {
2819
+ rightOperand.value = draftFunctions.getCanonicalId(rightOperand.value);
2820
+ }
2821
+ }
2822
+ }
2823
+ else if (isStringArray(rightOperand)) {
2824
+ if (rightOperand.value !== null) {
2825
+ rightOperand.value = rightOperand.value.map((originalId) => {
2826
+ if (originalId !== null) {
2827
+ if (draftFunctions.isDraftId(originalId)) {
2828
+ return draftFunctions.getCanonicalId(originalId);
2829
+ }
2830
+ }
2831
+ return originalId;
2832
+ });
2833
+ }
2834
+ }
2835
+ }
2836
+ return comparison(extract, op.operator, rightOperand);
2801
2837
  });
2802
2838
  const combined = combinePredicates(comparisons.concat(...dateFunction.value), CompoundOperator.and);
2803
2839
  const container = {
@@ -3899,7 +3935,7 @@ function recordQuery(selection, apiName, alias, predicates, input) {
3899
3935
  const orderByJoins = [];
3900
3936
  const orderByResult = parseOrderBy(orderByArg, alias, apiName, input.objectInfoMap, orderByJoins);
3901
3937
  const filterJoins = [];
3902
- const whereResult = recordFilter(whereArg, alias, apiName, input.objectInfoMap, filterJoins);
3938
+ const whereResult = recordFilter(whereArg, alias, apiName, input.objectInfoMap, filterJoins, input.draftFunctions);
3903
3939
  const scopeJoins = [];
3904
3940
  const scopeResult = scopeFilter(scopeArg, alias, apiName, input, scopeJoins);
3905
3941
  let additionalPredicates = [];
@@ -4061,27 +4097,19 @@ function generateVariableGQLQuery(document, variables) {
4061
4097
  ? node.arguments
4062
4098
  .map((args) => {
4063
4099
  const { value, name } = args;
4100
+ //The variable is on the top level, for example `where: ${filter}`
4064
4101
  if (is(value, 'Variable')) {
4065
- const variable = variables[value.name];
4066
- if (variable) {
4067
- const jsonString = JSON.stringify(variable);
4068
- const buildRecordQueryString = (name, query, transform) => {
4069
- return `${name}: ${transform(query)}`;
4070
- };
4071
- switch (name) {
4072
- case 'scope':
4073
- case 'orderBy':
4074
- return buildRecordQueryString(name, jsonString, removeAllQuotations);
4075
- default:
4076
- return buildRecordQueryString(name, jsonString, removeQuotationsFromKeys);
4077
- }
4078
- }
4079
- return '';
4102
+ return generateVariableNodeQuery(value, name, name, variables);
4103
+ }
4104
+ else if (isObjectValueNode$1(value)) {
4105
+ return generateVariableSubQuery(value, name, name, variables);
4080
4106
  }
4081
4107
  })
4082
4108
  .filter(Boolean)
4083
4109
  : undefined;
4084
- return gqlArguments ? `${node.name}(${gqlArguments.join(',')}) { Id }` : '';
4110
+ return gqlArguments
4111
+ ? `${node.name} ${gqlArguments.length > 0 ? '(' + gqlArguments.join(',') + ')' : ''} { Id }`
4112
+ : '';
4085
4113
  })
4086
4114
  //remove empty strings
4087
4115
  .filter(Boolean)
@@ -4091,6 +4119,51 @@ function generateVariableGQLQuery(document, variables) {
4091
4119
  return [accu.slice(0, 1), query, accu.slice(1, length)].join('');
4092
4120
  }, '{ }'));
4093
4121
  }
4122
+ /**
4123
+ * Given a LuvioValueNode, generates a sql with its variable node replaced with actual value.
4124
+ * @param valueNode G
4125
+ * @param name
4126
+ * @param type
4127
+ * @param variables
4128
+ * @returns
4129
+ */
4130
+ function generateVariableSubQuery(valueNode, name, type, variables) {
4131
+ switch (valueNode.kind) {
4132
+ case Kind.OBJECT: {
4133
+ // For example, `{ Id: { eq: $draftId } }` is a `ObjectValueNode`, which has field keys 'Id'
4134
+ const resultQuery = keys$5(valueNode.fields)
4135
+ .map((key) => generateVariableSubQuery(valueNode.fields[key], key, type, variables))
4136
+ .filter((subquery) => subquery.length > 0)
4137
+ .join(',');
4138
+ if (resultQuery.length > 0) {
4139
+ return `${name}: {${resultQuery}}`;
4140
+ }
4141
+ return resultQuery;
4142
+ }
4143
+ case Kind.VARIABLE:
4144
+ return generateVariableNodeQuery(valueNode, name, type, variables);
4145
+ default:
4146
+ return '';
4147
+ }
4148
+ }
4149
+ // Generate a sql for the variable node with its actual value.
4150
+ function generateVariableNodeQuery(value, name, type, variables) {
4151
+ const variable = variables[value.name];
4152
+ if (variable) {
4153
+ const jsonString = JSON.stringify(variable);
4154
+ const buildRecordQueryString = (name, query, transform) => {
4155
+ return `${name}: ${transform(query)}`;
4156
+ };
4157
+ switch (type) {
4158
+ case 'scope':
4159
+ case 'orderBy':
4160
+ return buildRecordQueryString(name, jsonString, removeAllQuotations);
4161
+ default:
4162
+ return buildRecordQueryString(name, jsonString, removeQuotationsFromKeys);
4163
+ }
4164
+ }
4165
+ return '';
4166
+ }
4094
4167
  /**
4095
4168
  * Given an AST with variables
4096
4169
  * Swap out the LuvioArgumentNodes on the original AST with ones generated from its variables.
@@ -4109,14 +4182,43 @@ function swapVariableArguments(document, variables) {
4109
4182
  const { name } = node;
4110
4183
  const first = allArgumentRecords.find((n) => n.name === name);
4111
4184
  if (first) {
4112
- // if we had arguments that did not contain variables we still want those
4113
- first.arguments = flatten$1(first.arguments
4114
- ? first.arguments.filter((x) => x.value.kind !== 'Variable')
4115
- : [], node.arguments ? node.arguments : []);
4185
+ const swappedArgments = swapArgumentWithVariableNodes(node.arguments, first.arguments);
4186
+ first.arguments = swappedArgments ? swappedArgments : [];
4116
4187
  }
4117
4188
  });
4118
4189
  }
4119
4190
  }
4191
+ // Replaces the variable node in original LuvioArgumentNode with the actual value in the swapped node with the same path.
4192
+ function swapArgumentWithVariableNodes(swapped, original) {
4193
+ if (swapped === undefined || original === undefined) {
4194
+ return original;
4195
+ }
4196
+ return original.map((x) => {
4197
+ const targetNode = swapped.find((y) => y.name === x.name);
4198
+ if (targetNode === undefined) {
4199
+ return x;
4200
+ }
4201
+ if (x.value.kind === 'Variable') {
4202
+ return targetNode;
4203
+ }
4204
+ swapValueNodeWithVariableNodes(x.value, targetNode.value);
4205
+ return x;
4206
+ });
4207
+ }
4208
+ function swapValueNodeWithVariableNodes(original, swapped) {
4209
+ if (original.kind === Kind.OBJECT) {
4210
+ for (const key of keys$5(original.fields)) {
4211
+ if (isObjectValueNode$1(swapped) && swapped.fields[key]) {
4212
+ if (is(original.fields[key], 'Variable')) {
4213
+ original.fields[key] = swapped.fields[key];
4214
+ }
4215
+ else {
4216
+ swapValueNodeWithVariableNodes(original.fields[key], swapped.fields[key]);
4217
+ }
4218
+ }
4219
+ }
4220
+ }
4221
+ }
4120
4222
  //find top level record queries
4121
4223
  function findRecordSelections(document) {
4122
4224
  return document.definitions
@@ -4151,7 +4253,7 @@ class StoreEvalPreconditioner {
4151
4253
  * Missing object info records triggers the objectInfoService (same instance shared with Drafts code), to
4152
4254
  * use the getObjectInfos adapter to efficiently fetch the necessary records.
4153
4255
  */
4154
- async createRootQuery(config, objectInfoService, userId) {
4256
+ async createRootQuery(config, objectInfoService, userId, draftFunctions) {
4155
4257
  const { query: ast, variables } = config;
4156
4258
  swapVariableArguments(ast, variables);
4157
4259
  // Parse out top-level record queries types we know we will need, since spanning fields will
@@ -4198,6 +4300,7 @@ class StoreEvalPreconditioner {
4198
4300
  astTransformResult = transform(ast, {
4199
4301
  userId,
4200
4302
  objectInfoMap,
4303
+ draftFunctions,
4201
4304
  });
4202
4305
  if (astTransformResult.isSuccess === false) {
4203
4306
  for (const error of astTransformResult.error) {
@@ -4235,8 +4338,6 @@ class StoreEvalPreconditioner {
4235
4338
  }
4236
4339
  }
4237
4340
 
4238
- const { isArray: isArray$4 } = Array;
4239
-
4240
4341
  /**
4241
4342
  * Checks a GraphQL-shaped network response for errors, returning true if it does
4242
4343
  * and false otherwise
@@ -4282,7 +4383,7 @@ const wrapStartEndEvents = (storeEval) => {
4282
4383
  return snapshot;
4283
4384
  };
4284
4385
  };
4285
- function sqliteStoreEvalFactory(userId, sqliteStore, objectInfoService) {
4386
+ function sqliteStoreEvalFactory(userId, sqliteStore, objectInfoService, draftFunctions) {
4286
4387
  // if the store does not support eval then use the noop version
4287
4388
  if (sqliteStore.isEvalSupported() === false) {
4288
4389
  return noopStoreEval;
@@ -4290,7 +4391,7 @@ function sqliteStoreEvalFactory(userId, sqliteStore, objectInfoService) {
4290
4391
  const preconditioner = new StoreEvalPreconditioner();
4291
4392
  return makeStoreEval(preconditioner, objectInfoService, userId, async () => {
4292
4393
  return undefined;
4293
- }, (query, _context, eventEmitter) => evaluateSqlite(query, eventEmitter, sqliteStore));
4394
+ }, (query, _context, eventEmitter) => evaluateSqlite(query, eventEmitter, sqliteStore), draftFunctions);
4294
4395
  }
4295
4396
  async function noopStoreEval(_config, nonEvaluatedSnapshotOrPromise, _observers) {
4296
4397
  return nonEvaluatedSnapshotOrPromise;
@@ -4309,7 +4410,7 @@ function isErrorSnapshotThatShouldGetReturnedToCaller$1(snapshot) {
4309
4410
  function generateUniqueRecordId$1() {
4310
4411
  return `${GRAPHQL_ROOT_KEY$1}${Date.now() + Math.random().toFixed(5).split('.')[1]}`;
4311
4412
  }
4312
- function makeStoreEval(preconditioner, objectInfoService, userId, contextProvider, queryEvaluator) {
4413
+ function makeStoreEval(preconditioner, objectInfoService, userId, contextProvider, queryEvaluator, draftFunctions) {
4313
4414
  const storeEval = async (config, nonEvaluatedSnapshotOrPromise, observers) => {
4314
4415
  const eventEmitter = createCustomAdapterEventEmitter(GRAPHQL_EVAL_NAMESPACE$1, observers);
4315
4416
  // the non-eval'ed input could either be a snapshot or promise of one so
@@ -4339,7 +4440,7 @@ function makeStoreEval(preconditioner, objectInfoService, userId, contextProvide
4339
4440
  context = await contextProvider();
4340
4441
  // Ensures ObjectInfo metadata is available for the request. Sourcing records from L1/L2/Network
4341
4442
  // is delegated to the getObjectInfo adapter via objectInfoService
4342
- rootQuery = await preconditioner.createRootQuery(config, objectInfoService, userId);
4443
+ rootQuery = await preconditioner.createRootQuery(config, objectInfoService, userId, draftFunctions);
4343
4444
  }
4344
4445
  catch (error) {
4345
4446
  eventEmitter({
@@ -15645,11 +15746,6 @@ function getRuntime() {
15645
15746
  getIngestMetadataForInternalAdapters =
15646
15747
  internalAdapterDurableEnvironment.getIngestStagingStoreRecords;
15647
15748
  lazyObjectInfoService = new ObjectInfoService(getObjectInfo, getObjectInfos, internalAdapterDurableStore);
15648
- // set storeEval function for lds-adapters-graghql to use
15649
- withRegistration('@salesforce/lds-adapters-graphql', (registration) => {
15650
- const { configuration: { setStoreEval }, } = registration;
15651
- setStoreEval(sqliteStoreEvalFactory(userId, lazyBaseDurableStore, lazyObjectInfoService));
15652
- });
15653
15749
  // creates a durable store that denormalizes scalar fields for records
15654
15750
  let getIngestRecords;
15655
15751
  let getIngestMetadata;
@@ -15688,6 +15784,20 @@ function getRuntime() {
15688
15784
  setupMobileInstrumentation(lazyLuvio, store);
15689
15785
  // If the inspection nimbus plugin is configured, inspection is enabled otherwise this is a no-op
15690
15786
  setupInspection(lazyLuvio);
15787
+ // set storeEval function for lds-adapters-graghql to use
15788
+ withRegistration('@salesforce/lds-adapters-graphql', (registration) => {
15789
+ const { configuration: { setStoreEval, setDraftFunctions }, } = registration;
15790
+ const getCanonicalId = (id) => {
15791
+ var _a;
15792
+ return ((_a = extractRecordIdFromStoreKey(lazyLuvio.storeGetCanonicalKey(RECORD_ID_PREFIX + id))) !== null && _a !== void 0 ? _a : id);
15793
+ };
15794
+ const draftFuncs = {
15795
+ isDraftId: isGenerated,
15796
+ getCanonicalId,
15797
+ };
15798
+ setStoreEval(sqliteStoreEvalFactory(userId, lazyBaseDurableStore, lazyObjectInfoService, draftFuncs));
15799
+ setDraftFunctions(draftFuncs);
15800
+ });
15691
15801
  // on core the graphql configuration is split so we need to set configureUIAPIGraphQL both in the
15692
15802
  // graphql registration and the uiapi for off core
15693
15803
  const configureUIAPIGraphQL = (registration) => {
@@ -15740,4 +15850,4 @@ register({
15740
15850
  });
15741
15851
 
15742
15852
  export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
15743
- // version: 1.136.6-0f5ec3ee7
15853
+ // version: 1.136.7-777657471
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-runtime-mobile",
3
- "version": "1.136.6",
3
+ "version": "1.136.7",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "LDS runtime for mobile/hybrid environments.",
6
6
  "main": "dist/main.js",
@@ -59,7 +59,7 @@
59
59
  "maxSize": {
60
60
  "none": "650 kB",
61
61
  "min": "255 kB",
62
- "compressed": "100 kB"
62
+ "compressed": "102 kB"
63
63
  }
64
64
  },
65
65
  {
@@ -67,7 +67,7 @@
67
67
  "maxSize": {
68
68
  "none": "650 kB",
69
69
  "min": "255 kB",
70
- "compressed": "100 kB"
70
+ "compressed": "102 kB"
71
71
  }
72
72
  }
73
73
  ],
package/sfdc/main.js CHANGED
@@ -37,7 +37,7 @@ import formattingOptions from 'lightning/i18nCldrOptions';
37
37
  const { parse: parse$5, stringify: stringify$5 } = JSON;
38
38
  const { join: join$2, push: push$2, unshift } = Array.prototype;
39
39
  const { isArray: isArray$5 } = Array;
40
- const { entries: entries$3, keys: keys$6 } = Object;
40
+ const { entries: entries$3, keys: keys$7 } = Object;
41
41
 
42
42
  const UI_API_BASE_URI = '/services/data/v59.0/ui-api';
43
43
 
@@ -102,7 +102,7 @@ function isSpanningRecord$1(fieldValue) {
102
102
  function mergeRecordFields$1(first, second) {
103
103
  const { fields: targetFields } = first;
104
104
  const { fields: sourceFields } = second;
105
- const fieldNames = keys$6(sourceFields);
105
+ const fieldNames = keys$7(sourceFields);
106
106
  for (let i = 0, len = fieldNames.length; i < len; i += 1) {
107
107
  const fieldName = fieldNames[i];
108
108
  const sourceField = sourceFields[fieldName];
@@ -516,7 +516,7 @@ function isDeprecatedDurableStoreEntry(durableRecord) {
516
516
  }
517
517
  const DefaultDurableSegment = 'DEFAULT';
518
518
 
519
- const { keys: keys$5, create: create$5, assign: assign$4, freeze: freeze$1 } = Object;
519
+ const { keys: keys$6, create: create$5, assign: assign$4, freeze: freeze$1 } = Object;
520
520
 
521
521
  //Durable store error instrumentation key
522
522
  const DURABLE_STORE_ERROR = 'durable-store-error';
@@ -563,7 +563,7 @@ function publishDurableStoreEntries(durableRecords, put, publishMetadata) {
563
563
  if (durableRecords === undefined) {
564
564
  return { revivedKeys, hadUnexpectedShape };
565
565
  }
566
- const durableKeys = keys$5(durableRecords);
566
+ const durableKeys = keys$6(durableRecords);
567
567
  if (durableKeys.length === 0) {
568
568
  // no records to revive
569
569
  return { revivedKeys, hadUnexpectedShape };
@@ -737,7 +737,7 @@ class DurableTTLStore {
737
737
  overrides,
738
738
  };
739
739
  }
740
- const keys$1 = keys$5(entries);
740
+ const keys$1 = keys$6(entries);
741
741
  for (let i = 0, len = keys$1.length; i < len; i++) {
742
742
  const key = keys$1[i];
743
743
  const entry = entries[key];
@@ -765,7 +765,7 @@ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStor
765
765
  // TODO: W-8909393 Once metadata is stored in its own segment we need to
766
766
  // call setEntries for the visitedIds on default segment and call setEntries
767
767
  // on the metadata segment for the refreshedIds
768
- const keys$1 = keys$5({ ...visitedIds, ...refreshedIds });
768
+ const keys$1 = keys$6({ ...visitedIds, ...refreshedIds });
769
769
  for (let i = 0, len = keys$1.length; i < len; i += 1) {
770
770
  const key = keys$1[i];
771
771
  const record = records[key];
@@ -787,7 +787,7 @@ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStor
787
787
  }
788
788
  const durableStoreOperations = [];
789
789
  // publishes
790
- const recordKeys = keys$5(durableRecords);
790
+ const recordKeys = keys$6(durableRecords);
791
791
  if (recordKeys.length > 0) {
792
792
  durableStoreOperations.push({
793
793
  type: 'setEntries',
@@ -796,7 +796,7 @@ function flushInMemoryStoreValuesToDurableStore(store, durableStore, durableStor
796
796
  });
797
797
  }
798
798
  // evicts
799
- const evictedKeys = keys$5(evictedRecords);
799
+ const evictedKeys = keys$6(evictedRecords);
800
800
  if (evictedKeys.length > 0) {
801
801
  durableStoreOperations.push({
802
802
  type: 'evictEntries',
@@ -950,7 +950,7 @@ function makeDurable(environment, { durableStore, instrumentation }) {
950
950
  try {
951
951
  const entries = await durableStore.getEntries(adapterContextKeysFromDifferentInstance, AdapterContextSegment);
952
952
  if (entries !== undefined) {
953
- const entryKeys = keys$5(entries);
953
+ const entryKeys = keys$6(entries);
954
954
  for (let i = 0, len = entryKeys.length; i < len; i++) {
955
955
  const entryKey = entryKeys[i];
956
956
  const entry = entries[entryKey];
@@ -1767,6 +1767,12 @@ function getRelationshipInfo(apiName, fieldName, infoMap) {
1767
1767
  function stringLiteral(value, safe = false, isCaseSensitive = false) {
1768
1768
  return { type: ValueType.StringLiteral, value, safe, isCaseSensitive };
1769
1769
  }
1770
+ function isStringLiteral(expression) {
1771
+ return expression.type === ValueType.StringLiteral;
1772
+ }
1773
+ function isStringArray(expression) {
1774
+ return expression.type === ValueType.StringArray;
1775
+ }
1770
1776
  function comparison(left, operator, right) {
1771
1777
  return { type: PredicateType$1.comparison, left, right, operator };
1772
1778
  }
@@ -2537,6 +2543,9 @@ function compoundOperatorToSql(operator) {
2537
2543
  }
2538
2544
  }
2539
2545
 
2546
+ const { isArray: isArray$4 } = Array;
2547
+ const { keys: keys$5 } = Object;
2548
+
2540
2549
  function isListValueNode(node) {
2541
2550
  return node.kind === 'ListValue';
2542
2551
  }
@@ -2589,13 +2598,13 @@ function isScalarDataType(type) {
2589
2598
  const NotOperator = 'not';
2590
2599
  const { eq, ne, gt, gte, lt, lte, nin, like, includes, excludes } = ComparisonOperator;
2591
2600
  const inOp = ComparisonOperator.in;
2592
- function fieldsToFilters(fieldValues, joinAlias, apiName, input, compoundOperator = CompoundOperator.and, joins) {
2601
+ function fieldsToFilters(fieldValues, joinAlias, apiName, input, compoundOperator = CompoundOperator.and, joins, draftFunctions) {
2593
2602
  const results = fieldValues
2594
2603
  .map((value) => {
2595
2604
  if (!isObjectValueNode$1(value)) {
2596
2605
  return [failure([message('Parent filter node should be an object.')])];
2597
2606
  }
2598
- return Object.entries(value.fields).map(([key, value]) => filter(key, value, joinAlias, apiName, input, joins));
2607
+ return Object.entries(value.fields).map(([key, value]) => filter(key, value, joinAlias, apiName, input, joins, draftFunctions));
2599
2608
  })
2600
2609
  .reduce(flatten$1, []);
2601
2610
  const failures = results.filter(isFailure).reduce(flatMap(errors), []);
@@ -2617,22 +2626,22 @@ function fieldsToFilters(fieldValues, joinAlias, apiName, input, compoundOperato
2617
2626
  return success({ predicate: resolvedPredicate });
2618
2627
  }
2619
2628
  //{where: {Field: ... | and: ... | or: ... | not: ...}}
2620
- function recordFilter(where, joinAlias, apiName, input, joins) {
2629
+ function recordFilter(where, joinAlias, apiName, input, joins, draftFunctions) {
2621
2630
  if (where === undefined) {
2622
2631
  return success(undefined);
2623
2632
  }
2624
2633
  // when 'recordFilter' starts, there is no 'NotPredicated'
2625
- return fieldsToFilters([where.value], joinAlias, apiName, input, CompoundOperator.and, joins).map((result) => result.predicate === undefined || isEmptyPredicate(result.predicate) ? undefined : result);
2634
+ return fieldsToFilters([where.value], joinAlias, apiName, input, CompoundOperator.and, joins, draftFunctions).map((result) => result.predicate === undefined || isEmptyPredicate(result.predicate) ? undefined : result);
2626
2635
  }
2627
- function filter(name, value, tableAlias, apiName, input, joins) {
2636
+ function filter(name, value, tableAlias, apiName, input, joins, draftFunctions) {
2628
2637
  if (isCompoundOperator(name)) {
2629
2638
  if (!isListValueNode(value)) {
2630
2639
  return failure([message(`Value for ${name} node must be a list.`)]);
2631
2640
  }
2632
- return compoundPredicate(name, value, tableAlias, apiName, input, joins);
2641
+ return compoundPredicate(name, value, tableAlias, apiName, input, joins, draftFunctions);
2633
2642
  }
2634
2643
  if (name === NotOperator) {
2635
- const children = fieldsToFilters([value], tableAlias, apiName, input, CompoundOperator.and, joins);
2644
+ const children = fieldsToFilters([value], tableAlias, apiName, input, CompoundOperator.and, joins, draftFunctions);
2636
2645
  // take the children of a not predicate
2637
2646
  // and wrap them all inside it
2638
2647
  return children.flatMap((container) => {
@@ -2650,10 +2659,10 @@ function filter(name, value, tableAlias, apiName, input, joins) {
2650
2659
  if (!isObjectValueNode$1(value)) {
2651
2660
  return failure([message('Filter node must be an object or list.')]);
2652
2661
  }
2653
- return fieldFilter(name, value, tableAlias, apiName, input, joins);
2662
+ return fieldFilter(name, value, tableAlias, apiName, input, joins, draftFunctions);
2654
2663
  }
2655
- function compoundPredicate(operator, list, joinAlias, apiName, input, joins) {
2656
- return fieldsToFilters(list.values, joinAlias, apiName, input, operator, joins);
2664
+ function compoundPredicate(operator, list, joinAlias, apiName, input, joins, draftFunctions) {
2665
+ return fieldsToFilters(list.values, joinAlias, apiName, input, operator, joins, draftFunctions);
2657
2666
  }
2658
2667
  /**
2659
2668
  * spans a FieldNode with its ObjectValueNode is passed. All the predicates is added into the 'join' array.
@@ -2664,7 +2673,7 @@ function compoundPredicate(operator, list, joinAlias, apiName, input, joins) {
2664
2673
  * @param joins
2665
2674
  * @returns undefined predicate
2666
2675
  */
2667
- function spanningFilter(fieldInfo, fieldNode, alias, input, joins) {
2676
+ function spanningFilter(fieldInfo, fieldNode, alias, input, joins, draftFunctions) {
2668
2677
  const { apiName: fieldName, referenceToInfos, relationshipName } = fieldInfo;
2669
2678
  const referenceInfo = referenceToInfos[0];
2670
2679
  const jsonAlias = `${alias}.${relationshipName}`;
@@ -2683,7 +2692,7 @@ function spanningFilter(fieldInfo, fieldNode, alias, input, joins) {
2683
2692
  joins.push(join);
2684
2693
  // moves constraint predicate to where
2685
2694
  const constraintPredicates = [];
2686
- const filterResult = fieldsToFilters([fieldNode], jsonAlias, apiName, input, CompoundOperator.and, joins);
2695
+ const filterResult = fieldsToFilters([fieldNode], jsonAlias, apiName, input, CompoundOperator.and, joins, draftFunctions);
2687
2696
  if (filterResult.isSuccess === false) {
2688
2697
  return filterResult;
2689
2698
  }
@@ -2695,7 +2704,11 @@ function spanningFilter(fieldInfo, fieldNode, alias, input, joins) {
2695
2704
  });
2696
2705
  return success({ predicate: combinePredicates(constraintPredicates, CompoundOperator.and) });
2697
2706
  }
2698
- function fieldFilter(fieldName, fieldNode, alias, apiName, input, joins) {
2707
+ function isIDValueField$1(fieldInfo) {
2708
+ return (fieldInfo.apiName === 'Id' ||
2709
+ (fieldInfo.referenceToInfos !== undefined && fieldInfo.referenceToInfos.length > 0));
2710
+ }
2711
+ function fieldFilter(fieldName, fieldNode, alias, apiName, input, joins, draftFunctions) {
2699
2712
  const fieldInfoResult = getFieldInfo(apiName, fieldName, input);
2700
2713
  if (fieldInfoResult.isSuccess === false) {
2701
2714
  return failure([fieldInfoResult.error]);
@@ -2705,8 +2718,9 @@ function fieldFilter(fieldName, fieldNode, alias, apiName, input, joins) {
2705
2718
  return failure([message(`Field ${fieldName} for type ${apiName} not found.`)]);
2706
2719
  }
2707
2720
  if (fieldInfo.dataType === 'Reference' && fieldInfo.relationshipName === fieldName) {
2708
- return spanningFilter(fieldInfo, fieldNode, alias, input, joins);
2721
+ return spanningFilter(fieldInfo, fieldNode, alias, input, joins, draftFunctions);
2709
2722
  }
2723
+ const idProcessingNeeded = isIDValueField$1(fieldInfo);
2710
2724
  const extract = {
2711
2725
  type: ValueType.Extract,
2712
2726
  jsonAlias: alias,
@@ -2797,7 +2811,29 @@ function fieldFilter(fieldName, fieldNode, alias, apiName, input, joins) {
2797
2811
  children,
2798
2812
  };
2799
2813
  }
2800
- return comparison(extract, op.operator, op.value);
2814
+ const rightOperand = op.value;
2815
+ if (idProcessingNeeded) {
2816
+ if (isStringLiteral(rightOperand)) {
2817
+ if (rightOperand.value !== null) {
2818
+ if (draftFunctions.isDraftId(rightOperand.value)) {
2819
+ rightOperand.value = draftFunctions.getCanonicalId(rightOperand.value);
2820
+ }
2821
+ }
2822
+ }
2823
+ else if (isStringArray(rightOperand)) {
2824
+ if (rightOperand.value !== null) {
2825
+ rightOperand.value = rightOperand.value.map((originalId) => {
2826
+ if (originalId !== null) {
2827
+ if (draftFunctions.isDraftId(originalId)) {
2828
+ return draftFunctions.getCanonicalId(originalId);
2829
+ }
2830
+ }
2831
+ return originalId;
2832
+ });
2833
+ }
2834
+ }
2835
+ }
2836
+ return comparison(extract, op.operator, rightOperand);
2801
2837
  });
2802
2838
  const combined = combinePredicates(comparisons.concat(...dateFunction.value), CompoundOperator.and);
2803
2839
  const container = {
@@ -3899,7 +3935,7 @@ function recordQuery(selection, apiName, alias, predicates, input) {
3899
3935
  const orderByJoins = [];
3900
3936
  const orderByResult = parseOrderBy(orderByArg, alias, apiName, input.objectInfoMap, orderByJoins);
3901
3937
  const filterJoins = [];
3902
- const whereResult = recordFilter(whereArg, alias, apiName, input.objectInfoMap, filterJoins);
3938
+ const whereResult = recordFilter(whereArg, alias, apiName, input.objectInfoMap, filterJoins, input.draftFunctions);
3903
3939
  const scopeJoins = [];
3904
3940
  const scopeResult = scopeFilter(scopeArg, alias, apiName, input, scopeJoins);
3905
3941
  let additionalPredicates = [];
@@ -4061,27 +4097,19 @@ function generateVariableGQLQuery(document, variables) {
4061
4097
  ? node.arguments
4062
4098
  .map((args) => {
4063
4099
  const { value, name } = args;
4100
+ //The variable is on the top level, for example `where: ${filter}`
4064
4101
  if (is(value, 'Variable')) {
4065
- const variable = variables[value.name];
4066
- if (variable) {
4067
- const jsonString = JSON.stringify(variable);
4068
- const buildRecordQueryString = (name, query, transform) => {
4069
- return `${name}: ${transform(query)}`;
4070
- };
4071
- switch (name) {
4072
- case 'scope':
4073
- case 'orderBy':
4074
- return buildRecordQueryString(name, jsonString, removeAllQuotations);
4075
- default:
4076
- return buildRecordQueryString(name, jsonString, removeQuotationsFromKeys);
4077
- }
4078
- }
4079
- return '';
4102
+ return generateVariableNodeQuery(value, name, name, variables);
4103
+ }
4104
+ else if (isObjectValueNode$1(value)) {
4105
+ return generateVariableSubQuery(value, name, name, variables);
4080
4106
  }
4081
4107
  })
4082
4108
  .filter(Boolean)
4083
4109
  : undefined;
4084
- return gqlArguments ? `${node.name}(${gqlArguments.join(',')}) { Id }` : '';
4110
+ return gqlArguments
4111
+ ? `${node.name} ${gqlArguments.length > 0 ? '(' + gqlArguments.join(',') + ')' : ''} { Id }`
4112
+ : '';
4085
4113
  })
4086
4114
  //remove empty strings
4087
4115
  .filter(Boolean)
@@ -4091,6 +4119,51 @@ function generateVariableGQLQuery(document, variables) {
4091
4119
  return [accu.slice(0, 1), query, accu.slice(1, length)].join('');
4092
4120
  }, '{ }'));
4093
4121
  }
4122
+ /**
4123
+ * Given a LuvioValueNode, generates a sql with its variable node replaced with actual value.
4124
+ * @param valueNode G
4125
+ * @param name
4126
+ * @param type
4127
+ * @param variables
4128
+ * @returns
4129
+ */
4130
+ function generateVariableSubQuery(valueNode, name, type, variables) {
4131
+ switch (valueNode.kind) {
4132
+ case Kind.OBJECT: {
4133
+ // For example, `{ Id: { eq: $draftId } }` is a `ObjectValueNode`, which has field keys 'Id'
4134
+ const resultQuery = keys$5(valueNode.fields)
4135
+ .map((key) => generateVariableSubQuery(valueNode.fields[key], key, type, variables))
4136
+ .filter((subquery) => subquery.length > 0)
4137
+ .join(',');
4138
+ if (resultQuery.length > 0) {
4139
+ return `${name}: {${resultQuery}}`;
4140
+ }
4141
+ return resultQuery;
4142
+ }
4143
+ case Kind.VARIABLE:
4144
+ return generateVariableNodeQuery(valueNode, name, type, variables);
4145
+ default:
4146
+ return '';
4147
+ }
4148
+ }
4149
+ // Generate a sql for the variable node with its actual value.
4150
+ function generateVariableNodeQuery(value, name, type, variables) {
4151
+ const variable = variables[value.name];
4152
+ if (variable) {
4153
+ const jsonString = JSON.stringify(variable);
4154
+ const buildRecordQueryString = (name, query, transform) => {
4155
+ return `${name}: ${transform(query)}`;
4156
+ };
4157
+ switch (type) {
4158
+ case 'scope':
4159
+ case 'orderBy':
4160
+ return buildRecordQueryString(name, jsonString, removeAllQuotations);
4161
+ default:
4162
+ return buildRecordQueryString(name, jsonString, removeQuotationsFromKeys);
4163
+ }
4164
+ }
4165
+ return '';
4166
+ }
4094
4167
  /**
4095
4168
  * Given an AST with variables
4096
4169
  * Swap out the LuvioArgumentNodes on the original AST with ones generated from its variables.
@@ -4109,14 +4182,43 @@ function swapVariableArguments(document, variables) {
4109
4182
  const { name } = node;
4110
4183
  const first = allArgumentRecords.find((n) => n.name === name);
4111
4184
  if (first) {
4112
- // if we had arguments that did not contain variables we still want those
4113
- first.arguments = flatten$1(first.arguments
4114
- ? first.arguments.filter((x) => x.value.kind !== 'Variable')
4115
- : [], node.arguments ? node.arguments : []);
4185
+ const swappedArgments = swapArgumentWithVariableNodes(node.arguments, first.arguments);
4186
+ first.arguments = swappedArgments ? swappedArgments : [];
4116
4187
  }
4117
4188
  });
4118
4189
  }
4119
4190
  }
4191
+ // Replaces the variable node in original LuvioArgumentNode with the actual value in the swapped node with the same path.
4192
+ function swapArgumentWithVariableNodes(swapped, original) {
4193
+ if (swapped === undefined || original === undefined) {
4194
+ return original;
4195
+ }
4196
+ return original.map((x) => {
4197
+ const targetNode = swapped.find((y) => y.name === x.name);
4198
+ if (targetNode === undefined) {
4199
+ return x;
4200
+ }
4201
+ if (x.value.kind === 'Variable') {
4202
+ return targetNode;
4203
+ }
4204
+ swapValueNodeWithVariableNodes(x.value, targetNode.value);
4205
+ return x;
4206
+ });
4207
+ }
4208
+ function swapValueNodeWithVariableNodes(original, swapped) {
4209
+ if (original.kind === Kind.OBJECT) {
4210
+ for (const key of keys$5(original.fields)) {
4211
+ if (isObjectValueNode$1(swapped) && swapped.fields[key]) {
4212
+ if (is(original.fields[key], 'Variable')) {
4213
+ original.fields[key] = swapped.fields[key];
4214
+ }
4215
+ else {
4216
+ swapValueNodeWithVariableNodes(original.fields[key], swapped.fields[key]);
4217
+ }
4218
+ }
4219
+ }
4220
+ }
4221
+ }
4120
4222
  //find top level record queries
4121
4223
  function findRecordSelections(document) {
4122
4224
  return document.definitions
@@ -4151,7 +4253,7 @@ class StoreEvalPreconditioner {
4151
4253
  * Missing object info records triggers the objectInfoService (same instance shared with Drafts code), to
4152
4254
  * use the getObjectInfos adapter to efficiently fetch the necessary records.
4153
4255
  */
4154
- async createRootQuery(config, objectInfoService, userId) {
4256
+ async createRootQuery(config, objectInfoService, userId, draftFunctions) {
4155
4257
  const { query: ast, variables } = config;
4156
4258
  swapVariableArguments(ast, variables);
4157
4259
  // Parse out top-level record queries types we know we will need, since spanning fields will
@@ -4198,6 +4300,7 @@ class StoreEvalPreconditioner {
4198
4300
  astTransformResult = transform(ast, {
4199
4301
  userId,
4200
4302
  objectInfoMap,
4303
+ draftFunctions,
4201
4304
  });
4202
4305
  if (astTransformResult.isSuccess === false) {
4203
4306
  for (const error of astTransformResult.error) {
@@ -4235,8 +4338,6 @@ class StoreEvalPreconditioner {
4235
4338
  }
4236
4339
  }
4237
4340
 
4238
- const { isArray: isArray$4 } = Array;
4239
-
4240
4341
  /**
4241
4342
  * Checks a GraphQL-shaped network response for errors, returning true if it does
4242
4343
  * and false otherwise
@@ -4282,7 +4383,7 @@ const wrapStartEndEvents = (storeEval) => {
4282
4383
  return snapshot;
4283
4384
  };
4284
4385
  };
4285
- function sqliteStoreEvalFactory(userId, sqliteStore, objectInfoService) {
4386
+ function sqliteStoreEvalFactory(userId, sqliteStore, objectInfoService, draftFunctions) {
4286
4387
  // if the store does not support eval then use the noop version
4287
4388
  if (sqliteStore.isEvalSupported() === false) {
4288
4389
  return noopStoreEval;
@@ -4290,7 +4391,7 @@ function sqliteStoreEvalFactory(userId, sqliteStore, objectInfoService) {
4290
4391
  const preconditioner = new StoreEvalPreconditioner();
4291
4392
  return makeStoreEval(preconditioner, objectInfoService, userId, async () => {
4292
4393
  return undefined;
4293
- }, (query, _context, eventEmitter) => evaluateSqlite(query, eventEmitter, sqliteStore));
4394
+ }, (query, _context, eventEmitter) => evaluateSqlite(query, eventEmitter, sqliteStore), draftFunctions);
4294
4395
  }
4295
4396
  async function noopStoreEval(_config, nonEvaluatedSnapshotOrPromise, _observers) {
4296
4397
  return nonEvaluatedSnapshotOrPromise;
@@ -4309,7 +4410,7 @@ function isErrorSnapshotThatShouldGetReturnedToCaller$1(snapshot) {
4309
4410
  function generateUniqueRecordId$1() {
4310
4411
  return `${GRAPHQL_ROOT_KEY$1}${Date.now() + Math.random().toFixed(5).split('.')[1]}`;
4311
4412
  }
4312
- function makeStoreEval(preconditioner, objectInfoService, userId, contextProvider, queryEvaluator) {
4413
+ function makeStoreEval(preconditioner, objectInfoService, userId, contextProvider, queryEvaluator, draftFunctions) {
4313
4414
  const storeEval = async (config, nonEvaluatedSnapshotOrPromise, observers) => {
4314
4415
  const eventEmitter = createCustomAdapterEventEmitter(GRAPHQL_EVAL_NAMESPACE$1, observers);
4315
4416
  // the non-eval'ed input could either be a snapshot or promise of one so
@@ -4339,7 +4440,7 @@ function makeStoreEval(preconditioner, objectInfoService, userId, contextProvide
4339
4440
  context = await contextProvider();
4340
4441
  // Ensures ObjectInfo metadata is available for the request. Sourcing records from L1/L2/Network
4341
4442
  // is delegated to the getObjectInfo adapter via objectInfoService
4342
- rootQuery = await preconditioner.createRootQuery(config, objectInfoService, userId);
4443
+ rootQuery = await preconditioner.createRootQuery(config, objectInfoService, userId, draftFunctions);
4343
4444
  }
4344
4445
  catch (error) {
4345
4446
  eventEmitter({
@@ -15645,11 +15746,6 @@ function getRuntime() {
15645
15746
  getIngestMetadataForInternalAdapters =
15646
15747
  internalAdapterDurableEnvironment.getIngestStagingStoreRecords;
15647
15748
  lazyObjectInfoService = new ObjectInfoService(getObjectInfo, getObjectInfos, internalAdapterDurableStore);
15648
- // set storeEval function for lds-adapters-graghql to use
15649
- withRegistration('@salesforce/lds-adapters-graphql', (registration) => {
15650
- const { configuration: { setStoreEval }, } = registration;
15651
- setStoreEval(sqliteStoreEvalFactory(userId, lazyBaseDurableStore, lazyObjectInfoService));
15652
- });
15653
15749
  // creates a durable store that denormalizes scalar fields for records
15654
15750
  let getIngestRecords;
15655
15751
  let getIngestMetadata;
@@ -15688,6 +15784,20 @@ function getRuntime() {
15688
15784
  setupMobileInstrumentation(lazyLuvio, store);
15689
15785
  // If the inspection nimbus plugin is configured, inspection is enabled otherwise this is a no-op
15690
15786
  setupInspection(lazyLuvio);
15787
+ // set storeEval function for lds-adapters-graghql to use
15788
+ withRegistration('@salesforce/lds-adapters-graphql', (registration) => {
15789
+ const { configuration: { setStoreEval, setDraftFunctions }, } = registration;
15790
+ const getCanonicalId = (id) => {
15791
+ var _a;
15792
+ return ((_a = extractRecordIdFromStoreKey(lazyLuvio.storeGetCanonicalKey(RECORD_ID_PREFIX + id))) !== null && _a !== void 0 ? _a : id);
15793
+ };
15794
+ const draftFuncs = {
15795
+ isDraftId: isGenerated,
15796
+ getCanonicalId,
15797
+ };
15798
+ setStoreEval(sqliteStoreEvalFactory(userId, lazyBaseDurableStore, lazyObjectInfoService, draftFuncs));
15799
+ setDraftFunctions(draftFuncs);
15800
+ });
15691
15801
  // on core the graphql configuration is split so we need to set configureUIAPIGraphQL both in the
15692
15802
  // graphql registration and the uiapi for off core
15693
15803
  const configureUIAPIGraphQL = (registration) => {
@@ -15740,4 +15850,4 @@ register({
15740
15850
  });
15741
15851
 
15742
15852
  export { getRuntime, registerReportObserver, reportGraphqlQueryParseError };
15743
- // version: 1.136.6-0f5ec3ee7
15853
+ // version: 1.136.7-777657471