@hubcommerce/n11 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 +48 -0
- package/LICENSE +21 -0
- package/README.md +81 -0
- package/dist/categories/api.d.ts +12 -0
- package/dist/categories/api.d.ts.map +1 -0
- package/dist/categories/api.js +34 -0
- package/dist/client.d.ts +37 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +70 -0
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +58 -0
- package/dist/connection.d.ts +5 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +4 -0
- package/dist/constants/defaults.d.ts +16 -0
- package/dist/constants/defaults.d.ts.map +1 -0
- package/dist/constants/defaults.js +15 -0
- package/dist/constants/hosts.d.ts +9 -0
- package/dist/constants/hosts.d.ts.map +1 -0
- package/dist/constants/hosts.js +25 -0
- package/dist/constants/page-limits.d.ts +15 -0
- package/dist/constants/page-limits.d.ts.map +1 -0
- package/dist/constants/page-limits.js +14 -0
- package/dist/errors.d.ts +42 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +162 -0
- package/dist/http/query.d.ts +2 -0
- package/dist/http/query.d.ts.map +1 -0
- package/dist/http/query.js +10 -0
- package/dist/http/response.d.ts +12 -0
- package/dist/http/response.d.ts.map +1 -0
- package/dist/http/response.js +43 -0
- package/dist/http/security.d.ts +6 -0
- package/dist/http/security.d.ts.map +1 -0
- package/dist/http/security.js +29 -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 +12 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +143 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/invoice/api.d.ts +14 -0
- package/dist/invoice/api.d.ts.map +1 -0
- package/dist/invoice/api.js +12 -0
- package/dist/invoice/parse.d.ts +3 -0
- package/dist/invoice/parse.d.ts.map +1 -0
- package/dist/invoice/parse.js +12 -0
- package/dist/invoice/send-link.d.ts +9 -0
- package/dist/invoice/send-link.d.ts.map +1 -0
- package/dist/invoice/send-link.js +16 -0
- package/dist/invoice/soap-body.d.ts +6 -0
- package/dist/invoice/soap-body.d.ts.map +1 -0
- package/dist/invoice/soap-body.js +23 -0
- package/dist/invoice/validate.d.ts +7 -0
- package/dist/invoice/validate.d.ts.map +1 -0
- package/dist/invoice/validate.js +73 -0
- package/dist/logger.d.ts +20 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +61 -0
- package/dist/orders/api.d.ts +22 -0
- package/dist/orders/api.d.ts.map +1 -0
- package/dist/orders/api.js +40 -0
- package/dist/orders/date.d.ts +12 -0
- package/dist/orders/date.d.ts.map +1 -0
- package/dist/orders/date.js +21 -0
- package/dist/orders/labor-cost.d.ts +9 -0
- package/dist/orders/labor-cost.d.ts.map +1 -0
- package/dist/orders/labor-cost.js +23 -0
- package/dist/orders/list.d.ts +23 -0
- package/dist/orders/list.d.ts.map +1 -0
- package/dist/orders/list.js +76 -0
- package/dist/orders/paths.d.ts +7 -0
- package/dist/orders/paths.d.ts.map +1 -0
- package/dist/orders/paths.js +6 -0
- package/dist/orders/reconciler.d.ts +30 -0
- package/dist/orders/reconciler.d.ts.map +1 -0
- package/dist/orders/reconciler.js +38 -0
- package/dist/orders/shipping.d.ts +11 -0
- package/dist/orders/shipping.d.ts.map +1 -0
- package/dist/orders/shipping.js +57 -0
- package/dist/orders/update.d.ts +15 -0
- package/dist/orders/update.d.ts.map +1 -0
- package/dist/orders/update.js +25 -0
- package/dist/products/api.d.ts +21 -0
- package/dist/products/api.d.ts.map +1 -0
- package/dist/products/api.js +35 -0
- package/dist/products/builder.d.ts +18 -0
- package/dist/products/builder.d.ts.map +1 -0
- package/dist/products/builder.js +138 -0
- package/dist/products/paths.d.ts +6 -0
- package/dist/products/paths.d.ts.map +1 -0
- package/dist/products/paths.js +5 -0
- package/dist/products/query.d.ts +9 -0
- package/dist/products/query.d.ts.map +1 -0
- package/dist/products/query.js +49 -0
- package/dist/products/tasks.d.ts +12 -0
- package/dist/products/tasks.d.ts.map +1 -0
- package/dist/products/tasks.js +49 -0
- package/dist/qna/answer.d.ts +10 -0
- package/dist/qna/answer.d.ts.map +1 -0
- package/dist/qna/answer.js +23 -0
- package/dist/qna/api.d.ts +17 -0
- package/dist/qna/api.d.ts.map +1 -0
- package/dist/qna/api.js +20 -0
- package/dist/qna/detail.d.ts +9 -0
- package/dist/qna/detail.d.ts.map +1 -0
- package/dist/qna/detail.js +18 -0
- package/dist/qna/list.d.ts +9 -0
- package/dist/qna/list.d.ts.map +1 -0
- package/dist/qna/list.js +16 -0
- package/dist/qna/parse.d.ts +6 -0
- package/dist/qna/parse.d.ts.map +1 -0
- package/dist/qna/parse.js +65 -0
- package/dist/qna/soap-body.d.ts +14 -0
- package/dist/qna/soap-body.d.ts.map +1 -0
- package/dist/qna/soap-body.js +48 -0
- package/dist/qna/validate.d.ts +7 -0
- package/dist/qna/validate.d.ts.map +1 -0
- package/dist/qna/validate.js +75 -0
- package/dist/rate-limit/governor.d.ts +8 -0
- package/dist/rate-limit/governor.d.ts.map +1 -0
- package/dist/rate-limit/governor.js +30 -0
- package/dist/rate-limit/groups.d.ts +34 -0
- package/dist/rate-limit/groups.d.ts.map +1 -0
- package/dist/rate-limit/groups.js +32 -0
- package/dist/retry.d.ts +5 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +22 -0
- package/dist/returns/api.d.ts +21 -0
- package/dist/returns/api.d.ts.map +1 -0
- package/dist/returns/api.js +36 -0
- package/dist/returns/call.d.ts +2 -0
- package/dist/returns/call.d.ts.map +1 -0
- package/dist/returns/call.js +1 -0
- package/dist/returns/cancel-partial.d.ts +9 -0
- package/dist/returns/cancel-partial.d.ts.map +1 -0
- package/dist/returns/cancel-partial.js +18 -0
- package/dist/returns/list.d.ts +9 -0
- package/dist/returns/list.d.ts.map +1 -0
- package/dist/returns/list.js +16 -0
- package/dist/returns/mutations.d.ts +11 -0
- package/dist/returns/mutations.d.ts.map +1 -0
- package/dist/returns/mutations.js +22 -0
- package/dist/returns/parse.d.ts +6 -0
- package/dist/returns/parse.d.ts.map +1 -0
- package/dist/returns/parse.js +89 -0
- package/dist/returns/reasons.d.ts +11 -0
- package/dist/returns/reasons.d.ts.map +1 -0
- package/dist/returns/reasons.js +20 -0
- package/dist/returns/soap-body.d.ts +26 -0
- package/dist/returns/soap-body.d.ts.map +1 -0
- package/dist/returns/soap-body.js +95 -0
- package/dist/soap/call.d.ts +8 -0
- package/dist/soap/call.d.ts.map +1 -0
- package/dist/soap/call.js +22 -0
- package/dist/soap/client.d.ts +13 -0
- package/dist/soap/client.d.ts.map +1 -0
- package/dist/soap/client.js +125 -0
- package/dist/soap/envelope.d.ts +10 -0
- package/dist/soap/envelope.d.ts.map +1 -0
- package/dist/soap/envelope.js +47 -0
- package/dist/soap/operations.d.ts +6 -0
- package/dist/soap/operations.d.ts.map +1 -0
- package/dist/soap/operations.js +91 -0
- package/dist/soap/parse.d.ts +17 -0
- package/dist/soap/parse.d.ts.map +1 -0
- package/dist/soap/parse.js +37 -0
- package/dist/tasks/api.d.ts +11 -0
- package/dist/tasks/api.d.ts.map +1 -0
- package/dist/tasks/api.js +44 -0
- package/dist/tasks/module.d.ts +14 -0
- package/dist/tasks/module.d.ts.map +1 -0
- package/dist/tasks/module.js +15 -0
- package/dist/tasks/poller.d.ts +12 -0
- package/dist/tasks/poller.d.ts.map +1 -0
- package/dist/tasks/poller.js +133 -0
- package/dist/tasks/types.d.ts +27 -0
- package/dist/tasks/types.d.ts.map +1 -0
- package/dist/tasks/types.js +2 -0
- package/dist/testing/fixtures/category-leaf.json +11 -0
- package/dist/testing/fixtures/order-package.json +12 -0
- package/dist/testing/fixtures/task-partial-fail.json +18 -0
- package/dist/testing/fixtures.d.ts +76 -0
- package/dist/testing/fixtures.d.ts.map +1 -0
- package/dist/testing/fixtures.js +85 -0
- package/dist/testing/guard.d.ts +21 -0
- package/dist/testing/guard.d.ts.map +1 -0
- package/dist/testing/guard.js +50 -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/mock-client.d.ts +49 -0
- package/dist/testing/mock-client.d.ts.map +1 -0
- package/dist/testing/mock-client.js +100 -0
- package/dist/types/invoice.d.ts +21 -0
- package/dist/types/invoice.d.ts.map +1 -0
- package/dist/types/invoice.js +1 -0
- package/dist/types/orders.d.ts +127 -0
- package/dist/types/orders.d.ts.map +1 -0
- package/dist/types/orders.js +1 -0
- package/dist/types/products.d.ts +146 -0
- package/dist/types/products.d.ts.map +1 -0
- package/dist/types/products.js +1 -0
- package/dist/types/qna.d.ts +61 -0
- package/dist/types/qna.d.ts.map +1 -0
- package/dist/types/qna.js +1 -0
- package/dist/types/returns.d.ts +96 -0
- package/dist/types/returns.d.ts.map +1 -0
- package/dist/types/returns.js +1 -0
- package/dist/types.d.ts +112 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/wire/normalize.d.ts +20 -0
- package/dist/wire/normalize.d.ts.map +1 -0
- package/dist/wire/normalize.js +158 -0
- package/dist/wire/validate.d.ts +6 -0
- package/dist/wire/validate.d.ts.map +1 -0
- package/dist/wire/validate.js +53 -0
- package/package.json +53 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Bu proje [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) formatını izler.
|
|
4
|
+
Sürümleme [Semantic Versioning](https://semver.org/spec/v2.0.0.html) uyumludur.
|
|
5
|
+
|
|
6
|
+
## [1.0.0] - 2026-08-27
|
|
7
|
+
|
|
8
|
+
### Added
|
|
9
|
+
|
|
10
|
+
- TR Marketplace documented kapsam **26/26 metod** (14 REST + 12 SOAP)
|
|
11
|
+
- REST: kategori CDN, ürün task submit×4, task-details poll, product-query, sipariş×6, poll reconciler
|
|
12
|
+
- SOAP sıfır runtime dep: iade×6, parçalı iptal×2, fatura link, Q&A×3
|
|
13
|
+
- Task async poll: `tasks.waitForResult` — terminal, partial SKU fail, in-flight dedup
|
|
14
|
+
- Sipariş poll-primary: `orders.pollPackagesSince` — GMT+3 lookback, tek statü/istek
|
|
15
|
+
- Multi-resource path router: `cdn` / `ms` / `rest` + SOAP WSDL
|
|
16
|
+
- Auth: REST header `appKey`+`appSecret`; SOAP body `<auth>`; task `integrator`
|
|
17
|
+
- Rate limit groups: orders 1000/dk, Q&A 1/dk + muhafazakâr defaults (TD-002 defer)
|
|
18
|
+
- HTTP lifecycle: GET retry, mutasyon no retry, `combineAbortSignals`, PII mask
|
|
19
|
+
- Observability: `x-correlation-id` her istekte, structured log hooks
|
|
20
|
+
- `@hubcommerce/n11/testing`: mock client, prod guard, fixture export, qa-smoke
|
|
21
|
+
- Portal snapshot + `check:snapshot-drift` script
|
|
22
|
+
- Tam dokümantasyon: CONFORMANCE, QA, MIGRATION, VERSIONING, ADAPTER-CONTRACT, OFFICIAL-ANSWERS
|
|
23
|
+
|
|
24
|
+
### Notes
|
|
25
|
+
|
|
26
|
+
- npm paket adı: `@hubcommerce/n11` · `publishConfig.access: public`
|
|
27
|
+
- Tek prod host — sandbox yok (G5)
|
|
28
|
+
- Webhook export edilmez (G2) — poll-primary
|
|
29
|
+
- ↷ TD-002 (P2): rate limit tablosu resmi sayı eksikleri — release blocker değil
|
|
30
|
+
|
|
31
|
+
## [0.1.0] - 2026-08-27
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
- Faz 0 scaffold: REST + SOAP çekirdek iskelet
|
|
36
|
+
- `N11Result<T>`, `createN11Client`, `testConnection` (GET `/cdn/categories`)
|
|
37
|
+
- REST HTTP lifecycle: `appKey` + `appSecret` (G1), `x-correlation-id`, GET retry
|
|
38
|
+
- SOAP iskelet: envelope builder, minimal parse (G7), `N11SoapClient`
|
|
39
|
+
- Task poller iskelet: yalnızca `task-details/page-query` hedefi (G4)
|
|
40
|
+
- Rate limit groups: orders 1000/dk, Q&A 1/dk + muhafazakâr defaults (TD-002)
|
|
41
|
+
- Domain API facade stub'ları (26 metod — Faz 1+ implementasyonu defer)
|
|
42
|
+
- Scripts: `verify-exports`, `check:deps`, `check:snapshot-drift`
|
|
43
|
+
- Portal gate docs: OFFICIAL-ANSWERS G1–G8, ADAPTER-CONTRACT
|
|
44
|
+
|
|
45
|
+
### Notes
|
|
46
|
+
|
|
47
|
+
- Tek prod host (`https://api.n11.com`) — sandbox yok (G5)
|
|
48
|
+
- Webhook export edilmez (G2)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# @hubcommerce/n11
|
|
2
|
+
|
|
3
|
+
n11 TR Marketplace API SDK — REST (JSON) + SOAP (XML), task async poll, poll-primary sipariş.
|
|
4
|
+
|
|
5
|
+
> **Yalnızca server-side kullanın.** `N11_APP_KEY` / `N11_APP_SECRET` tarayıcıda, mobil uygulamada veya public repo'da **asla** bulunmamalı.
|
|
6
|
+
|
|
7
|
+
- Node `>=20.10.0` · ESM-only · sıfır runtime dependency
|
|
8
|
+
- `N11Result<T>` — throw yerine `ok` / `error`
|
|
9
|
+
- **1.0.0** — 26/26 metod (14 REST + 12 SOAP), task poll, poll-primary sipariş
|
|
10
|
+
|
|
11
|
+
Detay: [`docs/CONFORMANCE.md`](./docs/CONFORMANCE.md) · [`docs/ADAPTER-CONTRACT.md`](./docs/ADAPTER-CONTRACT.md) · [`docs/OFFICIAL-ANSWERS.md`](./docs/OFFICIAL-ANSWERS.md)
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Kurulum
|
|
16
|
+
|
|
17
|
+
```powershell
|
|
18
|
+
npm install @hubcommerce/n11
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Monorepo yerel:
|
|
22
|
+
|
|
23
|
+
```powershell
|
|
24
|
+
npm install file:../commerce-packages/marketplace/n11
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Yapılandırma
|
|
30
|
+
|
|
31
|
+
`.env.example` dosyasını kopyalayın:
|
|
32
|
+
|
|
33
|
+
```powershell
|
|
34
|
+
copy marketplace\n11\.env.example .env
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
| Değişken | Açıklama |
|
|
38
|
+
|----------|----------|
|
|
39
|
+
| `N11_APP_KEY` | REST header + SOAP body auth |
|
|
40
|
+
| `N11_APP_SECRET` | REST header + SOAP body auth (G1 — kategori CDN dahil) |
|
|
41
|
+
| `N11_INTEGRATOR_NAME` | Task body `integrator` sabiti |
|
|
42
|
+
| `N11_DEBUG` | `1` / `true` — debug log |
|
|
43
|
+
| `N11_ALLOW_PROD_MUTATIONS` | `1` — prod mutasyon guard bypass (QA) |
|
|
44
|
+
|
|
45
|
+
**Host:** Tek prod `https://api.n11.com` — sandbox dokümante değil (G5).
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## Hızlı başlangıç
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { createN11Client } from "@hubcommerce/n11";
|
|
53
|
+
|
|
54
|
+
const client = createN11Client({
|
|
55
|
+
appKey: process.env.N11_APP_KEY!,
|
|
56
|
+
appSecret: process.env.N11_APP_SECRET!,
|
|
57
|
+
integratorName: "MyIntegrator",
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const conn = await client.testConnection();
|
|
61
|
+
if (conn.ok) {
|
|
62
|
+
console.log("n11 bağlantı OK");
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## Geliştirme
|
|
69
|
+
|
|
70
|
+
```powershell
|
|
71
|
+
npm run build --workspace=@hubcommerce/n11
|
|
72
|
+
npm test --workspace=@hubcommerce/n11
|
|
73
|
+
npm run test:exports --workspace=@hubcommerce/n11
|
|
74
|
+
npm run check:deps --workspace=@hubcommerce/n11
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## Lisans
|
|
80
|
+
|
|
81
|
+
MIT — [LICENSE](./LICENSE)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { N11HttpClient } from "../http.js";
|
|
2
|
+
import type { CategoryListResponse, N11Result } from "../types.js";
|
|
3
|
+
import type { N11CategoryAttributesResponse } from "../types/products.js";
|
|
4
|
+
export declare class CategoriesApi {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(http: N11HttpClient);
|
|
7
|
+
list(): Promise<N11Result<CategoryListResponse>>;
|
|
8
|
+
getAttributes(categoryId: number | string, options?: {
|
|
9
|
+
signal?: AbortSignal;
|
|
10
|
+
}): Promise<N11Result<N11CategoryAttributesResponse>>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/categories/api.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAE1E,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAE1C,IAAI,IAAI,OAAO,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;IAgBhD,aAAa,CACjB,UAAU,EAAE,MAAM,GAAG,MAAM,EAC3B,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACjC,OAAO,CAAC,SAAS,CAAC,6BAA6B,CAAC,CAAC;CAerD"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { N11_TEST_CONNECTION_PATH } from "../constants/hosts.js";
|
|
2
|
+
import { normalizeCategoryAttributes, normalizeCategoryTree } from "../wire/normalize.js";
|
|
3
|
+
export class CategoriesApi {
|
|
4
|
+
http;
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
async list() {
|
|
9
|
+
const result = await this.http.requestJson({
|
|
10
|
+
resource: "cdn",
|
|
11
|
+
method: "GET",
|
|
12
|
+
path: N11_TEST_CONNECTION_PATH,
|
|
13
|
+
retryPolicy: "safe",
|
|
14
|
+
});
|
|
15
|
+
if (!result.ok) {
|
|
16
|
+
return result;
|
|
17
|
+
}
|
|
18
|
+
const normalized = normalizeCategoryTree(result.data);
|
|
19
|
+
return { ok: true, data: normalized };
|
|
20
|
+
}
|
|
21
|
+
async getAttributes(categoryId, options) {
|
|
22
|
+
const result = await this.http.requestJson({
|
|
23
|
+
resource: "cdn",
|
|
24
|
+
method: "GET",
|
|
25
|
+
path: `/category/${categoryId}/attribute`,
|
|
26
|
+
retryPolicy: "safe",
|
|
27
|
+
signal: options?.signal,
|
|
28
|
+
});
|
|
29
|
+
if (!result.ok) {
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
32
|
+
return { ok: true, data: normalizeCategoryAttributes(result.data) };
|
|
33
|
+
}
|
|
34
|
+
}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { CategoriesApi } from "./categories/api.js";
|
|
2
|
+
import { N11HttpClient } from "./http.js";
|
|
3
|
+
import { InvoiceApi } from "./invoice/api.js";
|
|
4
|
+
import { OrdersApi } from "./orders/api.js";
|
|
5
|
+
import { ProductsApi } from "./products/api.js";
|
|
6
|
+
import { QnaApi } from "./qna/api.js";
|
|
7
|
+
import { ReturnsApi } from "./returns/api.js";
|
|
8
|
+
import { N11SoapClient } from "./soap/client.js";
|
|
9
|
+
import { N11TasksModule } from "./tasks/module.js";
|
|
10
|
+
import type { TaskPollOptions, TaskPollResult } from "./tasks/types.js";
|
|
11
|
+
import type { CategoryListResponse, N11Config, N11Hooks, N11Result } from "./types.js";
|
|
12
|
+
export type N11TransportOverride = {
|
|
13
|
+
http?: Pick<N11HttpClient, "requestJson" | "setHooks" | "getHooks">;
|
|
14
|
+
soap?: Pick<N11SoapClient, "call" | "setHooks" | "getHooks">;
|
|
15
|
+
};
|
|
16
|
+
export declare class N11Client {
|
|
17
|
+
readonly config: N11Config;
|
|
18
|
+
readonly categories: CategoriesApi;
|
|
19
|
+
readonly products: ProductsApi;
|
|
20
|
+
readonly orders: OrdersApi;
|
|
21
|
+
readonly returns: ReturnsApi;
|
|
22
|
+
readonly invoice: InvoiceApi;
|
|
23
|
+
readonly qna: QnaApi;
|
|
24
|
+
readonly tasks: N11TasksModule;
|
|
25
|
+
private readonly http;
|
|
26
|
+
private readonly soap;
|
|
27
|
+
private readonly taskPoller;
|
|
28
|
+
constructor(config?: Partial<N11Config>, transport?: N11TransportOverride);
|
|
29
|
+
getHttpClient(): N11HttpClient;
|
|
30
|
+
getSoapClient(): N11SoapClient;
|
|
31
|
+
setHooks(hooks: N11Hooks): void;
|
|
32
|
+
getHooks(): N11Hooks;
|
|
33
|
+
testConnection(): Promise<N11Result<CategoryListResponse>>;
|
|
34
|
+
waitForTaskResult(taskId: string, options: TaskPollOptions): Promise<N11Result<TaskPollResult>>;
|
|
35
|
+
}
|
|
36
|
+
export declare function createN11Client(config?: Partial<N11Config>): N11Client;
|
|
37
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,KAAK,EACV,oBAAoB,EACpB,SAAS,EACT,QAAQ,EACR,SAAS,EACV,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,GAAG,UAAU,GAAG,UAAU,CAAC,CAAC;IACpE,IAAI,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,UAAU,GAAG,UAAU,CAAC,CAAC;CAC9D,CAAC;AAEF,qBAAa,SAAS;IACpB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAgB;IACrC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAgB;IACrC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAa;gBAE5B,MAAM,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,EAAE,SAAS,CAAC,EAAE,oBAAoB;IA0BzE,aAAa,IAAI,aAAa;IAI9B,aAAa,IAAI,aAAa;IAI9B,QAAQ,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAK/B,QAAQ,IAAI,QAAQ;IAIpB,cAAc,IAAI,OAAO,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;IAI1D,iBAAiB,CACf,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;CAGtC;AAED,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CAEtE"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { CategoriesApi } from "./categories/api.js";
|
|
2
|
+
import { getN11Config } from "./config.js";
|
|
3
|
+
import { testConnection as testConnectionImpl } from "./connection.js";
|
|
4
|
+
import { N11HttpClient } from "./http.js";
|
|
5
|
+
import { InvoiceApi } from "./invoice/api.js";
|
|
6
|
+
import { OrdersApi } from "./orders/api.js";
|
|
7
|
+
import { ProductsApi } from "./products/api.js";
|
|
8
|
+
import { QnaApi } from "./qna/api.js";
|
|
9
|
+
import { RateLimitGovernor } from "./rate-limit/governor.js";
|
|
10
|
+
import { ReturnsApi } from "./returns/api.js";
|
|
11
|
+
import { N11SoapClient } from "./soap/client.js";
|
|
12
|
+
import { TasksApi } from "./tasks/api.js";
|
|
13
|
+
import { N11TasksModule } from "./tasks/module.js";
|
|
14
|
+
import { TaskPoller } from "./tasks/poller.js";
|
|
15
|
+
export class N11Client {
|
|
16
|
+
config;
|
|
17
|
+
categories;
|
|
18
|
+
products;
|
|
19
|
+
orders;
|
|
20
|
+
returns;
|
|
21
|
+
invoice;
|
|
22
|
+
qna;
|
|
23
|
+
tasks;
|
|
24
|
+
http;
|
|
25
|
+
soap;
|
|
26
|
+
taskPoller;
|
|
27
|
+
constructor(config, transport) {
|
|
28
|
+
this.config = getN11Config(config);
|
|
29
|
+
const governor = this.config.enableClientSideLimiter
|
|
30
|
+
? new RateLimitGovernor()
|
|
31
|
+
: undefined;
|
|
32
|
+
this.http =
|
|
33
|
+
transport?.http ??
|
|
34
|
+
new N11HttpClient(this.config, governor);
|
|
35
|
+
this.soap =
|
|
36
|
+
transport?.soap ??
|
|
37
|
+
new N11SoapClient(this.config, governor);
|
|
38
|
+
const tasksApi = new TasksApi(this.http, this.config);
|
|
39
|
+
this.categories = new CategoriesApi(this.http);
|
|
40
|
+
this.products = new ProductsApi(this.http, this.config);
|
|
41
|
+
this.orders = new OrdersApi(this.http, this.config);
|
|
42
|
+
this.returns = new ReturnsApi(this.soap, this.config);
|
|
43
|
+
this.invoice = new InvoiceApi(this.soap, this.config);
|
|
44
|
+
this.qna = new QnaApi(this.soap, this.config);
|
|
45
|
+
this.taskPoller = new TaskPoller((taskId, kind, signal) => tasksApi.pageQuery(taskId, kind, signal), () => this.getHooks(), this.config.debug);
|
|
46
|
+
this.tasks = new N11TasksModule(tasksApi, this.taskPoller);
|
|
47
|
+
}
|
|
48
|
+
getHttpClient() {
|
|
49
|
+
return this.http;
|
|
50
|
+
}
|
|
51
|
+
getSoapClient() {
|
|
52
|
+
return this.soap;
|
|
53
|
+
}
|
|
54
|
+
setHooks(hooks) {
|
|
55
|
+
this.http.setHooks(hooks);
|
|
56
|
+
this.soap.setHooks(hooks);
|
|
57
|
+
}
|
|
58
|
+
getHooks() {
|
|
59
|
+
return this.http.getHooks();
|
|
60
|
+
}
|
|
61
|
+
testConnection() {
|
|
62
|
+
return testConnectionImpl(this.categories);
|
|
63
|
+
}
|
|
64
|
+
waitForTaskResult(taskId, options) {
|
|
65
|
+
return this.taskPoller.waitForResult(taskId, options);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export function createN11Client(config) {
|
|
69
|
+
return new N11Client(config);
|
|
70
|
+
}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { N11Config } from "./types.js";
|
|
2
|
+
export declare class N11ConfigError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
export declare function getN11Config(overrides?: Partial<N11Config>): N11Config;
|
|
6
|
+
export declare function isN11Configured(): boolean;
|
|
7
|
+
/** G1 gate: tum REST isteklerinde appKey + appSecret header. */
|
|
8
|
+
export declare function buildRestAuthHeaders(config: N11Config): Record<string, string>;
|
|
9
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,qBAAa,cAAe,SAAQ,KAAK;gBAC3B,OAAO,EAAE,MAAM;CAI5B;AAaD,wBAAgB,YAAY,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CA8CtE;AAED,wBAAgB,eAAe,IAAI,OAAO,CAOzC;AAED,gEAAgE;AAChE,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAK9E"}
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { N11_DEFAULT_INTEGRATOR, N11_DEFAULT_MAX_RESPONSE_BYTES, N11_DEFAULT_MAX_RETRIES, N11_DEFAULT_MAX_SOAP_BYTES, N11_DEFAULT_RETRY_BASE_MS, N11_DEFAULT_TIMEOUT_MS, } from "./constants/defaults.js";
|
|
2
|
+
export class N11ConfigError extends Error {
|
|
3
|
+
constructor(message) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "N11ConfigError";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
function parsePositiveInt(value, fallback) {
|
|
9
|
+
const parsed = Number(value);
|
|
10
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
11
|
+
}
|
|
12
|
+
function parseBoolean(value, fallback = false) {
|
|
13
|
+
if (value === undefined)
|
|
14
|
+
return fallback;
|
|
15
|
+
const normalized = value.trim().toLowerCase();
|
|
16
|
+
return normalized === "1" || normalized === "true" || normalized === "yes";
|
|
17
|
+
}
|
|
18
|
+
export function getN11Config(overrides) {
|
|
19
|
+
const appKey = overrides?.appKey ?? process.env.N11_APP_KEY?.trim() ?? "";
|
|
20
|
+
const appSecret = overrides?.appSecret ?? process.env.N11_APP_SECRET?.trim() ?? "";
|
|
21
|
+
if (!appKey || !appSecret) {
|
|
22
|
+
throw new N11ConfigError("n11 bilgileri eksik. N11_APP_KEY ve N11_APP_SECRET tanimlanmalidir.");
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
appKey,
|
|
26
|
+
appSecret,
|
|
27
|
+
integratorName: overrides?.integratorName ??
|
|
28
|
+
process.env.N11_INTEGRATOR_NAME?.trim() ??
|
|
29
|
+
N11_DEFAULT_INTEGRATOR,
|
|
30
|
+
requestTimeoutMs: parsePositiveInt(overrides?.requestTimeoutMs?.toString() ?? process.env.N11_REQUEST_TIMEOUT_MS, N11_DEFAULT_TIMEOUT_MS),
|
|
31
|
+
debug: overrides?.debug ?? parseBoolean(process.env.N11_DEBUG),
|
|
32
|
+
maxRetries: parsePositiveInt(overrides?.maxRetries?.toString() ?? process.env.N11_MAX_RETRIES, N11_DEFAULT_MAX_RETRIES),
|
|
33
|
+
retryBaseMs: parsePositiveInt(overrides?.retryBaseMs?.toString() ?? process.env.N11_RETRY_BASE_MS, N11_DEFAULT_RETRY_BASE_MS),
|
|
34
|
+
enableClientSideLimiter: overrides?.enableClientSideLimiter ??
|
|
35
|
+
parseBoolean(process.env.N11_ENABLE_CLIENT_LIMITER),
|
|
36
|
+
maxResponseBodyBytes: parsePositiveInt(overrides?.maxResponseBodyBytes?.toString(), N11_DEFAULT_MAX_RESPONSE_BYTES),
|
|
37
|
+
maxSoapBodyBytes: parsePositiveInt(overrides?.maxSoapBodyBytes?.toString(), N11_DEFAULT_MAX_SOAP_BYTES),
|
|
38
|
+
allowProdMutations: overrides?.allowProdMutations ??
|
|
39
|
+
parseBoolean(process.env.N11_ALLOW_PROD_MUTATIONS),
|
|
40
|
+
maxConcurrent: overrides?.maxConcurrent,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export function isN11Configured() {
|
|
44
|
+
try {
|
|
45
|
+
getN11Config();
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** G1 gate: tum REST isteklerinde appKey + appSecret header. */
|
|
53
|
+
export function buildRestAuthHeaders(config) {
|
|
54
|
+
return {
|
|
55
|
+
appKey: config.appKey,
|
|
56
|
+
appSecret: config.appSecret,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CategoriesApi } from "./categories/api.js";
|
|
2
|
+
import type { CategoryListResponse, N11Result } from "./types.js";
|
|
3
|
+
/** Canonical testConnection — yalnizca categories.list() (GET /cdn/categories). */
|
|
4
|
+
export declare function testConnection(categories: CategoriesApi): Promise<N11Result<CategoryListResponse>>;
|
|
5
|
+
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../src/connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAElE,mFAAmF;AACnF,wBAAsB,cAAc,CAClC,UAAU,EAAE,aAAa,GACxB,OAAO,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC,CAE1C"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const N11_DEFAULT_TIMEOUT_MS = 30000;
|
|
2
|
+
export declare const N11_DEFAULT_MAX_RETRIES = 3;
|
|
3
|
+
export declare const N11_DEFAULT_RETRY_BASE_MS = 500;
|
|
4
|
+
export declare const N11_DEFAULT_INTEGRATOR = "SelfIntegration";
|
|
5
|
+
export declare const N11_DEFAULT_MAX_RESPONSE_BYTES: number;
|
|
6
|
+
export declare const N11_DEFAULT_MAX_SOAP_BYTES: number;
|
|
7
|
+
export declare const N11_DEFAULT_ORDER_LOOKBACK_MS = 300000;
|
|
8
|
+
export declare const N11_DEFAULT_TASK_POLL_INTERVAL_MS = 2000;
|
|
9
|
+
export declare const N11_DEFAULT_TASK_POLL_MAX_INTERVAL_MS = 15000;
|
|
10
|
+
export declare const N11_DEFAULT_TASK_POLL_TIMEOUT_MS = 300000;
|
|
11
|
+
export declare const N11_DEFAULT_TASK_BACKOFF_MULTIPLIER = 1.5;
|
|
12
|
+
export declare const N11_RETRY_DELAY_CAP_MS = 60000;
|
|
13
|
+
export declare const N11_TASK_TERMINAL_STATUSES: readonly ["PROCESSED", "REJECT"];
|
|
14
|
+
export declare const N11_TASK_IN_PROGRESS_STATUS = "IN_QUEUE";
|
|
15
|
+
export declare const N11_CORRELATION_HEADER = "x-correlation-id";
|
|
16
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/constants/defaults.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAC7C,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,sBAAsB,oBAAoB,CAAC;AACxD,eAAO,MAAM,8BAA8B,QAAmB,CAAC;AAC/D,eAAO,MAAM,0BAA0B,QAAkB,CAAC;AAC1D,eAAO,MAAM,6BAA6B,SAAU,CAAC;AACrD,eAAO,MAAM,iCAAiC,OAAQ,CAAC;AACvD,eAAO,MAAM,qCAAqC,QAAS,CAAC;AAC5D,eAAO,MAAM,gCAAgC,SAAU,CAAC;AACxD,eAAO,MAAM,mCAAmC,MAAM,CAAC;AACvD,eAAO,MAAM,sBAAsB,QAAS,CAAC;AAE7C,eAAO,MAAM,0BAA0B,kCAAmC,CAAC;AAC3E,eAAO,MAAM,2BAA2B,aAAa,CAAC;AAEtD,eAAO,MAAM,sBAAsB,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const N11_DEFAULT_TIMEOUT_MS = 30_000;
|
|
2
|
+
export const N11_DEFAULT_MAX_RETRIES = 3;
|
|
3
|
+
export const N11_DEFAULT_RETRY_BASE_MS = 500;
|
|
4
|
+
export const N11_DEFAULT_INTEGRATOR = "SelfIntegration";
|
|
5
|
+
export const N11_DEFAULT_MAX_RESPONSE_BYTES = 10 * 1024 * 1024;
|
|
6
|
+
export const N11_DEFAULT_MAX_SOAP_BYTES = 1 * 1024 * 1024;
|
|
7
|
+
export const N11_DEFAULT_ORDER_LOOKBACK_MS = 300_000;
|
|
8
|
+
export const N11_DEFAULT_TASK_POLL_INTERVAL_MS = 2_000;
|
|
9
|
+
export const N11_DEFAULT_TASK_POLL_MAX_INTERVAL_MS = 15_000;
|
|
10
|
+
export const N11_DEFAULT_TASK_POLL_TIMEOUT_MS = 300_000;
|
|
11
|
+
export const N11_DEFAULT_TASK_BACKOFF_MULTIPLIER = 1.5;
|
|
12
|
+
export const N11_RETRY_DELAY_CAP_MS = 60_000;
|
|
13
|
+
export const N11_TASK_TERMINAL_STATUSES = ["PROCESSED", "REJECT"];
|
|
14
|
+
export const N11_TASK_IN_PROGRESS_STATUS = "IN_QUEUE";
|
|
15
|
+
export const N11_CORRELATION_HEADER = "x-correlation-id";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const N11_API_HOST = "https://api.n11.com";
|
|
2
|
+
export declare const N11_CDN_BASE = "https://api.n11.com/cdn";
|
|
3
|
+
export declare const N11_MS_BASE = "https://api.n11.com/ms";
|
|
4
|
+
export declare const N11_REST_BASE = "https://api.n11.com/rest";
|
|
5
|
+
export declare const N11_WS_BASE = "https://api.n11.com/ws";
|
|
6
|
+
export declare const N11_TEST_CONNECTION_PATH = "/categories";
|
|
7
|
+
export declare function buildRestUrl(resource: "cdn" | "ms" | "rest", path: string): string;
|
|
8
|
+
export declare function resolveSoapEndpoint(servicePath: string): string;
|
|
9
|
+
//# sourceMappingURL=hosts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosts.d.ts","sourceRoot":"","sources":["../../src/constants/hosts.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,wBAAwB,CAAC;AAElD,eAAO,MAAM,YAAY,4BAAwB,CAAC;AAClD,eAAO,MAAM,WAAW,2BAAuB,CAAC;AAChD,eAAO,MAAM,aAAa,6BAAyB,CAAC;AACpD,eAAO,MAAM,WAAW,2BAAuB,CAAC;AAEhD,eAAO,MAAM,wBAAwB,gBAAgB,CAAC;AAEtD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,KAAK,GAAG,IAAI,GAAG,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAclF;AAED,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAG/D"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const N11_API_HOST = "https://api.n11.com";
|
|
2
|
+
export const N11_CDN_BASE = `${N11_API_HOST}/cdn`;
|
|
3
|
+
export const N11_MS_BASE = `${N11_API_HOST}/ms`;
|
|
4
|
+
export const N11_REST_BASE = `${N11_API_HOST}/rest`;
|
|
5
|
+
export const N11_WS_BASE = `${N11_API_HOST}/ws`;
|
|
6
|
+
export const N11_TEST_CONNECTION_PATH = "/categories";
|
|
7
|
+
export function buildRestUrl(resource, path) {
|
|
8
|
+
const normalized = path.startsWith("/") ? path : `/${path}`;
|
|
9
|
+
switch (resource) {
|
|
10
|
+
case "cdn":
|
|
11
|
+
return `${N11_CDN_BASE}${normalized}`;
|
|
12
|
+
case "ms":
|
|
13
|
+
return `${N11_MS_BASE}${normalized}`;
|
|
14
|
+
case "rest":
|
|
15
|
+
return `${N11_REST_BASE}${normalized}`;
|
|
16
|
+
default: {
|
|
17
|
+
const _exhaustive = resource;
|
|
18
|
+
return `${N11_API_HOST}${normalized}`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function resolveSoapEndpoint(servicePath) {
|
|
23
|
+
const normalized = servicePath.endsWith("/") ? servicePath : `${servicePath}/`;
|
|
24
|
+
return `${N11_WS_BASE}/${normalized}`;
|
|
25
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** product-query varsayilan sayfa boyutu (portal). */
|
|
2
|
+
export declare const N11_PRODUCT_QUERY_DEFAULT_SIZE = 20;
|
|
3
|
+
/** product-query maksimum sayfa boyutu (portal). */
|
|
4
|
+
export declare const N11_PRODUCT_QUERY_MAX_SIZE = 250;
|
|
5
|
+
/** Urun task submit maksimum SKU (portal). */
|
|
6
|
+
export declare const N11_PRODUCT_TASK_MAX_SKUS = 1000;
|
|
7
|
+
/** task-details/page-query maksimum sayfa boyutu (portal). */
|
|
8
|
+
export declare const N11_TASK_DETAILS_MAX_PAGE_SIZE = 1000;
|
|
9
|
+
/** shipmentPackages maksimum sayfa boyutu (portal). */
|
|
10
|
+
export declare const N11_SHIPMENT_PACKAGES_MAX_SIZE = 100;
|
|
11
|
+
/** shipmentPackages varsayilan sayfa boyutu (reconciler). */
|
|
12
|
+
export declare const N11_SHIPMENT_PACKAGES_DEFAULT_SIZE = 100;
|
|
13
|
+
/** ClaimReturnList sabit sayfa boyutu (portal). */
|
|
14
|
+
export declare const N11_RETURN_LIST_PAGE_SIZE = 20;
|
|
15
|
+
//# sourceMappingURL=page-limits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"page-limits.d.ts","sourceRoot":"","sources":["../../src/constants/page-limits.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,eAAO,MAAM,8BAA8B,KAAK,CAAC;AAEjD,oDAAoD;AACpD,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAE9C,8CAA8C;AAC9C,eAAO,MAAM,yBAAyB,OAAO,CAAC;AAE9C,8DAA8D;AAC9D,eAAO,MAAM,8BAA8B,OAAO,CAAC;AAEnD,uDAAuD;AACvD,eAAO,MAAM,8BAA8B,MAAM,CAAC;AAElD,6DAA6D;AAC7D,eAAO,MAAM,kCAAkC,MAAM,CAAC;AAEtD,mDAAmD;AACnD,eAAO,MAAM,yBAAyB,KAAK,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** product-query varsayilan sayfa boyutu (portal). */
|
|
2
|
+
export const N11_PRODUCT_QUERY_DEFAULT_SIZE = 20;
|
|
3
|
+
/** product-query maksimum sayfa boyutu (portal). */
|
|
4
|
+
export const N11_PRODUCT_QUERY_MAX_SIZE = 250;
|
|
5
|
+
/** Urun task submit maksimum SKU (portal). */
|
|
6
|
+
export const N11_PRODUCT_TASK_MAX_SKUS = 1000;
|
|
7
|
+
/** task-details/page-query maksimum sayfa boyutu (portal). */
|
|
8
|
+
export const N11_TASK_DETAILS_MAX_PAGE_SIZE = 1000;
|
|
9
|
+
/** shipmentPackages maksimum sayfa boyutu (portal). */
|
|
10
|
+
export const N11_SHIPMENT_PACKAGES_MAX_SIZE = 100;
|
|
11
|
+
/** shipmentPackages varsayilan sayfa boyutu (reconciler). */
|
|
12
|
+
export const N11_SHIPMENT_PACKAGES_DEFAULT_SIZE = 100;
|
|
13
|
+
/** ClaimReturnList sabit sayfa boyutu (portal). */
|
|
14
|
+
export const N11_RETURN_LIST_PAGE_SIZE = 20;
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { N11Result } from "./types.js";
|
|
2
|
+
export declare class N11ApiError extends Error {
|
|
3
|
+
code?: string | number;
|
|
4
|
+
status: number;
|
|
5
|
+
raw?: unknown;
|
|
6
|
+
retryable: boolean;
|
|
7
|
+
constructor(message: string, options: {
|
|
8
|
+
status: number;
|
|
9
|
+
code?: string | number;
|
|
10
|
+
raw?: unknown;
|
|
11
|
+
retryable?: boolean;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export declare class N11TransportError extends Error {
|
|
15
|
+
retryable: boolean;
|
|
16
|
+
constructor(message: string, options?: {
|
|
17
|
+
retryable?: boolean;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
export declare class TaskTimeoutError extends Error {
|
|
21
|
+
readonly taskId: string;
|
|
22
|
+
readonly lastStatus?: string;
|
|
23
|
+
constructor(taskId: string, timeoutMs: number, lastStatus?: string);
|
|
24
|
+
}
|
|
25
|
+
export declare class TaskPollAbortedError extends Error {
|
|
26
|
+
constructor(taskId: string);
|
|
27
|
+
}
|
|
28
|
+
export declare class UnknownTaskStatusError extends Error {
|
|
29
|
+
constructor(status: string, taskId: string);
|
|
30
|
+
}
|
|
31
|
+
export declare class NotImplementedError extends Error {
|
|
32
|
+
readonly endpoint: string;
|
|
33
|
+
constructor(endpoint: string);
|
|
34
|
+
}
|
|
35
|
+
export declare function isHtmlErrorBody(body: unknown): boolean;
|
|
36
|
+
export declare function isHtmlGatewayError(error: unknown): boolean;
|
|
37
|
+
export declare function parseApiError(status: number, body: unknown): N11ApiError;
|
|
38
|
+
export declare function parseSoapFailure(rawBody: string, status: number): N11ApiError;
|
|
39
|
+
export declare function isRetryableError(error: unknown): boolean;
|
|
40
|
+
export declare function toFailure<T>(error: unknown): N11Result<T>;
|
|
41
|
+
export declare function notImplemented<T>(endpoint: string): N11Result<T>;
|
|
42
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C,qBAAa,WAAY,SAAQ,KAAK;IACpC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;gBAGjB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE;QACP,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QACvB,GAAG,CAAC,EAAE,OAAO,CAAC;QACd,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB;CASJ;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,SAAS,EAAE,OAAO,CAAC;gBAEP,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE;CAK/D;AAED,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAEjB,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAMnE;AAED,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,MAAM,EAAE,MAAM;CAI3B;AAED,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAI3C;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,QAAQ,EAAE,MAAM;CAK7B;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAItD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAU1D;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,WAAW,CA8BxE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CA8B7E;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAIxD;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC,CAAC,CAAC,CA8BzD;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,CAEhE"}
|