Type Definitions
Full type reference for processor SDK
Type Definitions
Complete type reference for the processor SDK. Use these types when building custom processors to ensure type safety and proper integration with CyanPrint's processing pipeline.
For usage examples, see Processor Input/Output.
Core Types
CyanProcessorInput
The input type received by processor handlers.
interface CyanProcessorInput {/*** Path to source files from blob image* @example "/workspace/cyanprint/"*/readDir: string;/*** Path where processed files should be written* @example "/workspace/output/"*/writeDir: string;/*** File patterns passed from template configuration*/globs: CyanGlob[];/*** Custom configuration from template's processor config* Cast to your expected type when using*/config: unknown;}
@dataclassclass CyanProcessorInput:"""Input type received by processor handlers."""# Path to source files from blob image# @example "/workspace/cyanprint/"read_dir: str# Path where processed files should be written# @example "/workspace/output/"write_dir: str# File patterns passed from template configurationglobs: List[CyanGlob]# Custom configuration from template's processor config# Cast to your expected type when usingconfig: Any
/// <summary>/// Input type received by processor handlers./// </summary>public class CyanProcessorInput{/// <summary>/// Path to source files from blob image/// </summary>/// <example>/workspace/cyanprint/</example>public string ReadDir { get; set; }/// <summary>/// Path where processed files should be written/// </summary>/// <example>/workspace/output/</example>public string WriteDir { get; set; }/// <summary>/// File patterns passed from template configuration/// </summary>public List<CyanGlob> Globs { get; set; }/// <summary>/// Custom configuration from template's processor config/// Cast to your expected type when using/// </summary>public object Config { get; set; }}
The config property is typed as unknown. You must cast it to your expected type or use a type guard pattern. See the Type Guard Pattern section below.
ProcessorOutput
interface ProcessorOutput {/*** Output directory - must be input.writeDir*/readonly directory: string;}
@dataclassclass ProcessorOutput:"""Output type returned by processor handlers."""# Output directory - must be input.write_dirdirectory: str
/// <summary>/// Output type returned by processor handlers./// </summary>public class ProcessorOutput{/// <summary>/// Output directory - must be input.WriteDir/// </summary>public string Directory { get; set; }}
GlobType Enum
Specifies the type of file matching for a glob pattern.
enum GlobType {/*** Files will be processed through the processor*/Template = 0,/*** Files will be copied directly without processing*/Copy = 1,}
from enum import IntEnumclass GlobType(IntEnum):"""Specifies the type of file matching for a glob pattern."""# Files will be processed through the processorTEMPLATE = 0# Files will be copied directly without processingCOPY = 1
/// <summary>/// Specifies the type of file matching for a glob pattern./// </summary>public enum GlobType{/// <summary>/// Files will be processed through the processor/// </summary>Template = 0,/// <summary>/// Files will be copied directly without processing/// </summary>Copy = 1}
CyanGlob
interface CyanGlob {/*** Base directory for glob matching* @optional Defaults to root of read directory* @example "templates"*/root?: string | null;/*** Glob pattern to match files* @example "**/*.md"*/glob: string;/*** Patterns to exclude from matching* @example ["**/*.test.ts"]*/exclude: string[];/*** Type of glob - determines how files are handled*/type: GlobType;}
@dataclassclass CyanGlob:"""Defines which files to process."""# Glob pattern to match files# @example "**/*.md"glob: str# Patterns to exclude from matching# @example ["**/*.test.ts"]exclude: List[str]# Type of glob - determines how files are handledtype: GlobType# Base directory for glob matching# @optional Defaults to root of read directory# @example "templates"root: Optional[str] = None
/// <summary>/// Defines which files to process./// </summary>public class CyanGlob{/// <summary>/// Glob pattern to match files/// </summary>/// <example>**/*.md</example>public string GlobPattern { get; set; }/// <summary>/// Patterns to exclude from matching/// </summary>/// <example>["**/*.test.ts"]</example>public string[] Exclude { get; set; }/// <summary>/// Type of glob - determines how files are handled/// </summary>public GlobType Type { get; set; }/// <summary>/// Base directory for glob matching/// </summary>/// <example>templates</example>public string? Root { get; set; }}
VirtualFile Types
Classes, not interfaces
All VirtualFile types are classes, not interfaces. This means they have constructor signatures and methods, not just property definitions.
VirtualFile
File with loaded content (from resolveAll() or read()).
class VirtualFile {constructor(public baseRead: string,public baseWrite: string,public relative: string,public content: string,) {}/*** Full path to source file*/get read(): string;/*** Full path to output file*/get write(): string;/*** Path relative to read directory* @example "docs/readme.md"*/relative: string;/*** File contents as string*/content: string;/*** Write file to output directory*/writeFile(): void;}
@dataclassclass VirtualFile:"""File with loaded content (from resolve_all() or read())."""# Path relative to read directory# @example "docs/readme.md"relative: str# File contents as stringcontent: str@propertydef read(self) -> str:"""Full path to source file"""...@propertydef write(self) -> str:"""Full path to output file"""...def write_file(self) -> None:"""Write file to output directory"""...
/// <summary>/// File with loaded content (from ResolveAll() or Read())./// </summary>public class VirtualFile{/// <summary>/// Path relative to read directory/// </summary>/// <example>docs/readme.md</example>public string Relative { get; set; }/// <summary>/// File contents as string/// </summary>public string Content { get; set; }/// <summary>/// Full path to source file/// </summary>public string Read { get; }/// <summary>/// Full path to output file/// </summary>public string Write { get; }/// <summary>/// Write file to output directory/// </summary>public void WriteFile() { }}
VirtualFileReference
Lazy-loaded file reference (from get()).
class VirtualFileReference {constructor(public baseRead: string,public baseWrite: string,public relative: string,) {}/*** Full path to source file*/get read(): string;/*** Full path to output file*/get write(): string;/*** Path relative to read directory*/relative: string;/*** Load file content and return VirtualFile* @returns VirtualFile with loaded content*/readFile(): VirtualFile;}
@dataclassclass VirtualFileReference:"""Lazy-loaded file reference (from get())."""# Path relative to read directoryrelative: str@propertydef read(self) -> str:"""Full path to source file"""...@propertydef write(self) -> str:"""Full path to output file"""...def read_file(self) -> VirtualFile:"""Load file content and return VirtualFile@returns VirtualFile with loaded content"""...
/// <summary>/// Lazy-loaded file reference (from Get())./// </summary>public class VirtualFileReference{/// <summary>/// Path relative to read directory/// </summary>public string Relative { get; set; }/// <summary>/// Full path to source file/// </summary>public string Read { get; }/// <summary>/// Full path to output file/// </summary>public string Write { get; }/// <summary>/// Load file content and return VirtualFile/// </summary>/// <returns>VirtualFile with loaded content</returns>public VirtualFile ReadFile() { }}
VirtualFileStream
Streaming file access (from readAsStream()). Wraps Node.js streams directly.
class VirtualFileStream {constructor(public reader: fs.ReadStream,public writer: fs.WriteStream,) {}}
# Note: VirtualFileStream is not available in Python SDK# Use read() or get() instead for large files
/// <summary>/// Streaming file access (from ReadAsStream())./// </summary>public class VirtualFileStream{/// <summary>/// Stream for reading source file/// </summary>public Stream Reader { get; }/// <summary>/// Stream for writing output file/// </summary>public Stream Writer { get; }}
CyanFileHelper
Class providing file operations for processors.
class CyanFileHelper {constructor(private readonly _readDir: string,private readonly _writeDir: string,private readonly globs: CyanGlob[],) {}/*** Resolved read directory path*/get readDir(): string;/*** Resolved write directory path*/get writeDir(): string;/*** Load all files matching processor globs into memory* Files with GlobType.Copy are copied directly* Files with GlobType.Template are loaded and returned* @returns Array of files with content*/resolveAll(): VirtualFile[];/*** Load specific files matching glob pattern* @param glob - Pattern to match* @returns Array of matching files with content*/read(glob: CyanGlob): VirtualFile[];/*** Get file references without loading content* @param glob - Pattern to match* @returns Array of file references*/get(glob: CyanGlob): VirtualFileReference[];/*** Stream files for memory-efficient processing* @param glob - Pattern to match* @returns Array of streaming file handles*/readAsStream(glob: CyanGlob): VirtualFileStream[];/*** Copy files directly to output without loading* @param glob - Pattern to match*/copy(glob: CyanGlob): void;}
class CyanFileHelper:"""Class providing file operations for processors."""@propertydef read_dir(self) -> str:"""Resolved read directory path"""...@propertydef write_dir(self) -> str:"""Resolved write directory path"""...def resolve_all(self) -> List[VirtualFile]:"""Load all files matching processor globs into memoryFiles with GlobType.COPY are copied directlyFiles with GlobType.TEMPLATE are loaded and returned@returns List of files with content"""...def read(self, glob: CyanGlob) -> List[VirtualFile]:"""Load specific files matching glob pattern@param glob - Pattern to match@returns List of matching files with content"""...def get(self, glob: CyanGlob) -> List[VirtualFileReference]:"""Get file references without loading content@param glob - Pattern to match@returns List of file references"""...# Note: read_as_stream is not available in Python SDK# Use read() or get() instead for large filesdef copy(self, glob: CyanGlob) -> None:"""Copy files directly to output without loading@param glob - Pattern to match"""...
/// <summary>/// Class providing file operations for processors./// </summary>public class CyanFileHelper{/// <summary>/// Resolved read directory path/// </summary>public string ReadDir { get; }/// <summary>/// Resolved write directory path/// </summary>public string WriteDir { get; }/// <summary>/// Load all files matching processor globs into memory/// Files with GlobType.Copy are copied directly/// Files with GlobType.Template are loaded and returned/// </summary>/// <returns>Array of files with content</returns>public VirtualFile[] ResolveAll() { }/// <summary>/// Load specific files matching glob pattern/// </summary>/// <param name="glob">Pattern to match</param>/// <returns>Array of matching files with content</returns>public VirtualFile[] Read(CyanGlob glob) { }/// <summary>/// Get file references without loading content/// </summary>/// <param name="glob">Pattern to match</param>/// <returns>Array of file references</returns>public VirtualFileReference[] Get(CyanGlob glob) { }/// <summary>/// Stream files for memory-efficient processing/// </summary>/// <param name="glob">Pattern to match</param>/// <returns>Array of streaming file handles</returns>public VirtualFileStream[] ReadAsStream(CyanGlob glob) { }/// <summary>/// Copy files directly to output without loading/// </summary>/// <param name="glob">Pattern to match</param>public void Copy(CyanGlob glob) { }}
Handler Function
/*** Processor handler function type* @param input - Processor input containing directories, globs, and config* @param fileHelper - File operations API* @returns Promise resolving to processor output*/type LambdaProcessorFn = (input: CyanProcessorInput,fileHelper: CyanFileHelper) => Promise<ProcessorOutput>;
# Processor handler function type# @param input - Processor input containing directories, globs, and config# @param file_helper - File operations API# @returns Coroutine resolving to processor outputAsyncHandler = Callable[[CyanProcessorInput, CyanFileHelper], Awaitable[ProcessorOutput]]
/// <summary>/// Processor handler function type/// </summary>/// <param name="input">Processor input containing directories, globs, and config</param>/// <param name="fileHelper">File operations API</param>/// <returns>Task resolving to processor output</returns>public delegate Task<ProcessorOutput> LambdaProcessorFn(CyanProcessorInput input,CyanFileHelper fileHelper);
Entry Point
StartProcessorWithLambda
/*** Register processor handler* @param handler - Async function implementing processor logic*/function StartProcessorWithLambda(handler: LambdaProcessorFn): void;
def start_processor_with_lambda(handler: Callable[[CyanProcessorInput, CyanFileHelper], Awaitable[ProcessorOutput]]) -> None:"""Register processor handler@param handler - Async function implementing processor logic"""...
/// <summary>/// Register processor handler/// </summary>/// <param name="handler">Async function implementing processor logic</param>public static async Task StartAsync(LambdaProcessorFn handler) { }
Example Patterns
The following sections show common patterns you can use in your processors. These are not SDK types, but examples of how to structure your code.
Related
- Processor Input/Output - Detailed usage
- CyanFileHelper - File operations
- StartProcessorWithLambda - Entry point