@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.
@@ -4280,7 +4280,7 @@
4280
4280
  }
4281
4281
  callbacks.push(callback);
4282
4282
  }
4283
- // version: 1.383.0-b9875fc4e1
4283
+ // version: 1.384.0-cb845692ac
4284
4284
 
4285
4285
  // TODO [TD-0081508]: once that TD is fulfilled we can probably change this file
4286
4286
  function instrumentAdapter$1(createFunction, _metadata) {
@@ -5324,7 +5324,7 @@
5324
5324
  const { apiFamily, name } = metadata;
5325
5325
  return createGraphQLWireAdapterConstructor$1(adapter, `${apiFamily}.${name}`, luvio, astResolver);
5326
5326
  }
5327
- // version: 1.383.0-b9875fc4e1
5327
+ // version: 1.384.0-cb845692ac
5328
5328
 
5329
5329
  /**
5330
5330
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -34160,7 +34160,7 @@
34160
34160
  throttle(60, 60000, setupNotifyAllListRecordUpdateAvailable(luvio));
34161
34161
  throttle(60, 60000, setupNotifyAllListInfoSummaryUpdateAvailable(luvio));
34162
34162
  });
34163
- // version: 1.383.0-d85dce8db1
34163
+ // version: 1.384.0-835fd13f44
34164
34164
 
34165
34165
  function requestIdleDetectedCallback(_callback) { }
34166
34166
  function declareNotifierTaskSingle(_name) {
@@ -81036,6 +81036,16 @@
81036
81036
  ldsMobileInstrumentation$2.trackValue(GARBAGE_COLLECTION_AGGRESSIVE_TRIM_TOTAL_RECORDS_BEFORE_TRIM, beforeTrimRecordCount);
81037
81037
  ldsMobileInstrumentation$2.trackValue(GARBAGE_COLLECTION_AGGRESSIVE_TRIM_RECORDS_TRIMMED, totalRecordsTrimmed);
81038
81038
  }
81039
+ /** One Store Cache Purge */
81040
+ const ONESTORE_CACHE_PURGING_RECORDS_PURGED = 'onestore-cache-purging-records-purged';
81041
+ const ONESTORE_CACHE_PURGING_RECORDS_ERROR = 'onestore-cache-purging-records-error';
81042
+ function reportOneStoreRecordsPurgedFromCache(recordsPurged) {
81043
+ ldsMobileInstrumentation$2.trackValue(ONESTORE_CACHE_PURGING_RECORDS_PURGED, recordsPurged);
81044
+ }
81045
+ function reportOneStoreCachePurgingError(error) {
81046
+ const errorMessage = normalizeError$1(error);
81047
+ ldsMobileInstrumentation$2.error(errorMessage, ONESTORE_CACHE_PURGING_RECORDS_ERROR);
81048
+ }
81039
81049
 
81040
81050
  const QUICK_ACTION_HANDLER = 'QUICK_ACTION_HANDLER';
81041
81051
  class QuickActionExecutionRepresentationHandler extends AbstractQuickActionHandler {
@@ -94274,7 +94284,7 @@
94274
94284
  }
94275
94285
  requestFromNetwork() {
94276
94286
  const that = this;
94277
- return async function* () {
94287
+ return (async function* () {
94278
94288
  const result = await that.requestFromNetworkInternal();
94279
94289
  if (result.isErr()) {
94280
94290
  that.networkError = result;
@@ -94282,7 +94292,7 @@
94282
94292
  that.networkData = result;
94283
94293
  }
94284
94294
  yield result;
94285
- }();
94295
+ })();
94286
94296
  }
94287
94297
  writeToCache(cache, networkResult) {
94288
94298
  return this.writeToCacheInternal(cache, networkResult);
@@ -95887,7 +95897,7 @@
95887
95897
  },
95888
95898
  };
95889
95899
  }
95890
- // version: 1.383.0-d85dce8db1
95900
+ // version: 1.384.0-835fd13f44
95891
95901
 
95892
95902
  /**
95893
95903
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -95913,7 +95923,7 @@
95913
95923
  },
95914
95924
  };
95915
95925
  }
95916
- // version: 1.383.0-d85dce8db1
95926
+ // version: 1.384.0-835fd13f44
95917
95927
 
95918
95928
  /*!
95919
95929
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -96758,7 +96768,7 @@
96758
96768
  * All rights reserved.
96759
96769
  * For full license text, see the LICENSE.txt file
96760
96770
  */
96761
- function findExecutableOperation$1(input) {
96771
+ function findExecutableOperation$2(input) {
96762
96772
  const operations = input.query.definitions.filter(
96763
96773
  (def) => def.kind === Kind$2.OPERATION_DEFINITION
96764
96774
  );
@@ -96781,7 +96791,7 @@
96781
96791
  return err$1$1(new Error("Multiple operations found in query, and no operation name provided"));
96782
96792
  }
96783
96793
  function buildGraphQLInputExtension$1(input) {
96784
- const operationResult = findExecutableOperation$1(input);
96794
+ const operationResult = findExecutableOperation$2(input);
96785
96795
  if (operationResult.isErr()) {
96786
96796
  return err$1$1(operationResult.error);
96787
96797
  }
@@ -97818,6 +97828,7 @@
97818
97828
  }
97819
97829
  }
