@orchestrator-ui/orchestrator-ui-components 3.10.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/.turbo/turbo-build.log +9 -9
  2. package/.turbo/turbo-lint.log +2 -11
  3. package/.turbo/turbo-test.log +6 -6
  4. package/CHANGELOG.md +319 -307
  5. package/dist/index.d.ts +812 -794
  6. package/dist/index.js +1047 -488
  7. package/dist/index.js.map +1 -1
  8. package/eslint.config.js +5 -0
  9. package/package.json +6 -7
  10. package/src/components/WfoForms/UserInputForm.tsx +0 -1
  11. package/src/components/WfoForms/formFields/AcceptField.tsx +2 -2
  12. package/src/components/WfoForms/formFields/ListSelectField.tsx +0 -1
  13. package/src/components/WfoForms/formFields/SelectField/SelectField.tsx +1 -1
  14. package/src/components/WfoForms/formFields/deprecated/ImsNodeIdField.tsx +2 -2
  15. package/src/components/WfoForms/formFields/deprecated/ImsPortIdField.tsx +2 -2
  16. package/src/components/WfoForms/formFields/deprecated/VlanField.tsx +11 -11
  17. package/src/components/WfoPageTemplate/WfoPageHeader/WfoHamburgerMenu.tsx +1 -1
  18. package/src/components/WfoSubscription/WfoCustomerDescriptionsField.tsx +2 -3
  19. package/src/components/WfoTable/WfoTableSettingsModal/WfoTableSettingsModal.tsx +1 -1
  20. package/src/components/WfoWorkflowSteps/WfoStep/WfoStep.tsx +4 -2
  21. package/src/components/WfoWorkflowSteps/WfoWorkflowStepList/WfoWorkflowStepList.tsx +4 -6
  22. package/src/configuration/version.ts +1 -1
  23. package/src/pages/processes/WfoProcessDetail.tsx +3 -3
  24. package/src/rtk/api.ts +4 -2
  25. package/src/types/types.ts +1 -1
  26. package/src/utils/getDefaultTableConfig.ts +20 -16
  27. package/src/utils/getEnvironmentVariables.ts +13 -10
  28. package/eslintrc.js +0 -3
  29. package/src/stories/Button.jsx +0 -62
  30. package/src/stories/Button.stories.js +0 -45
  31. package/src/stories/Configure.mdx +0 -452
  32. package/src/stories/Header.jsx +0 -74
  33. package/src/stories/Header.stories.js +0 -23
  34. package/src/stories/Page.jsx +0 -89
  35. package/src/stories/Page.stories.js +0 -25
  36. package/src/stories/assets/accessibility.png +0 -0
  37. package/src/stories/assets/accessibility.svg +0 -5
  38. package/src/stories/assets/addon-library.png +0 -0
  39. package/src/stories/assets/assets.png +0 -0
  40. package/src/stories/assets/context.png +0 -0
  41. package/src/stories/assets/discord.svg +0 -15
  42. package/src/stories/assets/docs.png +0 -0
  43. package/src/stories/assets/figma-plugin.png +0 -0
  44. package/src/stories/assets/github.svg +0 -3
  45. package/src/stories/assets/share.png +0 -0
  46. package/src/stories/assets/styling.png +0 -0
  47. package/src/stories/assets/testing.png +0 -0
  48. package/src/stories/assets/theming.png +0 -0
  49. package/src/stories/assets/tutorials.svg +0 -12
  50. package/src/stories/assets/youtube.svg +0 -4
  51. package/src/stories/button.css +0 -30
  52. package/src/stories/colors.mdx +0 -13
  53. package/src/stories/header.css +0 -32
  54. package/src/stories/page.css +0 -69
package/dist/index.js CHANGED
@@ -26798,7 +26798,7 @@ var PolicyResource = /* @__PURE__ */ ((PolicyResource2) => {
26798
26798
  })(PolicyResource || {});
26799
26799
 
26800
26800
  // src/configuration/version.ts
26801
- var ORCHESTRATOR_UI_LIBRARY_VERSION = "3.10.0";
26801
+ var ORCHESTRATOR_UI_LIBRARY_VERSION = "4.0.1";
26802
26802
 
26803
26803
  // src/types/types.ts
