import {z} from 'zod' export type CreateApiV1ContentFlagsIdDismissOptions = {baseUrl?: string | undefined, apiKeyAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const flagAction = z.enum(["DELETE_CONTENT", "BAN_USER", "DELETE_AND_BAN"]); export const analysisCategory = z.enum(["VIOLENCE", "HATE_SPEECH", "SEXUAL_CONTENT", "HARASSMENT", "SPAM", "SCAM", "SELF_HARM", "ILLEGAL_ACTIVITY", "MISINFORMATION", "COPYRIGHT", "SAFE"]); export const contentFlagCategoryResultDto = z.object({category: analysisCategory, confidence: z.number(), detected: z.boolean()}); export const analysisStatus = z.enum(["PENDING", "PROCESSING", "COMPLETED", "FAILED"]); export const contentFlagModerationDto = z.object({categories: z.array(contentFlagCategoryResultDto).nullable(), completedAt: z.string().nullable(), confidence: z.number().nullable(), errorMessage: z.string().nullable(), provider: z.string().nullable(), reasoning: z.string().nullable(), recommendation: z.string().nullable(), status: analysisStatus, summary: z.string().nullable()}); export const contentType = z.enum(["CHAT_MESSAGE", "COMMENT", "STREAM", "RECORDING"]); export const flagReason = z.enum(["INAPPROPRIATE_CONTENT", "SPAM", "HARASSMENT", "SCAM", "OTHER"]); export const engagementBadge = z.enum(["SPARK", "GATHERING", "CROWD", "MOVEMENT"]); export const launchBadge = z.enum(["ONE_HIT_WONDER", "TOKEN_CRAFTER", "CRYPTO_SAVVY", "CRYPTO_PRO", "MIDAS_TOUCH"]); export const successBadge = z.enum(["250k", "1M", "10M+"]); export const volumeBadge = z.enum(["1k", "10k", "100k", "1M+"]); export const contentFlagReporterDto = z.object({bio: z.string().nullable().optional(), createdAt: z.string().optional(), engagementBadge: z.union([engagementBadge, z.unknown()]).optional(), fullName: z.string().nullable(), launchBadge: z.union([launchBadge, z.unknown()]).optional(), profileImage: z.string().nullable(), successBadge: z.union([successBadge, z.unknown()]).optional(), volumeBadge: z.union([volumeBadge, z.unknown()]).optional()}); export const flagStatus = z.enum(["PENDING", "DISMISSED", "ACTIONED"]); export const contentFlagResponseDto = z.object({actionTaken: z.union([flagAction, z.unknown()]), aiModeration: z.union([contentFlagModerationDto, z.unknown()]).optional(), contentId: z.string(), contentSnapshot: z.string().nullable(), contentType: contentType, createdAt: z.string(), details: z.string().nullable(), id: z.number(), reason: z.union([flagReason, z.unknown()]), reportedUserAddress: z.string(), reporter: contentFlagReporterDto.optional(), reporterAddress: z.string(), reviewedAt: z.string().nullable(), reviewedBy: z.string().nullable(), status: flagStatus, tokenName: z.string(), updatedAt: z.string()}); export const contentFlagMutationDataDto = z.object({flag: contentFlagResponseDto}); export const contentFlagMutationSuccessEnvelopeDto = z.object({data: contentFlagMutationDataDto, error: z.literal(false), message: z.string(), status: z.number()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Dismiss flag * * POST /v1/content-flags/{id}/dismiss * * Also accepts auth: bearer */ export const createApiV1ContentFlagsIdDismiss = async (options?: CreateApiV1ContentFlagsIdDismissOptions) => { const {baseUrl = "https://lpad-backend.stage.defi.ovh.gala.com", fetch: fetchFn = fetch, apiKeyAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (apiKeyAuth !== undefined) headers.set("x-api-key", apiKeyAuth) const url = `${baseUrl.replace(/\/+$/, '')}/v1/content-flags/${encodeURIComponent(String(args.id))}/dismiss${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(contentFlagMutationSuccessEnvelopeDto, await res.json()) };