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

@azimutt/serde-aml

v0.1.1

Published

Parse and Generate AML.

Downloads

7

Readme

@azimutt/serde-aml

Work In Progress

This is a module to validate, parse and generate AML. And also provide syntax highlighter for it.

Read the full AML documentation.

AML syntax ideas:

# define a global namespace for the definitions
# each top level is optional (valid ones: "schema", "catalog.schema", "database.catalog.schema")
# it can be overriden by each declaration if specified, ex: pg.sales.public.usrers table will not be in database.catalog.schema namespace
namespace database.catalog.schema

# properties are the default ones but can be changed in each layout
users {color: red, tags: [auth, common]}
  id uuid pk {autoincrement: true}
  name varchar
  email varchar unique
  description text nullable
  created_at timestamp=`now()`

roles
  id uuid pk
  name varchar unique
  priority int=0

user_roles
  user_id uuid pk
  role_id uuid pk

user_roles_ext
  user_id uuid pk
  role_id uuid pk
  details json

events
  id uuid pk
  item_kind varchar
  item_id uuid

books
  id uuid pk
  title varchar
  authors uuid[] >- users.id

book_details
  book_id uuid pk
  details json
    isbn varchar
    price json
      currency varchar
      value float8

# basic relation, with properties
rel user_roles(user_id) >- users(id) {delete: cascade, update: no action}

# composite relation
rel user_roles_ext(user_id, role_id) >- user_roles(user_id, role_id)

# polymorphic relation
rel events(item_id) >item_kind=User- users(id)
rel events(item_id) -item_kind=Role> roles(id)

# many-to-many relation
rel books(id) <> users(id)

# one-to-one relation
rel book_details(book_id) -- books(id)

bugs |||
  This is a multiline note fot the table
  It can be used to describe the table or the relation
|||
  id uuid |||
    a multiline note for a column
  |||
  name varchar |||
    a multiline note for a column
  |||
  status bug_status |||
    💸 1 = processing, 
    ✔️ 2 = shipped, 
    ❌ 3 = cancelled,
    😔 4 = refunded
  |||

type bug_status enum(new, in progress, done) {...props} | note # comment

Relationships:

  • one-to-many: normal foreign keys: rel user_roles.user_id >- users.id or inline in column: user_id >- users.id
  • many-to-one: reverse foreign keys: rel users.id -< user_roles.user_id but not inline in column => useless, not implemented
  • many-to-many: native in db, junction table or array column: rel books.id >< users.id, authors uuid[] >< users.id or with junction table
  • one-to-one: foreign key with unique constraint fk book_details.book_id -- books.id or inline in column: book_id unique -- books.id
  • zero-to-many: foreign key from nullable column one-to-one and many-to-many relations can be "manually" specified without the schema constraints to be present (unique or junction table) Interesting discussion: https://community.dbdiagram.io/t/tutorial-many-to-many-relationships/412

Other concepts:

  • multiline notes: |||, remove the leading spaces of the first line, for all the lines
  • custom types: type $name $definition, definition is optional and can be parsed more...
    • type bug_status enum(new, in progress, done)
    • type bug_value range(subtype = float8, subtype_diff = float8mi)
    • type address {number: int, street: varchar}
  • if a fk column don't have a type, it takes the type of the referenced column

Publish

  • update package.json version
  • update lib versions (npm run update + manual) & run npm install
  • test with npm run dry-publish and check azimutt-serde-aml-x.y.z.tgz content
  • launch npm publish --access public

View it on npm.