@navios/adapter-xml 0.1.0 → 0.7.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 (101) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +2 -1
  3. package/bun-plugin.mts +5 -3
  4. package/bunPlugin.cache +1 -1
  5. package/dist/bun-plugin.d.mts.map +1 -1
  6. package/dist/src/adapters/xml-stream-adapter.service.d.mts +63 -8
  7. package/dist/src/adapters/xml-stream-adapter.service.d.mts.map +1 -1
  8. package/dist/src/decorators/component.decorator.d.mts +68 -2
  9. package/dist/src/decorators/component.decorator.d.mts.map +1 -1
  10. package/dist/src/decorators/xml-stream.decorator.d.mts +58 -3
  11. package/dist/src/decorators/xml-stream.decorator.d.mts.map +1 -1
  12. package/dist/src/define-environment.d.mts +2 -2
  13. package/dist/src/define-environment.d.mts.map +1 -1
  14. package/dist/src/handlers/xml-stream.d.mts +25 -3
  15. package/dist/src/handlers/xml-stream.d.mts.map +1 -1
  16. package/dist/src/runtime/render-to-xml.d.mts +70 -2
  17. package/dist/src/runtime/render-to-xml.d.mts.map +1 -1
  18. package/dist/src/tags/define-tag.d.mts +8 -0
  19. package/dist/src/tags/define-tag.d.mts.map +1 -1
  20. package/dist/src/types/component.d.mts +46 -2
  21. package/dist/src/types/component.d.mts.map +1 -1
  22. package/dist/src/types/config.d.mts +22 -0
  23. package/dist/src/types/config.d.mts.map +1 -1
  24. package/dist/tsconfig.lib.tsbuildinfo +1 -1
  25. package/dist/tsconfig.spec.tsbuildinfo +1 -1
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/dist/tsdown.config.d.mts +3 -0
  28. package/dist/tsdown.config.d.mts.map +1 -0
  29. package/dist/vitest.e2e.fastify.config.d.mts.map +1 -1
  30. package/lib/create-element--Gd2L8UR.d.cts +26 -0
  31. package/lib/create-element--Gd2L8UR.d.cts.map +1 -0
  32. package/lib/create-element-61MP7_99.d.mts +26 -0
  33. package/lib/create-element-61MP7_99.d.mts.map +1 -0
  34. package/lib/create-element-DiOt_-Vs.cjs +183 -0
  35. package/lib/create-element-DiOt_-Vs.cjs.map +1 -0
  36. package/lib/create-element-NZEYaRw5.mjs +124 -0
  37. package/lib/create-element-NZEYaRw5.mjs.map +1 -0
  38. package/lib/index.cjs +746 -0
  39. package/lib/index.cjs.map +1 -0
  40. package/lib/index.d.cts +520 -0
  41. package/lib/index.d.cts.map +1 -0
  42. package/lib/index.d.mts +520 -29
  43. package/lib/index.d.mts.map +1 -0
  44. package/lib/index.mjs +692 -223
  45. package/lib/index.mjs.map +1 -1
  46. package/lib/jsx-dev-runtime.cjs +11 -0
  47. package/lib/jsx-dev-runtime.cjs.map +1 -0
  48. package/lib/jsx-dev-runtime.d.cts +8 -0
  49. package/lib/jsx-dev-runtime.d.cts.map +1 -0
  50. package/lib/jsx-dev-runtime.d.mts +8 -4
  51. package/lib/jsx-dev-runtime.d.mts.map +1 -0
  52. package/lib/jsx-dev-runtime.mjs +5 -6
  53. package/lib/jsx-dev-runtime.mjs.map +1 -1
  54. package/lib/jsx-runtime.cjs +5 -0
  55. package/lib/jsx-runtime.d.cts +3 -0
  56. package/lib/jsx-runtime.d.mts +3 -3
  57. package/lib/jsx-runtime.mjs +3 -3
  58. package/lib/jsx.cjs +0 -0
  59. package/lib/jsx.d.cts +19 -0
  60. package/lib/jsx.d.cts.map +1 -0
  61. package/lib/jsx.d.mts +19 -1
  62. package/lib/jsx.d.mts.map +1 -0
  63. package/lib/jsx.mjs +1 -3
  64. package/lib/xml-node-BQA44ydQ.d.mts +96 -0
  65. package/lib/xml-node-BQA44ydQ.d.mts.map +1 -0
  66. package/lib/xml-node-CddziLym.d.cts +96 -0
  67. package/lib/xml-node-CddziLym.d.cts.map +1 -0
  68. package/package.json +20 -20
  69. package/project.json +2 -2
  70. package/src/adapters/xml-stream-adapter.service.mts +77 -16
  71. package/src/decorators/component.decorator.mts +72 -10
  72. package/src/decorators/component.decorator.spec.mts +40 -22
  73. package/src/decorators/xml-stream.decorator.mts +58 -3
  74. package/src/define-environment.mts +5 -6
  75. package/src/handlers/xml-stream.mts +25 -3
  76. package/src/runtime/render-to-xml.mts +72 -4
  77. package/src/tags/define-tag.mts +8 -0
  78. package/src/types/component.mts +46 -2
  79. package/src/types/config.mts +22 -0
  80. package/tsdown.config.mts +39 -0
  81. package/dist/tsup.config.d.mts +0 -3
  82. package/dist/tsup.config.d.mts.map +0 -1
  83. package/lib/_tsup-dts-rollup.d.mts +0 -414
  84. package/lib/_tsup-dts-rollup.d.ts +0 -414
  85. package/lib/chunk-6OR6LGJA.mjs +0 -153
  86. package/lib/chunk-6OR6LGJA.mjs.map +0 -1
  87. package/lib/index.d.ts +0 -29
  88. package/lib/index.js +0 -376
  89. package/lib/index.js.map +0 -1
  90. package/lib/jsx-dev-runtime.d.ts +0 -4
  91. package/lib/jsx-dev-runtime.js +0 -61
  92. package/lib/jsx-dev-runtime.js.map +0 -1
  93. package/lib/jsx-runtime.d.ts +0 -3
  94. package/lib/jsx-runtime.js +0 -57
  95. package/lib/jsx-runtime.js.map +0 -1
  96. package/lib/jsx-runtime.mjs.map +0 -1
  97. package/lib/jsx.d.ts +0 -1
  98. package/lib/jsx.js +0 -4
  99. package/lib/jsx.js.map +0 -1
  100. package/lib/jsx.mjs.map +0 -1
  101. package/tsup.config.mts +0 -18