97820
97830
 
97831
+ const PURGE_CACHE_DAYS = 30;
97821
97832
  // TODO[@W-18753648]: These services depend on WebApis that aren't available in the worker.
97822
97833
  // import { buildServiceDescriptor as buildNdJsonServiceDescriptor } from '@luvio/command-ndjson/v1';
97823
97834
  // import { buildServiceDescriptor as buildStreamingCommandServiceDescriptor } from '@luvio/command-streaming/v1';
@@ -97866,6 +97877,48 @@
97866
97877
  // buildSseCommandServiceDescriptor(),
97867
97878
  ];
97868
97879
  setServices(services);
97880
+ purgeDurableCacheByDays(PURGE_CACHE_DAYS, sqliteStore);
97881
+ }
97882
+ /**
97883
+ * Manually purges the OneStore cache by days.
97884
+ * Until we have real cache eviction in one store.
97885
+ *
97886
+ * @param days - The number of days to purge the cache by.
97887
+ * @param sqliteStore - The SqliteStorePlugin to purge the cache from.
97888
+ */
97889
+ async function purgeDurableCacheByDays(days, sqliteStore) {
97890
+ const MILLISECONDS_PER_DAY = 24 * 60 * 60 * 1000;
97891
+ const cutoffTimestamp = Date.now() - days * MILLISECONDS_PER_DAY;
97892
+ try {
97893
+ // This has to be ran in a SELECT since the DELETE query may not support return on SQLite version in mobile
97894
+ const countQuery = `
97895
+ SELECT COUNT(*) FROM lds_one_store_data
97896
+ WHERE json_extract(metadata, '$.cacheControl.generatedTime') < ?
97897
+ `;
97898
+ const countResult = await queryAsync(sqliteStore, countQuery, [cutoffTimestamp]);
97899
+ const deleteCount = countResult.rows[0][0];
97900
+ if (deleteCount === 0) {
97901
+ reportOneStoreRecordsPurgedFromCache(0);
97902
+ return;
97903
+ }
97904
+ const deleteQuery = `
97905
+ DELETE FROM lds_one_store_data
97906
+ WHERE json_extract(metadata, '$.cacheControl.generatedTime') < ?
97907
+ `;
97908
+ await queryAsync(sqliteStore, deleteQuery, [cutoffTimestamp]);
97909
+ reportOneStoreRecordsPurgedFromCache(deleteCount);
97910
+ }
97911
+ catch (error) {
97912
+ reportOneStoreCachePurgingError(error);
97913
+ }
97914
+ }
97915
+ /**
97916
+ * Promisified wrapper for SqliteStorePlugin.query
97917
+ */
97918
+ function queryAsync(sqliteStore, sql, params) {
97919
+ return new Promise((resolve, reject) => {
97920
+ sqliteStore.query(sql, params, (result) => resolve(result), (error) => reject(error));
97921
+ });
97869
97922
  }
97870
97923
 
97871
97924
  // so eslint doesn't complain about nimbus
@@ -98070,7 +98123,7 @@
98070
98123
  id: '@salesforce/lds-network-adapter',
98071
98124
  instrument: instrument$2,
98072
98125
  });
98073
- // version: 1.383.0-b9875fc4e1
98126
+ // version: 1.384.0-cb845692ac
98074
98127
 
98075
98128
  const { create: create$3, keys: keys$3 } = Object;
98076
98129
  const { stringify: stringify$1, parse } = JSON;
@@ -98990,7 +99043,7 @@
98990
99043
  }
98991
99044
  return target;
98992
99045
  }
98993
- function findExecutableOperation(input) {
99046
+ function findExecutableOperation$1(input) {
98994
99047
  const operations = input.query.definitions.filter(
98995
99048
  (def) => def.kind === Kind.OPERATION_DEFINITION
98996
99049
  );
@@ -99013,7 +99066,7 @@
99013
99066
  return err$3(new Error("Multiple operations found in query, and no operation name provided"));
99014
99067
  }
99015
99068
  function buildGraphQLInputExtension(input) {
99016
- const operationResult = findExecutableOperation(input);
99069
+ const operationResult = findExecutableOperation$1(input);
99017
99070
  if (operationResult.isErr()) {
99018
99071
  return err$3(operationResult.error);
99019
99072
  }
@@ -99038,14 +99091,24 @@
99038
99091
  parentFieldSelection: void 0
99039
99092
  });
99040
99093
  }
99041
- function buildUniqueAugmentedFieldSelection(newSelection, selections, fragments) {
99094
+ function buildAugmentedFieldSelection(newSelection, selections, fragments) {
99042
99095
  var _a;
99096
+ if (selectionExists(newSelection, selections)) {
99097
+ return void 0;
99098
+ }
99043
99099
  const baseAlias = ((_a = newSelection.alias) == null ? void 0 : _a.value) || newSelection.name.value;
99044
99100
  const baseInjectedAlias = `framework_augmented_${baseAlias}`;
99045
- const fieldName = getUniqueSelectionName(baseInjectedAlias, selections, fragments);
99046
- if (fieldName === newSelection.name.value) {
99047
- return newSelection;
99101
+ const baseAliasedSelection = {
99102
+ ...newSelection,
99103
+ alias: {
99104
+ kind: Kind.NAME,
99105
+ value: baseInjectedAlias
99106
+ }
99107
+ };
99108
+ if (selectionExists(baseAliasedSelection, selections)) {
99109
+ return void 0;
99048
99110
  }
99111
+ const fieldName = getUniqueSelectionName(baseInjectedAlias, selections, fragments);
99049
99112
  return {
99050
99113
  ...newSelection,
99051
99114
  alias: {
@@ -99054,6 +99117,94 @@
99054
99117
  }
99055
99118
  };
99056
99119
  }
99120
+ function selectionExists(selection, selections) {
99121
+ return selections.some((s) => selectionEquals(selection, s));
99122
+ }
99123
+ function selectionEquals(a, b) {
99124
+ var _a, _b, _c, _d, _e, _f;
99125
+ if (a.kind !== b.kind) {
99126
+ return false;
99127
+ }
99128
+ if (a.kind === Kind.FIELD) {
99129
+ const bField = b;
99130
+ 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);
99131
+ }
99132
+ if (a.kind === Kind.FRAGMENT_SPREAD) {
99133
+ const bFragmentSpread = b;
99134
+ return a.name.value === bFragmentSpread.name.value && directivesEqual(a.directives, bFragmentSpread.directives);
99135
+ }
99136
+ const bInlineFragment = b;
99137
+ 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);
99138
+ }
99139
+ function argumentValueEquals(a, b) {
99140
+ if (a.kind !== b.kind) {
99141
+ return false;
99142
+ }
99143
+ switch (a.kind) {
99144
+ case Kind.STRING:
99145
+ case Kind.INT:
99146
+ case Kind.FLOAT:
99147
+ case Kind.BOOLEAN:
99148
+ case Kind.ENUM:
99149
+ return a.value === b.value;
99150
+ case Kind.NULL:
99151
+ return true;
99152
+ case Kind.VARIABLE:
99153
+ return a.name.value === b.name.value;
99154
+ case Kind.LIST:
99155
+ const bList = b;
99156
+ if (a.values.length !== bList.values.length) {
99157
+ return false;
99158
+ }
99159
+ return a.values.every((val, index) => argumentValueEquals(val, bList.values[index]));
99160
+ case Kind.OBJECT:
99161
+ const bObject = b;
99162
+ if (a.fields.length !== bObject.fields.length) {
99163
+ return false;
99164
+ }
99165
+ return a.fields.every((field, index) => {
99166
+ const bField = bObject.fields[index];
99167
+ return field.name.value === bField.name.value && argumentValueEquals(field.value, bField.value);
99168
+ });
99169
+ default:
99170
+ return false;
99171
+ }
99172
+ }
99173
+ function directivesEqual(a, b) {
99174
+ if (a === void 0 && b === void 0) {
99175
+ return true;
99176
+ }
99177
+ if (a === void 0 || b === void 0) {
99178
+ return ((a == null ? void 0 : a.length) || 0) === ((b == null ? void 0 : b.length) || 0);
99179
+ }
99180
+ if (a.length !== b.length) {
99181
+ return false;
99182
+ }
99183
+ return a.every((directive, index) => {
99184
+ const bDirective = b[index];
99185
+ return directive.name.value === bDirective.name.value && argumentsEqual(directive.arguments, bDirective.arguments);
99186
+ });
99187
+ }
99188
+ function argumentsEqual(a, b) {
99189
+ if (a === void 0 && b === void 0) {
99190
+ return true;
99191
+ }
99192
+ if (a === void 0 || b === void 0) {
99193
+ return ((a == null ? void 0 : a.length) || 0) === ((b == null ? void 0 : b.length) || 0);
99194
+ }
99195
+ if (a.length !== b.length) {
99196
+ return false;
99197
+ }
99198
+ return a.every((arg, index) => {
99199
+ const bArg = b[index];
99200
+ return arg.name.value === bArg.name.value && argumentValueEquals(arg.value, bArg.value);
99201
+ });
99202
+ }
99203
+ function selectionSetsEqual(a, b) {
99204
+ return a === void 0 || b === void 0 || !!(a.length === b.length) && !!a.every((selection, index) => {
99205
+ return selectionEquals(selection, b[index]);
99206
+ });
99207
+ }
99057
99208
  function getUniqueSelectionName(fieldName, selections, fragments) {
99058
99209
  const fieldNames = collectFieldNames(selections, fragments);
99059
99210
  if (!fieldNames.includes(fieldName)) {
@@ -99428,19 +99579,20 @@
99428
99579
  augmentedFragments = augmentedFragmentSelections.fragments;
99429
99580
  }
99430
99581
  }
99431
- augmentedSelections.push(
99432
- buildUniqueAugmentedFieldSelection(
99433
- {
99434
- kind: Kind.FIELD,
99435
- name: {
99436
- kind: Kind.NAME,
99437
- value: "__typename"
99438
- }
99439
- },
99440
- [...augmentedSelections, ...input.selections],
99441
- augmentedFragments
99442
- )
99582
+ const newTypenameSelection = buildAugmentedFieldSelection(
99583
+ {
99584
+ kind: Kind.FIELD,
99585
+ name: {
99586
+ kind: Kind.NAME,
99587
+ value: "__typename"
99588
+ }
99589
+ },
99590
+ [...augmentedSelections, ...input.selections],
99591
+ augmentedFragments
99443
99592
  );
99593
+ if (newTypenameSelection) {
99594
+ augmentedSelections.push(newTypenameSelection);
99595
+ }
99444
99596
  return { selections: augmentedSelections, fragments: augmentedFragments };
99445
99597
  }
99446
99598
  augmentFieldSelection(selection, fragments) {
@@ -99503,21 +99655,21 @@
99503
99655
  fragment
99504
99656
  );
99505
99657
  if (satisfiedFragmentTypeConditionResult.isErr() || !satisfiedFragmentTypeConditionResult.value) {
99506
- return { selections: [], fragments };
99658
+ return { selections: [selection], fragments };
99507
99659
  }
