Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add type def to docs for column endpoints #596

Merged
merged 2 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading