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

@daotl/edgedb-generate

v0.0.7-fix.1

Published

EdgeDB code generators for TS/JavaScript

Downloads

9

Readme

@edgedb/generate: Code generation tools for EdgeDB

The @edgedb/generate package implements a set of code generation tools that are useful when developing an EdgeDB-backed applications with TypeScript/JavaScript.

View Documentation >>

Installation

If you're using Deno, you can skip this step.

Install the edgedb package.

$ npm install edgedb       # npm users
$ yarn add edgedb          # yarn users

Then install @edgedb/generate as a dev dependency.

$ npm install @edgedb/generate --save-dev      # npm users
$ yarn add @edgedb/generate --dev              # yarn users

Run a generator

Run a generator with the following command.

Node.js

$ npx @edgedb/generate <generator> [options]

Deno

$ deno run --allow-all --unstable https://deno.land/x/edgedb/generate.ts <generator> [options]

The value of <generator> should be one of the following.

  • queries: This generator scans your project for *.edgeql files and generates a file containing a strongly-typed function for each.
  • edgeql-js: This generator introspects your database schema and generates a query builder.
  • interfaces: This generator introspects your database schema and generates TypeScript interfaces for each object type.

Third-party generators

✨ If you build a code generator for EdgeDB, ping us or open a PR and we'll list it here! ✨

The edgedb package exports a set of utilities to introspect the schema and analyze queries. We use this same set of tools to implement the first-party generators.

import {createClient, $} from "edgedb";

const client = createClient();

const types = await $.introspect.types(client);
// Map<string, Type>

const queryData = await $.analyzeQuery(client, `select 2 + 2`);
// {args: string; result: string; ...}

Contributing

If you want to implement a code generator, please open an issue first. This package only contains first-party generators with widespread appeal. From the root directory:

yarn
yarn workspaces run build  # build all packages

Navigate into packages/generate:

Build @edgedb/generate

yarn build

Build without typechecking (uses esbuild):

yarn build:fast

Run a generator:

npx @edgedb/generate edgeql-js    # query builder
npx @edgedb/generate queries      # query files

Execute playground.ts (uses tsx). Useful for testing things quickly in development:

yarn play

⚠️ All imports from "edgedb" resolve to the local build version of the driver in packages/driver/dist. This imports the built library, not the so you need to re-run yarn workspace edgedb build for changes to be reflected in your playground code. Run yarn dev watcher inside packages/driver to rebuild the project anytime you make a change.

Run commands in watch mode. Useful when in development. The following command rebuilds the package and executes the playground whenever a file change is detected.

yarn watch 'yarn build:fast && yarn play`

Run tests. All test:* scripts are self-contained, in that they execute any prerequisite generation steps before running any tests.

yarn test         # runs all tests (listed below)
yarn test:ts
yarn test:esm
yarn test:cjs
yarn test:mts
yarn test:deno