@navios/openapi-bun 0.7.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.
Files changed (60) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/LICENSE +8 -0
  3. package/README.md +286 -0
  4. package/dist/src/controllers/index.d.mts +4 -0
  5. package/dist/src/controllers/index.d.mts.map +1 -0
  6. package/dist/src/controllers/openapi-json.controller.d.mts +10 -0
  7. package/dist/src/controllers/openapi-json.controller.d.mts.map +1 -0
  8. package/dist/src/controllers/openapi-ui.controller.d.mts +10 -0
  9. package/dist/src/controllers/openapi-ui.controller.d.mts.map +1 -0
  10. package/dist/src/controllers/openapi-yaml.controller.d.mts +10 -0
  11. package/dist/src/controllers/openapi-yaml.controller.d.mts.map +1 -0
  12. package/dist/src/index.d.mts +8 -0
  13. package/dist/src/index.d.mts.map +1 -0
  14. package/dist/src/openapi-bun.plugin.d.mts +68 -0
  15. package/dist/src/openapi-bun.plugin.d.mts.map +1 -0
  16. package/dist/src/schemas/index.d.mts +2 -0
  17. package/dist/src/schemas/index.d.mts.map +1 -0
  18. package/dist/src/schemas/openapi-bun-options.schema.d.mts +114 -0
  19. package/dist/src/schemas/openapi-bun-options.schema.d.mts.map +1 -0
  20. package/dist/src/services/index.d.mts +2 -0
  21. package/dist/src/services/index.d.mts.map +1 -0
  22. package/dist/src/services/openapi-document.service.d.mts +38 -0
  23. package/dist/src/services/openapi-document.service.d.mts.map +1 -0
  24. package/dist/src/tokens/index.d.mts +2 -0
  25. package/dist/src/tokens/index.d.mts.map +1 -0
  26. package/dist/src/tokens/openapi-options.token.d.mts +25 -0
  27. package/dist/src/tokens/openapi-options.token.d.mts.map +1 -0
  28. package/dist/tsconfig.lib.tsbuildinfo +1 -0
  29. package/dist/tsconfig.tsbuildinfo +1 -0
  30. package/dist/tsdown.config.d.mts +3 -0
  31. package/dist/tsdown.config.d.mts.map +1 -0
  32. package/dist/vitest.config.d.mts +3 -0
  33. package/dist/vitest.config.d.mts.map +1 -0
  34. package/lib/index.cjs +4326 -0
  35. package/lib/index.cjs.map +1 -0
  36. package/lib/index.d.cts +262 -0
  37. package/lib/index.d.cts.map +1 -0
  38. package/lib/index.d.mts +262 -0
  39. package/lib/index.d.mts.map +1 -0
  40. package/lib/index.mjs +4311 -0
  41. package/lib/index.mjs.map +1 -0
  42. package/package.json +48 -0
  43. package/project.json +66 -0
  44. package/src/controllers/index.mts +3 -0
  45. package/src/controllers/openapi-json.controller.mts +51 -0
  46. package/src/controllers/openapi-ui.controller.mts +72 -0
  47. package/src/controllers/openapi-yaml.controller.mts +46 -0
  48. package/src/index.mts +30 -0
  49. package/src/openapi-bun.plugin.mts +167 -0
  50. package/src/schemas/index.mts +10 -0
  51. package/src/schemas/openapi-bun-options.schema.mts +135 -0
  52. package/src/services/index.mts +4 -0
  53. package/src/services/openapi-document.service.mts +83 -0
  54. package/src/tokens/index.mts +1 -0
  55. package/src/tokens/openapi-options.token.mts +31 -0
  56. package/tsconfig.json +15 -0
  57. package/tsconfig.lib.json +8 -0
  58. package/tsconfig.spec.json +8 -0
  59. package/tsdown.config.mts +41 -0
  60. package/vitest.config.mts +11 -0
