@vizzly-testing/cli 0.16.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist/client/index.js +21 -4
  2. package/dist/reporter/reporter-bundle.css +1 -1
  3. package/dist/reporter/reporter-bundle.iife.js +11 -11
  4. package/dist/sdk/index.js +6 -6
  5. package/dist/services/test-runner.js +0 -8
  6. package/dist/services/uploader.js +1 -1
  7. package/dist/types/client.d.ts +88 -0
  8. package/dist/types/config.d.ts +29 -0
  9. package/dist/types/index.d.ts +426 -9
  10. package/dist/types/sdk.d.ts +146 -0
  11. package/dist/utils/config-helpers.js +2 -2
  12. package/package.json +21 -4
  13. package/dist/types/cli.d.ts +0 -2
  14. package/dist/types/client/index.d.ts +0 -80
  15. package/dist/types/commands/doctor.d.ts +0 -11
  16. package/dist/types/commands/finalize.d.ts +0 -13
  17. package/dist/types/commands/init.d.ts +0 -32
  18. package/dist/types/commands/login.d.ts +0 -11
  19. package/dist/types/commands/logout.d.ts +0 -11
  20. package/dist/types/commands/project.d.ts +0 -28
  21. package/dist/types/commands/run.d.ts +0 -16
  22. package/dist/types/commands/status.d.ts +0 -13
  23. package/dist/types/commands/tdd-daemon.d.ts +0 -24
  24. package/dist/types/commands/tdd.d.ts +0 -17
  25. package/dist/types/commands/upload.d.ts +0 -13
  26. package/dist/types/commands/whoami.d.ts +0 -11
  27. package/dist/types/errors/vizzly-error.d.ts +0 -75
  28. package/dist/types/plugin-loader.d.ts +0 -7
  29. package/dist/types/reporter/src/api/client.d.ts +0 -178
  30. package/dist/types/reporter/src/components/app-router.d.ts +0 -1
  31. package/dist/types/reporter/src/components/code-block.d.ts +0 -4
  32. package/dist/types/reporter/src/components/comparison/comparison-actions.d.ts +0 -5
  33. package/dist/types/reporter/src/components/comparison/comparison-card.d.ts +0 -7
  34. package/dist/types/reporter/src/components/comparison/comparison-group.d.ts +0 -10
  35. package/dist/types/reporter/src/components/comparison/comparison-list.d.ts +0 -6
  36. package/dist/types/reporter/src/components/comparison/comparison-modes/onion-skin-mode.d.ts +0 -10
  37. package/dist/types/reporter/src/components/comparison/comparison-modes/overlay-mode.d.ts +0 -11
  38. package/dist/types/reporter/src/components/comparison/comparison-modes/shared/base-comparison-mode.d.ts +0 -14
  39. package/dist/types/reporter/src/components/comparison/comparison-modes/shared/image-renderer.d.ts +0 -30
  40. package/dist/types/reporter/src/components/comparison/comparison-modes/toggle-view.d.ts +0 -8
  41. package/dist/types/reporter/src/components/comparison/comparison-viewer.d.ts +0 -8
  42. package/dist/types/reporter/src/components/comparison/fullscreen-viewer.d.ts +0 -13
  43. package/dist/types/reporter/src/components/comparison/screenshot-display.d.ts +0 -16
  44. package/dist/types/reporter/src/components/comparison/screenshot-list.d.ts +0 -9
  45. package/dist/types/reporter/src/components/comparison/variant-selector.d.ts +0 -9
  46. package/dist/types/reporter/src/components/comparison/view-mode-selector.d.ts +0 -4
  47. package/dist/types/reporter/src/components/dashboard/dashboard-filters.d.ts +0 -16
  48. package/dist/types/reporter/src/components/design-system/alert.d.ts +0 -9
  49. package/dist/types/reporter/src/components/design-system/badge.d.ts +0 -17
  50. package/dist/types/reporter/src/components/design-system/button.d.ts +0 -19
  51. package/dist/types/reporter/src/components/design-system/card.d.ts +0 -31
  52. package/dist/types/reporter/src/components/design-system/empty-state.d.ts +0 -13
  53. package/dist/types/reporter/src/components/design-system/form-controls.d.ts +0 -44
  54. package/dist/types/reporter/src/components/design-system/health-ring.d.ts +0 -7
  55. package/dist/types/reporter/src/components/design-system/index.d.ts +0 -11
  56. package/dist/types/reporter/src/components/design-system/modal.d.ts +0 -10
  57. package/dist/types/reporter/src/components/design-system/skeleton.d.ts +0 -19
  58. package/dist/types/reporter/src/components/design-system/spinner.d.ts +0 -10
  59. package/dist/types/reporter/src/components/design-system/tabs.d.ts +0 -13
  60. package/dist/types/reporter/src/components/layout/header.d.ts +0 -5
  61. package/dist/types/reporter/src/components/layout/index.d.ts +0 -2
  62. package/dist/types/reporter/src/components/layout/layout.d.ts +0 -6
  63. package/dist/types/reporter/src/components/ui/smart-image.d.ts +0 -7
  64. package/dist/types/reporter/src/components/ui/toast.d.ts +0 -4
  65. package/dist/types/reporter/src/components/views/builds-view.d.ts +0 -1
  66. package/dist/types/reporter/src/components/views/comparison-detail-view.d.ts +0 -5
  67. package/dist/types/reporter/src/components/views/comparisons-view.d.ts +0 -5
  68. package/dist/types/reporter/src/components/views/projects-view.d.ts +0 -1
  69. package/dist/types/reporter/src/components/views/settings-view.d.ts +0 -1
  70. package/dist/types/reporter/src/components/views/stats-view.d.ts +0 -1
  71. package/dist/types/reporter/src/components/waiting-for-screenshots.d.ts +0 -1
  72. package/dist/types/reporter/src/hooks/queries/use-auth-queries.d.ts +0 -15
  73. package/dist/types/reporter/src/hooks/queries/use-cloud-queries.d.ts +0 -6
  74. package/dist/types/reporter/src/hooks/queries/use-config-queries.d.ts +0 -6
  75. package/dist/types/reporter/src/hooks/queries/use-tdd-queries.d.ts +0 -9
  76. package/dist/types/reporter/src/hooks/use-comparison-filters.d.ts +0 -20
  77. package/dist/types/reporter/src/hooks/use-image-loader.d.ts +0 -1
  78. package/dist/types/reporter/src/lib/query-client.d.ts +0 -2
  79. package/dist/types/reporter/src/lib/query-keys.d.ts +0 -13
  80. package/dist/types/reporter/src/main.d.ts +0 -1
  81. package/dist/types/reporter/src/services/api-client.d.ts +0 -11
  82. package/dist/types/reporter/src/utils/comparison-helpers.d.ts +0 -16
  83. package/dist/types/reporter/src/utils/constants.d.ts +0 -37
  84. package/dist/types/reporter/vite.config.d.ts +0 -2
  85. package/dist/types/reporter/vite.dev.config.d.ts +0 -2
  86. package/dist/types/sdk/index.d.ts +0 -110
  87. package/dist/types/server/handlers/api-handler.d.ts +0 -88
  88. package/dist/types/server/handlers/tdd-handler.d.ts +0 -162
  89. package/dist/types/server/http-server.d.ts +0 -6
  90. package/dist/types/server/middleware/cors.d.ts +0 -11
  91. package/dist/types/server/middleware/json-parser.d.ts +0 -10
  92. package/dist/types/server/middleware/response.d.ts +0 -50
  93. package/dist/types/server/routers/assets.d.ts +0 -6
  94. package/dist/types/server/routers/auth.d.ts +0 -9
  95. package/dist/types/server/routers/baseline.d.ts +0 -13
  96. package/dist/types/server/routers/cloud-proxy.d.ts +0 -11
  97. package/dist/types/server/routers/config.d.ts +0 -9
  98. package/dist/types/server/routers/dashboard.d.ts +0 -6
  99. package/dist/types/server/routers/health.d.ts +0 -11
  100. package/dist/types/server/routers/projects.d.ts +0 -9
  101. package/dist/types/server/routers/screenshot.d.ts +0 -11
  102. package/dist/types/services/api-service.d.ts +0 -121
  103. package/dist/types/services/auth-service.d.ts +0 -59
  104. package/dist/types/services/build-manager.d.ts +0 -69
  105. package/dist/types/services/config-service.d.ts +0 -97
  106. package/dist/types/services/html-report-generator.d.ts +0 -52
  107. package/dist/types/services/index.d.ts +0 -7
  108. package/dist/types/services/project-service.d.ts +0 -105
  109. package/dist/types/services/report-generator/viewer.d.ts +0 -0
  110. package/dist/types/services/screenshot-server.d.ts +0 -10
  111. package/dist/types/services/server-manager.d.ts +0 -269
  112. package/dist/types/services/static-report-generator.d.ts +0 -25
  113. package/dist/types/services/tdd-service.d.ts +0 -122
  114. package/dist/types/services/test-runner.d.ts +0 -31
  115. package/dist/types/services/uploader.d.ts +0 -36
  116. package/dist/types/utils/browser.d.ts +0 -6
  117. package/dist/types/utils/build-history.d.ts +0 -16
  118. package/dist/types/utils/ci-env.d.ts +0 -55
  119. package/dist/types/utils/colors.d.ts +0 -12
  120. package/dist/types/utils/config-helpers.d.ts +0 -6
  121. package/dist/types/utils/config-loader.d.ts +0 -25
  122. package/dist/types/utils/config-schema.d.ts +0 -51
  123. package/dist/types/utils/environment-config.d.ts +0 -59
  124. package/dist/types/utils/environment.d.ts +0 -36
  125. package/dist/types/utils/fetch-utils.d.ts +0 -1
  126. package/dist/types/utils/file-helpers.d.ts +0 -18
  127. package/dist/types/utils/git.d.ts +0 -56
  128. package/dist/types/utils/global-config.d.ts +0 -84
  129. package/dist/types/utils/image-input-detector.d.ts +0 -71
  130. package/dist/types/utils/output.d.ts +0 -84
  131. package/dist/types/utils/package-info.d.ts +0 -15
  132. package/dist/types/utils/security.d.ts +0 -30
