import type * as os from 'node:os'; import type { GrowiDeploymentType, GrowiServiceType } from '../consts/system'; export const GrowiWikiType = { open: 'open', closed: 'closed' } as const; type GrowiWikiType = (typeof GrowiWikiType)[keyof typeof GrowiWikiType]; // Info options for additionalInfo selection export interface GrowiInfoOptions { includeAttachmentInfo?: boolean; includeInstalledInfo?: boolean; includeUserCountInfo?: boolean; includePageCountInfo?: boolean; // Future extensions can be added here } interface IGrowiOSInfo { type?: ReturnType; platform?: ReturnType; arch?: ReturnType; totalmem?: ReturnType; } interface IAdditionalAttachmentInfo { attachmentType: string; activeExternalAccountTypes: string[]; } interface IAdditionalInstalledAtInfo { installedAt: Date; installedAtByOldestUser: Date | null; } interface IAdditionalUserCountInfo { currentUsersCount: number; currentActiveUsersCount: number; } interface IAdditionalPageCountInfo { currentPagesCount: number; } export interface IGrowiAdditionalInfo extends IAdditionalInstalledAtInfo, IAdditionalUserCountInfo, IAdditionalPageCountInfo, IAdditionalAttachmentInfo {} // Type mapping for flexible options export type IGrowiAdditionalInfoByOptions = (T['includeAttachmentInfo'] extends true ? IAdditionalAttachmentInfo : Record) & (T['includeInstalledInfo'] extends true ? IAdditionalInstalledAtInfo : Record) & (T['includeUserCountInfo'] extends true ? IAdditionalUserCountInfo : Record) & (T['includePageCountInfo'] extends true ? IAdditionalPageCountInfo : Record); // Helper type to check if any option is enabled export type HasAnyOption = T['includeAttachmentInfo'] extends true ? true : T['includeInstalledInfo'] extends true ? true : T['includeUserCountInfo'] extends true ? true : T['includePageCountInfo'] extends true ? true : false; // Final result type based on options export type IGrowiAdditionalInfoResult = HasAnyOption extends true ? IGrowiAdditionalInfoByOptions : undefined; export interface IGrowiInfo { serviceInstanceId: string; appSiteUrl: string; osInfo: IGrowiOSInfo; version: string; type: GrowiServiceType; wikiType: GrowiWikiType; deploymentType: GrowiDeploymentType; additionalInfo?: A; }