@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 +217 -216
- package/package.json +2 -5
- package/dist/api-ISSD7HZ6.js +0 -134436
- package/dist/chunk-GI5RMYH6.js +0 -37
- package/dist/performance.test.js +0 -2485
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 {
|
|
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
|
|
103
|
-
console.log('
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
npm
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
yarn
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
pnpm
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
bun
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
deno
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
<Parameter id="
|
|
150
|
-
|
|
151
|
-
</
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
console.log('
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
xapi.addParameter({ id: '
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
usersDataset
|
|
178
|
-
usersDataset.addColumn({ id: '
|
|
179
|
-
|
|
180
|
-
rowIdx
|
|
181
|
-
usersDataset.
|
|
182
|
-
usersDataset.setColumn(rowIdx, '
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
usersDataset.
|
|
186
|
-
usersDataset.setColumn(rowIdx, '
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
xapi
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
productsDataset
|
|
205
|
-
productsDataset.addColumn({ id: '
|
|
206
|
-
productsDataset.
|
|
207
|
-
productsDataset.
|
|
208
|
-
productsDataset.setColumn(0, '
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
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.
|
|
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",
|