pcbway-mcp-server 0.1.23 → 0.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -25
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +15 -15
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +6 -7
- package/dist/config.js.map +1 -1
- package/dist/index.js +276 -209
- package/dist/index.js.map +1 -1
- package/dist/resources/Account.d.ts +2 -2
- package/dist/resources/Account.d.ts.map +1 -1
- package/dist/resources/Account.js +4 -4
- package/dist/resources/Account.js.map +1 -1
- package/dist/resources/CancelOrder.d.ts +2 -2
- package/dist/resources/CancelOrder.js +5 -5
- package/dist/resources/CancelTGroupOrder.d.ts +2 -2
- package/dist/resources/CancelTGroupOrder.js +6 -6
- package/dist/resources/CheckGroupOrder.d.ts +2 -2
- package/dist/resources/CheckGroupOrder.d.ts.map +1 -1
- package/dist/resources/CheckGroupOrder.js +4 -4
- package/dist/resources/CheckGroupOrder.js.map +1 -1
- package/dist/resources/CheckTGroupOrder.d.ts +2 -2
- package/dist/resources/CheckTGroupOrder.d.ts.map +1 -1
- package/dist/resources/CheckTGroupOrder.js +4 -4
- package/dist/resources/CheckTGroupOrder.js.map +1 -1
- package/dist/resources/ConfirmOrder.d.ts +2 -2
- package/dist/resources/ConfirmOrder.d.ts.map +1 -1
- package/dist/resources/ConfirmOrder.js +30 -20
- package/dist/resources/ConfirmOrder.js.map +1 -1
- package/dist/resources/GetCities.d.ts +2 -2
- package/dist/resources/GetCities.d.ts.map +1 -1
- package/dist/resources/GetCities.js +6 -8
- package/dist/resources/GetCities.js.map +1 -1
- package/dist/resources/GetCountries.d.ts +2 -2
- package/dist/resources/GetCountries.d.ts.map +1 -1
- package/dist/resources/GetCountries.js +4 -4
- package/dist/resources/GetCountries.js.map +1 -1
- package/dist/resources/GetStates.d.ts +2 -2
- package/dist/resources/GetStates.d.ts.map +1 -1
- package/dist/resources/GetStates.js +4 -6
- package/dist/resources/GetStates.js.map +1 -1
- package/dist/resources/OrderDetails.d.ts +2 -2
- package/dist/resources/OrderDetails.js +15 -15
- package/dist/resources/OrderProcess.d.ts +2 -2
- package/dist/resources/OrderProcess.js +6 -6
- package/dist/resources/PayTGroupOrder.d.ts +2 -2
- package/dist/resources/PayTGroupOrder.js +7 -7
- package/dist/resources/PayTGroupOrder.js.map +1 -1
- package/dist/resources/PcbQuote.d.ts +2 -2
- package/dist/resources/PcbQuote.d.ts.map +1 -1
- package/dist/resources/PcbQuote.js +59 -41
- package/dist/resources/PcbQuote.js.map +1 -1
- package/dist/resources/PlaceOrder.d.ts +2 -2
- package/dist/resources/PlaceOrder.d.ts.map +1 -1
- package/dist/resources/PlaceOrder.js +38 -35
- package/dist/resources/PlaceOrder.js.map +1 -1
- package/dist/resources/Shipping.d.ts +2 -2
- package/dist/resources/Shipping.js +12 -12
- package/dist/resources/Shipping.js.map +1 -1
- package/dist/resources/SmtQuote.d.ts +2 -2
- package/dist/resources/SmtQuote.d.ts.map +1 -1
- package/dist/resources/SmtQuote.js +21 -22
- package/dist/resources/SmtQuote.js.map +1 -1
- package/dist/resources/common.js +16 -16
- package/dist/types.d.ts +16 -16
- package/package.json +19 -7
package/README.md
CHANGED
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/pcbway-mcp-server)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
|
|
7
|
-
**Get instant PCB manufacturing and assembly quotes, place orders, and track fabrication —
|
|
7
|
+
**Get instant PCB manufacturing and assembly quotes, place orders, and track fabrication —
|
|
8
|
+
all from your AI coding assistant.** This MCP server gives you full access to the PCBWay
|
|
9
|
+
Partner API: PCB pricing, SMT assembly quotes, order lifecycle (place, confirm, cancel,
|
|
10
|
+
track), shipping costs, and account balance — compatible with Claude Desktop, opencode,
|
|
11
|
+
Cursor, and any MCP client.
|
|
8
12
|
|
|
9
13
|
```bash
|
|
10
14
|
npm install -g pcbway-mcp-server # or run without installing: npx pcbway-mcp-server
|
|
@@ -22,7 +26,8 @@ tools. See [Available Tools](#available-tools) for the full reference.
|
|
|
22
26
|
- **PCB quote API** — instant PCB manufacturing pricing with turn time options
|
|
23
27
|
- **SMT assembly API** — pricing by part counts
|
|
24
28
|
- **Order management** — place, confirm, cancel orders; query fabrication status & details
|
|
25
|
-
- **Order Package Management** — Check, pay, and cancel awaiting-payment packages; inspect
|
|
29
|
+
- **Order Package Management** — Check, pay, and cancel awaiting-payment packages; inspect
|
|
30
|
+
confirmed packages
|
|
26
31
|
- **Shipping costs** — pre-payment freight estimate
|
|
27
32
|
- **Account** — Balance, coupon value, reward points
|
|
28
33
|
- **Address Lookup** — Countries, states/provinces, cities with postal codes
|
|
@@ -30,7 +35,7 @@ tools. See [Available Tools](#available-tools) for the full reference.
|
|
|
30
35
|
|
|
31
36
|
## Requirements
|
|
32
37
|
|
|
33
|
-
- Node.js >=
|
|
38
|
+
- Node.js >= 24
|
|
34
39
|
- A PCBWay Partner account with an **API Key**
|
|
35
40
|
|
|
36
41
|
## Setup
|
|
@@ -64,7 +69,8 @@ export PCBWAY_BASE_DELAY_MS=500 # Base exponential-bac
|
|
|
64
69
|
export PCBWAY_TIMEOUT_MS=30000 # Request timeout (ms)
|
|
65
70
|
```
|
|
66
71
|
|
|
67
|
-
**Note:** The PCBWay Partner API uses a single `api-key` header for authentication. There is
|
|
72
|
+
**Note:** The PCBWay Partner API uses a single `api-key` header for authentication. There is
|
|
73
|
+
no App ID, HMAC signing, or timestamp required.
|
|
68
74
|
|
|
69
75
|
### 4. Run
|
|
70
76
|
|
|
@@ -98,7 +104,7 @@ npx pcbway-mcp-server
|
|
|
98
104
|
PCB manufacturing price quote. Requires shipping destination and board parameters.
|
|
99
105
|
|
|
100
106
|
| Argument | Type | Required | Description |
|
|
101
|
-
|
|
107
|
+
| --- | --- | --- | --- |
|
|
102
108
|
| `Country` | string | ✓ | Country name (e.g. "UNITED STATES OF AMERICA") |
|
|
103
109
|
| `CountryCode` | string | ✓ | ISO country code (e.g. "US") |
|
|
104
110
|
| `ShipType` | number | ✓ | Carrier: 1=DHL, 10=FedEx IP, 4=SF Express, 6=EMS, 7=E-packet, 9=China Post, 35=Global Standard |
|
|
@@ -116,7 +122,7 @@ Returns pricing by build speed (Standard / Express) with shipping cost.
|
|
|
116
122
|
SMT assembly price quote. Uses simple part counts (not a full BOM).
|
|
117
123
|
|
|
118
124
|
| Argument | Type | Required | Description |
|
|
119
|
-
|
|
125
|
+
| --- | --- | --- | --- |
|
|
120
126
|
| `Country` | string | ✓ | Country name |
|
|
121
127
|
| `CountryCode` | string | ✓ | ISO country code |
|
|
122
128
|
| `ShipType` | number | ✓ | Carrier ID |
|
|
@@ -135,15 +141,16 @@ SMT assembly price quote. Uses simple part counts (not a full BOM).
|
|
|
135
141
|
Get fabrication status — shows all required processes and which are completed.
|
|
136
142
|
|
|
137
143
|
| Argument | Type | Required | Description |
|
|
138
|
-
|
|
144
|
+
| --- | --- | --- | --- |
|
|
139
145
|
| `OrderNo` | string | ✓ | PCBWay order number (e.g. "W0002AS1") |
|
|
140
146
|
|
|
141
147
|
### `order_details`
|
|
142
148
|
|
|
143
|
-
Get full order details including all PCB parameters (dimensions, material, finish, audit
|
|
149
|
+
Get full order details including all PCB parameters (dimensions, material, finish, audit
|
|
150
|
+
result, delivery date, etc.)
|
|
144
151
|
|
|
145
152
|
| Argument | Type | Required | Description |
|
|
146
|
-
|
|
153
|
+
| --- | --- | --- | --- |
|
|
147
154
|
| `OrderNo` | string | ✓ | PCBWay order number |
|
|
148
155
|
|
|
149
156
|
### `shipping_freight`
|
|
@@ -151,7 +158,7 @@ Get full order details including all PCB parameters (dimensions, material, finis
|
|
|
151
158
|
Get shipping cost before payment (call after placing order, before confirming).
|
|
152
159
|
|
|
153
160
|
| Argument | Type | Required | Description |
|
|
154
|
-
|
|
161
|
+
| --- | --- | --- | --- |
|
|
155
162
|
| `OrderNo` | string | ✓ | Order number (comma-separated for joint shipment) |
|
|
156
163
|
| `ShipType` | number | ✓ | Carrier ID |
|
|
157
164
|
| `Country` | string | ✓ | Country name |
|
|
@@ -170,7 +177,7 @@ Query PCBWay account balance, coupon value, and reward points. No parameters req
|
|
|
170
177
|
Add a PCB order to your cart. Requires PCB file and all board parameters.
|
|
171
178
|
|
|
172
179
|
| Argument | Type | Required | Description |
|
|
173
|
-
|
|
180
|
+
| --- | --- | --- | --- |
|
|
174
181
|
| `PcbFileName` | string | ✓ | PCB file name |
|
|
175
182
|
| `BuildDays` | number | ✓ | Production cycle from quote response |
|
|
176
183
|
| `Length` | number | ✓ | Board length in mm |
|
|
@@ -192,7 +199,7 @@ Add a PCB order to your cart. Requires PCB file and all board parameters.
|
|
|
192
199
|
Confirm orders and make payment. Can confirm single or multiple orders together.
|
|
193
200
|
|
|
194
201
|
| Argument | Type | Required | Description |
|
|
195
|
-
|
|
202
|
+
| --- | --- | --- | --- |
|
|
196
203
|
| `OrderNo` | string | ✓ | Order number(s), comma-separated for multiple |
|
|
197
204
|
| `PayType` | number | ✓ | Payment method: 1=AccountPay, 2=PCBWayWebPay |
|
|
198
205
|
| `ShipType` | number | | Carrier (required unless adding to package) |
|
|
@@ -214,7 +221,7 @@ Confirm orders and make payment. Can confirm single or multiple orders together.
|
|
|
214
221
|
Cancel an existing PCBWay order.
|
|
215
222
|
|
|
216
223
|
| Argument | Type | Required | Description |
|
|
217
|
-
|
|
224
|
+
| --- | --- | --- | --- |
|
|
218
225
|
| `OrderNo` | string | ✓ | Order number to cancel |
|
|
219
226
|
|
|
220
227
|
### `check_tgroup_order`
|
|
@@ -222,7 +229,7 @@ Cancel an existing PCBWay order.
|
|
|
222
229
|
Check awaiting-payment order package details.
|
|
223
230
|
|
|
224
231
|
| Argument | Type | Required | Description |
|
|
225
|
-
|
|
232
|
+
| --- | --- | --- | --- |
|
|
226
233
|
| `TGroupNo` | string | ✓ | Awaiting-payment package number |
|
|
227
234
|
|
|
228
235
|
### `pay_tgroup_order`
|
|
@@ -230,7 +237,7 @@ Check awaiting-payment order package details.
|
|
|
230
237
|
Pay for an awaiting-payment order package.
|
|
231
238
|
|
|
232
239
|
| Argument | Type | Required | Description |
|
|
233
|
-
|
|
240
|
+
| --- | --- | --- | --- |
|
|
234
241
|
| `TGroupNo` | string | ✓ | Awaiting-payment package number |
|
|
235
242
|
| `PayType` | number | ✓ | 1=AccountPay, 2=PCBWayWebPay |
|
|
236
243
|
|
|
@@ -239,7 +246,7 @@ Pay for an awaiting-payment order package.
|
|
|
239
246
|
Cancel an awaiting-payment order package.
|
|
240
247
|
|
|
241
248
|
| Argument | Type | Required | Description |
|
|
242
|
-
|
|
249
|
+
| --- | --- | --- | --- |
|
|
243
250
|
| `TGroupNo` | string | ✓ | Awaiting-payment package number to cancel |
|
|
244
251
|
|
|
245
252
|
### `check_group_order`
|
|
@@ -247,7 +254,7 @@ Cancel an awaiting-payment order package.
|
|
|
247
254
|
Check a confirmed (paid) order package details.
|
|
248
255
|
|
|
249
256
|
| Argument | Type | Required | Description |
|
|
250
|
-
|
|
257
|
+
| --- | --- | --- | --- |
|
|
251
258
|
| `GroupNo` | string | ✓ | Confirmed order package number |
|
|
252
259
|
|
|
253
260
|
### `get_countries`
|
|
@@ -259,7 +266,7 @@ List all supported countries for PCBWay ordering. No parameters required.
|
|
|
259
266
|
List states/provinces for a country.
|
|
260
267
|
|
|
261
268
|
| Argument | Type | Required | Description |
|
|
262
|
-
|
|
269
|
+
| --- | --- | --- | --- |
|
|
263
270
|
| `Country` | string | ✓ | Country name (e.g. "UNITED STATES OF AMERICA") |
|
|
264
271
|
| `CountryCode` | string | ✓ | ISO country code (e.g. "US") |
|
|
265
272
|
|
|
@@ -268,7 +275,7 @@ List states/provinces for a country.
|
|
|
268
275
|
List cities with postal codes for a country/state.
|
|
269
276
|
|
|
270
277
|
| Argument | Type | Required | Description |
|
|
271
|
-
|
|
278
|
+
| --- | --- | --- | --- |
|
|
272
279
|
| `Country` | string | ✓ | Country name |
|
|
273
280
|
| `CountryCode` | string | ✓ | ISO country code |
|
|
274
281
|
| `State` | string | | State/Province to filter by (optional) |
|
|
@@ -284,7 +291,7 @@ npm run build
|
|
|
284
291
|
|
|
285
292
|
## Architecture
|
|
286
293
|
|
|
287
|
-
```
|
|
294
|
+
```text
|
|
288
295
|
src/
|
|
289
296
|
├── index.ts # MCP server entry point + tool registry
|
|
290
297
|
├── config.ts # Environment variable loading (PCBWAY_API_KEY only)
|
|
@@ -309,12 +316,13 @@ src/
|
|
|
309
316
|
└── GetCities.ts # POST /api/Address/GetCity
|
|
310
317
|
```
|
|
311
318
|
|
|
312
|
-
One class per resource. Input validation via Zod schemas. All endpoints use POST with JSON
|
|
319
|
+
One class per resource. Input validation via Zod schemas. All endpoints use POST with JSON
|
|
320
|
+
body and `api-key` header authentication.
|
|
313
321
|
|
|
314
322
|
## API Endpoint Coverage
|
|
315
323
|
|
|
316
324
|
| MCP Tool | PCBWay API Endpoint | Status |
|
|
317
|
-
|
|
325
|
+
| --- | --- | --- |
|
|
318
326
|
| `pcb_quote` | `POST /api/Pcb/PcbQuotation` | ✅ |
|
|
319
327
|
| `smt_quote` | `POST /api/SMT/SMTQuotation` | ✅ |
|
|
320
328
|
| `order_process` | `POST /api/Pcb/QueryOrderProcess` | ✅ |
|
|
@@ -343,14 +351,22 @@ Releases are published automatically by CI — no manual npm publish needed.
|
|
|
343
351
|
| Push `v*-beta*` tag | `beta` | from `package.json` | the tag | ✅ (prerelease) |
|
|
344
352
|
| Manual `workflow_dispatch` on CI | `beta` | next `-beta.N` after last published beta | — | — |
|
|
345
353
|
|
|
346
|
-
- Every PR push publishes `<version>-beta.<run_number>` to the `beta` dist-tag
|
|
354
|
+
- Every PR push publishes `<version>-beta.<run_number>` to the `beta` dist-tag
|
|
355
|
+
(`npm i pcbway-mcp-server@beta`), so every PR is instantly installable — same-repo,
|
|
356
|
+
non-draft, non-dependabot PRs; re-runs deduped.
|
|
347
357
|
|
|
348
358
|
- Stable version = last published `latest` + patch, so repeated merges never collide.
|
|
349
359
|
- An intentional minor/major bump in `package.json` is published as-is (honored).
|
|
350
360
|
- Publish is retried 3x for transient failures only; a version conflict is never retried.
|
|
351
361
|
- A push to `main` only tags/releases if it actually published (channel check).
|
|
352
|
-
- A push to `main` only publishes when it changed something the package ships.
|
|
353
|
-
-
|
|
362
|
+
- A push to `main` only publishes when it changed something the package ships.
|
|
363
|
+
`package-lock.json`, `.github/**`, and a `package.json` whose only diffs are the version
|
|
364
|
+
and/or the inert devDependencies (`@types/node`, `vitest`, `@vitest/coverage-v8`) are
|
|
365
|
+
non-shipping and cut no release. `typescript` is deliberately not inert — it compiles
|
|
366
|
+
`dist/`.
|
|
367
|
+
- The guard diffs from the newest stable `v*` tag, not from the previous commit, so a
|
|
368
|
+
shipping change whose publish failed is retried by the next run instead of waiting for the
|
|
369
|
+
next shipping merge.
|
|
354
370
|
|
|
355
371
|
## License
|
|
356
372
|
|
package/dist/client.d.ts
CHANGED
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAc,MAAM,aAAa,CAAC;AAItD;;;GAGG;AACH,qBAAa,cAAe,SAAQ,KAAK;aAGrB,IAAI,EAAE,MAAM;IAF9B,YACE,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EAI7B;CACF;AAED;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;aAGzB,MAAM,CAAC,EAAE,MAAM;IAFjC,YACE,OAAO,EAAE,MAAM,EACC,MAAM,CAAC,EAAE,MAAM,YAAA,EAIhC;CACF;AAqBD;;;;GAIG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAS;IAEvB,YAAY,MAAM,CAAC,EAAE,MAAM,EAE1B;IAED;;;;;;;OAOG;IACG,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA0FxE;CACF"}
|
package/dist/client.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { loadConfig } from
|
|
1
|
+
import { loadConfig } from "./config.js";
|
|
2
2
|
// ── Typed error ──────────────────────────────────────────────────
|
|
3
3
|
/**
|
|
4
4
|
* Thrown when the PCBWay API returns `Status: "error"`.
|
|
@@ -9,7 +9,7 @@ export class PcbWayApiError extends Error {
|
|
|
9
9
|
constructor(message, code) {
|
|
10
10
|
super(message);
|
|
11
11
|
this.code = code;
|
|
12
|
-
this.name =
|
|
12
|
+
this.name = "PcbWayApiError";
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
@@ -20,7 +20,7 @@ export class PcbWayNetworkError extends Error {
|
|
|
20
20
|
constructor(message, status) {
|
|
21
21
|
super(message);
|
|
22
22
|
this.status = status;
|
|
23
|
-
this.name =
|
|
23
|
+
this.name = "PcbWayNetworkError";
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
// ── Helpers ──────────────────────────────────────────────────────
|
|
@@ -65,10 +65,10 @@ export class PcbWayClient {
|
|
|
65
65
|
let response;
|
|
66
66
|
try {
|
|
67
67
|
response = await fetch(url, {
|
|
68
|
-
method:
|
|
68
|
+
method: "POST",
|
|
69
69
|
headers: {
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
"Content-Type": "application/json",
|
|
71
|
+
"api-key": this.config.apiKey,
|
|
72
72
|
},
|
|
73
73
|
body: JSON.stringify(body),
|
|
74
74
|
signal: controller.signal,
|
|
@@ -86,17 +86,17 @@ export class PcbWayClient {
|
|
|
86
86
|
await sleep(delay);
|
|
87
87
|
continue;
|
|
88
88
|
}
|
|
89
|
-
throw new PcbWayNetworkError(`HTTP ${response.status} ${response.statusText}${text ? ` — ${text}` :
|
|
89
|
+
throw new PcbWayNetworkError(`HTTP ${response.status} ${response.statusText}${text ? ` — ${text}` : ""}`, response.status);
|
|
90
90
|
}
|
|
91
91
|
// Parse JSON
|
|
92
92
|
const data = JSON.parse(text);
|
|
93
93
|
// Check API-level error status if the response type has it
|
|
94
94
|
// We do a safe check on the envelope fields
|
|
95
95
|
const envelope = data;
|
|
96
|
-
if (envelope.Status ===
|
|
97
|
-
const errText = typeof envelope.ErrorText ===
|
|
98
|
-
const code = typeof envelope.Code ===
|
|
99
|
-
throw new PcbWayApiError(errText ??
|
|
96
|
+
if (envelope.Status === "error") {
|
|
97
|
+
const errText = typeof envelope.ErrorText === "string" ? envelope.ErrorText : null;
|
|
98
|
+
const code = typeof envelope.Code === "number" ? envelope.Code : 0;
|
|
99
|
+
throw new PcbWayApiError(errText ?? "Unknown API error", code);
|
|
100
100
|
}
|
|
101
101
|
return data;
|
|
102
102
|
}
|
|
@@ -106,16 +106,16 @@ export class PcbWayClient {
|
|
|
106
106
|
throw err;
|
|
107
107
|
}
|
|
108
108
|
// AbortError (timeout) — retry
|
|
109
|
-
if (err instanceof Error && err.name ===
|
|
109
|
+
if (err instanceof Error && err.name === "AbortError") {
|
|
110
110
|
if (attempt < this.config.maxRetries) {
|
|
111
111
|
const delay = backoffDelay(this.config.baseDelayMs, attempt);
|
|
112
112
|
await sleep(delay);
|
|
113
113
|
continue;
|
|
114
114
|
}
|
|
115
|
-
throw new PcbWayNetworkError(
|
|
115
|
+
throw new PcbWayNetworkError("Request timed out");
|
|
116
116
|
}
|
|
117
117
|
// Fetch network error — retry
|
|
118
|
-
if (err instanceof TypeError || (err instanceof Error &&
|
|
118
|
+
if (err instanceof TypeError || (err instanceof Error && "code" in err)) {
|
|
119
119
|
lastError = err;
|
|
120
120
|
if (attempt < this.config.maxRetries) {
|
|
121
121
|
const delay = backoffDelay(this.config.baseDelayMs, attempt);
|
|
@@ -129,7 +129,7 @@ export class PcbWayClient {
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
// Should not reach here, but satisfy types
|
|
132
|
-
throw lastError ?? new PcbWayNetworkError(
|
|
132
|
+
throw lastError ?? new PcbWayNetworkError("Request failed");
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,UAAU,EAAE,MAAM,aAAa,CAAC;AAEtD,oEAAoE;AAEpE;;;GAGG;AACH,MAAM,OAAO,cAAe,SAAQ,KAAK;IAGrB,IAAI;IAFtB,YACE,OAAe,EACC,IAAY;QAE5B,KAAK,CAAC,OAAO,CAAC,CAAC;oBAFC,IAAI;QAGpB,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAGzB,MAAM;IAFxB,YACE,OAAe,EACC,MAAe;QAE/B,KAAK,CAAC,OAAO,CAAC,CAAC;sBAFC,MAAM;QAGtB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,oEAAoE;AAEpE,mCAAmC;AACnC,MAAM,KAAK,GAAG,CAAC,EAAU,EAAiB,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAE/F,mEAAmE;AACnE,SAAS,YAAY,CAAC,WAAmB,EAAE,OAAe;IACxD,MAAM,KAAK,GAAG,WAAW,GAAG,CAAC,IAAI,OAAO,CAAC,CAAC,qBAAq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2C;QAC3C,MAAM,SAAS,IAAI,IAAI,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;IAC9D,CAAC;CACF"}
|
package/dist/config.d.ts
CHANGED
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,eAAe,CAAC;AAEvB,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,eAAe,CAAC;AAEvB,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,0EAA0E;IAC1E,UAAU,EAAE,MAAM,CAAC;IACnB,6DAA6D;IAC7D,WAAW,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAcnC"}
|
package/dist/config.js
CHANGED
|
@@ -4,20 +4,19 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Loads .env file automatically via dotenv (if present).
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
7
|
+
import "dotenv/config";
|
|
8
8
|
/**
|
|
9
9
|
* Load config from process.env.
|
|
10
10
|
* Throws clearly if PCBWAY_API_KEY is missing.
|
|
11
11
|
*/
|
|
12
12
|
export function loadConfig() {
|
|
13
13
|
const apiKey = process.env.PCBWAY_API_KEY;
|
|
14
|
-
const baseUrl = process.env.PCBWAY_BASE_URL ??
|
|
15
|
-
const maxRetries = parseInt(process.env.PCBWAY_MAX_RETRIES ??
|
|
16
|
-
const baseDelayMs = parseInt(process.env.PCBWAY_BASE_DELAY_MS ??
|
|
17
|
-
const timeoutMs = parseInt(process.env.PCBWAY_TIMEOUT_MS ??
|
|
14
|
+
const baseUrl = process.env.PCBWAY_BASE_URL ?? "https://api-partner.pcbway.com";
|
|
15
|
+
const maxRetries = parseInt(process.env.PCBWAY_MAX_RETRIES ?? "", 10) || 3;
|
|
16
|
+
const baseDelayMs = parseInt(process.env.PCBWAY_BASE_DELAY_MS ?? "", 10) || 500;
|
|
17
|
+
const timeoutMs = parseInt(process.env.PCBWAY_TIMEOUT_MS ?? "", 10) || 30_000;
|
|
18
18
|
if (!apiKey) {
|
|
19
|
-
throw new Error(
|
|
20
|
-
'Set it to your PCBWay Partner API Key.');
|
|
19
|
+
throw new Error("Missing PCBWAY_API_KEY environment variable. " + "Set it to your PCBWay Partner API Key.");
|
|
21
20
|
}
|
|
22
21
|
return { apiKey, baseUrl, maxRetries, baseDelayMs, timeoutMs };
|
|
23
22
|
}
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,eAAe,CAAC;AAavB;;;GAGG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IAC1C,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,eAAe,CAAC;AAavB;;;GAGG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,gCAAgC,CAAC;IAChF,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;IAC3E,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,GAAG,CAAC;IAChF,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC;IAE9E,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,+CAA+C,GAAG,wCAAwC,CAC3F,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;AACjE,CAAC"}
|