daiso 1.0.6 → 1.0.7
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 +60 -4
- package/dist/api/actionsProxy.js +111 -21
- package/dist/api/configStatus.js +5 -1
- package/dist/api/gs25Handlers.js +45 -10
- package/dist/api/healthChecks.js +50 -9
- package/dist/api/placesHandlers.js +44 -0
- package/dist/api/routes/healthRoutes.js +1 -1
- package/dist/api/routes/placesRoutes.js +9 -0
- package/dist/cli/commandOptions.js +64 -6
- package/dist/cli/commands/convenience.js +20 -0
- package/dist/cli.js +3 -1
- package/dist/cliHelp.js +14 -6
- package/dist/cliRenderer.js +9 -2
- package/dist/core/registry.js +21 -2
- package/dist/index.js +17 -3
- package/dist/pages/openapiFullSpec.js +3 -0
- package/dist/pages/openapiSpecActions.js +308 -42
- package/dist/pages/openapiSpecPathsPlaces.js +85 -0
- package/dist/pages/promptReferenceText.js +3 -0
- package/dist/pages/promptRetailCinemaText.js +22 -1
- package/dist/services/gs25/api.js +3 -0
- package/dist/services/gs25/client.js +211 -35
- package/dist/services/gs25/index.js +11 -3
- package/dist/services/gs25/tools/checkInventory.js +39 -12
- package/dist/services/gs25/tools/findNearbyStores.js +19 -5
- package/dist/services/gs25/tools/searchProducts.js +11 -4
- package/dist/services/oliveyoung/client.js +90 -41
- package/dist/services/places/client.js +116 -0
- package/dist/services/places/index.js +23 -0
- package/dist/services/places/tools/searchNearby.js +56 -0
- package/dist/services/places/types.js +1 -0
- package/dist/utils/zyte.js +45 -18
- package/openapi.json +19 -0
- package/openapi.yaml +13 -0
- package/package.json +3 -2
|
@@ -10,6 +10,8 @@ const OLIVEYOUNG_PRODUCT_ID_CACHE_TTL_MS = 10 * 60 * 1000;
|
|
|
10
10
|
const OLIVEYOUNG_PRODUCT_SEARCH_STALE_CACHE_TTL_MS = 30 * 60 * 1000;
|
|
11
11
|
const oliveyoungProductIdCache = new Map();
|
|
12
12
|
const oliveyoungProductSearchCache = new Map();
|
|
13
|
+
const oliveyoungStoreSearchCache = new Map();
|
|
14
|
+
const oliveyoungStockStoresCache = new Map();
|
|
13
15
|
const OLIVEYOUNG_IMAGE_PATH_PREFIX = '/uploads/images/goods';
|
|
14
16
|
function resolveOliveyoungInStock(o2oStockFlag, o2oRemainQuantity) {
|
|
15
17
|
return o2oStockFlag || o2oRemainQuantity > 0;
|
|
@@ -67,6 +69,12 @@ function resolveOliveyoungStoreStock(rawStore) {
|
|
|
67
69
|
function createOliveyoungProductSearchCacheKey(params) {
|
|
68
70
|
return JSON.stringify([params.keyword, params.page, params.size, params.sort, params.includeSoldOut]);
|
|
69
71
|
}
|
|
72
|
+
function createOliveyoungStoreSearchCacheKey(params) {
|
|
73
|
+
return JSON.stringify([params.latitude, params.longitude, params.pageIdx, params.searchWords]);
|
|
74
|
+
}
|
|
75
|
+
function createOliveyoungStockStoresCacheKey(params) {
|
|
76
|
+
return JSON.stringify([params.productId, params.latitude, params.longitude, params.pageIdx, params.searchWords]);
|
|
77
|
+
}
|
|
70
78
|
function cloneOliveyoungProductSearchResult(result) {
|
|
71
79
|
return {
|
|
72
80
|
totalCount: result.totalCount,
|
|
@@ -74,17 +82,32 @@ function cloneOliveyoungProductSearchResult(result) {
|
|
|
74
82
|
products: result.products.map((product) => ({ ...product })),
|
|
75
83
|
};
|
|
76
84
|
}
|
|
77
|
-
function
|
|
78
|
-
|
|
85
|
+
function cloneOliveyoungStoreSearchResult(result) {
|
|
86
|
+
return {
|
|
87
|
+
totalCount: result.totalCount,
|
|
88
|
+
stores: result.stores.map((store) => ({ ...store })),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function cloneOliveyoungStockStoresResult(result) {
|
|
92
|
+
return {
|
|
93
|
+
totalCount: result.totalCount,
|
|
94
|
+
inStockCount: result.inStockCount,
|
|
95
|
+
outOfStockCount: result.outOfStockCount,
|
|
96
|
+
notSoldCount: result.notSoldCount,
|
|
97
|
+
stores: result.stores.map((store) => ({ ...store })),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function readStaleResult(cache, cacheKey, cloneResult) {
|
|
101
|
+
const cached = cache.get(cacheKey);
|
|
79
102
|
if (!cached || cached.expiresAt <= Date.now()) {
|
|
80
103
|
return null;
|
|
81
104
|
}
|
|
82
|
-
return
|
|
105
|
+
return cloneResult(cached.result);
|
|
83
106
|
}
|
|
84
|
-
function
|
|
85
|
-
|
|
107
|
+
function writeStaleResult(cache, cacheKey, result, cloneResult) {
|
|
108
|
+
cache.set(cacheKey, {
|
|
86
109
|
expiresAt: Date.now() + OLIVEYOUNG_PRODUCT_SEARCH_STALE_CACHE_TTL_MS,
|
|
87
|
-
result:
|
|
110
|
+
result: cloneResult(result),
|
|
88
111
|
});
|
|
89
112
|
}
|
|
90
113
|
async function zyteExtract(targetPath, requestBody, options = {}) {
|
|
@@ -130,20 +153,32 @@ export async function fetchOliveyoungStores(params, options = {}) {
|
|
|
130
153
|
mapLat: params.latitude,
|
|
131
154
|
mapLon: params.longitude,
|
|
132
155
|
};
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
156
|
+
const cacheKey = createOliveyoungStoreSearchCacheKey(params);
|
|
157
|
+
try {
|
|
158
|
+
const body = await zyteExtract(OLIVEYOUNG_API.STORE_FINDER_PATH, payload, options);
|
|
159
|
+
const stores = (body.data?.storeList || []).map((store) => ({
|
|
160
|
+
storeCode: store.storeCode || '',
|
|
161
|
+
storeName: store.storeName || '',
|
|
162
|
+
address: store.address || '',
|
|
163
|
+
latitude: store.latitude || 0,
|
|
164
|
+
longitude: store.longitude || 0,
|
|
165
|
+
pickupYn: Boolean(store.pickupYn),
|
|
166
|
+
o2oRemainQuantity: store.o2oRemainQuantity || 0,
|
|
167
|
+
}));
|
|
168
|
+
const result = {
|
|
169
|
+
totalCount: body.data?.totalCount || 0,
|
|
170
|
+
stores,
|
|
171
|
+
};
|
|
172
|
+
writeStaleResult(oliveyoungStoreSearchCache, cacheKey, result, cloneOliveyoungStoreSearchResult);
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
const staleResult = readStaleResult(oliveyoungStoreSearchCache, cacheKey, cloneOliveyoungStoreSearchResult);
|
|
177
|
+
if (staleResult) {
|
|
178
|
+
return staleResult;
|
|
179
|
+
}
|
|
180
|
+
throw error;
|
|
181
|
+
}
|
|
147
182
|
}
|
|
148
183
|
export async function fetchOliveyoungProducts(params, options = {}) {
|
|
149
184
|
const payload = {
|
|
@@ -182,11 +217,11 @@ export async function fetchOliveyoungProducts(params, options = {}) {
|
|
|
182
217
|
nextPage: Boolean(body.data?.nextPage),
|
|
183
218
|
products,
|
|
184
219
|
};
|
|
185
|
-
|
|
220
|
+
writeStaleResult(oliveyoungProductSearchCache, cacheKey, result, cloneOliveyoungProductSearchResult);
|
|
186
221
|
return result;
|
|
187
222
|
}
|
|
188
223
|
catch (error) {
|
|
189
|
-
const staleResult =
|
|
224
|
+
const staleResult = readStaleResult(oliveyoungProductSearchCache, cacheKey, cloneOliveyoungProductSearchResult);
|
|
190
225
|
if (staleResult) {
|
|
191
226
|
return staleResult;
|
|
192
227
|
}
|
|
@@ -214,25 +249,37 @@ async function fetchOliveyoungProductId(goodsNumber, options = {}) {
|
|
|
214
249
|
return productId;
|
|
215
250
|
}
|
|
216
251
|
async function fetchOliveyoungStockStores(params, options = {}) {
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
252
|
+
const cacheKey = createOliveyoungStockStoresCacheKey(params);
|
|
253
|
+
try {
|
|
254
|
+
const body = await zyteExtract(OLIVEYOUNG_API.STOCK_STORES_PATH, {
|
|
255
|
+
productId: params.productId,
|
|
256
|
+
lat: params.latitude,
|
|
257
|
+
lon: params.longitude,
|
|
258
|
+
pageIdx: params.pageIdx,
|
|
259
|
+
searchWords: params.searchWords,
|
|
260
|
+
mapLat: params.latitude,
|
|
261
|
+
mapLon: params.longitude,
|
|
262
|
+
}, options);
|
|
263
|
+
const stores = (body.data?.storeList || []).map((store) => resolveOliveyoungStoreStock(store));
|
|
264
|
+
const inStockCount = stores.filter((store) => store.stockStatus === 'in_stock').length;
|
|
265
|
+
const notSoldCount = stores.filter((store) => store.stockStatus === 'not_sold').length;
|
|
266
|
+
const result = {
|
|
267
|
+
totalCount: body.data?.totalCount || 0,
|
|
268
|
+
inStockCount,
|
|
269
|
+
outOfStockCount: stores.length - inStockCount - notSoldCount,
|
|
270
|
+
notSoldCount,
|
|
271
|
+
stores,
|
|
272
|
+
};
|
|
273
|
+
writeStaleResult(oliveyoungStockStoresCache, cacheKey, result, cloneOliveyoungStockStoresResult);
|
|
274
|
+
return result;
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
const staleResult = readStaleResult(oliveyoungStockStoresCache, cacheKey, cloneOliveyoungStockStoresResult);
|
|
278
|
+
if (staleResult) {
|
|
279
|
+
return staleResult;
|
|
280
|
+
}
|
|
281
|
+
throw error;
|
|
282
|
+
}
|
|
236
283
|
}
|
|
237
284
|
function sortOliveyoungProducts(products) {
|
|
238
285
|
const score = (product) => {
|
|
@@ -299,4 +346,6 @@ export async function enrichOliveyoungProductsWithNearbyStoreInventory(products,
|
|
|
299
346
|
export function __testOnlyClearOliveyoungCaches() {
|
|
300
347
|
oliveyoungProductIdCache.clear();
|
|
301
348
|
oliveyoungProductSearchCache.clear();
|
|
349
|
+
oliveyoungStoreSearchCache.clear();
|
|
350
|
+
oliveyoungStockStoresCache.clear();
|
|
302
351
|
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
const CATEGORY_KEYWORDS = {
|
|
2
|
+
restaurant: '음식점',
|
|
3
|
+
cafe: '카페',
|
|
4
|
+
food: '음식점',
|
|
5
|
+
dessert: '디저트',
|
|
6
|
+
all: '',
|
|
7
|
+
};
|
|
8
|
+
function getProcessEnvValue(name) {
|
|
9
|
+
/* c8 ignore next -- Node 테스트와 CLI 런타임은 process를 제공하며, Worker에는 API에서 키를 주입합니다. */
|
|
10
|
+
return typeof process !== 'undefined' ? process.env[name] : undefined;
|
|
11
|
+
}
|
|
12
|
+
function cleanHtml(value) {
|
|
13
|
+
if (!value) {
|
|
14
|
+
return '';
|
|
15
|
+
}
|
|
16
|
+
return value
|
|
17
|
+
.replace(/<[^>]*>/g, '')
|
|
18
|
+
.replace(/&/g, '&')
|
|
19
|
+
.replace(/</g, '<')
|
|
20
|
+
.replace(/>/g, '>')
|
|
21
|
+
.replace(/"/g, '"')
|
|
22
|
+
.replace(/'/g, "'")
|
|
23
|
+
.trim();
|
|
24
|
+
}
|
|
25
|
+
function toCoordinate(value) {
|
|
26
|
+
if (!value) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
const parsed = Number.parseInt(value, 10);
|
|
30
|
+
if (!Number.isFinite(parsed)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
return parsed / 10000000;
|
|
34
|
+
}
|
|
35
|
+
function clampDisplay(value) {
|
|
36
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
37
|
+
return 5;
|
|
38
|
+
}
|
|
39
|
+
return Math.min(Math.max(Math.trunc(value), 1), 5);
|
|
40
|
+
}
|
|
41
|
+
function clampStart(value) {
|
|
42
|
+
if (typeof value !== 'number' || !Number.isFinite(value)) {
|
|
43
|
+
return 1;
|
|
44
|
+
}
|
|
45
|
+
return Math.min(Math.max(Math.trunc(value), 1), 1000);
|
|
46
|
+
}
|
|
47
|
+
export function buildNaverLocalQuery({ location = '', keyword = '', category = 'all', }) {
|
|
48
|
+
const parts = [location.trim(), keyword.trim() || CATEGORY_KEYWORDS[category]].filter((part) => part.length > 0);
|
|
49
|
+
return parts.join(' ').trim();
|
|
50
|
+
}
|
|
51
|
+
function normalizePlace(item) {
|
|
52
|
+
return {
|
|
53
|
+
name: cleanHtml(item.title),
|
|
54
|
+
category: cleanHtml(item.category),
|
|
55
|
+
address: cleanHtml(item.address),
|
|
56
|
+
roadAddress: cleanHtml(item.roadAddress),
|
|
57
|
+
phone: cleanHtml(item.telephone),
|
|
58
|
+
link: item.link,
|
|
59
|
+
longitude: toCoordinate(item.mapx),
|
|
60
|
+
latitude: toCoordinate(item.mapy),
|
|
61
|
+
raw: item,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export async function searchNaverLocalPlaces(args) {
|
|
65
|
+
const naverClientId = args.naverClientId?.trim() || getProcessEnvValue('NAVER_CLIENT_ID')?.trim();
|
|
66
|
+
const naverClientSecret = args.naverClientSecret?.trim() || getProcessEnvValue('NAVER_CLIENT_SECRET')?.trim();
|
|
67
|
+
if (!naverClientId || !naverClientSecret) {
|
|
68
|
+
throw new Error('NAVER_CLIENT_ID와 NAVER_CLIENT_SECRET 환경 변수가 필요합니다.');
|
|
69
|
+
}
|
|
70
|
+
const category = args.category ?? 'all';
|
|
71
|
+
const location = args.location?.trim() ?? '';
|
|
72
|
+
const query = buildNaverLocalQuery({
|
|
73
|
+
location,
|
|
74
|
+
keyword: args.keyword,
|
|
75
|
+
category,
|
|
76
|
+
});
|
|
77
|
+
if (query.length === 0) {
|
|
78
|
+
throw new Error('위치(location) 또는 검색어(keyword)를 입력해주세요.');
|
|
79
|
+
}
|
|
80
|
+
const url = new URL('https://openapi.naver.com/v1/search/local.json');
|
|
81
|
+
url.searchParams.set('query', query);
|
|
82
|
+
url.searchParams.set('display', String(clampDisplay(args.limit)));
|
|
83
|
+
url.searchParams.set('start', String(clampStart(args.start)));
|
|
84
|
+
url.searchParams.set('sort', args.sort ?? 'random');
|
|
85
|
+
const fetchImpl = args.fetchImpl ?? fetch;
|
|
86
|
+
const response = await fetchImpl(url.toString(), {
|
|
87
|
+
headers: {
|
|
88
|
+
'X-Naver-Client-Id': naverClientId,
|
|
89
|
+
'X-Naver-Client-Secret': naverClientSecret,
|
|
90
|
+
},
|
|
91
|
+
signal: AbortSignal.timeout(args.timeoutMs ?? 10000),
|
|
92
|
+
});
|
|
93
|
+
const bodyText = await response.text();
|
|
94
|
+
let parsed;
|
|
95
|
+
try {
|
|
96
|
+
parsed = JSON.parse(bodyText);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
parsed = {};
|
|
100
|
+
}
|
|
101
|
+
if (!response.ok) {
|
|
102
|
+
const message = parsed.errorMessage || bodyText || `HTTP ${response.status}`;
|
|
103
|
+
throw new Error(`네이버 지역 검색 실패: ${message}`);
|
|
104
|
+
}
|
|
105
|
+
const places = (parsed.items ?? []).map(normalizePlace);
|
|
106
|
+
return {
|
|
107
|
+
provider: 'naverLocal',
|
|
108
|
+
searchMode: 'keyword',
|
|
109
|
+
query,
|
|
110
|
+
category,
|
|
111
|
+
location,
|
|
112
|
+
totalCount: parsed.total ?? places.length,
|
|
113
|
+
count: places.length,
|
|
114
|
+
places,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createSearchNearbyPlacesTool } from './tools/searchNearby.js';
|
|
2
|
+
const PLACES_METADATA = {
|
|
3
|
+
id: 'places',
|
|
4
|
+
name: '장소 검색',
|
|
5
|
+
version: '1.0.0',
|
|
6
|
+
description: '네이버 지역 검색 기반 음식점, 카페, 주변 장소 탐색 서비스',
|
|
7
|
+
};
|
|
8
|
+
class PlacesService {
|
|
9
|
+
options;
|
|
10
|
+
metadata = PLACES_METADATA;
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
this.options = options;
|
|
13
|
+
}
|
|
14
|
+
getTools() {
|
|
15
|
+
return [
|
|
16
|
+
createSearchNearbyPlacesTool(this.options.naverClientId, this.options.naverClientSecret),
|
|
17
|
+
];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export function createPlacesService(options = {}) {
|
|
21
|
+
return new PlacesService(options);
|
|
22
|
+
}
|
|
23
|
+
export * from './types.js';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 네이버 지역 검색 기반 주변 장소 탐색 도구
|
|
3
|
+
*/
|
|
4
|
+
import * as z from 'zod';
|
|
5
|
+
import { searchNaverLocalPlaces } from '../client.js';
|
|
6
|
+
async function searchNearbyPlaces(args) {
|
|
7
|
+
const result = await searchNaverLocalPlaces(args);
|
|
8
|
+
return {
|
|
9
|
+
content: [
|
|
10
|
+
{
|
|
11
|
+
type: 'text',
|
|
12
|
+
text: JSON.stringify(result, null, 2),
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
structuredContent: result,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function createSearchNearbyPlacesTool(naverClientId, naverClientSecret) {
|
|
19
|
+
return {
|
|
20
|
+
name: 'places_search_nearby',
|
|
21
|
+
metadata: {
|
|
22
|
+
title: '주변 음식점/카페 검색',
|
|
23
|
+
description: '네이버 지역 검색으로 특정 지역의 음식점, 카페, 디저트 가게 등 주변 장소를 키워드 기반으로 찾습니다.',
|
|
24
|
+
inputSchema: {
|
|
25
|
+
location: z.string().optional().describe('지역/역/주소 키워드 (예: 강남역, 성수동)'),
|
|
26
|
+
keyword: z.string().optional().describe('검색어 (예: 라멘, 브런치, 조용한 카페)'),
|
|
27
|
+
category: z
|
|
28
|
+
.enum(['restaurant', 'cafe', 'food', 'dessert', 'all'])
|
|
29
|
+
.optional()
|
|
30
|
+
.default('all')
|
|
31
|
+
.describe('장소 카테고리. restaurant/food=음식점, cafe=카페, dessert=디저트'),
|
|
32
|
+
limit: z
|
|
33
|
+
.number()
|
|
34
|
+
.optional()
|
|
35
|
+
.default(5)
|
|
36
|
+
.describe('반환할 최대 장소 수 (네이버 지역 검색 최대 5)'),
|
|
37
|
+
start: z.number().optional().default(1).describe('검색 시작 위치 (기본값: 1)'),
|
|
38
|
+
sort: z
|
|
39
|
+
.enum(['random', 'comment'])
|
|
40
|
+
.optional()
|
|
41
|
+
.default('random')
|
|
42
|
+
.describe('정렬 방식. random=유사도순, comment=리뷰순'),
|
|
43
|
+
timeoutMs: z
|
|
44
|
+
.number()
|
|
45
|
+
.optional()
|
|
46
|
+
.default(10000)
|
|
47
|
+
.describe('요청 제한 시간(ms, 기본값: 10000)'),
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
handler: ((args) => searchNearbyPlaces({
|
|
51
|
+
...args,
|
|
52
|
+
naverClientId: args.naverClientId || naverClientId,
|
|
53
|
+
naverClientSecret: args.naverClientSecret || naverClientSecret,
|
|
54
|
+
})),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils/zyte.js
CHANGED
|
@@ -40,6 +40,17 @@ export function decodeBase64(value) {
|
|
|
40
40
|
function isAbortError(error) {
|
|
41
41
|
return error instanceof Error && error.name === 'AbortError';
|
|
42
42
|
}
|
|
43
|
+
class RetryableZyteError extends Error {
|
|
44
|
+
}
|
|
45
|
+
function isRetryableZyteStatus(status) {
|
|
46
|
+
return status === 408 || status === 429 || status >= 500;
|
|
47
|
+
}
|
|
48
|
+
function isRetryableTargetStatus(statusCode) {
|
|
49
|
+
return typeof statusCode === 'number' && statusCode >= 500;
|
|
50
|
+
}
|
|
51
|
+
function isRetryableError(error) {
|
|
52
|
+
return isAbortError(error) || error instanceof RetryableZyteError;
|
|
53
|
+
}
|
|
43
54
|
function wait(ms) {
|
|
44
55
|
if (ms <= 0) {
|
|
45
56
|
return Promise.resolve();
|
|
@@ -55,30 +66,46 @@ export async function requestByZyte(options) {
|
|
|
55
66
|
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
56
67
|
const { controller, timeoutId } = createTimeoutController(timeout);
|
|
57
68
|
try {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
let response;
|
|
70
|
+
try {
|
|
71
|
+
response = await fetch('https://api.zyte.com/v1/extract', {
|
|
72
|
+
method: 'POST',
|
|
73
|
+
headers: {
|
|
74
|
+
Authorization: `Basic ${auth}`,
|
|
75
|
+
'Content-Type': 'application/json',
|
|
76
|
+
Accept: 'application/json',
|
|
77
|
+
},
|
|
78
|
+
body: JSON.stringify({
|
|
79
|
+
url,
|
|
80
|
+
httpRequestMethod: method,
|
|
81
|
+
customHttpRequestHeaders: headers,
|
|
82
|
+
httpRequestText: bodyText,
|
|
83
|
+
httpResponseBody: true,
|
|
84
|
+
}),
|
|
85
|
+
signal: controller.signal,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
if (error instanceof TypeError) {
|
|
90
|
+
throw new RetryableZyteError(error.message);
|
|
91
|
+
}
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
74
94
|
const result = (await response.json());
|
|
75
95
|
if (!response.ok) {
|
|
76
|
-
|
|
96
|
+
const message = `Zyte API 호출 실패: ${response.status} ${result.detail || result.title || ''}`.trim();
|
|
97
|
+
if (isRetryableZyteStatus(response.status)) {
|
|
98
|
+
throw new RetryableZyteError(message);
|
|
99
|
+
}
|
|
100
|
+
throw new Error(message);
|
|
101
|
+
}
|
|
102
|
+
if (isRetryableTargetStatus(result.statusCode) && attempt < maxAttempts) {
|
|
103
|
+
throw new RetryableZyteError(`Zyte target response failed: ${result.statusCode}`);
|
|
77
104
|
}
|
|
78
105
|
return result;
|
|
79
106
|
}
|
|
80
107
|
catch (error) {
|
|
81
|
-
if (!
|
|
108
|
+
if (!isRetryableError(error) || attempt >= maxAttempts) {
|
|
82
109
|
throw error;
|
|
83
110
|
}
|
|
84
111
|
await wait(retryDelayMs);
|
package/openapi.json
CHANGED
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"sevenelevenCheckInventory",
|
|
54
54
|
"sevenelevenGetPopwords",
|
|
55
55
|
"sevenelevenGetCatalog",
|
|
56
|
+
"placesSearchNearby",
|
|
56
57
|
"megaboxFindTheaters",
|
|
57
58
|
"megaboxListMovies",
|
|
58
59
|
"megaboxGetSeats",
|
|
@@ -110,6 +111,24 @@
|
|
|
110
111
|
"type": "string"
|
|
111
112
|
}
|
|
112
113
|
},
|
|
114
|
+
{
|
|
115
|
+
"name": "location",
|
|
116
|
+
"in": "query",
|
|
117
|
+
"required": false,
|
|
118
|
+
"description": "주변 장소 검색 지역/역/주소 키워드",
|
|
119
|
+
"schema": {
|
|
120
|
+
"type": "string"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "category",
|
|
125
|
+
"in": "query",
|
|
126
|
+
"required": false,
|
|
127
|
+
"description": "주변 장소 카테고리(restaurant, cafe, food, dessert, all)",
|
|
128
|
+
"schema": {
|
|
129
|
+
"type": "string"
|
|
130
|
+
}
|
|
131
|
+
},
|
|
113
132
|
{
|
|
114
133
|
"name": "sido",
|
|
115
134
|
"in": "query",
|
package/openapi.yaml
CHANGED
|
@@ -54,6 +54,7 @@ paths:
|
|
|
54
54
|
- sevenelevenCheckInventory
|
|
55
55
|
- sevenelevenGetPopwords
|
|
56
56
|
- sevenelevenGetCatalog
|
|
57
|
+
- placesSearchNearby
|
|
57
58
|
- megaboxFindTheaters
|
|
58
59
|
- megaboxListMovies
|
|
59
60
|
- megaboxGetSeats
|
|
@@ -93,6 +94,18 @@ paths:
|
|
|
93
94
|
description: 공통 키워드 파라미터
|
|
94
95
|
schema:
|
|
95
96
|
type: string
|
|
97
|
+
- name: location
|
|
98
|
+
in: query
|
|
99
|
+
required: false
|
|
100
|
+
description: 주변 장소 검색 지역/역/주소 키워드
|
|
101
|
+
schema:
|
|
102
|
+
type: string
|
|
103
|
+
- name: category
|
|
104
|
+
in: query
|
|
105
|
+
required: false
|
|
106
|
+
description: 주변 장소 카테고리(restaurant, cafe, food, dessert, all)
|
|
107
|
+
schema:
|
|
108
|
+
type: string
|
|
96
109
|
- name: sido
|
|
97
110
|
in: query
|
|
98
111
|
required: false
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "daiso",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Korean retail and cinema MCP server, CLI, and Codex Skill for Daiso, convenience stores, marts, Olive Young, and theaters",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -100,7 +100,8 @@
|
|
|
100
100
|
"overrides": {
|
|
101
101
|
"flatted": "3.4.2",
|
|
102
102
|
"undici": "7.24.0",
|
|
103
|
-
"brace-expansion": "5.0.6"
|
|
103
|
+
"brace-expansion": "5.0.6",
|
|
104
|
+
"ws": "8.20.1"
|
|
104
105
|
},
|
|
105
106
|
"dependencies": {
|
|
106
107
|
"@modelcontextprotocol/sdk": "^1.27.1",
|