@axvietnam/types
v1.0.27
Published
Shared types for AXVN connectors
Readme
AXVN TypeScript Types
@axvietnam/types is a TypeScript type definition package for AXVN modular connectors. It centralizes shared interfaces, types, and error classes, ensuring consistency across all AXVN Connectors.
This package is designed to be used with the modular AXVN connectors.
Table of Contents
Features
- Centralized Type Definitions for AXVN REST/WebSocket APIs
- Error Classes for standardized exception handling
- Shared Configuration Interfaces used across all AXVN Connectors
- Lightweight & Tree-Shakeable – excludes runtime values when possible
- Fully Compatible with TypeScript for strong type safety
Installation
To use this package, install it via npm:
npm install @axvietnam/typesUsage
This package provides types and error classes to be used within AXVN Connectors.
Example: Importing Common Types
import type { ConfigurationRestAPI } from '@axvietnam/types';
const config: ConfigurationRestAPI = {
apiKey: 'your-api-key',
apiSecret: 'your-api-secret',
};Example: Handling Errors Consistently
import { ConnectorClientError, UnauthorizedError } from '@axvietnam/types';
try {
// Some API call
} catch (err) {
if (err instanceof ConnectorClientError) {
console.error('Client error occurred:', err);
} else if (err instanceof UnauthorizedError) {
console.error('Invalid API credentials:', err);
} else {
console.error('Unexpected error:', err);
}
}Available Types
API Response Types
RestApiResponse<T>– Standardized REST API response structureWebsocketApiResponse<T>– WebSocket response format
Configuration Types
ConfigurationRestAPI– Configuration structure for REST API clientsConfigurationWebsocketAPI– Configuration for WebSocket API clientsConfigurationWebsocketStreams– Config for managing WebSocket streams
Rate Limit Types
RestApiRateLimitWebsocketApiRateLimit
Error Handling
The package includes predefined error classes to simplify error handling across AXVN SDKs.
| Error Class | Description |
| ---------------------- | --------------------------------- |
| ConnectorClientError | Generic client error |
| RequiredError | Missing required parameter |
| UnauthorizedError | Invalid or missing API key |
| ForbiddenError | Access denied |
| TooManyRequestsError | Rate limit exceeded |
| RateLimitBanError | Banned due to excessive API calls |
| ServerError | Internal AXVN server error |
| NetworkError | Network connectivity issue |
| NotFoundError | Requested resource not found |
| BadRequestError | Malformed request |
Example: Catching API Errors
import { RequiredError, NotFoundError } from '@axvietnam/types';
try {
// API call
} catch (err) {
if (err instanceof RequiredError) {
console.error('Missing required parameters:', err);
} else if (err instanceof NotFoundError) {
console.error('Requested resource does not exist:', err);
}
}Contributing
Contributions are welcome!
- Open a GitHub issue before making changes.
- Discuss proposed changes with maintainers.
- Follow the existing TypeScript structure.
Disclaimer
This SDK is provided by AXVN on an "as is" and "as available" basis for use at your own risk. AXVN makes no representations or warranties of any kind, whether express or implied, as to the operation of the SDK, its accuracy, reliability, completeness, or fitness for any particular purpose.
To the fullest extent permitted by law, AXVN shall not be liable for any losses, damages, or expenses of any kind arising from or in connection with your use of, or inability to use, this SDK, including but not limited to any financial losses resulting from errors, bugs, interruptions, or inaccuracies in the SDK.
Your use of this SDK to access the AXVN Platform is subject to the AXVN API Key Terms and the AXVN Terms of Use, which shall prevail in the event of any conflict with this disclaimer. You are solely responsible for any orders or transactions executed through the AXVN Platform using this SDK.
This SDK is not intended to constitute investment advice or a recommendation to buy, sell, or hold any digital asset. You should independently evaluate and verify all information before acting.
License
This project is licensed under the MIT License - see the LICENSE file for details.
