@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
@@ -1,21 +1,76 @@
1
- import type { AbstractHttpHandlerAdapterInterface, HandlerMetadata } from '@navios/core';
2
- import type { ClassType, RequestContextHolder } from '@navios/di';
3
- import { Container } from '@navios/di';
1
+ import type { AbstractHttpHandlerAdapterInterface, ClassType, HandlerMetadata, ScopedContainer } from '@navios/core';
4
2
  import type { BaseXmlStreamConfig } from '../types/config.mjs';
3
+ /**
4
+ * Adapter service for handling XML Stream endpoints in Navios.
5
+ *
6
+ * This service integrates with the base stream adapter (Fastify or Bun) to handle
7
+ * XML endpoints that return JSX-based XML responses. It automatically renders JSX
8
+ * nodes to XML strings and sends them with the appropriate Content-Type headers.
9
+ *
10
+ * The service supports:
11
+ * - Async components (resolved in parallel)
12
+ * - Class components (resolved via DI container)
13
+ * - Regular JSX elements
14
+ * - CDATA sections
15
+ * - Raw XML content
16
+ *
17
+ * @implements {AbstractHttpHandlerAdapterInterface}
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * // This service is automatically registered when using defineXmlEnvironment()
22
+ * // and is used by endpoints decorated with @XmlStream()
23
+ * ```
24
+ */
5
25
  export declare class XmlStreamAdapterService implements AbstractHttpHandlerAdapterInterface {
6
- protected container: Container;
7
26
  /** Base stream adapter - we proxy hasSchema, prepareArguments, provideSchema to it */
8
27
  protected streamAdapter: AbstractHttpHandlerAdapterInterface;
9
28
  /**
10
- * Proxy to base StreamAdapter - reuses existing argument preparation logic
11
- * (handles querySchema, requestSchema, URL params for both Fastify and Bun)
29
+ * Prepares argument getters for parsing request data.
30
+ *
31
+ * Proxies to the base stream adapter to reuse existing argument preparation logic
32
+ * that handles query parameters, request body, and URL parameters for both
33
+ * Fastify and Bun adapters.
34
+ *
35
+ * @param handlerMetadata - The handler metadata with schemas and configuration.
36
+ * @returns An array of getter functions that populate request arguments.
12
37
  */
13
38
  prepareArguments(handlerMetadata: HandlerMetadata<BaseXmlStreamConfig>): ((target: Record<string, any>, request: any) => Promise<void> | void)[];
39
+ /**
40
+ * Provides schema information for the handler.
41
+ *
42
+ * Proxies to the base stream adapter to reuse existing schema generation logic.
43
+ * For Fastify, this enables built-in validation. For Bun, this returns an empty object.
44
+ *
45
+ * @param handlerMetadata - The handler metadata containing configuration and schemas.
46
+ * @returns Schema information (Fastify route schema or empty object for Bun).
47
+ */
14
48
  provideSchema(handlerMetadata: HandlerMetadata<BaseXmlStreamConfig>): Record<string, any>;
49
+ /**
50
+ * Checks if the handler has any validation schemas defined.
51
+ *
52
+ * Proxies to the base stream adapter to check for query or request schemas.
53
+ *
54
+ * @param handlerMetadata - The handler metadata containing configuration.
55
+ * @returns `true` if the handler has any schemas (query or request).
56
+ */
15
57
  hasSchema(handlerMetadata: HandlerMetadata<any>): boolean;
16
58
  /**
17
- * Custom handler - renders JSX to XML and handles response for both Fastify and Bun
59
+ * Creates a request handler function for XML Stream endpoints.
60
+ *
61
+ * This method generates a handler that:
62
+ * 1. Parses and validates request data (body, query, URL params) using the base adapter
63
+ * 2. Invokes the controller method with validated arguments (returns JSX)
64
+ * 3. Renders the JSX tree to XML string (resolves async and class components)
65
+ * 4. Sends the XML response with appropriate Content-Type header
66
+ *
67
+ * The handler automatically detects the environment (Fastify vs Bun) and uses the
68
+ * appropriate response mechanism (reply object vs Response object).
69
+ *
70
+ * @param controller - The controller class containing the handler method.
71
+ * @param handlerMetadata - The handler metadata with configuration and schemas.
72
+ * @returns A function that handles incoming requests and sends XML responses.
18
73
  */
19
- provideHandler(controller: ClassType, handlerMetadata: HandlerMetadata<BaseXmlStreamConfig>): (context: RequestContextHolder, request: any, reply: any) => Promise<any>;
74
+ provideHandler(controller: ClassType, handlerMetadata: HandlerMetadata<BaseXmlStreamConfig>): (context: ScopedContainer, request: any, reply: any) => Promise<any>;
20
75
  }
