@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.
- package/CHANGELOG.md +29 -0
- package/README.md +2 -1
- package/bun-plugin.mts +5 -3
- package/bunPlugin.cache +1 -1
- package/dist/bun-plugin.d.mts.map +1 -1
- package/dist/src/adapters/xml-stream-adapter.service.d.mts +63 -8
- package/dist/src/adapters/xml-stream-adapter.service.d.mts.map +1 -1
- package/dist/src/decorators/component.decorator.d.mts +68 -2
- package/dist/src/decorators/component.decorator.d.mts.map +1 -1
- package/dist/src/decorators/xml-stream.decorator.d.mts +58 -3
- package/dist/src/decorators/xml-stream.decorator.d.mts.map +1 -1
- package/dist/src/define-environment.d.mts +2 -2
- package/dist/src/define-environment.d.mts.map +1 -1
- package/dist/src/handlers/xml-stream.d.mts +25 -3
- package/dist/src/handlers/xml-stream.d.mts.map +1 -1
- package/dist/src/runtime/render-to-xml.d.mts +70 -2
- package/dist/src/runtime/render-to-xml.d.mts.map +1 -1
- package/dist/src/tags/define-tag.d.mts +8 -0
- package/dist/src/tags/define-tag.d.mts.map +1 -1
- package/dist/src/types/component.d.mts +46 -2
- package/dist/src/types/component.d.mts.map +1 -1
- package/dist/src/types/config.d.mts +22 -0
- package/dist/src/types/config.d.mts.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/tsconfig.spec.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/tsdown.config.d.mts +3 -0
- package/dist/tsdown.config.d.mts.map +1 -0
- package/dist/vitest.e2e.fastify.config.d.mts.map +1 -1
- package/lib/create-element--Gd2L8UR.d.cts +26 -0
- package/lib/create-element--Gd2L8UR.d.cts.map +1 -0
- package/lib/create-element-61MP7_99.d.mts +26 -0
- package/lib/create-element-61MP7_99.d.mts.map +1 -0
- package/lib/create-element-CTOxv6Df.cjs +183 -0
- package/lib/create-element-CTOxv6Df.cjs.map +1 -0
- package/lib/create-element-NZEYaRw5.mjs +124 -0
- package/lib/create-element-NZEYaRw5.mjs.map +1 -0
- package/lib/index.cjs +746 -0
- package/lib/index.cjs.map +1 -0
- package/lib/index.d.cts +520 -0
- package/lib/index.d.cts.map +1 -0
- package/lib/index.d.mts +520 -29
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +692 -223
- package/lib/index.mjs.map +1 -1
- package/lib/jsx-dev-runtime.cjs +11 -0
- package/lib/jsx-dev-runtime.cjs.map +1 -0
- package/lib/jsx-dev-runtime.d.cts +8 -0
- package/lib/jsx-dev-runtime.d.cts.map +1 -0
- package/lib/jsx-dev-runtime.d.mts +8 -4
- package/lib/jsx-dev-runtime.d.mts.map +1 -0
- package/lib/jsx-dev-runtime.mjs +5 -6
- package/lib/jsx-dev-runtime.mjs.map +1 -1
- package/lib/jsx-runtime.cjs +5 -0
- package/lib/jsx-runtime.d.cts +3 -0
- package/lib/jsx-runtime.d.mts +3 -3
- package/lib/jsx-runtime.mjs +3 -3
- package/lib/jsx.cjs +0 -0
- package/lib/jsx.d.cts +19 -0
- package/lib/jsx.d.cts.map +1 -0
- package/lib/jsx.d.mts +19 -1
- package/lib/jsx.d.mts.map +1 -0
- package/lib/jsx.mjs +1 -3
- package/lib/xml-node-BQA44ydQ.d.mts +96 -0
- package/lib/xml-node-BQA44ydQ.d.mts.map +1 -0
- package/lib/xml-node-CddziLym.d.cts +96 -0
- package/lib/xml-node-CddziLym.d.cts.map +1 -0
- package/package.json +9 -9
- package/project.json +2 -2
- package/src/adapters/xml-stream-adapter.service.mts +77 -16
- package/src/decorators/component.decorator.mts +72 -10
- package/src/decorators/component.decorator.spec.mts +40 -22
- package/src/decorators/xml-stream.decorator.mts +58 -3
- package/src/define-environment.mts +5 -6
- package/src/handlers/xml-stream.mts +25 -3
- package/src/runtime/render-to-xml.mts +72 -4
- package/src/tags/define-tag.mts +8 -0
- package/src/types/component.mts +46 -2
- package/src/types/config.mts +22 -0
- package/tsdown.config.mts +39 -0
- package/lib/_tsup-dts-rollup.d.mts +0 -414
- package/lib/_tsup-dts-rollup.d.ts +0 -414
- package/lib/chunk-6OR6LGJA.mjs +0 -153
- package/lib/chunk-6OR6LGJA.mjs.map +0 -1
- package/lib/index.d.ts +0 -29
- package/lib/index.js +0 -376
- package/lib/index.js.map +0 -1
- package/lib/jsx-dev-runtime.d.ts +0 -4
- package/lib/jsx-dev-runtime.js +0 -61
- package/lib/jsx-dev-runtime.js.map +0 -1
- package/lib/jsx-runtime.d.ts +0 -3
- package/lib/jsx-runtime.js +0 -57
- package/lib/jsx-runtime.js.map +0 -1
- package/lib/jsx-runtime.mjs.map +0 -1
- package/lib/jsx.d.ts +0 -1
- package/lib/jsx.js +0 -4
- package/lib/jsx.js.map +0 -1
- package/lib/jsx.mjs.map +0 -1
- package/tsup.config.mts +0 -18
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type { Container } from '@navios/
|
|
1
|
+
import type { Container, ScopedContainer } from '@navios/core'
|
|
2
2
|
|
|
3
|
+
import type { XmlComponent } from '../types/component.mjs'
|
|
3
4
|
import type {
|
|
4
5
|
AnyXmlNode,
|
|
5
6
|
AsyncXmlNode,
|
|
@@ -7,7 +8,6 @@ import type {
|
|
|
7
8
|
ClassComponentNode,
|
|
8
9
|
RawXmlNode,
|
|
9
10
|
} from '../types/xml-node.mjs'
|
|
10
|
-
import type { XmlComponent } from '../types/component.mjs'
|
|
11
11
|
|
|
12
12
|
import {
|
|
13
13
|
AsyncComponent,
|
|
@@ -17,6 +17,19 @@ import {
|
|
|
17
17
|
RawXmlSymbol,
|
|
18
18
|
} from '../types/xml-node.mjs'
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Options for rendering XML from JSX nodes.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const xml = await renderToXml(<rss version="2.0">...</rss>, {
|
|
26
|
+
* declaration: true,
|
|
27
|
+
* encoding: 'UTF-8',
|
|
28
|
+
* pretty: true,
|
|
29
|
+
* container: myContainer, // Required for class components
|
|
30
|
+
* })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
20
33
|
export interface RenderOptions {
|
|
21
34
|
/** Include XML declaration (<?xml version="1.0"?>) - defaults to true */
|
|
22
35
|
declaration?: boolean
|
|
@@ -28,9 +41,28 @@ export interface RenderOptions {
|
|
|
28
41
|
* DI container for resolving class components.
|
|
29
42
|
* Required if the tree contains any class components.
|
|
30
43
|
*/
|
|
31
|
-
container?: Container
|
|
44
|
+
container?: Container | ScopedContainer
|
|
32
45
|
}
|
|
33
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Error thrown when attempting to render a class component without a container.
|
|
49
|
+
*
|
|
50
|
+
* Class components require a dependency injection container to be instantiated.
|
|
51
|
+
* This error is thrown when `renderToXml` is called with a class component in
|
|
52
|
+
* the tree but no container is provided in the options.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* try {
|
|
57
|
+
* await renderToXml(<MyClassComponent />)
|
|
58
|
+
* } catch (error) {
|
|
59
|
+
* if (error instanceof MissingContainerError) {
|
|
60
|
+
* // Provide a container
|
|
61
|
+
* await renderToXml(<MyClassComponent />, { container })
|
|
62
|
+
* }
|
|
63
|
+
* }
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
34
66
|
export class MissingContainerError extends Error {
|
|
35
67
|
constructor(componentName: string) {
|
|
36
68
|
super(
|
|
@@ -41,6 +73,42 @@ export class MissingContainerError extends Error {
|
|
|
41
73
|
}
|
|
42
74
|
}
|
|
43
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Renders a JSX XML node tree to an XML string.
|
|
78
|
+
*
|
|
79
|
+
* This function handles:
|
|
80
|
+
* - Regular XML nodes (tags with props and children)
|
|
81
|
+
* - Async components (resolves promises in parallel)
|
|
82
|
+
* - Class components (resolves via DI container)
|
|
83
|
+
* - CDATA sections
|
|
84
|
+
* - Raw XML content
|
|
85
|
+
* - Fragments
|
|
86
|
+
* - Text content with proper escaping
|
|
87
|
+
*
|
|
88
|
+
* @param node - The root XML node (JSX element) to render.
|
|
89
|
+
* @param options - Rendering options including declaration, encoding, pretty printing, and container.
|
|
90
|
+
* @returns A promise that resolves to the XML string.
|
|
91
|
+
*
|
|
92
|
+
* @throws {MissingContainerError} If the tree contains class components but no container is provided.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```ts
|
|
96
|
+
* // Simple rendering
|
|
97
|
+
* const xml = await renderToXml(<rss version="2.0"><channel>...</channel></rss>)
|
|
98
|
+
*
|
|
99
|
+
* // With options
|
|
100
|
+
* const xml = await renderToXml(<feed>...</feed>, {
|
|
101
|
+
* declaration: true,
|
|
102
|
+
* encoding: 'UTF-8',
|
|
103
|
+
* pretty: true,
|
|
104
|
+
* })
|
|
105
|
+
*
|
|
106
|
+
* // With class components (requires container)
|
|
107
|
+
* const container = new Container()
|
|
108
|
+
* container.beginRequest('request-id')
|
|
109
|
+
* const xml = await renderToXml(<MyClassComponent />, { container })
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
44
112
|
export async function renderToXml(
|
|
45
113
|
node: AnyXmlNode,
|
|
46
114
|
options: RenderOptions = {},
|
|
@@ -65,7 +133,7 @@ export async function renderToXml(
|
|
|
65
133
|
async function renderNode(
|
|
66
134
|
node: AnyXmlNode,
|
|
67
135
|
indent: number,
|
|
68
|
-
container: Container | undefined,
|
|
136
|
+
container: Container | ScopedContainer | undefined,
|
|
69
137
|
): Promise<string> {
|
|
70
138
|
if (node == null) return ''
|
|
71
139
|
if (typeof node === 'string') return escapeXml(node)
|
package/src/tags/define-tag.mts
CHANGED
|
@@ -3,6 +3,14 @@ import type { z } from 'zod/v4'
|
|
|
3
3
|
|
|
4
4
|
import type { AnyXmlNode, XmlNode } from '../types/xml-node.mjs'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Type for XML tag components created by `defineTag`.
|
|
8
|
+
*
|
|
9
|
+
* Tag components are functions that accept props and children, and return
|
|
10
|
+
* an XML node. They also have a `tagName` property for identification.
|
|
11
|
+
*
|
|
12
|
+
* @template Props - The props type for the tag component.
|
|
13
|
+
*/
|
|
6
14
|
export interface TagComponent<Props extends Record<string, unknown>> {
|
|
7
15
|
(props: Props & { children?: AnyXmlNode | AnyXmlNode[] }): XmlNode
|
|
8
16
|
tagName: string
|
package/src/types/component.mts
CHANGED
|
@@ -1,15 +1,59 @@
|
|
|
1
1
|
import type { AnyXmlNode } from './xml-node.mjs'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Base interface for class components.
|
|
5
|
-
*
|
|
4
|
+
* Base interface for class-based XML components.
|
|
5
|
+
*
|
|
6
|
+
* Class components are classes decorated with `@Component` that can use
|
|
7
|
+
* dependency injection and return JSX-based XML nodes. The `render()` method
|
|
8
|
+
* takes no arguments - props are received via the constructor.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* @Component()
|
|
13
|
+
* class LatestPostsComponent implements XmlComponent {
|
|
14
|
+
* private readonly postService = inject(PostService)
|
|
15
|
+
*
|
|
16
|
+
* async render() {
|
|
17
|
+
* const posts = await this.postService.getLatestPosts()
|
|
18
|
+
* return (
|
|
19
|
+
* <>
|
|
20
|
+
* {posts.map(post => <item>...</item>)}
|
|
21
|
+
* </>
|
|
22
|
+
* )
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* // With props
|
|
30
|
+
* @Component({ schema: MyPropsSchema })
|
|
31
|
+
* class MyComponent implements XmlComponent {
|
|
32
|
+
* constructor(private props: z.output<typeof MyPropsSchema>) {}
|
|
33
|
+
*
|
|
34
|
+
* render() {
|
|
35
|
+
* return <div>{this.props.content}</div>
|
|
36
|
+
* }
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
6
39
|
*/
|
|
7
40
|
export interface XmlComponent {
|
|
41
|
+
/**
|
|
42
|
+
* Renders the component to an XML node.
|
|
43
|
+
*
|
|
44
|
+
* This method is called when the component is rendered. It can return
|
|
45
|
+
* a synchronous XML node or a Promise that resolves to an XML node.
|
|
46
|
+
*
|
|
47
|
+
* @returns An XML node or a Promise that resolves to an XML node.
|
|
48
|
+
*/
|
|
8
49
|
render(): AnyXmlNode | Promise<AnyXmlNode>
|
|
9
50
|
}
|
|
10
51
|
|
|
11
52
|
/**
|
|
12
53
|
* Type for class component constructors.
|
|
54
|
+
*
|
|
55
|
+
* This type represents a class constructor that creates instances of
|
|
56
|
+
* `XmlComponent`. Used for type checking and dependency injection.
|
|
13
57
|
*/
|
|
14
58
|
export interface ComponentClass {
|
|
15
59
|
new (...args: any[]): XmlComponent
|
package/src/types/config.mts
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
import type { BaseStreamConfig, HttpMethod } from '@navios/builder'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Configuration interface for XML Stream endpoints.
|
|
5
|
+
*
|
|
6
|
+
* Extends the base stream configuration with XML-specific options including
|
|
7
|
+
* content type, XML declaration, and encoding settings.
|
|
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
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const config: BaseXmlStreamConfig = {
|
|
17
|
+
* method: 'GET',
|
|
18
|
+
* url: '/feed.xml',
|
|
19
|
+
* contentType: 'application/rss+xml',
|
|
20
|
+
* xmlDeclaration: true,
|
|
21
|
+
* encoding: 'UTF-8',
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
3
25
|
export interface BaseXmlStreamConfig<
|
|
4
26
|
Method extends HttpMethod = HttpMethod,
|
|
5
27
|
Url extends string = string,
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { withFilter } from 'rolldown/filter'
|
|
2
|
+
import { defineConfig } from 'tsdown'
|
|
3
|
+
import swc from 'unplugin-swc'
|
|
4
|
+
|
|
5
|
+
export default defineConfig({
|
|
6
|
+
entry: [
|
|
7
|
+
'src/index.mts',
|
|
8
|
+
'src/jsx-runtime.mts',
|
|
9
|
+
'src/jsx-dev-runtime.mts',
|
|
10
|
+
'src/jsx.mts',
|
|
11
|
+
],
|
|
12
|
+
outDir: 'lib',
|
|
13
|
+
format: ['esm', 'cjs'],
|
|
14
|
+
clean: true,
|
|
15
|
+
tsconfig: 'tsconfig.lib.json',
|
|
16
|
+
treeshake: true,
|
|
17
|
+
sourcemap: true,
|
|
18
|
+
platform: 'node',
|
|
19
|
+
dts: true,
|
|
20
|
+
target: 'es2022',
|
|
21
|
+
plugins: [
|
|
22
|
+
withFilter(
|
|
23
|
+
swc.rolldown({
|
|
24
|
+
jsc: {
|
|
25
|
+
target: 'es2022',
|
|
26
|
+
parser: {
|
|
27
|
+
syntax: 'typescript',
|
|
28
|
+
decorators: true,
|
|
29
|
+
},
|
|
30
|
+
transform: {
|
|
31
|
+
decoratorVersion: '2022-03',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
// Only run this transform if the file contains a decorator.
|
|
36
|
+
{ transform: { code: '@' } },
|
|
37
|
+
),
|
|
38
|
+
],
|
|
39
|
+
})
|
|
@@ -1,414 +0,0 @@
|
|
|
1
|
-
import type { AbstractHttpHandlerAdapterInterface } from '@navios/core';
|
|
2
|
-
import type { AnyInjectableType } from '@navios/di';
|
|
3
|
-
import type { BaseStreamConfig } from '@navios/builder';
|
|
4
|
-
import type { ClassType } from '@navios/di';
|
|
5
|
-
import { Container } from '@navios/di';
|
|
6
|
-
import type { EndpointFunctionArgs } from '@navios/builder';
|
|
7
|
-
import type { HandlerMetadata } from '@navios/core';
|
|
8
|
-
import type { HttpMethod } from '@navios/builder';
|
|
9
|
-
import { InjectionToken } from '@navios/di';
|
|
10
|
-
import type { Registry } from '@navios/di';
|
|
11
|
-
import type { RequestContextHolder } from '@navios/di';
|
|
12
|
-
import type { Util_FlatObject } from '@navios/builder';
|
|
13
|
-
import type { z } from 'zod/v4';
|
|
14
|
-
import type { ZodObject } from 'zod/v4';
|
|
15
|
-
import type { ZodRawShape } from 'zod/v4';
|
|
16
|
-
import type { ZodType } from 'zod/v4';
|
|
17
|
-
|
|
18
|
-
/** Union type for all possible node types */
|
|
19
|
-
declare type AnyXmlNode = XmlNode | AsyncXmlNode | CDataNode | RawXmlNode | ClassComponentNode | string | number | null | undefined;
|
|
20
|
-
export { AnyXmlNode }
|
|
21
|
-
export { AnyXmlNode as AnyXmlNode_alias_1 }
|
|
22
|
-
export { AnyXmlNode as AnyXmlNode_alias_2 }
|
|
23
|
-
|
|
24
|
-
declare const AsyncComponent: unique symbol;
|
|
25
|
-
export { AsyncComponent }
|
|
26
|
-
export { AsyncComponent as AsyncComponent_alias_1 }
|
|
27
|
-
export { AsyncComponent as AsyncComponent_alias_2 }
|
|
28
|
-
|
|
29
|
-
declare type AsyncComponentFn = (props: any) => Promise<XmlNode | AsyncXmlNode | ClassComponentNode>;
|
|
30
|
-
|
|
31
|
-
/** Represents an async component that needs to be resolved before rendering */
|
|
32
|
-
declare interface AsyncXmlNode {
|
|
33
|
-
type: typeof AsyncComponent;
|
|
34
|
-
promise: Promise<AnyXmlNode>;
|
|
35
|
-
}
|
|
36
|
-
export { AsyncXmlNode }
|
|
37
|
-
export { AsyncXmlNode as AsyncXmlNode_alias_1 }
|
|
38
|
-
export { AsyncXmlNode as AsyncXmlNode_alias_2 }
|
|
39
|
-
|
|
40
|
-
declare interface BaseXmlStreamConfig<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, RequestSchema = undefined> extends BaseStreamConfig<Method, Url, QuerySchema, RequestSchema> {
|
|
41
|
-
/** Content-Type header, defaults to 'application/xml' */
|
|
42
|
-
contentType?: 'application/xml' | 'text/xml' | 'application/rss+xml' | 'application/atom+xml';
|
|
43
|
-
/** Include XML declaration (<?xml version="1.0"?>) - defaults to true */
|
|
44
|
-
xmlDeclaration?: boolean;
|
|
45
|
-
/** XML encoding, defaults to 'UTF-8' */
|
|
46
|
-
encoding?: string;
|
|
47
|
-
}
|
|
48
|
-
export { BaseXmlStreamConfig }
|
|
49
|
-
export { BaseXmlStreamConfig as BaseXmlStreamConfig_alias_1 }
|
|
50
|
-
export { BaseXmlStreamConfig as BaseXmlStreamConfig_alias_2 }
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* CDATA component - wraps content in <![CDATA[...]]>
|
|
54
|
-
* Use for text content that may contain characters like < > &
|
|
55
|
-
* that would otherwise need escaping.
|
|
56
|
-
*
|
|
57
|
-
* Note: If content contains "]]>", it will be split into multiple CDATA sections.
|
|
58
|
-
*/
|
|
59
|
-
declare function CData({ children }: {
|
|
60
|
-
children: string;
|
|
61
|
-
}): CDataNode;
|
|
62
|
-
export { CData }
|
|
63
|
-
export { CData as CData_alias_1 }
|
|
64
|
-
export { CData as CData_alias_2 }
|
|
65
|
-
|
|
66
|
-
/** Represents a CDATA section - content is wrapped in <![CDATA[...]]> */
|
|
67
|
-
declare interface CDataNode {
|
|
68
|
-
type: typeof CDataSymbol;
|
|
69
|
-
content: string;
|
|
70
|
-
}
|
|
71
|
-
export { CDataNode }
|
|
72
|
-
export { CDataNode as CDataNode_alias_1 }
|
|
73
|
-
export { CDataNode as CDataNode_alias_2 }
|
|
74
|
-
|
|
75
|
-
declare const CDataSymbol: unique symbol;
|
|
76
|
-
export { CDataSymbol }
|
|
77
|
-
export { CDataSymbol as CDataSymbol_alias_1 }
|
|
78
|
-
export { CDataSymbol as CDataSymbol_alias_2 }
|
|
79
|
-
|
|
80
|
-
declare const ClassComponent: unique symbol;
|
|
81
|
-
export { ClassComponent }
|
|
82
|
-
export { ClassComponent as ClassComponent_alias_1 }
|
|
83
|
-
export { ClassComponent as ClassComponent_alias_2 }
|
|
84
|
-
|
|
85
|
-
/** Represents a class component that needs to be resolved via DI */
|
|
86
|
-
declare interface ClassComponentNode {
|
|
87
|
-
type: typeof ClassComponent;
|
|
88
|
-
componentClass: ComponentClass;
|
|
89
|
-
props: Record<string, unknown>;
|
|
90
|
-
}
|
|
91
|
-
export { ClassComponentNode }
|
|
92
|
-
export { ClassComponentNode as ClassComponentNode_alias_1 }
|
|
93
|
-
export { ClassComponentNode as ClassComponentNode_alias_2 }
|
|
94
|
-
|
|
95
|
-
declare function Component(): <T extends ComponentClass>(target: T, context?: ClassDecoratorContext) => T;
|
|
96
|
-
|
|
97
|
-
declare function Component<Schema extends ZodObject<ZodRawShape>>(options: {
|
|
98
|
-
schema: Schema;
|
|
99
|
-
registry?: Registry;
|
|
100
|
-
}): <T extends new (props: z.output<Schema>, ...args: any[]) => XmlComponent>(target: T, context?: ClassDecoratorContext) => T;
|
|
101
|
-
|
|
102
|
-
declare function Component(options: {
|
|
103
|
-
registry: Registry;
|
|
104
|
-
}): <T extends ComponentClass>(target: T, context?: ClassDecoratorContext) => T;
|
|
105
|
-
export { Component }
|
|
106
|
-
export { Component as Component_alias_1 }
|
|
107
|
-
export { Component as Component_alias_2 }
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Type for class component constructors.
|
|
111
|
-
*/
|
|
112
|
-
declare interface ComponentClass {
|
|
113
|
-
new (...args: any[]): XmlComponent;
|
|
114
|
-
}
|
|
115
|
-
export { ComponentClass }
|
|
116
|
-
export { ComponentClass as ComponentClass_alias_1 }
|
|
117
|
-
export { ComponentClass as ComponentClass_alias_2 }
|
|
118
|
-
|
|
119
|
-
declare const ComponentMeta: unique symbol;
|
|
120
|
-
export { ComponentMeta }
|
|
121
|
-
export { ComponentMeta as ComponentMeta_alias_1 }
|
|
122
|
-
|
|
123
|
-
declare type ComponentType = FunctionalComponent | ComponentClass;
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Classic createElement for manual usage.
|
|
127
|
-
* Children are passed as rest arguments.
|
|
128
|
-
*/
|
|
129
|
-
declare function createElement(type: string | typeof Fragment | ComponentType, props: Record<string, unknown> | null, ...children: any[]): XmlNode | AsyncXmlNode | ClassComponentNode;
|
|
130
|
-
export { createElement }
|
|
131
|
-
export { createElement as createElement_alias_1 }
|
|
132
|
-
export { createElement as createElement_alias_2 }
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* DangerouslyInsertRawXml - inserts raw XML/HTML without any escaping or wrapping
|
|
136
|
-
*
|
|
137
|
-
* WARNING: This bypasses all XML escaping. Only use with trusted content!
|
|
138
|
-
* Use cases:
|
|
139
|
-
* - Pre-rendered XML fragments
|
|
140
|
-
* - HTML content in RSS/Atom feeds (in description/content:encoded)
|
|
141
|
-
* - Including XML from external sources that's already valid
|
|
142
|
-
*/
|
|
143
|
-
declare function DangerouslyInsertRawXml({ children }: {
|
|
144
|
-
children: string;
|
|
145
|
-
}): RawXmlNode;
|
|
146
|
-
export { DangerouslyInsertRawXml }
|
|
147
|
-
export { DangerouslyInsertRawXml as DangerouslyInsertRawXml_alias_1 }
|
|
148
|
-
export { DangerouslyInsertRawXml as DangerouslyInsertRawXml_alias_2 }
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Declares an XML Stream endpoint configuration for use with @XmlStream decorator.
|
|
152
|
-
*
|
|
153
|
-
* @example
|
|
154
|
-
* ```typescript
|
|
155
|
-
* import { declareXmlStream } from '@navios/adapter-xml'
|
|
156
|
-
*
|
|
157
|
-
* export const getRssFeed = declareXmlStream({
|
|
158
|
-
* method: 'GET',
|
|
159
|
-
* url: '/feed.xml',
|
|
160
|
-
* querySchema: undefined,
|
|
161
|
-
* requestSchema: undefined,
|
|
162
|
-
* contentType: 'application/rss+xml',
|
|
163
|
-
* xmlDeclaration: true,
|
|
164
|
-
* })
|
|
165
|
-
* ```
|
|
166
|
-
*/
|
|
167
|
-
declare function declareXmlStream<Method extends HttpMethod, Url extends string, QuerySchema = undefined, RequestSchema = undefined>(config: BaseXmlStreamConfig<Method, Url, QuerySchema, RequestSchema>): {
|
|
168
|
-
config: BaseXmlStreamConfig<Method, Url, QuerySchema, RequestSchema>;
|
|
169
|
-
};
|
|
170
|
-
export { declareXmlStream }
|
|
171
|
-
export { declareXmlStream as declareXmlStream_alias_1 }
|
|
172
|
-
export { declareXmlStream as declareXmlStream_alias_2 }
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Creates a type-safe XML tag component with optional Zod schema validation.
|
|
176
|
-
*
|
|
177
|
-
* @param name - The tag name (supports namespace prefixes like 'atom:link')
|
|
178
|
-
* @param propsSchema - Optional Zod schema for validating props
|
|
179
|
-
* @returns A component function that can be used in JSX
|
|
180
|
-
*
|
|
181
|
-
* @example
|
|
182
|
-
* ```tsx
|
|
183
|
-
* // Simple tag
|
|
184
|
-
* const item = defineTag('item')
|
|
185
|
-
* <item>Content</item>
|
|
186
|
-
*
|
|
187
|
-
* // Namespaced tag with Zod validation
|
|
188
|
-
* const atomLink = defineTag('atom:link', z.object({
|
|
189
|
-
* href: z.string().url(),
|
|
190
|
-
* rel: z.enum(['self', 'alternate']),
|
|
191
|
-
* type: z.string().optional(),
|
|
192
|
-
* }))
|
|
193
|
-
* <atomLink href="https://example.com/feed" rel="self" />
|
|
194
|
-
* ```
|
|
195
|
-
*/
|
|
196
|
-
declare function defineTag<T extends ZodRawShape>(name: string, propsSchema?: ZodObject<T>): TagComponent<T extends ZodRawShape ? z.infer<ZodObject<T>> : Record<string, never>>;
|
|
197
|
-
export { defineTag }
|
|
198
|
-
export { defineTag as defineTag_alias_1 }
|
|
199
|
-
export { defineTag as defineTag_alias_2 }
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Creates the XML environment configuration to be merged with base adapter (Fastify/Bun).
|
|
203
|
-
*
|
|
204
|
-
* @example
|
|
205
|
-
* ```typescript
|
|
206
|
-
* import { defineFastifyEnvironment } from '@navios/adapter-fastify'
|
|
207
|
-
* import { defineXmlEnvironment } from '@navios/adapter-xml'
|
|
208
|
-
* import { NaviosFactory } from '@navios/core'
|
|
209
|
-
*
|
|
210
|
-
* const fastifyEnv = defineFastifyEnvironment()
|
|
211
|
-
* const xmlEnv = defineXmlEnvironment()
|
|
212
|
-
*
|
|
213
|
-
* // Merge environments
|
|
214
|
-
* const mergedEnv = {
|
|
215
|
-
* httpTokens: new Map([
|
|
216
|
-
* ...fastifyEnv.httpTokens,
|
|
217
|
-
* ...xmlEnv.httpTokens,
|
|
218
|
-
* ]),
|
|
219
|
-
* }
|
|
220
|
-
*
|
|
221
|
-
* const app = await NaviosFactory.create(AppModule, {
|
|
222
|
-
* adapter: mergedEnv,
|
|
223
|
-
* })
|
|
224
|
-
* ```
|
|
225
|
-
*/
|
|
226
|
-
declare function defineXmlEnvironment(): {
|
|
227
|
-
httpTokens: Map<InjectionToken<any, undefined, false>, AnyInjectableType>;
|
|
228
|
-
};
|
|
229
|
-
export { defineXmlEnvironment }
|
|
230
|
-
export { defineXmlEnvironment as defineXmlEnvironment_alias_1 }
|
|
231
|
-
|
|
232
|
-
declare const Fragment: unique symbol;
|
|
233
|
-
export { Fragment }
|
|
234
|
-
export { Fragment as Fragment_alias_1 }
|
|
235
|
-
export { Fragment as Fragment_alias_2 }
|
|
236
|
-
export { Fragment as Fragment_alias_3 }
|
|
237
|
-
export { Fragment as Fragment_alias_4 }
|
|
238
|
-
export { Fragment as Fragment_alias_5 }
|
|
239
|
-
export { Fragment as Fragment_alias_6 }
|
|
240
|
-
export { Fragment as Fragment_alias_7 }
|
|
241
|
-
|
|
242
|
-
declare type FunctionalComponent = SyncComponent | AsyncComponentFn;
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Type guard to check if a class is a component
|
|
246
|
-
*/
|
|
247
|
-
declare function isComponentClass(value: unknown): value is ComponentClass;
|
|
248
|
-
export { isComponentClass }
|
|
249
|
-
export { isComponentClass as isComponentClass_alias_1 }
|
|
250
|
-
export { isComponentClass as isComponentClass_alias_2 }
|
|
251
|
-
|
|
252
|
-
/**
|
|
253
|
-
* JSX automatic runtime function.
|
|
254
|
-
* Used by the JSX transformer when jsxImportSource is set.
|
|
255
|
-
* Children are passed as part of props.children.
|
|
256
|
-
*/
|
|
257
|
-
declare function jsx(type: string | typeof Fragment | ComponentType, props: Record<string, unknown> | null): XmlNode | AsyncXmlNode | ClassComponentNode;
|
|
258
|
-
export { jsx }
|
|
259
|
-
export { jsx as jsx_alias_1 }
|
|
260
|
-
export { jsx as jsx_alias_2 }
|
|
261
|
-
|
|
262
|
-
export declare const jsxDEV: typeof jsx;
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* JSX automatic runtime function for static children.
|
|
266
|
-
* Identical to jsx() for XML - React uses this for optimization hints.
|
|
267
|
-
*/
|
|
268
|
-
declare const jsxs: typeof jsx;
|
|
269
|
-
export { jsxs }
|
|
270
|
-
export { jsxs as jsxs_alias_1 }
|
|
271
|
-
export { jsxs as jsxs_alias_2 }
|
|
272
|
-
|
|
273
|
-
declare class MissingContainerError extends Error {
|
|
274
|
-
constructor(componentName: string);
|
|
275
|
-
}
|
|
276
|
-
export { MissingContainerError }
|
|
277
|
-
export { MissingContainerError as MissingContainerError_alias_1 }
|
|
278
|
-
export { MissingContainerError as MissingContainerError_alias_2 }
|
|
279
|
-
|
|
280
|
-
/** Represents raw XML content - inserted without any escaping or wrapping */
|
|
281
|
-
declare interface RawXmlNode {
|
|
282
|
-
type: typeof RawXmlSymbol;
|
|
283
|
-
content: string;
|
|
284
|
-
}
|
|
285
|
-
export { RawXmlNode }
|
|
286
|
-
export { RawXmlNode as RawXmlNode_alias_1 }
|
|
287
|
-
export { RawXmlNode as RawXmlNode_alias_2 }
|
|
288
|
-
|
|
289
|
-
declare const RawXmlSymbol: unique symbol;
|
|
290
|
-
export { RawXmlSymbol }
|
|
291
|
-
export { RawXmlSymbol as RawXmlSymbol_alias_1 }
|
|
292
|
-
export { RawXmlSymbol as RawXmlSymbol_alias_2 }
|
|
293
|
-
|
|
294
|
-
declare interface RenderOptions {
|
|
295
|
-
/** Include XML declaration (<?xml version="1.0"?>) - defaults to true */
|
|
296
|
-
declaration?: boolean;
|
|
297
|
-
/** XML encoding, defaults to 'UTF-8' */
|
|
298
|
-
encoding?: string;
|
|
299
|
-
/** Pretty print with indentation */
|
|
300
|
-
pretty?: boolean;
|
|
301
|
-
/**
|
|
302
|
-
* DI container for resolving class components.
|
|
303
|
-
* Required if the tree contains any class components.
|
|
304
|
-
*/
|
|
305
|
-
container?: Container;
|
|
306
|
-
}
|
|
307
|
-
export { RenderOptions }
|
|
308
|
-
export { RenderOptions as RenderOptions_alias_1 }
|
|
309
|
-
export { RenderOptions as RenderOptions_alias_2 }
|
|
310
|
-
|
|
311
|
-
declare function renderToXml(node: AnyXmlNode, options?: RenderOptions): Promise<string>;
|
|
312
|
-
export { renderToXml }
|
|
313
|
-
export { renderToXml as renderToXml_alias_1 }
|
|
314
|
-
export { renderToXml as renderToXml_alias_2 }
|
|
315
|
-
|
|
316
|
-
declare type SyncComponent = (props: any) => XmlNode | AsyncXmlNode | ClassComponentNode;
|
|
317
|
-
|
|
318
|
-
declare interface TagComponent<Props extends Record<string, unknown>> {
|
|
319
|
-
(props: Props & {
|
|
320
|
-
children?: AnyXmlNode | AnyXmlNode[];
|
|
321
|
-
}): XmlNode;
|
|
322
|
-
tagName: string;
|
|
323
|
-
}
|
|
324
|
-
export { TagComponent }
|
|
325
|
-
export { TagComponent as TagComponent_alias_1 }
|
|
326
|
-
export { TagComponent as TagComponent_alias_2 }
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Base interface for class components.
|
|
330
|
-
* The render method takes no arguments - props are received via constructor.
|
|
331
|
-
*/
|
|
332
|
-
declare interface XmlComponent {
|
|
333
|
-
render(): AnyXmlNode | Promise<AnyXmlNode>;
|
|
334
|
-
}
|
|
335
|
-
export { XmlComponent }
|
|
336
|
-
export { XmlComponent as XmlComponent_alias_1 }
|
|
337
|
-
export { XmlComponent as XmlComponent_alias_2 }
|
|
338
|
-
|
|
339
|
-
declare interface XmlNode {
|
|
340
|
-
type: string | typeof Fragment;
|
|
341
|
-
props: Record<string, unknown>;
|
|
342
|
-
children: AnyXmlNode[];
|
|
343
|
-
}
|
|
344
|
-
export { XmlNode }
|
|
345
|
-
export { XmlNode as XmlNode_alias_1 }
|
|
346
|
-
export { XmlNode as XmlNode_alias_2 }
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* Decorator for XML Stream endpoints that return JSX-based XML responses.
|
|
350
|
-
*
|
|
351
|
-
* @example
|
|
352
|
-
* ```typescript
|
|
353
|
-
* import { XmlStream } from '@navios/adapter-xml'
|
|
354
|
-
* import { Controller } from '@navios/core'
|
|
355
|
-
*
|
|
356
|
-
* const getRssFeed = declareXmlStream({
|
|
357
|
-
* method: 'GET',
|
|
358
|
-
* url: '/feed.xml',
|
|
359
|
-
* querySchema: undefined,
|
|
360
|
-
* requestSchema: undefined,
|
|
361
|
-
* contentType: 'application/rss+xml',
|
|
362
|
-
* })
|
|
363
|
-
*
|
|
364
|
-
* @Controller('/api')
|
|
365
|
-
* class FeedController {
|
|
366
|
-
* @XmlStream(getRssFeed)
|
|
367
|
-
* async getFeed() {
|
|
368
|
-
* return (
|
|
369
|
-
* <rss version="2.0">
|
|
370
|
-
* <channel>
|
|
371
|
-
* <title>My Feed</title>
|
|
372
|
-
* </channel>
|
|
373
|
-
* </rss>
|
|
374
|
-
* )
|
|
375
|
-
* }
|
|
376
|
-
* }
|
|
377
|
-
* ```
|
|
378
|
-
*/
|
|
379
|
-
declare function XmlStream<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, RequestSchema = ZodType>(endpoint: {
|
|
380
|
-
config: BaseXmlStreamConfig<Method, Url, QuerySchema, RequestSchema>;
|
|
381
|
-
}): (target: (params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, RequestSchema, true>> : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>> : RequestSchema extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, RequestSchema, true>> : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>) => Promise<any>, // Returns XmlNode
|
|
382
|
-
context: ClassMethodDecoratorContext) => (params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, RequestSchema, true>> : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>> : RequestSchema extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, RequestSchema, true>> : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>) => Promise<any>;
|
|
383
|
-
export { XmlStream }
|
|
384
|
-
export { XmlStream as XmlStream_alias_1 }
|
|
385
|
-
export { XmlStream as XmlStream_alias_2 }
|
|
386
|
-
|
|
387
|
-
declare class XmlStreamAdapterService implements AbstractHttpHandlerAdapterInterface {
|
|
388
|
-
protected container: Container;
|
|
389
|
-
/** Base stream adapter - we proxy hasSchema, prepareArguments, provideSchema to it */
|
|
390
|
-
protected streamAdapter: AbstractHttpHandlerAdapterInterface;
|
|
391
|
-
/**
|
|
392
|
-
* Proxy to base StreamAdapter - reuses existing argument preparation logic
|
|
393
|
-
* (handles querySchema, requestSchema, URL params for both Fastify and Bun)
|
|
394
|
-
*/
|
|
395
|
-
prepareArguments(handlerMetadata: HandlerMetadata<BaseXmlStreamConfig>): ((target: Record<string, any>, request: any) => Promise<void> | void)[];
|
|
396
|
-
provideSchema(handlerMetadata: HandlerMetadata<BaseXmlStreamConfig>): Record<string, any>;
|
|
397
|
-
hasSchema(handlerMetadata: HandlerMetadata<any>): boolean;
|
|
398
|
-
/**
|
|
399
|
-
* Custom handler - renders JSX to XML and handles response for both Fastify and Bun
|
|
400
|
-
*/
|
|
401
|
-
provideHandler(controller: ClassType, handlerMetadata: HandlerMetadata<BaseXmlStreamConfig>): (context: RequestContextHolder, request: any, reply: any) => Promise<any>;
|
|
402
|
-
}
|
|
403
|
-
export { XmlStreamAdapterService }
|
|
404
|
-
export { XmlStreamAdapterService as XmlStreamAdapterService_alias_1 }
|
|
405
|
-
export { XmlStreamAdapterService as XmlStreamAdapterService_alias_2 }
|
|
406
|
-
|
|
407
|
-
declare type XmlStreamParams<EndpointDeclaration extends {
|
|
408
|
-
config: BaseXmlStreamConfig<any, any, any, any>;
|
|
409
|
-
}, 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>>;
|
|
410
|
-
export { XmlStreamParams }
|
|
411
|
-
export { XmlStreamParams as XmlStreamParams_alias_1 }
|
|
412
|
-
export { XmlStreamParams as XmlStreamParams_alias_2 }
|
|
413
|
-
|
|
414
|
-
export { }
|