@trackunit/react-core-contexts-test 1.13.0 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -25,6 +25,7 @@ exports.TrackunitProvidersMockBuilder = index.TrackunitProvidersMockBuilder;
25
25
  exports.doNothing = index.doNothing;
26
26
  exports.flushPromises = index.flushPromises;
27
27
  exports.flushPromisesInAct = index.flushPromisesInAct;
28
+ exports.mergeDeepVars = index.mergeDeepVars;
28
29
  exports.mockAnalyticsContext = index.mockAnalyticsContext;
29
30
  exports.mockAssetSortingContext = index.mockAssetSortingContext;
30
31
  exports.mockCurrentUserContext = index.mockCurrentUserContext;
package/index.cjs2.js CHANGED
@@ -14443,6 +14443,35 @@ const safeStringify = (obj) => {
14443
14443
  });
14444
14444
  };
14445
14445
 
14446
+ /**
14447
+ * Deep merge for GraphQL mock variables that preserves `undefined` values.
14448
+ *
14449
+ * Unlike Apollo's `mergeDeep` which drops `undefined`, this retains all keys
14450
+ * from the defaults and only overrides keys explicitly present in the source.
14451
+ * This is critical for Apollo MockedProvider's exact variable matching.
14452
+ */
14453
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14454
+ const mergeDeepVars = (defaults, overrides) => {
14455
+ if (!overrides)
14456
+ return { ...defaults };
14457
+ const src = overrides;
14458
+ const result = { ...defaults };
14459
+ for (const key of Object.keys(src)) {
14460
+ const overrideVal = src[key];
14461
+ const defaultVal = result[key];
14462
+ const bothObjects = typeof overrideVal === "object" &&
14463
+ overrideVal !== null &&
14464
+ !Array.isArray(overrideVal) &&
14465
+ typeof defaultVal === "object" &&
14466
+ defaultVal !== null &&
14467
+ !Array.isArray(defaultVal);
14468
+ result[key] = bothObjects
14469
+ ? mergeDeepVars(defaultVal, overrideVal)
14470
+ : overrideVal;
14471
+ }
14472
+ return result;
14473
+ };
14474
+
14446
14475
  /**
14447
14476
  *
14448
14477
  * @param document Document that represents the specific GQL query / mutation schema.
@@ -14587,6 +14616,7 @@ exports.act = act;
14587
14616
  exports.doNothing = doNothing;
14588
14617
  exports.flushPromises = flushPromises;
14589
14618
  exports.flushPromisesInAct = flushPromisesInAct;
14619
+ exports.mergeDeepVars = mergeDeepVars;
14590
14620
  exports.mockAnalyticsContext = mockAnalyticsContext;
14591
14621
  exports.mockAssetSortingContext = mockAssetSortingContext;
14592
14622
  exports.mockCurrentUserContext = mockCurrentUserContext;
package/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- export { D as Debugger, T as TrackunitProvidersMockBuilder, l as doNothing, f as flushPromises, b as flushPromisesInAct, m as mockAnalyticsContext, c as mockAssetSortingContext, d as mockCurrentUserContext, e as mockEnvironmentContext, g as mockFilterBarContext, h as mockNavigationContext, i as mockOemBrandingContext, j as mockToastContext, k as mockUserSubscriptionContext, q as queryFor, n as queryForHook, t as trackunitProviders, u as useDebugger, v as validateIrisApp } from './index.esm2.js';
1
+ export { D as Debugger, T as TrackunitProvidersMockBuilder, n as doNothing, f as flushPromises, b as flushPromisesInAct, l as mergeDeepVars, m as mockAnalyticsContext, c as mockAssetSortingContext, d as mockCurrentUserContext, e as mockEnvironmentContext, g as mockFilterBarContext, h as mockNavigationContext, i as mockOemBrandingContext, j as mockToastContext, k as mockUserSubscriptionContext, q as queryFor, o as queryForHook, t as trackunitProviders, u as useDebugger, v as validateIrisApp } from './index.esm2.js';
2
2
  import '@trackunit/iris-app-runtime-core-api';
3
3
  import 'react/jsx-runtime';
4
4
  import 'react';
package/index.esm2.js CHANGED
@@ -14421,6 +14421,35 @@ const safeStringify = (obj) => {
14421
14421
  });
14422
14422
  };
14423
14423
 
14424
+ /**
14425
+ * Deep merge for GraphQL mock variables that preserves `undefined` values.
14426
+ *
14427
+ * Unlike Apollo's `mergeDeep` which drops `undefined`, this retains all keys
14428
+ * from the defaults and only overrides keys explicitly present in the source.
14429
+ * This is critical for Apollo MockedProvider's exact variable matching.
14430
+ */
14431
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14432
+ const mergeDeepVars = (defaults, overrides) => {
14433
+ if (!overrides)
14434
+ return { ...defaults };
14435
+ const src = overrides;
14436
+ const result = { ...defaults };
14437
+ for (const key of Object.keys(src)) {
14438
+ const overrideVal = src[key];
14439
+ const defaultVal = result[key];
14440
+ const bothObjects = typeof overrideVal === "object" &&
14441
+ overrideVal !== null &&
14442
+ !Array.isArray(overrideVal) &&
14443
+ typeof defaultVal === "object" &&
14444
+ defaultVal !== null &&
14445
+ !Array.isArray(defaultVal);
14446
+ result[key] = bothObjects
14447
+ ? mergeDeepVars(defaultVal, overrideVal)
14448
+ : overrideVal;
14449
+ }
14450
+ return result;
14451
+ };
14452
+
14424
14453
  /**
14425
14454
  *
14426
14455
  * @param document Document that represents the specific GQL query / mutation schema.
@@ -14559,4 +14588,4 @@ const validateIrisApp = async (irisApp) => {
14559
14588
  return null;
14560
14589
  };
14561
14590
 
14562
- export { Debugger as D, TrackunitProvidersMockBuilder as T, act as a, flushPromisesInAct as b, mockAssetSortingContext as c, mockCurrentUserContext as d, mockEnvironmentContext as e, flushPromises as f, mockFilterBarContext as g, mockNavigationContext as h, mockOemBrandingContext as i, mockToastContext as j, mockUserSubscriptionContext as k, doNothing as l, mockAnalyticsContext as m, queryForHook as n, queryFor as q, renderHook as r, trackunitProviders as t, useDebugger as u, validateIrisApp as v };
14591
+ export { Debugger as D, TrackunitProvidersMockBuilder as T, act as a, flushPromisesInAct as b, mockAssetSortingContext as c, mockCurrentUserContext as d, mockEnvironmentContext as e, flushPromises as f, mockFilterBarContext as g, mockNavigationContext as h, mockOemBrandingContext as i, mockToastContext as j, mockUserSubscriptionContext as k, mergeDeepVars as l, mockAnalyticsContext as m, doNothing as n, queryForHook as o, queryFor as q, renderHook as r, trackunitProviders as t, useDebugger as u, validateIrisApp as v };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-contexts-test",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
package/src/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export * from "./mocks/mockToastContext";
9
9
  export * from "./mocks/mockUserSubscriptionContext";
10
10
  export * from "./TrackunitProvidersMockBuilder";
11
11
  export * from "./useDebugger";
12
+ export * from "./utils/mergeDeepVars";
12
13
  export * from "./utils/doNothing";
13
14
  export * from "./utils/queryFor";
14
15
  export * from "./utils/validateIrisApp";
@@ -0,0 +1,9 @@
1
+ import { DeepPartialNullable } from "./queryFor";
2
+ /**
3
+ * Deep merge for GraphQL mock variables that preserves `undefined` values.
4
+ *
5
+ * Unlike Apollo's `mergeDeep` which drops `undefined`, this retains all keys
6
+ * from the defaults and only overrides keys explicitly present in the source.
7
+ * This is critical for Apollo MockedProvider's exact variable matching.
8
+ */
9
+ export declare const mergeDeepVars: <TDefaults extends Record<string, any>>(defaults: TDefaults, overrides?: DeepPartialNullable<NoInfer<TDefaults>> | Partial<NoInfer<TDefaults>>) => TDefaults;
@@ -4,6 +4,14 @@ export type DeepPartialNullable<TValue> = TValue extends Array<any> ? DeepPartia
4
4
  [KeyProperty in keyof TValue]?: DeepPartialNullable<TValue[KeyProperty]> | null;
5
5
  } : TValue | null;
6
6
  type DeepPartialNullableArray<TValue> = Array<DeepPartialNullable<TValue>>;
7
+ /**
8
+ * Like Pick<T, K>, but each picked value is DeepPartialNullable.
9
+ * The keys themselves stay required so callers must supply them,
10
+ * while nested fields become optional (filled by generated defaults).
11
+ */
12
+ export type PickDeepPartialNullable<TValue, TKeys extends keyof TValue> = {
13
+ [Key in TKeys]: DeepPartialNullable<TValue[Key]>;
14
+ };
7
15
  /**
8
16
  *
9
17
  * @param document Document that represents the specific GQL query / mutation schema.