@playlive/fundraiser-data
    Preparing search index...

    Function createDonationsFetcher

    Fallthrough overload — used when charityType is a runtime value (CharityType) rather than a string literal. The return type is the union of both Tiltify + Twitch shapes; consumers must narrow on metadata.after vs. metadata.nextPage before advancing.

    See the main createDonationsFetcher docblock for full behavior notes.

    • Unified donations fetcher factory.

      Three overload signatures are exposed so the return type is narrowed to the concrete underlying fetcher when the caller passes a string-literal charityType. This matters because Tiltify and Twitch donations paginate differently:

      • Tiltify uses an opaque string cursor (metadata.after). The returned closure expects pageParam: string | null | undefined and returns PaginatedResponse<TiltifyDonation, TiltifyPaginationMetadata>.
      • Twitch uses a numeric page index (metadata.nextPage). The returned closure expects pageParam: number | null | undefined and returns PaginatedResponse<TiltifyDonation, TwitchPaginationMetadata>. Note that even on the Twitch path the rows are shaped as TiltifyDonation — the per-row conversion happens inside the factory via convertTwitchToTiltifyDonation.

      When the caller passes a runtime-typed CharityType (the fallthrough overload) the union of both shapes is returned and the caller must narrow before consuming pageParam.

      Both underlying factories are themselves cursor-aware closures shaped to plug directly into TanStack Query's useInfiniteQuery.

      Parameters

      • params: {
            campaignId: string;
            charityType: "twitch";
            config?: DonationFetchConfig;
            count?: number;
            isTeam?: boolean;
        }
        • campaignId: string

          Source-platform campaign UUID.

        • charityType: "twitch"

          String-literal "tiltify" / "twitch" to engage the typed overloads; a runtime CharityType to use the fallthrough.

        • Optionalconfig?: DonationFetchConfig

          DonationFetchConfig (completedBefore, completedAfter, test-flag toggles, caching). Twitch reads only the two timestamp filters; the rest are Tiltify-only.

        • Optionalcount?: number

          Page size, clamped to 100 by the Tiltify client. Defaults to 100.

        • OptionalisTeam?: boolean

          Tiltify-only: route through team_campaigns. Ignored on the Twitch path.

      Returns (
          fetchParams: { pageParam: number | null | undefined },
      ) => Promise<PaginatedResponse<TiltifyDonation, TwitchPaginationMetadata>>

      // Tiltify: pageParam is a string cursor.
      const tiltifyPage = createDonationsFetcher({
      charityType: "tiltify",
      campaignId: "abc-123",
      });
      const p1 = await tiltifyPage({ pageParam: null });
      const p2 = await tiltifyPage({ pageParam: p1.metadata.after });
      // Twitch: pageParam is a numeric page index.
      const twitchPage = createDonationsFetcher({
      charityType: "twitch",
      campaignId: "twitch-1",
      });
      const p1 = await twitchPage({ pageParam: 0 });
      const p2 = await twitchPage({ pageParam: p1.metadata.nextPage });
    • Tiltify overload — see the main createDonationsFetcher docblock.

      Parameters

      • params: {
            campaignId: string;
            charityType: "tiltify";
            config?: DonationFetchConfig;
            count?: number;
            isTeam?: boolean;
        }

      Returns (
          fetchParams: { pageParam: string | null | undefined },
      ) => Promise<PaginatedResponse<TiltifyDonation, TiltifyPaginationMetadata>>

      A cursor-aware closure where pageParam is the Tiltify opaque after cursor and the response carries metadata.after / metadata.before for cursor advancement.