Skip to content

TransactionAuthorizationProtocol/ivms101

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IVMS101 TypeScript Library

This library provides TypeScript type definitions and conversion utilities for the IVMS101 (interVASP Messaging Standard) in both its original 2020 version and the updated 2023 version.

Features

  • Type definitions for IVMS101 2020 and 2023 versions
  • Conversion functions between 2020 and 2023 formats
  • Version detection and automatic conversion

Installation

npm install ivms101

Usage

Importing

import { IVMS101, ensureVersion, PayloadVersionCode } from 'ivms101';

Converting between versions

import { IVMS101, ensureVersion, PayloadVersionCode } from 'ivms101';

// Assuming you have some IVMS101 data
const ivmsData: IVMS101 = { /* ... */ };

// Convert to 2023 version (default)
const ivms2023 = ensureVersion(ivmsData); // Defaults to 2023 version
// Or explicitly specify version
const ivms2023Explicit = ensureVersion(PayloadVersionCode.V2023, ivmsData);

// Convert to 2020 version
const ivms2020 = ensureVersion(PayloadVersionCode.V2020, ivmsData);

Type Checking

The library provides type definitions for both versions, allowing for type-safe usage in TypeScript projects.

import { IVMS101_2020, IVMS101_2023 } from 'ivms101';

function processIVMS101(data: IVMS101_2020.IVMS101 | IVMS101_2023.IVMS101) {
  // Process the data...
}

API Reference

ensureVersion(version?: PayloadVersionCode, data: IVMS101): IVMS101

Converts the given IVMS101 data to the specified version. Defaults to 2023 version if no version is specified.

ivms101_version(data: IVMS101): PayloadVersionCode

Detects the version of the given IVMS101 data.

convertTo2023(data: IVMS101_2020.IVMS101): IVMS101_2023.IVMS101

Converts IVMS101 2020 data to 2023 format.

convertFrom2023(data: IVMS101_2023.IVMS101): IVMS101_2020.IVMS101

Converts IVMS101 2023 data back to 2020 format.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.

About

Typescript types for IVMS 101

Resources

Stars

Watchers

Forks

Packages

No packages published