daiso 1.0.9 → 1.1.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.
Files changed (86) hide show
  1. package/README.md +88 -9
  2. package/dist/api/actionsProxy.js +3 -0
  3. package/dist/api/cgvHandlers.js +15 -3
  4. package/dist/api/configStatus.js +1 -1
  5. package/dist/api/dtryxHandlers.js +113 -0
  6. package/dist/api/emart24Handlers.js +6 -2
  7. package/dist/api/gs25Handlers.js +22 -19
  8. package/dist/api/handlers.js +3 -0
  9. package/dist/api/healthCheckDefinitions.js +56 -8
  10. package/dist/api/healthCheckShape.js +24 -8
  11. package/dist/api/healthChecks.js +48 -20
  12. package/dist/api/operationalAuth.js +32 -0
  13. package/dist/api/routes/dtryxRoutes.js +22 -0
  14. package/dist/api/routes/healthRoutes.js +19 -11
  15. package/dist/api/routes/rateLimitStatsRoutes.js +274 -0
  16. package/dist/api/routes/registerServiceRoutes.js +37 -0
  17. package/dist/api/sevenelevenHandlers.js +7 -3
  18. package/dist/cli/commandOptions.js +24 -0
  19. package/dist/cli/commands/cinema.js +27 -0
  20. package/dist/cli/commands/convenience.js +2 -2
  21. package/dist/cli.js +7 -1
  22. package/dist/cliHelp.js +3 -337
  23. package/dist/cliHelpDefinitions.js +369 -0
  24. package/dist/cliInteractive.js +8 -5
  25. package/dist/core/errors.js +17 -2
  26. package/dist/core/registry.js +13 -15
  27. package/dist/durableObjects/dailyRateLimiter.js +185 -0
  28. package/dist/durableObjects/rateLimitMetricsStore.js +144 -0
  29. package/dist/index.js +16 -30
  30. package/dist/middleware/dailyRateLimit.js +176 -0
  31. package/dist/pages/openapiFullSpec.js +2 -0
  32. package/dist/pages/openapiSpecActionParameters.js +429 -0
  33. package/dist/pages/openapiSpecActions.js +1 -391
  34. package/dist/pages/openapiSpecComponentsLottecinema.js +2 -2
  35. package/dist/pages/openapiSpecPathsDtryx.js +148 -0
  36. package/dist/pages/openapiSpecPathsLotteMart.js +10 -2
  37. package/dist/pages/promptRetailCinemaText.js +9 -1
  38. package/dist/services/cgv/client.js +7 -4
  39. package/dist/services/cgv/errors.js +12 -0
  40. package/dist/services/cgv/transport.js +19 -2
  41. package/dist/services/cu/client.js +42 -12
  42. package/dist/services/cu/index.js +13 -3
  43. package/dist/services/cu/tools/checkInventory.js +65 -45
  44. package/dist/services/cu/tools/findNearbyStores.js +4 -3
  45. package/dist/services/cu/upstreamError.js +15 -0
  46. package/dist/services/dtryx/api.js +25 -0
  47. package/dist/services/dtryx/client.js +133 -0
  48. package/dist/services/dtryx/index.js +24 -0
  49. package/dist/services/dtryx/location.js +216 -0
  50. package/dist/services/dtryx/tools/getRemainingSeats.js +117 -0
  51. package/dist/services/dtryx/tools/listCinemas.js +46 -0
  52. package/dist/services/dtryx/tools/listNowShowing.js +77 -0
  53. package/dist/services/dtryx/types.js +4 -0
  54. package/dist/services/dtryx/validation.js +21 -0
  55. package/dist/services/emart24/tools/searchProducts.js +37 -19
  56. package/dist/services/feedback/tools/submitDeveloperRequest.js +15 -1
  57. package/dist/services/gs25/api.js +2 -2
  58. package/dist/services/gs25/client.js +16 -123
  59. package/dist/services/gs25/errors.js +12 -0
  60. package/dist/services/gs25/index.js +2 -2
  61. package/dist/services/gs25/productSearch.js +1 -0
  62. package/dist/services/gs25/storeStockTransport.js +55 -0
  63. package/dist/services/gs25/tools/checkInventory.js +7 -2
  64. package/dist/services/gs25/tools/findNearbyStores.js +20 -5
  65. package/dist/services/lottecinema/client.js +4 -2
  66. package/dist/services/lottemart/config.js +1 -1
  67. package/dist/services/lottemart/session.js +29 -160
  68. package/dist/services/lottemart/socketTransport.js +149 -0
  69. package/dist/services/oliveyoung/client.js +1 -0
  70. package/dist/services/places/client.js +29 -8
  71. package/dist/services/seveneleven/client.js +18 -8
  72. package/dist/services/seveneleven/index.js +11 -7
  73. package/dist/services/seveneleven/inventory.js +5 -2
  74. package/dist/services/seveneleven/productKeyword.js +3 -2
  75. package/dist/services/seveneleven/tools/checkInventory.js +4 -3
  76. package/dist/services/seveneleven/tools/getCatalogSnapshot.js +4 -3
  77. package/dist/services/seveneleven/tools/getSearchPopwords.js +4 -3
  78. package/dist/services/seveneleven/tools/searchProducts.js +40 -20
  79. package/dist/services/seveneleven/tools/searchStores.js +4 -3
  80. package/dist/utils/format.js +10 -3
  81. package/dist/utils/http.js +38 -10
  82. package/dist/utils/zyte.js +13 -2
  83. package/dist/utils/zyteJsonFallback.js +67 -0
  84. package/openapi.json +51 -3
  85. package/openapi.yaml +36 -3
  86. package/package.json +28 -24
