import type { create as CreateIpfsClient, Options as IpfsHttpClientOptions } from "kubo-rpc-client"; import type Publication from "./publications/publication.js"; import type { PKCError } from "./pkc-error.js"; import type { PKC } from "./pkc/pkc.js"; import { AuthorAvatarNftSchema, AuthorPubsubSchema, AuthorWithOptionalCommentUpdateSchema, CreatePublicationUserOptionsSchema, ProtocolVersionSchema } from "./schema/schema.js"; import { z } from "zod"; import type { DecryptedChallengeRequestPublication } from "./pubsub-messages/types.js"; import { ChainTickerSchema, NameResolverSchema, PKCParsedOptionsSchema, PKCUserOptionsSchema } from "./schema.js"; import PKCRpcClient from "./clients/rpc-client/pkc-rpc-client.js"; import type { PKCWsServerSettingsSerialized } from "./rpc/src/types.js"; import { LRUCache } from "lru-cache"; import type { CommunityIpfsType } from "./community/types.js"; import type { PageIpfs } from "./pages/types.js"; import type { CommentIpfsType } from "./publications/comment/types.js"; import type { CidRpcParam } from "./clients/rpc-client/types.js"; export type ProtocolVersion = z.infer; export type ChainTicker = z.infer; export type NameResolver = z.infer; export type InputPKCOptions = z.input; export type ParsedPKCOptions = z.output; export type GetCommunityArgs = { address?: string; name?: CommunityIpfsType["name"]; publicKey?: string; abortSignal?: AbortSignal; }; export type GetCommentArgs = CidRpcParam & { abortSignal?: AbortSignal; }; export type AuthorPubsubType = z.infer; export type AuthorTypeWithCommentUpdate = z.infer; export type RuntimeAuthorType = AuthorPubsubType & { address: string; publicKey: string; }; export type RuntimeAuthorWithCommentUpdateType = AuthorTypeWithCommentUpdate & { address: string; publicKey: string; nameResolved?: boolean; }; export type CreatePublicationOptions = z.infer; export type Nft = z.infer; export type AuthorPubsubJsonType = RuntimeAuthorType & { shortAddress: string; }; export type AuthorWithOptionalCommentUpdateJson = RuntimeAuthorWithCommentUpdateType & { shortAddress: string; }; export type PublicationTypeName = keyof DecryptedChallengeRequestPublication; export type NativeFunctions = { fetch: typeof fetch; }; export interface PKCEvents { error: (error: PKCError | Error) => void; communitieschange: (listOfCommunities: string[]) => void; settingschange: (newSettings: ParsedPKCOptions) => void; } export interface PKCRpcClientEvents { statechange: (state: PKCRpcClient["state"]) => void; error: (error: PKCError | Error) => void; communitieschange: (listOfCommunities: string[]) => void; settingschange: (newSettings: PKCWsServerSettingsSerialized) => void; } export interface GenericClientEvents { statechange: (state: T) => void; } export interface IpfsStats { totalIn: number; totalOut: number; rateIn: number; rateOut: number; succeededIpfsCount: number; failedIpfsCount: number; succeededIpfsAverageTime: number; succeededIpfsMedianTime: number; succeededIpnsCount: number; failedIpnsCount: number; succeededIpnsAverageTime: number; succeededIpnsMedianTime: number; } export interface IpfsCommunityStats { stats: IpfsStats; sessionStats: IpfsStats; } export interface PubsubStats { totalIn: number; totalOut: number; rateIn: number; rateOut: number; succeededChallengeRequestMessageCount: number; failedChallengeRequestMessageCount: number; succeededChallengeRequestMessageAverageTime: number; succeededChallengeRequestMessageMedianTime: number; succeededChallengeAnswerMessageCount: number; failedChallengeAnswerMessageCount: number; succeededChallengeAnswerMessageAverageTime: number; succeededChallengeAnswerMessageMedianTime: number; } export interface PubsubCommunityStats { stats: PubsubStats; sessionStats: PubsubStats; } export interface KuboRpcClient { peers: () => ReturnType; stats?: undefined; sessionStats?: undefined; communityStats?: undefined; _client: ReturnType; url: string; _clientOptions: IpfsHttpClientOptions; destroy: () => Promise; } export type PubsubSubscriptionHandler = Extract[1], Function>; export type IpfsHttpClientPubsubMessage = Parameters["0"]; export interface PubsubClient { peers: () => Promise; stats?: undefined; sessionStats?: undefined; communityStats?: undefined; _client: Pick; _clientOptions: KuboRpcClient["_clientOptions"]; url: string; destroy: () => Promise; } export interface GatewayClient { stats?: IpfsStats; sessionStats?: IpfsStats; communityStats?: { [communityAddress: string]: IpfsCommunityStats; }; } export interface StorageInterface { init: () => Promise; getItem: (key: string) => Promise; setItem: (key: string, value: any) => Promise; removeItem: (key: string | string[]) => Promise; clear: () => Promise; destroy: () => Promise; } type LRUStorageCacheNames = "pkcjs_lrustorage_postTimestamp" | "pkcjs_lrustorage_commentPostUpdatesParentsPath" | "pkcjs_lrustorage_nameResolutions"; export interface LRUStorageConstructor { maxItems: number; cacheName: LRUStorageCacheNames | string; pkc: Pick; } export interface LRUStorageInterface { init: () => Promise; getItem: (key: string) => Promise; setItem: (key: string, value: any) => Promise; removeItem: (key: string) => Promise; clear: () => Promise; keys: () => Promise; destroy: () => Promise; } type OmitUnderscoreProps = Omit; type ExcludeMethods = { [K in keyof T as T[K] extends Function ? never : K]: T[K]; }; export type JsonOfClass = ExcludeMethods>; export type ResultOfFetchingCommunity = { community: CommunityIpfsType; cid: string; } | undefined; export type PKCMemCaches = { communityVerificationCache: LRUCache; pageVerificationCache: LRUCache; commentVerificationCache: LRUCache; commentUpdateVerificationCache: LRUCache; commentIpfs: LRUCache; communityForPublishing: LRUCache>; pageCidToSortTypes: LRUCache, string[]>; pagesMaxSize: LRUCache, number>; nameResolvedCache: LRUCache; }; export {};