npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@graf-research/adf-core

v0.0.20

Published

<div align="center"> <a href="http://typeorm.io/"> <img src="https://adf-lang.com/logo.png" height="120"> </a> <br> <br> <a href="https://badge.fury.io/js/@graf-research%2Fadf-core"> <img src="https://badge.fury.io/js/@graf-research%2Fad

Downloads

1,187

Readme

DSL (Domain Specific Language) ADF didesain untuk mendokumentasikan sistem/program dan men-generate kode sesuai spesifikasi ADF. Kode ADF mendokumentasikan desain model data dan mekanisme komunikasi antar program dalam sebuah sistem. Lihat Spesifikasi Bahasa ADF untuk panduan menulis desain ADF.

Generator Kode

Spesifikasi ADF memiliki informasi minimal untuk desain sebuah sistem berbasis data. Informasi pada ADF dapat digunakan untuk men-generate kode program langsung/template kode program. Generator kode yang ada saat ini:

Todo List Generator Kode:

  1. Generator API Tester (seperti Swagger, Postman, Apiary, dll).
  2. HTTP Client secara umum untuk segala jenis framework frontend web.
  3. React useAPI HTTP Client, mirip poin nomor 2, namun untuk framework react dengan fitur hook.
  4. HTTP Client untuk bahasa pemrograman lain, kasus pemakaiannya untuk koneksi host-to-host.
  5. dll

Library

npm install --save @graf-research/adf-core

Fungsi

parse(uri: string)

Menerima masukan berupa path (absolute/relative) ke file *.adf atau url file ADF.

async function parse(uri: string): Promise<SAResult>

parseString(code: string)

Menerima masukan berupa kode ADF dengan format string.

async function parseString(code: string): Promise<SAResult>

Contoh Penggunaan

import { parse, SAResult } from '@graf-research/adf-core';

async function main() {
  const adf_url = 'https://gitlab.graf.run/api/v4/projects/rio%2Fblueprint-collection/repository/files/contoh-marketplace.adf/raw';
  const result: SAResult = await parse(adf_url);
  console.log(result)
}

main();

ADF Core

ADF Core berisi program parser file desain ADF yang berisi format Spesifikasi Bahasa ADF menjadi spesifikasi JSON. Proses parsing ADF terdiri dari tiga tahap:

  • Lexer
  • Parser
  • Analisis Semantik

Lexer

ADF menggunakan no-context/moo sebagai lexer. Daftar token lexer dapat dilihat di file ast/grammar/lexer.js.

Parser

ADF menggunakan grammar dan parser nearley.js. Grammar ADF dapat dilihat di file ast/grammar/adf-lang.ne. Parser ADF menghasilkan bentuk JSON sementara representasi AST (abstract syntax tree) dengan skema/jenis data berikut:

  • AST_Import
  • AST_Model
  • AST_Flow
  • AST_Schema
  • AST_API

Analisis Semantik

Data JSON hasil parser dianalisis memastikan seluruh sintaks sesuai aturan ADF. Proses analisis semantik dilakukan pada:

  • API memastikan method, path, paths param, query, headers, body, dan return value pada AST valid dan jenis data yang digunakan ada pada skema, tabel, atau enum.
  • Schema memastikan jenis data skema valid, referensi ke table, enum, atau skema lain valid.
  • Model memastikan item enum valid, kolom tabel sesuai semantik yang seharusnya.
  • Import mengimpor data dari file atau url lain.
  • Flow <pending>

Analisis semantik menghasilkan spesifikasi JSON dengan format berikut:

export interface SAResult {
  list_enum: Model.Enum[]
  list_table: Model.Table[]
  list_flow: Flow.Flow[]
  list_schema: Schema.Schema[]
  list_api: API.API[]
}

SAResult merupakan keluaran akhir dari parser (lexer, parser, semantic analysis).