daiso 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/handlers.js +10 -0
- package/dist/core/errors.js +1 -0
- package/dist/index.js +2 -0
- package/dist/services/oliveyoung/transport.js +23 -4
- package/package.json +1 -1
package/dist/api/handlers.js
CHANGED
|
@@ -46,6 +46,8 @@ export async function handleOliveyoungSearchProducts(c) {
|
|
|
46
46
|
}, {
|
|
47
47
|
relayUrl: c.env?.OY_RELAY_URL,
|
|
48
48
|
relayToken: c.env?.OY_RELAY_TOKEN,
|
|
49
|
+
accessClientId: c.env?.OY_ACCESS_CLIENT_ID,
|
|
50
|
+
accessClientSecret: c.env?.OY_ACCESS_CLIENT_SECRET,
|
|
49
51
|
timeout: timeoutMs,
|
|
50
52
|
});
|
|
51
53
|
return successResponse(c, {
|
|
@@ -82,6 +84,8 @@ export async function handleOliveyoungFindStores(c) {
|
|
|
82
84
|
}, {
|
|
83
85
|
relayUrl: c.env?.OY_RELAY_URL,
|
|
84
86
|
relayToken: c.env?.OY_RELAY_TOKEN,
|
|
87
|
+
accessClientId: c.env?.OY_ACCESS_CLIENT_ID,
|
|
88
|
+
accessClientSecret: c.env?.OY_ACCESS_CLIENT_SECRET,
|
|
85
89
|
timeout: timeoutMs,
|
|
86
90
|
});
|
|
87
91
|
return successResponse(c, {
|
|
@@ -124,6 +128,8 @@ export async function handleOliveyoungCheckInventory(c) {
|
|
|
124
128
|
}, {
|
|
125
129
|
relayUrl: c.env?.OY_RELAY_URL,
|
|
126
130
|
relayToken: c.env?.OY_RELAY_TOKEN,
|
|
131
|
+
accessClientId: c.env?.OY_ACCESS_CLIENT_ID,
|
|
132
|
+
accessClientSecret: c.env?.OY_ACCESS_CLIENT_SECRET,
|
|
127
133
|
timeout: timeoutMs,
|
|
128
134
|
}),
|
|
129
135
|
fetchOliveyoungProducts({
|
|
@@ -135,6 +141,8 @@ export async function handleOliveyoungCheckInventory(c) {
|
|
|
135
141
|
}, {
|
|
136
142
|
relayUrl: c.env?.OY_RELAY_URL,
|
|
137
143
|
relayToken: c.env?.OY_RELAY_TOKEN,
|
|
144
|
+
accessClientId: c.env?.OY_ACCESS_CLIENT_ID,
|
|
145
|
+
accessClientSecret: c.env?.OY_ACCESS_CLIENT_SECRET,
|
|
138
146
|
timeout: timeoutMs,
|
|
139
147
|
}),
|
|
140
148
|
]);
|
|
@@ -146,6 +154,8 @@ export async function handleOliveyoungCheckInventory(c) {
|
|
|
146
154
|
}, {
|
|
147
155
|
relayUrl: c.env?.OY_RELAY_URL,
|
|
148
156
|
relayToken: c.env?.OY_RELAY_TOKEN,
|
|
157
|
+
accessClientId: c.env?.OY_ACCESS_CLIENT_ID,
|
|
158
|
+
accessClientSecret: c.env?.OY_ACCESS_CLIENT_SECRET,
|
|
149
159
|
timeout: timeoutMs,
|
|
150
160
|
});
|
|
151
161
|
const inStockCount = enrichedInventory.products.filter((product) => product.inStock).length;
|
package/dist/core/errors.js
CHANGED
|
@@ -62,6 +62,7 @@ export function toStandardErrorDiagnostics(code, message, options = {}) {
|
|
|
62
62
|
const oliveyoungRelayConfigurationError = [
|
|
63
63
|
'올리브영 릴레이 URL은 HTTPS 또는 로컬 HTTP 주소여야 합니다.',
|
|
64
64
|
'OY_RELAY_TOKEN이 필요합니다.',
|
|
65
|
+
'올리브영 Access 서비스 토큰 설정이 필요합니다.',
|
|
65
66
|
'올리브영 직접 요청 실패. 운영자는 OY_RELAY_URL과 OY_RELAY_TOKEN으로 브라우저 릴레이를 설정해주세요.',
|
|
66
67
|
].includes(message);
|
|
67
68
|
const retryable = !oliveyoungRelayConfigurationError &&
|
package/dist/index.js
CHANGED
|
@@ -87,6 +87,8 @@ const createRegistry = (bindings) => {
|
|
|
87
87
|
() => createOliveyoungService({
|
|
88
88
|
relayUrl: bindings?.OY_RELAY_URL,
|
|
89
89
|
relayToken: bindings?.OY_RELAY_TOKEN,
|
|
90
|
+
accessClientId: bindings?.OY_ACCESS_CLIENT_ID,
|
|
91
|
+
accessClientSecret: bindings?.OY_ACCESS_CLIENT_SECRET,
|
|
90
92
|
}),
|
|
91
93
|
]);
|
|
92
94
|
return registry;
|
|
@@ -4,7 +4,8 @@ import { OLIVEYOUNG_API } from './api.js';
|
|
|
4
4
|
export async function requestOliveyoung(path, body, options = {}) {
|
|
5
5
|
const { timeout = 15000, relayUrl, relayToken } = options;
|
|
6
6
|
const headers = {
|
|
7
|
-
'Content-Type': 'application/json',
|
|
7
|
+
'Content-Type': 'application/json',
|
|
8
|
+
Accept: 'application/json',
|
|
8
9
|
'X-Requested-With': 'XMLHttpRequest',
|
|
9
10
|
};
|
|
10
11
|
let url = `${OLIVEYOUNG_API.BASE_URL}${path}`;
|
|
@@ -16,19 +17,37 @@ export async function requestOliveyoung(path, body, options = {}) {
|
|
|
16
17
|
catch {
|
|
17
18
|
throw new Error('올리브영 릴레이 URL은 HTTPS 또는 로컬 HTTP 주소여야 합니다.');
|
|
18
19
|
}
|
|
19
|
-
if (relay.username ||
|
|
20
|
-
|
|
20
|
+
if (relay.username ||
|
|
21
|
+
relay.password ||
|
|
22
|
+
relay.search ||
|
|
23
|
+
relay.hash ||
|
|
24
|
+
(relay.protocol !== 'https:' &&
|
|
25
|
+
!(relay.protocol === 'http:' && ['127.0.0.1', 'localhost'].includes(relay.hostname)))) {
|
|
21
26
|
throw new Error('올리브영 릴레이 URL은 HTTPS 또는 로컬 HTTP 주소여야 합니다.');
|
|
22
27
|
}
|
|
23
28
|
if (!relayToken?.trim())
|
|
24
29
|
throw new Error('OY_RELAY_TOKEN이 필요합니다.');
|
|
25
30
|
url = `${relayUrl.replace(/\/$/, '')}/v1/oliveyoung/${path.split('/').pop()}`;
|
|
26
31
|
headers.Authorization = `Bearer ${relayToken}`;
|
|
32
|
+
const { accessClientId, accessClientSecret } = options;
|
|
33
|
+
if (accessClientId !== undefined || accessClientSecret !== undefined) {
|
|
34
|
+
if (!accessClientId?.trim() || !accessClientSecret?.trim()) {
|
|
35
|
+
throw new Error('올리브영 Access 서비스 토큰 설정이 필요합니다.');
|
|
36
|
+
}
|
|
37
|
+
headers['CF-Access-Client-Id'] = accessClientId;
|
|
38
|
+
headers['CF-Access-Client-Secret'] = accessClientSecret;
|
|
39
|
+
}
|
|
27
40
|
}
|
|
28
41
|
let result;
|
|
29
42
|
try {
|
|
30
43
|
result = await fetchJson(url, {
|
|
31
|
-
method: 'POST',
|
|
44
|
+
method: 'POST',
|
|
45
|
+
redirect: 'error',
|
|
46
|
+
headers,
|
|
47
|
+
body: JSON.stringify(body),
|
|
48
|
+
timeout,
|
|
49
|
+
retries: 0,
|
|
50
|
+
expectedStatus: 200,
|
|
32
51
|
});
|
|
33
52
|
}
|
|
34
53
|
catch (error) {
|
package/package.json
CHANGED