@getpanto/sc4m-mco-utils
v0.0.1
Published
This software provides utility functions which (1) generate MCO contracts represented in TURTLE from Media Contractual Objects, and (2) parses MCO contracts represented in TURTLE and converts them into Media Contractual Objects.
Downloads
2
Readme
Smart Contracts for Media - MCO Utils
MCO Generator
This software generates MCO contracts represented in TURTLE from Media Contractual Objects. This software is composed of:
- a series of JSON files composing the Look Up Table (
./lookup-tables
) - a set of generators for the generation of JSON-LD objects (
./generators
)
The generation process starts in the ./index.js
file:
- a JSON file representing the Media Contractual Objects is transformed into the JSON-LD format
- Elements in it are used to generate the Turtle file representing the MCO contract.
Media Contractual Objects (JSON strings) -> JSON-LD (JSON objects) -> MCO Contracts (turtle)
Usage
Importing this module will provide with a method getMCOFromContract
that takes in input an object containing Media Contractual Objects and returns the related string in Turtle form. The utility function jsonld2turtle
(used within getMCOFromContract
) parses a json-ld string and serializes it into a Turtle string.
Test
To test the generator execute the following command in the main directory:
npm test
MCO Parser
This software parses MCO contracts represented in TURTLE and converts them into Media Contractual Objects. This software is composed of:
- a series of JSON file composing the Look Up Table (
./lookup-tables
) - a set of generators for the generation of Media Contractual Objects (
./generators
) - a set of handlers to manage the inter-relation of Objects during the generation phase (
./handlers
)
The parsing process starts in the ./index.js
file:
- a Turtle file representing the MCO contract is transformed into the JSON-LD format
- Elements in it are used to generate the Objects.
MCO Contracts (turtle) -> JSON-LD (JSON objects) -> Media Contractual Objects
For more info check the READMEs into the sub-folders.
Usage
To use the parser execute one of the following command in the main directory:
npm test <turtle file path>
Importing this module will provide with a method getContractFromMCO
that takes in input a string in Turtle form and returns the related Media Contractual Objects.
Test
To test the parser execute the following command in the main directory:
npm test turtle/new/use-case-stream-small-label.ttl