@vritti/api-sdk 0.0.6 → 0.0.7

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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _nestjs_common from '@nestjs/common';
2
- import { DynamicModule, OnModuleDestroy, OnModuleInit, Logger, CanActivate, ExecutionContext, ExceptionFilter, ArgumentsHost } from '@nestjs/common';
2
+ import { DynamicModule, OnModuleDestroy, OnModuleInit, Logger, CanActivate, ExecutionContext, ExceptionFilter, ArgumentsHost, HttpException, HttpStatus } from '@nestjs/common';
3
3
  import { ConfigService } from '@nestjs/config';
4
4
  import { Reflector } from '@nestjs/core';
5
5
  import { JwtService } from '@nestjs/jwt';
@@ -1325,4 +1325,448 @@ declare class HttpExceptionFilter implements ExceptionFilter {
1325
1325
  private parseValidationErrors;
1326
1326
  }
1327
1327
 
1328
- export { AuthConfigModule, CsrfGuard, DatabaseModule, type DatabaseModuleOptions, HttpExceptionFilter, HttpModule, Onboarding, PrimaryBaseRepository, PrimaryDatabaseService, type PrimaryDbConfig, Public, Tenant, TenantBaseRepository, TenantContextService, TenantDatabaseService, type TenantInfo, VrittiAuthGuard };
1328
+ /**
1329
+ * Converts an HTTP status code to its corresponding title string.
1330
+ * Uses the HttpStatus enum to map status codes to human-readable titles.
1331
+ *
1332
+ * @param status - The HTTP status code
1333
+ * @returns The human-readable title for the status code
1334
+ *
1335
+ * @example
1336
+ * getHttpStatusTitle(400) // Returns: "Bad Request"
1337
+ * getHttpStatusTitle(404) // Returns: "Not Found"
1338
+ * getHttpStatusTitle(500) // Returns: "Internal Server Error"
1339
+ */
1340
+ declare function getHttpStatusTitle(status: number): string;
1341
+
1342
+ interface FieldError$1 {
1343
+ field?: string;
1344
+ message: string;
1345
+ }
1346
+ interface ProblemDetails {
1347
+ title: string;
1348
+ status: number;
1349
+ detail: string;
1350
+ }
1351
+ interface ApiErrorResponse extends ProblemDetails {
1352
+ errors: FieldError$1[];
1353
+ }
1354
+
1355
+ interface FieldError {
1356
+ field?: string;
1357
+ message: string;
1358
+ }
1359
+ declare abstract class BaseFieldException extends HttpException {
1360
+ constructor(statusOrMessageOrErrors: HttpStatus | string | FieldError[], messageOrStatus?: string | HttpStatus, statusOrDetail?: HttpStatus | string, detail?: string);
1361
+ }
1362
+
1363
+ /**
1364
+ * Exception thrown when a request is malformed or contains invalid data (HTTP 400).
1365
+ *
1366
+ * @example
1367
+ * // Simple message
1368
+ * throw new BadRequestException('Invalid request data');
1369
+ *
1370
+ * // Field-specific error
1371
+ * throw new BadRequestException('email', 'Invalid email format');
1372
+ *
1373
+ * // With detail
1374
+ * throw new BadRequestException('email', 'Invalid email format', 'Email must be in valid format');
1375
+ *
1376
+ * // Multiple field errors
1377
+ * throw new BadRequestException([
1378
+ * { field: 'email', message: 'Invalid email' },
1379
+ * { field: 'password', message: 'Password too short' }
1380
+ * ]);
1381
+ */
1382
+ declare class BadRequestException extends BaseFieldException {
1383
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1384
+ }
1385
+
1386
+ /**
1387
+ * Exception thrown when authentication is required or has failed (HTTP 401).
1388
+ *
1389
+ * @example
1390
+ * // Simple message
1391
+ * throw new UnauthorizedException('Authentication required');
1392
+ *
1393
+ * // Field-specific error
1394
+ * throw new UnauthorizedException('token', 'Invalid or expired token');
1395
+ *
1396
+ * // With detail
1397
+ * throw new UnauthorizedException('token', 'Invalid token', 'Please login again');
1398
+ *
1399
+ * // Multiple field errors
1400
+ * throw new UnauthorizedException([
1401
+ * { field: 'token', message: 'Token expired' }
1402
+ * ]);
1403
+ */
1404
+ declare class UnauthorizedException extends BaseFieldException {
1405
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1406
+ }
1407
+
1408
+ /**
1409
+ * Exception thrown when the user does not have permission to access a resource (HTTP 403).
1410
+ *
1411
+ * @example
1412
+ * // Simple message
1413
+ * throw new ForbiddenException('Access denied');
1414
+ *
1415
+ * // Field-specific error
1416
+ * throw new ForbiddenException('resource', 'You do not have permission');
1417
+ *
1418
+ * // With detail
1419
+ * throw new ForbiddenException('resource', 'Access denied', 'Admin role required');
1420
+ *
1421
+ * // Multiple field errors
1422
+ * throw new ForbiddenException([
1423
+ * { field: 'action', message: 'Insufficient permissions' }
1424
+ * ]);
1425
+ */
1426
+ declare class ForbiddenException extends BaseFieldException {
1427
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1428
+ }
1429
+
1430
+ /**
1431
+ * Exception thrown when a requested resource cannot be found (HTTP 404).
1432
+ *
1433
+ * @example
1434
+ * // Simple message
1435
+ * throw new NotFoundException('Resource not found');
1436
+ *
1437
+ * // Field-specific error
1438
+ * throw new NotFoundException('userId', 'User not found');
1439
+ *
1440
+ * // With detail
1441
+ * throw new NotFoundException('userId', 'User not found', 'No user exists with the provided ID');
1442
+ *
1443
+ * // Multiple field errors
1444
+ * throw new NotFoundException([
1445
+ * { field: 'userId', message: 'User does not exist' }
1446
+ * ]);
1447
+ */
1448
+ declare class NotFoundException extends BaseFieldException {
1449
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1450
+ }
1451
+
1452
+ /**
1453
+ * Exception thrown when a request conflicts with the current state (HTTP 409).
1454
+ * Commonly used for duplicate resources or concurrent modification issues.
1455
+ *
1456
+ * @example
1457
+ * // Simple message
1458
+ * throw new ConflictException('Resource already exists');
1459
+ *
1460
+ * // Field-specific error
1461
+ * throw new ConflictException('email', 'Email already registered');
1462
+ *
1463
+ * // With detail
1464
+ * throw new ConflictException('email', 'Email already exists', 'Try logging in instead');
1465
+ *
1466
+ * // Multiple field errors
1467
+ * throw new ConflictException([
1468
+ * { field: 'email', message: 'Email already in use' }
1469
+ * ]);
1470
+ */
1471
+ declare class ConflictException extends BaseFieldException {
1472
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1473
+ }
1474
+
1475
+ /**
1476
+ * Exception thrown when an unexpected server error occurs (HTTP 500).
1477
+ *
1478
+ * @example
1479
+ * // Simple message
1480
+ * throw new InternalServerErrorException('An unexpected error occurred');
1481
+ *
1482
+ * // Field-specific error
1483
+ * throw new InternalServerErrorException('database', 'Database connection failed');
1484
+ *
1485
+ * // With detail
1486
+ * throw new InternalServerErrorException('database', 'Connection failed', 'Please try again later');
1487
+ *
1488
+ * // Multiple field errors
1489
+ * throw new InternalServerErrorException([
1490
+ * { field: 'system', message: 'Internal error' }
1491
+ * ]);
1492
+ */
1493
+ declare class InternalServerErrorException extends BaseFieldException {
1494
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1495
+ }
1496
+
1497
+ /**
1498
+ * Exception thrown when request validation fails (HTTP 400).
1499
+ * Typically used for form validation or DTO validation errors.
1500
+ *
1501
+ * @example
1502
+ * // Multiple validation errors
1503
+ * throw new ValidationException([
1504
+ * { field: 'email', message: 'Invalid email format' },
1505
+ * { field: 'password', message: 'Password must be at least 8 characters' }
1506
+ * ]);
1507
+ *
1508
+ * // With detail
1509
+ * throw new ValidationException(
1510
+ * [{ field: 'email', message: 'Invalid format' }],
1511
+ * 'Please correct the errors and try again'
1512
+ * );
1513
+ */
1514
+ declare class ValidationException extends BaseFieldException {
1515
+ constructor(errors: FieldError[], detail?: string);
1516
+ }
1517
+
1518
+ /**
1519
+ * Exception thrown when the request is well-formed but contains semantic errors (HTTP 422).
1520
+ * Used for business logic validation failures that prevent processing.
1521
+ *
1522
+ * @example
1523
+ * // Simple message
1524
+ * throw new UnprocessableEntityException('Cannot process the request');
1525
+ *
1526
+ * // Field-specific error
1527
+ * throw new UnprocessableEntityException('age', 'Age must be 18 or older');
1528
+ *
1529
+ * // With detail
1530
+ * throw new UnprocessableEntityException('quantity', 'Insufficient stock', 'Only 5 items available');
1531
+ *
1532
+ * // Multiple field errors
1533
+ * throw new UnprocessableEntityException([
1534
+ * { field: 'startDate', message: 'Start date must be before end date' },
1535
+ * { field: 'endDate', message: 'End date cannot be in the past' }
1536
+ * ]);
1537
+ */
1538
+ declare class UnprocessableEntityException extends BaseFieldException {
1539
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1540
+ }
1541
+
1542
+ /**
1543
+ * Exception thrown when rate limiting is triggered (HTTP 429).
1544
+ * Used to prevent abuse and ensure fair resource usage.
1545
+ *
1546
+ * @example
1547
+ * // Simple message
1548
+ * throw new TooManyRequestsException('Too many requests');
1549
+ *
1550
+ * // Field-specific error
1551
+ * throw new TooManyRequestsException('api', 'Rate limit exceeded');
1552
+ *
1553
+ * // With detail
1554
+ * throw new TooManyRequestsException('api', 'Rate limit exceeded', 'Try again in 60 seconds');
1555
+ *
1556
+ * // Multiple field errors
1557
+ * throw new TooManyRequestsException([
1558
+ * { field: 'requests', message: 'Rate limit exceeded for this endpoint' }
1559
+ * ]);
1560
+ */
1561
+ declare class TooManyRequestsException extends BaseFieldException {
1562
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1563
+ }
1564
+
1565
+ /**
1566
+ * Exception thrown when the service is temporarily unavailable (HTTP 503).
1567
+ * Used during maintenance, overload, or temporary outages.
1568
+ *
1569
+ * @example
1570
+ * // Simple message
1571
+ * throw new ServiceUnavailableException('Service temporarily unavailable');
1572
+ *
1573
+ * // Field-specific error
1574
+ * throw new ServiceUnavailableException('service', 'Scheduled maintenance in progress');
1575
+ *
1576
+ * // With detail
1577
+ * throw new ServiceUnavailableException('service', 'Maintenance', 'Service will be back at 2 PM EST');
1578
+ *
1579
+ * // Multiple field errors
1580
+ * throw new ServiceUnavailableException([
1581
+ * { field: 'database', message: 'Database is temporarily unavailable' }
1582
+ * ]);
1583
+ */
1584
+ declare class ServiceUnavailableException extends BaseFieldException {
1585
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1586
+ }
1587
+
1588
+ /**
1589
+ * Exception thrown when an HTTP method is not supported for the endpoint (HTTP 405).
1590
+ * For example, when a POST is sent to a GET-only endpoint.
1591
+ *
1592
+ * @example
1593
+ * // Simple message
1594
+ * throw new MethodNotAllowedException('Method not allowed');
1595
+ *
1596
+ * // Field-specific error
1597
+ * throw new MethodNotAllowedException('method', 'POST method not allowed on this endpoint');
1598
+ *
1599
+ * // With detail
1600
+ * throw new MethodNotAllowedException('method', 'Not allowed', 'Only GET and PUT are supported');
1601
+ *
1602
+ * // Multiple field errors
1603
+ * throw new MethodNotAllowedException([
1604
+ * { field: 'method', message: 'DELETE is not allowed on this resource' }
1605
+ * ]);
1606
+ */
1607
+ declare class MethodNotAllowedException extends BaseFieldException {
1608
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1609
+ }
1610
+
1611
+ /**
1612
+ * Exception thrown when a resource has been permanently removed (HTTP 410).
1613
+ * Unlike 404, this indicates the resource existed but is intentionally gone.
1614
+ *
1615
+ * @example
1616
+ * // Simple message
1617
+ * throw new GoneException('Resource permanently deleted');
1618
+ *
1619
+ * // Field-specific error
1620
+ * throw new GoneException('account', 'Account has been permanently deleted');
1621
+ *
1622
+ * // With detail
1623
+ * throw new GoneException('account', 'Deleted', 'This account was removed on user request');
1624
+ *
1625
+ * // Multiple field errors
1626
+ * throw new GoneException([
1627
+ * { field: 'resource', message: 'This content has been permanently removed' }
1628
+ * ]);
1629
+ */
1630
+ declare class GoneException extends BaseFieldException {
1631
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1632
+ }
1633
+
1634
+ /**
1635
+ * Exception thrown when content negotiation fails (HTTP 406).
1636
+ * Used when the server cannot produce a response matching the Accept headers.
1637
+ *
1638
+ * @example
1639
+ * // Simple message
1640
+ * throw new NotAcceptableException('Requested format not available');
1641
+ *
1642
+ * // Field-specific error
1643
+ * throw new NotAcceptableException('accept', 'Cannot produce response in requested format');
1644
+ *
1645
+ * // With detail
1646
+ * throw new NotAcceptableException('accept', 'Format not supported', 'Only JSON is available');
1647
+ *
1648
+ * // Multiple field errors
1649
+ * throw new NotAcceptableException([
1650
+ * { field: 'contentType', message: 'XML format is not supported' }
1651
+ * ]);
1652
+ */
1653
+ declare class NotAcceptableException extends BaseFieldException {
1654
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1655
+ }
1656
+
1657
+ /**
1658
+ * Exception thrown when a request takes too long to process (HTTP 408).
1659
+ * Used when the client or server times out while waiting for completion.
1660
+ *
1661
+ * @example
1662
+ * // Simple message
1663
+ * throw new RequestTimeoutException('Request timeout');
1664
+ *
1665
+ * // Field-specific error
1666
+ * throw new RequestTimeoutException('operation', 'Operation timed out');
1667
+ *
1668
+ * // With detail
1669
+ * throw new RequestTimeoutException('query', 'Database query timeout', 'Try with fewer filters');
1670
+ *
1671
+ * // Multiple field errors
1672
+ * throw new RequestTimeoutException([
1673
+ * { field: 'processing', message: 'Request took too long to complete' }
1674
+ * ]);
1675
+ */
1676
+ declare class RequestTimeoutException extends BaseFieldException {
1677
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1678
+ }
1679
+
1680
+ /**
1681
+ * Exception thrown when request payload exceeds size limits (HTTP 413).
1682
+ * Commonly used for file upload size restrictions or large request bodies.
1683
+ *
1684
+ * @example
1685
+ * // Simple message
1686
+ * throw new PayloadTooLargeException('Request payload too large');
1687
+ *
1688
+ * // Field-specific error
1689
+ * throw new PayloadTooLargeException('file', 'File size exceeds maximum allowed');
1690
+ *
1691
+ * // With detail
1692
+ * throw new PayloadTooLargeException('file', 'File too large', 'Maximum size is 10MB');
1693
+ *
1694
+ * // Multiple field errors
1695
+ * throw new PayloadTooLargeException([
1696
+ * { field: 'upload', message: 'File exceeds 10MB limit' }
1697
+ * ]);
1698
+ */
1699
+ declare class PayloadTooLargeException extends BaseFieldException {
1700
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1701
+ }
1702
+
1703
+ /**
1704
+ * Exception thrown when the media type of the request is not supported (HTTP 415).
1705
+ * Used when the Content-Type header specifies an unsupported format.
1706
+ *
1707
+ * @example
1708
+ * // Simple message
1709
+ * throw new UnsupportedMediaTypeException('Unsupported media type');
1710
+ *
1711
+ * // Field-specific error
1712
+ * throw new UnsupportedMediaTypeException('contentType', 'XML is not supported');
1713
+ *
1714
+ * // With detail
1715
+ * throw new UnsupportedMediaTypeException('contentType', 'Not supported', 'Only JSON and form-data are accepted');
1716
+ *
1717
+ * // Multiple field errors
1718
+ * throw new UnsupportedMediaTypeException([
1719
+ * { field: 'contentType', message: 'application/xml is not supported' }
1720
+ * ]);
1721
+ */
1722
+ declare class UnsupportedMediaTypeException extends BaseFieldException {
1723
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1724
+ }
1725
+
1726
+ /**
1727
+ * Exception thrown when a feature or endpoint is not yet implemented (HTTP 501).
1728
+ * Used for planned but unavailable functionality.
1729
+ *
1730
+ * @example
1731
+ * // Simple message
1732
+ * throw new NotImplementedException('Feature not yet implemented');
1733
+ *
1734
+ * // Field-specific error
1735
+ * throw new NotImplementedException('feature', 'This feature is coming soon');
1736
+ *
1737
+ * // With detail
1738
+ * throw new NotImplementedException('export', 'Not implemented', 'PDF export will be available in v2.0');
1739
+ *
1740
+ * // Multiple field errors
1741
+ * throw new NotImplementedException([
1742
+ * { field: 'functionality', message: 'This functionality is not available yet' }
1743
+ * ]);
1744
+ */
1745
+ declare class NotImplementedException extends BaseFieldException {
1746
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1747
+ }
1748
+
1749
+ /**
1750
+ * Exception thrown when a gateway or proxy receives an invalid response (HTTP 502).
1751
+ * Used when a server acting as a gateway gets an error from an upstream server.
1752
+ *
1753
+ * @example
1754
+ * // Simple message
1755
+ * throw new BadGatewayException('Bad gateway');
1756
+ *
1757
+ * // Field-specific error
1758
+ * throw new BadGatewayException('upstream', 'Upstream service returned invalid response');
1759
+ *
1760
+ * // With detail
1761
+ * throw new BadGatewayException('proxy', 'Gateway error', 'Payment service is not responding correctly');
1762
+ *
1763
+ * // Multiple field errors
1764
+ * throw new BadGatewayException([
1765
+ * { field: 'gateway', message: 'Invalid response from upstream server' }
1766
+ * ]);
1767
+ */
1768
+ declare class BadGatewayException extends BaseFieldException {
1769
+ constructor(messageOrField: string | FieldError[], fieldMessageOrDetail?: string, detail?: string);
1770
+ }
1771
+
1772
+ export { type ApiErrorResponse, AuthConfigModule, BadGatewayException, BadRequestException, BaseFieldException, ConflictException, CsrfGuard, DatabaseModule, type DatabaseModuleOptions, type FieldError, ForbiddenException, GoneException, HttpExceptionFilter, HttpModule, InternalServerErrorException, MethodNotAllowedException, NotAcceptableException, NotFoundException, NotImplementedException, Onboarding, PayloadTooLargeException, PrimaryBaseRepository, PrimaryDatabaseService, type PrimaryDbConfig, type ProblemDetails, Public, RequestTimeoutException, ServiceUnavailableException, Tenant, TenantBaseRepository, TenantContextService, TenantDatabaseService, type TenantInfo, TooManyRequestsException, UnauthorizedException, UnprocessableEntityException, UnsupportedMediaTypeException, ValidationException, VrittiAuthGuard, getHttpStatusTitle };