npm package: @fnet/vast-vmap
Description: This project is designed to facilitate the generation of VMAP (Video Multiple Ad Playlist) compliant XML documents using data retrieved from a collection of VAST (Video Ad Serving Template) ad providers. The goal is to enable integration and management of
Latest version: 0.1.2

# @fnet/vast-vmap

This project is designed to facilitate the generation of VMAP (Video Multiple Ad Playlist) compliant XML documents using data retrieved from a collection of VAST (Video Ad Serving Template) ad providers. The goal is to enable integration and management of multiple video ads into a single VMAP document, which can be utilized to schedule video ad breaks during content playback.

## How It Works

The module accepts a configuration object containing a list of VAST providers. When initialized, it processes each provider to construct an ad break within the VMAP document based on the VAST data returned from the providers. The finalized VMAP XML is pretty-printed to ensure it is well-structured and easy to interpret.

## Key Features

- **Multiple VAST Provider Support**: Accepts an array of VAST providers to generate ad data.
- **Ad Break Construction**: Generates ad breaks for each provider with detailed ad sources.
- **Customization**: Allows for additional attributes such as the extension of the ad break, which can modify playback characteristics.
- **XML Serialization**: Outputs the VMAP as a well-formed, indent-friendly XML document for smooth integration with video players supporting VMAP.

## Conclusion

The @fnet/vast-vmap module provides a straightforward solution for creating VMAP documents from multiple VAST ad providers. It is aimed at users who need to integrate multiple video ads efficiently during content playback, ensuring a seamless video ad scheduling experience.


# @fnet/vast-vmap Developer Guide

## Overview

The `@fnet/vast-vmap` library is designed to help developers generate VMAP (Video Multiple Ad Playlist) XML data from multiple VAST (Video Ad Serving Template) providers. This allows for seamless integration and management of video ads across different platforms and ad providers. The library focuses on ease of use by providing a straightforward API for creating VMAP documents with support for both direct XML inclusion and ad tag URIs.

## Installation

To install the `@fnet/vast-vmap` library, use either npm or yarn:

Using npm:
```bash
npm install @fnet/vast-vmap
```

Using yarn:
```bash
yarn add @fnet/vast-vmap
```

## Usage

The primary functionality of the library is accessible through an asynchronous function titled `index`. The example below showcases how to initialize the library with a list of providers and retrieve a VMAP XML document.

```javascript
import VastVmap from '@fnet/vast-vmap';

// Define your VAST providers
const providers = [
  {
    getVAST: async () => ({ type: 'xml', value: '<VAST>...</VAST>' })
  },
  {
    getVAST: async () => ({ type: 'url', value: 'http://example.com/vast.xml' })
  }
];

// Initialize the library with configuration
const vastVmapProcessor = await VastVmap({ providers });

// Retrieve VMAP Data
vastVmapProcessor.getVAST().then(vmap => {
  console.log(vmap); // Outputs the prettified VMAP XML
});
```

## Examples

Here are some examples that illustrate the common use cases:

### Example 1: Simple VMAP Generation

Here is how you can create a VMAP XML with two VAST sources, one providing XML directly and the other providing a URL.

```javascript
import VastVmap from '@fnet/vast-vmap';

const providers = [
  {
    getVAST: async () => ({
      type: 'xml',
      value: '<VAST version="3.0">....</VAST>'
    })
  },
  {
    getVAST: async () => ({
      type: 'url',
      value: 'https://example.com/ad/vast.xml'
    })
  }
];

const vastVmapProcessor = await VastVmap({ providers });

const vmapData = await vastVmapProcessor.getVAST();

console.log(vmapData.value);
```

### Example 2: Complex VMAP with Bumper Suppression

This example illustrates a VMAP with a bumper suppression on the last ad break.

```javascript
import VastVmap from '@fnet/vast-vmap';

const providers = [
  {
    getVAST: async () => ({ type: 'xml', value: '<VAST>...</VAST>' })
  },
  {
    getVAST: async () => ({ type: 'xml', value: '<VAST>...</VAST>' })
  }
];

const vastVmapProcessor = await VastVmap({ providers });

const vmapData = await vastVmapProcessor.getVAST();

console.log(vmapData.value);
```

## Acknowledgement

This library leverages the simplicity of asynchronous functions in JavaScript to streamline the process of combining VAST data into a standard VMAP format, ensuring a cohesive ad experience across multiple sources.



# Input Schema
```yaml
$schema: https://json-schema.org/draft/2020-12/schema
title: VastConfig
type: object
properties:
  providers:
    type: array
    items:
      type: object
      properties:
        getVAST:
          type: string
required:
  - providers
additionalProperties: false

```