profile
viewpoint

adelsz/pgtyped 183

PgTyped - Typesafe SQL in TypeScript

adelsz/inquirer-fuzzy-path 36

Fuzzy file/directory search and select prompt for Inquirer.js

adelsz/graphql-deno 5

GraphQL-JS ported to Deno

adelsz/mnotify 1

Minimal D-Bus notification daemon

adelsz/csv-edit 0

Simple CSV editor in ClojureScript/React

adelsz/deno_website2 0

deno.land website

adelsz/graphql-code-generator 0

GraphQL code generator with flexible support for custom plugins and templates

adelsz/Inquirer.js 0

A collection of common interactive command line user interfaces.

adelsz/join-monster-graphql-tools-adapter 0

Use Join Monster to fetch your data with Apollo Server.

issue closedadelsz/pgtyped

Order seems to matter in insert into

If inserting a row with a subset of the columns if the order of my subset does not match the declared order of the table columns.

For example if I insert a row with just four columns out of many set in the same order as they were declared in the table the query works as expected:

const insertParamUpdate = sql<IInsertParamUpdateQuery>`
    insert into data.event_log
    (_chainid, _height, _txindex, storage_address  )
    values
    $$params(_chainid, _height, _txindex,  storage_address);
`;

But if I swap storage_address in the column list nad the values object:

const insertParamUpdate = sql<IInsertParamUpdateQuery>`
    insert into data.event_log
    (_chainid, storage_address, _height, _txindex )
    values
    $$params(_chainid, storage_address _height, _txindex);
`;

This fails with a invalid input for type bigint. This makes it seem like storage_address is being provided for a _height value.

It's late now but a test case shouldn't be too hard if this is a general bug.

closed time in 3 days

silasdavis

issue commentadelsz/pgtyped

Order seems to matter in insert into

Thanks for creating a test case! Fixed in v0.7.2.

silasdavis

comment created time in 3 days

release adelsz/pgtyped

v0.7.2

released time in 3 days

created tagadelsz/pgtyped

tagv0.7.2

PgTyped - Typesafe SQL in TypeScript

created time in 3 days

push eventadelsz/pgtyped

Adel

commit sha 12f658f8cf16e7857547d0e483d5af8afe2243c9

v0.7.2

view details

push time in 3 days

push eventadelsz/pgtyped

Silas Davis

commit sha 2b5705550d8b992db10022fd8da250c70d9a5d68

