Git Product home page Git Product logo

pgtyped-rescript's People

Contributors

adelsz avatar bag-man avatar bradleyayers avatar darky avatar dependabot[bot] avatar elob avatar gervinfung avatar gitter-badger avatar golergka avatar jessevelden avatar jgonera avatar joecarver avatar johanholmerin avatar johnnycrazy avatar logan12358 avatar lucas-gregoire avatar mako-taco avatar maylukas avatar mrjackdavis avatar msakrejda avatar mudrz avatar nbarnett avatar nick-keller avatar renovate-bot avatar renovate[bot] avatar robinclowers avatar snarky-puppy avatar tamlyn avatar water-a avatar zth avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pgtyped-rescript's Issues

Convenience methods

It'd be nice to generate variations of every function:

e.g.

/* @name findDataSetCaseById */
SELECT * FROM test_case where id = :id! limit 1;

could generate:

  • findDataSetCaseById- a list of results
  • findDataSetCaseByIdOne - a single result, throws an exception if there isn't exactly one element
    -findDataSetCaseByIdOneOpt - a single option of a result

genType support

There are a few low-hanging bits of fruit that would enable a first-pass at genType support!

As an example of the changes necessary, here is are the manual tweaks I made to the pgtyped-rescript artifacts https://gist.github.com/sgrove/68c85bd81f3776bfa4bf9ad9baf1bb48/revisions

  1. type aliases with @genType.opaque to hide the upstream types (pgClient, Null.t) + manual type specification for the parameters rescript-association/genType#636 and rescript-association/genType#634 (comment)
  2. No labeled arguments, since genType just outputs the wrong stuff rescript-association/genType#635

With those changes, we get this behavior in TypeScript:
Screenshot 2023-08-16 at 21 12 10

It doesn't provide an all-the-way optimal experience on the other side (e.g. pgClient isn't appropriately typed):
Screenshot 2023-08-16 at 21 12 23

But it's a minor detail compared to the experience before!

Querying for an array of jsonb generates invalid rescript

Describe the bug
Selecting a column of type jsonb[] will generate invalid rescript:

/* @name findById */
SELECT examples FROM test_case where id = :id! limit 1;

generates:

open PgTyped
type Js.Json.tArray = array<Js.Json.t>

/** 'FindById' parameters type */
type findByIdParams = {
  id: string,
}

/** 'FindById' return type */
type findByIdResult = {
  /** Examples conforming to the input schema */
  examples: Null.t<Js.Json.tArray>,
}

type Js.Json.tArray is syntactically invalid

Expected behavior
The type value is fine, so maybe just munging Js.Json.tArray to jsJsontArray would be enough?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.