@tensorify.io/sdk
Version:
TypeScript SDK for developing Tensorify plugins with comprehensive validation, frontend enforcement, and publishing tools
147 lines • 5.17 kB
TypeScript
/**
* Utility functions for plugin development and CLI integration
*/
import { TensorifyPlugin } from "../core/TensorifyPlugin";
import { FrontendPluginManifest, PackageJsonInfo, PluginValidationResult } from "../types/plugin";
import { PluginSettings, NodeType, PluginCapability } from "../types/core";
import { SettingsField } from "../types/settings";
/**
* Generate a plugin manifest from a plugin instance and package.json
*
* @param plugin Plugin instance
* @param packageJsonPath Path to package.json file
* @param entrypointClassName Name of the plugin class
* @returns Generated manifest
*/
export declare function generatePluginManifest(plugin: TensorifyPlugin, packageJsonPath: string, entrypointClassName: string): FrontendPluginManifest;
/**
* Read and parse package.json file
*
* @param packageJsonPath Path to package.json
* @returns Parsed package.json information
*/
export declare function readPackageJson(packageJsonPath: string): PackageJsonInfo;
/**
* Write manifest to file
*
* @param manifest Plugin manifest to write
* @param outputPath Output file path
*/
export declare function writeManifestFile(manifest: FrontendPluginManifest, outputPath: string): void;
/**
* Complete build workflow: generate manifest and write to file
*
* @param plugin Plugin instance
* @param packageJsonPath Path to package.json
* @param entrypointClassName Plugin class name
* @param outputPath Output manifest file path
* @returns Generated manifest
*/
export declare function buildPluginManifest(plugin: TensorifyPlugin, packageJsonPath: string, entrypointClassName: string, outputPath: string): FrontendPluginManifest;
/**
* Validate a plugin instance comprehensively
*
* @param plugin Plugin instance to validate
* @returns Validation result
*/
export declare function validatePlugin(plugin: TensorifyPlugin): PluginValidationResult;
/**
* Validate plugin settings against field definitions
*
* @param plugin Plugin instance
* @param settings Settings to validate
* @returns Validation result with detailed feedback
*/
export declare function validatePluginSettings(plugin: TensorifyPlugin, settings: PluginSettings): {
isValid: boolean;
message: string;
details?: string[];
};
/**
* Create default settings object from field definitions
*
* @param settingsFields Array of settings field definitions
* @returns Default settings object
*/
export declare function createDefaultSettings(settingsFields: SettingsField[]): PluginSettings;
/**
* Merge user settings with defaults
*
* @param userSettings User-provided settings
* @param settingsFields Settings field definitions
* @returns Merged settings with defaults applied
*/
export declare function mergeSettingsWithDefaults(userSettings: PluginSettings, settingsFields: SettingsField[]): PluginSettings;
/**
* Generate dynamic label from template and settings
*
* @param template Template string with {placeholders}
* @param settings Settings object
* @returns Processed label string
*/
export declare function processDynamicLabelTemplate(template: string | undefined, settings: PluginSettings): string;
/**
* Generate a unique variable name with prefix
*
* @param prefix Variable name prefix
* @returns Unique variable name
*/
export declare function generateVariableName(prefix?: string): string;
/**
* Sanitize a string to be a valid variable name
*
* @param name Input string
* @returns Sanitized variable name
*/
export declare function sanitizeVariableName(name: string): string;
/**
* Indent code by specified levels
*
* @param code Code string to indent
* @param levels Number of indentation levels
* @param indentString String to use for each level (default: 2 spaces)
* @returns Indented code
*/
export declare function indentCode(code: string, levels: number, indentString?: string): string;
/**
* Auto-detect the entrypoint class name from source files
*
* @param sourceDir Source directory to search
* @returns Detected class name or null
*/
export declare function autoDetectEntrypointClassName(sourceDir: string): string | null;
/**
* Check if a directory contains a valid plugin structure
*
* @param directory Directory to check
* @returns True if valid plugin structure
*/
export declare function isValidPluginDirectory(directory: string): boolean;
/**
* Create a minimal plugin template
*
* @param pluginName Human-readable plugin name
* @param pluginId Unique plugin identifier
* @param nodeType Plugin category
* @returns Plugin template code
*/
export declare function createPluginTemplate(pluginName: string, pluginId: string, nodeType?: NodeType): string;
/**
* Get plugin metadata summary
*
* @param plugin Plugin instance
* @returns Metadata summary object
*/
export declare function getPluginMetadata(plugin: TensorifyPlugin): {
id: string | undefined;
name: string | undefined;
version: string | undefined;
nodeType: NodeType | undefined;
inputHandles: number;
outputHandles: number;
settingsFields: number;
capabilities: PluginCapability[];
hasVisualConfig: boolean;
hasDynamicLabel: boolean;
};
//# sourceMappingURL=plugin-utils.d.ts.map