@xapi-js/adaptor-nestjs 1.3.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 Robert Soriano <https://github.com/wobsoriano>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Robert Soriano <https://github.com/wobsoriano>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,151 +1,58 @@
1
- # @xapi-ts/adaptor-nestjs
2
-
3
- This package provides a NestJS adaptor for X-API data.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- # npm
9
- npm install @xapi-ts/adaptor-nestjs
10
-
11
- # yarn
12
- yarn add @xapi-ts/adaptor-nestjs
13
-
14
- # pnpm
15
- pnpm add @xapi-ts/adaptor-nestjs
16
-
17
- # bun
18
- bun add @xapi-ts/adaptor-nestjs
19
-
20
- # deno
21
- deno add @xapi-ts/adaptor-nestjs
22
- ```
23
-
24
- ## Usage
25
-
26
- `@xapi-ts/adaptor-nestjs` provides NestJS interceptors to automatically handle X-API request deserialization and response serialization.
27
-
28
- ### XapiRequestInterceptor
29
-
30
- Use `XapiRequestInterceptor` to automatically parse incoming `application/xml` requests into `XapiRoot` objects.
31
-
32
- ```typescript
33
- // app.controller.ts
34
- import { Controller, Post, UseInterceptors, Body } from '@nestjs/common';
35
- import { XapiRoot } from '@xapi-ts/core';
36
- import { XapiRequestInterceptor } from '@xapi-ts/adaptor-nestjs';
37
-
38
- @Controller('xapi')
39
- export class AppController {
40
- @Post('/')
41
- @UseInterceptors(XapiRequestInterceptor)
42
- handleXapi(@Body() xapi: XapiRoot): XapiRoot {
43
- console.log('Received XapiRoot:', xapi.parameters.get('service')?.value);
44
- // Process the XapiRoot object
45
- const responseXapi = new XapiRoot();
46
- responseXapi.addParameter({ id: 'result', value: 'success' });
47
- return responseXapi;
48
- }
49
- }
50
- ```
51
-
52
- ### XapiResponseInterceptor
53
-
54
- Use `XapiResponseInterceptor` to automatically serialize `XapiRoot` objects returned from your NestJS controllers into `application/xml` responses.
55
-
56
- ```typescript
57
- // app.controller.ts
58
- import { Controller, Post, UseInterceptors, Body } from '@nestjs/common';
59
- import { XapiRoot } from '@xapi-ts/core
60
- import { XapiRequestInterceptor, XapiResponseInterceptor } from '@xapi-ts/adaptor-nestjs';
61
-
62
- @Controller('xapi')
63
- export class AppController {
64
- @Post('/')
65
- @UseInterceptors(XapiRequestInterceptor, XapiResponseInterceptor)
66
- handleXapi(@Body() xapi: XapiRoot): XapiRoot {
67
- console.log('Received XapiRoot:', xapi.parameters.get('service')?.value);
68
- // Process the XapiRoot object
69
- const responseXapi = new XapiRoot();
70
- responseXapi.addParameter({ id: 'result', value: 'success' });
71
- return responseXapi;
72
- }
73
- }
74
- ```
75
-
76
- ---
77
-
78
- # @xapi-ts/adaptor-nestjs
79
-
80
- 이 패키지는 X-API 데이터를 위한 NestJS 어댑터를 제공합니다.
81
-
82
- ## 설치
83
-
84
- ```bash
85
- # npm
86
- npm install @xapi-ts/adaptor-nestjs
87
-
88
- # yarn
89
- yarn add @xapi-ts/adaptor-nestjs
90
-
91
- # pnpm
92
- pnpm add @xapi-ts/adaptor-nestjs
93
-
94
- # bun
95
- bun add @xapi-ts/adaptor-nestjs
96
-
97
- # deno
98
- deno add @xapi-ts/adaptor-nestjs
99
- ```
100
-
101
- ## 사용법
102
-
103
- `@xapi-ts/adaptor-nestjs`는 X-API 요청 역직렬화 및 응답 직렬화를 자동으로 처리하는 NestJS 인터셉터를 제공합니다.
104
-
105
- ### XapiRequestInterceptor
106
-
107
- 들어오는 `application/xml` 요청을 `XapiRoot` 객체로 자동 구문 분석하려면 `XapiRequestInterceptor`를 사용하십시오.
108
-
109
- ```typescript
110
- // app.controller.ts
111
- import { Controller, Post, UseInterceptors, Body } from '@nestjs/common';
112
- import { XapiRoot } from '@xapi-ts/core';
113
- import { XapiRequestInterceptor } from '@xapi-ts/adaptor-nestjs';
114
-
115
- @Controller('xapi')
116
- export class AppController {
117
- @Post('/')
118
- @UseInterceptors(XapiRequestInterceptor)
119
- handleXapi(@Body() xapi: XapiRoot): XapiRoot {
120
- console.log('Received XapiRoot:', xapi.parameters.get('service')?.value);
121
- // XapiRoot 객체 처리
122
- const responseXapi = new XapiRoot();
123
- responseXapi.addParameter({ id: 'result', value: 'success' });
124
- return responseXapi;
125
- }
126
- }
127
- ```
128
-
129
- ### XapiResponseInterceptor
130
-
131
- NestJS 컨트롤러에서 반환된 `XapiRoot` 객체를 `application/xml` 응답으로 자동 직렬화하려면 `XapiResponseInterceptor`를 사용하십시오.
132
-
133
- ```typescript
134
- // app.controller.ts
135
- import { Controller, Post, UseInterceptors, Body } from '@nestjs/common';
136
- import { XapiRoot } from '@xapi-ts/core
137
- import { XapiRequestInterceptor, XapiResponseInterceptor } from '@xapi-ts/adaptor-nestjs';
138
-
139
- @Controller('xapi')
140
- export class AppController {
141
- @Post('/')
142
- @UseInterceptors(XapiRequestInterceptor, XapiResponseInterceptor)
143
- handleXapi(@Body() xapi: XapiRoot): XapiRoot {
144
- console.log('Received XapiRoot:', xapi.parameters.get('service')?.value);
145
- // XapiRoot 객체 처리
146
- const responseXapi = new XapiRoot();
147
- responseXapi.addParameter({ id: 'result', value: 'success' });
148
- return responseXapi;
149
- }
150
- }
151
- ```
1
+ # @xapi-js/adaptor-nestjs
2
+
3
+ NestJS interceptors for raw or schema-typed X-API requests and responses.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pnpm add @xapi-js/core @xapi-js/adaptor-nestjs @nestjs/common rxjs
9
+ ```
10
+
11
+ ## Typed usage
12
+
13
+ ```ts
14
+ import { Body, Controller, Post, UseInterceptors } from '@nestjs/common';
15
+ import { InferRoot, xapi } from '@xapi-js/core';
16
+ import {
17
+ XapiRequestInterceptor,
18
+ XapiResponseInterceptor,
19
+ } from '@xapi-js/adaptor-nestjs';
20
+
21
+ const requestSchema = xapi.root({
22
+ datasets: {
23
+ input: xapi.dataset({ id: xapi.int() }),
24
+ },
25
+ });
26
+
27
+ const responseSchema = xapi.root({
28
+ datasets: {
29
+ users: xapi.dataset({ id: xapi.int(), name: xapi.string() }),
30
+ },
31
+ });
32
+
33
+ @Controller('xapi')
34
+ export class XapiController {
35
+ @Post()
36
+ @UseInterceptors(
37
+ new XapiRequestInterceptor(requestSchema),
38
+ new XapiResponseInterceptor(responseSchema),
39
+ )
40
+ handle(
41
+ @Body() request: InferRoot<typeof requestSchema>,
42
+ ): InferRoot<typeof responseSchema> {
43
+ return {
44
+ parameters: {},
45
+ datasets: {
46
+ users: request.datasets.input.map(({ id }) => ({ id, name: `user-${id}` })),
47
+ },
48
+ };
49
+ }
50
+ }
51
+ ```
52
+
53
+ Without a schema, both interceptors retain their original `XapiRoot` behavior.
54
+
55
+ ---
56
+
57
+ schema를 interceptor에 전달하면 컨트롤러 body와 반환값을 Dataset 기반
58
+ `XapiRoot` 대신 타입이 추론된 plain object로 사용할 있습니다.
package/dist/index.cjs CHANGED
@@ -1,37 +1,21 @@
1
- //#region rolldown:runtime
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
- key = keys[i];
11
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
- get: ((k) => from[k]).bind(null, key),
13
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
- });
15
- }
16
- return to;
17
- };
18
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
- value: mod,
20
- enumerable: true
21
- }) : target, mod));
22
-
23
- //#endregion
24
- let __nestjs_common = require("@nestjs/common");
25
- __nestjs_common = __toESM(__nestjs_common);
26
- let __xapi_js_core = require("@xapi-js/core");
27
- __xapi_js_core = __toESM(__xapi_js_core);
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _nestjs_common = require("@nestjs/common");
3
+ let _xapi_js_core = require("@xapi-js/core");
28
4
  let rxjs = require("rxjs");
