daiso 1.0.8 → 1.0.10
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 +96 -11
- package/dist/api/actionsProxy.js +5 -0
- package/dist/api/configStatus.js +8 -0
- package/dist/api/feedbackHandlers.js +60 -0
- package/dist/api/healthCheckDefinitions.js +188 -0
- package/dist/api/healthCheckShape.js +106 -0
- package/dist/api/healthCheckTypes.js +4 -0
- package/dist/api/healthChecks.js +13 -272
- package/dist/api/opinetHandlers.js +91 -0
- package/dist/api/routes/feedbackRoutes.js +5 -0
- package/dist/api/routes/healthRoutes.js +17 -1
- package/dist/api/routes/opinetRoutes.js +24 -0
- package/dist/bin.js +0 -0
- package/dist/cli/commandOptions.js +23 -2
- package/dist/cli/commands/apiCommand.js +24 -0
- package/dist/cli/commands/cinema.js +65 -0
- package/dist/cli/commands/convenience.js +57 -100
- package/dist/cli/http.js +1 -1
- package/dist/cli.js +10 -1
- package/dist/cliHelp.js +44 -8
- package/dist/core/outputSchema.js +141 -0
- package/dist/core/registry.js +1 -138
- package/dist/index.js +92 -29
- package/dist/pages/openapiFullSpec.js +5 -0
- package/dist/pages/openapiSpecActions.js +63 -0
- package/dist/pages/openapiSpecPathsFeedback.js +95 -0
- package/dist/pages/openapiSpecPathsOpinet.js +81 -0
- package/dist/pages/promptReferenceText.js +15 -0
- package/dist/services/cgv/client.js +7 -4
- package/dist/services/emart24/tools/searchProducts.js +37 -19
- package/dist/services/feedback/client.js +109 -0
- package/dist/services/feedback/index.js +22 -0
- package/dist/services/feedback/tools/submitDeveloperRequest.js +54 -0
- package/dist/services/feedback/types.js +3 -0
- package/dist/services/gs25/client.js +1 -84
- package/dist/services/gs25/productSearch.js +97 -0
- package/dist/services/oliveyoung/client.js +1 -55
- package/dist/services/oliveyoung/normalize.js +58 -0
- package/dist/services/opinet/client.js +231 -0
- package/dist/services/opinet/index.js +26 -0
- package/dist/services/opinet/location.js +119 -0
- package/dist/services/opinet/tools.js +80 -0
- package/dist/services/opinet/types.js +1 -0
- package/dist/services/places/client.js +29 -8
- package/dist/services/seveneleven/tools/searchProducts.js +36 -17
- package/openapi.json +82 -0
- package/openapi.yaml +55 -0
- package/package.json +24 -20
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { resolveOpinetLocation } from './location.js';
|
|
2
|
+
const OPINET_API_BASE_URL = 'https://www.opinet.co.kr/api';
|
|
3
|
+
const OPINET_SOURCE = '한국석유공사 오피넷';
|
|
4
|
+
const DEFAULT_TIMEOUT_MS = 10000;
|
|
5
|
+
const FUEL_CODES = new Set(['B027', 'D047', 'B034', 'C004', 'K015']);
|
|
6
|
+
const BRAND_NAMES = {
|
|
7
|
+
SKE: 'SK에너지',
|
|
8
|
+
GSC: 'GS칼텍스',
|
|
9
|
+
HDO: '현대오일뱅크',
|
|
10
|
+
SOL: 'S-OIL',
|
|
11
|
+
RTE: '자영알뜰',
|
|
12
|
+
RTX: '고속도로알뜰',
|
|
13
|
+
NHO: '농협알뜰',
|
|
14
|
+
ETC: '자가상표',
|
|
15
|
+
E1G: 'E1',
|
|
16
|
+
SKG: 'SK가스',
|
|
17
|
+
};
|
|
18
|
+
function getProcessEnvValue(name) {
|
|
19
|
+
/* c8 ignore next -- Worker 런타임은 bindings로 키를 주입합니다. */
|
|
20
|
+
return typeof process !== 'undefined' ? process.env[name] : undefined;
|
|
21
|
+
}
|
|
22
|
+
function requireApiKey(apiKey) {
|
|
23
|
+
const resolved = apiKey?.trim() || getProcessEnvValue('OPINET_API_KEY')?.trim();
|
|
24
|
+
if (!resolved) {
|
|
25
|
+
throw new Error('OPINET_API_KEY 환경 변수가 필요합니다.');
|
|
26
|
+
}
|
|
27
|
+
return resolved;
|
|
28
|
+
}
|
|
29
|
+
export function normalizeFuelCode(value, fallback = 'B027') {
|
|
30
|
+
const normalized = (value || fallback).trim().toUpperCase();
|
|
31
|
+
if (!FUEL_CODES.has(normalized)) {
|
|
32
|
+
throw new Error('fuelCode는 B027, D047, B034, C004, K015 중 하나여야 합니다.');
|
|
33
|
+
}
|
|
34
|
+
return normalized;
|
|
35
|
+
}
|
|
36
|
+
export function normalizeOpinetSort(value) {
|
|
37
|
+
return value === 'distance' || value === '2' ? 'distance' : 'price';
|
|
38
|
+
}
|
|
39
|
+
function toOpinetSortCode(sort) {
|
|
40
|
+
return sort === 'distance' ? '2' : '1';
|
|
41
|
+
}
|
|
42
|
+
function toNumber(value) {
|
|
43
|
+
if (value === null || value === undefined || value === '') {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const parsed = Number(value);
|
|
47
|
+
return Number.isFinite(parsed) ? parsed : null;
|
|
48
|
+
}
|
|
49
|
+
function toStringValue(value) {
|
|
50
|
+
return typeof value === 'string' || typeof value === 'number' ? String(value).trim() : '';
|
|
51
|
+
}
|
|
52
|
+
function toBooleanYn(value) {
|
|
53
|
+
const normalized = toStringValue(value).toUpperCase();
|
|
54
|
+
if (normalized === 'Y') {
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
if (normalized === 'N') {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
function asRecord(value) {
|
|
63
|
+
return typeof value === 'object' && value !== null ? value : {};
|
|
64
|
+
}
|
|
65
|
+
function asArray(value) {
|
|
66
|
+
if (Array.isArray(value)) {
|
|
67
|
+
return value.map(asRecord);
|
|
68
|
+
}
|
|
69
|
+
if (value && typeof value === 'object') {
|
|
70
|
+
return [asRecord(value)];
|
|
71
|
+
}
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
function unwrapOil(payload) {
|
|
75
|
+
return asArray(payload.RESULT?.OIL ?? payload.OIL);
|
|
76
|
+
}
|
|
77
|
+
async function fetchOpinetJson(path, params, options) {
|
|
78
|
+
const url = new URL(`${OPINET_API_BASE_URL}/${path}`);
|
|
79
|
+
for (const [key, value] of Object.entries(params)) {
|
|
80
|
+
url.searchParams.set(key, value);
|
|
81
|
+
}
|
|
82
|
+
url.searchParams.set('out', 'json');
|
|
83
|
+
url.searchParams.set('certkey', requireApiKey(options.apiKey));
|
|
84
|
+
const response = await (options.fetchImpl ?? fetch)(url.toString(), {
|
|
85
|
+
signal: AbortSignal.timeout(options.timeoutMs ?? DEFAULT_TIMEOUT_MS),
|
|
86
|
+
});
|
|
87
|
+
const bodyText = await response.text();
|
|
88
|
+
let parsed;
|
|
89
|
+
try {
|
|
90
|
+
parsed = JSON.parse(bodyText);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
parsed = {};
|
|
94
|
+
}
|
|
95
|
+
if (!response.ok) {
|
|
96
|
+
throw new Error(`오피넷 API 호출 실패: HTTP ${response.status} ${bodyText}`);
|
|
97
|
+
}
|
|
98
|
+
return parsed;
|
|
99
|
+
}
|
|
100
|
+
function normalizeStationSummary(row) {
|
|
101
|
+
const brandCode = toStringValue(row.POLL_DIV_CD || row.POLL_DIV_CO);
|
|
102
|
+
return {
|
|
103
|
+
stationId: toStringValue(row.UNI_ID),
|
|
104
|
+
brandCode,
|
|
105
|
+
brandName: BRAND_NAMES[brandCode] || brandCode,
|
|
106
|
+
name: toStringValue(row.OS_NM),
|
|
107
|
+
price: toNumber(row.PRICE),
|
|
108
|
+
distanceMeters: toNumber(row.DISTANCE),
|
|
109
|
+
address: toStringValue(row.VAN_ADR) || undefined,
|
|
110
|
+
roadAddress: toStringValue(row.NEW_ADR) || undefined,
|
|
111
|
+
katecX: toNumber(row.GIS_X_COOR),
|
|
112
|
+
katecY: toNumber(row.GIS_Y_COOR),
|
|
113
|
+
raw: row,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
function normalizeAveragePrice(row) {
|
|
117
|
+
return {
|
|
118
|
+
tradeDate: toStringValue(row.TRADE_DT),
|
|
119
|
+
productCode: toStringValue(row.PRODCD),
|
|
120
|
+
productName: toStringValue(row.PRODNM),
|
|
121
|
+
price: toNumber(row.PRICE),
|
|
122
|
+
diff: toStringValue(row.DIFF),
|
|
123
|
+
raw: row,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function normalizeStationDetail(row) {
|
|
127
|
+
const summary = normalizeStationSummary(row);
|
|
128
|
+
const prices = asArray(row.OIL_PRICE).map((priceRow) => ({
|
|
129
|
+
productCode: toStringValue(priceRow.PRODCD),
|
|
130
|
+
price: toNumber(priceRow.PRICE),
|
|
131
|
+
tradeDate: toStringValue(priceRow.TRADE_DT),
|
|
132
|
+
tradeTime: toStringValue(priceRow.TRADE_TM),
|
|
133
|
+
raw: priceRow,
|
|
134
|
+
}));
|
|
135
|
+
return {
|
|
136
|
+
...summary,
|
|
137
|
+
phone: toStringValue(row.TEL) || undefined,
|
|
138
|
+
areaCode: toStringValue(row.SIGUNCD) || undefined,
|
|
139
|
+
lpgType: toStringValue(row.LPG_YN) || undefined,
|
|
140
|
+
hasMaintenance: toBooleanYn(row.MAINT_YN),
|
|
141
|
+
hasCarWash: toBooleanYn(row.CAR_WASH_YN),
|
|
142
|
+
hasConvenienceStore: toBooleanYn(row.CVS_YN),
|
|
143
|
+
isKpetroCertified: toBooleanYn(row.KPETRO_YN),
|
|
144
|
+
prices,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
export async function fetchOpinetAveragePrices(options = {}) {
|
|
148
|
+
const payload = await fetchOpinetJson('avgAllPrice.do', {}, options);
|
|
149
|
+
const prices = unwrapOil(payload).map(normalizeAveragePrice);
|
|
150
|
+
return {
|
|
151
|
+
provider: 'opinet',
|
|
152
|
+
source: OPINET_SOURCE,
|
|
153
|
+
fetchedAt: new Date().toISOString(),
|
|
154
|
+
count: prices.length,
|
|
155
|
+
prices,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
export async function fetchOpinetLowestStations(params, options = {}) {
|
|
159
|
+
const fuelCode = normalizeFuelCode(params.fuelCode);
|
|
160
|
+
const count = Math.min(Math.max(Math.trunc(params.count ?? 10), 1), 20);
|
|
161
|
+
const apiParams = {
|
|
162
|
+
prodcd: fuelCode,
|
|
163
|
+
cnt: String(count),
|
|
164
|
+
};
|
|
165
|
+
const areaCode = params.areaCode?.trim();
|
|
166
|
+
if (areaCode) {
|
|
167
|
+
apiParams.area = areaCode;
|
|
168
|
+
}
|
|
169
|
+
const payload = await fetchOpinetJson('lowTop10.do', apiParams, options);
|
|
170
|
+
const stations = unwrapOil(payload).map(normalizeStationSummary);
|
|
171
|
+
return {
|
|
172
|
+
provider: 'opinet',
|
|
173
|
+
source: OPINET_SOURCE,
|
|
174
|
+
fetchedAt: new Date().toISOString(),
|
|
175
|
+
fuelCode,
|
|
176
|
+
areaCode: areaCode || null,
|
|
177
|
+
count: stations.length,
|
|
178
|
+
stations,
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
export async function fetchOpinetStationsAround(params, options = {}) {
|
|
182
|
+
const resolvedLocation = await resolveOpinetLocation(params, {
|
|
183
|
+
googleMapsApiKey: options.googleMapsApiKey,
|
|
184
|
+
timeoutMs: options.timeoutMs,
|
|
185
|
+
fetchImpl: options.fetchImpl,
|
|
186
|
+
});
|
|
187
|
+
const radiusMeters = Math.min(Math.max(Math.trunc(params.radiusMeters ?? 3000), 100), 5000);
|
|
188
|
+
const fuelCode = normalizeFuelCode(params.fuelCode);
|
|
189
|
+
const sort = normalizeOpinetSort(params.sort);
|
|
190
|
+
const payload = await fetchOpinetJson('aroundAll.do', {
|
|
191
|
+
x: String(resolvedLocation.katec.x),
|
|
192
|
+
y: String(resolvedLocation.katec.y),
|
|
193
|
+
radius: String(radiusMeters),
|
|
194
|
+
prodcd: fuelCode,
|
|
195
|
+
sort: toOpinetSortCode(sort),
|
|
196
|
+
}, options);
|
|
197
|
+
const stations = unwrapOil(payload).map(normalizeStationSummary);
|
|
198
|
+
return {
|
|
199
|
+
provider: 'opinet',
|
|
200
|
+
source: OPINET_SOURCE,
|
|
201
|
+
fetchedAt: new Date().toISOString(),
|
|
202
|
+
fuelCode,
|
|
203
|
+
radiusMeters,
|
|
204
|
+
sort,
|
|
205
|
+
katec: resolvedLocation.katec,
|
|
206
|
+
location: {
|
|
207
|
+
latitude: resolvedLocation.latitude,
|
|
208
|
+
longitude: resolvedLocation.longitude,
|
|
209
|
+
location: resolvedLocation.location,
|
|
210
|
+
formattedAddress: resolvedLocation.formattedAddress,
|
|
211
|
+
geocodeUsed: resolvedLocation.geocodeUsed,
|
|
212
|
+
inputType: resolvedLocation.inputType,
|
|
213
|
+
},
|
|
214
|
+
count: stations.length,
|
|
215
|
+
stations,
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
export async function fetchOpinetStationDetail(stationId, options = {}) {
|
|
219
|
+
const id = stationId.trim();
|
|
220
|
+
if (!id) {
|
|
221
|
+
throw new Error('주유소 ID를 입력해주세요.');
|
|
222
|
+
}
|
|
223
|
+
const payload = await fetchOpinetJson('detailById.do', { id }, options);
|
|
224
|
+
const station = unwrapOil(payload).map(normalizeStationDetail)[0] ?? null;
|
|
225
|
+
return {
|
|
226
|
+
provider: 'opinet',
|
|
227
|
+
source: OPINET_SOURCE,
|
|
228
|
+
fetchedAt: new Date().toISOString(),
|
|
229
|
+
station,
|
|
230
|
+
};
|
|
231
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createOpinetAveragePricesTool, createOpinetLowestStationsTool, createOpinetStationDetailTool, createOpinetStationsAroundTool, } from './tools.js';
|
|
2
|
+
const OPINET_METADATA = {
|
|
3
|
+
id: 'opinet',
|
|
4
|
+
name: '오피넷',
|
|
5
|
+
version: '1.0.0',
|
|
6
|
+
description: '한국석유공사 오피넷 기반 전국 평균 유가, 최저가 주유소, 반경 내 주유소 조회 서비스',
|
|
7
|
+
};
|
|
8
|
+
class OpinetService {
|
|
9
|
+
options;
|
|
10
|
+
metadata = OPINET_METADATA;
|
|
11
|
+
constructor(options = {}) {
|
|
12
|
+
this.options = options;
|
|
13
|
+
}
|
|
14
|
+
getTools() {
|
|
15
|
+
return [
|
|
16
|
+
createOpinetAveragePricesTool(this.options.apiKey),
|
|
17
|
+
createOpinetLowestStationsTool(this.options.apiKey),
|
|
18
|
+
createOpinetStationsAroundTool(this.options.apiKey, this.options.googleMapsApiKey),
|
|
19
|
+
createOpinetStationDetailTool(this.options.apiKey),
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export function createOpinetService(options = {}) {
|
|
24
|
+
return new OpinetService(options);
|
|
25
|
+
}
|
|
26
|
+
export * from './types.js';
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import proj4 from 'proj4';
|
|
2
|
+
const WGS84 = 'EPSG:4326';
|
|
3
|
+
const KATEC = 'KATEC';
|
|
4
|
+
const KATEC_PROJ4 = '+proj=tmerc +lat_0=38 +lon_0=128 +k=0.9999 +x_0=400000 +y_0=600000 +ellps=bessel +units=m +no_defs +towgs84=-115.80,474.99,674.11,1.16,-2.31,-1.63,6.43';
|
|
5
|
+
proj4.defs(KATEC, KATEC_PROJ4);
|
|
6
|
+
const GEOCODE_CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
7
|
+
const geocodeCache = new Map();
|
|
8
|
+
function getProcessEnvValue(name) {
|
|
9
|
+
/* c8 ignore next -- Worker 런타임은 bindings로 키를 주입합니다. */
|
|
10
|
+
return typeof process !== 'undefined' ? process.env[name] : undefined;
|
|
11
|
+
}
|
|
12
|
+
function isFiniteNumber(value) {
|
|
13
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
14
|
+
}
|
|
15
|
+
export function wgs84ToKatec(latitude, longitude) {
|
|
16
|
+
if (!isFiniteNumber(latitude) || !isFiniteNumber(longitude)) {
|
|
17
|
+
throw new Error('유효한 위도/경도를 입력해주세요.');
|
|
18
|
+
}
|
|
19
|
+
const [x, y] = proj4(WGS84, KATEC, [longitude, latitude]);
|
|
20
|
+
return {
|
|
21
|
+
x: Number(x.toFixed(3)),
|
|
22
|
+
y: Number(y.toFixed(3)),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
async function geocodeLocation(location, options) {
|
|
26
|
+
const keyword = location.trim();
|
|
27
|
+
const cached = geocodeCache.get(keyword);
|
|
28
|
+
if (cached && cached.expiresAt > Date.now()) {
|
|
29
|
+
return cached.value;
|
|
30
|
+
}
|
|
31
|
+
const apiKey = options.googleMapsApiKey?.trim() || getProcessEnvValue('GOOGLE_MAPS_API_KEY')?.trim();
|
|
32
|
+
if (!apiKey) {
|
|
33
|
+
throw new Error('location 검색에는 GOOGLE_MAPS_API_KEY가 필요합니다.');
|
|
34
|
+
}
|
|
35
|
+
const endpoint = new URL('https://maps.googleapis.com/maps/api/geocode/json');
|
|
36
|
+
endpoint.searchParams.set('address', keyword);
|
|
37
|
+
endpoint.searchParams.set('key', apiKey);
|
|
38
|
+
const response = await (options.fetchImpl ?? fetch)(endpoint.toString(), {
|
|
39
|
+
headers: { Accept: 'application/json' },
|
|
40
|
+
signal: AbortSignal.timeout(options.timeoutMs ?? 10000),
|
|
41
|
+
});
|
|
42
|
+
const bodyText = await response.text();
|
|
43
|
+
let parsed;
|
|
44
|
+
try {
|
|
45
|
+
parsed = JSON.parse(bodyText);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
parsed = { status: 'INVALID_JSON' };
|
|
49
|
+
}
|
|
50
|
+
if (!response.ok) {
|
|
51
|
+
throw new Error(`Google Geocoding 호출 실패: HTTP ${response.status} ${bodyText}`);
|
|
52
|
+
}
|
|
53
|
+
if (parsed.status !== 'OK') {
|
|
54
|
+
geocodeCache.set(keyword, {
|
|
55
|
+
expiresAt: Date.now() + GEOCODE_CACHE_TTL_MS,
|
|
56
|
+
value: null,
|
|
57
|
+
});
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
const first = parsed.results?.[0];
|
|
61
|
+
const latitude = first?.geometry?.location?.lat;
|
|
62
|
+
const longitude = first?.geometry?.location?.lng;
|
|
63
|
+
const value = isFiniteNumber(latitude) && isFiniteNumber(longitude)
|
|
64
|
+
? {
|
|
65
|
+
latitude,
|
|
66
|
+
longitude,
|
|
67
|
+
formattedAddress: first?.formatted_address ?? null,
|
|
68
|
+
}
|
|
69
|
+
: null;
|
|
70
|
+
geocodeCache.set(keyword, {
|
|
71
|
+
expiresAt: Date.now() + GEOCODE_CACHE_TTL_MS,
|
|
72
|
+
value,
|
|
73
|
+
});
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
76
|
+
export async function resolveOpinetLocation(input, options = {}) {
|
|
77
|
+
if (isFiniteNumber(input.x) && isFiniteNumber(input.y)) {
|
|
78
|
+
return {
|
|
79
|
+
katec: { x: input.x, y: input.y },
|
|
80
|
+
latitude: null,
|
|
81
|
+
longitude: null,
|
|
82
|
+
location: input.location?.trim() || null,
|
|
83
|
+
formattedAddress: null,
|
|
84
|
+
geocodeUsed: false,
|
|
85
|
+
inputType: 'katec',
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
if (isFiniteNumber(input.latitude) && isFiniteNumber(input.longitude)) {
|
|
89
|
+
return {
|
|
90
|
+
katec: wgs84ToKatec(input.latitude, input.longitude),
|
|
91
|
+
latitude: input.latitude,
|
|
92
|
+
longitude: input.longitude,
|
|
93
|
+
location: input.location?.trim() || null,
|
|
94
|
+
formattedAddress: null,
|
|
95
|
+
geocodeUsed: false,
|
|
96
|
+
inputType: 'coordinates',
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
const location = input.location?.trim() || '';
|
|
100
|
+
if (location.length > 0) {
|
|
101
|
+
const geocoded = await geocodeLocation(location, options);
|
|
102
|
+
if (!geocoded) {
|
|
103
|
+
throw new Error(`위치를 좌표로 변환하지 못했습니다: ${location}`);
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
katec: wgs84ToKatec(geocoded.latitude, geocoded.longitude),
|
|
107
|
+
latitude: geocoded.latitude,
|
|
108
|
+
longitude: geocoded.longitude,
|
|
109
|
+
location,
|
|
110
|
+
formattedAddress: geocoded.formattedAddress,
|
|
111
|
+
geocodeUsed: true,
|
|
112
|
+
inputType: 'location',
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
throw new Error('KATEC x/y, 위도/경도(latitude/longitude), 또는 location 중 하나를 입력해주세요.');
|
|
116
|
+
}
|
|
117
|
+
export function __testOnlyClearOpinetGeocodeCache() {
|
|
118
|
+
geocodeCache.clear();
|
|
119
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import { fetchOpinetAveragePrices, fetchOpinetLowestStations, fetchOpinetStationDetail, fetchOpinetStationsAround, } from './client.js';
|
|
3
|
+
function buildTextResponse(payload) {
|
|
4
|
+
return {
|
|
5
|
+
content: [{ type: 'text', text: JSON.stringify(payload, null, 2) }],
|
|
6
|
+
structuredContent: payload,
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export function createOpinetAveragePricesTool(apiKey) {
|
|
10
|
+
return {
|
|
11
|
+
name: 'opinet_get_average_prices',
|
|
12
|
+
metadata: {
|
|
13
|
+
title: '오피넷 전국 평균 유가',
|
|
14
|
+
description: '한국석유공사 오피넷의 전국 평균 유가를 조회합니다.',
|
|
15
|
+
inputSchema: {
|
|
16
|
+
timeoutMs: z.number().optional().default(10000).describe('요청 제한 시간(ms)'),
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
handler: (async (args) => buildTextResponse(await fetchOpinetAveragePrices({ apiKey, timeoutMs: args.timeoutMs }))),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function createOpinetLowestStationsTool(apiKey) {
|
|
23
|
+
return {
|
|
24
|
+
name: 'opinet_get_lowest_price_stations',
|
|
25
|
+
metadata: {
|
|
26
|
+
title: '오피넷 최저가 주유소',
|
|
27
|
+
description: '전국 또는 지역별 최저가 주유소를 유종별로 조회합니다.',
|
|
28
|
+
inputSchema: {
|
|
29
|
+
fuelCode: z
|
|
30
|
+
.enum(['B027', 'D047', 'B034', 'C004', 'K015'])
|
|
31
|
+
.optional()
|
|
32
|
+
.default('B027')
|
|
33
|
+
.describe('유종 코드: B027 휘발유, D047 경유, B034 고급휘발유, C004 실내등유, K015 자동차부탄'),
|
|
34
|
+
areaCode: z.string().optional().describe('오피넷 지역 코드. 미입력 시 전국 기준'),
|
|
35
|
+
count: z.number().optional().default(10).describe('최저가 결과 수(1~20)'),
|
|
36
|
+
timeoutMs: z.number().optional().default(10000).describe('요청 제한 시간(ms)'),
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
handler: (async (args) => buildTextResponse(await fetchOpinetLowestStations(args, { apiKey, timeoutMs: args.timeoutMs }))),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export function createOpinetStationsAroundTool(apiKey, googleMapsApiKey) {
|
|
43
|
+
return {
|
|
44
|
+
name: 'opinet_search_stations_around',
|
|
45
|
+
metadata: {
|
|
46
|
+
title: '오피넷 반경 내 주유소',
|
|
47
|
+
description: 'KATEC x/y, 위도/경도, 또는 장소 키워드 기준 반경 내 주유소를 가격순 또는 거리순으로 조회합니다.',
|
|
48
|
+
inputSchema: {
|
|
49
|
+
x: z.number().optional().describe('기준 위치 X좌표(KATEC)'),
|
|
50
|
+
y: z.number().optional().describe('기준 위치 Y좌표(KATEC)'),
|
|
51
|
+
latitude: z.number().optional().describe('위도(WGS84)'),
|
|
52
|
+
longitude: z.number().optional().describe('경도(WGS84)'),
|
|
53
|
+
location: z.string().optional().describe('장소/주소 키워드. 예: 강남역, 서울역'),
|
|
54
|
+
radiusMeters: z.number().optional().default(3000).describe('검색 반경 m(100~5000)'),
|
|
55
|
+
fuelCode: z
|
|
56
|
+
.enum(['B027', 'D047', 'B034', 'C004', 'K015'])
|
|
57
|
+
.optional()
|
|
58
|
+
.default('B027')
|
|
59
|
+
.describe('유종 코드'),
|
|
60
|
+
sort: z.enum(['price', 'distance']).optional().default('price').describe('정렬 기준'),
|
|
61
|
+
timeoutMs: z.number().optional().default(10000).describe('요청 제한 시간(ms)'),
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
handler: (async (args) => buildTextResponse(await fetchOpinetStationsAround(args, { apiKey, googleMapsApiKey, timeoutMs: args.timeoutMs }))),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export function createOpinetStationDetailTool(apiKey) {
|
|
68
|
+
return {
|
|
69
|
+
name: 'opinet_get_station_detail',
|
|
70
|
+
metadata: {
|
|
71
|
+
title: '오피넷 주유소 상세정보',
|
|
72
|
+
description: '오피넷 주유소 ID로 상세 정보, 부가시설, 유종별 가격을 조회합니다.',
|
|
73
|
+
inputSchema: {
|
|
74
|
+
stationId: z.string().describe('오피넷 주유소 ID'),
|
|
75
|
+
timeoutMs: z.number().optional().default(10000).describe('요청 제한 시간(ms)'),
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
handler: (async (args) => buildTextResponse(await fetchOpinetStationDetail(args.stationId, { apiKey, timeoutMs: args.timeoutMs }))),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,22 +5,43 @@ const CATEGORY_KEYWORDS = {
|
|
|
5
5
|
dessert: '디저트',
|
|
6
6
|
all: '',
|
|
7
7
|
};
|
|
8
|
+
const HTML_ENTITY_REPLACEMENTS = {
|
|
9
|
+
'&': '&',
|
|
10
|
+
'"': '"',
|
|
11
|
+
''': "'",
|
|
12
|
+
''': "'",
|
|
13
|
+
};
|
|
8
14
|
function getProcessEnvValue(name) {
|
|
9
15
|
/* c8 ignore next -- Node 테스트와 CLI 런타임은 process를 제공하며, Worker에는 API에서 키를 주입합니다. */
|
|
10
16
|
return typeof process !== 'undefined' ? process.env[name] : undefined;
|
|
11
17
|
}
|
|
18
|
+
function stripHtmlTags(value) {
|
|
19
|
+
let result = '';
|
|
20
|
+
let insideTag = false;
|
|
21
|
+
for (const character of value) {
|
|
22
|
+
if (character === '<') {
|
|
23
|
+
insideTag = true;
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (character === '>' && insideTag) {
|
|
27
|
+
insideTag = false;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (!insideTag) {
|
|
31
|
+
result += character;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
12
36
|
function cleanHtml(value) {
|
|
13
37
|
if (!value) {
|
|
14
38
|
return '';
|
|
15
39
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
.replace(/"/g, '"')
|
|
22
|
-
.replace(/'/g, "'")
|
|
23
|
-
.trim();
|
|
40
|
+
let result = stripHtmlTags(value);
|
|
41
|
+
for (const [entity, replacement] of Object.entries(HTML_ENTITY_REPLACEMENTS)) {
|
|
42
|
+
result = result.split(entity).join(replacement);
|
|
43
|
+
}
|
|
44
|
+
return result.trim();
|
|
24
45
|
}
|
|
25
46
|
function toCoordinate(value) {
|
|
26
47
|
if (!value) {
|
|
@@ -14,23 +14,40 @@ async function searchProducts(args) {
|
|
|
14
14
|
if (!query || query.trim().length === 0) {
|
|
15
15
|
throw new Error('상품 검색어(query)를 입력해주세요.');
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
17
|
+
try {
|
|
18
|
+
const result = await searchSevenElevenProductsWithVariants(query, {
|
|
19
|
+
page,
|
|
20
|
+
size,
|
|
21
|
+
sort,
|
|
22
|
+
timeout: timeoutMs,
|
|
23
|
+
});
|
|
24
|
+
return buildTextResponse({
|
|
25
|
+
query: result.query,
|
|
26
|
+
page,
|
|
27
|
+
size,
|
|
28
|
+
sort,
|
|
29
|
+
totalCount: result.totalCount,
|
|
30
|
+
count: result.products.length,
|
|
31
|
+
collectionIds: result.collectionIds,
|
|
32
|
+
appliedQueries: result.appliedQueries,
|
|
33
|
+
products: result.products,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
return buildTextResponse({
|
|
38
|
+
query,
|
|
39
|
+
page,
|
|
40
|
+
size,
|
|
41
|
+
sort,
|
|
42
|
+
totalCount: 0,
|
|
43
|
+
count: 0,
|
|
44
|
+
collectionIds: [],
|
|
45
|
+
appliedQueries: [query],
|
|
46
|
+
products: [],
|
|
47
|
+
status: 'degraded',
|
|
48
|
+
message: error instanceof Error ? error.message : '세븐일레븐 상품 검색에 실패했습니다.',
|
|
49
|
+
});
|
|
50
|
+
}
|
|
34
51
|
}
|
|
35
52
|
const searchProductsOutputSchema = {
|
|
36
53
|
query: z.string().describe('적용된 검색어'),
|
|
@@ -42,6 +59,8 @@ const searchProductsOutputSchema = {
|
|
|
42
59
|
collectionIds: z.array(z.string()).describe('검색 컬렉션 ID 목록'),
|
|
43
60
|
appliedQueries: z.array(z.string()).describe('실제로 시도한 검색어 목록'),
|
|
44
61
|
products: z.array(z.unknown()).describe('세븐일레븐 상품 검색 결과'),
|
|
62
|
+
status: z.string().optional().describe('외부 API 차단 등으로 결과가 제한된 경우 degraded'),
|
|
63
|
+
message: z.string().optional().describe('degraded 상태의 원인 메시지'),
|
|
45
64
|
};
|
|
46
65
|
export function createSearchProductsTool() {
|
|
47
66
|
return {
|
package/openapi.json
CHANGED
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"sevenelevenGetCatalog",
|
|
56
56
|
"compareProducts",
|
|
57
57
|
"placesSearchNearby",
|
|
58
|
+
"submitDeveloperRequest",
|
|
58
59
|
"megaboxFindTheaters",
|
|
59
60
|
"megaboxListMovies",
|
|
60
61
|
"megaboxGetSeats",
|
|
@@ -139,6 +140,87 @@
|
|
|
139
140
|
"type": "string"
|
|
140
141
|
}
|
|
141
142
|
},
|
|
143
|
+
{
|
|
144
|
+
"name": "type",
|
|
145
|
+
"in": "query",
|
|
146
|
+
"required": false,
|
|
147
|
+
"description": "개발자 요청 유형(bug, improvement, feature, docs, other)",
|
|
148
|
+
"schema": {
|
|
149
|
+
"type": "string"
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"name": "severity",
|
|
154
|
+
"in": "query",
|
|
155
|
+
"required": false,
|
|
156
|
+
"description": "개발자 요청 영향도(low, medium, high, critical)",
|
|
157
|
+
"schema": {
|
|
158
|
+
"type": "string"
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "title",
|
|
163
|
+
"in": "query",
|
|
164
|
+
"required": false,
|
|
165
|
+
"description": "개발자 요청 제목",
|
|
166
|
+
"schema": {
|
|
167
|
+
"type": "string"
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"name": "description",
|
|
172
|
+
"in": "query",
|
|
173
|
+
"required": false,
|
|
174
|
+
"description": "개발자 요청 상세 설명",
|
|
175
|
+
"schema": {
|
|
176
|
+
"type": "string"
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"name": "toolName",
|
|
181
|
+
"in": "query",
|
|
182
|
+
"required": false,
|
|
183
|
+
"description": "문제가 발생했거나 개선이 필요한 MCP 도구 이름",
|
|
184
|
+
"schema": {
|
|
185
|
+
"type": "string"
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"name": "reproduction",
|
|
190
|
+
"in": "query",
|
|
191
|
+
"required": false,
|
|
192
|
+
"description": "오류 재현 방법",
|
|
193
|
+
"schema": {
|
|
194
|
+
"type": "string"
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"name": "expected",
|
|
199
|
+
"in": "query",
|
|
200
|
+
"required": false,
|
|
201
|
+
"description": "기대 결과",
|
|
202
|
+
"schema": {
|
|
203
|
+
"type": "string"
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"name": "actual",
|
|
208
|
+
"in": "query",
|
|
209
|
+
"required": false,
|
|
210
|
+
"description": "실제 결과",
|
|
211
|
+
"schema": {
|
|
212
|
+
"type": "string"
|
|
213
|
+
}
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
"name": "source",
|
|
217
|
+
"in": "query",
|
|
218
|
+
"required": false,
|
|
219
|
+
"description": "요청 출처(mcp, chatgpt, claude, cli, api, other)",
|
|
220
|
+
"schema": {
|
|
221
|
+
"type": "string"
|
|
222
|
+
}
|
|
223
|
+
},
|
|
142
224
|
{
|
|
143
225
|
"name": "sido",
|
|
144
226
|
"in": "query",
|