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

@besync/graphstore-dev

v1.0.8

Published

Generate GraphQL Schema and @besync/graphstore Model from Firebase realtime database

Downloads

17

Readme

GRAPHSTORE-DEV Model Generator

This repository contains an automatic code generator. It converts a production Firebase to a GraphQL style database schema and in turn such a GraphQl schmea to typescript code that drops right into @besync/graphstore.

Non-production prototype

This is a working prototype that was corrected to work off a single production database. It will likely require some debugging and editing of the code generation to work for your database.

Example input

 "users": {
    "google-Jk0wcm5svSaBAU6Doh5UlPqBrZj1:0": {
      "email": "[email protected]",
      "profile_picture": "https://lh4.googleusercontent.com/-asdsdad/AAAAAAAAAAI/AAAAAAAAAJY/dfqq8tfiGoA/photo.jpg",
      "username": "Demo User"
    }
  }

Example generated output (GraphQL)

type User 
     @connector(byId: "(id) => getDocument('users/${id}')")
    {
        id: UserId! @primary,
        email: String!,
        profile_picture: String!,
        username: String!
        chats: [Chat] @resolver(get: "ChatsForUser(id)"),
        logs: [Log] @resolver(get: "LogsForUser(id)"),
        userPosts: [UserPost] @resolver(get: "UserPostsForUser(id)")
    }

Example generated output (TypeScript)

export class User extends Model 
{

    @primary @observable id: string;
    @observable email: string;
    @observable profile_picture: string;
    @observable username: string;
    @resolver get chats(): Chat[] { return ChatStore.getChatsForUser(this.id); };
    @resolver get logs(): Log[] { return LogStore.getLogsForUser(this.id); };
    @resolver get userPosts(): UserPost[] { return UserPostStore.getUserPostsForUser(this.id); };

    protected static Store: typeof Store = UserStore;

    constructor (defaults: {id: string, [extra: string]: any }, ...args) { super(defaults, ...args); } 

}

Command Line Usage (Firebase Json to GraphQL)

graphstore-dev firebase data/db-export.json build/schema.graphql

Command Line Usage (GraphQL to TypeScript)

graphstore-dev graphql build/schema.graphql src/model.ts

See besync\graphstore-test-mockdata package.json for an example of where this is used in an npm script.

Alternative API to execute the generator from Javascript Node.js or equivalent application

var inputfile = path.resolve(__dirname, "../data/db-export.json");
var graphQLFile = path.resolve(__dirname, "../build/schema.graphql");
var modelTSFile = path.resolve(__dirname, "../src/model.ts");

createDirectories(graphQLFile);
createDirectories(modelTSFile);
importJsonExportGraphQl(inputfile, graphQLFile);
exportModelTs(modelTSFile, importGraphQl(graphQLFile));

LICENSE

Apache 2.0