package/dist/sdk/index.js CHANGED
@@ -22,7 +22,7 @@ import { VizzlyError } from '../errors/vizzly-error.js';
22
22
  /**
23
23
  * Create a new Vizzly instance with custom configuration
24
24
  *
25
- * @param {import('../types').VizzlyConfig} [config] - Configuration options
25
+ * @param {Object} [config] - Configuration options
26
26
  * @returns {Promise<VizzlySDK>} Configured Vizzly SDK instance
27
27
  *
28
28
  * @example
@@ -147,7 +147,7 @@ export function createVizzly(config = {}, options = {}) {
147
147
  */
148
148
  export class VizzlySDK extends EventEmitter {
149
149
  /**
150
- * @param {import('../types').VizzlyConfig} config - Configuration
150
+ * @param {Object} config - Configuration
151
151
  * @param {Object} services - Service instances
152
152
  */
153
153
  constructor(config, services) {
@@ -223,7 +223,7 @@ export class VizzlySDK extends EventEmitter {
223
223
  * Capture a screenshot
224
224
  * @param {string} name - Screenshot name
225
225
  * @param {Buffer|string} imageBuffer - Image data as a Buffer, or a file path to an image
226
- * @param {import('../types').ScreenshotOptions} [options] - Options
226
+ * @param {Object} [options] - Options
227
227
  * @returns {Promise<void>}
228
228
  * @throws {VizzlyError} When server is not running
229
229
  * @throws {VizzlyError} When file path is provided but file doesn't exist
@@ -288,8 +288,8 @@ export class VizzlySDK extends EventEmitter {
288
288
 
289
289
  /**
290
290
  * Upload all captured screenshots
291
- * @param {import('../types').UploadOptions} [options] - Upload options
292
- * @returns {Promise<import('../types').UploadResult>} Upload result
291
+ * @param {Object} [options] - Upload options
292
+ * @returns {Promise<Object>} Upload result
293
293
  */
294
294
  async upload(options = {}) {
295
295
  if (!this.services?.uploader) {
@@ -332,7 +332,7 @@ export class VizzlySDK extends EventEmitter {
332
332
  * Run local comparison in TDD mode
333
333
  * @param {string} name - Screenshot name
334
334
  * @param {Buffer|string} imageBuffer - Current image as a Buffer, or a file path to an image
335
- * @returns {Promise<import('../types').ComparisonResult>} Comparison result
335
+ * @returns {Promise<Object>} Comparison result
336
336
  * @throws {VizzlyError} When file path is provided but file doesn't exist
337
337
  * @throws {VizzlyError} When file cannot be read due to permissions or I/O errors
338
338
  */
@@ -94,14 +94,6 @@ export class TestRunner extends EventEmitter {
94
94
 
95
95
  // Start server with appropriate handler
96
96
  await this.serverManager.start(buildId, tdd, options.setBaseline);
97
-
98
- // Forward server events
99
- if (this.serverManager.server?.emitter) {
100
- this.serverManager.server.emitter.on('screenshot-captured', screenshotInfo => {
101
- screenshotCount++;
102
- this.emit('screenshot-captured', screenshotInfo);
103
- });
104
- }
105
97
  const env = {
106
98
  ...process.env,
107
99
  VIZZLY_SERVER_URL: `http://localhost:${this.config.server.port}`,
@@ -24,7 +24,7 @@ export function createUploader({
24
24
  userAgent,
25
25
  command,
26
26
  upload: uploadConfig = {}
27
- }, options = {}) {
27
+ } = {}, options = {}) {
28
28
  let signal = options.signal || new AbortController().signal;
29
29
  const api = new ApiService({
30
30
  baseUrl: apiUrl,
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Vizzly Client Type Definitions
3
+ * Lightweight client for test runners
4
+ * @module @vizzly-testing/cli/client
5
+ */
6
+
7
+ /**
8
+ * Take a screenshot for visual regression testing
9
+ *
10
+ * @param name - Unique name for the screenshot
11
+ * @param imageBuffer - PNG image data as a Buffer, or a file path to an image
12
+ * @param options - Optional configuration
13
+ *
14
+ * @example
15
+ * // Basic usage with Buffer
16
+ * import { vizzlyScreenshot } from '@vizzly-testing/cli/client';
17
+ *
18
+ * const screenshot = await page.screenshot();
19
+ * await vizzlyScreenshot('homepage', screenshot);
20
+ *
21
+ * @example
22
+ * // Basic usage with file path
23
+ * await vizzlyScreenshot('homepage', './screenshots/homepage.png');
24
+ *
25
+ * @example
26
+ * // With properties and threshold
27
+ * await vizzlyScreenshot('checkout-form', screenshot, {
28
+ * properties: { browser: 'chrome', viewport: '1920x1080' },
29
+ * threshold: 5
30
+ * });
31
+ */
32
+ export function vizzlyScreenshot(
33
+ name: string,
34
+ imageBuffer: Buffer | string,
35
+ options?: {
36
+ properties?: Record<string, unknown>;
37
+ threshold?: number;
38
+ fullPage?: boolean;
39
+ }
40
+ ): Promise<void>;
41
+
42
+ /**
43
+ * Wait for all queued screenshots to be processed
44
+ *
45
+ * @example
46
+ * afterAll(async () => {
47
+ * await vizzlyFlush();
48
+ * });
49
+ */
50
+ export function vizzlyFlush(): Promise<void>;
51
+
52
+ /**
53
+ * Check if the Vizzly client is initialized and ready
54
+ *
55
+ * @returns True if client is ready, false otherwise
56
+ */
57
+ export function isVizzlyReady(): boolean;
58
+
59
+ /**
60
+ * Configure the client with custom settings
61
+ *
62
+ * @param config - Configuration options
63
+ */
64
+ export function configure(config?: {
65
+ serverUrl?: string;
66
+ enabled?: boolean;
67
+ }): void;
68
+
69
+ /**
70
+ * Enable or disable screenshot capture
71
+ *
72
+ * @param enabled - Whether to enable screenshots
73
+ */
74
+ export function setEnabled(enabled: boolean): void;
75
+
76
+ /**
77
+ * Get information about Vizzly client state
78
+ *
79
+ * @returns Client information
80
+ */
81
+ export function getVizzlyInfo(): {
82
+ enabled: boolean;
83
+ serverUrl: string | null;
84
+ ready: boolean;
85
+ buildId: string | null;
86
+ tddMode: boolean;
87
+ disabled: boolean;
88
+ };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Vizzly Config Type Definitions
3
+ * Configuration helpers
4
+ * @module @vizzly-testing/cli/config
5
+ */
6
+
7
+ export { VizzlyConfig } from './index';
8
+
9
+ /**
10
+ * Define Vizzly configuration with type hints
11
+ *
12
+ * Use this in your vizzly.config.js for better IDE support:
13
+ *
14
+ * @example
15
+ * import { defineConfig } from '@vizzly-testing/cli/config';
16
+ *
17
+ * export default defineConfig({
18
+ * apiKey: process.env.VIZZLY_TOKEN,
19
+ * server: {
20
+ * port: 47392
21
+ * },
22
+ * comparison: {
23
+ * threshold: 0.1
24
+ * }
25
+ * });
26
+ */
27
+ export function defineConfig(
28
+ config: import('./index').VizzlyConfig
29
+ ): import('./index').VizzlyConfig;
@@ -1,9 +1,426 @@
1
- export { createVizzly } from "./sdk/index.js";
2
- export { createUploader } from "./services/uploader.js";
3
- export { createTDDService } from "./services/tdd-service.js";
4
- export { createServices } from "./services/index.js";
5
- export { loadConfig } from "./utils/config-loader.js";
6
- export * as output from "./utils/output.js";
7
- export { defineConfig } from "./utils/config-helpers.js";
8
- export { UploadError } from "./errors/vizzly-error.js";
9
- export { vizzlyScreenshot, configure, setEnabled } from "./client/index.js";
1
+ /**
2
+ * Vizzly CLI Type Definitions
3
+ * @module @vizzly-testing/cli
4
+ */
5
+
6
+ import { EventEmitter } from 'events';
7
+
8
+ // ============================================================================
9
+ // Configuration Types
10
+ // ============================================================================
11
+
12
+ export interface ServerConfig {
13
+ port?: number;
14
+ timeout?: number;
15
+ }
16
+
17
+ export interface BuildConfig {
18
+ name?: string;
19
+ environment?: string;
20
+ branch?: string;
21
+ commit?: string;
22
+ message?: string;
23
+ }
24
+
25
+ export interface UploadConfig {
26
+ screenshotsDir?: string | string[];
27
+ batchSize?: number;
28
+ timeout?: number;
29
+ }
30
+
31
+ export interface ComparisonConfig {
32
+ threshold?: number;
33
+ }
34
+
35
+ export interface TddConfig {
36
+ openReport?: boolean;
37
+ }
38
+
39
+ export interface VizzlyConfig {
40
+ apiKey?: string;
41
+ apiUrl?: string;
42
+ server?: ServerConfig;
43
+ build?: BuildConfig;
44
+ upload?: UploadConfig;
45
+ comparison?: ComparisonConfig;
46
+ tdd?: TddConfig;
47
+ plugins?: string[];
48
+ parallelId?: string;
49
+ baselineBuildId?: string;
50
+ baselineComparisonId?: string;
51
+ eager?: boolean;
52
+ wait?: boolean;
53
+ allowNoToken?: boolean;
54
+ /** Allow additional plugin-specific configuration */
55
+ [key: string]: unknown;
56
+ }
57
+
58
+ // ============================================================================
59
+ // Screenshot Types
60
+ // ============================================================================
61
+
62
+ export interface ScreenshotOptions {
63
+ properties?: Record<string, unknown>;
64
+ threshold?: number;
65
+ fullPage?: boolean;
66
+ buildId?: string;
67
+ }
68
+
69
+ export interface ScreenshotResult {
70
+ success: boolean;
71
+ status?: 'passed' | 'failed' | 'new';
72
+ name?: string;
73
+ diffPercentage?: number;
74
+ }
75
+
76
+ // ============================================================================
77
+ // Comparison Types
78
+ // ============================================================================
79
+
80
+ export interface ComparisonResult {
81
+ id: string;
82
+ name: string;
83
+ status: 'passed' | 'failed' | 'new' | 'error' | 'baseline-updated';
84
+ baseline: string;
85
+ current: string;
86
+ diff: string | null;
87
+ properties: Record<string, unknown>;
88
+ signature: string;
89
+ threshold?: number;
90
+ diffPercentage?: number;
91
+ diffCount?: number;
92
+ error?: string;
93
+ }
94
+
95
+ export interface TddResults {
96
+ total: number;
97
+ passed: number;
98
+ failed: number;
99
+ new: number;
100
+ errors: number;
101
+ comparisons: ComparisonResult[];
102
+ baseline: BaselineData | null;
103
+ }
104
+
105
+ export interface BaselineData {
106
+ buildId: string;
107
+ buildName: string;
108
+ environment?: string;
109
+ branch?: string;
110
+ threshold: number;
111
+ createdAt?: string;
112
+ screenshots: BaselineScreenshot[];
113
+ }
114
+
115
+ export interface BaselineScreenshot {
116
+ name: string;
117
+ originalName?: string;
118
+ sha256?: string;
119
+ id?: string;
120
+ properties: Record<string, unknown>;
121
+ path: string;
122
+ signature: string;
123
+ }
124
+
125
+ // ============================================================================
126
+ // Upload Types
127
+ // ============================================================================
128
+
129
+ export interface UploadOptions {
130
+ screenshotsDir?: string;
131
+ buildName?: string;
132
+ branch?: string;
133
+ commit?: string;
134
+ message?: string;
135
+ environment?: string;
136
+ threshold?: number;
137
+ pullRequestNumber?: string;
138
+ parallelId?: string;
139
+ onProgress?: (progress: UploadProgress) => void;
140
+ }
141
+
142
+ export interface UploadProgress {
143
+ phase:
144
+ | 'scanning'
145
+ | 'processing'
146
+ | 'deduplication'
147
+ | 'uploading'
148
+ | 'completed';
149
+ message: string;
150
+ total?: number;
151
+ current?: number;
152
+ toUpload?: number;
153
+ existing?: number;
154
+ buildId?: string;
155
+ url?: string;
156
+ }
157
+
158
+ export interface UploadResult {
159
+ success: boolean;
160
+ buildId: string;
161
+ url: string | null;
162
+ stats: {
163
+ total: number;
164
+ uploaded: number;
165
+ skipped: number;
166
+ };
167
+ }
168
+
169
+ export interface BuildResult {
170
+ status: 'completed' | 'failed' | 'pending';
171
+ build: unknown;
172
+ comparisons?: number;
173
+ passedComparisons?: number;
174
+ failedComparisons?: number;
175
+ url?: string;
176
+ }
177
+
178
+ // ============================================================================
179
+ // Error Types
180
+ // ============================================================================
181
+
182
+ export class VizzlyError extends Error {
183
+ code: string;
184
+ context: Record<string, unknown>;
185
+ timestamp: string;
186
+ constructor(
187
+ message: string,
188
+ code?: string,
189
+ context?: Record<string, unknown>
190
+ );
191
+ getUserMessage(): string;
192
+ toJSON(): {
193
+ name: string;
194
+ code: string;
195
+ message: string;
196
+ context: Record<string, unknown>;
197
+ timestamp: string;
198
+ stack?: string;
199
+ };
200
+ }
201
+
202
+ export class ConfigError extends VizzlyError {
203
+ constructor(message: string, context?: Record<string, unknown>);
204
+ }
205
+
206
+ export class AuthError extends VizzlyError {
207
+ constructor(message: string, context?: Record<string, unknown>);
208
+ }
209
+
210
+ export class NetworkError extends VizzlyError {
211
+ constructor(message: string, context?: Record<string, unknown>);
212
+ }
213
+
214
+ export class UploadError extends VizzlyError {
215
+ constructor(message: string, context?: Record<string, unknown>);
216
+ }
217
+
218
+ export class ScreenshotError extends VizzlyError {
219
+ constructor(message: string, context?: Record<string, unknown>);
220
+ }
221
+
222
+ export class BuildError extends VizzlyError {
223
+ constructor(message: string, context?: Record<string, unknown>);
224
+ }
225
+
226
+ export class TimeoutError extends VizzlyError {
227
+ duration: number;
228
+ constructor(
229
+ message: string,
230
+ duration?: number,
231
+ context?: Record<string, unknown>
232
+ );
233
+ }
234
+
235
+ export class ValidationError extends VizzlyError {
236
+ errors: string[];
237
+ constructor(
238
+ message: string,
239
+ errors?: string[],
240
+ context?: Record<string, unknown>
241
+ );
242
+ }
243
+
244
+ // ============================================================================
245
+ // SDK Types
246
+ // ============================================================================
247
+
248
+ export interface VizzlySDKInstance extends EventEmitter {
249
+ config: VizzlyConfig;
250
+
251
+ /** Start the Vizzly server */
252
+ start(): Promise<{ port: number; url: string }>;
253
+
254
+ /** Stop the Vizzly server */
255
+ stop(): Promise<void>;
256
+
257
+ /** Get current configuration */
258
+ getConfig(): VizzlyConfig;
259
+
260
+ /** Capture a screenshot */
261
+ screenshot(
262
+ name: string,
263
+ imageBuffer: Buffer | string,
264
+ options?: ScreenshotOptions
265
+ ): Promise<void>;
266
+
267
+ /** Upload all captured screenshots */
268
+ upload(options?: UploadOptions): Promise<UploadResult>;
269
+
270
+ /** Run local comparison in TDD mode */
271
+ compare(
272
+ name: string,
273
+ imageBuffer: Buffer | string
274
+ ): Promise<ComparisonResult>;
275
+ }
276
+
277
+ export class VizzlySDK extends EventEmitter implements VizzlySDKInstance {
278
+ config: VizzlyConfig;
279
+
280
+ constructor(config: VizzlyConfig, services: unknown);
281
+
282
+ start(): Promise<{ port: number; url: string }>;
283
+ stop(): Promise<void>;
284
+ getConfig(): VizzlyConfig;
285
+ screenshot(
286
+ name: string,
287
+ imageBuffer: Buffer | string,
288
+ options?: ScreenshotOptions
289
+ ): Promise<void>;
290
+ upload(options?: UploadOptions): Promise<UploadResult>;
291
+ compare(
292
+ name: string,
293
+ imageBuffer: Buffer | string
294
+ ): Promise<ComparisonResult>;
295
+ }
296
+
297
+ // ============================================================================
298
+ // Service Types
299
+ // ============================================================================
300
+
301
+ export interface Uploader {
302
+ upload(options: UploadOptions): Promise<UploadResult>;
303
+ waitForBuild(buildId: string, timeout?: number): Promise<BuildResult>;
304
+ }
305
+
306
+ export interface TddService {
307
+ downloadBaselines(
308
+ environment?: string,
309
+ branch?: string,
310
+ buildId?: string,
311
+ comparisonId?: string
312
+ ): Promise<BaselineData | null>;
313
+
314
+ loadBaseline(): Promise<BaselineData | null>;
315
+
316
+ compareScreenshot(
317
+ name: string,
318
+ imageBuffer: Buffer,
319
+ properties?: Record<string, unknown>
320
+ ): Promise<ComparisonResult>;
321
+
322
+ getResults(): TddResults;
323
+ printResults(): Promise<TddResults>;
324
+ updateBaselines(): number;
325
+ acceptBaseline(idOrComparison: string | ComparisonResult): Promise<{
326
+ name: string;
327
+ status: string;
328
+ message: string;
329
+ }>;
330
+ }
331
+
332
+ export interface Services {
333
+ apiService: unknown;
334
+ authService: unknown;
335
+ configService: unknown;
336
+ projectService: unknown;
337
+ uploader: Uploader;
338
+ buildManager: unknown;
339
+ serverManager: unknown;
340
+ tddService: TddService;
341
+ testRunner: unknown;
342
+ }
343
+
344
+ // ============================================================================
345
+ // Output Utilities
346
+ // ============================================================================
347
+
348
+ export interface OutputUtils {
349
+ info(message: string): void;
350
+ warn(message: string): void;
351
+ error(message: string): void;
352
+ success(message: string): void;
353
+ debug(category: string, ...args: unknown[]): void;
354
+ configure(options: { verbose?: boolean }): void;
355
+ }
356
+
357
+ // ============================================================================
358
+ // Main Exports
359
+ // ============================================================================
360
+
361
+ /** Create a new Vizzly SDK instance */
362
+ export function createVizzly(
363
+ config?: VizzlyConfig,
364
+ options?: { verbose?: boolean }
365
+ ): Promise<VizzlySDKInstance>;
366
+
367
+ /** Take a screenshot for visual regression testing */
368
+ export function vizzlyScreenshot(
369
+ name: string,
370
+ imageBuffer: Buffer | string,
371
+ options?: {
372
+ properties?: Record<string, unknown>;
373
+ threshold?: number;
374
+ fullPage?: boolean;
375
+ }
376
+ ): Promise<void>;
377
+
378
+ /** Configure the Vizzly client */
379
+ export function configure(config?: {
380
+ serverUrl?: string;
381
+ enabled?: boolean;
382
+ }): void;
383
+
384
+ /** Enable or disable screenshot capture */
385
+ export function setEnabled(enabled: boolean): void;
386
+
387
+ /** Create an uploader instance */
388
+ export function createUploader(
389
+ config?: {
390
+ apiKey?: string;
391
+ apiUrl?: string;
392
+ userAgent?: string;
393
+ command?: string;
394
+ upload?: UploadConfig;
395
+ },
396
+ options?: {
397
+ signal?: AbortSignal;
398
+ batchSize?: number;
399
+ timeout?: number;
400
+ }
401
+ ): Uploader;
402
+
403
+ /** Create a TDD service instance */
404
+ export function createTDDService(
405
+ config: VizzlyConfig,
406
+ options?: {
407
+ workingDir?: string;
408
+ setBaseline?: boolean;
409
+ authService?: unknown;
410
+ }
411
+ ): TddService;
412
+
413
+ /** Create all services with dependencies */
414
+ export function createServices(
415
+ config: VizzlyConfig,
416
+ command?: string
417
+ ): Services;
418
+
419
+ /** Load configuration from file and environment */
420
+ export function loadConfig(options?: { cwd?: string }): Promise<VizzlyConfig>;
421
+
422
+ /** Define Vizzly configuration with type hints */
423
+ export function defineConfig(config: VizzlyConfig): VizzlyConfig;
424
+
425
+ /** Output utilities namespace */
426
+ export const output: OutputUtils;