@@ -0,0 +1,369 @@
1
+ /**
2
+ * CLI 도움말 정의
3
+ */
4
+ export const COMMAND_LIST = [
5
+ 'help',
6
+ 'version',
7
+ 'url',
8
+ 'health',
9
+ 'claude',
10
+ 'get',
11
+ 'products',
12
+ 'product',
13
+ 'stores',
14
+ 'inventory',
15
+ 'display-location',
16
+ 'compare',
17
+ 'places',
18
+ 'cu-stores',
19
+ 'cu-inventory',
20
+ 'cgv-theaters',
21
+ 'cgv-movies',
22
+ 'cgv-timetable',
23
+ 'lottecinema-theaters',
24
+ 'lottecinema-movies',
25
+ 'lottecinema-seats',
26
+ 'megabox-theaters',
27
+ 'megabox-movies',
28
+ 'megabox-seats',
29
+ 'lottemart-stores',
30
+ 'lottemart-products',
31
+ 'emart24-stores',
32
+ 'emart24-products',
33
+ 'emart24-inventory',
34
+ 'gs25-stores',
35
+ 'gs25-products',
36
+ 'gs25-inventory',
37
+ 'seveneleven-products',
38
+ 'seveneleven-stores',
39
+ 'seveneleven-inventory',
40
+ 'seveneleven-popwords',
41
+ 'seveneleven-catalog',
42
+ ];
43
+ export const COMMAND_SUMMARY = {
44
+ help: '도움말 출력',
45
+ version: 'CLI 버전 출력',
46
+ url: 'MCP 엔드포인트 URL 출력',
47
+ health: '원격 서버 상태 확인',
48
+ claude: 'Claude Code MCP 등록 명령 출력/실행',
49
+ get: '임의 API 경로 GET 호출',
50
+ products: '다이소 제품 검색',
51
+ product: '다이소 제품 상세 조회',
52
+ stores: '다이소 매장 검색',
53
+ inventory: '다이소 재고 조회',
54
+ 'display-location': '다이소 진열 위치 조회',
55
+ compare: '키 없는 통합 상품 가격 후보 비교',
56
+ places: '음식점/카페 등 주변 장소 검색',
57
+ 'cu-stores': 'CU 매장 검색',
58
+ 'cu-inventory': 'CU 재고 조회',
59
+ 'cgv-theaters': 'CGV 극장 검색',
60
+ 'cgv-movies': 'CGV 영화 검색',
61
+ 'cgv-timetable': 'CGV 시간표 조회',
62
+ 'lottecinema-theaters': '롯데시네마 주변 지점 조회',
63
+ 'lottecinema-movies': '롯데시네마 영화/회차 조회',
64
+ 'lottecinema-seats': '롯데시네마 잔여 좌석 조회',
65
+ 'megabox-theaters': '메가박스 주변 지점 조회',
66
+ 'megabox-movies': '메가박스 영화/회차 조회',
67
+ 'megabox-seats': '메가박스 잔여 좌석 조회',
68
+ 'lottemart-stores': '롯데마트 매장 검색',
69
+ 'lottemart-products': '롯데마트 상품 검색',
70
+ 'emart24-stores': '이마트24 매장 검색',
71
+ 'emart24-products': '이마트24 상품 검색',
72
+ 'emart24-inventory': '이마트24 재고 조회',
73
+ 'gs25-stores': 'GS25 매장 검색',
74
+ 'gs25-products': 'GS25 상품 검색',
75
+ 'gs25-inventory': 'GS25 재고 조회',
76
+ 'seveneleven-products': '세븐일레븐 상품 검색',
77
+ 'seveneleven-stores': '세븐일레븐 매장 검색',
78
+ 'seveneleven-inventory': '세븐일레븐 재고 조회',
79
+ 'seveneleven-popwords': '세븐일레븐 인기 검색어 조회',
80
+ 'seveneleven-catalog': '세븐일레븐 카탈로그 스냅샷 조회',
81
+ };
82
+ export const COMMAND_DETAIL = {
83
+ help: [
84
+ '명령: help',
85
+ '설명: 전체 도움말 또는 특정 명령 상세 도움말을 출력합니다.',
86
+ '사용법: daiso help [command]',
87
+ '예시: daiso help products',
88
+ ],
89
+ version: ['명령: version', '설명: 설치된 daiso CLI 버전을 출력합니다.', '사용법: daiso version'],
90
+ url: [
91
+ '명령: url',
92
+ '설명: MCP 엔드포인트 URL을 출력합니다.',
93
+ '사용법: daiso url',
94
+ '출력 예시: https://mcp.aka.page/mcp',
95
+ ],
96
+ health: [
97
+ '명령: health',
98
+ '설명: 서버 /health API를 호출해 상태를 확인합니다.',
99
+ '사용법: daiso health',
100
+ '출력: status, endpoint, checkedAt(JSON)',
101
+ ],
102
+ claude: [
103
+ '명령: claude',
104
+ '설명: Claude Code MCP 등록 명령을 출력하거나 실행합니다.',
105
+ '사용법: daiso claude [--exec]',
106
+ '옵션: --exec 실제 claude 명령 실행',
107
+ '예시: daiso claude --exec',
108
+ ],
109
+ get: [
110
+ '명령: get',
111
+ '설명: 임의 API 경로를 GET으로 호출합니다.',
112
+ '사용법: daiso get <path|url> [--queryKey value ...] [--json]',
113
+ '필수: <path|url>',
114
+ '옵션: --json 원본 JSON 출력',
115
+ '예시: daiso get /api/cgv/movies --playDate 20260307 --theaterCode 0056',
116
+ ],
117
+ products: [
118
+ '명령: products',
119
+ '설명: 다이소 제품 검색 API를 호출합니다.',
120
+ '사용법: daiso products <query> [--page N] [--pageSize N] [--json]',
121
+ '필수: <query>',
122
+ '옵션: --page, --pageSize, --json',
123
+ '예시: daiso products 수납박스 --page 1 --pageSize 30',
124
+ ],
125
+ product: [
126
+ '명령: product',
127
+ '설명: 다이소 제품 상세 API를 호출합니다.',
128
+ '사용법: daiso product <productId> [--json]',
129
+ '필수: <productId>',
130
+ '옵션: --json',
131
+ '예시: daiso product 1034604',
132
+ ],
133
+ stores: [
134
+ '명령: stores',
135
+ '설명: 다이소 매장 검색 API를 호출합니다.',
136
+ '사용법: daiso stores [keyword] [--sido 값] [--gugun 값] [--dong 값] [--limit N] [--json]',
137
+ '필수: keyword 또는 --sido',
138
+ '옵션: --keyword, --sido, --gugun, --dong, --limit, --json',
139
+ '예시: daiso stores 강남역',
140
+ '예시: daiso stores --sido 서울 --gugun 강남구',
141
+ ],
142
+ inventory: [
143
+ '명령: inventory',
144
+ '설명: 다이소 재고 API를 호출합니다.',
145
+ '사용법: daiso inventory <productId> [--keyword 값] [--lat 값] [--lng 값] [--page N] [--pageSize N] [--json]',
146
+ '필수: <productId>',
147
+ '옵션: --keyword, --lat, --lng, --page, --pageSize, --json',
148
+ '예시: daiso inventory 1034604 --keyword 강남역',
149
+ ],
150
+ 'display-location': [
151
+ '명령: display-location',
152
+ '설명: 다이소 매장 내 상품 진열 위치 API를 호출합니다.',
153
+ '사용법: daiso display-location <productId> <storeCode> [--json]',
154
+ '필수: <productId>, <storeCode>',
155
+ '옵션: --json',
156
+ '예시: daiso display-location 1034604 04515',
157
+ ],
158
+ compare: [
159
+ '명령: compare',
160
+ '설명: 새 외부 키 없이 다이소, GS25, 세븐일레븐, 이마트24 상품 검색을 묶어 가격 후보를 비교합니다.',
161
+ '사용법: daiso compare <keyword> [--services daiso,gs25,seveneleven,emart24] [--limit N] [--json]',
162
+ '필수: <keyword>',
163
+ '옵션: --services, --limit, --json',
164
+ '예시: daiso compare 콜라 --limit 3',
165
+ '예시: daiso compare 컵라면 --services seveneleven,emart24 --json',
166
+ ],
167
+ places: [
168
+ '명령: places',
169
+ '설명: 네이버 지역 검색으로 음식점, 카페, 디저트 가게 등 주변 장소를 검색합니다.',
170
+ '사용법: daiso places <location> [--category cafe|restaurant|food|dessert|all] [--keyword 검색어] [--limit N] [--json]',
171
+ '필수: <location> 또는 --keyword',
172
+ '옵션: --category, --keyword, --limit, --start, --sort, --json',
173
+ '예시: daiso places 강남역 --category cafe --limit 5',
174
+ '예시: daiso places 성수동 --keyword 브런치 --limit 5',
175
+ ],
176
+ 'cu-stores': [
177
+ '명령: cu-stores',
178
+ '설명: CU 매장 검색 API를 호출합니다.',
179
+ '사용법: daiso cu-stores [keyword] [--lat 값] [--lng 값] [--limit N] [--json]',
180
+ '옵션: --keyword, --lat, --lng, --limit, --json',
181
+ '예시: daiso cu-stores 강남',
182
+ '예시: daiso cu-stores --lat 37.498 --lng 127.027 --limit 10',
183
+ ],
184
+ 'cu-inventory': [
185
+ '명령: cu-inventory',
186
+ '설명: CU 재고 검색 API를 호출합니다.',
187
+ '사용법: daiso cu-inventory <keyword> [--storeKeyword 값] [--lat 값] [--lng 값] [--size N] [--offset N] [--json]',
188
+ '필수: <keyword>',
189
+ '옵션: --storeKeyword, --lat, --lng, --size, --offset, --searchSort, --storeLimit, --json',
190
+ '예시: daiso cu-inventory 과자',
191
+ '예시: daiso cu-inventory 컵라면 --storeKeyword 강남 --size 10',
192
+ ],
193
+ 'cgv-theaters': [
194
+ '명령: cgv-theaters',
195
+ '설명: CGV 극장 검색 API를 호출합니다.',
196
+ '사용법: daiso cgv-theaters [keyword] [--regionCode 값] [--playDate YYYYMMDD] [--lat 값] [--lng 값] [--limit N] [--json]',
197
+ '옵션: --keyword, --regionCode, --playDate, --lat, --lng, --limit, --json',
198
+ '예시: daiso cgv-theaters 강남 --limit 5',
199
+ '예시: daiso cgv-theaters --regionCode 01 --playDate 20260304',
200
+ ],
201
+ 'cgv-movies': [
202
+ '명령: cgv-movies',
203
+ '설명: CGV 영화 검색 API를 호출합니다.',
204
+ '사용법: daiso cgv-movies [keyword] [--playDate YYYYMMDD] [--theaterCode 값] [--movieCode 값] [--lat 값] [--lng 값] [--json]',
205
+ '옵션: --keyword, --playDate, --theaterCode, --movieCode, --lat, --lng, --json',
206
+ '예시: daiso cgv-movies 강남 --playDate 20260304',
207
+ '예시: daiso cgv-movies --playDate 20260304 --theaterCode 0056',
208
+ ],
209
+ 'cgv-timetable': [
210
+ '명령: cgv-timetable',
211
+ '설명: CGV 시간표 API를 호출합니다.',
212
+ '사용법: daiso cgv-timetable [keyword] [--playDate YYYYMMDD] [--theaterCode 값] [--movieCode 값] [--lat 값] [--lng 값] [--json]',
213
+ '옵션: --keyword, --playDate, --theaterCode, --movieCode, --lat, --lng, --json',
214
+ '예시: daiso cgv-timetable 강남 --playDate 20260304',
215
+ '예시: daiso cgv-timetable --playDate 20260304 --theaterCode 0056',
216
+ ],
217
+ 'lottecinema-theaters': [
218
+ '명령: lottecinema-theaters',
219
+ '설명: 롯데시네마 주변 지점 API를 호출합니다.',
220
+ '사용법: daiso lottecinema-theaters [keyword] [--lat 값] [--lng 값] [--playDate YYYYMMDD] [--limit N] [--json]',
221
+ '옵션: --keyword, --lat, --lng, --playDate, --limit, --json',
222
+ '예시: daiso lottecinema-theaters 잠실 --limit 5',
223
+ '예시: daiso lottecinema-theaters --keyword "안산 중앙역" --limit 5',
224
+ ],
225
+ 'lottecinema-movies': [
226
+ '명령: lottecinema-movies',
227
+ '설명: 롯데시네마 영화/회차 API를 호출합니다.',
228
+ '사용법: daiso lottecinema-movies [keyword] [--playDate YYYYMMDD] [--theaterId 값] [--movieId 값] [--lat 값] [--lng 값] [--json]',
229
+ '옵션: --playDate, --theaterId, --movieId, --keyword, --lat, --lng, --json',
230
+ '예시: daiso lottecinema-movies 잠실 --playDate 20260310',
231
+ '예시: daiso lottecinema-movies --playDate 20260310 --keyword "안산 중앙역"',
232
+ ],
233
+ 'lottecinema-seats': [
234
+ '명령: lottecinema-seats',
235
+ '설명: 롯데시네마 잔여 좌석 API를 호출합니다.',
236
+ '사용법: daiso lottecinema-seats [keyword] [--playDate YYYYMMDD] [--theaterId 값] [--movieId 값] [--lat 값] [--lng 값] [--limit N] [--json]',
237
+ '옵션: --playDate, --theaterId, --movieId, --keyword, --lat, --lng, --limit, --json',
238
+ '예시: daiso lottecinema-seats 잠실 --playDate 20260310 --movieId 23816',
239
+ '예시: daiso lottecinema-seats --playDate 20260310 --keyword "안산 중앙역" --movieId 23816',
240
+ ],
241
+ 'megabox-theaters': [
242
+ '명령: megabox-theaters',
243
+ '설명: 메가박스 주변 지점 API를 호출합니다.',
244
+ '사용법: daiso megabox-theaters [keyword] [--lat 값] [--lng 값] [--playDate YYYYMMDD] [--areaCode 값] [--limit N] [--json]',
245
+ '옵션: --keyword, --lat, --lng, --playDate, --areaCode, --limit, --json',
246
+ '예시: daiso megabox-theaters 강남 --limit 5',
247
+ '예시: daiso megabox-theaters --keyword "코엑스" --limit 5',
248
+ ],
249
+ 'megabox-movies': [
250
+ '명령: megabox-movies',
251
+ '설명: 메가박스 영화/회차 API를 호출합니다.',
252
+ '사용법: daiso megabox-movies [keyword] [--playDate YYYYMMDD] [--theaterId 값] [--movieId 값] [--areaCode 값] [--lat 값] [--lng 값] [--json]',
253
+ '옵션: --playDate, --theaterId, --movieId, --keyword, --areaCode, --lat, --lng, --json',
254
+ '예시: daiso megabox-movies 강남 --playDate 20260310',
255
+ '예시: daiso megabox-movies --playDate 20260310 --keyword "코엑스"',
256
+ ],
257
+ 'megabox-seats': [
258
+ '명령: megabox-seats',
259
+ '설명: 메가박스 잔여 좌석 API를 호출합니다.',
260
+ '사용법: daiso megabox-seats [keyword] [--playDate YYYYMMDD] [--theaterId 값] [--movieId 값] [--areaCode 값] [--lat 값] [--lng 값] [--limit N] [--json]',
261
+ '옵션: --playDate, --theaterId, --movieId, --keyword, --areaCode, --lat, --lng, --limit, --json',
262
+ '예시: daiso megabox-seats 강남 --playDate 20260310 --movieId 23816',
263
+ '예시: daiso megabox-seats --playDate 20260310 --keyword "코엑스" --movieId 23816',
264
+ ],
265
+ 'lottemart-stores': [
266
+ '명령: lottemart-stores',
267
+ '설명: 롯데마트 계열 매장 검색 API를 호출합니다.',
268
+ '사용법: daiso lottemart-stores [keyword] [--area 값] [--brandVariant 값] [--lat 값] [--lng 값] [--limit N] [--json]',
269
+ '옵션: --keyword, --area, --brandVariant, --lat, --lng, --limit, --json',
270
+ '예시: daiso lottemart-stores 잠실 --area 서울',
271
+ '예시: daiso lottemart-stores --area 경기 --brandVariant lottemart --limit 10',
272
+ ],
273
+ 'lottemart-products': [
274
+ '명령: lottemart-products',
275
+ '설명: 롯데마트 매장 기준 상품 검색 API를 호출합니다.',
276
+ '사용법: daiso lottemart-products <keyword> [--storeCode 값 | --storeName 값] [--area 값] [--pageLimit N] [--json]',
277
+ '필수: <keyword>, --storeCode 또는 --storeName',
278
+ '옵션: --storeCode, --storeName, --area, --pageLimit, --json',
279
+ '예시: daiso lottemart-products 콜라 --storeName 강변점 --area 서울',
280
+ '예시: daiso lottemart-products 우유 --storeCode 2301 --pageLimit 2',
281
+ ],
282
+ 'emart24-stores': [
283
+ '명령: emart24-stores',
284
+ '설명: 이마트24 매장 검색 API를 호출합니다.',
285
+ '사용법: daiso emart24-stores [keyword] [--area1 값] [--area2 값] [--lat 값] [--lng 값] [--service24h true|false] [--limit N] [--json]',
286
+ '옵션: --keyword, --area1, --area2, --lat, --lng, --service24h, --limit, --json',
287
+ '예시: daiso emart24-stores 강남',
288
+ '예시: daiso emart24-stores --area1 서울특별시 --area2 강남구 --service24h true',
289
+ ],
290
+ 'emart24-products': [
291
+ '명령: emart24-products',
292
+ '설명: 이마트24 상품 검색 API를 호출합니다.',
293
+ '사용법: daiso emart24-products <keyword> [--page N] [--pageSize N] [--sortType 값] [--saleProductYn Y|N] [--json]',
294
+ '필수: <keyword>',
295
+ '옵션: --page, --pageSize, --sortType, --saleProductYn, --json',
296
+ '예시: daiso emart24-products 두바이',
297
+ '예시: daiso emart24-products 도시락 --page 2 --pageSize 20',
298
+ ],
299
+ 'emart24-inventory': [
300
+ '명령: emart24-inventory',
301
+ '설명: 이마트24 매장별 재고 API를 호출합니다.',
302
+ '사용법: daiso emart24-inventory <pluCd> --bizNoArr 코드1,코드2 [--json]',
303
+ '필수: <pluCd>, --bizNoArr',
304
+ '옵션: --bizNoArr, --json',
305
+ '예시: daiso emart24-inventory 8800244010504 --bizNoArr 28339,05015,23233',
306
+ ],
307
+ 'gs25-stores': [
308
+ '명령: gs25-stores',
309
+ '설명: GS25 매장 검색 API를 호출합니다.',
310
+ '사용법: daiso gs25-stores [keyword] [--lat 값] [--lng 값] [--limit N] [--json]',
311
+ '옵션: --keyword, --lat, --lng, --serviceCode, --limit, --json',
312
+ '예시: daiso gs25-stores 강남',
313
+ '예시: daiso gs25-stores --lat 37.4982 --lng 127.0276 --limit 10',
314
+ ],
315
+ 'gs25-products': [
316
+ '명령: gs25-products',
317
+ '설명: GS25 상품 키워드 검색 API를 호출합니다.',
318
+ '사용법: daiso gs25-products <keyword> [--limit N] [--json]',
319
+ '필수: <keyword>',
320
+ '옵션: --serviceCode, --limit, --json',
321
+ '예시: daiso gs25-products 오감자',
322
+ ],
323
+ 'gs25-inventory': [
324
+ '명령: gs25-inventory',
325
+ '설명: GS25 재고 검색 API를 호출합니다.',
326
+ '사용법: daiso gs25-inventory <keyword> [--storeKeyword 값] [--lat 값] [--lng 값] [--storeLimit N] [--json]',
327
+ '필수: <keyword>',
328
+ '옵션: --storeKeyword, --lat, --lng, --serviceCode, --storeLimit, --json',
329
+ '예시: daiso gs25-inventory 오감자 --storeKeyword 강남',
330
+ ],
331
+ 'seveneleven-products': [
332
+ '명령: seveneleven-products',
333
+ '설명: 세븐일레븐 상품 검색 API를 호출합니다.',
334
+ '사용법: daiso seveneleven-products <query> [--page N] [--size N] [--sort 값] [--json]',
335
+ '필수: <query>',
336
+ '옵션: --page, --size, --sort, --json',
337
+ '예시: daiso seveneleven-products 삼각김밥 --size 20',
338
+ ],
339
+ 'seveneleven-stores': [
340
+ '명령: seveneleven-stores',
341
+ '설명: 세븐일레븐 매장 검색 API를 호출합니다.',
342
+ '사용법: daiso seveneleven-stores <keyword> [--limit N] [--json]',
343
+ '필수: <keyword>',
344
+ '옵션: --limit, --json',
345
+ '예시: daiso seveneleven-stores 안산 중앙역 --limit 10',
346
+ ],
347
+ 'seveneleven-inventory': [
348
+ '명령: seveneleven-inventory',
349
+ '설명: 세븐일레븐 재고 API를 호출합니다.',
350
+ '사용법: daiso seveneleven-inventory <keyword> [--storeKeyword 값] [--storeLimit N] [--page N] [--size N] [--json]',
351
+ '필수: <keyword>',
352
+ '옵션: --keyword, --storeKeyword, --storeLimit, --page, --size, --json',
353
+ '예시: daiso seveneleven-inventory 핫식스 --storeKeyword "안산 중앙역" --storeLimit 10',
354
+ ],
355
+ 'seveneleven-popwords': [
356
+ '명령: seveneleven-popwords',
357
+ '설명: 세븐일레븐 인기 검색어 API를 호출합니다.',
358
+ '사용법: daiso seveneleven-popwords [--label 값] [--json]',
359
+ '옵션: --label, --json',
360
+ '예시: daiso seveneleven-popwords --label home',
361
+ ],
362
+ 'seveneleven-catalog': [
363
+ '명령: seveneleven-catalog',
364
+ '설명: 세븐일레븐 카탈로그 스냅샷 API를 호출합니다.',
365
+ '사용법: daiso seveneleven-catalog [--includeIssues true|false] [--includeExhibition true|false] [--limit N] [--json]',
366
+ '옵션: --includeIssues, --includeExhibition, --limit, --json',
367
+ '예시: daiso seveneleven-catalog --includeIssues true --includeExhibition true --limit 10',
368
+ ],
369
+ };
@@ -4,12 +4,12 @@
4
4
  * 좌표 입력 없이 서비스/매장/상품을 순차 선택해 재고를 확인합니다.
