@salesforce/lds-worker-api 1.383.0 → 1.384.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4274,7 +4274,7 @@ function withDefaultLuvio(callback) {
4274
4274
  }
4275
4275
  callbacks.push(callback);
4276
4276
  }
4277
- // version: 1.383.0-b9875fc4e1
4277
+ // version: 1.384.0-cb845692ac
4278
4278
 
4279
4279
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4280
4280
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -5318,7 +5318,7 @@ function createGraphQLWireAdapterConstructor(luvio, adapter, metadata, astResolv
5318
5318
  const { apiFamily, name } = metadata;
5319
5319
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
5320
5320
  }
5321
- // version: 1.383.0-b9875fc4e1
5321
+ // version: 1.384.0-cb845692ac
5322
5322
 
5323
5323
  /**
5324
5324
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -34154,7 +34154,7 @@ withDefaultLuvio((luvio) => {
34154
34154
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
34155
34155
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
34156
34156
  });
34157
- // version: 1.383.0-d85dce8db1
34157
+ // version: 1.384.0-835fd13f44
34158
34158
 
34159
34159
  function requestIdleDetectedCallback(_callback) { }
34160
34160
  function declareNotifierTaskSingle(_name) {
@@ -81030,6 +81030,16 @@ function reportAggressiveTrimTriggered(trimCount, beforeTrimRecordCount, totalRe
81030
81030
  ldsMobileInstrumentation$2.trackValue(GARBAGE_COLLECTION_AGGRESSIVE_TRIM_TOTAL_RECORDS_BEFORE_TRIM, beforeTrimRecordCount);
81031
81031
  ldsMobileInstrumentation$2.trackValue(GARBAGE_COLLECTION_AGGRESSIVE_TRIM_RECORDS_TRIMMED, totalRecordsTrimmed);
81032
81032
  }
81033
+ /** One Store Cache Purge */
81034
+ const ONESTORE_CACHE_PURGING_RECORDS_PURGED = 'onestore-cache-purging-records-purged';
81035
+ const ONESTORE_CACHE_PURGING_RECORDS_ERROR = 'onestore-cache-purging-records-error';
81036
+ function reportOneStoreRecordsPurgedFromCache(recordsPurged) {
81037
+ ldsMobileInstrumentation$2.trackValue(ONESTORE_CACHE_PURGING_RECORDS_PURGED, recordsPurged);
81038
+ }
81039
+ function reportOneStoreCachePurgingError(error) {
81040
+ const errorMessage = normalizeError$1(error);
81041
+ ldsMobileInstrumentation$2.error(errorMessage, ONESTORE_CACHE_PURGING_RECORDS_ERROR);
81042
+ }
81033
81043
 
81034
81044
  const QUICK_ACTION_HANDLER = 'QUICK_ACTION_HANDLER';
