@vedika-io/sdk 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 +196 -0
- package/LICENSE +21 -0
- package/README.md +445 -0
- package/SECURITY.md +301 -0
- package/dist/client.d.ts +89 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +222 -0
- package/dist/client.js.map +1 -0
- package/dist/exceptions.d.ts +225 -0
- package/dist/exceptions.d.ts.map +1 -0
- package/dist/exceptions.js +268 -0
- package/dist/exceptions.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +294 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vedika API Exceptions
|
|
3
|
+
* Custom exception classes for the Vedika Astrology API.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Base exception for all Vedika API errors
|
|
7
|
+
*
|
|
8
|
+
* This is the parent class for all Vedika SDK exceptions.
|
|
9
|
+
* Catch this to handle any SDK-related error.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* try {
|
|
14
|
+
* const response = await client.askQuestion(...);
|
|
15
|
+
* } catch (error) {
|
|
16
|
+
* if (error instanceof VedikaAPIError) {
|
|
17
|
+
* console.error('API error:', error.message);
|
|
18
|
+
* }
|
|
19
|
+
* }
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare class VedikaAPIError extends Error {
|
|
23
|
+
statusCode?: number;
|
|
24
|
+
constructor(message: string, statusCode?: number);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Authentication failed - invalid API key
|
|
28
|
+
*
|
|
29
|
+
* Raised when:
|
|
30
|
+
* - API key is missing
|
|
31
|
+
* - API key is invalid
|
|
32
|
+
* - API key is expired
|
|
33
|
+
*
|
|
34
|
+
* Solution:
|
|
35
|
+
* - Get a valid API key from https://vedika.io/dashboard.html
|
|
36
|
+
* - Check that your key starts with vk_test_ or vk_live_
|
|
37
|
+
* - Ensure you haven't accidentally exposed your key
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* try {
|
|
42
|
+
* const client = new VedikaClient({ apiKey: 'invalid_key' });
|
|
43
|
+
* } catch (error) {
|
|
44
|
+
* if (error instanceof AuthenticationError) {
|
|
45
|
+
* console.error('Please provide a valid API key');
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare class AuthenticationError extends VedikaAPIError {
|
|
51
|
+
constructor(message?: string);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Rate limit exceeded
|
|
55
|
+
*
|
|
56
|
+
* Raised when:
|
|
57
|
+
* - Too many requests in a short time period
|
|
58
|
+
* - Account rate limit reached
|
|
59
|
+
*
|
|
60
|
+
* Solution:
|
|
61
|
+
* - Wait a moment before retrying
|
|
62
|
+
* - Implement exponential backoff
|
|
63
|
+
* - Upgrade your plan for higher limits
|
|
64
|
+
*
|
|
65
|
+
* Rate limits:
|
|
66
|
+
* - Free tier: 10 requests/minute
|
|
67
|
+
* - Starter: 60 requests/minute
|
|
68
|
+
* - Professional: 300 requests/minute
|
|
69
|
+
* - Enterprise: Custom limits
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* try {
|
|
74
|
+
* const response = await client.askQuestion(...);
|
|
75
|
+
* } catch (error) {
|
|
76
|
+
* if (error instanceof RateLimitError) {
|
|
77
|
+
* await new Promise(resolve => setTimeout(resolve, 60000)); // Wait 1 minute
|
|
78
|
+
* // Retry request
|
|
79
|
+
* }
|
|
80
|
+
* }
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare class RateLimitError extends VedikaAPIError {
|
|
84
|
+
constructor(message?: string);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Insufficient credits in account
|
|
88
|
+
*
|
|
89
|
+
* Raised when:
|
|
90
|
+
* - Account has run out of credits
|
|
91
|
+
* - Query would exceed available credits
|
|
92
|
+
*
|
|
93
|
+
* Solution:
|
|
94
|
+
* - Add more credits at https://vedika.io/dashboard.html
|
|
95
|
+
* - Check your credit balance before making requests
|
|
96
|
+
* - Enable auto-recharge to prevent interruptions
|
|
97
|
+
*
|
|
98
|
+
* Credit costs:
|
|
99
|
+
* - Simple queries: ~500 tokens ($0.19)
|
|
100
|
+
* - Standard queries: ~800 tokens ($0.35)
|
|
101
|
+
* - Complex queries: ~1,500 tokens ($0.65)
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* try {
|
|
106
|
+
* const response = await client.askQuestion(...);
|
|
107
|
+
* } catch (error) {
|
|
108
|
+
* if (error instanceof InsufficientCreditsError) {
|
|
109
|
+
* console.error('Please add credits at https://vedika.io/dashboard.html');
|
|
110
|
+
* }
|
|
111
|
+
* }
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export declare class InsufficientCreditsError extends VedikaAPIError {
|
|
115
|
+
constructor(message?: string);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Request validation failed - invalid input
|
|
119
|
+
*
|
|
120
|
+
* Raised when:
|
|
121
|
+
* - Birth details are invalid or missing
|
|
122
|
+
* - Date/time format is incorrect
|
|
123
|
+
* - Latitude/longitude out of range
|
|
124
|
+
* - Required fields are missing
|
|
125
|
+
*
|
|
126
|
+
* Solution:
|
|
127
|
+
* - Check that datetime is in ISO 8601 format
|
|
128
|
+
* - Verify latitude is between -90 and 90
|
|
129
|
+
* - Verify longitude is between -180 and 180
|
|
130
|
+
* - Ensure timezone is a valid IANA timezone
|
|
131
|
+
*
|
|
132
|
+
* Valid input examples:
|
|
133
|
+
* - datetime: "1990-06-15T14:30:00+05:30"
|
|
134
|
+
* - latitude: 28.6139 (Delhi)
|
|
135
|
+
* - longitude: 77.2090 (Delhi)
|
|
136
|
+
* - timezone: "Asia/Kolkata"
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* try {
|
|
141
|
+
* await client.askQuestion({
|
|
142
|
+
* question: 'Career prospects?',
|
|
143
|
+
* birthDetails: {
|
|
144
|
+
* datetime: 'invalid-date', // Wrong format!
|
|
145
|
+
* latitude: 28.6139,
|
|
146
|
+
* longitude: 77.2090
|
|
147
|
+
* }
|
|
148
|
+
* });
|
|
149
|
+
* } catch (error) {
|
|
150
|
+
* if (error instanceof ValidationError) {
|
|
151
|
+
* console.error('Invalid input:', error.message);
|
|
152
|
+
* }
|
|
153
|
+
* }
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
export declare class ValidationError extends VedikaAPIError {
|
|
157
|
+
constructor(message?: string);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Request timeout - server took too long to respond
|
|
161
|
+
*
|
|
162
|
+
* Raised when:
|
|
163
|
+
* - Request exceeds configured timeout
|
|
164
|
+
* - Complex query takes longer than expected
|
|
165
|
+
* - Server is experiencing high load
|
|
166
|
+
*
|
|
167
|
+
* Solution:
|
|
168
|
+
* - Increase timeout for complex queries
|
|
169
|
+
* - Retry the request
|
|
170
|
+
* - Contact support if issue persists
|
|
171
|
+
*
|
|
172
|
+
* Typical response times:
|
|
173
|
+
* - Simple queries: 2-5 seconds
|
|
174
|
+
* - Standard queries: 5-15 seconds
|
|
175
|
+
* - Complex queries: 20-40 seconds
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* // Increase timeout for complex queries
|
|
180
|
+
* const client = new VedikaClient({
|
|
181
|
+
* apiKey: 'vk_test_...',
|
|
182
|
+
* timeout: 120000 // 2 minutes
|
|
183
|
+
* });
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
export declare class TimeoutError extends VedikaAPIError {
|
|
187
|
+
constructor(message?: string);
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Internal server error
|
|
191
|
+
*
|
|
192
|
+
* Raised when:
|
|
193
|
+
* - Server encountered an unexpected error
|
|
194
|
+
* - Service is temporarily unavailable
|
|
195
|
+
* - Database or ephemeris error
|
|
196
|
+
*
|
|
197
|
+
* Solution:
|
|
198
|
+
* - Retry the request (automatic with SDK)
|
|
199
|
+
* - Wait a few moments if service is down
|
|
200
|
+
* - Contact support@vedika.io if issue persists
|
|
201
|
+
*
|
|
202
|
+
* The SDK automatically retries failed requests up to 3 times
|
|
203
|
+
* with exponential backoff.
|
|
204
|
+
*/
|
|
205
|
+
export declare class ServerError extends VedikaAPIError {
|
|
206
|
+
constructor(message?: string, statusCode?: number);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Network connectivity error
|
|
210
|
+
*
|
|
211
|
+
* Raised when:
|
|
212
|
+
* - Cannot connect to Vedika API server
|
|
213
|
+
* - Network timeout
|
|
214
|
+
* - DNS resolution failure
|
|
215
|
+
*
|
|
216
|
+
* Solution:
|
|
217
|
+
* - Check your internet connection
|
|
218
|
+
* - Verify firewall settings allow HTTPS
|
|
219
|
+
* - Check if vedika.io is accessible
|
|
220
|
+
* - Try again in a few moments
|
|
221
|
+
*/
|
|
222
|
+
export declare class NetworkError extends VedikaAPIError {
|
|
223
|
+
constructor(message?: string);
|
|
224
|
+
}
|
|
225
|
+
//# sourceMappingURL=exceptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions.d.ts","sourceRoot":"","sources":["../src/exceptions.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,cAAe,SAAQ,KAAK;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;gBAEf,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAMjD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,mBAAoB,SAAQ,cAAc;gBACzC,OAAO,GAAE,MAA0B;CAKhD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,cAAe,SAAQ,cAAc;gBACpC,OAAO,GAAE,MAA8B;CAKpD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,wBAAyB,SAAQ,cAAc;gBAC9C,OAAO,GAAE,MAA+B;CAKrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,qBAAa,eAAgB,SAAQ,cAAc;gBACrC,OAAO,GAAE,MAA2B;CAKjD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,YAAa,SAAQ,cAAc;gBAClC,OAAO,GAAE,MAA4B;CAKlD;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,WAAY,SAAQ,cAAc;gBACjC,OAAO,GAAE,MAAgC,EAAE,UAAU,GAAE,MAAY;CAKhF;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,YAAa,SAAQ,cAAc;gBAClC,OAAO,GAAE,MAAwB;CAK9C"}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Vedika API Exceptions
|
|
4
|
+
* Custom exception classes for the Vedika Astrology API.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.NetworkError = exports.ServerError = exports.TimeoutError = exports.ValidationError = exports.InsufficientCreditsError = exports.RateLimitError = exports.AuthenticationError = exports.VedikaAPIError = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* Base exception for all Vedika API errors
|
|
10
|
+
*
|
|
11
|
+
* This is the parent class for all Vedika SDK exceptions.
|
|
12
|
+
* Catch this to handle any SDK-related error.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* try {
|
|
17
|
+
* const response = await client.askQuestion(...);
|
|
18
|
+
* } catch (error) {
|
|
19
|
+
* if (error instanceof VedikaAPIError) {
|
|
20
|
+
* console.error('API error:', error.message);
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
class VedikaAPIError extends Error {
|
|
26
|
+
constructor(message, statusCode) {
|
|
27
|
+
super(message);
|
|
28
|
+
this.name = 'VedikaAPIError';
|
|
29
|
+
this.statusCode = statusCode;
|
|
30
|
+
Object.setPrototypeOf(this, VedikaAPIError.prototype);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.VedikaAPIError = VedikaAPIError;
|
|
34
|
+
/**
|
|
35
|
+
* Authentication failed - invalid API key
|
|
36
|
+
*
|
|
37
|
+
* Raised when:
|
|
38
|
+
* - API key is missing
|
|
39
|
+
* - API key is invalid
|
|
40
|
+
* - API key is expired
|
|
41
|
+
*
|
|
42
|
+
* Solution:
|
|
43
|
+
* - Get a valid API key from https://vedika.io/dashboard.html
|
|
44
|
+
* - Check that your key starts with vk_test_ or vk_live_
|
|
45
|
+
* - Ensure you haven't accidentally exposed your key
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```typescript
|
|
49
|
+
* try {
|
|
50
|
+
* const client = new VedikaClient({ apiKey: 'invalid_key' });
|
|
51
|
+
* } catch (error) {
|
|
52
|
+
* if (error instanceof AuthenticationError) {
|
|
53
|
+
* console.error('Please provide a valid API key');
|
|
54
|
+
* }
|
|
55
|
+
* }
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
class AuthenticationError extends VedikaAPIError {
|
|
59
|
+
constructor(message = 'Invalid API key') {
|
|
60
|
+
super(message, 401);
|
|
61
|
+
this.name = 'AuthenticationError';
|
|
62
|
+
Object.setPrototypeOf(this, AuthenticationError.prototype);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.AuthenticationError = AuthenticationError;
|
|
66
|
+
/**
|
|
67
|
+
* Rate limit exceeded
|
|
68
|
+
*
|
|
69
|
+
* Raised when:
|
|
70
|
+
* - Too many requests in a short time period
|
|
71
|
+
* - Account rate limit reached
|
|
72
|
+
*
|
|
73
|
+
* Solution:
|
|
74
|
+
* - Wait a moment before retrying
|
|
75
|
+
* - Implement exponential backoff
|
|
76
|
+
* - Upgrade your plan for higher limits
|
|
77
|
+
*
|
|
78
|
+
* Rate limits:
|
|
79
|
+
* - Free tier: 10 requests/minute
|
|
80
|
+
* - Starter: 60 requests/minute
|
|
81
|
+
* - Professional: 300 requests/minute
|
|
82
|
+
* - Enterprise: Custom limits
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* try {
|
|
87
|
+
* const response = await client.askQuestion(...);
|
|
88
|
+
* } catch (error) {
|
|
89
|
+
* if (error instanceof RateLimitError) {
|
|
90
|
+
* await new Promise(resolve => setTimeout(resolve, 60000)); // Wait 1 minute
|
|
91
|
+
* // Retry request
|
|
92
|
+
* }
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
class RateLimitError extends VedikaAPIError {
|
|
97
|
+
constructor(message = 'Rate limit exceeded') {
|
|
98
|
+
super(message, 429);
|
|
99
|
+
this.name = 'RateLimitError';
|
|
100
|
+
Object.setPrototypeOf(this, RateLimitError.prototype);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.RateLimitError = RateLimitError;
|
|
104
|
+
/**
|
|
105
|
+
* Insufficient credits in account
|
|
106
|
+
*
|
|
107
|
+
* Raised when:
|
|
108
|
+
* - Account has run out of credits
|
|
109
|
+
* - Query would exceed available credits
|
|
110
|
+
*
|
|
111
|
+
* Solution:
|
|
112
|
+
* - Add more credits at https://vedika.io/dashboard.html
|
|
113
|
+
* - Check your credit balance before making requests
|
|
114
|
+
* - Enable auto-recharge to prevent interruptions
|
|
115
|
+
*
|
|
116
|
+
* Credit costs:
|
|
117
|
+
* - Simple queries: ~500 tokens ($0.19)
|
|
118
|
+
* - Standard queries: ~800 tokens ($0.35)
|
|
119
|
+
* - Complex queries: ~1,500 tokens ($0.65)
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```typescript
|
|
123
|
+
* try {
|
|
124
|
+
* const response = await client.askQuestion(...);
|
|
125
|
+
* } catch (error) {
|
|
126
|
+
* if (error instanceof InsufficientCreditsError) {
|
|
127
|
+
* console.error('Please add credits at https://vedika.io/dashboard.html');
|
|
128
|
+
* }
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
class InsufficientCreditsError extends VedikaAPIError {
|
|
133
|
+
constructor(message = 'Insufficient credits') {
|
|
134
|
+
super(message, 402);
|
|
135
|
+
this.name = 'InsufficientCreditsError';
|
|
136
|
+
Object.setPrototypeOf(this, InsufficientCreditsError.prototype);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.InsufficientCreditsError = InsufficientCreditsError;
|
|
140
|
+
/**
|
|
141
|
+
* Request validation failed - invalid input
|
|
142
|
+
*
|
|
143
|
+
* Raised when:
|
|
144
|
+
* - Birth details are invalid or missing
|
|
145
|
+
* - Date/time format is incorrect
|
|
146
|
+
* - Latitude/longitude out of range
|
|
147
|
+
* - Required fields are missing
|
|
148
|
+
*
|
|
149
|
+
* Solution:
|
|
150
|
+
* - Check that datetime is in ISO 8601 format
|
|
151
|
+
* - Verify latitude is between -90 and 90
|
|
152
|
+
* - Verify longitude is between -180 and 180
|
|
153
|
+
* - Ensure timezone is a valid IANA timezone
|
|
154
|
+
*
|
|
155
|
+
* Valid input examples:
|
|
156
|
+
* - datetime: "1990-06-15T14:30:00+05:30"
|
|
157
|
+
* - latitude: 28.6139 (Delhi)
|
|
158
|
+
* - longitude: 77.2090 (Delhi)
|
|
159
|
+
* - timezone: "Asia/Kolkata"
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* try {
|
|
164
|
+
* await client.askQuestion({
|
|
165
|
+
* question: 'Career prospects?',
|
|
166
|
+
* birthDetails: {
|
|
167
|
+
* datetime: 'invalid-date', // Wrong format!
|
|
168
|
+
* latitude: 28.6139,
|
|
169
|
+
* longitude: 77.2090
|
|
170
|
+
* }
|
|
171
|
+
* });
|
|
172
|
+
* } catch (error) {
|
|
173
|
+
* if (error instanceof ValidationError) {
|
|
174
|
+
* console.error('Invalid input:', error.message);
|
|
175
|
+
* }
|
|
176
|
+
* }
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
class ValidationError extends VedikaAPIError {
|
|
180
|
+
constructor(message = 'Validation error') {
|
|
181
|
+
super(message, 422);
|
|
182
|
+
this.name = 'ValidationError';
|
|
183
|
+
Object.setPrototypeOf(this, ValidationError.prototype);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
exports.ValidationError = ValidationError;
|
|
187
|
+
/**
|
|
188
|
+
* Request timeout - server took too long to respond
|
|
189
|
+
*
|
|
190
|
+
* Raised when:
|
|
191
|
+
* - Request exceeds configured timeout
|
|
192
|
+
* - Complex query takes longer than expected
|
|
193
|
+
* - Server is experiencing high load
|
|
194
|
+
*
|
|
195
|
+
* Solution:
|
|
196
|
+
* - Increase timeout for complex queries
|
|
197
|
+
* - Retry the request
|
|
198
|
+
* - Contact support if issue persists
|
|
199
|
+
*
|
|
200
|
+
* Typical response times:
|
|
201
|
+
* - Simple queries: 2-5 seconds
|
|
202
|
+
* - Standard queries: 5-15 seconds
|
|
203
|
+
* - Complex queries: 20-40 seconds
|
|
204
|
+
*
|
|
205
|
+
* @example
|
|
206
|
+
* ```typescript
|
|
207
|
+
* // Increase timeout for complex queries
|
|
208
|
+
* const client = new VedikaClient({
|
|
209
|
+
* apiKey: 'vk_test_...',
|
|
210
|
+
* timeout: 120000 // 2 minutes
|
|
211
|
+
* });
|
|
212
|
+
* ```
|
|
213
|
+
*/
|
|
214
|
+
class TimeoutError extends VedikaAPIError {
|
|
215
|
+
constructor(message = 'Request timed out') {
|
|
216
|
+
super(message, 408);
|
|
217
|
+
this.name = 'TimeoutError';
|
|
218
|
+
Object.setPrototypeOf(this, TimeoutError.prototype);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
exports.TimeoutError = TimeoutError;
|
|
222
|
+
/**
|
|
223
|
+
* Internal server error
|
|
224
|
+
*
|
|
225
|
+
* Raised when:
|
|
226
|
+
* - Server encountered an unexpected error
|
|
227
|
+
* - Service is temporarily unavailable
|
|
228
|
+
* - Database or ephemeris error
|
|
229
|
+
*
|
|
230
|
+
* Solution:
|
|
231
|
+
* - Retry the request (automatic with SDK)
|
|
232
|
+
* - Wait a few moments if service is down
|
|
233
|
+
* - Contact support@vedika.io if issue persists
|
|
234
|
+
*
|
|
235
|
+
* The SDK automatically retries failed requests up to 3 times
|
|
236
|
+
* with exponential backoff.
|
|
237
|
+
*/
|
|
238
|
+
class ServerError extends VedikaAPIError {
|
|
239
|
+
constructor(message = 'Internal server error', statusCode = 500) {
|
|
240
|
+
super(message, statusCode);
|
|
241
|
+
this.name = 'ServerError';
|
|
242
|
+
Object.setPrototypeOf(this, ServerError.prototype);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
exports.ServerError = ServerError;
|
|
246
|
+
/**
|
|
247
|
+
* Network connectivity error
|
|
248
|
+
*
|
|
249
|
+
* Raised when:
|
|
250
|
+
* - Cannot connect to Vedika API server
|
|
251
|
+
* - Network timeout
|
|
252
|
+
* - DNS resolution failure
|
|
253
|
+
*
|
|
254
|
+
* Solution:
|
|
255
|
+
* - Check your internet connection
|
|
256
|
+
* - Verify firewall settings allow HTTPS
|
|
257
|
+
* - Check if vedika.io is accessible
|
|
258
|
+
* - Try again in a few moments
|
|
259
|
+
*/
|
|
260
|
+
class NetworkError extends VedikaAPIError {
|
|
261
|
+
constructor(message = 'Network error') {
|
|
262
|
+
super(message);
|
|
263
|
+
this.name = 'NetworkError';
|
|
264
|
+
Object.setPrototypeOf(this, NetworkError.prototype);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
exports.NetworkError = NetworkError;
|
|
268
|
+
//# sourceMappingURL=exceptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../src/exceptions.ts"],"names":[],"mappings":"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"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vedika JavaScript/Node.js SDK
|
|
3
|
+
* The only B2B astrology API with AI-powered chatbot queries.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*/
|
|
7
|
+
export { VedikaClient } from './client';
|
|
8
|
+
export type { BirthDetails, QuestionResponse, Planet, House, BirthChart, Dasha, DashaResponse, CompatibilityResponse, Yoga, YogaResponse, DoshaInfo, DoshaResponse, TimeWindow, MuhurthaResponse, NumerologyResponse, VedikaClientOptions, QuestionQuery, BirthChartQuery, CompatibilityQuery, MuhurthaQuery, NumerologyQuery, BatchQueryItem, } from './types';
|
|
9
|
+
export { VedikaAPIError, AuthenticationError, RateLimitError, InsufficientCreditsError, ValidationError, TimeoutError, ServerError, NetworkError, } from './exceptions';
|
|
10
|
+
export declare const VERSION = "1.0.0";
|
|
11
|
+
export declare const AUTHOR = "Vedika Intelligence";
|
|
12
|
+
export declare const HOMEPAGE = "https://vedika.io";
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAExC,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,MAAM,EACN,KAAK,EACL,UAAU,EACV,KAAK,EACL,aAAa,EACb,qBAAqB,EACrB,IAAI,EACJ,YAAY,EACZ,SAAS,EACT,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,EACnB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,cAAc,GACf,MAAM,SAAS,CAAC;AAEjB,OAAO,EACL,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,wBAAwB,EACxB,eAAe,EACf,YAAY,EACZ,WAAW,EACX,YAAY,GACb,MAAM,cAAc,CAAC;AAGtB,eAAO,MAAM,OAAO,UAAU,CAAC;AAC/B,eAAO,MAAM,MAAM,wBAAwB,CAAC;AAC5C,eAAO,MAAM,QAAQ,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Vedika JavaScript/Node.js SDK
|
|
4
|
+
* The only B2B astrology API with AI-powered chatbot queries.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.HOMEPAGE = exports.AUTHOR = exports.VERSION = exports.NetworkError = exports.ServerError = exports.TimeoutError = exports.ValidationError = exports.InsufficientCreditsError = exports.RateLimitError = exports.AuthenticationError = exports.VedikaAPIError = exports.VedikaClient = void 0;
|
|
10
|
+
var client_1 = require("./client");
|
|
11
|
+
Object.defineProperty(exports, "VedikaClient", { enumerable: true, get: function () { return client_1.VedikaClient; } });
|
|
12
|
+
var exceptions_1 = require("./exceptions");
|
|
13
|
+
Object.defineProperty(exports, "VedikaAPIError", { enumerable: true, get: function () { return exceptions_1.VedikaAPIError; } });
|
|
14
|
+
Object.defineProperty(exports, "AuthenticationError", { enumerable: true, get: function () { return exceptions_1.AuthenticationError; } });
|
|
15
|
+
Object.defineProperty(exports, "RateLimitError", { enumerable: true, get: function () { return exceptions_1.RateLimitError; } });
|
|
16
|
+
Object.defineProperty(exports, "InsufficientCreditsError", { enumerable: true, get: function () { return exceptions_1.InsufficientCreditsError; } });
|
|
17
|
+
Object.defineProperty(exports, "ValidationError", { enumerable: true, get: function () { return exceptions_1.ValidationError; } });
|
|
18
|
+
Object.defineProperty(exports, "TimeoutError", { enumerable: true, get: function () { return exceptions_1.TimeoutError; } });
|
|
19
|
+
Object.defineProperty(exports, "ServerError", { enumerable: true, get: function () { return exceptions_1.ServerError; } });
|
|
20
|
+
Object.defineProperty(exports, "NetworkError", { enumerable: true, get: function () { return exceptions_1.NetworkError; } });
|
|
21
|
+
// Package metadata
|
|
22
|
+
exports.VERSION = '1.0.0';
|
|
23
|
+
exports.AUTHOR = 'Vedika Intelligence';
|
|
24
|
+
exports.HOMEPAGE = 'https://vedika.io';
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AA2BrB,2CASsB;AARpB,4GAAA,cAAc,OAAA;AACd,iHAAA,mBAAmB,OAAA;AACnB,4GAAA,cAAc,OAAA;AACd,sHAAA,wBAAwB,OAAA;AACxB,6GAAA,eAAe,OAAA;AACf,0GAAA,YAAY,OAAA;AACZ,yGAAA,WAAW,OAAA;AACX,0GAAA,YAAY,OAAA;AAGd,mBAAmB;AACN,QAAA,OAAO,GAAG,OAAO,CAAC;AAClB,QAAA,MAAM,GAAG,qBAAqB,CAAC;AAC/B,QAAA,QAAQ,GAAG,mBAAmB,CAAC"}
|