@salesforce/lds-worker-api 1.129.1 → 1.130.9

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.
@@ -761,4 +761,4 @@ if (process.env.NODE_ENV !== 'production') {
761
761
  }
762
762
 
763
763
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
764
- // version: 1.129.1-eb59a8867
764
+ // version: 1.130.9-2d38b9869
@@ -2057,24 +2057,24 @@ class GraphNode {
2057
2057
  object(propertyName) {
2058
2058
  const value = this.data[propertyName];
2059
2059
  if (isNodeLink(value)) {
2060
- throw new Error(`Cannot walk to path ${propertyName}. "${propertyName}" is a link: "${value}"`);
2060
+ throw new Error(`Cannot walk to path ${String(propertyName)}. "${String(propertyName)}" is a link: "${value}"`);
2061
2061
  }
2062
2062
  if (typeof value !== 'object' || value === null) {
2063
- throw new Error(`Cannot walk to path ${propertyName}. "${propertyName}" is a scalar: "${value}"`);
2063
+ throw new Error(`Cannot walk to path ${String(propertyName)}. "${String(propertyName)}" is a scalar: "${value}"`);
2064
2064
  }
2065
2065
  return new GraphNode(this.store, value);
2066
2066
  }
2067
2067
  link(propertyName) {
2068
2068
  const value = this.data[propertyName];
2069
2069
  if (!isNodeLink(value)) {
2070
- throw new Error(`Cannot walk to link ${propertyName}. "${propertyName}" is not a link: "${value}"`);
2070
+ throw new Error(`Cannot walk to link ${String(propertyName)}. "${String(propertyName)}" is not a link: "${value}"`);
2071
2071
  }
2072
2072
  return new GraphLink(this.store, value);
2073
2073
  }
2074
2074
  scalar(propertyName) {
2075
2075
  const value = this.data[propertyName];
2076
2076
  if (typeof value === 'object' && value !== null) {
2077
- throw new Error(`Cannot return value at path ${propertyName}. ${propertyName} is not a scalar.`);
2077
+ throw new Error(`Cannot return value at path ${String(propertyName)}. ${String(propertyName)} is not a scalar.`);
2078
2078
  }
2079
2079
  return value;
2080
2080
  }
@@ -3649,7 +3649,7 @@ class Luvio {
3649
3649
  return this.environment.buildStructuredKey(namespace, representationName, idValues);
3650
3650
  }
3651
3651
  }
3652
- // engine version: 0.138.3-dee50acf
3652
+ // engine version: 0.138.8-480e18f2
3653
3653
 
