@cardog/api 0.1.2 → 0.2.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 ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 (2026-03-31)
4
+
5
+ ### Breaking Changes
6
+ - Replaced axios with native fetch. If you were accessing the internal axios instance directly, that no longer exists.
7
+
8
+ ### Security
9
+ - Removed axios dependency in response to supply chain compromise (axios@1.14.1, axios@0.30.4)
10
+
11
+ ### Changed
12
+ - `APIError` now wraps fetch Response errors instead of AxiosError (same public interface)
13
+ - DELETE requests now support request body via `{ body }` option
14
+
15
+ ## 0.1.3
16
+
17
+ - Initial public release
package/README.md CHANGED
@@ -291,7 +291,7 @@ queryKeys.recalls.search(params)
291
291
  ```typescript
292
292
  const client = new CardogClient({
293
293
  apiKey: "your-api-key",
294
- baseUrl: "https://api.cardog.io", // Default
294
+ baseUrl: "https://api.cardog.app", // Default
295
295
  });
296
296
 
297
297
  // Update config at runtime
package/dist/index.d.mts CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as _cardog_contracts from '@cardog/contracts';
2
2
  import { VinDecodeResponse, VinCorgiResponse, VinImageResponse, MarketAnalysis, MarketOverview, MarketPricing, BreakdownResponse, MarketOdometer, MarketGeography, MarketTrends, MarketPosition, MarketPulse, LocalMarketResponse, DemandMatrixResponse, ListingQuery, ListingSearchResponse, ListingCountResponse, Listing as Listing$1, ListingFacetsResponse, ListingFilters, LocationSearchParams, LocationResult, ChargingParams, ChargingStationResponse, ChargingStation, FuelTypeString, FuelStationResponse, LineupQuery, LineupResponse, VariantArrayResponse, VariantResponse, ResearchImageArray, ColorData, RecallSearchParams, RecallResponse, EfficiencySearchParams } from '@cardog/contracts';
3
3
  export { BreakdownResponse, ChargingParams, ChargingStation, ChargingStationResponse, ColorData, ColorInfo, DemandMatrixResponse, FuelStation, FuelStationResponse, FuelType, LineupQuery, LineupResponse, LocalMarketResponse, MarketAnalysis, MarketGeography, MarketOdometer, MarketOverview, MarketPosition, MarketPricing, MarketPulse, MarketTrends, RecallDetail, RecallResponse, RecallSearchParams, ResearchImage, ResearchImageArray, Variant, VariantArrayResponse, VariantResponse, VinDecodeResponse, VinImageResponse, listingSchema } from '@cardog/contracts';
4
- import { AxiosInstance } from 'axios';
5
4
  import { z } from 'zod';
6
5
 
7
6
  interface ClientConfig {
@@ -19,16 +18,20 @@ declare class APIError extends Error {
19
18
  constructor(message: string, status: number, code: string, data?: any | undefined);
20
19
  }
21
20
  declare class BaseClient {
22
- protected client: AxiosInstance;
21
+ protected baseUrl: string;
23
22
  protected config: ClientConfig;
24
23
  constructor(config: ClientConfig);
25
24
  setConfig(config: ClientConfig): void;
26
- private setupInterceptors;
25
+ private getHeaders;
26
+ private buildUrl;
27
+ private request;
27
28
  protected get<T>(path: string, options?: RequestOptions): Promise<T>;
28
29
  protected post<T>(path: string, data: any, options?: RequestOptions): Promise<T>;
29
30
  protected put<T>(path: string, data: any, options?: RequestOptions): Promise<T>;
30
31
  protected patch<T>(path: string, data: any, options?: RequestOptions): Promise<T>;
31
- protected delete<T>(path: string, options?: RequestOptions): Promise<T>;
32
+ protected delete<T>(path: string, options?: RequestOptions & {
33
+ body?: any;
34
+ }): Promise<T>;
32
35
  }
33
36
 
34
37
  declare const vinKeys: {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import * as _cardog_contracts from '@cardog/contracts';
2
2
  import { VinDecodeResponse, VinCorgiResponse, VinImageResponse, MarketAnalysis, MarketOverview, MarketPricing, BreakdownResponse, MarketOdometer, MarketGeography, MarketTrends, MarketPosition, MarketPulse, LocalMarketResponse, DemandMatrixResponse, ListingQuery, ListingSearchResponse, ListingCountResponse, Listing as Listing$1, ListingFacetsResponse, ListingFilters, LocationSearchParams, LocationResult, ChargingParams, ChargingStationResponse, ChargingStation, FuelTypeString, FuelStationResponse, LineupQuery, LineupResponse, VariantArrayResponse, VariantResponse, ResearchImageArray, ColorData, RecallSearchParams, RecallResponse, EfficiencySearchParams } from '@cardog/contracts';
3
3
  export { BreakdownResponse, ChargingParams, ChargingStation, ChargingStationResponse, ColorData, ColorInfo, DemandMatrixResponse, FuelStation, FuelStationResponse, FuelType, LineupQuery, LineupResponse, LocalMarketResponse, MarketAnalysis, MarketGeography, MarketOdometer, MarketOverview, MarketPosition, MarketPricing, MarketPulse, MarketTrends, RecallDetail, RecallResponse, RecallSearchParams, ResearchImage, ResearchImageArray, Variant, VariantArrayResponse, VariantResponse, VinDecodeResponse, VinImageResponse, listingSchema } from '@cardog/contracts';
4
- import { AxiosInstance } from 'axios';
5
4
  import { z } from 'zod';
6
5
 
7
6
  interface ClientConfig {
@@ -19,16 +18,20 @@ declare class APIError extends Error {
19
18
  constructor(message: string, status: number, code: string, data?: any | undefined);
20
19
  }
21
20
  declare class BaseClient {
22
- protected client: AxiosInstance;
21
+ protected baseUrl: string;
23
22
  protected config: ClientConfig;
24
23
  constructor(config: ClientConfig);
25
24
  setConfig(config: ClientConfig): void;
26
- private setupInterceptors;
25
+ private getHeaders;
26
+ private buildUrl;
27
+ private request;
27
28
  protected get<T>(path: string, options?: RequestOptions): Promise<T>;
28
29
  protected post<T>(path: string, data: any, options?: RequestOptions): Promise<T>;
29
30
  protected put<T>(path: string, data: any, options?: RequestOptions): Promise<T>;
30
31
  protected patch<T>(path: string, data: any, options?: RequestOptions): Promise<T>;
31
- protected delete<T>(path: string, options?: RequestOptions): Promise<T>;
32
+ protected delete<T>(path: string, options?: RequestOptions & {
33
+ body?: any;
34
+ }): Promise<T>;
32
35
  }
33
36
 
34
37
  declare const vinKeys: {
package/dist/index.js CHANGED
@@ -2,14 +2,11 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var axios = require('axios');
6
5
  var zod = require('zod');
7
6
 
8
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
-
10
- var axios__default = /*#__PURE__*/_interopDefault(axios);
11
-
12
7
  // src/base.ts
8
+ var CLIENT_VERSION = "0.2.0";
9
+ var DEFAULT_BASE_URL = "https://api.cardog.app/v1";
13
10
  var APIError = class extends Error {
14
11
  constructor(message, status, code, data) {
15
12
  super(message);
@@ -22,69 +19,65 @@ var APIError = class extends Error {
22
19
  var BaseClient = class {
23
20
  constructor(config) {
24
21
  this.config = config;
25
- this.client = axios__default.default.create({
26
- baseURL: config.baseUrl || "https://api.cardog.io",
27
- headers: {
28
- "Content-Type": "application/json",
29
- ...config.apiKey && { Authorization: `Bearer ${config.apiKey}` }
30
- }
31
- });
32
- this.setupInterceptors();
22
+ this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
33
23
  }
34
24
  setConfig(config) {
35
25
  this.config = config;
36
- if (config.apiKey) {
37
- this.client.defaults.headers.Authorization = `Bearer ${config.apiKey}`;
38
- } else {
39
- delete this.client.defaults.headers.Authorization;
26
+ if (config.baseUrl) {
27
+ this.baseUrl = config.baseUrl;
40
28
  }
41
29
  }
42
- setupInterceptors() {
43
- this.client.interceptors.response.use(
44
- (response) => response.data,
45
- (error) => {
46
- if (error.response) {
47
- const { status, data } = error.response;
48
- throw new APIError(
49
- error.message,
50
- status,
51
- data?.code || "unknown_error",
52
- data
53
- );
30
+ getHeaders(extra) {
31
+ return {
32
+ "Content-Type": "application/json",
33
+ "User-Agent": `@cardog/api/${CLIENT_VERSION}`,
34
+ ...this.config.apiKey && { Authorization: `Bearer ${this.config.apiKey}` },
35
+ ...extra
36
+ };
37
+ }
38
+ buildUrl(path, params) {
39
+ const url = new URL(path, this.baseUrl);
40
+ if (params) {
41
+ for (const [key, value] of Object.entries(params)) {
42
+ if (value !== void 0 && value !== null) {
43
+ url.searchParams.set(key, String(value));
54
44
  }
55
- throw error;
56
45
  }
57
- );
46
+ }
47
+ return url.toString();
58
48
  }
59
- async get(path, options = {}) {
60
- return this.client.get(path, {
61
- headers: options.headers,
62
- params: options.params
49
+ async request(method, path, options = {}) {
50
+ const url = this.buildUrl(path, options.params);
51
+ const response = await fetch(url, {
52
+ method,
53
+ headers: this.getHeaders(options.headers),
54
+ body: options.body ? JSON.stringify(options.body) : void 0
63
55
  });
56
+ const data = await response.json().catch(() => null);
57
+ if (!response.ok) {
58
+ throw new APIError(
59
+ data?.message || response.statusText,
60
+ response.status,
61
+ data?.code || "unknown_error",
62
+ data
63
+ );
64
+ }
65
+ return data;
66
+ }
67
+ async get(path, options = {}) {
68
+ return this.request("GET", path, options);
64
69
  }
65
70
  async post(path, data, options = {}) {
66
- return this.client.post(path, data, {
67
- headers: options.headers,
68
- params: options.params
69
- });
71
+ return this.request("POST", path, { ...options, body: data });
70
72
  }
71
73
  async put(path, data, options = {}) {
72
- return this.client.put(path, data, {
73
- headers: options.headers,
74
- params: options.params
75
- });
74
+ return this.request("PUT", path, { ...options, body: data });
76
75
  }
77
76
  async patch(path, data, options = {}) {
78
- return this.client.patch(path, data, {
79
- headers: options.headers,
80
- params: options.params
81
- });
77
+ return this.request("PATCH", path, { ...options, body: data });
82
78
  }
83
79
  async delete(path, options = {}) {
84
- return this.client.delete(path, {
85
- headers: options.headers,
86
- params: options.params
87
- });
80
+ return this.request("DELETE", path, options);
88
81
  }
89
82
  };
90
83
  var MAX_PAGE_SIZE = 250;
package/dist/index.mjs CHANGED
@@ -1,7 +1,8 @@
1
- import axios from 'axios';
2
1
  import { z } from 'zod';
3
2
 
4
3
  // src/base.ts
4
+ var CLIENT_VERSION = "0.2.0";
5
+ var DEFAULT_BASE_URL = "https://api.cardog.app/v1";
5
6
  var APIError = class extends Error {
6
7
  constructor(message, status, code, data) {
7
8
  super(message);
@@ -14,69 +15,65 @@ var APIError = class extends Error {
14
15
  var BaseClient = class {
15
16
  constructor(config) {
16
17
  this.config = config;
17
- this.client = axios.create({
18
- baseURL: config.baseUrl || "https://api.cardog.io",
19
- headers: {
20
- "Content-Type": "application/json",
21
- ...config.apiKey && { Authorization: `Bearer ${config.apiKey}` }
22
- }
23
- });
24
- this.setupInterceptors();
18
+ this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
25
19
  }
26
20
  setConfig(config) {
27
21
  this.config = config;
28
- if (config.apiKey) {
29
- this.client.defaults.headers.Authorization = `Bearer ${config.apiKey}`;
30
- } else {
31
- delete this.client.defaults.headers.Authorization;
22
+ if (config.baseUrl) {
23
+ this.baseUrl = config.baseUrl;
32
24
  }
33
25
  }
34
- setupInterceptors() {
35
- this.client.interceptors.response.use(
36
- (response) => response.data,
37
- (error) => {
38
- if (error.response) {
39
- const { status, data } = error.response;
40
- throw new APIError(
41
- error.message,
42
- status,
43
- data?.code || "unknown_error",
44
- data
45
- );
26
+ getHeaders(extra) {
27
+ return {
28
+ "Content-Type": "application/json",
29
+ "User-Agent": `@cardog/api/${CLIENT_VERSION}`,
30
+ ...this.config.apiKey && { Authorization: `Bearer ${this.config.apiKey}` },
31
+ ...extra
32
+ };
33
+ }
34
+ buildUrl(path, params) {
35
+ const url = new URL(path, this.baseUrl);
36
+ if (params) {
37
+ for (const [key, value] of Object.entries(params)) {
38
+ if (value !== void 0 && value !== null) {
39
+ url.searchParams.set(key, String(value));
46
40
  }
47
- throw error;
48
41
  }
49
- );
42
+ }
43
+ return url.toString();
50
44
  }
51
- async get(path, options = {}) {
52
- return this.client.get(path, {
53
- headers: options.headers,
54
- params: options.params
45
+ async request(method, path, options = {}) {
46
+ const url = this.buildUrl(path, options.params);
47
+ const response = await fetch(url, {
48
+ method,
49
+ headers: this.getHeaders(options.headers),
50
+ body: options.body ? JSON.stringify(options.body) : void 0
55
51
  });
52
+ const data = await response.json().catch(() => null);
53
+ if (!response.ok) {
54
+ throw new APIError(
55
+ data?.message || response.statusText,
56
+ response.status,
57
+ data?.code || "unknown_error",
58
+ data
59
+ );
60
+ }
61
+ return data;
62
+ }
63
+ async get(path, options = {}) {
64
+ return this.request("GET", path, options);
56
65
  }
57
66
  async post(path, data, options = {}) {
58
- return this.client.post(path, data, {
59
- headers: options.headers,
60
- params: options.params
61
- });
67
+ return this.request("POST", path, { ...options, body: data });
62
68
  }
63
69
  async put(path, data, options = {}) {
64
- return this.client.put(path, data, {
65
- headers: options.headers,
66
- params: options.params
67
- });
70
+ return this.request("PUT", path, { ...options, body: data });
68
71
  }
69
72
  async patch(path, data, options = {}) {
70
- return this.client.patch(path, data, {
71
- headers: options.headers,
72
- params: options.params
73
- });
73
+ return this.request("PATCH", path, { ...options, body: data });
74
74
  }
75
75
  async delete(path, options = {}) {
76
- return this.client.delete(path, {
77
- headers: options.headers,
78
- params: options.params
79
- });
76
+ return this.request("DELETE", path, options);
80
77
  }
81
78
  };
82
79
  var MAX_PAGE_SIZE = 250;
@@ -2,7 +2,6 @@ import { UseQueryOptions, useQuery, UseInfiniteQueryOptions, QueryKey, useInfini
2
2
  import { VinDecodeResponse, VinImageResponse, MarketAnalysis, MarketOverview, MarketPricing, BreakdownResponse, MarketOdometer, MarketGeography, MarketTrends, MarketPosition, MarketPulse, LocalMarketResponse, FuelTypeString, FuelStationResponse, ChargingParams, ChargingStationResponse, LineupResponse, Variant, ResearchImage, ColorData, RecallSearchParams, RecallResponse } from '@cardog/contracts';
3
3
  import CardogClient, { ListingsSearchParams, ListingsResponse, ListingsCountResponse, Listing, ListingsFacetsResponse, LocationsSearchParams, LocationsSearchResponse, LocationDetailResponse, ComplaintsSearchParams, ComplaintsResponse } from '../index.mjs';
4
4
  export { queryKeys } from '../index.mjs';
5
- import 'axios';
6
5
  import 'zod';
7
6
 
8
7
  /**
@@ -2,7 +2,6 @@ import { UseQueryOptions, useQuery, UseInfiniteQueryOptions, QueryKey, useInfini
2
2
  import { VinDecodeResponse, VinImageResponse, MarketAnalysis, MarketOverview, MarketPricing, BreakdownResponse, MarketOdometer, MarketGeography, MarketTrends, MarketPosition, MarketPulse, LocalMarketResponse, FuelTypeString, FuelStationResponse, ChargingParams, ChargingStationResponse, LineupResponse, Variant, ResearchImage, ColorData, RecallSearchParams, RecallResponse } from '@cardog/contracts';
3
3
  import CardogClient, { ListingsSearchParams, ListingsResponse, ListingsCountResponse, Listing, ListingsFacetsResponse, LocationsSearchParams, LocationsSearchResponse, LocationDetailResponse, ComplaintsSearchParams, ComplaintsResponse } from '../index.js';
4
4
  export { queryKeys } from '../index.js';
5
- import 'axios';
6
5
  import 'zod';
7
6
 
8
7
  /**
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var reactQuery = require('@tanstack/react-query');
4
- require('axios');
5
4
  var zod = require('zod');
6
5
 
7
6
  // src/react/hooks.ts
@@ -1,5 +1,4 @@
1
1
  import { useQuery, useInfiniteQuery } from '@tanstack/react-query';
2
- import 'axios';
3
2
  import { z } from 'zod';
4
3
 
5
4
  // src/react/hooks.ts
package/package.json CHANGED
@@ -1,16 +1,9 @@
1
1
  {
2
2
  "name": "@cardog/api",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "description": "Official Cardog API client library for vehicle data, market analysis, and VIN decoding",
5
5
  "license": "MIT",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/cardog-ai/cardog-api"
9
- },
10
6
  "homepage": "https://docs.cardog.app",
11
- "bugs": {
12
- "url": "https://github.com/cardog-ai/cardog-api/issues"
13
- },
14
7
  "keywords": [
15
8
  "cardog",
16
9
  "api",
@@ -47,10 +40,19 @@
47
40
  "module": "./dist/index.mjs",
48
41
  "types": "./dist/index.d.ts",
49
42
  "files": [
50
- "dist"
43
+ "dist",
44
+ "CHANGELOG.md"
51
45
  ],
46
+ "scripts": {
47
+ "build": "tsup",
48
+ "dev": "tsup --watch",
49
+ "clean": "rm -rf dist",
50
+ "test": "vitest run",
51
+ "test:watch": "vitest",
52
+ "typecheck": "tsc --noEmit",
53
+ "prepublishOnly": "pnpm build"
54
+ },
52
55
  "dependencies": {
53
- "axios": "^1.6.7",
54
56
  "zod": "^3.24.3"
55
57
  },
56
58
  "peerDependencies": {
@@ -70,24 +72,16 @@
70
72
  }
71
73
  },
72
74
  "devDependencies": {
75
+ "@cardog/contracts": "workspace:*",
73
76
  "@tanstack/react-query": "^5.0.0",
74
77
  "@types/node": "^20.11.24",
75
78
  "@types/react": "^18.2.0",
76
79
  "react": "^18.2.0",
77
80
  "tsup": "^8.0.2",
78
81
  "typescript": "^5.3.3",
79
- "vitest": "^1.3.1",
80
- "@cardog/contracts": "0.1.0"
82
+ "vitest": "^1.3.1"
81
83
  },
82
84
  "publishConfig": {
83
85
  "access": "public"
84
- },
85
- "scripts": {
86
- "build": "tsup",
87
- "dev": "tsup --watch",
88
- "clean": "rm -rf dist",
89
- "test": "vitest run",
90
- "test:watch": "vitest",
91
- "typecheck": "tsc --noEmit"
92
86
  }
93
- }
87
+ }