/** Save beside zplcraft.mjs as zplcraft.d.mts. */ export type Variables = Record; export type OutputFormat = 'bitmap' | 'vector'; export interface Label { id: string; name: string; width: number; height: number; dpi: number; revision: number; created_at: string; updated_at: string; output_format: OutputFormat; } export interface BarcodeFailure { symbology: string; template: string; value: string; reason: string; } export interface Artifact { /** ZPL is text; PNG/PDF is a Uint8Array. */ data: string | Uint8Array; contentType: string; outputFormat: OutputFormat | null; labelCount: number | null; } export class ZplCraftError extends Error { constructor(status: number, details?: { error?: string; code?: string; fields?: BarcodeFailure[]; required_scope?: string }, retryAfter?: number | null); status: number; code: string | null; fields: BarcodeFailure[]; requiredScope: string | null; /** Retry-After in seconds; the client does not automatically retry. */ retryAfter: number | null; } export class ZplCraftClient { constructor(options: { baseUrl: string; apiKey: string; timeoutMs?: number; fetch?: typeof fetch }); listLabels(options?: { limit?: number; offset?: number }): Promise<{ data: Label[]; pagination: { limit: number; offset: number; total: number | null; next_offset: number | null }; }>; getLabel(id: string): Promise<{ data: Label & { dynamic_tokens: string[]; zpl: string | null } }>; getStoredZpl(id: string): Promise; render(id: string, options?: { variables?: Variables; format?: 'zpl' | 'png' | 'pdf' }): Promise; /** Returns ZPL bytes for your transport; does not send anything to a printer. */ createPrintJob(id: string, options?: { copies?: number } & ( { variables?: Variables; records?: never } | { variables?: never; records: Variables[] } )): Promise; }