Skip to content
This repository has been archived by the owner. It is now read-only.
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

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.

Doc (StringElement)

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

About

Minim ALPS Namespace

Resources

License

Releases

No releases published

Packages

No packages published
You can’t perform that action at this time.