Fix another unhandled exception and provide early fatal failure via (#78) fail-on-error Signed-off-by: Silas Davis <silas@monax.io>

view details

push time in 3 days

PR merged adelsz/pgtyped

Fix another unhandled exception and provide early fatal failure via

fail-on-error

Signed-off-by: Silas Davis silas@monax.io

+31 -14

0 comment

4 changed files

silasdavis

pr closed time in 3 days

push eventadelsz/pgtyped

Silas Davis

commit sha 5027ebd7b894ecc57a6bbddbf5796ea50302a94a

Add test case for order-dependence of parameters Signed-off-by: Silas Davis <silas@monax.io>

view details

Adel

commit sha aae243d4eca5a7c74edfcd69917fc25076f24515

Fix array spread order dependence bug Fix array spread order dependence bug in TS based queries

view details

Adel Salakh

commit sha 0ca761091980c610ff7765a49e3c156647a722b8

Merge pull request #80 from silasdavis/order-dependence Add test case for order-dependence of parameters

view details

push time in 3 days

PR merged adelsz/pgtyped

Add test case for order-dependence of parameters

Test case for #79

+48 -4

0 comment

5 changed files

silasdavis

pr closed time in 3 days

push eventsilasdavis/pgtyped

Adel

commit sha aae243d4eca5a7c74edfcd69917fc25076f24515

Fix array spread order dependence bug Fix array spread order dependence bug in TS based queries

view details

push time in 3 days

push eventsilasdavis/pgtyped

Adel

commit sha 786d89c48e7ca2b6c57b413cd39a2b107662905b

Fix array spread order dependence bug Fix array spread order dependence bug in TS based queries

view details

push time in 3 days

issue commentadelsz/graphql-deno

graphql not working as expected

Thanks for reporting! This does look like a deno bug. I have added a workaround for it, so it should work now. Make sure to clean your Deno cache directory before retrying. To find the cache dir: deno info | grep 'Remote modules cache:'

WaseemRakab

comment created time in 4 days

issue closedadelsz/graphql-deno

graphql not working as expected

with deno version 1.0.1, graphql no longer works. this errors occurred ` error: TS2305 [ERROR]: Module '"https://raw.githubusercontent.com/adelsz/graphql-deno/v15.0.0/mod"' has no exported member 'graphql'. graphql, ~~~~~~~ at file:///C:/Users/sc12/Downloads/AngularProjects/Deno/deps/deps.ts:7:5

TS2305 [ERROR]: Module '"https://raw.githubusercontent.com/adelsz/graphql-deno/v15.0.0/mod"' has no exported member 'GraphQLSchema'. GraphQLSchema, ~~~~~~~~~~~~~ at file:///C:/Users/***/Deno/deps/deps.ts:8:5

TS2305 [ERROR]: Module '"https://raw.githubusercontent.com/adelsz/graphql-deno/v15.0.0/mod"' has no exported member 'GraphQLObjectType'. GraphQLObjectType, ~~~~~~~~~~~~~~~~~ at file:///C:/Users/***/Deno/deps/deps.ts:9:5

TS2305 [ERROR]: Module '"https://raw.githubusercontent.com/adelsz/graphql-deno/v15.0.0/mod"' has no exported member 'GraphQLString'. GraphQLString, ~~~~~~~~~~~~~ at file:///C:/Users/***/Deno/deps/deps.ts:10:5

Found 4 errors. `

closed time in 4 days

WaseemRakab

push eventadelsz/graphql-deno

Adel

commit sha 2ad661b279185258231e6921f2f8373b3ff4b871

Fix bindings for Deno 1.0.1

view details

push time in 4 days

push eventadelsz/deno_website2

Adel Salakh

commit sha 388c2ee5b624ec661e0cbff1a3972287ef1613f6

Update database.json Adds a port of the reference GraphQL standard implementation to Deno https://github.com/adelsz/graphql-deno

view details

push time in 5 days

PR opened denoland/deno_website2

Update database.json

Adds a port of the reference GraphQL standard implementation to Deno https://github.com/adelsz/graphql-deno

+6 -0

0 comment

1 changed file

pr created time in 5 days

push eventadelsz/deno_website2

Adel Salakh

commit sha 3818c783419ee3e96cee113103a97f4b5cf4fbbc

Update database.json Adds a port of the reference GraphQL standard implementation to Deno https://github.com/adelsz/graphql-deno

view details

push time in 5 days

push eventadelsz/graphql-deno

Adel

commit sha 3ee37f93d738d9b7dada09d298d78b671e9b5659

Update readme example

view details

push time in 5 days

created tagadelsz/graphql-deno

tagv15.0.0

GraphQL-JS ported to Deno

created time in 5 days

push eventadelsz/graphql-deno

Adel

commit sha 67092b30354b65b70223c3933861e80266624625

Add test to readme

view details

push time in 5 days

push eventadelsz/graphql-deno

Adel

commit sha 9b0e47d8d7edf88fbab0a14cf41d3f0a50c6c37e

Add graphql-js license

view details

Adel

commit sha 4e20e0a9a8434913687e33e064a4092cc3c3204e

Add test to readme

view details

push time in 5 days

push eventadelsz/graphql-deno

Adel Salakh

commit sha 425efe87a4aab181a808673b0dbe07ef4fefb56e

Update README

view details

push time in 5 days

create barnchadelsz/graphql-deno

branch : master

created branch time in 5 days

created repositoryadelsz/graphql-deno

GraphQL-JS ported to Deno

created time in 5 days

issue commentdenoland/deno_website2

Add module owner to deno.land/x URLs

@alessandrorivero I agree, but #406 is closed now.

The whole database.json + PR mechanism definitely won't scale well, but might be working OK for the time being as ry mentioned.

This ticket proposes an immediate fix to name squatting and doesn't require much effort to implement. I have changed the wording to fix some of the problems to avoid confusion.

adelsz

comment created time in 5 days

issue openeddenoland/deno_website2

Add module owner to deno.land/x URLs

Having all module names in the global namespace leads to name squatting. This is a proposal to add package owner name to deno.land/x URLs:

- https://deno.land/x/MODULE_NAME@BRANCH/SCRIPT.ts
+ https://deno.land/x/OWNER/MODULE_NAME@BRANCH/SCRIPT.ts

This should solve some of problems raised in: #547, #548, #406

created time in 5 days

startedwagoodman/dive

started time in 6 days

issue commentadelsz/pgtyped

Order seems to matter in insert into

Hm, this is interesting. I can also see a comma missing on line 5 in the second code block, is that a typo?

silasdavis

comment created time in 7 days

Pull request review commentadelsz/pgtyped

Fix another unhandled exception and provide early fatal failure via

 class FileProcessor {     this.processQueue();   }; +  private onFileProcessingError = (err: any) => {+    console.log(`Error processing file: ${err.stack || JSON.stringify(err)}`);

Interesting, ServerError means that this error was thrown by Postgres server. Looks like there is a syntax problem with the query (syntax error at or near \). Do you have a reproducible example for this query? You can also see more detailed logs by setting env DEBUG=* when running PgTyped.

silasdavis

comment created time in 7 days

issue closedadelsz/pgtyped

Release 0.7.1

I see the tag exists with the enum changes, did you mean to release it or is just pending?

closed time in 7 days

silasdavis

issue commentadelsz/pgtyped

Release 0.7.1

Yes, by default lerna bumps and publishes only changed packages. query didn't change in that release.

silasdavis

comment created time in 7 days

push eventadelsz/pgtyped

Adel Salakh

commit sha 9d8cb688218869051cfd8616b877e70c380f0e04

Reconfigure Renovate: group deps together (#76)

view details

push time in 8 days

push eventadelsz/pgtyped

renovate[bot]

commit sha c560c87ce1146b97af9ac067460f94aa34989c1f

Update dependency @types/jest to v25.2.2 (#72) Co-authored-by: Renovate Bot <bot@renovateapp.com>

view details

push time in 8 days

PR merged adelsz/pgtyped

Update dependency @types/jest to v25.2.2

This PR contains the following updates:

Package Type Update Change
@types/jest devDependencies patch 25.2.1 -> 25.2.2

Renovate configuration

:date: Schedule: At any time (no schedule defined).

:vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

:recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

:no_bell: Ignore: Close this PR and you won't be reminded about this update again.


  • [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

This PR has been generated by WhiteSource Renovate. View repository job log here.

+15 -15

0 comment

2 changed files

renovate[bot]

pr closed time in 8 days

push eventadelsz/pgtyped

renovate[bot]

commit sha b81d7017b36181e00d39837727b44048546d1414

Update dependency lerna to v3.21.0 (#70) Co-authored-by: Renovate Bot <bot@renovateapp.com>

view details

push time in 8 days

PR merged adelsz/pgtyped

Update dependency lerna to v3.21.0

This PR contains the following updates:

Package Type Update Change
lerna devDependencies minor 3.20.2 -> 3.21.0

Release Notes

<details> <summary>lerna/lerna</summary>

v3.21.0

Compare Source

Bug Fixes
  • publish: Canary releases without previous tags should not explode (c9eb590)
Features
  • project: Add getPackagesSync() export (068bdd7)
  • version: Ignore private packages completely with --no-private (a9b9f97)

3.20.2 (2020-01-02)

Bug Fixes
  • version: Loosen --atomic fallback to catch incompatible CLI versions (6f0e2bb), closes #​2400

3.20.1 (2019-12-29)

Bug Fixes
  • version: Support git clients that do not support git push --atomic (2b9b210)

</details>


Renovate configuration

:date: Schedule: At any time (no schedule defined).

:vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

:recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

:no_bell: Ignore: Close this PR and you won't be reminded about this update again.


  • [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

This PR has been generated by WhiteSource Renovate. View repository job log here.

+561 -265

0 comment

2 changed files

renovate[bot]

pr closed time in 8 days

PR opened adelsz/pgtyped

Reconfigure Renovate: group deps together
+11 -3

0 comment

2 changed files

pr created time in 8 days

create barnchadelsz/pgtyped

branch : group-renovate-deps

created branch time in 8 days

push eventadelsz/pgtyped

renovate[bot]

commit sha c6b3b53a2680feac9780d4dfb5697149c19c40dd

Update dependency ts-jest to v26 (#74) Co-authored-by: Renovate Bot <bot@renovateapp.com>

view details

push time in 8 days

PR merged adelsz/pgtyped

Update dependency ts-jest to v26

This PR contains the following updates:

Package Type Update Change
ts-jest (source) devDependencies major 25.5.1 -> 26.0.0

Release Notes

<details> <summary>kulshekhar/ts-jest</summary>

v26.0.0

Compare Source

Bug Fixes
  • compiler: return undefined for getScriptVersion when a file doesn't exist in memory cache (#​1641) (6851b8e)
Features
BREAKING CHANGES
  • Requires a minimum of TypeScript v3.8
  • Drop support for Node 8

25.5.1 (2020-05-09)

Bug Fixes
  • compiler: don't resolve files from build folder for projectReferences (#​1614) (74b92d3)
  • config: don't set include value of tsconfig to empty array (#​1606) (8a29aaa)

</details>


Renovate configuration

:date: Schedule: At any time (no schedule defined).

:vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

:recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

:no_bell: Ignore: Close this PR and you won't be reminded about this update again.


  • [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

This PR has been generated by WhiteSource Renovate. View repository job log here.

+15 -9

0 comment

2 changed files

renovate[bot]

pr closed time in 8 days

push eventadelsz/pgtyped

renovate[bot]

commit sha 84bb0c6c6a5314acc0f0d2c82036a32a55880169

Update dependency pg to v8.2.1 (#71) Co-authored-by: Renovate Bot <bot@renovateapp.com>

view details

push time in 8 days

PR merged adelsz/pgtyped

Update dependency pg to v8.2.1

This PR contains the following updates:

Package Type Update Change
pg dependencies minor 8.1.0 -> 8.2.1

Release Notes

<details> <summary>brianc/node-postgres</summary>

v8.2.1

Compare Source

v8.2.0

Compare Source

  • Switch internal protocol parser & serializer to pg-protocol. The change is backwards compatible but results in a significant performance improvement across the board, with some queries as much as 50% faster. This is the first work to land in an on-going performance improvment initiative I'm working on. Stay tuned as things are set to get much faster still! :rocket:

</details>


Renovate configuration

:date: Schedule: At any time (no schedule defined).

:vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

:recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

:no_bell: Ignore: Close this PR and you won't be reminded about this update again.


  • [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

This PR has been generated by WhiteSource Renovate. View repository job log here.

+16 -16

0 comment

2 changed files

renovate[bot]

pr closed time in 8 days

push eventadelsz/pgtyped

renovate[bot]

commit sha b2c8acf0ba8daa5d2f8d6092531cfe9db98434b0

Update dependency @types/node to v13.13.6 (#69) Co-authored-by: Renovate Bot <bot@renovateapp.com>

view details

push time in 8 days

PR merged adelsz/pgtyped

Update dependency @types/node to v13.13.6

This PR contains the following updates:

Package Type Update Change
@types/node devDependencies patch 13.13.5 -> 13.13.6

Renovate configuration

:date: Schedule: At any time (no schedule defined).

:vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

:recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

:no_bell: Ignore: Close this PR and you won't be reminded about this update again.


  • [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

This PR has been generated by WhiteSource Renovate. View repository job log here.

+4 -4

0 comment

2 changed files

renovate[bot]

pr closed time in 8 days

issue commentadelsz/pgtyped

Union types for enums

Hm, in example/index.ts we use type: 'reminder' and TS is able to infer it correctly as const. It looks like by default TS infers a string as a const string literal, unless it is explicitly casted as string (like in the stackoverflow example you posted). It is a bit unergonomic, but is a reasonable requirement by the typechecker.

The double export approach proposed does look good, I would only suggest to change it to:

// generated only if enum labels are valid TS key names
// if generation not possible emit a console warning
export const enum ActionRepetitionValue {
  ONCE = 'ONCE',
  EVERY = 'EVERY',
};

// always generated
export type ActionRepetition = 'ONCE' | 'EVERY';

It might not always be possible to create the ActionRepetitionValue enum because postgres supports unicode and whitespace as enum labels. I would also say it is safe to pascal case (haha, here I go again) the exported type/enum names. What do you think?

silasdavis

comment created time in 8 days

issue commentadelsz/pgtyped

Release 0.7.1

Isn't it published? v0.7.1 is on NPM.

silasdavis

comment created time in 8 days

issue commentadelsz/pgtyped

Usage with concatenated query

Unfortunately, PgTyped doesn't not support query concatenation. You can still achieve the logic you describe in PgTyped and SQL using boolean ops:

SELECT * FROM foo WHERE bar = true AND (:baz != true OR baz = true);
moltar

comment created time in 11 days

startedbuildondata/deno-postgres

started time in 12 days

issue closedadelsz/pgtyped

Infer field names for object pick

When you have a long list of columns for example in an INSERT INTO query you end up having to write down the same long list twice. Once in the parameter pick expansion and once in the query. It would be nice to have a parameter expansion that expands both the values and the keys of an object. Something like:

/*
  @name insertUsers
  @param users -> ((name, age)...)
*/
INSERT INTO users ::users VALUES :users RETURNING id;

Possible syntax for the keys: ::users, :keyof:users, :users.keys, :users:keys, would any of these be ambiguous?

closed time in 12 days

silasdavis

created tagadelsz/pgtyped

tagv0.7.1

PgTyped - Typesafe SQL in TypeScript

created time in 13 days

push eventadelsz/pgtyped

Adel

commit sha d16269695d8d4da7e9cb8df229eba142d7200ba8

Update docs

view details

Adel

commit sha e2c261e96e736042b9dd26988954ba43012ee059

v0.7.1

view details

push time in 13 days

push eventadelsz/pgtyped

renovate[bot]

commit sha fa827d0a6715b0e5e5a017a6f9adb54b78747a69

Pin dependency ts-node to 8.10.1 (#67) Co-authored-by: Renovate Bot <bot@renovateapp.com>

view details

push time in 13 days

PR merged adelsz/pgtyped

Pin dependency ts-node to 8.10.1

This PR contains the following updates:

Package Type Update Change
ts-node devDependencies pin ^8.10.1 -> 8.10.1

:pushpin: Important: Renovate will wait until you have merged this Pin PR before creating any upgrade PRs for the affected packages. Add the preset :preserveSemverRanges your config if you instead don't wish to pin dependencies.


Renovate configuration

:date: Schedule: At any time (no schedule defined).

:vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

:recycle: Rebasing: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

:ghost: Immortal: This PR will be recreated if closed unmerged. Get config help if that's undesired.


  • [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

This PR has been generated by WhiteSource Renovate. View repository job log here.

+2 -406

0 comment

3 changed files

renovate[bot]

pr closed time in 13 days

push eventadelsz/pgtyped

Silas Davis

commit sha eb931d510d4324a33fb296d5769f7ab9b84e6d75

Use unions to represent Postgres enum types (#66) This provides assignability between enum-mapped types from different query files where Typescript enums would be incompatible. Also harness up packages/example as a form of integration/smoke test in CI. Signed-off-by: Silas Davis <silas@monax.io>

view details

push time in 13 days

PR merged adelsz/pgtyped

Use unions to represent Postgres enum types

This provides assignability between enum-mapped types from different query files where Typescript enums would be incompatible.

Also harness up pacakges/example as a form of integration/smoke test in CI.

fixes #65

+186 -48

0 comment

13 changed files

silasdavis

pr closed time in 13 days

issue closedadelsz/pgtyped

Union types for enums

Slight buyers remorse from me (shame I didn't think of this a bit earlier!): an issue with using Typescript enums for database enums is that the types we generate in different files are incompatible. That is, Typescript considers them to be different types when in fact they represent the same underlying type.

This ends up feeling quite clumsy if you are passing otherwise compatible objects around because you end up having to convert enum types; payloadType as string as PayloadTypeFromQuery2.

We could instead use unions, so:

export const enum PayloadType {
  Message = 'Message',
  Dynamite = 'Dynamite',
}

becomes:

export type PayloadType = 'Message' | 'Dynamite';

This means that we would get type-safety on enums and type arguments referencing the same database enum would be compatible.

We would loose the runtime abilities of a enum doing this though. Some thoughts on options:

  1. Switch entirely to unions
  2. Generate string enums for each type but make the parameters/returns be of union type
  3. Attempt to 'globalise' enums across generation of different files sharing a enum so that the enum definition is hoisted to some location where it can be imported by all queries that use that enum

I am leaning towards 1 being a better default. We can also give an option to generate enums (but maybe we should favour simplicity and drop support for now). It maintains generated file locality and mostly 'just works'. If someone needs a runtime enum or prefers the enum syntax (which does feel clearer and more conventional) they can always create one.

2 is an attempt at the best of both worlds, but it feels a bit weird generating enums that we don't actually use directly, it won't be obvious that you can use them, and you'll loose editor/IDE support.

3 might be cleanest for a codebase but feels like scope creep and without knowing/assuming a lot more about a project structure would be hard to do.

closed time in 13 days

silasdavis

Pull request review commentadelsz/pgtyped

Use unions to represent Postgres enum types

 name: CI on: [push, pull_request]  jobs:-  build:+  test:     runs-on: ubuntu-latest     steps:       - uses: actions/checkout@v1-      - name: npm ci-        run: npm ci+      - run: npm ci       - name: Bootstrap packages         run: npx lerna bootstrap && npm run build       - name: Run tests         run: npm test++  test_integration:+    runs-on: ubuntu-latest+    steps:+      - uses: actions/checkout@v1+      - run: npm ci+      - name: Bootstrap packages+        run: npx lerna bootstrap && npm run build+      - name: Run integration tests+        run: npm test:integration
        run: npm run test:integration

Looks like CI is failing because of this

silasdavis

comment created time in 13 days

Pull request review commentadelsz/pgtyped

Use unions to represent Postgres enum types

+#!/bin/sh++RETRIES=${RETRIES:-15}++err_file=$(mktemp)++echo "Checking postgres is up..."+until psql "postgres" -c "select 1" > /dev/null 2> "$err_file" || [ "$RETRIES" -eq 0 ]; do

Might be better to use pg_isready, which can check for the DB to be created

silasdavis

comment created time in 13 days

issue commentadelsz/pgtyped

Union types for enums

Right, I missed that too. I think the correct solution here is to switch entirely to literal string unions. This will also allow us to handle rare postgres enums that contain spaces or unicode.

silasdavis

comment created time in 13 days

push eventadelsz/pgtyped

Adel Salakh

commit sha d99453afbc80844bf538ebd917bdbfa025dbcc53

Update README

view details

push time in 13 days

push eventadelsz/pgtyped

Adel Salakh

commit sha ae3c0defac4743435a847f49f91ed0ac0650e351

Update README

view details

push time in 13 days

issue commentporsager/postgres

TypeScript types for returned values

@bfelbo @JAForbes You might want to checkout PgTyped, which supports generating strictly typed TS code for SQL queries of any complexity. It also supports two usage modes: SQL queries can be defined directly in TS files using an sql template literal or in .sql files.

bfelbo

comment created time in 14 days

pull request commentadelsz/pgtyped

Implement support for Postgres enums

Released in v0.7.0 :)

silasdavis

comment created time in 14 days

release adelsz/pgtyped

v0.7.0

released time in 14 days

push eventadelsz/pgtyped

Adel

commit sha 66a04239e5a22fc6456713b62603aef5cbe564cf

v0.7.0

view details

push time in 14 days

created tagadelsz/pgtyped

tagv0.7.0

PgTyped - Typesafe SQL in TypeScript

created time in 14 days

push eventadelsz/pgtyped

Silas Davis

commit sha 5b8d3e55f67b17a255b7ff0ea24b1502e3c65636

Emit type declarations for Typescript too (#64) Accidentally forgot to pass types. Remove default. Signed-off-by: Silas Davis <silas@monax.io>

view details

push time in 14 days

PR merged adelsz/pgtyped

Emit type declarations for Typescript too (oops)

Accidentally forgot to pass types to TS generation.

Removed default parameter to avoid this happening and run generator tests against both generations regimes systematically.

+108 -163

1 comment

3 changed files

silasdavis

pr closed time in 14 days

pull request commentadelsz/pgtyped

Emit type declarations for Typescript too (oops)

Thanks! One more reminder to add integration testing.

silasdavis

comment created time in 14 days

push eventadelsz/pgtyped

renovate[bot]

commit sha ca53a62752cab99ab591f8aacbc73692acf7b8c3

Update dependency ts-jest to v25.5.1 (#63) Co-authored-by: Renovate Bot <bot@renovateapp.com>

view details

push time in 16 days

PR merged adelsz/pgtyped

Update dependency ts-jest to v25.5.1

This PR contains the following updates:

Package Type Update Change
ts-jest (source) devDependencies patch 25.5.0 -> 25.5.1

Release Notes

<details> <summary>kulshekhar/ts-jest</summary>

v25.5.1

Compare Source

Bug Fixes
  • compiler: don't resolve files from build folder for projectReferences (#​1614) (74b92d3)
  • config: don't set include value of tsconfig to empty array (#​1606) (8a29aaa)

</details>


Renovate configuration

:date: Schedule: At any time (no schedule defined).

:vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

:recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

:no_bell: Ignore: Close this PR and you won't be reminded about this update again.


  • [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

This PR has been generated by WhiteSource Renovate. View repository job log here.

+4 -4

0 comment

2 changed files

renovate[bot]

pr closed time in 16 days

push eventadelsz/pgtyped

renovate[bot]

commit sha a64b1a2d8125fc836993f31ac06801774aa50245

Update dependency pg to v8.1.0 (#61) Co-authored-by: Renovate Bot <bot@renovateapp.com>

view details

push time in 16 days

PR merged adelsz/pgtyped

Update dependency pg to v8.1.0

This PR contains the following updates:

Package Type Update Change
pg dependencies minor 8.0.3 -> 8.1.0

Release Notes

<details> <summary>brianc/node-postgres</summary>

v8.1.0

Compare Source

  • Switch to using monorepo version of pg-connection-string. This includes better support for SSL argument parsing from connection strings and ensures continuity of support.
  • Add &ssl=no-verify option to connection string and PGSSLMODE=no-verify environment variable support for the pure JS driver. This is equivalent of passing { ssl: { rejectUnauthorize: false } } to the client/pool constructor. The advantage of having support in connection strings and environment variables is it can be "externally" configured via environment variables and CLI arguments much more easily, and should remove the need to directly edit any application code for the SSL default changes in 8.0. This should make using pg@8.x significantly less difficult on environments like Heroku for example.

</details>


Renovate configuration

:date: Schedule: At any time (no schedule defined).

:vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

:recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

:no_bell: Ignore: Close this PR and you won't be reminded about this update again.


  • [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

This PR has been generated by WhiteSource Renovate. View repository job log here.

+12 -12

0 comment

2 changed files

renovate[bot]

pr closed time in 16 days

push eventadelsz/pgtyped

Silas Davis

commit sha 0d87ab0222d43887894772815d7ef4155c392c0d

Implement support for Postgres enums (#59) * Implement support for Postgres enums This allows pgtyped to generate code from queries involving database enum types. The postgres enums will be converted to a string-valued const enum in the generated code. The `getTypes` reflection query now joins on pg_enum and accumulates enum information as it collects other type information. I think it may be possible to accomodate composite types by aggregating over the object graph given by a suitable join query in a similar way. @pgtyped/query now returns `MappableTypes` which are either a string referencing a database type name or a fully-described `Type`. `Type` now includes `EnumType`. This allows type definitions to be realised at different stages in the reflection/mapping process and should allow for custom overrides in config. Signed-off-by: Silas Davis <silas@monax.io> * Add database catalog types row reduction test Also respond to various issues from review: - Tweak names - Make db config work with localhost Signed-off-by: Silas Davis <silas@monax.io>

view details

push time in 16 days

PR merged adelsz/pgtyped

Implement support for Postgres enums

This allows pgtyped to generate code from queries involving database enum types. The postgres enums will be converted to a string-valued const enum in the generated code.

The getTypes reflection query now joins on pg_enum and accumulates enum information as it collects other type information. I think it may be possible to accomodate composite types by aggregating over the object graph given by a suitable join query in a similar way.

@pgtyped/query now returns MappableTypes which are either a string referencing a database type name or a fully-described Type. Type now includes EnumType. This allows type definitions to be realised at different stages in the reflection/mapping process and should allow for custom overrides in config.

fixes #54

+945 -190

10 comments

22 changed files

silasdavis

pr closed time in 16 days

issue closedadelsz/pgtyped

Support enums

This seems like the most obvious/useful place to start with types that need to be pulled in from Postgres. Enum types and their values need to be read from the Postgres catalog and passed along as additional types from getTypes in the query package. These types can be merged in with the type mapping in #51 which can generate a corresponding typescript enum declaration as a TypeAlias and output that in the header of the generated file.

A similar approach can probably be used for composite types.

closed time in 16 days

silasdavis

pull request commentadelsz/pgtyped

Implement support for Postgres enums

Actually, having thought about it a bit more, I agree it does make sense to keep the current behavior as default. Changing case by default can be surprising and given the possible edge-cases it is best to provide it behind a config setting. Thanks for the discussion there, that was helpful. I will open a separate issue for implementing case conversion and a flag for it.

silasdavis

comment created time in 16 days

issue commentadelsz/pgtyped

Infer field names for object pick

Copying very long param lists can indeed be a bit ugly, but it is probably an OK compromise at the moment.

The main issues I see with adding this are:

  1. Passed object keys may or may not be equal to inserted column names.
  2. Potential issues/ambiguities that can arise from overloading query param syntax.
silasdavis

comment created time in 16 days

pull request commentadelsz/pgtyped

Implement support for Postgres enums

How about adding the verbatim case enum values as well as the converted pascal case ones (is they differ) How would that look?

Another degenerate case is where two different enum values become identical when pascalcased. It is a very rare case imo, it has to be an enum that looks like ENUM ('sad', 'Sad', 'happy', 'Happy)`. The general goal is to provide great defaults for most users and have an escape hatch for those who have rare edge-cases.

Can you give an example? Yes, node-postgres, knex and most other DB libraries send/return field names as is from the DB. On the other hand, most JS linter defaults enforce camelcase. This requires the user to write/use case adapters which are not typesafe.

silasdavis

comment created time in 16 days

pull request commentadelsz/pgtyped

Implement support for Postgres enums

Re: Enums

I think it is useful to have PgTyped transform postgres types to match TS style guidelines by default, potentially even converting snake-case field names into camel-case. Of course it should also be possible to opt-out of such behavior via the config. This largely grows out of my frustration with existing JS DB tools that require you to camelcase identifiers manually before and after each DB interaction.

The good thing about PgTyped is that this conversion can now be deterministic because the DB<->JS interface is typed.

For this PR, I think we can merge it as is, but I do want to enable code style transforms by default before next release (with an opt-out switch ofc). Stabilizing this part of the PgTyped API for the end users is important, given its potential to cause generated code breaking changes later on.

silasdavis

comment created time in 17 days

Pull request review commentadelsz/pgtyped

Implement support for Postgres enums

       "emitTemplate": "{{dir}}/{{name}}.types.ts"     }   ],-  "srcDir": "./src/",-  "db": {

Wrapping package/example with integration testing is a good idea, we should do that. Eventually, we will want to decouple the example from the integration tests, but for now it should work just fine.

silasdavis

comment created time in 17 days

Pull request review commentadelsz/pgtyped

Implement support for Postgres enums

 class FileProcessor {    private processQueue = () => {     if (this.activePromise) {-      this.activePromise.then(this.onFileProcessed);-      // TODO: handle promise rejection+      this.activePromise+        .then(this.onFileProcessed)+        .catch((err) => console.log(`Error processing file: ${err.stack}`));

Hm, that is good to know

silasdavis

comment created time in 17 days

Pull request review commentadelsz/pgtyped

Implement support for Postgres enums

 export async function getTypes(   const paramTypeOIDs = params.map((p) => p.oid);   const returnTypesOIDs = fields.map((f) => f.typeOID);   const usedTypesOIDs = paramTypeOIDs.concat(returnTypesOIDs);-   const typeRows = await runQuery(-    `select oid, typname from pg_type where oid in (${usedTypesOIDs.join(-      ',',-    )})`,+    `+SELECT pt.oid, pt.typname, pt.typtype, pe.enumlabel+FROM pg_type pt+LEFT JOIN pg_enum pe ON pt.oid = pe.enumtypid+WHERE pt.oid IN (${usedTypesOIDs.join(',')})`,

Yes, self-hosting isn't ready yet :) Back when I implemented the wire protocol, I couldn't find a good TS native package that provided packet level primitives for interacting with PostgreSQL. These low level messages are needed to query the DB for type data. Another reason was to potentially evolve PgTyped into a self-contained Postgres client. I think there is a good possibility to improve the reliability and performance of existing client, but this is a side goal and not a priority at the moment.

silasdavis

comment created time in 17 days

pull request commentadelsz/pgtyped

Implement support for Postgres enums

@silasdavis thanks for all the updates, I will be looking through them a bit later today. Also, can I kindly ask you to put new code changes into new commits to make tracking change history and reviewing a bit easier for me? Github UI doesn't play nice with branch force-pushes, requiring me to do manual git diffs between force-pushed commit hashes.

silasdavis

comment created time in 17 days

Pull request review commentadelsz/pgtyped

Implement support for Postgres enums

 export async function getTypeData(   return { params, fields }; } +function mergeTypeRow<T extends Record<number, MappableType>>(

Looks like this function is meant to be used in a reduce context. What do you think about moving the reduce call into this function and renaming it to mergeTypeRows? Adding some basic tests for the resulting function would also be nice to have, especially given that typeRows are typed as any atm.

silasdavis

comment created time in 18 days

Pull request review commentadelsz/pgtyped

Implement support for Postgres enums

+export type Type = NamedType | ImportedType | AliasedType | EnumType;+// May be a database source type name (string) or a typescript destination type (Type)+export type MappableType = string | Type;++export interface NamedType {+  name: string;+  definition?: string;+  enumValues?: string[];+}++export interface ImportedType extends NamedType {+  from: string;+}++export interface AliasedType extends NamedType {+  definition: string;+}++export interface EnumType extends NamedType {+  enumValues: string[];+}++export function isImport(typ: Type): typ is ImportedType {+  return 'from' in typ;+}++export function isAlias(typ: Type): typ is AliasedType {+  return 'definition' in typ;+}++export function isEnum(typ: MappableType): typ is EnumType {+  return typeof typ !== 'string' && 'enumValues' in typ;+}++export const enum DatabaseTypeType {
export const enum DatabaseTypeKind {
silasdavis

comment created time in 18 days

Pull request review commentadelsz/pgtyped

Implement support for Postgres enums

 services:    app:     build: .+    environment:

Lets keep this config in the config file for now, not everyone might be using docker to run the app

silasdavis

comment created time in 18 days

Pull request review commentadelsz/pgtyped

Implement support for Postgres enums

 export async function getTypes(   const paramTypeOIDs = params.map((p) => p.oid);   const returnTypesOIDs = fields.map((f) => f.typeOID);   const usedTypesOIDs = paramTypeOIDs.concat(returnTypesOIDs);-   const typeRows = await runQuery(-    `select oid, typname from pg_type where oid in (${usedTypesOIDs.join(-      ',',-    )})`,+    `+SELECT pt.oid, pt.typname, pt.typtype, pe.enumlabel+FROM pg_type pt+LEFT JOIN pg_enum pe ON pt.oid = pe.enumtypid+WHERE pt.oid IN (${usedTypesOIDs.join(',')})`,

Soon PgTyped will be self-hosting and this query will be typed by PgTyped, hehe

silasdavis

comment created time in 18 days

Pull request review commentadelsz/pgtyped

Implement support for Postgres enums

 export async function getTypes(   const paramTypeOIDs = params.map((p) => p.oid);   const returnTypesOIDs = fields.map((f) => f.typeOID);   const usedTypesOIDs = paramTypeOIDs.concat(returnTypesOIDs);-   const typeRows = await runQuery(-    `select oid, typname from pg_type where oid in (${usedTypesOIDs.join(-      ',',-    )})`,+    `+SELECT pt.oid, pt.typname, pt.typtype, pe.enumlabel+FROM pg_type pt+LEFT JOIN pg_enum pe ON pt.oid = pe.enumtypid+WHERE pt.oid IN (${usedTypesOIDs.join(',')})`,     queue,   );-  const typeMap: { [oid: number]: string } = typeRows.reduce(-    (acc, [oid, typeName]) => ({ ...acc, [oid]: typeName }),+  const typeMap: Record<string, MappableType> = typeRows.reduce(+    (acc, [oid, typName, typType, enumLabel]) =>
    (acc, [oid, typeName, typeKind, enumLabel]) =>
silasdavis

comment created time in 18 days

Pull request review commentadelsz/pgtyped

Implement support for Postgres enums

       "emitTemplate": "{{dir}}/{{name}}.types.ts"     }   ],-  "srcDir": "./src/",-  "db": {

I suggest to keep the db config in config.json, not everyone will want to use docker

silasdavis

comment created time in 18 days

Pull request review commentadelsz/pgtyped

Implement support for Postgres enums

   "transforms": [     {       "mode": "sql",-      "include": "**/*.sql",+      "include": "**/notifications.sql",

This will exclude all other SQL queries?

silasdavis

comment created time in 18 days

Pull request review commentadelsz/pgtyped

Implement support for Postgres enums

 class FileProcessor {    private processQueue = () => {     if (this.activePromise) {-      this.activePromise.then(this.onFileProcessed);-      // TODO: handle promise rejection+      this.activePromise+        .then(this.onFileProcessed)+        .catch((err) => console.log(`Error processing file: ${err.stack}`));

Should this also include error name and message?

silasdavis

comment created time in 18 days

issue openedianstormtaylor/slate

Broken Hovering Toolbar Example

Thanks for the amazing library! I have noticed a bug on the hovering-toolbar example on slatejs.com/examples. Editor crashes when pressing CMD-B with an active selection. We are running into the same bug on a project based of the hovering-toolbar configuration.

What's the current behavior?

  1. Visit https://www.slatejs.org/examples/hovering-toolbar
  2. Select any word
  3. Press CMD-B
  4. Page crashes, printing:
Cannot resolve a DOM point from Slate point: {"path":[0,0],"offset":35}

Slate: 0.XX.X (version live on the demo website) Browser: Chrome 81 OS: Mac

What's the expected behavior?

Page doesn't crash.

created time in 18 days

push eventadelsz/pgtyped

renovate[bot]

commit sha d38230ba24e315fef22c8418df1cf1473cb8c1e3

Update dependency ts-jest to v25.5.0 (#58) Co-authored-by: Renovate Bot <bot@renovateapp.com>

view details

push time in 19 days

PR merged adelsz/pgtyped

Update dependency ts-jest to v25.5.0

This PR contains the following updates:

Package Type Update Change
ts-jest (source) devDependencies minor 25.4.0 -> 25.5.0

Release Notes

<details> <summary>kulshekhar/ts-jest</summary>

v25.5.0

Compare Source

Bug Fixes
  • compiler: make projectReferences work with isolatedModules: false (#​1541) (3e8efbe)
  • compiler: allow using files provided by tsconfig (#​1562) (a9f02bd)
  • config: verify testMatchPatterns contain RegExp instance or string type values (#​1569) (7f85bab)
Features
  • config: add tsconfig alias to tsConfig option (#​1565) (c10eb6d)
  • config: define 'ts-jest' on ConfigGlobals interface of @jest/types (#​1592) (4526392)
Performance Improvements
  • compiler: don’t write compile output to file system but rely on jest cache (#​1561) (d11a4ea)
  • compiler: improve performance for isolatedModules: false (#​1558) (85c09e3)
BREAKING CHANGES
  • Any custom typing files or files which are needed to be compiled and intended to use with jest need to be defined in files option of tsconfig.

For example:

// tsconfig.json
{
   // ...other configs
   "files": [
       "my-custom-typings.d.ts".
       "my-global-module.ts"
   ]
}
  • compiler: incremental and compilerHost options are no longer available. Please remove it from your ts-jest config.

</details>


Renovate configuration

:date: Schedule: At any time (no schedule defined).

:vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

:recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

:no_bell: Ignore: Close this PR and you won't be reminded about this update again.


  • [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

This PR has been generated by WhiteSource Renovate. View repository job log here.

+5 -12

0 comment

2 changed files

renovate[bot]

pr closed time in 19 days

Pull request review commentadelsz/pgtyped

Implement postgres types for JSON, timestamps, and bytes

 services:     build: .     volumes:       - ../../:/app+    restart: always

Agree, on-failure should be a better fit here. I should probably add a reconnect feature to the CLI at some point.

silasdavis

comment created time in 20 days

push eventadelsz/pgtyped

renovate[bot]

commit sha e741dd12bed176cc6d21d9f027ebae05c93c19b9

Update dependency @types/node to v13.13.5 (#57) Co-authored-by: Renovate Bot <bot@renovateapp.com>

view details

push time in 20 days

PR merged adelsz/pgtyped

Update dependency @types/node to v13.13.5

This PR contains the following updates:

Package Type Update Change
@types/node devDependencies patch 13.13.4 -> 13.13.5

Renovate configuration

:date: Schedule: At any time (no schedule defined).

:vertical_traffic_light: Automerge: Disabled by config. Please merge this manually once you are satisfied.

:recycle: Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

:no_bell: Ignore: Close this PR and you won't be reminded about this update again.


  • [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

This PR has been generated by WhiteSource Renovate. View repository job log here.

+6 -39

0 comment

4 changed files

renovate[bot]

pr closed time in 20 days

more