Skip to content

Commit

Permalink
feat: add type def to docs for column endpoints (#596)
Browse files Browse the repository at this point in the history
* feat: add type def to docs for column endpoints

* update types

---------

Co-authored-by: Bobbie Soedirgo <[email protected]>
  • Loading branch information
owaisahmad-dev and soedirgo authored Aug 10, 2023
1 parent 8514ff0 commit 7e7d114
Show file tree
Hide file tree
Showing 2 changed files with 250 additions and 132 deletions.
39 changes: 39 additions & 0 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,45 @@ export const postgresColumnSchema = Type.Object({
})
export type PostgresColumn = Static<typeof postgresColumnSchema>

export const postgresColumnCreateSchema = Type.Object({
table_id: Type.Integer(),
name: Type.String(),
type: Type.String(),
default_value: Type.Optional(Type.Unknown()),
default_value_format: Type.Optional(
Type.Union([Type.Literal('expression'), Type.Literal('literal')])
),
is_identity: Type.Optional(Type.Boolean()),
identity_generation: Type.Optional(
Type.Union([Type.Literal('BY DEFAULT'), Type.Literal('ALWAYS')])
),
is_nullable: Type.Optional(Type.Boolean()),
is_primary_key: Type.Optional(Type.Boolean()),
is_unique: Type.Optional(Type.Boolean()),
comment: Type.Optional(Type.String()),
check: Type.Optional(Type.String()),
})
export type PostgresColumnCreate = Static<typeof postgresColumnCreateSchema>

export const postgresColumnUpdateSchema = Type.Object({
name: Type.Optional(Type.String()),
type: Type.Optional(Type.String()),
drop_default: Type.Optional(Type.Boolean()),
default_value: Type.Optional(Type.Unknown()),
default_value_format: Type.Optional(
Type.Union([Type.Literal('expression'), Type.Literal('literal')])
),
is_identity: Type.Optional(Type.Boolean()),
identity_generation: Type.Optional(
Type.Union([Type.Literal('BY DEFAULT'), Type.Literal('ALWAYS')])
),
is_nullable: Type.Optional(Type.Boolean()),
is_unique: Type.Optional(Type.Boolean()),
comment: Type.Optional(Type.String()),
check: Type.Optional(Type.Union([Type.String(), Type.Null()])),
})
export type PostgresColumnUpdate = Static<typeof postgresColumnUpdateSchema>

// TODO Rethink config.sql
export const postgresConfigSchema = Type.Object({
name: Type.Unknown(),
Expand Down
Loading

0 comments on commit 7e7d114

Please sign in to comment.