3654
3654
  /**
3655
3655
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -3776,7 +3776,7 @@ function withDefaultLuvio(callback) {
3776
3776
  }
3777
3777
  callbacks.push(callback);
3778
3778
  }
3779
- // version: 1.129.1-eb59a8867
3779
+ // version: 1.130.9-2d38b9869
3780
3780
 
3781
3781
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3782
3782
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15200,7 +15200,7 @@ function parseAndVisit(source) {
15200
15200
  updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
15201
15201
  return luvioDocumentNode;
15202
15202
  }
15203
- // version: 1.129.1-eb59a8867
15203
+ // version: 1.130.9-2d38b9869
15204
15204
 
15205
15205
  function unwrap(data) {
15206
15206
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16113,7 +16113,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
16113
16113
  const { apiFamily, name } = metadata;
16114
16114
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16115
16115
  }
16116
- // version: 1.129.1-eb59a8867
16116
+ // version: 1.130.9-2d38b9869
16117
16117
 
16118
16118
  /**
16119
16119
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -16196,7 +16196,7 @@ var FragmentReadResultState;
16196
16196
  ({
16197
16197
  state: FragmentReadResultState.Missing,
16198
16198
  });
16199
- // engine version: 0.138.3-dee50acf
16199
+ // engine version: 0.138.8-480e18f2
16200
16200
 
16201
16201
  const { keys: ObjectKeys$3, freeze: ObjectFreeze$3, create: ObjectCreate$3 } = Object;
16202
16202
 
@@ -40515,7 +40515,7 @@ function ingestAndBroadcast(luvio, key, config, body) {
40515
40515
  return buildCachedSnapshot$5(luvio, config);
40516
40516
  });
40517
40517
  }
40518
- function clone(userLayoutState) {
40518
+ function clone$1(userLayoutState) {
40519
40519
  return parse$7(stringify$7(userLayoutState));
40520
40520
  }
40521
40521
  // Applies optimisticUpdate to layoutUserState
@@ -40538,7 +40538,7 @@ function optimisticUpdate(cachedLayoutUserState, layoutUserStateInput) {
40538
40538
  if (clonedLayoutUserState === undefined) {
40539
40539
  // We have to clone cachedLayoutUserState because this object is coming from
40540
40540
  // a snapshot, where it is frozen
40541
- clonedLayoutUserState = clone(cachedLayoutUserState);
40541
+ clonedLayoutUserState = clone$1(cachedLayoutUserState);
40542
40542
  // hold onto sectionUserStates from clonedLayoutUserState
40543
40543
  clonedLayoutUserStateSections = clonedLayoutUserState.sectionUserStates;
40544
40544
  }
@@ -44412,7 +44412,7 @@ withDefaultLuvio((luvio) => {
44412
44412
  dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
44413
44413
  });
44414
44414
  });
44415
- // version: 1.129.1-e413ee547
44415
+ // version: 1.130.9-a2fbc710a
44416
44416
 
44417
44417
  var caseSensitiveUserId = '005B0000000GR4OIAW';
44418
44418
 
@@ -45680,7 +45680,8 @@ function makeDurable(environment, { durableStore, instrumentation }) {
45680
45680
  for (const cacheKeyMapKey of cacheKeyMapKeys) {
45681
45681
  const cacheKey = cacheKeyMap.get(cacheKeyMapKey);
45682
45682
  if (cacheKey.mergeable === true) {
45683
- keysToRevive.add(cacheKeyMapKey);
45683
+ const canonical = environment.storeGetCanonicalKey(cacheKeyMapKey);
45684
+ keysToRevive.add(canonical);
45684
45685
  }
45685
45686
  }
45686
45687
  let snapshotFromMemoryIngest = undefined;
@@ -46536,6 +46537,7 @@ const recordPrefix = '.data.uiapi.query';
46536
46537
  const recordSuffix = 'edges';
46537
46538
  const pathPrefix = '$';
46538
46539
  const recordsCTE = 'recordsCTE';
46540
+ const MultiPickListValueSeparator$1 = ';';
46539
46541
  function cteSql() {
46540
46542
  return (`WITH ${recordsCTE} AS NOT materialized ` +
46541
46543
  `(select data from lds_data where key like 'UiApi::RecordRepresentation:%')`);
@@ -46704,16 +46706,26 @@ function existsPredicateToSql(exists) {
46704
46706
  }
46705
46707
  function comparisonPredicateToSql(predicate) {
46706
46708
  const operator = comparisonOperatorToSql(predicate.operator);
46707
- const { sql: left, bindings: leftBindings } = expressionToSql(predicate.left);
46709
+ let { sql: left, bindings: leftBindings } = expressionToSql(predicate.left, undefined, predicate.operator);
46708
46710
  if (predicate.right.type === ValueType.DateEnum ||
46709
46711
  predicate.right.type === ValueType.DateTimeEnum ||
46710
46712
  predicate.right.type === ValueType.DateArray ||
46711
46713
  predicate.right.type === ValueType.DateTimeArray ||
46712
- predicate.right.type === ValueType.DateValue) {
46713
- const fieldDateValue = `date(${left})`;
46714
+ predicate.right.type === ValueType.DateValue ||
46715
+ predicate.right.type === ValueType.DateTimeValue) {
46716
+ const dateFunction = predicate.right.type === ValueType.DateTimeEnum ||
46717
+ predicate.right.type === ValueType.DateTimeArray ||
46718
+ predicate.right.type === ValueType.DateTimeValue
46719
+ ? 'datetime'
46720
+ : 'date';
46721
+ const fieldDateValue = `${dateFunction}(${left})`;
46714
46722
  return comparisonDateLiteralToSql(fieldDateValue, predicate.operator, predicate.right);
46715
46723
  }
46716
- const { sql: right, bindings: rightBindings } = expressionToSql(predicate.right);
46724
+ if (predicate.right.type === ValueType.RelativeDate) {
46725
+ const dateFunc = predicate.right.hasTime ? 'datetime' : 'date';
46726
+ left = `${dateFunc}(${left})`;
46727
+ }
46728
+ const { sql: right, bindings: rightBindings } = expressionToSql(predicate.right, undefined, predicate.operator);
46717
46729
  let bindings = leftBindings.concat(rightBindings);
46718
46730
  if (predicate.operator === ComparisonOperator.eq &&
46719
46731
  predicate.right.type === ValueType.StringLiteral &&
@@ -46798,11 +46810,21 @@ function coerceToTargetDataType(initialSql, targetDataType) {
46798
46810
  return initialSql;
46799
46811
  }
46800
46812
  }
46801
- function expressionToSql(expression, targetDataType) {
46813
+ function expressionToSql(expression, targetDataType, operator) {
46802
46814
  switch (expression.type) {
46803
46815
  case ValueType.Extract: {
46816
+ // displayValue's for Booleans are special, they return null
46817
+ if (expression.subfield === 'displayValue' && targetDataType === 'Boolean') {
46818
+ return { sql: 'null', bindings: [] };
46819
+ }
46804
46820
  let path = extractPath(expression.field, expression.subfield);
46805
- let sql = `json_extract("${expression.jsonAlias}.JSON", '${pathPrefix}.${path}')`;
46821
+ // For multiple picklist includes/excluding filtering, we need to prefix and suffix the field value with ';'
46822
+ // to make the match safe.
46823
+ // sample: field value: 'item12;item123', input value is 'item1'; they need to be converted to
46824
+ // ';item12;item123;' and '%;item1;%' first, then do sqlite like operation.
46825
+ let sql = operator === ComparisonOperator.includes || operator === ComparisonOperator.excludes
46826
+ ? `'${MultiPickListValueSeparator$1}' || json_extract("${expression.jsonAlias}.JSON", '${pathPrefix}.${path}') || '${MultiPickListValueSeparator$1}'`
46827
+ : `json_extract("${expression.jsonAlias}.JSON", '${pathPrefix}.${path}')`;
46806
46828
  if (targetDataType !== undefined) {
46807
46829
  sql = coerceToTargetDataType(sql, targetDataType);
46808
46830
  }
@@ -46849,7 +46871,7 @@ function expressionToSql(expression, targetDataType) {
46849
46871
  case ValueType.StringLiteral:
46850
46872
  return stringLiteralToSql(expression);
46851
46873
  case ValueType.MultiPicklistSet:
46852
- return multiPicklistToSql$1(expression);
46874
+ return multiPicklistToSql$1(expression, operator);
46853
46875
  }
46854
46876
  }
46855
46877
  function stringLiteralToSql(string) {
@@ -46865,14 +46887,18 @@ function expressionArrayToSql(expressions, toSql) {
46865
46887
  const bindings = results.length > 0 ? results.map((v) => v.bindings).reduce(flatten$1) : [];
46866
46888
  return { sql, bindings };
46867
46889
  }
46868
- function multiPicklistToSql$1({ value }) {
46890
+ function multiPicklistToSql$1({ value }, operator) {
46869
46891
  // Individual multipicklist terms that delimited by semicolon are stored server-side
46870
46892
  // as lexically sorted strings and treated like logical ANDs. We can approximate this
46871
46893
  // behavior in SQL with wildcarded `LIKE` SQL operators. Terms with no delimiter can
46872
46894
  // be treated as string literals. Multiple terms are logically OR'd together to
46873
46895
  // match the behavior described in SOQL documentation (https://sfdc.co/c9j0r)
46896
+ // To make sure the match is safe for includes/excludes. the value is prefix and
46897
+ // suffix with ';', like 'abc' to '%;abc;%'. raw value for eq and ne.
46874
46898
  const sql = '?';
46875
- const binding = value && value.includes(';') ? `'%${value.split(';').join('%')}%'` : `'%${value}%'`;
46899
+ const binding = operator === ComparisonOperator.includes || operator === ComparisonOperator.excludes
46900
+ ? `%${MultiPickListValueSeparator$1}${value}${MultiPickListValueSeparator$1}%`
46901
+ : value;
46876
46902
  return { sql, bindings: [binding] };
46877
46903
  }
46878
46904
  function relativeDateToSql(expression) {
@@ -46943,8 +46969,12 @@ function comparisonDateLiteralToSql(leftOperand, operator, dateInput) {
46943
46969
  }
46944
46970
  }
46945
46971
  if (dateInput.type === ValueType.DateValue || dateInput.type === ValueType.DateTimeValue) {
46972
+ const dateFunction = dateInput.type === ValueType.DateTimeValue ? 'datetime' : 'date';
46946
46973
  const compOperator = comparisonOperatorToSql(operator);
46947
- return { sql: leftOperand + ` ${compOperator} ` + '?', bindings: [`${dateInput.value}`] };
46974
+ return {
46975
+ sql: leftOperand + ` ${compOperator} ` + `${dateFunction}(?)`,
46976
+ bindings: [`${dateInput.value}`],
46977
+ };
46948
46978
  }
46949
46979
  return { sql: '', bindings: [] };
46950
46980
  }
@@ -47175,15 +47205,41 @@ function fieldFilter(fieldName, fieldNode, alias, apiName, input, joins) {
47175
47205
  return dateRangeComparison(op.value, op.operator, extract);
47176
47206
  }
47177
47207
  if (op.type === 'MultiPicklistSetOperator') {
47208
+ const operator = op.operator === ComparisonOperator.includes
47209
+ ? CompoundOperator.or
47210
+ : CompoundOperator.and;
47211
+ const children = [];
47212
+ const length = op.value.value.length;
47213
+ for (let i = 0; i < length; i++) {
47214
+ const term = op.value.value[i];
47215
+ if (term !== null) {
47216
+ const splittedValue = term.split(MultiPickListValueSeparator$1);
47217
+ if (splittedValue.length === 1) {
47218
+ children.push(comparison(extract, op.operator, {
47219
+ type: ValueType.MultiPicklistSet,
47220
+ value: term,
47221
+ }));
47222
+ }
47223
+ else {
47224
+ children.push({
47225
+ type: PredicateType$1.compound,
47226
+ operator: op.operator === ComparisonOperator.includes
47227
+ ? CompoundOperator.and
47228
+ : CompoundOperator.or,
47229
+ children: splittedValue.map((singleValue) => {
47230
+ return comparison(extract, op.operator, {
47231
+ type: ValueType.MultiPicklistSet,
47232
+ value: singleValue,
47233
+ });
47234
+ }),
47235
+ });
47236
+ }
47237
+ }
47238
+ }
47178
47239
  return {
47179
47240
  type: PredicateType$1.compound,
47180
- operator: CompoundOperator.or,
47181
- children: op.value.value.map((term) => {
47182
- return comparison(extract, op.operator, {
47183
- type: ValueType.MultiPicklistSet,
47184
- value: term,
47185
- });
47186
- }),
47241
+ operator,
47242
+ children,
47187
47243
  };
47188
47244
  }
47189
47245
  if (op.type === 'StringSetOperator' && op.value.value.includes(null)) {
@@ -47247,8 +47303,6 @@ function dateRangeComparison(dateRange, operator, compareDate) {
47247
47303
  return comparison(compareDate, gte, dateRange.start);
47248
47304
  }
47249
47305
  }
47250
- const dateRegEx = /^([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))$/;
47251
- const dateTimeRegEx = /^([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))T(2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9](\.[0-9]{3})?Z$/;
47252
47306
  function dateFunctions(operatorNode, extract, dataType) {
47253
47307
  if (dataType !== 'Date' && dataType !== 'DateTime') {
47254
47308
  return success([]);
@@ -47326,7 +47380,7 @@ function isStringOperatorType(value) {
47326
47380
  return isScalarOperatorType(value) || value === like;
47327
47381
  }
47328
47382
  function isPicklistOperatorType(value) {
47329
- let values = [eq, ne];
47383
+ let values = [eq, ne, like, lt, gt, lte, gte];
47330
47384
  return values.includes(value);
47331
47385
  }
47332
47386
  function isCurrencyOperatorType(value) {
@@ -47677,8 +47731,11 @@ function operatorWithValue(operator, valueNode, objectInfoDataType) {
47677
47731
  message(`Comparison operator ${operator} is not supported for type ${objectInfoDataType}.`),
47678
47732
  ]);
47679
47733
  }
47734
+ function isValidDate(value) {
47735
+ return isNaN(Date.parse(value)) === false;
47736
+ }
47680
47737
  function dateInput(node) {
47681
- return parseDateNode(node, dateRegEx, false, 'YYYY-MM-DD').map((result) => {
47738
+ return parseDateNode(node, false, 'YYYY-MM-DD', isValidDate).map((result) => {
47682
47739
  switch (result.type) {
47683
47740
  case ValueType.NullValue:
47684
47741
  return result;
@@ -47692,7 +47749,7 @@ function dateInput(node) {
47692
47749
  });
47693
47750
  }
47694
47751
  function dateTimeInput(node) {
47695
- return parseDateNode(node, dateTimeRegEx, true, 'YYYY-MM-DDTHH:MM:SS.SSSZ or YYYY-MM-DDTHH:MM:SSZ').map((result) => {
47752
+ return parseDateNode(node, true, 'YYYY-MM-DDTHH:MM:SS.SSSZ, YYYY-MM-DDTHH:MM:SSZ, YYYY-MM-DDTHH:MM:SS.SSS+|-HH:MM, or YYYY-MM-DDTHH:MM:SS+|-HH:MM', isValidDate).map((result) => {
47696
47753
  switch (result.type) {
47697
47754
  case ValueType.NullValue:
47698
47755
  return result;
@@ -47717,7 +47774,7 @@ function parseNullValue(op) {
47717
47774
  }
47718
47775
  return failure(message(`Null can not be compared with ${op}`));
47719
47776
  }
47720
- function parseDateNode(node, regex, hasTime, dateFormat) {
47777
+ function parseDateNode(node, hasTime, dateFormat, isValidDate) {
47721
47778
  const typeName = hasTime ? 'DateTime' : 'Date';
47722
47779
  if (!isObjectValueNode$1(node)) {
47723
47780
  return failure(message(`Comparison value must be a ${typeName} input.`));
@@ -47725,7 +47782,12 @@ function parseDateNode(node, regex, hasTime, dateFormat) {
47725
47782
  const valueField = node.fields.value;
47726
47783
  if (valueField !== undefined) {
47727
47784
  if (is(valueField, 'StringValue')) {
47728
- if (valueField.value.match(regex)) {
47785
+ // check the date is valid
47786
+ // then make sure if it isnt suppose to contain time stamps that it doesnt
47787
+ // and if it should have a timestamp it should contain it
47788
+ const includesTimeStamp = valueField.value.includes('T');
47789
+ if (isValidDate(valueField.value) &&
47790
+ ((hasTime && includesTimeStamp) || (!hasTime && !includesTimeStamp))) {
47729
47791
  return success(stringLiteral(valueField.value));
47730
47792
  }
47731
47793
  return failure(message(`${typeName} format must be ${dateFormat}.`));
@@ -48717,7 +48779,20 @@ function makeStoreEval(preconditioner, objectInfoService, userId, contextProvide
48717
48779
  // await it here to normalize the input to a snapshot
48718
48780
  const nonEvaluatedSnapshot = await nonEvaluatedSnapshotOrPromise;
48719
48781
  // if the non-eval result has errors we want to return to caller
48720
- if (isErrorSnapshotThatShouldGetReturnedToCaller$1(nonEvaluatedSnapshot)) {
48782
+ const nonEvaluatedGQLSnapshot = nonEvaluatedSnapshot;
48783
+ if (isErrorSnapshotThatShouldGetReturnedToCaller$1(nonEvaluatedGQLSnapshot)) {
48784
+ const { data: gqlData } = nonEvaluatedGQLSnapshot;
48785
+ if (hasGraphQlErrors$1(gqlData) && gqlData !== undefined) {
48786
+ return {
48787
+ ...nonEvaluatedSnapshot,
48788
+ data: undefined,
48789
+ state: 'Error',
48790
+ error: {
48791
+ errorType: 'adapterError',
48792
+ error: gqlData.errors,
48793
+ },
48794
+ };
48795
+ }
48721
48796
  return nonEvaluatedSnapshot;
48722
48797
  }
48723
48798
  let rootQuery;
@@ -55374,6 +55449,10 @@ function makeEnvironmentUiApiRecordDraftAware(luvio, options, env) {
55374
55449
  return create$2$1(adapterSpecificEnvironments, {});
55375
55450
  }
55376
55451
 
55452
+ function clone(obj) {
55453
+ return parse$2(stringify$2(obj));
55454
+ }
55455
+
55377
55456
  const DEFAULT_FIELD_CREATED_BY_ID = 'CreatedById';
55378
55457
  const DEFAULT_FIELD_CREATED_DATE = 'CreatedDate';
55379
55458
  const DEFAULT_FIELD_ID = 'Id';
@@ -55401,7 +55480,9 @@ function replayDraftsOnRecord(record, draftMetadata) {
55401
55480
  // no baseRecord
55402
55481
  return undefined;
55403
55482
  }
55404
- const { recordOperations } = draftMetadata;
55483
+ const { recordOperations: originalOperations } = draftMetadata;
55484
+ // since replaying drafts is destructive, we need to clone the original operations
55485
+ const recordOperations = clone(originalOperations);
55405
55486
  if (recordOperations.length === 0) {
55406
55487
  return undefined;
55407
55488
  }
@@ -55432,7 +55513,11 @@ function recursivelyApplyDraftsToRecord(record, draftMetadata, recordOperations)
55432
55513
  }
55433
55514
  const draftActionType = draftOperation.type;
55434
55515
  if (draftActionType === 'create') {
55435
- throw Error('a create action cannot exist on an existing record');
55516
+ if (record.drafts !== undefined) {
55517
+ throw Error('a create action cannot exist on an existing draft record');
55518
+ }
55519
+ // the draft may have been uploaded already so skip the create operation and apply the rest (if any)
55520
+ return recursivelyApplyDraftsToRecord(record, draftMetadata, recordOperations);
55436
55521
  }
55437
55522
  // add the draft node
55438
55523
  if (record.drafts === undefined) {
@@ -56195,6 +56280,11 @@ function makeRecordDenormalizingDurableStore(luvio, durableStore, getStoreRecord
56195
56280
  let record = entry && entry.data;
56196
56281
  if (record === undefined) {
56197
56282
  record = storeRecords[recordKey];
56283
+ if (record === undefined) {
56284
+ // fields are being published without a record for them existing,
56285
+ // fields cannot exist standalone in the durable store
56286
+ continue;
56287
+ }
56198
56288
  }
56199
56289
  putRecords[recordId] = true;
56200
56290
  if (isStoreRecordError(record)) {
@@ -59934,7 +60024,7 @@ register({
59934
60024
  id: '@salesforce/lds-network-adapter',
59935
60025
  instrument: instrument$1,
59936
60026
  });
59937
- // version: 1.129.1-eb59a8867
60027
+ // version: 1.130.9-2d38b9869
59938
60028
 
59939
60029
  const { create: create$2, keys: keys$2 } = Object;
59940
60030
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -60244,16 +60334,27 @@ function trimEdges(edges, startOffset, endOffset) {
60244
60334
  return trimmedEdges;
60245
60335
  }
60246
60336
  function optimizePagination(metadata, firstArgName, afterArgName, variables) {
60247
- if (typeof metadata === 'object' && metadata !== null && offsetFromToken(metadata, variables[afterArgName]) >= 0) {
60337
+ if (typeof metadata === 'object' && metadata !== null) {
60338
+ const requestedAfterCursor = variables[afterArgName];
60339
+ const afterCursorOffset = offsetFromToken(metadata, requestedAfterCursor);
60248
60340
  // optimize only if after cursor is unspecified in the request or it's already loaded in metadata
60249
- const length = Object.keys(metadata).length;
60250
- const lastTokenAndOffset = tokenForAtMost(metadata, length);
60251
- if (lastTokenAndOffset !== undefined) {
60252
- const [token, offset] = lastTokenAndOffset;
60253
- variables[firstArgName + '_original'] = variables[firstArgName];
60254
- variables[afterArgName + '_original'] = variables[afterArgName];
60255
- variables[firstArgName] -= variables[afterArgName] === null ? (offset + 1) : (offset - 1);
60256
- variables[afterArgName] = token;
60341
+ if (afterCursorOffset >= 0) {
60342
+ const requestedItems = variables[firstArgName];
60343
+ const atMostOffset = afterCursorOffset + requestedItems; // The largest offset we care about for this page.
60344
+ const lastTokenAndOffset = tokenForAtMost(metadata, atMostOffset);
60345
+ if (lastTokenAndOffset !== undefined) {
60346
+ const [token, offset] = lastTokenAndOffset;
60347
+ const isSubpage = atMostOffset === offset; // We already have all the cursors we seem to need
60348
+ const isExactPagination = atMostOffset === offset + requestedItems; // Using the last cursor we have to paginate
60349
+ if (!(isSubpage || isExactPagination)) { // If we're asking for more than we have, only request what we're missing.
60350
+ const existingItems = afterCursorOffset === 0 ? offset + 1 : offset - afterCursorOffset;
60351
+ const itemsToRequest = requestedItems - existingItems;
60352
+ variables[firstArgName + '_original'] = requestedItems;
60353
+ variables[firstArgName] = itemsToRequest;
60354
+ variables[afterArgName + '_original'] = requestedAfterCursor;
60355
+ variables[afterArgName] = token;
60356
+ }
60357
+ }
60257
60358
  }
60258
60359
  }
60259
60360
  }
@@ -66491,7 +66592,13 @@ function ingestPaginationMetadata(astNode, state, key, sink, existingData) {
66491
66592
  : 0;
66492
66593
  const nextOffset = startOffset + edges.length;
66493
66594
  const incomingPaginationMetadata = createPaginationMetadata(startOffset, edges);
66494
- if (!hasNextPage) {
66595
+ if (hasNextPage) {
66596
+ // Cleanup any __END__ cursors that are before than the newly ingested page
66597
+ if (existingPaginationMetadata !== undefined && existingPaginationMetadata.__END__ !== undefined && existingPaginationMetadata.__END__ < nextOffset) {
66598
+ delete existingPaginationMetadata.__END__;
66599
+ }
66600
+ }
66601
+ else {
66495
66602
  incomingPaginationMetadata.__END__ = nextOffset;
66496
66603
  }
66497
66604
  // store the updated pagination metadata
@@ -72768,6 +72875,25 @@ function selectTypeLink(sel, fieldData, reader, key, sink, variables, fragments,
72768
72875
  reader.markMissing();
72769
72876
  }
72770
72877
  }
72878
+ function augmentDefaultVariableValues(variableDefinitions, variables) {
72879
+ variableDefinitions.forEach(({ defaultValue, variable }) => {
72880
+ if (defaultValue !== undefined && variables[variable.name.value] === undefined) {
72881
+ switch (defaultValue.kind) {
72882
+ case ("IntValue"):
72883
+ case ("FloatValue"):
72884
+ variables[variable.name.value] = Number(defaultValue.value);
72885
+ break;
72886
+ case ("NullValue"):
72887
+ variables[variable.name.value] = null;
72888
+ break;
72889
+ case ("BooleanValue"):
72890
+ case ("StringValue"):
72891
+ case ("EnumValue"):
72892
+ variables[variable.name.value] = defaultValue.value;
72893
+ }
72894
+ }
72895
+ });
72896
+ }
72771
72897
  function selectTypeLinkWithPagination(resolvedLink, sel, fieldData, reader, key, sink, variables, fragments, selectFn) {
72772
72898
  var _a, _b, _c, _d, _e;
72773
72899
  const source = resolvedLink.data.data;
@@ -72935,6 +73061,9 @@ function select$8(luvio, query, variables) {
72935
73061
  }
72936
73062
  function ingestOperationNode(luvio, input, node, state) {
72937
73063
  if (node.operation === 'query') {
73064
+ if (node.variableDefinitions !== undefined) {
73065
+ augmentDefaultVariableValues(node.variableDefinitions, state.variables);
73066
+ }
72938
73067
  ingest$1(node, {
72939
73068
  ...state,
72940
73069
  path: {
@@ -74203,7 +74332,7 @@ register({
74203
74332
  configuration: { ...configurationForGraphQLAdapters },
74204
74333
  instrument,
74205
74334
  });
74206
- // version: 1.129.1-e413ee547
74335
+ // version: 1.130.9-a2fbc710a
74207
74336
 
74208
74337
  // On core the unstable adapters are re-exported with different names,
74209
74338
 
@@ -76332,7 +76461,7 @@ withDefaultLuvio((luvio) => {
76332
76461
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
76333
76462
  graphQLImperative = ldsAdapter;
76334
76463
  });
76335
- // version: 1.129.1-e413ee547
76464
+ // version: 1.130.9-a2fbc710a
76336
76465
 
76337
76466
  var gqlApi = /*#__PURE__*/Object.freeze({
76338
76467
  __proto__: null,
@@ -77024,4 +77153,4 @@ const { luvio } = getRuntime();
77024
77153
  setDefaultLuvio({ luvio });
77025
77154
 
77026
77155
  export { createPrimingSession, draftManager, draftQueue, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, invokeAdapter, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, subscribeToAdapter };
77027
- // version: 1.129.1-eb59a8867
77156
+ // version: 1.130.9-2d38b9869
@@ -2063,24 +2063,24 @@
2063
2063
  object(propertyName) {
2064
2064
  const value = this.data[propertyName];
2065
2065
  if (isNodeLink(value)) {
2066
- throw new Error(`Cannot walk to path ${propertyName}. "${propertyName}" is a link: "${value}"`);
2066
+ throw new Error(`Cannot walk to path ${String(propertyName)}. "${String(propertyName)}" is a link: "${value}"`);
2067
2067
  }
2068
2068
  if (typeof value !== 'object' || value === null) {
2069
- throw new Error(`Cannot walk to path ${propertyName}. "${propertyName}" is a scalar: "${value}"`);
2069
+ throw new Error(`Cannot walk to path ${String(propertyName)}. "${String(propertyName)}" is a scalar: "${value}"`);
2070
2070
  }
2071
2071
  return new GraphNode(this.store, value);
2072
2072
  }
2073
2073
  link(propertyName) {
2074
2074
  const value = this.data[propertyName];
2075
2075
  if (!isNodeLink(value)) {
2076
- throw new Error(`Cannot walk to link ${propertyName}. "${propertyName}" is not a link: "${value}"`);
2076
+ throw new Error(`Cannot walk to link ${String(propertyName)}. "${String(propertyName)}" is not a link: "${value}"`);
2077
2077
  }
2078
2078
  return new GraphLink(this.store, value);
2079
2079
  }
2080
2080
  scalar(propertyName) {
2081
2081
  const value = this.data[propertyName];
2082
2082
  if (typeof value === 'object' && value !== null) {
2083
- throw new Error(`Cannot return value at path ${propertyName}. ${propertyName} is not a scalar.`);
2083
+ throw new Error(`Cannot return value at path ${String(propertyName)}. ${String(propertyName)} is not a scalar.`);
2084
2084
  }
2085
2085
  return value;
2086
2086
  }
@@ -3655,7 +3655,7 @@
3655
3655
  return this.environment.buildStructuredKey(namespace, representationName, idValues);
3656
3656
  }
3657
3657
  }