21
76
  //# sourceMappingURL=xml-stream-adapter.service.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"xml-stream-adapter.service.d.mts","sourceRoot":"","sources":["../../../src/adapters/xml-stream-adapter.service.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mCAAmC,EACnC,eAAe,EAChB,MAAM,cAAc,CAAA;AACrB,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAGjE,OAAO,EAAE,SAAS,EAAsB,MAAM,YAAY,CAAA;AAE1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAK9D,qBAGa,uBAAwB,YAAW,mCAAmC;IACjF,SAAS,CAAC,SAAS,YAAoB;IACvC,sFAAsF;IACtF,SAAS,CAAC,aAAa,sCAA6B;IAEpD;;;OAGG;IACH,gBAAgB,CAAC,eAAe,EAAE,eAAe,CAAC,mBAAmB,CAAC;IAItE,aAAa,CACX,eAAe,EAAE,eAAe,CAAC,mBAAmB,CAAC,GACpD,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAUtB,SAAS,CAAC,eAAe,EAAE,eAAe,CAAC,GAAG,CAAC,GAAG,OAAO;IAUzD;;OAEG;IACH,cAAc,CACZ,UAAU,EAAE,SAAS,EACrB,eAAe,EAAE,eAAe,CAAC,mBAAmB,CAAC,GACpD,CAAC,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC;CA8D7E"}
