@navios/adapter-xml 0.1.0 → 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 (99) hide show
  1. package/CHANGELOG.md +29 -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-CTOxv6Df.cjs +183 -0
  35. package/lib/create-element-CTOxv6Df.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 +9 -9
  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/lib/_tsup-dts-rollup.d.mts +0 -414
  82. package/lib/_tsup-dts-rollup.d.ts +0 -414
  83. package/lib/chunk-6OR6LGJA.mjs +0 -153
  84. package/lib/chunk-6OR6LGJA.mjs.map +0 -1
  85. package/lib/index.d.ts +0 -29
  86. package/lib/index.js +0 -376
  87. package/lib/index.js.map +0 -1
  88. package/lib/jsx-dev-runtime.d.ts +0 -4
  89. package/lib/jsx-dev-runtime.js +0 -61
  90. package/lib/jsx-dev-runtime.js.map +0 -1
  91. package/lib/jsx-runtime.d.ts +0 -3
  92. package/lib/jsx-runtime.js +0 -57
  93. package/lib/jsx-runtime.js.map +0 -1
  94. package/lib/jsx-runtime.mjs.map +0 -1
  95. package/lib/jsx.d.ts +0 -1
  96. package/lib/jsx.js +0 -4
  97. package/lib/jsx.js.map +0 -1
  98. package/lib/jsx.mjs.map +0 -1
  99. package/tsup.config.mts +0 -18
