@agg-build/hooks 2.7.0 → 2.7.2
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/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +15 -5
- package/dist/index.mjs +15 -5
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -5364,6 +5364,8 @@ interface UseVenueMarketsOptions {
|
|
|
5364
5364
|
marketGroup?: string[];
|
|
5365
5365
|
/** Page size when using cursor pagination. Default 20. */
|
|
5366
5366
|
limit?: number;
|
|
5367
|
+
/** Eagerly fetch every page until exhausted (no scroll wiring needed). */
|
|
5368
|
+
fetchAll?: boolean;
|
|
5367
5369
|
/** Enable/disable the query. Default true. */
|
|
5368
5370
|
enabled?: boolean;
|
|
5369
5371
|
/** Sort by this field. */
|
package/dist/index.d.ts
CHANGED
|
@@ -5364,6 +5364,8 @@ interface UseVenueMarketsOptions {
|
|
|
5364
5364
|
marketGroup?: string[];
|
|
5365
5365
|
/** Page size when using cursor pagination. Default 20. */
|
|
5366
5366
|
limit?: number;
|
|
5367
|
+
/** Eagerly fetch every page until exhausted (no scroll wiring needed). */
|
|
5368
|
+
fetchAll?: boolean;
|
|
5367
5369
|
/** Enable/disable the query. Default true. */
|
|
5368
5370
|
enabled?: boolean;
|
|
5369
5371
|
/** Sort by this field. */
|
package/dist/index.js
CHANGED
|
@@ -8005,7 +8005,7 @@ function useVenueEvent(options) {
|
|
|
8005
8005
|
var import_react_query39 = require("@tanstack/react-query");
|
|
8006
8006
|
var import_react33 = require("react");
|
|
8007
8007
|
function useVenueMarkets(options) {
|
|
8008
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
8008
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
8009
8009
|
const client = (0, import_react33.useContext)(AggClientContext);
|
|
8010
8010
|
const queryClient = (0, import_react33.useContext)(import_react_query39.QueryClientContext);
|
|
8011
8011
|
const [fallbackQueryClient] = (0, import_react33.useState)(() => new import_react_query39.QueryClient());
|
|
@@ -8091,6 +8091,12 @@ function useVenueMarkets(options) {
|
|
|
8091
8091
|
);
|
|
8092
8092
|
const markets = (_j = (_i = query.data) == null ? void 0 : _i.pages.flatMap((page) => page.data)) != null ? _j : [];
|
|
8093
8093
|
const hasNextPage = !!query.hasNextPage;
|
|
8094
|
+
const { fetchNextPage, isFetchingNextPage } = query;
|
|
8095
|
+
const fetchAll = (_k = options == null ? void 0 : options.fetchAll) != null ? _k : false;
|
|
8096
|
+
(0, import_react33.useEffect)(() => {
|
|
8097
|
+
if (!fetchAll || !hasNextPage || isFetchingNextPage) return;
|
|
8098
|
+
void fetchNextPage();
|
|
8099
|
+
}, [fetchAll, hasNextPage, isFetchingNextPage, fetchNextPage]);
|
|
8094
8100
|
return __spreadProps(__spreadValues({}, query), {
|
|
8095
8101
|
markets,
|
|
8096
8102
|
hasNextPage
|
|
@@ -8116,19 +8122,23 @@ function useEnrichedVenueEvent(options) {
|
|
|
8116
8122
|
const { markets: openMarkets, isLoading: isEnrichingOpenMarkets } = useVenueMarkets({
|
|
8117
8123
|
venueEventId: options.eventId,
|
|
8118
8124
|
enabled: ((_b = options.enabled) != null ? _b : true) && !!event,
|
|
8119
|
-
status: shouldFetchOnlyOpenMarkets ? "open" /* open */ : void 0
|
|
8125
|
+
status: shouldFetchOnlyOpenMarkets ? "open" /* open */ : void 0,
|
|
8120
8126
|
// No explicit sortBy: event-scoped /venue-markets sorts by the event's
|
|
8121
8127
|
// type-aware order (structureOrderBy). Keeping this in lockstep with
|
|
8122
|
-
// MarketDetailsList
|
|
8123
|
-
// event-type ordering.
|
|
8128
|
+
// MarketDetailsList (including limit, part of the query key) preserves the
|
|
8129
|
+
// shared React Query cache key and the event-type ordering.
|
|
8130
|
+
limit: 100,
|
|
8131
|
+
fetchAll: true
|
|
8124
8132
|
});
|
|
8125
8133
|
const shouldFetchAllMarketsFallback = ((_c = options.enabled) != null ? _c : true) && !!event && shouldFetchOnlyOpenMarkets && !isEnrichingOpenMarkets && openMarkets.length === 0;
|
|
8126
8134
|
const { markets: fallbackMarkets, isLoading: isEnrichingFallbackMarkets } = useVenueMarkets({
|
|
8127
8135
|
venueEventId: options.eventId,
|
|
8128
|
-
enabled: shouldFetchAllMarketsFallback
|
|
8136
|
+
enabled: shouldFetchAllMarketsFallback,
|
|
8129
8137
|
// No status filter on fallback: if an active event temporarily has only
|
|
8130
8138
|
// closed/resolved markets, still render the event page instead of the
|
|
8131
8139
|
// unavailable state.
|
|
8140
|
+
limit: 100,
|
|
8141
|
+
fetchAll: true
|
|
8132
8142
|
});
|
|
8133
8143
|
const markets = fallbackMarkets.length > 0 ? fallbackMarkets : openMarkets;
|
|
8134
8144
|
const isEnriching = isEnrichingOpenMarkets || isEnrichingFallbackMarkets;
|
package/dist/index.mjs
CHANGED
|
@@ -2580,7 +2580,7 @@ function useVenueEvent(options) {
|
|
|
2580
2580
|
import { QueryClient as QueryClient2, QueryClientContext as QueryClientContext2, useInfiniteQuery as useInfiniteQuery7 } from "@tanstack/react-query";
|
|
2581
2581
|
import { useContext as useContext3, useEffect as useEffect8, useState as useState8 } from "react";
|
|
2582
2582
|
function useVenueMarkets(options) {
|
|
2583
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2583
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
2584
2584
|
const client = useContext3(AggClientContext);
|
|
2585
2585
|
const queryClient = useContext3(QueryClientContext2);
|
|
2586
2586
|
const [fallbackQueryClient] = useState8(() => new QueryClient2());
|
|
@@ -2666,6 +2666,12 @@ function useVenueMarkets(options) {
|
|
|
2666
2666
|
);
|
|
2667
2667
|
const markets = (_j = (_i = query.data) == null ? void 0 : _i.pages.flatMap((page) => page.data)) != null ? _j : [];
|
|
2668
2668
|
const hasNextPage = !!query.hasNextPage;
|
|
2669
|
+
const { fetchNextPage, isFetchingNextPage } = query;
|
|
2670
|
+
const fetchAll = (_k = options == null ? void 0 : options.fetchAll) != null ? _k : false;
|
|
2671
|
+
useEffect8(() => {
|
|
2672
|
+
if (!fetchAll || !hasNextPage || isFetchingNextPage) return;
|
|
2673
|
+
void fetchNextPage();
|
|
2674
|
+
}, [fetchAll, hasNextPage, isFetchingNextPage, fetchNextPage]);
|
|
2669
2675
|
return __spreadProps(__spreadValues({}, query), {
|
|
2670
2676
|
markets,
|
|
2671
2677
|
hasNextPage
|
|
@@ -2691,19 +2697,23 @@ function useEnrichedVenueEvent(options) {
|
|
|
2691
2697
|
const { markets: openMarkets, isLoading: isEnrichingOpenMarkets } = useVenueMarkets({
|
|
2692
2698
|
venueEventId: options.eventId,
|
|
2693
2699
|
enabled: ((_b = options.enabled) != null ? _b : true) && !!event,
|
|
2694
|
-
status: shouldFetchOnlyOpenMarkets ? "open" /* open */ : void 0
|
|
2700
|
+
status: shouldFetchOnlyOpenMarkets ? "open" /* open */ : void 0,
|
|
2695
2701
|
// No explicit sortBy: event-scoped /venue-markets sorts by the event's
|
|
2696
2702
|
// type-aware order (structureOrderBy). Keeping this in lockstep with
|
|
2697
|
-
// MarketDetailsList
|
|
2698
|
-
// event-type ordering.
|
|
2703
|
+
// MarketDetailsList (including limit, part of the query key) preserves the
|
|
2704
|
+
// shared React Query cache key and the event-type ordering.
|
|
2705
|
+
limit: 100,
|
|
2706
|
+
fetchAll: true
|
|
2699
2707
|
});
|
|
2700
2708
|
const shouldFetchAllMarketsFallback = ((_c = options.enabled) != null ? _c : true) && !!event && shouldFetchOnlyOpenMarkets && !isEnrichingOpenMarkets && openMarkets.length === 0;
|
|
2701
2709
|
const { markets: fallbackMarkets, isLoading: isEnrichingFallbackMarkets } = useVenueMarkets({
|
|
2702
2710
|
venueEventId: options.eventId,
|
|
2703
|
-
enabled: shouldFetchAllMarketsFallback
|
|
2711
|
+
enabled: shouldFetchAllMarketsFallback,
|
|
2704
2712
|
// No status filter on fallback: if an active event temporarily has only
|
|
2705
2713
|
// closed/resolved markets, still render the event page instead of the
|
|
2706
2714
|
// unavailable state.
|
|
2715
|
+
limit: 100,
|
|
2716
|
+
fetchAll: true
|
|
2707
2717
|
});
|
|
2708
2718
|
const markets = fallbackMarkets.length > 0 ? fallbackMarkets : openMarkets;
|
|
2709
2719
|
const isEnriching = isEnrichingOpenMarkets || isEnrichingFallbackMarkets;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agg-build/hooks",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.2",
|
|
4
4
|
"description": "React hooks and providers for the AGG prediction market aggregator. Wraps @agg-build/sdk with TanStack Query, shared session state, and live WebSocket data.",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "MIT",
|