@@ -0,0 +1,262 @@
1
+ import { InjectionToken, ModuleMetadata, NaviosPlugin, PluginContext, PluginDefinition } from "@navios/core";
2
+ import { z } from "zod";
3
+ import { OpenApiGeneratorOptions } from "@navios/openapi";
4
+ import { oas31 } from "zod-openapi";
5
+ import { ClassType } from "@navios/di";
6
+
7
+ //#region src/schemas/openapi-bun-options.schema.d.mts
8
+ /**
9
+ * Zod schema for Scalar UI theme options
10
+ */
11
+ declare const scalarThemeSchema: z.ZodEnum<{
12
+ default: "default";
13
+ alternate: "alternate";
14
+ moon: "moon";
15
+ purple: "purple";
16
+ solarized: "solarized";
17
+ bluePlanet: "bluePlanet";
18
+ saturn: "saturn";
19
+ kepler: "kepler";
20
+ mars: "mars";
21
+ deepSpace: "deepSpace";
22
+ laserwave: "laserwave";
23
+ elysiajs: "elysiajs";
24
+ fastify: "fastify";
25
+ none: "none";
26
+ }>;
27
+ /**
28
+ * Zod schema for Scalar UI configuration options
29
+ */
30
+ declare const scalarOptionsSchema: z.ZodObject<{
31
+ theme: z.ZodOptional<z.ZodEnum<{
32
+ default: "default";
33
+ alternate: "alternate";
34
+ moon: "moon";
35
+ purple: "purple";
36
+ solarized: "solarized";
37
+ bluePlanet: "bluePlanet";
38
+ saturn: "saturn";
39
+ kepler: "kepler";
40
+ mars: "mars";
41
+ deepSpace: "deepSpace";
42
+ laserwave: "laserwave";
43
+ elysiajs: "elysiajs";
44
+ fastify: "fastify";
45
+ none: "none";
46
+ }>>;
47
+ favicon: z.ZodOptional<z.ZodString>;
48
+ logo: z.ZodOptional<z.ZodString>;
49
+ hideDownloadButton: z.ZodOptional<z.ZodBoolean>;
50
+ hideSearch: z.ZodOptional<z.ZodBoolean>;
51
+ customCss: z.ZodOptional<z.ZodString>;
52
+ metaData: z.ZodOptional<z.ZodObject<{
53
+ title: z.ZodOptional<z.ZodString>;
54
+ description: z.ZodOptional<z.ZodString>;
55
+ ogDescription: z.ZodOptional<z.ZodString>;
56
+ ogTitle: z.ZodOptional<z.ZodString>;
57
+ ogImage: z.ZodOptional<z.ZodString>;
58
+ twitterCard: z.ZodOptional<z.ZodString>;
59
+ }, z.core.$strip>>;
60
+ cdn: z.ZodOptional<z.ZodString>;
61
+ }, z.core.$strip>;
62
+ /**
63
+ * Zod schema for Bun OpenAPI plugin options
64
+ */
65
+ declare const bunOpenApiPluginOptionsSchema: z.ZodObject<{
66
+ jsonPath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
67
+ yamlPath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
68
+ docsPath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
69
+ scalar: z.ZodOptional<z.ZodObject<{
70
+ theme: z.ZodOptional<z.ZodEnum<{
71
+ default: "default";
72
+ alternate: "alternate";
73
+ moon: "moon";
74
+ purple: "purple";
75
+ solarized: "solarized";
76
+ bluePlanet: "bluePlanet";
77
+ saturn: "saturn";
78
+ kepler: "kepler";
79
+ mars: "mars";
80
+ deepSpace: "deepSpace";
81
+ laserwave: "laserwave";
82
+ elysiajs: "elysiajs";
83
+ fastify: "fastify";
84
+ none: "none";
85
+ }>>;
86
+ favicon: z.ZodOptional<z.ZodString>;
87
+ logo: z.ZodOptional<z.ZodString>;
88
+ hideDownloadButton: z.ZodOptional<z.ZodBoolean>;
89
+ hideSearch: z.ZodOptional<z.ZodBoolean>;
90
+ customCss: z.ZodOptional<z.ZodString>;
91
+ metaData: z.ZodOptional<z.ZodObject<{
92
+ title: z.ZodOptional<z.ZodString>;
93
+ description: z.ZodOptional<z.ZodString>;
94
+ ogDescription: z.ZodOptional<z.ZodString>;
95
+ ogTitle: z.ZodOptional<z.ZodString>;
96
+ ogImage: z.ZodOptional<z.ZodString>;
97
+ twitterCard: z.ZodOptional<z.ZodString>;
98
+ }, z.core.$strip>>;
99
+ cdn: z.ZodOptional<z.ZodString>;
100
+ }, z.core.$strip>>;
101
+ disableJson: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
102
+ disableScalar: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
103
+ disableYaml: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
104
+ }, z.core.$strip>;
105
+ type ScalarTheme = z.infer<typeof scalarThemeSchema>;
106
+ type ScalarOptions = z.infer<typeof scalarOptionsSchema>;
107
+ type BunOpenApiPluginOptionsBase = z.infer<typeof bunOpenApiPluginOptionsSchema>;
108
+ //#endregion
109
+ //#region src/tokens/openapi-options.token.d.mts
110
+ /**
111
+ * Combined options for the Bun OpenAPI plugin.
112
+ * Extends OpenApiGeneratorOptions with Bun-specific settings.
113
+ */
114
+ interface BunOpenApiPluginOptions extends OpenApiGeneratorOptions, Partial<BunOpenApiPluginOptionsBase> {}
115
+ /**
116
+ * Injection token for OpenAPI plugin options.
117
+ *
118
+ * Controllers inject this to access the plugin configuration
119
+ * (paths, Scalar theme, info, etc.)
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * @Injectable()
124
+ * class OpenApiJsonController {
125
+ * private options = inject(OpenApiOptionsToken)
126
+ * }
127
+ * ```
128
+ */
129
+ declare const OpenApiOptionsToken: InjectionToken<BunOpenApiPluginOptions, undefined, false>;
130
+ //#endregion
131
+ //#region src/openapi-bun.plugin.d.mts
132
+ /**
133
+ * OpenAPI plugin for Bun adapter.
134
+ *
135
+ * This plugin:
136
+ * - Scans all registered modules for endpoints
137
+ * - Generates an OpenAPI 3.1 document
138
+ * - Injects controllers for JSON, YAML, and Scalar UI endpoints
139
+ *
140
+ * Unlike the Fastify plugin which registers routes directly,
141
+ * this plugin uses the standard Navios controller pattern via
142
+ * ModuleLoaderService.extendModules().
143
+ */
144
+ declare class OpenApiBunPlugin implements NaviosPlugin<BunOpenApiPluginOptions> {
145
+ readonly name = "openapi-bun";
146
+ register(context: PluginContext, options: BunOpenApiPluginOptions): Promise<void>;
147
+ /**
148
+ * Registers the plugin options in the DI container.
149
+ */
150
+ private registerOptions;
151
+ /**
152
+ * Registers and initializes the document service.
153
+ */
154
+ private initializeDocumentService;
155
+ /**
156
+ * Creates controller classes based on options.
157
+ */
158
+ private createControllers;
159
+ }
160
+ /**
161
+ * Creates a plugin definition for the OpenAPI Bun plugin.
162
+ *
163
+ * @param options - Plugin configuration options
164
+ * @returns Plugin definition to pass to `app.usePlugin()`
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * import { NaviosFactory } from '@navios/core'
169
+ * import { defineBunEnvironment } from '@navios/adapter-bun'
170
+ * import { defineOpenApiPlugin } from '@navios/openapi-bun'
171
+ *
172
+ * const app = await NaviosFactory.create(AppModule, {
173
+ * adapter: defineBunEnvironment(),
174
+ * })
175
+ *
176
+ * app.usePlugin(defineOpenApiPlugin({
177
+ * info: {
178
+ * title: 'My API',
179
+ * version: '1.0.0',
180
+ * description: 'API documentation',
181
+ * },
182
+ * servers: [
183
+ * { url: 'http://localhost:3000', description: 'Development' },
184
+ * ],
185
+ * scalar: {
186
+ * theme: 'purple',
187
+ * },
188
+ * }))
189
+ *
190
+ * await app.listen({ port: 3000 })
191
+ * // API docs available at http://localhost:3000/docs
192
+ * ```
193
+ */
194
+ declare function defineOpenApiPlugin(options: BunOpenApiPluginOptions): PluginDefinition<BunOpenApiPluginOptions>;
195
+ //#endregion
196
+ //#region src/services/openapi-document.service.d.mts
197
+ type OpenAPIObject = oas31.OpenAPIObject;
198
+ /**
199
+ * Injection token for the document service
200
+ */
201
+ declare const OpenApiDocumentServiceToken: InjectionToken<OpenApiDocumentService, undefined, false>;
202
+ /**
203
+ * Service that generates and caches the OpenAPI document.
204
+ *
205
+ * The document is generated once during plugin initialization
206
+ * and served by controllers.
207
+ */
208
+ declare class OpenApiDocumentService {
209
+ private options;
210
+ private generator;
211
+ private document;
212
+ private yamlDocument;
213
+ /**
214
+ * Initializes the document service by generating the OpenAPI document.
215
+ * Called by the plugin during registration.
216
+ *
217
+ * @param modules - All loaded modules with their metadata
218
+ * @param globalPrefix - Global route prefix (e.g., '/api/v1')
219
+ */
220
+ initialize(modules: Map<string, ModuleMetadata>, globalPrefix: string): void;
221
+ /**
222
+ * Returns the OpenAPI document as JSON-serializable object.
223
+ */
224
+ getDocument(): OpenAPIObject;
225
+ /**
226
+ * Returns the OpenAPI document as YAML string.
227
+ */
228
+ getYamlDocument(): string;
229
+ }
230
+ //#endregion
231
+ //#region src/controllers/openapi-json.controller.d.mts
232
+ /**
233
+ * Creates a customized JSON controller with the correct path.
234
+ * Called by the plugin to create a controller with the configured jsonPath.
235
+ *
236
+ * @param jsonPath - The path to serve the OpenAPI JSON (e.g., '/openapi.json')
237
+ * @returns A controller class that serves the OpenAPI document as JSON
238
+ */
239
+ declare function createOpenApiJsonController(jsonPath: string): ClassType;
240
+ //#endregion
241
+ //#region src/controllers/openapi-yaml.controller.d.mts
242
+ /**
243
+ * Creates a customized YAML controller with the correct path.
244
+ * Uses Stream endpoint to set content-type header properly.
245
+ *
246
+ * @param yamlPath - The path to serve the OpenAPI YAML (e.g., '/openapi.yaml')
247
+ * @returns A controller class that serves the OpenAPI document as YAML
248
+ */
249
+ declare function createOpenApiYamlController(yamlPath: string): ClassType;
250
+ //#endregion
251
+ //#region src/controllers/openapi-ui.controller.d.mts
252
+ /**
253
+ * Creates a customized Scalar UI controller with the correct path.
254
+ *
255
+ * @param docsPath - The path to serve the Scalar UI (e.g., '/docs')
256
+ * @param jsonPath - The path to the OpenAPI JSON spec (used by Scalar to load the spec)
257
+ * @returns A controller class that serves the Scalar API Reference UI
258
+ */
259
+ declare function createOpenApiUiController(docsPath: string, jsonPath: string): ClassType;
260
+ //#endregion
261
+ export { type BunOpenApiPluginOptions, type BunOpenApiPluginOptionsBase, OpenApiBunPlugin, OpenApiDocumentService, OpenApiDocumentServiceToken, OpenApiOptionsToken, type ScalarOptions, type ScalarTheme, bunOpenApiPluginOptionsSchema, createOpenApiJsonController, createOpenApiUiController, createOpenApiYamlController, defineOpenApiPlugin, scalarOptionsSchema, scalarThemeSchema };
262
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/schemas/openapi-bun-options.schema.mts","../src/tokens/openapi-options.token.mts","../src/openapi-bun.plugin.mts","../src/services/openapi-document.service.mts","../src/controllers/openapi-json.controller.mts","../src/controllers/openapi-yaml.controller.mts","../src/controllers/openapi-ui.controller.mts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAKa,mBAAiB,CAAA,CAAA;;;EAAjB,IAAA,EAAA,MAAA;EAkCA,MAAA,EAAA,QAAA;;;;;;;;;;;;;;;cAAA,qBAAmB,CAAA,CAAA;;;;;IAAA,MAAA,EAAA,QAAA;IAAA,SAAA,EAAA,WAAA;IAiDnB,UAAA,EAAA,YAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAA,+BAA6B,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;IAAA,UAAA,eAAA,aAAA,C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AkCa,iBMnBG,yBAAA,CN+Dd,QAAA,EAAA,MAAA,EAAA,QAAA,EAAA,MAAA,CAAA,EM5DC,SN4DD"}
@@ -0,0 +1,262 @@
1
+ import { InjectionToken, ModuleMetadata, NaviosPlugin, PluginContext, PluginDefinition } from "@navios/core";
2
+ import { OpenApiGeneratorOptions } from "@navios/openapi";
3
+ import { z } from "zod";
4
+ import { oas31 } from "zod-openapi";
5
+ import { ClassType } from "@navios/di";
6
+
7
+ //#region src/schemas/openapi-bun-options.schema.d.mts
8
+ /**
9
+ * Zod schema for Scalar UI theme options
10
+ */
11
+ declare const scalarThemeSchema: z.ZodEnum<{
12
+ default: "default";
13
+ alternate: "alternate";
14
+ moon: "moon";
15
+ purple: "purple";
16
+ solarized: "solarized";
17
+ bluePlanet: "bluePlanet";
18
+ saturn: "saturn";
19
+ kepler: "kepler";
20
+ mars: "mars";
21
+ deepSpace: "deepSpace";
22
+ laserwave: "laserwave";
23
+ elysiajs: "elysiajs";
24
+ fastify: "fastify";
25
+ none: "none";
26
+ }>;
27
+ /**
28
+ * Zod schema for Scalar UI configuration options
29
+ */
30
+ declare const scalarOptionsSchema: z.ZodObject<{
31
+ theme: z.ZodOptional<z.ZodEnum<{
32
+ default: "default";
33
+ alternate: "alternate";
34
+ moon: "moon";
35
+ purple: "purple";
36
+ solarized: "solarized";
37
+ bluePlanet: "bluePlanet";
38
+ saturn: "saturn";
39
+ kepler: "kepler";
40
+ mars: "mars";
41
+ deepSpace: "deepSpace";
42
+ laserwave: "laserwave";
43
+ elysiajs: "elysiajs";
44
+ fastify: "fastify";
45
+ none: "none";
46
+ }>>;
47
+ favicon: z.ZodOptional<z.ZodString>;
48
+ logo: z.ZodOptional<z.ZodString>;
49
+ hideDownloadButton: z.ZodOptional<z.ZodBoolean>;
50
+ hideSearch: z.ZodOptional<z.ZodBoolean>;
51
+ customCss: z.ZodOptional<z.ZodString>;
52
+ metaData: z.ZodOptional<z.ZodObject<{
53
+ title: z.ZodOptional<z.ZodString>;
54
+ description: z.ZodOptional<z.ZodString>;
55
+ ogDescription: z.ZodOptional<z.ZodString>;
56
+ ogTitle: z.ZodOptional<z.ZodString>;
57
+ ogImage: z.ZodOptional<z.ZodString>;
58
+ twitterCard: z.ZodOptional<z.ZodString>;
59
+ }, z.core.$strip>>;
60
+ cdn: z.ZodOptional<z.ZodString>;
61
+ }, z.core.$strip>;
62
+ /**
63
+ * Zod schema for Bun OpenAPI plugin options
64
+ */
65
+ declare const bunOpenApiPluginOptionsSchema: z.ZodObject<{
66
+ jsonPath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
67
+ yamlPath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
68
+ docsPath: z.ZodDefault<z.ZodOptional<z.ZodString>>;
69
+ scalar: z.ZodOptional<z.ZodObject<{
70
+ theme: z.ZodOptional<z.ZodEnum<{
71
+ default: "default";
72
+ alternate: "alternate";
73
+ moon: "moon";
74
+ purple: "purple";
75
+ solarized: "solarized";
76
+ bluePlanet: "bluePlanet";
77
+ saturn: "saturn";
78
+ kepler: "kepler";
79
+ mars: "mars";
80
+ deepSpace: "deepSpace";
81
+ laserwave: "laserwave";
82
+ elysiajs: "elysiajs";
83
+ fastify: "fastify";
84
+ none: "none";
85
+ }>>;
86
+ favicon: z.ZodOptional<z.ZodString>;
87
+ logo: z.ZodOptional<z.ZodString>;
88
+ hideDownloadButton: z.ZodOptional<z.ZodBoolean>;
89
+ hideSearch: z.ZodOptional<z.ZodBoolean>;
90
+ customCss: z.ZodOptional<z.ZodString>;
91
+ metaData: z.ZodOptional<z.ZodObject<{
92
+ title: z.ZodOptional<z.ZodString>;
93
+ description: z.ZodOptional<z.ZodString>;
94
+ ogDescription: z.ZodOptional<z.ZodString>;
95
+ ogTitle: z.ZodOptional<z.ZodString>;
96
+ ogImage: z.ZodOptional<z.ZodString>;
97
+ twitterCard: z.ZodOptional<z.ZodString>;
98
+ }, z.core.$strip>>;
99
+ cdn: z.ZodOptional<z.ZodString>;
100
+ }, z.core.$strip>>;
101
+ disableJson: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
102
+ disableScalar: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
103
+ disableYaml: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
104
+ }, z.core.$strip>;
105
+ type ScalarTheme = z.infer<typeof scalarThemeSchema>;
106
+ type ScalarOptions = z.infer<typeof scalarOptionsSchema>;
107
+ type BunOpenApiPluginOptionsBase = z.infer<typeof bunOpenApiPluginOptionsSchema>;
108
+ //#endregion
109
+ //#region src/tokens/openapi-options.token.d.mts
110
+ /**
111
+ * Combined options for the Bun OpenAPI plugin.
112
+ * Extends OpenApiGeneratorOptions with Bun-specific settings.
113
+ */
114
+ interface BunOpenApiPluginOptions extends OpenApiGeneratorOptions, Partial<BunOpenApiPluginOptionsBase> {}
115
+ /**
116
+ * Injection token for OpenAPI plugin options.
117
+ *
118
+ * Controllers inject this to access the plugin configuration
119
+ * (paths, Scalar theme, info, etc.)
120
+ *
121
+ * @example
122
+ * ```typescript
123
+ * @Injectable()
124
+ * class OpenApiJsonController {
125
+ * private options = inject(OpenApiOptionsToken)
126
+ * }
127
+ * ```
128
+ */
129
+ declare const OpenApiOptionsToken: InjectionToken<BunOpenApiPluginOptions, undefined, false>;
130
+ //#endregion
131
+ //#region src/openapi-bun.plugin.d.mts
132
+ /**
133
+ * OpenAPI plugin for Bun adapter.
134
+ *
135
+ * This plugin:
136
+ * - Scans all registered modules for endpoints
137
+ * - Generates an OpenAPI 3.1 document
138
+ * - Injects controllers for JSON, YAML, and Scalar UI endpoints
139
+ *
140
+ * Unlike the Fastify plugin which registers routes directly,
141
+ * this plugin uses the standard Navios controller pattern via
142
+ * ModuleLoaderService.extendModules().
143
+ */
144
+ declare class OpenApiBunPlugin implements NaviosPlugin<BunOpenApiPluginOptions> {
145
+ readonly name = "openapi-bun";
146
+ register(context: PluginContext, options: BunOpenApiPluginOptions): Promise<void>;
147
+ /**
148
+ * Registers the plugin options in the DI container.
149
+ */
150
+ private registerOptions;
151
+ /**
152
+ * Registers and initializes the document service.
153
+ */
154
+ private initializeDocumentService;
155
+ /**
156
+ * Creates controller classes based on options.
157
+ */
158
+ private createControllers;
159
+ }
160
+ /**
161
+ * Creates a plugin definition for the OpenAPI Bun plugin.
162
+ *
163
+ * @param options - Plugin configuration options
164
+ * @returns Plugin definition to pass to `app.usePlugin()`
165
+ *
166
+ * @example
167
+ * ```typescript
168
+ * import { NaviosFactory } from '@navios/core'
169
+ * import { defineBunEnvironment } from '@navios/adapter-bun'
170
+ * import { defineOpenApiPlugin } from '@navios/openapi-bun'
171
+ *
172
+ * const app = await NaviosFactory.create(AppModule, {
173
+ * adapter: defineBunEnvironment(),
174
+ * })
175
+ *
176
+ * app.usePlugin(defineOpenApiPlugin({
177
+ * info: {
178
+ * title: 'My API',
179
+ * version: '1.0.0',
180
+ * description: 'API documentation',
181
+ * },
182
+ * servers: [
183
+ * { url: 'http://localhost:3000', description: 'Development' },
184
+ * ],
185
+ * scalar: {
186
+ * theme: 'purple',
187
+ * },
188
+ * }))
189
+ *
190
+ * await app.listen({ port: 3000 })
191
+ * // API docs available at http://localhost:3000/docs
192
+ * ```
193
+ */
194
+ declare function defineOpenApiPlugin(options: BunOpenApiPluginOptions): PluginDefinition<BunOpenApiPluginOptions>;
195
+ //#endregion
196
+ //#region src/services/openapi-document.service.d.mts
197
+ type OpenAPIObject = oas31.OpenAPIObject;
198
+ /**
199
+ * Injection token for the document service
200
+ */
201
+ declare const OpenApiDocumentServiceToken: InjectionToken<OpenApiDocumentService, undefined, false>;
202
+ /**
203
+ * Service that generates and caches the OpenAPI document.
204
+ *
205
+ * The document is generated once during plugin initialization
206
+ * and served by controllers.
207
+ */
208
+ declare class OpenApiDocumentService {
209
+ private options;
210
+ private generator;
211
+ private document;
212
+ private yamlDocument;
213
+ /**
214
+ * Initializes the document service by generating the OpenAPI document.
215
+ * Called by the plugin during registration.
216
+ *
217
+ * @param modules - All loaded modules with their metadata
218
+ * @param globalPrefix - Global route prefix (e.g., '/api/v1')
219
+ */
220
+ initialize(modules: Map<string, ModuleMetadata>, globalPrefix: string): void;
221
+ /**
222
+ * Returns the OpenAPI document as JSON-serializable object.
223
+ */
224
+ getDocument(): OpenAPIObject;
225
+ /**
226
+ * Returns the OpenAPI document as YAML string.
227
+ */
228
+ getYamlDocument(): string;
229
+ }
230
+ //#endregion
231
+ //#region src/controllers/openapi-json.controller.d.mts
232
+ /**
233
+ * Creates a customized JSON controller with the correct path.
234
+ * Called by the plugin to create a controller with the configured jsonPath.
235
+ *
236
+ * @param jsonPath - The path to serve the OpenAPI JSON (e.g., '/openapi.json')
237
+ * @returns A controller class that serves the OpenAPI document as JSON
238
+ */
239
+ declare function createOpenApiJsonController(jsonPath: string): ClassType;
240
+ //#endregion
241
+ //#region src/controllers/openapi-yaml.controller.d.mts
242
+ /**
243
+ * Creates a customized YAML controller with the correct path.
244
+ * Uses Stream endpoint to set content-type header properly.
245
+ *
246
+ * @param yamlPath - The path to serve the OpenAPI YAML (e.g., '/openapi.yaml')
247
+ * @returns A controller class that serves the OpenAPI document as YAML
248
+ */
249
+ declare function createOpenApiYamlController(yamlPath: string): ClassType;
250
+ //#endregion
251
+ //#region src/controllers/openapi-ui.controller.d.mts
252
+ /**
253
+ * Creates a customized Scalar UI controller with the correct path.
254
+ *
255
+ * @param docsPath - The path to serve the Scalar UI (e.g., '/docs')
256
+ * @param jsonPath - The path to the OpenAPI JSON spec (used by Scalar to load the spec)
257
+ * @returns A controller class that serves the Scalar API Reference UI
258
+ */
259
+ declare function createOpenApiUiController(docsPath: string, jsonPath: string): ClassType;
260
+ //#endregion
261
+ export { type BunOpenApiPluginOptions, type BunOpenApiPluginOptionsBase, OpenApiBunPlugin, OpenApiDocumentService, OpenApiDocumentServiceToken, OpenApiOptionsToken, type ScalarOptions, type ScalarTheme, bunOpenApiPluginOptionsSchema, createOpenApiJsonController, createOpenApiUiController, createOpenApiYamlController, defineOpenApiPlugin, scalarOptionsSchema, scalarThemeSchema };
262
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/schemas/openapi-bun-options.schema.mts","../src/tokens/openapi-options.token.mts","../src/openapi-bun.plugin.mts","../src/services/openapi-document.service.mts","../src/controllers/openapi-json.controller.mts","../src/controllers/openapi-yaml.controller.mts","../src/controllers/openapi-ui.controller.mts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAKa,mBAAiB,CAAA,CAAA;;;EAAjB,IAAA,EAAA,MAAA;EAkCA,MAAA,EAAA,QAAA;;;;;;;;;;;;;;;cAAA,qBAAmB,CAAA,CAAA;;;;;IAAA,MAAA,EAAA,QAAA;IAAA,SAAA,EAAA,WAAA;IAiDnB,UAAA,EAAA,YAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAA,+BAA6B,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;IAAA,UAAA,eAAA,aAAA,CAAA;IAAA,SAAA,eAAA,YAAA,CAAA;IA2C9B,QAAA,eAA6B,YAAA,CAAA;MAE7B,KAAA,eAA+B,YAAA,CAAA;MAC/B,WAAA,eAA2B,YAAkB,CAAA;;;;MC5HxC,WAAA,eACf,YAAA,CAAA;IAAyC,CAAA,eAAA,CAAA,CAAA;IAAjC,GAAA,eAAA,YAAA,CAAA;EAAyB,CAAA,eAAA,CAAA,CAAA;EAAO,WAAA,cAAA,cAAA,aAAA,CAAA,CAAA;EAgB7B,aAAA,cAGV,cAH6B,aAAA,CAAA,CAAA;;;KDwGpB,WAAA,GAAc,CAAA,CAAE,aAAa;AEpGa,KFsG1C,aAAA,GAAgB,CAAA,CAAE,KEtGwB,CAAA,OFsGX,mBEtGW,CAAA;AAIzC,KFmGD,2BAAA,GAA8B,CAAA,CAAE,KEnG/B,CAAA,OFmG4C,6BEnG5C,CAAA;;;;;;;AF9BA,UCKI,uBAAA,SACP,uBDNoB,ECMK,ODNL,CCMa,2BDNb,CAAA,CAAA,CAkC9B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