81035
81045
  class QuickActionExecutionRepresentationHandler extends AbstractQuickActionHandler {
@@ -94268,7 +94278,7 @@ class CacheControlRequestRunner {
94268
94278
  }
94269
94279
  requestFromNetwork() {
94270
94280
  const that = this;
94271
- return async function* () {
94281
+ return (async function* () {
94272
94282
  const result = await that.requestFromNetworkInternal();
94273
94283
  if (result.isErr()) {
94274
94284
  that.networkError = result;
@@ -94276,7 +94286,7 @@ class CacheControlRequestRunner {
94276
94286
  that.networkData = result;
94277
94287
  }
94278
94288
  yield result;
94279
- }();
94289
+ })();
94280
94290
  }
94281
94291
  writeToCache(cache, networkResult) {
94282
94292
  return this.writeToCacheInternal(cache, networkResult);
@@ -95881,7 +95891,7 @@ function buildServiceDescriptor$5(luvio) {
95881
95891
  },
95882
95892
  };
95883
95893
  }
95884
- // version: 1.383.0-d85dce8db1
95894
+ // version: 1.384.0-835fd13f44
95885
95895
 
95886
95896
  /**
95887
95897
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -95907,7 +95917,7 @@ function buildServiceDescriptor$4(notifyRecordUpdateAvailable, getNormalizedLuvi
95907
95917
  },
95908
95918
  };
95909
95919
  }
95910
- // version: 1.383.0-d85dce8db1
95920
+ // version: 1.384.0-835fd13f44
95911
95921
 
95912
95922
  /*!
95913
95923
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -96752,7 +96762,7 @@ function hasMultilineItems(maybeArray) {
96752
96762
  * All rights reserved.
96753
96763
  * For full license text, see the LICENSE.txt file
96754
96764
  */
96755
- function findExecutableOperation$1(input) {
96765
+ function findExecutableOperation$2(input) {
96756
96766
  const operations = input.query.definitions.filter(
96757
96767
  (def) => def.kind === Kind$2.OPERATION_DEFINITION
96758
96768
  );
@@ -96775,7 +96785,7 @@ function findExecutableOperation$1(input) {
96775
96785
  return err$1$1(new Error("Multiple operations found in query, and no operation name provided"));
96776
96786
  }
96777
96787
  function buildGraphQLInputExtension$1(input) {
96778
- const operationResult = findExecutableOperation$1(input);
96788
+ const operationResult = findExecutableOperation$2(input);
96779
96789
  if (operationResult.isErr()) {
96780
96790
  return err$1$1(operationResult.error);
96781
96791
  }
@@ -97812,6 +97822,7 @@ class NimbusSqliteOneStoreCache {
97812
97822
  }
97813
97823
  }
97814
97824
 
97825
+ const PURGE_CACHE_DAYS = 30;
97815
97826
  // TODO[@W-18753648]: These services depend on WebApis that aren't available in the worker.
97816
97827
  // import { buildServiceDescriptor as buildNdJsonServiceDescriptor } from '@luvio/command-ndjson/v1';
97817
97828
  // import { buildServiceDescriptor as buildStreamingCommandServiceDescriptor } from '@luvio/command-streaming/v1';
@@ -97860,6 +97871,48 @@ function initializeOneStore(sqliteStore) {
97860
97871
  // buildSseCommandServiceDescriptor(),
97861
97872
  ];
97862
97873
  setServices(services);
97874
+ purgeDurableCacheByDays(PURGE_CACHE_DAYS, sqliteStore);
97875
+ }
97876
+ /**
97877
+ * Manually purges the OneStore cache by days.
97878
+ * Until we have real cache eviction in one store.
97879
+ *
97880
+ * @param days - The number of days to purge the cache by.
97881
+ * @param sqliteStore - The SqliteStorePlugin to purge the cache from.
97882
+ */
97883
+ async function purgeDurableCacheByDays(days, sqliteStore) {
97884
+ const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
97885
+ const cutoffTimestamp = Date.now() - days * MILLISECONDS_PER_DAY;
97886
+ try {
97887
+ // This has to be ran in a SELECT since the DELETE query may not support return on SQLite version in mobile
97888
+ const countQuery = `
97889
+ SELECT COUNT(*) FROM lds_one_store_data
97890
+ WHERE json_extract(metadata, '$.cacheControl.generatedTime') < ?
97891
+ `;
97892
+ const countResult = await queryAsync(sqliteStore, countQuery, [cutoffTimestamp]);
97893
+ const deleteCount = countResult.rows[0][0];
97894
+ if (deleteCount === 0) {
97895
+ reportOneStoreRecordsPurgedFromCache(0);
97896
+ return;
97897
+ }
97898
+ const deleteQuery = `
97899
+ DELETE FROM lds_one_store_data
97900
+ WHERE json_extract(metadata, '$.cacheControl.generatedTime') < ?
97901
+ `;
97902
+ await queryAsync(sqliteStore, deleteQuery, [cutoffTimestamp]);
97903
+ reportOneStoreRecordsPurgedFromCache(deleteCount);
97904
+ }
97905
+ catch (error) {
97906
+ reportOneStoreCachePurgingError(error);
97907
+ }
97908
+ }
97909
+ /**
97910
+ * Promisified wrapper for SqliteStorePlugin.query
97911
+ */
97912
+ function queryAsync(sqliteStore, sql, params) {
97913
+ return new Promise((resolve, reject) => {
97914
+ sqliteStore.query(sql, params, (result) => resolve(result), (error) => reject(error));
97915
+ });
97863
97916
  }
97864
97917
 
97865
97918
  // so eslint doesn't complain about nimbus
@@ -98064,7 +98117,7 @@ register$1({
98064
98117
  id: '@salesforce/lds-network-adapter',
98065
98118
  instrument: instrument$2,
98066
98119
  });
98067
- // version: 1.383.0-b9875fc4e1
98120
+ // version: 1.384.0-cb845692ac
98068
98121
 
98069
98122
  const { create: create$3, keys: keys$3 } = Object;
98070
98123
  const { stringify: stringify$1, parse } = JSON;
@@ -98984,7 +99037,7 @@ function deepMerge$2(target, ...sources) {
98984
99037
  }
98985
99038
  return target;
98986
99039
  }
98987
- function findExecutableOperation(input) {
99040
+ function findExecutableOperation$1(input) {
98988
99041
  const operations = input.query.definitions.filter(
98989
99042
  (def) => def.kind === Kind.OPERATION_DEFINITION
98990
99043
  );
@@ -99007,7 +99060,7 @@ function findExecutableOperation(input) {
99007
99060
  return err$3(new Error("Multiple operations found in query, and no operation name provided"));
99008
99061
  }
99009
99062
  function buildGraphQLInputExtension(input) {
99010
- const operationResult = findExecutableOperation(input);
99063
+ const operationResult = findExecutableOperation$1(input);
99011
99064
  if (operationResult.isErr()) {
99012
99065
  return err$3(operationResult.error);
99013
99066
  }
@@ -99032,14 +99085,24 @@ function buildGraphQLInputExtension(input) {
99032
99085
  parentFieldSelection: void 0
99033
99086
  });
99034
99087
  }
99035
- function buildUniqueAugmentedFieldSelection(newSelection, selections, fragments) {
99088
+ function buildAugmentedFieldSelection(newSelection, selections, fragments) {
99036
99089
  var _a;
99090
+ if (selectionExists(newSelection, selections)) {
99091
+ return void 0;
99092
+ }
99037
99093
  const baseAlias = ((_a = newSelection.alias) == null ? void 0 : _a.value) || newSelection.name.value;
99038
99094
  const baseInjectedAlias = `framework_augmented_${baseAlias}`;
99039
- const fieldName = getUniqueSelectionName(baseInjectedAlias, selections, fragments);
99040
- if (fieldName === newSelection.name.value) {
99041
- return newSelection;
99095
+ const baseAliasedSelection = {
99096
+ ...newSelection,
99097
+ alias: {
99098
+ kind: Kind.NAME,
99099
+ value: baseInjectedAlias
99100
+ }
99101
+ };
99102
+ if (selectionExists(baseAliasedSelection, selections)) {
99103
+ return void 0;
99042
99104
  }
99105
+ const fieldName = getUniqueSelectionName(baseInjectedAlias, selections, fragments);
99043
99106
  return {
99044
99107
  ...newSelection,
99045
99108
  alias: {
@@ -99048,6 +99111,94 @@ function buildUniqueAugmentedFieldSelection(newSelection, selections, fragments)
99048
99111
  }
99049
99112
  };
99050
99113
  }
99114
+ function selectionExists(selection, selections) {
99115
+ return selections.some((s) => selectionEquals(selection, s));
99116
+ }
99117
+ function selectionEquals(a, b) {
99118
+ var _a, _b, _c, _d, _e, _f;
99119
+ if (a.kind !== b.kind) {
99120
+ return false;
99121
+ }
99122
+ if (a.kind === Kind.FIELD) {
99123
+ const bField = b;
99124
+ return !!(a.name.value === bField.name.value) && !!(((_a = a.alias) == null ? void 0 : _a.value) === ((_b = bField.alias) == null ? void 0 : _b.value)) && argumentsEqual(a.arguments, bField.arguments) && selectionSetsEqual((_c = a.selectionSet) == null ? void 0 : _c.selections, (_d = bField.selectionSet) == null ? void 0 : _d.selections) && directivesEqual(a.directives, bField.directives);
99125
+ }
99126
+ if (a.kind === Kind.FRAGMENT_SPREAD) {
99127
+ const bFragmentSpread = b;
99128
+ return a.name.value === bFragmentSpread.name.value && directivesEqual(a.directives, bFragmentSpread.directives);
99129
+ }
99130
+ const bInlineFragment = b;
99131
+ return a.typeCondition === bInlineFragment.typeCondition && directivesEqual(a.directives, bInlineFragment.directives) && selectionSetsEqual((_e = a.selectionSet) == null ? void 0 : _e.selections, (_f = bInlineFragment.selectionSet) == null ? void 0 : _f.selections);
99132
+ }
99133
+ function argumentValueEquals(a, b) {
99134
+ if (a.kind !== b.kind) {
99135
+ return false;
99136
+ }
99137
+ switch (a.kind) {
99138
+ case Kind.STRING:
99139
+ case Kind.INT:
99140
+ case Kind.FLOAT:
99141
+ case Kind.BOOLEAN:
99142
+ case Kind.ENUM:
99143
+ return a.value === b.value;
99144
+ case Kind.NULL:
99145
+ return true;
99146
+ case Kind.VARIABLE:
99147
+ return a.name.value === b.name.value;
99148
+ case Kind.LIST:
99149
+ const bList = b;
99150
+ if (a.values.length !== bList.values.length) {
99151
+ return false;
99152
+ }
99153
+ return a.values.every((val, index) => argumentValueEquals(val, bList.values[index]));
99154
+ case Kind.OBJECT:
99155
+ const bObject = b;
99156
+ if (a.fields.length !== bObject.fields.length) {
99157
+ return false;
99158
+ }
99159
+ return a.fields.every((field, index) => {
99160
+ const bField = bObject.fields[index];
99161
+ return field.name.value === bField.name.value && argumentValueEquals(field.value, bField.value);
99162
+ });
99163
+ default:
99164
+ return false;
99165
+ }
99166
+ }
99167
+ function directivesEqual(a, b) {
99168
+ if (a === void 0 && b === void 0) {
99169
+ return true;
99170
+ }
99171
+ if (a === void 0 || b === void 0) {
99172
+ return ((a == null ? void 0 : a.length) || 0) === ((b == null ? void 0 : b.length) || 0);
99173
+ }
99174
+ if (a.length !== b.length) {
99175
+ return false;
99176
+ }
99177
+ return a.every((directive, index) => {
99178
+ const bDirective = b[index];
99179
+ return directive.name.value === bDirective.name.value && argumentsEqual(directive.arguments, bDirective.arguments);
99180
+ });
99181
+ }
99182
+ function argumentsEqual(a, b) {
99183
+ if (a === void 0 && b === void 0) {
99184
+ return true;
99185
+ }
99186
+ if (a === void 0 || b === void 0) {
99187
+ return ((a == null ? void 0 : a.length) || 0) === ((b == null ? void 0 : b.length) || 0);
99188
+ }
99189
+ if (a.length !== b.length) {
99190
+ return false;
99191
+ }
99192
+ return a.every((arg, index) => {
99193
+ const bArg = b[index];
99194
+ return arg.name.value === bArg.name.value && argumentValueEquals(arg.value, bArg.value);
99195
+ });
99196
+ }
99197
+ function selectionSetsEqual(a, b) {
99198
+ return a === void 0 || b === void 0 || !!(a.length === b.length) && !!a.every((selection, index) => {
99199
+ return selectionEquals(selection, b[index]);
99200
+ });
99201
+ }
99051
99202
  function getUniqueSelectionName(fieldName, selections, fragments) {
99052
99203
  const fieldNames = collectFieldNames(selections, fragments);
99053
99204
  if (!fieldNames.includes(fieldName)) {
@@ -99422,19 +99573,20 @@ class BaseGraphQLTypeRepository {
99422
99573
  augmentedFragments = augmentedFragmentSelections.fragments;
99423
99574
  }
99424
99575
  }
99425
- augmentedSelections.push(
99426
- buildUniqueAugmentedFieldSelection(
99427
- {
99428
- kind: Kind.FIELD,
99429
- name: {
99430
- kind: Kind.NAME,
99431
- value: "__typename"
99432
- }
99433
- },
99434
- [...augmentedSelections, ...input.selections],
99435
- augmentedFragments
99436
- )
99576
+ const newTypenameSelection = buildAugmentedFieldSelection(
99577
+ {
99578
+ kind: Kind.FIELD,
99579
+ name: {
99580
+ kind: Kind.NAME,
99581
+ value: "__typename"
99582
+ }
99583
+ },
99584
+ [...augmentedSelections, ...input.selections],
99585
+ augmentedFragments
99437
99586
  );
99587
+ if (newTypenameSelection) {
99588
+ augmentedSelections.push(newTypenameSelection);
99589
+ }
99438
99590
  return { selections: augmentedSelections, fragments: augmentedFragments };
99439
99591
  }
99440
99592
  augmentFieldSelection(selection, fragments) {
@@ -99497,21 +99649,21 @@ class BaseGraphQLTypeRepository {
99497
99649
  fragment
99498
99650
  );
99499
99651
  if (satisfiedFragmentTypeConditionResult.isErr() || !satisfiedFragmentTypeConditionResult.value) {
99500
- return { selections: [], fragments };
99652
+ return { selections: [selection], fragments };
99501
99653
  }
99502
- const augmentedFragmentSelections = this.augmentSelections({
99654
+ const augmentedFragment = this.augmentSelections({
99503
99655
  selections: ((_a = fragment.selectionSet) == null ? void 0 : _a.selections) || [],
99504
99656
  fragments
99505
99657
  });
99506
99658
  return {
99507
99659
  selections: [selection],
99508
99660
  fragments: {
99509
- ...fragments,
99661
+ ...augmentedFragment.fragments,
99510
99662
  [fragment.name.value]: {
99511
99663
  ...fragment,
99512
99664
  selectionSet: {
99513
99665
  kind: Kind.SELECTION_SET,
99514
- selections: augmentedFragmentSelections.selections
99666
+ selections: augmentedFragment.selections
99515
99667
  }
99516
99668
  }
99517
99669
  }
@@ -99830,19 +99982,20 @@ class IdentifiableGraphQLTypeRepository extends IdentifiableTypeRepository {
99830
99982
  const result = super.augmentSelections(input);
99831
99983
  const augmentedSelections = result.selections;
99832
99984
  let augmentedFragments = result.fragments;
99833
- augmentedSelections.push(
99834
- buildUniqueAugmentedFieldSelection(
99835
- {
99836
- kind: Kind.FIELD,
99837
- name: {
99838
- kind: Kind.NAME,
99839
- value: this.idField
99840
- }
99841
- },
99842
- [...augmentedSelections, ...input.selections],
99843
- augmentedFragments
99844
- )
99985
+ const newSelection = buildAugmentedFieldSelection(
99986
+ {
99987
+ kind: Kind.FIELD,
99988
+ name: {
99989
+ kind: Kind.NAME,
99990
+ value: this.idField
99991
+ }
99992
+ },
99993
+ [...augmentedSelections, ...input.selections],
99994
+ augmentedFragments
99845
99995
  );
99996
+ if (newSelection) {
99997
+ augmentedSelections.push(newSelection);
99998
+ }
99846
99999
  return { selections: augmentedSelections, fragments: augmentedFragments };
99847
100000
  }
99848
100001
  };
@@ -99898,6 +100051,19 @@ class IdentifiableGraphQLTypeRepository extends IdentifiableTypeRepository {
99898
100051
  buildFieldKey(selection, variables) {
99899
100052
  return this.graphqlRepository.buildFieldKey(selection, variables);
99900
100053
  }
100054
+ buildKeyParams(input) {
100055
+ var _a;
100056
+ const idField = input.selections.find(
100057
+ (selection) => selection.kind === Kind.FIELD && selection.name.value === this.idField
100058
+ );
100059
+ if (!idField) {
100060
+ throw new Error(`Id field ${this.idField} not found in selections`);
100061
+ }
100062
+ const idFieldDataProperty = ((_a = idField.alias) == null ? void 0 : _a.value) || idField.name.value;
100063
+ return {
100064
+ [this.idField]: input.data[idFieldDataProperty]
100065
+ };
100066
+ }
99901
100067
  }
99902
100068
  class GraphQLDocumentRootTypeRepository extends IdentifiableGraphQLTypeRepository {
99903
100069
  constructor() {
@@ -99944,7 +100110,7 @@ class GraphQLDocumentRootTypeRepository extends IdentifiableGraphQLTypeRepositor
99944
100110
  }
99945
100111
  buildAugmentedQuery(input) {
99946
100112
  var _a;
99947
- const operationResult = findExecutableOperation(input);
100113
+ const operationResult = findExecutableOperation$1(input);
99948
100114
  if (operationResult.isErr()) {
99949
100115
  return err$3(operationResult.error);
99950
100116
  }
@@ -100089,13 +100255,14 @@ class BaseUnionRepository {
100089
100255
  );
100090
100256
  augmentedSelections.push(...result.selections);
100091
100257
  augmentedFragments = result.fragments;
100092
- augmentedSelections.push(
100093
- buildUniqueAugmentedFieldSelection(
100094
- { kind: Kind.FIELD, name: { kind: Kind.NAME, value: "__typename" } },
100095
- augmentedSelections,
100096
- input.fragments
100097
- )
100258
+ const newSelection = buildAugmentedFieldSelection(
100259
+ { kind: Kind.FIELD, name: { kind: Kind.NAME, value: "__typename" } },
100260
+ augmentedSelections,
100261
+ input.fragments
100098
100262
  );
100263
+ if (newSelection) {
100264
+ augmentedSelections.push(newSelection);
100265
+ }
100099
100266
  return { selections: augmentedSelections, fragments: augmentedFragments };
100100
100267
  }
100101
100268
  getTypeDiscriminator(data, _selections) {
@@ -100443,6 +100610,56 @@ function isIncompleteConfigError(err) {
100443
100610
  (validationError) => validationError instanceof MissingRequiredPropertyError
100444
100611
  ) !== void 0;
100445
100612
  }
100613
+ function findExecutableOperation(document, operationName) {
100614
+ const operations = document.definitions.filter(
100615
+ (def) => def.kind === Kind$1.OPERATION_DEFINITION
100616
+ );
100617
+ if (operations.length === 0) {
100618
+ return void 0;
100619
+ }
100620
+ if (operations.length === 1 && !operationName) {
100621
+ return operations[0];
100622
+ }
100623
+ if (operationName) {
100624
+ return operations.find((op) => {
100625
+ var _a;
100626
+ return ((_a = op.name) == null ? void 0 : _a.value) === operationName;
100627
+ });
100628
+ }
100629
+ return void 0;
100630
+ }
100631
+ function validateGraphQLOperations(config, options) {
100632
+ const executableOperation = findExecutableOperation(config.query, config.operationName);
100633
+ if (executableOperation) {
100634
+ const operationType = executableOperation.operation;
100635
+ if (!options.acceptedOperations.includes(operationType)) {
100636
+ const operationTypeCapitalized = operationType.charAt(0).toUpperCase() + operationType.slice(1);
100637
+ throw new Error(
100638
+ `${operationTypeCapitalized} operations are not supported in this context`
100639
+ );
100640
+ }
100641
+ }
100642
+ }
100643
+ function resolveAst(ast) {
100644
+ if (ast === null) {
100645
+ return;
100646
+ }
100647
+ const result = astResolver(ast);
100648
+ if (result === void 0) {
100649
+ throw new Error("Could not resolve AST. Did you parse the query with gql?");
100650
+ }
100651
+ return result;
100652
+ }
100653
+ function wrapConfigAndVerify(config) {
100654
+ if (config == null ? void 0 : config.query) {
100655
+ config = { ...config, query: resolveAst(config.query) };
100656
+ if (config.query === void 0) {
100657
+ throw new Error("Internal error in GraphQL adapter occurred: Unable to resolve query");
100658
+ }
100659
+ validateGraphQLOperations(config, { acceptedOperations: ["query"] });
100660
+ }
100661
+ return config;
100662
+ }
100446
100663
  class GraphQLCommandWireAdapterConstructor extends CommandWireAdapterConstructor {
100447
100664
  emit(result) {
100448
100665
  try {
@@ -100511,15 +100728,110 @@ class GraphQLCommandWireAdapterConstructor extends CommandWireAdapterConstructor
100511
100728
  }
100512
100729
  update(config, _context) {
100513
100730
  this.unsubscribe();
100731
+ const resolvedQuery = resolveAst(config.query);
100732
+ if (resolvedQuery) {
100733
+ validateGraphQLOperations(
100734
+ { query: resolvedQuery, operationName: config == null ? void 0 : config.operationName },
100735
+ { acceptedOperations: ["query"] }
100736
+ );
100737
+ }
100514
100738
  this.config = {
100515
100739
  ...sanitize(config),
100516
- query: config.query
100740
+ query: resolvedQuery
100517
100741
  };
100518
100742
  this.invokeAdapter();
100519
100743
  }
100520
100744
  }
100745
+ function buildAsyncGraphQLImperativeInvoker(getCommand, exposeRefresh = false) {
100746
+ return async (...params) => {
100747
+ try {
100748
+ if (params.length) {
100749
+ params[0] = wrapConfigAndVerify(params[0]);
100750
+ }
100751
+ const command = getCommand({ params, assertIsValid });
100752
+ const result = await command.execute();
100753
+ const consumerEmittedData = {
100754
+ data: void 0,
100755
+ errors: void 0
100756
+ };
100757
+ if (result.isOk()) {
100758
+ deepFreeze(result.value);
100759
+ consumerEmittedData.data = result.value.data.data;
100760
+ consumerEmittedData.subscribe = (cb) => {
100761
+ result.value.subscribe((res) => {
100762
+ const consumerEmittedData2 = {
100763
+ data: void 0,
100764
+ errors: void 0
100765
+ };
100766
+ if (res.isOk()) {
100767
+ consumerEmittedData2.data = res.value.data;
100768
+ } else {
100769
+ if (isUserVisibleError(res.error)) {
100770
+ consumerEmittedData2.data = res.error.data.data;
100771
+ consumerEmittedData2.errors = res.error.data.errors;
100772
+ } else {
100773
+ logError(res.error);
100774
+ consumerEmittedData2.errors = [
100775
+ {
100776
+ message: "Internal error in GraphQL adapter occurred",
100777
+ locations: []
100778
+ }
100779
+ ];
100780
+ }
100781
+ }
100782
+ cb(consumerEmittedData2);
100783
+ });
100784
+ };
100785
+ if (exposeRefresh) {
100786
+ consumerEmittedData.refresh = () => {
100787
+ return new Promise((resolve, reject) => {
100788
+ try {
100789
+ result.value.refresh().then((res) => {
100790
+ if (res.isOk()) {
100791
+ resolve();
100792
+ } else {
100793
+ reject(
100794
+ new Error(
100795
+ "Internal error in GraphQL adapter occurred: Failed to refresh GraphQL data"
100796
+ )
100797
+ );
100798
+ }
100799
+ });
100800
+ } catch (error) {
100801
+ logError(error);
100802
+ reject(
100803
+ new Error(
100804
+ "Internal error in GraphQL adapter occurred: Failed to refresh GraphQL data"
100805
+ )
100806
+ );
100807
+ }
100808
+ });
100809
+ };
100810
+ }
100811
+ } else {
100812
+ if (isUserVisibleError(result.error)) {
100813
+ consumerEmittedData.data = result.error.data.data;
100814
+ consumerEmittedData.errors = result.error.data.errors;
100815
+ } else {
100816
+ logError(result.error);
100817
+ consumerEmittedData.errors = [
100818
+ { message: "Internal error in GraphQL adapter occurred", locations: [] }
100819
+ ];
100820
+ }
100821
+ }
100822
+ return consumerEmittedData;
100823
+ } catch (error) {
100824
+ logError(error);
100825
+ return {
100826
+ data: void 0,
100827
+ errors: [{ message: "Internal error in GraphQL adapter occurred", locations: [] }]
100828
+ };
100829
+ }
100830
+ };
100831
+ }
100521
100832
  function buildAsyncGraphQLImperativeLegacyInvoker(getCommand) {
100522
100833
  const invoke = async (config, requestContext, callback) => {
100834
+ config = wrapConfigAndVerify(config);
100523
100835
  const command = getCommand({ config, assertIsValid });
100524
100836
  try {
100525
100837
  const overrides = requestContextIsCachePolicy(requestContext) ? { cacheControlConfig: { type: "no-cache" } } : {};
@@ -100552,6 +100864,7 @@ function buildAsyncGraphQLImperativeLegacyInvoker(getCommand) {
100552
100864
  }
100553
100865
  };
100554
100866
  const subscribe = (config, requestContext, callback) => {
100867
+ config = wrapConfigAndVerify(config);
100555
100868
  const command = getCommand({ config, assertIsValid });
100556
100869
  let unsubscribe = () => {
100557
100870
  };
@@ -100612,14 +100925,7 @@ function buildAsyncGraphQLImperativeLegacyInvoker(getCommand) {
100612
100925
  function requestContextIsCachePolicy(requestContext) {
100613
100926
  return typeof requestContext === "object" && requestContext !== null && "cachePolicy" in requestContext && typeof requestContext.cachePolicy === "object" && requestContext.cachePolicy !== null && "type" in requestContext.cachePolicy && requestContext.cachePolicy.type === "no-cache";
100614
100927
  }
100615
- function resolveAst(ast) {
100616
- const result = astResolver(ast);
100617
- if (result === void 0) {
100618
- throw new Error("Could not resolve AST. Did you parse the query with gql?");
100619
- }
100620
- return result;
100621
- }
100622
- // version: 1.383.0-d85dce8db1
100928
+ // version: 1.384.0-835fd13f44
100623
100929
 
100624
100930
  class Analytics__AnalyticsBrowseRepository extends UnidentifiableGraphQLTypeRepository {
100625
100931
  constructor(services, typeRegistry) {
@@ -100684,6 +100990,7 @@ class Analytics__AnalyticsRepresentationRepository extends IdentifiableGraphQLTy
100684
100990
  this.namespace = "oas";
100685
100991
  this.typeName = "Analytics__AnalyticsRepresentation";
100686
100992
  this.implementedInterfaces = ["Analytics__AnalyticsRepresentationInterface"];
100993
+ this.idField = "Id";
100687
100994
  }
100688
100995
  get fields() {
100689
100996
  return {
@@ -100702,9 +101009,6 @@ class Analytics__AnalyticsRepresentationRepository extends IdentifiableGraphQLTy
100702
101009
  Dataspaces: new BaseArrayFieldDef(new BaseObjectFieldDef(this.typeRegistry.Analytics__DataspaceRepresentation, true), true),
100703
101010
  };
100704
101011
  }
100705
- buildKeyParams(input) {
100706
- return { Id: input.data.Id };
100707
- }
100708
101012
  get cacheControl() {
100709
101013
  return { type: "max-age", maxAge: 60 };
100710
101014
  }
@@ -100775,6 +101079,7 @@ class Analytics__AnalyticsWorkspaceRepository extends IdentifiableGraphQLTypeRep
100775
101079
  this.namespace = "oas";
100776
101080
  this.typeName = "Analytics__AnalyticsWorkspace";
100777
101081
  this.implementedInterfaces = [];
101082
+ this.idField = "Id";
100778
101083
  }
100779
101084
  get fields() {
100780
101085
  return {
@@ -100789,9 +101094,6 @@ class Analytics__AnalyticsWorkspaceRepository extends IdentifiableGraphQLTypeRep
100789
101094
  ApiName: new BaseScalarFieldDef(false),
100790
101095
  };
100791
101096
  }
100792
- buildKeyParams(input) {
100793
- return { Id: input.data.Id };
100794
- }
100795
101097
  get cacheControl() {
100796
101098
  return { type: "max-age", maxAge: 60 };
100797
101099
  }
@@ -100805,6 +101107,7 @@ class Analytics__DataspaceRepresentationRepository extends IdentifiableGraphQLTy
100805
101107
  this.namespace = "oas";
100806
101108
  this.typeName = "Analytics__DataspaceRepresentation";
100807
101109
  this.implementedInterfaces = [];
101110
+ this.idField = "Id";
100808
101111
  }
100809
101112
  get fields() {
100810
101113
  return {
@@ -100815,9 +101118,6 @@ class Analytics__DataspaceRepresentationRepository extends IdentifiableGraphQLTy
100815
101118
  DeveloperName: new BaseScalarFieldDef(true),
100816
101119
  };
100817
101120
  }
100818
- buildKeyParams(input) {
100819
- return { Id: input.data.Id };
100820
- }
100821
101121
  get cacheControl() {
100822
101122
  return { type: "max-age", maxAge: 60 };
100823
101123
  }
@@ -101995,6 +102295,7 @@ let RecordRepresentationRepository$1 = class RecordRepresentationRepository exte
101995
102295
  this.namespace = "oas";
101996
102296
  this.typeName = "RecordRepresentation";
101997
102297
  this.implementedInterfaces = ["Record"];
102298
+ this.idField = "Id";
101998
102299
  }
101999
102300
  get fields() {
102000
102301
  return {
@@ -102038,9 +102339,6 @@ let RecordRepresentationRepository$1 = class RecordRepresentationRepository exte
102038
102339
  AnyType: new BaseObjectFieldDef(this.typeRegistry.AnyType, true),
102039
102340
  };
102040
102341
  }
102041
- buildKeyParams(input) {
102042
- return { Id: input.data.Id };
102043
- }
102044
102342
  get cacheControl() {
102045
102343
  return { type: "max-age", maxAge: 60 };
102046
102344
  }
@@ -102170,6 +102468,7 @@ class Setup__EntityRepresentationRepository extends IdentifiableGraphQLTypeRepos
102170
102468
  this.namespace = "oas";
102171
102469
  this.typeName = "Setup__EntityRepresentation";
102172
102470
  this.implementedInterfaces = [];
102471
+ this.idField = "Id";
102173
102472
  }
102174
102473
  get fields() {
102175
102474
  return {
@@ -102208,9 +102507,6 @@ class Setup__EntityRepresentationRepository extends IdentifiableGraphQLTypeRepos
102208
102507
  AnyType: new BaseObjectFieldDef(this.typeRegistry.AnyType, true),
102209
102508
  };
102210
102509
  }
102211
- buildKeyParams(input) {
102212
- return { Id: input.data.Id };
102213
- }
102214
102510
  get cacheControl() {
102215
102511
  return { type: "max-age", maxAge: 60 };
102216
102512
  }
@@ -102385,6 +102681,7 @@ class Setup__ListViewRowRepository extends IdentifiableGraphQLTypeRepository {
102385
102681
  this.namespace = "oas";
102386
102682
  this.typeName = "Setup__ListViewRow";
102387
102683
  this.implementedInterfaces = [];
102684
+ this.idField = "id";
102388
102685
  }
102389
102686
  get fields() {
102390
102687
  return {
@@ -102393,9 +102690,6 @@ class Setup__ListViewRowRepository extends IdentifiableGraphQLTypeRepository {
102393
102690
  columns: new BaseArrayFieldDef(new BaseObjectFieldDef(this.typeRegistry.Setup__ListScalarField, true), false),
102394
102691
  };
102395
102692
  }
102396
- buildKeyParams(input) {
102397
- return { id: input.data.id };
102398
- }
102399
102693
  get cacheControl() {
102400
102694
  return { type: "max-age", maxAge: 60 };
102401
102695
  }
@@ -104345,6 +104639,7 @@ function buildCommandClass(baseClass) {
104345
104639
 
104346
104640
  let graphql$1;
104347
104641
  let graphql_imperative$1;
104642
+ let graphql_imperative_legacy;
104348
104643
  let useOneStoreGraphQL = false;
104349
104644
  const serviceRequirements = {
104350
104645
  instrumentCommand: {
@@ -104404,18 +104699,24 @@ getServices(serviceRequirements).then((services) => {
104404
104699
  this.exposeRefresh = true;
104405
104700
  }
104406
104701
  getCommand() {
104407
- return new graphql_ctor({ ...this.config, query: resolveAst(this.config.query) }, documentRootType, services);
104702
+ return new graphql_ctor(this.config, documentRootType, services);
104408
104703
  }
104409
104704
  };
104410
104705
  const graphql_imperative_ctor = services.instrumentCommand(buildCommandClass(services.auraGraphQLNormalizedCacheControlCommand), 'graphql_imperative');
104411
- graphql_imperative$1 = buildAsyncGraphQLImperativeLegacyInvoker(({ config, assertIsValid }) => {
104706
+ graphql_imperative$1 = buildAsyncGraphQLImperativeInvoker(({ params, assertIsValid }) => {
104707
+ const config = params[0];
104412
104708
  const _ = assertIsValid;
104413
104709
  _(config, CONFIG_SCHEMA);
104414
- return new graphql_imperative_ctor({ ...config, query: resolveAst(config.query) }, documentRootType, services);
104710
+ return new graphql_imperative_ctor(config, documentRootType, services);
104711
+ }, true);
104712
+ graphql_imperative_legacy = buildAsyncGraphQLImperativeLegacyInvoker(({ config, assertIsValid }) => {
104713
+ const _ = assertIsValid;
104714
+ _(config, CONFIG_SCHEMA);
104715
+ return new graphql_imperative_ctor(config, documentRootType, services);
104415
104716
  });
104416
104717
  useOneStoreGraphQL = services.featureFlags?.get('useOneStoreGraphQL') ?? false;
104417
104718
  if (provisionedCallback) {
104418
- provisionedCallback(graphql$1, graphql_imperative$1, useOneStoreGraphQL);
104719
+ provisionedCallback(graphql$1, graphql_imperative$1, graphql_imperative_legacy, useOneStoreGraphQL);
104419
104720
  }
104420
104721
  }, (_err) => { });
104421
104722
  function registerCallback(cb) {
@@ -104423,10 +104724,10 @@ function registerCallback(cb) {
104423
104724
  provisionedCallback = cb;
104424
104725
  }
104425
104726
  else {
104426
- cb(graphql$1, graphql_imperative$1, useOneStoreGraphQL);
104727
+ cb(graphql$1, graphql_imperative$1, graphql_imperative_legacy, useOneStoreGraphQL);
104427
104728
  }
104428
104729
  }
104429
- // version: 1.383.0-d85dce8db1
104730
+ // version: 1.384.0-835fd13f44
104430
104731
 
104431
104732
  function createFragmentMap(documentNode) {
104432
104733
  const fragments = {};
@@ -130378,11 +130679,15 @@ function buildCachedSnapshotCachePolicy(context, storeLookup) {
130378
130679
  return cacheSnapshot;
130379
130680
  }
130380
130681
 
130682
+ // Wire Adapters
130381
130683
  let graphql;
130382
130684
  let graphqlBatch;
130383
130685
  // Imperative GET Adapters
130384
130686
  let graphql_imperative;
130385
130687
  let graphqlBatch_imperative;
130688
+ let refreshGraphQL = (data) => {
130689
+ return refresh$3(data, 'refreshUiApi');
130690
+ };
130386
130691
  // Adapter Metadata
130387
130692
  const graphqlMetadata = { apiFamily: keyPrefix$1, name: 'graphql', ttl: 900000 };
130388
130693
  const graphqlBatchMetadata = { apiFamily: keyPrefix$1, name: 'graphqlBatch' };
@@ -130404,10 +130709,16 @@ withDefaultLuvio((luvio) => {
130404
130709
  ({ graphql, graphqlBatch, graphql_imperative, graphqlBatch_imperative } = bindExportsTo(luvio));
130405
130710
  // We register the callback here rather than above withDefaultLuvio because we want environments
130406
130711
  // that don't have onestore bootstrapped with the required services to default to the luvio versions of the adapters
130407
- registerCallback((oneStoreGraphql, oneStoreGraphql_imperative, useOneStoreGraphQL) => {
130712
+ registerCallback((oneStoreGraphql, oneStoreGraphql_imperative, oneStoreGraphql_imperative_legacy, useOneStoreGraphQL) => {
130408
130713
  if (useOneStoreGraphQL) {
130409
130714
  graphql = oneStoreGraphql;
130410
- graphql_imperative = oneStoreGraphql_imperative;
130715
+ graphql_imperative = oneStoreGraphql_imperative_legacy;
130716
+ refreshGraphQL = (data) => {
130717
+ if (typeof data?.refresh === 'function') {
130718
+ return data.refresh();
130719
+ }
130720
+ throw new Error('Component attempted to refresh a GraphQL result that is not refreshable');
130721
+ };
130411
130722
  }
130412
130723
  });
130413
130724
  });
@@ -130914,14 +131225,7 @@ register$1({
130914
131225
  configuration: { ...configurationForGraphQLAdapters$1 },
130915
131226
  instrument: instrument$1,
130916
131227
  });
130917
- function refreshGraphQL(data) {
130918
- // If OneStore data, call its refresh instead
130919
- if (typeof data?.refresh === 'function') {
130920
- return data.refresh();
130921
- }
130922
- return refresh$3(data, 'refreshUiApi');
130923
- }
130924
- // version: 1.383.0-d85dce8db1
131228
+ // version: 1.384.0-835fd13f44
130925
131229
 
130926
131230
  // On core the unstable adapters are re-exported with different names,
130927
131231
  // we want to match them here.
@@ -130933,7 +131237,7 @@ var unstableLightningRelatedListApi = /*#__PURE__*/Object.freeze({
130933
131237
  gql: gql,
130934
131238
  get graphql () { return graphql; },
130935
131239
  get graphqlBatch () { return graphqlBatch; },
130936
- refreshGraphQL: refreshGraphQL,
131240
+ get refreshGraphQL () { return refreshGraphQL; },
130937
131241
  get unstable_getActionOverrides_imperative () { return unstable_getActionOverrides_imperative; },
130938
131242
  get unstable_getFlexipageFormulaOverrides_imperative () { return unstable_getFlexipageFormulaOverrides_imperative; },
130939
131243
  get unstable_getGlobalActions_imperative () { return unstable_getGlobalActions_imperative; },
@@ -131073,7 +131377,7 @@ withDefaultLuvio((luvio) => {
131073
131377
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
131074
131378
  graphQLImperative = ldsAdapter;
131075
131379
  });
131076
- // version: 1.383.0-d85dce8db1
131380
+ // version: 1.384.0-835fd13f44
131077
131381
 
131078
131382
  var gqlApi = /*#__PURE__*/Object.freeze({
131079
131383
  __proto__: null,
@@ -131872,7 +132176,7 @@ const callbacks$1 = [];
131872
132176
  function register(r) {
131873
132177
  callbacks$1.forEach((callback) => callback(r));
131874
132178
  }
131875
- // version: 1.383.0-b9875fc4e1
132179
+ // version: 1.384.0-cb845692ac
131876
132180
 
131877
132181
  /**
131878
132182
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -133188,4 +133492,4 @@ const { luvio } = getRuntime();
133188
133492
  setDefaultLuvio({ luvio });
133189
133493
 
133190
133494
  export { createPrimingSession, draftManager, draftQueue, evictCacheRecordsByIds, evictExpiredCacheEntries, executeAdapter, executeMutatingAdapter, getImperativeAdapterNames, importLuvioAdapterModule, importOneStoreAdapterModule, invokeAdapter, invokeAdapterWithDraftToMerge, invokeAdapterWithDraftToReplace, invokeAdapterWithMetadata, nimbusDraftQueue, registerReportObserver, setMetadataTTL, setUiApiRecordTTL, stopEviction, subscribeToAdapter };
133191
- // version: 1.383.0-b9875fc4e1
133495
+ // version: 1.384.0-cb845692ac