juana

0.1.2 • Public • Published

Juana

JSON-RPC description language.

Installation

npm i juana

Usage

From source:

import juana from 'juana';

const juanaDocument = juana`
name = "Math API";
version = "1.0.0";

http.servers.default.url = "https://math.juana.dev/v1";

add(a: float, b: float): float;
sub(a: float, b: float): float;
mul(a: float, b: float): float;
div(a: float, b: float): float;
`;

console.log(juanaDocument);

By url:

import juana from 'juana';

const juanaDocument = await juana.byUrl('https://math.juana.dev/v1');

console.log(juanaDocument);

API

jd.variables // list of top level variables (name, version etc.)
jd.types // list of types
jd.methods // list of methods
jd.handlers // list of directive handlers

jd.getVariable(name) // get variable by name
jd.getType(name) // get type by name
jd.getMethod(name) // get method by name
jd.getHandler(name) // get directive handler by name

jd.putVariable(type) // put variable to context
jd.putType(type) // put type to context
jd.putMethod(method) // put method to context
jd.putHandler(handler) // put directive handler to context

Syntax

// value can be
// - "a string" (string)
// - 123 (number)
// - -3.14 (negative number)
// - typeName (type reference)
// - variableName (variable reference)

// variable
variableName = value;
variable2Name = value;

// type
typeName {
    parameterName: typeName;
    parameter2Name: typeName;
};

// type alias
typeName typeName;

// method
methodName(parameterName: typeName, parameter2Name: typeName): typeName;

// directive
@directiveName value {
    variableName = value;
    variable2Name = value;
}

Readme

Keywords

none

Package Sidebar

Install

npm i juana

Weekly Downloads

0

Version

0.1.2

License

MIT

Unpacked Size

3.64 MB

Total Files

34

Last publish

Collaborators

  • kohutd