99508
- const augmentedFragmentSelections = this.augmentSelections({
99660
+ const augmentedFragment = this.augmentSelections({
99509
99661
  selections: ((_a = fragment.selectionSet) == null ? void 0 : _a.selections) || [],
99510
99662
  fragments
99511
99663
  });
99512
99664
  return {
99513
99665
  selections: [selection],
99514
99666
  fragments: {
99515
- ...fragments,
99667
+ ...augmentedFragment.fragments,
99516
99668
  [fragment.name.value]: {
99517
99669
  ...fragment,
99518
99670
  selectionSet: {
99519
99671
  kind: Kind.SELECTION_SET,
99520
- selections: augmentedFragmentSelections.selections
99672
+ selections: augmentedFragment.selections
99521
99673
  }
99522
99674
  }
99523
99675
  }
@@ -99836,19 +99988,20 @@
99836
99988
  const result = super.augmentSelections(input);
99837
99989
  const augmentedSelections = result.selections;
99838
99990
  let augmentedFragments = result.fragments;
99839
- augmentedSelections.push(
99840
- buildUniqueAugmentedFieldSelection(
99841
- {
99842
- kind: Kind.FIELD,
99843
- name: {
99844
- kind: Kind.NAME,
99845
- value: this.idField
99846
- }
99847
- },
99848
- [...augmentedSelections, ...input.selections],
99849
- augmentedFragments
99850
- )
99991
+ const newSelection = buildAugmentedFieldSelection(
99992
+ {
99993
+ kind: Kind.FIELD,
99994
+ name: {
99995
+ kind: Kind.NAME,
99996
+ value: this.idField
99997
+ }
99998
+ },
99999
+ [...augmentedSelections, ...input.selections],
100000
+ augmentedFragments
99851
100001
  );
100002
+ if (newSelection) {
100003
+ augmentedSelections.push(newSelection);
100004
+ }
99852
100005
  return { selections: augmentedSelections, fragments: augmentedFragments };
99853
100006
  }
99854
100007
  };
@@ -99904,6 +100057,19 @@
99904
100057
  buildFieldKey(selection, variables) {
99905
100058
  return this.graphqlRepository.buildFieldKey(selection, variables);
99906
100059
  }
100060
+ buildKeyParams(input) {
100061
+ var _a;
100062
+ const idField = input.selections.find(
100063
+ (selection) => selection.kind === Kind.FIELD && selection.name.value === this.idField
100064
+ );
100065
+ if (!idField) {
100066
+ throw new Error(`Id field ${this.idField} not found in selections`);
100067
+ }
100068
+ const idFieldDataProperty = ((_a = idField.alias) == null ? void 0 : _a.value) || idField.name.value;
100069
+ return {
100070
+ [this.idField]: input.data[idFieldDataProperty]
100071
+ };
100072
+ }
99907
100073
  }
99908
100074
  class GraphQLDocumentRootTypeRepository extends IdentifiableGraphQLTypeRepository {
99909
100075
  constructor() {
@@ -99950,7 +100116,7 @@
99950
100116
  }
99951
100117
  buildAugmentedQuery(input) {
99952
100118
  var _a;
99953
- const operationResult = findExecutableOperation(input);
100119
+ const operationResult = findExecutableOperation$1(input);
99954
100120
  if (operationResult.isErr()) {
99955
100121
  return err$3(operationResult.error);
99956
100122
  }
@@ -100095,13 +100261,14 @@
100095
100261
  );
100096
100262
  augmentedSelections.push(...result.selections);
100097
100263
  augmentedFragments = result.fragments;
100098
- augmentedSelections.push(
100099
- buildUniqueAugmentedFieldSelection(
100100
- { kind: Kind.FIELD, name: { kind: Kind.NAME, value: "__typename" } },
100101
- augmentedSelections,
100102
- input.fragments
100103
- )
100264
+ const newSelection = buildAugmentedFieldSelection(
100265
+ { kind: Kind.FIELD, name: { kind: Kind.NAME, value: "__typename" } },
100266
+ augmentedSelections,
100267
+ input.fragments
100104
100268
  );
100269
+ if (newSelection) {
100270
+ augmentedSelections.push(newSelection);
100271
+ }
100105
100272
  return { selections: augmentedSelections, fragments: augmentedFragments };
100106
100273
  }
100107
100274
  getTypeDiscriminator(data, _selections) {
@@ -100449,6 +100616,56 @@
100449
100616
  (validationError) => validationError instanceof MissingRequiredPropertyError
100450
100617
  ) !== void 0;
100451
100618
  }
100619
+ function findExecutableOperation(document, operationName) {
100620
+ const operations = document.definitions.filter(
100621
+ (def) => def.kind === Kind$1.OPERATION_DEFINITION
100622
+ );
100623
+ if (operations.length === 0) {
100624
+ return void 0;
100625
+ }
100626
+ if (operations.length === 1 && !operationName) {
100627
+ return operations[0];
100628
+ }
100629
+ if (operationName) {
100630
+ return operations.find((op) => {
100631
+ var _a;
100632
+ return ((_a = op.name) == null ? void 0 : _a.value) === operationName;
100633
+ });
100634
+ }
100635
+ return void 0;
100636
+ }
100637
+ function validateGraphQLOperations(config, options) {
100638
+ const executableOperation = findExecutableOperation(config.query, config.operationName);
100639
+ if (executableOperation) {
100640
+ const operationType = executableOperation.operation;
100641
+ if (!options.acceptedOperations.includes(operationType)) {
100642
+ const operationTypeCapitalized = operationType.charAt(0).toUpperCase() + operationType.slice(1);
100643
+ throw new Error(
100644
+ `${operationTypeCapitalized} operations are not supported in this context`
100645
+ );
100646
+ }
100647
+ }
100648
+ }
100649
+ function resolveAst(ast) {
100650
+ if (ast === null) {
100651
+ return;
100652
+ }
100653
+ const result = astResolver(ast);
100654
+ if (result === void 0) {
100655
+ throw new Error("Could not resolve AST. Did you parse the query with gql?");
100656
+ }
100657
+ return result;
100658
+ }
100659
+ function wrapConfigAndVerify(config) {
100660
+ if (config == null ? void 0 : config.query) {
100661
+ config = { ...config, query: resolveAst(config.query) };
100662
+ if (config.query === void 0) {
100663
+ throw new Error("Internal error in GraphQL adapter occurred: Unable to resolve query");
100664
+ }
100665
+ validateGraphQLOperations(config, { acceptedOperations: ["query"] });
100666
+ }
100667
+ return config;
100668
+ }
100452
100669
  class GraphQLCommandWireAdapterConstructor extends CommandWireAdapterConstructor {
100453
100670
  emit(result) {
100454
100671
  try {
@@ -100517,15 +100734,110 @@
100517
100734
  }
100518
100735
  update(config, _context) {
100519
100736
  this.unsubscribe();
100737
+ const resolvedQuery = resolveAst(config.query);
100738
+ if (resolvedQuery) {
100739
+ validateGraphQLOperations(
100740
+ { query: resolvedQuery, operationName: config == null ? void 0 : config.operationName },
100741
+ { acceptedOperations: ["query"] }
100742
+ );
100743
+ }
100520
100744
  this.config = {
100521
100745
  ...sanitize(config),
100522
- query: config.query
100746
+ query: resolvedQuery
100523
100747
  };
100524
100748
  this.invokeAdapter();
100525
100749
  }
100526
100750
  }
100751
+ function buildAsyncGraphQLImperativeInvoker(getCommand, exposeRefresh = false) {
100752
+ return async (...params) => {
100753
+ try {
100754
+ if (params.length) {
100755
+ params[0] = wrapConfigAndVerify(params[0]);
100756
+ }
100757
+ const command = getCommand({ params, assertIsValid });
100758
+ const result = await command.execute();
100759
+ const consumerEmittedData = {
100760
+ data: void 0,
100761
+ errors: void 0
100762
+ };
100763
+ if (result.isOk()) {
100764
+ deepFreeze(result.value);
100765
+ consumerEmittedData.data = result.value.data.data;
100766
+ consumerEmittedData.subscribe = (cb) => {
100767
+ result.value.subscribe((res) => {
100768
+ const consumerEmittedData2 = {
100769
+ data: void 0,
100770
+ errors: void 0
100771
+ };
100772
+ if (res.isOk()) {
100773
+ consumerEmittedData2.data = res.value.data;
100774
+ } else {
100775
+ if (isUserVisibleError(res.error)) {
100776
+ consumerEmittedData2.data = res.error.data.data;
100777
+ consumerEmittedData2.errors = res.error.data.errors;
100778
+ } else {
100779
+ logError(res.error);
100780
+ consumerEmittedData2.errors = [
100781
+ {
100782
+ message: "Internal error in GraphQL adapter occurred",
100783
+ locations: []
100784
+ }
100785
+ ];
100786
+ }
100787
+ }
100788
+ cb(consumerEmittedData2);
100789
+ });
100790
+ };
100791
+ if (exposeRefresh) {
100792
+ consumerEmittedData.refresh = () => {
100793
+ return new Promise((resolve, reject) => {
100794
+ try {
100795
+ result.value.refresh().then((res) => {
100796
+ if (res.isOk()) {
100797
+ resolve();
100798
+ } else {
100799
+ reject(
100800
+ new Error(
100801
+ "Internal error in GraphQL adapter occurred: Failed to refresh GraphQL data"
100802
+ )
100803
+ );
100804
+ }
100805
+ });
100806
+ } catch (error) {
100807
+ logError(error);
100808
+ reject(
100809
+ new Error(
100810
+ "Internal error in GraphQL adapter occurred: Failed to refresh GraphQL data"
100811
+ )
100812
+ );
100813
+ }
100814
+ });
100815
+ };
100816
+ }
100817
+ } else {
100818
+ if (isUserVisibleError(result.error)) {
100819
+ consumerEmittedData.data = result.error.data.data;
100820
+ consumerEmittedData.errors = result.error.data.errors;
100821
+ } else {
100822
+ logError(result.error);
100823
+ consumerEmittedData.errors = [
100824
+ { message: "Internal error in GraphQL adapter occurred", locations: [] }
100825
+ ];
100826
+ }
100827
+ }
100828
+ return consumerEmittedData;
100829
+ } catch (error) {
100830
+ logError(error);
100831
+ return {
100832
+ data: void 0,
100833
+ errors: [{ message: "Internal error in GraphQL adapter occurred", locations: [] }]
100834
+ };
100835
+ }
100836
+ };
100837
+ }
100527
100838
  function buildAsyncGraphQLImperativeLegacyInvoker(getCommand) {
100528
100839
  const invoke = async (config, requestContext, callback) => {
100840
+ config = wrapConfigAndVerify(config);
100529
100841
  const command = getCommand({ config, assertIsValid });
100530
100842
  try {
100531
100843
  const overrides = requestContextIsCachePolicy(requestContext) ? { cacheControlConfig: { type: "no-cache" } } : {};
@@ -100558,6 +100870,7 @@
100558
100870
  }
100559
100871
  };
100560
100872
  const subscribe = (config, requestContext, callback) => {
100873
+ config = wrapConfigAndVerify(config);
100561
100874
  const command = getCommand({ config, assertIsValid });
100562
100875
  let unsubscribe = () => {
100563
100876
  };
@@ -100618,14 +100931,7 @@
100618
100931
  function requestContextIsCachePolicy(requestContext) {
100619
100932
  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";
100620
100933
  }
100621
- function resolveAst(ast) {
100622
- const result = astResolver(ast);
100623
- if (result === void 0) {
100624
- throw new Error("Could not resolve AST. Did you parse the query with gql?");
100625
- }
100626
- return result;
100627
- }
100628
- // version: 1.383.0-d85dce8db1
100934
+ // version: 1.384.0-835fd13f44
100629
100935
 
100630
100936
  class Analytics__AnalyticsBrowseRepository extends UnidentifiableGraphQLTypeRepository {
100631
100937
  constructor(services, typeRegistry) {
@@ -100690,6 +100996,7 @@
100690
100996
  this.namespace = "oas";
100691
100997
  this.typeName = "Analytics__AnalyticsRepresentation";
100692
100998
  this.implementedInterfaces = ["Analytics__AnalyticsRepresentationInterface"];
100999
+ this.idField = "Id";
100693
101000
  }
100694
101001
  get fields() {
100695
101002
  return {
@@ -100708,9 +101015,6 @@
100708
101015
  Dataspaces: new BaseArrayFieldDef(new BaseObjectFieldDef(this.typeRegistry.Analytics__DataspaceRepresentation, true), true),
100709
101016
  };
100710
101017
  }
100711
- buildKeyParams(input) {
100712
- return { Id: input.data.Id };
100713
- }
100714
101018
  get cacheControl() {
100715
101019
  return { type: "max-age", maxAge: 60 };
100716
101020
  }
@@ -100781,6 +101085,7 @@
100781
101085
  this.namespace = "oas";
100782
101086
  this.typeName = "Analytics__AnalyticsWorkspace";
100783
101087
  this.implementedInterfaces = [];
101088
+ this.idField = "Id";
100784
101089
  }
100785
101090
  get fields() {
100786
101091
  return {
@@ -100795,9 +101100,6 @@
100795
101100
  ApiName: new BaseScalarFieldDef(false),
100796
101101
  };
100797
101102
  }
100798
- buildKeyParams(input) {
100799
- return { Id: input.data.Id };
100800
- }
100801
101103
  get cacheControl() {
100802
101104
  return { type: "max-age", maxAge: 60 };
100803
101105
  }
@@ -100811,6 +101113,7 @@
100811
101113
  this.namespace = "oas";
100812
101114
  this.typeName = "Analytics__DataspaceRepresentation";
100813
101115
  this.implementedInterfaces = [];
101116
+ this.idField = "Id";
100814
101117
  }
100815
101118
  get fields() {
100816
101119
  return {
@@ -100821,9 +101124,6 @@
100821
101124
  DeveloperName: new BaseScalarFieldDef(true),
100822
101125
  };
100823
101126
  }
100824
- buildKeyParams(input) {
100825
- return { Id: input.data.Id };
100826
- }
100827
101127
  get cacheControl() {
100828
101128
  return { type: "max-age", maxAge: 60 };
100829
101129
  }
@@ -102001,6 +102301,7 @@
102001
102301
  this.namespace = "oas";
102002
102302
  this.typeName = "RecordRepresentation";
102003
102303
  this.implementedInterfaces = ["Record"];
102304
+ this.idField = "Id";
102004
102305
  }
102005
102306
  get fields() {
102006
102307
  return {
@@ -102044,9 +102345,6 @@
102044
102345
  AnyType: new BaseObjectFieldDef(this.typeRegistry.AnyType, true),
102045
102346
  };
102046
102347
  }
102047
- buildKeyParams(input) {
102048
- return { Id: input.data.Id };
102049
- }
102050
102348
  get cacheControl() {
102051
102349
  return { type: "max-age", maxAge: 60 };
102052
102350
  }
@@ -102176,6 +102474,7 @@
102176
102474
  this.namespace = "oas";
102177
102475
  this.typeName = "Setup__EntityRepresentation";
102178
102476
  this.implementedInterfaces = [];
102477
+ this.idField = "Id";
102179
102478
  }
102180
102479
  get fields() {
102181
102480
  return {
@@ -102214,9 +102513,6 @@
102214
102513
  AnyType: new BaseObjectFieldDef(this.typeRegistry.AnyType, true),
102215
102514
  };
102216
102515
  }
102217
- buildKeyParams(input) {
102218
- return { Id: input.data.Id };
102219
- }
102220
102516
  get cacheControl() {
102221
102517
  return { type: "max-age", maxAge: 60 };
102222
102518
  }
@@ -102391,6 +102687,7 @@
102391
102687
  this.namespace = "oas";
102392
102688
  this.typeName = "Setup__ListViewRow";
102393
102689
  this.implementedInterfaces = [];
102690
+ this.idField = "id";
102394
102691
  }
