capgen

1.0.8 • Public • Published

capgen

A package to generate Common Alerting Protocol XML Payload

CAP 1.2 is a popular Common Alerting protocol/specification.

Find the CAP Specification details at CAP Stanard

npm version GitHub license GitHub stars GitHub issues GitHub forks

Code

  • Simply import Capgen from capgen package. NPM URL: https://www.npmjs.com/package/capgen npm install capgen
  • create instance of Capgen class by passing the config object to the constructor.
  • generate the cap xml using the 'createUsing' method.
import { Capgen} from 'capgen';


const config={
  strictMode:false,
  comment:false,
  xmlOptions:{
    headless:true,
    prettyPrint:true
  }
}

const gen = new Capgen(config);
const xml =gen.createUsing({
  
  sender: 'Abhijeet',
  sent: 'Monday 09 feb 2021 21:38:00 +8:00',
  status: 'Active',
  msgType: 'Alert',
  source: 'FeedJar',
  scope: 'Public',
  code: ['2.1', '2.2'],
  info: [
    {
      category: ["A","B"],
      eventCode:["e1","e2"],
      parameter: [
        {
          valueName: 'same',
          value: 'CEM',
        },
        {
          valueName: 'ISOK',
          value: 'OK',
        },
      ],
      resource:[{
        resourceDesc:"IWS",
        mimeType:"html"
      },
      {
        resourceDesc:"IWS",
        mimeType:"image" ,
        digest:'SHA1'
      }
    ],
    area:[
      {
        areaDesc:"Taylor; Clark",
        geocode:[
          {
            valueName:"UGC",
            value:"WIZ017"
          },
          {
            valueName:"UGC",
            value:"WIZ017"
          },
          {
            valueName:"UGC",
            value:"WIZ017"
          }
        ]
      }
    ]
    },
  ],
});

console.log(xml);

ChangeLog

see change log here

Package Sidebar

Install

npm i capgen

Weekly Downloads

3

Version

1.0.8

License

MIT

Unpacked Size

41.1 kB

Total Files

13

Last publish

Collaborators

  • bhagatabhijeet