@outfitcanvas/fitview-sdk 1.0.1 → 1.0.2
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 +21 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +17 -2
- package/dist/index.mjs +17 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ import { FitViewClient, OutfitCanvasModel } from '@outfitcanvas/fitview-sdk';
|
|
|
20
20
|
// Initialize the client
|
|
21
21
|
const client = new FitViewClient({
|
|
22
22
|
apiKey: 'pk_live_your_api_key_here',
|
|
23
|
-
baseURL: 'https://api.fitview.
|
|
23
|
+
baseURL: 'https://api.fitview.io', // Optional, defaults to production
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
// Generate a virtual try-on
|
|
@@ -53,7 +53,7 @@ Main client class for interacting with the FitView API.
|
|
|
53
53
|
```typescript
|
|
54
54
|
const client = new FitViewClient({
|
|
55
55
|
apiKey: string, // Required: Your API key
|
|
56
|
-
baseURL?: string, // Optional: API base URL (default: https://api.fitview.
|
|
56
|
+
baseURL?: string, // Optional: API base URL (default: https://api.fitview.io)
|
|
57
57
|
timeout?: number, // Optional: Request timeout in ms (default: 300000)
|
|
58
58
|
apiVersion?: string, // Optional: API version (default: 'v1')
|
|
59
59
|
maxRetries?: number, // Optional: Retries for 429/5xx (default: 3, set 0 to disable)
|
|
@@ -528,6 +528,25 @@ The SDK provides specific error classes for different scenarios:
|
|
|
528
528
|
- `FitViewTimeoutError` - Timeout errors
|
|
529
529
|
- `FitViewNetworkError` - Network errors
|
|
530
530
|
|
|
531
|
+
## Troubleshooting
|
|
532
|
+
|
|
533
|
+
### `getaddrinfo ENOTFOUND api.fitview.io` (or similar)
|
|
534
|
+
|
|
535
|
+
This means the hostname of the API could not be resolved (DNS failure). Common causes:
|
|
536
|
+
|
|
537
|
+
1. **Wrong or placeholder base URL** – The default `baseURL` is `https://api.fitview.io`. If your API is hosted elsewhere (e.g. your own Cloud Run URL), set the correct URL when creating the client:
|
|
538
|
+
```typescript
|
|
539
|
+
const client = new FitViewClient({
|
|
540
|
+
apiKey: process.env.FITVIEW_API_KEY!,
|
|
541
|
+
baseURL: process.env.FITVIEW_BASE_URL || 'https://your-actual-api.run.app',
|
|
542
|
+
});
|
|
543
|
+
```
|
|
544
|
+
Or set the `FITVIEW_BASE_URL` environment variable (e.g. `https://fitview-api-xxxxx-uc.a.run.app` without `/api/v1`).
|
|
545
|
+
|
|
546
|
+
2. **Network or DNS issues** – Firewall, VPN, or local DNS may block or fail to resolve the host. Try from another network or verify the API URL in a browser/curl.
|
|
547
|
+
|
|
548
|
+
3. **Custom domain not set up** – If `api.fitview.io` is not yet configured in DNS for your environment, use the actual API URL provided by your dashboard or deployment (e.g. Cloud Run URL) as `baseURL`.
|
|
549
|
+
|
|
531
550
|
## Requirements
|
|
532
551
|
|
|
533
552
|
- Node.js 18.0.0 or higher
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -13678,7 +13678,7 @@ var FitViewClient = class {
|
|
|
13678
13678
|
throw new Error("API key is required. Pass apiKey in the client options.");
|
|
13679
13679
|
}
|
|
13680
13680
|
this.apiKey = options.apiKey;
|
|
13681
|
-
this.baseURL = (options.baseURL || "https://api.fitview.
|
|
13681
|
+
this.baseURL = (options.baseURL || "https://api.fitview.io").replace(/\/$/, "");
|
|
13682
13682
|
this.timeout = options.timeout ?? 3e5;
|
|
13683
13683
|
this.apiVersion = options.apiVersion || "v1";
|
|
13684
13684
|
this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
@@ -13740,7 +13740,22 @@ var FitViewClient = class {
|
|
|
13740
13740
|
signal.addEventListener("abort", () => controller.abort());
|
|
13741
13741
|
}
|
|
13742
13742
|
requestOptions.signal = controller.signal;
|
|
13743
|
-
|
|
13743
|
+
let response;
|
|
13744
|
+
try {
|
|
13745
|
+
response = await this.fetchImpl(url, requestOptions);
|
|
13746
|
+
} catch (err) {
|
|
13747
|
+
clearTimeout(timeoutId);
|
|
13748
|
+
const msg = err?.message ?? String(err);
|
|
13749
|
+
const code = err?.code ?? err?.cause?.code;
|
|
13750
|
+
const isDnsFailure = code === "ENOTFOUND" || code === "ENODATA" || /getaddrinfo|ENOTFOUND|ENODATA|Could not resolve host/i.test(msg);
|
|
13751
|
+
if (isDnsFailure) {
|
|
13752
|
+
throw new FitViewNetworkError(
|
|
13753
|
+
`Could not reach the API (${msg}). If you see ENOTFOUND for the API host, the base URL may be wrong: set baseURL in client options or FITVIEW_BASE_URL to your actual API URL (e.g. from your dashboard or Cloud Run).`,
|
|
13754
|
+
err
|
|
13755
|
+
);
|
|
13756
|
+
}
|
|
13757
|
+
throw new FitViewNetworkError(msg || "Network request failed", err);
|
|
13758
|
+
}
|
|
13744
13759
|
clearTimeout(timeoutId);
|
|
13745
13760
|
const data = await response.json().catch(() => ({}));
|
|
13746
13761
|
if (!response.ok) {
|
package/dist/index.mjs
CHANGED
|
@@ -8519,7 +8519,7 @@ var FitViewClient = class {
|
|
|
8519
8519
|
throw new Error("API key is required. Pass apiKey in the client options.");
|
|
8520
8520
|
}
|
|
8521
8521
|
this.apiKey = options.apiKey;
|
|
8522
|
-
this.baseURL = (options.baseURL || "https://api.fitview.
|
|
8522
|
+
this.baseURL = (options.baseURL || "https://api.fitview.io").replace(/\/$/, "");
|
|
8523
8523
|
this.timeout = options.timeout ?? 3e5;
|
|
8524
8524
|
this.apiVersion = options.apiVersion || "v1";
|
|
8525
8525
|
this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
|
|
@@ -8581,7 +8581,22 @@ var FitViewClient = class {
|
|
|
8581
8581
|
signal.addEventListener("abort", () => controller.abort());
|
|
8582
8582
|
}
|
|
8583
8583
|
requestOptions.signal = controller.signal;
|
|
8584
|
-
|
|
8584
|
+
let response;
|
|
8585
|
+
try {
|
|
8586
|
+
response = await this.fetchImpl(url, requestOptions);
|
|
8587
|
+
} catch (err) {
|
|
8588
|
+
clearTimeout(timeoutId);
|
|
8589
|
+
const msg = err?.message ?? String(err);
|
|
8590
|
+
const code = err?.code ?? err?.cause?.code;
|
|
8591
|
+
const isDnsFailure = code === "ENOTFOUND" || code === "ENODATA" || /getaddrinfo|ENOTFOUND|ENODATA|Could not resolve host/i.test(msg);
|
|
8592
|
+
if (isDnsFailure) {
|
|
8593
|
+
throw new FitViewNetworkError(
|
|
8594
|
+
`Could not reach the API (${msg}). If you see ENOTFOUND for the API host, the base URL may be wrong: set baseURL in client options or FITVIEW_BASE_URL to your actual API URL (e.g. from your dashboard or Cloud Run).`,
|
|
8595
|
+
err
|
|
8596
|
+
);
|
|
8597
|
+
}
|
|
8598
|
+
throw new FitViewNetworkError(msg || "Network request failed", err);
|
|
8599
|
+
}
|
|
8585
8600
|
clearTimeout(timeoutId);
|
|
8586
8601
|
const data = await response.json().catch(() => ({}));
|
|
8587
8602
|
if (!response.ok) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@outfitcanvas/fitview-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "TypeScript SDK for FitView API - virtual try-on service",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -52,4 +52,4 @@
|
|
|
52
52
|
"engines": {
|
|
53
53
|
"node": ">=18.0.0"
|
|
54
54
|
}
|
|
55
|
-
}
|
|
55
|
+
}
|