@vorionsys/shared-constants 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.
Files changed (46) hide show
  1. package/dist/api-versions.cjs +183 -0
  2. package/dist/api-versions.d.cts +91 -0
  3. package/dist/api-versions.js +46 -0
  4. package/dist/capabilities.cjs +246 -0
  5. package/dist/capabilities.d.cts +55 -0
  6. package/dist/capabilities.js +21 -0
  7. package/dist/chunk-F2R6HBF5.js +253 -0
  8. package/dist/chunk-IKLCEYZT.js +142 -0
  9. package/dist/chunk-JZJPDGG7.js +215 -0
  10. package/dist/chunk-P3VPMVF3.js +223 -0
  11. package/dist/chunk-PHL3CB53.js +159 -0
  12. package/dist/chunk-RZQZEF6Q.js +176 -0
  13. package/dist/chunk-TYCMBQGU.js +353 -0
  14. package/dist/chunk-UDCZKJSQ.js +139 -0
  15. package/dist/domains.cjs +175 -0
  16. package/dist/domains.d.cts +250 -0
  17. package/dist/domains.js +24 -0
  18. package/dist/error-codes.cjs +390 -0
  19. package/dist/error-codes.d.cts +633 -0
  20. package/dist/error-codes.js +32 -0
  21. package/dist/index.cjs +1762 -0
  22. package/dist/index.d.cts +54 -0
  23. package/dist/index.js +198 -0
  24. package/dist/products.cjs +208 -0
  25. package/dist/products.d.cts +80 -0
  26. package/dist/products.js +22 -0
  27. package/dist/rate-limits.cjs +295 -0
  28. package/dist/rate-limits.d.cts +80 -0
  29. package/dist/rate-limits.js +21 -0
  30. package/dist/themes.cjs +251 -0
  31. package/dist/themes.d.cts +85 -0
  32. package/dist/themes.js +14 -0
  33. package/dist/tiers.cjs +194 -0
  34. package/dist/tiers.d.cts +75 -0
  35. package/dist/tiers.js +28 -0
  36. package/package.json +71 -0
  37. package/src/api-versions.ts +250 -0
  38. package/src/capabilities.ts +272 -0
  39. package/src/domains.ts +216 -0
  40. package/src/error-codes.ts +494 -0
  41. package/src/index.ts +206 -0
  42. package/src/products.ts +285 -0
  43. package/src/rate-limits.ts +334 -0
  44. package/src/themes.ts +380 -0
  45. package/src/tiers.ts +239 -0
  46. package/tsconfig.json +25 -0