package/lib/index.d.mts CHANGED
@@ -1,29 +1,520 @@
1
- export { XmlNode } from './_tsup-dts-rollup.mjs';
2
- export { AsyncXmlNode } from './_tsup-dts-rollup.mjs';
3
- export { CDataNode } from './_tsup-dts-rollup.mjs';
4
- export { RawXmlNode } from './_tsup-dts-rollup.mjs';
5
- export { ClassComponentNode } from './_tsup-dts-rollup.mjs';
6
- export { AnyXmlNode } from './_tsup-dts-rollup.mjs';
7
- export { BaseXmlStreamConfig } from './_tsup-dts-rollup.mjs';
8
- export { XmlComponent } from './_tsup-dts-rollup.mjs';
9
- export { ComponentClass } from './_tsup-dts-rollup.mjs';
10
- export { Fragment } from './_tsup-dts-rollup.mjs';
11
- export { AsyncComponent } from './_tsup-dts-rollup.mjs';
12
- export { CDataSymbol } from './_tsup-dts-rollup.mjs';
13
- export { RawXmlSymbol } from './_tsup-dts-rollup.mjs';
14
- export { ClassComponent } from './_tsup-dts-rollup.mjs';
15
- export { createElement } from './_tsup-dts-rollup.mjs';
16
- export { CData } from './_tsup-dts-rollup.mjs';
17
- export { DangerouslyInsertRawXml } from './_tsup-dts-rollup.mjs';
18
- export { renderToXml } from './_tsup-dts-rollup.mjs';
19
- export { MissingContainerError } from './_tsup-dts-rollup.mjs';
20
- export { RenderOptions } from './_tsup-dts-rollup.mjs';
21
- export { defineTag } from './_tsup-dts-rollup.mjs';
22
- export { TagComponent } from './_tsup-dts-rollup.mjs';
23
- export { XmlStream } from './_tsup-dts-rollup.mjs';
24
- export { Component } from './_tsup-dts-rollup.mjs';
25
- export { isComponentClass } from './_tsup-dts-rollup.mjs';
26
- export { XmlStreamParams } from './_tsup-dts-rollup.mjs';
27
- export { declareXmlStream } from './_tsup-dts-rollup.mjs';
28
- export { XmlStreamAdapterService } from './_tsup-dts-rollup.mjs';
29
- export { defineXmlEnvironment_alias_1 as defineXmlEnvironment } from './_tsup-dts-rollup.mjs';
1
+ import { a as CDataSymbol, c as Fragment, d as XmlNode, f as ComponentClass, i as CDataNode, l as RawXmlNode, n as AsyncComponent, o as ClassComponent, p as XmlComponent, r as AsyncXmlNode, s as ClassComponentNode, t as AnyXmlNode, u as RawXmlSymbol } from "./xml-node-BQA44ydQ.mjs";
2
+ import { t as createElement } from "./create-element-61MP7_99.mjs";
3
+ import { AbstractHttpHandlerAdapterInterface, AnyInjectableType, ClassType, Container, HandlerMetadata, InjectionToken, Registry, ScopedContainer } from "@navios/core";
4
+ import { BaseStreamConfig, EndpointFunctionArgs, HttpMethod, Util_FlatObject } from "@navios/builder";
5
+ import { ZodObject, ZodRawShape, ZodType, z } from "zod/v4";
6
+
7
+ //#region src/types/config.d.mts
8
+
9
+ /**
10
+ * Configuration interface for XML Stream endpoints.
11
+ *
12
+ * Extends the base stream configuration with XML-specific options including
13
+ * content type, XML declaration, and encoding settings.
14
+ *
15
+ * @template Method - The HTTP method (GET, POST, etc.).
16
+ * @template Url - The URL path pattern (supports parameters like `/posts/:id`).
17
+ * @template QuerySchema - Optional Zod schema for query parameter validation.
18
+ * @template RequestSchema - Optional Zod schema for request body validation.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const config: BaseXmlStreamConfig = {
23
+ * method: 'GET',
24
+ * url: '/feed.xml',
25
+ * contentType: 'application/rss+xml',
26
+ * xmlDeclaration: true,
27
+ * encoding: 'UTF-8',
28
+ * }
29
+ * ```
30
+ */
31
+ interface BaseXmlStreamConfig<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, RequestSchema = undefined> extends BaseStreamConfig<Method, Url, QuerySchema, RequestSchema> {
32
+ /** Content-Type header, defaults to 'application/xml' */
33
+ contentType?: 'application/xml' | 'text/xml' | 'application/rss+xml' | 'application/atom+xml';
34
+ /** Include XML declaration (<?xml version="1.0"?>) - defaults to true */
35
+ xmlDeclaration?: boolean;
36
+ /** XML encoding, defaults to 'UTF-8' */
37
+ encoding?: string;
38
+ }
39
+ //#endregion
40
+ //#region src/runtime/special-nodes.d.mts
41
+ /**
42
+ * CDATA component - wraps content in <![CDATA[...]]>
43
+ * Use for text content that may contain characters like < > &
44
+ * that would otherwise need escaping.
45
+ *
46
+ * Note: If content contains "]]>", it will be split into multiple CDATA sections.
47
+ */
48
+ declare function CData({
49
+ children
50
+ }: {
51
+ children: string;
52
+ }): CDataNode;
53
+ /**
54
+ * DangerouslyInsertRawXml - inserts raw XML/HTML without any escaping or wrapping
55
+ *
56
+ * WARNING: This bypasses all XML escaping. Only use with trusted content!
57
+ * Use cases:
58
+ * - Pre-rendered XML fragments
59
+ * - HTML content in RSS/Atom feeds (in description/content:encoded)
60
+ * - Including XML from external sources that's already valid
61
+ */
62
+ declare function DangerouslyInsertRawXml({
63
+ children
64
+ }: {
65
+ children: string;
66
+ }): RawXmlNode;
67
+ //#endregion
68
+ //#region src/runtime/render-to-xml.d.mts
69
+ /**
70
+ * Options for rendering XML from JSX nodes.
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * const xml = await renderToXml(<rss version="2.0">...</rss>, {
75
+ * declaration: true,
76
+ * encoding: 'UTF-8',
77
+ * pretty: true,
78
+ * container: myContainer, // Required for class components
79
+ * })
80
+ * ```
81
+ */
82
+ interface RenderOptions {
83
+ /** Include XML declaration (<?xml version="1.0"?>) - defaults to true */
84
+ declaration?: boolean;
85
+ /** XML encoding, defaults to 'UTF-8' */
86
+ encoding?: string;
87
+ /** Pretty print with indentation */
88
+ pretty?: boolean;
89
+ /**
90
+ * DI container for resolving class components.
91
+ * Required if the tree contains any class components.
92
+ */
93
+ container?: Container | ScopedContainer;
94
+ }
95
+ /**
96
+ * Error thrown when attempting to render a class component without a container.
97
+ *
98
+ * Class components require a dependency injection container to be instantiated.
99
+ * This error is thrown when `renderToXml` is called with a class component in
100
+ * the tree but no container is provided in the options.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * try {
105
+ * await renderToXml(<MyClassComponent />)
106
+ * } catch (error) {
107
+ * if (error instanceof MissingContainerError) {
108
+ * // Provide a container
109
+ * await renderToXml(<MyClassComponent />, { container })
110
+ * }
111
+ * }
112
+ * ```
113
+ */
114
+ declare class MissingContainerError extends Error {
115
+ constructor(componentName: string);
116
+ }
117
+ /**
118
+ * Renders a JSX XML node tree to an XML string.
119
+ *
120
+ * This function handles:
121
+ * - Regular XML nodes (tags with props and children)
122
+ * - Async components (resolves promises in parallel)
123
+ * - Class components (resolves via DI container)
124
+ * - CDATA sections
125
+ * - Raw XML content
126
+ * - Fragments
127
+ * - Text content with proper escaping
128
+ *
129
+ * @param node - The root XML node (JSX element) to render.
130
+ * @param options - Rendering options including declaration, encoding, pretty printing, and container.
131
+ * @returns A promise that resolves to the XML string.
132
+ *
133
+ * @throws {MissingContainerError} If the tree contains class components but no container is provided.
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * // Simple rendering
138
+ * const xml = await renderToXml(<rss version="2.0"><channel>...</channel></rss>)
139
+ *
140
+ * // With options
141
+ * const xml = await renderToXml(<feed>...</feed>, {
142
+ * declaration: true,
143
+ * encoding: 'UTF-8',
144
+ * pretty: true,
145
+ * })
146
+ *
147
+ * // With class components (requires container)
148
+ * const container = new Container()
149
+ * container.beginRequest('request-id')
150
+ * const xml = await renderToXml(<MyClassComponent />, { container })
151
+ * ```
152
+ */
153
+ declare function renderToXml(node: AnyXmlNode, options?: RenderOptions): Promise<string>;
154
+ //#endregion
155
+ //#region src/tags/define-tag.d.mts
156
+ /**
157
+ * Type for XML tag components created by `defineTag`.
158
+ *
159
+ * Tag components are functions that accept props and children, and return
160
+ * an XML node. They also have a `tagName` property for identification.
161
+ *
162
+ * @template Props - The props type for the tag component.
163
+ */
164
+ interface TagComponent<Props extends Record<string, unknown>> {
165
+ (props: Props & {
166
+ children?: AnyXmlNode | AnyXmlNode[];
167
+ }): XmlNode;
168
+ tagName: string;
169
+ }
170
+ /**
171
+ * Creates a type-safe XML tag component with optional Zod schema validation.
172
+ *
173
+ * @param name - The tag name (supports namespace prefixes like 'atom:link')
174
+ * @param propsSchema - Optional Zod schema for validating props
175
+ * @returns A component function that can be used in JSX
176
+ *
177
+ * @example
178
+ * ```tsx
179
+ * // Simple tag
180
+ * const item = defineTag('item')
181
+ * <item>Content</item>
182
+ *
183
+ * // Namespaced tag with Zod validation
184
+ * const atomLink = defineTag('atom:link', z.object({
185
+ * href: z.string().url(),
186
+ * rel: z.enum(['self', 'alternate']),
187
+ * type: z.string().optional(),
188
+ * }))
189
+ * <atomLink href="https://example.com/feed" rel="self" />
190
+ * ```
191
+ */
192
+ declare function defineTag<T extends ZodRawShape>(name: string, propsSchema?: ZodObject<T>): TagComponent<T extends ZodRawShape ? z.infer<ZodObject<T>> : Record<string, never>>;
193
+ //#endregion
194
+ //#region src/decorators/xml-stream.decorator.d.mts
195
+ /**
196
+ * Type helper that extracts the parameter types for an XML Stream endpoint handler.
197
+ *
198
+ * This type automatically infers the correct parameter types based on the endpoint
199
+ * configuration, including URL parameters, query parameters, and request body.
200
+ *
201
+ * @template EndpointDeclaration - The endpoint declaration type from `declareXmlStream`.
202
+ * @template Url - The URL path pattern.
203
+ * @template QuerySchema - The query parameter schema type.
204
+ *
205
+ * @example
206
+ * ```typescript
207
+ * const getFeed = declareXmlStream({
208
+ * method: 'GET',
209
+ * url: '/feed/:category',
210
+ * querySchema: z.object({ page: z.string() }),
211
+ * })
212
+ *
213
+ * // XmlStreamParams<typeof getFeed> resolves to:
214
+ * // { urlParams: { category: string }, query: { page: string } }
215
+ * ```
216
+ */
217
+ type XmlStreamParams<EndpointDeclaration extends {
218
+ config: BaseXmlStreamConfig<any, any, any, any>;
219
+ }, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends ZodObject ? EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>> : EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>;
220
+ /**
221
+ * Decorator for XML Stream endpoints that return JSX-based XML responses.
222
+ *
223
+ * This decorator marks controller methods that return JSX elements, which will be
224
+ * automatically rendered to XML and sent with the appropriate Content-Type header.
225
+ * The method can be async and can contain async components, class components, and
226
+ * regular JSX elements.
227
+ *
228
+ * @template Method - The HTTP method (GET, POST, etc.).
229
+ * @template Url - The URL path pattern (supports parameters like `/posts/:id`).
230
+ * @template QuerySchema - Optional Zod schema for query parameter validation.
231
+ * @template RequestSchema - Optional Zod schema for request body validation.
232
+ *
233
+ * @param endpoint - The endpoint declaration created with `declareXmlStream`.
234
+ * @returns A method decorator function.
235
+ *
236
+ * @throws {Error} If used on a non-function or non-method.
237
+ * @throws {Error} If the endpoint URL already exists.
238
+ *
239
+ * @example
240
+ * ```typescript
241
+ * import { XmlStream, declareXmlStream } from '@navios/adapter-xml'
242
+ * import { Controller } from '@navios/core'
243
+ *
244
+ * const getRssFeed = declareXmlStream({
245
+ * method: 'GET',
246
+ * url: '/feed.xml',
247
+ * contentType: 'application/rss+xml',
248
+ * })
249
+ *
250
+ * @Controller('/api')
251
+ * class FeedController {
252
+ * @XmlStream(getRssFeed)
253
+ * async getFeed() {
254
+ * return (
255
+ * <rss version="2.0">
256
+ * <channel>
257
+ * <title>My Feed</title>
258
+ * </channel>
259
+ * </rss>
260
+ * )
261
+ * }
262
+ * }
263
+ * ```
264
+ *
265
+ * @example
266
+ * ```typescript
267
+ * // With query parameters
268
+ * const getSitemap = declareXmlStream({
269
+ * method: 'GET',
270
+ * url: '/sitemap.xml',
271
+ * querySchema: z.object({ page: z.string().optional() }),
272
+ * })
273
+ *
274
+ * @Controller()
275
+ * class SitemapController {
276
+ * @XmlStream(getSitemap)
277
+ * async getSitemap(params: { query?: { page?: string } }) {
278
+ * const page = params.query?.page
279
+ * return <urlset>...</urlset>
280
+ * }
281
+ * }
282
+ * ```
283
+ */
284
+ declare function XmlStream<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, RequestSchema = ZodType>(endpoint: {
285
+ config: BaseXmlStreamConfig<Method, Url, QuerySchema, RequestSchema>;
286
+ }): (target: (params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, RequestSchema, true>> : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>> : RequestSchema extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, RequestSchema, true>> : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>) => Promise<any>,
287
+ // Returns XmlNode
288
+ context: ClassMethodDecoratorContext) => (params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, RequestSchema, true>> : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>> : RequestSchema extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, RequestSchema, true>> : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>) => Promise<any>;
289
+ //#endregion
290
+ //#region src/decorators/component.decorator.d.mts
291
+ /**
292
+ * Decorator for class-based XML components with dependency injection support.
293
+ *
294
+ * Class components must implement the `XmlComponent` interface with a `render()` method.
295
+ * They can optionally accept props via constructor, validated with a Zod schema.
296
+ *
297
+ * @overload
298
+ * Component without props (no schema).
299
+ *
300
+ * @example
301
+ * ```tsx
302
+ * @Component()
303
+ * class LatestPostsComponent implements XmlComponent {
304
+ * private readonly postService = inject(PostService)
305
+ *
306
+ * async render() {
307
+ * const posts = await this.postService.getLatestPosts()
308
+ * return <>{posts.map(post => <item>...</item>)}</>
309
+ * }
310
+ * }
311
+ * ```
312
+ *
313
+ * @overload
314
+ * Component with props schema for type-safe props.
315
+ *
316
+ * @param options - Configuration object with schema and optional registry.
317
+ * @param options.schema - Zod schema for validating and typing component props.
318
+ * @param options.registry - Optional custom DI registry (defaults to global registry).
319
+ *
320
+ * @example
321
+ * ```tsx
322
+ * const DescriptionSchema = z.object({
323
+ * content: z.string(),
324
+ * wrapInCData: z.boolean().optional(),
325
+ * })
326
+ *
327
+ * @Component({ schema: DescriptionSchema })
328
+ * class DescriptionComponent implements XmlComponent {
329
+ * constructor(private props: z.output<typeof DescriptionSchema>) {}
330
+ *
331
+ * async render() {
332
+ * return <description>{this.props.wrapInCData ? <CData>{this.props.content}</CData> : this.props.content}</description>
333
+ * }
334
+ * }
335
+ * ```
336
+ *
337
+ * @overload
338
+ * Component with custom registry only (no props).
339
+ *
340
+ * @param options - Configuration object with registry.
341
+ * @param options.registry - Custom DI registry to use for this component.
342
+ */
343
+ declare function Component(): <T extends ComponentClass>(target: T, context?: ClassDecoratorContext) => T;
344
+ declare function Component<Schema extends ZodObject<ZodRawShape>>(options: {
345
+ schema: Schema;
346
+ registry?: Registry;
347
+ }): <T extends new (props: z.output<Schema>, ...args: any[]) => XmlComponent>(target: T, context?: ClassDecoratorContext) => T;
348
+ declare function Component(options: {
349
+ registry: Registry;
350
+ }): <T extends ComponentClass>(target: T, context?: ClassDecoratorContext) => T;
351
+ /**
352
+ * Type guard to check if a value is a component class.
353
+ *
354
+ * Component classes are classes decorated with `@Component` that implement
355
+ * the `XmlComponent` interface.
356
+ *
357
+ * @param value - The value to check.
358
+ * @returns `true` if the value is a component class, `false` otherwise.
359
+ *
360
+ * @example
361
+ * ```ts
362
+ * if (isComponentClass(MyClass)) {
363
+ * // MyClass is a component class
364
+ * const instance = await container.get(MyClass)
365
+ * }
366
+ * ```
367
+ */
368
+ declare function isComponentClass(value: unknown): value is ComponentClass;
369
+ //#endregion
370
+ //#region src/handlers/xml-stream.d.mts
371
+ /**
372
+ * Declares an XML Stream endpoint configuration for use with `@XmlStream` decorator.
373
+ *
374
+ * This function creates an endpoint declaration that can be used with the `@XmlStream`
375
+ * decorator to mark controller methods that return JSX-based XML responses.
376
+ *
377
+ * @template Method - The HTTP method (GET, POST, etc.).
378
+ * @template Url - The URL path pattern (supports parameters like `/posts/:id`).
379
+ * @template QuerySchema - Optional Zod schema for query parameter validation.
380
+ * @template RequestSchema - Optional Zod schema for request body validation.
381
+ *
382
+ * @param config - The endpoint configuration including method, URL, schemas, and XML options.
383
+ * @returns An endpoint declaration object to be used with `@XmlStream` decorator.
384
+ *
385
+ * @example
386
+ * ```typescript
387
+ * import { declareXmlStream } from '@navios/adapter-xml'
388
+ * import { z } from 'zod/v4'
389
+ *
390
+ * // Simple endpoint
391
+ * export const getRssFeed = declareXmlStream({
392
+ * method: 'GET',
393
+ * url: '/feed.xml',
394
+ * contentType: 'application/rss+xml',
395
+ * })
396
+ *
397
+ * // With query parameters
398
+ * export const getSitemap = declareXmlStream({
399
+ * method: 'GET',
400
+ * url: '/sitemap.xml',
401
+ * querySchema: z.object({
402
+ * page: z.string().optional(),
403
+ * }),
404
+ * contentType: 'application/xml',
405
+ * xmlDeclaration: true,
406
+ * encoding: 'UTF-8',
407
+ * })
408
+ * ```
409
+ */
410
+ declare function declareXmlStream<Method extends HttpMethod, Url extends string, QuerySchema = undefined, RequestSchema = undefined>(config: BaseXmlStreamConfig<Method, Url, QuerySchema, RequestSchema>): {
411
+ config: BaseXmlStreamConfig<Method, Url, QuerySchema, RequestSchema>;
412
+ };
413
+ //#endregion
414
+ //#region src/adapters/xml-stream-adapter.service.d.mts
415
+ /**
416
+ * Adapter service for handling XML Stream endpoints in Navios.
417
+ *
418
+ * This service integrates with the base stream adapter (Fastify or Bun) to handle
419
+ * XML endpoints that return JSX-based XML responses. It automatically renders JSX
420
+ * nodes to XML strings and sends them with the appropriate Content-Type headers.
421
+ *
422
+ * The service supports:
423
+ * - Async components (resolved in parallel)
424
+ * - Class components (resolved via DI container)
425
+ * - Regular JSX elements
426
+ * - CDATA sections
427
+ * - Raw XML content
428
+ *
429
+ * @implements {AbstractHttpHandlerAdapterInterface}
430
+ *
431
+ * @example
432
+ * ```ts
433
+ * // This service is automatically registered when using defineXmlEnvironment()
434
+ * // and is used by endpoints decorated with @XmlStream()
435
+ * ```
436
+ */
437
+ declare class XmlStreamAdapterService implements AbstractHttpHandlerAdapterInterface {
438
+ /** Base stream adapter - we proxy hasSchema, prepareArguments, provideSchema to it */
439
+ protected streamAdapter: AbstractHttpHandlerAdapterInterface;
440
+ /**
441
+ * Prepares argument getters for parsing request data.
442
+ *
443
+ * Proxies to the base stream adapter to reuse existing argument preparation logic
444
+ * that handles query parameters, request body, and URL parameters for both
445
+ * Fastify and Bun adapters.
446
+ *
447
+ * @param handlerMetadata - The handler metadata with schemas and configuration.
448
+ * @returns An array of getter functions that populate request arguments.
449
+ */
450
+ prepareArguments(handlerMetadata: HandlerMetadata<BaseXmlStreamConfig>): ((target: Record<string, any>, request: any) => Promise<void> | void)[];
451
+ /**
452
+ * Provides schema information for the handler.
453
+ *
454
+ * Proxies to the base stream adapter to reuse existing schema generation logic.
455
+ * For Fastify, this enables built-in validation. For Bun, this returns an empty object.
456
+ *
457
+ * @param handlerMetadata - The handler metadata containing configuration and schemas.
458
+ * @returns Schema information (Fastify route schema or empty object for Bun).
459
+ */
460
+ provideSchema(handlerMetadata: HandlerMetadata<BaseXmlStreamConfig>): Record<string, any>;
461
+ /**
462
+ * Checks if the handler has any validation schemas defined.
463
+ *
464
+ * Proxies to the base stream adapter to check for query or request schemas.
465
+ *
466
+ * @param handlerMetadata - The handler metadata containing configuration.
467
+ * @returns `true` if the handler has any schemas (query or request).
468
+ */
469
+ hasSchema(handlerMetadata: HandlerMetadata<any>): boolean;
470
+ /**
471
+ * Creates a request handler function for XML Stream endpoints.
472
+ *
473
+ * This method generates a handler that:
474
+ * 1. Parses and validates request data (body, query, URL params) using the base adapter
475
+ * 2. Invokes the controller method with validated arguments (returns JSX)
476
+ * 3. Renders the JSX tree to XML string (resolves async and class components)
477
+ * 4. Sends the XML response with appropriate Content-Type header
478
+ *
479
+ * The handler automatically detects the environment (Fastify vs Bun) and uses the
480
+ * appropriate response mechanism (reply object vs Response object).
481
+ *
482
+ * @param controller - The controller class containing the handler method.
483
+ * @param handlerMetadata - The handler metadata with configuration and schemas.
484
+ * @returns A function that handles incoming requests and sends XML responses.
485
+ */
486
+ provideHandler(controller: ClassType, handlerMetadata: HandlerMetadata<BaseXmlStreamConfig>): (context: ScopedContainer, request: any, reply: any) => Promise<any>;
487
+ }
488
+ //#endregion
489
+ //#region src/define-environment.d.mts
490
+ /**
491
+ * Creates the XML environment configuration to be merged with base adapter (Fastify/Bun).
492
+ *
493
+ * @example
494
+ * ```typescript
495
+ * import { defineFastifyEnvironment } from '@navios/adapter-fastify'
496
+ * import { defineXmlEnvironment } from '@navios/adapter-xml'
497
+ * import { NaviosFactory } from '@navios/core'
498
+ *
499
+ * const fastifyEnv = defineFastifyEnvironment()
500
+ * const xmlEnv = defineXmlEnvironment()
501
+ *
502
+ * // Merge environments
503
+ * const mergedEnv = {
504
+ * httpTokens: new Map([
505
+ * ...fastifyEnv.httpTokens,
506
+ * ...xmlEnv.httpTokens,
507
+ * ]),
508
+ * }
509
+ *
510
+ * const app = await NaviosFactory.create(AppModule, {
511
+ * adapter: mergedEnv,
512
+ * })
513
+ * ```
514
+ */
515
+ declare function defineXmlEnvironment(): {
516
+ httpTokens: Map<InjectionToken<any, undefined, false>, AnyInjectableType>;
517
+ };
518
+ //#endregion
519
+ export { type AnyXmlNode, AsyncComponent, type AsyncXmlNode, type BaseXmlStreamConfig, CData, type CDataNode, CDataSymbol, ClassComponent, type ClassComponentNode, Component, type ComponentClass, DangerouslyInsertRawXml, Fragment, MissingContainerError, type RawXmlNode, RawXmlSymbol, type RenderOptions, type TagComponent, type XmlComponent, type XmlNode, XmlStream, XmlStreamAdapterService, type XmlStreamParams, createElement, declareXmlStream, defineTag, defineXmlEnvironment, isComponentClass, renderToXml };
520
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/types/config.mts","../src/runtime/special-nodes.mts","../src/runtime/render-to-xml.mts","../src/tags/define-tag.mts","../src/decorators/xml-stream.decorator.mts","../src/decorators/component.decorator.mts","../src/handlers/xml-stream.mts","../src/adapters/xml-stream-adapter.service.mts","../src/define-environment.mts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;AAwBA;;;;;;;;;;;;ACdA;AAgBA;;;UDFiB,mCACA,aAAa,qGAIpB,iBAAiB,QAAQ,KAAK,aAAa;EEGpC;EAiCJ,WAAA,CAAA,EAAA,iBAAsB,GAAA,UAAa,GAAA,qBAAA,GAAA,sBAAA;EA8C1B;EACd,cAAA,CAAA,EAAA,OAAA;EACG;EACR,QAAA,CAAA,EAAA,MAAA;;;;;;;;;;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