26804
26804
  var EngineStatus = /* @__PURE__ */ ((EngineStatus3) => {
@@ -28609,19 +28609,9 @@ function freezeDraftable(val) {
28609
28609
  return isDraftable(val) ? produce(val, () => {
28610
28610
  }) : val;
28611
28611
  }
28612
- function emplace(map, key, handler) {
28613
- if (map.has(key)) {
28614
- let value = map.get(key);
28615
- if (handler.update) {
28616
- value = handler.update(value, key, map);
28617
- map.set(key, value);
28618
- }
28619
- return value;
28620
- }
28621
- if (!handler.insert) throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage2(10) : "No insert provided for key not already in map");
28622
- const inserted = handler.insert(key, map);
28623
- map.set(key, inserted);
28624
- return inserted;
28612
+ function getOrInsertComputed(map, key, compute) {
28613
+ if (map.has(key)) return map.get(key);
28614
+ return map.set(key, compute(key)).get(key);
28625
28615
  }
28626
28616
  function isImmutableDefault(value) {
28627
28617
  return typeof value !== "object" || value == null || Object.isFrozen(value);
@@ -28759,7 +28749,7 @@ function isPlain(val) {
28759
28749
  const type = typeof val;
28760
28750
  return val == null || type === "string" || type === "boolean" || type === "number" || Array.isArray(val) || isPlainObject(val);
28761
28751
  }
28762
- function findNonSerializableValue(value, path = "", isSerializable = isPlain, getEntries, ignoredPaths = [], cache3) {
28752
+ function findNonSerializableValue(value, path = "", isSerializable = isPlain, getEntries, ignoredPaths = [], cache2) {
28763
28753
  let foundNestedSerializable;
28764
28754
  if (!isSerializable(value)) {
28765
28755
  return {
@@ -28770,7 +28760,7 @@ function findNonSerializableValue(value, path = "", isSerializable = isPlain, ge
28770
28760
  if (typeof value !== "object" || value === null) {
28771
28761
  return false;
28772
28762
  }
28773
- if (cache3?.has(value)) return false;
28763
+ if (cache2?.has(value)) return false;
28774
28764
  const entries = getEntries != null ? getEntries(value) : Object.entries(value);
28775
28765
  const hasIgnoredPaths = ignoredPaths.length > 0;
28776
28766
  for (const [key, nestedValue] of entries) {
@@ -28793,13 +28783,13 @@ function findNonSerializableValue(value, path = "", isSerializable = isPlain, ge
28793
28783
  };
28794
28784
  }
28795
28785
  if (typeof nestedValue === "object") {
28796
- foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache3);
28786
+ foundNestedSerializable = findNonSerializableValue(nestedValue, nestedPath, isSerializable, getEntries, ignoredPaths, cache2);
28797
28787
  if (foundNestedSerializable) {
28798
28788
  return foundNestedSerializable;
28799
28789
  }
28800
28790
  }
28801
28791
  }
28802
- if (cache3 && isNestedFrozen(value)) cache3.add(value);
28792
+ if (cache2 && isNestedFrozen(value)) cache2.add(value);
28803
28793
  return false;
28804
28794
  }
28805
28795
  function isNestedFrozen(value) {
@@ -28825,7 +28815,7 @@ function createSerializableStateInvariantMiddleware(options = {}) {
28825
28815
  ignoreActions = false,
28826
28816
  disableCache = false
28827
28817
  } = options;
28828
- const cache3 = !disableCache && WeakSet ? /* @__PURE__ */ new WeakSet() : void 0;
28818
+ const cache2 = !disableCache && WeakSet ? /* @__PURE__ */ new WeakSet() : void 0;
28829
28819
  return (storeAPI) => (next) => (action) => {
28830
28820
  if (!isAction(action)) {
28831
28821
  return next(action);
@@ -28834,7 +28824,7 @@ function createSerializableStateInvariantMiddleware(options = {}) {
28834
28824
  const measureUtils = getTimeMeasureUtils(warnAfter, "SerializableStateInvariantMiddleware");
28835
28825
  if (!ignoreActions && !(ignoredActions.length && ignoredActions.indexOf(action.type) !== -1)) {
28836
28826
  measureUtils.measureTime(() => {
28837
- const foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache3);
28827
+ const foundActionNonSerializableValue = findNonSerializableValue(action, "", isSerializable, getEntries, ignoredActionPaths, cache2);
28838
28828
  if (foundActionNonSerializableValue) {
28839
28829
  const {
28840
28830
  keyPath,
@@ -28847,7 +28837,7 @@ function createSerializableStateInvariantMiddleware(options = {}) {
28847
28837
  if (!ignoreState) {
28848
28838
  measureUtils.measureTime(() => {
28849
28839
  const state = storeAPI.getState();
28850
- const foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache3);
28840
+ const foundStateNonSerializableValue = findNonSerializableValue(state, "", isSerializable, getEntries, ignoredPaths, cache2);
28851
28841
  if (foundStateNonSerializableValue) {
28852
28842
  const {
28853
28843
  keyPath,
@@ -28919,7 +28909,6 @@ var createQueueWithTimer = (timeout) => {
28919
28909
  setTimeout(notify, timeout);
28920
28910
  };
28921
28911
  };
28922
- var rAF = typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10);
28923
28912
  var autoBatchEnhancer = (options = {
28924
28913
  type: "raf"
28925
28914
  }) => (next) => (...args) => {
@@ -28928,7 +28917,10 @@ var autoBatchEnhancer = (options = {
28928
28917
  let shouldNotifyAtEndOfTick = false;
28929
28918
  let notificationQueued = false;
28930
28919
  const listeners = /* @__PURE__ */ new Set();
28931
- const queueCallback = options.type === "tick" ? queueMicrotask : options.type === "raf" ? rAF : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
28920
+ const queueCallback = options.type === "tick" ? queueMicrotask : options.type === "raf" ? (
28921
+ // requestAnimationFrame won't exist in SSR environments. Fall back to a vague approximation just to keep from erroring.
28922
+ typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame : createQueueWithTimer(10)
28923
+ ) : options.type === "callback" ? options.queueNotification : createQueueWithTimer(options.timeout);
28932
28924
  const notifyListeners = () => {
28933
28925
  notificationQueued = false;
28934
28926
  if (shouldNotifyAtEndOfTick) {
@@ -28983,6 +28975,7 @@ function configureStore(options) {
28983
28975
  reducer = void 0,
28984
28976
  middleware,
28985
28977
  devTools = true,
28978
+ duplicateMiddlewareCheck = true,
28986
28979
  preloadedState = void 0,
28987
28980
  enhancers = void 0
28988
28981
  } = options || {};
@@ -29009,6 +29002,15 @@ function configureStore(options) {
29009
29002
  if (process.env.NODE_ENV !== "production" && finalMiddleware.some((item) => typeof item !== "function")) {
29010
29003
  throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage2(4) : "each middleware provided to configureStore must be a function");
29011
29004
  }
29005
+ if (process.env.NODE_ENV !== "production" && duplicateMiddlewareCheck) {
29006
+ let middlewareReferences = /* @__PURE__ */ new Set();
29007
+ finalMiddleware.forEach((middleware2) => {
29008
+ if (middlewareReferences.has(middleware2)) {
29009
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage2(42) : "Duplicate middleware references found when creating the store. Ensure that each middleware is only included once.");
29010
+ }
29011
+ middlewareReferences.add(middleware2);
29012
+ });
29013
+ }
29012
29014
  let finalCompose = compose;
29013
29015
  if (devTools) {
29014
29016
  finalCompose = composeWithDevTools({
@@ -29260,6 +29262,7 @@ var miniSerializeError = (value) => {
29260
29262
  message: String(value)
29261
29263
  };
29262
29264
  };
29265
+ var externalAbortMessage = "External signal was aborted";
29263
29266
  var createAsyncThunk = /* @__PURE__ */ (() => {
29264
29267
  function createAsyncThunk2(typePrefix, payloadCreator, options) {
29265
29268
  const fulfilled = createAction(typePrefix + "/fulfilled", (payload, requestId, arg, meta) => ({
@@ -29293,7 +29296,9 @@ var createAsyncThunk = /* @__PURE__ */ (() => {
29293
29296
  condition: error?.name === "ConditionError"
29294
29297
  }
29295
29298
  }));
29296
- function actionCreator(arg) {
29299
+ function actionCreator(arg, {
29300
+ signal
29301
+ } = {}) {
29297
29302
  return (dispatch, getState, extra) => {
29298
29303
  const requestId = options?.idGenerator ? options.idGenerator(arg) : nanoid();
29299
29304
  const abortController = new AbortController();
@@ -29303,6 +29308,15 @@ var createAsyncThunk = /* @__PURE__ */ (() => {
29303
29308
  abortReason = reason;
29304
29309
  abortController.abort();
29305
29310
  }
29311
+ if (signal) {
29312
+ if (signal.aborted) {
29313
+ abort(externalAbortMessage);
29314
+ } else {
29315
+ signal.addEventListener("abort", () => abort(externalAbortMessage), {
29316
+ once: true
29317
+ });
29318
+ }
29319
+ }
29306
29320
  const promise = async function() {
29307
29321
  let finalAction;
29308
29322
  try {
@@ -29504,6 +29518,7 @@ function buildCreateSlice({
29504
29518
  }
29505
29519
  const selectSelf = (state) => state;
29506
29520
  const injectedSelectorCache = /* @__PURE__ */ new Map();
29521
+ const injectedStateCache = /* @__PURE__ */ new WeakMap();
29507
29522
  let _reducer;
29508
29523
  function reducer(state, action) {
29509
29524
  if (!_reducer) _reducer = buildReducer();
@@ -29518,7 +29533,7 @@ function buildCreateSlice({
29518
29533
  let sliceState = state[reducerPath2];
29519
29534
  if (typeof sliceState === "undefined") {
29520
29535
  if (injected) {
29521
- sliceState = getInitialState();
29536
+ sliceState = getOrInsertComputed(injectedStateCache, selectSlice, getInitialState);
29522
29537
  } else if (process.env.NODE_ENV !== "production") {
29523
29538
  throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage2(15) : "selectSlice returned undefined for an uninjected slice reducer");
29524
29539
  }
@@ -29526,17 +29541,13 @@ function buildCreateSlice({
29526
29541
  return sliceState;
29527
29542
  }
29528
29543
  function getSelectors(selectState = selectSelf) {
29529
- const selectorCache = emplace(injectedSelectorCache, injected, {
29530
- insert: () => /* @__PURE__ */ new WeakMap()
29531
- });
29532
- return emplace(selectorCache, selectState, {
29533
- insert: () => {
29534
- const map = {};
29535
- for (const [name2, selector] of Object.entries(options.selectors ?? {})) {
29536
- map[name2] = wrapSelector(selector, selectState, getInitialState, injected);
29537
- }
29538
- return map;
29544
+ const selectorCache = getOrInsertComputed(injectedSelectorCache, injected, () => /* @__PURE__ */ new WeakMap());
29545
+ return getOrInsertComputed(selectorCache, selectState, () => {
29546
+ const map = {};
29547
+ for (const [name2, selector] of Object.entries(options.selectors ?? {})) {
29548
+ map[name2] = wrapSelector(selector, selectState, () => getOrInsertComputed(injectedStateCache, selectState, getInitialState), injected);
29539
29549
  }
29550
+ return map;
29540
29551
  });
29541
29552
  }
29542
29553
  return {
@@ -29706,6 +29717,24 @@ function formatProdErrorMessage2(code) {
29706
29717
  return `Minified Redux Toolkit error #${code}; visit https://redux-toolkit.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
29707
29718
  }
29708
29719
 
29720
+ // ../../node_modules/@standard-schema/utils/dist/index.js
29721
+ var SchemaError = class extends Error {
29722
+ /**
29723
+ * Creates a schema error with useful information.
29724
+ *
29725
+ * @param issues The schema issues.
29726
+ */
29727
+ constructor(issues) {
29728
+ super(issues[0].message);
29729
+ /**
29730
+ * The schema issues.
29731
+ */
29732
+ __publicField(this, "issues");
29733
+ this.name = "SchemaError";
29734
+ this.issues = issues;
29735
+ }
29736
+ };
29737
+
29709
29738
  // ../../node_modules/@reduxjs/toolkit/dist/query/rtk-query.modern.mjs
29710
29739
  var QueryStatus = /* @__PURE__ */ ((QueryStatus2) => {
29711
29740
  QueryStatus2["uninitialized"] = "uninitialized";
@@ -29779,6 +29808,10 @@ function joinUrls(base, url) {
29779
29808
  url = withoutLeadingSlash(url);
29780
29809
  return `${base}${delimiter}${url}`;
29781
29810
  }
29811
+ function getOrInsert(map, key, value) {
29812
+ if (map.has(key)) return map.get(key);
29813
+ return map.set(key, value).get(key);
29814
+ }
29782
29815
  var defaultFetchFn = (...args) => fetch(...args);
29783
29816
  var defaultValidateStatus = (response) => response.status >= 200 && response.status <= 299;
29784
29817
  var defaultIsJsonContentType = (headers) => (
@@ -29956,9 +29989,15 @@ function isQueryDefinition(e) {
29956
29989
  function isMutationDefinition(e) {
29957
29990
  return e.type === "mutation";
29958
29991
  }
29992
+ function isInfiniteQueryDefinition(e) {
29993
+ return e.type === "infinitequery";
29994
+ }
29995
+ function isAnyQueryDefinition(e) {
29996
+ return isQueryDefinition(e) || isInfiniteQueryDefinition(e);
29997
+ }
29959
29998
  function calculateProvidedBy(description, result, error, queryArg, meta, assertTagTypes) {
29960
29999
  if (isFunction(description)) {
29961
- return description(result, error, queryArg, meta).map(expandTagDescription).map(assertTagTypes);
30000
+ return description(result, error, queryArg, meta).filter(isNotNullish).map(expandTagDescription).map(assertTagTypes);
29962
30001
  }
29963
30002
  if (Array.isArray(description)) {
29964
30003
  return description.map(expandTagDescription).map(assertTagTypes);
@@ -29981,6 +30020,7 @@ var isUpsertQuery = (arg) => typeof arg[forceQueryFnSymbol] === "function";
29981
30020
  function buildInitiate({
29982
30021
  serializeQueryArgs,
29983
30022
  queryThunk,
30023
+ infiniteQueryThunk,
29984
30024
  mutationThunk,
29985
30025
  api,
29986
30026
  context
@@ -29994,6 +30034,7 @@ function buildInitiate({
29994
30034
  } = api.internalActions;
29995
30035
  return {
29996
30036
  buildInitiateQuery,
30037
+ buildInitiateInfiniteQuery,
29997
30038
  buildInitiateMutation,
29998
30039
  getRunningQueryThunk,
29999
30040
  getRunningMutationThunk,
@@ -30033,7 +30074,7 @@ You must add the middleware for RTK-Query to function correctly!`);
30033
30074
  }
30034
30075
  }
30035
30076
  }
30036
- function buildInitiateQuery(endpointName, endpointDefinition) {
30077
+ function buildInitiateAnyQuery(endpointName, endpointDefinition) {
30037
30078
  const queryAction = (arg, {
30038
30079
  subscribe = true,
30039
30080
  forceRefetch,
@@ -30046,7 +30087,8 @@ You must add the middleware for RTK-Query to function correctly!`);
30046
30087
  endpointDefinition,
30047
30088
  endpointName
30048
30089
  });
30049
- const thunk2 = queryThunk({
30090
+ let thunk2;
30091
+ const commonThunkArgs = {
30050
30092
  ...rest,
30051
30093
  type: "query",
30052
30094
  subscribe,
@@ -30056,7 +30098,22 @@ You must add the middleware for RTK-Query to function correctly!`);
30056
30098
  originalArgs: arg,
30057
30099
  queryCacheKey,
30058
30100
  [forceQueryFnSymbol]: forceQueryFn
30059
- });
30101
+ };
30102
+ if (isQueryDefinition(endpointDefinition)) {
30103
+ thunk2 = queryThunk(commonThunkArgs);
30104
+ } else {
30105
+ const {
30106
+ direction,
30107
+ initialPageParam
30108
+ } = rest;
30109
+ thunk2 = infiniteQueryThunk({
30110
+ ...commonThunkArgs,
30111
+ // Supply these even if undefined. This helps with a field existence
30112
+ // check over in `buildSlice.ts`
30113
+ direction,
30114
+ initialPageParam
30115
+ });
30116
+ }
30060
30117
  const selector = api.endpoints[endpointName].select(arg);
30061
30118
  const thunkResult = dispatch(thunk2);
30062
30119
  const stateAfter = selector(getState());
@@ -30114,9 +30171,8 @@ You must add the middleware for RTK-Query to function correctly!`);
30114
30171
  }
30115
30172
  });
30116
30173
  if (!runningQuery && !skippedSynchronously && !forceQueryFn) {
30117
- const running = runningQueries.get(dispatch) || {};
30174
+ const running = getOrInsert(runningQueries, dispatch, {});
30118
30175
  running[queryCacheKey] = statePromise;
30119
- runningQueries.set(dispatch, running);
30120
30176
  statePromise.then(() => {
30121
30177
  delete running[queryCacheKey];
30122
30178
  if (!countObjectKeys(running)) {
@@ -30128,6 +30184,14 @@ You must add the middleware for RTK-Query to function correctly!`);
30128
30184
  };
30129
30185
  return queryAction;
30130
30186
  }
30187
+ function buildInitiateQuery(endpointName, endpointDefinition) {
30188
+ const queryAction = buildInitiateAnyQuery(endpointName, endpointDefinition);
30189
+ return queryAction;
30190
+ }
30191
+ function buildInitiateInfiniteQuery(endpointName, endpointDefinition) {
30192
+ const infiniteQueryAction = buildInitiateAnyQuery(endpointName, endpointDefinition);
30193
+ return infiniteQueryAction;
30194
+ }
30131
30195
  function buildInitiateMutation(endpointName) {
30132
30196
  return (arg, {
30133
30197
  track = true,
@@ -30189,9 +30253,30 @@ You must add the middleware for RTK-Query to function correctly!`);
30189
30253
  };
30190
30254
  }
30191
30255
  }
30256
+ var NamedSchemaError = class extends SchemaError {
30257
+ constructor(issues, value, schemaName, _bqMeta) {
30258
+ super(issues);
30259
+ this.value = value;
30260
+ this.schemaName = schemaName;
30261
+ this._bqMeta = _bqMeta;
30262
+ }
30263
+ };
30264
+ async function parseWithSchema(schema, data, schemaName, bqMeta) {
30265
+ const result = await schema["~standard"].validate(data);
30266
+ if (result.issues) {
30267
+ throw new NamedSchemaError(result.issues, data, schemaName, bqMeta);
30268
+ }
30269
+ return result.value;
30270
+ }
30192
30271
  function defaultTransformResponse(baseQueryReturnValue) {
30193
30272
  return baseQueryReturnValue;
30194
30273
  }
30274
+ var addShouldAutoBatch = (arg = {}) => {
30275
+ return {
30276
+ ...arg,
30277
+ [SHOULD_AUTOBATCH]: true
30278
+ };
30279
+ };
30195
30280
  function buildThunks({
30196
30281
  reducerPath,
30197
30282
  baseQuery,
@@ -30200,7 +30285,11 @@ function buildThunks({
30200
30285
  },
30201
30286
  serializeQueryArgs,
30202
30287
  api,
30203
- assertTagType
30288
+ assertTagType,
30289
+ selectors,
30290
+ onSchemaFailure,
30291
+ catchSchemaFailure: globalCatchSchemaFailure,
30292
+ skipSchemaValidation: globalSkipSchemaValidation
30204
30293
  }) {
30205
30294
  const patchQueryData = (endpointName, arg, patches, updateProvided) => (dispatch, getState) => {
30206
30295
  const endpointDefinition = endpointDefinitions[endpointName];
@@ -30221,11 +30310,19 @@ function buildThunks({
30221
30310
  getState()
30222
30311
  );
30223
30312
  const providedTags = calculateProvidedBy(endpointDefinition.providesTags, newValue.data, void 0, arg, {}, assertTagType);
30224
- dispatch(api.internalActions.updateProvidedBy({
30313
+ dispatch(api.internalActions.updateProvidedBy([{
30225
30314
  queryCacheKey,
30226
30315
  providedTags
30227
- }));
30316
+ }]));
30228
30317
  };
30318
+ function addToStart(items, item, max = 0) {
30319
+ const newItems = [item, ...items];
30320
+ return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
30321
+ }
30322
+ function addToEnd(items, item, max = 0) {
30323
+ const newItems = [...items, item];
30324
+ return max && newItems.length > max ? newItems.slice(1) : newItems;
30325
+ }
30229
30326
  const updateQueryData = (endpointName, arg, updateRecipe, updateProvided = true) => (dispatch, getState) => {
30230
30327
  const endpointDefinition = api.endpoints[endpointName];
30231
30328
  const currentState = endpointDefinition.select(arg)(
@@ -30268,13 +30365,17 @@ function buildThunks({
30268
30365
  return ret;
30269
30366
  };
30270
30367
  const upsertQueryData = (endpointName, arg, value) => (dispatch) => {
30271
- return dispatch(api.endpoints[endpointName].initiate(arg, {
30368
+ const res = dispatch(api.endpoints[endpointName].initiate(arg, {
30272
30369
  subscribe: false,
30273
30370
  forceRefetch: true,
30274
30371
  [forceQueryFnSymbol]: () => ({
30275
30372
  data: value
30276
30373
  })
30277
30374
  }));
30375
+ return res;
30376
+ };
30377
+ const getTransformCallbackForEndpoint = (endpointDefinition, transformFieldName) => {
30378
+ return endpointDefinition.query && endpointDefinition[transformFieldName] ? endpointDefinition[transformFieldName] : defaultTransformResponse;
30278
30379
  };
30279
30380
  const executeEndpoint = async (arg, {
30280
30381
  signal,
@@ -30286,9 +30387,12 @@ function buildThunks({
30286
30387
  extra
30287
30388
  }) => {
30288
30389
  const endpointDefinition = endpointDefinitions[arg.endpointName];
30390
+ const {
30391
+ metaSchema,
30392
+ skipSchemaValidation = globalSkipSchemaValidation
30393
+ } = endpointDefinition;
30289
30394
  try {
30290
- let transformResponse = defaultTransformResponse;
30291
- let result;
30395
+ let transformResponse = getTransformCallbackForEndpoint(endpointDefinition, "transformResponse");
30292
30396
  const baseQueryApi = {
30293
30397
  signal,
30294
30398
  abort,
@@ -30301,76 +30405,209 @@ function buildThunks({
30301
30405
  queryCacheKey: arg.type === "query" ? arg.queryCacheKey : void 0
30302
30406
  };
30303
30407
  const forceQueryFn = arg.type === "query" ? arg[forceQueryFnSymbol] : void 0;
30304
- if (forceQueryFn) {
30305
- result = forceQueryFn();
30306
- } else if (endpointDefinition.query) {
30307
- result = await baseQuery(endpointDefinition.query(arg.originalArgs), baseQueryApi, endpointDefinition.extraOptions);
30308
- if (endpointDefinition.transformResponse) {
30309
- transformResponse = endpointDefinition.transformResponse;
30408
+ let finalQueryReturnValue;
30409
+ const fetchPage = async (data, param, maxPages, previous) => {
30410
+ if (param == null && data.pages.length) {
30411
+ return Promise.resolve({
30412
+ data
30413
+ });
30310
30414
  }
30311
- } else {
30312
- result = await endpointDefinition.queryFn(arg.originalArgs, baseQueryApi, endpointDefinition.extraOptions, (arg2) => baseQuery(arg2, baseQueryApi, endpointDefinition.extraOptions));
30313
- }
30314
- if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
30315
- const what = endpointDefinition.query ? "`baseQuery`" : "`queryFn`";
30316
- let err;
30317
- if (!result) {
30318
- err = `${what} did not return anything.`;
30319
- } else if (typeof result !== "object") {
30320
- err = `${what} did not return an object.`;
30321
- } else if (result.error && result.data) {
30322
- err = `${what} returned an object containing both \`error\` and \`result\`.`;
30323
- } else if (result.error === void 0 && result.data === void 0) {
30324
- err = `${what} returned an object containing neither a valid \`error\` and \`result\`. At least one of them should not be \`undefined\``;
30415
+ const finalQueryArg = {
30416
+ queryArg: arg.originalArgs,
30417
+ pageParam: param
30418
+ };
30419
+ const pageResponse = await executeRequest(finalQueryArg);
30420
+ const addTo = previous ? addToStart : addToEnd;
30421
+ return {
30422
+ data: {
30423
+ pages: addTo(data.pages, pageResponse.data, maxPages),
30424
+ pageParams: addTo(data.pageParams, param, maxPages)
30425
+ },
30426
+ meta: pageResponse.meta
30427
+ };
30428
+ };
30429
+ async function executeRequest(finalQueryArg) {
30430
+ let result;
30431
+ const {
30432
+ extraOptions,
30433
+ argSchema,
30434
+ rawResponseSchema,
30435
+ responseSchema
30436
+ } = endpointDefinition;
30437
+ if (argSchema && !skipSchemaValidation) {
30438
+ finalQueryArg = await parseWithSchema(
30439
+ argSchema,
30440
+ finalQueryArg,
30441
+ "argSchema",
30442
+ {}
30443
+ // we don't have a meta yet, so we can't pass it
30444
+ );
30445
+ }
30446
+ if (forceQueryFn) {
30447
+ result = forceQueryFn();
30448
+ } else if (endpointDefinition.query) {
30449
+ result = await baseQuery(endpointDefinition.query(finalQueryArg), baseQueryApi, extraOptions);
30325
30450
  } else {
30326
- for (const key of Object.keys(result)) {
30327
- if (key !== "error" && key !== "data" && key !== "meta") {
30328
- err = `The object returned by ${what} has the unknown property ${key}.`;
30329
- break;
30451
+ result = await endpointDefinition.queryFn(finalQueryArg, baseQueryApi, extraOptions, (arg2) => baseQuery(arg2, baseQueryApi, extraOptions));
30452
+ }
30453
+ if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
30454
+ const what = endpointDefinition.query ? "`baseQuery`" : "`queryFn`";
30455
+ let err;
30456
+ if (!result) {
30457
+ err = `${what} did not return anything.`;
30458
+ } else if (typeof result !== "object") {
30459
+ err = `${what} did not return an object.`;
30460
+ } else if (result.error && result.data) {
30461
+ err = `${what} returned an object containing both \`error\` and \`result\`.`;
30462
+ } else if (result.error === void 0 && result.data === void 0) {
30463
+ err = `${what} returned an object containing neither a valid \`error\` and \`result\`. At least one of them should not be \`undefined\``;
30464
+ } else {
30465
+ for (const key of Object.keys(result)) {
30466
+ if (key !== "error" && key !== "data" && key !== "meta") {
30467
+ err = `The object returned by ${what} has the unknown property ${key}.`;
30468
+ break;
30469
+ }
30330
30470
  }
30331
30471
  }
30472
+ if (err) {
30473
+ console.error(`Error encountered handling the endpoint ${arg.endpointName}.
30474
+ ${err}
30475
+ It needs to return an object with either the shape \`{ data: <value> }\` or \`{ error: <value> }\` that may contain an optional \`meta\` property.
30476
+ Object returned was:`, result);
30477
+ }
30478
+ }
30479
+ if (result.error) throw new HandledError(result.error, result.meta);
30480
+ let {
30481
+ data
30482
+ } = result;
30483
+ if (rawResponseSchema && !skipSchemaValidation) {
30484
+ data = await parseWithSchema(rawResponseSchema, result.data, "rawResponseSchema", result.meta);
30332
30485
  }
30333
- if (err) {
30334
- console.error(`Error encountered handling the endpoint ${arg.endpointName}.
30335
- ${err}
30336
- It needs to return an object with either the shape \`{ data: <value> }\` or \`{ error: <value> }\` that may contain an optional \`meta\` property.
30337
- Object returned was:`, result);
30486
+ let transformedResponse = await transformResponse(data, result.meta, finalQueryArg);
30487
+ if (responseSchema && !skipSchemaValidation) {
30488
+ transformedResponse = await parseWithSchema(responseSchema, transformedResponse, "responseSchema", result.meta);
30489
+ }
30490
+ return {
30491
+ ...result,
30492
+ data: transformedResponse
30493
+ };
30494
+ }
30495
+ if (arg.type === "query" && "infiniteQueryOptions" in endpointDefinition) {
30496
+ const {
30497
+ infiniteQueryOptions
30498
+ } = endpointDefinition;
30499
+ const {
30500
+ maxPages = Infinity
30501
+ } = infiniteQueryOptions;
30502
+ let result;
30503
+ const blankData = {
30504
+ pages: [],
30505
+ pageParams: []
30506
+ };
30507
+ const cachedData = selectors.selectQueryEntry(getState(), arg.queryCacheKey)?.data;
30508
+ const isForcedQueryNeedingRefetch = (
30509
+ // arg.forceRefetch
30510
+ isForcedQuery(arg, getState()) && !arg.direction
30511
+ );
30512
+ const existingData = isForcedQueryNeedingRefetch || !cachedData ? blankData : cachedData;
30513
+ if ("direction" in arg && arg.direction && existingData.pages.length) {
30514
+ const previous = arg.direction === "backward";
30515
+ const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;
30516
+ const param = pageParamFn(infiniteQueryOptions, existingData);
30517
+ result = await fetchPage(existingData, param, maxPages, previous);
30518
+ } else {
30519
+ const {
30520
+ initialPageParam = infiniteQueryOptions.initialPageParam
30521
+ } = arg;
30522
+ const cachedPageParams = cachedData?.pageParams ?? [];
30523
+ const firstPageParam = cachedPageParams[0] ?? initialPageParam;
30524
+ const totalPages = cachedPageParams.length;
30525
+ result = await fetchPage(existingData, firstPageParam, maxPages);
30526
+ if (forceQueryFn) {
30527
+ result = {
30528
+ data: result.data.pages[0]
30529
+ };
30530
+ }
30531
+ for (let i = 1; i < totalPages; i++) {
30532
+ const param = getNextPageParam(infiniteQueryOptions, result.data);
30533
+ result = await fetchPage(result.data, param, maxPages);
30534
+ }
30338
30535
  }
30536
+ finalQueryReturnValue = result;
30537
+ } else {
30538
+ finalQueryReturnValue = await executeRequest(arg.originalArgs);
30339
30539
  }
30340
- if (result.error) throw new HandledError(result.error, result.meta);
30341
- return fulfillWithValue(await transformResponse(result.data, result.meta, arg.originalArgs), {
30540
+ if (metaSchema && !skipSchemaValidation && finalQueryReturnValue.meta) {
30541
+ finalQueryReturnValue.meta = await parseWithSchema(metaSchema, finalQueryReturnValue.meta, "metaSchema", finalQueryReturnValue.meta);
30542
+ }
30543
+ return fulfillWithValue(finalQueryReturnValue.data, addShouldAutoBatch({
30342
30544
  fulfilledTimeStamp: Date.now(),
30343
- baseQueryMeta: result.meta,
30344
- [SHOULD_AUTOBATCH]: true
30345
- });
30545
+ baseQueryMeta: finalQueryReturnValue.meta
30546
+ }));
30346
30547
  } catch (error) {
30347
- let catchedError = error;
30348
- if (catchedError instanceof HandledError) {
30349
- let transformErrorResponse = defaultTransformResponse;
30350
- if (endpointDefinition.query && endpointDefinition.transformErrorResponse) {
30351
- transformErrorResponse = endpointDefinition.transformErrorResponse;
30352
- }
30548
+ let caughtError = error;
30549
+ if (caughtError instanceof HandledError) {
30550
+ let transformErrorResponse = getTransformCallbackForEndpoint(endpointDefinition, "transformErrorResponse");
30551
+ const {
30552
+ rawErrorResponseSchema,
30553
+ errorResponseSchema
30554
+ } = endpointDefinition;
30555
+ let {
30556
+ value,
30557
+ meta
30558
+ } = caughtError;
30353
30559
  try {
30354
- return rejectWithValue(await transformErrorResponse(catchedError.value, catchedError.meta, arg.originalArgs), {
30355
- baseQueryMeta: catchedError.meta,
30356
- [SHOULD_AUTOBATCH]: true
30357
- });
30560
+ if (rawErrorResponseSchema && !skipSchemaValidation) {
30561
+ value = await parseWithSchema(rawErrorResponseSchema, value, "rawErrorResponseSchema", meta);
30562
+ }
30563
+ if (metaSchema && !skipSchemaValidation) {
30564
+ meta = await parseWithSchema(metaSchema, meta, "metaSchema", meta);
30565
+ }
30566
+ let transformedErrorResponse = await transformErrorResponse(value, meta, arg.originalArgs);
30567
+ if (errorResponseSchema && !skipSchemaValidation) {
30568
+ transformedErrorResponse = await parseWithSchema(errorResponseSchema, transformedErrorResponse, "errorResponseSchema", meta);
30569
+ }
30570
+ return rejectWithValue(transformedErrorResponse, addShouldAutoBatch({
30571
+ baseQueryMeta: meta
30572
+ }));
30358
30573
  } catch (e) {
30359
- catchedError = e;
30574
+ caughtError = e;
30575
+ }
30576
+ }
30577
+ try {
30578
+ if (caughtError instanceof NamedSchemaError) {
30579
+ const info = {
30580
+ endpoint: arg.endpointName,
30581
+ arg: arg.originalArgs,
30582
+ type: arg.type,
30583
+ queryCacheKey: arg.type === "query" ? arg.queryCacheKey : void 0
30584
+ };
30585
+ endpointDefinition.onSchemaFailure?.(caughtError, info);
30586
+ onSchemaFailure?.(caughtError, info);
30587
+ const {
30588
+ catchSchemaFailure = globalCatchSchemaFailure
30589
+ } = endpointDefinition;
30590
+ if (catchSchemaFailure) {
30591
+ return rejectWithValue(catchSchemaFailure(caughtError, info), addShouldAutoBatch({
30592
+ baseQueryMeta: caughtError._bqMeta
30593
+ }));
30594
+ }
30360
30595
  }
30596
+ } catch (e) {
30597
+ caughtError = e;
30361
30598
  }
30362
30599
  if (typeof process !== "undefined" && process.env.NODE_ENV !== "production") {
30363
30600
  console.error(`An unhandled error occurred processing a request for the endpoint "${arg.endpointName}".
30364
- In the case of an unhandled error, no tags will be "provided" or "invalidated".`, catchedError);
30601
+ In the case of an unhandled error, no tags will be "provided" or "invalidated".`, caughtError);
30365
30602
  } else {
30366
- console.error(catchedError);
30603
+ console.error(caughtError);
30367
30604
  }
30368
- throw catchedError;
30605
+ throw caughtError;
30369
30606
  }
30370
30607
  };
30371
30608
  function isForcedQuery(arg, state) {
30372
- const requestState = state[reducerPath]?.queries?.[arg.queryCacheKey];
30373
- const baseFetchOnMountOrArgChange = state[reducerPath]?.config.refetchOnMountOrArgChange;
30609
+ const requestState = selectors.selectQueryEntry(state, arg.queryCacheKey);
30610
+ const baseFetchOnMountOrArgChange = selectors.selectConfig(state).refetchOnMountOrArgChange;
30374
30611
  const fulfilledVal = requestState?.fulfilledTimeStamp;
30375
30612
  const refetchVal = arg.forceRefetch ?? (arg.subscribe && baseFetchOnMountOrArgChange);
30376
30613
  if (refetchVal) {
@@ -30378,52 +30615,62 @@ In the case of an unhandled error, no tags will be "provided" or "invalidated".`
30378
30615
  }
30379
30616
  return false;
30380
30617
  }
30381
- const queryThunk = createAsyncThunk(`${reducerPath}/executeQuery`, executeEndpoint, {
30382
- getPendingMeta() {
30383
- return {
30384
- startedTimeStamp: Date.now(),
30385
- [SHOULD_AUTOBATCH]: true
30386
- };
30387
- },
30388
- condition(queryThunkArgs, {
30389
- getState
30390
- }) {
30391
- const state = getState();
30392
- const requestState = state[reducerPath]?.queries?.[queryThunkArgs.queryCacheKey];
30393
- const fulfilledVal = requestState?.fulfilledTimeStamp;
30394
- const currentArg = queryThunkArgs.originalArgs;
30395
- const previousArg = requestState?.originalArgs;
30396
- const endpointDefinition = endpointDefinitions[queryThunkArgs.endpointName];
30397
- if (isUpsertQuery(queryThunkArgs)) {
30398
- return true;
30399
- }
30400
- if (requestState?.status === "pending") {
30401
- return false;
30402
- }
30403
- if (isForcedQuery(queryThunkArgs, state)) {
30404
- return true;
30405
- }
30406
- if (isQueryDefinition(endpointDefinition) && endpointDefinition?.forceRefetch?.({
30407
- currentArg,
30408
- previousArg,
30409
- endpointState: requestState,
30410
- state
30411
- })) {
30618
+ const createQueryThunk = () => {
30619
+ const generatedQueryThunk = createAsyncThunk(`${reducerPath}/executeQuery`, executeEndpoint, {
30620
+ getPendingMeta({
30621
+ arg
30622
+ }) {
30623
+ const endpointDefinition = endpointDefinitions[arg.endpointName];
30624
+ return addShouldAutoBatch({
30625
+ startedTimeStamp: Date.now(),
30626
+ ...isInfiniteQueryDefinition(endpointDefinition) ? {
30627
+ direction: arg.direction
30628
+ } : {}
30629
+ });
30630
+ },
30631
+ condition(queryThunkArg, {
30632
+ getState
30633
+ }) {
30634
+ const state = getState();
30635
+ const requestState = selectors.selectQueryEntry(state, queryThunkArg.queryCacheKey);
30636
+ const fulfilledVal = requestState?.fulfilledTimeStamp;
30637
+ const currentArg = queryThunkArg.originalArgs;
30638
+ const previousArg = requestState?.originalArgs;
30639
+ const endpointDefinition = endpointDefinitions[queryThunkArg.endpointName];
30640
+ const direction = queryThunkArg.direction;
30641
+ if (isUpsertQuery(queryThunkArg)) {
30642
+ return true;
30643
+ }
30644
+ if (requestState?.status === "pending") {
30645
+ return false;
30646
+ }
30647
+ if (isForcedQuery(queryThunkArg, state)) {
30648
+ return true;
30649
+ }
30650
+ if (isQueryDefinition(endpointDefinition) && endpointDefinition?.forceRefetch?.({
30651
+ currentArg,
30652
+ previousArg,
30653
+ endpointState: requestState,
30654
+ state
30655
+ })) {
30656
+ return true;
30657
+ }
30658
+ if (fulfilledVal && !direction) {
30659
+ return false;
30660
+ }
30412
30661
  return true;
30413
- }
30414
- if (fulfilledVal) {
30415
- return false;
30416
- }
30417
- return true;
30418
- },
30419
- dispatchConditionRejection: true
30420
- });
30662
+ },
30663
+ dispatchConditionRejection: true
30664
+ });
30665
+ return generatedQueryThunk;
30666
+ };
30667
+ const queryThunk = createQueryThunk();
30668
+ const infiniteQueryThunk = createQueryThunk();
30421
30669
  const mutationThunk = createAsyncThunk(`${reducerPath}/executeMutation`, executeEndpoint, {
30422
30670
  getPendingMeta() {
30423
- return {
30424
- startedTimeStamp: Date.now(),
30425
- [SHOULD_AUTOBATCH]: true
30426
- };
30671
+ return addShouldAutoBatch({
30672
+ startedTimeStamp: Date.now()
30673
+ });
30427
30674
  }
30428
30675
  });
30429
30676
  const hasTheForce = (options) => "force" in options;
@@ -30468,6 +30715,7 @@ In the case of an unhandled error, no tags will be "provided" or "invalidated".`
30468
30715
  return {
30469
30716
  queryThunk,
30470
30717
  mutationThunk,
30718
+ infiniteQueryThunk,
30471
30719
  prefetch,
30472
30720
  updateQueryData,
30473
30721
  upsertQueryData,
@@ -30475,6 +30723,19 @@ In the case of an unhandled error, no tags will be "provided" or "invalidated".`
30475
30723
  buildMatchThunkActions
30476
30724
  };
30477
30725
  }
30726
+ function getNextPageParam(options, {
30727
+ pages,
30728
+ pageParams
30729
+ }) {
30730
+ const lastIndex = pages.length - 1;
30731
+ return options.getNextPageParam(pages[lastIndex], pages, pageParams[lastIndex], pageParams);
30732
+ }
30733
+ function getPreviousPageParam(options, {
30734
+ pages,
30735
+ pageParams
30736
+ }) {
30737
+ return options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams);
30738
+ }
30478
30739
  function calculateProvidedByThunk(action, type, endpointDefinitions, assertTagType) {
30479
30740
  return calculateProvidedBy(endpointDefinitions[action.meta.arg.endpointName][type], isFulfilled(action) ? action.payload : void 0, isRejectedWithValue(action) ? action.payload : void 0, action.meta.arg.originalArgs, "baseQueryMeta" in action.meta ? action.meta.baseQueryMeta : void 0, assertTagType);
30480
30741
  }
@@ -30528,11 +30789,16 @@ function buildSlice({
30528
30789
  substate.originalArgs = arg.originalArgs;
30529
30790
  }
30530
30791
  substate.startedTimeStamp = meta.startedTimeStamp;
30792
+ const endpointDefinition = definitions[meta.arg.endpointName];
30793
+ if (isInfiniteQueryDefinition(endpointDefinition) && "direction" in arg) {
30794
+ ;
30795
+ substate.direction = arg.direction;
30796
+ }
30531
30797
  });
30532
30798
  }
30533
- function writeFulfilledCacheEntry(draft, meta, payload) {
30799
+ function writeFulfilledCacheEntry(draft, meta, payload, upserting) {
30534
30800
  updateQuerySubstateIfExists(draft, meta.arg.queryCacheKey, (substate) => {
30535
- if (substate.requestId !== meta.requestId && !isUpsertQuery(meta.arg)) return;
30801
+ if (substate.requestId !== meta.requestId && !upserting) return;
30536
30802
  const {
30537
30803
  merge
30538
30804
  } = definitions[meta.arg.endpointName];
@@ -30590,12 +30856,18 @@ function buildSlice({
30590
30856
  requestId: action.meta.requestId,
30591
30857
  startedTimeStamp: action.meta.timestamp
30592
30858
  });
30593
- writeFulfilledCacheEntry(draft, {
30594
- arg,
30595
- requestId: action.meta.requestId,
30596
- fulfilledTimeStamp: action.meta.timestamp,
30597
- baseQueryMeta: {}
30598
- }, value);
30859
+ writeFulfilledCacheEntry(
30860
+ draft,
30861
+ {
30862
+ arg,
30863
+ requestId: action.meta.requestId,
30864
+ fulfilledTimeStamp: action.meta.timestamp,
30865
+ baseQueryMeta: {}
30866
+ },
30867
+ value,
30868
+ // We know we're upserting here
30869
+ true
30870
+ );
30599
30871
  }
30600
30872
  },
30601
30873
  prepare: (payload) => {
@@ -30659,7 +30931,8 @@ function buildSlice({
30659
30931
  meta,
30660
30932
  payload
30661
30933
  }) => {
30662
- writeFulfilledCacheEntry(draft, meta, payload);
30934
+ const upserting = isUpsertQuery(meta.arg);
30935
+ writeFulfilledCacheEntry(draft, meta, payload, upserting);
30663
30936
  }).addCase(queryThunk.rejected, (draft, {
30664
30937
  meta: {
30665
30938
  condition,
@@ -30762,34 +31035,33 @@ function buildSlice({
30762
31035
  });
30763
31036
  }
30764
31037
  });
31038
+ const initialInvalidationState = {
31039
+ tags: {},
31040
+ keys: {}
31041
+ };
30765
31042
  const invalidationSlice = createSlice({
30766
31043
  name: `${reducerPath}/invalidation`,
30767
- initialState,
31044
+ initialState: initialInvalidationState,
30768
31045
  reducers: {
30769
31046
  updateProvidedBy: {
30770
31047
  reducer(draft, action) {
30771
- var _a, _b;
30772
- const {
31048
+ var _a, _b, _c;
31049
+ for (const {
30773
31050
  queryCacheKey,
30774
31051
  providedTags
30775
- } = action.payload;
30776
- for (const tagTypeSubscriptions of Object.values(draft)) {
30777
- for (const idSubscriptions of Object.values(tagTypeSubscriptions)) {
30778
- const foundAt = idSubscriptions.indexOf(queryCacheKey);
30779
- if (foundAt !== -1) {
30780
- idSubscriptions.splice(foundAt, 1);
31052
+ } of action.payload) {
31053
+ removeCacheKeyFromTags(draft, queryCacheKey);
31054
+ for (const {
31055
+ type,
31056
+ id
31057
+ } of providedTags) {
31058
+ const subscribedQueries = (_b = (_a = draft.tags)[type] ?? (_a[type] = {}))[_c = id || "__internal_without_id"] ?? (_b[_c] = []);
31059
+ const alreadySubscribed = subscribedQueries.includes(queryCacheKey);
31060
+ if (!alreadySubscribed) {
31061
+ subscribedQueries.push(queryCacheKey);
30781
31062
  }
30782
31063
  }
30783
- }
30784
- for (const {
30785
- type,
30786
- id
30787
- } of providedTags) {
30788
- const subscribedQueries = (_a = draft[type] ?? (draft[type] = {}))[_b = id || "__internal_without_id"] ?? (_a[_b] = []);
30789
- const alreadySubscribed = subscribedQueries.includes(queryCacheKey);
30790
- if (!alreadySubscribed) {
30791
- subscribedQueries.push(queryCacheKey);
30792
- }
31064
+ draft.keys[queryCacheKey] = providedTags;
30793
31065
  }
30794
31066
  },
30795
31067
  prepare: prepareAutoBatched()
@@ -30801,22 +31073,15 @@ function buildSlice({
30801
31073
  queryCacheKey
30802
31074
  }
30803
31075
  }) => {
30804
- for (const tagTypeSubscriptions of Object.values(draft)) {
30805
- for (const idSubscriptions of Object.values(tagTypeSubscriptions)) {
30806
- const foundAt = idSubscriptions.indexOf(queryCacheKey);
30807
- if (foundAt !== -1) {
30808
- idSubscriptions.splice(foundAt, 1);
30809
- }
30810
- }
30811
- }
31076
+ removeCacheKeyFromTags(draft, queryCacheKey);
30812
31077
  }).addMatcher(hasRehydrationInfo, (draft, action) => {
30813
- var _a, _b;
31078
+ var _a, _b, _c;
30814
31079
  const {
30815
31080
  provided
30816
31081
  } = extractRehydrationInfo(action);
30817
31082
  for (const [type, incomingTags] of Object.entries(provided)) {
30818
31083
  for (const [id, cacheKeys] of Object.entries(incomingTags)) {
30819
- const subscribedQueries = (_a = draft[type] ?? (draft[type] = {}))[_b = id || "__internal_without_id"] ?? (_a[_b] = []);
31084
+ const subscribedQueries = (_b = (_a = draft.tags)[type] ?? (_a[type] = {}))[_c = id || "__internal_without_id"] ?? (_b[_c] = []);
30820
31085
  for (const queryCacheKey of cacheKeys) {
30821
31086
  const alreadySubscribed = subscribedQueries.includes(queryCacheKey);
30822
31087
  if (!alreadySubscribed) {
@@ -30826,17 +31091,51 @@ function buildSlice({
30826
31091
  }
30827
31092
  }
30828
31093
  }).addMatcher(isAnyOf(isFulfilled(queryThunk), isRejectedWithValue(queryThunk)), (draft, action) => {
30829
- const providedTags = calculateProvidedByThunk(action, "providesTags", definitions, assertTagType);
30830
- const {
30831
- queryCacheKey
30832
- } = action.meta.arg;
30833
- invalidationSlice.caseReducers.updateProvidedBy(draft, invalidationSlice.actions.updateProvidedBy({
30834
- queryCacheKey,
30835
- providedTags
30836
- }));
31094
+ writeProvidedTagsForQueries(draft, [action]);
31095
+ }).addMatcher(querySlice.actions.cacheEntriesUpserted.match, (draft, action) => {
31096
+ const mockActions = action.payload.map(({
31097
+ queryDescription,
31098
+ value
31099
+ }) => {
31100
+ return {
31101
+ type: "UNKNOWN",
31102
+ payload: value,
31103
+ meta: {
31104
+ requestStatus: "fulfilled",
31105
+ requestId: "UNKNOWN",
31106
+ arg: queryDescription
31107
+ }
31108
+ };
31109
+ });
31110
+ writeProvidedTagsForQueries(draft, mockActions);
30837
31111
  });
30838
31112
  }
30839
31113
  });
31114
+ function removeCacheKeyFromTags(draft, queryCacheKey) {
31115
+ const existingTags = draft.keys[queryCacheKey] ?? [];
31116
+ for (const tag of existingTags) {
31117
+ const tagType = tag.type;
31118
+ const tagId = tag.id ?? "__internal_without_id";
31119
+ const tagSubscriptions = draft.tags[tagType]?.[tagId];
31120
+ if (tagSubscriptions) {
31121
+ draft.tags[tagType][tagId] = tagSubscriptions.filter((qc) => qc !== queryCacheKey);
31122
+ }
31123
+ }
31124
+ delete draft.keys[queryCacheKey];
31125
+ }
31126
+ function writeProvidedTagsForQueries(draft, actions2) {
31127
+ const providedByEntries = actions2.map((action) => {
31128
+ const providedTags = calculateProvidedByThunk(action, "providesTags", definitions, assertTagType);
31129
+ const {
31130
+ queryCacheKey
31131
+ } = action.meta.arg;
31132
+ return {
31133
+ queryCacheKey,
31134
+ providedTags
31135
+ };
31136
+ });
31137
+ invalidationSlice.caseReducers.updateProvidedBy(draft, invalidationSlice.actions.updateProvidedBy(providedByEntries));
31138
+ }
30840
31139
  const subscriptionSlice = createSlice({
30841
31140
  name: `${reducerPath}/subscriptions`,
30842
31141
  initialState,
@@ -30930,9 +31229,15 @@ function buildSelectors({
30930
31229
  const selectSkippedMutation = (state) => defaultMutationSubState;
30931
31230
  return {
30932
31231
  buildQuerySelector,
31232
+ buildInfiniteQuerySelector,
30933
31233
  buildMutationSelector,
30934
31234
  selectInvalidatedBy,
30935
- selectCachedArgsForQuery
31235
+ selectCachedArgsForQuery,
31236
+ selectApiState,
31237
+ selectQueries,
31238
+ selectMutations,
31239
+ selectQueryEntry,
31240
+ selectConfig
30936
31241
  };
30937
31242
  function withRequestFlags(substate) {
30938
31243
  return {
@@ -30940,29 +31245,74 @@ function buildSelectors({
30940
31245
  ...getRequestStatusFlags(substate.status)
30941
31246
  };
30942
31247
  }
30943
- function selectInternalState(rootState) {
31248
+ function selectApiState(rootState) {
30944
31249
  const state = rootState[reducerPath];
30945
31250
  if (process.env.NODE_ENV !== "production") {
30946
31251
  if (!state) {
30947
- if (selectInternalState.triggered) return state;
30948
- selectInternalState.triggered = true;
31252
+ if (selectApiState.triggered) return state;
31253
+ selectApiState.triggered = true;
30949
31254
  console.error(`Error: No data found at \`state.${reducerPath}\`. Did you forget to add the reducer to the store?`);
30950
31255
  }
30951
31256
  }
30952
31257
  return state;
30953
31258
  }
30954
- function buildQuerySelector(endpointName, endpointDefinition) {
31259
+ function selectQueries(rootState) {
31260
+ return selectApiState(rootState)?.queries;
31261
+ }
31262
+ function selectQueryEntry(rootState, cacheKey) {
31263
+ return selectQueries(rootState)?.[cacheKey];
31264
+ }
31265
+ function selectMutations(rootState) {
31266
+ return selectApiState(rootState)?.mutations;
31267
+ }
31268
+ function selectConfig(rootState) {
31269
+ return selectApiState(rootState)?.config;
31270
+ }
31271
+ function buildAnyQuerySelector(endpointName, endpointDefinition, combiner) {
30955
31272
  return (queryArgs) => {
31273
+ if (queryArgs === skipToken) {
31274
+ return createSelector2(selectSkippedQuery, combiner);
31275
+ }
30956
31276
  const serializedArgs = serializeQueryArgs({
30957
31277
  queryArgs,
30958
31278
  endpointDefinition,
30959
31279
  endpointName
30960
31280
  });
30961
- const selectQuerySubstate = (state) => selectInternalState(state)?.queries?.[serializedArgs] ?? defaultQuerySubState;
30962
- const finalSelectQuerySubState = queryArgs === skipToken ? selectSkippedQuery : selectQuerySubstate;
30963
- return createSelector2(finalSelectQuerySubState, withRequestFlags);
31281
+ const selectQuerySubstate = (state) => selectQueryEntry(state, serializedArgs) ?? defaultQuerySubState;
31282
+ return createSelector2(selectQuerySubstate, combiner);
30964
31283
  };
30965
31284
  }
31285
+ function buildQuerySelector(endpointName, endpointDefinition) {
31286
+ return buildAnyQuerySelector(endpointName, endpointDefinition, withRequestFlags);
31287
+ }
31288
+ function buildInfiniteQuerySelector(endpointName, endpointDefinition) {
31289
+ const {
31290
+ infiniteQueryOptions
31291
+ } = endpointDefinition;
31292
+ function withInfiniteQueryResultFlags(substate) {
31293
+ const stateWithRequestFlags = {
31294
+ ...substate,
31295
+ ...getRequestStatusFlags(substate.status)
31296
+ };
31297
+ const {
31298
+ isLoading,
31299
+ isError: isError2,
31300
+ direction
31301
+ } = stateWithRequestFlags;
31302
+ const isForward = direction === "forward";
31303
+ const isBackward = direction === "backward";
31304
+ return {
31305
+ ...stateWithRequestFlags,
31306
+ hasNextPage: getHasNextPage(infiniteQueryOptions, stateWithRequestFlags.data),
31307
+ hasPreviousPage: getHasPreviousPage(infiniteQueryOptions, stateWithRequestFlags.data),
31308
+ isFetchingNextPage: isLoading && isForward,
31309
+ isFetchingPreviousPage: isLoading && isBackward,
31310
+ isFetchNextPageError: isError2 && isForward,
31311
+ isFetchPreviousPageError: isError2 && isBackward
31312
+ };
31313
+ }
31314
+ return buildAnyQuerySelector(endpointName, endpointDefinition, withInfiniteQueryResultFlags);
31315
+ }
30966
31316
  function buildMutationSelector() {
30967
31317
  return (id) => {
30968
31318
  let mutationId;
@@ -30971,7 +31321,7 @@ function buildSelectors({
30971
31321
  } else {
30972
31322
  mutationId = id;
30973
31323
  }
30974
- const selectMutationSubstate = (state) => selectInternalState(state)?.mutations?.[mutationId] ?? defaultMutationSubState;
31324
+ const selectMutationSubstate = (state) => selectApiState(state)?.mutations?.[mutationId] ?? defaultMutationSubState;
30975
31325
  const finalSelectMutationSubstate = mutationId === skipToken ? selectSkippedMutation : selectMutationSubstate;
30976
31326
  return createSelector2(finalSelectMutationSubstate, withRequestFlags);
30977
31327
  };
@@ -30979,8 +31329,8 @@ function buildSelectors({
30979
31329
  function selectInvalidatedBy(state, tags) {
30980
31330
  const apiState = state[reducerPath];
30981
31331
  const toInvalidate = /* @__PURE__ */ new Set();
30982
- for (const tag of tags.map(expandTagDescription)) {
30983
- const provided = apiState.provided[tag.type];
31332
+ for (const tag of tags.filter(isNotNullish).map(expandTagDescription)) {
31333
+ const provided = apiState.provided.tags[tag.type];
30984
31334
  if (!provided) {
30985
31335
  continue;
30986
31336
  }
@@ -31005,11 +31355,19 @@ function buildSelectors({
31005
31355
  }));
31006
31356
  }
31007
31357
  function selectCachedArgsForQuery(state, queryName) {
31008
- return Object.values(state[reducerPath].queries).filter(
31358
+ return Object.values(selectQueries(state)).filter(
31009
31359
  (entry) => entry?.endpointName === queryName && entry.status !== "uninitialized"
31010
31360
  /* uninitialized */
31011
31361
  ).map((entry) => entry.originalArgs);
31012
31362
  }
31363
+ function getHasNextPage(options, data) {
31364
+ if (!data) return false;
31365
+ return getNextPageParam(options, data) != null;
31366
+ }
31367
+ function getHasPreviousPage(options, data) {
31368
+ if (!data || !options.getPreviousPageParam) return false;
31369
+ return getPreviousPageParam(options, data) != null;
31370
+ }
31013
31371
  }
31014
31372
  var cache = WeakMap ? /* @__PURE__ */ new WeakMap() : void 0;
31015
31373
  var defaultSerializeQueryArgs = ({
@@ -31121,6 +31479,11 @@ function buildCreateApi(...modules) {
31121
31479
  ...x,
31122
31480
  type: "mutation"
31123
31481
  /* mutation */
31482
+ }),
31483
+ infiniteQuery: (x) => ({
31484
+ ...x,
31485
+ type: "infinitequery"
31486
+ /* infinitequery */
31124
31487
  })
31125
31488
  });
31126
31489
  for (const [endpointName, definition] of Object.entries(evaluatedEndpoints)) {
@@ -31132,6 +31495,25 @@ function buildCreateApi(...modules) {
31132
31495
  }
31133
31496
  continue;
31134
31497
  }
31498
+ if (typeof process !== "undefined" && process.env.NODE_ENV === "development") {
31499
+ if (isInfiniteQueryDefinition(definition)) {
31500
+ const {
31501
+ infiniteQueryOptions
31502
+ } = definition;
31503
+ const {
31504
+ maxPages,
31505
+ getPreviousPageParam: getPreviousPageParam2
31506
+ } = infiniteQueryOptions;
31507
+ if (typeof maxPages === "number") {
31508
+ if (maxPages < 1) {
31509
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage2(40) : `maxPages for endpoint '${endpointName}' must be a number greater than 0`);
31510
+ }
31511
+ if (typeof getPreviousPageParam2 !== "function") {
31512
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage2(41) : `getPreviousPageParam for endpoint '${endpointName}' must be a function if maxPages is used`);
31513
+ }
31514
+ }
31515
+ }
31516
+ }
31135
31517
  context.endpointDefinitions[endpointName] = definition;
31136
31518
  for (const m of initializedModules) {
31137
31519
  m.injectEndpoint(endpointName, definition);
@@ -31283,7 +31665,11 @@ var buildCacheCollectionHandler = ({
31283
31665
  api,
31284
31666
  queryThunk,
31285
31667
  context,
31286
- internalState
31668
+ internalState,
31669
+ selectors: {
31670
+ selectQueryEntry,
31671
+ selectConfig
31672
+ }
31287
31673
  }) => {
31288
31674
  const {
31289
31675
  removeQueryResult,
@@ -31297,8 +31683,9 @@ var buildCacheCollectionHandler = ({
31297
31683
  }
31298
31684
  const currentRemovalTimeouts = {};
31299
31685
  const handler = (action, mwApi, internalState2) => {
31686
+ const state = mwApi.getState();
31687
+ const config = selectConfig(state);
31300
31688
  if (canTriggerUnsubscribe(action)) {
31301
- const state = mwApi.getState()[reducerPath];
31302
31689
  let queryCacheKeys;
31303
31690
  if (cacheEntriesUpserted.match(action)) {
31304
31691
  queryCacheKeys = action.payload.map((entry) => entry.queryDescription.queryCacheKey);
@@ -31308,9 +31695,7 @@ var buildCacheCollectionHandler = ({
31308
31695
  } = unsubscribeQueryResult.match(action) ? action.payload : action.meta.arg;
31309
31696
  queryCacheKeys = [queryCacheKey];
31310
31697
  }
31311
- for (const queryCacheKey of queryCacheKeys) {
31312
- handleUnsubscribe(queryCacheKey, state.queries[queryCacheKey]?.endpointName, mwApi, state.config);
31313
- }
31698
+ handleUnsubscribeMany(queryCacheKeys, mwApi, config);
31314
31699
  }
31315
31700
  if (api.util.resetApiState.match(action)) {
31316
31701
  for (const [key, timeout] of Object.entries(currentRemovalTimeouts)) {
@@ -31319,15 +31704,19 @@ var buildCacheCollectionHandler = ({
31319
31704
  }
31320
31705
  }
31321
31706
  if (context.hasRehydrationInfo(action)) {
31322
- const state = mwApi.getState()[reducerPath];
31323
31707
  const {
31324
31708
  queries
31325
31709
  } = context.extractRehydrationInfo(action);
31326
- for (const [queryCacheKey, queryState] of Object.entries(queries)) {
31327
- handleUnsubscribe(queryCacheKey, queryState?.endpointName, mwApi, state.config);
31328
- }
31710
+ handleUnsubscribeMany(Object.keys(queries), mwApi, config);
31329
31711
  }
31330
31712
  };
31713
+ function handleUnsubscribeMany(cacheKeys, api2, config) {
31714
+ const state = api2.getState();
31715
+ for (const queryCacheKey of cacheKeys) {
31716
+ const entry = selectQueryEntry(state, queryCacheKey);
31717
+ handleUnsubscribe(queryCacheKey, entry?.endpointName, api2, config);
31718
+ }
31719
+ }
31331
31720
  function handleUnsubscribe(queryCacheKey, endpointName, api2, config) {
31332
31721
  const endpointDefinition = context.endpointDefinitions[endpointName];
31333
31722
  const keepUnusedDataFor = endpointDefinition?.keepUnusedDataFor ?? config.keepUnusedDataFor;
@@ -31359,7 +31748,11 @@ var buildCacheLifecycleHandler = ({
31359
31748
  context,
31360
31749
  queryThunk,
31361
31750
  mutationThunk,
31362
- internalState
31751
+ internalState,
31752
+ selectors: {
31753
+ selectQueryEntry,
31754
+ selectApiState
31755
+ }
31363
31756
  }) => {
31364
31757
  const isQueryThunk = isAsyncThunkAction(queryThunk);
31365
31758
  const isMutationThunk = isAsyncThunkAction(mutationThunk);
@@ -31385,9 +31778,9 @@ var buildCacheLifecycleHandler = ({
31385
31778
  const handler = (action, mwApi, stateBefore) => {
31386
31779
  const cacheKey = getCacheKey(action);
31387
31780
  function checkForNewCacheKey(endpointName, cacheKey2, requestId, originalArgs) {
31388
- const oldState = stateBefore[reducerPath].queries[cacheKey2];
31389
- const state = mwApi.getState()[reducerPath].queries[cacheKey2];
31390
- if (!oldState && state) {
31781
+ const oldEntry = selectQueryEntry(stateBefore, cacheKey2);
31782
+ const newEntry = selectQueryEntry(mwApi.getState(), cacheKey2);
31783
+ if (!oldEntry && newEntry) {
31391
31784
  handleNewKey(endpointName, originalArgs, cacheKey2, mwApi, requestId);
31392
31785
  }
31393
31786
  }
@@ -31446,14 +31839,14 @@ var buildCacheLifecycleHandler = ({
31446
31839
  cacheDataLoaded.catch(() => {
31447
31840
  });
31448
31841
  lifecycleMap[queryCacheKey] = lifecycle;
31449
- const selector = api.endpoints[endpointName].select(endpointDefinition.type === "query" ? originalArgs : queryCacheKey);
31842
+ const selector = api.endpoints[endpointName].select(isAnyQueryDefinition(endpointDefinition) ? originalArgs : queryCacheKey);
31450
31843
  const extra = mwApi.dispatch((_2, __, extra2) => extra2);
31451
31844
  const lifecycleApi = {
31452
31845
  ...mwApi,
31453
31846
  getCacheEntry: () => selector(mwApi.getState()),
31454
31847
  requestId,
31455
31848
  extra,
31456
- updateCachedData: endpointDefinition.type === "query" ? (updateRecipe) => mwApi.dispatch(api.util.updateQueryData(endpointName, originalArgs, updateRecipe)) : void 0,
31849
+ updateCachedData: isAnyQueryDefinition(endpointDefinition) ? (updateRecipe) => mwApi.dispatch(api.util.updateQueryData(endpointName, originalArgs, updateRecipe)) : void 0,
31457
31850
  cacheDataLoaded,
31458
31851
  cacheEntryRemoved
31459
31852
  };
@@ -31514,11 +31907,14 @@ var buildInvalidationByTagsHandler = ({
31514
31907
  }
31515
31908
  };
31516
31909
  function hasPendingRequests(state) {
31517
- for (const key in state.queries) {
31518
- if (state.queries[key]?.status === "pending") return true;
31519
- }
31520
- for (const key in state.mutations) {
31521
- if (state.mutations[key]?.status === "pending") return true;
31910
+ const {
31911
+ queries,
31912
+ mutations
31913
+ } = state;
31914
+ for (const cacheRecord of [queries, mutations]) {
31915
+ for (const key in cacheRecord) {
31916
+ if (cacheRecord[key]?.status === "pending") return true;
31917
+ }
31522
31918
  }
31523
31919
  return false;
31524
31920
  }
@@ -31576,6 +31972,13 @@ var buildPollingHandler = ({
31576
31972
  clearPolls();
31577
31973
  }
31578
31974
  };
31975
+ function getCacheEntrySubscriptions(queryCacheKey, api2) {
31976
+ const state = api2.getState()[reducerPath];
31977
+ const querySubState = state.queries[queryCacheKey];
31978
+ const subscriptions = internalState.currentSubscriptions[queryCacheKey];
31979
+ if (!querySubState || querySubState.status === "uninitialized") return;
31980
+ return subscriptions;
31981
+ }
31579
31982
  function startNextPoll({
31580
31983
  queryCacheKey
31581
31984
  }, api2) {
@@ -31689,14 +32092,14 @@ var buildQueryLifecycleHandler = ({
31689
32092
  queryFulfilled.catch(() => {
31690
32093
  });
31691
32094
  lifecycleMap[requestId] = lifecycle;
31692
- const selector = api.endpoints[endpointName].select(endpointDefinition.type === "query" ? originalArgs : requestId);
32095
+ const selector = api.endpoints[endpointName].select(isAnyQueryDefinition(endpointDefinition) ? originalArgs : requestId);
31693
32096
  const extra = mwApi.dispatch((_2, __, extra2) => extra2);
31694
32097
  const lifecycleApi = {
31695
32098
  ...mwApi,
31696
32099
  getCacheEntry: () => selector(mwApi.getState()),
31697
32100
  requestId,
31698
32101
  extra,
31699
- updateCachedData: endpointDefinition.type === "query" ? (updateRecipe) => mwApi.dispatch(api.util.updateQueryData(endpointName, originalArgs, updateRecipe)) : void 0,
32102
+ updateCachedData: isAnyQueryDefinition(endpointDefinition) ? (updateRecipe) => mwApi.dispatch(api.util.updateQueryData(endpointName, originalArgs, updateRecipe)) : void 0,
31700
32103
  queryFulfilled
31701
32104
  };
31702
32105
  onQueryStarted(originalArgs, lifecycleApi);
@@ -31856,7 +32259,10 @@ var coreModule = ({
31856
32259
  refetchOnMountOrArgChange,
31857
32260
  refetchOnFocus,
31858
32261
  refetchOnReconnect,
31859
- invalidationBehavior
32262
+ invalidationBehavior,
32263
+ onSchemaFailure,
32264
+ catchSchemaFailure,
32265
+ skipSchemaValidation
31860
32266
  }, context) {
31861
32267
  enablePatches();
31862
32268
  assertCast(serializeQueryArgs);
@@ -31879,8 +32285,25 @@ var coreModule = ({
31879
32285
  },
31880
32286
  util: {}
31881
32287
  });
32288
+ const selectors = buildSelectors({
32289
+ serializeQueryArgs,
32290
+ reducerPath,
32291
+ createSelector: createSelector2
32292
+ });
32293
+ const {
32294
+ selectInvalidatedBy,
32295
+ selectCachedArgsForQuery,
32296
+ buildQuerySelector,
32297
+ buildInfiniteQuerySelector,
32298
+ buildMutationSelector
32299
+ } = selectors;
32300
+ safeAssign(api.util, {
32301
+ selectInvalidatedBy,
32302
+ selectCachedArgsForQuery
32303
+ });
31882
32304
  const {
31883
32305
  queryThunk,
32306
+ infiniteQueryThunk,
31884
32307
  mutationThunk,
31885
32308
  patchQueryData,
31886
32309
  updateQueryData,
@@ -31893,7 +32316,11 @@ var coreModule = ({
31893
32316
  context,
31894
32317
  api,
31895
32318
  serializeQueryArgs,
31896
- assertTagType
32319
+ assertTagType,
32320
+ selectors,
32321
+ onSchemaFailure,
32322
+ catchSchemaFailure,
32323
+ skipSchemaValidation
31897
32324
  });
31898
32325
  const {
31899
32326
  reducer,
@@ -31901,6 +32328,7 @@ var coreModule = ({
31901
32328
  } = buildSlice({
31902
32329
  context,
31903
32330
  queryThunk,
32331
+ infiniteQueryThunk,
31904
32332
  mutationThunk,
31905
32333
  serializeQueryArgs,
31906
32334
  reducerPath,
@@ -31931,30 +32359,19 @@ var coreModule = ({
31931
32359
  context,
31932
32360
  queryThunk,
31933
32361
  mutationThunk,
32362
+ infiniteQueryThunk,
31934
32363
  api,
31935
- assertTagType
32364
+ assertTagType,
32365
+ selectors
31936
32366
  });
31937
32367
  safeAssign(api.util, middlewareActions);
31938
32368
  safeAssign(api, {
31939
32369
  reducer,
31940
32370
  middleware
31941
32371
  });
31942
- const {
31943
- buildQuerySelector,
31944
- buildMutationSelector,
31945
- selectInvalidatedBy,
31946
- selectCachedArgsForQuery
31947
- } = buildSelectors({
31948
- serializeQueryArgs,
31949
- reducerPath,
31950
- createSelector: createSelector2
31951
- });
31952
- safeAssign(api.util, {
31953
- selectInvalidatedBy,
31954
- selectCachedArgsForQuery
31955
- });
31956
32372
  const {
31957
32373
  buildInitiateQuery,
32374
+ buildInitiateInfiniteQuery,
31958
32375
  buildInitiateMutation,
31959
32376
  getRunningMutationThunk,
31960
32377
  getRunningMutationsThunk,
@@ -31963,6 +32380,7 @@ var coreModule = ({
31963
32380
  } = buildInitiate({
31964
32381
  queryThunk,
31965
32382
  mutationThunk,
32383
+ infiniteQueryThunk,
31966
32384
  api,
31967
32385
  serializeQueryArgs,
31968
32386
  context
@@ -31978,20 +32396,28 @@ var coreModule = ({
31978
32396
  injectEndpoint(endpointName, definition) {
31979
32397
  var _a;
31980
32398
  const anyApi = api;
31981
- (_a = anyApi.endpoints)[endpointName] ?? (_a[endpointName] = {});
32399
+ const endpoint = (_a = anyApi.endpoints)[endpointName] ?? (_a[endpointName] = {});
31982
32400
  if (isQueryDefinition(definition)) {
31983
- safeAssign(anyApi.endpoints[endpointName], {
32401
+ safeAssign(endpoint, {
31984
32402
  name: endpointName,
31985
32403
  select: buildQuerySelector(endpointName, definition),
31986
32404
  initiate: buildInitiateQuery(endpointName, definition)
31987
32405
  }, buildMatchThunkActions(queryThunk, endpointName));
31988
- } else if (isMutationDefinition(definition)) {
31989
- safeAssign(anyApi.endpoints[endpointName], {
32406
+ }
32407
+ if (isMutationDefinition(definition)) {
32408
+ safeAssign(endpoint, {
31990
32409
  name: endpointName,
31991
32410
  select: buildMutationSelector(),
31992
32411
  initiate: buildInitiateMutation(endpointName)
31993
32412
  }, buildMatchThunkActions(mutationThunk, endpointName));
31994
32413
  }
32414
+ if (isInfiniteQueryDefinition(definition)) {
32415
+ safeAssign(endpoint, {
32416
+ name: endpointName,
32417
+ select: buildInfiniteQuerySelector(endpointName, definition),
32418
+ initiate: buildInitiateInfiniteQuery(endpointName, definition)
32419
+ }, buildMatchThunkActions(queryThunk, endpointName));
32420
+ }
31995
32421
  }
31996
32422
  };
31997
32423
  }
@@ -32002,59 +32428,35 @@ var createApi = /* @__PURE__ */ buildCreateApi(coreModule());
32002
32428
  import { batch as rrBatch, useDispatch as rrUseDispatch, useSelector as rrUseSelector, useStore as rrUseStore } from "react-redux";
32003
32429
  import { useCallback, useDebugValue, useEffect as useEffect3, useLayoutEffect, useMemo as useMemo2, useRef as useRef3, useState } from "react";
32004
32430
  import { shallowEqual as shallowEqual2 } from "react-redux";
32005
- import { useEffect, useRef, useMemo } from "react";
32006
- import { useEffect as useEffect2, useRef as useRef2 } from "react";
32007
- import { shallowEqual } from "react-redux";
32008
- import { useContext } from "react";
32009
- import { useEffect as useEffect4 } from "react";
32010
- import * as React from "react";
32011
- import { Provider, ReactReduxContext } from "react-redux";
32012
- function isQueryDefinition2(e) {
32013
- return e.type === "query";
32014
- }
32015
- function isMutationDefinition2(e) {
32016
- return e.type === "mutation";
32017
- }
32018
- function safeAssign2(target, ...args) {
32019
- return Object.assign(target, ...args);
32020
- }
32021
- function capitalize(str) {
32022
- return str.replace(str[0], str[0].toUpperCase());
32023
- }
32024
- function countObjectKeys2(obj) {
32025
- let count = 0;
32026
- for (const _key in obj) {
32027
- count++;
32028
- }
32029
- return count;
32030
- }
32031
- var cache2 = WeakMap ? /* @__PURE__ */ new WeakMap() : void 0;
32032
- var defaultSerializeQueryArgs2 = ({
32033
- endpointName,
32034
- queryArgs
32035
- }) => {
32036
- let serialized = "";
32037
- const cached = cache2?.get(queryArgs);
32038
- if (typeof cached === "string") {
32039
- serialized = cached;
32040
- } else {
32041
- const stringified = JSON.stringify(queryArgs, (key, value) => {
32042
- value = typeof value === "bigint" ? {
32043
- $bigint: value.toString()
32044
- } : value;
32045
- value = isPlainObject(value) ? Object.keys(value).sort().reduce((acc, key2) => {
32046
- acc[key2] = value[key2];
32047
- return acc;
32048
- }, {}) : value;
32049
- return value;
32050
- });
32051
- if (isPlainObject(queryArgs)) {
32052
- cache2?.set(queryArgs, stringified);
32053
- }
32054
- serialized = stringified;
32431
+ import { useEffect, useRef, useMemo } from "react";
32432
+ import { useEffect as useEffect2, useRef as useRef2 } from "react";
32433
+ import { shallowEqual } from "react-redux";
32434
+ import { useContext } from "react";
32435
+ import { useEffect as useEffect4 } from "react";
32436
+ import * as React from "react";
32437
+ import { Provider, ReactReduxContext } from "react-redux";
32438
+ function capitalize(str) {
32439
+ return str.replace(str[0], str[0].toUpperCase());
32440
+ }
32441
+ function countObjectKeys2(obj) {
32442
+ let count = 0;
32443
+ for (const _key in obj) {
32444
+ count++;
32055
32445
  }
32056
- return `${endpointName}(${serialized})`;
32057
- };
32446
+ return count;
32447
+ }
32448
+ function isQueryDefinition2(e) {
32449
+ return e.type === "query";
32450
+ }
32451
+ function isMutationDefinition2(e) {
32452
+ return e.type === "mutation";
32453
+ }
32454
+ function isInfiniteQueryDefinition2(e) {
32455
+ return e.type === "infinitequery";
32456
+ }
32457
+ function safeAssign2(target, ...args) {
32458
+ return Object.assign(target, ...args);
32459
+ }
32058
32460
  var UNINITIALIZED_VALUE = Symbol();
32059
32461
  function useStableQueryArgs(queryArgs, serialize, endpointDefinition, endpointName) {
32060
32462
  const incoming = useMemo(() => ({
@@ -32065,22 +32467,22 @@ function useStableQueryArgs(queryArgs, serialize, endpointDefinition, endpointNa
32065
32467
  endpointName
32066
32468
  }) : queryArgs
32067
32469
  }), [queryArgs, serialize, endpointDefinition, endpointName]);
32068
- const cache22 = useRef(incoming);
32470
+ const cache2 = useRef(incoming);
32069
32471
  useEffect(() => {
32070
- if (cache22.current.serialized !== incoming.serialized) {
32071
- cache22.current = incoming;
32472
+ if (cache2.current.serialized !== incoming.serialized) {
32473
+ cache2.current = incoming;
32072
32474
  }
32073
32475
  }, [incoming]);
32074
- return cache22.current.serialized === incoming.serialized ? cache22.current.queryArgs : queryArgs;
32476
+ return cache2.current.serialized === incoming.serialized ? cache2.current.queryArgs : queryArgs;
32075
32477
  }
32076
32478
  function useShallowStableValue(value) {
32077
- const cache22 = useRef2(value);
32479
+ const cache2 = useRef2(value);
32078
32480
  useEffect2(() => {
32079
- if (!shallowEqual(cache22.current, value)) {
32080
- cache22.current = value;
32481
+ if (!shallowEqual(cache2.current, value)) {
32482
+ cache2.current = value;
32081
32483
  }
32082
32484
  }, [value]);
32083
- return shallowEqual(cache22.current, value) ? cache22.current : value;
32485
+ return shallowEqual(cache2.current, value) ? cache2.current : value;
32084
32486
  }
32085
32487
  var canUseDOM = () => !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
32086
32488
  var isDOM = /* @__PURE__ */ canUseDOM();
@@ -32100,6 +32502,14 @@ var noPendingQueryStateSelector = (selected) => {
32100
32502
  }
32101
32503
  return selected;
32102
32504
  };
32505
+ function pick(obj, ...keys) {
32506
+ const ret = {};
32507
+ keys.forEach((key) => {
32508
+ ret[key] = obj[key];
32509
+ });
32510
+ return ret;
32511
+ }
32512
+ var COMMON_HOOK_DEBUG_FIELDS = ["data", "status", "isLoading", "isSuccess", "isError", "error"];
32103
32513
  function buildHooks({
32104
32514
  api,
32105
32515
  moduleOptions: {
@@ -32118,6 +32528,7 @@ function buildHooks({
32118
32528
  const usePossiblyImmediateEffect = unstable__sideEffectsInRender ? (cb) => cb() : useEffect3;
32119
32529
  return {
32120
32530
  buildQueryHooks,
32531
+ buildInfiniteQueryHooks,
32121
32532
  buildMutationHook,
32122
32533
  usePrefetch
32123
32534
  };
@@ -32127,7 +32538,38 @@ function buildHooks({
32127
32538
  endpointName
32128
32539
  } = lastResult;
32129
32540
  const endpointDefinition = context.endpointDefinitions[endpointName];
32130
- if (serializeQueryArgs({
32541
+ if (queryArgs !== skipToken && serializeQueryArgs({
32542
+ queryArgs: lastResult.originalArgs,
32543
+ endpointDefinition,
32544
+ endpointName
32545
+ }) === serializeQueryArgs({
32546
+ queryArgs,
32547
+ endpointDefinition,
32548
+ endpointName
32549
+ })) lastResult = void 0;
32550
+ }
32551
+ let data = currentState.isSuccess ? currentState.data : lastResult?.data;
32552
+ if (data === void 0) data = currentState.data;
32553
+ const hasData = data !== void 0;
32554
+ const isFetching = currentState.isLoading;
32555
+ const isLoading = (!lastResult || lastResult.isLoading || lastResult.isUninitialized) && !hasData && isFetching;
32556
+ const isSuccess = currentState.isSuccess || hasData && (isFetching && !lastResult?.isError || currentState.isUninitialized);
32557
+ return {
32558
+ ...currentState,
32559
+ data,
32560
+ currentData: currentState.data,
32561
+ isFetching,
32562
+ isLoading,
32563
+ isSuccess
32564
+ };
32565
+ }
32566
+ function infiniteQueryStatePreSelector(currentState, lastResult, queryArgs) {
32567
+ if (lastResult?.endpointName && currentState.isUninitialized) {
32568
+ const {
32569
+ endpointName
32570
+ } = lastResult;
32571
+ const endpointDefinition = context.endpointDefinitions[endpointName];
32572
+ if (queryArgs !== skipToken && serializeQueryArgs({
32131
32573
  queryArgs: lastResult.originalArgs,
32132
32574
  endpointDefinition,
32133
32575
  endpointName
@@ -32160,103 +32602,154 @@ function buildHooks({
32160
32602
  ...options
32161
32603
  })), [endpointName, dispatch, stableDefaultOptions]);
32162
32604
  }
32163
- function buildQueryHooks(name) {
32164
- const useQuerySubscription = (arg, {
32605
+ function useQuerySubscriptionCommonImpl(endpointName, arg, {
32606
+ refetchOnReconnect,
32607
+ refetchOnFocus,
32608
+ refetchOnMountOrArgChange,
32609
+ skip = false,
32610
+ pollingInterval = 0,
32611
+ skipPollingIfUnfocused = false,
32612
+ ...rest
32613
+ } = {}) {
32614
+ const {
32615
+ initiate
32616
+ } = api.endpoints[endpointName];
32617
+ const dispatch = useDispatch3();
32618
+ const subscriptionSelectorsRef = useRef3(void 0);
32619
+ if (!subscriptionSelectorsRef.current) {
32620
+ const returnedValue = dispatch(api.internalActions.internal_getRTKQSubscriptions());
32621
+ if (process.env.NODE_ENV !== "production") {
32622
+ if (typeof returnedValue !== "object" || typeof returnedValue?.type === "string") {
32623
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage2(37) : `Warning: Middleware for RTK-Query API at reducerPath "${api.reducerPath}" has not been added to the store.
32624
+ You must add the middleware for RTK-Query to function correctly!`);
32625
+ }
32626
+ }
32627
+ subscriptionSelectorsRef.current = returnedValue;
32628
+ }
32629
+ const stableArg = useStableQueryArgs(
32630
+ skip ? skipToken : arg,
32631
+ // Even if the user provided a per-endpoint `serializeQueryArgs` with
32632
+ // a consistent return value, _here_ we want to use the default behavior
32633
+ // so we can tell if _anything_ actually changed. Otherwise, we can end up
32634
+ // with a case where the query args did change but the serialization doesn't,
32635
+ // and then we never try to initiate a refetch.
32636
+ defaultSerializeQueryArgs,
32637
+ context.endpointDefinitions[endpointName],
32638
+ endpointName
32639
+ );
32640
+ const stableSubscriptionOptions = useShallowStableValue({
32165
32641
  refetchOnReconnect,
32166
32642
  refetchOnFocus,
32167
- refetchOnMountOrArgChange,
32643
+ pollingInterval,
32644
+ skipPollingIfUnfocused
32645
+ });
32646
+ const initialPageParam = rest.initialPageParam;
32647
+ const stableInitialPageParam = useShallowStableValue(initialPageParam);
32648
+ const promiseRef = useRef3(void 0);
32649
+ let {
32650
+ queryCacheKey,
32651
+ requestId
32652
+ } = promiseRef.current || {};
32653
+ let currentRenderHasSubscription = false;
32654
+ if (queryCacheKey && requestId) {
32655
+ currentRenderHasSubscription = subscriptionSelectorsRef.current.isRequestSubscribed(queryCacheKey, requestId);
32656
+ }
32657
+ const subscriptionRemoved = !currentRenderHasSubscription && promiseRef.current !== void 0;
32658
+ usePossiblyImmediateEffect(() => {
32659
+ if (subscriptionRemoved) {
32660
+ promiseRef.current = void 0;
32661
+ }
32662
+ }, [subscriptionRemoved]);
32663
+ usePossiblyImmediateEffect(() => {
32664
+ const lastPromise = promiseRef.current;
32665
+ if (typeof process !== "undefined" && process.env.NODE_ENV === "removeMeOnCompilation") {
32666
+ console.log(subscriptionRemoved);
32667
+ }
32668
+ if (stableArg === skipToken) {
32669
+ lastPromise?.unsubscribe();
32670
+ promiseRef.current = void 0;
32671
+ return;
32672
+ }
32673
+ const lastSubscriptionOptions = promiseRef.current?.subscriptionOptions;
32674
+ if (!lastPromise || lastPromise.arg !== stableArg) {
32675
+ lastPromise?.unsubscribe();
32676
+ const promise = dispatch(initiate(stableArg, {
32677
+ subscriptionOptions: stableSubscriptionOptions,
32678
+ forceRefetch: refetchOnMountOrArgChange,
32679
+ ...isInfiniteQueryDefinition2(context.endpointDefinitions[endpointName]) ? {
32680
+ initialPageParam: stableInitialPageParam
32681
+ } : {}
32682
+ }));
32683
+ promiseRef.current = promise;
32684
+ } else if (stableSubscriptionOptions !== lastSubscriptionOptions) {
32685
+ lastPromise.updateSubscriptionOptions(stableSubscriptionOptions);
32686
+ }
32687
+ }, [dispatch, initiate, refetchOnMountOrArgChange, stableArg, stableSubscriptionOptions, subscriptionRemoved, stableInitialPageParam, endpointName]);
32688
+ return [promiseRef, dispatch, initiate, stableSubscriptionOptions];
32689
+ }
32690
+ function buildUseQueryState(endpointName, preSelector) {
32691
+ const useQueryState = (arg, {
32168
32692
  skip = false,
32169
- pollingInterval = 0,
32170
- skipPollingIfUnfocused = false
32693
+ selectFromResult
32171
32694
  } = {}) => {
32172
32695
  const {
32173
- initiate
32174
- } = api.endpoints[name];
32175
- const dispatch = useDispatch3();
32176
- const subscriptionSelectorsRef = useRef3(void 0);
32177
- if (!subscriptionSelectorsRef.current) {
32178
- const returnedValue = dispatch(api.internalActions.internal_getRTKQSubscriptions());
32179
- if (process.env.NODE_ENV !== "production") {
32180
- if (typeof returnedValue !== "object" || typeof returnedValue?.type === "string") {
32181
- throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage2(37) : `Warning: Middleware for RTK-Query API at reducerPath "${api.reducerPath}" has not been added to the store.
32182
- You must add the middleware for RTK-Query to function correctly!`);
32696
+ select
32697
+ } = api.endpoints[endpointName];
32698
+ const stableArg = useStableQueryArgs(skip ? skipToken : arg, serializeQueryArgs, context.endpointDefinitions[endpointName], endpointName);
32699
+ const lastValue = useRef3(void 0);
32700
+ const selectDefaultResult = useMemo2(() => (
32701
+ // Normally ts-ignores are bad and should be avoided, but we're
32702
+ // already casting this selector to be `Selector<any>` anyway,
32703
+ // so the inconsistencies don't matter here
32704
+ // @ts-ignore
32705
+ createSelector2([
32706
+ // @ts-ignore
32707
+ select(stableArg),
32708
+ (_2, lastResult) => lastResult,
32709
+ (_2) => stableArg
32710
+ ], preSelector, {
32711
+ memoizeOptions: {
32712
+ resultEqualityCheck: shallowEqual2
32183
32713
  }
32714
+ })
32715
+ ), [select, stableArg]);
32716
+ const querySelector = useMemo2(() => selectFromResult ? createSelector2([selectDefaultResult], selectFromResult, {
32717
+ devModeChecks: {
32718
+ identityFunctionCheck: "never"
32184
32719
  }
32185
- subscriptionSelectorsRef.current = returnedValue;
32186
- }
32187
- const stableArg = useStableQueryArgs(
32188
- skip ? skipToken : arg,
32189
- // Even if the user provided a per-endpoint `serializeQueryArgs` with
32190
- // a consistent return value, _here_ we want to use the default behavior
32191
- // so we can tell if _anything_ actually changed. Otherwise, we can end up
32192
- // with a case where the query args did change but the serialization doesn't,
32193
- // and then we never try to initiate a refetch.
32194
- defaultSerializeQueryArgs2,
32195
- context.endpointDefinitions[name],
32196
- name
32197
- );
32198
- const stableSubscriptionOptions = useShallowStableValue({
32199
- refetchOnReconnect,
32200
- refetchOnFocus,
32201
- pollingInterval,
32202
- skipPollingIfUnfocused
32203
- });
32204
- const lastRenderHadSubscription = useRef3(false);
32205
- const promiseRef = useRef3(void 0);
32206
- let {
32207
- queryCacheKey,
32208
- requestId
32209
- } = promiseRef.current || {};
32210
- let currentRenderHasSubscription = false;
32211
- if (queryCacheKey && requestId) {
32212
- currentRenderHasSubscription = subscriptionSelectorsRef.current.isRequestSubscribed(queryCacheKey, requestId);
32213
- }
32214
- const subscriptionRemoved = !currentRenderHasSubscription && lastRenderHadSubscription.current;
32215
- usePossiblyImmediateEffect(() => {
32216
- lastRenderHadSubscription.current = currentRenderHasSubscription;
32217
- });
32218
- usePossiblyImmediateEffect(() => {
32219
- if (subscriptionRemoved) {
32220
- promiseRef.current = void 0;
32221
- }
32222
- }, [subscriptionRemoved]);
32223
- usePossiblyImmediateEffect(() => {
32224
- const lastPromise = promiseRef.current;
32225
- if (typeof process !== "undefined" && process.env.NODE_ENV === "removeMeOnCompilation") {
32226
- console.log(subscriptionRemoved);
32227
- }
32228
- if (stableArg === skipToken) {
32229
- lastPromise?.unsubscribe();
32230
- promiseRef.current = void 0;
32231
- return;
32232
- }
32233
- const lastSubscriptionOptions = promiseRef.current?.subscriptionOptions;
32234
- if (!lastPromise || lastPromise.arg !== stableArg) {
32235
- lastPromise?.unsubscribe();
32236
- const promise = dispatch(initiate(stableArg, {
32237
- subscriptionOptions: stableSubscriptionOptions,
32238
- forceRefetch: refetchOnMountOrArgChange
32239
- }));
32240
- promiseRef.current = promise;
32241
- } else if (stableSubscriptionOptions !== lastSubscriptionOptions) {
32242
- lastPromise.updateSubscriptionOptions(stableSubscriptionOptions);
32243
- }
32244
- }, [dispatch, initiate, refetchOnMountOrArgChange, stableArg, stableSubscriptionOptions, subscriptionRemoved]);
32245
- useEffect3(() => {
32246
- return () => {
32247
- promiseRef.current?.unsubscribe();
32248
- promiseRef.current = void 0;
32249
- };
32250
- }, []);
32720
+ }) : selectDefaultResult, [selectDefaultResult, selectFromResult]);
32721
+ const currentState = useSelector3((state) => querySelector(state, lastValue.current), shallowEqual2);
32722
+ const store = useStore();
32723
+ const newLastValue = selectDefaultResult(store.getState(), lastValue.current);
32724
+ useIsomorphicLayoutEffect(() => {
32725
+ lastValue.current = newLastValue;
32726
+ }, [newLastValue]);
32727
+ return currentState;
32728
+ };
32729
+ return useQueryState;
32730
+ }
32731
+ function usePromiseRefUnsubscribeOnUnmount(promiseRef) {
32732
+ useEffect3(() => {
32733
+ return () => {
32734
+ promiseRef.current?.unsubscribe?.();
32735
+ promiseRef.current = void 0;
32736
+ };
32737
+ }, [promiseRef]);
32738
+ }
32739
+ function refetchOrErrorIfUnmounted(promiseRef) {
32740
+ if (!promiseRef.current) throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage2(38) : "Cannot refetch a query that has not been started yet.");
32741
+ return promiseRef.current.refetch();
32742
+ }
32743
+ function buildQueryHooks(endpointName) {
32744
+ const useQuerySubscription = (arg, options = {}) => {
32745
+ const [promiseRef] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
32746
+ usePromiseRefUnsubscribeOnUnmount(promiseRef);
32251
32747
  return useMemo2(() => ({
32252
32748
  /**
32253
32749
  * A method to manually refetch data for the query
32254
32750
  */
32255
- refetch: () => {
32256
- if (!promiseRef.current) throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage2(38) : "Cannot refetch a query that has not been started yet.");
32257
- return promiseRef.current?.refetch();
32258
- }
32259
- }), []);
32751
+ refetch: () => refetchOrErrorIfUnmounted(promiseRef)
32752
+ }), [promiseRef]);
32260
32753
  };
32261
32754
  const useLazyQuerySubscription = ({
32262
32755
  refetchOnReconnect,
@@ -32266,7 +32759,7 @@ function buildHooks({
32266
32759
  } = {}) => {
32267
32760
  const {
32268
32761
  initiate
32269
- } = api.endpoints[name];
32762
+ } = api.endpoints[endpointName];
32270
32763
  const dispatch = useDispatch3();
32271
32764
  const [arg, setArg] = useState(UNINITIALIZED_VALUE);
32272
32765
  const promiseRef = useRef3(void 0);
@@ -32298,6 +32791,13 @@ function buildHooks({
32298
32791
  });
32299
32792
  return promise;
32300
32793
  }, [dispatch, initiate]);
32794
+ const reset = useCallback(() => {
32795
+ if (promiseRef.current?.queryCacheKey) {
32796
+ dispatch(api.internalActions.removeQueryResult({
32797
+ queryCacheKey: promiseRef.current?.queryCacheKey
32798
+ }));
32799
+ }
32800
+ }, [dispatch]);
32301
32801
  useEffect3(() => {
32302
32802
  return () => {
32303
32803
  promiseRef?.current?.unsubscribe();
@@ -32308,41 +32808,19 @@ function buildHooks({
32308
32808
  trigger(arg, true);
32309
32809
  }
32310
32810
  }, [arg, trigger]);
32311
- return useMemo2(() => [trigger, arg], [trigger, arg]);
32312
- };
32313
- const useQueryState = (arg, {
32314
- skip = false,
32315
- selectFromResult
32316
- } = {}) => {
32317
- const {
32318
- select
32319
- } = api.endpoints[name];
32320
- const stableArg = useStableQueryArgs(skip ? skipToken : arg, serializeQueryArgs, context.endpointDefinitions[name], name);
32321
- const lastValue = useRef3(void 0);
32322
- const selectDefaultResult = useMemo2(() => createSelector2([select(stableArg), (_2, lastResult) => lastResult, (_2) => stableArg], queryStatePreSelector, {
32323
- memoizeOptions: {
32324
- resultEqualityCheck: shallowEqual2
32325
- }
32326
- }), [select, stableArg]);
32327
- const querySelector = useMemo2(() => selectFromResult ? createSelector2([selectDefaultResult], selectFromResult, {
32328
- devModeChecks: {
32329
- identityFunctionCheck: "never"
32330
- }
32331
- }) : selectDefaultResult, [selectDefaultResult, selectFromResult]);
32332
- const currentState = useSelector3((state) => querySelector(state, lastValue.current), shallowEqual2);
32333
- const store = useStore();
32334
- const newLastValue = selectDefaultResult(store.getState(), lastValue.current);
32335
- useIsomorphicLayoutEffect(() => {
32336
- lastValue.current = newLastValue;
32337
- }, [newLastValue]);
32338
- return currentState;
32811
+ return useMemo2(() => [trigger, arg, {
32812
+ reset
32813
+ }], [trigger, arg, reset]);
32339
32814
  };
32815
+ const useQueryState = buildUseQueryState(endpointName, queryStatePreSelector);
32340
32816
  return {
32341
32817
  useQueryState,
32342
32818
  useQuerySubscription,
32343
32819
  useLazyQuerySubscription,
32344
32820
  useLazyQuery(options) {
32345
- const [trigger, arg] = useLazyQuerySubscription(options);
32821
+ const [trigger, arg, {
32822
+ reset
32823
+ }] = useLazyQuerySubscription(options);
32346
32824
  const queryStateResults = useQueryState(arg, {
32347
32825
  ...options,
32348
32826
  skip: arg === UNINITIALIZED_VALUE
@@ -32350,7 +32828,10 @@ function buildHooks({
32350
32828
  const info = useMemo2(() => ({
32351
32829
  lastArg: arg
32352
32830
  }), [arg]);
32353
- return useMemo2(() => [trigger, queryStateResults, info], [trigger, queryStateResults, info]);
32831
+ return useMemo2(() => [trigger, {
32832
+ ...queryStateResults,
32833
+ reset
32834
+ }, info], [trigger, queryStateResults, reset, info]);
32354
32835
  },
32355
32836
  useQuery(arg, options) {
32356
32837
  const querySubscriptionResults = useQuerySubscription(arg, options);
@@ -32358,22 +32839,8 @@ function buildHooks({
32358
32839
  selectFromResult: arg === skipToken || options?.skip ? void 0 : noPendingQueryStateSelector,
32359
32840
  ...options
32360
32841
  });
32361
- const {
32362
- data,
32363
- status,
32364
- isLoading,
32365
- isSuccess,
32366
- isError: isError2,
32367
- error
32368
- } = queryStateResults;
32369
- useDebugValue({
32370
- data,
32371
- status,
32372
- isLoading,
32373
- isSuccess,
32374
- isError: isError2,
32375
- error
32376
- });
32842
+ const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS);
32843
+ useDebugValue(debugValue);
32377
32844
  return useMemo2(() => ({
32378
32845
  ...queryStateResults,
32379
32846
  ...querySubscriptionResults
@@ -32381,6 +32848,80 @@ function buildHooks({
32381
32848
  }
32382
32849
  };
32383
32850
  }
32851
+ function buildInfiniteQueryHooks(endpointName) {
32852
+ const useInfiniteQuerySubscription = (arg, options = {}) => {
32853
+ const [promiseRef, dispatch, initiate, stableSubscriptionOptions] = useQuerySubscriptionCommonImpl(endpointName, arg, options);
32854
+ const subscriptionOptionsRef = useRef3(stableSubscriptionOptions);
32855
+ usePossiblyImmediateEffect(() => {
32856
+ subscriptionOptionsRef.current = stableSubscriptionOptions;
32857
+ }, [stableSubscriptionOptions]);
32858
+ const trigger = useCallback(function(arg2, direction) {
32859
+ let promise;
32860
+ batch(() => {
32861
+ promiseRef.current?.unsubscribe();
32862
+ promiseRef.current = promise = dispatch(initiate(arg2, {
32863
+ subscriptionOptions: subscriptionOptionsRef.current,
32864
+ direction
32865
+ }));
32866
+ });
32867
+ return promise;
32868
+ }, [promiseRef, dispatch, initiate]);
32869
+ usePromiseRefUnsubscribeOnUnmount(promiseRef);
32870
+ const stableArg = useStableQueryArgs(
32871
+ options.skip ? skipToken : arg,
32872
+ // Even if the user provided a per-endpoint `serializeQueryArgs` with
32873
+ // a consistent return value, _here_ we want to use the default behavior
32874
+ // so we can tell if _anything_ actually changed. Otherwise, we can end up
32875
+ // with a case where the query args did change but the serialization doesn't,
32876
+ // and then we never try to initiate a refetch.
32877
+ defaultSerializeQueryArgs,
32878
+ context.endpointDefinitions[endpointName],
32879
+ endpointName
32880
+ );
32881
+ const refetch = useCallback(() => refetchOrErrorIfUnmounted(promiseRef), [promiseRef]);
32882
+ return useMemo2(() => {
32883
+ const fetchNextPage = () => {
32884
+ return trigger(stableArg, "forward");
32885
+ };
32886
+ const fetchPreviousPage = () => {
32887
+ return trigger(stableArg, "backward");
32888
+ };
32889
+ return {
32890
+ trigger,
32891
+ /**
32892
+ * A method to manually refetch data for the query
32893
+ */
32894
+ refetch,
32895
+ fetchNextPage,
32896
+ fetchPreviousPage
32897
+ };
32898
+ }, [refetch, trigger, stableArg]);
32899
+ };
32900
+ const useInfiniteQueryState = buildUseQueryState(endpointName, infiniteQueryStatePreSelector);
32901
+ return {
32902
+ useInfiniteQueryState,
32903
+ useInfiniteQuerySubscription,
32904
+ useInfiniteQuery(arg, options) {
32905
+ const {
32906
+ refetch,
32907
+ fetchNextPage,
32908
+ fetchPreviousPage
32909
+ } = useInfiniteQuerySubscription(arg, options);
32910
+ const queryStateResults = useInfiniteQueryState(arg, {
32911
+ selectFromResult: arg === skipToken || options?.skip ? void 0 : noPendingQueryStateSelector,
32912
+ ...options
32913
+ });
32914
+ const debugValue = pick(queryStateResults, ...COMMON_HOOK_DEBUG_FIELDS, "hasNextPage", "hasPreviousPage");
32915
+ useDebugValue(debugValue);
32916
+ return useMemo2(() => ({
32917
+ ...queryStateResults,
32918
+ fetchNextPage,
32919
+ fetchPreviousPage,
32920
+ refetch
32921
+ }), [queryStateResults, fetchNextPage, fetchPreviousPage, refetch]);
32922
+ }
32923
+ };
32924
+ }
32384
32925
  function buildMutationHook(name) {
32385
32926
  return ({
32386
32927
  selectFromResult,
@@ -32427,24 +32968,8 @@ function buildHooks({
32427
32968
  }
32428
32969
  });
32429
32970
  }, [dispatch, fixedCacheKey, promise, requestId]);
32430
- const {
32431
- endpointName,
32432
- data,
32433
- status,
32434
- isLoading,
32435
- isSuccess,
32436
- isError: isError2,
32437
- error
32438
- } = currentState;
32439
- useDebugValue({
32440
- endpointName,
32441
- data,
32442
- status,
32443
- isLoading,
32444
- isSuccess,
32445
- isError: isError2,
32446
- error
32447
- });
32971
+ const debugValue = pick(currentState, ...COMMON_HOOK_DEBUG_FIELDS, "endpointName");
32972
+ useDebugValue(debugValue);
32448
32973
  const finalState = useMemo2(() => ({
32449
32974
  ...currentState,
32450
32975
  originalArgs,
@@ -32493,6 +33018,7 @@ Hook ${hookName} was either not provided or not a function.`);
32493
33018
  const anyApi = api;
32494
33019
  const {
32495
33020
  buildQueryHooks,
33021
+ buildInfiniteQueryHooks,
32496
33022
  buildMutationHook,
32497
33023
  usePrefetch
32498
33024
  } = buildHooks({
@@ -32531,12 +33057,25 @@ Hook ${hookName} was either not provided or not a function.`);
32531
33057
  });
32532
33058
  api[`use${capitalize(endpointName)}Query`] = useQuery;
32533
33059
  api[`useLazy${capitalize(endpointName)}Query`] = useLazyQuery;
32534
- } else if (isMutationDefinition2(definition)) {
33060
+ }
33061
+ if (isMutationDefinition2(definition)) {
32535
33062
  const useMutation = buildMutationHook(endpointName);
32536
33063
  safeAssign2(anyApi.endpoints[endpointName], {
32537
33064
  useMutation
32538
33065
  });
32539
33066
  api[`use${capitalize(endpointName)}Mutation`] = useMutation;
33067
+ } else if (isInfiniteQueryDefinition2(definition)) {
33068
+ const {
33069
+ useInfiniteQuery,
33070
+ useInfiniteQuerySubscription,
33071
+ useInfiniteQueryState
33072
+ } = buildInfiniteQueryHooks(endpointName);
33073
+ safeAssign2(anyApi.endpoints[endpointName], {
33074
+ useInfiniteQuery,
33075
+ useInfiniteQuerySubscription,
33076
+ useInfiniteQueryState
33077
+ });
33078
+ api[`use${capitalize(endpointName)}InfiniteQuery`] = useInfiniteQuery;
32540
33079
  }
32541
33080
  }
32542
33081
  };
@@ -32728,14 +33267,15 @@ var orchestratorApi = createApi2({
32728
33267
  (query) => query.apiName === apiName
32729
33268
  );
32730
33269
  switch (baseQueryType) {
32731
- case "fetch" /* fetch */:
33270
+ case "fetch" /* fetch */: {
32732
33271
  const fetchFn = fetchBaseQuery({
32733
33272
  baseUrl: customApi ? customApi.apiBaseUrl : orchestratorApiBaseUrl,
32734
33273
  prepareHeaders,
32735
33274
  responseHandler: (response) => catchErrorResponse(response, authActive)
32736
33275
  });
32737
33276
  return fetchFn(args, api, {});
32738
- default:
33277
+ }
33278
+ default: {
32739
33279
  const graphqlFn = wfoGraphqlRequestBaseQuery(
32740
33280
  {
32741
33281
  url: customApi ? customApi.apiBaseUrl : graphqlEndpointCore,
@@ -32747,6 +33287,7 @@ var orchestratorApi = createApi2({
32747
33287
  authActive
32748
33288
  );
32749
33289
  return graphqlFn(args, api, {});
33290
+ }
32750
33291
  }
32751
33292
  },
32752
33293
  endpoints: () => ({}),
@@ -36686,7 +37227,7 @@ function getTableConfig(hiddenColumns = [], selectedPageSize = DEFAULT_PAGE_SIZE
36686
37227
  }
36687
37228
  var getDefaultTableConfig = (storageKey) => {
36688
37229
  switch (storageKey) {
36689
- case METADATA_PRODUCT_BLOCKS_TABLE_LOCAL_STORAGE_KEY:
37230
+ case METADATA_PRODUCT_BLOCKS_TABLE_LOCAL_STORAGE_KEY: {
36690
37231
  const productBlockColumns = [
36691
37232
  "productBlockId",
36692
37233
  "status",
@@ -36694,12 +37235,14 @@ var getDefaultTableConfig = (storageKey) => {
36694
37235
  "createdAt"
36695
37236
  ];
36696
37237
  return getTableConfig(productBlockColumns);
36697
- case METADATA_RESOURCE_TYPES_TABLE_LOCAL_STORAGE_KEY:
37238
+ }
37239
+ case METADATA_RESOURCE_TYPES_TABLE_LOCAL_STORAGE_KEY: {
36698
37240
  const resourceTypeColumns = [
36699
37241
  "resourceTypeId"
36700
37242
  ];
36701
37243
  return getTableConfig(resourceTypeColumns);
36702
- case METADATA_PRODUCT_TABLE_LOCAL_STORAGE_KEY:
37244
+ }
37245
+ case METADATA_PRODUCT_TABLE_LOCAL_STORAGE_KEY: {
36703
37246
  const productColumns = [
36704
37247
  "productId",
36705
37248
  "productType",
@@ -36707,19 +37250,22 @@ var getDefaultTableConfig = (storageKey) => {
36707
37250
  "createdAt"
36708
37251
  ];
36709
37252
  return getTableConfig(productColumns);
36710
- case METADATA_WORKFLOWS_TABLE_LOCAL_STORAGE_KEY:
37253
+ }
37254
+ case METADATA_WORKFLOWS_TABLE_LOCAL_STORAGE_KEY: {
36711
37255
  const workflowColumns = [
36712
37256
  "workflowId",
36713
37257
  "createdAt"
36714
37258
  ];
36715
37259
  return getTableConfig(workflowColumns);
36716
- case METADATA_TASKS_TABLE_LOCAL_STORAGE_KEY:
37260
+ }
37261
+ case METADATA_TASKS_TABLE_LOCAL_STORAGE_KEY: {
36717
37262
  const taskColumns = [
36718
37263
  "workflowId",
36719
37264
  "createdAt"
36720
37265
  ];
36721
37266
  return getTableConfig(taskColumns);
36722
- case ACTIVE_PROCESSES_LIST_TABLE_LOCAL_STORAGE_KEY:
37267
+ }
37268
+ case ACTIVE_PROCESSES_LIST_TABLE_LOCAL_STORAGE_KEY: {
36723
37269
  const activeProcessColumns = [
36724
37270
  "productName",
36725
37271
  "customer",
@@ -36728,7 +37274,8 @@ var getDefaultTableConfig = (storageKey) => {
36728
37274
  "startedAt"
36729
37275
  ];
36730
37276
  return getTableConfig(activeProcessColumns);
36731
- case COMPLETED_PROCESSES_LIST_TABLE_LOCAL_STORAGE_KEY:
37277
+ }
37278
+ case COMPLETED_PROCESSES_LIST_TABLE_LOCAL_STORAGE_KEY: {
36732
37279
  const completedProcessColumns = [
36733
37280
  "lastStep",
36734
37281
  "productName",
@@ -36738,7 +37285,8 @@ var getDefaultTableConfig = (storageKey) => {
36738
37285
  "startedAt"
36739
37286
  ];
36740
37287
  return getTableConfig(completedProcessColumns);
36741
- case ACTIVE_TASKS_LIST_TABLE_LOCAL_STORAGE_KEY:
37288
+ }
37289
+ case ACTIVE_TASKS_LIST_TABLE_LOCAL_STORAGE_KEY: {
36742
37290
  const activeTasksColumns = [
36743
37291
  "assignee",
36744
37292
  "workflowTarget",
@@ -36747,7 +37295,8 @@ var getDefaultTableConfig = (storageKey) => {
36747
37295
  "processId"
36748
37296
  ];
36749
37297
  return getTableConfig(activeTasksColumns);
36750
- case COMPLETED_TASKS_LIST_TABLE_LOCAL_STORAGE_KEY:
37298
+ }
37299
+ case COMPLETED_TASKS_LIST_TABLE_LOCAL_STORAGE_KEY: {
36751
37300
  const completedTasksColumns = [
36752
37301
  "assignee",
36753
37302
  "workflowTarget",
@@ -36756,13 +37305,15 @@ var getDefaultTableConfig = (storageKey) => {
36756
37305
  "processId"
36757
37306
  ];
36758
37307
  return getTableConfig(completedTasksColumns);
36759
- case SUBSCRIPTIONS_TABLE_LOCAL_STORAGE_KEY:
37308
+ }
37309
+ case SUBSCRIPTIONS_TABLE_LOCAL_STORAGE_KEY: {
36760
37310
  const subscriptionColumns = [
36761
37311
  "productName",
36762
37312
  "customerFullname",
36763
37313
  "metadata"
36764
37314
  ];
36765
37315
  return getTableConfig(subscriptionColumns);
37316
+ }
36766
37317
  default:
36767
37318
  return getTableConfig();
36768
37319
  }
@@ -36772,16 +37323,19 @@ var getDefaultTableConfig = (storageKey) => {
36772
37323
  import process2 from "process";
36773
37324
  function getEnvironmentVariables(envVars) {
36774
37325
  const missingEnvironmentVariables = [];
36775
- const environmentVariablesWithValues = envVars.reduce((acc, currentKey) => {
36776
- const value = process2.env[currentKey.toString()];
36777
- if (value === void 0) {
36778
- missingEnvironmentVariables.push(currentKey.toString());
36779
- }
36780
- return {
36781
- ...acc,
36782
- [currentKey]: value || ""
36783
- };
36784
- }, {});
37326
+ const environmentVariablesWithValues = envVars.reduce(
37327
+ (acc, currentKey) => {
37328
+ const value = process2.env[currentKey.toString()];
37329
+ if (value === void 0) {
37330
+ missingEnvironmentVariables.push(currentKey.toString());
37331
+ }
37332
+ return {
37333
+ ...acc,
37334
+ [currentKey]: value || ""
37335
+ };
37336
+ },
37337
+ {}
37338
+ );
36785
37339
  if (missingEnvironmentVariables.length > 0) {
36786
37340
  console.warn(
36787
37341
  `Warning: Missing required environment variables: ${missingEnvironmentVariables.join(
@@ -36948,7 +37502,7 @@ var getUrlWithQueryParams = (url, params) => {
36948
37502
 
36949
37503
  // src/components/WfoPageTemplate/WfoPageHeader/WfoHamburgerMenu.tsx
36950
37504
  import { jsx as jsx57 } from "@emotion/react/jsx-runtime";
36951
- var WfoHamburgerMenu = ({}) => {
37505
+ var WfoHamburgerMenu = () => {
36952
37506
  const t = useTranslations4("hamburgerMenu");
36953
37507
  const [isPopoverOpen, setPopoverIsOpen] = useState7(false);
36954
37508
  const { theme, isDarkThemeActive } = useOrchestratorTheme();
@@ -42761,8 +43315,8 @@ var WfoCustomerDescriptionsField = ({ customerDescriptions, subscriptionCustomer
42761
43315
  customerDescriptionsCustomerNameStyle,
42762
43316
  customerDescriptionsFormStyle
42763
43317
  } = useWithOrchestratorTheme(getSubscriptionDetailStyles);
42764
- const [updateCustomerDescription, {}] = useUpdateCustomerDescriptionMutation();
42765
- const [setCustomerDescription, {}] = useSetCustomerDescriptionMutation();
43318
+ const [updateCustomerDescription] = useUpdateCustomerDescriptionMutation();
43319
+ const [setCustomerDescription] = useSetCustomerDescriptionMutation();
42766
43320
  const customerIds = customerDescriptions.map(
42767
43321
  (customerDescription) => customerDescription.customerId
42768
43322
  );
@@ -42916,7 +43470,7 @@ var TableSettingsModal = ({
42916
43470
  /* @__PURE__ */ jsx134(
42917
43471
  EuiFormRow2,
42918
43472
  {
42919
- display: "columnCompressedSwitch",
43473
+ display: "columnCompressed",
42920
43474
  label: name,
42921
43475
  css: formRowStyle,
42922
43476
  children: /* @__PURE__ */ jsx134(
@@ -44589,7 +45143,7 @@ function UnconnectedSelectField({
44589
45143
  if (selectedValue && selectedValue.value !== "undefined") {
44590
45144
  onChange(selectedValue.value);
44591
45145
  }
44592
- }, []);
45146
+ }, [onChange, selectedValue]);
44593
45147
  if (fieldType === Array) {
44594
45148
  return /* @__PURE__ */ jsx157(ListField, { name, children: /* @__PURE__ */ jsx157(ListItemField, { name: "$", children: /* @__PURE__ */ jsx157(
44595
45149
  ListSelectField,
@@ -46218,7 +46772,7 @@ function Vlan({
46218
46772
  } else if (!disabled && (!subscriptionId && value !== "" || subscriptionId && portIsTagged && value === "0")) {
46219
46773
  onChange("");
46220
46774
  }
46221
- }, [onChange, subscriptionId, isFetched, portIsTagged]);
46775
+ }, [onChange, subscriptionId, isFetched, portIsTagged, value, disabled]);
46222
46776
  const [usedVlansInIms, setUsedVlansInIms] = useState31([]);
46223
46777
  const [missingInIms, setMissingInIms] = useState31(false);
46224
46778
  const {
@@ -49227,7 +49781,7 @@ var WfoProcessDetail = ({
49227
49781
  question: t(
49228
49782
  processIsTask ? "retryTaskQuestion" : "retryWorkflowQuestion",
49229
49783
  {
49230
- workflowName: processDetail?.workflowName
49784
+ workflowName: processDetail?.workflowName || ""
49231
49785
  }
49232
49786
  ),
49233
49787
  onConfirm: () => {
@@ -49240,7 +49794,7 @@ var WfoProcessDetail = ({
49240
49794
  question: t(
49241
49795
  processIsTask ? "abortTaskQuestion" : "abortWorkflowQuestion",
49242
49796
  {
49243
- workflowName: processDetail?.workflowName
49797
+ workflowName: processDetail?.workflowName || ""
49244
49798
  }
49245
49799
  ),
49246
49800
  onConfirm: () => {
@@ -49252,7 +49806,7 @@ var WfoProcessDetail = ({
49252
49806
  });
49253
49807
  const deleteAction = () => showConfirmDialog({
49254
49808
  question: t("deleteQuestion", {
49255
- workflowName: processDetail?.workflowName
49809
+ workflowName: processDetail?.workflowName || ""
49256
49810
  }),
49257
49811
  onConfirm: () => {
49258
49812
  if (processDetail?.processId) {
@@ -50022,7 +50576,10 @@ var WfoStep = React65.forwardRef(
50022
50576
  getStepToggleExpandStyle
50023
50577
  } = useWithOrchestratorTheme(getWorkflowStepsStyles);
50024
50578
  const t = useTranslations61("processes.steps");
50025
- const hasHtmlMail = step.stateDelta?.hasOwnProperty("confirmation_mail");
50579
+ const hasHtmlMail = Object.prototype.hasOwnProperty.call(
50580
+ step?.stateDelta || {},
50581
+ "confirmation_mail"
50582
+ );
50026
50583
  const stepContent = step.stateDelta ? getStepContent(step.stateDelta, showHiddenKeys) : {};
50027
50584
  const hasStepContent = hasHtmlMail || Object.keys(stepContent).length > 0;
50028
50585
  const displayMailConfirmation = (value) => {
@@ -50413,9 +50970,11 @@ var WfoProcessSubscriptionDelta = ({
50413
50970
  processId
50414
50971
  }) => {
50415
50972
  const { data, isFetching } = useGetRawProcessDetailQuery({ processId });
50416
- const subscriptionKey = data?.current_state?.subscription?.subscription_id ?? "";
50973
+ const subscriptionId = data?.current_state?.subscription?.subscription_id ?? "";
50417
50974
  const newText = data?.current_state?.subscription ?? null;
50418
- const oldText = data?.current_state?.__old_subscriptions__ && subscriptionKey in data?.current_state?.__old_subscriptions__ ? data?.current_state?.__old_subscriptions__[subscriptionKey] : null;
50975
+ const oldSubscriptions = data?.current_state?.__old_subscriptions__ || {};
50976
+ const oldSubscription = subscriptionId in oldSubscriptions;
50977
+ const oldText = oldSubscription || null;
50419
50978
  return isFetching ? /* @__PURE__ */ jsx210(WfoLoading, {}) : /* @__PURE__ */ jsx210(
50420
50979
  WfoDiff_default,
50421
50980
  {