Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

refractproject/minim-alps

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minim ALPS

Build Status

This library provides an interface to the Refract ALPS. It extends upon the base types as defined in Minim.

Install

npm install minim-alps

Usage Example

import minim from 'minim';
import alpsNamespace from 'minim-alps';

const namespace = minim
  .namespace()
  .use(alpsNamespace);

// Convert from Compact Refract
// Converted from http://tools.ietf.org/html/draft-amundsen-richardson-foster-alps-01
let compactRefract = [
  'alps', {}, {version: '1.0'}, [
    ['doc', {}, {format: 'text'}, 'A contact list.'],
    ['descriptor', {id:'collection'}, {type: 'safe', rt: 'contact'}, [
      ['doc', {}, {}, 'A simple link/form for getting a list of contacts.'],
      ['descriptor', {id: 'nameSearch'}, {type: 'semantic'}, [
        ['doc', {}, {}, 'Input for a search form.']
      ]]
    ]],
    ['descriptor', {id:'contact'}, {type: 'semantic'}, [
      ['descriptor', {id: 'item'}, {type: 'safe'}, [
        ['doc', {}, {}, 'A link to an individual contact.'],
        ['descriptor', {id:'fullName'}, {type: 'semantic'}, []],
        ['descriptor', {id:'email'}, {type: 'semantic'}, []],
        ['descriptor', {id:'phone'}, {type: 'semantic'}, []]
      ]]
    ]]
  ]
];

let alpsDoc = namespace.fromCompactRefract(compactRefract);

// Initialize elements directly
const Alps = namespace.getElementClass('alps');
const alps = new Alps();

// Set version
alps.attributes.set('version', '1.0');

const doc = alps.addDoc();
doc.attributes.set('type', 'text');
doc.set('A contact list.');

const collection = alps.addDescriptor();
collection.id = 'collection';
collection.attributes.set({type: 'safe', rt: 'contact'});

const collectionDoc = collection.addDoc();
doc.set('A simple link/form for getting a list of contacts.');

const nameSearch = collection.addDescriptor();
nameSearch.attributes.set('type', 'semantic');

Element Reference

Alps (Descriptor)

Indicates the root of the ALPS document.

Descriptor (ArrayElement)

A descriptor element defines the semantics of specific data elements or state transitions that MAY exist in an associated representation.

A text field that contains free-form, usually human-readable, text.

Releases

No releases published

Packages

No packages published