3658
- // engine version: 0.138.3-dee50acf
3658
+ // engine version: 0.138.8-480e18f2
3659
3659
 
3660
3660
  /**
3661
3661
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -3782,7 +3782,7 @@
3782
3782
  }
3783
3783
  callbacks.push(callback);
3784
3784
  }
3785
- // version: 1.129.1-eb59a8867
3785
+ // version: 1.130.9-2d38b9869
3786
3786
 
3787
3787
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
3788
3788
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -15206,7 +15206,7 @@
15206
15206
  updateReferenceMapWithKnownKey(ast, luvioDocumentNode);
15207
15207
  return luvioDocumentNode;
15208
15208
  }
15209
- // version: 1.129.1-eb59a8867
15209
+ // version: 1.130.9-2d38b9869
15210
15210
 
15211
15211
  function unwrap(data) {
15212
15212
  // The lwc-luvio bindings import a function from lwc called "unwrap".
@@ -16119,7 +16119,7 @@
16119
16119
  const { apiFamily, name } = metadata;
16120
16120
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
16121
16121
  }
16122
- // version: 1.129.1-eb59a8867
16122
+ // version: 1.130.9-2d38b9869
16123
16123
 
16124
16124
  /**
16125
16125
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -16202,7 +16202,7 @@
16202
16202
  ({
16203
16203
  state: FragmentReadResultState.Missing,
16204
16204
  });
16205
- // engine version: 0.138.3-dee50acf
16205
+ // engine version: 0.138.8-480e18f2
16206
16206
 
16207
16207
  const { keys: ObjectKeys$3, freeze: ObjectFreeze$3, create: ObjectCreate$3 } = Object;
16208
16208
 
@@ -40521,7 +40521,7 @@
40521
40521
  return buildCachedSnapshot$5(luvio, config);
40522
40522
  });
40523
40523
  }
40524
- function clone(userLayoutState) {
40524
+ function clone$1(userLayoutState) {
40525
40525
  return parse$7(stringify$7(userLayoutState));
40526
40526
  }
40527
40527
  // Applies optimisticUpdate to layoutUserState
@@ -40544,7 +40544,7 @@
40544
40544
  if (clonedLayoutUserState === undefined) {
40545
40545
  // We have to clone cachedLayoutUserState because this object is coming from
40546
40546
  // a snapshot, where it is frozen
40547
- clonedLayoutUserState = clone(cachedLayoutUserState);
40547
+ clonedLayoutUserState = clone$1(cachedLayoutUserState);
40548
40548
  // hold onto sectionUserStates from clonedLayoutUserState
40549
40549
  clonedLayoutUserStateSections = clonedLayoutUserState.sectionUserStates;
40550
40550
  }
@@ -44418,7 +44418,7 @@
44418
44418
  dropFunction: instrumentation$2.notifyRecordUpdateAvailableDropped,
44419
44419
  });
44420
44420
  });
44421
- // version: 1.129.1-e413ee547
44421
+ // version: 1.130.9-a2fbc710a
44422
44422
 
44423
44423
  var caseSensitiveUserId = '005B0000000GR4OIAW';
44424
44424
 
@@ -45686,7 +45686,8 @@
45686
45686
  for (const cacheKeyMapKey of cacheKeyMapKeys) {
45687
45687
  const cacheKey = cacheKeyMap.get(cacheKeyMapKey);
45688
45688
  if (cacheKey.mergeable === true) {
45689
- keysToRevive.add(cacheKeyMapKey);
45689
+ const canonical = environment.storeGetCanonicalKey(cacheKeyMapKey);
45690
+ keysToRevive.add(canonical);
45690
45691
  }
45691
45692
  }
45692
45693
  let snapshotFromMemoryIngest = undefined;
@@ -46542,6 +46543,7 @@
46542
46543
  const recordSuffix = 'edges';
46543
46544
  const pathPrefix = '$';
46544
46545
  const recordsCTE = 'recordsCTE';
46546
+ const MultiPickListValueSeparator$1 = ';';
46545
46547
  function cteSql() {
46546
46548
  return (`WITH ${recordsCTE} AS NOT materialized ` +
46547
46549
  `(select data from lds_data where key like 'UiApi::RecordRepresentation:%')`);
@@ -46710,16 +46712,26 @@
46710
46712
  }
46711
46713
  function comparisonPredicateToSql(predicate) {
46712
46714
  const operator = comparisonOperatorToSql(predicate.operator);
46713
- const { sql: left, bindings: leftBindings } = expressionToSql(predicate.left);
46715
+ let { sql: left, bindings: leftBindings } = expressionToSql(predicate.left, undefined, predicate.operator);
46714
46716
  if (predicate.right.type === ValueType.DateEnum ||
46715
46717
  predicate.right.type === ValueType.DateTimeEnum ||
46716
46718
  predicate.right.type === ValueType.DateArray ||
46717
46719
  predicate.right.type === ValueType.DateTimeArray ||
46718
- predicate.right.type === ValueType.DateValue) {
46719
- const fieldDateValue = `date(${left})`;
46720
+ predicate.right.type === ValueType.DateValue ||
46721
+ predicate.right.type === ValueType.DateTimeValue) {
46722
+ const dateFunction = predicate.right.type === ValueType.DateTimeEnum ||
46723
+ predicate.right.type === ValueType.DateTimeArray ||
46724
+ predicate.right.type === ValueType.DateTimeValue
46725
+ ? 'datetime'
46726
+ : 'date';
46727
+ const fieldDateValue = `${dateFunction}(${left})`;
46720
46728
  return comparisonDateLiteralToSql(fieldDateValue, predicate.operator, predicate.right);
46721
46729
  }
46722
- const { sql: right, bindings: rightBindings } = expressionToSql(predicate.right);
46730
+ if (predicate.right.type === ValueType.RelativeDate) {
46731
+ const dateFunc = predicate.right.hasTime ? 'datetime' : 'date';
46732
+ left = `${dateFunc}(${left})`;
46733
+ }
46734
+ const { sql: right, bindings: rightBindings } = expressionToSql(predicate.right, undefined, predicate.operator);
46723
46735
  let bindings = leftBindings.concat(rightBindings);
46724
46736
  if (predicate.operator === ComparisonOperator.eq &&
46725
46737
  predicate.right.type === ValueType.StringLiteral &&
@@ -46804,11 +46816,21 @@
46804
46816
  return initialSql;
46805
46817
  }
46806
46818
  }
46807
- function expressionToSql(expression, targetDataType) {
46819
+ function expressionToSql(expression, targetDataType, operator) {
46808
46820
  switch (expression.type) {
46809
46821
  case ValueType.Extract: {
46822
+ // displayValue's for Booleans are special, they return null
46823
+ if (expression.subfield === 'displayValue' && targetDataType === 'Boolean') {
46824
+ return { sql: 'null', bindings: [] };
46825
+ }
46810
46826
  let path = extractPath(expression.field, expression.subfield);
46811
- let sql = `json_extract("${expression.jsonAlias}.JSON", '${pathPrefix}.${path}')`;
46827
+ // For multiple picklist includes/excluding filtering, we need to prefix and suffix the field value with ';'
46828
+ // to make the match safe.
46829
+ // sample: field value: 'item12;item123', input value is 'item1'; they need to be converted to
46830
+ // ';item12;item123;' and '%;item1;%' first, then do sqlite like operation.
46831
+ let sql = operator === ComparisonOperator.includes || operator === ComparisonOperator.excludes
46832
+ ? `'${MultiPickListValueSeparator$1}' || json_extract("${expression.jsonAlias}.JSON", '${pathPrefix}.${path}') || '${MultiPickListValueSeparator$1}'`
46833
+ : `json_extract("${expression.jsonAlias}.JSON", '${pathPrefix}.${path}')`;
46812
46834
  if (targetDataType !== undefined) {
46813
46835
  sql = coerceToTargetDataType(sql, targetDataType);
46814
46836
  }
@@ -46855,7 +46877,7 @@
46855
46877
  case ValueType.StringLiteral:
46856
46878
  return stringLiteralToSql(expression);
46857
46879
  case ValueType.MultiPicklistSet:
46858
- return multiPicklistToSql$1(expression);
46880
+ return multiPicklistToSql$1(expression, operator);
46859
46881
  }
46860
46882
  }
46861
46883
  function stringLiteralToSql(string) {
@@ -46871,14 +46893,18 @@
46871
46893
  const bindings = results.length > 0 ? results.map((v) => v.bindings).reduce(flatten$1) : [];
46872
46894
  return { sql, bindings };
46873
46895
  }
46874
- function multiPicklistToSql$1({ value }) {
46896
+ function multiPicklistToSql$1({ value }, operator) {
46875
46897
  // Individual multipicklist terms that delimited by semicolon are stored server-side
46876
46898
  // as lexically sorted strings and treated like logical ANDs. We can approximate this
46877
46899
  // behavior in SQL with wildcarded `LIKE` SQL operators. Terms with no delimiter can
46878
46900
  // be treated as string literals. Multiple terms are logically OR'd together to
46879
46901
  // match the behavior described in SOQL documentation (https://sfdc.co/c9j0r)
46902
+ // To make sure the match is safe for includes/excludes. the value is prefix and
46903
+ // suffix with ';', like 'abc' to '%;abc;%'. raw value for eq and ne.
46880
46904
  const sql = '?';
46881
- const binding = value && value.includes(';') ? `'%${value.split(';').join('%')}%'` : `'%${value}%'`;
46905
+ const binding = operator === ComparisonOperator.includes || operator === ComparisonOperator.excludes
46906
+ ? `%${MultiPickListValueSeparator$1}${value}${MultiPickListValueSeparator$1}%`
46907
+ : value;
46882
46908
  return { sql, bindings: [binding] };
46883
46909
  }
46884
46910
  function relativeDateToSql(expression) {
@@ -46949,8 +46975,12 @@
46949
46975
  }
46950
46976
  }
46951
46977
  if (dateInput.type === ValueType.DateValue || dateInput.type === ValueType.DateTimeValue) {
46978
+ const dateFunction = dateInput.type === ValueType.DateTimeValue ? 'datetime' : 'date';
46952
46979
  const compOperator = comparisonOperatorToSql(operator);
46953
- return { sql: leftOperand + ` ${compOperator} ` + '?', bindings: [`${dateInput.value}`] };
46980
+ return {
46981
+ sql: leftOperand + ` ${compOperator} ` + `${dateFunction}(?)`,
46982
+ bindings: [`${dateInput.value}`],
46983
+ };
46954
46984
  }
46955
46985
  return { sql: '', bindings: [] };
46956
46986
  }
@@ -47181,15 +47211,41 @@
47181
47211
  return dateRangeComparison(op.value, op.operator, extract);
47182
47212
  }
47183
47213
  if (op.type === 'MultiPicklistSetOperator') {
47214
+ const operator = op.operator === ComparisonOperator.includes
47215
+ ? CompoundOperator.or
47216
+ : CompoundOperator.and;
47217
+ const children = [];
47218
+ const length = op.value.value.length;
47219
+ for (let i = 0; i < length; i++) {
47220
+ const term = op.value.value[i];
47221
+ if (term !== null) {
47222
+ const splittedValue = term.split(MultiPickListValueSeparator$1);
47223
+ if (splittedValue.length === 1) {
47224
+ children.push(comparison(extract, op.operator, {
47225
+ type: ValueType.MultiPicklistSet,
47226
+ value: term,
47227
+ }));
47228
+ }
47229
+ else {
47230
+ children.push({
47231
+ type: PredicateType$1.compound,
47232
+ operator: op.operator === ComparisonOperator.includes
47233
+ ? CompoundOperator.and
47234
+ : CompoundOperator.or,
47235
+ children: splittedValue.map((singleValue) => {
47236
+ return comparison(extract, op.operator, {
47237
+ type: ValueType.MultiPicklistSet,
47238
+ value: singleValue,
47239
+ });
47240
+ }),
47241
+ });
47242
+ }
47243
+ }
47244
+ }
47184
47245
  return {
47185
47246
  type: PredicateType$1.compound,
47186
- operator: CompoundOperator.or,
47187
- children: op.value.value.map((term) => {
47188
- return comparison(extract, op.operator, {
47189
- type: ValueType.MultiPicklistSet,
47190
- value: term,
47191
- });
47192
- }),
47247
+ operator,
47248
+ children,
47193
47249
  };
47194
47250
  }
47195
47251
  if (op.type === 'StringSetOperator' && op.value.value.includes(null)) {
@@ -47253,8 +47309,6 @@
47253
47309
  return comparison(compareDate, gte, dateRange.start);
47254
47310
  }
47255
47311
  }
47256
- const dateRegEx = /^([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))$/;
47257
- const dateTimeRegEx = /^([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))T(2[0-3]|[01][0-9]):[0-5][0-9]:[0-5][0-9](\.[0-9]{3})?Z$/;
47258
47312
  function dateFunctions(operatorNode, extract, dataType) {
47259
47313
  if (dataType !== 'Date' && dataType !== 'DateTime') {
47260
47314
  return success([]);
@@ -47332,7 +47386,7 @@
47332
47386
  return isScalarOperatorType(value) || value === like;
47333
47387
  }
47334
47388
  function isPicklistOperatorType(value) {
47335
- let values = [eq, ne];
47389
+ let values = [eq, ne, like, lt, gt, lte, gte];
47336
47390
  return values.includes(value);
47337
47391
  }
47338
47392
  function isCurrencyOperatorType(value) {
@@ -47683,8 +47737,11 @@
47683
47737
  message(`Comparison operator ${operator} is not supported for type ${objectInfoDataType}.`),
47684
47738
  ]);
47685
47739
  }
47740
+ function isValidDate(value) {
47741
+ return isNaN(Date.parse(value)) === false;
47742
+ }
47686
47743
  function dateInput(node) {
47687
- return parseDateNode(node, dateRegEx, false, 'YYYY-MM-DD').map((result) => {
47744
+ return parseDateNode(node, false, 'YYYY-MM-DD', isValidDate).map((result) => {
47688
47745
  switch (result.type) {
47689
47746
  case ValueType.NullValue:
47690
47747
  return result;
@@ -47698,7 +47755,7 @@
47698
47755
  });
47699
47756
  }
47700
47757
  function dateTimeInput(node) {
47701
- return parseDateNode(node, dateTimeRegEx, true, 'YYYY-MM-DDTHH:MM:SS.SSSZ or YYYY-MM-DDTHH:MM:SSZ').map((result) => {
47758
+ return parseDateNode(node, true, 'YYYY-MM-DDTHH:MM:SS.SSSZ, YYYY-MM-DDTHH:MM:SSZ, YYYY-MM-DDTHH:MM:SS.SSS+|-HH:MM, or YYYY-MM-DDTHH:MM:SS+|-HH:MM', isValidDate).map((result) => {
47702
47759
  switch (result.type) {
47703
47760
  case ValueType.NullValue:
47704
47761
  return result;
@@ -47723,7 +47780,7 @@
47723
47780
  }
47724
47781
  return failure(message(`Null can not be compared with ${op}`));
47725
47782
  }
47726
- function parseDateNode(node, regex, hasTime, dateFormat) {
47783
+ function parseDateNode(node, hasTime, dateFormat, isValidDate) {
47727
47784
  const typeName = hasTime ? 'DateTime' : 'Date';
47728
47785
  if (!isObjectValueNode$1(node)) {
47729
47786
  return failure(message(`Comparison value must be a ${typeName} input.`));
@@ -47731,7 +47788,12 @@
47731
47788
  const valueField = node.fields.value;
47732
47789
  if (valueField !== undefined) {
47733
47790
  if (is(valueField, 'StringValue')) {
47734
- if (valueField.value.match(regex)) {
47791
+ // check the date is valid
47792
+ // then make sure if it isnt suppose to contain time stamps that it doesnt
47793
+ // and if it should have a timestamp it should contain it
47794
+ const includesTimeStamp = valueField.value.includes('T');
47795
+ if (isValidDate(valueField.value) &&
47796
+ ((hasTime && includesTimeStamp) || (!hasTime && !includesTimeStamp))) {
47735
47797
  return success(stringLiteral(valueField.value));
47736
47798
  }
47737
47799
  return failure(message(`${typeName} format must be ${dateFormat}.`));
@@ -48723,7 +48785,20 @@
48723
48785
  // await it here to normalize the input to a snapshot
48724
48786
  const nonEvaluatedSnapshot = await nonEvaluatedSnapshotOrPromise;
48725
48787
  // if the non-eval result has errors we want to return to caller
48726
- if (isErrorSnapshotThatShouldGetReturnedToCaller$1(nonEvaluatedSnapshot)) {
48788
+ const nonEvaluatedGQLSnapshot = nonEvaluatedSnapshot;
48789
+ if (isErrorSnapshotThatShouldGetReturnedToCaller$1(nonEvaluatedGQLSnapshot)) {
48790
+ const { data: gqlData } = nonEvaluatedGQLSnapshot;
48791
+ if (hasGraphQlErrors$1(gqlData) && gqlData !== undefined) {
48792
+ return {
48793
+ ...nonEvaluatedSnapshot,
48794
+ data: undefined,
48795
+ state: 'Error',
48796
+ error: {
48797
+ errorType: 'adapterError',
48798
+ error: gqlData.errors,
48799
+ },
48800
+ };
48801
+ }
48727
48802
  return nonEvaluatedSnapshot;
48728
48803
  }
48729
48804
  let rootQuery;
@@ -55380,6 +55455,10 @@
55380
55455
  return create$2$1(adapterSpecificEnvironments, {});
55381
55456
  }
55382
55457
 
55458
+ function clone(obj) {
55459
+ return parse$2(stringify$2(obj));
55460
+ }
55461
+
55383
55462
  const DEFAULT_FIELD_CREATED_BY_ID = 'CreatedById';
55384
55463
  const DEFAULT_FIELD_CREATED_DATE = 'CreatedDate';
55385
55464
  const DEFAULT_FIELD_ID = 'Id';
@@ -55407,7 +55486,9 @@
55407
55486
  // no baseRecord
55408
55487
  return undefined;
55409
55488
  }
55410
- const { recordOperations } = draftMetadata;
55489
+ const { recordOperations: originalOperations } = draftMetadata;
55490
+ // since replaying drafts is destructive, we need to clone the original operations
55491
+ const recordOperations = clone(originalOperations);
55411
55492
  if (recordOperations.length === 0) {
55412
55493
  return undefined;
55413
55494
  }
@@ -55438,7 +55519,11 @@
55438
55519
  }
55439
55520
  const draftActionType = draftOperation.type;
55440
55521
  if (draftActionType === 'create') {
55441
- throw Error('a create action cannot exist on an existing record');
55522
+ if (record.drafts !== undefined) {
55523
+ throw Error('a create action cannot exist on an existing draft record');
55524
+ }
55525
+ // the draft may have been uploaded already so skip the create operation and apply the rest (if any)
55526
+ return recursivelyApplyDraftsToRecord(record, draftMetadata, recordOperations);
55442
55527
  }
55443
55528
  // add the draft node
55444
55529
  if (record.drafts === undefined) {
@@ -56201,6 +56286,11 @@
56201
56286
  let record = entry && entry.data;
56202
56287
  if (record === undefined) {
56203
56288
  record = storeRecords[recordKey];
56289
+ if (record === undefined) {
56290
+ // fields are being published without a record for them existing,
56291
+ // fields cannot exist standalone in the durable store
56292
+ continue;
56293
+ }
56204
56294
  }
56205
56295
  putRecords[recordId] = true;
56206
56296
  if (isStoreRecordError(record)) {
@@ -59940,7 +60030,7 @@
59940
60030
  id: '@salesforce/lds-network-adapter',
59941
60031
  instrument: instrument$1,
59942
60032
  });
59943
- // version: 1.129.1-eb59a8867
60033
+ // version: 1.130.9-2d38b9869
59944
60034
 
59945
60035
  const { create: create$2, keys: keys$2 } = Object;
59946
60036
  const { stringify: stringify$1, parse: parse$1 } = JSON;
@@ -60250,16 +60340,27 @@
60250
60340
  return trimmedEdges;
60251
60341
  }
60252
60342
  function optimizePagination(metadata, firstArgName, afterArgName, variables) {
60253
- if (typeof metadata === 'object' && metadata !== null && offsetFromToken(metadata, variables[afterArgName]) >= 0) {
60343
+ if (typeof metadata === 'object' && metadata !== null) {
60344
+ const requestedAfterCursor = variables[afterArgName];
60345
+ const afterCursorOffset = offsetFromToken(metadata, requestedAfterCursor);
60254
60346
  // optimize only if after cursor is unspecified in the request or it's already loaded in metadata
60255
- const length = Object.keys(metadata).length;
60256
- const lastTokenAndOffset = tokenForAtMost(metadata, length);
60257
- if (lastTokenAndOffset !== undefined) {
60258
- const [token, offset] = lastTokenAndOffset;
60259
- variables[firstArgName + '_original'] = variables[firstArgName];
60260
- variables[afterArgName + '_original'] = variables[afterArgName];
60261
- variables[firstArgName] -= variables[afterArgName] === null ? (offset + 1) : (offset - 1);
60262
- variables[afterArgName] = token;
60347
+ if (afterCursorOffset >= 0) {
60348
+ const requestedItems = variables[firstArgName];
60349
+ const atMostOffset = afterCursorOffset + requestedItems; // The largest offset we care about for this page.
60350
+ const lastTokenAndOffset = tokenForAtMost(metadata, atMostOffset);
60351
+ if (lastTokenAndOffset !== undefined) {
60352
+ const [token, offset] = lastTokenAndOffset;
60353
+ const isSubpage = atMostOffset === offset; // We already have all the cursors we seem to need
60354
+ const isExactPagination = atMostOffset === offset + requestedItems; // Using the last cursor we have to paginate
60355
+ if (!(isSubpage || isExactPagination)) { // If we're asking for more than we have, only request what we're missing.
60356
+ const existingItems = afterCursorOffset === 0 ? offset + 1 : offset - afterCursorOffset;
60357
+ const itemsToRequest = requestedItems - existingItems;
60358
+ variables[firstArgName + '_original'] = requestedItems;
60359
+ variables[firstArgName] = itemsToRequest;
60360
+ variables[afterArgName + '_original'] = requestedAfterCursor;
60361
+ variables[afterArgName] = token;
60362
+ }
60363
+ }
60263
60364
  }
60264
60365
  }
60265
60366
  }
@@ -66497,7 +66598,13 @@
66497
66598
  : 0;
66498
66599
  const nextOffset = startOffset + edges.length;
66499
66600
  const incomingPaginationMetadata = createPaginationMetadata(startOffset, edges);
66500
- if (!hasNextPage) {
66601
+ if (hasNextPage) {
66602
+ // Cleanup any __END__ cursors that are before than the newly ingested page
66603
+ if (existingPaginationMetadata !== undefined && existingPaginationMetadata.__END__ !== undefined && existingPaginationMetadata.__END__ < nextOffset) {
66604
+ delete existingPaginationMetadata.__END__;
66605
+ }
66606
+ }
66607
+ else {
66501
66608
  incomingPaginationMetadata.__END__ = nextOffset;
66502
66609
  }
66503
66610
  // store the updated pagination metadata
@@ -72774,6 +72881,25 @@
72774
72881
  reader.markMissing();
72775
72882
  }
72776
72883
  }
72884
+ function augmentDefaultVariableValues(variableDefinitions, variables) {
72885
+ variableDefinitions.forEach(({ defaultValue, variable }) => {
72886
+ if (defaultValue !== undefined && variables[variable.name.value] === undefined) {
72887
+ switch (defaultValue.kind) {
72888
+ case ("IntValue"):
72889
+ case ("FloatValue"):
72890
+ variables[variable.name.value] = Number(defaultValue.value);
72891
+ break;
72892
+ case ("NullValue"):
72893
+ variables[variable.name.value] = null;
72894
+ break;
72895
+ case ("BooleanValue"):
72896
+ case ("StringValue"):
72897
+ case ("EnumValue"):
72898
+ variables[variable.name.value] = defaultValue.value;
72899
+ }
72900
+ }
72901
+ });
72902
+ }
72777
72903
  function selectTypeLinkWithPagination(resolvedLink, sel, fieldData, reader, key, sink, variables, fragments, selectFn) {
72778
72904
  var _a, _b, _c, _d, _e;
72779
72905
  const source = resolvedLink.data.data;
@@ -72941,6 +73067,9 @@
72941
73067
  }
72942
73068
  function ingestOperationNode(luvio, input, node, state) {
72943
73069
  if (node.operation === 'query') {
73070
+ if (node.variableDefinitions !== undefined) {
73071
+ augmentDefaultVariableValues(node.variableDefinitions, state.variables);
73072
+ }
72944
73073
  ingest$1(node, {
72945
73074
  ...state,
72946
73075
  path: {
@@ -74209,7 +74338,7 @@
74209
74338
  configuration: { ...configurationForGraphQLAdapters },
74210
74339
  instrument,
74211
74340
  });
74212
- // version: 1.129.1-e413ee547
74341
+ // version: 1.130.9-a2fbc710a
74213
74342
 
74214
74343
  // On core the unstable adapters are re-exported with different names,
74215
74344
 
@@ -76338,7 +76467,7 @@
76338
76467
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
76339
76468
  graphQLImperative = ldsAdapter;
76340
76469
  });
76341
- // version: 1.129.1-e413ee547
76470
+ // version: 1.130.9-a2fbc710a
76342
76471
 
76343
76472
  var gqlApi = /*#__PURE__*/Object.freeze({
76344
76473
  __proto__: null,
@@ -77047,4 +77176,4 @@
77047
77176
  Object.defineProperty(exports, '__esModule', { value: true });
77048
77177
 
77049
77178
  }));
77050
- // version: 1.129.1-eb59a8867
77179
+ // version: 1.130.9-2d38b9869
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/lds-worker-api",
3
- "version": "1.129.1",
3
+ "version": "1.130.9",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "description": "",
6
6
  "main": "dist/standalone/es/lds-worker-api.js",