import { z } from "zod"; import { FlairSchema } from "../schema/schema.js"; import { ChallengeExcludeSchema, ChallengeFileFactoryArgsSchema, ChallengeFileFactorySchema, ChallengeFileSchema, ChallengeFromGetChallengeSchema, ChallengeResultSchema, CommunityAnchorSchema, CreateNewLocalCommunityParsedOptionsSchema, CreateNewLocalCommunityUserOptionsSchema, CreateRemoteCommunityOptionsSchema, GetChallengeArgsSchema, CommunityChallengeSchema, CommunityChallengeSettingSchema, CommunityEditOptionsSchema, CommunityEncryptionSchema, CommunityFeaturesSchema, CommunityIpfsSchema, CommunityRoleSchema, CommunitySettingsSchema, CommunitySuggestedSchema, RpcRemoteCommunityUpdateEventResultSchema, CommunitySignedPropertyNames, CommunityRoleNames, ExportCommunityUserOptionsSchema, ExportCommunityModLogsOptionsSchema, CommunityExportRecordSchema } from "./schema.js"; import { RpcLocalCommunity } from "./rpc-local-community.js"; import { LocalCommunity } from "../runtime/browser/community/local-community.js"; import { RemoteCommunity } from "./remote-community.js"; import { RpcRemoteCommunity } from "./rpc-remote-community.js"; import type { JsonOfClass } from "../types.js"; import type { JsonSignature } from "../signer/types.js"; import type { DecryptedChallengeAnswerMessageType, DecryptedChallengeMessageType, DecryptedChallengeRequestMessageTypeWithCommunityAuthor, DecryptedChallengeVerificationMessageType } from "../pubsub-messages/types.js"; import { PKCError } from "../pkc-error.js"; export type ReplyStats = { hourReplyCount: number; dayReplyCount: number; weekReplyCount: number; monthReplyCount: number; yearReplyCount: number; allReplyCount: number; }; export type CommunityStats = { hourActiveUserCount: number; dayActiveUserCount: number; weekActiveUserCount: number; monthActiveUserCount: number; yearActiveUserCount: number; allActiveUserCount: number; hourPostCount: number; dayPostCount: number; weekPostCount: number; monthPostCount: number; yearPostCount: number; allPostCount: number; } & ReplyStats; export type CommunityFeatures = z.infer; export type CommunitySuggested = z.infer; export type Flair = z.infer; export type CommunityEncryption = z.infer; export type CommunityRole = z.infer; export type CommunityRoleNameUnion = z.infer; export type RpcRemoteCommunityType = z.infer; export type CommunityIpfsType = z.infer; export interface CommunitySignature extends JsonSignature { signedPropertyNames: typeof CommunitySignedPropertyNames; } export type CreateRemoteCommunityOptions = z.infer; export type CommunityAnchor = z.infer; export interface AnchorPublishPreparation { nextSequence: string; currentAnchorRecordSequence: string; hasPersistedAnchorRecord: boolean; } export interface PublishedAnchorRecord { sequence: string; value: string; anchorPublicKey: string; } export type CreateNewLocalCommunityUserOptions = z.infer; export type CreateNewLocalCommunityParsedOptions = z.infer; export type CreateInstanceOfLocalOrRemoteCommunityOptions = { address: string; }; export type CommunityEditOptions = z.infer; export type Exclude = z.infer; export type CommunityChallenge = z.infer; export type CommunityChallengeSetting = z.infer; export type Challenge = z.infer; export type ChallengeInput = z.input; export type ChallengeResult = z.infer; export type ChallengeResultInput = z.input; export type ChallengeFile = z.infer; export type ChallengeFileInput = z.input; export type ChallengeFileFactory = z.infer; export type ChallengeFileFactoryInput = z.input; export type ChallengeFileFactoryArgs = z.infer; export type ChallengeFileFactoryArgsInput = z.input; export type GetChallengeArgs = z.infer; export type GetChallengeArgsInput = z.input; export type CommunitySettings = z.infer; export type RpcRemoteCommunityUpdateEventResultType = z.infer; export type RemoteCommunityJson = JsonOfClass; export type RpcRemoteCommunityJson = JsonOfClass; export type RpcLocalCommunityJson = JsonOfClass; export type LocalCommunityJson = JsonOfClass; export type CommunityJson = RemoteCommunityJson | RpcRemoteCommunityJson | RpcLocalCommunityJson | LocalCommunityJson; export type CommunityState = "stopped" | "updating" | "started"; export type CommunityStartedState = "stopped" | "publishing-ipns" | "failed" | "succeeded"; export type CommunityUpdatingState = CommunityStartedState | "stopped" | "resolving-name" | "fetching-ipns" | "fetching-ipfs" | "failed" | "succeeded" | "waiting-retry"; export interface InternalCommunityRecordBeforeFirstUpdateType extends CreateNewLocalCommunityParsedOptions { settings: CommunitySettings; challenges: CommunityIpfsType["challenges"]; createdAt: CommunityIpfsType["createdAt"]; protocolVersion: CommunityIpfsType["protocolVersion"]; encryption: CommunityIpfsType["encryption"]; _usingDefaultChallenge: boolean; _internalStateUpdateId: string; _pendingEditProps: Partial[]; } export interface InternalCommunityRecordAfterFirstUpdateType extends InternalCommunityRecordBeforeFirstUpdateType, CommunityIpfsType { updateCid: string; _cidsToUnPin: string[]; _mfsPathsToRemove: string[]; _configuredPubsubTopic?: string; } export interface RpcLocalCommunityLocalProps { signer: Omit; anchor?: CommunityAnchor; anchorRecordSequence?: string; settings: CommunitySettings; _usingDefaultChallenge: boolean; address: string; started: boolean; startedState: RpcLocalCommunity["startedState"]; } export interface RpcInternalCommunityRecordBeforeFirstUpdateType { localCommunity: Omit & RpcLocalCommunityLocalProps; } export interface RpcInternalCommunityRecordAfterFirstUpdateType { community: CommunityIpfsType; localCommunity: RpcLocalCommunityLocalProps; runtimeFields: { updateCid: string; updatingState?: RpcLocalCommunity["updatingState"]; nameResolved?: boolean; }; } export type RpcLocalCommunityUpdateResultType = RpcInternalCommunityRecordBeforeFirstUpdateType | RpcInternalCommunityRecordAfterFirstUpdateType; export interface ParsedCommunityEditOptions extends Omit, Pick { } export interface CommunityEvents { challengerequest: (request: DecryptedChallengeRequestMessageTypeWithCommunityAuthor) => void; challenge: (challenge: DecryptedChallengeMessageType) => void; challengeanswer: (answer: DecryptedChallengeAnswerMessageType) => void; challengeverification: (verification: DecryptedChallengeVerificationMessageType) => void; error: (error: PKCError | Error) => void; statechange: (newState: RemoteCommunity["state"]) => void; updatingstatechange: (newState: RemoteCommunity["updatingState"]) => void; startedstatechange: (newState: RpcLocalCommunity["startedState"]) => void; update: (updatedCommunity: RemoteCommunity) => void; exportschange: (records: CommunityExportRecord[]) => void; removeListener: (eventName: string, listener: Function) => void; } export type ExportCommunityUserOptions = z.infer; export type ExportCommunityModLogsOptions = z.infer; export type CommunityExportRecord = z.infer; export type CommunityEventArgs = Parameters; export type CommunityRpcErrorToTransmit = CommunityEventArgs<"error">[0] & { details?: PKCError["details"] & { newUpdatingState?: RemoteCommunity["updatingState"]; newStartedState?: RpcLocalCommunity["startedState"]; }; };