vast-core
v1.0.0
Published
Core package for VAST (Video Ad Serving Template) handling
Maintainers
Readme
vast-core
A TypeScript library for handling VAST (Video Ad Serving Template) error codes and validation in video advertising applications. This module provides standardized error codes as defined by the IAB VAST specification, making it easier to handle and report video ad-related errors in a consistent manner.
Features
- Comprehensive set of VAST error codes
- TypeScript support with type definitions
- Zero dependencies
- Fully tested
- IAB VAST specification compliant
Installation
npm install vast-coreor using yarn:
yarn add vast-coreUsage
Basic Usage
import { vastErrorCode } from 'vast-core';
// Example: Handling a VAST parsing error
function handleVastError(error: Error) {
if (error instanceof XMLParseError) {
return vastErrorCode.PARSING_ERROR; // Returns 100
}
if (error instanceof SchemaValidationError) {
return vastErrorCode.SCHEMA_VALIDATION_ERROR; // Returns 101
}
}Error Code Categories
The library provides the following error code categories:
Parsing Errors (100-102)
PARSING_ERROR(100): XML parsing errorSCHEMA_VALIDATION_ERROR(101): VAST schema validation errorINVALID_VAST_VERSION(102): VAST version not supported
Trafficking Errors (200)
AD_TYPE_NOT_SUPPORTED(200): Received unsupported ad type
Wrapper Errors (300-303)
GENERAL_WRAPPER_ERROR(300): General wrapper errorTIMEOUT_ERROR(301): VAST URI timeoutWRAPPER_LIMIT_REACHED(302): Too many wrapper responsesNO_AD_FOUND_IN_WRAPPER(303): No ads found in wrapper response
Linear Ad Errors (400-403)
GENERAL_LINEAR_ERROR(400): Unable to display linear adFILE_NOT_FOUND(401): Linear/mediaFile not foundMEDIA_MIME_TYPE_NOT_SUPPORTED(403): Media type not supported
Non-Linear Ad Errors (500)
GENERAL_NON_LINEAR_AD(500): General non-linear ads error
Companion Ad Errors (600)
GENERAL_COMPANION_ERROR(600): General companion ad error
General Errors (900)
UNEXPECTED_ERROR(900): Unexpected errorGENERAL_VPAID_ERROR(900): General VPAID error
Development
Prerequisites
- Node.js (>= 14.x)
- npm (>= 6.x)
Setting Up Development Environment
- Clone the repository:
git clone https://github.com/sourabh-garg/vast-core.git
cd vast-core- Install dependencies:
npm installAvailable Scripts
npm run build- Builds the package for productionnpm test- Runs the test suite with coveragenpm run test:watch- Runs tests in watch modenpm run lint- Lints the codenpm run format- Formats the code using Prettiernpm run typecheck- Runs TypeScript type checking
Building
npm run buildThe build output will be in the lib directory.
Testing
# Run tests with coverage
npm test
# Run tests in watch mode
npm run test:watchCode Style
The project uses ESLint and Prettier for code formatting. Format your code using:
npm run formatContributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT Sourabh Garg
