Skip to content

ONLang (Object Notation Language) is a markup-style programming language designed to define and interact with objects in a user-friendly and intuitive way. It is built on top of TypeScript, making it easy to use and extend.

License

Notifications You must be signed in to change notification settings

onlang-org/onlang

Repository files navigation

onlang_shorthand

ONLang (Object Notation Language) is a markup-style programming language designed to define and interact with objects in a user-friendly and intuitive way. It is built on top of TypeScript, making it easy to use and extend.

Built on top of TypeScript and NestJS

Information

JS.org npm version npm downloads GitHub license GitHub forks

Project Health

CodeQL ESLint Node.js Package GitHub issues

Note ONLang works with any JSON schema. Currently it offers a helper package to fetch and validate JSON schemas. See onst for more information. This is the default registry for ONLang schemas with examples and documentation. More details can be found in the README.

Table of Contents

Description

NOTE: This Language is in active development. Please read current stage of development here

Features

  • Markup Syntax: Intuitive and human-readable syntax for defining objects.
  • Dynamic Aspect Resolution: ONLang understands and adapts to the structure of various systems, making it versatile for integrating with different APIs and services.

Installation

To install ONLang, run the following command:

npm install -g on-lang

This will install the ONLang package globally.

Usage

ONLang Script file (.onl)

!onlang
Survey:
    SurveyOptions:
        Language: "en"
        SurveyTitle: "User Satisfaction Survey"
    Block:
        Type: "Standard"
        Questions:
          QID1:
            Type: "MultipleChoice"
            Question: "How satisfied are you with our service?"
            Options: ["Very Satisfied", "Satisfied", "Neutral", "Dissatisfied", "Very Dissatisfied"]
          QID2:
            Type: "Text"
            Question: "Any additional comments or suggestions?"

NOTE: The !onlang tag is required at the beginning of dynamic objects that need to be resolved and compiled at runtime. The validation is performed at compile time by the ONLang compiler using Validation Functions generated for schemas available at runtime.

ONLang CLI

onlang [files(optional)]

NOTE: You need node.js installed to use ONLang. See here for installation instructions.

files is optional. Without it, ONLang will read and compile all files in the current directory taking the schema path from the onlang.schemaPath config in .env file.

Configuring .env file

onlang.schemaPath=src/schemas

Examples

Schema Validation

onlang validate test_schema.json test_schema2.json

Script Parsing

onlang parse script.onl

Command Options

  • -h, --help: Display this help message
  • -v, --version: Display the current version
  • parse: Parse ONLang script
  • validate: Validate JSON schema for ONLang script

Stage of Development

[DONE] Step 1: Read and Compile

  • JSON Schema Conversion:

ONLang dynamically generates JSON schemas for objects from external systems (Qualtrics, Salesforce, etc.). These JSON schemas are validated using Ajv here and are used to generate Validation Functions.

[ONGOING] Step 2: ONLang Scripting:

Users create ONLang scripts that involve the creation of objects (e.g., Qualtrics survey) using the YAML syntax and onlang schema.

Step 3: Dynamic Aspect Resolution:

The ONLang compiler utilizes dynamic aspect resolution to understand and adapt to the schema for objects from external systems without explicit user-provided JSON schemas.

Step 4: Validation in ONLang Compiler:

The ONLang compiler validates ONLang scripts: Ensures that objects created conform to the dynamically resolved schema. Verifies the syntax and hierarchy of the ONLang script.

Step 5: Transpilation and Execution:

If the validation is successful, the ONLang script is transpiled into a JavaScript file. The transpiled JavaScript file is then executed.

Contributing

If you'd like to contribute, please see CONTRIBUTING.md See code of conduct here

About

ONLang (Object Notation Language) is a markup-style programming language designed to define and interact with objects in a user-friendly and intuitive way. It is built on top of TypeScript, making it easy to use and extend.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks