@hubcommerce/trendyol 1.0.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.
- package/CHANGELOG.md +47 -0
- package/LICENSE +21 -0
- package/README.md +257 -0
- package/dist/batch/poller.d.ts +23 -0
- package/dist/batch/poller.d.ts.map +1 -0
- package/dist/batch/poller.js +85 -0
- package/dist/batch/report.d.ts +15 -0
- package/dist/batch/report.d.ts.map +1 -0
- package/dist/batch/report.js +41 -0
- package/dist/batch/types.d.ts +4 -0
- package/dist/batch/types.d.ts.map +1 -0
- package/dist/batch/types.js +2 -0
- package/dist/claims/api.d.ts +48 -0
- package/dist/claims/api.d.ts.map +1 -0
- package/dist/claims/api.js +116 -0
- package/dist/claims/form.d.ts +9 -0
- package/dist/claims/form.d.ts.map +1 -0
- package/dist/claims/form.js +20 -0
- package/dist/claims/paths.d.ts +3 -0
- package/dist/claims/paths.d.ts.map +1 -0
- package/dist/claims/paths.js +8 -0
- package/dist/client.d.ts +39 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +66 -0
- package/dist/compensation/api.d.ts +17 -0
- package/dist/compensation/api.d.ts.map +1 -0
- package/dist/compensation/api.js +37 -0
- package/dist/compensation/paths.d.ts +2 -0
- package/dist/compensation/paths.d.ts.map +1 -0
- package/dist/compensation/paths.js +4 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +78 -0
- package/dist/connection.d.ts +4 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +8 -0
- package/dist/constants/claim-reasons.d.ts +10 -0
- package/dist/constants/claim-reasons.d.ts.map +1 -0
- package/dist/constants/claim-reasons.js +43 -0
- package/dist/constants/error-codes.d.ts +3 -0
- package/dist/constants/error-codes.d.ts.map +1 -0
- package/dist/constants/error-codes.js +9 -0
- package/dist/constants/origins.d.ts +6 -0
- package/dist/constants/origins.d.ts.map +1 -0
- package/dist/constants/origins.js +6 -0
- package/dist/constants/package-status.d.ts +3 -0
- package/dist/constants/package-status.d.ts.map +1 -0
- package/dist/constants/package-status.js +15 -0
- package/dist/constants/page-limits.d.ts +3 -0
- package/dist/constants/page-limits.d.ts.map +1 -0
- package/dist/constants/page-limits.js +9 -0
- package/dist/constants.d.ts +18 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +17 -0
- package/dist/errors.d.ts +27 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +113 -0
- package/dist/finance/api.d.ts +39 -0
- package/dist/finance/api.d.ts.map +1 -0
- package/dist/finance/api.js +165 -0
- package/dist/finance/paths.d.ts +6 -0
- package/dist/finance/paths.d.ts.map +1 -0
- package/dist/finance/paths.js +16 -0
- package/dist/http/multipart.d.ts +10 -0
- package/dist/http/multipart.d.ts.map +1 -0
- package/dist/http/multipart.js +1 -0
- package/dist/http/query.d.ts +5 -0
- package/dist/http/query.d.ts.map +1 -0
- package/dist/http/query.js +24 -0
- package/dist/http/response.d.ts +9 -0
- package/dist/http/response.d.ts.map +1 -0
- package/dist/http/response.js +37 -0
- package/dist/http/signals.d.ts +5 -0
- package/dist/http/signals.d.ts.map +1 -0
- package/dist/http/signals.js +26 -0
- package/dist/http.d.ts +14 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +180 -0
- package/dist/index.d.ts +61 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/inventory/api.d.ts +26 -0
- package/dist/inventory/api.d.ts.map +1 -0
- package/dist/inventory/api.js +51 -0
- package/dist/inventory/paths.d.ts +2 -0
- package/dist/inventory/paths.d.ts.map +1 -0
- package/dist/inventory/paths.js +4 -0
- package/dist/invoices/api.d.ts +23 -0
- package/dist/invoices/api.d.ts.map +1 -0
- package/dist/invoices/api.js +52 -0
- package/dist/labels/api.d.ts +45 -0
- package/dist/labels/api.d.ts.map +1 -0
- package/dist/labels/api.js +89 -0
- package/dist/labels/paths.d.ts +3 -0
- package/dist/labels/paths.d.ts.map +1 -0
- package/dist/labels/paths.js +7 -0
- package/dist/logger.d.ts +6 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +47 -0
- package/dist/orders/api.d.ts +68 -0
- package/dist/orders/api.d.ts.map +1 -0
- package/dist/orders/api.js +69 -0
- package/dist/orders/created-by.d.ts +4 -0
- package/dist/orders/created-by.d.ts.map +1 -0
- package/dist/orders/created-by.js +9 -0
- package/dist/orders/mutations.d.ts +31 -0
- package/dist/orders/mutations.d.ts.map +1 -0
- package/dist/orders/mutations.js +139 -0
- package/dist/orders/paths.d.ts +4 -0
- package/dist/orders/paths.d.ts.map +1 -0
- package/dist/orders/paths.js +12 -0
- package/dist/orders/read.d.ts +35 -0
- package/dist/orders/read.d.ts.map +1 -0
- package/dist/orders/read.js +140 -0
- package/dist/orders/split.d.ts +17 -0
- package/dist/orders/split.d.ts.map +1 -0
- package/dist/orders/split.js +45 -0
- package/dist/orders/status.d.ts +9 -0
- package/dist/orders/status.d.ts.map +1 -0
- package/dist/orders/status.js +20 -0
- package/dist/orders/stream.d.ts +19 -0
- package/dist/orders/stream.d.ts.map +1 -0
- package/dist/orders/stream.js +26 -0
- package/dist/orders/warranty.d.ts +24 -0
- package/dist/orders/warranty.d.ts.map +1 -0
- package/dist/orders/warranty.js +30 -0
- package/dist/pagination.d.ts +23 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +34 -0
- package/dist/products/api.d.ts +52 -0
- package/dist/products/api.d.ts.map +1 -0
- package/dist/products/api.js +222 -0
- package/dist/products/builder.d.ts +22 -0
- package/dist/products/builder.d.ts.map +1 -0
- package/dist/products/builder.js +89 -0
- package/dist/products/paths.d.ts +7 -0
- package/dist/products/paths.d.ts.map +1 -0
- package/dist/products/paths.js +20 -0
- package/dist/qna/api.d.ts +32 -0
- package/dist/qna/api.d.ts.map +1 -0
- package/dist/qna/api.js +78 -0
- package/dist/qna/paths.d.ts +5 -0
- package/dist/qna/paths.d.ts.map +1 -0
- package/dist/qna/paths.js +13 -0
- package/dist/rate-limit/governor.d.ts +11 -0
- package/dist/rate-limit/governor.d.ts.map +1 -0
- package/dist/rate-limit/governor.js +25 -0
- package/dist/rate-limit/groups.d.ts +15 -0
- package/dist/rate-limit/groups.d.ts.map +1 -0
- package/dist/rate-limit/groups.js +14 -0
- package/dist/reference/addresses-cache.d.ts +13 -0
- package/dist/reference/addresses-cache.d.ts.map +1 -0
- package/dist/reference/addresses-cache.js +33 -0
- package/dist/reference/api.d.ts +48 -0
- package/dist/reference/api.d.ts.map +1 -0
- package/dist/reference/api.js +215 -0
- package/dist/reference/paths.d.ts +12 -0
- package/dist/reference/paths.d.ts.map +1 -0
- package/dist/reference/paths.js +34 -0
- package/dist/retry.d.ts +6 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +37 -0
- package/dist/testing/fixtures/batch-partial-fail.json +12 -0
- package/dist/testing/fixtures/shipment-package.json +5 -0
- package/dist/testing/fixtures/webhook-payload.json +4 -0
- package/dist/testing/fixtures.d.ts +23 -0
- package/dist/testing/fixtures.d.ts.map +1 -0
- package/dist/testing/fixtures.js +9 -0
- package/dist/testing/guard.d.ts +13 -0
- package/dist/testing/guard.d.ts.map +1 -0
- package/dist/testing/guard.js +32 -0
- package/dist/testing/index.d.ts +6 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +4 -0
- package/dist/testing/paths.d.ts +5 -0
- package/dist/testing/paths.d.ts.map +1 -0
- package/dist/testing/paths.js +14 -0
- package/dist/testing/stage-helpers.d.ts +24 -0
- package/dist/testing/stage-helpers.d.ts.map +1 -0
- package/dist/testing/stage-helpers.js +64 -0
- package/dist/testing/types.d.ts +66 -0
- package/dist/testing/types.d.ts.map +1 -0
- package/dist/testing/types.js +1 -0
- package/dist/types/claims.d.ts +132 -0
- package/dist/types/claims.d.ts.map +1 -0
- package/dist/types/claims.js +1 -0
- package/dist/types/compensation.d.ts +32 -0
- package/dist/types/compensation.d.ts.map +1 -0
- package/dist/types/compensation.js +20 -0
- package/dist/types/finance.d.ts +98 -0
- package/dist/types/finance.d.ts.map +1 -0
- package/dist/types/finance.js +1 -0
- package/dist/types/inventory.d.ts +12 -0
- package/dist/types/inventory.d.ts.map +1 -0
- package/dist/types/inventory.js +1 -0
- package/dist/types/labels.d.ts +19 -0
- package/dist/types/labels.d.ts.map +1 -0
- package/dist/types/labels.js +1 -0
- package/dist/types/orders.d.ts +276 -0
- package/dist/types/orders.d.ts.map +1 -0
- package/dist/types/orders.js +1 -0
- package/dist/types/products.d.ts +99 -0
- package/dist/types/products.d.ts.map +1 -0
- package/dist/types/products.js +1 -0
- package/dist/types/qna.d.ts +51 -0
- package/dist/types/qna.d.ts.map +1 -0
- package/dist/types/qna.js +6 -0
- package/dist/types/reference.d.ts +78 -0
- package/dist/types/reference.d.ts.map +1 -0
- package/dist/types/reference.js +1 -0
- package/dist/types/webhooks.d.ts +47 -0
- package/dist/types/webhooks.d.ts.map +1 -0
- package/dist/types/webhooks.js +19 -0
- package/dist/types.d.ts +73 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/validate.d.ts +9 -0
- package/dist/validate.d.ts.map +1 -0
- package/dist/validate.js +70 -0
- package/dist/video/api.d.ts +46 -0
- package/dist/video/api.d.ts.map +1 -0
- package/dist/video/api.js +95 -0
- package/dist/video/paths.d.ts +3 -0
- package/dist/video/paths.d.ts.map +1 -0
- package/dist/video/paths.js +7 -0
- package/dist/webhooks/inbound.d.ts +33 -0
- package/dist/webhooks/inbound.d.ts.map +1 -0
- package/dist/webhooks/inbound.js +113 -0
- package/dist/webhooks/management.d.ts +49 -0
- package/dist/webhooks/management.d.ts.map +1 -0
- package/dist/webhooks/management.js +89 -0
- package/dist/webhooks/paths.d.ts +5 -0
- package/dist/webhooks/paths.d.ts.map +1 -0
- package/dist/webhooks/paths.js +13 -0
- package/package.json +47 -0
package/dist/http.js
ADDED
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { buildBasicAuthHeader, buildUserAgent, resolveGatewayUrl, } from "./config.js";
|
|
2
|
+
import { isHtmlGatewayError, parseApiError, toFailure, TrendyolTransportError, } from "./errors.js";
|
|
3
|
+
import { forbiddenPathGuard } from "./testing/guard.js";
|
|
4
|
+
import { buildQuery } from "./http/query.js";
|
|
5
|
+
import { parseJsonResponse } from "./http/response.js";
|
|
6
|
+
import { combineAbortSignals } from "./http/signals.js";
|
|
7
|
+
import { trendyolLog, truncateBody } from "./logger.js";
|
|
8
|
+
import { computeRetryDelayMs, shouldRetryStatus, sleep } from "./retry.js";
|
|
9
|
+
export class TrendyolHttpClient {
|
|
10
|
+
config;
|
|
11
|
+
governor;
|
|
12
|
+
hooks = {};
|
|
13
|
+
constructor(config, governor) {
|
|
14
|
+
this.config = config;
|
|
15
|
+
this.governor = governor;
|
|
16
|
+
}
|
|
17
|
+
setHooks(hooks) {
|
|
18
|
+
this.hooks = hooks;
|
|
19
|
+
}
|
|
20
|
+
getHooks() {
|
|
21
|
+
return this.hooks;
|
|
22
|
+
}
|
|
23
|
+
async requestJson(options) {
|
|
24
|
+
try {
|
|
25
|
+
forbiddenPathGuard(this.config, options.path);
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
return toFailure(error);
|
|
29
|
+
}
|
|
30
|
+
const query = options.query ? buildQuery(options.query) : "";
|
|
31
|
+
const url = `${resolveGatewayUrl(this.config, options.path)}${query}`;
|
|
32
|
+
if (this.config.enableClientSideLimiter && this.governor) {
|
|
33
|
+
await this.governor.acquire(options.path);
|
|
34
|
+
}
|
|
35
|
+
for (let attempt = 0; attempt <= this.config.maxRetries; attempt += 1) {
|
|
36
|
+
const started = Date.now();
|
|
37
|
+
const timeoutSignal = AbortSignal.timeout(this.config.requestTimeoutMs);
|
|
38
|
+
const signal = combineAbortSignals(timeoutSignal, options.signal);
|
|
39
|
+
trendyolLog(this.config.debug, "debug", "request", {
|
|
40
|
+
method: options.method,
|
|
41
|
+
url,
|
|
42
|
+
attempt,
|
|
43
|
+
retryPolicy: options.retryPolicy,
|
|
44
|
+
body: options.body ? truncateBody(JSON.stringify(options.body)) : undefined,
|
|
45
|
+
});
|
|
46
|
+
try {
|
|
47
|
+
const response = await fetch(url, {
|
|
48
|
+
method: options.method,
|
|
49
|
+
headers: {
|
|
50
|
+
Authorization: buildBasicAuthHeader(this.config.apiKey, this.config.apiSecret),
|
|
51
|
+
"User-Agent": buildUserAgent(this.config.integratorName, this.config.sellerId),
|
|
52
|
+
storeFrontCode: this.config.storeFrontCode,
|
|
53
|
+
"Content-Type": "application/json",
|
|
54
|
+
...options.headers,
|
|
55
|
+
},
|
|
56
|
+
body: options.body === undefined ? undefined : JSON.stringify(options.body),
|
|
57
|
+
signal,
|
|
58
|
+
});
|
|
59
|
+
const parsed = await parseJsonResponse(response);
|
|
60
|
+
const { data, rawText } = parsed;
|
|
61
|
+
trendyolLog(this.config.debug, "debug", "response", {
|
|
62
|
+
method: options.method,
|
|
63
|
+
url,
|
|
64
|
+
status: response.status,
|
|
65
|
+
durationMs: Date.now() - started,
|
|
66
|
+
body: truncateBody(rawText),
|
|
67
|
+
});
|
|
68
|
+
if (shouldRetryStatus(response.status, options.retryPolicy) &&
|
|
69
|
+
attempt < this.config.maxRetries) {
|
|
70
|
+
const delay = computeRetryDelayMs(this.config, attempt, response.headers.get("Retry-After"), response.headers.get("X-RateLimit-Reset"));
|
|
71
|
+
this.hooks.onRetry?.({ attempt, status: response.status, delayMs: delay });
|
|
72
|
+
if (response.status === 429) {
|
|
73
|
+
this.hooks.onRateLimitHit?.({
|
|
74
|
+
retryAfterMs: delay,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
await sleep(delay);
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (!response.ok) {
|
|
81
|
+
const apiError = parseApiError(response.status, data ?? rawText, response.headers);
|
|
82
|
+
if (isHtmlGatewayError(apiError) &&
|
|
83
|
+
options.retryPolicy === "safe" &&
|
|
84
|
+
attempt < this.config.maxRetries) {
|
|
85
|
+
const delay = computeRetryDelayMs(this.config, attempt);
|
|
86
|
+
this.hooks.onRetry?.({ attempt, status: response.status, delayMs: delay });
|
|
87
|
+
await sleep(delay);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
return toFailure(apiError);
|
|
91
|
+
}
|
|
92
|
+
return { ok: true, data: data ?? null };
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
const retryable = options.retryPolicy === "safe";
|
|
96
|
+
const transport = error instanceof Error
|
|
97
|
+
? new TrendyolTransportError(error.message, { retryable })
|
|
98
|
+
: new TrendyolTransportError("Trendyol transport hatasi.", { retryable });
|
|
99
|
+
trendyolLog(this.config.debug, "warn", "request failed", {
|
|
100
|
+
method: options.method,
|
|
101
|
+
url,
|
|
102
|
+
attempt,
|
|
103
|
+
error: transport.message,
|
|
104
|
+
});
|
|
105
|
+
if (retryable && attempt < this.config.maxRetries) {
|
|
106
|
+
const delay = computeRetryDelayMs(this.config, attempt);
|
|
107
|
+
this.hooks.onRetry?.({ attempt, delayMs: delay });
|
|
108
|
+
await sleep(delay);
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
return toFailure(transport);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
ok: false,
|
|
116
|
+
reason: "Trendyol istegi maksimum deneme sayisina ulasti.",
|
|
117
|
+
retryable: options.retryPolicy === "safe",
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
async requestMultipart(options) {
|
|
121
|
+
try {
|
|
122
|
+
forbiddenPathGuard(this.config, options.path);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
return toFailure(error);
|
|
126
|
+
}
|
|
127
|
+
const query = options.query ? buildQuery(options.query) : "";
|
|
128
|
+
const url = `${resolveGatewayUrl(this.config, options.path)}${query}`;
|
|
129
|
+
if (this.config.enableClientSideLimiter && this.governor) {
|
|
130
|
+
await this.governor.acquire(options.path);
|
|
131
|
+
}
|
|
132
|
+
for (let attempt = 0; attempt <= this.config.maxRetries; attempt += 1) {
|
|
133
|
+
const timeoutSignal = AbortSignal.timeout(this.config.requestTimeoutMs);
|
|
134
|
+
const signal = combineAbortSignals(timeoutSignal, options.signal);
|
|
135
|
+
try {
|
|
136
|
+
const response = await fetch(url, {
|
|
137
|
+
method: options.method,
|
|
138
|
+
headers: {
|
|
139
|
+
Authorization: buildBasicAuthHeader(this.config.apiKey, this.config.apiSecret),
|
|
140
|
+
"User-Agent": buildUserAgent(this.config.integratorName, this.config.sellerId),
|
|
141
|
+
storeFrontCode: this.config.storeFrontCode,
|
|
142
|
+
...options.headers,
|
|
143
|
+
},
|
|
144
|
+
body: options.formData,
|
|
145
|
+
signal,
|
|
146
|
+
});
|
|
147
|
+
const parsed = await parseJsonResponse(response);
|
|
148
|
+
const { data, rawText } = parsed;
|
|
149
|
+
if (shouldRetryStatus(response.status, options.retryPolicy) &&
|
|
150
|
+
attempt < this.config.maxRetries) {
|
|
151
|
+
const delay = computeRetryDelayMs(this.config, attempt, response.headers.get("Retry-After"), response.headers.get("X-RateLimit-Reset"));
|
|
152
|
+
await sleep(delay);
|
|
153
|
+
continue;
|
|
154
|
+
}
|
|
155
|
+
if (!response.ok) {
|
|
156
|
+
return toFailure(parseApiError(response.status, data ?? rawText, response.headers));
|
|
157
|
+
}
|
|
158
|
+
return { ok: true, data: data ?? null };
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
const retryable = options.retryPolicy === "safe";
|
|
162
|
+
const transport = error instanceof Error
|
|
163
|
+
? new TrendyolTransportError(error.message, { retryable })
|
|
164
|
+
: new TrendyolTransportError("Trendyol multipart transport hatasi.", {
|
|
165
|
+
retryable,
|
|
166
|
+
});
|
|
167
|
+
if (retryable && attempt < this.config.maxRetries) {
|
|
168
|
+
await sleep(computeRetryDelayMs(this.config, attempt));
|
|
169
|
+
continue;
|
|
170
|
+
}
|
|
171
|
+
return toFailure(transport);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
ok: false,
|
|
176
|
+
reason: "Trendyol multipart istegi maksimum deneme sayisina ulasti.",
|
|
177
|
+
retryable: options.retryPolicy === "safe",
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export { createTrendyolClient, TrendyolClient } from "./client.js";
|
|
2
|
+
export { OrdersApi } from "./orders/api.js";
|
|
3
|
+
export { ClaimsApi } from "./claims/api.js";
|
|
4
|
+
export { buildClaimIssueFormData } from "./claims/form.js";
|
|
5
|
+
export type { BuildClaimIssueFormDataInput } from "./claims/form.js";
|
|
6
|
+
export { InvoicesApi } from "./invoices/api.js";
|
|
7
|
+
export { InventoryApi } from "./inventory/api.js";
|
|
8
|
+
export { ReferenceApi } from "./reference/api.js";
|
|
9
|
+
export { ProductsApi } from "./products/api.js";
|
|
10
|
+
export { VideoApi } from "./video/api.js";
|
|
11
|
+
export { WarrantyApi } from "./orders/warranty.js";
|
|
12
|
+
export { WebhooksApi } from "./webhooks/management.js";
|
|
13
|
+
export { FinanceApi } from "./finance/api.js";
|
|
14
|
+
export { QnaApi } from "./qna/api.js";
|
|
15
|
+
export { LabelsApi, isCommonLabelNotAllowed } from "./labels/api.js";
|
|
16
|
+
export { CompensationApi } from "./compensation/api.js";
|
|
17
|
+
export { extractPackageStatus, isWebhookPayload, parseWebhookPayload, verifyWebhookApiKey, verifyWebhookBasicAuth, WebhookPayloadTooLargeError, } from "./webhooks/inbound.js";
|
|
18
|
+
export type { ParseWebhookPayloadOptions, VerifyWebhookApiKeyOptions, WebhookHeaderSource, } from "./webhooks/inbound.js";
|
|
19
|
+
export { buildProductCreatePayload } from "./products/builder.js";
|
|
20
|
+
export type { BuildProductPayloadOptions } from "./products/builder.js";
|
|
21
|
+
export { BatchPoller } from "./batch/poller.js";
|
|
22
|
+
export type { WaitForBatchOptions } from "./batch/poller.js";
|
|
23
|
+
export { SUPPLIER_ADDRESSES_CACHE_TTL_MS } from "./reference/addresses-cache.js";
|
|
24
|
+
export { CREATED_BY_VALUES, isCreatedBy, type CreatedBy, } from "./orders/created-by.js";
|
|
25
|
+
export { isPackageStatus, isUpdatePackageStatusValue, UPDATE_PACKAGE_STATUS_VALUES, validateUpdatePackageStatus, type UpdatePackageStatusValue, } from "./orders/status.js";
|
|
26
|
+
export type { PriceAndInventoryItem, UpdatePriceAndInventoryResponse, } from "./types/inventory.js";
|
|
27
|
+
export type { ArchiveProductsBody, BuyboxInformationBody, BuyboxInformationItem, BuyboxInformationResponse, DeleteProductsBody, ProductAttribute, ProductBaseResponse, ProductBatchSubmitResponse, ProductCreateItem, ProductFilterParams, ProductFilterResponse, ProductImage, UnlockProductsBody, UpdateAuditEntry, UpdateAuditsResponse, } from "./types/products.js";
|
|
28
|
+
export type { CreateVideoBody, CreateVideoResponse, ListVideosResponse, VideoListItem, WaitForVideoOptions, } from "./video/api.js";
|
|
29
|
+
export type { UploadWarrantyDocumentFields } from "./orders/warranty.js";
|
|
30
|
+
export type { CreateWebhookBody, CreateWebhookResponse, UpdateWebhookBody, WebhookAuthenticationType, WebhookParseErrorCode, WebhookParseResult, WebhookPayload, WebhookRegistration, WebhookRegistrationStatus, WebhookSubscribedStatus, } from "./types/webhooks.js";
|
|
31
|
+
export { WEBHOOK_SUBSCRIBED_STATUSES } from "./types/webhooks.js";
|
|
32
|
+
export type { AnswerQuestionBody, GetQuestionsParams, Question, QuestionAnswer, QuestionOrderByDirection, QuestionOrderByField, QuestionStatus, QuestionsListResponse, } from "./types/qna.js";
|
|
33
|
+
export { QUESTION_STATUSES } from "./types/qna.js";
|
|
34
|
+
export type { CargoInvoiceItem, CargoInvoiceItemsResponse, FinancePageResponse, FinancialTransaction, GetCargoInvoiceItemsParams, GetOtherFinancialsParams, GetPaymentOrdersParams, GetSettlementDetailsParams, GetSettlementsParams, OtherFinancialTransactionType, PaymentOrder, PaymentOrdersResponse, SettlementDetails, SettlementTransactionType, } from "./types/finance.js";
|
|
35
|
+
export type { CommonLabelFormat, CommonLabelItem, CommonLabelResponse, CreateCommonLabelBody, LabelType, ProductLabelType, } from "./types/labels.js";
|
|
36
|
+
export type { CompensationItemDetail, CompensationTicket, CompensationTicketState, CompensationTicketsResponse, GetCompensationTicketsParams, } from "./types/compensation.js";
|
|
37
|
+
export { COMPENSATION_TICKET_STATES } from "./types/compensation.js";
|
|
38
|
+
export type { ApproveClaimLineItemsBody, Claim, ClaimItemAudit, ClaimItemStatusFilter, ClaimIssueReason, ClaimLineItem, ClaimsListResponse, CreateClaimBody, CreateClaimIssueFields, CreateClaimItemInput, CreateClaimResponse, GetClaimsParams, } from "./types/claims.js";
|
|
39
|
+
export type { Brand, BrandsListResponse, CargoProvider, CategoryAttribute, CategoryAttributeValue, CategoryAttributesResponse, CategoryAttributeValuesResponse, CreateBrandParams, GeoItem, GetBrandsByNameParams, GetBrandsParams, SupplierAddress, } from "./types/reference.js";
|
|
40
|
+
export type { Address, CancelUnsuppliedBody, DeleteInvoiceLinkBody, DiscountDisplay, GetShipmentPackagesParams, GetShipmentPackagesStreamParams, LineDiscountDetail, OrderLine, ProcessAlternativeDeliveryBody, SendInvoiceLinkBody, ShipmentPackage, ShipmentPackageListResponse, ShipmentPackageStreamResponse, SplitByQuantityBody, SplitMultiPackageByQuantityBody, SplitShipmentPackageBody, StreamPackagesOptions, UpdateBoxInfoBody, UpdatePackageStatusBody, UploadInvoiceFileFields, } from "./types/orders.js";
|
|
41
|
+
export { getTrendyolConfig, isTrendyolConfigured, TrendyolConfigError } from "./config.js";
|
|
42
|
+
export { TRENDYOL_TEST_CONNECTION_PATH } from "./constants.js";
|
|
43
|
+
export { PACKAGE_STATUSES, type PackageStatus } from "./constants/package-status.js";
|
|
44
|
+
export { CLAIM_REASONS } from "./constants/claim-reasons.js";
|
|
45
|
+
export { ORIGIN_COUNTRIES } from "./constants/origins.js";
|
|
46
|
+
export { TRENDYOL_ERROR_CODES } from "./constants/error-codes.js";
|
|
47
|
+
export { MAX_PAGE_SIZE } from "./constants/page-limits.js";
|
|
48
|
+
export { testConnection } from "./connection.js";
|
|
49
|
+
export { TrendyolApiError, TrendyolTransportError, isHtmlGatewayError, isHtmlErrorBody, isRetryableError, isTransientGatewayError, parseApiError, } from "./errors.js";
|
|
50
|
+
export { collectBatchFailureReasons, hasPartialBatchFailures, parseBatchRequestReport, } from "./batch/report.js";
|
|
51
|
+
export type { BatchItemResult, BatchRequestReport } from "./batch/report.js";
|
|
52
|
+
export { applyLookback, buildStreamQueryParams, DEFAULT_STREAM_LOOKBACK_MS, resolveStreamStartDate, } from "./orders/stream.js";
|
|
53
|
+
export type { MultipartRequestOptions } from "./http/multipart.js";
|
|
54
|
+
export { TrendyolHttpClient } from "./http.js";
|
|
55
|
+
export { buildQuery } from "./http/query.js";
|
|
56
|
+
export { combineAbortSignals } from "./http/signals.js";
|
|
57
|
+
export { setTrendyolLogger } from "./logger.js";
|
|
58
|
+
export { fetchAllPages, normalizeListResponse } from "./pagination.js";
|
|
59
|
+
export type { CategoryTreeNode, CategoryTreeResponse, CursorPage, PageParams, TokenPage, TrendyolConfig, TrendyolEnv, TrendyolHooks, TrendyolResult, } from "./types.js";
|
|
60
|
+
export { validateBatchSize, validateEan13, validatePageSize, validatePrices, validateQuantity, validateSellerId, } from "./validate.js";
|
|
61
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,YAAY,EAAE,4BAA4B,EAAE,MAAM,kBAAkB,CAAC;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AC1D,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,0BAA0B,EAC1B,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACvE,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,UAAU,EACV,SAAS,EACT,cAAc,EACd,WAAW,EACX,aAAa,EACb,cAAc,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export { createTrendyolClient, TrendyolClient } from "./client.js";
|
|
2
|
+
export { OrdersApi } from "./orders/api.js";
|
|
3
|
+
export { ClaimsApi } from "./claims/api.js";
|
|
4
|
+
export { buildClaimIssueFormData } from "./claims/form.js";
|
|
5
|
+
export { InvoicesApi } from "./invoices/api.js";
|
|
6
|
+
export { InventoryApi } from "./inventory/api.js";
|
|
7
|
+
export { ReferenceApi } from "./reference/api.js";
|
|
8
|
+
export { ProductsApi } from "./products/api.js";
|
|
9
|
+
export { VideoApi } from "./video/api.js";
|
|
10
|
+
export { WarrantyApi } from "./orders/warranty.js";
|
|
11
|
+
export { WebhooksApi } from "./webhooks/management.js";
|
|
12
|
+
export { FinanceApi } from "./finance/api.js";
|
|
13
|
+
export { QnaApi } from "./qna/api.js";
|
|
14
|
+
export { LabelsApi, isCommonLabelNotAllowed } from "./labels/api.js";
|
|
15
|
+
export { CompensationApi } from "./compensation/api.js";
|
|
16
|
+
export { extractPackageStatus, isWebhookPayload, parseWebhookPayload, verifyWebhookApiKey, verifyWebhookBasicAuth, WebhookPayloadTooLargeError, } from "./webhooks/inbound.js";
|
|
17
|
+
export { buildProductCreatePayload } from "./products/builder.js";
|
|
18
|
+
export { BatchPoller } from "./batch/poller.js";
|
|
19
|
+
export { SUPPLIER_ADDRESSES_CACHE_TTL_MS } from "./reference/addresses-cache.js";
|
|
20
|
+
export { CREATED_BY_VALUES, isCreatedBy, } from "./orders/created-by.js";
|
|
21
|
+
export { isPackageStatus, isUpdatePackageStatusValue, UPDATE_PACKAGE_STATUS_VALUES, validateUpdatePackageStatus, } from "./orders/status.js";
|
|
22
|
+
export { WEBHOOK_SUBSCRIBED_STATUSES } from "./types/webhooks.js";
|
|
23
|
+
export { QUESTION_STATUSES } from "./types/qna.js";
|
|
24
|
+
export { COMPENSATION_TICKET_STATES } from "./types/compensation.js";
|
|
25
|
+
export { getTrendyolConfig, isTrendyolConfigured, TrendyolConfigError } from "./config.js";
|
|
26
|
+
export { TRENDYOL_TEST_CONNECTION_PATH } from "./constants.js";
|
|
27
|
+
export { PACKAGE_STATUSES } from "./constants/package-status.js";
|
|
28
|
+
export { CLAIM_REASONS } from "./constants/claim-reasons.js";
|
|
29
|
+
export { ORIGIN_COUNTRIES } from "./constants/origins.js";
|
|
30
|
+
export { TRENDYOL_ERROR_CODES } from "./constants/error-codes.js";
|
|
31
|
+
export { MAX_PAGE_SIZE } from "./constants/page-limits.js";
|
|
32
|
+
export { testConnection } from "./connection.js";
|
|
33
|
+
export { TrendyolApiError, TrendyolTransportError, isHtmlGatewayError, isHtmlErrorBody, isRetryableError, isTransientGatewayError, parseApiError, } from "./errors.js";
|
|
34
|
+
export { collectBatchFailureReasons, hasPartialBatchFailures, parseBatchRequestReport, } from "./batch/report.js";
|
|
35
|
+
export { applyLookback, buildStreamQueryParams, DEFAULT_STREAM_LOOKBACK_MS, resolveStreamStartDate, } from "./orders/stream.js";
|
|
36
|
+
export { TrendyolHttpClient } from "./http.js";
|
|
37
|
+
export { buildQuery } from "./http/query.js";
|
|
38
|
+
export { combineAbortSignals } from "./http/signals.js";
|
|
39
|
+
export { setTrendyolLogger } from "./logger.js";
|
|
40
|
+
export { fetchAllPages, normalizeListResponse } from "./pagination.js";
|
|
41
|
+
export { validateBatchSize, validateEan13, validatePageSize, validatePrices, validateQuantity, validateSellerId, } from "./validate.js";
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TrendyolHttpClient } from "../http.js";
|
|
2
|
+
import type { TrendyolConfig, TrendyolResult } from "../types.js";
|
|
3
|
+
import type { PriceAndInventoryItem, UpdatePriceAndInventoryResponse } from "../types/inventory.js";
|
|
4
|
+
type InventoryOptions = {
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Stok ve fiyat guncelleme API.
|
|
9
|
+
*
|
|
10
|
+
* - En fazla 1000 SKU/istek
|
|
11
|
+
* - Ayni urun icin 15 dk tekrar guncelleme kilidi (adapter debounce onerilir)
|
|
12
|
+
* - {@link validateQuantity} `quantity === 0` kabul eder; **satis durabilir**
|
|
13
|
+
*/
|
|
14
|
+
export declare class InventoryApi {
|
|
15
|
+
private readonly http;
|
|
16
|
+
private readonly config;
|
|
17
|
+
constructor(http: TrendyolHttpClient, config: TrendyolConfig);
|
|
18
|
+
/**
|
|
19
|
+
* POST /inventory/sellers/{sellerId}/products/price-and-inventory
|
|
20
|
+
*
|
|
21
|
+
* `quantity: 0` gecerlidir — urun satisi durabilir; bilincli kullanin.
|
|
22
|
+
*/
|
|
23
|
+
updatePriceAndInventory(items: PriceAndInventoryItem[], options?: InventoryOptions): Promise<TrendyolResult<UpdatePriceAndInventoryResponse>>;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/inventory/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EACV,qBAAqB,EACrB,+BAA+B,EAChC,MAAM,uBAAuB,CAAC;AAI/B,KAAK,gBAAgB,GAAG;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAEjD;;;;;;GAMG;AACH,qBAAa,YAAY;IAErB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,cAAc;IAGzC;;;;OAIG;IACH,uBAAuB,CACrB,KAAK,EAAE,qBAAqB,EAAE,EAC9B,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,cAAc,CAAC,+BAA+B,CAAC,CAAC;CAuC5D"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { validateBatchSize, validatePrices, validateQuantity } from "../validate.js";
|
|
2
|
+
import { inventorySellerBase } from "./paths.js";
|
|
3
|
+
/**
|
|
4
|
+
* Stok ve fiyat guncelleme API.
|
|
5
|
+
*
|
|
6
|
+
* - En fazla 1000 SKU/istek
|
|
7
|
+
* - Ayni urun icin 15 dk tekrar guncelleme kilidi (adapter debounce onerilir)
|
|
8
|
+
* - {@link validateQuantity} `quantity === 0` kabul eder; **satis durabilir**
|
|
9
|
+
*/
|
|
10
|
+
export class InventoryApi {
|
|
11
|
+
http;
|
|
12
|
+
config;
|
|
13
|
+
constructor(http, config) {
|
|
14
|
+
this.http = http;
|
|
15
|
+
this.config = config;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* POST /inventory/sellers/{sellerId}/products/price-and-inventory
|
|
19
|
+
*
|
|
20
|
+
* `quantity: 0` gecerlidir — urun satisi durabilir; bilincli kullanin.
|
|
21
|
+
*/
|
|
22
|
+
updatePriceAndInventory(items, options) {
|
|
23
|
+
const batchValidation = validateBatchSize(items.length, 1000);
|
|
24
|
+
if (!batchValidation.ok) {
|
|
25
|
+
return Promise.resolve(batchValidation);
|
|
26
|
+
}
|
|
27
|
+
for (const item of items) {
|
|
28
|
+
const quantityValidation = validateQuantity(item.quantity);
|
|
29
|
+
if (!quantityValidation.ok) {
|
|
30
|
+
return Promise.resolve(quantityValidation);
|
|
31
|
+
}
|
|
32
|
+
const priceValidation = validatePrices(item.listPrice, item.salePrice);
|
|
33
|
+
if (!priceValidation.ok) {
|
|
34
|
+
return Promise.resolve(priceValidation);
|
|
35
|
+
}
|
|
36
|
+
if (!item.barcode.trim()) {
|
|
37
|
+
return Promise.resolve({
|
|
38
|
+
ok: false,
|
|
39
|
+
reason: "barcode bos olamaz.",
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return this.http.requestJson({
|
|
44
|
+
method: "POST",
|
|
45
|
+
path: `${inventorySellerBase(this.config.sellerId)}/products/price-and-inventory`,
|
|
46
|
+
body: { items },
|
|
47
|
+
retryPolicy: "none",
|
|
48
|
+
signal: options?.signal,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/inventory/paths.ts"],"names":[],"mappings":"AAEA,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAE5D"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { TrendyolHttpClient } from "../http.js";
|
|
2
|
+
import type { TrendyolConfig, TrendyolResult } from "../types.js";
|
|
3
|
+
import type { DeleteInvoiceLinkBody, SendInvoiceLinkBody, UploadInvoiceFileFields } from "../types/orders.js";
|
|
4
|
+
type InvoiceOptions = {
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Fatura API — link, dosya, silme.
|
|
9
|
+
*
|
|
10
|
+
* Invoiced tuzağı: `updatePackageStatus(..., 'Invoiced')` fatura gonderimi degildir.
|
|
11
|
+
* Hatali fatura: deleteInvoiceLink → yeniden send/upload.
|
|
12
|
+
* Ayni invoiceNumber → INVOICE_NUMBER_ALREADY_EXISTS (yeni numara gerekir).
|
|
13
|
+
*/
|
|
14
|
+
export declare class InvoicesApi {
|
|
15
|
+
private readonly http;
|
|
16
|
+
private readonly config;
|
|
17
|
+
constructor(http: TrendyolHttpClient, config: TrendyolConfig);
|
|
18
|
+
sendInvoiceLink(body: SendInvoiceLinkBody, options?: InvoiceOptions): Promise<TrendyolResult<unknown>>;
|
|
19
|
+
deleteInvoiceLink(body: DeleteInvoiceLinkBody, options?: InvoiceOptions): Promise<TrendyolResult<unknown>>;
|
|
20
|
+
uploadInvoiceFile(fields: UploadInvoiceFileFields, options?: InvoiceOptions): Promise<TrendyolResult<unknown>>;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/invoices/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,oBAAoB,CAAC;AAG5B,KAAK,cAAc,GAAG;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAE/C;;;;;;GAMG;AACH,qBAAa,WAAW;IAEpB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,cAAc;IAGzC,eAAe,CACb,IAAI,EAAE,mBAAmB,EACzB,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAUnC,iBAAiB,CACf,IAAI,EAAE,qBAAqB,EAC3B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAUnC,iBAAiB,CACf,MAAM,EAAE,uBAAuB,EAC/B,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;CAuBpC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { sellerBase } from "../orders/paths.js";
|
|
2
|
+
/**
|
|
3
|
+
* Fatura API — link, dosya, silme.
|
|
4
|
+
*
|
|
5
|
+
* Invoiced tuzağı: `updatePackageStatus(..., 'Invoiced')` fatura gonderimi degildir.
|
|
6
|
+
* Hatali fatura: deleteInvoiceLink → yeniden send/upload.
|
|
7
|
+
* Ayni invoiceNumber → INVOICE_NUMBER_ALREADY_EXISTS (yeni numara gerekir).
|
|
8
|
+
*/
|
|
9
|
+
export class InvoicesApi {
|
|
10
|
+
http;
|
|
11
|
+
config;
|
|
12
|
+
constructor(http, config) {
|
|
13
|
+
this.http = http;
|
|
14
|
+
this.config = config;
|
|
15
|
+
}
|
|
16
|
+
sendInvoiceLink(body, options) {
|
|
17
|
+
return this.http.requestJson({
|
|
18
|
+
method: "POST",
|
|
19
|
+
path: `${sellerBase(this.config.sellerId)}/seller-invoice-links`,
|
|
20
|
+
body,
|
|
21
|
+
retryPolicy: "none",
|
|
22
|
+
signal: options?.signal,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
deleteInvoiceLink(body, options) {
|
|
26
|
+
return this.http.requestJson({
|
|
27
|
+
method: "POST",
|
|
28
|
+
path: `${sellerBase(this.config.sellerId)}/seller-invoice-links/delete`,
|
|
29
|
+
body,
|
|
30
|
+
retryPolicy: "none",
|
|
31
|
+
signal: options?.signal,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
uploadInvoiceFile(fields, options) {
|
|
35
|
+
const form = new FormData();
|
|
36
|
+
form.append("shipmentPackageId", String(fields.shipmentPackageId));
|
|
37
|
+
if (fields.invoiceDateTime !== undefined) {
|
|
38
|
+
form.append("invoiceDateTime", String(fields.invoiceDateTime));
|
|
39
|
+
}
|
|
40
|
+
if (fields.invoiceNumber !== undefined) {
|
|
41
|
+
form.append("invoiceNumber", fields.invoiceNumber);
|
|
42
|
+
}
|
|
43
|
+
form.append("file", fields.file, fields.fileName ?? "invoice.pdf");
|
|
44
|
+
return this.http.requestMultipart({
|
|
45
|
+
method: "POST",
|
|
46
|
+
path: `${sellerBase(this.config.sellerId)}/seller-invoice-file`,
|
|
47
|
+
formData: form,
|
|
48
|
+
retryPolicy: "none",
|
|
49
|
+
signal: options?.signal,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { TrendyolHttpClient } from "../http.js";
|
|
2
|
+
import type { TrendyolConfig, TrendyolResult } from "../types.js";
|
|
3
|
+
import type { CommonLabelResponse, CreateCommonLabelBody, ProductLabelType } from "../types/labels.js";
|
|
4
|
+
type LabelOptions = {
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
};
|
|
7
|
+
type CreateCommonLabelOptions = LabelOptions & {
|
|
8
|
+
body?: CreateCommonLabelBody;
|
|
9
|
+
};
|
|
10
|
+
type GetCommonLabelWithAbProductOptions = LabelOptions & {
|
|
11
|
+
productLabelType: ProductLabelType;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Ortak etiket hatasi: capability yok veya paket tipi uygun degil.
|
|
15
|
+
* TEX / Aras Kargo, Trendyol oder gonderiler icin gecerlidir.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isCommonLabelNotAllowed(result: TrendyolResult<unknown>): result is Extract<TrendyolResult<unknown>, {
|
|
18
|
+
ok: false;
|
|
19
|
+
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Ortak etiket (ZPL) API.
|
|
22
|
+
* PICKING veya INVOICED sonrasi barkod talebi onerilir.
|
|
23
|
+
*/
|
|
24
|
+
export declare class LabelsApi {
|
|
25
|
+
private readonly http;
|
|
26
|
+
private readonly config;
|
|
27
|
+
constructor(http: TrendyolHttpClient, config: TrendyolConfig);
|
|
28
|
+
/**
|
|
29
|
+
* Ortak etiket barkod talebi (ZPL).
|
|
30
|
+
* POST .../common-label/{cargoTrackingNumber}
|
|
31
|
+
*/
|
|
32
|
+
createCommonLabel(cargoTrackingNumber: string, options?: CreateCommonLabelOptions): Promise<TrendyolResult<null>>;
|
|
33
|
+
/**
|
|
34
|
+
* Olusturulan ortak etiketi alir (ZPL).
|
|
35
|
+
* GET .../common-label/{cargoTrackingNumber}
|
|
36
|
+
*/
|
|
37
|
+
getCommonLabel(cargoTrackingNumber: string, options?: LabelOptions): Promise<TrendyolResult<CommonLabelResponse>>;
|
|
38
|
+
/**
|
|
39
|
+
* AB urun etiketi + ortak etiket varyanti (ihracat).
|
|
40
|
+
* GET .../common-labels/{cargoTrackingNumber}/with-product-labels
|
|
41
|
+
*/
|
|
42
|
+
getCommonLabelWithAbProduct(cargoTrackingNumber: string, options: GetCommonLabelWithAbProductOptions): Promise<TrendyolResult<CommonLabelResponse>>;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/labels/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAM5B,KAAK,YAAY,GAAG;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,CAAC;AAE7C,KAAK,wBAAwB,GAAG,YAAY,GAAG;IAC7C,IAAI,CAAC,EAAE,qBAAqB,CAAC;CAC9B,CAAC;AAEF,KAAK,kCAAkC,GAAG,YAAY,GAAG;IACvD,gBAAgB,EAAE,gBAAgB,CAAC;CACpC,CAAC;AAwBF;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,cAAc,CAAC,OAAO,CAAC,GAC9B,MAAM,IAAI,OAAO,CAAC,cAAc,CAAC,OAAO,CAAC,EAAE;IAAE,EAAE,EAAE,KAAK,CAAA;CAAE,CAAC,CAc3D;AAED;;;GAGG;AACH,qBAAa,SAAS;IAElB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,MAAM;gBADN,IAAI,EAAE,kBAAkB,EACxB,MAAM,EAAE,cAAc;IAGzC;;;OAGG;IACH,iBAAiB,CACf,mBAAmB,EAAE,MAAM,EAC3B,OAAO,CAAC,EAAE,wBAAwB,GACjC,OAAO,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC;IAUhC;;;OAGG;IACH,cAAc,CACZ,mBAAmB,EAAE,MAAM,EAC3B,OAAO,CAAC,EAAE,YAAY,GACrB,OAAO,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC;IAS/C;;;OAGG;IACH,2BAA2B,CACzB,mBAAmB,EAAE,MAAM,EAC3B,OAAO,EAAE,kCAAkC,GAC1C,OAAO,CAAC,cAAc,CAAC,mBAAmB,CAAC,CAAC;CAYhD"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { TRENDYOL_ERROR_CODES } from "../constants/error-codes.js";
|
|
2
|
+
import { commonLabelPath, commonLabelWithProductLabelsPath, } from "./paths.js";
|
|
3
|
+
function defaultCreateLabelBody(body) {
|
|
4
|
+
return body ?? { format: "ZPL" };
|
|
5
|
+
}
|
|
6
|
+
function extractNestedErrorCodes(raw) {
|
|
7
|
+
if (!raw || typeof raw !== "object")
|
|
8
|
+
return [];
|
|
9
|
+
const record = raw;
|
|
10
|
+
const errorBlock = record.error;
|
|
11
|
+
if (!errorBlock || typeof errorBlock !== "object")
|
|
12
|
+
return [];
|
|
13
|
+
const errors = errorBlock.errors;
|
|
14
|
+
if (!Array.isArray(errors))
|
|
15
|
+
return [];
|
|
16
|
+
return errors.flatMap((entry) => {
|
|
17
|
+
if (!entry || typeof entry !== "object")
|
|
18
|
+
return [];
|
|
19
|
+
const code = entry.code;
|
|
20
|
+
return code !== undefined ? [String(code)] : [];
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Ortak etiket hatasi: capability yok veya paket tipi uygun degil.
|
|
25
|
+
* TEX / Aras Kargo, Trendyol oder gonderiler icin gecerlidir.
|
|
26
|
+
*/
|
|
27
|
+
export function isCommonLabelNotAllowed(result) {
|
|
28
|
+
if (result.ok)
|
|
29
|
+
return false;
|
|
30
|
+
if (result.code === "COMMON_LABEL_NOT_ALLOWED") {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
const mappedMessage = TRENDYOL_ERROR_CODES.COMMON_LABEL_NOT_ALLOWED;
|
|
34
|
+
if (result.reason === mappedMessage) {
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
const nestedCodes = extractNestedErrorCodes(result.raw);
|
|
38
|
+
return nestedCodes.some((code) => code === "COMMON_LABEL_NOT_ALLOWED");
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Ortak etiket (ZPL) API.
|
|
42
|
+
* PICKING veya INVOICED sonrasi barkod talebi onerilir.
|
|
43
|
+
*/
|
|
44
|
+
export class LabelsApi {
|
|
45
|
+
http;
|
|
46
|
+
config;
|
|
47
|
+
constructor(http, config) {
|
|
48
|
+
this.http = http;
|
|
49
|
+
this.config = config;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Ortak etiket barkod talebi (ZPL).
|
|
53
|
+
* POST .../common-label/{cargoTrackingNumber}
|
|
54
|
+
*/
|
|
55
|
+
createCommonLabel(cargoTrackingNumber, options) {
|
|
56
|
+
return this.http.requestJson({
|
|
57
|
+
method: "POST",
|
|
58
|
+
path: commonLabelPath(this.config.sellerId, cargoTrackingNumber),
|
|
59
|
+
body: defaultCreateLabelBody(options?.body),
|
|
60
|
+
retryPolicy: "none",
|
|
61
|
+
signal: options?.signal,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Olusturulan ortak etiketi alir (ZPL).
|
|
66
|
+
* GET .../common-label/{cargoTrackingNumber}
|
|
67
|
+
*/
|
|
68
|
+
getCommonLabel(cargoTrackingNumber, options) {
|
|
69
|
+
return this.http.requestJson({
|
|
70
|
+
method: "GET",
|
|
71
|
+
path: commonLabelPath(this.config.sellerId, cargoTrackingNumber),
|
|
72
|
+
retryPolicy: "safe",
|
|
73
|
+
signal: options?.signal,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* AB urun etiketi + ortak etiket varyanti (ihracat).
|
|
78
|
+
* GET .../common-labels/{cargoTrackingNumber}/with-product-labels
|
|
79
|
+
*/
|
|
80
|
+
getCommonLabelWithAbProduct(cargoTrackingNumber, options) {
|
|
81
|
+
return this.http.requestJson({
|
|
82
|
+
method: "GET",
|
|
83
|
+
path: commonLabelWithProductLabelsPath(this.config.sellerId, cargoTrackingNumber),
|
|
84
|
+
query: { productLabelType: options.productLabelType },
|
|
85
|
+
retryPolicy: "safe",
|
|
86
|
+
signal: options?.signal,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/labels/paths.ts"],"names":[],"mappings":"AAEA,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,mBAAmB,EAAE,MAAM,GAC1B,MAAM,CAER;AAED,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,MAAM,EAChB,mBAAmB,EAAE,MAAM,GAC1B,MAAM,CAER"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TRENDYOL_INTEGRATION_PREFIX } from "../constants.js";
|
|
2
|
+
export function commonLabelPath(sellerId, cargoTrackingNumber) {
|
|
3
|
+
return `${TRENDYOL_INTEGRATION_PREFIX}/sellers/${sellerId}/common-label/${encodeURIComponent(cargoTrackingNumber)}`;
|
|
4
|
+
}
|
|
5
|
+
export function commonLabelWithProductLabelsPath(sellerId, cargoTrackingNumber) {
|
|
6
|
+
return `${TRENDYOL_INTEGRATION_PREFIX}/sellers/${sellerId}/common-labels/${encodeURIComponent(cargoTrackingNumber)}/with-product-labels`;
|
|
7
|
+
}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TrendyolLogger } from "./types.js";
|
|
2
|
+
export declare function setTrendyolLogger(logger: TrendyolLogger | null): void;
|
|
3
|
+
export declare function truncateBody(value: string, max?: number): string;
|
|
4
|
+
export declare function trendyolLog(enabled: boolean, level: "debug" | "info" | "warn" | "error", message: string, meta?: Record<string, unknown>): void;
|
|
5
|
+
export declare function maskSecret(value: string | undefined): string;
|
|
6
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,cAAc,EAAE,MAAM,YAAY,CAAC;AAMjE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,GAAG,IAAI,CAErE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAQ,GAAG,MAAM,CAG/D;AAiBD,wBAAgB,WAAW,CACzB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,EAC1C,OAAO,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,IAAI,CAUN;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAI5D"}
|