@apifn/core 0.0.2 → 0.0.4

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.
package/dist/types.cjs ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/types.ts
17
+ var types_exports = {};
18
+ module.exports = __toCommonJS(types_exports);
19
+ //# sourceMappingURL=types.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * @apifn/core — Core types and interfaces\n *\n * All shared types for route introspection, schema descriptors,\n * OpenAPI generation, diff detection, and ecosystem integrations.\n */\n\nimport type { Router, Route, Middleware } from \"@superfunctions/http\";\n\n// Re-export for convenience\nexport type { Router, Route, Middleware };\n\n// ============================================================================\n// HTTP Method\n// ============================================================================\n\nexport type HttpMethod =\n | \"GET\"\n | \"POST\"\n | \"PUT\"\n | \"PATCH\"\n | \"DELETE\"\n | \"OPTIONS\"\n | \"HEAD\";\n\n// ============================================================================\n// Schema Type Aliases\n// ============================================================================\n\n/** Represents any schema type: zod, TypeBox, or plain JSON Schema */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type SchemaInput = any;\n\n/** JSON Schema object */\nexport type JsonSchema = Record<string, unknown>;\n\n// ============================================================================\n// Route Introspection\n// ============================================================================\n\nexport interface IntrospectOptions {\n /** Include routes matching these path prefixes only */\n include?: string[];\n /** Exclude routes matching these path prefixes */\n exclude?: string[];\n /** Base path to prepend to all route paths */\n basePath?: string;\n}\n\nexport interface ParameterDescriptor {\n name: string;\n in: \"path\" | \"query\" | \"header\" | \"cookie\";\n required: boolean;\n description?: string;\n deprecated?: boolean;\n schema: JsonSchema;\n}\n\nexport interface RequestBodyDescriptor {\n required?: boolean;\n description?: string;\n content: Record<\n string,\n {\n schema: JsonSchema;\n examples?: Record<string, unknown>;\n }\n >;\n}\n\nexport interface ResponseDescriptor {\n description: string;\n content?: Record<\n string,\n {\n schema: JsonSchema;\n examples?: Record<string, unknown>;\n }\n >;\n headers?: Record<string, { schema: JsonSchema; description?: string }>;\n}\n\nexport type SecurityRequirement = Record<string, string[]>;\n\nexport interface IntrospectedRoute {\n method: HttpMethod;\n path: string;\n operationId?: string;\n summary?: string;\n description?: string;\n tags?: string[];\n deprecated?: boolean;\n parameters: ParameterDescriptor[];\n requestBody?: RequestBodyDescriptor;\n responses: Record<string, ResponseDescriptor>;\n security?: SecurityRequirement[];\n meta: Record<string, unknown>;\n}\n\n// ============================================================================\n// Schema Descriptors\n// ============================================================================\n\nexport interface SchemaDescriptorResponse {\n description: string;\n schema?: SchemaInput;\n headers?: Record<string, SchemaInput>;\n}\n\nexport interface SchemaDescriptor {\n /** Human-readable summary */\n summary?: string;\n /** Detailed description */\n description?: string;\n /** Unique operation identifier */\n operationId?: string;\n /** Tags for grouping */\n tags?: string[];\n /** Whether this endpoint is deprecated */\n deprecated?: boolean;\n /** Request body schema (zod, TypeBox, or JSON Schema) */\n body?: SchemaInput;\n /** Query parameter schemas */\n query?: Record<string, SchemaInput>;\n /** Path parameter schemas */\n params?: Record<string, SchemaInput>;\n /** Header parameter schemas */\n headers?: Record<string, SchemaInput>;\n /** Response schemas keyed by status code */\n responses?: Record<string | number, SchemaDescriptorResponse>;\n /** Security requirements */\n security?: SecurityRequirement[];\n}\n\n// ============================================================================\n// OpenAPI Types\n// ============================================================================\n\nexport interface OpenAPIInfoObject {\n title: string;\n version: string;\n description?: string;\n termsOfService?: string;\n contact?: { name?: string; url?: string; email?: string };\n license?: { name: string; url?: string; identifier?: string };\n summary?: string;\n}\n\nexport interface ServerObject {\n url: string;\n description?: string;\n variables?: Record<\n string,\n {\n default: string;\n enum?: string[];\n description?: string;\n }\n >;\n}\n\nexport interface ExternalDocsObject {\n url: string;\n description?: string;\n}\n\nexport interface TagObject {\n name: string;\n description?: string;\n externalDocs?: ExternalDocsObject;\n}\n\nexport interface SchemaObject extends JsonSchema {\n [key: string]: unknown;\n}\n\nexport interface MediaTypeObject {\n schema?: SchemaObject;\n example?: unknown;\n examples?: Record<string, ExampleObject | ReferenceObject>;\n encoding?: Record<string, EncodingObject>;\n}\n\nexport interface ExampleObject {\n summary?: string;\n description?: string;\n value?: unknown;\n externalValue?: string;\n}\n\nexport interface ReferenceObject {\n $ref: string;\n summary?: string;\n description?: string;\n}\n\nexport interface EncodingObject {\n contentType?: string;\n headers?: Record<string, HeaderObject | ReferenceObject>;\n style?: string;\n explode?: boolean;\n allowReserved?: boolean;\n}\n\nexport interface HeaderObject {\n description?: string;\n required?: boolean;\n deprecated?: boolean;\n schema?: SchemaObject;\n}\n\nexport interface ParameterObject {\n name: string;\n in: \"path\" | \"query\" | \"header\" | \"cookie\";\n description?: string;\n required?: boolean;\n deprecated?: boolean;\n allowEmptyValue?: boolean;\n style?: string;\n explode?: boolean;\n allowReserved?: boolean;\n schema?: SchemaObject;\n example?: unknown;\n examples?: Record<string, ExampleObject | ReferenceObject>;\n content?: Record<string, MediaTypeObject>;\n}\n\nexport interface RequestBodyObject {\n description?: string;\n content: Record<string, MediaTypeObject>;\n required?: boolean;\n}\n\nexport interface ResponseObject {\n description: string;\n headers?: Record<string, HeaderObject | ReferenceObject>;\n content?: Record<string, MediaTypeObject>;\n links?: Record<string, LinkObject | ReferenceObject>;\n}\n\nexport interface LinkObject {\n operationRef?: string;\n operationId?: string;\n parameters?: Record<string, unknown>;\n requestBody?: unknown;\n description?: string;\n server?: ServerObject;\n}\n\nexport interface OperationObject {\n tags?: string[];\n summary?: string;\n description?: string;\n externalDocs?: ExternalDocsObject;\n operationId?: string;\n parameters?: Array<ParameterObject | ReferenceObject>;\n requestBody?: RequestBodyObject | ReferenceObject;\n responses?: Record<string, ResponseObject | ReferenceObject>;\n callbacks?: Record<\n string,\n Record<string, PathItemObject> | ReferenceObject\n >;\n deprecated?: boolean;\n security?: SecurityRequirement[];\n servers?: ServerObject[];\n}\n\nexport interface PathItemObject {\n summary?: string;\n description?: string;\n get?: OperationObject;\n put?: OperationObject;\n post?: OperationObject;\n delete?: OperationObject;\n options?: OperationObject;\n head?: OperationObject;\n patch?: OperationObject;\n trace?: OperationObject;\n servers?: ServerObject[];\n parameters?: Array<ParameterObject | ReferenceObject>;\n}\n\nexport type PathsObject = Record<string, PathItemObject>;\n\nexport interface SecuritySchemeObject {\n type: \"apiKey\" | \"http\" | \"mutualTLS\" | \"oauth2\" | \"openIdConnect\";\n description?: string;\n name?: string;\n in?: \"query\" | \"header\" | \"cookie\";\n scheme?: string;\n bearerFormat?: string;\n flows?: OAuthFlowsObject;\n openIdConnectUrl?: string;\n}\n\nexport interface OAuthFlowsObject {\n implicit?: OAuthFlowObject;\n password?: OAuthFlowObject;\n clientCredentials?: OAuthFlowObject;\n authorizationCode?: OAuthFlowObject;\n}\n\nexport interface OAuthFlowObject {\n authorizationUrl?: string;\n tokenUrl?: string;\n refreshUrl?: string;\n scopes: Record<string, string>;\n}\n\nexport interface ComponentsObject {\n schemas?: Record<string, SchemaObject | ReferenceObject>;\n responses?: Record<string, ResponseObject | ReferenceObject>;\n parameters?: Record<string, ParameterObject | ReferenceObject>;\n examples?: Record<string, ExampleObject | ReferenceObject>;\n requestBodies?: Record<string, RequestBodyObject | ReferenceObject>;\n headers?: Record<string, HeaderObject | ReferenceObject>;\n securitySchemes?: Record<string, SecuritySchemeObject | ReferenceObject>;\n links?: Record<string, LinkObject | ReferenceObject>;\n callbacks?: Record<\n string,\n Record<string, PathItemObject> | ReferenceObject\n >;\n pathItems?: Record<string, PathItemObject | ReferenceObject>;\n}\n\nexport interface OpenAPIDocument {\n openapi: \"3.1.0\";\n info: OpenAPIInfoObject;\n servers?: ServerObject[];\n paths: PathsObject;\n components?: ComponentsObject;\n security?: SecurityRequirement[];\n tags?: TagObject[];\n externalDocs?: ExternalDocsObject;\n jsonSchemaDialect?: string;\n webhooks?: Record<string, PathItemObject | ReferenceObject>;\n [key: `x-${string}`]: unknown;\n}\n\n// ============================================================================\n// OpenAPI Generation Options\n// ============================================================================\n\nexport interface OpenAPIGenerateOptions {\n /** OpenAPI info object */\n info: {\n title: string;\n version: string;\n description?: string;\n termsOfService?: string;\n contact?: { name?: string; url?: string; email?: string };\n license?: { name: string; url?: string };\n };\n /** Server URLs */\n servers?: Array<{ url: string; description?: string }>;\n /** Global security schemes */\n securitySchemes?: Record<string, SecuritySchemeObject>;\n /** Global security requirements */\n security?: SecurityRequirement[];\n /** External docs */\n externalDocs?: { url: string; description?: string };\n /** Custom x- extensions on the root document */\n extensions?: Record<string, unknown>;\n}\n\n// ============================================================================\n// Diff Types\n// ============================================================================\n\nexport interface DiffEntry {\n type: \"added\" | \"removed\" | \"modified\";\n breaking: boolean;\n path: string;\n description: string;\n before?: unknown;\n after?: unknown;\n}\n\nexport interface DiffResult {\n breaking: DiffEntry[];\n nonBreaking: DiffEntry[];\n /** Overall: true if any breaking changes exist */\n hasBreakingChanges: boolean;\n summary: {\n added: number;\n removed: number;\n modified: number;\n breaking: number;\n nonBreaking: number;\n };\n}\n\n// ============================================================================\n// Validation\n// ============================================================================\n\nexport interface ValidationError {\n path: string;\n message: string;\n severity: \"error\" | \"warning\";\n}\n\n// ============================================================================\n// Auth Config (used by UI, collections, snippets)\n// ============================================================================\n\nexport interface AuthConfig {\n type: \"bearer\" | \"basic\" | \"apikey\" | \"oauth2\";\n token?: string;\n username?: string;\n password?: string;\n key?: string;\n keyName?: string;\n keyIn?: \"header\" | \"query\";\n}\n\n// ============================================================================\n// watchfn Integration Types\n// ============================================================================\n\nexport interface EndpointMetrics {\n method: string;\n path: string;\n latency: { p50: number; p95: number; p99: number; avg: number };\n throughput: { rpm: number; total: number };\n errors: { rate: number; count: number; lastError?: string };\n availability: number;\n lastUpdated: string;\n}\n\nexport interface WatchFnClient {\n fetchMetrics(options?: {\n timeRange?: string;\n endpoints?: string[];\n }): Promise<EndpointMetrics[]>;\n}\n\n// ============================================================================\n// secfn Integration Types\n// ============================================================================\n\nexport interface RateLimitInfo {\n endpoint: string;\n method: string;\n remaining: number;\n limit: number;\n resetAt: number;\n blocked: boolean;\n}\n\nexport interface SecFnRateLimiter {\n peek(endpoint: string, context?: Record<string, string>): Promise<RateLimitInfo | null>;\n}\n\n// ============================================================================\n// authfn Integration Types\n// ============================================================================\n\nexport interface AuthFnClient {\n baseUrl: string;\n adminKey?: string;\n}\n\n// ============================================================================\n// logfn Integration Types\n// ============================================================================\n\nexport interface LogFnClient {\n info(eventType: string, payload?: unknown): void;\n error(eventType: string, error: Error | string, payload?: unknown): void;\n warn(eventType: string, payload?: unknown): void;\n debug(eventType: string, payload?: unknown): void;\n child(context: Record<string, unknown>): LogFnClient;\n}\n\n// ============================================================================\n// Code Snippet Types\n// ============================================================================\n\nexport type SnippetTarget =\n | \"curl\"\n | \"fetch\"\n | \"axios\"\n | \"node-fetch\"\n | \"python-requests\"\n | \"python-httpx\"\n | \"go-http\"\n | \"ruby-net-http\"\n | \"php-curl\"\n | \"csharp-httpclient\"\n | \"java-okhttp\";\n\nexport interface SnippetOptions {\n /** Target language/library */\n target: SnippetTarget;\n /** Include auth headers */\n auth?: { type: string; token?: string; key?: string };\n /** Base URL */\n baseUrl: string;\n /** Indentation (default: 2 spaces) */\n indent?: number;\n}\n\n// ============================================================================\n// Mock Server Types\n// ============================================================================\n\nexport interface MockServerOptions {\n /** OpenAPI document */\n spec: OpenAPIDocument;\n /** Port (default: 4010) */\n port?: number;\n /** Generate responses from examples or schema (default: \"schema\") */\n responseMode?: \"examples\" | \"schema\" | \"random\";\n /** Validate incoming requests against schemas */\n validateRequests?: boolean;\n /** Delay responses by ms (simulates latency) */\n delay?: number;\n /** Maximum accepted request body size in bytes (default: 10 MiB) */\n maxRequestBodyBytes?: number;\n /** CORS configuration */\n cors?: boolean | CorsOptions;\n}\n\nexport interface CorsOptions {\n origin?: string | string[] | ((origin: string) => boolean);\n methods?: HttpMethod[];\n allowedHeaders?: string[];\n exposedHeaders?: string[];\n credentials?: boolean;\n maxAge?: number;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -0,0 +1,430 @@
1
+ export { Middleware, Route, Router } from '@superfunctions/http';
2
+
3
+ /**
4
+ * @apifn/core — Core types and interfaces
5
+ *
6
+ * All shared types for route introspection, schema descriptors,
7
+ * OpenAPI generation, diff detection, and ecosystem integrations.
8
+ */
9
+
10
+ type HttpMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "OPTIONS" | "HEAD";
11
+ /** Represents any schema type: zod, TypeBox, or plain JSON Schema */
12
+ type SchemaInput = any;
13
+ /** JSON Schema object */
14
+ type JsonSchema = Record<string, unknown>;
15
+ interface IntrospectOptions {
16
+ /** Include routes matching these path prefixes only */
17
+ include?: string[];
18
+ /** Exclude routes matching these path prefixes */
19
+ exclude?: string[];
20
+ /** Base path to prepend to all route paths */
21
+ basePath?: string;
22
+ }
23
+ interface ParameterDescriptor {
24
+ name: string;
25
+ in: "path" | "query" | "header" | "cookie";
26
+ required: boolean;
27
+ description?: string;
28
+ deprecated?: boolean;
29
+ schema: JsonSchema;
30
+ }
31
+ interface RequestBodyDescriptor {
32
+ required?: boolean;
33
+ description?: string;
34
+ content: Record<string, {
35
+ schema: JsonSchema;
36
+ examples?: Record<string, unknown>;
37
+ }>;
38
+ }
39
+ interface ResponseDescriptor {
40
+ description: string;
41
+ content?: Record<string, {
42
+ schema: JsonSchema;
43
+ examples?: Record<string, unknown>;
44
+ }>;
45
+ headers?: Record<string, {
46
+ schema: JsonSchema;
47
+ description?: string;
48
+ }>;
49
+ }
50
+ type SecurityRequirement = Record<string, string[]>;
51
+ interface IntrospectedRoute {
52
+ method: HttpMethod;
53
+ path: string;
54
+ operationId?: string;
55
+ summary?: string;
56
+ description?: string;
57
+ tags?: string[];
58
+ deprecated?: boolean;
59
+ parameters: ParameterDescriptor[];
60
+ requestBody?: RequestBodyDescriptor;
61
+ responses: Record<string, ResponseDescriptor>;
62
+ security?: SecurityRequirement[];
63
+ meta: Record<string, unknown>;
64
+ }
65
+ interface SchemaDescriptorResponse {
66
+ description: string;
67
+ schema?: SchemaInput;
68
+ headers?: Record<string, SchemaInput>;
69
+ }
70
+ interface SchemaDescriptor {
71
+ /** Human-readable summary */
72
+ summary?: string;
73
+ /** Detailed description */
74
+ description?: string;
75
+ /** Unique operation identifier */
76
+ operationId?: string;
77
+ /** Tags for grouping */
78
+ tags?: string[];
79
+ /** Whether this endpoint is deprecated */
80
+ deprecated?: boolean;
81
+ /** Request body schema (zod, TypeBox, or JSON Schema) */
82
+ body?: SchemaInput;
83
+ /** Query parameter schemas */
84
+ query?: Record<string, SchemaInput>;
85
+ /** Path parameter schemas */
86
+ params?: Record<string, SchemaInput>;
87
+ /** Header parameter schemas */
88
+ headers?: Record<string, SchemaInput>;
89
+ /** Response schemas keyed by status code */
90
+ responses?: Record<string | number, SchemaDescriptorResponse>;
91
+ /** Security requirements */
92
+ security?: SecurityRequirement[];
93
+ }
94
+ interface OpenAPIInfoObject {
95
+ title: string;
96
+ version: string;
97
+ description?: string;
98
+ termsOfService?: string;
99
+ contact?: {
100
+ name?: string;
101
+ url?: string;
102
+ email?: string;
103
+ };
104
+ license?: {
105
+ name: string;
106
+ url?: string;
107
+ identifier?: string;
108
+ };
109
+ summary?: string;
110
+ }
111
+ interface ServerObject {
112
+ url: string;
113
+ description?: string;
114
+ variables?: Record<string, {
115
+ default: string;
116
+ enum?: string[];
117
+ description?: string;
118
+ }>;
119
+ }
120
+ interface ExternalDocsObject {
121
+ url: string;
122
+ description?: string;
123
+ }
124
+ interface TagObject {
125
+ name: string;
126
+ description?: string;
127
+ externalDocs?: ExternalDocsObject;
128
+ }
129
+ interface SchemaObject extends JsonSchema {
130
+ [key: string]: unknown;
131
+ }
132
+ interface MediaTypeObject {
133
+ schema?: SchemaObject;
134
+ example?: unknown;
135
+ examples?: Record<string, ExampleObject | ReferenceObject>;
136
+ encoding?: Record<string, EncodingObject>;
137
+ }
138
+ interface ExampleObject {
139
+ summary?: string;
140
+ description?: string;
141
+ value?: unknown;
142
+ externalValue?: string;
143
+ }
144
+ interface ReferenceObject {
145
+ $ref: string;
146
+ summary?: string;
147
+ description?: string;
148
+ }
149
+ interface EncodingObject {
150
+ contentType?: string;
151
+ headers?: Record<string, HeaderObject | ReferenceObject>;
152
+ style?: string;
153
+ explode?: boolean;
154
+ allowReserved?: boolean;
155
+ }
156
+ interface HeaderObject {
157
+ description?: string;
158
+ required?: boolean;
159
+ deprecated?: boolean;
160
+ schema?: SchemaObject;
161
+ }
162
+ interface ParameterObject {
163
+ name: string;
164
+ in: "path" | "query" | "header" | "cookie";
165
+ description?: string;
166
+ required?: boolean;
167
+ deprecated?: boolean;
168
+ allowEmptyValue?: boolean;
169
+ style?: string;
170
+ explode?: boolean;
171
+ allowReserved?: boolean;
172
+ schema?: SchemaObject;
173
+ example?: unknown;
174
+ examples?: Record<string, ExampleObject | ReferenceObject>;
175
+ content?: Record<string, MediaTypeObject>;
176
+ }
177
+ interface RequestBodyObject {
178
+ description?: string;
179
+ content: Record<string, MediaTypeObject>;
180
+ required?: boolean;
181
+ }
182
+ interface ResponseObject {
183
+ description: string;
184
+ headers?: Record<string, HeaderObject | ReferenceObject>;
185
+ content?: Record<string, MediaTypeObject>;
186
+ links?: Record<string, LinkObject | ReferenceObject>;
187
+ }
188
+ interface LinkObject {
189
+ operationRef?: string;
190
+ operationId?: string;
191
+ parameters?: Record<string, unknown>;
192
+ requestBody?: unknown;
193
+ description?: string;
194
+ server?: ServerObject;
195
+ }
196
+ interface OperationObject {
197
+ tags?: string[];
198
+ summary?: string;
199
+ description?: string;
200
+ externalDocs?: ExternalDocsObject;
201
+ operationId?: string;
202
+ parameters?: Array<ParameterObject | ReferenceObject>;
203
+ requestBody?: RequestBodyObject | ReferenceObject;
204
+ responses?: Record<string, ResponseObject | ReferenceObject>;
205
+ callbacks?: Record<string, Record<string, PathItemObject> | ReferenceObject>;
206
+ deprecated?: boolean;
207
+ security?: SecurityRequirement[];
208
+ servers?: ServerObject[];
209
+ }
210
+ interface PathItemObject {
211
+ summary?: string;
212
+ description?: string;
213
+ get?: OperationObject;
214
+ put?: OperationObject;
215
+ post?: OperationObject;
216
+ delete?: OperationObject;
217
+ options?: OperationObject;
218
+ head?: OperationObject;
219
+ patch?: OperationObject;
220
+ trace?: OperationObject;
221
+ servers?: ServerObject[];
222
+ parameters?: Array<ParameterObject | ReferenceObject>;
223
+ }
224
+ type PathsObject = Record<string, PathItemObject>;
225
+ interface SecuritySchemeObject {
226
+ type: "apiKey" | "http" | "mutualTLS" | "oauth2" | "openIdConnect";
227
+ description?: string;
228
+ name?: string;
229
+ in?: "query" | "header" | "cookie";
230
+ scheme?: string;
231
+ bearerFormat?: string;
232
+ flows?: OAuthFlowsObject;
233
+ openIdConnectUrl?: string;
234
+ }
235
+ interface OAuthFlowsObject {
236
+ implicit?: OAuthFlowObject;
237
+ password?: OAuthFlowObject;
238
+ clientCredentials?: OAuthFlowObject;
239
+ authorizationCode?: OAuthFlowObject;
240
+ }
241
+ interface OAuthFlowObject {
242
+ authorizationUrl?: string;
243
+ tokenUrl?: string;
244
+ refreshUrl?: string;
245
+ scopes: Record<string, string>;
246
+ }
247
+ interface ComponentsObject {
248
+ schemas?: Record<string, SchemaObject | ReferenceObject>;
249
+ responses?: Record<string, ResponseObject | ReferenceObject>;
250
+ parameters?: Record<string, ParameterObject | ReferenceObject>;
251
+ examples?: Record<string, ExampleObject | ReferenceObject>;
252
+ requestBodies?: Record<string, RequestBodyObject | ReferenceObject>;
253
+ headers?: Record<string, HeaderObject | ReferenceObject>;
254
+ securitySchemes?: Record<string, SecuritySchemeObject | ReferenceObject>;
255
+ links?: Record<string, LinkObject | ReferenceObject>;
256
+ callbacks?: Record<string, Record<string, PathItemObject> | ReferenceObject>;
257
+ pathItems?: Record<string, PathItemObject | ReferenceObject>;
258
+ }
259
+ interface OpenAPIDocument {
260
+ openapi: "3.1.0";
261
+ info: OpenAPIInfoObject;
262
+ servers?: ServerObject[];
263
+ paths: PathsObject;
264
+ components?: ComponentsObject;
265
+ security?: SecurityRequirement[];
266
+ tags?: TagObject[];
267
+ externalDocs?: ExternalDocsObject;
268
+ jsonSchemaDialect?: string;
269
+ webhooks?: Record<string, PathItemObject | ReferenceObject>;
270
+ [key: `x-${string}`]: unknown;
271
+ }
272
+ interface OpenAPIGenerateOptions {
273
+ /** OpenAPI info object */
274
+ info: {
275
+ title: string;
276
+ version: string;
277
+ description?: string;
278
+ termsOfService?: string;
279
+ contact?: {
280
+ name?: string;
281
+ url?: string;
282
+ email?: string;
283
+ };
284
+ license?: {
285
+ name: string;
286
+ url?: string;
287
+ };
288
+ };
289
+ /** Server URLs */
290
+ servers?: Array<{
291
+ url: string;
292
+ description?: string;
293
+ }>;
294
+ /** Global security schemes */
295
+ securitySchemes?: Record<string, SecuritySchemeObject>;
296
+ /** Global security requirements */
297
+ security?: SecurityRequirement[];
298
+ /** External docs */
299
+ externalDocs?: {
300
+ url: string;
301
+ description?: string;
302
+ };
303
+ /** Custom x- extensions on the root document */
304
+ extensions?: Record<string, unknown>;
305
+ }
306
+ interface DiffEntry {
307
+ type: "added" | "removed" | "modified";
308
+ breaking: boolean;
309
+ path: string;
310
+ description: string;
311
+ before?: unknown;
312
+ after?: unknown;
313
+ }
314
+ interface DiffResult {
315
+ breaking: DiffEntry[];
316
+ nonBreaking: DiffEntry[];
317
+ /** Overall: true if any breaking changes exist */
318
+ hasBreakingChanges: boolean;
319
+ summary: {
320
+ added: number;
321
+ removed: number;
322
+ modified: number;
323
+ breaking: number;
324
+ nonBreaking: number;
325
+ };
326
+ }
327
+ interface ValidationError {
328
+ path: string;
329
+ message: string;
330
+ severity: "error" | "warning";
331
+ }
332
+ interface AuthConfig {
333
+ type: "bearer" | "basic" | "apikey" | "oauth2";
334
+ token?: string;
335
+ username?: string;
336
+ password?: string;
337
+ key?: string;
338
+ keyName?: string;
339
+ keyIn?: "header" | "query";
340
+ }
341
+ interface EndpointMetrics {
342
+ method: string;
343
+ path: string;
344
+ latency: {
345
+ p50: number;
346
+ p95: number;
347
+ p99: number;
348
+ avg: number;
349
+ };
350
+ throughput: {
351
+ rpm: number;
352
+ total: number;
353
+ };
354
+ errors: {
355
+ rate: number;
356
+ count: number;
357
+ lastError?: string;
358
+ };
359
+ availability: number;
360
+ lastUpdated: string;
361
+ }
362
+ interface WatchFnClient {
363
+ fetchMetrics(options?: {
364
+ timeRange?: string;
365
+ endpoints?: string[];
366
+ }): Promise<EndpointMetrics[]>;
367
+ }
368
+ interface RateLimitInfo {
369
+ endpoint: string;
370
+ method: string;
371
+ remaining: number;
372
+ limit: number;
373
+ resetAt: number;
374
+ blocked: boolean;
375
+ }
376
+ interface SecFnRateLimiter {
377
+ peek(endpoint: string, context?: Record<string, string>): Promise<RateLimitInfo | null>;
378
+ }
379
+ interface AuthFnClient {
380
+ baseUrl: string;
381
+ adminKey?: string;
382
+ }
383
+ interface LogFnClient {
384
+ info(eventType: string, payload?: unknown): void;
385
+ error(eventType: string, error: Error | string, payload?: unknown): void;
386
+ warn(eventType: string, payload?: unknown): void;
387
+ debug(eventType: string, payload?: unknown): void;
388
+ child(context: Record<string, unknown>): LogFnClient;
389
+ }
390
+ type SnippetTarget = "curl" | "fetch" | "axios" | "node-fetch" | "python-requests" | "python-httpx" | "go-http" | "ruby-net-http" | "php-curl" | "csharp-httpclient" | "java-okhttp";
391
+ interface SnippetOptions {
392
+ /** Target language/library */
393
+ target: SnippetTarget;
394
+ /** Include auth headers */
395
+ auth?: {
396
+ type: string;
397
+ token?: string;
398
+ key?: string;
399
+ };
400
+ /** Base URL */
401
+ baseUrl: string;
402
+ /** Indentation (default: 2 spaces) */
403
+ indent?: number;
404
+ }
405
+ interface MockServerOptions {
406
+ /** OpenAPI document */
407
+ spec: OpenAPIDocument;
408
+ /** Port (default: 4010) */
409
+ port?: number;
410
+ /** Generate responses from examples or schema (default: "schema") */
411
+ responseMode?: "examples" | "schema" | "random";
412
+ /** Validate incoming requests against schemas */
413
+ validateRequests?: boolean;
414
+ /** Delay responses by ms (simulates latency) */
415
+ delay?: number;
416
+ /** Maximum accepted request body size in bytes (default: 10 MiB) */
417
+ maxRequestBodyBytes?: 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
+ export type { AuthConfig, AuthFnClient, ComponentsObject, CorsOptions, DiffEntry, DiffResult, EncodingObject, EndpointMetrics, ExampleObject, ExternalDocsObject, HeaderObject, HttpMethod, IntrospectOptions, IntrospectedRoute, JsonSchema, LinkObject, LogFnClient, MediaTypeObject, MockServerOptions, OAuthFlowObject, OAuthFlowsObject, OpenAPIDocument, OpenAPIGenerateOptions, OpenAPIInfoObject, OperationObject, ParameterDescriptor, ParameterObject, PathItemObject, PathsObject, RateLimitInfo, ReferenceObject, RequestBodyDescriptor, RequestBodyObject, ResponseDescriptor, ResponseObject, SchemaDescriptor, SchemaDescriptorResponse, SchemaInput, SchemaObject, SecFnRateLimiter, SecurityRequirement, SecuritySchemeObject, ServerObject, SnippetOptions, SnippetTarget, TagObject, ValidationError, WatchFnClient };