@@ -0,0 +1,633 @@
1
+ /**
2
+ * @vorionsys/shared-constants - Error Codes
3
+ *
4
+ * Standardized error codes across all Vorion ecosystem APIs
5
+ * Ensures consistent error handling and reporting
6
+ *
7
+ * @see https://cognigate.dev/docs/errors
8
+ */
9
+ declare enum ErrorCategory {
10
+ /** Authentication and authorization errors (4xx) */
11
+ AUTH = "auth",
12
+ /** Validation and input errors (4xx) */
13
+ VALIDATION = "validation",
14
+ /** Rate limiting and quota errors (429) */
15
+ RATE_LIMIT = "rate_limit",
16
+ /** Resource not found errors (404) */
17
+ NOT_FOUND = "not_found",
18
+ /** Trust and governance errors (4xx) */
19
+ TRUST = "trust",
20
+ /** Server and internal errors (5xx) */
21
+ SERVER = "server",
22
+ /** External service errors (5xx) */
23
+ EXTERNAL = "external",
24
+ /** Configuration errors */
25
+ CONFIG = "config"
26
+ }
27
+ interface ErrorDefinition {
28
+ /** Unique error code */
29
+ code: string;
30
+ /** HTTP status code */
31
+ httpStatus: number;
32
+ /** Error category */
33
+ category: ErrorCategory;
34
+ /** Human-readable message template */
35
+ message: string;
36
+ /** Whether this error is retryable */
37
+ retryable: boolean;
38
+ /** Documentation URL for this error */
39
+ docsUrl?: string;
40
+ }
41
+ declare const AUTH_ERRORS: {
42
+ readonly MISSING_API_KEY: {
43
+ readonly code: "E1001";
44
+ readonly httpStatus: 401;
45
+ readonly category: ErrorCategory.AUTH;
46
+ readonly message: "API key is missing. Include it in the Authorization header.";
47
+ readonly retryable: false;
48
+ readonly docsUrl: "https://cognigate.dev/docs/authentication";
49
+ };
50
+ readonly INVALID_API_KEY: {
51
+ readonly code: "E1002";
52
+ readonly httpStatus: 401;
53
+ readonly category: ErrorCategory.AUTH;
54
+ readonly message: "API key is invalid or has been revoked.";
55
+ readonly retryable: false;
56
+ readonly docsUrl: "https://cognigate.dev/docs/authentication";
57
+ };
58
+ readonly EXPIRED_API_KEY: {
59
+ readonly code: "E1003";
60
+ readonly httpStatus: 401;
61
+ readonly category: ErrorCategory.AUTH;
62
+ readonly message: "API key has expired. Generate a new key.";
63
+ readonly retryable: false;
64
+ readonly docsUrl: "https://cognigate.dev/docs/authentication";
65
+ };
66
+ readonly INSUFFICIENT_PERMISSIONS: {
67
+ readonly code: "E1004";
68
+ readonly httpStatus: 403;
69
+ readonly category: ErrorCategory.AUTH;
70
+ readonly message: "Insufficient permissions for this operation.";
71
+ readonly retryable: false;
72
+ };
73
+ readonly AGENT_NOT_AUTHORIZED: {
74
+ readonly code: "E1005";
75
+ readonly httpStatus: 403;
76
+ readonly category: ErrorCategory.AUTH;
77
+ readonly message: "Agent is not authorized for this action.";
78
+ readonly retryable: false;
79
+ };
80
+ readonly TOKEN_EXPIRED: {
81
+ readonly code: "E1006";
82
+ readonly httpStatus: 401;
83
+ readonly category: ErrorCategory.AUTH;
84
+ readonly message: "Authentication token has expired.";
85
+ readonly retryable: false;
86
+ };
87
+ readonly MFA_REQUIRED: {
88
+ readonly code: "E1007";
89
+ readonly httpStatus: 403;
90
+ readonly category: ErrorCategory.AUTH;
91
+ readonly message: "Multi-factor authentication is required for this operation.";
92
+ readonly retryable: false;
93
+ };
94
+ };
95
+ declare const VALIDATION_ERRORS: {
96
+ readonly INVALID_REQUEST: {
97
+ readonly code: "E2001";
98
+ readonly httpStatus: 400;
99
+ readonly category: ErrorCategory.VALIDATION;
100
+ readonly message: "Request body is invalid or malformed.";
101
+ readonly retryable: false;
102
+ };
103
+ readonly MISSING_REQUIRED_FIELD: {
104
+ readonly code: "E2002";
105
+ readonly httpStatus: 400;
106
+ readonly category: ErrorCategory.VALIDATION;
107
+ readonly message: "Required field is missing: {field}";
108
+ readonly retryable: false;
109
+ };
110
+ readonly INVALID_FIELD_TYPE: {
111
+ readonly code: "E2003";
112
+ readonly httpStatus: 400;
113
+ readonly category: ErrorCategory.VALIDATION;
114
+ readonly message: "Field {field} has invalid type. Expected {expected}.";
115
+ readonly retryable: false;
116
+ };
117
+ readonly INVALID_FIELD_VALUE: {
118
+ readonly code: "E2004";
119
+ readonly httpStatus: 400;
120
+ readonly category: ErrorCategory.VALIDATION;
121
+ readonly message: "Field {field} has invalid value.";
122
+ readonly retryable: false;
123
+ };
124
+ readonly PAYLOAD_TOO_LARGE: {
125
+ readonly code: "E2005";
126
+ readonly httpStatus: 413;
127
+ readonly category: ErrorCategory.VALIDATION;
128
+ readonly message: "Request payload exceeds maximum size of {maxSize}.";
129
+ readonly retryable: false;
130
+ };
131
+ readonly INVALID_JSON: {
132
+ readonly code: "E2006";
133
+ readonly httpStatus: 400;
134
+ readonly category: ErrorCategory.VALIDATION;
135
+ readonly message: "Request body is not valid JSON.";
136
+ readonly retryable: false;
137
+ };
138
+ readonly INVALID_CAR_ID: {
139
+ readonly code: "E2007";
140
+ readonly httpStatus: 400;
141
+ readonly category: ErrorCategory.VALIDATION;
142
+ readonly message: "Invalid CAR ID format. Expected: car:domain/category/name:version";
143
+ readonly retryable: false;
144
+ readonly docsUrl: "https://carid.vorion.org/format";
145
+ };
146
+ readonly INVALID_TRUST_SCORE: {
147
+ readonly code: "E2008";
148
+ readonly httpStatus: 400;
149
+ readonly category: ErrorCategory.VALIDATION;
150
+ readonly message: "Trust score must be between 0 and 1000.";
151
+ readonly retryable: false;
152
+ };
153
+ };
154
+ declare const RATE_LIMIT_ERRORS: {
155
+ readonly RATE_LIMIT_EXCEEDED: {
156
+ readonly code: "E3001";
157
+ readonly httpStatus: 429;
158
+ readonly category: ErrorCategory.RATE_LIMIT;
159
+ readonly message: "Rate limit exceeded. Retry after {retryAfter} seconds.";
160
+ readonly retryable: true;
161
+ };
162
+ readonly QUOTA_EXCEEDED: {
163
+ readonly code: "E3002";
164
+ readonly httpStatus: 429;
165
+ readonly category: ErrorCategory.RATE_LIMIT;
166
+ readonly message: "Monthly quota exceeded. Upgrade your tier or wait for reset.";
167
+ readonly retryable: false;
168
+ };
169
+ readonly CONCURRENT_LIMIT: {
170
+ readonly code: "E3003";
171
+ readonly httpStatus: 429;
172
+ readonly category: ErrorCategory.RATE_LIMIT;
173
+ readonly message: "Too many concurrent requests. Max burst: {burstLimit}.";
174
+ readonly retryable: true;
175
+ };
176
+ readonly DAILY_LIMIT_EXCEEDED: {
177
+ readonly code: "E3004";
178
+ readonly httpStatus: 429;
179
+ readonly category: ErrorCategory.RATE_LIMIT;
180
+ readonly message: "Daily request limit exceeded. Resets at midnight UTC.";
181
+ readonly retryable: true;
182
+ };
183
+ };
184
+ declare const NOT_FOUND_ERRORS: {
185
+ readonly RESOURCE_NOT_FOUND: {
186
+ readonly code: "E4001";
187
+ readonly httpStatus: 404;
188
+ readonly category: ErrorCategory.NOT_FOUND;
189
+ readonly message: "Resource not found: {resourceType}/{resourceId}";
190
+ readonly retryable: false;
191
+ };
192
+ readonly AGENT_NOT_FOUND: {
193
+ readonly code: "E4002";
194
+ readonly httpStatus: 404;
195
+ readonly category: ErrorCategory.NOT_FOUND;
196
+ readonly message: "Agent not found: {agentId}";
197
+ readonly retryable: false;
198
+ };
199
+ readonly PROOF_NOT_FOUND: {
200
+ readonly code: "E4003";
201
+ readonly httpStatus: 404;
202
+ readonly category: ErrorCategory.NOT_FOUND;
203
+ readonly message: "Proof not found: {proofId}";
204
+ readonly retryable: false;
205
+ };
206
+ readonly ENDPOINT_NOT_FOUND: {
207
+ readonly code: "E4004";
208
+ readonly httpStatus: 404;
209
+ readonly category: ErrorCategory.NOT_FOUND;
210
+ readonly message: "API endpoint not found.";
211
+ readonly retryable: false;
212
+ };
213
+ readonly ATTESTATION_NOT_FOUND: {
214
+ readonly code: "E4005";
215
+ readonly httpStatus: 404;
216
+ readonly category: ErrorCategory.NOT_FOUND;
217
+ readonly message: "Attestation not found: {attestationId}";
218
+ readonly retryable: false;
219
+ };
220
+ };
221
+ declare const TRUST_ERRORS: {
222
+ readonly TRUST_TIER_INSUFFICIENT: {
223
+ readonly code: "E5001";
224
+ readonly httpStatus: 403;
225
+ readonly category: ErrorCategory.TRUST;
226
+ readonly message: "Trust tier {currentTier} insufficient. Required: {requiredTier}.";
227
+ readonly retryable: false;
228
+ readonly docsUrl: "https://basis.vorion.org/tiers";
229
+ };
230
+ readonly CAPABILITY_NOT_AVAILABLE: {
231
+ readonly code: "E5002";
232
+ readonly httpStatus: 403;
233
+ readonly category: ErrorCategory.TRUST;
234
+ readonly message: "Capability {capability} not available at tier {tier}.";
235
+ readonly retryable: false;
236
+ readonly docsUrl: "https://cognigate.dev/docs/capabilities";
237
+ };
238
+ readonly GOVERNANCE_DENIED: {
239
+ readonly code: "E5003";
240
+ readonly httpStatus: 403;
241
+ readonly category: ErrorCategory.TRUST;
242
+ readonly message: "Action denied by governance policy: {reason}.";
243
+ readonly retryable: false;
244
+ };
245
+ readonly AGENT_SUSPENDED: {
246
+ readonly code: "E5004";
247
+ readonly httpStatus: 403;
248
+ readonly category: ErrorCategory.TRUST;
249
+ readonly message: "Agent is suspended. Contact support for reinstatement.";
250
+ readonly retryable: false;
251
+ };
252
+ readonly PROOF_VERIFICATION_FAILED: {
253
+ readonly code: "E5005";
254
+ readonly httpStatus: 400;
255
+ readonly category: ErrorCategory.TRUST;
256
+ readonly message: "Proof verification failed: {reason}.";
257
+ readonly retryable: false;
258
+ };
259
+ readonly ATTESTATION_INVALID: {
260
+ readonly code: "E5006";
261
+ readonly httpStatus: 400;
262
+ readonly category: ErrorCategory.TRUST;
263
+ readonly message: "Attestation is invalid or has expired.";
264
+ readonly retryable: false;
265
+ };
266
+ readonly ESCALATION_REQUIRED: {
267
+ readonly code: "E5007";
268
+ readonly httpStatus: 403;
269
+ readonly category: ErrorCategory.TRUST;
270
+ readonly message: "Action requires human approval. Escalation ID: {escalationId}.";
271
+ readonly retryable: false;
272
+ };
273
+ };
274
+ declare const SERVER_ERRORS: {
275
+ readonly INTERNAL_ERROR: {
276
+ readonly code: "E6001";
277
+ readonly httpStatus: 500;
278
+ readonly category: ErrorCategory.SERVER;
279
+ readonly message: "An internal error occurred. Please try again later.";
280
+ readonly retryable: true;
281
+ };
282
+ readonly SERVICE_UNAVAILABLE: {
283
+ readonly code: "E6002";
284
+ readonly httpStatus: 503;
285
+ readonly category: ErrorCategory.SERVER;
286
+ readonly message: "Service is temporarily unavailable. Please try again later.";
287
+ readonly retryable: true;
288
+ };
289
+ readonly DATABASE_ERROR: {
290
+ readonly code: "E6003";
291
+ readonly httpStatus: 500;
292
+ readonly category: ErrorCategory.SERVER;
293
+ readonly message: "Database operation failed. Please try again later.";
294
+ readonly retryable: true;
295
+ };
296
+ readonly MAINTENANCE_MODE: {
297
+ readonly code: "E6004";
298
+ readonly httpStatus: 503;
299
+ readonly category: ErrorCategory.SERVER;
300
+ readonly message: "Service is under maintenance. Expected completion: {eta}.";
301
+ readonly retryable: true;
302
+ };
303
+ };
304
+ declare const EXTERNAL_ERRORS: {
305
+ readonly BLOCKCHAIN_ERROR: {
306
+ readonly code: "E7001";
307
+ readonly httpStatus: 502;
308
+ readonly category: ErrorCategory.EXTERNAL;
309
+ readonly message: "Blockchain network error. Please try again later.";
310
+ readonly retryable: true;
311
+ };
312
+ readonly UPSTREAM_TIMEOUT: {
313
+ readonly code: "E7002";
314
+ readonly httpStatus: 504;
315
+ readonly category: ErrorCategory.EXTERNAL;
316
+ readonly message: "Upstream service timed out.";
317
+ readonly retryable: true;
318
+ };
319
+ readonly EXTERNAL_SERVICE_ERROR: {
320
+ readonly code: "E7003";
321
+ readonly httpStatus: 502;
322
+ readonly category: ErrorCategory.EXTERNAL;
323
+ readonly message: "External service error: {service}.";
324
+ readonly retryable: true;
325
+ };
326
+ };
327
+ declare const ERROR_CODES: {
328
+ readonly BLOCKCHAIN_ERROR: {
329
+ readonly code: "E7001";
330
+ readonly httpStatus: 502;
331
+ readonly category: ErrorCategory.EXTERNAL;
332
+ readonly message: "Blockchain network error. Please try again later.";
333
+ readonly retryable: true;
334
+ };
335
+ readonly UPSTREAM_TIMEOUT: {
336
+ readonly code: "E7002";
337
+ readonly httpStatus: 504;
338
+ readonly category: ErrorCategory.EXTERNAL;
339
+ readonly message: "Upstream service timed out.";
340
+ readonly retryable: true;
341
+ };
342
+ readonly EXTERNAL_SERVICE_ERROR: {
343
+ readonly code: "E7003";
344
+ readonly httpStatus: 502;
345
+ readonly category: ErrorCategory.EXTERNAL;
346
+ readonly message: "External service error: {service}.";
347
+ readonly retryable: true;
348
+ };
349
+ readonly INTERNAL_ERROR: {
350
+ readonly code: "E6001";
351
+ readonly httpStatus: 500;
352
+ readonly category: ErrorCategory.SERVER;
353
+ readonly message: "An internal error occurred. Please try again later.";
354
+ readonly retryable: true;
355
+ };
356
+ readonly SERVICE_UNAVAILABLE: {
357
+ readonly code: "E6002";
358
+ readonly httpStatus: 503;
359
+ readonly category: ErrorCategory.SERVER;
360
+ readonly message: "Service is temporarily unavailable. Please try again later.";
361
+ readonly retryable: true;
362
+ };
363
+ readonly DATABASE_ERROR: {
364
+ readonly code: "E6003";
365
+ readonly httpStatus: 500;
366
+ readonly category: ErrorCategory.SERVER;
367
+ readonly message: "Database operation failed. Please try again later.";
368
+ readonly retryable: true;
369
+ };
370
+ readonly MAINTENANCE_MODE: {
371
+ readonly code: "E6004";
372
+ readonly httpStatus: 503;
373
+ readonly category: ErrorCategory.SERVER;
374
+ readonly message: "Service is under maintenance. Expected completion: {eta}.";
375
+ readonly retryable: true;
376
+ };
377
+ readonly TRUST_TIER_INSUFFICIENT: {
378
+ readonly code: "E5001";
379
+ readonly httpStatus: 403;
380
+ readonly category: ErrorCategory.TRUST;
381
+ readonly message: "Trust tier {currentTier} insufficient. Required: {requiredTier}.";
382
+ readonly retryable: false;
383
+ readonly docsUrl: "https://basis.vorion.org/tiers";
384
+ };
385
+ readonly CAPABILITY_NOT_AVAILABLE: {
386
+ readonly code: "E5002";
387
+ readonly httpStatus: 403;
388
+ readonly category: ErrorCategory.TRUST;
389
+ readonly message: "Capability {capability} not available at tier {tier}.";
390
+ readonly retryable: false;
391
+ readonly docsUrl: "https://cognigate.dev/docs/capabilities";
392
+ };
393
+ readonly GOVERNANCE_DENIED: {
394
+ readonly code: "E5003";
395
+ readonly httpStatus: 403;
396
+ readonly category: ErrorCategory.TRUST;
397
+ readonly message: "Action denied by governance policy: {reason}.";
398
+ readonly retryable: false;
399
+ };
400
+ readonly AGENT_SUSPENDED: {
401
+ readonly code: "E5004";
402
+ readonly httpStatus: 403;
403
+ readonly category: ErrorCategory.TRUST;
404
+ readonly message: "Agent is suspended. Contact support for reinstatement.";
405
+ readonly retryable: false;
406
+ };
407
+ readonly PROOF_VERIFICATION_FAILED: {
408
+ readonly code: "E5005";
409
+ readonly httpStatus: 400;
410
+ readonly category: ErrorCategory.TRUST;
411
+ readonly message: "Proof verification failed: {reason}.";
412
+ readonly retryable: false;
413
+ };
414
+ readonly ATTESTATION_INVALID: {
415
+ readonly code: "E5006";
416
+ readonly httpStatus: 400;
417
+ readonly category: ErrorCategory.TRUST;
418
+ readonly message: "Attestation is invalid or has expired.";
419
+ readonly retryable: false;
420
+ };
421
+ readonly ESCALATION_REQUIRED: {
422
+ readonly code: "E5007";
423
+ readonly httpStatus: 403;
424
+ readonly category: ErrorCategory.TRUST;
425
+ readonly message: "Action requires human approval. Escalation ID: {escalationId}.";
426
+ readonly retryable: false;
427
+ };
428
+ readonly RESOURCE_NOT_FOUND: {
429
+ readonly code: "E4001";
430
+ readonly httpStatus: 404;
431
+ readonly category: ErrorCategory.NOT_FOUND;
432
+ readonly message: "Resource not found: {resourceType}/{resourceId}";
433
+ readonly retryable: false;
434
+ };
435
+ readonly AGENT_NOT_FOUND: {
436
+ readonly code: "E4002";
437
+ readonly httpStatus: 404;
438
+ readonly category: ErrorCategory.NOT_FOUND;
439
+ readonly message: "Agent not found: {agentId}";
440
+ readonly retryable: false;
441
+ };
442
+ readonly PROOF_NOT_FOUND: {
443
+ readonly code: "E4003";
444
+ readonly httpStatus: 404;
445
+ readonly category: ErrorCategory.NOT_FOUND;
446
+ readonly message: "Proof not found: {proofId}";
447
+ readonly retryable: false;
448
+ };
449
+ readonly ENDPOINT_NOT_FOUND: {
450
+ readonly code: "E4004";
451
+ readonly httpStatus: 404;
452
+ readonly category: ErrorCategory.NOT_FOUND;
453
+ readonly message: "API endpoint not found.";
454
+ readonly retryable: false;
455
+ };
456
+ readonly ATTESTATION_NOT_FOUND: {
457
+ readonly code: "E4005";
458
+ readonly httpStatus: 404;
459
+ readonly category: ErrorCategory.NOT_FOUND;
460
+ readonly message: "Attestation not found: {attestationId}";
461
+ readonly retryable: false;
462
+ };
463
+ readonly RATE_LIMIT_EXCEEDED: {
464
+ readonly code: "E3001";
465
+ readonly httpStatus: 429;
466
+ readonly category: ErrorCategory.RATE_LIMIT;
467
+ readonly message: "Rate limit exceeded. Retry after {retryAfter} seconds.";
468
+ readonly retryable: true;
469
+ };
470
+ readonly QUOTA_EXCEEDED: {
471
+ readonly code: "E3002";
472
+ readonly httpStatus: 429;
473
+ readonly category: ErrorCategory.RATE_LIMIT;
474
+ readonly message: "Monthly quota exceeded. Upgrade your tier or wait for reset.";
475
+ readonly retryable: false;
476
+ };
477
+ readonly CONCURRENT_LIMIT: {
478
+ readonly code: "E3003";
479
+ readonly httpStatus: 429;
480
+ readonly category: ErrorCategory.RATE_LIMIT;
481
+ readonly message: "Too many concurrent requests. Max burst: {burstLimit}.";
482
+ readonly retryable: true;
483
+ };
484
+ readonly DAILY_LIMIT_EXCEEDED: {
485
+ readonly code: "E3004";
486
+ readonly httpStatus: 429;
487
+ readonly category: ErrorCategory.RATE_LIMIT;
488
+ readonly message: "Daily request limit exceeded. Resets at midnight UTC.";
489
+ readonly retryable: true;
490
+ };
491
+ readonly INVALID_REQUEST: {
492
+ readonly code: "E2001";
493
+ readonly httpStatus: 400;
494
+ readonly category: ErrorCategory.VALIDATION;
495
+ readonly message: "Request body is invalid or malformed.";
496
+ readonly retryable: false;
497
+ };
498
+ readonly MISSING_REQUIRED_FIELD: {
499
+ readonly code: "E2002";
500
+ readonly httpStatus: 400;
501
+ readonly category: ErrorCategory.VALIDATION;
502
+ readonly message: "Required field is missing: {field}";
503
+ readonly retryable: false;
504
+ };
505
+ readonly INVALID_FIELD_TYPE: {
506
+ readonly code: "E2003";
507
+ readonly httpStatus: 400;
508
+ readonly category: ErrorCategory.VALIDATION;
509
+ readonly message: "Field {field} has invalid type. Expected {expected}.";
510
+ readonly retryable: false;
511
+ };
512
+ readonly INVALID_FIELD_VALUE: {
513
+ readonly code: "E2004";
514
+ readonly httpStatus: 400;
515
+ readonly category: ErrorCategory.VALIDATION;
516
+ readonly message: "Field {field} has invalid value.";
517
+ readonly retryable: false;
518
+ };
519
+ readonly PAYLOAD_TOO_LARGE: {
520
+ readonly code: "E2005";
521
+ readonly httpStatus: 413;
522
+ readonly category: ErrorCategory.VALIDATION;
523
+ readonly message: "Request payload exceeds maximum size of {maxSize}.";
524
+ readonly retryable: false;
525
+ };
526
+ readonly INVALID_JSON: {
527
+ readonly code: "E2006";
528
+ readonly httpStatus: 400;
529
+ readonly category: ErrorCategory.VALIDATION;
530
+ readonly message: "Request body is not valid JSON.";
531
+ readonly retryable: false;
532
+ };
533
+ readonly INVALID_CAR_ID: {
534
+ readonly code: "E2007";
535
+ readonly httpStatus: 400;
536
+ readonly category: ErrorCategory.VALIDATION;
537
+ readonly message: "Invalid CAR ID format. Expected: car:domain/category/name:version";
538
+ readonly retryable: false;
539
+ readonly docsUrl: "https://carid.vorion.org/format";
540
+ };
541
+ readonly INVALID_TRUST_SCORE: {
542
+ readonly code: "E2008";
543
+ readonly httpStatus: 400;
544
+ readonly category: ErrorCategory.VALIDATION;
545
+ readonly message: "Trust score must be between 0 and 1000.";
546
+ readonly retryable: false;
547
+ };
548
+ readonly MISSING_API_KEY: {
549
+ readonly code: "E1001";
550
+ readonly httpStatus: 401;
551
+ readonly category: ErrorCategory.AUTH;
552
+ readonly message: "API key is missing. Include it in the Authorization header.";
553
+ readonly retryable: false;
554
+ readonly docsUrl: "https://cognigate.dev/docs/authentication";
555
+ };
556
+ readonly INVALID_API_KEY: {
557
+ readonly code: "E1002";
558
+ readonly httpStatus: 401;
559
+ readonly category: ErrorCategory.AUTH;
560
+ readonly message: "API key is invalid or has been revoked.";
561
+ readonly retryable: false;
562
+ readonly docsUrl: "https://cognigate.dev/docs/authentication";
563
+ };
564
+ readonly EXPIRED_API_KEY: {
565
+ readonly code: "E1003";
566
+ readonly httpStatus: 401;
567
+ readonly category: ErrorCategory.AUTH;
568
+ readonly message: "API key has expired. Generate a new key.";
569
+ readonly retryable: false;
570
+ readonly docsUrl: "https://cognigate.dev/docs/authentication";
571
+ };
572
+ readonly INSUFFICIENT_PERMISSIONS: {
573
+ readonly code: "E1004";
574
+ readonly httpStatus: 403;
575
+ readonly category: ErrorCategory.AUTH;
576
+ readonly message: "Insufficient permissions for this operation.";
577
+ readonly retryable: false;
578
+ };
579
+ readonly AGENT_NOT_AUTHORIZED: {
580
+ readonly code: "E1005";
581
+ readonly httpStatus: 403;
582
+ readonly category: ErrorCategory.AUTH;
583
+ readonly message: "Agent is not authorized for this action.";
584
+ readonly retryable: false;
585
+ };
586
+ readonly TOKEN_EXPIRED: {
587
+ readonly code: "E1006";
588
+ readonly httpStatus: 401;
589
+ readonly category: ErrorCategory.AUTH;
590
+ readonly message: "Authentication token has expired.";
591
+ readonly retryable: false;
592
+ };
593
+ readonly MFA_REQUIRED: {
594
+ readonly code: "E1007";
595
+ readonly httpStatus: 403;
596
+ readonly category: ErrorCategory.AUTH;
597
+ readonly message: "Multi-factor authentication is required for this operation.";
598
+ readonly retryable: false;
599
+ };
600
+ };
601
+ /**
602
+ * Get error definition by code
603
+ */
604
+ declare function getErrorByCode(code: string): ErrorDefinition | undefined;
605
+ /**
606
+ * Get all errors by category
607
+ */
608
+ declare function getErrorsByCategory(category: ErrorCategory): ErrorDefinition[];
609
+ /**
610
+ * Get all retryable errors
611
+ */
612
+ declare function getRetryableErrors(): ErrorDefinition[];
613
+ /**
614
+ * Format error message with parameters
615
+ */
616
+ declare function formatErrorMessage(error: ErrorDefinition, params: Record<string, string | number>): string;
617
+ /**
618
+ * Create a structured error response
619
+ */
620
+ declare function createErrorResponse(error: ErrorDefinition, params?: Record<string, string | number>, requestId?: string): {
621
+ error: {
622
+ requestId?: string | undefined;
623
+ docsUrl?: string | undefined;
624
+ code: string;
625
+ message: string;
626
+ category: ErrorCategory;
627
+ retryable: boolean;
628
+ };
629
+ status: number;
630
+ };
631
+ type ErrorCode = keyof typeof ERROR_CODES;
632
+
633
+ export { AUTH_ERRORS, ERROR_CODES, EXTERNAL_ERRORS, ErrorCategory, type ErrorCode, type ErrorDefinition, NOT_FOUND_ERRORS, RATE_LIMIT_ERRORS, SERVER_ERRORS, TRUST_ERRORS, VALIDATION_ERRORS, createErrorResponse, formatErrorMessage, getErrorByCode, getErrorsByCategory, getRetryableErrors };
@@ -0,0 +1,32 @@
1
+ import {
2
+ AUTH_ERRORS,
3
+ ERROR_CODES,
4
+ EXTERNAL_ERRORS,
5
+ ErrorCategory,
6
+ NOT_FOUND_ERRORS,
7
+ RATE_LIMIT_ERRORS,
8
+ SERVER_ERRORS,
9
+ TRUST_ERRORS,
10
+ VALIDATION_ERRORS,
11
+ createErrorResponse,
12
+ formatErrorMessage,
13
+ getErrorByCode,
14
+ getErrorsByCategory,
15
+ getRetryableErrors
16
+ } from "./chunk-TYCMBQGU.js";
17
+ export {
18
+ AUTH_ERRORS,
19
+ ERROR_CODES,
20
+ EXTERNAL_ERRORS,
21
+ ErrorCategory,
22
+ NOT_FOUND_ERRORS,
23
+ RATE_LIMIT_ERRORS,
24
+ SERVER_ERRORS,
25
+ TRUST_ERRORS,
26
+ VALIDATION_ERRORS,
27
+ createErrorResponse,
28
+ formatErrorMessage,
29
+ getErrorByCode,
30
+ getErrorsByCategory,
31
+ getRetryableErrors
32
+ };