JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • 0
  • Score
    100M100P100Q26345F
  • License MIT

A package to generate Common Alerting Protocol XML Payload

Package Exports

  • capgen

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (capgen) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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

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