daiso 1.0.3 → 1.0.5
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 +218 -537
- package/dist/api/actionsProxy.js +82 -0
- package/dist/api/cgvHandlers.js +103 -16
- package/dist/api/daisoHandlers.js +127 -0
- package/dist/api/emart24Handlers.js +176 -0
- package/dist/api/gs25Handlers.js +256 -0
- package/dist/api/handlers.js +184 -108
- package/dist/api/healthChecks.js +332 -0
- package/dist/api/lottecinemaHandlers.js +155 -0
- package/dist/api/lottemartHandlers.js +128 -0
- package/dist/api/megaboxHandlers.js +81 -50
- package/dist/api/routes/cuRoutes.js +17 -0
- package/dist/api/routes/daisoRoutes.js +6 -1
- package/dist/api/routes/emart24Routes.js +22 -0
- package/dist/api/routes/gs25Routes.js +22 -0
- package/dist/api/routes/healthRoutes.js +44 -0
- package/dist/api/routes/lottecinemaRoutes.js +22 -0
- package/dist/api/routes/lottemartRoutes.js +18 -0
- package/dist/api/routes/oliveyoungRoutes.js +6 -1
- package/dist/api/routes/sevenelevenRoutes.js +32 -0
- package/dist/api/sevenelevenHandlers.js +200 -0
- package/dist/cli/args.js +54 -0
- package/dist/cli/commands/convenience.js +241 -0
- package/dist/cli/commands/daiso.js +96 -0
- package/dist/cli/constants.js +5 -0
- package/dist/cli/deps.js +48 -0
- package/dist/cli/http.js +98 -0
- package/dist/cli/interactiveFetch.js +31 -0
- package/dist/cli/interactiveItemSearch.js +259 -0
- package/dist/cli/interactivePrompt.js +49 -0
- package/dist/cli/interactiveTypes.js +4 -0
- package/dist/cli/types.js +4 -0
- package/dist/cli.js +66 -181
- package/dist/cliHelp.js +216 -9
- package/dist/cliInteractive.js +174 -0
- package/dist/cliPicker.js +56 -0
- package/dist/cliRenderer.js +139 -0
- package/dist/index.js +147 -8
- package/dist/pages/openapi.js +2 -1
- package/dist/pages/openapiFullSpec.js +58 -0
- package/dist/pages/openapiResponse.js +28 -0
- package/dist/pages/openapiSpec.js +2 -41
- package/dist/pages/openapiSpecActions.js +109 -0
- package/dist/pages/openapiSpecComponents.js +30 -391
- package/dist/pages/openapiSpecComponentsCgv.js +24 -0
- package/dist/pages/openapiSpecComponentsCu.js +112 -0
- package/dist/pages/openapiSpecComponentsDaisoOliveyoung.js +342 -0
- package/dist/pages/openapiSpecComponentsEmart24.js +141 -0
- package/dist/pages/openapiSpecComponentsGs25.js +109 -0
- package/dist/pages/openapiSpecComponentsLotteMart.js +85 -0
- package/dist/pages/openapiSpecComponentsLottecinema.js +163 -0
- package/dist/pages/openapiSpecComponentsMegabox.js +144 -0
- package/dist/pages/openapiSpecComponentsSeveneleven.js +82 -0
- package/dist/pages/openapiSpecPathsCgv.js +66 -3
- package/dist/pages/openapiSpecPathsCu.js +138 -0
- package/dist/pages/openapiSpecPathsDaiso.js +302 -0
- package/dist/pages/openapiSpecPathsDaisoOliveyoung.js +4 -376
- package/dist/pages/openapiSpecPathsEmart24.js +223 -0
- package/dist/pages/openapiSpecPathsGs25.js +166 -0
- package/dist/pages/openapiSpecPathsLotteMart.js +135 -0
- package/dist/pages/openapiSpecPathsLottecinema.js +212 -0
- package/dist/pages/openapiSpecPathsMegabox.js +52 -3
- package/dist/pages/openapiSpecPathsOliveyoung.js +231 -0
- package/dist/pages/openapiSpecPathsSeveneleven.js +234 -0
- package/dist/pages/prompt.js +8 -402
- package/dist/pages/promptCoreText.js +278 -0
- package/dist/pages/promptReferenceText.js +131 -0
- package/dist/pages/promptRetailCinemaText.js +273 -0
- package/dist/services/cgv/client.js +6 -1
- package/dist/services/cgv/index.js +3 -3
- package/dist/services/cgv/location.js +235 -0
- package/dist/services/cgv/tools/findTheaters.js +30 -5
- package/dist/services/cgv/tools/getTimetable.js +42 -14
- package/dist/services/cgv/tools/searchMovies.js +40 -12
- package/dist/services/cgv/transport.js +0 -3
- package/dist/services/cu/api.js +11 -0
- package/dist/services/cu/client.js +297 -0
- package/dist/services/cu/index.js +21 -0
- package/dist/services/cu/tools/checkInventory.js +123 -0
- package/dist/services/cu/tools/findNearbyStores.js +49 -0
- package/dist/services/cu/types.js +4 -0
- package/dist/services/daiso/api.js +22 -2
- package/dist/services/daiso/client.js +59 -0
- package/dist/services/daiso/index.js +2 -0
- package/dist/services/daiso/product.js +17 -0
- package/dist/services/daiso/tools/checkInventory.js +76 -41
- package/dist/services/daiso/tools/findStores.js +17 -7
- package/dist/services/daiso/tools/getDisplayLocation.js +75 -0
- package/dist/services/emart24/api.js +11 -0
- package/dist/services/emart24/client.js +173 -0
- package/dist/services/emart24/index.js +22 -0
- package/dist/services/emart24/inventoryLookup.js +134 -0
- package/dist/services/emart24/tools/checkInventory.js +54 -0
- package/dist/services/emart24/tools/findNearbyStores.js +72 -0
- package/dist/services/emart24/tools/searchProducts.js +63 -0
- package/dist/services/emart24/types.js +4 -0
- package/dist/services/gs25/api.js +9 -0
- package/dist/services/gs25/client.js +198 -0
- package/dist/services/gs25/index.js +22 -0
- package/dist/services/gs25/storeUtils.js +168 -0
- package/dist/services/gs25/tools/checkInventory.js +163 -0
- package/dist/services/gs25/tools/findNearbyStores.js +103 -0
- package/dist/services/gs25/tools/searchProducts.js +50 -0
- package/dist/services/gs25/types.js +4 -0
- package/dist/services/lottecinema/api.js +12 -0
- package/dist/services/lottecinema/client.js +161 -0
- package/dist/services/lottecinema/index.js +30 -0
- package/dist/services/lottecinema/location.js +191 -0
- package/dist/services/lottecinema/tools/findNearbyTheaters.js +47 -0
- package/dist/services/lottecinema/tools/getRemainingSeats.js +85 -0
- package/dist/services/lottecinema/tools/listNowShowing.js +79 -0
- package/dist/services/lottecinema/types.js +4 -0
- package/dist/services/lottemart/api.js +31 -0
- package/dist/services/lottemart/client.js +245 -0
- package/dist/services/lottemart/clientTypes.js +4 -0
- package/dist/services/lottemart/config.js +4 -0
- package/dist/services/lottemart/debug.js +92 -0
- package/dist/services/lottemart/geocode.js +49 -0
- package/dist/services/lottemart/index.js +30 -0
- package/dist/services/lottemart/keyword.js +29 -0
- package/dist/services/lottemart/parser.js +185 -0
- package/dist/services/lottemart/session.js +331 -0
- package/dist/services/lottemart/storeSearch.js +52 -0
- package/dist/services/lottemart/tools/findNearbyStores.js +67 -0
- package/dist/services/lottemart/tools/searchProducts.js +62 -0
- package/dist/services/lottemart/types.js +4 -0
- package/dist/services/lottemart/zetta.js +105 -0
- package/dist/services/megabox/location.js +219 -0
- package/dist/services/megabox/tools/findNearbyTheaters.js +13 -44
- package/dist/services/megabox/tools/getRemainingSeats.js +31 -3
- package/dist/services/megabox/tools/listNowShowing.js +31 -3
- package/dist/services/oliveyoung/api.js +2 -0
- package/dist/services/oliveyoung/client.js +150 -9
- package/dist/services/oliveyoung/index.js +3 -1
- package/dist/services/oliveyoung/tools/checkInventory.js +15 -4
- package/dist/services/oliveyoung/tools/searchProducts.js +57 -0
- package/dist/services/seveneleven/api.js +15 -0
- package/dist/services/seveneleven/client.js +279 -0
- package/dist/services/seveneleven/index.js +30 -0
- package/dist/services/seveneleven/inventory.js +302 -0
- package/dist/services/seveneleven/productKeyword.js +141 -0
- package/dist/services/seveneleven/tools/checkInventory.js +82 -0
- package/dist/services/seveneleven/tools/getCatalogSnapshot.js +55 -0
- package/dist/services/seveneleven/tools/getSearchPopwords.js +41 -0
- package/dist/services/seveneleven/tools/searchProducts.js +56 -0
- package/dist/services/seveneleven/tools/searchStores.js +45 -0
- package/dist/services/seveneleven/types.js +4 -0
- package/dist/utils/cliInteractiveHelpers.js +63 -0
- package/dist/utils/daisoKeyword.js +30 -0
- package/dist/utils/http.js +16 -2
- package/openapi.json +1977 -734
- package/openapi.yaml +1430 -543
- package/package.json +28 -15
- package/dist/tools/checkInventory.js +0 -98
- package/dist/tools/findStores.js +0 -125
- package/dist/tools/getPriceInfo.js +0 -77
- package/dist/tools/searchProducts.js +0 -61
- package/dist/types/index.js +0 -4
package/dist/cliHelp.js
CHANGED
|
@@ -12,6 +12,24 @@ export const COMMAND_LIST = [
|
|
|
12
12
|
'product',
|
|
13
13
|
'stores',
|
|
14
14
|
'inventory',
|
|
15
|
+
'display-location',
|
|
16
|
+
'cu-stores',
|
|
17
|
+
'cu-inventory',
|
|
18
|
+
'lottecinema-theaters',
|
|
19
|
+
'lottecinema-movies',
|
|
20
|
+
'lottecinema-seats',
|
|
21
|
+
'lottemart-stores',
|
|
22
|
+
'lottemart-products',
|
|
23
|
+
'emart24-stores',
|
|
24
|
+
'emart24-products',
|
|
25
|
+
'emart24-inventory',
|
|
26
|
+
'gs25-stores',
|
|
27
|
+
'gs25-products',
|
|
28
|
+
'gs25-inventory',
|
|
29
|
+
'seveneleven-products',
|
|
30
|
+
'seveneleven-stores',
|
|
31
|
+
'seveneleven-popwords',
|
|
32
|
+
'seveneleven-catalog',
|
|
15
33
|
];
|
|
16
34
|
const COMMAND_SUMMARY = {
|
|
17
35
|
help: '도움말 출력',
|
|
@@ -24,6 +42,24 @@ const COMMAND_SUMMARY = {
|
|
|
24
42
|
product: '다이소 제품 상세 조회',
|
|
25
43
|
stores: '다이소 매장 검색',
|
|
26
44
|
inventory: '다이소 재고 조회',
|
|
45
|
+
'display-location': '다이소 진열 위치 조회',
|
|
46
|
+
'cu-stores': 'CU 매장 검색',
|
|
47
|
+
'cu-inventory': 'CU 재고 조회',
|
|
48
|
+
'lottecinema-theaters': '롯데시네마 주변 지점 조회',
|
|
49
|
+
'lottecinema-movies': '롯데시네마 영화/회차 조회',
|
|
50
|
+
'lottecinema-seats': '롯데시네마 잔여 좌석 조회',
|
|
51
|
+
'lottemart-stores': '롯데마트 매장 검색',
|
|
52
|
+
'lottemart-products': '롯데마트 상품 검색',
|
|
53
|
+
'emart24-stores': '이마트24 매장 검색',
|
|
54
|
+
'emart24-products': '이마트24 상품 검색',
|
|
55
|
+
'emart24-inventory': '이마트24 재고 조회',
|
|
56
|
+
'gs25-stores': 'GS25 매장 검색',
|
|
57
|
+
'gs25-products': 'GS25 상품 검색',
|
|
58
|
+
'gs25-inventory': 'GS25 재고 조회',
|
|
59
|
+
'seveneleven-products': '세븐일레븐 상품 검색',
|
|
60
|
+
'seveneleven-stores': '세븐일레븐 매장 검색',
|
|
61
|
+
'seveneleven-popwords': '세븐일레븐 인기 검색어 조회',
|
|
62
|
+
'seveneleven-catalog': '세븐일레븐 카탈로그 스냅샷 조회',
|
|
27
63
|
};
|
|
28
64
|
const COMMAND_DETAIL = {
|
|
29
65
|
help: [
|
|
@@ -59,48 +95,201 @@ const COMMAND_DETAIL = {
|
|
|
59
95
|
get: [
|
|
60
96
|
'명령: get',
|
|
61
97
|
'설명: 임의 API 경로를 GET으로 호출합니다.',
|
|
62
|
-
'사용법: daiso get <path|url> [--queryKey value ...]',
|
|
98
|
+
'사용법: daiso get <path|url> [--queryKey value ...] [--json]',
|
|
63
99
|
'필수: <path|url>',
|
|
100
|
+
'옵션: --json 원본 JSON 출력',
|
|
64
101
|
'예시: daiso get /api/cgv/movies --playDate 20260307 --theaterCode 0056',
|
|
65
102
|
],
|
|
66
103
|
products: [
|
|
67
104
|
'명령: products',
|
|
68
105
|
'설명: 다이소 제품 검색 API를 호출합니다.',
|
|
69
|
-
'사용법: daiso products <query> [--page N] [--pageSize N]',
|
|
106
|
+
'사용법: daiso products <query> [--page N] [--pageSize N] [--json]',
|
|
70
107
|
'필수: <query>',
|
|
71
|
-
'옵션: --page, --pageSize',
|
|
108
|
+
'옵션: --page, --pageSize, --json',
|
|
72
109
|
'예시: daiso products 수납박스 --page 1 --pageSize 30',
|
|
73
110
|
],
|
|
74
111
|
product: [
|
|
75
112
|
'명령: product',
|
|
76
113
|
'설명: 다이소 제품 상세 API를 호출합니다.',
|
|
77
|
-
'사용법: daiso product <productId>',
|
|
114
|
+
'사용법: daiso product <productId> [--json]',
|
|
78
115
|
'필수: <productId>',
|
|
116
|
+
'옵션: --json',
|
|
79
117
|
'예시: daiso product 1034604',
|
|
80
118
|
],
|
|
81
119
|
stores: [
|
|
82
120
|
'명령: stores',
|
|
83
121
|
'설명: 다이소 매장 검색 API를 호출합니다.',
|
|
84
|
-
'사용법: daiso stores [keyword] [--sido 값] [--gugun 값] [--dong 값] [--limit N]',
|
|
122
|
+
'사용법: daiso stores [keyword] [--sido 값] [--gugun 값] [--dong 값] [--limit N] [--json]',
|
|
85
123
|
'필수: keyword 또는 --sido',
|
|
86
|
-
'옵션: --keyword, --sido, --gugun, --dong, --limit',
|
|
124
|
+
'옵션: --keyword, --sido, --gugun, --dong, --limit, --json',
|
|
87
125
|
'예시: daiso stores 강남역',
|
|
88
126
|
'예시: daiso stores --sido 서울 --gugun 강남구',
|
|
89
127
|
],
|
|
90
128
|
inventory: [
|
|
91
129
|
'명령: inventory',
|
|
92
130
|
'설명: 다이소 재고 API를 호출합니다.',
|
|
93
|
-
'사용법: daiso inventory <productId> [--keyword 값] [--lat 값] [--lng 값] [--page N] [--pageSize N]',
|
|
131
|
+
'사용법: daiso inventory <productId> [--keyword 값] [--lat 값] [--lng 값] [--page N] [--pageSize N] [--json]',
|
|
94
132
|
'필수: <productId>',
|
|
95
|
-
'옵션: --keyword, --lat, --lng, --page, --pageSize',
|
|
133
|
+
'옵션: --keyword, --lat, --lng, --page, --pageSize, --json',
|
|
96
134
|
'예시: daiso inventory 1034604 --keyword 강남역',
|
|
97
135
|
],
|
|
136
|
+
'display-location': [
|
|
137
|
+
'명령: display-location',
|
|
138
|
+
'설명: 다이소 매장 내 상품 진열 위치 API를 호출합니다.',
|
|
139
|
+
'사용법: daiso display-location <productId> <storeCode> [--json]',
|
|
140
|
+
'필수: <productId>, <storeCode>',
|
|
141
|
+
'옵션: --json',
|
|
142
|
+
'예시: daiso display-location 1034604 04515',
|
|
143
|
+
],
|
|
144
|
+
'cu-stores': [
|
|
145
|
+
'명령: cu-stores',
|
|
146
|
+
'설명: CU 매장 검색 API를 호출합니다.',
|
|
147
|
+
'사용법: daiso cu-stores [keyword] [--lat 값] [--lng 값] [--limit N] [--json]',
|
|
148
|
+
'옵션: --keyword, --lat, --lng, --limit, --json',
|
|
149
|
+
'예시: daiso cu-stores 강남',
|
|
150
|
+
'예시: daiso cu-stores --lat 37.498 --lng 127.027 --limit 10',
|
|
151
|
+
],
|
|
152
|
+
'cu-inventory': [
|
|
153
|
+
'명령: cu-inventory',
|
|
154
|
+
'설명: CU 재고 검색 API를 호출합니다.',
|
|
155
|
+
'사용법: daiso cu-inventory <keyword> [--storeKeyword 값] [--lat 값] [--lng 값] [--size N] [--offset N] [--json]',
|
|
156
|
+
'필수: <keyword>',
|
|
157
|
+
'옵션: --storeKeyword, --lat, --lng, --size, --offset, --searchSort, --storeLimit, --json',
|
|
158
|
+
'예시: daiso cu-inventory 과자',
|
|
159
|
+
'예시: daiso cu-inventory 컵라면 --storeKeyword 강남 --size 10',
|
|
160
|
+
],
|
|
161
|
+
'lottecinema-theaters': [
|
|
162
|
+
'명령: lottecinema-theaters',
|
|
163
|
+
'설명: 롯데시네마 주변 지점 API를 호출합니다.',
|
|
164
|
+
'사용법: daiso lottecinema-theaters [keyword] [--lat 값] [--lng 값] [--playDate YYYYMMDD] [--limit N] [--json]',
|
|
165
|
+
'옵션: --keyword, --lat, --lng, --playDate, --limit, --json',
|
|
166
|
+
'예시: daiso lottecinema-theaters 잠실 --limit 5',
|
|
167
|
+
'예시: daiso lottecinema-theaters --keyword "안산 중앙역" --limit 5',
|
|
168
|
+
],
|
|
169
|
+
'lottecinema-movies': [
|
|
170
|
+
'명령: lottecinema-movies',
|
|
171
|
+
'설명: 롯데시네마 영화/회차 API를 호출합니다.',
|
|
172
|
+
'사용법: daiso lottecinema-movies [keyword] [--playDate YYYYMMDD] [--theaterId 값] [--movieId 값] [--lat 값] [--lng 값] [--json]',
|
|
173
|
+
'옵션: --playDate, --theaterId, --movieId, --keyword, --lat, --lng, --json',
|
|
174
|
+
'예시: daiso lottecinema-movies 잠실 --playDate 20260310',
|
|
175
|
+
'예시: daiso lottecinema-movies --playDate 20260310 --keyword "안산 중앙역"',
|
|
176
|
+
],
|
|
177
|
+
'lottecinema-seats': [
|
|
178
|
+
'명령: lottecinema-seats',
|
|
179
|
+
'설명: 롯데시네마 잔여 좌석 API를 호출합니다.',
|
|
180
|
+
'사용법: daiso lottecinema-seats [keyword] [--playDate YYYYMMDD] [--theaterId 값] [--movieId 값] [--lat 값] [--lng 값] [--limit N] [--json]',
|
|
181
|
+
'옵션: --playDate, --theaterId, --movieId, --keyword, --lat, --lng, --limit, --json',
|
|
182
|
+
'예시: daiso lottecinema-seats 잠실 --playDate 20260310 --movieId 23816',
|
|
183
|
+
'예시: daiso lottecinema-seats --playDate 20260310 --keyword "안산 중앙역" --movieId 23816',
|
|
184
|
+
],
|
|
185
|
+
'lottemart-stores': [
|
|
186
|
+
'명령: lottemart-stores',
|
|
187
|
+
'설명: 롯데마트 계열 매장 검색 API를 호출합니다.',
|
|
188
|
+
'사용법: daiso lottemart-stores [keyword] [--area 값] [--brandVariant 값] [--lat 값] [--lng 값] [--limit N] [--json]',
|
|
189
|
+
'옵션: --keyword, --area, --brandVariant, --lat, --lng, --limit, --json',
|
|
190
|
+
'예시: daiso lottemart-stores 잠실 --area 서울',
|
|
191
|
+
'예시: daiso lottemart-stores --area 경기 --brandVariant lottemart --limit 10',
|
|
192
|
+
],
|
|
193
|
+
'lottemart-products': [
|
|
194
|
+
'명령: lottemart-products',
|
|
195
|
+
'설명: 롯데마트 매장 기준 상품 검색 API를 호출합니다.',
|
|
196
|
+
'사용법: daiso lottemart-products <keyword> [--storeCode 값 | --storeName 값] [--area 값] [--pageLimit N] [--json]',
|
|
197
|
+
'필수: <keyword>, --storeCode 또는 --storeName',
|
|
198
|
+
'옵션: --storeCode, --storeName, --area, --pageLimit, --json',
|
|
199
|
+
'예시: daiso lottemart-products 콜라 --storeName 강변점 --area 서울',
|
|
200
|
+
'예시: daiso lottemart-products 우유 --storeCode 2301 --pageLimit 2',
|
|
201
|
+
],
|
|
202
|
+
'emart24-stores': [
|
|
203
|
+
'명령: emart24-stores',
|
|
204
|
+
'설명: 이마트24 매장 검색 API를 호출합니다.',
|
|
205
|
+
'사용법: daiso emart24-stores [keyword] [--area1 값] [--area2 값] [--lat 값] [--lng 값] [--service24h true|false] [--limit N] [--json]',
|
|
206
|
+
'옵션: --keyword, --area1, --area2, --lat, --lng, --service24h, --limit, --json',
|
|
207
|
+
'예시: daiso emart24-stores 강남',
|
|
208
|
+
'예시: daiso emart24-stores --area1 서울특별시 --area2 강남구 --service24h true',
|
|
209
|
+
],
|
|
210
|
+
'emart24-products': [
|
|
211
|
+
'명령: emart24-products',
|
|
212
|
+
'설명: 이마트24 상품 검색 API를 호출합니다.',
|
|
213
|
+
'사용법: daiso emart24-products <keyword> [--page N] [--pageSize N] [--sortType 값] [--saleProductYn Y|N] [--json]',
|
|
214
|
+
'필수: <keyword>',
|
|
215
|
+
'옵션: --page, --pageSize, --sortType, --saleProductYn, --json',
|
|
216
|
+
'예시: daiso emart24-products 두바이',
|
|
217
|
+
'예시: daiso emart24-products 도시락 --page 2 --pageSize 20',
|
|
218
|
+
],
|
|
219
|
+
'emart24-inventory': [
|
|
220
|
+
'명령: emart24-inventory',
|
|
221
|
+
'설명: 이마트24 매장별 재고 API를 호출합니다.',
|
|
222
|
+
'사용법: daiso emart24-inventory <pluCd> --bizNoArr 코드1,코드2 [--json]',
|
|
223
|
+
'필수: <pluCd>, --bizNoArr',
|
|
224
|
+
'옵션: --bizNoArr, --json',
|
|
225
|
+
'예시: daiso emart24-inventory 8800244010504 --bizNoArr 28339,05015,23233',
|
|
226
|
+
],
|
|
227
|
+
'gs25-stores': [
|
|
228
|
+
'명령: gs25-stores',
|
|
229
|
+
'설명: GS25 매장 검색 API를 호출합니다.',
|
|
230
|
+
'사용법: daiso gs25-stores [keyword] [--lat 값] [--lng 값] [--limit N] [--json]',
|
|
231
|
+
'옵션: --keyword, --lat, --lng, --serviceCode, --limit, --json',
|
|
232
|
+
'예시: daiso gs25-stores 강남',
|
|
233
|
+
'예시: daiso gs25-stores --lat 37.4982 --lng 127.0276 --limit 10',
|
|
234
|
+
],
|
|
235
|
+
'gs25-products': [
|
|
236
|
+
'명령: gs25-products',
|
|
237
|
+
'설명: GS25 상품 키워드 검색 API를 호출합니다.',
|
|
238
|
+
'사용법: daiso gs25-products <keyword> [--limit N] [--json]',
|
|
239
|
+
'필수: <keyword>',
|
|
240
|
+
'옵션: --serviceCode, --limit, --json',
|
|
241
|
+
'예시: daiso gs25-products 오감자',
|
|
242
|
+
],
|
|
243
|
+
'gs25-inventory': [
|
|
244
|
+
'명령: gs25-inventory',
|
|
245
|
+
'설명: GS25 재고 검색 API를 호출합니다.',
|
|
246
|
+
'사용법: daiso gs25-inventory <keyword> [--storeKeyword 값] [--lat 값] [--lng 값] [--storeLimit N] [--json]',
|
|
247
|
+
'필수: <keyword>',
|
|
248
|
+
'옵션: --storeKeyword, --lat, --lng, --serviceCode, --storeLimit, --json',
|
|
249
|
+
'예시: daiso gs25-inventory 오감자 --storeKeyword 강남',
|
|
250
|
+
],
|
|
251
|
+
'seveneleven-products': [
|
|
252
|
+
'명령: seveneleven-products',
|
|
253
|
+
'설명: 세븐일레븐 상품 검색 API를 호출합니다.',
|
|
254
|
+
'사용법: daiso seveneleven-products <query> [--page N] [--size N] [--sort 값] [--json]',
|
|
255
|
+
'필수: <query>',
|
|
256
|
+
'옵션: --page, --size, --sort, --json',
|
|
257
|
+
'예시: daiso seveneleven-products 삼각김밥 --size 20',
|
|
258
|
+
],
|
|
259
|
+
'seveneleven-stores': [
|
|
260
|
+
'명령: seveneleven-stores',
|
|
261
|
+
'설명: 세븐일레븐 매장 검색 API를 호출합니다.',
|
|
262
|
+
'사용법: daiso seveneleven-stores <keyword> [--limit N] [--json]',
|
|
263
|
+
'필수: <keyword>',
|
|
264
|
+
'옵션: --limit, --json',
|
|
265
|
+
'예시: daiso seveneleven-stores 안산 중앙역 --limit 10',
|
|
266
|
+
],
|
|
267
|
+
'seveneleven-popwords': [
|
|
268
|
+
'명령: seveneleven-popwords',
|
|
269
|
+
'설명: 세븐일레븐 인기 검색어 API를 호출합니다.',
|
|
270
|
+
'사용법: daiso seveneleven-popwords [--label 값] [--json]',
|
|
271
|
+
'옵션: --label, --json',
|
|
272
|
+
'예시: daiso seveneleven-popwords --label home',
|
|
273
|
+
],
|
|
274
|
+
'seveneleven-catalog': [
|
|
275
|
+
'명령: seveneleven-catalog',
|
|
276
|
+
'설명: 세븐일레븐 카탈로그 스냅샷 API를 호출합니다.',
|
|
277
|
+
'사용법: daiso seveneleven-catalog [--includeIssues true|false] [--includeExhibition true|false] [--limit N] [--json]',
|
|
278
|
+
'옵션: --includeIssues, --includeExhibition, --limit, --json',
|
|
279
|
+
'예시: daiso seveneleven-catalog --includeIssues true --includeExhibition true --limit 10',
|
|
280
|
+
],
|
|
98
281
|
};
|
|
99
282
|
export function printHelp(writeOut) {
|
|
100
283
|
writeOut('daiso CLI');
|
|
101
284
|
writeOut('');
|
|
285
|
+
writeOut('기본 실행:');
|
|
286
|
+
writeOut(' npx daiso (인터랙티브 모드)');
|
|
287
|
+
writeOut(' npx daiso --non-interactive (도움말 출력)');
|
|
288
|
+
writeOut('');
|
|
102
289
|
writeOut('사용법:');
|
|
103
290
|
writeOut(' daiso <command> [options]');
|
|
291
|
+
writeOut('전역 옵션:');
|
|
292
|
+
writeOut(' --non-interactive 인터랙티브 진입 비활성화');
|
|
104
293
|
writeOut('');
|
|
105
294
|
writeOut('명령어:');
|
|
106
295
|
for (const command of COMMAND_LIST) {
|
|
@@ -114,6 +303,24 @@ export function printHelp(writeOut) {
|
|
|
114
303
|
writeOut(' npx daiso products 수납박스');
|
|
115
304
|
writeOut(' npx daiso stores 강남역');
|
|
116
305
|
writeOut(' npx daiso inventory 1034604 --keyword 강남역');
|
|
306
|
+
writeOut(' npx daiso display-location 1034604 04515');
|
|
307
|
+
writeOut(' npx daiso cu-stores 강남');
|
|
308
|
+
writeOut(' npx daiso cu-inventory 과자 --storeKeyword 강남');
|
|
309
|
+
writeOut(' npx daiso lottecinema-theaters --keyword "안산 중앙역" --limit 5');
|
|
310
|
+
writeOut(' npx daiso lottecinema-movies --playDate 20260310 --keyword "안산 중앙역"');
|
|
311
|
+
writeOut(' npx daiso lottecinema-seats --playDate 20260310 --keyword "안산 중앙역" --movieId 23816');
|
|
312
|
+
writeOut(' npx daiso lottemart-stores 잠실 --area 서울 --limit 10');
|
|
313
|
+
writeOut(' npx daiso lottemart-products 콜라 --storeName 강변점 --area 서울');
|
|
314
|
+
writeOut(' npx daiso emart24-stores 강남 --limit 10');
|
|
315
|
+
writeOut(' npx daiso emart24-products 두바이 --pageSize 20');
|
|
316
|
+
writeOut(' npx daiso emart24-inventory 8800244010504 --bizNoArr 28339,05015');
|
|
317
|
+
writeOut(' npx daiso gs25-stores 강남 --limit 10');
|
|
318
|
+
writeOut(' npx daiso gs25-products 오감자');
|
|
319
|
+
writeOut(' npx daiso gs25-inventory 오감자 --storeKeyword 강남');
|
|
320
|
+
writeOut(' npx daiso seveneleven-products 삼각김밥 --size 20');
|
|
321
|
+
writeOut(' npx daiso seveneleven-stores 안산 중앙역 --limit 10');
|
|
322
|
+
writeOut(' npx daiso seveneleven-popwords --label home');
|
|
323
|
+
writeOut(' npx daiso seveneleven-catalog --limit 10');
|
|
117
324
|
writeOut(' npx daiso get /api/cgv/movies --playDate 20260307 --theaterCode 0056');
|
|
118
325
|
writeOut('');
|
|
119
326
|
writeOut('상세 도움말:');
|
|
@@ -122,7 +329,7 @@ export function printHelp(writeOut) {
|
|
|
122
329
|
export function printCommandHelp(command, writeOut, writeErr) {
|
|
123
330
|
if (!Object.hasOwn(COMMAND_DETAIL, command)) {
|
|
124
331
|
writeErr(`도움말을 찾을 수 없는 명령어: ${command}`);
|
|
125
|
-
writeErr('사용 가능한 명령어: help, version, url, health, claude, get, products, product, stores, inventory');
|
|
332
|
+
writeErr('사용 가능한 명령어: help, version, url, health, claude, get, products, product, stores, inventory, display-location, cu-stores, cu-inventory, lottecinema-theaters, lottecinema-movies, lottecinema-seats, lottemart-stores, lottemart-products, emart24-stores, emart24-products, emart24-inventory, gs25-stores, gs25-products, gs25-inventory, seveneleven-products, seveneleven-stores, seveneleven-popwords, seveneleven-catalog');
|
|
126
333
|
return 1;
|
|
127
334
|
}
|
|
128
335
|
const detail = COMMAND_DETAIL[command];
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI 인터랙티브 모드
|
|
3
|
+
*
|
|
4
|
+
* 좌표 입력 없이 서비스/매장/상품을 순차 선택해 재고를 확인합니다.
|
|
5
|
+
*/
|
|
6
|
+
import { createInterface } from 'node:readline/promises';
|
|
7
|
+
import { stdin as input, stdout as output } from 'node:process';
|
|
8
|
+
import { pickFromList } from './cliPicker.js';
|
|
9
|
+
import { fetchEnvelope, fetchStoresWithKeywordFallback } from './cli/interactiveFetch.js';
|
|
10
|
+
import { askMenu, askNextAction, askNonEmpty, askYesNo, printStoreDetail } from './cli/interactivePrompt.js';
|
|
11
|
+
import { parseLotteCinemaTheaters, printTheaterDetail, runCuItemSearch, runDaisoItemSearch, runLotteCinemaSearch, runOliveyoungItemSearch, } from './cli/interactiveItemSearch.js';
|
|
12
|
+
import { buildDaisoStoreKeywordVariants, isRecord, parseDaisoProducts, parseStores, toText } from './utils/cliInteractiveHelpers.js';
|
|
13
|
+
function createPrompt() {
|
|
14
|
+
const rl = createInterface({ input, output });
|
|
15
|
+
return {
|
|
16
|
+
ask: async (question) => {
|
|
17
|
+
const answer = await rl.question(question);
|
|
18
|
+
return answer.trim();
|
|
19
|
+
},
|
|
20
|
+
close: () => {
|
|
21
|
+
rl.close();
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 테스트 전용 내부 헬퍼 노출
|
|
27
|
+
*/
|
|
28
|
+
export const cliInteractiveTestables = {
|
|
29
|
+
isRecord,
|
|
30
|
+
toText,
|
|
31
|
+
buildDaisoStoreKeywordVariants,
|
|
32
|
+
fetchEnvelope,
|
|
33
|
+
fetchStoresWithKeywordFallback,
|
|
34
|
+
parseStores,
|
|
35
|
+
parseDaisoProducts,
|
|
36
|
+
askMenu,
|
|
37
|
+
askYesNo,
|
|
38
|
+
askNonEmpty,
|
|
39
|
+
askNextAction,
|
|
40
|
+
printStoreDetail,
|
|
41
|
+
runDaisoItemSearch,
|
|
42
|
+
runOliveyoungItemSearch,
|
|
43
|
+
runCuItemSearch,
|
|
44
|
+
runLotteCinemaSearch,
|
|
45
|
+
};
|
|
46
|
+
export async function runInteractiveCli(deps) {
|
|
47
|
+
const prompt = deps.createPrompt ? deps.createPrompt() : createPrompt();
|
|
48
|
+
try {
|
|
49
|
+
deps.writeOut('daiso 인터랙티브 모드');
|
|
50
|
+
let keepRunning = true;
|
|
51
|
+
while (keepRunning) {
|
|
52
|
+
deps.writeOut('');
|
|
53
|
+
deps.writeOut('[서비스 선택]');
|
|
54
|
+
deps.writeOut('1. 다이소');
|
|
55
|
+
deps.writeOut('2. 올리브영');
|
|
56
|
+
deps.writeOut('3. CU');
|
|
57
|
+
deps.writeOut('4. 롯데시네마');
|
|
58
|
+
const serviceChoice = await askMenu(prompt, '서비스 번호를 선택하세요 (0: 종료):', [
|
|
59
|
+
'다이소',
|
|
60
|
+
'올리브영',
|
|
61
|
+
'CU',
|
|
62
|
+
'롯데시네마',
|
|
63
|
+
]);
|
|
64
|
+
if (serviceChoice === 0) {
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
if (serviceChoice === 4) {
|
|
68
|
+
const theaterKeyword = await askNonEmpty(prompt, '극장 검색 키워드를 입력하세요: ');
|
|
69
|
+
const payload = await fetchEnvelope(deps.fetchImpl, '/api/lottecinema/theaters', {
|
|
70
|
+
keyword: theaterKeyword,
|
|
71
|
+
limit: '10',
|
|
72
|
+
});
|
|
73
|
+
const theaters = parseLotteCinemaTheaters(payload).filter((entry) => `${entry.name} ${entry.address}`.includes(theaterKeyword));
|
|
74
|
+
if (theaters.length === 0) {
|
|
75
|
+
deps.writeOut('검색된 극장이 없습니다.');
|
|
76
|
+
keepRunning = await askYesNo(prompt, '다시 시도할까요? (y/n): ');
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const selectedTheater = await pickFromList({
|
|
80
|
+
prompt,
|
|
81
|
+
writeOut: deps.writeOut,
|
|
82
|
+
title: '[극장 선택]',
|
|
83
|
+
emptyText: '검색된 극장이 없습니다.',
|
|
84
|
+
cancelText: '극장 검색으로 돌아갑니다.',
|
|
85
|
+
items: theaters,
|
|
86
|
+
renderItem: (theater, index) => `${index + 1}. ${theater.name} | ${theater.address || '주소 정보 없음'} | ${theater.distanceKm}km`,
|
|
87
|
+
filterText: (theater) => `${theater.name} ${theater.address} ${theater.theaterId}`,
|
|
88
|
+
indexText: '입력: 번호 선택 | /키워드 필터 | all 전체보기 | 0 다시 검색',
|
|
89
|
+
});
|
|
90
|
+
if (!selectedTheater) {
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
printTheaterDetail(deps.writeOut, selectedTheater);
|
|
94
|
+
let keepTheaterSearch = true;
|
|
95
|
+
while (keepTheaterSearch) {
|
|
96
|
+
await runLotteCinemaSearch(deps, prompt, selectedTheater);
|
|
97
|
+
const nextAction = await askNextAction(prompt, deps.writeOut);
|
|
98
|
+
if (nextAction === 'same-store') {
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
if (nextAction === 'change-store') {
|
|
102
|
+
keepTheaterSearch = false;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
keepRunning = false;
|
|
106
|
+
keepTheaterSearch = false;
|
|
107
|
+
}
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const service = serviceChoice === 1 ? 'daiso' : serviceChoice === 2 ? 'oliveyoung' : 'cu';
|
|
111
|
+
const storeKeyword = await askNonEmpty(prompt, '매장 검색 키워드를 입력하세요: ');
|
|
112
|
+
const storeResult = await fetchStoresWithKeywordFallback(deps.fetchImpl, service, storeKeyword);
|
|
113
|
+
const stores = storeResult.stores;
|
|
114
|
+
if (service === 'daiso' && stores.length > 0 && storeResult.matchedKeyword !== storeKeyword) {
|
|
115
|
+
deps.writeOut(`입력 키워드 "${storeKeyword}" 대신 "${storeResult.matchedKeyword}"로 매장을 찾았습니다.`);
|
|
116
|
+
}
|
|
117
|
+
if (stores.length === 0) {
|
|
118
|
+
deps.writeOut('검색된 매장이 없습니다.');
|
|
119
|
+
if (service === 'daiso') {
|
|
120
|
+
deps.writeOut('힌트: "안산 중앙역" 대신 "안산중앙" 또는 "고잔"으로 검색해보세요.');
|
|
121
|
+
}
|
|
122
|
+
keepRunning = await askYesNo(prompt, '다시 시도할까요? (y/n): ');
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const selectedStore = await pickFromList({
|
|
126
|
+
prompt,
|
|
127
|
+
writeOut: deps.writeOut,
|
|
128
|
+
title: '[매장 선택]',
|
|
129
|
+
emptyText: '검색된 매장이 없습니다.',
|
|
130
|
+
cancelText: '매장 검색으로 돌아갑니다.',
|
|
131
|
+
items: stores,
|
|
132
|
+
renderItem: (store, index) => `${index + 1}. ${store.name} | ${store.address || '주소 정보 없음'}`,
|
|
133
|
+
filterText: (store) => `${store.name} ${store.address} ${store.phone}`,
|
|
134
|
+
indexText: '입력: 번호 선택 | /키워드 필터 | all 전체보기 | 0 다시 검색',
|
|
135
|
+
});
|
|
136
|
+
if (!selectedStore) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
printStoreDetail(deps.writeOut, selectedStore);
|
|
140
|
+
let keepItemSearch = true;
|
|
141
|
+
while (keepItemSearch) {
|
|
142
|
+
if (service === 'daiso') {
|
|
143
|
+
await runDaisoItemSearch(deps, prompt, selectedStore);
|
|
144
|
+
}
|
|
145
|
+
else if (service === 'oliveyoung') {
|
|
146
|
+
await runOliveyoungItemSearch(deps, prompt, selectedStore);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
await runCuItemSearch(deps, prompt, selectedStore);
|
|
150
|
+
}
|
|
151
|
+
const nextAction = await askNextAction(prompt, deps.writeOut);
|
|
152
|
+
if (nextAction === 'same-store') {
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (nextAction === 'change-store') {
|
|
156
|
+
keepItemSearch = false;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
keepRunning = false;
|
|
160
|
+
keepItemSearch = false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
deps.writeOut('인터랙티브 모드를 종료합니다.');
|
|
164
|
+
return 0;
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
168
|
+
deps.writeErr(`인터랙티브 실행 중 오류 발생: ${message}`);
|
|
169
|
+
return 1;
|
|
170
|
+
}
|
|
171
|
+
finally {
|
|
172
|
+
prompt.close();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 인터랙티브 목록 선택 유틸리티
|
|
3
|
+
*
|
|
4
|
+
* 번호 선택, /키워드 필터, all(전체 복원), 0(취소)을 지원합니다.
|
|
5
|
+
*/
|
|
6
|
+
function normalize(value) {
|
|
7
|
+
return value.toLowerCase();
|
|
8
|
+
}
|
|
9
|
+
function defaultFilterText(item) {
|
|
10
|
+
return typeof item === 'string' ? item : JSON.stringify(item);
|
|
11
|
+
}
|
|
12
|
+
export async function pickFromList(options) {
|
|
13
|
+
const { prompt, writeOut, title, emptyText, cancelText, items, renderItem, indexText = '입력: 번호 선택 | /키워드 필터 | all 전체보기 | 0 취소', filterText = defaultFilterText, } = options;
|
|
14
|
+
if (items.length === 0) {
|
|
15
|
+
writeOut(emptyText);
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
let visibleItems = items;
|
|
19
|
+
while (true) {
|
|
20
|
+
writeOut('');
|
|
21
|
+
writeOut(title);
|
|
22
|
+
for (let i = 0; i < visibleItems.length; i += 1) {
|
|
23
|
+
writeOut(renderItem(visibleItems[i], i));
|
|
24
|
+
}
|
|
25
|
+
writeOut(indexText);
|
|
26
|
+
const answer = await prompt.ask('선택: ');
|
|
27
|
+
if (answer === '0') {
|
|
28
|
+
writeOut(cancelText);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
if (answer === 'all') {
|
|
32
|
+
visibleItems = items;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (answer.startsWith('/')) {
|
|
36
|
+
const query = answer.slice(1).trim();
|
|
37
|
+
if (!query) {
|
|
38
|
+
visibleItems = items;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const needle = normalize(query);
|
|
42
|
+
const filtered = items.filter((item) => normalize(filterText(item)).includes(needle));
|
|
43
|
+
if (filtered.length === 0) {
|
|
44
|
+
writeOut(`"${query}" 검색 결과가 없습니다.`);
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
visibleItems = filtered;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const picked = Number.parseInt(answer, 10);
|
|
51
|
+
if (Number.isNaN(picked) || picked < 1 || picked > visibleItems.length) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
return visibleItems[picked - 1];
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI 응답 렌더러
|
|
3
|
+
*/
|
|
4
|
+
function isRecord(value) {
|
|
5
|
+
return typeof value === 'object' && value !== null;
|
|
6
|
+
}
|
|
7
|
+
function toText(value) {
|
|
8
|
+
if (value === null || value === undefined) {
|
|
9
|
+
return '-';
|
|
10
|
+
}
|
|
11
|
+
if (typeof value === 'string') {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
15
|
+
return String(value);
|
|
16
|
+
}
|
|
17
|
+
return JSON.stringify(value);
|
|
18
|
+
}
|
|
19
|
+
function formatMeta(meta) {
|
|
20
|
+
if (!isRecord(meta)) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
const pairs = Object.entries(meta)
|
|
24
|
+
.filter(([, value]) => typeof value === 'string' || typeof value === 'number')
|
|
25
|
+
.map(([key, value]) => `${key}=${value}`);
|
|
26
|
+
if (pairs.length === 0) {
|
|
27
|
+
return [];
|
|
28
|
+
}
|
|
29
|
+
return [`메타: ${pairs.join(', ')}`];
|
|
30
|
+
}
|
|
31
|
+
function detectName(item) {
|
|
32
|
+
const keys = ['name', 'productName', 'storeName', 'theaterName', 'movieName'];
|
|
33
|
+
for (const key of keys) {
|
|
34
|
+
if (typeof item[key] === 'string' && item[key].trim().length > 0) {
|
|
35
|
+
return item[key];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return '이름 없음';
|
|
39
|
+
}
|
|
40
|
+
function formatCollection(title, items) {
|
|
41
|
+
if (!Array.isArray(items)) {
|
|
42
|
+
return [];
|
|
43
|
+
}
|
|
44
|
+
const lines = [`${title}: ${items.length}건`];
|
|
45
|
+
const preview = items.slice(0, 5);
|
|
46
|
+
for (const entry of preview) {
|
|
47
|
+
if (!isRecord(entry)) {
|
|
48
|
+
lines.push(`- ${toText(entry)}`);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const name = detectName(entry);
|
|
52
|
+
const id = entry.id ?? entry.productId ?? entry.PD_NO ?? entry.storeCode ?? entry.theaterId ?? entry.movieId;
|
|
53
|
+
const price = entry.price ?? entry.prc ?? entry.PD_PRC;
|
|
54
|
+
let detail = `- ${name}`;
|
|
55
|
+
if (id !== undefined) {
|
|
56
|
+
detail += ` [${toText(id)}]`;
|
|
57
|
+
}
|
|
58
|
+
if (price !== undefined) {
|
|
59
|
+
detail += ` / ${toText(price)}원`;
|
|
60
|
+
}
|
|
61
|
+
lines.push(detail);
|
|
62
|
+
}
|
|
63
|
+
if (items.length > preview.length) {
|
|
64
|
+
lines.push(`...외 ${items.length - preview.length}건`);
|
|
65
|
+
}
|
|
66
|
+
return lines;
|
|
67
|
+
}
|
|
68
|
+
function formatProductDetail(data) {
|
|
69
|
+
const id = data.id ?? data.productId ?? '-';
|
|
70
|
+
const name = data.name ?? data.productName ?? '-';
|
|
71
|
+
const price = data.price ?? '-';
|
|
72
|
+
const soldOut = data.soldOut;
|
|
73
|
+
const lines = [`제품 상세: ${toText(name)} (${toText(id)})`, `가격: ${toText(price)}원`];
|
|
74
|
+
if (typeof soldOut === 'boolean') {
|
|
75
|
+
lines.push(`품절 여부: ${soldOut ? '품절' : '재고 있음'}`);
|
|
76
|
+
}
|
|
77
|
+
return lines;
|
|
78
|
+
}
|
|
79
|
+
function formatInventory(data) {
|
|
80
|
+
const lines = [];
|
|
81
|
+
const onlineStock = data.onlineStock;
|
|
82
|
+
if (onlineStock !== undefined) {
|
|
83
|
+
lines.push(`온라인 재고: ${toText(onlineStock)}`);
|
|
84
|
+
}
|
|
85
|
+
const storeInventory = data.storeInventory;
|
|
86
|
+
if (isRecord(storeInventory)) {
|
|
87
|
+
const total = storeInventory.totalStores;
|
|
88
|
+
const inStock = storeInventory.inStockCount;
|
|
89
|
+
lines.push(`매장 재고: 재고보유 ${toText(inStock)} / 전체 ${toText(total)}`);
|
|
90
|
+
lines.push(...formatCollection('매장 목록', storeInventory.stores));
|
|
91
|
+
}
|
|
92
|
+
return lines;
|
|
93
|
+
}
|
|
94
|
+
export function renderApiEnvelope(command, url, payload) {
|
|
95
|
+
if (!isRecord(payload)) {
|
|
96
|
+
return `요청 성공: ${url.pathname}\n${toText(payload)}\n\n원본 JSON은 --json 옵션으로 확인하세요.`;
|
|
97
|
+
}
|
|
98
|
+
const envelope = payload;
|
|
99
|
+
if (envelope.success !== true) {
|
|
100
|
+
return JSON.stringify(payload, null, 2);
|
|
101
|
+
}
|
|
102
|
+
const lines = [`요청 성공: ${url.pathname}`];
|
|
103
|
+
lines.push(...formatMeta(envelope.meta));
|
|
104
|
+
if (!isRecord(envelope.data)) {
|
|
105
|
+
lines.push(`응답 데이터: ${toText(envelope.data)}`);
|
|
106
|
+
lines.push('', '원본 JSON은 --json 옵션으로 확인하세요.');
|
|
107
|
+
return lines.join('\n');
|
|
108
|
+
}
|
|
109
|
+
const data = envelope.data;
|
|
110
|
+
if (command === 'product') {
|
|
111
|
+
lines.push(...formatProductDetail(data));
|
|
112
|
+
}
|
|
113
|
+
else if (command === 'inventory') {
|
|
114
|
+
lines.push(...formatInventory(data));
|
|
115
|
+
}
|
|
116
|
+
else if (command === 'cu-inventory') {
|
|
117
|
+
lines.push(...formatCollection('매장 목록', isRecord(data.nearbyStores) ? data.nearbyStores.stores : undefined));
|
|
118
|
+
lines.push(...formatCollection('재고 항목', isRecord(data.inventory) ? data.inventory.items : undefined));
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
lines.push(...formatCollection('제품 목록', data.products));
|
|
122
|
+
lines.push(...formatCollection('매장 목록', data.stores));
|
|
123
|
+
lines.push(...formatCollection('극장 목록', data.theaters));
|
|
124
|
+
lines.push(...formatCollection('영화 목록', data.movies));
|
|
125
|
+
lines.push(...formatCollection('시간표', data.timetable));
|
|
126
|
+
lines.push(...formatCollection('좌석 목록', data.seats));
|
|
127
|
+
lines.push(...formatCollection('상영 목록', data.showtimes));
|
|
128
|
+
if (lines.length <= 2) {
|
|
129
|
+
const summaryEntries = Object.entries(data)
|
|
130
|
+
.filter(([, value]) => typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean')
|
|
131
|
+
.slice(0, 8);
|
|
132
|
+
for (const [key, value] of summaryEntries) {
|
|
133
|
+
lines.push(`${key}: ${toText(value)}`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
lines.push('', '원본 JSON은 --json 옵션으로 확인하세요.');
|
|
138
|
+
return lines.join('\n');
|
|
139
|
+
}
|