5
5
  */
6
6
  import { createInterface } from 'node:readline/promises';
7
- import { stdin as input, stdout as output } from 'node:process';
7
+ import process from 'node:process';
8
8
  import { pickFromList } from './cliPicker.js';
9
9
  import { fetchEnvelope, fetchStoresWithKeywordFallback } from './cli/interactiveFetch.js';
10
- import { askMenu, askNextAction, askNonEmpty, askYesNo, printStoreDetail } from './cli/interactivePrompt.js';
10
+ import { askMenu, askNextAction, askNonEmpty, askYesNo, printStoreDetail, } from './cli/interactivePrompt.js';
11
11
  import { parseLotteCinemaTheaters, printTheaterDetail, runCuItemSearch, runDaisoItemSearch, runLotteCinemaSearch, runOliveyoungItemSearch, } from './cli/interactiveItemSearch.js';
12
- import { buildDaisoStoreKeywordVariants, isRecord, parseDaisoProducts, parseStores, toText } from './utils/cliInteractiveHelpers.js';
12
+ import { buildDaisoStoreKeywordVariants, isRecord, parseDaisoProducts, parseStores, toText, } from './utils/cliInteractiveHelpers.js';
13
13
  function isLocationToken(token) {
14
14
  return /(?:역|점|동|구|시|군|읍|면|로|길)$/.test(token);
15
15
  }
