@xapi-js/core 1.1.0 → 1.1.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/README.md CHANGED
@@ -1,217 +1,218 @@
1
- # @xapi-ts/core
2
-
3
- This package provides core utilities and types for working with X-API data.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- # npm
9
- npm install @xapi-ts/core
10
-
11
- # yarn
12
- yarn add @xapi-ts/core
13
-
14
- # pnpm
15
- pnpm add @xapi-ts/core
16
-
17
- # bun
18
- bun add @xapi-ts/core
19
-
20
- # deno
21
- deno add @xapi-ts/core
22
- ```
23
-
24
- ## Usage
25
-
26
- `@xapi-ts/core` provides the fundamental classes and functions for working with X-API data.
27
-
28
- ### Parsing X-API XML
29
-
30
- You can parse an X-API XML string into an `XapiRoot` object:
31
-
32
- ```typescript
33
- import { parse, XapiRoot } from '@xapi-ts/core';
34
-
35
- const xmlString = `<?xml version="1.0" encoding="UTF-8"?>
36
- <Root xmlns="http://www.tobesoft.com/platform/Dataset" ver="4000">
37
- <Parameters>
38
- <Parameter id="service">stock</Parameter>
39
- <Parameter id="method">search</Parameter>
40
- </Parameters>
41
- </Root>`;
42
-
43
- async function parseXapi() {
44
- const xapi = await parse(xmlString);
45
- console.log('Service:', xapi.getParameter('service')?.value);
46
- console.log('Method:', xapi.getParameter('method')?.value);
47
- }
48
-
49
- parseXapi();
50
- ```
51
-
52
- ### Creating and Manipulating XapiRoot
53
-
54
- You can create an `XapiRoot` object and add parameters and datasets programmatically:
55
-
56
- ```typescript
57
- import { XapiRoot, Dataset } from '@xapi-ts/core';
58
-
59
- const xapi = new XapiRoot();
60
-
61
- // Add parameters
62
- xapi.addParameter({ id: 'resultCode', value: '0' });
63
- xapi.addParameter({ id: 'resultMsg', value: 'SUCCESS' });
64
-
65
- // Create and add a dataset
66
- const usersDataset = new Dataset('users');
67
- usersDataset.addColumn({ id: 'id', type: 'INT' });
68
- usersDataset.addColumn({ id: 'name', type: 'STRING' });
69
-
70
- usersDataset.newRow();
71
- usersDataset.setColumn(0, 'id', 1);
72
- usersDataset.setColumn(0, 'name', 'Alice');
73
-
74
- usersDataset.newRow();
75
- usersDataset.setColumn(1, 'id', 2);
76
- usersDataset.setColumn(1, 'name', 'Bob');
77
-
78
- xapi.addDataset(usersDataset);
79
-
80
- console.log('XapiRoot created:', xapi);
81
- ```
82
-
83
- ### Serializing XapiRoot to XML
84
-
85
- You can serialize an `XapiRoot` object back into an X-API XML string:
86
-
87
- ```typescript
88
- import { write, XapiRoot, Dataset } from '@xapi-ts/core';
89
-
90
- const xapi = new XapiRoot();
91
- xapi.addParameter({ id: 'status', value: 'OK' });
92
-
93
- const productsDataset = new Dataset('products');
94
- productsDataset.addColumn({ id: 'productId', type: 'STRING' });
95
- productsDataset.addColumn({ id: 'price', type: 'INT' });
96
- productsDataset.newRow();
97
- productsDataset.setColumn(0, 'productId', 'P001');
98
- productsDataset.setColumn(0, 'price', 1000);
99
- xapi.addDataset(productsDataset);
100
-
101
- async function writeXapi() {
102
- const xmlOutput = await write(xapi);
103
- console.log('Generated XML:\n', xmlOutput);
104
- }
105
-
106
- writeXapi();
107
- ```
108
-
109
- ---
110
-
111
- # @xapi-ts/core
112
-
113
- 이 패키지는 X-API 데이터를 다루기 위한 핵심 유틸리티 및 타입을 제공합니다.
114
-
115
- ## 설치
116
-
117
- ```bash
118
- # npm
119
- npm install @xapi-ts/core
120
-
121
- # yarn
122
- yarn add @xapi-ts/core
123
-
124
- # pnpm
125
- pnpm add @xapi-ts/core
126
-
127
- # bun
128
- bun add @xapi-ts/core
129
-
130
- # deno
131
- deno add @xapi-ts/core
132
- ```
133
-
134
- ## 사용법
135
-
136
- `@xapi-ts/core`는 X-API 데이터를 다루기 위한 기본적인 클래스와 함수를 제공합니다.
137
-
138
- ### X-API XML 파싱
139
-
140
- X-API XML 문자열을 `XapiRoot` 객체로 파싱할 수 있습니다:
141
-
142
- ```typescript
143
- import { parse, XapiRoot } from '@xapi-ts/core';
144
-
145
- const xmlString = `<?xml version="1.0" encoding="UTF-8"?>
146
- <Root xmlns="http://www.tobesoft.com/platform/Dataset" ver="4000">
147
- <Parameters>
148
- <Parameter id="service">stock</Parameter>
149
- <Parameter id="method">search</Parameter>
150
- </Parameters>
151
- </Root>`;
152
-
153
- async function parseXapi() {
154
- const xapi = await parse(xmlString);
155
- console.log('서비스:', xapi.getParameter('service')?.value);
156
- console.log('메서드:', xapi.getParameter('method')?.value);
157
- }
158
-
159
- parseXapi();
160
- ```
161
-
162
- ### XapiRoot 생성 및 조작
163
-
164
- `XapiRoot` 객체를 생성하고 매개변수 및 데이터셋을 프로그래밍 방식으로 추가할 수 있습니다:
165
-
166
- ```typescript
167
- import { XapiRoot, Dataset } from '@xapi-ts/core';
168
-
169
- const xapi = new XapiRoot();
170
-
171
- // 매개변수 추가
172
- xapi.addParameter({ id: 'resultCode', value: '0' });
173
- xapi.addParameter({ id: 'resultMsg', value: 'SUCCESS' });
174
-
175
- // 데이터셋 생성 및 추가
176
- const usersDataset = new Dataset('users');
177
- usersDataset.addColumn({ id: 'id', type: 'INT' });
178
- usersDataset.addColumn({ id: 'name', type: 'STRING' });
179
- let rowIdx: number;
180
- rowIdx = usersDataset.newRow();
181
- usersDataset.setColumn(rowIdx, 'id', 1);
182
- usersDataset.setColumn(rowIdx, 'name', 'Alice');
183
-
184
- rowIdx = usersDataset.newRow();
185
- usersDataset.setColumn(rowIdx, 'id', 2);
186
- usersDataset.setColumn(rowIdx, 'name', 'Bob');
187
-
188
- xapi.addDataset(usersDataset);
189
-
190
- console.log('XapiRoot 생성됨:', xapi);
191
- ```
192
-
193
- ### XapiRoot를 XML로 직렬화
194
-
195
- `XapiRoot` 객체를 X-API XML 문자열로 다시 직렬화할 수 있습니다:
196
-
197
- ```typescript
198
- import { write, XapiRoot, Dataset } from '@xapi-ts/core';
199
-
200
- const xapi = new XapiRoot();
201
- xapi.addParameter({ id: 'status', value: 'OK' });
202
-
203
- const productsDataset = new Dataset('products');
204
- productsDataset.addColumn({ id: 'productId', type: 'STRING' });
205
- productsDataset.addColumn({ id: 'price', type: 'INT' });
206
- productsDataset.newRow();
207
- productsDataset.setColumn(0, 'productId', 'P001');
208
- productsDataset.setColumn(0, 'price', 1000);
209
- xapi.addDataset(productsDataset);
210
-
211
- async function writeXapi() {
212
- const xmlOutput = await write(xapi);
213
- console.log('생성된 XML:\n', xmlOutput);
214
- }
215
-
216
- writeXapi();
1
+ # @xapi-ts/core
2
+
3
+ This package provides core utilities and types for working with X-API data.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # npm
9
+ npm install @xapi-ts/core
10
+
11
+ # yarn
12
+ yarn add @xapi-ts/core
13
+
14
+ # pnpm
15
+ pnpm add @xapi-ts/core
16
+
17
+ # bun
18
+ bun add @xapi-ts/core
19
+
20
+ # deno
21
+ deno add @xapi-ts/core
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ `@xapi-ts/core` provides the fundamental classes and functions for working with X-API data.
27
+
28
+ ### Parsing X-API XML
29
+
30
+ You can parse an X-API XML string into an `XapiRoot` object:
31
+
32
+ ```typescript
33
+ import { parse, XapiRoot } from '@xapi-ts/core';
34
+
35
+ const xmlString = `<?xml version="1.0" encoding="UTF-8"?>
36
+ <Root xmlns="http://www.tobesoft.com/platform/Dataset" ver="4000">
37
+ <Parameters>
38
+ <Parameter id="service">stock</Parameter>
39
+ <Parameter id="method">search</Parameter>
40
+ </Parameters>
41
+ </Root>`;
42
+
43
+ async function parseXapi() {
44
+ const xapi = await parse(xmlString);
45
+ console.log('Service:', xapi.getParameter('service')?.value);
46
+ console.log('Method:', xapi.getParameter('method')?.value);
47
+ }
48
+
49
+ parseXapi();
50
+ ```
51
+
52
+ ### Creating and Manipulating XapiRoot
53
+
54
+ You can create an `XapiRoot` object and add parameters and datasets programmatically:
55
+
56
+ ```typescript
57
+ import { XapiRoot, Dataset } from '@xapi-ts/core';
58
+
59
+ const xapi = new XapiRoot();
60
+
61
+ // Add parameters
62
+ xapi.addParameter({ id: 'resultCode', value: '0' });
63
+ xapi.addParameter({ id: 'resultMsg', value: 'SUCCESS' });
64
+
65
+ // Create and add a dataset
66
+ const usersDataset = new Dataset('users');
67
+ usersDataset.addColumn({ id: 'id', type: 'INT' });
68
+ usersDataset.addColumn({ id: 'name', type: 'STRING' });
69
+
70
+ usersDataset.newRow();
71
+ usersDataset.setColumn(0, 'id', 1);
72
+ usersDataset.setColumn(0, 'name', 'Alice');
73
+
74
+ usersDataset.newRow();
75
+ usersDataset.setColumn(1, 'id', 2);
76
+ usersDataset.setColumn(1, 'name', 'Bob');
77
+
78
+ xapi.addDataset(usersDataset);
79
+
80
+ console.log('XapiRoot created:', xapi);
81
+ ```
82
+
83
+ ### Serializing XapiRoot to XML
84
+
85
+ You can serialize an `XapiRoot` object back into an X-API XML string:
86
+
87
+ ```typescript
88
+ import { writeString, XapiRoot, Dataset } from '@xapi-ts/core';
89
+
90
+ const xapi = new XapiRoot();
91
+ xapi.addParameter({ id: 'status', value: 'OK' });
92
+
93
+ const productsDataset = new Dataset('products');
94
+ productsDataset.addColumn({ id: 'productId', type: 'STRING' });
95
+ productsDataset.addColumn({ id: 'price', type: 'INT' });
96
+ productsDataset.newRow();
97
+ productsDataset.setColumn(0, 'productId', 'P001');
98
+ productsDataset.setColumn(0, 'price', 1000);
99
+ xapi.addDataset(productsDataset);
100
+
101
+ async function writeXapi() {
102
+ const xmlOutput = await writeString(xapi);
103
+ console.log('생성된 XML:
104
+ ', xmlOutput);
105
+ }
106
+
107
+ writeXapi();
108
+ ```
109
+
110
+ ---
111
+
112
+ # @xapi-ts/core
113
+
114
+ 이 패키지는 X-API 데이터를 다루기 위한 핵심 유틸리티 및 타입을 제공합니다.
115
+
116
+ ## 설치
117
+
118
+ ```bash
119
+ # npm
120
+ npm install @xapi-ts/core
121
+
122
+ # yarn
123
+ yarn add @xapi-ts/core
124
+
125
+ # pnpm
126
+ pnpm add @xapi-ts/core
127
+
128
+ # bun
129
+ bun add @xapi-ts/core
130
+
131
+ # deno
132
+ deno add @xapi-ts/core
133
+ ```
134
+
135
+ ## 사용법
136
+
137
+ `@xapi-ts/core`는 X-API 데이터를 다루기 위한 기본적인 클래스와 함수를 제공합니다.
138
+
139
+ ### X-API XML 파싱
140
+
141
+ X-API XML 문자열을 `XapiRoot` 객체로 파싱할 수 있습니다:
142
+
143
+ ```typescript
144
+ import { parse, XapiRoot } from '@xapi-ts/core';
145
+
146
+ const xmlString = `<?xml version="1.0" encoding="UTF-8"?>
147
+ <Root xmlns="http://www.tobesoft.com/platform/Dataset" ver="4000">
148
+ <Parameters>
149
+ <Parameter id="service">stock</Parameter>
150
+ <Parameter id="method">search</Parameter>
151
+ </Parameters>
152
+ </Root>`;
153
+
154
+ async function parseXapi() {
155
+ const xapi = await parse(xmlString);
156
+ console.log('서비스:', xapi.getParameter('service')?.value);
157
+ console.log('메서드:', xapi.getParameter('method')?.value);
158
+ }
159
+
160
+ parseXapi();
161
+ ```
162
+
163
+ ### XapiRoot 생성 및 조작
164
+
165
+ `XapiRoot` 객체를 생성하고 매개변수 및 데이터셋을 프로그래밍 방식으로 추가할 수 있습니다:
166
+
167
+ ```typescript
168
+ import { XapiRoot, Dataset } from '@xapi-ts/core';
169
+
170
+ const xapi = new XapiRoot();
171
+
172
+ // 매개변수 추가
173
+ xapi.addParameter({ id: 'resultCode', value: '0' });
174
+ xapi.addParameter({ id: 'resultMsg', value: 'SUCCESS' });
175
+
176
+ // 데이터셋 생성 추가
177
+ const usersDataset = new Dataset('users');
178
+ usersDataset.addColumn({ id: 'id', type: 'INT' });
179
+ usersDataset.addColumn({ id: 'name', type: 'STRING' });
180
+ let rowIdx: number;
181
+ rowIdx = usersDataset.newRow();
182
+ usersDataset.setColumn(rowIdx, 'id', 1);
183
+ usersDataset.setColumn(rowIdx, 'name', 'Alice');
184
+
185
+ rowIdx = usersDataset.newRow();
186
+ usersDataset.setColumn(rowIdx, 'id', 2);
187
+ usersDataset.setColumn(rowIdx, 'name', 'Bob');
188
+
189
+ xapi.addDataset(usersDataset);
190
+
191
+ console.log('XapiRoot 생성됨:', xapi);
192
+ ```
193
+
194
+ ### XapiRoot를 XML로 직렬화
195
+
196
+ `XapiRoot` 객체를 X-API XML 문자열로 다시 직렬화할 수 있습니다:
197
+
198
+ ```typescript
199
+ import { write, XapiRoot, Dataset } from '@xapi-ts/core';
200
+
201
+ const xapi = new XapiRoot();
202
+ xapi.addParameter({ id: 'status', value: 'OK' });
203
+
204
+ const productsDataset = new Dataset('products');
205
+ productsDataset.addColumn({ id: 'productId', type: 'STRING' });
206
+ productsDataset.addColumn({ id: 'price', type: 'INT' });
207
+ productsDataset.newRow();
208
+ productsDataset.setColumn(0, 'productId', 'P001');
209
+ productsDataset.setColumn(0, 'price', 1000);
210
+ xapi.addDataset(productsDataset);
211
+
212
+ async function writeXapi() {
213
+ const xmlOutput = await write(xapi);
214
+ console.log('생성된 XML:\n', xmlOutput);
215
+ }
216
+
217
+ writeXapi();
217
218
  ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xapi-js/core",
3
3
  "type": "module",
4
- "version": "1.1.0",
4
+ "version": "1.1.1",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
7
7
  "types": "./dist/index.d.ts",
@@ -32,11 +32,8 @@
32
32
  "typescript": "^5.3.3"
33
33
  },
34
34
  "dependencies": {
35
- "@types/xml2js": "^0.4.14",
36
- "fast-xml-parser": "^5.2.5",
37
35
  "stax-xml": "^0.2.4",
38
- "txml": "^5.1.1",
39
- "xml2js": "^0.6.2"
36
+ "txml": "^5.1.1"
40
37
  },
41
38
  "scripts": {
42
39
  "build": "tsup src/index.ts --format cjs,esm --dts",