102395
102692
  get fields() {
102396
102693
  return {
@@ -102399,9 +102696,6 @@
102399
102696
  columns: new BaseArrayFieldDef(new BaseObjectFieldDef(this.typeRegistry.Setup__ListScalarField, true), false),
102400
102697
  };
102401
102698
  }
102402
- buildKeyParams(input) {
102403
- return { id: input.data.id };
102404
- }
102405
102699
  get cacheControl() {
102406
102700
  return { type: "max-age", maxAge: 60 };
102407
102701
  }
@@ -104351,6 +104645,7 @@
104351
104645
 
104352
104646
  let graphql$1;
104353
104647
  let graphql_imperative$1;
104648
+ let graphql_imperative_legacy;
104354
104649
  let useOneStoreGraphQL = false;
104355
104650
  const serviceRequirements = {
104356
104651
  instrumentCommand: {
@@ -104410,18 +104705,24 @@
104410
104705
  this.exposeRefresh = true;
104411
104706
  }
104412
104707
  getCommand() {
104413
- return new graphql_ctor({ ...this.config, query: resolveAst(this.config.query) }, documentRootType, services);
104708
+ return new graphql_ctor(this.config, documentRootType, services);
104414
104709
  }
104415
104710
  };
104416
104711
  const graphql_imperative_ctor = services.instrumentCommand(buildCommandClass(services.auraGraphQLNormalizedCacheControlCommand), 'graphql_imperative');