1
+ {"version":3,"file":"xml-stream-adapter.service.d.mts","sourceRoot":"","sources":["../../../src/adapters/xml-stream-adapter.service.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mCAAmC,EACnC,SAAS,EACT,eAAe,EACf,eAAe,EAChB,MAAM,cAAc,CAAA;AASrB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAK9D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAGa,uBAAwB,YAAW,mCAAmC;IACjF,sFAAsF;IACtF,SAAS,CAAC,aAAa,sCAA6B;IAEpD;;;;;;;;;OASG;IACH,gBAAgB,CAAC,eAAe,EAAE,eAAe,CAAC,mBAAmB,CAAC;IAItE;;;;;;;;OAQG;IACH,aAAa,CACX,eAAe,EAAE,eAAe,CAAC,mBAAmB,CAAC,GACpD,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAUtB;;;;;;;OAOG;IACH,SAAS,CAAC,eAAe,EAAE,eAAe,CAAC,GAAG,CAAC,GAAG,OAAO;IAUzD;;;;;;;;;;;;;;;OAeG;IACH,cAAc,CACZ,UAAU,EAAE,SAAS,EACrB,eAAe,EAAE,eAAe,CAAC,mBAAmB,CAAC,GACpD,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,CAAC;CA6DxE"}
@@ -1,7 +1,59 @@
1
+ import type { Registry } from '@navios/core';
1
2
  import type { z, ZodObject, ZodRawShape } from 'zod/v4';
2
- import type { Registry } from '@navios/di';
3
3
  import type { ComponentClass, XmlComponent } from '../types/component.mjs';
4
4
  export declare const ComponentMeta: unique symbol;
5
+ /**
6
+ * Decorator for class-based XML components with dependency injection support.
7
+ *
8
+ * Class components must implement the `XmlComponent` interface with a `render()` method.
9
+ * They can optionally accept props via constructor, validated with a Zod schema.
10
+ *
11
+ * @overload
12
+ * Component without props (no schema).
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * @Component()
17
+ * class LatestPostsComponent implements XmlComponent {
18
+ * private readonly postService = inject(PostService)
19
+ *
20
+ * async render() {
21
+ * const posts = await this.postService.getLatestPosts()
22
+ * return <>{posts.map(post => <item>...</item>)}</>
23
+ * }
24
+ * }
25
+ * ```
26
+ *
27
+ * @overload
28
+ * Component with props schema for type-safe props.
29
+ *
30
+ * @param options - Configuration object with schema and optional registry.
31
+ * @param options.schema - Zod schema for validating and typing component props.
32
+ * @param options.registry - Optional custom DI registry (defaults to global registry).
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * const DescriptionSchema = z.object({
37
+ * content: z.string(),
38
+ * wrapInCData: z.boolean().optional(),
39
+ * })
40
+ *
41
+ * @Component({ schema: DescriptionSchema })
42
+ * class DescriptionComponent implements XmlComponent {
43
+ * constructor(private props: z.output<typeof DescriptionSchema>) {}
44
+ *
45
+ * async render() {
46
+ * return <description>{this.props.wrapInCData ? <CData>{this.props.content}</CData> : this.props.content}</description>
47
+ * }
48
+ * }
49
+ * ```
50
+ *
51
+ * @overload
52
+ * Component with custom registry only (no props).
53
+ *
54
+ * @param options - Configuration object with registry.
55
+ * @param options.registry - Custom DI registry to use for this component.
56
+ */
5
57
  export declare function Component(): <T extends ComponentClass>(target: T, context?: ClassDecoratorContext) => T;
6
58
  export declare function Component<Schema extends ZodObject<ZodRawShape>>(options: {
7
59
  schema: Schema;
@@ -11,7 +63,21 @@ export declare function Component(options: {
11
63
  registry: Registry;
12
64
  }): <T extends ComponentClass>(target: T, context?: ClassDecoratorContext) => T;
13
65
  /**
14
- * Type guard to check if a class is a component
66
+ * Type guard to check if a value is a component class.
67
+ *
68
+ * Component classes are classes decorated with `@Component` that implement
69
+ * the `XmlComponent` interface.
70
+ *
71
+ * @param value - The value to check.
72
+ * @returns `true` if the value is a component class, `false` otherwise.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * if (isComponentClass(MyClass)) {
77
+ * // MyClass is a component class
78
+ * const instance = await container.get(MyClass)
79
+ * }
80
+ * ```
15
81
  */
16
82
  export declare function isComponentClass(value: unknown): value is ComponentClass;
17
83
  //# sourceMappingURL=component.decorator.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"component.decorator.d.mts","sourceRoot":"","sources":["../../../src/decorators/component.decorator.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAEvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAU1C,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAE1E,eAAO,MAAM,aAAa,eAAmC,CAAA;AAG7D,wBAAgB,SAAS,IAAI,CAAC,CAAC,SAAS,cAAc,EACpD,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,qBAAqB,KAC5B,CAAC,CAAA;AAGN,wBAAgB,SAAS,CAAC,MAAM,SAAS,SAAS,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE;IACxE,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,QAAQ,CAAA;CACpB,GAAG,CAAC,CAAC,SAAS,KAAK,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,YAAY,EAC1E,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAA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,QAAQ,EAAE,QAAQ,CAAA;CACnB,GAAG,CAAC,CAAC,SAAS,cAAc,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,qBAAqB,KAAK,CAAC,CAAA;AAuD/E;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,cAAc,CAMxE"}
@@ -1,22 +1,58 @@
1
1
  import type { EndpointFunctionArgs, HttpMethod, Util_FlatObject } from '@navios/builder';
2
2
  import type { ZodObject, ZodType } from 'zod/v4';
3
3
  import type { BaseXmlStreamConfig } from '../types/config.mjs';
4
+ /**
5
+ * Type helper that extracts the parameter types for an XML Stream endpoint handler.
6
+ *
7
+ * This type automatically infers the correct parameter types based on the endpoint
8
+ * configuration, including URL parameters, query parameters, and request body.
9
+ *
10
+ * @template EndpointDeclaration - The endpoint declaration type from `declareXmlStream`.
11
+ * @template Url - The URL path pattern.
12
+ * @template QuerySchema - The query parameter schema type.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const getFeed = declareXmlStream({
17
+ * method: 'GET',
18
+ * url: '/feed/:category',
19
+ * querySchema: z.object({ page: z.string() }),
20
+ * })
21
+ *
22
+ * // XmlStreamParams<typeof getFeed> resolves to:
23
+ * // { urlParams: { category: string }, query: { page: string } }
24
+ * ```
25
+ */
4
26
  export type XmlStreamParams<EndpointDeclaration extends {
5
27
  config: BaseXmlStreamConfig<any, any, any, any>;
6
28
  }, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends ZodObject ? EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>> : EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>;
7
29
  /**
8
30
  * Decorator for XML Stream endpoints that return JSX-based XML responses.
9
31
  *
32
+ * This decorator marks controller methods that return JSX elements, which will be
33
+ * automatically rendered to XML and sent with the appropriate Content-Type header.
34
+ * The method can be async and can contain async components, class components, and
35
+ * regular JSX elements.
36
+ *
37
+ * @template Method - The HTTP method (GET, POST, etc.).
38
+ * @template Url - The URL path pattern (supports parameters like `/posts/:id`).
39
+ * @template QuerySchema - Optional Zod schema for query parameter validation.
40
+ * @template RequestSchema - Optional Zod schema for request body validation.
41
+ *
42
+ * @param endpoint - The endpoint declaration created with `declareXmlStream`.
43
+ * @returns A method decorator function.
44
+ *
45
+ * @throws {Error} If used on a non-function or non-method.
46
+ * @throws {Error} If the endpoint URL already exists.
47
+ *
10
48
  * @example
11
49
  * ```typescript
12
- * import { XmlStream } from '@navios/adapter-xml'
50
+ * import { XmlStream, declareXmlStream } from '@navios/adapter-xml'
13
51
  * import { Controller } from '@navios/core'
14
52
  *
15
53
  * const getRssFeed = declareXmlStream({
16
54
  * method: 'GET',
17
55
  * url: '/feed.xml',
18
- * querySchema: undefined,
19
- * requestSchema: undefined,
20
56
  * contentType: 'application/rss+xml',
21
57
  * })
22
58
  *
@@ -34,6 +70,25 @@ export type XmlStreamParams<EndpointDeclaration extends {
34
70
  * }
35
71
  * }
36
72
  * ```
73
+ *
74
+ * @example
75
+ * ```typescript
76
+ * // With query parameters
77
+ * const getSitemap = declareXmlStream({
78
+ * method: 'GET',
79
+ * url: '/sitemap.xml',
80
+ * querySchema: z.object({ page: z.string().optional() }),
81
+ * })
82
+ *
83
+ * @Controller()
84
+ * class SitemapController {
85
+ * @XmlStream(getSitemap)
86
+ * async getSitemap(params: { query?: { page?: string } }) {
87
+ * const page = params.query?.page
88
+ * return <urlset>...</urlset>
89
+ * }
90
+ * }
91
+ * ```
37
92
  */
38
93
  export declare function XmlStream<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, RequestSchema = ZodType>(endpoint: {
39
94
  config: BaseXmlStreamConfig<Method, Url, QuerySchema, RequestSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"xml-stream.decorator.d.mts","sourceRoot":"","sources":["../../../src/decorators/xml-stream.decorator.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACxF,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAIhD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAE9D,MAAM,MAAM,eAAe,CACzB,mBAAmB,SAAS;IAC1B,MAAM,EAAE,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;CAChD,EACD,GAAG,SAAS,MAAM,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,EACzD,WAAW,GAAG,mBAAmB,CAAC,QAAQ,CAAC,CAAC,aAAa,CAAC,IACxD,WAAW,SAAS,SAAS,GAC7B,mBAAmB,CAAC,QAAQ,CAAC,CAAC,eAAe,CAAC,SAAS,OAAO,GAC5D,eAAe,CAAC,oBAAoB,CAAC,GAAG,EAAE,WAAW,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC,eAAe,CAAC,EAAE,IAAI,CAAC,CAAC,GAC7G,eAAe,CAAC,oBAAoB,CAAC,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,GAC1E,mBAAmB,CAAC,QAAQ,CAAC,CAAC,eAAe,CAAC,SAAS,OAAO,GAC5D,eAAe,CAAC,oBAAoB,CAAC,GAAG,EAAE,SAAS,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAC,eAAe,CAAC,EAAE,IAAI,CAAC,CAAC,GAC3G,eAAe,CAAC,oBAAoB,CAAC,GAAG,EAAE,SA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AAE,aAAa,EAAE,IAAI,CAAC,CAAC,GAC1E,eAAe,CAAC,oBAAoB,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,KACzE,OAAO,CAAC,GAAG,CAAC,CAyBpB"}
@@ -1,5 +1,5 @@
1
- import type { AnyInjectableType } from '@navios/di';
2
- import { InjectionToken } from '@navios/di';
1
+ import type { AnyInjectableType } from '@navios/core';
2
+ import { InjectionToken } from '@navios/core';
3
3
  /**
4
4
  * Creates the XML environment configuration to be merged with base adapter (Fastify/Bun).
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"define-environment.d.mts","sourceRoot":"","sources":["../../src/define-environment.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAGnD,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAI3C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB;;EAOnC"}
1
+ {"version":3,"file":"define-environment.d.mts","sourceRoot":"","sources":["../../src/define-environment.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAErD,OAAO,EAAE,cAAc,EAAyB,MAAM,cAAc,CAAA;AAIpE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB;;EAOnC"}
@@ -1,19 +1,41 @@
1
1
  import type { HttpMethod } from '@navios/builder';
2
2
  import type { BaseXmlStreamConfig } from '../types/config.mjs';
3
3
  /**
4
- * Declares an XML Stream endpoint configuration for use with @XmlStream decorator.
4
+ * Declares an XML Stream endpoint configuration for use with `@XmlStream` decorator.
5
+ *
6
+ * This function creates an endpoint declaration that can be used with the `@XmlStream`
7
+ * decorator to mark controller methods that return JSX-based XML responses.
8
+ *
9
+ * @template Method - The HTTP method (GET, POST, etc.).
10
+ * @template Url - The URL path pattern (supports parameters like `/posts/:id`).
11
+ * @template QuerySchema - Optional Zod schema for query parameter validation.
12
+ * @template RequestSchema - Optional Zod schema for request body validation.
13
+ *
14
+ * @param config - The endpoint configuration including method, URL, schemas, and XML options.
15
+ * @returns An endpoint declaration object to be used with `@XmlStream` decorator.
5
16
  *
6
17
  * @example
7
18
  * ```typescript
8
19
  * import { declareXmlStream } from '@navios/adapter-xml'
20
+ * import { z } from 'zod/v4'
9
21
  *
22
+ * // Simple endpoint
10
23
  * export const getRssFeed = declareXmlStream({
11
24
  * method: 'GET',
12
25
  * url: '/feed.xml',
13
- * querySchema: undefined,
14
- * requestSchema: undefined,
15
26
  * contentType: 'application/rss+xml',
27
+ * })
28
+ *
29
+ * // With query parameters
30
+ * export const getSitemap = declareXmlStream({
31
+ * method: 'GET',
32
+ * url: '/sitemap.xml',
33
+ * querySchema: z.object({
34
+ * page: z.string().optional(),
35
+ * }),
36
+ * contentType: 'application/xml',
16
37
  * xmlDeclaration: true,
38
+ * encoding: 'UTF-8',
17
39
  * })
18
40
  * ```
19
41
  */
@@ -1 +1 @@
1
- {"version":3,"file":"xml-stream.d.mts","sourceRoot":"","sources":["../../../src/handlers/xml-stream.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAE9D;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,SAAS,UAAU,EACzB,GAAG,SAAS,MAAM,EAClB,WAAW,GAAG,SAAS,EACvB,aAAa,GAAG,SAAS,EAEzB,MAAM,EAAE,mBAAmB,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,aAAa,CAAC,GACnE;IAAE,MAAM,EAAE,mBAAmB,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,aAAa,CAAC,CAAA;CAAE,CAE1E"}
1
+ {"version":3,"file":"xml-stream.d.mts","sourceRoot":"","sources":["../../../src/handlers/xml-stream.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEjD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAA;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,SAAS,UAAU,EACzB,GAAG,SAAS,MAAM,EAClB,WAAW,GAAG,SAAS,EACvB,aAAa,GAAG,SAAS,EAEzB,MAAM,EAAE,mBAAmB,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,aAAa,CAAC,GACnE;IAAE,MAAM,EAAE,mBAAmB,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,aAAa,CAAC,CAAA;CAAE,CAE1E"}
@@ -1,5 +1,18 @@
1
- import type { Container } from '@navios/di';
1
+ import type { Container, ScopedContainer } from '@navios/core';
2
2
  import type { AnyXmlNode } from '../types/xml-node.mjs';
3
+ /**
4
+ * Options for rendering XML from JSX nodes.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * const xml = await renderToXml(<rss version="2.0">...</rss>, {
9
+ * declaration: true,
10
+ * encoding: 'UTF-8',
11
+ * pretty: true,
12
+ * container: myContainer, // Required for class components
13
+ * })
14
+ * ```
15
+ */
3
16
  export interface RenderOptions {
4
17
  /** Include XML declaration (<?xml version="1.0"?>) - defaults to true */
5
18
  declaration?: boolean;
@@ -11,10 +24,65 @@ export interface RenderOptions {
11
24
  * DI container for resolving class components.
12
25
  * Required if the tree contains any class components.
13
26
  */
14
- container?: Container;
27
+ container?: Container | ScopedContainer;
15
28
  }
29
+ /**
30
+ * Error thrown when attempting to render a class component without a container.
31
+ *
32
+ * Class components require a dependency injection container to be instantiated.
33
+ * This error is thrown when `renderToXml` is called with a class component in
34
+ * the tree but no container is provided in the options.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * try {
39
+ * await renderToXml(<MyClassComponent />)
40
+ * } catch (error) {
41
+ * if (error instanceof MissingContainerError) {
42
+ * // Provide a container
43
+ * await renderToXml(<MyClassComponent />, { container })
44
+ * }
45
+ * }
46
+ * ```
47
+ */
16
48
  export declare class MissingContainerError extends Error {
17
49
  constructor(componentName: string);
18
50
  }
51
+ /**
52
+ * Renders a JSX XML node tree to an XML string.
53
+ *
54
+ * This function handles:
55
+ * - Regular XML nodes (tags with props and children)
56
+ * - Async components (resolves promises in parallel)
57
+ * - Class components (resolves via DI container)
58
+ * - CDATA sections
59
+ * - Raw XML content
60
+ * - Fragments
61
+ * - Text content with proper escaping
62
+ *
63
+ * @param node - The root XML node (JSX element) to render.
64
+ * @param options - Rendering options including declaration, encoding, pretty printing, and container.
65
+ * @returns A promise that resolves to the XML string.
66
+ *
67
+ * @throws {MissingContainerError} If the tree contains class components but no container is provided.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * // Simple rendering
72
+ * const xml = await renderToXml(<rss version="2.0"><channel>...</channel></rss>)
73
+ *
74
+ * // With options
75
+ * const xml = await renderToXml(<feed>...</feed>, {
76
+ * declaration: true,
77
+ * encoding: 'UTF-8',
78
+ * pretty: true,
79
+ * })
80
+ *
81
+ * // With class components (requires container)
82
+ * const container = new Container()
83
+ * container.beginRequest('request-id')
84
+ * const xml = await renderToXml(<MyClassComponent />, { container })
85
+ * ```
86
+ */
19
87
  export declare function renderToXml(node: AnyXmlNode, options?: RenderOptions): Promise<string>;
20
88
  //# sourceMappingURL=render-to-xml.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-to-xml.d.mts","sourceRoot":"","sources":["../../../src/runtime/render-to-xml.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAE3C,OAAO,KAAK,EACV,UAAU,EAKX,MAAM,uBAAuB,CAAA;AAW9B,MAAM,WAAW,aAAa;IAC5B,yEAAyE;IACzE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oCAAoC;IACpC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB;AAED,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,aAAa,EAAE,MAAM;CAOlC;AAED,wBAAsB,WAAW,CAC/B,IAAI,EAAE,UAAU,EAChB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAgBjB"}
1
+ {"version":3,"file":"render-to-xml.d.mts","sourceRoot":"","sources":["../../../src/runtime/render-to-xml.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAG9D,OAAO,KAAK,EACV,UAAU,EAKX,MAAM,uBAAuB,CAAA;AAU9B;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC5B,yEAAyE;IACzE,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,oCAAoC;IACpC,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;;OAGG;IACH,SAAS,CAAC,EAAE,SAAS,GAAG,eAAe,CAAA;CACxC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;gBAClC,aAAa,EAAE,MAAM;CAOlC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAsB,WAAW,CAC/B,IAAI,EAAE,UAAU,EAChB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,MAAM,CAAC,CAgBjB"}
@@ -1,6 +1,14 @@
1
1
  import type { ZodObject, ZodRawShape } from 'zod/v4';
2
2
  import type { z } from 'zod/v4';
3
3
  import type { AnyXmlNode, XmlNode } from '../types/xml-node.mjs';
4
+ /**
5
+ * Type for XML tag components created by `defineTag`.
6
+ *
7
+ * Tag components are functions that accept props and children, and return
8
+ * an XML node. They also have a `tagName` property for identification.
9
+ *
10
+ * @template Props - The props type for the tag component.
11
+ */
4
12
  export interface TagComponent<Props extends Record<string, unknown>> {
5
13
  (props: Props & {
6
14
  children?: AnyXmlNode | AnyXmlNode[];
@@ -1 +1 @@
1
- {"version":3,"file":"define-tag.d.mts","sourceRoot":"","sources":["../../../src/tags/define-tag.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAEhE,MAAM,WAAW,YAAY,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACjE,CAAC,KAAK,EAAE,KAAK,GAAG;QAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,UAAU,EAAE,CAAA;KAAE,GAAG,OAAO,CAAA;IAClE,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,WAAW,EAC7C,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,GACzB,YAAY,CAAC,CAAC,SAAS,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAkBrF"}
1
+ {"version":3,"file":"define-tag.d.mts","sourceRoot":"","sources":["../../../src/tags/define-tag.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpD,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAA;AAEhE;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACjE,CAAC,KAAK,EAAE,KAAK,GAAG;QAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,UAAU,EAAE,CAAA;KAAE,GAAG,OAAO,CAAA;IAClE,OAAO,EAAE,MAAM,CAAA;CAChB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,WAAW,EAC7C,IAAI,EAAE,MAAM,EACZ,WAAW,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,GACzB,YAAY,CAAC,CAAC,SAAS,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAkBrF"}
@@ -1,13 +1,57 @@
1
1
  import type { AnyXmlNode } from './xml-node.mjs';
2
2
  /**
3
- * Base interface for class components.
4
- * The render method takes no arguments - props are received via constructor.
3
+ * Base interface for class-based XML components.
4
+ *
5
+ * Class components are classes decorated with `@Component` that can use
6
+ * dependency injection and return JSX-based XML nodes. The `render()` method
7
+ * takes no arguments - props are received via the constructor.
8
+ *
9
+ * @example
10
+ * ```tsx
11
+ * @Component()
12
+ * class LatestPostsComponent implements XmlComponent {
13
+ * private readonly postService = inject(PostService)
14
+ *
15
+ * async render() {
16
+ * const posts = await this.postService.getLatestPosts()
17
+ * return (
18
+ * <>
19
+ * {posts.map(post => <item>...</item>)}
20
+ * </>
21
+ * )
22
+ * }
23
+ * }
24
+ * ```
25
+ *
26
+ * @example
27
+ * ```tsx
28
+ * // With props
29
+ * @Component({ schema: MyPropsSchema })
30
+ * class MyComponent implements XmlComponent {
31
+ * constructor(private props: z.output<typeof MyPropsSchema>) {}
32
+ *
33
+ * render() {
34
+ * return <div>{this.props.content}</div>
35
+ * }
36
+ * }
37
+ * ```
5
38
  */
6
39
  export interface XmlComponent {
40
+ /**
41
+ * Renders the component to an XML node.
42
+ *
43
+ * This method is called when the component is rendered. It can return
44
+ * a synchronous XML node or a Promise that resolves to an XML node.
45
+ *
46
+ * @returns An XML node or a Promise that resolves to an XML node.
47
+ */
7
48
  render(): AnyXmlNode | Promise<AnyXmlNode>;
8
49
  }
9
50
  /**
10
51
  * Type for class component constructors.
52
+ *
53
+ * This type represents a class constructor that creates instances of
54
+ * `XmlComponent`. Used for type checking and dependency injection.
11
55
  */
12
56
  export interface ComponentClass {
13
57
  new (...args: any[]): XmlComponent;
@@ -1 +1 @@
1
- {"version":3,"file":"component.d.mts","sourceRoot":"","sources":["../../../src/types/component.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,IAAI,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CAC3C;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,YAAY,CAAA;CACnC"}
1
+ {"version":3,"file":"component.d.mts","sourceRoot":"","sources":["../../../src/types/component.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;;;;OAOG;IACH,MAAM,IAAI,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CAC3C;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,YAAY,CAAA;CACnC"}
@@ -1,4 +1,26 @@
1
1
  import type { BaseStreamConfig, HttpMethod } from '@navios/builder';
2
+ /**
3
+ * Configuration interface for XML Stream endpoints.
4
+ *
5
+ * Extends the base stream configuration with XML-specific options including
6
+ * content type, XML declaration, and encoding settings.
7
+ *
8
+ * @template Method - The HTTP method (GET, POST, etc.).
9
+ * @template Url - The URL path pattern (supports parameters like `/posts/:id`).
10
+ * @template QuerySchema - Optional Zod schema for query parameter validation.
11
+ * @template RequestSchema - Optional Zod schema for request body validation.
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const config: BaseXmlStreamConfig = {
16
+ * method: 'GET',
17
+ * url: '/feed.xml',
18
+ * contentType: 'application/rss+xml',
19
+ * xmlDeclaration: true,
20
+ * encoding: 'UTF-8',
21
+ * }
22
+ * ```
23
+ */
2
24
  export interface BaseXmlStreamConfig<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, RequestSchema = undefined> extends BaseStreamConfig<Method, Url, QuerySchema, RequestSchema> {
3
25
  /** Content-Type header, defaults to 'application/xml' */
4
26
  contentType?: 'application/xml' | 'text/xml' | 'application/rss+xml' | 'application/atom+xml';
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.mts","sourceRoot":"","sources":["../../../src/types/config.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEnE,MAAM,WAAW,mBAAmB,CAClC,MAAM,SAAS,UAAU,GAAG,UAAU,EACtC,GAAG,SAAS,MAAM,GAAG,MAAM,EAC3B,WAAW,GAAG,SAAS,EACvB,aAAa,GAAG,SAAS,CACzB,SAAQ,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,aAAa,CAAC;IACjE,yDAAyD;IACzD,WAAW,CAAC,EAAE,iBAAiB,GAAG,UAAU,GAAG,qBAAqB,GAAG,sBAAsB,CAAA;IAC7F,yEAAyE;IACzE,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB"}
1
+ {"version":3,"file":"config.d.mts","sourceRoot":"","sources":["../../../src/types/config.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAEnE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,WAAW,mBAAmB,CAClC,MAAM,SAAS,UAAU,GAAG,UAAU,EACtC,GAAG,SAAS,MAAM,GAAG,MAAM,EAC3B,WAAW,GAAG,SAAS,EACvB,aAAa,GAAG,SAAS,CACzB,SAAQ,gBAAgB,CAAC,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,aAAa,CAAC;IACjE,yDAAyD;IACzD,WAAW,CAAC,EAAE,iBAAiB,GAAG,UAAU,GAAG,qBAAqB,GAAG,sBAAsB,CAAA;IAC7F,yEAAyE;IACzE,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB"}