@@ -22,7 +22,10 @@ export function inferDaisoFreeTextIntent(input) {
22
22
  const locationIndex = tokens.findIndex(isLocationToken);
23
23
  if (locationIndex >= 0) {
24
24
  const storeKeyword = tokens[locationIndex];
25
- const productQuery = tokens.filter((_, index) => index !== locationIndex).join(' ').trim() || input.trim();
25
+ const productQuery = tokens
26
+ .filter((_, index) => index !== locationIndex)
27
+ .join(' ')
28
+ .trim() || input.trim();
26
29
  return { productQuery, storeKeyword };
27
30
  }
28
31
  const storeKeyword = tokens[tokens.length - 1];
@@ -47,7 +50,7 @@ async function askServiceChoice(prompt, writeOut) {
47
50
  }
48
51
  }
49
52
  function createPrompt() {
50
- const rl = createInterface({ input, output });
53
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
51
54
  return {
52
55
  ask: async (question) => {
53
56
  const answer = await rl.question(question);
@@ -11,6 +11,7 @@ const SERVICE_PREFIXES = [
11
11
  'megabox',
12
12
  'lottecinema',
13
13
  'cgv',
14
+ 'dtryx',
14
15
  'oliveyoung',
15
16
  ];
16
17
  function normalizeService(value) {
@@ -49,7 +50,17 @@ function buildHint(retryable) {
49
50
  }
50
51
  export function toStandardErrorDiagnostics(code, message, options = {}) {
51
52
  const inferred = inferServiceAndOperation(code);
52
- const retryable = isRetryable(code, options.status || options.upstreamStatus);
53
+ // 실제 Zyte 진단 문구만 설정 오류로 취급해 일반적인 접근 차단과 구분합니다.
54
+ const configurationError = [
55
+ 'Zyte API 호출 실패: 403 Your account has been suspended.',
56
+ 'Zyte API 호출 실패: 403 account suspended',
57
+ 'ZYTE_API_KEY가 설정되지 않았습니다.',
58
+ ].some((diagnostic) => message.includes(diagnostic));
59
+ const gs25AuthenticationError = code === 'GS25_UPSTREAM_UNAVAILABLE' &&
60
+ message.includes('GS25 재고 서비스 인증을 사용할 수 없습니다.');
61
+ const retryable = !configurationError &&
62
+ !gs25AuthenticationError &&
63
+ isRetryable(code, options.status || options.upstreamStatus);
53
64
  return {
54
65
  code,
55
66
  message,
@@ -58,7 +69,11 @@ export function toStandardErrorDiagnostics(code, message, options = {}) {
58
69
  service: options.service || inferred.service,
59
70
  operation: options.operation || inferred.operation,
60
71
  upstreamStatus: options.upstreamStatus,
61
- hint: buildHint(retryable),
72
+ hint: gs25AuthenticationError
73
+ ? '운영자는 GS25_API_KEY 설정을 확인하세요.'
74
+ : configurationError
75
+ ? '운영자는 ZYTE_API_KEY 설정과 Zyte 계정 상태를 확인하세요.'
76
+ : buildHint(retryable),
62
77
  };
63
78
  }
64
79
  export function getErrorMessage(error) {
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * 서비스 프로바이더를 등록하고 MCP 서버에 도구를 연결합니다.
5
5
  */
6
- import { getErrorMessage, toStandardErrorDiagnostics } from './errors.js';
6
+ import { getErrorMessage } from './errors.js';
7
7
  import { createToolOutputSchema } from './outputSchema.js';
8
8
  function parseJsonText(text) {
9
9
  try {
@@ -181,24 +181,22 @@ export class ServiceRegistry {
181
181
  return {
182
182
  isError: true,
183
183
  content: [{ type: 'text', text: message }],
184
- structuredContent: {
185
- error: toStandardErrorDiagnostics('TOOL_EXECUTION_FAILED', message, {
186
- operation: tool.name,
187
- }),
188
- },
189
184
  };
190
185
  }
191
- const response = {
192
- content: result.content.map((item) => ({
193
- type: item.type,
194
- text: item.text,
195
- })),
196
- structuredContent: buildStructuredContent(result),
197
- };
186
+ const content = result.content.map((item) => ({
187
+ type: item.type,
188
+ text: item.text,
189
+ }));
198
190
  if (result.isError) {
199
- response.isError = true;
191
+ return {
192
+ isError: true,
193
+ content,
194
+ };
200
195
  }
201
- return response;
196
+ return {
197
+ content,
198
+ structuredContent: buildStructuredContent(result),
199
+ };
202
200
  });
203
201
  }
204
202
  /**
@@ -0,0 +1,185 @@
1
+ /**
2
+ * IP별 KST 일일 호출량을 저장하는 Durable Object
3
+ */
4
+ import { RATE_LIMIT_SERVICES, RateLimitMetricsStore, StaleRateLimitEventDayError, } from './rateLimitMetricsStore.js';
5
+ export const DAILY_RATE_LIMIT = 3000;
6
+ const KST_OFFSET_MS = 9 * 60 * 60 * 1000;
7
+ const COUNTER_KEY = 'counter';
8
+ const DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
9
+ const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
10
+ // DurableObjectId.toString()이 반환하는 namespace-scoped 불투명 ID 형식입니다.
11
+ const DURABLE_OBJECT_ID_PATTERN = /^[0-9a-f]{64}$/;
12
+ const BLOCKED_EVENT_FIELDS = ['eventId', 'occurredAt', 'day', 'service', 'identityId'];
13
+ export function toKstDay(nowMs) {
14
+ return new Date(nowMs + KST_OFFSET_MS).toISOString().slice(0, 10);
15
+ }
16
+ export function nextKstMidnightEpochSeconds(nowMs) {
17
+ const shifted = new Date(nowMs + KST_OFFSET_MS);
18
+ const nextMidnightUtcMs = Date.UTC(shifted.getUTCFullYear(), shifted.getUTCMonth(), shifted.getUTCDate() + 1) -
19
+ KST_OFFSET_MS;
20
+ return Math.floor(nextMidnightUtcMs / 1000);
21
+ }
22
+ function isRecord(value) {
23
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
24
+ }
25
+ function isExactDate(value) {
26
+ if (typeof value !== 'string' || !DATE_PATTERN.test(value)) {
27
+ return false;
28
+ }
29
+ const timestamp = Date.parse(`${value}T00:00:00.000Z`);
30
+ return Number.isFinite(timestamp) && new Date(timestamp).toISOString().slice(0, 10) === value;
31
+ }
32
+ function isRateLimitService(value) {
33
+ return typeof value === 'string' && RATE_LIMIT_SERVICES.includes(value);
34
+ }
35
+ function isBlockedRateLimitEvent(value) {
36
+ if (!isRecord(value) ||
37
+ Object.keys(value).length !== BLOCKED_EVENT_FIELDS.length ||
38
+ !BLOCKED_EVENT_FIELDS.every((field) => Object.hasOwn(value, field))) {
39
+ return false;
40
+ }
41
+ const occurredAt = value.occurredAt;
42
+ return (typeof value.eventId === 'string' &&
43
+ UUID_PATTERN.test(value.eventId) &&
44
+ typeof occurredAt === 'number' &&
45
+ Number.isSafeInteger(occurredAt) &&
46
+ occurredAt >= 0 &&
47
+ Number.isFinite(new Date(occurredAt).getTime()) &&
48
+ Number.isFinite(new Date(occurredAt + KST_OFFSET_MS).getTime()) &&
49
+ isExactDate(value.day) &&
50
+ value.day === toKstDay(occurredAt) &&
51
+ isRateLimitService(value.service) &&
52
+ typeof value.identityId === 'string' &&
53
+ DURABLE_OBJECT_ID_PATTERN.test(value.identityId));
54
+ }
55
+ async function parseBlockedEvent(request) {
56
+ let value;
57
+ try {
58
+ value = await request.json();
59
+ }
60
+ catch {
61
+ return undefined;
62
+ }
63
+ if (!isBlockedRateLimitEvent(value)) {
64
+ return undefined;
65
+ }
66
+ // 검증한 필드만 새 객체로 만들어 원장에 전달합니다.
67
+ return {
68
+ eventId: value.eventId,
69
+ occurredAt: value.occurredAt,
70
+ day: value.day,
71
+ service: value.service,
72
+ identityId: value.identityId,
73
+ };
74
+ }
75
+ function hasStrictStatsParameters(searchParams) {
76
+ let fromCount = 0;
77
+ let toCount = 0;
78
+ let asOfCount = 0;
79
+ let serviceCount = 0;
80
+ for (const [key] of searchParams) {
81
+ if (key === 'from') {
82
+ fromCount += 1;
83
+ }
84
+ else if (key === 'to') {
85
+ toCount += 1;
86
+ }
87
+ else if (key === 'asOf') {
88
+ asOfCount += 1;
89
+ }
90
+ else if (key === 'service') {
91
+ serviceCount += 1;
92
+ }
93
+ else {
94
+ return false;
95
+ }
96
+ }
97
+ return fromCount === 1 && toCount === 1 && asOfCount === 1 && serviceCount <= 1;
98
+ }
99
+ function parseStatsInput(url) {
100
+ if (!hasStrictStatsParameters(url.searchParams)) {
101
+ return undefined;
102
+ }
103
+ const from = url.searchParams.get('from');
104
+ const to = url.searchParams.get('to');
105
+ const asOfDay = url.searchParams.get('asOf');
106
+ const service = url.searchParams.get('service');
107
+ if (!isExactDate(from) || !isExactDate(to) || !isExactDate(asOfDay) || from > to) {
108
+ return undefined;
109
+ }
110
+ if (service !== null && !isRateLimitService(service)) {
111
+ return undefined;
112
+ }
113
+ return service === null ? { from, to, asOfDay } : { from, to, asOfDay, service };
114
+ }
115
+ function errorResponse(message, status) {
116
+ return Response.json({ error: message }, { status });
117
+ }
118
+ export class DailyRateLimiter {
119
+ state;
120
+ metricsStore;
121
+ constructor(state) {
122
+ this.state = state;
123
+ }
124
+ async consume(nowMs = Date.now()) {
125
+ const day = toKstDay(nowMs);
126
+ const stored = await this.state.storage.get(COUNTER_KEY);
127
+ const currentCount = stored?.day === day ? stored.count : 0;
128
+ const allowed = currentCount < DAILY_RATE_LIMIT;
129
+ const count = allowed ? currentCount + 1 : currentCount;
130
+ if (allowed) {
131
+ await this.state.storage.put(COUNTER_KEY, { day, count });
132
+ }
133
+ return {
134
+ allowed,
135
+ count,
136
+ remaining: Math.max(0, DAILY_RATE_LIMIT - count),
137
+ resetAt: nextKstMidnightEpochSeconds(nowMs),
138
+ day,
139
+ };
140
+ }
141
+ async fetch(request) {
142
+ const url = new URL(request.url);
143
+ if (request.method === 'POST' && url.pathname === '/consume') {
144
+ return Response.json(await this.consume());
145
+ }
146
+ if (request.method === 'POST' && url.pathname === '/blocked-events') {
147
+ const event = await parseBlockedEvent(request);
148
+ if (!event) {
149
+ return errorResponse('차단 이벤트 형식이 올바르지 않습니다.', 400);
150
+ }
151
+ const store = this.getMetricsStore();
152
+ try {
153
+ await store.record(event);
154
+ }
155
+ catch (error) {
156
+ if (error instanceof StaleRateLimitEventDayError) {
157
+ return errorResponse('차단 이벤트 날짜가 만료되었습니다.', 409);
158
+ }
159
+ throw error;
160
+ }
161
+ return new Response(null, { status: 204 });
162
+ }
163
+ if (request.method === 'GET' && url.pathname === '/stats') {
164
+ const input = parseStatsInput(url);
165
+ if (!input) {
166
+ return errorResponse('통계 조회 조건이 올바르지 않습니다.', 400);
167
+ }
168
+ if (input.asOfDay !== toKstDay(Date.now())) {
169
+ return errorResponse('통계 조회 기준 날짜가 만료되었습니다.', 409);
170
+ }
171
+ const store = this.getMetricsStore();
172
+ return Response.json(await store.query(input));
173
+ }
174
+ return errorResponse('요청한 작업을 찾을 수 없습니다.', 404);
175
+ }
176
+ async alarm() {
177
+ const store = this.getMetricsStore();
178
+ await store.cleanup();
179
+ await store.ensureAlarm();
180
+ }
181
+ getMetricsStore() {
182
+ this.metricsStore ??= new RateLimitMetricsStore(this.state);
183
+ return this.metricsStore;
184
+ }
185
+ }