104417
- graphql_imperative$1 = buildAsyncGraphQLImperativeLegacyInvoker(({ config, assertIsValid }) => {
104712
+ graphql_imperative$1 = buildAsyncGraphQLImperativeInvoker(({ params, assertIsValid }) => {
104713
+ const config = params[0];
104418
104714
  const _ = assertIsValid;
104419
104715
  _(config, CONFIG_SCHEMA);
104420
- return new graphql_imperative_ctor({ ...config, query: resolveAst(config.query) }, documentRootType, services);
104716
+ return new graphql_imperative_ctor(config, documentRootType, services);
104717
+ }, true);
104718
+ graphql_imperative_legacy = buildAsyncGraphQLImperativeLegacyInvoker(({ config, assertIsValid }) => {
104719
+ const _ = assertIsValid;
104720
+ _(config, CONFIG_SCHEMA);
104721
+ return new graphql_imperative_ctor(config, documentRootType, services);
104421
104722
  });
104422
104723
  useOneStoreGraphQL = services.featureFlags?.get('useOneStoreGraphQL') ?? false;
104423
104724
  if (provisionedCallback) {
104424
- provisionedCallback(graphql$1, graphql_imperative$1, useOneStoreGraphQL);
104725
+ provisionedCallback(graphql$1, graphql_imperative$1, graphql_imperative_legacy, useOneStoreGraphQL);
104425
104726
  }
104426
104727
  }, (_err) => { });
104427
104728
  function registerCallback(cb) {
@@ -104429,10 +104730,10 @@
104429
104730
  provisionedCallback = cb;
104430
104731
  }
