import Logger from "../../logger.js"; import EventEmitter from "events"; import type { CreateNewLocalCommunityUserOptions } from "../../community/types.js"; import type { CommentChallengeRequestToEncryptType } from "../../publications/comment/types.js"; import type { VoteChallengeRequestToEncryptType } from "../../publications/vote/types.js"; import type { CommentEditChallengeRequestToEncryptType } from "../../publications/comment-edit/types.js"; import type { CommentModerationChallengeRequestToEncrypt } from "../../publications/comment-moderation/types.js"; import type { CommunityEditChallengeRequestToEncryptType } from "../../publications/community-edit/types.js"; import type { PKCWsServerSettingsSerialized } from "../../rpc/src/types.js"; import type { CommentIpfsType } from "../../publications/comment/types.js"; import { SetNewSettingsPKCWsServerSchema } from "../../rpc/src/schema.js"; import * as z from "zod"; import { TypedEmitter } from "tiny-typed-emitter"; import type { PKCRpcClientEvents } from "../../types.js"; import type { AuthorNameRpcParam, CommunityIdentifierRpcParam, CidRpcParam, FetchCidRpcParam, CommentPageRpcParam, CommunityPageRpcParam, EditCommunityRpcParam, PublishChallengeAnswersRpcParam, RpcInternalCommunityRecordBeforeFirstUpdateType, RpcLocalCommunityUpdateResultType, RpcCommentPageResult, RpcCommunityPageResult, RpcResolveAuthorNameResult, RpcSubscriptionIdResult, RpcSuccessResult, RpcFetchCidResult, ExportCommunityRpcParam, CancelExportRpcParam, RpcExportCommunityResult, ExportCommunityModLogsRpcParam, RpcExportCommunityModLogsResult, PublishAnchorRecordRpcParam, AnchorPublishPreparation, PublishedAnchorRecord } from "./types.js"; export default class PKCRpcClient extends TypedEmitter { state: "stopped" | "connecting" | "failed" | "connected"; communities: string[]; settings?: PKCWsServerSettingsSerialized; private _webSocketClient; private _websocketServerUrl; private _subscriptionEvents; private _pendingSubscriptionMsgs; private _timeoutSeconds; private _callTimeoutMs; private _openConnectionPromise?; private _destroyRequested; constructor(rpcServerUrl: string); setState(newState: PKCRpcClient["state"]): void; _init(): Promise; destroy(): Promise; private _waitForSocketClose; toJSON(): undefined; getSubscription(subscriptionId: number): EventEmitter<[never]>; unsubscribe(subscriptionId: number): Promise; private _deserializeRpcError; private _setErrorName; private _assignAdditionalProps; subscriptionActive(subscriptionId: number): boolean; attachSubscriptionHandlersDeferred(opts: { subscriptionId: number; isStale: () => boolean; attach: (subscription: EventEmitter) => void; replayErrorContainment: { entityName: string; log: ReturnType; emitError: (error: Error) => void; stop: () => Promise; }; }): void; private _containReplayError; private _emitPendingMessagesWhile; emitAllPendingMessages(subscriptionId: number): void; getComment(args: CidRpcParam): Promise; getCommentPage(page: CommentPageRpcParam): Promise; getCommunityPage(page: CommunityPageRpcParam): Promise; createCommunity(createCommunityOptions: CreateNewLocalCommunityUserOptions): Promise; private _initSubscriptionEvent; startCommunity(communityIdentifier: CommunityIdentifierRpcParam): Promise; stopCommunity(communityIdentifier: CommunityIdentifierRpcParam): Promise; prepareAnchorPublish(communityIdentifier: CommunityIdentifierRpcParam): Promise; publishAnchorRecord(args: PublishAnchorRecordRpcParam): Promise; editCommunity(args: EditCommunityRpcParam): Promise; deleteCommunity(communityIdentifier: CommunityIdentifierRpcParam): Promise; communityUpdateSubscribe(communityIdentifier: CommunityIdentifierRpcParam): Promise; publishComment(commentProps: CommentChallengeRequestToEncryptType): Promise; publishCommentEdit(commentEditProps: CommentEditChallengeRequestToEncryptType): Promise; publishCommentModeration(commentModProps: CommentModerationChallengeRequestToEncrypt): Promise; publishVote(voteProps: VoteChallengeRequestToEncryptType): Promise; publishCommunityEdit(communityEdit: CommunityEditChallengeRequestToEncryptType): Promise; commentUpdateSubscribe(args: CidRpcParam): Promise; publishChallengeAnswers(args: PublishChallengeAnswersRpcParam): Promise; resolveAuthorName(parsedAuthorName: AuthorNameRpcParam): Promise; initalizeCommunitieschangeEvent(): Promise; initalizeSettingschangeEvent(): Promise; fetchCid(args: FetchCidRpcParam): Promise; setSettings(settings: z.input): Promise; rpcCall(method: string, params: any[]): Promise; get rpcHttpOrigin(): string; exportCommunity(args: ExportCommunityRpcParam): Promise; exportCommunityModLogs(args: ExportCommunityModLogsRpcParam): Promise; exportsSubscribe(args: CommunityIdentifierRpcParam): Promise; cancelExport(args: CancelExportRpcParam): Promise; getDefaults(): Promise; getPeers(): Promise; getStats(): Promise; }