UNPKG

@lobehub/market-sdk

Version:
1,470 lines (1,456 loc) 54.9 kB
import { MarketItemBase, PluginConnectionType, InstallFailureAnalysisQuery, InstallFailureAnalysis, RangeQuery, RangeStats, TopPluginsQuery, TopPlugin, PluginManifest, AdminPluginItem, AdminPluginItemDetail, PluginVersion, PluginVersionLocalization, AdminDeploymentOption, InstallationDetails, SystemDependency, IncompleteI18nPlugin, CategoryListQuery, CategoryItem, PluginItemDetail, InstallReportRequest, InstallReportResponse, CallReportRequest, CallReportResponse } from '@lobehub/market-types'; export * from '@lobehub/market-types'; export { CategoryItem, CategoryListQuery, CategoryListResponse } from '@lobehub/market-types'; import { z } from 'zod'; /** * Visibility levels for plugins in the marketplace * - public: Visible to all users * - private: Visible only to the owner and authorized users * - internal: Visible only within the organization */ declare const VisibilityEnumSchema: z.ZodEnum<["public", "private", "internal"]>; /** * Publication status options for plugins * - published: Publicly available in the marketplace * - unpublished: Not publicly visible * - archived: Marked as no longer maintained * - deprecated: Marked as deprecated, but still available */ declare const StatusEnumSchema: z.ZodEnum<["published", "unpublished", "archived", "deprecated"]>; /** * Common query parameters for admin list endpoints * These parameters are used for pagination, filtering, and sorting. */ interface AdminListQueryParams { /** Current page number (1-based) */ current?: number; /** Search keyword for filtering results */ keyword?: string; /** Number of items per page */ pageSize?: number; /** Field to sort results by */ sortField?: string; /** Sort direction */ sortOrder?: 'ascend' | 'descend'; } /** * Common response format for paginated admin list endpoints * This structure provides both the data and pagination information. */ interface AdminListResponse<T> { /** Current page number (1-based) */ current: number; /** Array of items for the current page */ data: T[]; /** Number of items per page */ pageSize: number; /** Total number of items across all pages */ total: number; /** Total number of pages */ totalPages: number; } /** * Review status options * - pending: Awaiting review * - approved: Review approved * - rejected: Review rejected */ type ReviewStatus = 'pending' | 'approved' | 'rejected'; /** * Review status schema for validation */ declare const ReviewStatusEnumSchema: z.ZodEnum<["published", "draft", "review", "rejected"]>; /** * Parameters for admin plugin listing * Extends the common query parameters with plugin-specific filters. */ interface AdminPluginParams { /** Filter for featured plugins */ featured?: boolean; /** Maximum number of items to return */ limit?: number; /** Number of items to skip */ offset?: number; /** Sort direction */ order?: 'asc' | 'desc'; /** Field to sort by */ orderBy?: 'createdAt' | 'updatedAt' | 'installCount' | 'ratingAverage'; /** Filter by owner ID */ ownerId?: number; /** Search query string */ query?: string; /** Filter by plugin status */ status?: 'published' | 'draft' | 'review' | 'rejected'; /** Filter by visibility level */ visibility?: 'public' | 'private' | 'unlisted'; } /** * Parameters for creating a new plugin version */ interface PluginVersionCreateParams { /** Author or organization name for this version */ author?: string; /** URL to the author's website or profile */ authorUrl?: string; /** Capability flag: whether this plugin provides prompts */ capabilitiesPrompts?: boolean; /** Capability flag: whether this plugin manages resources (MCP) */ capabilitiesResources?: boolean; /** Capability flag: whether this plugin provides tools */ capabilitiesTools?: boolean; /** Category key for the plugin */ category?: string; /** Description of the plugin version */ description?: string; /** Icon URL or emoji for the plugin */ icon?: string; /** Whether this is the latest version */ isLatest?: boolean; /** Whether this version has been validated */ isValidated?: boolean; /** Name of the plugin version */ name?: string; /** Array of prompt definitions */ prompts?: any[]; /** README content */ readme?: string; /** Array of resource definitions */ resources?: any[]; /** Summary of the plugin version */ summary?: string; /** Array of tags for categorization */ tags?: string[]; /** Array of tool definitions */ tools?: any[]; /** Semantic version string (e.g., "1.0.0") */ version: string; } /** * Parameters for updating an existing plugin version */ interface PluginVersionUpdateParams { /** Author or organization name for this version */ author?: string; /** URL to the author's website or profile */ authorUrl?: string; /** Capability flag: whether this plugin provides prompts */ capabilitiesPrompts?: boolean; /** Capability flag: whether this plugin manages resources (MCP) */ capabilitiesResources?: boolean; /** Capability flag: whether this plugin provides tools */ capabilitiesTools?: boolean; /** Category key for the plugin */ category?: string; /** Description of the plugin version */ description?: string; /** Icon URL or emoji for the plugin */ icon?: string; /** Whether this version has been validated */ isValidated?: boolean; /** Name of the plugin version */ name?: string; /** Array of prompt definitions */ prompts?: any[]; /** README content */ readme?: string; /** Array of resource definitions */ resources?: any[]; /** Summary of the plugin version */ summary?: string; /** Array of tags for categorization */ tags?: string[]; /** Array of tool definitions */ tools?: any[]; } /** * Parameters for updating plugin basic metadata (non-version specific) */ interface PluginUpdateParams { /** Unique identifier for the plugin */ identifier?: string; /** Whether this plugin has been claimed by its original author */ isClaimed?: boolean; /** Whether this plugin is featured */ isFeatured?: boolean; /** Whether this plugin is officially maintained by LobeHub */ isOfficial?: boolean; /** Publication status */ status?: 'published' | 'draft' | 'review' | 'rejected'; /** Visibility level */ visibility?: 'public' | 'private' | 'unlisted'; } /** * Plugin localization data */ interface PluginLocalization { /** Plugin description in specific locale */ description: string; /** Locale identifier (e.g., 'en-US', 'zh-CN') */ locale: string; /** Plugin name in specific locale */ name: string; /** Summary in specific locale */ summary?: string; /** Plugin tags in specific locale */ tags?: string[]; } /** * Parameters for importing plugin i18n data */ interface PluginI18nImportParams { /** Plugin identifier */ identifier: string; /** Array of localizations for this plugin version */ localizations: PluginLocalization[]; /** Plugin version */ version: string; } /** * Response from plugin i18n import operation */ interface PluginI18nImportResponse { /** Number of failed localizations */ failed: number; /** Number of successful localizations */ success: number; /** Total number of processed localizations */ totalLocalizations: number; } /** * Unclaimed plugin item data structure * Represents a plugin that has not been claimed by its author */ interface UnclaimedPluginItem { /** Plugin ID */ id: number; /** Plugin identifier */ identifier: string; } /** * Market Service Discovery Document * * Defines the structure of the discovery document returned by the API. * This document provides information about available endpoints, authentication * methods, and other capabilities of the Market API. */ interface DiscoveryDocument { /** URL to the API documentation */ api_documentation_url?: string; /** Authentication schemes supported by the API */ authentication?: { /** List of supported authentication methods */ schemes_supported: Array<'none' | 'apiKey' | 'oauth2'>; }; /** API issuer identifier (typically the base domain) */ issuer: string; /** Template for constructing manifest endpoint URLs */ manifest_endpoint_template: string | Record<string, string>; /** Version of the market index schema */ market_index_schema_version: number; /** URL to the privacy policy */ policy_url?: string; /** Mapping of resource types to their endpoint paths */ resource_endpoints: Record<string, string>; /** List of resource types available in the marketplace */ resource_types_supported: string[]; /** List of response types supported by the API */ response_types_supported: string[]; /** List of locales supported for content localization */ support_locales: string[]; /** URL to the terms of service */ terms_of_service_url?: string; } /** * SDK Configuration Options * * Options for configuring the behavior of the Market SDK. */ interface MarketSDKOptions { /** * Access Token for server-side authentication. * If provided, the SDK will use this token directly instead of fetching one. */ accessToken?: string; /** * API Key for authentication */ apiKey?: string; /** * The base URL for the LobeHub Market API */ baseURL?: string; /** * The client ID for M2M authentication */ clientId?: string; /** * The client secret for M2M authentication */ clientSecret?: string; /** * The default locale for the market * @default 'en-US' */ defaultLocale?: string; /** * Base URL for root path */ rootBaseURL?: string; } /** * Shared token state for SDK instances * * Used to share authentication tokens between multiple service instances * to avoid duplicate token requests and improve performance. */ interface SharedTokenState { /** * The current access token */ accessToken?: string; /** * Token expiry timestamp (milliseconds since epoch) */ tokenExpiry?: number; /** * Promise for ongoing token request to prevent concurrent requests */ tokenPromise?: Promise<string>; } interface ClientRegistrationRequest { /** Client name (required) */ clientName: string; /** Client type (required) */ clientType: 'desktop' | 'mobile' | 'web' | 'server' | 'docker'; /** Client version (optional) */ clientVersion?: string; /** Description (optional) */ description?: string; /** Device ID (required) */ deviceId: string; /** Platform (e.g., 'x64', 'arm64') (optional) */ platform?: string; /** OS version (optional) */ version?: string; } interface ClientRegistrationResponse { /** Generated client ID */ client_id: string; /** Generated client secret */ client_secret: string; /** Token expiry in seconds (optional) */ expires_in?: number; /** Success message (optional) */ message?: string; } interface ClientRegistrationError { /** Error code */ error: string; /** Error description (optional) */ error_description?: string; } /** * Plugin item in the marketplace * Represents a plugin as displayed in the marketplace listing. */ interface PluginItem extends MarketItemBase { /** Plugin capabilities */ capabilities: { /** Whether the plugin provides custom prompts */ prompts: boolean; /** Whether the plugin provides resources (assets) */ resources: boolean; /** Whether the plugin provides tools (functions) */ tools: boolean; }; /** Number of comments on this plugin */ commentCount?: number; /** Connection type strategy for communicating with the plugin */ connectionType?: PluginConnectionType; /** GitHub repository information */ github?: { language?: string; license?: string; stars?: number; url: string; }; /** Number of installations */ installCount?: number; /** Installation method required by the plugin's recommended deployment option */ installationMethods?: string; /** Whether this plugin has been claimed by its original author */ isClaimed?: boolean; /** Whether the plugin is featured */ isFeatured?: boolean; /** Whether this plugin is officially maintained by LobeHub */ isOfficial?: boolean; /** Whether this plugin has been validated */ isValidated?: boolean; /** Number of prompts provided by this plugin */ promptsCount?: number; /** Average rating (typically 1-5 scale) */ ratingAverage?: number; /** Number of ratings received */ ratingCount?: number; /** Number of resources provided by this plugin */ resourcesCount?: number; /** Number of tools provided by this plugin */ toolsCount?: number; } /** * Response structure for plugin listing endpoints * Contains both the plugin items and pagination/filtering metadata. */ interface PluginListResponse { /** Available categories for filtering */ categories: string[]; /** Current page number (1-based) */ currentPage: number; /** Array of plugin items for the current page */ items: PluginItem[]; /** Number of items per page */ pageSize: number; /** Total number of items across all pages */ totalCount: number; /** Total number of pages */ totalPages: number; } /** * Query parameters for plugin listing * Used to filter, sort, and paginate plugin results. */ interface PluginQueryParams { /** Filter by category */ category?: string; /** Locale for localized content */ locale?: string; /** Sort direction */ order?: 'asc' | 'desc'; /** Page number (1-based) */ page?: number; /** Number of items per page */ pageSize?: number; /** Search query string */ q?: string; /** Field to sort by */ sort?: 'installCount' | 'createdAt' | 'updatedAt' | 'ratingAverage' | 'ratingCount' | 'isFeatured' | 'isValidated'; /** Filter by tags (comma-separated) */ tags?: string; } /** * Base SDK class * * Provides shared request handling and authentication functionality that is used * by both the Market SDK and Admin SDK. This class handles the common concerns: * - API endpoint configuration * - Authentication header management * - HTTP request handling * - Error handling * - Query string building */ declare class BaseSDK { /** Base API URL */ protected apiBaseUrl: string; /** Base URL */ protected baseUrl: string; /** OAuth URL */ protected oauthBaseUrl: string; /** Default locale for requests that require localization */ protected defaultLocale: string; /** HTTP headers to include with all requests */ protected headers: Record<string, string>; private clientId?; private clientSecret?; private readonly initialAccessToken?; private accessToken?; private tokenExpiry?; private sharedTokenState?; /** * Creates a new BaseSDK instance * * @param options - Configuration options for the SDK * @param sharedHeaders - Optional shared headers object for reuse across services * @param sharedTokenState - Optional shared token state object for reuse across services */ constructor(options?: MarketSDKOptions, sharedHeaders?: Record<string, string>, sharedTokenState?: SharedTokenState); /** * Sends an HTTP request to the API and handles the response * * @param url - Request URL path (will be appended to baseUrl) * @param options - Fetch API request options * @returns Promise resolving to the parsed JSON response * @throws Error if the request fails */ protected request<T>(url: string, options?: RequestInit): Promise<T>; /** * Builds a URL query string from a parameters object * * @param params - Object containing query parameters * @returns Formatted query string (including leading ? if params exist) */ protected buildQueryString(params: Record<string, any>): string; /** * Sets an authentication token for API requests * * @param token - API authentication token */ setAuthToken(token: string): void; /** * Clears the authentication token */ clearAuthToken(): void; /** * Fetches an M2M access token. * This method is designed for server-side use cases where you need to manage the token lifecycle * (e.g., storing it in a cookie). * * @returns A promise that resolves to an object containing the access token and its expiry time. */ fetchM2MToken(): Promise<{ accessToken: string; expiresIn: number; }>; private createClientAssertion; private exchangeToken; private exchangeTokenForServer; private setM2MAuthToken; private fetchNewToken; } /** * Market Overview Statistics Interface * Defines the structure for market overview data */ interface MarketOverviewStats { devices: { count: number; prevCount: number; }; installs: { count: number; prevCount: number; }; period: string; pluginCalls: { count: number; prevCount: number; }; plugins: { count: number; prevCount: number; }; } /** * Period type for analysis queries */ type AnalysisPeriod = '1d' | '7d' | '30d' | '1mo' | '3mo' | '1y'; /** * Market overview query parameters */ interface MarketOverviewQuery { /** Analysis period: 1d, 7d, 30d (rolling periods) or 1mo, 3mo, 1y (natural periods) */ period?: AnalysisPeriod; } /** * Analysis Management Service * * Provides administrative functionality for accessing market analysis and statistics. * This service handles retrieving various analytics reports including market overview, * plugin trends, and installation analytics for administrative dashboards. */ declare class AnalysisService extends BaseSDK { /** * Retrieves market overview statistics * * Returns comprehensive market statistics including plugin counts, * installation metrics, new plugin trends, and rating averages * with comparison to previous periods. * * @param params - Query parameters for the analysis * @returns Promise resolving to market overview statistics */ getMarketOverview(params?: MarketOverviewQuery): Promise<MarketOverviewStats>; /** * Retrieves market overview statistics for 1 day period * * Convenience method for getting daily market statistics. * * @returns Promise resolving to market overview statistics for 1 day */ getDailyOverview(): Promise<MarketOverviewStats>; /** * Retrieves market overview statistics for 7 days period * * Convenience method for getting weekly market statistics. * * @returns Promise resolving to market overview statistics for 7 days */ getWeeklyOverview(): Promise<MarketOverviewStats>; /** * Retrieves market overview statistics for 30 days period * * Convenience method for getting monthly market statistics. * * @returns Promise resolving to market overview statistics for 30 days */ getMonthlyOverview(): Promise<MarketOverviewStats>; /** * Retrieves market overview statistics for current natural month * * Convenience method for getting current month vs previous month statistics. * * @returns Promise resolving to market overview statistics for current month */ getThisMonthOverview(): Promise<MarketOverviewStats>; /** * Retrieves market overview statistics for current quarter * * Convenience method for getting current quarter vs previous quarter statistics. * * @returns Promise resolving to market overview statistics for current quarter */ getQuarterlyOverview(): Promise<MarketOverviewStats>; /** * Retrieves market overview statistics for current year * * Convenience method for getting current year vs previous year statistics. * * @returns Promise resolving to market overview statistics for current year */ getYearlyOverview(): Promise<MarketOverviewStats>; /** * Retrieves install failure analysis for plugins within a date range * * Returns detailed analysis of plugin installation failures including failure counts, * failure rates, and most common error messages for each plugin with failures. * * @param params - Query parameters for the failure analysis * @returns Promise resolving to install failure analysis data */ getInstallFailureAnalysis(params: InstallFailureAnalysisQuery): Promise<InstallFailureAnalysis[]>; /** * Calculates growth rate between current and previous values * * Utility method for calculating percentage growth rates from the statistics. * * @param current - Current period value * @param previous - Previous period value * @returns Growth rate as percentage (e.g., 15.5 for 15.5% growth) */ static calculateGrowthRate(current: number, previous: number): number; /** * Formats market overview statistics with calculated growth rates * * Utility method that enhances the raw statistics with calculated growth rates * for easier consumption in dashboards and reports. * * @param stats - Raw market overview statistics * @returns Enhanced statistics with growth rate calculations */ static formatMarketOverview(stats: MarketOverviewStats): { growth: { devices: number; installs: number; pluginCalls: number; plugins: number; }; devices: { count: number; prevCount: number; }; installs: { count: number; prevCount: number; }; period: string; pluginCalls: { count: number; prevCount: number; }; plugins: { count: number; prevCount: number; }; }; /** * Retrieves installation trend statistics for a specified date range * * Returns daily installation counts and trends for the specified period * with optional comparison to a previous period. * * @param params - Query parameters including date range and display config * @returns Promise resolving to installation trend statistics */ getRangeInstalls(params: RangeQuery): Promise<RangeStats>; /** * Retrieves plugin growth trend statistics for a specified date range * * Returns daily plugin creation counts and trends for the specified period * with optional comparison to a previous period. * * @param params - Query parameters including date range and display config * @returns Promise resolving to plugin growth trend statistics */ getRangePlugins(params: RangeQuery): Promise<RangeStats>; /** * Retrieves device growth trend statistics for a specified date range * * Note: This is a system-level statistic that tracks device registrations, * not plugin-specific metrics. It provides daily device registration counts * and trends for the specified period with optional comparison to a previous period. * * @param params - Query parameters including date range and display config * @returns Promise resolving to device growth trend statistics */ getRangeDevices(params: RangeQuery): Promise<RangeStats>; /** * Retrieves plugin call trend statistics for a specified date range * * Returns daily plugin call counts and trends for the specified period * with optional comparison to a previous period. * * @param params - Query parameters including date range and display config * @returns Promise resolving to plugin call trend statistics */ getRangeCalls(params: RangeQuery): Promise<RangeStats>; /** * Calculates trend growth rate between current and previous period totals * * Utility method for calculating percentage growth rates from range statistics. * * @param stats - Range statistics with sum and prevSum * @returns Growth rate as percentage (e.g., 15.5 for 15.5% growth) */ static calculateTrendGrowthRate(stats: RangeStats): number; /** * Retrieves top plugins sorted by specified criteria within a date range * * Returns list of plugins sorted by the specified criteria (installs or calls) * in descending order for the specified date range. * * @param params - Query parameters including date range, sort criteria, and limit * @returns Promise resolving to list of top plugins */ getTopPlugins(params: TopPluginsQuery): Promise<TopPlugin[]>; } /** * Plugin Management Service * * Provides administrative functionality for managing plugins in the marketplace. * This service handles CRUD operations for plugins, plugin versions, and deployment options. */ declare class PluginService extends BaseSDK { /** * Batch imports plugin manifests using the dedicated import endpoint * * This method is intended for use with scripts and bulk import operations. * * @param manifests - Array of plugin manifests to import * @param ownerId - Optional owner ID to associate with the imported plugins * @returns Promise resolving to the import results with counts of success, skipped, failed, and a list of failed IDs */ importPlugins(manifests: PluginManifest[], ownerId?: number): Promise<{ failed: number; failedIds: string[]; skipped: number; success: number; }>; /** * Imports plugin internationalization (i18n) data * * Allows importing localized content for a specific plugin version. * This method creates or updates localizations for the specified plugin. * * @param params - Plugin i18n import parameters containing identifier, version, and localizations * @returns Promise resolving to the import results with counts of success and failure */ importPluginI18n(params: PluginI18nImportParams): Promise<PluginI18nImportResponse>; /** * Retrieves a list of plugins with admin details * * Supports filtering, pagination, and sorting of results. * * @param params - Query parameters for filtering and pagination * @returns Promise resolving to the plugin list response with admin details */ getPlugins(params?: AdminListQueryParams): Promise<AdminListResponse<AdminPluginItem>>; /** * Retrieves all published plugin identifiers * * Returns a lightweight list of all published plugin identifiers without * full plugin metadata. This is useful for admin operations that need to know * which plugins are currently published and available to users. * * @returns Promise resolving to an array containing identifiers array and last modified time */ getPublishedIdentifiers(): Promise<{ identifier: string; lastModified: string; }[]>; /** * Retrieves a single plugin with full admin details * * @param id - Plugin ID or identifier * @returns Promise resolving to the detailed plugin information with version history */ getPlugin(id: number | string): Promise<AdminPluginItemDetail>; /** * Retrieves a plugin by its GitHub repository URL * * @param githubUrl - The GitHub repository URL to search for * @returns Promise resolving to the detailed plugin information with version history */ getPluginByGithubUrl(githubUrl: string): Promise<AdminPluginItemDetail>; /** * Updates plugin information * * @param id - Plugin ID * @param data - Plugin update data containing fields to update * @returns Promise resolving to the updated plugin */ updatePlugin(id: number, data: PluginUpdateParams): Promise<AdminPluginItem>; /** * Updates plugin publication status * * @param id - Plugin ID * @param status - New status to set * @returns Promise resolving to success response */ updatePluginStatus(id: number, status: 'published' | 'draft' | 'review' | 'rejected'): Promise<{ message: string; success: boolean; }>; /** * Deletes a plugin * * @param id - Plugin ID * @returns Promise resolving to success response */ deletePlugin(id: number): Promise<{ message: string; success: boolean; }>; /** * Retrieves the version history for a plugin * * @param pluginId - Plugin ID * @returns Promise resolving to an array of plugin versions */ getPluginVersions(pluginId: number): Promise<PluginVersion[]>; /** * Retrieves a specific plugin version * * @param pluginId - Plugin ID * @param versionId - Version ID * @returns Promise resolving to the plugin version details */ getPluginVersion(pluginId: number, versionId: number): Promise<PluginVersion>; /** * Retrieves all localizations for a specific plugin version * * @param pluginId - Plugin ID or identifier * @param versionId - Version ID * @returns Promise resolving to an array of plugin version localizations */ getPluginLocalizations(pluginId: number | string, versionId: number): Promise<PluginVersionLocalization[]>; /** * Creates a new plugin version with all version-specific data * * @param pluginId - Plugin ID * @param data - Version creation data including all version-specific fields * @returns Promise resolving to the created plugin version */ createPluginVersion(pluginId: number, data: PluginVersionCreateParams): Promise<PluginVersion>; /** * Creates a new plugin version from a manifest * Extracts version data from the manifest for easier creation * * @param pluginId - Plugin ID * @param manifest - Plugin manifest containing all version data * @param options - Additional options for version creation * @returns Promise resolving to the created plugin version */ createPluginVersionFromManifest(pluginId: number, manifest: PluginManifest, options?: { isLatest?: boolean; isValidated?: boolean; }): Promise<PluginVersion>; /** * Updates a plugin version with comprehensive version-specific data * * @param idOrIdentifier - Plugin ID * @param versionId - Version ID * @param data - Version update data including all version-specific fields * @returns Promise resolving to the updated plugin version */ updatePluginVersion(idOrIdentifier: number | string, versionId: number, data: PluginVersionUpdateParams): Promise<PluginVersion>; /** * Deletes a plugin version * * @param pluginId - Plugin ID * @param versionId - Version ID * @returns Promise resolving to success response */ deletePluginVersion(pluginId: number, versionId: number): Promise<{ message: string; success: boolean; }>; /** * Sets a specific version as the latest version of a plugin * * @param pluginId - Plugin ID * @param versionId - Version ID to set as latest * @returns Promise resolving to success response */ setPluginVersionAsLatest(pluginId: number, versionId: number): Promise<{ message: string; success: boolean; }>; /** * Updates plugin visibility * * @param id - Plugin ID * @param visibility - New visibility setting * @returns Promise resolving to success response */ updatePluginVisibility(id: number, visibility: 'public' | 'private' | 'unlisted'): Promise<{ message: string; success: boolean; }>; /** * Updates status for multiple plugins in a single operation * * @param ids - Array of plugin IDs to update * @param status - New status to set for all specified plugins * @returns Promise resolving to success response */ batchUpdatePluginStatus(ids: number[], status: 'published' | 'draft' | 'review' | 'rejected'): Promise<{ message: string; success: boolean; }>; /** * Deletes multiple plugins in a single operation * * @param ids - Array of plugin IDs to delete * @returns Promise resolving to success response */ batchDeletePlugins(ids: number[]): Promise<{ message: string; success: boolean; }>; /** * Retrieves detailed information about a plugin version including deployment options * * @param pluginId - Plugin ID * @param versionId - Version ID * @returns Promise resolving to version details with deployment options */ getPluginVersionDetails(pluginId: number, versionId: number): Promise<PluginVersion & { deploymentOptions: any; }>; /** * Retrieves deployment options for a specific plugin version * * @param pluginId - Plugin ID * @param versionId - Version ID * @returns Promise resolving to an array of deployment options */ getDeploymentOptions(pluginId: number, versionId: number): Promise<AdminDeploymentOption[]>; /** * Creates a new deployment option for a plugin version * * @param pluginId - Plugin ID * @param versionId - Version ID * @param data - Deployment option configuration data * @returns Promise resolving to the created deployment option */ createDeploymentOption(pluginId: number, versionId: number, data: { connectionArgs?: string[]; connectionCommand?: string; connectionType: string; description?: string; installationDetails?: InstallationDetails; installationMethod: string; isRecommended?: boolean; }): Promise<AdminDeploymentOption>; /** * Updates an existing deployment option * * @param pluginId - Plugin ID * @param versionId - Version ID * @param optionId - Deployment option ID * @param data - Updated deployment option configuration * @returns Promise resolving to the updated deployment option */ updateDeploymentOption(pluginId: number, versionId: number, optionId: number, data: { connectionArgs?: string[]; connectionCommand?: string; connectionType?: string; description?: string; installationDetails?: Record<string, any>; installationMethod?: string; isRecommended?: boolean; }): Promise<AdminDeploymentOption>; /** * Deletes a deployment option * * @param pluginId - Plugin ID * @param versionId - Version ID * @param optionId - Deployment option ID * @returns Promise resolving to success response */ deleteDeploymentOption(pluginId: number, versionId: number, optionId: number): Promise<{ message: string; success: boolean; }>; /** * Retrieves system dependencies for a deployment option * * @param pluginId - Plugin ID * @param versionId - Version ID * @param optionId - Deployment option ID * @returns Promise resolving to an array of system dependencies */ getDeploymentOptionSystemDependencies(pluginId: number, versionId: number, optionId: number): Promise<SystemDependency[]>; /** * Retrieves verified plugins without summary information * * Returns plugins that are validated but missing summary data. * * @returns Promise resolving to array of plugins with incomplete summary data */ getVerifiedPluginsWithoutSummary(): Promise<{ identifier: string; manifest: PluginManifest; versionId: number; }[]>; /** * Retrieves plugins with incomplete internationalization * * Returns plugins where pluginVersionLocalizations has only 1 entry. * * @returns Promise resolving to an array of plugins with incomplete i18n */ getIncompleteI18nPlugins(): Promise<IncompleteI18nPlugin[]>; /** * Retrieves unclaimed plugins * * Returns plugins where isClaimed is false, containing only ID and identifier. * * @returns Promise resolving to an array of unclaimed plugins with basic info */ getUnclaimedPlugins(): Promise<UnclaimedPluginItem[]>; } /** * System Dependency Management Service * * Provides administrative functionality for managing system dependencies * required by plugins. This service handles creating, updating, deleting, * and listing system dependencies that plugins may require. */ declare class SystemDependencyService extends BaseSDK { /** * Retrieves all system dependencies * * Gets a list of all defined system dependencies that plugins may require. * * @returns Promise resolving to an array of system dependencies */ getSystemDependencies(): Promise<SystemDependency[]>; /** * Retrieves a specific system dependency by ID * * @param id - System dependency ID * @returns Promise resolving to the system dependency details */ getSystemDependency(id: number): Promise<SystemDependency>; /** * Creates a new system dependency * * @param data - System dependency creation data * @returns Promise resolving to the created system dependency */ createSystemDependency(data: Omit<SystemDependency, 'id'>): Promise<SystemDependency>; /** * Updates an existing system dependency * * @param id - System dependency ID * @param data - System dependency update data * @returns Promise resolving to the updated system dependency */ updateSystemDependency(id: number, data: Partial<SystemDependency>): Promise<SystemDependency>; /** * Deletes a system dependency * * @param id - System dependency ID * @returns Promise resolving to success response */ deleteSystemDependency(id: number): Promise<{ message: string; success: boolean; }>; } /** * Settings entity representing a system setting */ interface Settings { /** Creation timestamp (ISO 8601 format) */ createdAt: string; /** Optional description of the setting's purpose */ description?: string; /** Unique identifier for the setting */ id: number; /** Setting key name used for retrieving the setting */ key: string; /** Last update timestamp (ISO 8601 format) */ updatedAt: string; /** Setting value (stored as string) */ value: string; } /** * Configuration for enabled resource types */ interface EnabledResources { /** Whether agent resources are enabled */ agents: boolean; /** Whether plugin resources are enabled */ plugins: boolean; } /** * Authentication configuration */ interface AuthenticationConfig { /** Whether authentication is required */ enabled: boolean; /** Supported authentication schemes */ schemes: string[]; } /** * Documentation URL configuration */ interface DocumentationConfig { /** URL to API documentation */ apiUrl?: string; /** URL to privacy policy */ policyUrl?: string; /** URL to terms of service */ termsOfServiceUrl?: string; } /** * Map of all system settings with typed properties */ interface SettingsMap { /** Additional settings (dynamically added) */ [key: string]: any; /** Authentication configuration */ authentication: AuthenticationConfig; /** Base URL for the marketplace */ baseURL: string; /** Documentation URL configuration */ documentation: DocumentationConfig; /** Configuration for enabled resource types */ enabledResources: EnabledResources; /** Supported locales */ locales: string[]; } /** * Parameters for creating a new setting */ interface CreateSettingsParams { /** Optional description of the setting's purpose */ description?: string; /** Setting key name */ key: string; /** Setting value (will be stored as string) */ value: string; } /** * Parameters for updating an existing setting */ interface UpdateSettingsParams { /** Optional new description */ description?: string; /** New setting value */ value: string; } /** * Settings Management Service * * Provides administrative functionality for managing system settings. * This service handles getting, creating, updating, and deleting * configuration settings for the marketplace. */ declare class SettingsService extends BaseSDK { /** * Retrieves all system settings * * Returns a consolidated map of all settings with typed values * for known setting keys. * * @returns Promise resolving to the settings map */ getSettings(): Promise<SettingsMap>; /** * Retrieves a specific setting by key * * @param key - Setting key name * @returns Promise resolving to the setting details */ getSettingByKey(key: string): Promise<{ data: Settings; }>; /** * Creates a new system setting * * @param data - Setting creation parameters * @returns Promise resolving to the created setting */ createSetting(data: CreateSettingsParams): Promise<{ data: Settings; }>; /** * Updates an existing setting * * @param key - Setting key name * @param data - Setting update parameters * @returns Promise resolving to the updated setting */ updateSetting(key: string, data: UpdateSettingsParams): Promise<{ data: Settings; }>; /** * Deletes a setting * * @param key - Setting key name * @returns Promise resolving to success message */ deleteSetting(key: string): Promise<{ message: string; }>; } /** * Review entity representing a plugin review */ interface Review { /** Optional comment providing feedback */ comment?: string; /** Creation timestamp (ISO 8601 format) */ createdAt: string; /** Unique identifier for the review */ id: number; /** ID of the plugin being reviewed */ pluginId: number; /** ID of the reviewer (if available) */ reviewerId?: number; /** Current status of the review */ status: ReviewStatus; /** Last update timestamp (ISO 8601 format) */ updatedAt: string; } /** * Extended review information with related entities */ interface PluginReviewWithRelations extends Review { /** Related plugin information */ plugin?: any; /** Related version information */ version?: any; } /** * Parameters for updating a review */ interface UpdateReviewParams { /** Optional comment or feedback */ comment?: string; /** New status to set for the review */ status: ReviewStatus; } /** * Review Management Service * * Provides administrative functionality for managing plugin reviews. * This service handles listing, fetching, and updating review statuses * for plugins in the marketplace. */ declare class ReviewService extends BaseSDK { /** * Retrieves a list of reviews with filtering options * * @param params - Query parameters for filtering and pagination * @returns Promise resolving to the review list response */ getReviews(params?: AdminListQueryParams): Promise<AdminListResponse<PluginReviewWithRelations>>; /** * Retrieves a specific review by ID * * @param id - Review ID * @returns Promise resolving to the review details */ getReviewById(id: number): Promise<Review>; /** * Updates a review's status and comment * * @param id - Review ID * @param data - Update parameters containing new status and optional comment * @returns Promise resolving to the updated review */ updateReview(id: number, data: UpdateReviewParams): Promise<Review>; /** * Retrieves the review history for a specific plugin * * @param pluginId - Plugin ID * @returns Promise resolving to an array of reviews for the plugin */ getPluginReviews(pluginId: number): Promise<{ data: Review[]; }>; } type AdminPluginEnvListQuery = any; type PluginEnv = any; interface AdminPluginEnvCreateParams { description?: string; identifier: string; key: string; value: string; } interface AdminPluginEnvUpdateParams { description?: string; value?: string; } /** * Plugin Environment Variable Management Service * * Provides administrative functionality for managing plugin environment variables. */ declare class PluginEnvService extends BaseSDK { /** * Retrieves a paginated list of plugin environment variables * * @param params - Query parameters for filtering and pagination * @returns Promise resolving to the env list response */ getPluginEnvs(params?: AdminPluginEnvListQuery): Promise<AdminListResponse<PluginEnv>>; /** * Retrieves a single plugin environment variable by ID * * @param id - Env ID * @returns Promise resolving to the env item */ getPluginEnv(id: number): Promise<PluginEnv>; /** * Creates a new plugin environment variable * * @param data - Env creation data * @returns Promise resolving to the created env item */ createPluginEnv(data: AdminPluginEnvCreateParams): Promise<PluginEnv>; /** * Updates a plugin environment variable * * @param id - Env ID * @param data - Env update data * @returns Promise resolving to the updated env item */ updatePluginEnv(id: number, data: AdminPluginEnvUpdateParams): Promise<PluginEnv>; /** * Deletes a plugin environment variable * * @param id - Env ID * @returns Promise resolving to success response */ deletePluginEnv(id: number): Promise<{ success: boolean; }>; /** * Batch import plugin environment variables * * @param data - Batch import data, format: { [plugin: string]: { [envKey: string]: string } } * @returns Promise resolving to import result */ importPluginEnvs(data: Record<string, Record<string, string>>): Promise<{ success: number; }>; } /** * LobeHub Market Admin SDK Client * * Client for accessing administrative functionality of the LobeHub Marketplace. * This SDK provides privileged operations for managing plugins, reviews, * system settings, and dependencies. It requires admin-level authentication. */ declare class MarketAdmin extends BaseSDK { /** * Market analysis service * Provides methods for accessing market analytics and statistics */ readonly analysis: AnalysisService; /** * Plugin management service * Provides methods for creating, updating, and managing plugins */ readonly plugins: PluginService; readonly env: PluginEnvService; /** * Review management service * Provides methods for moderating and managing user reviews */ readonly reviews: ReviewService; /** * System settings management service * Provides methods for configuring marketplace settings */ readonly settings: SettingsService; /** * System dependency management service * Provides methods for managing system dependencies required by plugins */ readonly dependencies: SystemDependencyService; /** * Creates a new MarketAdmin instance * * @param options - Configuration options for the SDK */ constructor(options?: MarketSDKOptions); } /** * Plugins Service * * Provides access to plugin-related functionality in the LobeHub Marketplace. * This service handles listing, searching, and retrieving detailed information * about plugins available in the marketplace. */ declare class PluginsService extends BaseSDK { /** * Retrieves a list of plugins from the marketplace * * Supports filtering, pagination, and localization of results. * * @param params - Query parameters for filtering and pagination * @param options * @returns Promise resolving to the plugin list response containing items and pagination info */ getPluginList(params?: PluginQueryParams, options?: globalThis.RequestInit): Promise<PluginListResponse>; /** * Retrieves all plugin categories and their counts * * Returns a list of categories along with the number of plugins in each category. * Useful for building category filters in a UI. Supports optional search filtering * via 'q' parameter and locale specification. * * @param params - Query parameters for filtering categories * @param options - Optional request options * @returns Promise resolving to an array of category items with counts */ getCategories(params?: CategoryListQuery, options?: globalThis.RequestInit): Promise<CategoryItem[]>; /** * Retrieves all published plugin identifiers * * Returns a lightweight list of all published plugin identifiers without * full plugin metadata. This is useful for clients that need to know which * plugins are available without fetching complete plugin information. * * @returns Promise resolving to an array containing identifiers array and last modified time */ getPublishedIdentifiers(options?: globalThis.RequestInit): Promise<{ identifier: string; lastModified: string; }[]>; /**