UNPKG

@follow-app/client-sdk

Version:

TypeScript client SDK for Follow RSS Server API

144 lines (122 loc) 3.44 kB
// Import types from drizzle schema import type { featureFlags, userFeatureOverrides } from "@folo-services/drizzle" import type { InferInsertModel, InferSelectModel } from "drizzle-orm" import type { EmptyResponse, SerializedInsertModel, SerializedModel, SuccessResponse } from "../../types" // Re-export database types export type FeatureFlagModel = SerializedModel<InferSelectModel<typeof featureFlags>> export type FeatureFlagInsert = SerializedInsertModel<InferInsertModel<typeof featureFlags>> export type UserFeatureOverrideModel = SerializedModel<InferSelectModel< typeof userFeatureOverrides >> export type UserFeatureOverrideInsert = SerializedInsertModel<InferInsertModel< typeof userFeatureOverrides >> export const ROLLOUT_TYPES = ["whitelist", "percentage"] as const export type RolloutType = (typeof ROLLOUT_TYPES)[number] export type RolloutValue = 0 | 1 // Common response types export type MessageResponse = SuccessResponse<{ message: string }> // Feature flags types export type FeatureFlagResponse = SuccessResponse<FeatureFlagModel> export type FeatureFlagListResponse = SuccessResponse<FeatureFlagModel[]> export interface FeatureFlagUpdateRequest { description?: string enabled?: boolean rolloutType?: RolloutType rolloutValue?: RolloutValue rolloutPercentage?: number rolloutSeed?: string } export interface UserOverrideRequest { userId: string forceEnabled: boolean reason?: string expiresAt?: string } export type FeatureStatsResponse = SuccessResponse<{ totalUsers: number enabledUsers: number overrideUsers: number rolloutType: string rolloutPercentage: number enabledOverrides: number disabledOverrides: number enabled: boolean enabledByRollout: number enabledByOverride: number disabledUsers: number }> export interface AffectedUsersQuery { page?: number limit?: number filter?: "all" | "enabled" | "disabled" | "override" search?: string } export interface AffectedUser { id: string name: string | null email: string handle: string | null image: string | null createdAt: string status: "enabled" | "disabled" reason: "rollout" | "override" overrideReason: string | null overrideExpiresAt: string | null overrideCreatedBy: string | null } export type AffectedUsersResponse = SuccessResponse<{ users: AffectedUser[] pagination: { page: number limit: number total: number totalPages: number } }> // Unified input types for new API export interface FeatureFlagUpdateInput { name: string description?: string enabled?: boolean rolloutType?: RolloutType rolloutValue?: RolloutValue rolloutPercentage?: number rolloutSeed?: string } export interface UserOverrideInput { name: string userId: string forceEnabled: boolean reason?: string expiresAt?: string } export interface RemoveOverrideInput { name: string userId: string } export interface FeatureStatsInput { name: string } export interface AffectedUsersInput { name: string page?: number limit?: number filter?: "all" | "enabled" | "disabled" | "override" search?: string } // Clean operations types export interface CleanRequest { type: string feedId?: string nsfw?: boolean } export type CleanResponse = EmptyResponse // Mint operations types export interface MintRequest { userId: string amount: number key: string comment?: string } export type MintResponse = SuccessResponse<string>