29
- rxjs = __toESM(rxjs);
30
-
5
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/decorate.js
6
+ function __decorate(decorators, target, key, desc) {
7
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
8
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
9
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
10
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
11
+ }
12
+ //#endregion
31
13
  //#region src/xapi-request-interceptor.ts
32
- var XapiRequestInterceptor = @((0, __nestjs_common.Injectable)()) class XapiRequestInterceptor {
33
- constructor() {
34
- this.logger = new __nestjs_common.Logger(XapiRequestInterceptor.name);
14
+ var _XapiRequestInterceptor;
15
+ let XapiRequestInterceptor = _XapiRequestInterceptor = class XapiRequestInterceptor {
16
+ constructor(schema) {
17
+ this.schema = schema;
18
+ this.logger = new _nestjs_common.Logger(_XapiRequestInterceptor.name);
35
19
  }
36
20
  /**
37
21
  * Intercepts the incoming request to parse XML body.
@@ -44,16 +28,21 @@ var XapiRequestInterceptor = @((0, __nestjs_common.Injectable)()) class XapiRequ
44
28
  async intercept(context, next) {
45
29
  const request = context.switchToHttp().getRequest();
46
30
  this.logger.debug(`XapiRequestInterceptor Intercepting request: ${request.method} ${request.url}`);
47
- if (request.headers["content-type"] === "application/xml" && request.body) request.body = await (0, __xapi_js_core.parse)(request.body);
31
+ if (request.headers["content-type"]?.startsWith("application/xml") && request.body) {
32
+ const root = (0, _xapi_js_core.parse)(request.body);
33
+ request.body = this.schema ? (0, _xapi_js_core.decodeRoot)(this.schema, root) : root;
34
+ }
48
35
  return next.handle();
49
36
  }
50
37
  };
51
-
38
+ XapiRequestInterceptor = _XapiRequestInterceptor = __decorate([(0, _nestjs_common.Injectable)()], XapiRequestInterceptor);
52
39
  //#endregion
53
40
  //#region src/xapi-response-interceptor.ts
54
- var XapiResponseInterceptor = @((0, __nestjs_common.Injectable)()) class XapiResponseInterceptor {
55
- constructor() {
56
- this.logger = new __nestjs_common.Logger(XapiResponseInterceptor.name);
41
+ var _XapiResponseInterceptor;
42
+ let XapiResponseInterceptor = _XapiResponseInterceptor = class XapiResponseInterceptor {
43
+ constructor(schema) {
44
+ this.schema = schema;
45
+ this.logger = new _nestjs_common.Logger(_XapiResponseInterceptor.name);
57
46
  }
58
47
  /**
59
48
  * Intercepts the outgoing response to serialize XapiRoot to XML string.
@@ -67,8 +56,9 @@ var XapiResponseInterceptor = @((0, __nestjs_common.Injectable)()) class XapiRes
67
56
  intercept(context, next) {
68
57
  this.logger.debug(`XapiResponseInterceptor Intercepting response`);
69
58
  return next.handle().pipe((0, rxjs.map)((value) => {
70
- if ((0, __xapi_js_core.isXapiRoot)(value)) try {
71
- return (0, __xapi_js_core.write)(value);
59
+ const root = this.schema ? (0, _xapi_js_core.encodeRoot)(this.schema, value) : value;
60
+ if ((0, _xapi_js_core.isXapiRoot)(root)) try {
61
+ return (0, _xapi_js_core.write)(root);
72
62
  } catch (error) {
73
63
  this.logger.error(`Failed to serialize XapiRoot to XML string: ${error}`);
74
64
  throw error;
@@ -77,7 +67,17 @@ var XapiResponseInterceptor = @((0, __nestjs_common.Injectable)()) class XapiRes
77
67
  }));
78
68
  }
79
69
  };
80
-
70
+ XapiResponseInterceptor = _XapiResponseInterceptor = __decorate([(0, _nestjs_common.Injectable)()], XapiResponseInterceptor);
81
71
  //#endregion
82
- exports.XapiRequestInterceptor = XapiRequestInterceptor;
83
- exports.XapiResponseInterceptor = XapiResponseInterceptor;
72
+ Object.defineProperty(exports, "XapiRequestInterceptor", {
73
+ enumerable: true,
74
+ get: function() {
75
+ return XapiRequestInterceptor;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, "XapiResponseInterceptor", {
79
+ enumerable: true,
80
+ get: function() {
81
+ return XapiResponseInterceptor;
82
+ }
83
+ });
package/dist/index.d.cts CHANGED
@@ -1,16 +1,16 @@
1
1
  import { CallHandler, ExecutionContext, NestInterceptor } from "@nestjs/common";
2
+ import { XapiRootSchema } from "@xapi-js/core";
2
3
  import { Observable } from "rxjs";
3
- import { XapiRoot } from "@xapi-js/core";
4
-
5
4
  //#region src/xapi-request-interceptor.d.ts
6
-
7
5
  /**
8
6
  * Interceptor that parses incoming XML request bodies into XapiRoot objects.
9
7
  * This interceptor should be applied to routes that expect an `application/xml` content type
10
8
  * and whose body contains X-API XML data.
11
9
  */
12
10
  declare class XapiRequestInterceptor implements NestInterceptor {
11
+ private readonly schema?;
13
12
  private readonly logger;
13
+ constructor(schema?: XapiRootSchema | undefined);
14
14
  /**
15
15
  * Intercepts the incoming request to parse XML body.
16
16
  * If the content type is `application/xml` and a body exists, it attempts to parse the body
@@ -28,8 +28,10 @@ declare class XapiRequestInterceptor implements NestInterceptor {
28
28
  * This interceptor should be applied to routes that return an `XapiRoot` instance
29
29
  * and whose response should be `application/xml`.
30
30
  */
31
- declare class XapiResponseInterceptor implements NestInterceptor<XapiRoot, string> {
31
+ declare class XapiResponseInterceptor implements NestInterceptor<unknown, string> {
32
+ private readonly schema?;
32
33
  private readonly logger;
34
+ constructor(schema?: XapiRootSchema | undefined);
33
35
  /**
34
36
  * Intercepts the outgoing response to serialize XapiRoot to XML string.
35
37
  * If the handler returns an `XapiRoot` instance, it attempts to serialize it
package/dist/index.d.ts CHANGED
@@ -1,16 +1,16 @@
1
1
  import { CallHandler, ExecutionContext, NestInterceptor } from "@nestjs/common";
2
- import { XapiRoot } from "@xapi-js/core";
2
+ import { XapiRootSchema } from "@xapi-js/core";
3
3
  import { Observable } from "rxjs";
4
-
5
4
  //#region src/xapi-request-interceptor.d.ts
6
-
7
5
  /**
8
6
  * Interceptor that parses incoming XML request bodies into XapiRoot objects.
9
7
  * This interceptor should be applied to routes that expect an `application/xml` content type
10
8
  * and whose body contains X-API XML data.
11
9
  */
12
10
  declare class XapiRequestInterceptor implements NestInterceptor {
11
+ private readonly schema?;
13
12
  private readonly logger;
13
+ constructor(schema?: XapiRootSchema | undefined);
14
14
  /**
15
15
  * Intercepts the incoming request to parse XML body.
16
16
  * If the content type is `application/xml` and a body exists, it attempts to parse the body
@@ -28,8 +28,10 @@ declare class XapiRequestInterceptor implements NestInterceptor {
28
28
  * This interceptor should be applied to routes that return an `XapiRoot` instance
29
29
  * and whose response should be `application/xml`.
30
30
  */
31
- declare class XapiResponseInterceptor implements NestInterceptor<XapiRoot, string> {
31
+ declare class XapiResponseInterceptor implements NestInterceptor<unknown, string> {
32
+ private readonly schema?;
32
33
  private readonly logger;
34
+ constructor(schema?: XapiRootSchema | undefined);
33
35
  /**
34
36
  * Intercepts the outgoing response to serialize XapiRoot to XML string.
35
37
  * If the handler returns an `XapiRoot` instance, it attempts to serialize it
package/dist/index.js CHANGED
@@ -1,11 +1,20 @@
1
1
  import { Injectable, Logger } from "@nestjs/common";
2
- import { isXapiRoot, parse, write } from "@xapi-js/core";
2
+ import { decodeRoot, encodeRoot, isXapiRoot, parse, write } from "@xapi-js/core";
3
3
  import { map } from "rxjs";
4
-
4
+ //#region \0@oxc-project+runtime@0.139.0/helpers/esm/decorate.js
5
+ function __decorate(decorators, target, key, desc) {
6
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
7
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
8
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
9
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
10
+ }
11
+ //#endregion
5
12
  //#region src/xapi-request-interceptor.ts
6
- var XapiRequestInterceptor = @Injectable() class XapiRequestInterceptor {
7
- constructor() {
8
- this.logger = new Logger(XapiRequestInterceptor.name);
13
+ var _XapiRequestInterceptor;
14
+ let XapiRequestInterceptor = _XapiRequestInterceptor = class XapiRequestInterceptor {
15
+ constructor(schema) {
16
+ this.schema = schema;
17
+ this.logger = new Logger(_XapiRequestInterceptor.name);
9
18
  }
10
19
  /**
11
20
  * Intercepts the incoming request to parse XML body.
@@ -18,16 +27,21 @@ var XapiRequestInterceptor = @Injectable() class XapiRequestInterceptor {
18
27
  async intercept(context, next) {
19
28
  const request = context.switchToHttp().getRequest();
20
29
  this.logger.debug(`XapiRequestInterceptor Intercepting request: ${request.method} ${request.url}`);
21
- if (request.headers["content-type"] === "application/xml" && request.body) request.body = await parse(request.body);
30
+ if (request.headers["content-type"]?.startsWith("application/xml") && request.body) {
31
+ const root = parse(request.body);
32
+ request.body = this.schema ? decodeRoot(this.schema, root) : root;
33
+ }
22
34
  return next.handle();
23
35
  }
24
36
  };
25
-
37
+ XapiRequestInterceptor = _XapiRequestInterceptor = __decorate([Injectable()], XapiRequestInterceptor);
26
38
  //#endregion
27
39
  //#region src/xapi-response-interceptor.ts
28
- var XapiResponseInterceptor = @Injectable() class XapiResponseInterceptor {
29
- constructor() {
30
- this.logger = new Logger(XapiResponseInterceptor.name);
40
+ var _XapiResponseInterceptor;
41
+ let XapiResponseInterceptor = _XapiResponseInterceptor = class XapiResponseInterceptor {
42
+ constructor(schema) {
43
+ this.schema = schema;
44
+ this.logger = new Logger(_XapiResponseInterceptor.name);
31
45
  }
32
46
  /**
33
47
  * Intercepts the outgoing response to serialize XapiRoot to XML string.
@@ -41,8 +55,9 @@ var XapiResponseInterceptor = @Injectable() class XapiResponseInterceptor {
41
55
  intercept(context, next) {
42
56
  this.logger.debug(`XapiResponseInterceptor Intercepting response`);
43
57
  return next.handle().pipe(map((value) => {
44
- if (isXapiRoot(value)) try {
45
- return write(value);
58
+ const root = this.schema ? encodeRoot(this.schema, value) : value;
59
+ if (isXapiRoot(root)) try {
60
+ return write(root);
46
61
  } catch (error) {
47
62
  this.logger.error(`Failed to serialize XapiRoot to XML string: ${error}`);
48
63
  throw error;
@@ -51,6 +66,6 @@ var XapiResponseInterceptor = @Injectable() class XapiResponseInterceptor {
51
66
  }));
52
67
  }
53
68
  };
54
-
69
+ XapiResponseInterceptor = _XapiResponseInterceptor = __decorate([Injectable()], XapiResponseInterceptor);
55
70
  //#endregion
56
- export { XapiRequestInterceptor, XapiResponseInterceptor };
71
+ export { XapiRequestInterceptor, XapiResponseInterceptor };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xapi-js/adaptor-nestjs",
3
3
  "type": "module",
4
- "version": "1.3.0",
4
+ "version": "1.4.1",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -33,7 +33,7 @@
33
33
  "express": "^5.1.0",
34
34
  "rxjs": "^7.8.1",
35
35
  "@nestjs/common": "^10.3.10",
36
- "@xapi-js/core": "1.3.0"
36
+ "@xapi-js/core": "1.4.1"
37
37
  },
38
38
  "devDependencies": {},
39
39
  "scripts": {