0.0.3 • Published 8 months ago

@reyalp/preshape v0.0.3

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
8 months ago

Preshape

Typescript & PostgreSQL code generator


It generates typedefs/enums/serdes/pg-migrations from DSL, see sample/*.txt, sample/*.yml.

run them with:

pnpm run test:do:draft -- -f <input-file>

output files are in test/src/*.ts, test/data/*/*.sql.

Types

DSL notationmeansmap to typescriptmap to pgsql
boolbooleanbooleanint2
i32signed 32-bits integernumberint4
u8unsigned 8-bits integernumberuint2
i4unsigned 4-bits integernumberint2
i64unsigned 64-bits integerbigintint8
i53unsigned 53-bits integersafe integernumberint8
strstr(at most 232-1 octets)numberint2
str/16str(at most 16 octets)stringtext
str/i8str(at most 28-1 octets)stringtext
str/u8str(at most 28-1 octets)i/u are the samestringtext
byteabolb(at most <= 232-1 bytes)Bufferbytea
?i32i32 or nothingnumber &vert; undefinedint4NULLABLE
[i32]i32 array(at most 232-1 elements)number[]jsonbTODO: maybe array?
[i32; 4]i32 array(at most 4 elements)number[]jsonb
[i32; i8]i32 array(at most 28-1 elements)number[]jsonb
[?i32]optional i32 array(number &vert; undefined)[]jsonb
[str/4; 4]string array(at most 4 elements)(each contains at most 4 octets)string[]jsonb
(i4; i8; str)tuple[number, number, string]jsonb
(label: i4; i8; str)tuple, labelled[labal: number, number, string]jsonb
[(i8, i8)]array of tuple[number, number][]jsonb
[(i8, [i8])]array of tuple.. mixed[number, number[]][]jsonb
{  id i32  name str}a struct/object{ id: number; name: string }jsonb
{  ...  t case {    'u1' { arg1 str }    'u2' { arg2 i32 }  }}tagged union{ ... } & ({ t: 'u1'; arg1: string } | { t: 'u2'; arg2: number})jsonb

TODO Cont'd

0.0.3

8 months ago

0.0.2

9 months ago

0.0.1

9 months ago