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

@cedjj/magnus-metadata

v0.0.9-dev

Published

BLA BLAB

Downloads

2

Readme

Magnus Metadata

This library aim to provide a set of annotations/decorators that will expose meta-data to the different elements of the platform(front/back/shared).

Annotations/decoators

  • Entity : a set of annotations to define the entity metadata
    • Attributes
    • Reference
    • hooks
  • Modules
  • Static Values

Handler And registry

Registry to store all the metadata Handler to read the metadata for using inside you app. must copy the metadata first in a local registry, Altough it's already taken care of inside magnnus-back and magnus-front

Usage

Entity

To Define an Entity, annotate it this way :

@Entity({
  name: "DummyEntity",
  displayName: "DummyEntity",
  model: "DummyEntity",
  endPoint: "dummyendpoint",
  embedded: false
})
  • name: name of the entity this will be its code
  • displayName : Label to be displayed, In the future this will be the i18n key
  • model : Persistence model name
  • endPoint : url endpoints to access this ressource
  • embedded : if this is true the generated schema will be inside the entity referencing this one

Attribute

Simple (string)

 @Attribute({ magnus_key:'DummyEntity:code', displayName: 'CODE', type: TypeField.SimpleField })
  code: string;
  • magnus_key : [entityName]:[fieldName]
  • displayName : Label to be displayed, In the future this will be the i18n key
  • type: the type of field
    • SimpleField
    • NumberField
    • DateField
    • BooleanField
    • ListField[TO BE TESTED]

Reference

@Reference({
magnus_key: 'DummyEntity:dummyRef'
    displayName: "DummyEntity",
    targetModel: "DummyEntity",
    fieldLabel:"identifiant",
    type: TypeReference.ONE_TO_ONE,
    targetType: DoubleDummyEntity
  })
  dummyRef: DoubleDummyEntity;
  • magnus_key : [entityName]:[fieldName]
  • displayName : Label to be displayed, In the future this will be the i18n key
  • targetModel : target persistence model
  • type: the type of Reference
    • ONE_TO_ONE
    • ONE_TO_MANY
    • MANY_TO_ONE
    • MANY_TO_MANY
  • targetType : class of target entity

Full example


import {Entity, Attribute, Reference, TypeField, TypeReference, IModel} from 'magnus-metadata/magnus_metadata';

@Entity({
  name: "MgEntryPoint",
  displayName: "MgEntryPoint",
  model: "MgEntryPoint",
  endPoint: "entrypoints",
  embedded: true
})
export class MgEntryPoint extends IModel {

  @Attribute({magnus_key :"MgModule:path", displayName: 'MgModule:path', type: TypeField.SimpleField })
  path: string;

  @Attribute({magnus_key :"MgModule:as", displayName: 'MgModule:as', type: TypeField.SimpleField })
  as: string;

  @Attribute({magnus_key :"MgModule:component", displayName: 'MgModule:component', type: TypeField.SimpleField })
  component: string;

  @Attribute({magnus_key :"MgModule:package_path", displayName: 'MgModule:package_path', type: TypeField.SimpleField })
  package_path: string;
}


@Entity({
  name: "MgModule",
  displayName: "MgModule",
  model: "MgModule",
  endPoint: "modules"
})
export class MgModule extends IModel {

  @Attribute({magnus_key :"MgModule:name", displayName: 'MgModule:name', type: TypeField.SimpleField })
  name: string;
  @Attribute({magnus_key :"MgModule:displayName", displayName: 'MgModule:displayName', type: TypeField.SimpleField })
  displayName: string;

  @Reference({magnus_key :"MgModule:entryPoint",
      displayName: "MgEntryPoint",
      targetModel: "MgEntryPoint",
      fieldLabel:"path",
      type: TypeReference.ONE_TO_ONE,
      targetType:MgEntryPoint
    })
  entryPoint:MgEntryPoint;

  @Attribute({magnus_key :"MgModule:homePage", displayName: 'MgModule:homePage', type: TypeField.SimpleField })
  homePage: string;
}


@Entity({
  name: "MgFeature",
  displayName: "MgFeature",
  model: "MgFeature",
  endPoint: "features"
})
export class MgFeature extends IModel {

  @Attribute({magnus_key :"MgFeature:name", displayName: 'MgFeature:name', type: TypeField.SimpleField })
  name: string;

  @Attribute({magnus_key :"MgFeature:displayName", displayName: 'MgFeature:displayName', type: TypeField.SimpleField })
  displayName: string;

  @Reference({magnus_key :"MgFeature:childs",
     displayName: "MgModule",
     targetModel: "MgModule",
     fieldLabel:"displayName",
     type: TypeReference.MANY_TO_ONE,
     targetType:MgModule
   })
  childs:Array<MgModule>;

}

@Entity({
  name: "MgApp",
  displayName: "MgApp",
  model: "MgApp",
  endPoint: "apps"
})
export class MgApp extends IModel {

  @Attribute({magnus_key :"MgApp:name", displayName: 'MgApp:name', type: TypeField.SimpleField })
  name: string;


  @Reference({magnus_key :"MgApp:features",
    displayName: "MgFeature",
    targetModel: "MgFeature",
    type: TypeReference.ONE_TO_MANY,
    targetType:MgFeature
  })
  features: Array<MgFeature>;
}



### TODO
- add validation doc