@vasperacapital/vaspera-shared 0.1.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/.turbo/turbo-build.log +34 -0
- package/.turbo/turbo-typecheck.log +4 -0
- package/dist/errors/index.d.mts +288 -0
- package/dist/errors/index.d.ts +288 -0
- package/dist/errors/index.js +341 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/index.mjs +310 -0
- package/dist/errors/index.mjs.map +1 -0
- package/dist/index.d.mts +57 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +458 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +421 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types/index.d.mts +122 -0
- package/dist/types/index.d.ts +122 -0
- package/dist/types/index.js +45 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/index.mjs +19 -0
- package/dist/types/index.mjs.map +1 -0
- package/package.json +48 -0
- package/src/__tests__/api-key.test.ts +129 -0
- package/src/__tests__/encryption.test.ts +129 -0
- package/src/__tests__/errors.test.ts +185 -0
- package/src/errors/codes.ts +213 -0
- package/src/errors/factory.ts +164 -0
- package/src/errors/index.ts +10 -0
- package/src/index.ts +8 -0
- package/src/types/index.ts +164 -0
- package/src/utils/api-key.ts +72 -0
- package/src/utils/encryption.ts +79 -0
- package/src/utils/index.ts +15 -0
- package/tsconfig.json +9 -0
- package/tsup.config.ts +10 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
|
|
2
|
+
> @vaspera/shared@0.1.0 build /Users/ryancolkitt/Documents/GitHub/VasperaPM/packages/shared
|
|
3
|
+
> tsup
|
|
4
|
+
|
|
5
|
+
CLI Building entry: src/index.ts, src/errors/index.ts, src/types/index.ts
|
|
6
|
+
CLI Using tsconfig: tsconfig.json
|
|
7
|
+
CLI tsup v8.5.1
|
|
8
|
+
CLI Using tsup config: /Users/ryancolkitt/Documents/GitHub/VasperaPM/packages/shared/tsup.config.ts
|
|
9
|
+
CLI Target: es2022
|
|
10
|
+
CLI Cleaning output folder
|
|
11
|
+
CJS Build start
|
|
12
|
+
ESM Build start
|
|
13
|
+
ESM dist/types/index.mjs 403.00 B
|
|
14
|
+
ESM dist/index.mjs 11.17 KB
|
|
15
|
+
ESM dist/errors/index.mjs 8.10 KB
|
|
16
|
+
ESM dist/errors/index.mjs.map 14.80 KB
|
|
17
|
+
ESM dist/index.mjs.map 24.98 KB
|
|
18
|
+
ESM dist/types/index.mjs.map 4.13 KB
|
|
19
|
+
ESM ⚡️ Build success in 13ms
|
|
20
|
+
CJS dist/types/index.js 1.42 KB
|
|
21
|
+
CJS dist/index.js 12.81 KB
|
|
22
|
+
CJS dist/errors/index.js 9.26 KB
|
|
23
|
+
CJS dist/types/index.js.map 4.18 KB
|
|
24
|
+
CJS dist/errors/index.js.map 15.17 KB
|
|
25
|
+
CJS dist/index.js.map 25.20 KB
|
|
26
|
+
CJS ⚡️ Build success in 14ms
|
|
27
|
+
DTS Build start
|
|
28
|
+
DTS ⚡️ Build success in 888ms
|
|
29
|
+
DTS dist/types/index.d.ts 3.60 KB
|
|
30
|
+
DTS dist/index.d.ts 2.17 KB
|
|
31
|
+
DTS dist/errors/index.d.ts 9.85 KB
|
|
32
|
+
DTS dist/types/index.d.mts 3.60 KB
|
|
33
|
+
DTS dist/index.d.mts 2.17 KB
|
|
34
|
+
DTS dist/errors/index.d.mts 9.85 KB
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
interface ErrorDefinition {
|
|
2
|
+
code: string;
|
|
3
|
+
message: string;
|
|
4
|
+
httpStatus: number;
|
|
5
|
+
}
|
|
6
|
+
declare const ErrorCodes: {
|
|
7
|
+
readonly AUTH: {
|
|
8
|
+
readonly REQUIRED: {
|
|
9
|
+
readonly code: "VPM-AUTH-001";
|
|
10
|
+
readonly message: "Authentication required";
|
|
11
|
+
readonly httpStatus: 401;
|
|
12
|
+
};
|
|
13
|
+
readonly INVALID_TOKEN: {
|
|
14
|
+
readonly code: "VPM-AUTH-002";
|
|
15
|
+
readonly message: "Invalid or expired authentication token";
|
|
16
|
+
readonly httpStatus: 401;
|
|
17
|
+
};
|
|
18
|
+
readonly INSUFFICIENT_PERMISSIONS: {
|
|
19
|
+
readonly code: "VPM-AUTH-003";
|
|
20
|
+
readonly message: "Insufficient permissions for this action";
|
|
21
|
+
readonly httpStatus: 403;
|
|
22
|
+
};
|
|
23
|
+
readonly SESSION_EXPIRED: {
|
|
24
|
+
readonly code: "VPM-AUTH-004";
|
|
25
|
+
readonly message: "Session has expired, please login again";
|
|
26
|
+
readonly httpStatus: 401;
|
|
27
|
+
};
|
|
28
|
+
readonly MFA_REQUIRED: {
|
|
29
|
+
readonly code: "VPM-AUTH-005";
|
|
30
|
+
readonly message: "Multi-factor authentication required";
|
|
31
|
+
readonly httpStatus: 403;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
readonly API_KEY: {
|
|
35
|
+
readonly REQUIRED: {
|
|
36
|
+
readonly code: "VPM-API-KEY-001";
|
|
37
|
+
readonly message: "API key is required";
|
|
38
|
+
readonly httpStatus: 401;
|
|
39
|
+
};
|
|
40
|
+
readonly INVALID: {
|
|
41
|
+
readonly code: "VPM-API-KEY-002";
|
|
42
|
+
readonly message: "Invalid API key";
|
|
43
|
+
readonly httpStatus: 401;
|
|
44
|
+
};
|
|
45
|
+
readonly REVOKED: {
|
|
46
|
+
readonly code: "VPM-API-KEY-003";
|
|
47
|
+
readonly message: "API key has been revoked";
|
|
48
|
+
readonly httpStatus: 401;
|
|
49
|
+
};
|
|
50
|
+
readonly EXPIRED: {
|
|
51
|
+
readonly code: "VPM-API-KEY-004";
|
|
52
|
+
readonly message: "API key has expired";
|
|
53
|
+
readonly httpStatus: 401;
|
|
54
|
+
};
|
|
55
|
+
readonly RATE_LIMITED: {
|
|
56
|
+
readonly code: "VPM-API-KEY-005";
|
|
57
|
+
readonly message: "API key rate limit exceeded";
|
|
58
|
+
readonly httpStatus: 429;
|
|
59
|
+
};
|
|
60
|
+
readonly QUOTA_EXCEEDED: {
|
|
61
|
+
readonly code: "VPM-API-KEY-006";
|
|
62
|
+
readonly message: "Monthly usage quota exceeded";
|
|
63
|
+
readonly httpStatus: 429;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
readonly MCP: {
|
|
67
|
+
readonly TOOL_NOT_FOUND: {
|
|
68
|
+
readonly code: "VPM-MCP-001";
|
|
69
|
+
readonly message: "Requested tool not found";
|
|
70
|
+
readonly httpStatus: 404;
|
|
71
|
+
};
|
|
72
|
+
readonly INVALID_ARGUMENTS: {
|
|
73
|
+
readonly code: "VPM-MCP-002";
|
|
74
|
+
readonly message: "Invalid tool arguments provided";
|
|
75
|
+
readonly httpStatus: 400;
|
|
76
|
+
};
|
|
77
|
+
readonly EXECUTION_FAILED: {
|
|
78
|
+
readonly code: "VPM-MCP-003";
|
|
79
|
+
readonly message: "Tool execution failed";
|
|
80
|
+
readonly httpStatus: 500;
|
|
81
|
+
};
|
|
82
|
+
readonly TIMEOUT: {
|
|
83
|
+
readonly code: "VPM-MCP-004";
|
|
84
|
+
readonly message: "Tool execution timed out";
|
|
85
|
+
readonly httpStatus: 504;
|
|
86
|
+
};
|
|
87
|
+
readonly LLM_ERROR: {
|
|
88
|
+
readonly code: "VPM-MCP-005";
|
|
89
|
+
readonly message: "AI model returned an error";
|
|
90
|
+
readonly httpStatus: 502;
|
|
91
|
+
};
|
|
92
|
+
readonly CONTEXT_TOO_LARGE: {
|
|
93
|
+
readonly code: "VPM-MCP-006";
|
|
94
|
+
readonly message: "Input context exceeds maximum size";
|
|
95
|
+
readonly httpStatus: 413;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
readonly BILLING: {
|
|
99
|
+
readonly NO_SUBSCRIPTION: {
|
|
100
|
+
readonly code: "VPM-BILLING-001";
|
|
101
|
+
readonly message: "No active subscription found";
|
|
102
|
+
readonly httpStatus: 402;
|
|
103
|
+
};
|
|
104
|
+
readonly SUBSCRIPTION_EXPIRED: {
|
|
105
|
+
readonly code: "VPM-BILLING-002";
|
|
106
|
+
readonly message: "Subscription has expired";
|
|
107
|
+
readonly httpStatus: 402;
|
|
108
|
+
};
|
|
109
|
+
readonly PAYMENT_FAILED: {
|
|
110
|
+
readonly code: "VPM-BILLING-003";
|
|
111
|
+
readonly message: "Payment processing failed";
|
|
112
|
+
readonly httpStatus: 402;
|
|
113
|
+
};
|
|
114
|
+
readonly FEATURE_NOT_INCLUDED: {
|
|
115
|
+
readonly code: "VPM-BILLING-004";
|
|
116
|
+
readonly message: "Feature not included in current plan";
|
|
117
|
+
readonly httpStatus: 403;
|
|
118
|
+
};
|
|
119
|
+
readonly UPGRADE_REQUIRED: {
|
|
120
|
+
readonly code: "VPM-BILLING-005";
|
|
121
|
+
readonly message: "Plan upgrade required for this action";
|
|
122
|
+
readonly httpStatus: 403;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
readonly INTEGRATION: {
|
|
126
|
+
readonly NOT_CONNECTED: {
|
|
127
|
+
readonly code: "VPM-INT-001";
|
|
128
|
+
readonly message: "Integration not connected";
|
|
129
|
+
readonly httpStatus: 400;
|
|
130
|
+
};
|
|
131
|
+
readonly TOKEN_EXPIRED: {
|
|
132
|
+
readonly code: "VPM-INT-002";
|
|
133
|
+
readonly message: "Integration token expired, reconnection required";
|
|
134
|
+
readonly httpStatus: 401;
|
|
135
|
+
};
|
|
136
|
+
readonly REFRESH_FAILED: {
|
|
137
|
+
readonly code: "VPM-INT-003";
|
|
138
|
+
readonly message: "Failed to refresh integration token";
|
|
139
|
+
readonly httpStatus: 502;
|
|
140
|
+
};
|
|
141
|
+
readonly API_ERROR: {
|
|
142
|
+
readonly code: "VPM-INT-004";
|
|
143
|
+
readonly message: "External integration API error";
|
|
144
|
+
readonly httpStatus: 502;
|
|
145
|
+
};
|
|
146
|
+
readonly RATE_LIMITED: {
|
|
147
|
+
readonly code: "VPM-INT-005";
|
|
148
|
+
readonly message: "Integration rate limit exceeded";
|
|
149
|
+
readonly httpStatus: 429;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
readonly VALIDATION: {
|
|
153
|
+
readonly REQUIRED_FIELD: {
|
|
154
|
+
readonly code: "VPM-VAL-001";
|
|
155
|
+
readonly message: "Required field missing";
|
|
156
|
+
readonly httpStatus: 400;
|
|
157
|
+
};
|
|
158
|
+
readonly INVALID_FORMAT: {
|
|
159
|
+
readonly code: "VPM-VAL-002";
|
|
160
|
+
readonly message: "Invalid field format";
|
|
161
|
+
readonly httpStatus: 400;
|
|
162
|
+
};
|
|
163
|
+
readonly OUT_OF_RANGE: {
|
|
164
|
+
readonly code: "VPM-VAL-003";
|
|
165
|
+
readonly message: "Value out of allowed range";
|
|
166
|
+
readonly httpStatus: 400;
|
|
167
|
+
};
|
|
168
|
+
readonly INVALID_JSON: {
|
|
169
|
+
readonly code: "VPM-VAL-004";
|
|
170
|
+
readonly message: "Invalid JSON in request body";
|
|
171
|
+
readonly httpStatus: 400;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
readonly SYSTEM: {
|
|
175
|
+
readonly INTERNAL_ERROR: {
|
|
176
|
+
readonly code: "VPM-SYS-001";
|
|
177
|
+
readonly message: "Internal server error";
|
|
178
|
+
readonly httpStatus: 500;
|
|
179
|
+
};
|
|
180
|
+
readonly DATABASE_ERROR: {
|
|
181
|
+
readonly code: "VPM-SYS-002";
|
|
182
|
+
readonly message: "Database operation failed";
|
|
183
|
+
readonly httpStatus: 500;
|
|
184
|
+
};
|
|
185
|
+
readonly SERVICE_UNAVAILABLE: {
|
|
186
|
+
readonly code: "VPM-SYS-003";
|
|
187
|
+
readonly message: "Service temporarily unavailable";
|
|
188
|
+
readonly httpStatus: 503;
|
|
189
|
+
};
|
|
190
|
+
readonly MAINTENANCE_MODE: {
|
|
191
|
+
readonly code: "VPM-SYS-004";
|
|
192
|
+
readonly message: "System is under maintenance";
|
|
193
|
+
readonly httpStatus: 503;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
type ErrorCodeType = (typeof ErrorCodes)[keyof typeof ErrorCodes][keyof (typeof ErrorCodes)[keyof typeof ErrorCodes]];
|
|
198
|
+
|
|
199
|
+
interface VasperaError {
|
|
200
|
+
code: string;
|
|
201
|
+
message: string;
|
|
202
|
+
details?: Record<string, unknown>;
|
|
203
|
+
timestamp: string;
|
|
204
|
+
requestId: string;
|
|
205
|
+
docUrl?: string;
|
|
206
|
+
}
|
|
207
|
+
interface ErrorResponse {
|
|
208
|
+
success: false;
|
|
209
|
+
error: VasperaError;
|
|
210
|
+
}
|
|
211
|
+
declare function createError(errorDef: ErrorDefinition, details?: Record<string, unknown>, requestId?: string): VasperaError;
|
|
212
|
+
declare function createErrorResponse(errorDef: ErrorDefinition, details?: Record<string, unknown>, requestId?: string): {
|
|
213
|
+
response: ErrorResponse;
|
|
214
|
+
status: number;
|
|
215
|
+
};
|
|
216
|
+
declare const Errors: {
|
|
217
|
+
authRequired: (requestId?: string) => {
|
|
218
|
+
response: ErrorResponse;
|
|
219
|
+
status: number;
|
|
220
|
+
};
|
|
221
|
+
invalidApiKey: (requestId?: string) => {
|
|
222
|
+
response: ErrorResponse;
|
|
223
|
+
status: number;
|
|
224
|
+
};
|
|
225
|
+
apiKeyRevoked: (requestId?: string) => {
|
|
226
|
+
response: ErrorResponse;
|
|
227
|
+
status: number;
|
|
228
|
+
};
|
|
229
|
+
apiKeyExpired: (requestId?: string) => {
|
|
230
|
+
response: ErrorResponse;
|
|
231
|
+
status: number;
|
|
232
|
+
};
|
|
233
|
+
rateLimited: (retryAfter: number, requestId?: string) => {
|
|
234
|
+
response: ErrorResponse;
|
|
235
|
+
status: number;
|
|
236
|
+
};
|
|
237
|
+
quotaExceeded: (currentUsage: number, limit: number, requestId?: string) => {
|
|
238
|
+
response: ErrorResponse;
|
|
239
|
+
status: number;
|
|
240
|
+
};
|
|
241
|
+
toolNotFound: (toolName: string, requestId?: string) => {
|
|
242
|
+
response: ErrorResponse;
|
|
243
|
+
status: number;
|
|
244
|
+
};
|
|
245
|
+
toolExecutionFailed: (toolName: string, reason: string, requestId?: string) => {
|
|
246
|
+
response: ErrorResponse;
|
|
247
|
+
status: number;
|
|
248
|
+
};
|
|
249
|
+
toolTimeout: (toolName: string, timeoutMs: number, requestId?: string) => {
|
|
250
|
+
response: ErrorResponse;
|
|
251
|
+
status: number;
|
|
252
|
+
};
|
|
253
|
+
validationFailed: (field: string, reason: string, requestId?: string) => {
|
|
254
|
+
response: ErrorResponse;
|
|
255
|
+
status: number;
|
|
256
|
+
};
|
|
257
|
+
invalidFormat: (field: string, expected: string, requestId?: string) => {
|
|
258
|
+
response: ErrorResponse;
|
|
259
|
+
status: number;
|
|
260
|
+
};
|
|
261
|
+
internalError: (message?: string, requestId?: string) => {
|
|
262
|
+
response: ErrorResponse;
|
|
263
|
+
status: number;
|
|
264
|
+
};
|
|
265
|
+
databaseError: (operation: string, requestId?: string) => {
|
|
266
|
+
response: ErrorResponse;
|
|
267
|
+
status: number;
|
|
268
|
+
};
|
|
269
|
+
integrationNotConnected: (provider: string, requestId?: string) => {
|
|
270
|
+
response: ErrorResponse;
|
|
271
|
+
status: number;
|
|
272
|
+
};
|
|
273
|
+
subscriptionRequired: (feature: string, requiredTier: string, requestId?: string) => {
|
|
274
|
+
response: ErrorResponse;
|
|
275
|
+
status: number;
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
declare class VasperaApiError extends Error {
|
|
279
|
+
readonly errorDef: ErrorDefinition;
|
|
280
|
+
readonly details?: Record<string, unknown>;
|
|
281
|
+
constructor(errorDef: ErrorDefinition, details?: Record<string, unknown>);
|
|
282
|
+
toResponse(requestId?: string): {
|
|
283
|
+
response: ErrorResponse;
|
|
284
|
+
status: number;
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export { type ErrorCodeType, ErrorCodes, type ErrorDefinition, type ErrorResponse, Errors, VasperaApiError, type VasperaError, createError, createErrorResponse };
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
interface ErrorDefinition {
|
|
2
|
+
code: string;
|
|
3
|
+
message: string;
|
|
4
|
+
httpStatus: number;
|
|
5
|
+
}
|
|
6
|
+
declare const ErrorCodes: {
|
|
7
|
+
readonly AUTH: {
|
|
8
|
+
readonly REQUIRED: {
|
|
9
|
+
readonly code: "VPM-AUTH-001";
|
|
10
|
+
readonly message: "Authentication required";
|
|
11
|
+
readonly httpStatus: 401;
|
|
12
|
+
};
|
|
13
|
+
readonly INVALID_TOKEN: {
|
|
14
|
+
readonly code: "VPM-AUTH-002";
|
|
15
|
+
readonly message: "Invalid or expired authentication token";
|
|
16
|
+
readonly httpStatus: 401;
|
|
17
|
+
};
|
|
18
|
+
readonly INSUFFICIENT_PERMISSIONS: {
|
|
19
|
+
readonly code: "VPM-AUTH-003";
|
|
20
|
+
readonly message: "Insufficient permissions for this action";
|
|
21
|
+
readonly httpStatus: 403;
|
|
22
|
+
};
|
|
23
|
+
readonly SESSION_EXPIRED: {
|
|
24
|
+
readonly code: "VPM-AUTH-004";
|
|
25
|
+
readonly message: "Session has expired, please login again";
|
|
26
|
+
readonly httpStatus: 401;
|
|
27
|
+
};
|
|
28
|
+
readonly MFA_REQUIRED: {
|
|
29
|
+
readonly code: "VPM-AUTH-005";
|
|
30
|
+
readonly message: "Multi-factor authentication required";
|
|
31
|
+
readonly httpStatus: 403;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
readonly API_KEY: {
|
|
35
|
+
readonly REQUIRED: {
|
|
36
|
+
readonly code: "VPM-API-KEY-001";
|
|
37
|
+
readonly message: "API key is required";
|
|
38
|
+
readonly httpStatus: 401;
|
|
39
|
+
};
|
|
40
|
+
readonly INVALID: {
|
|
41
|
+
readonly code: "VPM-API-KEY-002";
|
|
42
|
+
readonly message: "Invalid API key";
|
|
43
|
+
readonly httpStatus: 401;
|
|
44
|
+
};
|
|
45
|
+
readonly REVOKED: {
|
|
46
|
+
readonly code: "VPM-API-KEY-003";
|
|
47
|
+
readonly message: "API key has been revoked";
|
|
48
|
+
readonly httpStatus: 401;
|
|
49
|
+
};
|
|
50
|
+
readonly EXPIRED: {
|
|
51
|
+
readonly code: "VPM-API-KEY-004";
|
|
52
|
+
readonly message: "API key has expired";
|
|
53
|
+
readonly httpStatus: 401;
|
|
54
|
+
};
|
|
55
|
+
readonly RATE_LIMITED: {
|
|
56
|
+
readonly code: "VPM-API-KEY-005";
|
|
57
|
+
readonly message: "API key rate limit exceeded";
|
|
58
|
+
readonly httpStatus: 429;
|
|
59
|
+
};
|
|
60
|
+
readonly QUOTA_EXCEEDED: {
|
|
61
|
+
readonly code: "VPM-API-KEY-006";
|
|
62
|
+
readonly message: "Monthly usage quota exceeded";
|
|
63
|
+
readonly httpStatus: 429;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
readonly MCP: {
|
|
67
|
+
readonly TOOL_NOT_FOUND: {
|
|
68
|
+
readonly code: "VPM-MCP-001";
|
|
69
|
+
readonly message: "Requested tool not found";
|
|
70
|
+
readonly httpStatus: 404;
|
|
71
|
+
};
|
|
72
|
+
readonly INVALID_ARGUMENTS: {
|
|
73
|
+
readonly code: "VPM-MCP-002";
|
|
74
|
+
readonly message: "Invalid tool arguments provided";
|
|
75
|
+
readonly httpStatus: 400;
|
|
76
|
+
};
|
|
77
|
+
readonly EXECUTION_FAILED: {
|
|
78
|
+
readonly code: "VPM-MCP-003";
|
|
79
|
+
readonly message: "Tool execution failed";
|
|
80
|
+
readonly httpStatus: 500;
|
|
81
|
+
};
|
|
82
|
+
readonly TIMEOUT: {
|
|
83
|
+
readonly code: "VPM-MCP-004";
|
|
84
|
+
readonly message: "Tool execution timed out";
|
|
85
|
+
readonly httpStatus: 504;
|
|
86
|
+
};
|
|
87
|
+
readonly LLM_ERROR: {
|
|
88
|
+
readonly code: "VPM-MCP-005";
|
|
89
|
+
readonly message: "AI model returned an error";
|
|
90
|
+
readonly httpStatus: 502;
|
|
91
|
+
};
|
|
92
|
+
readonly CONTEXT_TOO_LARGE: {
|
|
93
|
+
readonly code: "VPM-MCP-006";
|
|
94
|
+
readonly message: "Input context exceeds maximum size";
|
|
95
|
+
readonly httpStatus: 413;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
readonly BILLING: {
|
|
99
|
+
readonly NO_SUBSCRIPTION: {
|
|
100
|
+
readonly code: "VPM-BILLING-001";
|
|
101
|
+
readonly message: "No active subscription found";
|
|
102
|
+
readonly httpStatus: 402;
|
|
103
|
+
};
|
|
104
|
+
readonly SUBSCRIPTION_EXPIRED: {
|
|
105
|
+
readonly code: "VPM-BILLING-002";
|
|
106
|
+
readonly message: "Subscription has expired";
|
|
107
|
+
readonly httpStatus: 402;
|
|
108
|
+
};
|
|
109
|
+
readonly PAYMENT_FAILED: {
|
|
110
|
+
readonly code: "VPM-BILLING-003";
|
|
111
|
+
readonly message: "Payment processing failed";
|
|
112
|
+
readonly httpStatus: 402;
|
|
113
|
+
};
|
|
114
|
+
readonly FEATURE_NOT_INCLUDED: {
|
|
115
|
+
readonly code: "VPM-BILLING-004";
|
|
116
|
+
readonly message: "Feature not included in current plan";
|
|
117
|
+
readonly httpStatus: 403;
|
|
118
|
+
};
|
|
119
|
+
readonly UPGRADE_REQUIRED: {
|
|
120
|
+
readonly code: "VPM-BILLING-005";
|
|
121
|
+
readonly message: "Plan upgrade required for this action";
|
|
122
|
+
readonly httpStatus: 403;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
readonly INTEGRATION: {
|
|
126
|
+
readonly NOT_CONNECTED: {
|
|
127
|
+
readonly code: "VPM-INT-001";
|
|
128
|
+
readonly message: "Integration not connected";
|
|
129
|
+
readonly httpStatus: 400;
|
|
130
|
+
};
|
|
131
|
+
readonly TOKEN_EXPIRED: {
|
|
132
|
+
readonly code: "VPM-INT-002";
|
|
133
|
+
readonly message: "Integration token expired, reconnection required";
|
|
134
|
+
readonly httpStatus: 401;
|
|
135
|
+
};
|
|
136
|
+
readonly REFRESH_FAILED: {
|
|
137
|
+
readonly code: "VPM-INT-003";
|
|
138
|
+
readonly message: "Failed to refresh integration token";
|
|
139
|
+
readonly httpStatus: 502;
|
|
140
|
+
};
|
|
141
|
+
readonly API_ERROR: {
|
|
142
|
+
readonly code: "VPM-INT-004";
|
|
143
|
+
readonly message: "External integration API error";
|
|
144
|
+
readonly httpStatus: 502;
|
|
145
|
+
};
|
|
146
|
+
readonly RATE_LIMITED: {
|
|
147
|
+
readonly code: "VPM-INT-005";
|
|
148
|
+
readonly message: "Integration rate limit exceeded";
|
|
149
|
+
readonly httpStatus: 429;
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
readonly VALIDATION: {
|
|
153
|
+
readonly REQUIRED_FIELD: {
|
|
154
|
+
readonly code: "VPM-VAL-001";
|
|
155
|
+
readonly message: "Required field missing";
|
|
156
|
+
readonly httpStatus: 400;
|
|
157
|
+
};
|
|
158
|
+
readonly INVALID_FORMAT: {
|
|
159
|
+
readonly code: "VPM-VAL-002";
|
|
160
|
+
readonly message: "Invalid field format";
|
|
161
|
+
readonly httpStatus: 400;
|
|
162
|
+
};
|
|
163
|
+
readonly OUT_OF_RANGE: {
|
|
164
|
+
readonly code: "VPM-VAL-003";
|
|
165
|
+
readonly message: "Value out of allowed range";
|
|
166
|
+
readonly httpStatus: 400;
|
|
167
|
+
};
|
|
168
|
+
readonly INVALID_JSON: {
|
|
169
|
+
readonly code: "VPM-VAL-004";
|
|
170
|
+
readonly message: "Invalid JSON in request body";
|
|
171
|
+
readonly httpStatus: 400;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
readonly SYSTEM: {
|
|
175
|
+
readonly INTERNAL_ERROR: {
|
|
176
|
+
readonly code: "VPM-SYS-001";
|
|
177
|
+
readonly message: "Internal server error";
|
|
178
|
+
readonly httpStatus: 500;
|
|
179
|
+
};
|
|
180
|
+
readonly DATABASE_ERROR: {
|
|
181
|
+
readonly code: "VPM-SYS-002";
|
|
182
|
+
readonly message: "Database operation failed";
|
|
183
|
+
readonly httpStatus: 500;
|
|
184
|
+
};
|
|
185
|
+
readonly SERVICE_UNAVAILABLE: {
|
|
186
|
+
readonly code: "VPM-SYS-003";
|
|
187
|
+
readonly message: "Service temporarily unavailable";
|
|
188
|
+
readonly httpStatus: 503;
|
|
189
|
+
};
|
|
190
|
+
readonly MAINTENANCE_MODE: {
|
|
191
|
+
readonly code: "VPM-SYS-004";
|
|
192
|
+
readonly message: "System is under maintenance";
|
|
193
|
+
readonly httpStatus: 503;
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
type ErrorCodeType = (typeof ErrorCodes)[keyof typeof ErrorCodes][keyof (typeof ErrorCodes)[keyof typeof ErrorCodes]];
|
|
198
|
+
|
|
199
|
+
interface VasperaError {
|
|
200
|
+
code: string;
|
|
201
|
+
message: string;
|
|
202
|
+
details?: Record<string, unknown>;
|
|
203
|
+
timestamp: string;
|
|
204
|
+
requestId: string;
|
|
205
|
+
docUrl?: string;
|
|
206
|
+
}
|
|
207
|
+
interface ErrorResponse {
|
|
208
|
+
success: false;
|
|
209
|
+
error: VasperaError;
|
|
210
|
+
}
|
|
211
|
+
declare function createError(errorDef: ErrorDefinition, details?: Record<string, unknown>, requestId?: string): VasperaError;
|
|
212
|
+
declare function createErrorResponse(errorDef: ErrorDefinition, details?: Record<string, unknown>, requestId?: string): {
|
|
213
|
+
response: ErrorResponse;
|
|
214
|
+
status: number;
|
|
215
|
+
};
|
|
216
|
+
declare const Errors: {
|
|
217
|
+
authRequired: (requestId?: string) => {
|
|
218
|
+
response: ErrorResponse;
|
|
219
|
+
status: number;
|
|
220
|
+
};
|
|
221
|
+
invalidApiKey: (requestId?: string) => {
|
|
222
|
+
response: ErrorResponse;
|
|
223
|
+
status: number;
|
|
224
|
+
};
|
|
225
|
+
apiKeyRevoked: (requestId?: string) => {
|
|
226
|
+
response: ErrorResponse;
|
|
227
|
+
status: number;
|
|
228
|
+
};
|
|
229
|
+
apiKeyExpired: (requestId?: string) => {
|
|
230
|
+
response: ErrorResponse;
|
|
231
|
+
status: number;
|
|
232
|
+
};
|
|
233
|
+
rateLimited: (retryAfter: number, requestId?: string) => {
|
|
234
|
+
response: ErrorResponse;
|
|
235
|
+
status: number;
|
|
236
|
+
};
|
|
237
|
+
quotaExceeded: (currentUsage: number, limit: number, requestId?: string) => {
|
|
238
|
+
response: ErrorResponse;
|
|
239
|
+
status: number;
|
|
240
|
+
};
|
|
241
|
+
toolNotFound: (toolName: string, requestId?: string) => {
|
|
242
|
+
response: ErrorResponse;
|
|
243
|
+
status: number;
|
|
244
|
+
};
|
|
245
|
+
toolExecutionFailed: (toolName: string, reason: string, requestId?: string) => {
|
|
246
|
+
response: ErrorResponse;
|
|
247
|
+
status: number;
|
|
248
|
+
};
|
|
249
|
+
toolTimeout: (toolName: string, timeoutMs: number, requestId?: string) => {
|
|
250
|
+
response: ErrorResponse;
|
|
251
|
+
status: number;
|
|
252
|
+
};
|
|
253
|
+
validationFailed: (field: string, reason: string, requestId?: string) => {
|
|
254
|
+
response: ErrorResponse;
|
|
255
|
+
status: number;
|
|
256
|
+
};
|
|
257
|
+
invalidFormat: (field: string, expected: string, requestId?: string) => {
|
|
258
|
+
response: ErrorResponse;
|
|
259
|
+
status: number;
|
|
260
|
+
};
|
|
261
|
+
internalError: (message?: string, requestId?: string) => {
|
|
262
|
+
response: ErrorResponse;
|
|
263
|
+
status: number;
|
|
264
|
+
};
|
|
265
|
+
databaseError: (operation: string, requestId?: string) => {
|
|
266
|
+
response: ErrorResponse;
|
|
267
|
+
status: number;
|
|
268
|
+
};
|
|
269
|
+
integrationNotConnected: (provider: string, requestId?: string) => {
|
|
270
|
+
response: ErrorResponse;
|
|
271
|
+
status: number;
|
|
272
|
+
};
|
|
273
|
+
subscriptionRequired: (feature: string, requiredTier: string, requestId?: string) => {
|
|
274
|
+
response: ErrorResponse;
|
|
275
|
+
status: number;
|
|
276
|
+
};
|
|
277
|
+
};
|
|
278
|
+
declare class VasperaApiError extends Error {
|
|
279
|
+
readonly errorDef: ErrorDefinition;
|
|
280
|
+
readonly details?: Record<string, unknown>;
|
|
281
|
+
constructor(errorDef: ErrorDefinition, details?: Record<string, unknown>);
|
|
282
|
+
toResponse(requestId?: string): {
|
|
283
|
+
response: ErrorResponse;
|
|
284
|
+
status: number;
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export { type ErrorCodeType, ErrorCodes, type ErrorDefinition, type ErrorResponse, Errors, VasperaApiError, type VasperaError, createError, createErrorResponse };
|