@vritti/api-sdk 0.1.7 → 0.1.8
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/README.md +22 -6
- package/dist/index.cjs +131 -413
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +351 -227
- package/dist/index.d.ts +351 -227
- package/dist/index.js +148 -429
- package/dist/index.js.map +1 -1
- package/package.json +14 -15
package/dist/index.d.ts
CHANGED
|
@@ -1660,21 +1660,87 @@ declare abstract class TenantBaseRepository<TTable extends PgTable, TInsert = In
|
|
|
1660
1660
|
exists(where: SQL): Promise<boolean>;
|
|
1661
1661
|
}
|
|
1662
1662
|
|
|
1663
|
+
/**
|
|
1664
|
+
* RFC 9457 Problem Details field-specific error structure.
|
|
1665
|
+
*
|
|
1666
|
+
* Used for validation errors or other field-specific issues.
|
|
1667
|
+
* The `field` property is required to ensure clear association.
|
|
1668
|
+
*/
|
|
1663
1669
|
interface FieldError {
|
|
1664
|
-
field
|
|
1670
|
+
/** The field name (e.g., 'email', 'password') - REQUIRED */
|
|
1671
|
+
field: string;
|
|
1672
|
+
/** The error message for this field */
|
|
1665
1673
|
message: string;
|
|
1666
1674
|
}
|
|
1675
|
+
/**
|
|
1676
|
+
* RFC 9457 Problem Details standard fields.
|
|
1677
|
+
*
|
|
1678
|
+
* @see https://www.rfc-editor.org/rfc/rfc9457.html
|
|
1679
|
+
*/
|
|
1667
1680
|
interface ProblemDetails {
|
|
1681
|
+
/** Problem type URI (default: "about:blank") */
|
|
1682
|
+
type: string;
|
|
1683
|
+
/** HTTP status phrase (e.g., "Unauthorized", "Not Found") */
|
|
1668
1684
|
title: string;
|
|
1685
|
+
/** HTTP status code */
|
|
1669
1686
|
status: number;
|
|
1687
|
+
/** Root error heading (extension member, maps to AlertTitle in frontend) */
|
|
1688
|
+
label?: string;
|
|
1689
|
+
/** Detailed error description (maps to AlertDescription in frontend) */
|
|
1670
1690
|
detail: string;
|
|
1691
|
+
/** Request path where the error occurred */
|
|
1692
|
+
instance?: string;
|
|
1671
1693
|
}
|
|
1694
|
+
/**
|
|
1695
|
+
* Complete API error response following RFC 9457 Problem Details format.
|
|
1696
|
+
*
|
|
1697
|
+
* Extends ProblemDetails with field-specific errors.
|
|
1698
|
+
*/
|
|
1672
1699
|
interface ApiErrorResponse extends ProblemDetails {
|
|
1700
|
+
/** Field-specific errors (field is required in each FieldError) */
|
|
1673
1701
|
errors: FieldError[];
|
|
1674
1702
|
}
|
|
1675
1703
|
|
|
1676
|
-
|
|
1677
|
-
|
|
1704
|
+
/**
|
|
1705
|
+
* Options for creating RFC 9457 Problem Details exceptions.
|
|
1706
|
+
*
|
|
1707
|
+
* @example
|
|
1708
|
+
* throw new UnauthorizedException({
|
|
1709
|
+
* label: 'Invalid Credentials',
|
|
1710
|
+
* detail: 'The email or password is incorrect',
|
|
1711
|
+
* });
|
|
1712
|
+
*
|
|
1713
|
+
* @example
|
|
1714
|
+
* throw new BadRequestException({
|
|
1715
|
+
* detail: 'Validation failed',
|
|
1716
|
+
* errors: [
|
|
1717
|
+
* { field: 'email', message: 'Invalid email format' },
|
|
1718
|
+
* { field: 'password', message: 'Password too short' },
|
|
1719
|
+
* ],
|
|
1720
|
+
* });
|
|
1721
|
+
*/
|
|
1722
|
+
interface ProblemOptions {
|
|
1723
|
+
/** Problem type URI (default: "about:blank") */
|
|
1724
|
+
type?: string;
|
|
1725
|
+
/** Root error heading (maps to AlertTitle in frontend) */
|
|
1726
|
+
label?: string;
|
|
1727
|
+
/** Root error description (maps to AlertDescription in frontend) */
|
|
1728
|
+
detail?: string;
|
|
1729
|
+
/** Field-specific errors only (field is required) */
|
|
1730
|
+
errors?: FieldError[];
|
|
1731
|
+
}
|
|
1732
|
+
/**
|
|
1733
|
+
* Base exception class that follows RFC 9457 Problem Details format.
|
|
1734
|
+
*
|
|
1735
|
+
* Provides a clean interface for creating HTTP exceptions with:
|
|
1736
|
+
* - RFC 9457 standard fields (type, title, status, detail, instance)
|
|
1737
|
+
* - Extension members (label for root error heading, errors for field-specific errors)
|
|
1738
|
+
*
|
|
1739
|
+
* The `title` field is always set to the HTTP status phrase (e.g., "Unauthorized")
|
|
1740
|
+
* by the HttpExceptionFilter, not by this class.
|
|
1741
|
+
*/
|
|
1742
|
+
declare abstract class HttpProblemException extends HttpException {
|
|
1743
|
+
constructor(detailOrOptions: string | ProblemOptions, httpStatus: HttpStatus);
|
|
1678
1744
|
}
|
|
1679
1745
|
|
|
1680
1746
|
/**
|
|
@@ -1683,21 +1749,17 @@ declare abstract class BaseFieldException extends HttpException {
|
|
|
1683
1749
|
*
|
|
1684
1750
|
* @example
|
|
1685
1751
|
* // Simple message
|
|
1686
|
-
* throw new BadGatewayException('
|
|
1687
|
-
*
|
|
1688
|
-
* // Field-specific error
|
|
1689
|
-
* throw new BadGatewayException('upstream', 'Upstream service returned invalid response');
|
|
1690
|
-
*
|
|
1691
|
-
* // With detail
|
|
1692
|
-
* throw new BadGatewayException('proxy', 'Gateway error', 'Payment service is not responding correctly');
|
|
1752
|
+
* throw new BadGatewayException('Upstream service returned invalid response');
|
|
1693
1753
|
*
|
|
1694
|
-
* //
|
|
1695
|
-
* throw new BadGatewayException(
|
|
1696
|
-
*
|
|
1697
|
-
*
|
|
1754
|
+
* // With options
|
|
1755
|
+
* throw new BadGatewayException({
|
|
1756
|
+
* title: 'Upstream Service Error',
|
|
1757
|
+
* detail: 'The payment service is not responding correctly',
|
|
1758
|
+
* instance: '/api/payments/process',
|
|
1759
|
+
* });
|
|
1698
1760
|
*/
|
|
1699
|
-
declare class BadGatewayException extends
|
|
1700
|
-
constructor(
|
|
1761
|
+
declare class BadGatewayException extends HttpProblemException {
|
|
1762
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
1701
1763
|
}
|
|
1702
1764
|
|
|
1703
1765
|
/**
|
|
@@ -1707,20 +1769,24 @@ declare class BadGatewayException extends BaseFieldException {
|
|
|
1707
1769
|
* // Simple message
|
|
1708
1770
|
* throw new BadRequestException('Invalid request data');
|
|
1709
1771
|
*
|
|
1710
|
-
* //
|
|
1711
|
-
* throw new BadRequestException(
|
|
1712
|
-
*
|
|
1713
|
-
*
|
|
1714
|
-
*
|
|
1772
|
+
* // With field errors
|
|
1773
|
+
* throw new BadRequestException({
|
|
1774
|
+
* detail: 'Validation failed',
|
|
1775
|
+
* errors: [
|
|
1776
|
+
* { field: 'email', message: 'Invalid email format' },
|
|
1777
|
+
* { field: 'password', message: 'Password too short' }
|
|
1778
|
+
* ]
|
|
1779
|
+
* });
|
|
1715
1780
|
*
|
|
1716
|
-
* //
|
|
1717
|
-
* throw new BadRequestException(
|
|
1718
|
-
*
|
|
1719
|
-
*
|
|
1720
|
-
*
|
|
1781
|
+
* // With custom label and type
|
|
1782
|
+
* throw new BadRequestException({
|
|
1783
|
+
* label: 'Invalid Form Data',
|
|
1784
|
+
* detail: 'Please check your input',
|
|
1785
|
+
* type: 'validation-error'
|
|
1786
|
+
* });
|
|
1721
1787
|
*/
|
|
1722
|
-
declare class BadRequestException extends
|
|
1723
|
-
constructor(
|
|
1788
|
+
declare class BadRequestException extends HttpProblemException {
|
|
1789
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
1724
1790
|
}
|
|
1725
1791
|
|
|
1726
1792
|
/**
|
|
@@ -1728,44 +1794,56 @@ declare class BadRequestException extends BaseFieldException {
|
|
|
1728
1794
|
* Commonly used for duplicate resources or concurrent modification issues.
|
|
1729
1795
|
*
|
|
1730
1796
|
* @example
|
|
1731
|
-
* // Simple message
|
|
1797
|
+
* // Simple detail message
|
|
1732
1798
|
* throw new ConflictException('Resource already exists');
|
|
1733
1799
|
*
|
|
1734
|
-
* //
|
|
1735
|
-
* throw new ConflictException(
|
|
1800
|
+
* // With custom label and detail
|
|
1801
|
+
* throw new ConflictException({
|
|
1802
|
+
* label: 'Duplicate Entry',
|
|
1803
|
+
* detail: 'Email already exists',
|
|
1804
|
+
* });
|
|
1736
1805
|
*
|
|
1737
|
-
* // With
|
|
1738
|
-
* throw new ConflictException(
|
|
1806
|
+
* // With field-specific errors
|
|
1807
|
+
* throw new ConflictException({
|
|
1808
|
+
* detail: 'Duplicate data detected',
|
|
1809
|
+
* errors: [
|
|
1810
|
+
* { field: 'email', message: 'Email already registered' }
|
|
1811
|
+
* ],
|
|
1812
|
+
* });
|
|
1739
1813
|
*
|
|
1740
|
-
* //
|
|
1741
|
-
* throw new ConflictException(
|
|
1742
|
-
*
|
|
1743
|
-
*
|
|
1814
|
+
* // With custom label and field errors
|
|
1815
|
+
* throw new ConflictException({
|
|
1816
|
+
* label: 'Resource Conflict',
|
|
1817
|
+
* detail: 'Try logging in instead or use a different email',
|
|
1818
|
+
* errors: [{ field: 'email', message: 'Email already in use' }],
|
|
1819
|
+
* });
|
|
1744
1820
|
*/
|
|
1745
|
-
declare class ConflictException extends
|
|
1746
|
-
constructor(
|
|
1821
|
+
declare class ConflictException extends HttpProblemException {
|
|
1822
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
1747
1823
|
}
|
|
1748
1824
|
|
|
1749
1825
|
/**
|
|
1750
1826
|
* Exception thrown when the user does not have permission to access a resource (HTTP 403).
|
|
1751
1827
|
*
|
|
1752
1828
|
* @example
|
|
1753
|
-
* // Simple message
|
|
1829
|
+
* // Simple detail message
|
|
1754
1830
|
* throw new ForbiddenException('Access denied');
|
|
1755
1831
|
*
|
|
1756
|
-
* //
|
|
1757
|
-
* throw new ForbiddenException(
|
|
1758
|
-
*
|
|
1759
|
-
*
|
|
1760
|
-
*
|
|
1832
|
+
* // With custom label
|
|
1833
|
+
* throw new ForbiddenException({
|
|
1834
|
+
* label: 'Access Denied',
|
|
1835
|
+
* detail: 'You do not have permission to perform this action',
|
|
1836
|
+
* });
|
|
1761
1837
|
*
|
|
1762
|
-
* //
|
|
1763
|
-
* throw new ForbiddenException(
|
|
1764
|
-
*
|
|
1765
|
-
*
|
|
1838
|
+
* // With field-specific errors
|
|
1839
|
+
* throw new ForbiddenException({
|
|
1840
|
+
* label: 'Permission Denied',
|
|
1841
|
+
* detail: 'Contact your administrator for access',
|
|
1842
|
+
* errors: [{ field: 'role', message: 'Admin role required' }],
|
|
1843
|
+
* });
|
|
1766
1844
|
*/
|
|
1767
|
-
declare class ForbiddenException extends
|
|
1768
|
-
constructor(
|
|
1845
|
+
declare class ForbiddenException extends HttpProblemException {
|
|
1846
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
1769
1847
|
}
|
|
1770
1848
|
|
|
1771
1849
|
/**
|
|
@@ -1776,19 +1854,21 @@ declare class ForbiddenException extends BaseFieldException {
|
|
|
1776
1854
|
* // Simple message
|
|
1777
1855
|
* throw new GoneException('Resource permanently deleted');
|
|
1778
1856
|
*
|
|
1779
|
-
* //
|
|
1780
|
-
* throw new GoneException(
|
|
1781
|
-
*
|
|
1782
|
-
*
|
|
1783
|
-
*
|
|
1857
|
+
* // With label and detail
|
|
1858
|
+
* throw new GoneException({
|
|
1859
|
+
* label: 'Account Deleted',
|
|
1860
|
+
* detail: 'This account has been permanently removed',
|
|
1861
|
+
* });
|
|
1784
1862
|
*
|
|
1785
|
-
* //
|
|
1786
|
-
* throw new GoneException(
|
|
1787
|
-
*
|
|
1788
|
-
*
|
|
1863
|
+
* // With field errors
|
|
1864
|
+
* throw new GoneException({
|
|
1865
|
+
* label: 'Resource Removed',
|
|
1866
|
+
* detail: 'The resource was removed due to policy violation',
|
|
1867
|
+
* errors: [{ field: 'resource', message: 'This content has been permanently deleted' }],
|
|
1868
|
+
* });
|
|
1789
1869
|
*/
|
|
1790
|
-
declare class GoneException extends
|
|
1791
|
-
constructor(
|
|
1870
|
+
declare class GoneException extends HttpProblemException {
|
|
1871
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
1792
1872
|
}
|
|
1793
1873
|
|
|
1794
1874
|
/**
|
|
@@ -1798,19 +1878,15 @@ declare class GoneException extends BaseFieldException {
|
|
|
1798
1878
|
* // Simple message
|
|
1799
1879
|
* throw new InternalServerErrorException('An unexpected error occurred');
|
|
1800
1880
|
*
|
|
1801
|
-
* //
|
|
1802
|
-
* throw new InternalServerErrorException(
|
|
1803
|
-
*
|
|
1804
|
-
*
|
|
1805
|
-
*
|
|
1806
|
-
*
|
|
1807
|
-
* // Multiple field errors
|
|
1808
|
-
* throw new InternalServerErrorException([
|
|
1809
|
-
* { field: 'system', message: 'Internal error' }
|
|
1810
|
-
* ]);
|
|
1881
|
+
* // With options object
|
|
1882
|
+
* throw new InternalServerErrorException({
|
|
1883
|
+
* title: 'Server Error',
|
|
1884
|
+
* detail: 'Something went wrong',
|
|
1885
|
+
* instance: '/api/users',
|
|
1886
|
+
* });
|
|
1811
1887
|
*/
|
|
1812
|
-
declare class InternalServerErrorException extends
|
|
1813
|
-
constructor(
|
|
1888
|
+
declare class InternalServerErrorException extends HttpProblemException {
|
|
1889
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
1814
1890
|
}
|
|
1815
1891
|
|
|
1816
1892
|
/**
|
|
@@ -1821,19 +1897,28 @@ declare class InternalServerErrorException extends BaseFieldException {
|
|
|
1821
1897
|
* // Simple message
|
|
1822
1898
|
* throw new MethodNotAllowedException('Method not allowed');
|
|
1823
1899
|
*
|
|
1824
|
-
* // Field-specific error
|
|
1825
|
-
* throw new MethodNotAllowedException('method', 'POST method not allowed on this endpoint');
|
|
1826
|
-
*
|
|
1827
1900
|
* // With detail
|
|
1828
|
-
* throw new MethodNotAllowedException(
|
|
1901
|
+
* throw new MethodNotAllowedException({
|
|
1902
|
+
* detail: 'Method not allowed',
|
|
1903
|
+
* instance: '/api/resource/123'
|
|
1904
|
+
* });
|
|
1905
|
+
*
|
|
1906
|
+
* // With custom title
|
|
1907
|
+
* throw new MethodNotAllowedException({
|
|
1908
|
+
* title: 'Invalid HTTP Method',
|
|
1909
|
+
* detail: 'This endpoint only supports GET requests',
|
|
1910
|
+
* });
|
|
1829
1911
|
*
|
|
1830
|
-
* //
|
|
1831
|
-
* throw new MethodNotAllowedException(
|
|
1832
|
-
*
|
|
1833
|
-
*
|
|
1912
|
+
* // With additional context
|
|
1913
|
+
* throw new MethodNotAllowedException({
|
|
1914
|
+
* title: 'Unsupported Operation',
|
|
1915
|
+
* detail: 'PATCH is not supported for this resource',
|
|
1916
|
+
* instance: '/api/users/456',
|
|
1917
|
+
* extensions: { allowedMethods: ['GET', 'PUT', 'DELETE'] }
|
|
1918
|
+
* });
|
|
1834
1919
|
*/
|
|
1835
|
-
declare class MethodNotAllowedException extends
|
|
1836
|
-
constructor(
|
|
1920
|
+
declare class MethodNotAllowedException extends HttpProblemException {
|
|
1921
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
1837
1922
|
}
|
|
1838
1923
|
|
|
1839
1924
|
/**
|
|
@@ -1841,22 +1926,34 @@ declare class MethodNotAllowedException extends BaseFieldException {
|
|
|
1841
1926
|
* Used when the server cannot produce a response matching the Accept headers.
|
|
1842
1927
|
*
|
|
1843
1928
|
* @example
|
|
1844
|
-
* // Simple message
|
|
1929
|
+
* // Simple detail message
|
|
1845
1930
|
* throw new NotAcceptableException('Requested format not available');
|
|
1846
1931
|
*
|
|
1847
|
-
* //
|
|
1848
|
-
* throw new NotAcceptableException(
|
|
1932
|
+
* // With custom label
|
|
1933
|
+
* throw new NotAcceptableException({
|
|
1934
|
+
* label: 'Content Negotiation Failed',
|
|
1935
|
+
* detail: 'Cannot produce response in the requested format',
|
|
1936
|
+
* });
|
|
1849
1937
|
*
|
|
1850
|
-
* // With
|
|
1851
|
-
* throw new NotAcceptableException(
|
|
1938
|
+
* // With field-specific errors
|
|
1939
|
+
* throw new NotAcceptableException({
|
|
1940
|
+
* detail: 'Requested format is not supported',
|
|
1941
|
+
* errors: [
|
|
1942
|
+
* { field: 'accept', message: 'XML format is not available' },
|
|
1943
|
+
* { field: 'contentType', message: 'Only JSON is supported' },
|
|
1944
|
+
* ],
|
|
1945
|
+
* });
|
|
1852
1946
|
*
|
|
1853
|
-
* //
|
|
1854
|
-
* throw new NotAcceptableException(
|
|
1855
|
-
*
|
|
1856
|
-
*
|
|
1947
|
+
* // With all options
|
|
1948
|
+
* throw new NotAcceptableException({
|
|
1949
|
+
* type: 'https://api.example.com/errors/format-not-supported',
|
|
1950
|
+
* label: 'Unsupported Media Type',
|
|
1951
|
+
* detail: 'This API only supports JSON responses',
|
|
1952
|
+
* errors: [{ field: 'accept', message: 'XML format is not available' }],
|
|
1953
|
+
* });
|
|
1857
1954
|
*/
|
|
1858
|
-
declare class NotAcceptableException extends
|
|
1859
|
-
constructor(
|
|
1955
|
+
declare class NotAcceptableException extends HttpProblemException {
|
|
1956
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
1860
1957
|
}
|
|
1861
1958
|
|
|
1862
1959
|
/**
|
|
@@ -1866,19 +1963,20 @@ declare class NotAcceptableException extends BaseFieldException {
|
|
|
1866
1963
|
* // Simple message
|
|
1867
1964
|
* throw new NotFoundException('Resource not found');
|
|
1868
1965
|
*
|
|
1869
|
-
* //
|
|
1870
|
-
* throw new NotFoundException(
|
|
1871
|
-
*
|
|
1872
|
-
*
|
|
1873
|
-
*
|
|
1966
|
+
* // With custom label and detail
|
|
1967
|
+
* throw new NotFoundException({
|
|
1968
|
+
* label: 'User Not Found',
|
|
1969
|
+
* detail: 'The requested user does not exist',
|
|
1970
|
+
* });
|
|
1874
1971
|
*
|
|
1875
|
-
* //
|
|
1876
|
-
* throw new NotFoundException(
|
|
1877
|
-
*
|
|
1878
|
-
* ]
|
|
1972
|
+
* // With field errors
|
|
1973
|
+
* throw new NotFoundException({
|
|
1974
|
+
* detail: 'The requested resource could not be located',
|
|
1975
|
+
* errors: [{ field: 'userId', message: 'User does not exist' }],
|
|
1976
|
+
* });
|
|
1879
1977
|
*/
|
|
1880
|
-
declare class NotFoundException extends
|
|
1881
|
-
constructor(
|
|
1978
|
+
declare class NotFoundException extends HttpProblemException {
|
|
1979
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
1882
1980
|
}
|
|
1883
1981
|
|
|
1884
1982
|
/**
|
|
@@ -1889,19 +1987,14 @@ declare class NotFoundException extends BaseFieldException {
|
|
|
1889
1987
|
* // Simple message
|
|
1890
1988
|
* throw new NotImplementedException('Feature not yet implemented');
|
|
1891
1989
|
*
|
|
1892
|
-
* //
|
|
1893
|
-
* throw new NotImplementedException(
|
|
1894
|
-
*
|
|
1895
|
-
*
|
|
1896
|
-
*
|
|
1897
|
-
*
|
|
1898
|
-
* // Multiple field errors
|
|
1899
|
-
* throw new NotImplementedException([
|
|
1900
|
-
* { field: 'functionality', message: 'This functionality is not available yet' }
|
|
1901
|
-
* ]);
|
|
1990
|
+
* // With options
|
|
1991
|
+
* throw new NotImplementedException({
|
|
1992
|
+
* detail: 'This feature is coming soon',
|
|
1993
|
+
* instance: '/api/v1/export',
|
|
1994
|
+
* });
|
|
1902
1995
|
*/
|
|
1903
|
-
declare class NotImplementedException extends
|
|
1904
|
-
constructor(
|
|
1996
|
+
declare class NotImplementedException extends HttpProblemException {
|
|
1997
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
1905
1998
|
}
|
|
1906
1999
|
|
|
1907
2000
|
/**
|
|
@@ -1912,19 +2005,21 @@ declare class NotImplementedException extends BaseFieldException {
|
|
|
1912
2005
|
* // Simple message
|
|
1913
2006
|
* throw new PayloadTooLargeException('Request payload too large');
|
|
1914
2007
|
*
|
|
1915
|
-
* // Field-specific error
|
|
1916
|
-
* throw new PayloadTooLargeException('file', 'File size exceeds maximum allowed');
|
|
1917
|
-
*
|
|
1918
2008
|
* // With detail
|
|
1919
|
-
* throw new PayloadTooLargeException(
|
|
2009
|
+
* throw new PayloadTooLargeException({
|
|
2010
|
+
* detail: 'Request payload too large',
|
|
2011
|
+
* instance: '/api/upload',
|
|
2012
|
+
* });
|
|
1920
2013
|
*
|
|
1921
|
-
* //
|
|
1922
|
-
* throw new PayloadTooLargeException(
|
|
1923
|
-
*
|
|
1924
|
-
*
|
|
2014
|
+
* // With custom title
|
|
2015
|
+
* throw new PayloadTooLargeException({
|
|
2016
|
+
* title: 'File Size Limit Exceeded',
|
|
2017
|
+
* detail: 'The uploaded file is too large. Maximum size is 10MB',
|
|
2018
|
+
* instance: '/api/files/upload',
|
|
2019
|
+
* });
|
|
1925
2020
|
*/
|
|
1926
|
-
declare class PayloadTooLargeException extends
|
|
1927
|
-
constructor(
|
|
2021
|
+
declare class PayloadTooLargeException extends HttpProblemException {
|
|
2022
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
1928
2023
|
}
|
|
1929
2024
|
|
|
1930
2025
|
/**
|
|
@@ -1935,19 +2030,21 @@ declare class PayloadTooLargeException extends BaseFieldException {
|
|
|
1935
2030
|
* // Simple message
|
|
1936
2031
|
* throw new RequestTimeoutException('Request timeout');
|
|
1937
2032
|
*
|
|
1938
|
-
* //
|
|
1939
|
-
* throw new RequestTimeoutException(
|
|
1940
|
-
*
|
|
1941
|
-
*
|
|
1942
|
-
*
|
|
2033
|
+
* // With custom title and detail
|
|
2034
|
+
* throw new RequestTimeoutException({
|
|
2035
|
+
* title: 'Operation Timeout',
|
|
2036
|
+
* detail: 'The request took too long to complete',
|
|
2037
|
+
* });
|
|
1943
2038
|
*
|
|
1944
|
-
* //
|
|
1945
|
-
* throw new RequestTimeoutException(
|
|
1946
|
-
*
|
|
1947
|
-
*
|
|
2039
|
+
* // With instance for tracking
|
|
2040
|
+
* throw new RequestTimeoutException({
|
|
2041
|
+
* title: 'Database Timeout',
|
|
2042
|
+
* detail: 'Query execution exceeded time limit',
|
|
2043
|
+
* instance: '/api/queries/123',
|
|
2044
|
+
* });
|
|
1948
2045
|
*/
|
|
1949
|
-
declare class RequestTimeoutException extends
|
|
1950
|
-
constructor(
|
|
2046
|
+
declare class RequestTimeoutException extends HttpProblemException {
|
|
2047
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
1951
2048
|
}
|
|
1952
2049
|
|
|
1953
2050
|
/**
|
|
@@ -1958,19 +2055,21 @@ declare class RequestTimeoutException extends BaseFieldException {
|
|
|
1958
2055
|
* // Simple message
|
|
1959
2056
|
* throw new ServiceUnavailableException('Service temporarily unavailable');
|
|
1960
2057
|
*
|
|
1961
|
-
* //
|
|
1962
|
-
* throw new ServiceUnavailableException(
|
|
1963
|
-
*
|
|
1964
|
-
*
|
|
1965
|
-
*
|
|
2058
|
+
* // With custom title and detail
|
|
2059
|
+
* throw new ServiceUnavailableException({
|
|
2060
|
+
* title: 'Scheduled Maintenance',
|
|
2061
|
+
* detail: 'Expected completion: 2 PM EST',
|
|
2062
|
+
* });
|
|
1966
2063
|
*
|
|
1967
|
-
* //
|
|
1968
|
-
* throw new ServiceUnavailableException(
|
|
1969
|
-
*
|
|
1970
|
-
*
|
|
2064
|
+
* // With field errors
|
|
2065
|
+
* throw new ServiceUnavailableException({
|
|
2066
|
+
* title: 'External Service Unavailable',
|
|
2067
|
+
* detail: 'Payment service is down',
|
|
2068
|
+
* errors: [{ field: 'paymentGateway', message: 'Payment gateway unavailable' }],
|
|
2069
|
+
* });
|
|
1971
2070
|
*/
|
|
1972
|
-
declare class ServiceUnavailableException extends
|
|
1973
|
-
constructor(
|
|
2071
|
+
declare class ServiceUnavailableException extends HttpProblemException {
|
|
2072
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
1974
2073
|
}
|
|
1975
2074
|
|
|
1976
2075
|
/**
|
|
@@ -1981,19 +2080,30 @@ declare class ServiceUnavailableException extends BaseFieldException {
|
|
|
1981
2080
|
* // Simple message
|
|
1982
2081
|
* throw new TooManyRequestsException('Too many requests');
|
|
1983
2082
|
*
|
|
1984
|
-
* //
|
|
1985
|
-
* throw new TooManyRequestsException(
|
|
2083
|
+
* // With custom title and detail
|
|
2084
|
+
* throw new TooManyRequestsException({
|
|
2085
|
+
* title: 'Rate Limit Exceeded',
|
|
2086
|
+
* detail: 'You have exceeded the allowed number of requests',
|
|
2087
|
+
* });
|
|
1986
2088
|
*
|
|
1987
|
-
* // With
|
|
1988
|
-
* throw new TooManyRequestsException(
|
|
2089
|
+
* // With field errors
|
|
2090
|
+
* throw new TooManyRequestsException({
|
|
2091
|
+
* title: 'API Throttled',
|
|
2092
|
+
* detail: 'Too many requests to this endpoint',
|
|
2093
|
+
* errors: [{ field: 'requests', message: 'Rate limit exceeded' }],
|
|
2094
|
+
* });
|
|
1989
2095
|
*
|
|
1990
|
-
* //
|
|
1991
|
-
* throw new TooManyRequestsException(
|
|
1992
|
-
*
|
|
1993
|
-
*
|
|
2096
|
+
* // With instance and additional metadata
|
|
2097
|
+
* throw new TooManyRequestsException({
|
|
2098
|
+
* detail: 'Rate limit exceeded',
|
|
2099
|
+
* instance: '/api/v1/users',
|
|
2100
|
+
* retryAfter: 60,
|
|
2101
|
+
* limit: 100,
|
|
2102
|
+
* remaining: 0,
|
|
2103
|
+
* });
|
|
1994
2104
|
*/
|
|
1995
|
-
declare class TooManyRequestsException extends
|
|
1996
|
-
constructor(
|
|
2105
|
+
declare class TooManyRequestsException extends HttpProblemException {
|
|
2106
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
1997
2107
|
}
|
|
1998
2108
|
|
|
1999
2109
|
/**
|
|
@@ -2003,19 +2113,14 @@ declare class TooManyRequestsException extends BaseFieldException {
|
|
|
2003
2113
|
* // Simple message
|
|
2004
2114
|
* throw new UnauthorizedException('Authentication required');
|
|
2005
2115
|
*
|
|
2006
|
-
* //
|
|
2007
|
-
* throw new UnauthorizedException(
|
|
2008
|
-
*
|
|
2009
|
-
*
|
|
2010
|
-
*
|
|
2011
|
-
*
|
|
2012
|
-
* // Multiple field errors
|
|
2013
|
-
* throw new UnauthorizedException([
|
|
2014
|
-
* { field: 'token', message: 'Token expired' }
|
|
2015
|
-
* ]);
|
|
2116
|
+
* // With problem details
|
|
2117
|
+
* throw new UnauthorizedException({
|
|
2118
|
+
* detail: 'Invalid or expired token',
|
|
2119
|
+
* instance: '/api/auth/verify'
|
|
2120
|
+
* });
|
|
2016
2121
|
*/
|
|
2017
|
-
declare class UnauthorizedException extends
|
|
2018
|
-
constructor(
|
|
2122
|
+
declare class UnauthorizedException extends HttpProblemException {
|
|
2123
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
2019
2124
|
}
|
|
2020
2125
|
|
|
2021
2126
|
/**
|
|
@@ -2026,20 +2131,32 @@ declare class UnauthorizedException extends BaseFieldException {
|
|
|
2026
2131
|
* // Simple message
|
|
2027
2132
|
* throw new UnprocessableEntityException('Cannot process the request');
|
|
2028
2133
|
*
|
|
2029
|
-
* // Field-specific error
|
|
2030
|
-
* throw new UnprocessableEntityException('age', 'Age must be 18 or older');
|
|
2031
|
-
*
|
|
2032
2134
|
* // With detail
|
|
2033
|
-
* throw new UnprocessableEntityException(
|
|
2135
|
+
* throw new UnprocessableEntityException({
|
|
2136
|
+
* detail: 'Cannot process the order due to stock limitations',
|
|
2137
|
+
* });
|
|
2138
|
+
*
|
|
2139
|
+
* // With custom title
|
|
2140
|
+
* throw new UnprocessableEntityException({
|
|
2141
|
+
* title: 'Business Rule Violation',
|
|
2142
|
+
* detail: 'Cannot process the order due to stock limitations',
|
|
2143
|
+
* });
|
|
2144
|
+
*
|
|
2145
|
+
* // With field errors
|
|
2146
|
+
* throw new UnprocessableEntityException({
|
|
2147
|
+
* detail: 'One or more items exceed available inventory',
|
|
2148
|
+
* errors: [{ field: 'quantity', message: 'Insufficient stock available' }],
|
|
2149
|
+
* });
|
|
2034
2150
|
*
|
|
2035
|
-
* //
|
|
2036
|
-
* throw new UnprocessableEntityException(
|
|
2037
|
-
*
|
|
2038
|
-
*
|
|
2039
|
-
* ]
|
|
2151
|
+
* // With custom title and field errors
|
|
2152
|
+
* throw new UnprocessableEntityException({
|
|
2153
|
+
* title: 'Validation Failed',
|
|
2154
|
+
* detail: 'One or more items exceed available inventory',
|
|
2155
|
+
* errors: [{ field: 'quantity', message: 'Insufficient stock available' }],
|
|
2156
|
+
* });
|
|
2040
2157
|
*/
|
|
2041
|
-
declare class UnprocessableEntityException extends
|
|
2042
|
-
constructor(
|
|
2158
|
+
declare class UnprocessableEntityException extends HttpProblemException {
|
|
2159
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
2043
2160
|
}
|
|
2044
2161
|
|
|
2045
2162
|
/**
|
|
@@ -2050,19 +2167,21 @@ declare class UnprocessableEntityException extends BaseFieldException {
|
|
|
2050
2167
|
* // Simple message
|
|
2051
2168
|
* throw new UnsupportedMediaTypeException('Unsupported media type');
|
|
2052
2169
|
*
|
|
2053
|
-
* //
|
|
2054
|
-
* throw new UnsupportedMediaTypeException(
|
|
2055
|
-
*
|
|
2056
|
-
*
|
|
2057
|
-
*
|
|
2170
|
+
* // With label and detail
|
|
2171
|
+
* throw new UnsupportedMediaTypeException({
|
|
2172
|
+
* label: 'Invalid Content Type',
|
|
2173
|
+
* detail: 'The content type is not supported',
|
|
2174
|
+
* });
|
|
2058
2175
|
*
|
|
2059
|
-
* //
|
|
2060
|
-
* throw new UnsupportedMediaTypeException(
|
|
2061
|
-
*
|
|
2062
|
-
*
|
|
2176
|
+
* // With field errors
|
|
2177
|
+
* throw new UnsupportedMediaTypeException({
|
|
2178
|
+
* label: 'Unsupported File Format',
|
|
2179
|
+
* detail: 'Accepted formats: JPEG, PNG, GIF',
|
|
2180
|
+
* errors: [{ field: 'file', message: 'PDF format is not accepted for this upload' }],
|
|
2181
|
+
* });
|
|
2063
2182
|
*/
|
|
2064
|
-
declare class UnsupportedMediaTypeException extends
|
|
2065
|
-
constructor(
|
|
2183
|
+
declare class UnsupportedMediaTypeException extends HttpProblemException {
|
|
2184
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
2066
2185
|
}
|
|
2067
2186
|
|
|
2068
2187
|
/**
|
|
@@ -2070,20 +2189,36 @@ declare class UnsupportedMediaTypeException extends BaseFieldException {
|
|
|
2070
2189
|
* Typically used for form validation or DTO validation errors.
|
|
2071
2190
|
*
|
|
2072
2191
|
* @example
|
|
2073
|
-
* //
|
|
2074
|
-
* throw new ValidationException(
|
|
2075
|
-
* { field: 'email', message: 'Invalid email format' },
|
|
2076
|
-
* { field: 'password', message: 'Password must be at least 8 characters' }
|
|
2077
|
-
* ]);
|
|
2192
|
+
* // Simple message
|
|
2193
|
+
* throw new ValidationException('Validation failed');
|
|
2078
2194
|
*
|
|
2079
|
-
* // With detail
|
|
2080
|
-
* throw new ValidationException(
|
|
2081
|
-
*
|
|
2082
|
-
* '
|
|
2083
|
-
* );
|
|
2195
|
+
* // With custom label and detail
|
|
2196
|
+
* throw new ValidationException({
|
|
2197
|
+
* label: 'Invalid Input',
|
|
2198
|
+
* detail: 'The provided data is invalid',
|
|
2199
|
+
* });
|
|
2200
|
+
*
|
|
2201
|
+
* // With field-specific errors
|
|
2202
|
+
* throw new ValidationException({
|
|
2203
|
+
* detail: 'Please correct the highlighted fields',
|
|
2204
|
+
* errors: [
|
|
2205
|
+
* { field: 'email', message: 'Invalid email format' },
|
|
2206
|
+
* { field: 'password', message: 'Password must be at least 8 characters' }
|
|
2207
|
+
* ],
|
|
2208
|
+
* });
|
|
2209
|
+
*
|
|
2210
|
+
* // With custom label and field errors
|
|
2211
|
+
* throw new ValidationException({
|
|
2212
|
+
* label: 'Form Validation Failed',
|
|
2213
|
+
* detail: 'Please correct the highlighted fields',
|
|
2214
|
+
* errors: [
|
|
2215
|
+
* { field: 'email', message: 'Invalid email format' },
|
|
2216
|
+
* { field: 'password', message: 'Password too weak' }
|
|
2217
|
+
* ],
|
|
2218
|
+
* });
|
|
2084
2219
|
*/
|
|
2085
|
-
declare class ValidationException extends
|
|
2086
|
-
constructor(
|
|
2220
|
+
declare class ValidationException extends HttpProblemException {
|
|
2221
|
+
constructor(detailOrOptions?: string | ProblemOptions);
|
|
2087
2222
|
}
|
|
2088
2223
|
|
|
2089
2224
|
/**
|
|
@@ -2100,18 +2235,21 @@ declare class ValidationException extends BaseFieldException {
|
|
|
2100
2235
|
*/
|
|
2101
2236
|
declare function getHttpStatusTitle(status: number): string;
|
|
2102
2237
|
/**
|
|
2103
|
-
* Global HTTP Exception Filter implementing RFC
|
|
2238
|
+
* Global HTTP Exception Filter implementing RFC 9457 Problem Details
|
|
2104
2239
|
*
|
|
2105
|
-
* Transforms all exceptions into a standardized RFC
|
|
2240
|
+
* Transforms all exceptions into a standardized RFC 9457 format:
|
|
2106
2241
|
* {
|
|
2107
|
-
*
|
|
2242
|
+
* type: string, // Problem type URI (default: "about:blank")
|
|
2243
|
+
* title: string, // HTTP status phrase (e.g., "Unauthorized")
|
|
2108
2244
|
* status: number, // HTTP status code
|
|
2109
|
-
*
|
|
2110
|
-
*
|
|
2245
|
+
* label?: string, // Root error heading (maps to AlertTitle)
|
|
2246
|
+
* detail: string, // Root error description (maps to AlertDescription)
|
|
2247
|
+
* instance: string, // Request path
|
|
2248
|
+
* errors: FieldError[] // Field-specific errors (field is required)
|
|
2111
2249
|
* }
|
|
2112
2250
|
*
|
|
2113
2251
|
* Handles:
|
|
2114
|
-
* - Custom
|
|
2252
|
+
* - Custom HttpProblemException from @vritti/api-sdk
|
|
2115
2253
|
* - Class-validator DTO validation errors
|
|
2116
2254
|
* - Standard NestJS HTTP exceptions
|
|
2117
2255
|
* - Unknown errors
|
|
@@ -2141,20 +2279,6 @@ declare const SKIP_CSRF_KEY = "skipCsrf";
|
|
|
2141
2279
|
*/
|
|
2142
2280
|
declare const SkipCsrf: () => _nestjs_common.CustomDecorator<string>;
|
|
2143
2281
|
|
|
2144
|
-
/**
|
|
2145
|
-
* HTTP Module
|
|
2146
|
-
*
|
|
2147
|
-
* Provides HTTP utilities including:
|
|
2148
|
-
* - CSRF Guard for request protection
|
|
2149
|
-
* - HTTP Exception Filter for standardized error responses
|
|
2150
|
-
*
|
|
2151
|
-
* Usage:
|
|
2152
|
-
* Import this module to access HTTP guards and filters.
|
|
2153
|
-
* Guards and filters are registered globally in the main application.
|
|
2154
|
-
*/
|
|
2155
|
-
declare class HttpModule {
|
|
2156
|
-
}
|
|
2157
|
-
|
|
2158
2282
|
/**
|
|
2159
2283
|
* Extract ISO country code from E.164 phone number
|
|
2160
2284
|
* @param phone Phone number in E.164 format (e.g., +919876543210)
|
|
@@ -2569,4 +2693,4 @@ declare function generateCorrelationId(): string;
|
|
|
2569
2693
|
*/
|
|
2570
2694
|
declare function addCorrelationIdToResponse(reply: FastifyReply, correlationId: string, headerName?: string): void;
|
|
2571
2695
|
|
|
2572
|
-
export { type ApiErrorResponse, type ApiSdkConfig, AuthConfigModule, BadGatewayException, BadRequestException,
|
|
2696
|
+
export { type ApiErrorResponse, type ApiSdkConfig, AuthConfigModule, BadGatewayException, BadRequestException, ConflictException, type CookieConfig, type CorrelationContext, CorrelationIdMiddleware, DEFAULT_CORRELATION_HEADER, DatabaseModule, type DatabaseModuleOptions, type FieldError, ForbiddenException, GoneException, type GuardConfig, HttpExceptionFilter, HttpLoggerInterceptor, type HttpLoggerOptions, HttpProblemException, InternalServerErrorException, type JwtConfig, LOGGER_MODULE_OPTIONS, type LogFormat, type LogLevel, type LogMetadata, LoggerModule, type LoggerModuleAsyncOptions, type LoggerModuleOptions, type LoggerOptionsFactory, LoggerService, MethodNotAllowedException, NotAcceptableException, NotFoundException, NotImplementedException, Onboarding, PayloadTooLargeException, PrimaryBaseRepository, PrimaryDatabaseService, type PrimaryDbConfig, type ProblemDetails, type ProblemOptions, Public, type RegisteredSchema, RequestTimeoutException, SKIP_CSRF_KEY, ServiceUnavailableException, SkipCsrf, SseAuthGuard, Tenant, TenantBaseRepository, TenantContextService, TenantDatabaseService, type TenantInfo, TooManyRequestsException, type TypedDrizzleClient, UnauthorizedException, UnprocessableEntityException, UnsupportedMediaTypeException, UserId, ValidationException, VrittiAuthGuard, addCorrelationIdToResponse, configureApiSdk, correlationStorage, defineConfig, extractCountryFromPhone, generateCorrelationId, getConfig, getCorrelationContext, getHttpStatusTitle, getJwtExpiry, getRefreshCookieOptions, hashToken, normalizePhoneNumber, resetConfig, runWithCorrelationContext, updateCorrelationContext, verifyTokenHash };
|