package/CHANGELOG.md ADDED
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.7.0] - 2025-12-18
9
+
10
+ ### Added
11
+
12
+ - **Comprehensive JSDoc Documentation**: Added detailed JSDoc comments to all public APIs including:
13
+ - `defineXmlEnvironment` function with configuration examples
14
+ - `defineTag` function with tag creation and validation examples
15
+ - `renderToXml` function and `RenderOptions` interface
16
+ - `Component` decorator with all overloads and usage patterns
17
+ - `XmlStream` decorator and `declareXmlStream` function
18
+ - `CData` and `DangerouslyInsertRawXml` components
19
+ - `XmlStreamAdapterService` class
20
+ - Type definitions and interfaces (`XmlComponent`, `ComponentClass`, `BaseXmlStreamConfig`, `TagComponent`, `XmlStreamParams`)
21
+ - `MissingContainerError` error class
22
+ - **Enhanced README**: Improved documentation with better examples and clearer API reference
23
+
24
+ ### Documentation
25
+
26
+ - Complete JSDoc comments for better IDE support and developer experience
27
+ - Updated README with comprehensive examples and API documentation
28
+ - Clarified usage patterns for JSX-based XML generation
29
+ - Added examples for different XML formats (RSS, Atom, Sitemap)
package/README.md CHANGED
@@ -4,7 +4,7 @@ A JSX-based XML adapter for Navios that enables building XML responses (RSS feed
4
4
 
5
5
  ## Features
6
6
 
7
- - **JSX Syntax** - Write XML using JSX with TypeScript type checking
7
+ - **JSX Syntax** - Write XML using JSX with TypeScript type checking and comprehensive JSDoc support
8
8
  - **Async Components** - Support for async components that fetch data during rendering
9
9
  - **Class Components** - `@Component` decorator with dependency injection support via `@navios/di`
10
10
  - **Type-Safe Tags** - Define custom XML tags with Zod schema validation
@@ -12,6 +12,7 @@ A JSX-based XML adapter for Navios that enables building XML responses (RSS feed
12
12
  - **CDATA Support** - Built-in `CData` component for safe text content
13
13
  - **Raw XML** - `DangerouslyInsertRawXml` for pre-rendered content
14
14
  - **XML Namespaces** - Full support for namespaced tags (e.g., `atom:link`)
15
+ - **Full TypeScript Support** - Complete type definitions with JSDoc documentation for better IDE experience
15
16
 
16
17
  ## Installation
17
18
 
package/bun-plugin.mts CHANGED
@@ -1,6 +1,5 @@
1
1
  import fs from 'fs'
2
2
 
3
- import * as babel from '@babel/core'
4
3
  import { plugin } from 'bun'
5
4
  import chalk from 'chalk'
6
5
 
@@ -88,7 +87,9 @@ export function debounce<F extends (...args: any[]) => void>(
88
87
  }
89
88
 
90
89
  const saveCacheImpl = debounce(() => {
91
- log(`saving cache with ${cache.size} entries (spent ${totalTimeSpentTranspiling.toFixed(2)}ms transpiling)`)
90
+ log(
91
+ `saving cache with ${cache.size} entries (spent ${totalTimeSpentTranspiling.toFixed(2)}ms transpiling)`,
92
+ )
92
93
  void Bun.file('./bunPlugin.cache').write(JSON.stringify([...cache.entries()]))
93
94
  }, 50)
94
95
 
@@ -116,7 +117,8 @@ async function transpileFileForReal(
116
117
  const esbuild = (await import('esbuild')).default
117
118
 
118
119
  // Determine loader based on file extension and content
119
- const hasJsx = codeTS.includes('<') && (codeTS.includes('/>') || codeTS.includes('</'))
120
+ const hasJsx =
121
+ codeTS.includes('<') && (codeTS.includes('/>') || codeTS.includes('</'))
120
122
  const loader = hasJsx ? 'tsx' : 'ts'
121
123
 
122
124
  const result = await esbuild.transform(codeTS, {
package/bunPlugin.cache CHANGED
@@ -1 +1 @@
1
- [["import type { XmlComponent, XmlStreamParams } from '../../src/index.mjs'\n\nimport { builder } from '@navios/builder'\nimport {\n Controller,\n Endpoint,\n inject,\n Injectable,\n InjectableScope,\n Module,\n NaviosApplication,\n NaviosFactory,\n} from '@navios/core'\nimport { defineBunEnvironment } from '@navios/adapter-bun'\n\nimport supertest from 'supertest'\nimport { afterAll, beforeAll, describe, expect, it } from 'bun:test'\nimport { z } from 'zod/v4'\n\nimport {\n CData,\n Component,\n DangerouslyInsertRawXml,\n declareXmlStream,\n defineXmlEnvironment,\n Fragment,\n XmlStream,\n createElement,\n} from '../../src/index.mjs'\n\n// Helper to merge environments\nfunction mergeEnvironments(\n ...envs: Array<{ httpTokens: Map<any, any> }>\n): { httpTokens: Map<any, any> } {\n const merged = new Map()\n for (const env of envs) {\n for (const [key, value] of env.httpTokens) {\n merged.set(key, value)\n }\n }\n return { httpTokens: merged }\n}\n\ndescribe('XML Stream with Bun adapter', () => {\n let server: NaviosApplication\n let serverUrl: string\n\n // Request scoped service for tracking\n @Injectable({\n scope: InjectableScope.Request,\n })\n class RequestTrackerService {\n private requestId: string = Math.random().toString(36).substring(7)\n\n getRequestId(): string {\n return this.requestId\n }\n }\n\n // Injectable data service\n @Injectable()\n class DataService {\n getItems() {\n return [\n { id: '1', title: 'First Item', description: 'Description 1' },\n { id: '2', title: 'Second Item', description: 'Description 2' },\n { id: '3', title: 'Third Item', description: 'Description 3' },\n ]\n }\n\n getItem(id: string) {\n return this.getItems().find((item) => item.id === id)\n }\n }\n\n // Class component with DI\n @Component()\n class ItemComponent implements XmlComponent {\n private dataService = inject(DataService)\n private tracker = inject(RequestTrackerService)\n\n constructor(private props: { id: string }) {}\n\n render() {\n const item = this.dataService.getItem(this.props.id)\n if (!item) {\n return createElement('error', null, 'Item not found')\n }\n return createElement(\n 'item',\n { id: item.id, requestId: this.tracker.getRequestId() },\n createElement('title', null, item.title),\n createElement('description', null, item.description),\n )\n }\n }\n\n // Async component\n async function AsyncDataComponent({ delay }: { delay: number }) {\n await new Promise((resolve) => setTimeout(resolve, delay))\n return createElement('async-data', null, `Loaded after ${delay}ms`)\n }\n\n // Simple RSS feed endpoint\n const getRssFeed = declareXmlStream({\n method: 'GET',\n url: '/feed.xml',\n querySchema: undefined,\n requestSchema: undefined,\n contentType: 'application/rss+xml',\n xmlDeclaration: true,\n })\n\n // Atom feed with query params\n const getAtomFeed = declareXmlStream({\n method: 'GET',\n url: '/atom.xml',\n querySchema: z.object({\n limit: z.coerce.number().optional().default(10),\n }),\n requestSchema: undefined,\n contentType: 'application/atom+xml',\n xmlDeclaration: true,\n })\n\n // Sitemap endpoint\n const getSitemap = declareXmlStream({\n method: 'GET',\n url: '/sitemap.xml',\n querySchema: undefined,\n requestSchema: undefined,\n contentType: 'application/xml',\n xmlDeclaration: true,\n })\n\n // Dynamic XML with URL params (use path without extension for Bun compatibility)\n const getItemXml = declareXmlStream({\n method: 'GET',\n url: '/items/$id',\n querySchema: undefined,\n requestSchema: undefined,\n contentType: 'application/xml',\n xmlDeclaration: true,\n })\n\n // POST endpoint for XML generation\n const postGenerateXml = declareXmlStream({\n method: 'POST',\n url: '/generate.xml',\n querySchema: undefined,\n requestSchema: z.object({\n title: z.string(),\n items: z.array(z.string()),\n }),\n contentType: 'application/xml',\n xmlDeclaration: true,\n })\n\n // Endpoint with async components\n const getAsyncXml = declareXmlStream({\n method: 'GET',\n url: '/async.xml',\n querySchema: undefined,\n requestSchema: undefined,\n contentType: 'application/xml',\n xmlDeclaration: true,\n })\n\n // Endpoint with class components (DI) - use path without extension for Bun compatibility\n const getDiXml = declareXmlStream({\n method: 'GET',\n url: '/di/$id',\n querySchema: undefined,\n requestSchema: undefined,\n contentType: 'application/xml',\n xmlDeclaration: true,\n })\n\n // Endpoint with CDATA and raw XML\n const getSpecialXml = declareXmlStream({\n method: 'GET',\n url: '/special.xml',\n querySchema: undefined,\n requestSchema: undefined,\n contentType: 'application/xml',\n xmlDeclaration: true,\n })\n\n // Also test regular JSON endpoint alongside XML\n const getJsonEndpoint = builder().declareEndpoint({\n method: 'GET',\n url: '/api/data',\n responseSchema: z.object({\n message: z.string(),\n }),\n })\n\n @Controller()\n class FeedController {\n private dataService = inject(DataService)\n private tracker = inject(RequestTrackerService)\n\n @XmlStream(getRssFeed)\n async getRssFeed(_params: XmlStreamParams<typeof getRssFeed>) {\n const items = this.dataService.getItems()\n return (\n <rss version=\"2.0\">\n <channel>\n <title>My Blog</title>\n <link>https://example.com</link>\n <description>A sample RSS feed</description>\n {items.map((item) => (\n <item key={item.id}>\n <title>{item.title}</title>\n <link>https://example.com/items/{item.id}</link>\n <description>{item.description}</description>\n </item>\n ))}\n </channel>\n </rss>\n )\n }\n\n @XmlStream(getAtomFeed)\n async getAtomFeed(params: XmlStreamParams<typeof getAtomFeed>) {\n const limit = params.params.limit\n const items = this.dataService.getItems().slice(0, limit)\n return (\n <feed xmlns=\"http://www.w3.org/2005/Atom\">\n <title>My Atom Feed</title>\n <link href=\"https://example.com/atom.xml\" rel=\"self\" />\n <id>https://example.com/</id>\n <updated>2025-01-01T00:00:00Z</updated>\n {items.map((item) => (\n <entry key={item.id}>\n <title>{item.title}</title>\n <id>https://example.com/items/{item.id}</id>\n <updated>2025-01-01T00:00:00Z</updated>\n <summary>{item.description}</summary>\n </entry>\n ))}\n </feed>\n )\n }\n\n @XmlStream(getSitemap)\n async getSitemap(_params: XmlStreamParams<typeof getSitemap>) {\n const items = this.dataService.getItems()\n return (\n <urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n <url>\n <loc>https://example.com/</loc>\n <lastmod>2025-01-01</lastmod>\n <changefreq>daily</changefreq>\n <priority>1.0</priority>\n </url>\n {items.map((item) => (\n <url key={item.id}>\n <loc>https://example.com/items/{item.id}</loc>\n <lastmod>2025-01-01</lastmod>\n <changefreq>weekly</changefreq>\n <priority>0.8</priority>\n </url>\n ))}\n </urlset>\n )\n }\n\n @XmlStream(getItemXml)\n async getItemXml(params: XmlStreamParams<typeof getItemXml>) {\n const item = this.dataService.getItem(params.urlParams.id as string)\n if (!item) {\n return (\n <error>\n <message>Item not found</message>\n <requestedId>{params.urlParams.id}</requestedId>\n </error>\n )\n }\n return (\n <item id={item.id}>\n <title>{item.title}</title>\n <description>{item.description}</description>\n </item>\n )\n }\n\n @XmlStream(postGenerateXml)\n async postGenerateXml(params: XmlStreamParams<typeof postGenerateXml>) {\n const { title, items } = params.data\n return (\n <generated>\n <title>{title}</title>\n <items count={String(items.length)}>\n {items.map((item, index) => (\n <item index={String(index)} key={index}>\n {item}\n </item>\n ))}\n </items>\n </generated>\n )\n }\n\n @XmlStream(getAsyncXml)\n async getAsyncXml(_params: XmlStreamParams<typeof getAsyncXml>) {\n return (\n <root>\n <sync>Immediate content</sync>\n <AsyncDataComponent delay={10} />\n <AsyncDataComponent delay={5} />\n </root>\n )\n }\n\n @XmlStream(getDiXml)\n async getDiXml(params: XmlStreamParams<typeof getDiXml>) {\n return (\n <root requestId={this.tracker.getRequestId()}>\n <ItemComponent id={params.urlParams.id as string} />\n </root>\n )\n }\n\n @XmlStream(getSpecialXml)\n async getSpecialXml(_params: XmlStreamParams<typeof getSpecialXml>) {\n return (\n <root>\n <cdata-example>\n <CData>{'This is <raw> HTML & XML content that should not be escaped'}</CData>\n </cdata-example>\n <raw-xml-example>\n <DangerouslyInsertRawXml>{'<nested><element attr=\"value\">text</element></nested>'}</DangerouslyInsertRawXml>\n </raw-xml-example>\n <escaped>{'<this> & \"that\" should be escaped'}</escaped>\n </root>\n )\n }\n\n @Endpoint(getJsonEndpoint)\n async getJsonData() {\n return { message: 'JSON endpoint works alongside XML' }\n }\n }\n\n @Module({\n controllers: [FeedController],\n })\n class AppModule {}\n\n beforeAll(async () => {\n const bunEnv = defineBunEnvironment()\n const xmlEnv = defineXmlEnvironment()\n const mergedEnv = mergeEnvironments(bunEnv, xmlEnv)\n\n server = await NaviosFactory.create(AppModule, {\n adapter: mergedEnv,\n })\n await server.init()\n await server.listen({ port: 3002, host: 'localhost' })\n serverUrl = server.getServer().url.href\n })\n\n afterAll(async () => {\n await server.close()\n })\n\n describe('Basic XML endpoints', () => {\n it('should return RSS feed with correct content type', async () => {\n const response = await supertest(serverUrl).get('/feed.xml')\n\n expect(response.status).toBe(200)\n expect(response.headers['content-type']).toContain('application/rss+xml')\n expect(response.text).toContain('<?xml version=\"1.0\" encoding=\"UTF-8\"?>')\n expect(response.text).toContain('<rss version=\"2.0\">')\n expect(response.text).toContain('<title>My Blog</title>')\n expect(response.text).toContain('<item>')\n expect(response.text).toContain('<title>First Item</title>')\n })\n\n it('should return Atom feed with query params', async () => {\n const response = await supertest(serverUrl).get('/atom.xml?limit=2')\n\n expect(response.status).toBe(200)\n expect(response.headers['content-type']).toContain('application/atom+xml')\n expect(response.text).toContain('<feed xmlns=\"http://www.w3.org/2005/Atom\">')\n\n // Count entries - should be limited to 2\n const entryCount = (response.text.match(/<entry>/g) || []).length\n expect(entryCount).toBe(2)\n })\n\n it('should return sitemap XML', async () => {\n const response = await supertest(serverUrl).get('/sitemap.xml')\n\n expect(response.status).toBe(200)\n expect(response.headers['content-type']).toContain('application/xml')\n expect(response.text).toContain(\n '<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">',\n )\n expect(response.text).toContain('<loc>https://example.com/</loc>')\n expect(response.text).toContain('<priority>1.0</priority>')\n })\n })\n\n describe('URL parameters', () => {\n it('should handle URL parameters in XML endpoint', async () => {\n const response = await supertest(serverUrl).get('/items/1')\n\n expect(response.status).toBe(200)\n expect(response.text).toContain('<item id=\"1\">')\n expect(response.text).toContain('<title>First Item</title>')\n })\n\n it('should handle non-existent item', async () => {\n const response = await supertest(serverUrl).get('/items/999')\n\n expect(response.status).toBe(200)\n expect(response.text).toContain('<error>')\n expect(response.text).toContain('<message>Item not found</message>')\n expect(response.text).toContain('<requestedId>999</requestedId>')\n })\n })\n\n describe('POST with request body', () => {\n it('should generate XML from POST body', async () => {\n const response = await supertest(serverUrl)\n .post('/generate.xml')\n .send({\n title: 'Generated Document',\n items: ['Alpha', 'Beta', 'Gamma'],\n })\n\n expect(response.status).toBe(200)\n expect(response.text).toContain('<generated>')\n expect(response.text).toContain('<title>Generated Document</title>')\n expect(response.text).toContain('<items count=\"3\">')\n expect(response.text).toContain('<item index=\"0\">Alpha</item>')\n expect(response.text).toContain('<item index=\"1\">Beta</item>')\n expect(response.text).toContain('<item index=\"2\">Gamma</item>')\n })\n })\n\n describe('Async components', () => {\n it('should resolve async components in XML', async () => {\n const response = await supertest(serverUrl).get('/async.xml')\n\n expect(response.status).toBe(200)\n expect(response.text).toContain('<sync>Immediate content</sync>')\n expect(response.text).toContain('<async-data>Loaded after 10ms</async-data>')\n expect(response.text).toContain('<async-data>Loaded after 5ms</async-data>')\n })\n })\n\n describe('Class components with DI', () => {\n it('should render class components with injected services', async () => {\n const response = await supertest(serverUrl).get('/di/1')\n\n expect(response.status).toBe(200)\n expect(response.text).toContain('<root requestId=')\n expect(response.text).toContain('<item id=\"1\"')\n expect(response.text).toContain('<title>First Item</title>')\n })\n\n it('should isolate request-scoped services across parallel requests', async () => {\n const requests = [\n supertest(serverUrl).get('/di/1'),\n supertest(serverUrl).get('/di/2'),\n supertest(serverUrl).get('/di/3'),\n ]\n\n const responses = await Promise.all(requests)\n\n // All should succeed\n responses.forEach((response) => {\n expect(response.status).toBe(200)\n })\n\n // Extract request IDs from the responses\n const requestIds = responses.map((response) => {\n const match = response.text.match(/requestId=\"([^\"]+)\"/)\n return match ? match[1] : null\n })\n\n // All request IDs should be unique\n const uniqueIds = new Set(requestIds.filter(Boolean))\n expect(uniqueIds.size).toBe(3)\n })\n })\n\n describe('Special XML content', () => {\n it('should handle CDATA and raw XML correctly', async () => {\n const response = await supertest(serverUrl).get('/special.xml')\n\n expect(response.status).toBe(200)\n\n // CDATA should preserve raw content\n expect(response.text).toContain(\n '<![CDATA[This is <raw> HTML & XML content that should not be escaped]]>',\n )\n\n // Raw XML should be inserted without escaping\n expect(response.text).toContain('<nested><element attr=\"value\">text</element></nested>')\n\n // Regular content should be escaped\n expect(response.text).toContain('&lt;this&gt; &amp; \"that\" should be escaped')\n })\n })\n\n describe('Mixed endpoints', () => {\n it('should work alongside regular JSON endpoints', async () => {\n const xmlResponse = await supertest(serverUrl).get('/feed.xml')\n const jsonResponse = await supertest(serverUrl).get('/api/data')\n\n expect(xmlResponse.status).toBe(200)\n expect(xmlResponse.headers['content-type']).toContain('application/rss+xml')\n\n expect(jsonResponse.status).toBe(200)\n expect(jsonResponse.body.message).toBe('JSON endpoint works alongside XML')\n })\n })\n\n describe('Fragment support', () => {\n it('should correctly render fragments within XML', async () => {\n // The RSS feed uses fragments implicitly with array mapping\n const response = await supertest(serverUrl).get('/feed.xml')\n\n expect(response.status).toBe(200)\n // Multiple items should be rendered without extra wrapper\n const itemCount = (response.text.match(/<item>/g) || []).length\n expect(itemCount).toBeGreaterThan(1)\n })\n })\n})\n","var __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for(\"Symbol.\" + name);\nvar __typeError = (msg) => {\n throw TypeError(msg);\n};\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __name = (target, value) => __defProp(target, \"name\", { value, configurable: true });\nvar __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol(\"metadata\")] ?? null)];\nvar __decoratorStrings = [\"class\", \"method\", \"getter\", \"setter\", \"accessor\", \"field\", \"value\", \"get\", \"set\"];\nvar __expectFn = (fn) => fn !== void 0 && typeof fn !== \"function\" ? __typeError(\"Function expected\") : fn;\nvar __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError(\"Already initialized\") : fns.push(__expectFn(fn || null)) });\nvar __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol(\"metadata\"), array[3]);\nvar __runInitializers = (array, flags, self, value) => {\n for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);\n return value;\n};\nvar __decorateElement = (array, flags, name, decorators, target, extra) => {\n var fn, it2, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);\n var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];\n var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);\n var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {\n return __privateGet(this, extra);\n }, set [name](x) {\n return __privateSet(this, extra, x);\n } }, name));\n k ? p && k < 4 && __name(extra, (k > 2 ? \"set \" : k > 1 ? \"get \" : \"\") + name) : __name(target, name);\n for (var i = decorators.length - 1; i >= 0; i--) {\n ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);\n if (k) {\n ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };\n if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];\n if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;\n }\n it2 = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;\n if (k ^ 4 || it2 === void 0) __expectFn(it2) && (k > 4 ? initializers.unshift(it2) : k ? p ? extra = it2 : desc[key] = it2 : target = it2);\n else if (typeof it2 !== \"object\" || it2 === null) __typeError(\"Object expected\");\n else __expectFn(fn = it2.get) && (desc.get = fn), __expectFn(fn = it2.set) && (desc.set = fn), __expectFn(fn = it2.init) && initializers.unshift(fn);\n }\n return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;\n};\nvar __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\nvar __accessCheck = (obj, member, msg) => member.has(obj) || __typeError(\"Cannot \" + msg);\nvar __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the \"in\" operator on this value') : member.has(obj);\nvar __privateGet = (obj, member, getter) => (__accessCheck(obj, member, \"read from private field\"), getter ? getter.call(obj) : member.get(obj));\nvar __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, \"write to private field\"), setter ? setter.call(obj, value) : member.set(obj, value), value);\nvar __privateMethod = (obj, member, method) => (__accessCheck(obj, member, \"access private method\"), method);\nimport { jsx, jsxs } from \"@navios/adapter-xml/jsx-runtime\";\nimport { builder } from \"@navios/builder\";\nimport {\n Controller,\n Endpoint,\n inject,\n Injectable,\n InjectableScope,\n Module,\n NaviosFactory\n} from \"@navios/core\";\nimport { defineBunEnvironment } from \"@navios/adapter-bun\";\nimport supertest from \"supertest\";\nimport { afterAll, beforeAll, describe, expect, it } from \"bun:test\";\nimport { z } from \"zod/v4\";\nimport {\n CData,\n Component,\n DangerouslyInsertRawXml,\n declareXmlStream,\n defineXmlEnvironment,\n XmlStream,\n createElement\n} from \"../../src/index.mjs\";\nfunction mergeEnvironments(...envs) {\n const merged = /* @__PURE__ */ new Map();\n for (const env of envs) {\n for (const [key, value] of env.httpTokens) {\n merged.set(key, value);\n }\n }\n return { httpTokens: merged };\n}\ndescribe(\"XML Stream with Bun adapter\", () => {\n var _RequestTrackerService_decorators, _init, _DataService_decorators, _init2, _ItemComponent_decorators, _init3, _getJsonData_dec, _getSpecialXml_dec, _getDiXml_dec, _getAsyncXml_dec, _postGenerateXml_dec, _getItemXml_dec, _getSitemap_dec, _getAtomFeed_dec, _getRssFeed_dec, _FeedController_decorators, _init4, _AppModule_decorators, _init5;\n let server;\n let serverUrl;\n _RequestTrackerService_decorators = [Injectable({\n scope: InjectableScope.Request\n })];\n class RequestTrackerService {\n requestId = Math.random().toString(36).substring(7);\n getRequestId() {\n return this.requestId;\n }\n }\n _init = __decoratorStart(null);\n RequestTrackerService = __decorateElement(_init, 0, \"RequestTrackerService\", _RequestTrackerService_decorators, RequestTrackerService);\n __runInitializers(_init, 1, RequestTrackerService);\n _DataService_decorators = [Injectable()];\n class DataService {\n getItems() {\n return [\n { id: \"1\", title: \"First Item\", description: \"Description 1\" },\n { id: \"2\", title: \"Second Item\", description: \"Description 2\" },\n { id: \"3\", title: \"Third Item\", description: \"Description 3\" }\n ];\n }\n getItem(id) {\n return this.getItems().find((item) => item.id === id);\n }\n }\n _init2 = __decoratorStart(null);\n DataService = __decorateElement(_init2, 0, \"DataService\", _DataService_decorators, DataService);\n __runInitializers(_init2, 1, DataService);\n _ItemComponent_decorators = [Component()];\n class ItemComponent {\n constructor(props) {\n this.props = props;\n }\n dataService = inject(DataService);\n tracker = inject(RequestTrackerService);\n render() {\n const item = this.dataService.getItem(this.props.id);\n if (!item) {\n return createElement(\"error\", null, \"Item not found\");\n }\n return createElement(\n \"item\",\n { id: item.id, requestId: this.tracker.getRequestId() },\n createElement(\"title\", null, item.title),\n createElement(\"description\", null, item.description)\n );\n }\n }\n _init3 = __decoratorStart(null);\n ItemComponent = __decorateElement(_init3, 0, \"ItemComponent\", _ItemComponent_decorators, ItemComponent);\n __runInitializers(_init3, 1, ItemComponent);\n async function AsyncDataComponent({ delay }) {\n await new Promise((resolve) => setTimeout(resolve, delay));\n return createElement(\"async-data\", null, `Loaded after ${delay}ms`);\n }\n const getRssFeed = declareXmlStream({\n method: \"GET\",\n url: \"/feed.xml\",\n querySchema: void 0,\n requestSchema: void 0,\n contentType: \"application/rss+xml\",\n xmlDeclaration: true\n });\n const getAtomFeed = declareXmlStream({\n method: \"GET\",\n url: \"/atom.xml\",\n querySchema: z.object({\n limit: z.coerce.number().optional().default(10)\n }),\n requestSchema: void 0,\n contentType: \"application/atom+xml\",\n xmlDeclaration: true\n });\n const getSitemap = declareXmlStream({\n method: \"GET\",\n url: \"/sitemap.xml\",\n querySchema: void 0,\n requestSchema: void 0,\n contentType: \"application/xml\",\n xmlDeclaration: true\n });\n const getItemXml = declareXmlStream({\n method: \"GET\",\n url: \"/items/$id\",\n querySchema: void 0,\n requestSchema: void 0,\n contentType: \"application/xml\",\n xmlDeclaration: true\n });\n const postGenerateXml = declareXmlStream({\n method: \"POST\",\n url: \"/generate.xml\",\n querySchema: void 0,\n requestSchema: z.object({\n title: z.string(),\n items: z.array(z.string())\n }),\n contentType: \"application/xml\",\n xmlDeclaration: true\n });\n const getAsyncXml = declareXmlStream({\n method: \"GET\",\n url: \"/async.xml\",\n querySchema: void 0,\n requestSchema: void 0,\n contentType: \"application/xml\",\n xmlDeclaration: true\n });\n const getDiXml = declareXmlStream({\n method: \"GET\",\n url: \"/di/$id\",\n querySchema: void 0,\n requestSchema: void 0,\n contentType: \"application/xml\",\n xmlDeclaration: true\n });\n const getSpecialXml = declareXmlStream({\n method: \"GET\",\n url: \"/special.xml\",\n querySchema: void 0,\n requestSchema: void 0,\n contentType: \"application/xml\",\n xmlDeclaration: true\n });\n const getJsonEndpoint = builder().declareEndpoint({\n method: \"GET\",\n url: \"/api/data\",\n responseSchema: z.object({\n message: z.string()\n })\n });\n _FeedController_decorators = [Controller()], _getRssFeed_dec = [XmlStream(getRssFeed)], _getAtomFeed_dec = [XmlStream(getAtomFeed)], _getSitemap_dec = [XmlStream(getSitemap)], _getItemXml_dec = [XmlStream(getItemXml)], _postGenerateXml_dec = [XmlStream(postGenerateXml)], _getAsyncXml_dec = [XmlStream(getAsyncXml)], _getDiXml_dec = [XmlStream(getDiXml)], _getSpecialXml_dec = [XmlStream(getSpecialXml)], _getJsonData_dec = [Endpoint(getJsonEndpoint)];\n class FeedController {\n constructor() {\n __runInitializers(_init4, 5, this);\n __publicField(this, \"dataService\", inject(DataService));\n __publicField(this, \"tracker\", inject(RequestTrackerService));\n }\n async getRssFeed(_params) {\n const items = this.dataService.getItems();\n return /* @__PURE__ */ jsx(\"rss\", { version: \"2.0\", children: /* @__PURE__ */ jsxs(\"channel\", { children: [\n /* @__PURE__ */ jsx(\"title\", { children: \"My Blog\" }),\n /* @__PURE__ */ jsx(\"link\", { children: \"https://example.com\" }),\n /* @__PURE__ */ jsx(\"description\", { children: \"A sample RSS feed\" }),\n items.map((item) => /* @__PURE__ */ jsxs(\"item\", { children: [\n /* @__PURE__ */ jsx(\"title\", { children: item.title }),\n /* @__PURE__ */ jsxs(\"link\", { children: [\n \"https://example.com/items/\",\n item.id\n ] }),\n /* @__PURE__ */ jsx(\"description\", { children: item.description })\n ] }, item.id))\n ] }) });\n }\n async getAtomFeed(params) {\n const limit = params.params.limit;\n const items = this.dataService.getItems().slice(0, limit);\n return /* @__PURE__ */ jsxs(\"feed\", { xmlns: \"http://www.w3.org/2005/Atom\", children: [\n /* @__PURE__ */ jsx(\"title\", { children: \"My Atom Feed\" }),\n /* @__PURE__ */ jsx(\"link\", { href: \"https://example.com/atom.xml\", rel: \"self\" }),\n /* @__PURE__ */ jsx(\"id\", { children: \"https://example.com/\" }),\n /* @__PURE__ */ jsx(\"updated\", { children: \"2025-01-01T00:00:00Z\" }),\n items.map((item) => /* @__PURE__ */ jsxs(\"entry\", { children: [\n /* @__PURE__ */ jsx(\"title\", { children: item.title }),\n /* @__PURE__ */ jsxs(\"id\", { children: [\n \"https://example.com/items/\",\n item.id\n ] }),\n /* @__PURE__ */ jsx(\"updated\", { children: \"2025-01-01T00:00:00Z\" }),\n /* @__PURE__ */ jsx(\"summary\", { children: item.description })\n ] }, item.id))\n ] });\n }\n async getSitemap(_params) {\n const items = this.dataService.getItems();\n return /* @__PURE__ */ jsxs(\"urlset\", { xmlns: \"http://www.sitemaps.org/schemas/sitemap/0.9\", children: [\n /* @__PURE__ */ jsxs(\"url\", { children: [\n /* @__PURE__ */ jsx(\"loc\", { children: \"https://example.com/\" }),\n /* @__PURE__ */ jsx(\"lastmod\", { children: \"2025-01-01\" }),\n /* @__PURE__ */ jsx(\"changefreq\", { children: \"daily\" }),\n /* @__PURE__ */ jsx(\"priority\", { children: \"1.0\" })\n ] }),\n items.map((item) => /* @__PURE__ */ jsxs(\"url\", { children: [\n /* @__PURE__ */ jsxs(\"loc\", { children: [\n \"https://example.com/items/\",\n item.id\n ] }),\n /* @__PURE__ */ jsx(\"lastmod\", { children: \"2025-01-01\" }),\n /* @__PURE__ */ jsx(\"changefreq\", { children: \"weekly\" }),\n /* @__PURE__ */ jsx(\"priority\", { children: \"0.8\" })\n ] }, item.id))\n ] });\n }\n async getItemXml(params) {\n const item = this.dataService.getItem(params.urlParams.id);\n if (!item) {\n return /* @__PURE__ */ jsxs(\"error\", { children: [\n /* @__PURE__ */ jsx(\"message\", { children: \"Item not found\" }),\n /* @__PURE__ */ jsx(\"requestedId\", { children: params.urlParams.id })\n ] });\n }\n return /* @__PURE__ */ jsxs(\"item\", { id: item.id, children: [\n /* @__PURE__ */ jsx(\"title\", { children: item.title }),\n /* @__PURE__ */ jsx(\"description\", { children: item.description })\n ] });\n }\n async postGenerateXml(params) {\n const { title, items } = params.data;\n return /* @__PURE__ */ jsxs(\"generated\", { children: [\n /* @__PURE__ */ jsx(\"title\", { children: title }),\n /* @__PURE__ */ jsx(\"items\", { count: String(items.length), children: items.map((item, index) => /* @__PURE__ */ jsx(\"item\", { index: String(index), children: item }, index)) })\n ] });\n }\n async getAsyncXml(_params) {\n return /* @__PURE__ */ jsxs(\"root\", { children: [\n /* @__PURE__ */ jsx(\"sync\", { children: \"Immediate content\" }),\n /* @__PURE__ */ jsx(AsyncDataComponent, { delay: 10 }),\n /* @__PURE__ */ jsx(AsyncDataComponent, { delay: 5 })\n ] });\n }\n async getDiXml(params) {\n return /* @__PURE__ */ jsx(\"root\", { requestId: this.tracker.getRequestId(), children: /* @__PURE__ */ jsx(ItemComponent, { id: params.urlParams.id }) });\n }\n async getSpecialXml(_params) {\n return /* @__PURE__ */ jsxs(\"root\", { children: [\n /* @__PURE__ */ jsx(\"cdata-example\", { children: /* @__PURE__ */ jsx(CData, { children: \"This is <raw> HTML & XML content that should not be escaped\" }) }),\n /* @__PURE__ */ jsx(\"raw-xml-example\", { children: /* @__PURE__ */ jsx(DangerouslyInsertRawXml, { children: '<nested><element attr=\"value\">text</element></nested>' }) }),\n /* @__PURE__ */ jsx(\"escaped\", { children: '<this> & \"that\" should be escaped' })\n ] });\n }\n async getJsonData() {\n return { message: \"JSON endpoint works alongside XML\" };\n }\n }\n _init4 = __decoratorStart(null);\n __decorateElement(_init4, 1, \"getRssFeed\", _getRssFeed_dec, FeedController);\n __decorateElement(_init4, 1, \"getAtomFeed\", _getAtomFeed_dec, FeedController);\n __decorateElement(_init4, 1, \"getSitemap\", _getSitemap_dec, FeedController);\n __decorateElement(_init4, 1, \"getItemXml\", _getItemXml_dec, FeedController);\n __decorateElement(_init4, 1, \"postGenerateXml\", _postGenerateXml_dec, FeedController);\n __decorateElement(_init4, 1, \"getAsyncXml\", _getAsyncXml_dec, FeedController);\n __decorateElement(_init4, 1, \"getDiXml\", _getDiXml_dec, FeedController);\n __decorateElement(_init4, 1, \"getSpecialXml\", _getSpecialXml_dec, FeedController);\n __decorateElement(_init4, 1, \"getJsonData\", _getJsonData_dec, FeedController);\n FeedController = __decorateElement(_init4, 0, \"FeedController\", _FeedController_decorators, FeedController);\n __runInitializers(_init4, 1, FeedController);\n _AppModule_decorators = [Module({\n controllers: [FeedController]\n })];\n class AppModule {\n }\n _init5 = __decoratorStart(null);\n AppModule = __decorateElement(_init5, 0, \"AppModule\", _AppModule_decorators, AppModule);\n __runInitializers(_init5, 1, AppModule);\n beforeAll(async () => {\n const bunEnv = defineBunEnvironment();\n const xmlEnv = defineXmlEnvironment();\n const mergedEnv = mergeEnvironments(bunEnv, xmlEnv);\n server = await NaviosFactory.create(AppModule, {\n adapter: mergedEnv\n });\n await server.init();\n await server.listen({ port: 3002, host: \"localhost\" });\n serverUrl = server.getServer().url.href;\n });\n afterAll(async () => {\n await server.close();\n });\n describe(\"Basic XML endpoints\", () => {\n it(\"should return RSS feed with correct content type\", async () => {\n const response = await supertest(serverUrl).get(\"/feed.xml\");\n expect(response.status).toBe(200);\n expect(response.headers[\"content-type\"]).toContain(\"application/rss+xml\");\n expect(response.text).toContain('<?xml version=\"1.0\" encoding=\"UTF-8\"?>');\n expect(response.text).toContain('<rss version=\"2.0\">');\n expect(response.text).toContain(\"<title>My Blog</title>\");\n expect(response.text).toContain(\"<item>\");\n expect(response.text).toContain(\"<title>First Item</title>\");\n });\n it(\"should return Atom feed with query params\", async () => {\n const response = await supertest(serverUrl).get(\"/atom.xml?limit=2\");\n expect(response.status).toBe(200);\n expect(response.headers[\"content-type\"]).toContain(\"application/atom+xml\");\n expect(response.text).toContain('<feed xmlns=\"http://www.w3.org/2005/Atom\">');\n const entryCount = (response.text.match(/<entry>/g) || []).length;\n expect(entryCount).toBe(2);\n });\n it(\"should return sitemap XML\", async () => {\n const response = await supertest(serverUrl).get(\"/sitemap.xml\");\n expect(response.status).toBe(200);\n expect(response.headers[\"content-type\"]).toContain(\"application/xml\");\n expect(response.text).toContain(\n '<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">'\n );\n expect(response.text).toContain(\"<loc>https://example.com/</loc>\");\n expect(response.text).toContain(\"<priority>1.0</priority>\");\n });\n });\n describe(\"URL parameters\", () => {\n it(\"should handle URL parameters in XML endpoint\", async () => {\n const response = await supertest(serverUrl).get(\"/items/1\");\n expect(response.status).toBe(200);\n expect(response.text).toContain('<item id=\"1\">');\n expect(response.text).toContain(\"<title>First Item</title>\");\n });\n it(\"should handle non-existent item\", async () => {\n const response = await supertest(serverUrl).get(\"/items/999\");\n expect(response.status).toBe(200);\n expect(response.text).toContain(\"<error>\");\n expect(response.text).toContain(\"<message>Item not found</message>\");\n expect(response.text).toContain(\"<requestedId>999</requestedId>\");\n });\n });\n describe(\"POST with request body\", () => {\n it(\"should generate XML from POST body\", async () => {\n const response = await supertest(serverUrl).post(\"/generate.xml\").send({\n title: \"Generated Document\",\n items: [\"Alpha\", \"Beta\", \"Gamma\"]\n });\n expect(response.status).toBe(200);\n expect(response.text).toContain(\"<generated>\");\n expect(response.text).toContain(\"<title>Generated Document</title>\");\n expect(response.text).toContain('<items count=\"3\">');\n expect(response.text).toContain('<item index=\"0\">Alpha</item>');\n expect(response.text).toContain('<item index=\"1\">Beta</item>');\n expect(response.text).toContain('<item index=\"2\">Gamma</item>');\n });\n });\n describe(\"Async components\", () => {\n it(\"should resolve async components in XML\", async () => {\n const response = await supertest(serverUrl).get(\"/async.xml\");\n expect(response.status).toBe(200);\n expect(response.text).toContain(\"<sync>Immediate content</sync>\");\n expect(response.text).toContain(\"<async-data>Loaded after 10ms</async-data>\");\n expect(response.text).toContain(\"<async-data>Loaded after 5ms</async-data>\");\n });\n });\n describe(\"Class components with DI\", () => {\n it(\"should render class components with injected services\", async () => {\n const response = await supertest(serverUrl).get(\"/di/1\");\n expect(response.status).toBe(200);\n expect(response.text).toContain(\"<root requestId=\");\n expect(response.text).toContain('<item id=\"1\"');\n expect(response.text).toContain(\"<title>First Item</title>\");\n });\n it(\"should isolate request-scoped services across parallel requests\", async () => {\n const requests = [\n supertest(serverUrl).get(\"/di/1\"),\n supertest(serverUrl).get(\"/di/2\"),\n supertest(serverUrl).get(\"/di/3\")\n ];\n const responses = await Promise.all(requests);\n responses.forEach((response) => {\n expect(response.status).toBe(200);\n });\n const requestIds = responses.map((response) => {\n const match = response.text.match(/requestId=\"([^\"]+)\"/);\n return match ? match[1] : null;\n });\n const uniqueIds = new Set(requestIds.filter(Boolean));\n expect(uniqueIds.size).toBe(3);\n });\n });\n describe(\"Special XML content\", () => {\n it(\"should handle CDATA and raw XML correctly\", async () => {\n const response = await supertest(serverUrl).get(\"/special.xml\");\n expect(response.status).toBe(200);\n expect(response.text).toContain(\n \"<![CDATA[This is <raw> HTML & XML content that should not be escaped]]>\"\n );\n expect(response.text).toContain('<nested><element attr=\"value\">text</element></nested>');\n expect(response.text).toContain('&lt;this&gt; &amp; \"that\" should be escaped');\n });\n });\n describe(\"Mixed endpoints\", () => {\n it(\"should work alongside regular JSON endpoints\", async () => {\n const xmlResponse = await supertest(serverUrl).get(\"/feed.xml\");\n const jsonResponse = await supertest(serverUrl).get(\"/api/data\");\n expect(xmlResponse.status).toBe(200);\n expect(xmlResponse.headers[\"content-type\"]).toContain(\"application/rss+xml\");\n expect(jsonResponse.status).toBe(200);\n expect(jsonResponse.body.message).toBe(\"JSON endpoint works alongside XML\");\n });\n });\n describe(\"Fragment support\", () => {\n it(\"should correctly render fragments within XML\", async () => {\n const response = await supertest(serverUrl).get(\"/feed.xml\");\n expect(response.status).toBe(200);\n const itemCount = (response.text.match(/<item>/g) || []).length;\n expect(itemCount).toBeGreaterThan(1);\n });\n });\n});\n"],["// Types\nexport type {\n XmlNode,\n AsyncXmlNode,\n CDataNode,\n RawXmlNode,\n ClassComponentNode,\n AnyXmlNode,\n BaseXmlStreamConfig,\n XmlComponent,\n ComponentClass,\n} from './types/index.mjs'\n\nexport {\n Fragment,\n AsyncComponent,\n CDataSymbol,\n RawXmlSymbol,\n ClassComponent,\n} from './types/index.mjs'\n\n// Runtime\nexport { createElement, CData, DangerouslyInsertRawXml, renderToXml, MissingContainerError } from './runtime/index.mjs'\nexport type { RenderOptions } from './runtime/index.mjs'\n\n// Tags\nexport { defineTag } from './tags/index.mjs'\nexport type { TagComponent } from './tags/index.mjs'\n\n// Decorators\nexport { XmlStream, Component, isComponentClass } from './decorators/index.mjs'\nexport type { XmlStreamParams } from './decorators/index.mjs'\n\n// Handlers\nexport { declareXmlStream } from './handlers/index.mjs'\n\n// Adapters\nexport { XmlStreamAdapterService } from './adapters/index.mjs'\n\n// Environment\nexport { defineXmlEnvironment } from './define-environment.mjs'\n","export {\n Fragment,\n AsyncComponent,\n CDataSymbol,\n RawXmlSymbol,\n ClassComponent\n} from \"./types/index.mjs\";\nexport { createElement, CData, DangerouslyInsertRawXml, renderToXml, MissingContainerError } from \"./runtime/index.mjs\";\nexport { defineTag } from \"./tags/index.mjs\";\nexport { XmlStream, Component, isComponentClass } from \"./decorators/index.mjs\";\nexport { declareXmlStream } from \"./handlers/index.mjs\";\nexport { XmlStreamAdapterService } from \"./adapters/index.mjs\";\nexport { defineXmlEnvironment } from \"./define-environment.mjs\";\n"],["export {\n Fragment,\n AsyncComponent,\n CDataSymbol,\n RawXmlSymbol,\n ClassComponent,\n} from './xml-node.mjs'\n\nexport type {\n XmlNode,\n AsyncXmlNode,\n CDataNode,\n RawXmlNode,\n ClassComponentNode,\n AnyXmlNode,\n} from './xml-node.mjs'\n\nexport type { XmlComponent, ComponentClass } from './component.mjs'\n\nexport type { BaseXmlStreamConfig } from './config.mjs'\n\n// Re-export JSX types for side effects\n\n","export {\n Fragment,\n AsyncComponent,\n CDataSymbol,\n RawXmlSymbol,\n ClassComponent\n} from \"./xml-node.mjs\";\n"],["export { createElement, Fragment } from './create-element.mjs'\nexport { CData, DangerouslyInsertRawXml } from './special-nodes.mjs'\nexport { renderToXml, MissingContainerError } from './render-to-xml.mjs'\nexport type { RenderOptions } from './render-to-xml.mjs'\n","export { createElement, Fragment } from \"./create-element.mjs\";\nexport { CData, DangerouslyInsertRawXml } from \"./special-nodes.mjs\";\nexport { renderToXml, MissingContainerError } from \"./render-to-xml.mjs\";\n"],["export { defineTag } from './define-tag.mjs'\nexport type { TagComponent } from './define-tag.mjs'\n","export { defineTag } from \"./define-tag.mjs\";\n"],["export { XmlStream } from './xml-stream.decorator.mjs'\nexport type { XmlStreamParams } from './xml-stream.decorator.mjs'\n\nexport { Component, ComponentMeta, isComponentClass } from './component.decorator.mjs'\n","export { XmlStream } from \"./xml-stream.decorator.mjs\";\nexport { Component, ComponentMeta, isComponentClass } from \"./component.decorator.mjs\";\n"],["export { XmlStreamAdapterService } from './xml-stream-adapter.service.mjs'\n","export { XmlStreamAdapterService } from \"./xml-stream-adapter.service.mjs\";\n"],["import type { CDataNode, RawXmlNode } from '../types/xml-node.mjs'\nimport { CDataSymbol, RawXmlSymbol } from '../types/xml-node.mjs'\n\n/**\n * CDATA component - wraps content in <![CDATA[...]]>\n * Use for text content that may contain characters like < > &\n * that would otherwise need escaping.\n *\n * Note: If content contains \"]]>\", it will be split into multiple CDATA sections.\n */\nexport function CData({ children }: { children: string }): CDataNode {\n return {\n type: CDataSymbol,\n content: String(children),\n }\n}\n\n/**\n * DangerouslyInsertRawXml - inserts raw XML/HTML without any escaping or wrapping\n *\n * WARNING: This bypasses all XML escaping. Only use with trusted content!\n * Use cases:\n * - Pre-rendered XML fragments\n * - HTML content in RSS/Atom feeds (in description/content:encoded)\n * - Including XML from external sources that's already valid\n */\nexport function DangerouslyInsertRawXml({ children }: { children: string }): RawXmlNode {\n return {\n type: RawXmlSymbol,\n content: String(children),\n }\n}\n","import { CDataSymbol, RawXmlSymbol } from \"../types/xml-node.mjs\";\nexport function CData({ children }) {\n return {\n type: CDataSymbol,\n content: String(children)\n };\n}\nexport function DangerouslyInsertRawXml({ children }) {\n return {\n type: RawXmlSymbol,\n content: String(children)\n };\n}\n"],["import type { ComponentClass } from './component.mjs'\n\nexport const Fragment = Symbol.for('xml.fragment')\nexport const AsyncComponent = Symbol.for('xml.async')\nexport const CDataSymbol = Symbol.for('xml.cdata')\nexport const RawXmlSymbol = Symbol.for('xml.raw')\nexport const ClassComponent = Symbol.for('xml.class-component')\n\n/** Represents a CDATA section - content is wrapped in <![CDATA[...]]> */\nexport interface CDataNode {\n type: typeof CDataSymbol\n content: string\n}\n\n/** Represents raw XML content - inserted without any escaping or wrapping */\nexport interface RawXmlNode {\n type: typeof RawXmlSymbol\n content: string\n}\n\n/** Represents a class component that needs to be resolved via DI */\nexport interface ClassComponentNode {\n type: typeof ClassComponent\n componentClass: ComponentClass\n props: Record<string, unknown>\n}\n\nexport interface XmlNode {\n type: string | typeof Fragment\n props: Record<string, unknown>\n children: AnyXmlNode[]\n}\n\n/** Represents an async component that needs to be resolved before rendering */\nexport interface AsyncXmlNode {\n type: typeof AsyncComponent\n promise: Promise<AnyXmlNode>\n}\n\n/** Union type for all possible node types */\nexport type AnyXmlNode =\n | XmlNode\n | AsyncXmlNode\n | CDataNode\n | RawXmlNode\n | ClassComponentNode\n | string\n | number\n | null\n | undefined\n","export const Fragment = /* @__PURE__ */ Symbol.for(\"xml.fragment\");\nexport const AsyncComponent = /* @__PURE__ */ Symbol.for(\"xml.async\");\nexport const CDataSymbol = /* @__PURE__ */ Symbol.for(\"xml.cdata\");\nexport const RawXmlSymbol = /* @__PURE__ */ Symbol.for(\"xml.raw\");\nexport const ClassComponent = /* @__PURE__ */ Symbol.for(\"xml.class-component\");\n"],["import type { AnyInjectableType } from '@navios/di'\n\nimport { XmlStreamAdapterToken } from '@navios/core'\nimport { InjectionToken } from '@navios/di'\n\nimport { XmlStreamAdapterService } from './adapters/index.mjs'\n\n/**\n * Creates the XML environment configuration to be merged with base adapter (Fastify/Bun).\n *\n * @example\n * ```typescript\n * import { defineFastifyEnvironment } from '@navios/adapter-fastify'\n * import { defineXmlEnvironment } from '@navios/adapter-xml'\n * import { NaviosFactory } from '@navios/core'\n *\n * const fastifyEnv = defineFastifyEnvironment()\n * const xmlEnv = defineXmlEnvironment()\n *\n * // Merge environments\n * const mergedEnv = {\n * httpTokens: new Map([\n * ...fastifyEnv.httpTokens,\n * ...xmlEnv.httpTokens,\n * ]),\n * }\n *\n * const app = await NaviosFactory.create(AppModule, {\n * adapter: mergedEnv,\n * })\n * ```\n */\nexport function defineXmlEnvironment() {\n const httpTokens = new Map<InjectionToken<any, undefined>, AnyInjectableType>([\n [XmlStreamAdapterToken, XmlStreamAdapterService],\n ])\n return {\n httpTokens,\n }\n}\n","import { XmlStreamAdapterToken } from \"@navios/core\";\nimport { XmlStreamAdapterService } from \"./adapters/index.mjs\";\nexport function defineXmlEnvironment() {\n const httpTokens = /* @__PURE__ */ new Map([\n [XmlStreamAdapterToken, XmlStreamAdapterService]\n ]);\n return {\n httpTokens\n };\n}\n"],["export { declareXmlStream } from './xml-stream.mjs'\n","export { declareXmlStream } from \"./xml-stream.mjs\";\n"],["import type { AnyXmlNode, AsyncXmlNode, ClassComponentNode, XmlNode } from '../types/xml-node.mjs'\nimport type { ComponentClass } from '../types/component.mjs'\n\nimport { isComponentClass } from '../decorators/component.decorator.mjs'\nimport { AsyncComponent, ClassComponent, Fragment } from '../types/xml-node.mjs'\n\ntype SyncComponent = (props: any) => XmlNode | AsyncXmlNode | ClassComponentNode\ntype AsyncComponentFn = (props: any) => Promise<XmlNode | AsyncXmlNode | ClassComponentNode>\ntype FunctionalComponent = SyncComponent | AsyncComponentFn\ntype ComponentType = FunctionalComponent | ComponentClass\n\nfunction flattenChildren(children: any): AnyXmlNode[] {\n if (children == null || children === false) {\n return []\n }\n if (Array.isArray(children)) {\n return children.flat(Infinity).filter((c) => c != null && c !== false)\n }\n return [children]\n}\n\n/**\n * JSX automatic runtime function.\n * Used by the JSX transformer when jsxImportSource is set.\n * Children are passed as part of props.children.\n */\nexport function jsx(\n type: string | typeof Fragment | ComponentType,\n props: Record<string, unknown> | null,\n): XmlNode | AsyncXmlNode | ClassComponentNode {\n const { children, ...restProps } = props ?? {}\n const flatChildren = flattenChildren(children)\n\n // Handle class components - create ClassComponentNode for later resolution\n if (isComponentClass(type)) {\n return {\n type: ClassComponent,\n componentClass: type,\n props: { ...restProps, children: flatChildren },\n }\n }\n\n // Handle function components (sync or async)\n if (typeof type === 'function') {\n const result = type({ ...restProps, children: flatChildren })\n\n // If component returns a Promise, wrap it in AsyncXmlNode\n if (result instanceof Promise) {\n return {\n type: AsyncComponent,\n promise: result,\n }\n }\n\n return result\n }\n\n return {\n type,\n props: restProps,\n children: flatChildren,\n }\n}\n\n/**\n * JSX automatic runtime function for static children.\n * Identical to jsx() for XML - React uses this for optimization hints.\n */\nexport const jsxs = jsx\n\n/**\n * Classic createElement for manual usage.\n * Children are passed as rest arguments.\n */\nexport function createElement(\n type: string | typeof Fragment | ComponentType,\n props: Record<string, unknown> | null,\n ...children: any[]\n): XmlNode | AsyncXmlNode | ClassComponentNode {\n const flatChildren = flattenChildren(children)\n\n // Handle class components - create ClassComponentNode for later resolution\n if (isComponentClass(type)) {\n return {\n type: ClassComponent,\n componentClass: type,\n props: { ...props, children: flatChildren },\n }\n }\n\n // Handle function components (sync or async)\n if (typeof type === 'function') {\n const result = type({ ...props, children: flatChildren })\n\n // If component returns a Promise, wrap it in AsyncXmlNode\n if (result instanceof Promise) {\n return {\n type: AsyncComponent,\n promise: result,\n }\n }\n\n return result\n }\n\n return {\n type,\n props: props ?? {},\n children: flatChildren,\n }\n}\n\nexport { Fragment }\n","import { isComponentClass } from \"../decorators/component.decorator.mjs\";\nimport { AsyncComponent, ClassComponent, Fragment } from \"../types/xml-node.mjs\";\nfunction flattenChildren(children) {\n if (children == null || children === false) {\n return [];\n }\n if (Array.isArray(children)) {\n return children.flat(Infinity).filter((c) => c != null && c !== false);\n }\n return [children];\n}\nexport function jsx(type, props) {\n const { children, ...restProps } = props ?? {};\n const flatChildren = flattenChildren(children);\n if (isComponentClass(type)) {\n return {\n type: ClassComponent,\n componentClass: type,\n props: { ...restProps, children: flatChildren }\n };\n }\n if (typeof type === \"function\") {\n const result = type({ ...restProps, children: flatChildren });\n if (result instanceof Promise) {\n return {\n type: AsyncComponent,\n promise: result\n };\n }\n return result;\n }\n return {\n type,\n props: restProps,\n children: flatChildren\n };\n}\nexport const jsxs = jsx;\nexport function createElement(type, props, ...children) {\n const flatChildren = flattenChildren(children);\n if (isComponentClass(type)) {\n return {\n type: ClassComponent,\n componentClass: type,\n props: { ...props, children: flatChildren }\n };\n }\n if (typeof type === \"function\") {\n const result = type({ ...props, children: flatChildren });\n if (result instanceof Promise) {\n return {\n type: AsyncComponent,\n promise: result\n };\n }\n return result;\n }\n return {\n type,\n props: props ?? {},\n children: flatChildren\n };\n}\nexport { Fragment };\n"],["import type { z, ZodObject, ZodRawShape } from 'zod/v4'\n\nimport type { Registry } from '@navios/di'\n\nimport {\n InjectableScope,\n InjectableType,\n InjectableTokenMeta,\n InjectionToken,\n globalRegistry,\n} from '@navios/di'\n\nimport type { ComponentClass, XmlComponent } from '../types/component.mjs'\n\nexport const ComponentMeta = Symbol.for('xml.component.meta')\n\n// #1 Component without props (no schema)\nexport function Component(): <T extends ComponentClass>(\n target: T,\n context?: ClassDecoratorContext,\n) => T\n\n// #2 Component with props schema\nexport function Component<Schema extends ZodObject<ZodRawShape>>(options: {\n schema: Schema\n registry?: Registry\n}): <T extends new (props: z.output<Schema>, ...args: any[]) => XmlComponent>(\n target: T,\n context?: ClassDecoratorContext,\n) => T\n\n// #3 Component with custom registry only\nexport function Component(options: {\n registry: Registry\n}): <T extends ComponentClass>(\n target: T,\n context?: ClassDecoratorContext,\n) => T\n\nexport function Component(\n options: {\n schema?: ZodObject<ZodRawShape>\n registry?: Registry\n } = {},\n) {\n const { schema, registry = globalRegistry } = options\n\n return <T extends ComponentClass>(\n target: T,\n context?: ClassDecoratorContext,\n ): T => {\n if (\n (context && context.kind !== 'class') ||\n (target instanceof Function && !context)\n ) {\n throw new Error(\n '[@navios/adapter-xml] @Component decorator can only be used on classes.',\n )\n }\n\n // Verify the class has a render method\n if (typeof target.prototype.render !== 'function') {\n throw new Error(\n `[@navios/adapter-xml] @Component class \"${target.name}\" must implement render() method.`,\n )\n }\n\n // Create token with schema if provided\n const injectableToken = schema\n ? InjectionToken.create(target, schema)\n : InjectionToken.create(target)\n\n // Register with Request scope - each render gets fresh instances\n registry.set(\n injectableToken,\n InjectableScope.Request,\n target,\n InjectableType.Class,\n )\n\n // Store token metadata on the class (same pattern as @Injectable)\n // @ts-expect-error - Adding metadata to class\n target[InjectableTokenMeta] = injectableToken\n\n // Mark as component for JSX runtime detection\n // @ts-expect-error - Adding metadata to class\n target[ComponentMeta] = true\n\n return target\n }\n}\n\n/**\n * Type guard to check if a class is a component\n */\nexport function isComponentClass(value: unknown): value is ComponentClass {\n return (\n typeof value === 'function' &&\n // @ts-expect-error - Checking metadata\n value[ComponentMeta] === true\n )\n}\n","import {\n InjectableScope,\n InjectableType,\n InjectableTokenMeta,\n InjectionToken,\n globalRegistry\n} from \"@navios/di\";\nexport const ComponentMeta = /* @__PURE__ */ Symbol.for(\"xml.component.meta\");\nexport function Component(options = {}) {\n const { schema, registry = globalRegistry } = options;\n return (target, context) => {\n if (context && context.kind !== \"class\" || target instanceof Function && !context) {\n throw new Error(\n \"[@navios/adapter-xml] @Component decorator can only be used on classes.\"\n );\n }\n if (typeof target.prototype.render !== \"function\") {\n throw new Error(\n `[@navios/adapter-xml] @Component class \"${target.name}\" must implement render() method.`\n );\n }\n const injectableToken = schema ? InjectionToken.create(target, schema) : InjectionToken.create(target);\n registry.set(\n injectableToken,\n InjectableScope.Request,\n target,\n InjectableType.Class\n );\n target[InjectableTokenMeta] = injectableToken;\n target[ComponentMeta] = true;\n return target;\n };\n}\nexport function isComponentClass(value) {\n return typeof value === \"function\" && // @ts-expect-error - Checking metadata\n value[ComponentMeta] === true;\n}\n"],["import type { EndpointFunctionArgs, HttpMethod, Util_FlatObject } from '@navios/builder'\nimport type { ZodObject, ZodType } from 'zod/v4'\n\nimport { getEndpointMetadata, XmlStreamAdapterToken } from '@navios/core'\n\nimport type { BaseXmlStreamConfig } from '../types/config.mjs'\n\nexport type XmlStreamParams<\n EndpointDeclaration extends {\n config: BaseXmlStreamConfig<any, any, any, any>\n },\n Url extends string = EndpointDeclaration['config']['url'],\n QuerySchema = EndpointDeclaration['config']['querySchema'],\n> = QuerySchema extends ZodObject\n ? EndpointDeclaration['config']['requestSchema'] extends ZodType\n ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema'], true>>\n : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>>\n : EndpointDeclaration['config']['requestSchema'] extends ZodType\n ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, EndpointDeclaration['config']['requestSchema'], true>>\n : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>\n\n/**\n * Decorator for XML Stream endpoints that return JSX-based XML responses.\n *\n * @example\n * ```typescript\n * import { XmlStream } from '@navios/adapter-xml'\n * import { Controller } from '@navios/core'\n *\n * const getRssFeed = declareXmlStream({\n * method: 'GET',\n * url: '/feed.xml',\n * querySchema: undefined,\n * requestSchema: undefined,\n * contentType: 'application/rss+xml',\n * })\n *\n * @Controller('/api')\n * class FeedController {\n * @XmlStream(getRssFeed)\n * async getFeed() {\n * return (\n * <rss version=\"2.0\">\n * <channel>\n * <title>My Feed</title>\n * </channel>\n * </rss>\n * )\n * }\n * }\n * ```\n */\nexport function XmlStream<\n Method extends HttpMethod = HttpMethod,\n Url extends string = string,\n QuerySchema = undefined,\n RequestSchema = ZodType,\n>(endpoint: { config: BaseXmlStreamConfig<Method, Url, QuerySchema, RequestSchema> }) {\n return (\n target: (\n params: QuerySchema extends ZodObject\n ? RequestSchema extends ZodType\n ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, RequestSchema, true>>\n : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>>\n : RequestSchema extends ZodType\n ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, RequestSchema, true>>\n : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>,\n ) => Promise<any>, // Returns XmlNode\n context: ClassMethodDecoratorContext,\n ) => {\n if (typeof target !== 'function') {\n throw new Error('[Navios] XmlStream decorator can only be used on functions.')\n }\n if (context.kind !== 'method') {\n throw new Error('[Navios] XmlStream decorator can only be used on methods.')\n }\n\n const config = endpoint.config\n if (context.metadata) {\n const endpointMetadata = getEndpointMetadata<BaseXmlStreamConfig>(target, context)\n if (endpointMetadata.config && endpointMetadata.config.url) {\n throw new Error(`[Navios] Endpoint ${config.method} ${config.url} already exists.`)\n }\n // @ts-expect-error We don't need to set correctly in the metadata\n endpointMetadata.config = config\n endpointMetadata.adapterToken = XmlStreamAdapterToken\n endpointMetadata.classMethod = target.name\n endpointMetadata.httpMethod = config.method\n endpointMetadata.url = config.url\n }\n return target\n }\n}\n","import { getEndpointMetadata, XmlStreamAdapterToken } from \"@navios/core\";\nexport function XmlStream(endpoint) {\n return (target, context) => {\n if (typeof target !== \"function\") {\n throw new Error(\"[Navios] XmlStream decorator can only be used on functions.\");\n }\n if (context.kind !== \"method\") {\n throw new Error(\"[Navios] XmlStream decorator can only be used on methods.\");\n }\n const config = endpoint.config;\n if (context.metadata) {\n const endpointMetadata = getEndpointMetadata(target, context);\n if (endpointMetadata.config && endpointMetadata.config.url) {\n throw new Error(`[Navios] Endpoint ${config.method} ${config.url} already exists.`);\n }\n endpointMetadata.config = config;\n endpointMetadata.adapterToken = XmlStreamAdapterToken;\n endpointMetadata.classMethod = target.name;\n endpointMetadata.httpMethod = config.method;\n endpointMetadata.url = config.url;\n }\n return target;\n };\n}\n"],["import type { Container } from '@navios/di'\n\nimport type {\n AnyXmlNode,\n AsyncXmlNode,\n CDataNode,\n ClassComponentNode,\n RawXmlNode,\n} from '../types/xml-node.mjs'\nimport type { XmlComponent } from '../types/component.mjs'\n\nimport {\n AsyncComponent,\n CDataSymbol,\n ClassComponent,\n Fragment,\n RawXmlSymbol,\n} from '../types/xml-node.mjs'\n\nexport interface RenderOptions {\n /** Include XML declaration (<?xml version=\"1.0\"?>) - defaults to true */\n declaration?: boolean\n /** XML encoding, defaults to 'UTF-8' */\n encoding?: string\n /** Pretty print with indentation */\n pretty?: boolean\n /**\n * DI container for resolving class components.\n * Required if the tree contains any class components.\n */\n container?: Container\n}\n\nexport class MissingContainerError extends Error {\n constructor(componentName: string) {\n super(\n `[@navios/adapter-xml] Cannot render class component \"${componentName}\" without a container. ` +\n `Pass a container to renderToXml options: renderToXml(node, { container })`,\n )\n this.name = 'MissingContainerError'\n }\n}\n\nexport async function renderToXml(\n node: AnyXmlNode,\n options: RenderOptions = {},\n): Promise<string> {\n const {\n declaration = true,\n encoding = 'UTF-8',\n pretty = false,\n container,\n } = options\n\n let xml = ''\n if (declaration) {\n xml += `<?xml version=\"1.0\" encoding=\"${encoding}\"?>`\n if (pretty) xml += '\\n'\n }\n\n xml += await renderNode(node, pretty ? 0 : -1, container)\n return xml\n}\n\nasync function renderNode(\n node: AnyXmlNode,\n indent: number,\n container: Container | undefined,\n): Promise<string> {\n if (node == null) return ''\n if (typeof node === 'string') return escapeXml(node)\n if (typeof node === 'number') return String(node)\n\n // Handle class components - resolve via DI container\n if (isClassComponentNode(node)) {\n if (!container) {\n throw new MissingContainerError(node.componentClass.name)\n }\n\n // Resolve the component instance from the container, passing props as schema args\n // This validates props via Zod schema if defined on the component\n const instance = (await container.get(\n node.componentClass as any,\n node.props,\n )) as XmlComponent\n\n // Call render() - no arguments, props are already in the instance\n const result = instance.render()\n\n // Handle async render methods\n const resolved = result instanceof Promise ? await result : result\n\n // Recursively render the result\n return renderNode(resolved, indent, container)\n }\n\n // Handle async components - resolve the promise first\n if (isAsyncNode(node)) {\n const resolved = await node.promise\n return renderNode(resolved, indent, container)\n }\n\n // Handle CDATA nodes\n if (isCDataNode(node)) {\n return renderCData(node.content)\n }\n\n // Handle Raw XML nodes - no escaping\n if (isRawXmlNode(node)) {\n return node.content\n }\n\n const { type, props, children } = node\n\n if (type === Fragment) {\n const renderedChildren = await Promise.all(\n children\n .filter((c) => c != null)\n .map((c) => renderNode(c, indent, container)),\n )\n return renderedChildren.join('')\n }\n\n const prefix = indent >= 0 ? ' '.repeat(indent) : ''\n const newline = indent >= 0 ? '\\n' : ''\n\n const attrs = Object.entries(props)\n .filter(([_, v]) => v != null)\n .map(([k, v]) => ` ${k}=\"${escapeAttr(String(v))}\"`)\n .join('')\n\n if (children.length === 0) {\n return `${prefix}<${type}${attrs}/>${newline}`\n }\n\n const childIndent = indent >= 0 ? indent + 1 : -1\n\n // Resolve all children (including async and class components) in parallel\n const resolvedChildren = await Promise.all(\n children\n .filter((c) => c != null)\n .map((c) => renderNode(c, childIndent, container)),\n )\n const childContent = resolvedChildren.join('')\n\n // Check if children are simple (text, numbers, CDATA, or raw XML)\n const hasOnlySimpleContent = children.every(\n (c) =>\n typeof c === 'string' ||\n typeof c === 'number' ||\n isCDataNode(c) ||\n isRawXmlNode(c),\n )\n if (hasOnlySimpleContent) {\n return `${prefix}<${type}${attrs}>${childContent}</${type}>${newline}`\n }\n\n return `${prefix}<${type}${attrs}>${newline}${childContent}${prefix}</${type}>${newline}`\n}\n\nfunction isClassComponentNode(node: unknown): node is ClassComponentNode {\n return (\n node !== null &&\n typeof node === 'object' &&\n 'type' in node &&\n node.type === ClassComponent\n )\n}\n\nfunction isAsyncNode(node: unknown): node is AsyncXmlNode {\n return (\n node !== null &&\n typeof node === 'object' &&\n 'type' in node &&\n node.type === AsyncComponent\n )\n}\n\nfunction isCDataNode(node: any): node is CDataNode {\n return node && typeof node === 'object' && node.type === CDataSymbol\n}\n\nfunction isRawXmlNode(node: any): node is RawXmlNode {\n return node && typeof node === 'object' && node.type === RawXmlSymbol\n}\n\n/**\n * Renders content as CDATA section.\n * If content contains \"]]>\", splits into multiple CDATA sections.\n * The technique is to end the CDATA section before ]]>, then start a new one.\n */\nfunction renderCData(content: string): string {\n // Handle the edge case where content contains \"]]>\"\n // We split on \"]]>\" and join with \"]]]]><![CDATA[>\" which effectively\n // ends the CDATA section after \"]]\" and starts a new one for \">\"\n if (content.includes(']]>')) {\n // Replace ]]> with ]]]]><![CDATA[> which closes CDATA before > and reopens it\n const escaped = content.replace(/]]>/g, ']]]]><![CDATA[>')\n return `<![CDATA[${escaped}]]>`\n }\n return `<![CDATA[${content}]]>`\n}\n\nfunction escapeXml(str: string): string {\n return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')\n}\n\nfunction escapeAttr(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n}\n","import {\n AsyncComponent,\n CDataSymbol,\n ClassComponent,\n Fragment,\n RawXmlSymbol\n} from \"../types/xml-node.mjs\";\nexport class MissingContainerError extends Error {\n constructor(componentName) {\n super(\n `[@navios/adapter-xml] Cannot render class component \"${componentName}\" without a container. Pass a container to renderToXml options: renderToXml(node, { container })`\n );\n this.name = \"MissingContainerError\";\n }\n}\nexport async function renderToXml(node, options = {}) {\n const {\n declaration = true,\n encoding = \"UTF-8\",\n pretty = false,\n container\n } = options;\n let xml = \"\";\n if (declaration) {\n xml += `<?xml version=\"1.0\" encoding=\"${encoding}\"?>`;\n if (pretty) xml += \"\\n\";\n }\n xml += await renderNode(node, pretty ? 0 : -1, container);\n return xml;\n}\nasync function renderNode(node, indent, container) {\n if (node == null) return \"\";\n if (typeof node === \"string\") return escapeXml(node);\n if (typeof node === \"number\") return String(node);\n if (isClassComponentNode(node)) {\n if (!container) {\n throw new MissingContainerError(node.componentClass.name);\n }\n const instance = await container.get(\n node.componentClass,\n node.props\n );\n const result = instance.render();\n const resolved = result instanceof Promise ? await result : result;\n return renderNode(resolved, indent, container);\n }\n if (isAsyncNode(node)) {\n const resolved = await node.promise;\n return renderNode(resolved, indent, container);\n }\n if (isCDataNode(node)) {\n return renderCData(node.content);\n }\n if (isRawXmlNode(node)) {\n return node.content;\n }\n const { type, props, children } = node;\n if (type === Fragment) {\n const renderedChildren = await Promise.all(\n children.filter((c) => c != null).map((c) => renderNode(c, indent, container))\n );\n return renderedChildren.join(\"\");\n }\n const prefix = indent >= 0 ? \" \".repeat(indent) : \"\";\n const newline = indent >= 0 ? \"\\n\" : \"\";\n const attrs = Object.entries(props).filter(([_, v]) => v != null).map(([k, v]) => ` ${k}=\"${escapeAttr(String(v))}\"`).join(\"\");\n if (children.length === 0) {\n return `${prefix}<${type}${attrs}/>${newline}`;\n }\n const childIndent = indent >= 0 ? indent + 1 : -1;\n const resolvedChildren = await Promise.all(\n children.filter((c) => c != null).map((c) => renderNode(c, childIndent, container))\n );\n const childContent = resolvedChildren.join(\"\");\n const hasOnlySimpleContent = children.every(\n (c) => typeof c === \"string\" || typeof c === \"number\" || isCDataNode(c) || isRawXmlNode(c)\n );\n if (hasOnlySimpleContent) {\n return `${prefix}<${type}${attrs}>${childContent}</${type}>${newline}`;\n }\n return `${prefix}<${type}${attrs}>${newline}${childContent}${prefix}</${type}>${newline}`;\n}\nfunction isClassComponentNode(node) {\n return node !== null && typeof node === \"object\" && \"type\" in node && node.type === ClassComponent;\n}\nfunction isAsyncNode(node) {\n return node !== null && typeof node === \"object\" && \"type\" in node && node.type === AsyncComponent;\n}\nfunction isCDataNode(node) {\n return node && typeof node === \"object\" && node.type === CDataSymbol;\n}\nfunction isRawXmlNode(node) {\n return node && typeof node === \"object\" && node.type === RawXmlSymbol;\n}\nfunction renderCData(content) {\n if (content.includes(\"]]>\")) {\n const escaped = content.replace(/]]>/g, \"]]]]><![CDATA[>\");\n return `<![CDATA[${escaped}]]>`;\n }\n return `<![CDATA[${content}]]>`;\n}\nfunction escapeXml(str) {\n return str.replace(/&/g, \"&amp;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\");\n}\nfunction escapeAttr(str) {\n return str.replace(/&/g, \"&amp;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\").replace(/\"/g, \"&quot;\");\n}\n"],["import type { ZodObject, ZodRawShape } from 'zod/v4'\nimport type { z } from 'zod/v4'\n\nimport type { AnyXmlNode, XmlNode } from '../types/xml-node.mjs'\n\nexport interface TagComponent<Props extends Record<string, unknown>> {\n (props: Props & { children?: AnyXmlNode | AnyXmlNode[] }): XmlNode\n tagName: string\n}\n\n/**\n * Creates a type-safe XML tag component with optional Zod schema validation.\n *\n * @param name - The tag name (supports namespace prefixes like 'atom:link')\n * @param propsSchema - Optional Zod schema for validating props\n * @returns A component function that can be used in JSX\n *\n * @example\n * ```tsx\n * // Simple tag\n * const item = defineTag('item')\n * <item>Content</item>\n *\n * // Namespaced tag with Zod validation\n * const atomLink = defineTag('atom:link', z.object({\n * href: z.string().url(),\n * rel: z.enum(['self', 'alternate']),\n * type: z.string().optional(),\n * }))\n * <atomLink href=\"https://example.com/feed\" rel=\"self\" />\n * ```\n */\nexport function defineTag<T extends ZodRawShape>(\n name: string,\n propsSchema?: ZodObject<T>,\n): TagComponent<T extends ZodRawShape ? z.infer<ZodObject<T>> : Record<string, never>> {\n const component = (props: any): XmlNode => {\n const { children, ...rest } = props ?? {}\n\n // Validate props if schema provided\n if (propsSchema) {\n propsSchema.parse(rest)\n }\n\n return {\n type: name,\n props: rest,\n children: Array.isArray(children) ? children : children ? [children] : [],\n }\n }\n\n component.tagName = name\n return component as any\n}\n","export function defineTag(name, propsSchema) {\n const component = (props) => {\n const { children, ...rest } = props ?? {};\n if (propsSchema) {\n propsSchema.parse(rest);\n }\n return {\n type: name,\n props: rest,\n children: Array.isArray(children) ? children : children ? [children] : []\n };\n };\n component.tagName = name;\n return component;\n}\n"],["import type { HttpMethod } from '@navios/builder'\n\nimport type { BaseXmlStreamConfig } from '../types/config.mjs'\n\n/**\n * Declares an XML Stream endpoint configuration for use with @XmlStream decorator.\n *\n * @example\n * ```typescript\n * import { declareXmlStream } from '@navios/adapter-xml'\n *\n * export const getRssFeed = declareXmlStream({\n * method: 'GET',\n * url: '/feed.xml',\n * querySchema: undefined,\n * requestSchema: undefined,\n * contentType: 'application/rss+xml',\n * xmlDeclaration: true,\n * })\n * ```\n */\nexport function declareXmlStream<\n Method extends HttpMethod,\n Url extends string,\n QuerySchema = undefined,\n RequestSchema = undefined,\n>(\n config: BaseXmlStreamConfig<Method, Url, QuerySchema, RequestSchema>,\n): { config: BaseXmlStreamConfig<Method, Url, QuerySchema, RequestSchema> } {\n return { config }\n}\n","export function declareXmlStream(config) {\n return { config };\n}\n"],["import type {\n AbstractHttpHandlerAdapterInterface,\n HandlerMetadata,\n} from '@navios/core'\nimport type { ClassType, RequestContextHolder } from '@navios/di'\n\nimport { StreamAdapterToken, XmlStreamAdapterToken } from '@navios/core'\nimport { Container, inject, Injectable } from '@navios/di'\n\nimport type { BaseXmlStreamConfig } from '../types/config.mjs'\nimport type { AnyXmlNode } from '../types/xml-node.mjs'\n\nimport { renderToXml } from '../runtime/render-to-xml.mjs'\n\n@Injectable({\n token: XmlStreamAdapterToken,\n})\nexport class XmlStreamAdapterService implements AbstractHttpHandlerAdapterInterface {\n protected container = inject(Container)\n /** Base stream adapter - we proxy hasSchema, prepareArguments, provideSchema to it */\n protected streamAdapter = inject(StreamAdapterToken)\n\n /**\n * Proxy to base StreamAdapter - reuses existing argument preparation logic\n * (handles querySchema, requestSchema, URL params for both Fastify and Bun)\n */\n prepareArguments(handlerMetadata: HandlerMetadata<BaseXmlStreamConfig>) {\n return this.streamAdapter.prepareArguments?.(handlerMetadata) ?? []\n }\n\n provideSchema(\n handlerMetadata: HandlerMetadata<BaseXmlStreamConfig>,\n ): Record<string, any> {\n if (\n 'provideSchema' in this.streamAdapter &&\n typeof this.streamAdapter.provideSchema === 'function'\n ) {\n return this.streamAdapter.provideSchema(handlerMetadata)\n }\n return {}\n }\n\n hasSchema(handlerMetadata: HandlerMetadata<any>): boolean {\n if (\n 'hasSchema' in this.streamAdapter &&\n typeof this.streamAdapter.hasSchema === 'function'\n ) {\n return this.streamAdapter.hasSchema(handlerMetadata)\n }\n return false\n }\n\n /**\n * Custom handler - renders JSX to XML and handles response for both Fastify and Bun\n */\n provideHandler(\n controller: ClassType,\n handlerMetadata: HandlerMetadata<BaseXmlStreamConfig>,\n ): (context: RequestContextHolder, request: any, reply: any) => Promise<any> {\n const getters = this.prepareArguments(handlerMetadata)\n const config = handlerMetadata.config\n\n const formatArguments = async (request: any) => {\n const argument: Record<string, any> = {}\n const promises: Promise<void>[] = []\n for (const getter of getters) {\n const res = getter(argument, request)\n if (res instanceof Promise) {\n promises.push(res)\n }\n }\n await Promise.all(promises)\n return argument\n }\n\n const contentType = config.contentType ?? 'application/xml'\n const renderOptions = {\n declaration: config.xmlDeclaration ?? true,\n encoding: config.encoding ?? 'UTF-8',\n container: this.container,\n }\n\n return async (context: RequestContextHolder, request: any, reply: any) => {\n const controllerInstance = await this.container.get(controller)\n const argument = await formatArguments(request)\n\n // Call controller method - returns XmlNode (JSX), may contain async/class components\n const xmlNode: AnyXmlNode =\n await controllerInstance[handlerMetadata.classMethod](argument)\n\n // Render JSX to XML string (async - resolves all async and class components)\n const xml = await renderToXml(xmlNode, renderOptions)\n\n // Environment detection: Bun doesn't have reply\n const isHttpStandardEnvironment = reply === undefined\n\n if (isHttpStandardEnvironment) {\n // Bun: return Response object\n const headers: Record<string, string> = {\n 'Content-Type': contentType,\n }\n for (const [key, value] of Object.entries(handlerMetadata.headers)) {\n if (value != null) {\n headers[key] = String(value)\n }\n }\n return new Response(xml, {\n status: handlerMetadata.successStatusCode,\n headers,\n })\n } else {\n // Fastify: use reply object\n reply\n .status(handlerMetadata.successStatusCode)\n .header('Content-Type', contentType)\n .headers(handlerMetadata.headers)\n .send(xml)\n }\n }\n }\n}\n","var __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for(\"Symbol.\" + name);\nvar __typeError = (msg) => {\n throw TypeError(msg);\n};\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __name = (target, value) => __defProp(target, \"name\", { value, configurable: true });\nvar __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol(\"metadata\")] ?? null)];\nvar __decoratorStrings = [\"class\", \"method\", \"getter\", \"setter\", \"accessor\", \"field\", \"value\", \"get\", \"set\"];\nvar __expectFn = (fn) => fn !== void 0 && typeof fn !== \"function\" ? __typeError(\"Function expected\") : fn;\nvar __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError(\"Already initialized\") : fns.push(__expectFn(fn || null)) });\nvar __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol(\"metadata\"), array[3]);\nvar __runInitializers = (array, flags, self, value) => {\n for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);\n return value;\n};\nvar __decorateElement = (array, flags, name, decorators, target, extra) => {\n var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);\n var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];\n var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);\n var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {\n return __privateGet(this, extra);\n }, set [name](x) {\n return __privateSet(this, extra, x);\n } }, name));\n k ? p && k < 4 && __name(extra, (k > 2 ? \"set \" : k > 1 ? \"get \" : \"\") + name) : __name(target, name);\n for (var i = decorators.length - 1; i >= 0; i--) {\n ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);\n if (k) {\n ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };\n if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];\n if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;\n }\n it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;\n if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);\n else if (typeof it !== \"object\" || it === null) __typeError(\"Object expected\");\n else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);\n }\n return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;\n};\nvar __accessCheck = (obj, member, msg) => member.has(obj) || __typeError(\"Cannot \" + msg);\nvar __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the \"in\" operator on this value') : member.has(obj);\nvar __privateGet = (obj, member, getter) => (__accessCheck(obj, member, \"read from private field\"), getter ? getter.call(obj) : member.get(obj));\nvar __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, \"write to private field\"), setter ? setter.call(obj, value) : member.set(obj, value), value);\nvar __privateMethod = (obj, member, method) => (__accessCheck(obj, member, \"access private method\"), method);\nvar _XmlStreamAdapterService_decorators, _init;\nimport { StreamAdapterToken, XmlStreamAdapterToken } from \"@navios/core\";\nimport { Container, inject, Injectable } from \"@navios/di\";\nimport { renderToXml } from \"../runtime/render-to-xml.mjs\";\n_XmlStreamAdapterService_decorators = [Injectable({\n token: XmlStreamAdapterToken\n})];\nexport class XmlStreamAdapterService {\n container = inject(Container);\n /** Base stream adapter - we proxy hasSchema, prepareArguments, provideSchema to it */\n streamAdapter = inject(StreamAdapterToken);\n /**\n * Proxy to base StreamAdapter - reuses existing argument preparation logic\n * (handles querySchema, requestSchema, URL params for both Fastify and Bun)\n */\n prepareArguments(handlerMetadata) {\n return this.streamAdapter.prepareArguments?.(handlerMetadata) ?? [];\n }\n provideSchema(handlerMetadata) {\n if (\"provideSchema\" in this.streamAdapter && typeof this.streamAdapter.provideSchema === \"function\") {\n return this.streamAdapter.provideSchema(handlerMetadata);\n }\n return {};\n }\n hasSchema(handlerMetadata) {\n if (\"hasSchema\" in this.streamAdapter && typeof this.streamAdapter.hasSchema === \"function\") {\n return this.streamAdapter.hasSchema(handlerMetadata);\n }\n return false;\n }\n /**\n * Custom handler - renders JSX to XML and handles response for both Fastify and Bun\n */\n provideHandler(controller, handlerMetadata) {\n const getters = this.prepareArguments(handlerMetadata);\n const config = handlerMetadata.config;\n const formatArguments = async (request) => {\n const argument = {};\n const promises = [];\n for (const getter of getters) {\n const res = getter(argument, request);\n if (res instanceof Promise) {\n promises.push(res);\n }\n }\n await Promise.all(promises);\n return argument;\n };\n const contentType = config.contentType ?? \"application/xml\";\n const renderOptions = {\n declaration: config.xmlDeclaration ?? true,\n encoding: config.encoding ?? \"UTF-8\",\n container: this.container\n };\n return async (context, request, reply) => {\n const controllerInstance = await this.container.get(controller);\n const argument = await formatArguments(request);\n const xmlNode = await controllerInstance[handlerMetadata.classMethod](argument);\n const xml = await renderToXml(xmlNode, renderOptions);\n const isHttpStandardEnvironment = reply === void 0;\n if (isHttpStandardEnvironment) {\n const headers = {\n \"Content-Type\": contentType\n };\n for (const [key, value] of Object.entries(handlerMetadata.headers)) {\n if (value != null) {\n headers[key] = String(value);\n }\n }\n return new Response(xml, {\n status: handlerMetadata.successStatusCode,\n headers\n });\n } else {\n reply.status(handlerMetadata.successStatusCode).header(\"Content-Type\", contentType).headers(handlerMetadata.headers).send(xml);\n }\n };\n }\n}\n_init = __decoratorStart(null);\nXmlStreamAdapterService = __decorateElement(_init, 0, \"XmlStreamAdapterService\", _XmlStreamAdapterService_decorators, XmlStreamAdapterService);\n__runInitializers(_init, 1, XmlStreamAdapterService);\n"]]
1
+ [["import type { XmlComponent, XmlStreamParams } from '../../src/index.mjs'\n\nimport { builder } from '@navios/builder'\nimport {\n Controller,\n Endpoint,\n inject,\n Injectable,\n InjectableScope,\n Module,\n NaviosApplication,\n NaviosFactory,\n type EndpointParams,\n} from '@navios/core'\nimport { defineBunEnvironment } from '@navios/adapter-bun'\n\nimport supertest from 'supertest'\nimport { afterAll, beforeAll, describe, expect, it } from 'bun:test'\nimport { z } from 'zod/v4'\n\nimport {\n CData,\n Component,\n DangerouslyInsertRawXml,\n declareXmlStream,\n defineXmlEnvironment,\n Fragment,\n XmlStream,\n createElement,\n} from '../../src/index.mjs'\n\n// Helper to merge environments\nfunction mergeEnvironments(...envs: Array<{ httpTokens: Map<any, any> }>): {\n httpTokens: Map<any, any>\n} {\n const merged = new Map()\n for (const env of envs) {\n for (const [key, value] of env.httpTokens) {\n merged.set(key, value)\n }\n }\n return { httpTokens: merged }\n}\n\ndescribe('XML Stream with Bun adapter', () => {\n let server: NaviosApplication\n let serverUrl: string\n\n // Request scoped service for tracking\n @Injectable({\n scope: InjectableScope.Request,\n })\n class RequestTrackerService {\n private requestId: string = Math.random().toString(36).substring(7)\n\n getRequestId(): string {\n return this.requestId\n }\n }\n\n // Injectable data service\n @Injectable()\n class DataService {\n getItems() {\n return [\n { id: '1', title: 'First Item', description: 'Description 1' },\n { id: '2', title: 'Second Item', description: 'Description 2' },\n { id: '3', title: 'Third Item', description: 'Description 3' },\n ]\n }\n\n getItem(id: string) {\n return this.getItems().find((item) => item.id === id)\n }\n }\n\n // Class component with DI\n @Component()\n class ItemComponent implements XmlComponent {\n private dataService = inject(DataService)\n private tracker = inject(RequestTrackerService)\n\n constructor(private props: { id: string }) {}\n\n render() {\n const item = this.dataService.getItem(this.props.id)\n if (!item) {\n return createElement('error', null, 'Item not found')\n }\n return createElement(\n 'item',\n { id: item.id, requestId: this.tracker.getRequestId() },\n createElement('title', null, item.title),\n createElement('description', null, item.description),\n )\n }\n }\n\n // Async component\n async function AsyncDataComponent({ delay }: { delay: number }) {\n await new Promise((resolve) => setTimeout(resolve, delay))\n return createElement('async-data', null, `Loaded after ${delay}ms`)\n }\n\n // Simple RSS feed endpoint\n const getRssFeed = declareXmlStream({\n method: 'GET',\n url: '/feed.xml',\n querySchema: undefined,\n requestSchema: undefined,\n contentType: 'application/rss+xml',\n xmlDeclaration: true,\n })\n\n // Atom feed with query params\n const getAtomFeed = declareXmlStream({\n method: 'GET',\n url: '/atom.xml',\n querySchema: z.object({\n limit: z.coerce.number().optional().default(10),\n }),\n requestSchema: undefined,\n contentType: 'application/atom+xml',\n xmlDeclaration: true,\n })\n\n // Sitemap endpoint\n const getSitemap = declareXmlStream({\n method: 'GET',\n url: '/sitemap.xml',\n querySchema: undefined,\n requestSchema: undefined,\n contentType: 'application/xml',\n xmlDeclaration: true,\n })\n\n // Dynamic XML with URL params (use path without extension for Bun compatibility)\n const getItemXml = declareXmlStream({\n method: 'GET',\n url: '/items/$id',\n querySchema: undefined,\n requestSchema: undefined,\n contentType: 'application/xml',\n xmlDeclaration: true,\n })\n\n // POST endpoint for XML generation\n const postGenerateXml = declareXmlStream({\n method: 'POST',\n url: '/generate.xml',\n querySchema: undefined,\n requestSchema: z.object({\n title: z.string(),\n items: z.array(z.string()),\n }),\n contentType: 'application/xml',\n xmlDeclaration: true,\n })\n\n // Endpoint with async components\n const getAsyncXml = declareXmlStream({\n method: 'GET',\n url: '/async.xml',\n querySchema: undefined,\n requestSchema: undefined,\n contentType: 'application/xml',\n xmlDeclaration: true,\n })\n\n // Endpoint with class components (DI) - use path without extension for Bun compatibility\n const getDiXml = declareXmlStream({\n method: 'GET',\n url: '/di/$id',\n querySchema: undefined,\n requestSchema: undefined,\n contentType: 'application/xml',\n xmlDeclaration: true,\n })\n\n // Endpoint with CDATA and raw XML\n const getSpecialXml = declareXmlStream({\n method: 'GET',\n url: '/special.xml',\n querySchema: undefined,\n requestSchema: undefined,\n contentType: 'application/xml',\n xmlDeclaration: true,\n })\n\n // Also test regular JSON endpoint alongside XML\n const getJsonEndpoint = builder().declareEndpoint({\n method: 'GET',\n url: '/api/data',\n responseSchema: z.object({\n message: z.string(),\n }),\n })\n\n @Controller()\n class FeedController {\n private dataService = inject(DataService)\n private tracker = inject(RequestTrackerService)\n\n @XmlStream(getRssFeed)\n async getRssFeed(_params: XmlStreamParams<typeof getRssFeed>) {\n const items = this.dataService.getItems()\n return (\n <rss version=\"2.0\">\n <channel>\n <title>My Blog</title>\n <link>https://example.com</link>\n <description>A sample RSS feed</description>\n {items.map((item) => (\n <item key={item.id}>\n <title>{item.title}</title>\n <link>https://example.com/items/{item.id}</link>\n <description>{item.description}</description>\n </item>\n ))}\n </channel>\n </rss>\n )\n }\n\n @XmlStream(getAtomFeed)\n async getAtomFeed(params: XmlStreamParams<typeof getAtomFeed>) {\n const limit = params.params.limit\n const items = this.dataService.getItems().slice(0, limit)\n return (\n <feed xmlns=\"http://www.w3.org/2005/Atom\">\n <title>My Atom Feed</title>\n <link href=\"https://example.com/atom.xml\" rel=\"self\" />\n <id>https://example.com/</id>\n <updated>2025-01-01T00:00:00Z</updated>\n {items.map((item) => (\n <entry key={item.id}>\n <title>{item.title}</title>\n <id>https://example.com/items/{item.id}</id>\n <updated>2025-01-01T00:00:00Z</updated>\n <summary>{item.description}</summary>\n </entry>\n ))}\n </feed>\n )\n }\n\n @XmlStream(getSitemap)\n async getSitemap(_params: XmlStreamParams<typeof getSitemap>) {\n const items = this.dataService.getItems()\n return (\n <urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n <url>\n <loc>https://example.com/</loc>\n <lastmod>2025-01-01</lastmod>\n <changefreq>daily</changefreq>\n <priority>1.0</priority>\n </url>\n {items.map((item) => (\n <url key={item.id}>\n <loc>https://example.com/items/{item.id}</loc>\n <lastmod>2025-01-01</lastmod>\n <changefreq>weekly</changefreq>\n <priority>0.8</priority>\n </url>\n ))}\n </urlset>\n )\n }\n\n @XmlStream(getItemXml)\n async getItemXml(params: XmlStreamParams<typeof getItemXml>) {\n const item = this.dataService.getItem(params.urlParams.id as string)\n if (!item) {\n return (\n <error>\n <message>Item not found</message>\n <requestedId>{params.urlParams.id}</requestedId>\n </error>\n )\n }\n return (\n <item id={item.id}>\n <title>{item.title}</title>\n <description>{item.description}</description>\n </item>\n )\n }\n\n @XmlStream(postGenerateXml)\n async postGenerateXml(params: XmlStreamParams<typeof postGenerateXml>) {\n const { title, items } = params.data\n return (\n <generated>\n <title>{title}</title>\n <items count={String(items.length)}>\n {items.map((item, index) => (\n <item index={String(index)} key={index}>\n {item}\n </item>\n ))}\n </items>\n </generated>\n )\n }\n\n @XmlStream(getAsyncXml)\n async getAsyncXml(_params: XmlStreamParams<typeof getAsyncXml>) {\n return (\n <root>\n <sync>Immediate content</sync>\n <AsyncDataComponent delay={10} />\n <AsyncDataComponent delay={5} />\n </root>\n )\n }\n\n @XmlStream(getDiXml)\n async getDiXml(params: XmlStreamParams<typeof getDiXml>) {\n return (\n <root requestId={this.tracker.getRequestId()}>\n <ItemComponent id={params.urlParams.id as string} />\n </root>\n )\n }\n\n @XmlStream(getSpecialXml)\n async getSpecialXml(_params: XmlStreamParams<typeof getSpecialXml>) {\n return (\n <root>\n <cdata-example>\n <CData>\n {'This is <raw> HTML & XML content that should not be escaped'}\n </CData>\n </cdata-example>\n <raw-xml-example>\n <DangerouslyInsertRawXml>\n {'<nested><element attr=\"value\">text</element></nested>'}\n </DangerouslyInsertRawXml>\n </raw-xml-example>\n <escaped>{'<this> & \"that\" should be escaped'}</escaped>\n </root>\n )\n }\n\n @Endpoint(getJsonEndpoint)\n async getJsonData(_params: EndpointParams<typeof getJsonEndpoint>) {\n return { message: 'JSON endpoint works alongside XML' }\n }\n }\n\n @Module({\n controllers: [FeedController],\n })\n class AppModule {}\n\n beforeAll(async () => {\n const bunEnv = defineBunEnvironment()\n const xmlEnv = defineXmlEnvironment()\n const mergedEnv = mergeEnvironments(bunEnv, xmlEnv)\n\n server = await NaviosFactory.create(AppModule, {\n adapter: mergedEnv,\n })\n await server.init()\n await server.listen({ port: 3002, host: 'localhost' })\n serverUrl = server.getServer().url.href\n })\n\n afterAll(async () => {\n await server.close()\n })\n\n describe('Basic XML endpoints', () => {\n it('should return RSS feed with correct content type', async () => {\n const response = await supertest(serverUrl).get('/feed.xml')\n\n expect(response.status).toBe(200)\n expect(response.headers['content-type']).toContain('application/rss+xml')\n expect(response.text).toContain('<?xml version=\"1.0\" encoding=\"UTF-8\"?>')\n expect(response.text).toContain('<rss version=\"2.0\">')\n expect(response.text).toContain('<title>My Blog</title>')\n expect(response.text).toContain('<item>')\n expect(response.text).toContain('<title>First Item</title>')\n })\n\n it('should return Atom feed with query params', async () => {\n const response = await supertest(serverUrl).get('/atom.xml?limit=2')\n\n expect(response.status).toBe(200)\n expect(response.headers['content-type']).toContain('application/atom+xml')\n expect(response.text).toContain(\n '<feed xmlns=\"http://www.w3.org/2005/Atom\">',\n )\n\n // Count entries - should be limited to 2\n const entryCount = (response.text.match(/<entry>/g) || []).length\n expect(entryCount).toBe(2)\n })\n\n it('should return sitemap XML', async () => {\n const response = await supertest(serverUrl).get('/sitemap.xml')\n\n expect(response.status).toBe(200)\n expect(response.headers['content-type']).toContain('application/xml')\n expect(response.text).toContain(\n '<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">',\n )\n expect(response.text).toContain('<loc>https://example.com/</loc>')\n expect(response.text).toContain('<priority>1.0</priority>')\n })\n })\n\n describe('URL parameters', () => {\n it('should handle URL parameters in XML endpoint', async () => {\n const response = await supertest(serverUrl).get('/items/1')\n\n expect(response.status).toBe(200)\n expect(response.text).toContain('<item id=\"1\">')\n expect(response.text).toContain('<title>First Item</title>')\n })\n\n it('should handle non-existent item', async () => {\n const response = await supertest(serverUrl).get('/items/999')\n\n expect(response.status).toBe(200)\n expect(response.text).toContain('<error>')\n expect(response.text).toContain('<message>Item not found</message>')\n expect(response.text).toContain('<requestedId>999</requestedId>')\n })\n })\n\n describe('POST with request body', () => {\n it('should generate XML from POST body', async () => {\n const response = await supertest(serverUrl)\n .post('/generate.xml')\n .send({\n title: 'Generated Document',\n items: ['Alpha', 'Beta', 'Gamma'],\n })\n\n expect(response.status).toBe(200)\n expect(response.text).toContain('<generated>')\n expect(response.text).toContain('<title>Generated Document</title>')\n expect(response.text).toContain('<items count=\"3\">')\n expect(response.text).toContain('<item index=\"0\">Alpha</item>')\n expect(response.text).toContain('<item index=\"1\">Beta</item>')\n expect(response.text).toContain('<item index=\"2\">Gamma</item>')\n })\n })\n\n describe('Async components', () => {\n it('should resolve async components in XML', async () => {\n const response = await supertest(serverUrl).get('/async.xml')\n\n expect(response.status).toBe(200)\n expect(response.text).toContain('<sync>Immediate content</sync>')\n expect(response.text).toContain(\n '<async-data>Loaded after 10ms</async-data>',\n )\n expect(response.text).toContain(\n '<async-data>Loaded after 5ms</async-data>',\n )\n })\n })\n\n describe('Class components with DI', () => {\n it('should render class components with injected services', async () => {\n const response = await supertest(serverUrl).get('/di/1')\n\n expect(response.status).toBe(200)\n expect(response.text).toContain('<root requestId=')\n expect(response.text).toContain('<item id=\"1\"')\n expect(response.text).toContain('<title>First Item</title>')\n })\n\n it('should isolate request-scoped services across parallel requests', async () => {\n const requests = [\n supertest(serverUrl).get('/di/1'),\n supertest(serverUrl).get('/di/2'),\n supertest(serverUrl).get('/di/3'),\n ]\n\n const responses = await Promise.all(requests)\n\n // All should succeed\n responses.forEach((response) => {\n expect(response.status).toBe(200)\n })\n\n // Extract request IDs from the responses\n const requestIds = responses.map((response) => {\n const match = response.text.match(/requestId=\"([^\"]+)\"/)\n return match ? match[1] : null\n })\n\n // All request IDs should be unique\n const uniqueIds = new Set(requestIds.filter(Boolean))\n expect(uniqueIds.size).toBe(3)\n })\n })\n\n describe('Special XML content', () => {\n it('should handle CDATA and raw XML correctly', async () => {\n const response = await supertest(serverUrl).get('/special.xml')\n\n expect(response.status).toBe(200)\n\n // CDATA should preserve raw content\n expect(response.text).toContain(\n '<![CDATA[This is <raw> HTML & XML content that should not be escaped]]>',\n )\n\n // Raw XML should be inserted without escaping\n expect(response.text).toContain(\n '<nested><element attr=\"value\">text</element></nested>',\n )\n\n // Regular content should be escaped\n expect(response.text).toContain(\n '&lt;this&gt; &amp; \"that\" should be escaped',\n )\n })\n })\n\n describe('Mixed endpoints', () => {\n it('should work alongside regular JSON endpoints', async () => {\n const xmlResponse = await supertest(serverUrl).get('/feed.xml')\n const jsonResponse = await supertest(serverUrl).get('/api/data')\n\n expect(xmlResponse.status).toBe(200)\n expect(xmlResponse.headers['content-type']).toContain(\n 'application/rss+xml',\n )\n\n expect(jsonResponse.status).toBe(200)\n expect(jsonResponse.body.message).toBe(\n 'JSON endpoint works alongside XML',\n )\n })\n })\n\n describe('Fragment support', () => {\n it('should correctly render fragments within XML', async () => {\n // The RSS feed uses fragments implicitly with array mapping\n const response = await supertest(serverUrl).get('/feed.xml')\n\n expect(response.status).toBe(200)\n // Multiple items should be rendered without extra wrapper\n const itemCount = (response.text.match(/<item>/g) || []).length\n expect(itemCount).toBeGreaterThan(1)\n })\n })\n})\n","var __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for(\"Symbol.\" + name);\nvar __typeError = (msg) => {\n throw TypeError(msg);\n};\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __name = (target, value) => __defProp(target, \"name\", { value, configurable: true });\nvar __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol(\"metadata\")] ?? null)];\nvar __decoratorStrings = [\"class\", \"method\", \"getter\", \"setter\", \"accessor\", \"field\", \"value\", \"get\", \"set\"];\nvar __expectFn = (fn) => fn !== void 0 && typeof fn !== \"function\" ? __typeError(\"Function expected\") : fn;\nvar __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError(\"Already initialized\") : fns.push(__expectFn(fn || null)) });\nvar __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol(\"metadata\"), array[3]);\nvar __runInitializers = (array, flags, self, value) => {\n for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);\n return value;\n};\nvar __decorateElement = (array, flags, name, decorators, target, extra) => {\n var fn, it2, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);\n var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];\n var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);\n var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {\n return __privateGet(this, extra);\n }, set [name](x) {\n return __privateSet(this, extra, x);\n } }, name));\n k ? p && k < 4 && __name(extra, (k > 2 ? \"set \" : k > 1 ? \"get \" : \"\") + name) : __name(target, name);\n for (var i = decorators.length - 1; i >= 0; i--) {\n ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);\n if (k) {\n ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };\n if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];\n if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;\n }\n it2 = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;\n if (k ^ 4 || it2 === void 0) __expectFn(it2) && (k > 4 ? initializers.unshift(it2) : k ? p ? extra = it2 : desc[key] = it2 : target = it2);\n else if (typeof it2 !== \"object\" || it2 === null) __typeError(\"Object expected\");\n else __expectFn(fn = it2.get) && (desc.get = fn), __expectFn(fn = it2.set) && (desc.set = fn), __expectFn(fn = it2.init) && initializers.unshift(fn);\n }\n return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;\n};\nvar __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== \"symbol\" ? key + \"\" : key, value);\nvar __accessCheck = (obj, member, msg) => member.has(obj) || __typeError(\"Cannot \" + msg);\nvar __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the \"in\" operator on this value') : member.has(obj);\nvar __privateGet = (obj, member, getter) => (__accessCheck(obj, member, \"read from private field\"), getter ? getter.call(obj) : member.get(obj));\nvar __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, \"write to private field\"), setter ? setter.call(obj, value) : member.set(obj, value), value);\nvar __privateMethod = (obj, member, method) => (__accessCheck(obj, member, \"access private method\"), method);\nimport { jsx, jsxs } from \"@navios/adapter-xml/jsx-runtime\";\nimport { builder } from \"@navios/builder\";\nimport {\n Controller,\n Endpoint,\n inject,\n Injectable,\n InjectableScope,\n Module,\n NaviosFactory\n} from \"@navios/core\";\nimport { defineBunEnvironment } from \"@navios/adapter-bun\";\nimport supertest from \"supertest\";\nimport { afterAll, beforeAll, describe, expect, it } from \"bun:test\";\nimport { z } from \"zod/v4\";\nimport {\n CData,\n Component,\n DangerouslyInsertRawXml,\n declareXmlStream,\n defineXmlEnvironment,\n XmlStream,\n createElement\n} from \"../../src/index.mjs\";\nfunction mergeEnvironments(...envs) {\n const merged = /* @__PURE__ */ new Map();\n for (const env of envs) {\n for (const [key, value] of env.httpTokens) {\n merged.set(key, value);\n }\n }\n return { httpTokens: merged };\n}\ndescribe(\"XML Stream with Bun adapter\", () => {\n var _RequestTrackerService_decorators, _init, _DataService_decorators, _init2, _ItemComponent_decorators, _init3, _getJsonData_dec, _getSpecialXml_dec, _getDiXml_dec, _getAsyncXml_dec, _postGenerateXml_dec, _getItemXml_dec, _getSitemap_dec, _getAtomFeed_dec, _getRssFeed_dec, _FeedController_decorators, _init4, _AppModule_decorators, _init5;\n let server;\n let serverUrl;\n _RequestTrackerService_decorators = [Injectable({\n scope: InjectableScope.Request\n })];\n class RequestTrackerService {\n requestId = Math.random().toString(36).substring(7);\n getRequestId() {\n return this.requestId;\n }\n }\n _init = __decoratorStart(null);\n RequestTrackerService = __decorateElement(_init, 0, \"RequestTrackerService\", _RequestTrackerService_decorators, RequestTrackerService);\n __runInitializers(_init, 1, RequestTrackerService);\n _DataService_decorators = [Injectable()];\n class DataService {\n getItems() {\n return [\n { id: \"1\", title: \"First Item\", description: \"Description 1\" },\n { id: \"2\", title: \"Second Item\", description: \"Description 2\" },\n { id: \"3\", title: \"Third Item\", description: \"Description 3\" }\n ];\n }\n getItem(id) {\n return this.getItems().find((item) => item.id === id);\n }\n }\n _init2 = __decoratorStart(null);\n DataService = __decorateElement(_init2, 0, \"DataService\", _DataService_decorators, DataService);\n __runInitializers(_init2, 1, DataService);\n _ItemComponent_decorators = [Component()];\n class ItemComponent {\n constructor(props) {\n this.props = props;\n }\n dataService = inject(DataService);\n tracker = inject(RequestTrackerService);\n render() {\n const item = this.dataService.getItem(this.props.id);\n if (!item) {\n return createElement(\"error\", null, \"Item not found\");\n }\n return createElement(\n \"item\",\n { id: item.id, requestId: this.tracker.getRequestId() },\n createElement(\"title\", null, item.title),\n createElement(\"description\", null, item.description)\n );\n }\n }\n _init3 = __decoratorStart(null);\n ItemComponent = __decorateElement(_init3, 0, \"ItemComponent\", _ItemComponent_decorators, ItemComponent);\n __runInitializers(_init3, 1, ItemComponent);\n async function AsyncDataComponent({ delay }) {\n await new Promise((resolve) => setTimeout(resolve, delay));\n return createElement(\"async-data\", null, `Loaded after ${delay}ms`);\n }\n const getRssFeed = declareXmlStream({\n method: \"GET\",\n url: \"/feed.xml\",\n querySchema: void 0,\n requestSchema: void 0,\n contentType: \"application/rss+xml\",\n xmlDeclaration: true\n });\n const getAtomFeed = declareXmlStream({\n method: \"GET\",\n url: \"/atom.xml\",\n querySchema: z.object({\n limit: z.coerce.number().optional().default(10)\n }),\n requestSchema: void 0,\n contentType: \"application/atom+xml\",\n xmlDeclaration: true\n });\n const getSitemap = declareXmlStream({\n method: \"GET\",\n url: \"/sitemap.xml\",\n querySchema: void 0,\n requestSchema: void 0,\n contentType: \"application/xml\",\n xmlDeclaration: true\n });\n const getItemXml = declareXmlStream({\n method: \"GET\",\n url: \"/items/$id\",\n querySchema: void 0,\n requestSchema: void 0,\n contentType: \"application/xml\",\n xmlDeclaration: true\n });\n const postGenerateXml = declareXmlStream({\n method: \"POST\",\n url: \"/generate.xml\",\n querySchema: void 0,\n requestSchema: z.object({\n title: z.string(),\n items: z.array(z.string())\n }),\n contentType: \"application/xml\",\n xmlDeclaration: true\n });\n const getAsyncXml = declareXmlStream({\n method: \"GET\",\n url: \"/async.xml\",\n querySchema: void 0,\n requestSchema: void 0,\n contentType: \"application/xml\",\n xmlDeclaration: true\n });\n const getDiXml = declareXmlStream({\n method: \"GET\",\n url: \"/di/$id\",\n querySchema: void 0,\n requestSchema: void 0,\n contentType: \"application/xml\",\n xmlDeclaration: true\n });\n const getSpecialXml = declareXmlStream({\n method: \"GET\",\n url: \"/special.xml\",\n querySchema: void 0,\n requestSchema: void 0,\n contentType: \"application/xml\",\n xmlDeclaration: true\n });\n const getJsonEndpoint = builder().declareEndpoint({\n method: \"GET\",\n url: \"/api/data\",\n responseSchema: z.object({\n message: z.string()\n })\n });\n _FeedController_decorators = [Controller()], _getRssFeed_dec = [XmlStream(getRssFeed)], _getAtomFeed_dec = [XmlStream(getAtomFeed)], _getSitemap_dec = [XmlStream(getSitemap)], _getItemXml_dec = [XmlStream(getItemXml)], _postGenerateXml_dec = [XmlStream(postGenerateXml)], _getAsyncXml_dec = [XmlStream(getAsyncXml)], _getDiXml_dec = [XmlStream(getDiXml)], _getSpecialXml_dec = [XmlStream(getSpecialXml)], _getJsonData_dec = [Endpoint(getJsonEndpoint)];\n class FeedController {\n constructor() {\n __runInitializers(_init4, 5, this);\n __publicField(this, \"dataService\", inject(DataService));\n __publicField(this, \"tracker\", inject(RequestTrackerService));\n }\n async getRssFeed(_params) {\n const items = this.dataService.getItems();\n return /* @__PURE__ */ jsx(\"rss\", { version: \"2.0\", children: /* @__PURE__ */ jsxs(\"channel\", { children: [\n /* @__PURE__ */ jsx(\"title\", { children: \"My Blog\" }),\n /* @__PURE__ */ jsx(\"link\", { children: \"https://example.com\" }),\n /* @__PURE__ */ jsx(\"description\", { children: \"A sample RSS feed\" }),\n items.map((item) => /* @__PURE__ */ jsxs(\"item\", { children: [\n /* @__PURE__ */ jsx(\"title\", { children: item.title }),\n /* @__PURE__ */ jsxs(\"link\", { children: [\n \"https://example.com/items/\",\n item.id\n ] }),\n /* @__PURE__ */ jsx(\"description\", { children: item.description })\n ] }, item.id))\n ] }) });\n }\n async getAtomFeed(params) {\n const limit = params.params.limit;\n const items = this.dataService.getItems().slice(0, limit);\n return /* @__PURE__ */ jsxs(\"feed\", { xmlns: \"http://www.w3.org/2005/Atom\", children: [\n /* @__PURE__ */ jsx(\"title\", { children: \"My Atom Feed\" }),\n /* @__PURE__ */ jsx(\"link\", { href: \"https://example.com/atom.xml\", rel: \"self\" }),\n /* @__PURE__ */ jsx(\"id\", { children: \"https://example.com/\" }),\n /* @__PURE__ */ jsx(\"updated\", { children: \"2025-01-01T00:00:00Z\" }),\n items.map((item) => /* @__PURE__ */ jsxs(\"entry\", { children: [\n /* @__PURE__ */ jsx(\"title\", { children: item.title }),\n /* @__PURE__ */ jsxs(\"id\", { children: [\n \"https://example.com/items/\",\n item.id\n ] }),\n /* @__PURE__ */ jsx(\"updated\", { children: \"2025-01-01T00:00:00Z\" }),\n /* @__PURE__ */ jsx(\"summary\", { children: item.description })\n ] }, item.id))\n ] });\n }\n async getSitemap(_params) {\n const items = this.dataService.getItems();\n return /* @__PURE__ */ jsxs(\"urlset\", { xmlns: \"http://www.sitemaps.org/schemas/sitemap/0.9\", children: [\n /* @__PURE__ */ jsxs(\"url\", { children: [\n /* @__PURE__ */ jsx(\"loc\", { children: \"https://example.com/\" }),\n /* @__PURE__ */ jsx(\"lastmod\", { children: \"2025-01-01\" }),\n /* @__PURE__ */ jsx(\"changefreq\", { children: \"daily\" }),\n /* @__PURE__ */ jsx(\"priority\", { children: \"1.0\" })\n ] }),\n items.map((item) => /* @__PURE__ */ jsxs(\"url\", { children: [\n /* @__PURE__ */ jsxs(\"loc\", { children: [\n \"https://example.com/items/\",\n item.id\n ] }),\n /* @__PURE__ */ jsx(\"lastmod\", { children: \"2025-01-01\" }),\n /* @__PURE__ */ jsx(\"changefreq\", { children: \"weekly\" }),\n /* @__PURE__ */ jsx(\"priority\", { children: \"0.8\" })\n ] }, item.id))\n ] });\n }\n async getItemXml(params) {\n const item = this.dataService.getItem(params.urlParams.id);\n if (!item) {\n return /* @__PURE__ */ jsxs(\"error\", { children: [\n /* @__PURE__ */ jsx(\"message\", { children: \"Item not found\" }),\n /* @__PURE__ */ jsx(\"requestedId\", { children: params.urlParams.id })\n ] });\n }\n return /* @__PURE__ */ jsxs(\"item\", { id: item.id, children: [\n /* @__PURE__ */ jsx(\"title\", { children: item.title }),\n /* @__PURE__ */ jsx(\"description\", { children: item.description })\n ] });\n }\n async postGenerateXml(params) {\n const { title, items } = params.data;\n return /* @__PURE__ */ jsxs(\"generated\", { children: [\n /* @__PURE__ */ jsx(\"title\", { children: title }),\n /* @__PURE__ */ jsx(\"items\", { count: String(items.length), children: items.map((item, index) => /* @__PURE__ */ jsx(\"item\", { index: String(index), children: item }, index)) })\n ] });\n }\n async getAsyncXml(_params) {\n return /* @__PURE__ */ jsxs(\"root\", { children: [\n /* @__PURE__ */ jsx(\"sync\", { children: \"Immediate content\" }),\n /* @__PURE__ */ jsx(AsyncDataComponent, { delay: 10 }),\n /* @__PURE__ */ jsx(AsyncDataComponent, { delay: 5 })\n ] });\n }\n async getDiXml(params) {\n return /* @__PURE__ */ jsx(\"root\", { requestId: this.tracker.getRequestId(), children: /* @__PURE__ */ jsx(ItemComponent, { id: params.urlParams.id }) });\n }\n async getSpecialXml(_params) {\n return /* @__PURE__ */ jsxs(\"root\", { children: [\n /* @__PURE__ */ jsx(\"cdata-example\", { children: /* @__PURE__ */ jsx(CData, { children: \"This is <raw> HTML & XML content that should not be escaped\" }) }),\n /* @__PURE__ */ jsx(\"raw-xml-example\", { children: /* @__PURE__ */ jsx(DangerouslyInsertRawXml, { children: '<nested><element attr=\"value\">text</element></nested>' }) }),\n /* @__PURE__ */ jsx(\"escaped\", { children: '<this> & \"that\" should be escaped' })\n ] });\n }\n async getJsonData(_params) {\n return { message: \"JSON endpoint works alongside XML\" };\n }\n }\n _init4 = __decoratorStart(null);\n __decorateElement(_init4, 1, \"getRssFeed\", _getRssFeed_dec, FeedController);\n __decorateElement(_init4, 1, \"getAtomFeed\", _getAtomFeed_dec, FeedController);\n __decorateElement(_init4, 1, \"getSitemap\", _getSitemap_dec, FeedController);\n __decorateElement(_init4, 1, \"getItemXml\", _getItemXml_dec, FeedController);\n __decorateElement(_init4, 1, \"postGenerateXml\", _postGenerateXml_dec, FeedController);\n __decorateElement(_init4, 1, \"getAsyncXml\", _getAsyncXml_dec, FeedController);\n __decorateElement(_init4, 1, \"getDiXml\", _getDiXml_dec, FeedController);\n __decorateElement(_init4, 1, \"getSpecialXml\", _getSpecialXml_dec, FeedController);\n __decorateElement(_init4, 1, \"getJsonData\", _getJsonData_dec, FeedController);\n FeedController = __decorateElement(_init4, 0, \"FeedController\", _FeedController_decorators, FeedController);\n __runInitializers(_init4, 1, FeedController);\n _AppModule_decorators = [Module({\n controllers: [FeedController]\n })];\n class AppModule {\n }\n _init5 = __decoratorStart(null);\n AppModule = __decorateElement(_init5, 0, \"AppModule\", _AppModule_decorators, AppModule);\n __runInitializers(_init5, 1, AppModule);\n beforeAll(async () => {\n const bunEnv = defineBunEnvironment();\n const xmlEnv = defineXmlEnvironment();\n const mergedEnv = mergeEnvironments(bunEnv, xmlEnv);\n server = await NaviosFactory.create(AppModule, {\n adapter: mergedEnv\n });\n await server.init();\n await server.listen({ port: 3002, host: \"localhost\" });\n serverUrl = server.getServer().url.href;\n });\n afterAll(async () => {\n await server.close();\n });\n describe(\"Basic XML endpoints\", () => {\n it(\"should return RSS feed with correct content type\", async () => {\n const response = await supertest(serverUrl).get(\"/feed.xml\");\n expect(response.status).toBe(200);\n expect(response.headers[\"content-type\"]).toContain(\"application/rss+xml\");\n expect(response.text).toContain('<?xml version=\"1.0\" encoding=\"UTF-8\"?>');\n expect(response.text).toContain('<rss version=\"2.0\">');\n expect(response.text).toContain(\"<title>My Blog</title>\");\n expect(response.text).toContain(\"<item>\");\n expect(response.text).toContain(\"<title>First Item</title>\");\n });\n it(\"should return Atom feed with query params\", async () => {\n const response = await supertest(serverUrl).get(\"/atom.xml?limit=2\");\n expect(response.status).toBe(200);\n expect(response.headers[\"content-type\"]).toContain(\"application/atom+xml\");\n expect(response.text).toContain(\n '<feed xmlns=\"http://www.w3.org/2005/Atom\">'\n );\n const entryCount = (response.text.match(/<entry>/g) || []).length;\n expect(entryCount).toBe(2);\n });\n it(\"should return sitemap XML\", async () => {\n const response = await supertest(serverUrl).get(\"/sitemap.xml\");\n expect(response.status).toBe(200);\n expect(response.headers[\"content-type\"]).toContain(\"application/xml\");\n expect(response.text).toContain(\n '<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">'\n );\n expect(response.text).toContain(\"<loc>https://example.com/</loc>\");\n expect(response.text).toContain(\"<priority>1.0</priority>\");\n });\n });\n describe(\"URL parameters\", () => {\n it(\"should handle URL parameters in XML endpoint\", async () => {\n const response = await supertest(serverUrl).get(\"/items/1\");\n expect(response.status).toBe(200);\n expect(response.text).toContain('<item id=\"1\">');\n expect(response.text).toContain(\"<title>First Item</title>\");\n });\n it(\"should handle non-existent item\", async () => {\n const response = await supertest(serverUrl).get(\"/items/999\");\n expect(response.status).toBe(200);\n expect(response.text).toContain(\"<error>\");\n expect(response.text).toContain(\"<message>Item not found</message>\");\n expect(response.text).toContain(\"<requestedId>999</requestedId>\");\n });\n });\n describe(\"POST with request body\", () => {\n it(\"should generate XML from POST body\", async () => {\n const response = await supertest(serverUrl).post(\"/generate.xml\").send({\n title: \"Generated Document\",\n items: [\"Alpha\", \"Beta\", \"Gamma\"]\n });\n expect(response.status).toBe(200);\n expect(response.text).toContain(\"<generated>\");\n expect(response.text).toContain(\"<title>Generated Document</title>\");\n expect(response.text).toContain('<items count=\"3\">');\n expect(response.text).toContain('<item index=\"0\">Alpha</item>');\n expect(response.text).toContain('<item index=\"1\">Beta</item>');\n expect(response.text).toContain('<item index=\"2\">Gamma</item>');\n });\n });\n describe(\"Async components\", () => {\n it(\"should resolve async components in XML\", async () => {\n const response = await supertest(serverUrl).get(\"/async.xml\");\n expect(response.status).toBe(200);\n expect(response.text).toContain(\"<sync>Immediate content</sync>\");\n expect(response.text).toContain(\n \"<async-data>Loaded after 10ms</async-data>\"\n );\n expect(response.text).toContain(\n \"<async-data>Loaded after 5ms</async-data>\"\n );\n });\n });\n describe(\"Class components with DI\", () => {\n it(\"should render class components with injected services\", async () => {\n const response = await supertest(serverUrl).get(\"/di/1\");\n expect(response.status).toBe(200);\n expect(response.text).toContain(\"<root requestId=\");\n expect(response.text).toContain('<item id=\"1\"');\n expect(response.text).toContain(\"<title>First Item</title>\");\n });\n it(\"should isolate request-scoped services across parallel requests\", async () => {\n const requests = [\n supertest(serverUrl).get(\"/di/1\"),\n supertest(serverUrl).get(\"/di/2\"),\n supertest(serverUrl).get(\"/di/3\")\n ];\n const responses = await Promise.all(requests);\n responses.forEach((response) => {\n expect(response.status).toBe(200);\n });\n const requestIds = responses.map((response) => {\n const match = response.text.match(/requestId=\"([^\"]+)\"/);\n return match ? match[1] : null;\n });\n const uniqueIds = new Set(requestIds.filter(Boolean));\n expect(uniqueIds.size).toBe(3);\n });\n });\n describe(\"Special XML content\", () => {\n it(\"should handle CDATA and raw XML correctly\", async () => {\n const response = await supertest(serverUrl).get(\"/special.xml\");\n expect(response.status).toBe(200);\n expect(response.text).toContain(\n \"<![CDATA[This is <raw> HTML & XML content that should not be escaped]]>\"\n );\n expect(response.text).toContain(\n '<nested><element attr=\"value\">text</element></nested>'\n );\n expect(response.text).toContain(\n '&lt;this&gt; &amp; \"that\" should be escaped'\n );\n });\n });\n describe(\"Mixed endpoints\", () => {\n it(\"should work alongside regular JSON endpoints\", async () => {\n const xmlResponse = await supertest(serverUrl).get(\"/feed.xml\");\n const jsonResponse = await supertest(serverUrl).get(\"/api/data\");\n expect(xmlResponse.status).toBe(200);\n expect(xmlResponse.headers[\"content-type\"]).toContain(\n \"application/rss+xml\"\n );\n expect(jsonResponse.status).toBe(200);\n expect(jsonResponse.body.message).toBe(\n \"JSON endpoint works alongside XML\"\n );\n });\n });\n describe(\"Fragment support\", () => {\n it(\"should correctly render fragments within XML\", async () => {\n const response = await supertest(serverUrl).get(\"/feed.xml\");\n expect(response.status).toBe(200);\n const itemCount = (response.text.match(/<item>/g) || []).length;\n expect(itemCount).toBeGreaterThan(1);\n });\n });\n});\n"],["// Types\nexport type {\n XmlNode,\n AsyncXmlNode,\n CDataNode,\n RawXmlNode,\n ClassComponentNode,\n AnyXmlNode,\n BaseXmlStreamConfig,\n XmlComponent,\n ComponentClass,\n} from './types/index.mjs'\n\nexport {\n Fragment,\n AsyncComponent,\n CDataSymbol,\n RawXmlSymbol,\n ClassComponent,\n} from './types/index.mjs'\n\n// Runtime\nexport { createElement, CData, DangerouslyInsertRawXml, renderToXml, MissingContainerError } from './runtime/index.mjs'\nexport type { RenderOptions } from './runtime/index.mjs'\n\n// Tags\nexport { defineTag } from './tags/index.mjs'\nexport type { TagComponent } from './tags/index.mjs'\n\n// Decorators\nexport { XmlStream, Component, isComponentClass } from './decorators/index.mjs'\nexport type { XmlStreamParams } from './decorators/index.mjs'\n\n// Handlers\nexport { declareXmlStream } from './handlers/index.mjs'\n\n// Adapters\nexport { XmlStreamAdapterService } from './adapters/index.mjs'\n\n// Environment\nexport { defineXmlEnvironment } from './define-environment.mjs'\n","export {\n Fragment,\n AsyncComponent,\n CDataSymbol,\n RawXmlSymbol,\n ClassComponent\n} from \"./types/index.mjs\";\nexport { createElement, CData, DangerouslyInsertRawXml, renderToXml, MissingContainerError } from \"./runtime/index.mjs\";\nexport { defineTag } from \"./tags/index.mjs\";\nexport { XmlStream, Component, isComponentClass } from \"./decorators/index.mjs\";\nexport { declareXmlStream } from \"./handlers/index.mjs\";\nexport { XmlStreamAdapterService } from \"./adapters/index.mjs\";\nexport { defineXmlEnvironment } from \"./define-environment.mjs\";\n"],["export {\n Fragment,\n AsyncComponent,\n CDataSymbol,\n RawXmlSymbol,\n ClassComponent,\n} from './xml-node.mjs'\n\nexport type {\n XmlNode,\n AsyncXmlNode,\n CDataNode,\n RawXmlNode,\n ClassComponentNode,\n AnyXmlNode,\n} from './xml-node.mjs'\n\nexport type { XmlComponent, ComponentClass } from './component.mjs'\n\nexport type { BaseXmlStreamConfig } from './config.mjs'\n\n// Re-export JSX types for side effects\n\n","export {\n Fragment,\n AsyncComponent,\n CDataSymbol,\n RawXmlSymbol,\n ClassComponent\n} from \"./xml-node.mjs\";\n"],["export { createElement, Fragment } from './create-element.mjs'\nexport { CData, DangerouslyInsertRawXml } from './special-nodes.mjs'\nexport { renderToXml, MissingContainerError } from './render-to-xml.mjs'\nexport type { RenderOptions } from './render-to-xml.mjs'\n","export { createElement, Fragment } from \"./create-element.mjs\";\nexport { CData, DangerouslyInsertRawXml } from \"./special-nodes.mjs\";\nexport { renderToXml, MissingContainerError } from \"./render-to-xml.mjs\";\n"],["export { defineTag } from './define-tag.mjs'\nexport type { TagComponent } from './define-tag.mjs'\n","export { defineTag } from \"./define-tag.mjs\";\n"],["export { declareXmlStream } from './xml-stream.mjs'\n","export { declareXmlStream } from \"./xml-stream.mjs\";\n"],["export { XmlStream } from './xml-stream.decorator.mjs'\nexport type { XmlStreamParams } from './xml-stream.decorator.mjs'\n\nexport { Component, ComponentMeta, isComponentClass } from './component.decorator.mjs'\n","export { XmlStream } from \"./xml-stream.decorator.mjs\";\nexport { Component, ComponentMeta, isComponentClass } from \"./component.decorator.mjs\";\n"],["import type { AnyInjectableType } from '@navios/core'\n\nimport { InjectionToken, XmlStreamAdapterToken } from '@navios/core'\n\nimport { XmlStreamAdapterService } from './adapters/index.mjs'\n\n/**\n * Creates the XML environment configuration to be merged with base adapter (Fastify/Bun).\n *\n * @example\n * ```typescript\n * import { defineFastifyEnvironment } from '@navios/adapter-fastify'\n * import { defineXmlEnvironment } from '@navios/adapter-xml'\n * import { NaviosFactory } from '@navios/core'\n *\n * const fastifyEnv = defineFastifyEnvironment()\n * const xmlEnv = defineXmlEnvironment()\n *\n * // Merge environments\n * const mergedEnv = {\n * httpTokens: new Map([\n * ...fastifyEnv.httpTokens,\n * ...xmlEnv.httpTokens,\n * ]),\n * }\n *\n * const app = await NaviosFactory.create(AppModule, {\n * adapter: mergedEnv,\n * })\n * ```\n */\nexport function defineXmlEnvironment() {\n const httpTokens = new Map<InjectionToken<any, undefined>, AnyInjectableType>(\n [[XmlStreamAdapterToken, XmlStreamAdapterService]],\n )\n return {\n httpTokens,\n }\n}\n","import { XmlStreamAdapterToken } from \"@navios/core\";\nimport { XmlStreamAdapterService } from \"./adapters/index.mjs\";\nexport function defineXmlEnvironment() {\n const httpTokens = /* @__PURE__ */ new Map(\n [[XmlStreamAdapterToken, XmlStreamAdapterService]]\n );\n return {\n httpTokens\n };\n}\n"],["export { XmlStreamAdapterService } from './xml-stream-adapter.service.mjs'\n","export { XmlStreamAdapterService } from \"./xml-stream-adapter.service.mjs\";\n"],["import type { ComponentClass } from './component.mjs'\n\nexport const Fragment = Symbol.for('xml.fragment')\nexport const AsyncComponent = Symbol.for('xml.async')\nexport const CDataSymbol = Symbol.for('xml.cdata')\nexport const RawXmlSymbol = Symbol.for('xml.raw')\nexport const ClassComponent = Symbol.for('xml.class-component')\n\n/** Represents a CDATA section - content is wrapped in <![CDATA[...]]> */\nexport interface CDataNode {\n type: typeof CDataSymbol\n content: string\n}\n\n/** Represents raw XML content - inserted without any escaping or wrapping */\nexport interface RawXmlNode {\n type: typeof RawXmlSymbol\n content: string\n}\n\n/** Represents a class component that needs to be resolved via DI */\nexport interface ClassComponentNode {\n type: typeof ClassComponent\n componentClass: ComponentClass\n props: Record<string, unknown>\n}\n\nexport interface XmlNode {\n type: string | typeof Fragment\n props: Record<string, unknown>\n children: AnyXmlNode[]\n}\n\n/** Represents an async component that needs to be resolved before rendering */\nexport interface AsyncXmlNode {\n type: typeof AsyncComponent\n promise: Promise<AnyXmlNode>\n}\n\n/** Union type for all possible node types */\nexport type AnyXmlNode =\n | XmlNode\n | AsyncXmlNode\n | CDataNode\n | RawXmlNode\n | ClassComponentNode\n | string\n | number\n | null\n | undefined\n","export const Fragment = /* @__PURE__ */ Symbol.for(\"xml.fragment\");\nexport const AsyncComponent = /* @__PURE__ */ Symbol.for(\"xml.async\");\nexport const CDataSymbol = /* @__PURE__ */ Symbol.for(\"xml.cdata\");\nexport const RawXmlSymbol = /* @__PURE__ */ Symbol.for(\"xml.raw\");\nexport const ClassComponent = /* @__PURE__ */ Symbol.for(\"xml.class-component\");\n"],["import type { AnyXmlNode, AsyncXmlNode, ClassComponentNode, XmlNode } from '../types/xml-node.mjs'\nimport type { ComponentClass } from '../types/component.mjs'\n\nimport { isComponentClass } from '../decorators/component.decorator.mjs'\nimport { AsyncComponent, ClassComponent, Fragment } from '../types/xml-node.mjs'\n\ntype SyncComponent = (props: any) => XmlNode | AsyncXmlNode | ClassComponentNode\ntype AsyncComponentFn = (props: any) => Promise<XmlNode | AsyncXmlNode | ClassComponentNode>\ntype FunctionalComponent = SyncComponent | AsyncComponentFn\ntype ComponentType = FunctionalComponent | ComponentClass\n\nfunction flattenChildren(children: any): AnyXmlNode[] {\n if (children == null || children === false) {\n return []\n }\n if (Array.isArray(children)) {\n return children.flat(Infinity).filter((c) => c != null && c !== false)\n }\n return [children]\n}\n\n/**\n * JSX automatic runtime function.\n * Used by the JSX transformer when jsxImportSource is set.\n * Children are passed as part of props.children.\n */\nexport function jsx(\n type: string | typeof Fragment | ComponentType,\n props: Record<string, unknown> | null,\n): XmlNode | AsyncXmlNode | ClassComponentNode {\n const { children, ...restProps } = props ?? {}\n const flatChildren = flattenChildren(children)\n\n // Handle class components - create ClassComponentNode for later resolution\n if (isComponentClass(type)) {\n return {\n type: ClassComponent,\n componentClass: type,\n props: { ...restProps, children: flatChildren },\n }\n }\n\n // Handle function components (sync or async)\n if (typeof type === 'function') {\n const result = type({ ...restProps, children: flatChildren })\n\n // If component returns a Promise, wrap it in AsyncXmlNode\n if (result instanceof Promise) {\n return {\n type: AsyncComponent,\n promise: result,\n }\n }\n\n return result\n }\n\n return {\n type,\n props: restProps,\n children: flatChildren,\n }\n}\n\n/**\n * JSX automatic runtime function for static children.\n * Identical to jsx() for XML - React uses this for optimization hints.\n */\nexport const jsxs = jsx\n\n/**\n * Classic createElement for manual usage.\n * Children are passed as rest arguments.\n */\nexport function createElement(\n type: string | typeof Fragment | ComponentType,\n props: Record<string, unknown> | null,\n ...children: any[]\n): XmlNode | AsyncXmlNode | ClassComponentNode {\n const flatChildren = flattenChildren(children)\n\n // Handle class components - create ClassComponentNode for later resolution\n if (isComponentClass(type)) {\n return {\n type: ClassComponent,\n componentClass: type,\n props: { ...props, children: flatChildren },\n }\n }\n\n // Handle function components (sync or async)\n if (typeof type === 'function') {\n const result = type({ ...props, children: flatChildren })\n\n // If component returns a Promise, wrap it in AsyncXmlNode\n if (result instanceof Promise) {\n return {\n type: AsyncComponent,\n promise: result,\n }\n }\n\n return result\n }\n\n return {\n type,\n props: props ?? {},\n children: flatChildren,\n }\n}\n\nexport { Fragment }\n","import { isComponentClass } from \"../decorators/component.decorator.mjs\";\nimport { AsyncComponent, ClassComponent, Fragment } from \"../types/xml-node.mjs\";\nfunction flattenChildren(children) {\n if (children == null || children === false) {\n return [];\n }\n if (Array.isArray(children)) {\n return children.flat(Infinity).filter((c) => c != null && c !== false);\n }\n return [children];\n}\nexport function jsx(type, props) {\n const { children, ...restProps } = props ?? {};\n const flatChildren = flattenChildren(children);\n if (isComponentClass(type)) {\n return {\n type: ClassComponent,\n componentClass: type,\n props: { ...restProps, children: flatChildren }\n };\n }\n if (typeof type === \"function\") {\n const result = type({ ...restProps, children: flatChildren });\n if (result instanceof Promise) {\n return {\n type: AsyncComponent,\n promise: result\n };\n }\n return result;\n }\n return {\n type,\n props: restProps,\n children: flatChildren\n };\n}\nexport const jsxs = jsx;\nexport function createElement(type, props, ...children) {\n const flatChildren = flattenChildren(children);\n if (isComponentClass(type)) {\n return {\n type: ClassComponent,\n componentClass: type,\n props: { ...props, children: flatChildren }\n };\n }\n if (typeof type === \"function\") {\n const result = type({ ...props, children: flatChildren });\n if (result instanceof Promise) {\n return {\n type: AsyncComponent,\n promise: result\n };\n }\n return result;\n }\n return {\n type,\n props: props ?? {},\n children: flatChildren\n };\n}\nexport { Fragment };\n"],["import type { CDataNode, RawXmlNode } from '../types/xml-node.mjs'\nimport { CDataSymbol, RawXmlSymbol } from '../types/xml-node.mjs'\n\n/**\n * CDATA component - wraps content in <![CDATA[...]]>\n * Use for text content that may contain characters like < > &\n * that would otherwise need escaping.\n *\n * Note: If content contains \"]]>\", it will be split into multiple CDATA sections.\n */\nexport function CData({ children }: { children: string }): CDataNode {\n return {\n type: CDataSymbol,\n content: String(children),\n }\n}\n\n/**\n * DangerouslyInsertRawXml - inserts raw XML/HTML without any escaping or wrapping\n *\n * WARNING: This bypasses all XML escaping. Only use with trusted content!\n * Use cases:\n * - Pre-rendered XML fragments\n * - HTML content in RSS/Atom feeds (in description/content:encoded)\n * - Including XML from external sources that's already valid\n */\nexport function DangerouslyInsertRawXml({ children }: { children: string }): RawXmlNode {\n return {\n type: RawXmlSymbol,\n content: String(children),\n }\n}\n","import { CDataSymbol, RawXmlSymbol } from \"../types/xml-node.mjs\";\nexport function CData({ children }) {\n return {\n type: CDataSymbol,\n content: String(children)\n };\n}\nexport function DangerouslyInsertRawXml({ children }) {\n return {\n type: RawXmlSymbol,\n content: String(children)\n };\n}\n"],["import type { Container, ScopedContainer } from '@navios/core'\n\nimport type { XmlComponent } from '../types/component.mjs'\nimport type {\n AnyXmlNode,\n AsyncXmlNode,\n CDataNode,\n ClassComponentNode,\n RawXmlNode,\n} from '../types/xml-node.mjs'\n\nimport {\n AsyncComponent,\n CDataSymbol,\n ClassComponent,\n Fragment,\n RawXmlSymbol,\n} from '../types/xml-node.mjs'\n\n/**\n * Options for rendering XML from JSX nodes.\n *\n * @example\n * ```ts\n * const xml = await renderToXml(<rss version=\"2.0\">...</rss>, {\n * declaration: true,\n * encoding: 'UTF-8',\n * pretty: true,\n * container: myContainer, // Required for class components\n * })\n * ```\n */\nexport interface RenderOptions {\n /** Include XML declaration (<?xml version=\"1.0\"?>) - defaults to true */\n declaration?: boolean\n /** XML encoding, defaults to 'UTF-8' */\n encoding?: string\n /** Pretty print with indentation */\n pretty?: boolean\n /**\n * DI container for resolving class components.\n * Required if the tree contains any class components.\n */\n container?: Container | ScopedContainer\n}\n\n/**\n * Error thrown when attempting to render a class component without a container.\n *\n * Class components require a dependency injection container to be instantiated.\n * This error is thrown when `renderToXml` is called with a class component in\n * the tree but no container is provided in the options.\n *\n * @example\n * ```ts\n * try {\n * await renderToXml(<MyClassComponent />)\n * } catch (error) {\n * if (error instanceof MissingContainerError) {\n * // Provide a container\n * await renderToXml(<MyClassComponent />, { container })\n * }\n * }\n * ```\n */\nexport class MissingContainerError extends Error {\n constructor(componentName: string) {\n super(\n `[@navios/adapter-xml] Cannot render class component \"${componentName}\" without a container. ` +\n `Pass a container to renderToXml options: renderToXml(node, { container })`,\n )\n this.name = 'MissingContainerError'\n }\n}\n\n/**\n * Renders a JSX XML node tree to an XML string.\n *\n * This function handles:\n * - Regular XML nodes (tags with props and children)\n * - Async components (resolves promises in parallel)\n * - Class components (resolves via DI container)\n * - CDATA sections\n * - Raw XML content\n * - Fragments\n * - Text content with proper escaping\n *\n * @param node - The root XML node (JSX element) to render.\n * @param options - Rendering options including declaration, encoding, pretty printing, and container.\n * @returns A promise that resolves to the XML string.\n *\n * @throws {MissingContainerError} If the tree contains class components but no container is provided.\n *\n * @example\n * ```ts\n * // Simple rendering\n * const xml = await renderToXml(<rss version=\"2.0\"><channel>...</channel></rss>)\n *\n * // With options\n * const xml = await renderToXml(<feed>...</feed>, {\n * declaration: true,\n * encoding: 'UTF-8',\n * pretty: true,\n * })\n *\n * // With class components (requires container)\n * const container = new Container()\n * container.beginRequest('request-id')\n * const xml = await renderToXml(<MyClassComponent />, { container })\n * ```\n */\nexport async function renderToXml(\n node: AnyXmlNode,\n options: RenderOptions = {},\n): Promise<string> {\n const {\n declaration = true,\n encoding = 'UTF-8',\n pretty = false,\n container,\n } = options\n\n let xml = ''\n if (declaration) {\n xml += `<?xml version=\"1.0\" encoding=\"${encoding}\"?>`\n if (pretty) xml += '\\n'\n }\n\n xml += await renderNode(node, pretty ? 0 : -1, container)\n return xml\n}\n\nasync function renderNode(\n node: AnyXmlNode,\n indent: number,\n container: Container | ScopedContainer | undefined,\n): Promise<string> {\n if (node == null) return ''\n if (typeof node === 'string') return escapeXml(node)\n if (typeof node === 'number') return String(node)\n\n // Handle class components - resolve via DI container\n if (isClassComponentNode(node)) {\n if (!container) {\n throw new MissingContainerError(node.componentClass.name)\n }\n\n // Resolve the component instance from the container, passing props as schema args\n // This validates props via Zod schema if defined on the component\n const instance = (await container.get(\n node.componentClass as any,\n node.props,\n )) as XmlComponent\n\n // Call render() - no arguments, props are already in the instance\n const result = instance.render()\n\n // Handle async render methods\n const resolved = result instanceof Promise ? await result : result\n\n // Recursively render the result\n return renderNode(resolved, indent, container)\n }\n\n // Handle async components - resolve the promise first\n if (isAsyncNode(node)) {\n const resolved = await node.promise\n return renderNode(resolved, indent, container)\n }\n\n // Handle CDATA nodes\n if (isCDataNode(node)) {\n return renderCData(node.content)\n }\n\n // Handle Raw XML nodes - no escaping\n if (isRawXmlNode(node)) {\n return node.content\n }\n\n const { type, props, children } = node\n\n if (type === Fragment) {\n const renderedChildren = await Promise.all(\n children\n .filter((c) => c != null)\n .map((c) => renderNode(c, indent, container)),\n )\n return renderedChildren.join('')\n }\n\n const prefix = indent >= 0 ? ' '.repeat(indent) : ''\n const newline = indent >= 0 ? '\\n' : ''\n\n const attrs = Object.entries(props)\n .filter(([_, v]) => v != null)\n .map(([k, v]) => ` ${k}=\"${escapeAttr(String(v))}\"`)\n .join('')\n\n if (children.length === 0) {\n return `${prefix}<${type}${attrs}/>${newline}`\n }\n\n const childIndent = indent >= 0 ? indent + 1 : -1\n\n // Resolve all children (including async and class components) in parallel\n const resolvedChildren = await Promise.all(\n children\n .filter((c) => c != null)\n .map((c) => renderNode(c, childIndent, container)),\n )\n const childContent = resolvedChildren.join('')\n\n // Check if children are simple (text, numbers, CDATA, or raw XML)\n const hasOnlySimpleContent = children.every(\n (c) =>\n typeof c === 'string' ||\n typeof c === 'number' ||\n isCDataNode(c) ||\n isRawXmlNode(c),\n )\n if (hasOnlySimpleContent) {\n return `${prefix}<${type}${attrs}>${childContent}</${type}>${newline}`\n }\n\n return `${prefix}<${type}${attrs}>${newline}${childContent}${prefix}</${type}>${newline}`\n}\n\nfunction isClassComponentNode(node: unknown): node is ClassComponentNode {\n return (\n node !== null &&\n typeof node === 'object' &&\n 'type' in node &&\n node.type === ClassComponent\n )\n}\n\nfunction isAsyncNode(node: unknown): node is AsyncXmlNode {\n return (\n node !== null &&\n typeof node === 'object' &&\n 'type' in node &&\n node.type === AsyncComponent\n )\n}\n\nfunction isCDataNode(node: any): node is CDataNode {\n return node && typeof node === 'object' && node.type === CDataSymbol\n}\n\nfunction isRawXmlNode(node: any): node is RawXmlNode {\n return node && typeof node === 'object' && node.type === RawXmlSymbol\n}\n\n/**\n * Renders content as CDATA section.\n * If content contains \"]]>\", splits into multiple CDATA sections.\n * The technique is to end the CDATA section before ]]>, then start a new one.\n */\nfunction renderCData(content: string): string {\n // Handle the edge case where content contains \"]]>\"\n // We split on \"]]>\" and join with \"]]]]><![CDATA[>\" which effectively\n // ends the CDATA section after \"]]\" and starts a new one for \">\"\n if (content.includes(']]>')) {\n // Replace ]]> with ]]]]><![CDATA[> which closes CDATA before > and reopens it\n const escaped = content.replace(/]]>/g, ']]]]><![CDATA[>')\n return `<![CDATA[${escaped}]]>`\n }\n return `<![CDATA[${content}]]>`\n}\n\nfunction escapeXml(str: string): string {\n return str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')\n}\n\nfunction escapeAttr(str: string): string {\n return str\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n}\n","import {\n AsyncComponent,\n CDataSymbol,\n ClassComponent,\n Fragment,\n RawXmlSymbol\n} from \"../types/xml-node.mjs\";\nexport class MissingContainerError extends Error {\n constructor(componentName) {\n super(\n `[@navios/adapter-xml] Cannot render class component \"${componentName}\" without a container. Pass a container to renderToXml options: renderToXml(node, { container })`\n );\n this.name = \"MissingContainerError\";\n }\n}\nexport async function renderToXml(node, options = {}) {\n const {\n declaration = true,\n encoding = \"UTF-8\",\n pretty = false,\n container\n } = options;\n let xml = \"\";\n if (declaration) {\n xml += `<?xml version=\"1.0\" encoding=\"${encoding}\"?>`;\n if (pretty) xml += \"\\n\";\n }\n xml += await renderNode(node, pretty ? 0 : -1, container);\n return xml;\n}\nasync function renderNode(node, indent, container) {\n if (node == null) return \"\";\n if (typeof node === \"string\") return escapeXml(node);\n if (typeof node === \"number\") return String(node);\n if (isClassComponentNode(node)) {\n if (!container) {\n throw new MissingContainerError(node.componentClass.name);\n }\n const instance = await container.get(\n node.componentClass,\n node.props\n );\n const result = instance.render();\n const resolved = result instanceof Promise ? await result : result;\n return renderNode(resolved, indent, container);\n }\n if (isAsyncNode(node)) {\n const resolved = await node.promise;\n return renderNode(resolved, indent, container);\n }\n if (isCDataNode(node)) {\n return renderCData(node.content);\n }\n if (isRawXmlNode(node)) {\n return node.content;\n }\n const { type, props, children } = node;\n if (type === Fragment) {\n const renderedChildren = await Promise.all(\n children.filter((c) => c != null).map((c) => renderNode(c, indent, container))\n );\n return renderedChildren.join(\"\");\n }\n const prefix = indent >= 0 ? \" \".repeat(indent) : \"\";\n const newline = indent >= 0 ? \"\\n\" : \"\";\n const attrs = Object.entries(props).filter(([_, v]) => v != null).map(([k, v]) => ` ${k}=\"${escapeAttr(String(v))}\"`).join(\"\");\n if (children.length === 0) {\n return `${prefix}<${type}${attrs}/>${newline}`;\n }\n const childIndent = indent >= 0 ? indent + 1 : -1;\n const resolvedChildren = await Promise.all(\n children.filter((c) => c != null).map((c) => renderNode(c, childIndent, container))\n );\n const childContent = resolvedChildren.join(\"\");\n const hasOnlySimpleContent = children.every(\n (c) => typeof c === \"string\" || typeof c === \"number\" || isCDataNode(c) || isRawXmlNode(c)\n );\n if (hasOnlySimpleContent) {\n return `${prefix}<${type}${attrs}>${childContent}</${type}>${newline}`;\n }\n return `${prefix}<${type}${attrs}>${newline}${childContent}${prefix}</${type}>${newline}`;\n}\nfunction isClassComponentNode(node) {\n return node !== null && typeof node === \"object\" && \"type\" in node && node.type === ClassComponent;\n}\nfunction isAsyncNode(node) {\n return node !== null && typeof node === \"object\" && \"type\" in node && node.type === AsyncComponent;\n}\nfunction isCDataNode(node) {\n return node && typeof node === \"object\" && node.type === CDataSymbol;\n}\nfunction isRawXmlNode(node) {\n return node && typeof node === \"object\" && node.type === RawXmlSymbol;\n}\nfunction renderCData(content) {\n if (content.includes(\"]]>\")) {\n const escaped = content.replace(/]]>/g, \"]]]]><![CDATA[>\");\n return `<![CDATA[${escaped}]]>`;\n }\n return `<![CDATA[${content}]]>`;\n}\nfunction escapeXml(str) {\n return str.replace(/&/g, \"&amp;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\");\n}\nfunction escapeAttr(str) {\n return str.replace(/&/g, \"&amp;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\").replace(/\"/g, \"&quot;\");\n}\n"],["import type { HttpMethod } from '@navios/builder'\n\nimport type { BaseXmlStreamConfig } from '../types/config.mjs'\n\n/**\n * Declares an XML Stream endpoint configuration for use with `@XmlStream` decorator.\n *\n * This function creates an endpoint declaration that can be used with the `@XmlStream`\n * decorator to mark controller methods that return JSX-based XML responses.\n *\n * @template Method - The HTTP method (GET, POST, etc.).\n * @template Url - The URL path pattern (supports parameters like `/posts/:id`).\n * @template QuerySchema - Optional Zod schema for query parameter validation.\n * @template RequestSchema - Optional Zod schema for request body validation.\n *\n * @param config - The endpoint configuration including method, URL, schemas, and XML options.\n * @returns An endpoint declaration object to be used with `@XmlStream` decorator.\n *\n * @example\n * ```typescript\n * import { declareXmlStream } from '@navios/adapter-xml'\n * import { z } from 'zod/v4'\n *\n * // Simple endpoint\n * export const getRssFeed = declareXmlStream({\n * method: 'GET',\n * url: '/feed.xml',\n * contentType: 'application/rss+xml',\n * })\n *\n * // With query parameters\n * export const getSitemap = declareXmlStream({\n * method: 'GET',\n * url: '/sitemap.xml',\n * querySchema: z.object({\n * page: z.string().optional(),\n * }),\n * contentType: 'application/xml',\n * xmlDeclaration: true,\n * encoding: 'UTF-8',\n * })\n * ```\n */\nexport function declareXmlStream<\n Method extends HttpMethod,\n Url extends string,\n QuerySchema = undefined,\n RequestSchema = undefined,\n>(\n config: BaseXmlStreamConfig<Method, Url, QuerySchema, RequestSchema>,\n): { config: BaseXmlStreamConfig<Method, Url, QuerySchema, RequestSchema> } {\n return { config }\n}\n","export function declareXmlStream(config) {\n return { config };\n}\n"],["import type { Registry } from '@navios/core'\nimport type { z, ZodObject, ZodRawShape } from 'zod/v4'\n\nimport {\n globalRegistry,\n InjectableScope,\n InjectableTokenMeta,\n InjectableType,\n InjectionToken,\n} from '@navios/core'\n\nimport type { ComponentClass, XmlComponent } from '../types/component.mjs'\n\nexport const ComponentMeta = Symbol.for('xml.component.meta')\n\n/**\n * Decorator for class-based XML components with dependency injection support.\n *\n * Class components must implement the `XmlComponent` interface with a `render()` method.\n * They can optionally accept props via constructor, validated with a Zod schema.\n *\n * @overload\n * Component without props (no schema).\n *\n * @example\n * ```tsx\n * @Component()\n * class LatestPostsComponent implements XmlComponent {\n * private readonly postService = inject(PostService)\n *\n * async render() {\n * const posts = await this.postService.getLatestPosts()\n * return <>{posts.map(post => <item>...</item>)}</>\n * }\n * }\n * ```\n *\n * @overload\n * Component with props schema for type-safe props.\n *\n * @param options - Configuration object with schema and optional registry.\n * @param options.schema - Zod schema for validating and typing component props.\n * @param options.registry - Optional custom DI registry (defaults to global registry).\n *\n * @example\n * ```tsx\n * const DescriptionSchema = z.object({\n * content: z.string(),\n * wrapInCData: z.boolean().optional(),\n * })\n *\n * @Component({ schema: DescriptionSchema })\n * class DescriptionComponent implements XmlComponent {\n * constructor(private props: z.output<typeof DescriptionSchema>) {}\n *\n * async render() {\n * return <description>{this.props.wrapInCData ? <CData>{this.props.content}</CData> : this.props.content}</description>\n * }\n * }\n * ```\n *\n * @overload\n * Component with custom registry only (no props).\n *\n * @param options - Configuration object with registry.\n * @param options.registry - Custom DI registry to use for this component.\n */\n// #1 Component without props (no schema)\nexport function Component(): <T extends ComponentClass>(\n target: T,\n context?: ClassDecoratorContext,\n) => T\n\n// #2 Component with props schema\nexport function Component<Schema extends ZodObject<ZodRawShape>>(options: {\n schema: Schema\n registry?: Registry\n}): <T extends new (props: z.output<Schema>, ...args: any[]) => XmlComponent>(\n target: T,\n context?: ClassDecoratorContext,\n) => T\n\n// #3 Component with custom registry only\nexport function Component(options: {\n registry: Registry\n}): <T extends ComponentClass>(target: T, context?: ClassDecoratorContext) => T\n\nexport function Component(\n options: {\n schema?: ZodObject<ZodRawShape>\n registry?: Registry\n } = {},\n) {\n const { schema, registry = globalRegistry } = options\n\n return <T extends ComponentClass>(\n target: T,\n context?: ClassDecoratorContext,\n ): T => {\n if (\n (context && context.kind !== 'class') ||\n (target instanceof Function && !context)\n ) {\n throw new Error(\n '[@navios/adapter-xml] @Component decorator can only be used on classes.',\n )\n }\n\n // Verify the class has a render method\n if (typeof target.prototype.render !== 'function') {\n throw new Error(\n `[@navios/adapter-xml] @Component class \"${target.name}\" must implement render() method.`,\n )\n }\n\n // Create token with schema if provided\n const injectableToken = schema\n ? InjectionToken.create(target, schema)\n : InjectionToken.create(target)\n\n // Register with Request scope - each render gets fresh instances\n registry.set(\n injectableToken,\n InjectableScope.Request,\n target,\n InjectableType.Class,\n )\n\n // Store token metadata on the class (same pattern as @Injectable)\n // @ts-expect-error - Adding metadata to class\n target[InjectableTokenMeta] = injectableToken\n\n // Mark as component for JSX runtime detection\n // @ts-expect-error - Adding metadata to class\n target[ComponentMeta] = true\n\n return target\n }\n}\n\n/**\n * Type guard to check if a value is a component class.\n *\n * Component classes are classes decorated with `@Component` that implement\n * the `XmlComponent` interface.\n *\n * @param value - The value to check.\n * @returns `true` if the value is a component class, `false` otherwise.\n *\n * @example\n * ```ts\n * if (isComponentClass(MyClass)) {\n * // MyClass is a component class\n * const instance = await container.get(MyClass)\n * }\n * ```\n */\nexport function isComponentClass(value: unknown): value is ComponentClass {\n return (\n typeof value === 'function' &&\n // @ts-expect-error - Checking metadata\n value[ComponentMeta] === true\n )\n}\n","import {\n globalRegistry,\n InjectableScope,\n InjectableTokenMeta,\n InjectableType,\n InjectionToken\n} from \"@navios/core\";\nexport const ComponentMeta = /* @__PURE__ */ Symbol.for(\"xml.component.meta\");\nexport function Component(options = {}) {\n const { schema, registry = globalRegistry } = options;\n return (target, context) => {\n if (context && context.kind !== \"class\" || target instanceof Function && !context) {\n throw new Error(\n \"[@navios/adapter-xml] @Component decorator can only be used on classes.\"\n );\n }\n if (typeof target.prototype.render !== \"function\") {\n throw new Error(\n `[@navios/adapter-xml] @Component class \"${target.name}\" must implement render() method.`\n );\n }\n const injectableToken = schema ? InjectionToken.create(target, schema) : InjectionToken.create(target);\n registry.set(\n injectableToken,\n InjectableScope.Request,\n target,\n InjectableType.Class\n );\n target[InjectableTokenMeta] = injectableToken;\n target[ComponentMeta] = true;\n return target;\n };\n}\nexport function isComponentClass(value) {\n return typeof value === \"function\" && // @ts-expect-error - Checking metadata\n value[ComponentMeta] === true;\n}\n"],["import type { ZodObject, ZodRawShape } from 'zod/v4'\nimport type { z } from 'zod/v4'\n\nimport type { AnyXmlNode, XmlNode } from '../types/xml-node.mjs'\n\n/**\n * Type for XML tag components created by `defineTag`.\n *\n * Tag components are functions that accept props and children, and return\n * an XML node. They also have a `tagName` property for identification.\n *\n * @template Props - The props type for the tag component.\n */\nexport interface TagComponent<Props extends Record<string, unknown>> {\n (props: Props & { children?: AnyXmlNode | AnyXmlNode[] }): XmlNode\n tagName: string\n}\n\n/**\n * Creates a type-safe XML tag component with optional Zod schema validation.\n *\n * @param name - The tag name (supports namespace prefixes like 'atom:link')\n * @param propsSchema - Optional Zod schema for validating props\n * @returns A component function that can be used in JSX\n *\n * @example\n * ```tsx\n * // Simple tag\n * const item = defineTag('item')\n * <item>Content</item>\n *\n * // Namespaced tag with Zod validation\n * const atomLink = defineTag('atom:link', z.object({\n * href: z.string().url(),\n * rel: z.enum(['self', 'alternate']),\n * type: z.string().optional(),\n * }))\n * <atomLink href=\"https://example.com/feed\" rel=\"self\" />\n * ```\n */\nexport function defineTag<T extends ZodRawShape>(\n name: string,\n propsSchema?: ZodObject<T>,\n): TagComponent<T extends ZodRawShape ? z.infer<ZodObject<T>> : Record<string, never>> {\n const component = (props: any): XmlNode => {\n const { children, ...rest } = props ?? {}\n\n // Validate props if schema provided\n if (propsSchema) {\n propsSchema.parse(rest)\n }\n\n return {\n type: name,\n props: rest,\n children: Array.isArray(children) ? children : children ? [children] : [],\n }\n }\n\n component.tagName = name\n return component as any\n}\n","export function defineTag(name, propsSchema) {\n const component = (props) => {\n const { children, ...rest } = props ?? {};\n if (propsSchema) {\n propsSchema.parse(rest);\n }\n return {\n type: name,\n props: rest,\n children: Array.isArray(children) ? children : children ? [children] : []\n };\n };\n component.tagName = name;\n return component;\n}\n"],["import type { EndpointFunctionArgs, HttpMethod, Util_FlatObject } from '@navios/builder'\nimport type { ZodObject, ZodType } from 'zod/v4'\n\nimport { getEndpointMetadata, XmlStreamAdapterToken } from '@navios/core'\n\nimport type { BaseXmlStreamConfig } from '../types/config.mjs'\n\n/**\n * Type helper that extracts the parameter types for an XML Stream endpoint handler.\n *\n * This type automatically infers the correct parameter types based on the endpoint\n * configuration, including URL parameters, query parameters, and request body.\n *\n * @template EndpointDeclaration - The endpoint declaration type from `declareXmlStream`.\n * @template Url - The URL path pattern.\n * @template QuerySchema - The query parameter schema type.\n *\n * @example\n * ```typescript\n * const getFeed = declareXmlStream({\n * method: 'GET',\n * url: '/feed/:category',\n * querySchema: z.object({ page: z.string() }),\n * })\n *\n * // XmlStreamParams<typeof getFeed> resolves to:\n * // { urlParams: { category: string }, query: { page: string } }\n * ```\n */\nexport type XmlStreamParams<\n EndpointDeclaration extends {\n config: BaseXmlStreamConfig<any, any, any, any>\n },\n Url extends string = EndpointDeclaration['config']['url'],\n QuerySchema = EndpointDeclaration['config']['querySchema'],\n> = QuerySchema extends ZodObject\n ? EndpointDeclaration['config']['requestSchema'] extends ZodType\n ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema'], true>>\n : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>>\n : EndpointDeclaration['config']['requestSchema'] extends ZodType\n ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, EndpointDeclaration['config']['requestSchema'], true>>\n : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>\n\n/**\n * Decorator for XML Stream endpoints that return JSX-based XML responses.\n *\n * This decorator marks controller methods that return JSX elements, which will be\n * automatically rendered to XML and sent with the appropriate Content-Type header.\n * The method can be async and can contain async components, class components, and\n * regular JSX elements.\n *\n * @template Method - The HTTP method (GET, POST, etc.).\n * @template Url - The URL path pattern (supports parameters like `/posts/:id`).\n * @template QuerySchema - Optional Zod schema for query parameter validation.\n * @template RequestSchema - Optional Zod schema for request body validation.\n *\n * @param endpoint - The endpoint declaration created with `declareXmlStream`.\n * @returns A method decorator function.\n *\n * @throws {Error} If used on a non-function or non-method.\n * @throws {Error} If the endpoint URL already exists.\n *\n * @example\n * ```typescript\n * import { XmlStream, declareXmlStream } from '@navios/adapter-xml'\n * import { Controller } from '@navios/core'\n *\n * const getRssFeed = declareXmlStream({\n * method: 'GET',\n * url: '/feed.xml',\n * contentType: 'application/rss+xml',\n * })\n *\n * @Controller('/api')\n * class FeedController {\n * @XmlStream(getRssFeed)\n * async getFeed() {\n * return (\n * <rss version=\"2.0\">\n * <channel>\n * <title>My Feed</title>\n * </channel>\n * </rss>\n * )\n * }\n * }\n * ```\n *\n * @example\n * ```typescript\n * // With query parameters\n * const getSitemap = declareXmlStream({\n * method: 'GET',\n * url: '/sitemap.xml',\n * querySchema: z.object({ page: z.string().optional() }),\n * })\n *\n * @Controller()\n * class SitemapController {\n * @XmlStream(getSitemap)\n * async getSitemap(params: { query?: { page?: string } }) {\n * const page = params.query?.page\n * return <urlset>...</urlset>\n * }\n * }\n * ```\n */\nexport function XmlStream<\n Method extends HttpMethod = HttpMethod,\n Url extends string = string,\n QuerySchema = undefined,\n RequestSchema = ZodType,\n>(endpoint: { config: BaseXmlStreamConfig<Method, Url, QuerySchema, RequestSchema> }) {\n return (\n target: (\n params: QuerySchema extends ZodObject\n ? RequestSchema extends ZodType\n ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, RequestSchema, true>>\n : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>>\n : RequestSchema extends ZodType\n ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, RequestSchema, true>>\n : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>,\n ) => Promise<any>, // Returns XmlNode\n context: ClassMethodDecoratorContext,\n ) => {\n if (typeof target !== 'function') {\n throw new Error('[Navios] XmlStream decorator can only be used on functions.')\n }\n if (context.kind !== 'method') {\n throw new Error('[Navios] XmlStream decorator can only be used on methods.')\n }\n\n const config = endpoint.config\n if (context.metadata) {\n const endpointMetadata = getEndpointMetadata<BaseXmlStreamConfig>(target, context)\n if (endpointMetadata.config && endpointMetadata.config.url) {\n throw new Error(`[Navios] Endpoint ${config.method} ${config.url} already exists.`)\n }\n // @ts-expect-error We don't need to set correctly in the metadata\n endpointMetadata.config = config\n endpointMetadata.adapterToken = XmlStreamAdapterToken\n endpointMetadata.classMethod = target.name\n endpointMetadata.httpMethod = config.method\n endpointMetadata.url = config.url\n }\n return target\n }\n}\n","import { getEndpointMetadata, XmlStreamAdapterToken } from \"@navios/core\";\nexport function XmlStream(endpoint) {\n return (target, context) => {\n if (typeof target !== \"function\") {\n throw new Error(\"[Navios] XmlStream decorator can only be used on functions.\");\n }\n if (context.kind !== \"method\") {\n throw new Error(\"[Navios] XmlStream decorator can only be used on methods.\");\n }\n const config = endpoint.config;\n if (context.metadata) {\n const endpointMetadata = getEndpointMetadata(target, context);\n if (endpointMetadata.config && endpointMetadata.config.url) {\n throw new Error(`[Navios] Endpoint ${config.method} ${config.url} already exists.`);\n }\n endpointMetadata.config = config;\n endpointMetadata.adapterToken = XmlStreamAdapterToken;\n endpointMetadata.classMethod = target.name;\n endpointMetadata.httpMethod = config.method;\n endpointMetadata.url = config.url;\n }\n return target;\n };\n}\n"],["import type {\n AbstractHttpHandlerAdapterInterface,\n ClassType,\n HandlerMetadata,\n ScopedContainer,\n} from '@navios/core'\n\nimport {\n inject,\n Injectable,\n StreamAdapterToken,\n XmlStreamAdapterToken,\n} from '@navios/core'\n\nimport type { BaseXmlStreamConfig } from '../types/config.mjs'\nimport type { AnyXmlNode } from '../types/xml-node.mjs'\n\nimport { renderToXml } from '../runtime/render-to-xml.mjs'\n\n/**\n * Adapter service for handling XML Stream endpoints in Navios.\n *\n * This service integrates with the base stream adapter (Fastify or Bun) to handle\n * XML endpoints that return JSX-based XML responses. It automatically renders JSX\n * nodes to XML strings and sends them with the appropriate Content-Type headers.\n *\n * The service supports:\n * - Async components (resolved in parallel)\n * - Class components (resolved via DI container)\n * - Regular JSX elements\n * - CDATA sections\n * - Raw XML content\n *\n * @implements {AbstractHttpHandlerAdapterInterface}\n *\n * @example\n * ```ts\n * // This service is automatically registered when using defineXmlEnvironment()\n * // and is used by endpoints decorated with @XmlStream()\n * ```\n */\n@Injectable({\n token: XmlStreamAdapterToken,\n})\nexport class XmlStreamAdapterService implements AbstractHttpHandlerAdapterInterface {\n /** Base stream adapter - we proxy hasSchema, prepareArguments, provideSchema to it */\n protected streamAdapter = inject(StreamAdapterToken)\n\n /**\n * Prepares argument getters for parsing request data.\n *\n * Proxies to the base stream adapter to reuse existing argument preparation logic\n * that handles query parameters, request body, and URL parameters for both\n * Fastify and Bun adapters.\n *\n * @param handlerMetadata - The handler metadata with schemas and configuration.\n * @returns An array of getter functions that populate request arguments.\n */\n prepareArguments(handlerMetadata: HandlerMetadata<BaseXmlStreamConfig>) {\n return this.streamAdapter.prepareArguments?.(handlerMetadata) ?? []\n }\n\n /**\n * Provides schema information for the handler.\n *\n * Proxies to the base stream adapter to reuse existing schema generation logic.\n * For Fastify, this enables built-in validation. For Bun, this returns an empty object.\n *\n * @param handlerMetadata - The handler metadata containing configuration and schemas.\n * @returns Schema information (Fastify route schema or empty object for Bun).\n */\n provideSchema(\n handlerMetadata: HandlerMetadata<BaseXmlStreamConfig>,\n ): Record<string, any> {\n if (\n 'provideSchema' in this.streamAdapter &&\n typeof this.streamAdapter.provideSchema === 'function'\n ) {\n return this.streamAdapter.provideSchema(handlerMetadata)\n }\n return {}\n }\n\n /**\n * Checks if the handler has any validation schemas defined.\n *\n * Proxies to the base stream adapter to check for query or request schemas.\n *\n * @param handlerMetadata - The handler metadata containing configuration.\n * @returns `true` if the handler has any schemas (query or request).\n */\n hasSchema(handlerMetadata: HandlerMetadata<any>): boolean {\n if (\n 'hasSchema' in this.streamAdapter &&\n typeof this.streamAdapter.hasSchema === 'function'\n ) {\n return this.streamAdapter.hasSchema(handlerMetadata)\n }\n return false\n }\n\n /**\n * Creates a request handler function for XML Stream endpoints.\n *\n * This method generates a handler that:\n * 1. Parses and validates request data (body, query, URL params) using the base adapter\n * 2. Invokes the controller method with validated arguments (returns JSX)\n * 3. Renders the JSX tree to XML string (resolves async and class components)\n * 4. Sends the XML response with appropriate Content-Type header\n *\n * The handler automatically detects the environment (Fastify vs Bun) and uses the\n * appropriate response mechanism (reply object vs Response object).\n *\n * @param controller - The controller class containing the handler method.\n * @param handlerMetadata - The handler metadata with configuration and schemas.\n * @returns A function that handles incoming requests and sends XML responses.\n */\n provideHandler(\n controller: ClassType,\n handlerMetadata: HandlerMetadata<BaseXmlStreamConfig>,\n ): (context: ScopedContainer, request: any, reply: any) => Promise<any> {\n const getters = this.prepareArguments(handlerMetadata)\n const config = handlerMetadata.config\n\n const formatArguments = async (request: any) => {\n const argument: Record<string, any> = {}\n const promises: Promise<void>[] = []\n for (const getter of getters) {\n const res = getter(argument, request)\n if (res instanceof Promise) {\n promises.push(res)\n }\n }\n await Promise.all(promises)\n return argument\n }\n\n const contentType = config.contentType ?? 'application/xml'\n\n return async (context: ScopedContainer, request: any, reply: any) => {\n const controllerInstance = await context.get(controller)\n const argument = await formatArguments(request)\n\n // Call controller method - returns XmlNode (JSX), may contain async/class components\n const xmlNode: AnyXmlNode =\n await controllerInstance[handlerMetadata.classMethod](argument)\n\n // Render JSX to XML string (async - resolves all async and class components)\n const xml = await renderToXml(xmlNode, {\n declaration: config.xmlDeclaration ?? true,\n encoding: config.encoding ?? 'UTF-8',\n container: context,\n })\n\n // Environment detection: Bun doesn't have reply\n const isHttpStandardEnvironment = reply === undefined\n\n if (isHttpStandardEnvironment) {\n // Bun: return Response object\n const headers: Record<string, string> = {\n 'Content-Type': contentType,\n }\n for (const [key, value] of Object.entries(handlerMetadata.headers)) {\n if (value != null) {\n headers[key] = String(value)\n }\n }\n return new Response(xml, {\n status: handlerMetadata.successStatusCode,\n headers,\n })\n } else {\n // Fastify: use reply object\n reply\n .status(handlerMetadata.successStatusCode)\n .header('Content-Type', contentType)\n .headers(handlerMetadata.headers)\n .send(xml)\n }\n }\n }\n}\n","var __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __knownSymbol = (name, symbol) => (symbol = Symbol[name]) ? symbol : /* @__PURE__ */ Symbol.for(\"Symbol.\" + name);\nvar __typeError = (msg) => {\n throw TypeError(msg);\n};\nvar __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;\nvar __name = (target, value) => __defProp(target, \"name\", { value, configurable: true });\nvar __decoratorStart = (base) => [, , , __create(base?.[__knownSymbol(\"metadata\")] ?? null)];\nvar __decoratorStrings = [\"class\", \"method\", \"getter\", \"setter\", \"accessor\", \"field\", \"value\", \"get\", \"set\"];\nvar __expectFn = (fn) => fn !== void 0 && typeof fn !== \"function\" ? __typeError(\"Function expected\") : fn;\nvar __decoratorContext = (kind, name, done, metadata, fns) => ({ kind: __decoratorStrings[kind], name, metadata, addInitializer: (fn) => done._ ? __typeError(\"Already initialized\") : fns.push(__expectFn(fn || null)) });\nvar __decoratorMetadata = (array, target) => __defNormalProp(target, __knownSymbol(\"metadata\"), array[3]);\nvar __runInitializers = (array, flags, self, value) => {\n for (var i = 0, fns = array[flags >> 1], n = fns && fns.length; i < n; i++) flags & 1 ? fns[i].call(self) : value = fns[i].call(self, value);\n return value;\n};\nvar __decorateElement = (array, flags, name, decorators, target, extra) => {\n var fn, it, done, ctx, access, k = flags & 7, s = !!(flags & 8), p = !!(flags & 16);\n var j = k > 3 ? array.length + 1 : k ? s ? 1 : 2 : 0, key = __decoratorStrings[k + 5];\n var initializers = k > 3 && (array[j - 1] = []), extraInitializers = array[j] || (array[j] = []);\n var desc = k && (!p && !s && (target = target.prototype), k < 5 && (k > 3 || !p) && __getOwnPropDesc(k < 4 ? target : { get [name]() {\n return __privateGet(this, extra);\n }, set [name](x) {\n return __privateSet(this, extra, x);\n } }, name));\n k ? p && k < 4 && __name(extra, (k > 2 ? \"set \" : k > 1 ? \"get \" : \"\") + name) : __name(target, name);\n for (var i = decorators.length - 1; i >= 0; i--) {\n ctx = __decoratorContext(k, name, done = {}, array[3], extraInitializers);\n if (k) {\n ctx.static = s, ctx.private = p, access = ctx.access = { has: p ? (x) => __privateIn(target, x) : (x) => name in x };\n if (k ^ 3) access.get = p ? (x) => (k ^ 1 ? __privateGet : __privateMethod)(x, target, k ^ 4 ? extra : desc.get) : (x) => x[name];\n if (k > 2) access.set = p ? (x, y) => __privateSet(x, target, y, k ^ 4 ? extra : desc.set) : (x, y) => x[name] = y;\n }\n it = (0, decorators[i])(k ? k < 4 ? p ? extra : desc[key] : k > 4 ? void 0 : { get: desc.get, set: desc.set } : target, ctx), done._ = 1;\n if (k ^ 4 || it === void 0) __expectFn(it) && (k > 4 ? initializers.unshift(it) : k ? p ? extra = it : desc[key] = it : target = it);\n else if (typeof it !== \"object\" || it === null) __typeError(\"Object expected\");\n else __expectFn(fn = it.get) && (desc.get = fn), __expectFn(fn = it.set) && (desc.set = fn), __expectFn(fn = it.init) && initializers.unshift(fn);\n }\n return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;\n};\nvar __accessCheck = (obj, member, msg) => member.has(obj) || __typeError(\"Cannot \" + msg);\nvar __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the \"in\" operator on this value') : member.has(obj);\nvar __privateGet = (obj, member, getter) => (__accessCheck(obj, member, \"read from private field\"), getter ? getter.call(obj) : member.get(obj));\nvar __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, \"write to private field\"), setter ? setter.call(obj, value) : member.set(obj, value), value);\nvar __privateMethod = (obj, member, method) => (__accessCheck(obj, member, \"access private method\"), method);\nvar _XmlStreamAdapterService_decorators, _init;\nimport {\n inject,\n Injectable,\n StreamAdapterToken,\n XmlStreamAdapterToken\n} from \"@navios/core\";\nimport { renderToXml } from \"../runtime/render-to-xml.mjs\";\n_XmlStreamAdapterService_decorators = [Injectable({\n token: XmlStreamAdapterToken\n})];\nexport class XmlStreamAdapterService {\n /** Base stream adapter - we proxy hasSchema, prepareArguments, provideSchema to it */\n streamAdapter = inject(StreamAdapterToken);\n /**\n * Prepares argument getters for parsing request data.\n *\n * Proxies to the base stream adapter to reuse existing argument preparation logic\n * that handles query parameters, request body, and URL parameters for both\n * Fastify and Bun adapters.\n *\n * @param handlerMetadata - The handler metadata with schemas and configuration.\n * @returns An array of getter functions that populate request arguments.\n */\n prepareArguments(handlerMetadata) {\n return this.streamAdapter.prepareArguments?.(handlerMetadata) ?? [];\n }\n /**\n * Provides schema information for the handler.\n *\n * Proxies to the base stream adapter to reuse existing schema generation logic.\n * For Fastify, this enables built-in validation. For Bun, this returns an empty object.\n *\n * @param handlerMetadata - The handler metadata containing configuration and schemas.\n * @returns Schema information (Fastify route schema or empty object for Bun).\n */\n provideSchema(handlerMetadata) {\n if (\"provideSchema\" in this.streamAdapter && typeof this.streamAdapter.provideSchema === \"function\") {\n return this.streamAdapter.provideSchema(handlerMetadata);\n }\n return {};\n }\n /**\n * Checks if the handler has any validation schemas defined.\n *\n * Proxies to the base stream adapter to check for query or request schemas.\n *\n * @param handlerMetadata - The handler metadata containing configuration.\n * @returns `true` if the handler has any schemas (query or request).\n */\n hasSchema(handlerMetadata) {\n if (\"hasSchema\" in this.streamAdapter && typeof this.streamAdapter.hasSchema === \"function\") {\n return this.streamAdapter.hasSchema(handlerMetadata);\n }\n return false;\n }\n /**\n * Creates a request handler function for XML Stream endpoints.\n *\n * This method generates a handler that:\n * 1. Parses and validates request data (body, query, URL params) using the base adapter\n * 2. Invokes the controller method with validated arguments (returns JSX)\n * 3. Renders the JSX tree to XML string (resolves async and class components)\n * 4. Sends the XML response with appropriate Content-Type header\n *\n * The handler automatically detects the environment (Fastify vs Bun) and uses the\n * appropriate response mechanism (reply object vs Response object).\n *\n * @param controller - The controller class containing the handler method.\n * @param handlerMetadata - The handler metadata with configuration and schemas.\n * @returns A function that handles incoming requests and sends XML responses.\n */\n provideHandler(controller, handlerMetadata) {\n const getters = this.prepareArguments(handlerMetadata);\n const config = handlerMetadata.config;\n const formatArguments = async (request) => {\n const argument = {};\n const promises = [];\n for (const getter of getters) {\n const res = getter(argument, request);\n if (res instanceof Promise) {\n promises.push(res);\n }\n }\n await Promise.all(promises);\n return argument;\n };\n const contentType = config.contentType ?? \"application/xml\";\n return async (context, request, reply) => {\n const controllerInstance = await context.get(controller);\n const argument = await formatArguments(request);\n const xmlNode = await controllerInstance[handlerMetadata.classMethod](argument);\n const xml = await renderToXml(xmlNode, {\n declaration: config.xmlDeclaration ?? true,\n encoding: config.encoding ?? \"UTF-8\",\n container: context\n });\n const isHttpStandardEnvironment = reply === void 0;\n if (isHttpStandardEnvironment) {\n const headers = {\n \"Content-Type\": contentType\n };\n for (const [key, value] of Object.entries(handlerMetadata.headers)) {\n if (value != null) {\n headers[key] = String(value);\n }\n }\n return new Response(xml, {\n status: handlerMetadata.successStatusCode,\n headers\n });\n } else {\n reply.status(handlerMetadata.successStatusCode).header(\"Content-Type\", contentType).headers(handlerMetadata.headers).send(xml);\n }\n };\n }\n}\n_init = __decoratorStart(null);\nXmlStreamAdapterService = __decorateElement(_init, 0, \"XmlStreamAdapterService\", _XmlStreamAdapterService_decorators, XmlStreamAdapterService);\n__runInitializers(_init, 1, XmlStreamAdapterService);\n"]]
@@ -1 +1 @@
1
- {"version":3,"file":"bun-plugin.d.mts","sourceRoot":"","sources":["../bun-plugin.mts"],"names":[],"mappings":"AAgEA,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,MAAM,GAAG,SAQvD,CAAA;AACD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EACzD,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,MAAM,GAWK,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CACrD;AAOD,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,KAAG,IAG3D,CAAA"}
1
+ {"version":3,"file":"bun-plugin.d.mts","sourceRoot":"","sources":["../bun-plugin.mts"],"names":[],"mappings":"AA+DA,eAAO,MAAM,YAAY,GAAI,SAAS,MAAM,KAAG,MAAM,GAAG,SAQvD,CAAA;AACD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,EACzD,IAAI,EAAE,CAAC,EACP,OAAO,EAAE,MAAM,GAWK,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KAAK,IAAI,CACrD;AASD,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,KAAG,IAG3D,CAAA"}