@apifn/core 0.0.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.
@@ -0,0 +1,692 @@
1
+ import { Router } from '@superfunctions/http';
2
+ export { Middleware, Route, Router } from '@superfunctions/http';
3
+ import { BaseAdapter, TestCase, RunOptions, TestResult } from '@testfn/core';
4
+
5
+ /**
6
+ * @apifn/core — Core types and interfaces
7
+ *
8
+ * All shared types for route introspection, schema descriptors,
9
+ * OpenAPI generation, diff detection, and ecosystem integrations.
10
+ */
11
+
12
+ type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "HEAD";
13
+ /** Represents any schema type: zod, TypeBox, or plain JSON Schema */
14
+ type SchemaInput = any;
15
+ /** JSON Schema object */
16
+ type JsonSchema = Record<string, unknown>;
17
+ interface IntrospectOptions {
18
+ /** Include routes matching these path prefixes only */
19
+ include?: string[];
20
+ /** Exclude routes matching these path prefixes */
21
+ exclude?: string[];
22
+ /** Base path to prepend to all route paths */
23
+ basePath?: string;
24
+ }
25
+ interface ParameterDescriptor {
26
+ name: string;
27
+ in: "path" | "query" | "header" | "cookie";
28
+ required: boolean;
29
+ description?: string;
30
+ deprecated?: boolean;
31
+ schema: JsonSchema;
32
+ }
33
+ interface RequestBodyDescriptor {
34
+ required?: boolean;
35
+ description?: string;
36
+ content: Record<string, {
37
+ schema: JsonSchema;
38
+ examples?: Record<string, unknown>;
39
+ }>;
40
+ }
41
+ interface ResponseDescriptor {
42
+ description: string;
43
+ content?: Record<string, {
44
+ schema: JsonSchema;
45
+ examples?: Record<string, unknown>;
46
+ }>;
47
+ headers?: Record<string, {
48
+ schema: JsonSchema;
49
+ description?: string;
50
+ }>;
51
+ }
52
+ type SecurityRequirement = Record<string, string[]>;
53
+ interface IntrospectedRoute {
54
+ method: HttpMethod;
55
+ path: string;
56
+ operationId?: string;
57
+ summary?: string;
58
+ description?: string;
59
+ tags?: string[];
60
+ deprecated?: boolean;
61
+ parameters: ParameterDescriptor[];
62
+ requestBody?: RequestBodyDescriptor;
63
+ responses: Record<string, ResponseDescriptor>;
64
+ security?: SecurityRequirement[];
65
+ meta: Record<string, unknown>;
66
+ }
67
+ interface SchemaDescriptorResponse {
68
+ description: string;
69
+ schema?: SchemaInput;
70
+ headers?: Record<string, SchemaInput>;
71
+ }
72
+ interface SchemaDescriptor {
73
+ /** Human-readable summary */
74
+ summary?: string;
75
+ /** Detailed description */
76
+ description?: string;
77
+ /** Unique operation identifier */
78
+ operationId?: string;
79
+ /** Tags for grouping */
80
+ tags?: string[];
81
+ /** Whether this endpoint is deprecated */
82
+ deprecated?: boolean;
83
+ /** Request body schema (zod, TypeBox, or JSON Schema) */
84
+ body?: SchemaInput;
85
+ /** Query parameter schemas */
86
+ query?: Record<string, SchemaInput>;
87
+ /** Path parameter schemas */
88
+ params?: Record<string, SchemaInput>;
89
+ /** Header parameter schemas */
90
+ headers?: Record<string, SchemaInput>;
91
+ /** Response schemas keyed by status code */
92
+ responses?: Record<string | number, SchemaDescriptorResponse>;
93
+ /** Security requirements */
94
+ security?: SecurityRequirement[];
95
+ }
96
+ interface OpenAPIInfoObject {
97
+ title: string;
98
+ version: string;
99
+ description?: string;
100
+ termsOfService?: string;
101
+ contact?: {
102
+ name?: string;
103
+ url?: string;
104
+ email?: string;
105
+ };
106
+ license?: {
107
+ name: string;
108
+ url?: string;
109
+ identifier?: string;
110
+ };
111
+ summary?: string;
112
+ }
113
+ interface ServerObject {
114
+ url: string;
115
+ description?: string;
116
+ variables?: Record<string, {
117
+ default: string;
118
+ enum?: string[];
119
+ description?: string;
120
+ }>;
121
+ }
122
+ interface ExternalDocsObject {
123
+ url: string;
124
+ description?: string;
125
+ }
126
+ interface TagObject {
127
+ name: string;
128
+ description?: string;
129
+ externalDocs?: ExternalDocsObject;
130
+ }
131
+ interface SchemaObject extends JsonSchema {
132
+ [key: string]: unknown;
133
+ }
134
+ interface MediaTypeObject {
135
+ schema?: SchemaObject;
136
+ example?: unknown;
137
+ examples?: Record<string, ExampleObject | ReferenceObject>;
138
+ encoding?: Record<string, EncodingObject>;
139
+ }
140
+ interface ExampleObject {
141
+ summary?: string;
142
+ description?: string;
143
+ value?: unknown;
144
+ externalValue?: string;
145
+ }
146
+ interface ReferenceObject {
147
+ $ref: string;
148
+ summary?: string;
149
+ description?: string;
150
+ }
151
+ interface EncodingObject {
152
+ contentType?: string;
153
+ headers?: Record<string, HeaderObject | ReferenceObject>;
154
+ style?: string;
155
+ explode?: boolean;
156
+ allowReserved?: boolean;
157
+ }
158
+ interface HeaderObject {
159
+ description?: string;
160
+ required?: boolean;
161
+ deprecated?: boolean;
162
+ schema?: SchemaObject;
163
+ }
164
+ interface ParameterObject {
165
+ name: string;
166
+ in: "path" | "query" | "header" | "cookie";
167
+ description?: string;
168
+ required?: boolean;
169
+ deprecated?: boolean;
170
+ allowEmptyValue?: boolean;
171
+ style?: string;
172
+ explode?: boolean;
173
+ allowReserved?: boolean;
174
+ schema?: SchemaObject;
175
+ example?: unknown;
176
+ examples?: Record<string, ExampleObject | ReferenceObject>;
177
+ content?: Record<string, MediaTypeObject>;
178
+ }
179
+ interface RequestBodyObject {
180
+ description?: string;
181
+ content: Record<string, MediaTypeObject>;
182
+ required?: boolean;
183
+ }
184
+ interface ResponseObject {
185
+ description: string;
186
+ headers?: Record<string, HeaderObject | ReferenceObject>;
187
+ content?: Record<string, MediaTypeObject>;
188
+ links?: Record<string, LinkObject | ReferenceObject>;
189
+ }
190
+ interface LinkObject {
191
+ operationRef?: string;
192
+ operationId?: string;
193
+ parameters?: Record<string, unknown>;
194
+ requestBody?: unknown;
195
+ description?: string;
196
+ server?: ServerObject;
197
+ }
198
+ interface OperationObject {
199
+ tags?: string[];
200
+ summary?: string;
201
+ description?: string;
202
+ externalDocs?: ExternalDocsObject;
203
+ operationId?: string;
204
+ parameters?: Array<ParameterObject | ReferenceObject>;
205
+ requestBody?: RequestBodyObject | ReferenceObject;
206
+ responses?: Record<string, ResponseObject | ReferenceObject>;
207
+ callbacks?: Record<string, Record<string, PathItemObject> | ReferenceObject>;
208
+ deprecated?: boolean;
209
+ security?: SecurityRequirement[];
210
+ servers?: ServerObject[];
211
+ }
212
+ interface PathItemObject {
213
+ summary?: string;
214
+ description?: string;
215
+ get?: OperationObject;
216
+ put?: OperationObject;
217
+ post?: OperationObject;
218
+ delete?: OperationObject;
219
+ options?: OperationObject;
220
+ head?: OperationObject;
221
+ patch?: OperationObject;
222
+ trace?: OperationObject;
223
+ servers?: ServerObject[];
224
+ parameters?: Array<ParameterObject | ReferenceObject>;
225
+ }
226
+ type PathsObject = Record<string, PathItemObject>;
227
+ interface SecuritySchemeObject {
228
+ type: "apiKey" | "http" | "mutualTLS" | "oauth2" | "openIdConnect";
229
+ description?: string;
230
+ name?: string;
231
+ in?: "query" | "header" | "cookie";
232
+ scheme?: string;
233
+ bearerFormat?: string;
234
+ flows?: OAuthFlowsObject;
235
+ openIdConnectUrl?: string;
236
+ }
237
+ interface OAuthFlowsObject {
238
+ implicit?: OAuthFlowObject;
239
+ password?: OAuthFlowObject;
240
+ clientCredentials?: OAuthFlowObject;
241
+ authorizationCode?: OAuthFlowObject;
242
+ }
243
+ interface OAuthFlowObject {
244
+ authorizationUrl?: string;
245
+ tokenUrl?: string;
246
+ refreshUrl?: string;
247
+ scopes: Record<string, string>;
248
+ }
249
+ interface ComponentsObject {
250
+ schemas?: Record<string, SchemaObject | ReferenceObject>;
251
+ responses?: Record<string, ResponseObject | ReferenceObject>;
252
+ parameters?: Record<string, ParameterObject | ReferenceObject>;
253
+ examples?: Record<string, ExampleObject | ReferenceObject>;
254
+ requestBodies?: Record<string, RequestBodyObject | ReferenceObject>;
255
+ headers?: Record<string, HeaderObject | ReferenceObject>;
256
+ securitySchemes?: Record<string, SecuritySchemeObject | ReferenceObject>;
257
+ links?: Record<string, LinkObject | ReferenceObject>;
258
+ callbacks?: Record<string, Record<string, PathItemObject> | ReferenceObject>;
259
+ pathItems?: Record<string, PathItemObject | ReferenceObject>;
260
+ }
261
+ interface OpenAPIDocument {
262
+ openapi: "3.1.0";
263
+ info: OpenAPIInfoObject;
264
+ servers?: ServerObject[];
265
+ paths: PathsObject;
266
+ components?: ComponentsObject;
267
+ security?: SecurityRequirement[];
268
+ tags?: TagObject[];
269
+ externalDocs?: ExternalDocsObject;
270
+ jsonSchemaDialect?: string;
271
+ webhooks?: Record<string, PathItemObject | ReferenceObject>;
272
+ [key: `x-${string}`]: unknown;
273
+ }
274
+ interface OpenAPIGenerateOptions {
275
+ /** OpenAPI info object */
276
+ info: {
277
+ title: string;
278
+ version: string;
279
+ description?: string;
280
+ termsOfService?: string;
281
+ contact?: {
282
+ name?: string;
283
+ url?: string;
284
+ email?: string;
285
+ };
286
+ license?: {
287
+ name: string;
288
+ url?: string;
289
+ };
290
+ };
291
+ /** Server URLs */
292
+ servers?: Array<{
293
+ url: string;
294
+ description?: string;
295
+ }>;
296
+ /** Global security schemes */
297
+ securitySchemes?: Record<string, SecuritySchemeObject>;
298
+ /** Global security requirements */
299
+ security?: SecurityRequirement[];
300
+ /** External docs */
301
+ externalDocs?: {
302
+ url: string;
303
+ description?: string;
304
+ };
305
+ /** Custom x- extensions on the root document */
306
+ extensions?: Record<string, unknown>;
307
+ }
308
+ interface DiffEntry {
309
+ type: "added" | "removed" | "modified";
310
+ breaking: boolean;
311
+ path: string;
312
+ description: string;
313
+ before?: unknown;
314
+ after?: unknown;
315
+ }
316
+ interface DiffResult {
317
+ breaking: DiffEntry[];
318
+ nonBreaking: DiffEntry[];
319
+ /** Overall: true if any breaking changes exist */
320
+ hasBreakingChanges: boolean;
321
+ summary: {
322
+ added: number;
323
+ removed: number;
324
+ modified: number;
325
+ breaking: number;
326
+ nonBreaking: number;
327
+ };
328
+ }
329
+ interface ValidationError {
330
+ path: string;
331
+ message: string;
332
+ severity: "error" | "warning";
333
+ }
334
+ interface AuthConfig {
335
+ type: "bearer" | "basic" | "apikey" | "oauth2";
336
+ token?: string;
337
+ username?: string;
338
+ password?: string;
339
+ key?: string;
340
+ keyName?: string;
341
+ keyIn?: "header" | "query";
342
+ }
343
+ interface EndpointMetrics {
344
+ method: string;
345
+ path: string;
346
+ latency: {
347
+ p50: number;
348
+ p95: number;
349
+ p99: number;
350
+ avg: number;
351
+ };
352
+ throughput: {
353
+ rpm: number;
354
+ total: number;
355
+ };
356
+ errors: {
357
+ rate: number;
358
+ count: number;
359
+ lastError?: string;
360
+ };
361
+ availability: number;
362
+ lastUpdated: string;
363
+ }
364
+ interface WatchFnClient {
365
+ fetchMetrics(options?: {
366
+ timeRange?: string;
367
+ endpoints?: string[];
368
+ }): Promise<EndpointMetrics[]>;
369
+ }
370
+ interface RateLimitInfo {
371
+ endpoint: string;
372
+ method: string;
373
+ remaining: number;
374
+ limit: number;
375
+ resetAt: number;
376
+ blocked: boolean;
377
+ }
378
+ interface SecFnRateLimiter {
379
+ peek(endpoint: string, context?: Record<string, string>): Promise<RateLimitInfo | null>;
380
+ }
381
+ interface AuthFnClient {
382
+ baseUrl: string;
383
+ adminKey?: string;
384
+ }
385
+ interface LogFnClient {
386
+ info(eventType: string, payload?: unknown): void;
387
+ error(eventType: string, error: Error | string, payload?: unknown): void;
388
+ warn(eventType: string, payload?: unknown): void;
389
+ debug(eventType: string, payload?: unknown): void;
390
+ child(context: Record<string, unknown>): LogFnClient;
391
+ }
392
+ type SnippetTarget = "curl" | "fetch" | "axios" | "node-fetch" | "python-requests" | "python-httpx" | "go-http" | "ruby-net-http" | "php-curl" | "csharp-httpclient" | "java-okhttp";
393
+ interface SnippetOptions {
394
+ /** Target language/library */
395
+ target: SnippetTarget;
396
+ /** Include auth headers */
397
+ auth?: {
398
+ type: string;
399
+ token?: string;
400
+ key?: string;
401
+ };
402
+ /** Base URL */
403
+ baseUrl: string;
404
+ /** Indentation (default: 2 spaces) */
405
+ indent?: number;
406
+ }
407
+ interface MockServerOptions {
408
+ /** OpenAPI document */
409
+ spec: OpenAPIDocument;
410
+ /** Port (default: 4010) */
411
+ port?: number;
412
+ /** Generate responses from examples or schema (default: "schema") */
413
+ responseMode?: "examples" | "schema" | "random";
414
+ /** Validate incoming requests against schemas */
415
+ validateRequests?: boolean;
416
+ /** Delay responses by ms (simulates latency) */
417
+ delay?: number;
418
+ /** CORS configuration */
419
+ cors?: boolean | CorsOptions;
420
+ }
421
+ interface CorsOptions {
422
+ origin?: string | string[] | ((origin: string) => boolean);
423
+ methods?: HttpMethod[];
424
+ allowedHeaders?: string[];
425
+ exposedHeaders?: string[];
426
+ credentials?: boolean;
427
+ maxAge?: number;
428
+ }
429
+
430
+ declare function introspectRouter(router: Router<unknown>, options?: IntrospectOptions): IntrospectedRoute[];
431
+
432
+ declare function apiSchema(descriptor: SchemaDescriptor): SchemaDescriptor;
433
+
434
+ type SchemaType = "zod" | "typebox" | "jsonschema";
435
+ declare function detectSchemaType(schema: SchemaInput): SchemaType;
436
+
437
+ declare function convertZodSchema(schema: SchemaInput): JsonSchema;
438
+
439
+ declare function convertTypeBoxSchema(schema: SchemaInput): JsonSchema;
440
+
441
+ declare function convertSchema(schema: SchemaInput): JsonSchema;
442
+
443
+ interface DeduplicateSchemaInput {
444
+ schema: JsonSchema;
445
+ name?: string;
446
+ }
447
+ interface DeduplicateSchemasResult {
448
+ refs: string[];
449
+ components: Record<string, JsonSchema>;
450
+ }
451
+ declare function deduplicateSchemas(schemas: DeduplicateSchemaInput[]): DeduplicateSchemasResult;
452
+
453
+ declare function generateOpenAPI(routes: IntrospectedRoute[], options: OpenAPIGenerateOptions): OpenAPIDocument;
454
+
455
+ type FromRouterOptions = OpenAPIGenerateOptions & IntrospectOptions;
456
+ declare function fromRouter(router: Router<unknown>, options: FromRouterOptions): OpenAPIDocument;
457
+
458
+ declare function parseOpenAPI(input: string | Record<string, unknown>): OpenAPIDocument;
459
+
460
+ declare function validateOpenAPI(document: OpenAPIDocument): Promise<ValidationError[]>;
461
+
462
+ declare function upconvertFrom3_0(document: unknown): OpenAPIDocument;
463
+
464
+ /**
465
+ * `diffOpenAPI(before, after)` — full breaking/non-breaking diff engine.
466
+ *
467
+ * Implements DIFF-001 through DIFF-009, Section 7.5 rules.
468
+ *
469
+ * The result is deterministic: given the same two documents, the output
470
+ * is structurally identical (entries sorted by path). (DIFF-008)
471
+ */
472
+
473
+ /**
474
+ * Compute breaking vs. non-breaking differences between two OpenAPI documents.
475
+ *
476
+ * @returns DiffResult with entries sorted deterministically by `path`.
477
+ */
478
+ declare function diffOpenAPI(before: OpenAPIDocument, after: OpenAPIDocument): DiffResult;
479
+
480
+ /**
481
+ * Human-readable and JSON formatters for DiffResult.
482
+ *
483
+ * Implements DIFF-009.
484
+ */
485
+
486
+ interface DiffReportJson {
487
+ timestamp: string;
488
+ hasBreakingChanges: boolean;
489
+ summary: DiffResult["summary"];
490
+ breaking: DiffEntry[];
491
+ nonBreaking: DiffEntry[];
492
+ }
493
+ /**
494
+ * Serialize a DiffResult to the SPEC 6.5 JSON format.
495
+ */
496
+ declare function formatDiffAsJson(result: DiffResult, timestamp?: string): DiffReportJson;
497
+ /**
498
+ * Render a DiffResult as a human-readable text table.
499
+ * Caller can pass a `color` function map for terminal styling.
500
+ */
501
+ declare function formatDiffAsText(result: DiffResult, colors?: {
502
+ red?: (s: string) => string;
503
+ green?: (s: string) => string;
504
+ yellow?: (s: string) => string;
505
+ bold?: (s: string) => string;
506
+ dim?: (s: string) => string;
507
+ }): string;
508
+
509
+ /**
510
+ * watchfn integration for @apifn/core (WATCH-001 through WATCH-004).
511
+ *
512
+ * Provides:
513
+ * - `fetchEndpointMetrics()` — fetch performance metrics from a watchfn HTTP API
514
+ * - `createWatchFnClient()` — factory that returns a WatchFnClient
515
+ * - `apifnWatchMiddleware()` — @superfunctions/http middleware that reports per-route
516
+ * metrics to watchfn via its event API
517
+ */
518
+
519
+ interface FetchEndpointMetricsOptions {
520
+ /** watchfn query API base URL (e.g. "http://localhost:7100") */
521
+ baseUrl: string;
522
+ /** ISO 8601 duration string, e.g. "PT1H" for last 1 hour */
523
+ timeRange?: string;
524
+ /** Filter to specific endpoint keys in the form "METHOD /path" */
525
+ endpoints?: string[];
526
+ /** Request timeout in ms (default: 5000) */
527
+ timeoutMs?: number;
528
+ /** Optional API key for watchfn */
529
+ apiKey?: string;
530
+ }
531
+ interface CreateWatchFnClientOptions extends Omit<FetchEndpointMetricsOptions, "endpoints" | "timeRange"> {
532
+ }
533
+ interface WatchFnMiddlewareOptions {
534
+ /** watchfn event API base URL (e.g. "http://localhost:7100") */
535
+ baseUrl: string;
536
+ /** Optional API key */
537
+ apiKey?: string;
538
+ /** Fire-and-forget: do not await event POST (default: true) */
539
+ fireAndForget?: boolean;
540
+ /** Suppress console warnings on errors (default: false) */
541
+ silent?: boolean;
542
+ }
543
+ /**
544
+ * Fetch endpoint metrics from a watchfn query API endpoint.
545
+ *
546
+ * On network failure or non-2xx response, returns [] with a console.warn
547
+ * (graceful degradation — WATCH-001, WATCH-002).
548
+ *
549
+ * @example
550
+ * const metrics = await fetchEndpointMetrics({
551
+ * baseUrl: "http://localhost:7100",
552
+ * timeRange: "PT1H",
553
+ * endpoints: ["GET /users", "POST /orders"],
554
+ * });
555
+ */
556
+ declare function fetchEndpointMetrics(options: FetchEndpointMetricsOptions): Promise<EndpointMetrics[]>;
557
+ /**
558
+ * Creates a `WatchFnClient` object compatible with the UI components.
559
+ *
560
+ * @example
561
+ * const client = createWatchFnClient({ baseUrl: "http://localhost:7100" });
562
+ * const metrics = await client.fetchMetrics({ timeRange: "PT1H" });
563
+ */
564
+ declare function createWatchFnClient(options: CreateWatchFnClientOptions): WatchFnClient;
565
+ /**
566
+ * @superfunctions/http middleware that captures route metrics and ships them
567
+ * to a watchfn event API endpoint (WATCH-004).
568
+ *
569
+ * @example
570
+ * router.use(apifnWatchMiddleware({ baseUrl: "http://localhost:7100" }));
571
+ */
572
+ declare function apifnWatchMiddleware(options: WatchFnMiddlewareOptions): (req: unknown, res: unknown, next: (...args: unknown[]) => unknown) => Promise<void>;
573
+
574
+ interface AuthfnHttpClientRequest {
575
+ method: string;
576
+ url: string;
577
+ headers: Record<string, string>;
578
+ [key: string]: any;
579
+ }
580
+ interface AuthfnHttpClientResponse {
581
+ status: number;
582
+ headers: Record<string, string>;
583
+ body: string;
584
+ [key: string]: any;
585
+ }
586
+ interface AuthfnHttpClient {
587
+ send(request: AuthfnHttpClientRequest): Promise<AuthfnHttpClientResponse>;
588
+ }
589
+ interface MintTestTokenOptions {
590
+ ttl: number;
591
+ scopes?: string[];
592
+ resourceIds?: string[];
593
+ }
594
+ interface MintTestTokenResponse {
595
+ token: string;
596
+ expiresAt: string;
597
+ }
598
+ /**
599
+ * Mints a short-lived test API key using authfn's admin API (AUTH-001, AUTH-002).
600
+ * Validates that TTL does not exceed 3600 seconds.
601
+ */
602
+ declare function mintTestToken(client: AuthFnClient, options: MintTestTokenOptions): Promise<MintTestTokenResponse>;
603
+ /**
604
+ * A higher-order HttpClient wrapper that injects an Authorization header
605
+ * into all requests (AUTH-003). Useful for collection runner integration.
606
+ */
607
+ declare function createAuthfnCollectionMiddleware(baseClient: AuthfnHttpClient, token: string): AuthfnHttpClient;
608
+
609
+ /**
610
+ * Fetches rate limit headroom for a given list of endpoints (SEC-001).
611
+ * Uses the provided SecFnRateLimiter's `peek()` method which does not consume tokens.
612
+ *
613
+ * @param rateLimiter The secfn rate limiter instance
614
+ * @param endpoints Array of endpoints, e.g. ["GET /users", "POST /orders"]
615
+ * @param context Optional context variables to resolve rate limit keys
616
+ * @returns Array of RateLimitInfo objects detailing remaining limits and reset times
617
+ */
618
+ declare function fetchRateLimits(rateLimiter: SecFnRateLimiter, endpoints: string[], context?: Record<string, string>): Promise<RateLimitInfo[]>;
619
+
620
+ interface LogfnCollectionItem {
621
+ name: string;
622
+ path: string;
623
+ [key: string]: any;
624
+ }
625
+ interface LogfnCollection {
626
+ info: {
627
+ name: string;
628
+ [key: string]: any;
629
+ };
630
+ [key: string]: any;
631
+ }
632
+ interface LogfnRunOptions {
633
+ environment: string | {
634
+ name: string;
635
+ [key: string]: any;
636
+ };
637
+ [key: string]: any;
638
+ }
639
+ interface LogfnRequestResult {
640
+ name: string;
641
+ method: string;
642
+ url: string;
643
+ status: "passed" | "failed" | "skipped" | "error";
644
+ duration: number;
645
+ assertions: Array<{
646
+ passed: boolean;
647
+ [key: string]: any;
648
+ }>;
649
+ error?: string;
650
+ [key: string]: any;
651
+ }
652
+ interface LogfnRunReport {
653
+ duration: number;
654
+ summary: {
655
+ total: number;
656
+ passed: number;
657
+ [key: string]: any;
658
+ };
659
+ [key: string]: any;
660
+ }
661
+ interface LogfnRunReporter {
662
+ onStart?(collection: LogfnCollection, options: LogfnRunOptions): void;
663
+ onRequestStart?(item: LogfnCollectionItem): void;
664
+ onRequestComplete?(result: LogfnRequestResult): void;
665
+ onComplete?(report: LogfnRunReport): void;
666
+ }
667
+ /**
668
+ * Creates a RunReporter that logs collection run events via logfn (LOG-001).
669
+ *
670
+ * @param logfn The configured logfn client
671
+ */
672
+ declare function logfnReporter(logfn: LogFnClient): LogfnRunReporter;
673
+ interface CliLoggerOptions {
674
+ level?: "debug" | "info" | "warn" | "error";
675
+ logfn?: LogFnClient;
676
+ }
677
+ /**
678
+ * CLI logging integration (LOG-002)
679
+ *
680
+ * Provides structured logging using logfn when available, falling back
681
+ * to a simple console logger that respects the chosen log level.
682
+ */
683
+ declare function createCliLogger(options?: CliLoggerOptions): LogFnClient;
684
+
685
+ declare class ApifnTestAdapter extends BaseAdapter {
686
+ name: string;
687
+ supports(framework: string): boolean;
688
+ discover(patterns: string[]): Promise<TestCase[]>;
689
+ run(tests: TestCase[], options: RunOptions): Promise<TestResult[]>;
690
+ }
691
+
692
+ export { ApifnTestAdapter, type AuthConfig, type CliLoggerOptions, type ComponentsObject, type CorsOptions, type CreateWatchFnClientOptions, type DeduplicateSchemaInput, type DeduplicateSchemasResult, type DiffEntry, type DiffReportJson, type DiffResult, type EncodingObject, type EndpointMetrics, type ExampleObject, type ExternalDocsObject, type FetchEndpointMetricsOptions, type FromRouterOptions, type HeaderObject, type HttpMethod, type IntrospectOptions, type IntrospectedRoute, type JsonSchema, type LinkObject, type MediaTypeObject, type MintTestTokenOptions, type MintTestTokenResponse, type MockServerOptions, type OAuthFlowObject, type OAuthFlowsObject, type OpenAPIDocument, type OpenAPIGenerateOptions, type OpenAPIInfoObject, type OperationObject, type ParameterDescriptor, type ParameterObject, type PathItemObject, type PathsObject, type RateLimitInfo, type ReferenceObject, type RequestBodyDescriptor, type RequestBodyObject, type ResponseDescriptor, type ResponseObject, type SchemaDescriptor, type SchemaDescriptorResponse, type SchemaInput, type SchemaObject, type SchemaType, type SecurityRequirement, type SecuritySchemeObject, type ServerObject, type SnippetOptions, type SnippetTarget, type TagObject, type ValidationError, type WatchFnClient, type WatchFnMiddlewareOptions, apiSchema, apifnWatchMiddleware, convertSchema, convertTypeBoxSchema, convertZodSchema, createAuthfnCollectionMiddleware, createCliLogger, createWatchFnClient, deduplicateSchemas, detectSchemaType, diffOpenAPI, fetchEndpointMetrics, fetchRateLimits, formatDiffAsJson, formatDiffAsText, fromRouter, generateOpenAPI, introspectRouter, logfnReporter, mintTestToken, parseOpenAPI, upconvertFrom3_0, validateOpenAPI };