@cardog/api 0.1.3 → 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/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,15 +2,10 @@
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
13
- var CLIENT_VERSION = "0.1.3";
8
+ var CLIENT_VERSION = "0.2.0";
14
9
  var DEFAULT_BASE_URL = "https://api.cardog.app/v1";
15
10
  var APIError = class extends Error {
16
11
  constructor(message, status, code, data) {
@@ -24,70 +19,65 @@ var APIError = class extends Error {
24
19
  var BaseClient = class {
25
20
  constructor(config) {
26
21
  this.config = config;
27
- this.client = axios__default.default.create({
28
- baseURL: config.baseUrl || DEFAULT_BASE_URL,
29
- headers: {
30
- "Content-Type": "application/json",
31
- "User-Agent": `@cardog/api/${CLIENT_VERSION}`,
32
- ...config.apiKey && { Authorization: `Bearer ${config.apiKey}` }
33
- }
34
- });
35
- this.setupInterceptors();
22
+ this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
36
23
  }
37
24
  setConfig(config) {
38
25
  this.config = config;
39
- if (config.apiKey) {
40
- this.client.defaults.headers.Authorization = `Bearer ${config.apiKey}`;
41
- } else {
42
- delete this.client.defaults.headers.Authorization;
26
+ if (config.baseUrl) {
27
+ this.baseUrl = config.baseUrl;
43
28
  }
44
29
  }
45
- setupInterceptors() {
46
- this.client.interceptors.response.use(
47
- (response) => response.data,
48
- (error) => {
49
- if (error.response) {
50
- const { status, data } = error.response;
51
- throw new APIError(
52
- error.message,
53
- status,
54
- data?.code || "unknown_error",
55
- data
56
- );
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));
57
44
  }
58
- throw error;
59
45
  }
60
- );
46
+ }
47
+ return url.toString();
61
48
  }
62
- async get(path, options = {}) {
63
- return this.client.get(path, {
64
- headers: options.headers,
65
- 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
66
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);
67
69
  }
68
70
  async post(path, data, options = {}) {
69
- return this.client.post(path, data, {
70
- headers: options.headers,
71
- params: options.params
72
- });
71
+ return this.request("POST", path, { ...options, body: data });
73
72
  }
74
73
  async put(path, data, options = {}) {
75
- return this.client.put(path, data, {
76
- headers: options.headers,
77
- params: options.params
78
- });
74
+ return this.request("PUT", path, { ...options, body: data });
79
75
  }
80
76
  async patch(path, data, options = {}) {
81
- return this.client.patch(path, data, {
82
- headers: options.headers,
83
- params: options.params
84
- });
77
+ return this.request("PATCH", path, { ...options, body: data });
85
78
  }
86
79
  async delete(path, options = {}) {
87
- return this.client.delete(path, {
88
- headers: options.headers,
89
- params: options.params
90
- });
80
+ return this.request("DELETE", path, options);
91
81
  }
92
82
  };
93
83
  var MAX_PAGE_SIZE = 250;
package/dist/index.mjs CHANGED
@@ -1,8 +1,7 @@
1
- import axios from 'axios';
2
1
  import { z } from 'zod';
3
2
 
4
3
  // src/base.ts
5
- var CLIENT_VERSION = "0.1.3";
4
+ var CLIENT_VERSION = "0.2.0";
6
5
  var DEFAULT_BASE_URL = "https://api.cardog.app/v1";
7
6
  var APIError = class extends Error {
8
7
  constructor(message, status, code, data) {
@@ -16,70 +15,65 @@ var APIError = class extends Error {
16
15
  var BaseClient = class {
17
16
  constructor(config) {
18
17
  this.config = config;
19
- this.client = axios.create({
20
- baseURL: config.baseUrl || DEFAULT_BASE_URL,
21
- headers: {
22
- "Content-Type": "application/json",
23
- "User-Agent": `@cardog/api/${CLIENT_VERSION}`,
24
- ...config.apiKey && { Authorization: `Bearer ${config.apiKey}` }
25
- }
26
- });
27
- this.setupInterceptors();
18
+ this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
28
19
  }
29
20
  setConfig(config) {
30
21
  this.config = config;
31
- if (config.apiKey) {
32
- this.client.defaults.headers.Authorization = `Bearer ${config.apiKey}`;
33
- } else {
34
- delete this.client.defaults.headers.Authorization;
22
+ if (config.baseUrl) {
23
+ this.baseUrl = config.baseUrl;
35
24
  }
36
25
  }
37
- setupInterceptors() {
38
- this.client.interceptors.response.use(
39
- (response) => response.data,
40
- (error) => {
41
- if (error.response) {
42
- const { status, data } = error.response;
43
- throw new APIError(
44
- error.message,
45
- status,
46
- data?.code || "unknown_error",
47
- data
48
- );
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));
49
40
  }
50
- throw error;
51
41
  }
52
- );
42
+ }
43
+ return url.toString();
53
44
  }
54
- async get(path, options = {}) {
55
- return this.client.get(path, {
56
- headers: options.headers,
57
- 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
58
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);
59
65
  }
60
66
  async post(path, data, options = {}) {
61
- return this.client.post(path, data, {
62
- headers: options.headers,
63
- params: options.params
64
- });
67
+ return this.request("POST", path, { ...options, body: data });
65
68
  }
66
69
  async put(path, data, options = {}) {
67
- return this.client.put(path, data, {
68
- headers: options.headers,
69
- params: options.params
70
- });
70
+ return this.request("PUT", path, { ...options, body: data });
71
71
  }
72
72
  async patch(path, data, options = {}) {
73
- return this.client.patch(path, data, {
74
- headers: options.headers,
75
- params: options.params
76
- });
73
+ return this.request("PATCH", path, { ...options, body: data });
77
74
  }
78
75
  async delete(path, options = {}) {
79
- return this.client.delete(path, {
80
- headers: options.headers,
81
- params: options.params
82
- });
76
+ return this.request("DELETE", path, options);
83
77
  }
84
78
  };
85
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.3",
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
+ }