104431
104732
  else {
104432
- cb(graphql$1, graphql_imperative$1, useOneStoreGraphQL);
104733
+ cb(graphql$1, graphql_imperative$1, graphql_imperative_legacy, useOneStoreGraphQL);
104433
104734
  }
104434
104735
  }
104435
- // version: 1.383.0-d85dce8db1
104736
+ // version: 1.384.0-835fd13f44
104436
104737
 
104437
104738
  function createFragmentMap(documentNode) {
104438
104739
  const fragments = {};
@@ -130384,11 +130685,15 @@
130384
130685
  return cacheSnapshot;
130385
130686
  }
130386
130687
 
130688
+ // Wire Adapters
130387
130689
  let graphql;
130388
130690
  let graphqlBatch;
130389
130691
  // Imperative GET Adapters
130390
130692
  let graphql_imperative;
130391
130693
  let graphqlBatch_imperative;
130694
+ let refreshGraphQL = (data) => {
130695
+ return refresh$3(data, 'refreshUiApi');
130696
+ };
130392
130697
  // Adapter Metadata
130393
130698
  const graphqlMetadata = { apiFamily: keyPrefix$1, name: 'graphql', ttl: 900000 };
130394
130699
  const graphqlBatchMetadata = { apiFamily: keyPrefix$1, name: 'graphqlBatch' };
@@ -130410,10 +130715,16 @@
130410
130715
  ({ graphql, graphqlBatch, graphql_imperative, graphqlBatch_imperative } = bindExportsTo(luvio));
130411
130716
  // We register the callback here rather than above withDefaultLuvio because we want environments
130412
130717
  // that don't have onestore bootstrapped with the required services to default to the luvio versions of the adapters
130413
- registerCallback((oneStoreGraphql, oneStoreGraphql_imperative, useOneStoreGraphQL) => {
130718
+ registerCallback((oneStoreGraphql, oneStoreGraphql_imperative, oneStoreGraphql_imperative_legacy, useOneStoreGraphQL) => {
130414
130719
  if (useOneStoreGraphQL) {
130415
130720
  graphql = oneStoreGraphql;
130416
- graphql_imperative = oneStoreGraphql_imperative;
130721
+ graphql_imperative = oneStoreGraphql_imperative_legacy;
130722
+ refreshGraphQL = (data) => {
130723
+ if (typeof data?.refresh === 'function') {
130724
+ return data.refresh();
130725
+ }
130726
+ throw new Error('Component attempted to refresh a GraphQL result that is not refreshable');
130727
+ };
130417
130728
  }
130418
130729
  });
130419
130730
  });
@@ -130920,14 +131231,7 @@
130920
131231
  configuration: { ...configurationForGraphQLAdapters$1 },
130921
131232
  instrument: instrument$1,
130922
131233
  });
130923
- function refreshGraphQL(data) {
130924
- // If OneStore data, call its refresh instead
130925
- if (typeof data?.refresh === 'function') {
130926
- return data.refresh();
130927
- }
130928
- return refresh$3(data, 'refreshUiApi');
130929
- }
130930
- // version: 1.383.0-d85dce8db1
131234
+ // version: 1.384.0-835fd13f44
130931
131235
 
130932
131236
  // On core the unstable adapters are re-exported with different names,
130933
131237
  // we want to match them here.
@@ -130939,7 +131243,7 @@
130939
131243
  gql: gql,
130940
131244
  get graphql () { return graphql; },
130941
131245
  get graphqlBatch () { return graphqlBatch; },
130942
- refreshGraphQL: refreshGraphQL,
131246
+ get refreshGraphQL () { return refreshGraphQL; },
130943
131247
  get unstable_getActionOverrides_imperative () { return unstable_getActionOverrides_imperative; },
130944
131248
  get unstable_getFlexipageFormulaOverrides_imperative () { return unstable_getFlexipageFormulaOverrides_imperative; },
130945
131249
  get unstable_getGlobalActions_imperative () { return unstable_getGlobalActions_imperative; },
@@ -131079,7 +131383,7 @@
131079
131383
  unstable_graphQL_imperative = createImperativeAdapter(luvio, createInstrumentedAdapter(ldsAdapter, adapterMetadata), adapterMetadata);
131080
131384
  graphQLImperative = ldsAdapter;
131081
131385
  });
131082
- // version: 1.383.0-d85dce8db1
131386
+ // version: 1.384.0-835fd13f44
131083
131387
 
131084
131388
  var gqlApi = /*#__PURE__*/Object.freeze({
131085
131389
  __proto__: null,
@@ -131878,7 +132182,7 @@
131878
132182
  function register(r) {
131879
132183
  callbacks$1.forEach((callback) => callback(r));
131880
132184
  }
131881
- // version: 1.383.0-b9875fc4e1
132185
+ // version: 1.384.0-cb845692ac
131882
132186
 
131883
132187
  /**
131884
132188
  * Copyright (c) 2022, Salesforce, Inc.,
@@ -133215,4 +133519,4 @@
133215
133519
  exports.subscribeToAdapter = subscribeToAdapter;
133216
133520
 
133217
133521
  }));
133218
- // version: 1.383.0-b9875fc4e1
133522
+ // version: 1.384.0-cb845692ac