@postrun/react 2.19.0 → 2.21.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/dist/index.d.cts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, CSSProperties } from 'react';
3
3
  import * as _tanstack_react_query from '@tanstack/react-query';
4
- import { QueryClient, QueryKey, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
4
+ import { QueryClient, QueryKey, UseQueryResult, UseMutationOptions, UseMutationResult, UseQueryOptions } from '@tanstack/react-query';
5
5
  import * as _postrun_js from '@postrun/js';
6
- import { PostrunClient, ListProfilesQuery, DiscoverableAccountList, Connection, ConnectionKind, ConnectionStatus, ListMediaQuery, ListPostsQuery, ConnectablePlatform, MediaResource, MediaTarget, Metadata, ComposePostInput, PostValidation, MediaKind, InstagramPostVariant, PostVariant, LinkedInPostVariant, TikTokPostVariant, XPostVariant, PostVariantInput, XPoll as XPoll$1, TikTokCreatorInfo, TikTokOptionsValue } from '@postrun/js';
6
+ import { PostrunClient, ListProfilesQuery, DiscoverableAccountList, Connection, ConnectionKind, ConnectionStatus, ListMediaQuery, ListPostsQuery, ConnectablePlatform, MediaResource, MediaTarget, Metadata, ComposePostInput, PostValidation, GoogleGetAdTreeData, GoogleGetAdTreeResponse, GoogleGetAdTreeError, AdTreeNode, MediaKind, InstagramPostVariant, PostVariant, LinkedInPostVariant, TikTokPostVariant, XPostVariant, PostVariantInput, XPoll as XPoll$1, TikTokCreatorInfo, TikTokOptionsValue } from '@postrun/js';
7
7
  export { PostValidation, PostVariant, PostVariantError, TIKTOK_CAPTION_MAX, TikTokCreatorInfo, UploadError, ValidationIssue, captionMaxFor } from '@postrun/js';
8
8
  import { TwitterComponents } from 'react-tweet';
9
9
  export * from '@postrun/js/query';
@@ -2407,6 +2407,13 @@ declare function useValidatePost(profileId: string): {
2407
2407
  hint?: string;
2408
2408
  allowed?: Array<string>;
2409
2409
  got?: string;
2410
+ source?: {
2411
+ platform: "google" | "meta" | "x" | "linkedin" | "instagram" | "facebook" | "tiktok" | "youtube";
2412
+ platform_code?: string;
2413
+ field?: string;
2414
+ value?: string;
2415
+ platform_request_id?: string;
2416
+ };
2410
2417
  variant_index: number;
2411
2418
  path: Array<string | number>;
2412
2419
  platform?: "tiktok" | "x" | "linkedin" | "facebook_page" | "instagram";
@@ -2836,6 +2843,31 @@ declare function useTikTokCreatorInfo(connectionId: string | null): _tanstack_re
2836
2843
  max_video_duration_sec: number;
2837
2844
  }>, Error>;
2838
2845
 
2846
+ /**
2847
+ * The Google Ads campaign tree for one connection + window. The API returns FLAT
2848
+ * nodes lazily — `GET /ads/tree` gives the campaign level; `?campaign_id=` gives
2849
+ * that campaign's subtree — so this hook fetches the campaign level plus one query
2850
+ * per EXPANDED campaign, then `groupAdTree`s the merged set into the nested tree.
2851
+ *
2852
+ * Expansion is CONTROLLED: the caller owns which campaigns are open (a `Set`/array
2853
+ * of campaign ids) and passes it as `expanded`; the hook reacts by loading exactly
2854
+ * those subtrees. Changing `since`/`until`/`metrics` refetches (they're in the
2855
+ * query key). Metrics are Google's authoritative per-level numbers — no roll-up.
2856
+ */
2857
+ type UseAdTreeParams = Pick<GoogleGetAdTreeData['query'], 'since' | 'until' | 'metrics'> & {
2858
+ /** The Google Ads connection id (`conn_…`). */
2859
+ connectionId: string;
2860
+ /** Campaign ids whose subtree to load (the expanded rows). */
2861
+ expanded?: string[];
2862
+ };
2863
+ type UseAdTreeResult = Pick<UseQueryResult<GoogleGetAdTreeResponse, GoogleGetAdTreeError>, 'isLoading' | 'isError' | 'error' | 'refetch'> & {
2864
+ /** The campaign roots, each with its loaded children nested under it. */
2865
+ tree: AdTreeNode[];
2866
+ /** Whether the subtree for an expanded campaign is still loading. */
2867
+ isExpanding: (campaignId: string) => boolean;
2868
+ };
2869
+ declare function useAdTree(params: UseAdTreeParams): UseAdTreeResult;
2870
+
2839
2871
  /**
2840
2872
  * The paved FE path over the generated TanStack Query options. Pass a factory
2841
2873
  * that receives the configured client and returns one of the generated `*Options`
@@ -3339,4 +3371,4 @@ declare function Declaration({ brandedContent }: {
3339
3371
  brandedContent: boolean;
3340
3372
  }): react.JSX.Element;
3341
3373
 
3342
- export { ArticleCard, type ArticleCardProps, AudienceSelect, type CalendarFilters, CommercialDisclosure, Connect, type ConnectErrorReason, type ConnectOutcome, type ConnectProps, type ConnectRenderApi, type ConnectState, type ConnectionsFilter, Declaration, type DiscoverableAccount, DocumentCard, type DocumentCardProps, type InfiniteList, InstagramPostPreview, type InstagramPostPreviewProps, type InstagramPreviewVariant, type InstagramTheme, InteractionToggles, LinkedInPostPreview, type LinkedInPostPreviewProps, type LinkedInPreviewVariant, type LiveOptions, type MediaUploadItem, type MediaUploadOptions, type MediaUploadStatus, Poll, type PollProps, type PostrunContextValue, PostrunProvider, type PostrunProviderProps, type PreviewConnection, type PreviewMediaKind, type ReadPostVariant, type ReadyMedia, ReelPreview, type ReelPreviewProps, type ResolvedMedia, TikTokCaptionField, type TikTokCaptionFieldProps, TikTokPostPreview, type TikTokPostPreviewProps, type TikTokPreviewVariant, TikTokPublishPanel, type TikTokPublishPanelProps, type TikTokTheme, type UseConnectParams, type UseConnectResult, type UseMediaUploadOptions, type UseMediaUploadResult, XPoll, type XPollProps, XPostPreview, type XPostPreviewProps, type XPreviewQuotedTweet, type XPreviewVariant, connectionKeys, isReadyMedia, mediaKeys, postKeys, profileKeys, resolveVariantMedia, tiktokKeys, useCalendar, useConnect, useConnection, useConnections, useCreatePost, useCreateProfile, useDeleteMedia, useDeletePost, useDeleteProfile, useDisconnect, useDiscoverableAccounts, useInfiniteList, useMedia, useMediaInfinite, useMediaList, useMediaUpload, usePost, usePostrun, usePostrunMutation, usePostrunQuery, usePosts, usePostsInfinite, useProfile, useProfiles, useProfilesInfinite, useSelectAccount, useTikTokCreatorInfo, useUpdateMedia, useUpdatePost, useUpdateProfile, useValidatePost };
3374
+ export { ArticleCard, type ArticleCardProps, AudienceSelect, type CalendarFilters, CommercialDisclosure, Connect, type ConnectErrorReason, type ConnectOutcome, type ConnectProps, type ConnectRenderApi, type ConnectState, type ConnectionsFilter, Declaration, type DiscoverableAccount, DocumentCard, type DocumentCardProps, type InfiniteList, InstagramPostPreview, type InstagramPostPreviewProps, type InstagramPreviewVariant, type InstagramTheme, InteractionToggles, LinkedInPostPreview, type LinkedInPostPreviewProps, type LinkedInPreviewVariant, type LiveOptions, type MediaUploadItem, type MediaUploadOptions, type MediaUploadStatus, Poll, type PollProps, type PostrunContextValue, PostrunProvider, type PostrunProviderProps, type PreviewConnection, type PreviewMediaKind, type ReadPostVariant, type ReadyMedia, ReelPreview, type ReelPreviewProps, type ResolvedMedia, TikTokCaptionField, type TikTokCaptionFieldProps, TikTokPostPreview, type TikTokPostPreviewProps, type TikTokPreviewVariant, TikTokPublishPanel, type TikTokPublishPanelProps, type TikTokTheme, type UseAdTreeParams, type UseAdTreeResult, type UseConnectParams, type UseConnectResult, type UseMediaUploadOptions, type UseMediaUploadResult, XPoll, type XPollProps, XPostPreview, type XPostPreviewProps, type XPreviewQuotedTweet, type XPreviewVariant, connectionKeys, isReadyMedia, mediaKeys, postKeys, profileKeys, resolveVariantMedia, tiktokKeys, useAdTree, useCalendar, useConnect, useConnection, useConnections, useCreatePost, useCreateProfile, useDeleteMedia, useDeletePost, useDeleteProfile, useDisconnect, useDiscoverableAccounts, useInfiniteList, useMedia, useMediaInfinite, useMediaList, useMediaUpload, usePost, usePostrun, usePostrunMutation, usePostrunQuery, usePosts, usePostsInfinite, useProfile, useProfiles, useProfilesInfinite, useSelectAccount, useTikTokCreatorInfo, useUpdateMedia, useUpdatePost, useUpdateProfile, useValidatePost };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, CSSProperties } from 'react';
3
3
  import * as _tanstack_react_query from '@tanstack/react-query';
4
- import { QueryClient, QueryKey, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
4
+ import { QueryClient, QueryKey, UseQueryResult, UseMutationOptions, UseMutationResult, UseQueryOptions } from '@tanstack/react-query';
5
5
  import * as _postrun_js from '@postrun/js';
6
- import { PostrunClient, ListProfilesQuery, DiscoverableAccountList, Connection, ConnectionKind, ConnectionStatus, ListMediaQuery, ListPostsQuery, ConnectablePlatform, MediaResource, MediaTarget, Metadata, ComposePostInput, PostValidation, MediaKind, InstagramPostVariant, PostVariant, LinkedInPostVariant, TikTokPostVariant, XPostVariant, PostVariantInput, XPoll as XPoll$1, TikTokCreatorInfo, TikTokOptionsValue } from '@postrun/js';
6
+ import { PostrunClient, ListProfilesQuery, DiscoverableAccountList, Connection, ConnectionKind, ConnectionStatus, ListMediaQuery, ListPostsQuery, ConnectablePlatform, MediaResource, MediaTarget, Metadata, ComposePostInput, PostValidation, GoogleGetAdTreeData, GoogleGetAdTreeResponse, GoogleGetAdTreeError, AdTreeNode, MediaKind, InstagramPostVariant, PostVariant, LinkedInPostVariant, TikTokPostVariant, XPostVariant, PostVariantInput, XPoll as XPoll$1, TikTokCreatorInfo, TikTokOptionsValue } from '@postrun/js';
7
7
  export { PostValidation, PostVariant, PostVariantError, TIKTOK_CAPTION_MAX, TikTokCreatorInfo, UploadError, ValidationIssue, captionMaxFor } from '@postrun/js';
8
8
  import { TwitterComponents } from 'react-tweet';
9
9
  export * from '@postrun/js/query';
@@ -2407,6 +2407,13 @@ declare function useValidatePost(profileId: string): {
2407
2407
  hint?: string;
2408
2408
  allowed?: Array<string>;
2409
2409
  got?: string;
2410
+ source?: {
2411
+ platform: "google" | "meta" | "x" | "linkedin" | "instagram" | "facebook" | "tiktok" | "youtube";
2412
+ platform_code?: string;
2413
+ field?: string;
2414
+ value?: string;
2415
+ platform_request_id?: string;
2416
+ };
2410
2417
  variant_index: number;
2411
2418
  path: Array<string | number>;
2412
2419
  platform?: "tiktok" | "x" | "linkedin" | "facebook_page" | "instagram";
@@ -2836,6 +2843,31 @@ declare function useTikTokCreatorInfo(connectionId: string | null): _tanstack_re
2836
2843
  max_video_duration_sec: number;
2837
2844
  }>, Error>;
2838
2845
 
2846
+ /**
2847
+ * The Google Ads campaign tree for one connection + window. The API returns FLAT
2848
+ * nodes lazily — `GET /ads/tree` gives the campaign level; `?campaign_id=` gives
2849
+ * that campaign's subtree — so this hook fetches the campaign level plus one query
2850
+ * per EXPANDED campaign, then `groupAdTree`s the merged set into the nested tree.
2851
+ *
2852
+ * Expansion is CONTROLLED: the caller owns which campaigns are open (a `Set`/array
2853
+ * of campaign ids) and passes it as `expanded`; the hook reacts by loading exactly
2854
+ * those subtrees. Changing `since`/`until`/`metrics` refetches (they're in the
2855
+ * query key). Metrics are Google's authoritative per-level numbers — no roll-up.
2856
+ */
2857
+ type UseAdTreeParams = Pick<GoogleGetAdTreeData['query'], 'since' | 'until' | 'metrics'> & {
2858
+ /** The Google Ads connection id (`conn_…`). */
2859
+ connectionId: string;
2860
+ /** Campaign ids whose subtree to load (the expanded rows). */
2861
+ expanded?: string[];
2862
+ };
2863
+ type UseAdTreeResult = Pick<UseQueryResult<GoogleGetAdTreeResponse, GoogleGetAdTreeError>, 'isLoading' | 'isError' | 'error' | 'refetch'> & {
2864
+ /** The campaign roots, each with its loaded children nested under it. */
2865
+ tree: AdTreeNode[];
2866
+ /** Whether the subtree for an expanded campaign is still loading. */
2867
+ isExpanding: (campaignId: string) => boolean;
2868
+ };
2869
+ declare function useAdTree(params: UseAdTreeParams): UseAdTreeResult;
2870
+
2839
2871
  /**
2840
2872
  * The paved FE path over the generated TanStack Query options. Pass a factory
2841
2873
  * that receives the configured client and returns one of the generated `*Options`
@@ -3339,4 +3371,4 @@ declare function Declaration({ brandedContent }: {
3339
3371
  brandedContent: boolean;
3340
3372
  }): react.JSX.Element;
3341
3373
 
3342
- export { ArticleCard, type ArticleCardProps, AudienceSelect, type CalendarFilters, CommercialDisclosure, Connect, type ConnectErrorReason, type ConnectOutcome, type ConnectProps, type ConnectRenderApi, type ConnectState, type ConnectionsFilter, Declaration, type DiscoverableAccount, DocumentCard, type DocumentCardProps, type InfiniteList, InstagramPostPreview, type InstagramPostPreviewProps, type InstagramPreviewVariant, type InstagramTheme, InteractionToggles, LinkedInPostPreview, type LinkedInPostPreviewProps, type LinkedInPreviewVariant, type LiveOptions, type MediaUploadItem, type MediaUploadOptions, type MediaUploadStatus, Poll, type PollProps, type PostrunContextValue, PostrunProvider, type PostrunProviderProps, type PreviewConnection, type PreviewMediaKind, type ReadPostVariant, type ReadyMedia, ReelPreview, type ReelPreviewProps, type ResolvedMedia, TikTokCaptionField, type TikTokCaptionFieldProps, TikTokPostPreview, type TikTokPostPreviewProps, type TikTokPreviewVariant, TikTokPublishPanel, type TikTokPublishPanelProps, type TikTokTheme, type UseConnectParams, type UseConnectResult, type UseMediaUploadOptions, type UseMediaUploadResult, XPoll, type XPollProps, XPostPreview, type XPostPreviewProps, type XPreviewQuotedTweet, type XPreviewVariant, connectionKeys, isReadyMedia, mediaKeys, postKeys, profileKeys, resolveVariantMedia, tiktokKeys, useCalendar, useConnect, useConnection, useConnections, useCreatePost, useCreateProfile, useDeleteMedia, useDeletePost, useDeleteProfile, useDisconnect, useDiscoverableAccounts, useInfiniteList, useMedia, useMediaInfinite, useMediaList, useMediaUpload, usePost, usePostrun, usePostrunMutation, usePostrunQuery, usePosts, usePostsInfinite, useProfile, useProfiles, useProfilesInfinite, useSelectAccount, useTikTokCreatorInfo, useUpdateMedia, useUpdatePost, useUpdateProfile, useValidatePost };
3374
+ export { ArticleCard, type ArticleCardProps, AudienceSelect, type CalendarFilters, CommercialDisclosure, Connect, type ConnectErrorReason, type ConnectOutcome, type ConnectProps, type ConnectRenderApi, type ConnectState, type ConnectionsFilter, Declaration, type DiscoverableAccount, DocumentCard, type DocumentCardProps, type InfiniteList, InstagramPostPreview, type InstagramPostPreviewProps, type InstagramPreviewVariant, type InstagramTheme, InteractionToggles, LinkedInPostPreview, type LinkedInPostPreviewProps, type LinkedInPreviewVariant, type LiveOptions, type MediaUploadItem, type MediaUploadOptions, type MediaUploadStatus, Poll, type PollProps, type PostrunContextValue, PostrunProvider, type PostrunProviderProps, type PreviewConnection, type PreviewMediaKind, type ReadPostVariant, type ReadyMedia, ReelPreview, type ReelPreviewProps, type ResolvedMedia, TikTokCaptionField, type TikTokCaptionFieldProps, TikTokPostPreview, type TikTokPostPreviewProps, type TikTokPreviewVariant, TikTokPublishPanel, type TikTokPublishPanelProps, type TikTokTheme, type UseAdTreeParams, type UseAdTreeResult, type UseConnectParams, type UseConnectResult, type UseMediaUploadOptions, type UseMediaUploadResult, XPoll, type XPollProps, XPostPreview, type XPostPreviewProps, type XPreviewQuotedTweet, type XPreviewVariant, connectionKeys, isReadyMedia, mediaKeys, postKeys, profileKeys, resolveVariantMedia, tiktokKeys, useAdTree, useCalendar, useConnect, useConnection, useConnections, useCreatePost, useCreateProfile, useDeleteMedia, useDeletePost, useDeleteProfile, useDisconnect, useDiscoverableAccounts, useInfiniteList, useMedia, useMediaInfinite, useMediaList, useMediaUpload, usePost, usePostrun, usePostrunMutation, usePostrunQuery, usePosts, usePostsInfinite, useProfile, useProfiles, useProfilesInfinite, useSelectAccount, useTikTokCreatorInfo, useUpdateMedia, useUpdatePost, useUpdateProfile, useValidatePost };
package/dist/index.js CHANGED
@@ -1,12 +1,13 @@
1
1
  "use client";
2
2
  import { createContext, memo, useMemo, useState, Fragment as Fragment$1, useRef, useLayoutEffect, useCallback, useEffect, createElement, useContext, useId } from 'react';
3
- import { useInfiniteQuery, useQuery, useMutation, QueryClient } from '@tanstack/react-query';
4
- import { xPollDurationLabel, linkedinPollDurationLabel, captionMaxFor, UploadError, TIKTOK_CAPTION_MAX, createPostrunClient, profilesList, profilesGet, profilesCreate, profilesUpdate, profilesDelete, connectionsConnect, connectionsListByProfile, connectionsGet, connectionsListAccounts, connectionsSelect, connectionsDelete, mediaGet, mediaList, mediaUpdate, mediaDelete, postsList, postsGet, postsCreate, buildCreatePost, isPostPlatform, failedVariants, isPublished, postsValidate, postsUpdate, postsDelete, tiktokCreatorInfo, audiencePrivacyOptions, audienceUnselected, tiktokPrivacyLabel, parsePrivacyLevel, TIKTOK_AUDIENCE_REQUIRED_HINT, commercialLabelNotice, commercialDisclosureIncomplete, setCommercialDisclosure, setBrandKind, TIKTOK_DISCLOSURE_REQUIRED_HINT, TIKTOK_BRANDED_CONTENT_POLICY_URL, TIKTOK_MUSIC_CONFIRMATION_URL, interactionRows, interactionValueKey, toggleInteraction, tiktokOptionsReady, TIKTOK_PROCESSING_NOTICE, brandedContentDeclared, mediaCreate, uploadFile, PostrunError } from '@postrun/js';
3
+ import { useInfiniteQuery, useQuery, useMutation, useQueries, QueryClient } from '@tanstack/react-query';
4
+ import { xPollDurationLabel, linkedinPollDurationLabel, captionMaxFor, UploadError, TIKTOK_CAPTION_MAX, createPostrunClient, profilesList, profilesGet, profilesCreate, profilesUpdate, profilesDelete, connectionsConnect, connectionsListByProfile, connectionsGet, connectionsListAccounts, connectionsSelect, connectionsDelete, mediaGet, mediaList, mediaUpdate, mediaDelete, postsList, postsGet, postsCreate, buildCreatePost, isPostPlatform, failedVariants, isPublished, postsValidate, postsUpdate, postsDelete, tiktokCreatorInfo, groupAdTree, audiencePrivacyOptions, audienceUnselected, tiktokPrivacyLabel, parsePrivacyLevel, TIKTOK_AUDIENCE_REQUIRED_HINT, commercialLabelNotice, commercialDisclosureIncomplete, setCommercialDisclosure, setBrandKind, TIKTOK_DISCLOSURE_REQUIRED_HINT, TIKTOK_BRANDED_CONTENT_POLICY_URL, TIKTOK_MUSIC_CONFIRMATION_URL, interactionRows, interactionValueKey, toggleInteraction, tiktokOptionsReady, TIKTOK_PROCESSING_NOTICE, brandedContentDeclared, mediaCreate, uploadFile, PostrunError } from '@postrun/js';
5
5
  export { TIKTOK_CAPTION_MAX, UploadError, captionMaxFor } from '@postrun/js';
6
6
  import Nango, { AuthError } from '@nangohq/frontend';
7
7
  import pWaitFor, { TimeoutError } from 'p-wait-for';
8
8
  import pLimit from 'p-limit';
9
9
  import * as query_star from '@postrun/js/query';
10
+ import { googleGetAdTreeOptions } from '@postrun/js/query';
10
11
  import { enrichTweet, TweetContainer, TweetHeader, TweetInReplyTo, TweetBody, TweetMedia, QuotedTweet } from 'react-tweet';
11
12
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
12
13
  import { FiMessageCircle, FiRepeat, FiHeart, FiBarChart2, FiShare, FiGlobe, FiUsers, FiThumbsUp, FiMessageSquare, FiSend, FiBookmark, FiMoreHorizontal, FiFileText } from 'react-icons/fi';
@@ -64,6 +65,7 @@ __export(index_exports, {
64
65
  profileKeys: () => profileKeys,
65
66
  resolveVariantMedia: () => resolveVariantMedia,
66
67
  tiktokKeys: () => tiktokKeys,
68
+ useAdTree: () => useAdTree,
67
69
  useCalendar: () => useCalendar,
68
70
  useConnect: () => useConnect,
69
71
  useConnection: () => useConnection,
@@ -1002,6 +1004,76 @@ function useTikTokCreatorInfo(connectionId) {
1002
1004
  queryClient
1003
1005
  );
1004
1006
  }
1007
+ function useAdTree(params) {
1008
+ const { connectionId, since, until, metrics, expanded = [] } = params;
1009
+ const { client, queryClient } = usePostrun();
1010
+ const enabled = Boolean(connectionId && since && until);
1011
+ const path = { connection_id: connectionId };
1012
+ const baseQuery = { since, until, metrics };
1013
+ const campaign = useQuery(
1014
+ {
1015
+ ...googleGetAdTreeOptions({ client, path, query: baseQuery }),
1016
+ enabled
1017
+ },
1018
+ queryClient
1019
+ );
1020
+ const combine = useCallback(
1021
+ (results) => {
1022
+ const nodes = results.flatMap((q) => q.data?.data ?? []);
1023
+ const loadingById2 = new Map(
1024
+ expanded.map((id, i) => [id, results[i]?.isLoading ?? false])
1025
+ );
1026
+ return { nodes, loadingById: loadingById2 };
1027
+ },
1028
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- expanded is an array; join gives a stable string dep
1029
+ // biome-ignore lint/correctness/useExhaustiveDependencies: intentional string-join dep for array stability
1030
+ [expanded.join(",")]
1031
+ );
1032
+ const { nodes: subtreeNodes, loadingById } = useQueries(
1033
+ {
1034
+ queries: expanded.map((campaignId) => ({
1035
+ ...googleGetAdTreeOptions({
1036
+ client,
1037
+ path,
1038
+ query: { ...baseQuery, campaign_id: campaignId }
1039
+ }),
1040
+ enabled
1041
+ })),
1042
+ combine
1043
+ },
1044
+ queryClient
1045
+ );
1046
+ const tree = useMemo(
1047
+ () => groupAdTree([...campaign.data?.data ?? [], ...subtreeNodes]),
1048
+ [campaign.data, subtreeNodes]
1049
+ );
1050
+ const isExpanding = useCallback(
1051
+ (campaignId) => loadingById.get(campaignId) ?? false,
1052
+ [loadingById]
1053
+ );
1054
+ const refetch = useCallback(
1055
+ (...args) => campaign.refetch(...args),
1056
+ [campaign.refetch]
1057
+ );
1058
+ return useMemo(
1059
+ () => ({
1060
+ tree,
1061
+ isLoading: campaign.isLoading,
1062
+ isError: campaign.isError,
1063
+ error: campaign.error,
1064
+ isExpanding,
1065
+ refetch
1066
+ }),
1067
+ [
1068
+ tree,
1069
+ campaign.isLoading,
1070
+ campaign.isError,
1071
+ campaign.error,
1072
+ isExpanding,
1073
+ refetch
1074
+ ]
1075
+ );
1076
+ }
1005
1077
 
1006
1078
  // src/query.ts
1007
1079
  var query_exports = {};
@@ -3452,6 +3524,6 @@ var postButtonStyle = {
3452
3524
  transition: "opacity 160ms ease"
3453
3525
  };
3454
3526
 
3455
- export { ArticleCard, AudienceSelect, CommercialDisclosure, Connect, Declaration, DocumentCard, InstagramPostPreview, InteractionToggles, LinkedInPostPreview, Poll, PostrunProvider, ReelPreview, TikTokCaptionField, TikTokPostPreview, TikTokPublishPanel, XPoll, XPostPreview, connectionKeys, isReadyMedia, mediaKeys, postKeys, profileKeys, resolveVariantMedia, tiktokKeys, useCalendar, useConnect, useConnection, useConnections, useCreatePost, useCreateProfile, useDeleteMedia, useDeletePost, useDeleteProfile, useDisconnect, useDiscoverableAccounts, useInfiniteList, useMedia, useMediaInfinite, useMediaList, useMediaUpload, usePost, usePostrun, usePostrunMutation, usePostrunQuery, usePosts, usePostsInfinite, useProfile, useProfiles, useProfilesInfinite, useSelectAccount, useTikTokCreatorInfo, useUpdateMedia, useUpdatePost, useUpdateProfile, useValidatePost };
3527
+ export { ArticleCard, AudienceSelect, CommercialDisclosure, Connect, Declaration, DocumentCard, InstagramPostPreview, InteractionToggles, LinkedInPostPreview, Poll, PostrunProvider, ReelPreview, TikTokCaptionField, TikTokPostPreview, TikTokPublishPanel, XPoll, XPostPreview, connectionKeys, isReadyMedia, mediaKeys, postKeys, profileKeys, resolveVariantMedia, tiktokKeys, useAdTree, useCalendar, useConnect, useConnection, useConnections, useCreatePost, useCreateProfile, useDeleteMedia, useDeletePost, useDeleteProfile, useDisconnect, useDiscoverableAccounts, useInfiniteList, useMedia, useMediaInfinite, useMediaList, useMediaUpload, usePost, usePostrun, usePostrunMutation, usePostrunQuery, usePosts, usePostsInfinite, useProfile, useProfiles, useProfilesInfinite, useSelectAccount, useTikTokCreatorInfo, useUpdateMedia, useUpdatePost, useUpdateProfile, useValidatePost };
3456
3528
  //# sourceMappingURL=index.js.map
3457
3529
  //# sourceMappingURL=index.js.map