apogeoapi 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 +52 -0
- package/EXAMPLES.md +666 -0
- package/README.md +532 -0
- package/dist/clients/account.client.d.ts +76 -0
- package/dist/clients/account.client.d.ts.map +1 -0
- package/dist/clients/account.client.js +85 -0
- package/dist/clients/account.client.js.map +1 -0
- package/dist/clients/api-keys.client.d.ts +90 -0
- package/dist/clients/api-keys.client.d.ts.map +1 -0
- package/dist/clients/api-keys.client.js +105 -0
- package/dist/clients/api-keys.client.js.map +1 -0
- package/dist/clients/auth.client.d.ts +63 -0
- package/dist/clients/auth.client.d.ts.map +1 -0
- package/dist/clients/auth.client.js +86 -0
- package/dist/clients/auth.client.js.map +1 -0
- package/dist/clients/billing.client.d.ts +79 -0
- package/dist/clients/billing.client.d.ts.map +1 -0
- package/dist/clients/billing.client.js +101 -0
- package/dist/clients/billing.client.js.map +1 -0
- package/dist/clients/geo.client.d.ts +105 -0
- package/dist/clients/geo.client.d.ts.map +1 -0
- package/dist/clients/geo.client.js +149 -0
- package/dist/clients/geo.client.js.map +1 -0
- package/dist/clients/webhooks.client.d.ts +110 -0
- package/dist/clients/webhooks.client.d.ts.map +1 -0
- package/dist/clients/webhooks.client.js +129 -0
- package/dist/clients/webhooks.client.js.map +1 -0
- package/dist/index.d.ts +137 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +157 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +243 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +16 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/http-client.d.ts +43 -0
- package/dist/utils/http-client.d.ts.map +1 -0
- package/dist/utils/http-client.js +140 -0
- package/dist/utils/http-client.js.map +1 -0
- package/package.json +44 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @geo-api/sdk - Official TypeScript SDK for Geo API
|
|
4
|
+
*
|
|
5
|
+
* Professional geographic data API with comprehensive country, state, and city information.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { GeoAPI } from '@geo-api/sdk';
|
|
10
|
+
*
|
|
11
|
+
* // Initialize with API key
|
|
12
|
+
* const client = new GeoAPI({
|
|
13
|
+
* apiKey: 'geoapi_live_xxxxx',
|
|
14
|
+
* baseURL: 'https://api.yourcompany.com/v1'
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // Use the API
|
|
18
|
+
* const countries = await client.geo.getCountries();
|
|
19
|
+
* const usage = await client.account.getDashboard();
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @packageDocumentation
|
|
23
|
+
*/
|
|
24
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
27
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
28
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
29
|
+
}
|
|
30
|
+
Object.defineProperty(o, k2, desc);
|
|
31
|
+
}) : (function(o, m, k, k2) {
|
|
32
|
+
if (k2 === undefined) k2 = k;
|
|
33
|
+
o[k2] = m[k];
|
|
34
|
+
}));
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.WebhooksClient = exports.BillingClient = exports.ApiKeysClient = exports.AccountClient = exports.GeoClient = exports.AuthClient = exports.GeoAPI = void 0;
|
|
40
|
+
const http_client_1 = require("./utils/http-client");
|
|
41
|
+
const auth_client_1 = require("./clients/auth.client");
|
|
42
|
+
const geo_client_1 = require("./clients/geo.client");
|
|
43
|
+
const account_client_1 = require("./clients/account.client");
|
|
44
|
+
const api_keys_client_1 = require("./clients/api-keys.client");
|
|
45
|
+
const billing_client_1 = require("./clients/billing.client");
|
|
46
|
+
const webhooks_client_1 = require("./clients/webhooks.client");
|
|
47
|
+
/**
|
|
48
|
+
* Main SDK class
|
|
49
|
+
*
|
|
50
|
+
* Provides access to all API modules:
|
|
51
|
+
* - `auth` - Authentication (login, register, refresh token)
|
|
52
|
+
* - `geo` - Geography data (countries, states, cities)
|
|
53
|
+
* - `account` - User account management
|
|
54
|
+
* - `apiKeys` - API keys CRUD
|
|
55
|
+
* - `billing` - Subscription and billing
|
|
56
|
+
* - `webhooks` - Webhook management
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* const client = new GeoAPI({
|
|
61
|
+
* apiKey: 'geoapi_live_xxxxx'
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* // Get countries
|
|
65
|
+
* const countries = await client.geo.getCountries();
|
|
66
|
+
*
|
|
67
|
+
* // Login
|
|
68
|
+
* const { access_token } = await client.auth.login({
|
|
69
|
+
* email: 'user@example.com',
|
|
70
|
+
* password: 'password123'
|
|
71
|
+
* });
|
|
72
|
+
*
|
|
73
|
+
* // Get dashboard
|
|
74
|
+
* const dashboard = await client.account.getDashboard();
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
class GeoAPI {
|
|
78
|
+
/**
|
|
79
|
+
* Create a new Geo API client
|
|
80
|
+
*
|
|
81
|
+
* @param config - SDK configuration
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* // With API key (recommended for client-side)
|
|
86
|
+
* const client = new GeoAPI({
|
|
87
|
+
* apiKey: 'geoapi_live_xxxxx'
|
|
88
|
+
* });
|
|
89
|
+
*
|
|
90
|
+
* // With JWT token (for server-side after login)
|
|
91
|
+
* const client = new GeoAPI({
|
|
92
|
+
* token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
|
|
93
|
+
* });
|
|
94
|
+
*
|
|
95
|
+
* // With custom configuration
|
|
96
|
+
* const client = new GeoAPI({
|
|
97
|
+
* apiKey: 'geoapi_live_xxxxx',
|
|
98
|
+
* baseURL: 'https://api.yourcompany.com/v1',
|
|
99
|
+
* timeout: 30000,
|
|
100
|
+
* retries: 3,
|
|
101
|
+
* debug: true
|
|
102
|
+
* });
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
constructor(config) {
|
|
106
|
+
// Validate config
|
|
107
|
+
if (!config.apiKey && !config.token) {
|
|
108
|
+
throw new Error('GeoAPI SDK requires either apiKey or token for authentication');
|
|
109
|
+
}
|
|
110
|
+
// Initialize HTTP client
|
|
111
|
+
this.httpClient = new http_client_1.HttpClient(config);
|
|
112
|
+
// Initialize all clients
|
|
113
|
+
this.auth = new auth_client_1.AuthClient(this.httpClient);
|
|
114
|
+
this.geo = new geo_client_1.GeoClient(this.httpClient);
|
|
115
|
+
this.account = new account_client_1.AccountClient(this.httpClient);
|
|
116
|
+
this.apiKeys = new api_keys_client_1.ApiKeysClient(this.httpClient);
|
|
117
|
+
this.billing = new billing_client_1.BillingClient(this.httpClient);
|
|
118
|
+
this.webhooks = new webhooks_client_1.WebhooksClient(this.httpClient);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Update authentication token
|
|
122
|
+
*
|
|
123
|
+
* Useful after login or token refresh
|
|
124
|
+
*
|
|
125
|
+
* @param token - New JWT token
|
|
126
|
+
*/
|
|
127
|
+
setToken(token) {
|
|
128
|
+
this.httpClient.setToken(token);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Update API key
|
|
132
|
+
*
|
|
133
|
+
* @param apiKey - New API key
|
|
134
|
+
*/
|
|
135
|
+
setApiKey(apiKey) {
|
|
136
|
+
this.httpClient.setApiKey(apiKey);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.GeoAPI = GeoAPI;
|
|
140
|
+
// Export all types
|
|
141
|
+
__exportStar(require("./types"), exports);
|
|
142
|
+
// Export individual clients for advanced use cases
|
|
143
|
+
var auth_client_2 = require("./clients/auth.client");
|
|
144
|
+
Object.defineProperty(exports, "AuthClient", { enumerable: true, get: function () { return auth_client_2.AuthClient; } });
|
|
145
|
+
var geo_client_2 = require("./clients/geo.client");
|
|
146
|
+
Object.defineProperty(exports, "GeoClient", { enumerable: true, get: function () { return geo_client_2.GeoClient; } });
|
|
147
|
+
var account_client_2 = require("./clients/account.client");
|
|
148
|
+
Object.defineProperty(exports, "AccountClient", { enumerable: true, get: function () { return account_client_2.AccountClient; } });
|
|
149
|
+
var api_keys_client_2 = require("./clients/api-keys.client");
|
|
150
|
+
Object.defineProperty(exports, "ApiKeysClient", { enumerable: true, get: function () { return api_keys_client_2.ApiKeysClient; } });
|
|
151
|
+
var billing_client_2 = require("./clients/billing.client");
|
|
152
|
+
Object.defineProperty(exports, "BillingClient", { enumerable: true, get: function () { return billing_client_2.BillingClient; } });
|
|
153
|
+
var webhooks_client_2 = require("./clients/webhooks.client");
|
|
154
|
+
Object.defineProperty(exports, "WebhooksClient", { enumerable: true, get: function () { return webhooks_client_2.WebhooksClient; } });
|
|
155
|
+
// Default export
|
|
156
|
+
exports.default = GeoAPI;
|
|
157
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;;;;;;;;;;;;;;;AAEH,qDAAiD;AACjD,uDAAmD;AACnD,qDAAiD;AACjD,6DAAyD;AACzD,+DAA0D;AAC1D,6DAAyD;AACzD,+DAA2D;AAG3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAa,MAAM;IAiC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jD,gHAAA,aAAa,OAAA;AACtB,2DAAyD;AAAhD,+GAAA,aAAa,OAAA;AACtB,6DAA2D;AAAlD,iHAAA,cAAc,OAAA;AAEvB,iBAAiB;AACjB,kBAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for Geo API SDK
|
|
3
|
+
*/
|
|
4
|
+
export type Tier = 'free' | 'starter' | 'professional' | 'enterprise';
|
|
5
|
+
export type UserRole = 'user' | 'admin';
|
|
6
|
+
export type WebhookEvent = 'usage.quota_warning' | 'usage.quota_exceeded' | 'subscription.created' | 'subscription.updated' | 'subscription.canceled';
|
|
7
|
+
export interface User {
|
|
8
|
+
id: string;
|
|
9
|
+
email: string;
|
|
10
|
+
username: string;
|
|
11
|
+
role: UserRole;
|
|
12
|
+
tier: Tier;
|
|
13
|
+
monthlyQuota: number;
|
|
14
|
+
requestsThisMonth: number;
|
|
15
|
+
lastQuotaReset: Date;
|
|
16
|
+
isActive: boolean;
|
|
17
|
+
createdAt: Date;
|
|
18
|
+
updatedAt: Date;
|
|
19
|
+
}
|
|
20
|
+
export interface RegisterDto {
|
|
21
|
+
email: string;
|
|
22
|
+
password: string;
|
|
23
|
+
username: string;
|
|
24
|
+
}
|
|
25
|
+
export interface LoginDto {
|
|
26
|
+
email: string;
|
|
27
|
+
password: string;
|
|
28
|
+
}
|
|
29
|
+
export interface AuthResponse {
|
|
30
|
+
user: {
|
|
31
|
+
id: string;
|
|
32
|
+
email: string;
|
|
33
|
+
username: string;
|
|
34
|
+
role: UserRole;
|
|
35
|
+
tier: Tier;
|
|
36
|
+
};
|
|
37
|
+
access_token: string;
|
|
38
|
+
refresh_token: string;
|
|
39
|
+
}
|
|
40
|
+
export interface RefreshTokenDto {
|
|
41
|
+
refresh_token: string;
|
|
42
|
+
}
|
|
43
|
+
export interface ApiKey {
|
|
44
|
+
id: string;
|
|
45
|
+
key: string;
|
|
46
|
+
name: string;
|
|
47
|
+
isActive: boolean;
|
|
48
|
+
lastUsedAt: Date | null;
|
|
49
|
+
expiresAt: Date | null;
|
|
50
|
+
createdAt: Date;
|
|
51
|
+
}
|
|
52
|
+
export interface CreateApiKeyDto {
|
|
53
|
+
name: string;
|
|
54
|
+
expiresAt?: Date;
|
|
55
|
+
}
|
|
56
|
+
export interface UpdateApiKeyDto {
|
|
57
|
+
name?: string;
|
|
58
|
+
isActive?: boolean;
|
|
59
|
+
}
|
|
60
|
+
export interface Country {
|
|
61
|
+
id: number;
|
|
62
|
+
name: string;
|
|
63
|
+
iso2: string;
|
|
64
|
+
iso3: string;
|
|
65
|
+
capital: string;
|
|
66
|
+
region: string;
|
|
67
|
+
subregion: string;
|
|
68
|
+
currency: string;
|
|
69
|
+
phoneCode: string;
|
|
70
|
+
latitude: number;
|
|
71
|
+
longitude: number;
|
|
72
|
+
emoji: string;
|
|
73
|
+
}
|
|
74
|
+
export interface State {
|
|
75
|
+
id: number;
|
|
76
|
+
name: string;
|
|
77
|
+
stateCode: string;
|
|
78
|
+
latitude: number;
|
|
79
|
+
longitude: number;
|
|
80
|
+
countryId: number;
|
|
81
|
+
country?: Country;
|
|
82
|
+
}
|
|
83
|
+
export interface City {
|
|
84
|
+
id: number;
|
|
85
|
+
name: string;
|
|
86
|
+
latitude: number;
|
|
87
|
+
longitude: number;
|
|
88
|
+
stateId: number;
|
|
89
|
+
countryId: number;
|
|
90
|
+
state?: State;
|
|
91
|
+
country?: Country;
|
|
92
|
+
}
|
|
93
|
+
export interface GeoSearchParams {
|
|
94
|
+
query: string;
|
|
95
|
+
limit?: number;
|
|
96
|
+
offset?: number;
|
|
97
|
+
type?: 'country' | 'state' | 'city';
|
|
98
|
+
}
|
|
99
|
+
export interface AccountDashboard {
|
|
100
|
+
user: {
|
|
101
|
+
id: string;
|
|
102
|
+
email: string;
|
|
103
|
+
username: string;
|
|
104
|
+
tier: Tier;
|
|
105
|
+
createdAt: Date;
|
|
106
|
+
};
|
|
107
|
+
subscription: {
|
|
108
|
+
tier: Tier;
|
|
109
|
+
status: string;
|
|
110
|
+
currentPeriodEnd: Date | null;
|
|
111
|
+
cancelAtPeriodEnd: boolean;
|
|
112
|
+
};
|
|
113
|
+
usage: {
|
|
114
|
+
requestsThisMonth: number;
|
|
115
|
+
monthlyQuota: number;
|
|
116
|
+
remaining: number;
|
|
117
|
+
usagePercentage: number;
|
|
118
|
+
lastQuotaReset: Date;
|
|
119
|
+
};
|
|
120
|
+
limits: {
|
|
121
|
+
quota: number;
|
|
122
|
+
rateLimit: number;
|
|
123
|
+
maxApiKeys: number;
|
|
124
|
+
overageAllowed: boolean;
|
|
125
|
+
price: number;
|
|
126
|
+
};
|
|
127
|
+
apiKeys: {
|
|
128
|
+
active: number;
|
|
129
|
+
max: number;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
export interface UpdateProfileDto {
|
|
133
|
+
username?: string;
|
|
134
|
+
email?: string;
|
|
135
|
+
}
|
|
136
|
+
export interface ChangePasswordDto {
|
|
137
|
+
currentPassword: string;
|
|
138
|
+
newPassword: string;
|
|
139
|
+
}
|
|
140
|
+
export interface BillingPortalResponse {
|
|
141
|
+
url: string;
|
|
142
|
+
}
|
|
143
|
+
export interface CheckoutSessionResponse {
|
|
144
|
+
sessionId: string;
|
|
145
|
+
url: string;
|
|
146
|
+
}
|
|
147
|
+
export interface Invoice {
|
|
148
|
+
id: string;
|
|
149
|
+
amount: number;
|
|
150
|
+
currency: string;
|
|
151
|
+
status: string;
|
|
152
|
+
created: Date;
|
|
153
|
+
invoice_pdf: string;
|
|
154
|
+
}
|
|
155
|
+
export interface Webhook {
|
|
156
|
+
id: string;
|
|
157
|
+
url: string;
|
|
158
|
+
events: WebhookEvent[];
|
|
159
|
+
secret: string;
|
|
160
|
+
isActive: boolean;
|
|
161
|
+
createdAt: Date;
|
|
162
|
+
}
|
|
163
|
+
export interface CreateWebhookDto {
|
|
164
|
+
url: string;
|
|
165
|
+
events: WebhookEvent[];
|
|
166
|
+
}
|
|
167
|
+
export interface UpdateWebhookDto {
|
|
168
|
+
url?: string;
|
|
169
|
+
events?: WebhookEvent[];
|
|
170
|
+
isActive?: boolean;
|
|
171
|
+
}
|
|
172
|
+
export interface WebhookLog {
|
|
173
|
+
id: string;
|
|
174
|
+
webhookId: string;
|
|
175
|
+
event: WebhookEvent;
|
|
176
|
+
payload: any;
|
|
177
|
+
statusCode: number;
|
|
178
|
+
success: boolean;
|
|
179
|
+
createdAt: Date;
|
|
180
|
+
}
|
|
181
|
+
export interface UsageStats {
|
|
182
|
+
date: Date;
|
|
183
|
+
requests: number;
|
|
184
|
+
}
|
|
185
|
+
export interface UsageQuery {
|
|
186
|
+
startDate?: Date;
|
|
187
|
+
endDate?: Date;
|
|
188
|
+
groupBy?: 'day' | 'month';
|
|
189
|
+
}
|
|
190
|
+
export interface SDKConfig {
|
|
191
|
+
/**
|
|
192
|
+
* API Key for authentication (preferred)
|
|
193
|
+
*/
|
|
194
|
+
apiKey?: string;
|
|
195
|
+
/**
|
|
196
|
+
* JWT token for authentication (alternative)
|
|
197
|
+
*/
|
|
198
|
+
token?: string;
|
|
199
|
+
/**
|
|
200
|
+
* Base URL of the API
|
|
201
|
+
* @default "https://api.yourcompany.com/v1"
|
|
202
|
+
*/
|
|
203
|
+
baseURL?: string;
|
|
204
|
+
/**
|
|
205
|
+
* Request timeout in milliseconds
|
|
206
|
+
* @default 30000
|
|
207
|
+
*/
|
|
208
|
+
timeout?: number;
|
|
209
|
+
/**
|
|
210
|
+
* Number of retry attempts on failure
|
|
211
|
+
* @default 3
|
|
212
|
+
*/
|
|
213
|
+
retries?: number;
|
|
214
|
+
/**
|
|
215
|
+
* Enable debug logging
|
|
216
|
+
* @default false
|
|
217
|
+
*/
|
|
218
|
+
debug?: boolean;
|
|
219
|
+
}
|
|
220
|
+
export interface APIError {
|
|
221
|
+
statusCode: number;
|
|
222
|
+
message: string;
|
|
223
|
+
error?: string;
|
|
224
|
+
timestamp: string;
|
|
225
|
+
path: string;
|
|
226
|
+
}
|
|
227
|
+
export declare class GeoAPIError extends Error {
|
|
228
|
+
statusCode: number;
|
|
229
|
+
response?: APIError | undefined;
|
|
230
|
+
constructor(message: string, statusCode: number, response?: APIError | undefined);
|
|
231
|
+
}
|
|
232
|
+
export interface PaginatedResponse<T> {
|
|
233
|
+
data: T[];
|
|
234
|
+
total: number;
|
|
235
|
+
limit: number;
|
|
236
|
+
offset: number;
|
|
237
|
+
}
|
|
238
|
+
export interface SuccessResponse<T = any> {
|
|
239
|
+
success: boolean;
|
|
240
|
+
data: T;
|
|
241
|
+
message?: string;
|
|
242
|
+
}
|
|
243
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,MAAM,IAAI,GAAG,MAAM,GAAG,SAAS,GAAG,cAAc,GAAG,YAAY,CAAC;AACtE,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;AACxC,MAAM,MAAM,YAAY,GACpB,qBAAqB,GACrB,sBAAsB,GACtB,sBAAsB,GACtB,sBAAsB,GACtB,uBAAuB,CAAC;AAI5B,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,IAAI,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,IAAI,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAA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,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,QAAQ,YAAA;CAK7B;AAID,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eAAe,CAAC,CAAC,GAAG,GAAG;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Type definitions for Geo API SDK
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.GeoAPIError = void 0;
|
|
7
|
+
class GeoAPIError extends Error {
|
|
8
|
+
constructor(message, statusCode, response) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.statusCode = statusCode;
|
|
11
|
+
this.response = response;
|
|
12
|
+
this.name = 'GeoAPIError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.GeoAPIError = GeoAPIError;
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA0RH,MAAa,WAAY,SAAQ,KAAK;IACpC,YACE,OAAe,EACR,UAAkB,EAClB,QAAmB;QAE1B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,eAAU,GAAV,UAAU,CAAQ;QAClB,aAAQ,GAAR,QAAQ,CAAW;QAG1B,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF;AATD,kCASC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
2
|
+
import { SDKConfig } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Base HTTP client with retry logic and error handling
|
|
5
|
+
*/
|
|
6
|
+
export declare class HttpClient {
|
|
7
|
+
private client;
|
|
8
|
+
private config;
|
|
9
|
+
constructor(config: SDKConfig);
|
|
10
|
+
/**
|
|
11
|
+
* Handle and transform API errors
|
|
12
|
+
*/
|
|
13
|
+
private handleError;
|
|
14
|
+
/**
|
|
15
|
+
* Update authentication token
|
|
16
|
+
*/
|
|
17
|
+
setToken(token: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Update API key
|
|
20
|
+
*/
|
|
21
|
+
setApiKey(apiKey: string): void;
|
|
22
|
+
/**
|
|
23
|
+
* GET request
|
|
24
|
+
*/
|
|
25
|
+
get<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
26
|
+
/**
|
|
27
|
+
* POST request
|
|
28
|
+
*/
|
|
29
|
+
post<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
30
|
+
/**
|
|
31
|
+
* PUT request
|
|
32
|
+
*/
|
|
33
|
+
put<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
34
|
+
/**
|
|
35
|
+
* DELETE request
|
|
36
|
+
*/
|
|
37
|
+
delete<T = any>(url: string, config?: AxiosRequestConfig): Promise<T>;
|
|
38
|
+
/**
|
|
39
|
+
* PATCH request
|
|
40
|
+
*/
|
|
41
|
+
patch<T = any>(url: string, data?: any, config?: AxiosRequestConfig): Promise<T>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=http-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.d.ts","sourceRoot":"","sources":["../../src/utils/http-client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAiB,kBAAkB,EAA6B,MAAM,OAAO,CAAC;AAE5F,OAAO,EAAE,SAAS,EAAyB,MAAM,UAAU,CAAC;AAE5D;;GAEG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAY;gBAEd,MAAM,EAAE,SAAS;IAgF7B;;OAEG;IACH,OAAO,CAAC,WAAW;IAqBnB;;OAEG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIpC;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAItC;;OAEG;IACU,GAAG,CAAC,CAAC,GAAG,GAAG,EACtB,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,CAAC,CAAC;IAKb;;OAEG;IACU,IAAI,CAAC,CAAC,GAAG,GAAG,EACvB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,GAAG,EACV,MAAM,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,CAAC,CAAC;IAKb;;OAEG;IACU,GAAG,CAAC,CAAC,GAAG,GAAG,EACtB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,GAAG,EACV,MAAM,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,CAAC,CAAC;IAKb;;OAEG;IACU,MAAM,CAAC,CAAC,GAAG,GAAG,EACzB,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,CAAC,CAAC;IAKb;;OAEG;IACU,KAAK,CAAC,CAAC,GAAG,GAAG,EACxB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,GAAG,EACV,MAAM,CAAC,EAAE,kBAAkB,GAC1B,OAAO,CAAC,CAAC,CAAC;CAId"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HttpClient = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const axios_retry_1 = __importDefault(require("axios-retry"));
|
|
9
|
+
const types_1 = require("../types");
|
|
10
|
+
/**
|
|
11
|
+
* Base HTTP client with retry logic and error handling
|
|
12
|
+
*/
|
|
13
|
+
class HttpClient {
|
|
14
|
+
constructor(config) {
|
|
15
|
+
this.config = {
|
|
16
|
+
baseURL: config.baseURL || 'https://api.yourcompany.com/v1',
|
|
17
|
+
timeout: config.timeout || 30000,
|
|
18
|
+
retries: config.retries || 3,
|
|
19
|
+
debug: config.debug || false,
|
|
20
|
+
...config,
|
|
21
|
+
};
|
|
22
|
+
// Create axios instance
|
|
23
|
+
this.client = axios_1.default.create({
|
|
24
|
+
baseURL: this.config.baseURL,
|
|
25
|
+
timeout: this.config.timeout,
|
|
26
|
+
headers: {
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
'User-Agent': '@geo-api/sdk/1.0.0',
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
// Setup retry logic with exponential backoff
|
|
32
|
+
(0, axios_retry_1.default)(this.client, {
|
|
33
|
+
retries: this.config.retries,
|
|
34
|
+
retryDelay: axios_retry_1.default.exponentialDelay,
|
|
35
|
+
retryCondition: (error) => {
|
|
36
|
+
// Retry on network errors or 5xx server errors
|
|
37
|
+
return (axios_retry_1.default.isNetworkOrIdempotentRequestError(error) ||
|
|
38
|
+
(error.response?.status || 0) >= 500);
|
|
39
|
+
},
|
|
40
|
+
onRetry: (retryCount, error, requestConfig) => {
|
|
41
|
+
if (this.config.debug) {
|
|
42
|
+
console.log(`[SDK] Retry attempt ${retryCount} for ${requestConfig.url}`, error.message);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
// Setup request interceptor for authentication
|
|
47
|
+
this.client.interceptors.request.use((config) => {
|
|
48
|
+
// Add API Key if provided
|
|
49
|
+
if (this.config.apiKey) {
|
|
50
|
+
config.headers['X-API-Key'] = this.config.apiKey;
|
|
51
|
+
}
|
|
52
|
+
// Add JWT token if provided
|
|
53
|
+
if (this.config.token) {
|
|
54
|
+
config.headers['Authorization'] = `Bearer ${this.config.token}`;
|
|
55
|
+
}
|
|
56
|
+
if (this.config.debug) {
|
|
57
|
+
console.log(`[SDK] ${config.method?.toUpperCase()} ${config.url}`);
|
|
58
|
+
}
|
|
59
|
+
return config;
|
|
60
|
+
}, (error) => {
|
|
61
|
+
return Promise.reject(error);
|
|
62
|
+
});
|
|
63
|
+
// Setup response interceptor for error handling
|
|
64
|
+
this.client.interceptors.response.use((response) => {
|
|
65
|
+
if (this.config.debug) {
|
|
66
|
+
console.log(`[SDK] Response ${response.status} from ${response.config.url}`);
|
|
67
|
+
}
|
|
68
|
+
return response;
|
|
69
|
+
}, (error) => {
|
|
70
|
+
return Promise.reject(this.handleError(error));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Handle and transform API errors
|
|
75
|
+
*/
|
|
76
|
+
handleError(error) {
|
|
77
|
+
if (error.response) {
|
|
78
|
+
// Server responded with error status
|
|
79
|
+
const { status, data } = error.response;
|
|
80
|
+
return new types_1.GeoAPIError(data?.message || error.message, status, data);
|
|
81
|
+
}
|
|
82
|
+
else if (error.request) {
|
|
83
|
+
// Request was made but no response received
|
|
84
|
+
return new types_1.GeoAPIError('No response from server. Please check your network connection.', 0);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
// Something else happened
|
|
88
|
+
return new types_1.GeoAPIError(error.message, 0);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Update authentication token
|
|
93
|
+
*/
|
|
94
|
+
setToken(token) {
|
|
95
|
+
this.config.token = token;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Update API key
|
|
99
|
+
*/
|
|
100
|
+
setApiKey(apiKey) {
|
|
101
|
+
this.config.apiKey = apiKey;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* GET request
|
|
105
|
+
*/
|
|
106
|
+
async get(url, config) {
|
|
107
|
+
const response = await this.client.get(url, config);
|
|
108
|
+
return response.data;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* POST request
|
|
112
|
+
*/
|
|
113
|
+
async post(url, data, config) {
|
|
114
|
+
const response = await this.client.post(url, data, config);
|
|
115
|
+
return response.data;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* PUT request
|
|
119
|
+
*/
|
|
120
|
+
async put(url, data, config) {
|
|
121
|
+
const response = await this.client.put(url, data, config);
|
|
122
|
+
return response.data;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* DELETE request
|
|
126
|
+
*/
|
|
127
|
+
async delete(url, config) {
|
|
128
|
+
const response = await this.client.delete(url, config);
|
|
129
|
+
return response.data;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* PATCH request
|
|
133
|
+
*/
|
|
134
|
+
async patch(url, data, config) {
|
|
135
|
+
const response = await this.client.patch(url, data, config);
|
|
136
|
+
return response.data;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.HttpClient = HttpClient;
|
|
140
|
+
//# sourceMappingURL=http-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../src/utils/http-client.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA4F;AAC5F,8DAAqC;AACrC,oCAA4D;AAE5D;;GAEG;AACH,MAAa,UAAU;IAIrB,YAAY,MAAiB;QAC3B,IAAI,CAAC,MAAM,GAAG;YACZ,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,gCAAgC;YAC3D,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK;YAChC,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,CAAC;YAC5B,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,KAAK;YAC5B,GAAG,MAAM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AAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACzE,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,KAAK,CAChB,GAAW,EACX,IAAU,EACV,MAA2B;QAE3B,MAAM,QAAQ,GAAqB,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;QAC9E,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF;AAnLD,gCAmLC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "apogeoapi",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Official TypeScript/JavaScript SDK for ApogeoAPI — IP geolocation, countries, cities, and exchange rates",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"test": "jest",
|
|
10
|
+
"prepublishOnly": "npm run build"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"geolocation",
|
|
14
|
+
"ip",
|
|
15
|
+
"countries",
|
|
16
|
+
"states",
|
|
17
|
+
"cities",
|
|
18
|
+
"exchange-rates",
|
|
19
|
+
"api",
|
|
20
|
+
"sdk",
|
|
21
|
+
"typescript"
|
|
22
|
+
],
|
|
23
|
+
"author": "ApogeoAPI <support@apogeoapi.com>",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"axios": "^1.6.2",
|
|
27
|
+
"axios-retry": "^4.0.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^20.10.5",
|
|
31
|
+
"typescript": "^5.3.3"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=16.0.0"
|
|
35
|
+
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/APOGEOAPI/apogeoapi-js"
|
|
39
|
+
},
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/APOGEOAPI/apogeoapi-js/issues"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://apogeoapi.com"
|
|
44
|
+
}
|