@lykosjs/openapi 0.0.1 → 1.0.0

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,16 @@
1
+ import type { OpenAPIDocument, OpenAPIInfo, OpenAPISecurityScheme, OpenAPIServer } from '../types/openapi.types.js';
2
+ import type { ResolvedRoute } from '../types/internal.types.js';
3
+ export interface GeneratorInput {
4
+ readonly info: OpenAPIInfo;
5
+ readonly servers: readonly OpenAPIServer[];
6
+ readonly securitySchemes: Readonly<Record<string, OpenAPISecurityScheme>>;
7
+ /** Routes that exist in LykosJS (already filtered by strict validation). */
8
+ readonly routes: readonly ResolvedRoute[];
9
+ }
10
+ /**
11
+ * Builds an OpenAPI 3.1.0 document. Pure and deterministic: the same input always
12
+ * produces the same output, in declaration order. Documentation keys are only
13
+ * used as `operationId`, never as path keys.
14
+ */
15
+ export declare function generateDocument(input: GeneratorInput): OpenAPIDocument;
16
+ //# sourceMappingURL=generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/core/generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EAMX,qBAAqB,EACrB,aAAa,EACd,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAG/D,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAA;IAC1B,QAAQ,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE,CAAA;IAC1C,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAA;IACzE,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,SAAS,aAAa,EAAE,CAAA;CAC1C;AAyFD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,CA4BvE"}
@@ -0,0 +1,42 @@
1
+ import type { OpenAPIDocument } from '../types/openapi.types.js';
2
+ import type { OpenAPIOptions } from '../types/route.types.js';
3
+ import type { Lykos } from 'lykosjs';
4
+ /** The part of a LykosJS application this library needs. */
5
+ export type LykosApplication = Pick<Lykos, 'GET' | 'readRoutes'>;
6
+ /**
7
+ * OpenAPI 3.1 documentation for a LykosJS application.
8
+ *
9
+ * ```ts
10
+ * const openapi = new OpenAPI({ info, routes: { getUsers: { ... } } })
11
+ * openapi.setup(app) // after every route has been registered
12
+ * ```
13
+ */
14
+ export declare class OpenAPIManager {
15
+ #private;
16
+ /**
17
+ * Validates the configuration (including every schema) and throws one
18
+ * `OpenAPIValidationError` listing all problems.
19
+ */
20
+ constructor(options: OpenAPIOptions);
21
+ /**
22
+ * Builds the document for the routes currently registered in `app`, after strict validation.
23
+ * Pure: it registers nothing and can be called at any time. Documented routes with
24
+ * `isRequired: false` that are not registered are left out.
25
+ */
26
+ generate(app: LykosApplication): OpenAPIDocument;
27
+ /**
28
+ * Validates, generates the document once and registers the documentation routes
29
+ * (`GET <json>`, `GET <docs>` and its assets) in `app`.
30
+ *
31
+ * - Call it AFTER registering every application route: validation and the
32
+ * document reflect the routes registered at that moment.
33
+ * - Middlewares added with `use` before this call also protect the
34
+ * documentation; `options.middlewares` applies to it only.
35
+ * - Calling it again with the same application is a no-op; with another
36
+ * application it throws (one `OpenAPI` instance serves one application).
37
+ */
38
+ setup(app: LykosApplication): void;
39
+ /** A copy of the generated document. Only available after `setup()`. */
40
+ getDocument(): OpenAPIDocument;
41
+ }
42
+ //# sourceMappingURL=openapi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../src/core/openapi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAQ7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpC,4DAA4D;AAC5D,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY,CAAC,CAAA;AAoBhE;;;;;;;GAOG;AACH,qBAAa,cAAc;;IAKzB;;;OAGG;gBACS,OAAO,EAAE,cAAc;IAInC;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,gBAAgB,GAAG,eAAe;IAKhD;;;;;;;;;;OAUG;IACH,KAAK,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI;IAwBlC,wEAAwE;IACxE,WAAW,IAAI,eAAe;CAmC/B"}
@@ -0,0 +1,8 @@
1
+ import type { ResolvedOptions } from '../types/internal.types.js';
2
+ /**
3
+ * Validates and normalizes the developer-provided configuration.
4
+ * Everything is copied, so later mutations of the original object cannot affect the library.
5
+ * All problems found are reported together in one `OpenAPIValidationError`.
6
+ */
7
+ export declare function resolveOptions(options: unknown): ResolvedOptions;
8
+ //# sourceMappingURL=resolve-options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-options.d.ts","sourceRoot":"","sources":["../../src/core/resolve-options.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,4BAA4B,CAAA;AA6hBnC;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,eAAe,CAqFhE"}
@@ -0,0 +1,8 @@
1
+ export { OpenAPIManager } from './core/openapi';
2
+ export type { LykosApplication } from './core/openapi';
3
+ export { OpenAPIValidationError } from './validation/validation-error';
4
+ export type { ValidationIssue } from './validation/validation-error';
5
+ export type { OpenAPIBodyContentType, OpenAPIMethod, OpenAPIOptions, OpenAPIRequest, OpenAPIResponse, OpenAPIResponses, OpenAPIRoute, SwaggerUIOptions, } from './types/route.types';
6
+ export type { OpenAPIDocument, OpenAPIInfo, OpenAPIOperation, OpenAPIParameter, OpenAPIPathItem, OpenAPISecurityScheme, OpenAPIServer, } from './types/openapi.types';
7
+ export type { JsonSchema, LykosSchema } from './types/schema.types';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACtD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AACtE,YAAY,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAA;AAEpE,YAAY,EACV,sBAAsB,EACtB,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,GACjB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EACV,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,aAAa,GACd,MAAM,uBAAuB,CAAA;AAC9B,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA"}